mbuf.h (155051) | mbuf.h (155780) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 | 1/*- 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 |
30 * $FreeBSD: head/sys/sys/mbuf.h 155051 2006-01-30 13:45:15Z glebius $ | 30 * $FreeBSD: head/sys/sys/mbuf.h 155780 2006-02-17 14:14:15Z andre $ |
31 */ 32 33#ifndef _SYS_MBUF_H_ 34#define _SYS_MBUF_H_ 35 36/* XXX: These includes suck. Sorry! */ 37#include <sys/queue.h> 38#ifdef _KERNEL --- 141 unchanged lines hidden (view full) --- 180#define M_LASTFRAG 0x2000 /* packet is last fragment */ 181#define M_VLANTAG 0x10000 /* packet has VLAN tag attached */ 182 183/* 184 * External buffer types: identify ext_buf type. 185 */ 186#define EXT_CLUSTER 1 /* mbuf cluster */ 187#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ | 31 */ 32 33#ifndef _SYS_MBUF_H_ 34#define _SYS_MBUF_H_ 35 36/* XXX: These includes suck. Sorry! */ 37#include <sys/queue.h> 38#ifdef _KERNEL --- 141 unchanged lines hidden (view full) --- 180#define M_LASTFRAG 0x2000 /* packet is last fragment */ 181#define M_VLANTAG 0x10000 /* packet has VLAN tag attached */ 182 183/* 184 * External buffer types: identify ext_buf type. 185 */ 186#define EXT_CLUSTER 1 /* mbuf cluster */ 187#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ |
188#define EXT_JUMBO4 3 /* jumbo cluster 4096 bytes */ | 188#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ |
189#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ 190#define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ 191#define EXT_PACKET 6 /* mbuf+cluster from packet zone */ 192#define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */ 193#define EXT_MOD_TYPE 200 /* custom module's ext_buf type */ 194#define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */ 195#define EXT_EXTREF 400 /* has externally maintained ref_cnt ptr */ 196 --- 104 unchanged lines hidden (view full) --- 301/* 302 * String names of mbuf-related UMA(9) and malloc(9) types. Exposed to 303 * !_KERNEL so that monitoring tools can look up the zones with 304 * libmemstat(3). 305 */ 306#define MBUF_MEM_NAME "mbuf" 307#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster" 308#define MBUF_PACKET_MEM_NAME "mbuf_packet" | 189#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ 190#define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ 191#define EXT_PACKET 6 /* mbuf+cluster from packet zone */ 192#define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */ 193#define EXT_MOD_TYPE 200 /* custom module's ext_buf type */ 194#define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */ 195#define EXT_EXTREF 400 /* has externally maintained ref_cnt ptr */ 196 --- 104 unchanged lines hidden (view full) --- 301/* 302 * String names of mbuf-related UMA(9) and malloc(9) types. Exposed to 303 * !_KERNEL so that monitoring tools can look up the zones with 304 * libmemstat(3). 305 */ 306#define MBUF_MEM_NAME "mbuf" 307#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster" 308#define MBUF_PACKET_MEM_NAME "mbuf_packet" |
309#define MBUF_JUMBO4_MEM_NAME "mbuf_jumbo_4k" | 309#define MBUF_JUMBOP_MEM_NAME "mbuf_jumbo_pagesize" |
310#define MBUF_JUMBO9_MEM_NAME "mbuf_jumbo_9k" 311#define MBUF_JUMBO16_MEM_NAME "mbuf_jumbo_16k" 312#define MBUF_TAG_MEM_NAME "mbuf_tag" 313#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt" 314 315#ifdef _KERNEL 316 317#ifdef WITNESS --- 10 unchanged lines hidden (view full) --- 328 * Network buffer allocation API 329 * 330 * The rest of it is defined in kern/kern_mbuf.c 331 */ 332 333extern uma_zone_t zone_mbuf; 334extern uma_zone_t zone_clust; 335extern uma_zone_t zone_pack; | 310#define MBUF_JUMBO9_MEM_NAME "mbuf_jumbo_9k" 311#define MBUF_JUMBO16_MEM_NAME "mbuf_jumbo_16k" 312#define MBUF_TAG_MEM_NAME "mbuf_tag" 313#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt" 314 315#ifdef _KERNEL 316 317#ifdef WITNESS --- 10 unchanged lines hidden (view full) --- 328 * Network buffer allocation API 329 * 330 * The rest of it is defined in kern/kern_mbuf.c 331 */ 332 333extern uma_zone_t zone_mbuf; 334extern uma_zone_t zone_clust; 335extern uma_zone_t zone_pack; |
336extern uma_zone_t zone_jumbo4; | 336extern uma_zone_t zone_jumbop; |
337extern uma_zone_t zone_jumbo9; 338extern uma_zone_t zone_jumbo16; 339extern uma_zone_t zone_ext_refcnt; 340extern uma_zone_t zone_mtag_vlan; 341 342static __inline struct mbuf *m_get(int how, short type); 343static __inline struct mbuf *m_gethdr(int how, short type); 344static __inline struct mbuf *m_getcl(int how, short type, int flags); --- 51 unchanged lines hidden (view full) --- 396 397 args.flags = flags; 398 args.type = type; 399 return (uma_zalloc_arg(zone_pack, &args, how)); 400} 401 402/* 403 * m_getjcl() returns an mbuf with a cluster of the specified size attached. | 337extern uma_zone_t zone_jumbo9; 338extern uma_zone_t zone_jumbo16; 339extern uma_zone_t zone_ext_refcnt; 340extern uma_zone_t zone_mtag_vlan; 341 342static __inline struct mbuf *m_get(int how, short type); 343static __inline struct mbuf *m_gethdr(int how, short type); 344static __inline struct mbuf *m_getcl(int how, short type, int flags); --- 51 unchanged lines hidden (view full) --- 396 397 args.flags = flags; 398 args.type = type; 399 return (uma_zalloc_arg(zone_pack, &args, how)); 400} 401 402/* 403 * m_getjcl() returns an mbuf with a cluster of the specified size attached. |
404 * For size it takes MCLBYTES, MJUM4BYTES, MJUM9BYTES, MJUM16BYTES. | 404 * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES. |
405 */ 406static __inline /* XXX: This is rather large, should be real function maybe. */ 407struct mbuf * 408m_getjcl(int how, short type, int flags, int size) 409{ 410 struct mb_args args; 411 struct mbuf *m, *n; 412 uma_zone_t zone; --- 4 unchanged lines hidden (view full) --- 417 m = uma_zalloc_arg(zone_mbuf, &args, how); 418 if (m == NULL) 419 return NULL; 420 421 switch (size) { 422 case MCLBYTES: 423 zone = zone_clust; 424 break; | 405 */ 406static __inline /* XXX: This is rather large, should be real function maybe. */ 407struct mbuf * 408m_getjcl(int how, short type, int flags, int size) 409{ 410 struct mb_args args; 411 struct mbuf *m, *n; 412 uma_zone_t zone; --- 4 unchanged lines hidden (view full) --- 417 m = uma_zalloc_arg(zone_mbuf, &args, how); 418 if (m == NULL) 419 return NULL; 420 421 switch (size) { 422 case MCLBYTES: 423 zone = zone_clust; 424 break; |
425#if MJUM4BYTES != MCLBYTES 426 case MJUM4BYTES: 427 zone = zone_jumbo4; | 425#if MJUMPAGESIZE != MCLBYTES 426 case MJUMPAGESIZE: 427 zone = zone_jumbop; |
428 break; 429#endif 430 case MJUM9BYTES: 431 zone = zone_jumbo9; 432 break; 433 case MJUM16BYTES: 434 zone = zone_jumbo16; 435 break; --- 32 unchanged lines hidden (view full) --- 468} 469 470/* 471 * m_cljget() is different from m_clget() as it can allocate clusters 472 * without attaching them to an mbuf. In that case the return value 473 * is the pointer to the cluster of the requested size. If an mbuf was 474 * specified, it gets the cluster attached to it and the return value 475 * can be safely ignored. | 428 break; 429#endif 430 case MJUM9BYTES: 431 zone = zone_jumbo9; 432 break; 433 case MJUM16BYTES: 434 zone = zone_jumbo16; 435 break; --- 32 unchanged lines hidden (view full) --- 468} 469 470/* 471 * m_cljget() is different from m_clget() as it can allocate clusters 472 * without attaching them to an mbuf. In that case the return value 473 * is the pointer to the cluster of the requested size. If an mbuf was 474 * specified, it gets the cluster attached to it and the return value 475 * can be safely ignored. |
476 * For size it takes MCLBYTES, MJUM4BYTES, MJUM9BYTES, MJUM16BYTES. | 476 * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES. |
477 */ 478static __inline 479void * 480m_cljget(struct mbuf *m, int how, int size) 481{ 482 uma_zone_t zone; 483 484 if (m && m->m_flags & M_EXT) 485 printf("%s: %p mbuf already has cluster\n", __func__, m); 486 if (m != NULL) 487 m->m_ext.ext_buf = NULL; 488 489 switch (size) { 490 case MCLBYTES: 491 zone = zone_clust; 492 break; | 477 */ 478static __inline 479void * 480m_cljget(struct mbuf *m, int how, int size) 481{ 482 uma_zone_t zone; 483 484 if (m && m->m_flags & M_EXT) 485 printf("%s: %p mbuf already has cluster\n", __func__, m); 486 if (m != NULL) 487 m->m_ext.ext_buf = NULL; 488 489 switch (size) { 490 case MCLBYTES: 491 zone = zone_clust; 492 break; |
493#if MJUM4BYTES != MCLBYTES 494 case MJUM4BYTES: 495 zone = zone_jumbo4; | 493#if MJUMPAGESIZE != MCLBYTES 494 case MJUMPAGESIZE: 495 zone = zone_jumbop; |
496 break; 497#endif 498 case MJUM9BYTES: 499 zone = zone_jumbo9; 500 break; 501 case MJUM16BYTES: 502 zone = zone_jumbo16; 503 break; --- 362 unchanged lines hidden --- | 496 break; 497#endif 498 case MJUM9BYTES: 499 zone = zone_jumbo9; 500 break; 501 case MJUM16BYTES: 502 zone = zone_jumbo16; 503 break; --- 362 unchanged lines hidden --- |