From 3b9c87155a809e39aa28d25d621e41897ebd5298 Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 4 Dec 2005 19:15:21 +0000 Subject: [PATCH] Merge the 3 copies of m_getcl() so that fast ipsec compiles again together with net80211. XXX: We don't really have an m_getcl(), we just emulate it. --- sys/dev/ieee1394/fw_port.h | 14 +------------- sys/kern/uipc_mbuf2.c | 33 +++++++++++++++++++++++++++++++-- sys/net80211/ieee80211_netbsd.c | 26 ++------------------------ sys/net80211/ieee80211_netbsd.h | 3 +-- sys/netipsec/ipsec_osdep.h | 31 ++++--------------------------- 5 files changed, 39 insertions(+), 68 deletions(-) diff --git a/sys/dev/ieee1394/fw_port.h b/sys/dev/ieee1394/fw_port.h index 93b17337a6fa..9223b27848fa 100644 --- a/sys/dev/ieee1394/fw_port.h +++ b/sys/dev/ieee1394/fw_port.h @@ -1,4 +1,4 @@ -/* $NetBSD: fw_port.h,v 1.4 2005/08/26 11:20:33 drochner Exp $ */ +/* $NetBSD: fw_port.h,v 1.5 2005/12/04 19:15:21 christos Exp $ */ /* * Copyright (c) 2004 KIYOHARA Takashi * All rights reserved. @@ -1111,18 +1111,6 @@ struct fw_hwaddr { #define m_tag_locate(m, cookie, type, t) \ m_tag_find((m), (type), (t)) -static __inline struct mbuf * -m_getcl(int how, short type, int flags) -{ - struct mbuf *m; - - m = m_gethdr(how, type); - if (m != NULL) - m_clget(m, how); - - return (m); -} - /* * bus_dma macros for NetBSD */ diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c index f70b4edfa161..2e7987c90ad4 100644 --- a/sys/kern/uipc_mbuf2.c +++ b/sys/kern/uipc_mbuf2.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_mbuf2.c,v 1.19 2005/05/06 09:40:40 martin Exp $ */ +/* $NetBSD: uipc_mbuf2.c,v 1.20 2005/12/04 19:15:21 christos Exp $ */ /* $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.19 2005/05/06 09:40:40 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf2.c,v 1.20 2005/12/04 19:15:21 christos Exp $"); #include #include @@ -223,6 +223,35 @@ ok: return n; } +/* + * FreeBSD 4.6 introduced m_getcl(), which performs `fast' allocation + * mbuf clusters from a cache of recently-freed clusters. (If the cache + * is empty, new clusters are allocated en-masse). + * On NetBSD, for now, implement the `cache' as a function + * using normal NetBSD mbuf/cluster allocation macros. Replace this + * with fast-cache code, if and when NetBSD implements one. + */ +struct mbuf * +m_getcl(int how, int type, int flags) +{ + struct mbuf *mp; + + if ((flags & M_PKTHDR) != 0) + MGETHDR(mp, how, type); + else + MGET(mp, how, type); + + if (mp == NULL) + return NULL; + + MCLGET(mp, how); + if ((mp->m_flags & M_EXT) != 0) + return mp; + + m_free(mp); + return NULL; +} + /* Get a packet tag structure along with specified data following. */ struct m_tag * m_tag_get(int type, int len, int wait) diff --git a/sys/net80211/ieee80211_netbsd.c b/sys/net80211/ieee80211_netbsd.c index ff030ef5cc00..641886351cf2 100644 --- a/sys/net80211/ieee80211_netbsd.c +++ b/sys/net80211/ieee80211_netbsd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_netbsd.c,v 1.10 2005/11/25 17:33:56 thorpej Exp $ */ +/* $NetBSD: ieee80211_netbsd.c,v 1.11 2005/12/04 19:15:21 christos Exp $ */ /*- * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting * All rights reserved. @@ -30,7 +30,7 @@ #ifdef __FreeBSD__ __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.8 2005/08/08 18:46:35 sam Exp $"); #else -__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.10 2005/11/25 17:33:56 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.11 2005/12/04 19:15:21 christos Exp $"); #endif /* @@ -507,28 +507,6 @@ if_printf(struct ifnet *ifp, const char *fmt, ...) return; } -struct mbuf * -m_getcl(int how, int type, int flags) -{ - struct mbuf *m; - - if ((flags & M_PKTHDR) != 0) - MGETHDR(m, how, type); - else - MGET(m, how, type); - - if (m == NULL) - return NULL; - - MCLGET(m, flags); - - if ((m->m_flags & M_EXT) == 0) { - m_free(m); - return NULL; - } - return m; -} - /* * Append the specified data to the indicated mbuf chain, * Extend the mbuf chain if the new data does not fit in diff --git a/sys/net80211/ieee80211_netbsd.h b/sys/net80211/ieee80211_netbsd.h index 77b68484cfd7..857585d3eb06 100644 --- a/sys/net80211/ieee80211_netbsd.h +++ b/sys/net80211/ieee80211_netbsd.h @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_netbsd.h,v 1.7 2005/11/18 16:40:09 skrll Exp $ */ +/* $NetBSD: ieee80211_netbsd.h,v 1.8 2005/12/04 19:15:21 christos Exp $ */ /*- * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting * All rights reserved. @@ -259,7 +259,6 @@ struct ieee80211_michael_event { var = nextvar) void if_printf(struct ifnet *, const char *, ...); -struct mbuf *m_getcl(int, int, int); int m_append(struct mbuf *, int, const caddr_t); void get_random_bytes(void *, size_t); diff --git a/sys/netipsec/ipsec_osdep.h b/sys/netipsec/ipsec_osdep.h index 55aae0b63f5f..1f4314ab77c4 100644 --- a/sys/netipsec/ipsec_osdep.h +++ b/sys/netipsec/ipsec_osdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: ipsec_osdep.h,v 1.13 2005/08/18 00:30:59 yamt Exp $ */ +/* $NetBSD: ipsec_osdep.h,v 1.14 2005/12/04 19:15:21 christos Exp $ */ /* $FreeBSD: /repoman/r/ncvs/src/sys/netipsec/ipsec_osdep.h,v 1.1 2003/09/29 22:47:45 sam Exp $ */ /* @@ -116,33 +116,10 @@ read_random(void *bufp, u_int len) /* * 5. Fast mbuf-cluster allocation. - * FreeBSD 4.6 introduce m_getcl(), which performs `fast' allocation - * mbuf clusters from a cache of recently-freed clusters. (If the cache - * is empty, new clusters are allocated en-masse). - * On NetBSD, for now, implement the `cache' as an inline function - *using normal NetBSD mbuf/cluster allocation macros. Replace this - * with fast-cache code, if and when NetBSD implements one. */ -#ifdef __NetBSD__ -static __inline struct mbuf * -m_getcl(int how, short type, int flags) -{ - struct mbuf *mp; - if (flags & M_PKTHDR) - MGETHDR(mp, how, type); - else - MGET(mp, how, type); - if (mp == NULL) - return NULL; - - MCLGET(mp, how); - if ((mp->m_flags & M_EXT) == 0) { - m_free(mp); - mp = NULL; - } - return mp; -} -#endif /* __NetBSD__ */ +/* + * nothing. + */ /* * 6. Network output macros