Index: kern/uipc_mbuf.c =================================================================== RCS file: /usr/home/kmacy/devel/cxgb/ncvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.171 diff -d -u -r1.171 uipc_mbuf.c --- kern/uipc_mbuf.c 22 Jan 2007 14:50:28 -0000 1.171 +++ kern/uipc_mbuf.c 11 Apr 2007 03:56:14 -0000 @@ -218,11 +218,13 @@ if (*(m->m_ext.ref_cnt) == 1 || atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) { switch (m->m_ext.ext_type) { +#ifndef PACKET_ZONE_DISABLED case EXT_PACKET: /* The packet zone is special. */ if (*(m->m_ext.ref_cnt) == 0) *(m->m_ext.ref_cnt) = 1; uma_zfree(zone_pack, m); return; /* Job done. */ +#endif case EXT_CLUSTER: uma_zfree(zone_clust, m->m_ext.ext_buf); break; @@ -330,8 +332,11 @@ caddr_t a, b; int pktlen = 0; -#define M_SANITY_ACTION(s) return (0) -/* #define M_SANITY_ACTION(s) panic("mbuf %p: " s, m) */ +#ifdef INVARIANTS +#define M_SANITY_ACTION(s) panic("mbuf %p: " s, m) +#else +#define M_SANITY_ACTION(s) printf("mbuf %p: " s, m) +#endif for (m = m0; m != NULL; m = m->m_next) { /* @@ -365,14 +370,6 @@ M_SANITY_ACTION("m->m_nextpkt on in-chain mbuf"); } - /* correct type correlations. */ - if (m->m_type == MT_HEADER && !(m->m_flags & M_PKTHDR)) { - if (sanitize) - m->m_type = MT_DATA; - else - M_SANITY_ACTION("MT_HEADER set but not M_PKTHDR"); - } - /* packet length (not mbuf length!) calculation */ if (m0->m_flags & M_PKTHDR) pktlen += m->m_len; Index: kern/kern_mbuf.c =================================================================== RCS file: /usr/home/kmacy/devel/cxgb/ncvs/src/sys/kern/kern_mbuf.c,v retrieving revision 1.29 diff -d -u -r1.29 kern_mbuf.c --- kern/kern_mbuf.c 4 Apr 2007 21:27:01 -0000 1.29 +++ kern/kern_mbuf.c 10 Apr 2007 06:30:12 -0000 @@ -146,7 +146,9 @@ */ uma_zone_t zone_mbuf; uma_zone_t zone_clust; +#ifndef PACKET_ZONE_DISABLED uma_zone_t zone_pack; +#endif uma_zone_t zone_jumbop; uma_zone_t zone_jumbo9; uma_zone_t zone_jumbo16; @@ -157,13 +159,14 @@ */ static int mb_ctor_mbuf(void *, int, void *, int); static int mb_ctor_clust(void *, int, void *, int); -static int mb_ctor_pack(void *, int, void *, int); static void mb_dtor_mbuf(void *, int, void *); static void mb_dtor_clust(void *, int, void *); +#ifndef PACKET_ZONE_DISABLED +static int mb_ctor_pack(void *, int, void *, int); static void mb_dtor_pack(void *, int, void *); static int mb_zinit_pack(void *, int, int); static void mb_zfini_pack(void *, int); - +#endif static void mb_reclaim(void *); static void mbuf_init(void *); @@ -200,10 +203,10 @@ UMA_ALIGN_PTR, UMA_ZONE_REFCNT); if (nmbclusters > 0) uma_zone_set_max(zone_clust, nmbclusters); - +#ifndef PACKET_ZONE_DISABLED zone_pack = uma_zsecond_create(MBUF_PACKET_MEM_NAME, mb_ctor_pack, mb_dtor_pack, mb_zinit_pack, mb_zfini_pack, zone_mbuf); - +#endif /* Make jumbo frame zone too. Page size, 9k and 16k. */ zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, mb_ctor_clust, mb_dtor_clust, @@ -348,7 +351,7 @@ trash_dtor(mem, size, arg); #endif } - +#ifndef PACKET_ZONE_DISABLED /* * The Mbuf Packet zone destructor. */ @@ -381,7 +384,7 @@ if (uma_zone_exhausted_nolock(zone_clust)) zone_drain(zone_pack); } - +#endif /* !PACKET_ZONE_DISABLED */ /* * The Cluster and Jumbo[PAGESIZE|9|16] zone constructor. * @@ -459,7 +462,7 @@ trash_dtor(mem, size, arg); #endif } - +#ifndef PACKET_ZONE_DISABLED /* * The Packet secondary zone's init routine, executed on the * object's transition from mbuf keg slab to zone cache. @@ -548,7 +551,7 @@ return (0); } - +#endif /* * This is the protocol drain routine. * Index: sys/mbuf.h =================================================================== RCS file: /usr/home/kmacy/devel/cxgb/ncvs/src/sys/sys/mbuf.h,v retrieving revision 1.207 diff -d -u -r1.207 mbuf.h --- sys/mbuf.h 11 Apr 2007 23:13:12 -0000 1.207 +++ sys/mbuf.h 14 Apr 2007 05:07:38 -0000 @@ -84,9 +84,18 @@ struct mbuf *mh_next; /* next buffer in chain */ struct mbuf *mh_nextpkt; /* next chain in queue/record */ caddr_t mh_data; /* location of data */ - int mh_len; /* amount of data in this mbuf */ int mh_flags; /* flags; see below */ - short mh_type; /* type of data in this mbuf */ + uint16_t mh_type; /* type of data in this mbuf */ +#if defined(SMALL_M_HDR) + uint16_t mh_len; /* amount of data in this mbuf */ +#else + uint32_t mh_len; /* amount of data in this mbuf */ +#if defined(__LP64__) + uint8_t mh_pad[6]; +#else + uint8_t mh_pad[2]; +#endif +#endif /* !SMALL_M_HDR */ }; /* @@ -105,16 +114,16 @@ */ struct pkthdr { struct ifnet *rcvif; /* rcv interface */ - int len; /* total packet length */ /* variables for ip and tcp reassembly */ void *header; /* pointer to packet header */ + int len; /* total packet length */ /* variables for hardware checksum */ int csum_flags; /* flags regarding checksum */ int csum_data; /* data field used by csum routines */ u_int16_t tso_segsz; /* TSO segment size */ u_int16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */ SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ -}; +}; /* 40 bytes on 64-bit */ /* * Description of external storage mapped into mbuf; valid only if M_EXT is @@ -194,7 +203,9 @@ #define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ #define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ #define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ +#ifndef PACKET_ZONE_DISABLED #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ +#endif #define EXT_MBUF 7 /* external mbuf reference (M_IOVEC) */ #define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */ #define EXT_MOD_TYPE 200 /* custom module's ext_buf type */ @@ -325,10 +336,11 @@ * * The rest of it is defined in kern/kern_mbuf.c */ - +#ifndef PACKET_ZONE_DISABLED +extern uma_zone_t zone_pack; +#endif extern uma_zone_t zone_mbuf; extern uma_zone_t zone_clust; -extern uma_zone_t zone_pack; extern uma_zone_t zone_jumbop; extern uma_zone_t zone_jumbo9; extern uma_zone_t zone_jumbo16; @@ -444,16 +456,6 @@ return ((struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how))); } -static __inline struct mbuf * -m_getcl(int how, short type, int flags) -{ - struct mb_args args; - - args.flags = flags; - args.type = type; - return ((struct mbuf *)(uma_zalloc_arg(zone_pack, &args, how))); -} - /* * m_getjcl() returns an mbuf with a cluster of the specified size attached. * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES. @@ -484,6 +486,19 @@ } static __inline struct mbuf * +m_getcl(int how, short type, int flags) +{ +#ifndef PACKET_ZONE_DISABLED + struct mb_args args; + args.flags = flags; + args.type = type; + return ((struct mbuf *)(uma_zalloc_arg(zone_pack, &args, how))); +#else + return m_getjcl(how, type, flags, MCLBYTES); +#endif +} + +static __inline struct mbuf * m_free(struct mbuf *m) { struct mbuf *n = m->m_next; @@ -503,6 +518,7 @@ printf("%s: %p mbuf already has cluster\n", __func__, m); m->m_ext.ext_buf = (char *)NULL; uma_zalloc_arg(zone_clust, m, how); +#ifndef PACKET_ZONE_DISABLED /* * On a cluster allocation failure, drain the packet zone and retry, * we might be able to loosen a few clusters up on the drain. @@ -511,6 +527,7 @@ zone_drain(zone_pack); uma_zalloc_arg(zone_clust, m, how); } +#endif } /*