Deleted Added
full compact
mbuf.h (152583) mbuf.h (153232)
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 152583 2005-11-18 16:23:26Z andre $
30 * $FreeBSD: head/sys/sys/mbuf.h 153232 2005-12-08 13:13:06Z 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_JUMBO9 3 /* jumbo cluster 9216 bytes */
189#define EXT_JUMBO16 4 /* jumbo cluster 16184 bytes */
190#define EXT_PACKET 5 /* mbuf+cluster from packet zone */
188#define EXT_JUMBO4 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 */
191#define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */
192#define EXT_MOD_TYPE 200 /* custom module's ext_buf type */
193#define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */
194#define EXT_EXTREF 400 /* has externally maintained ref_cnt ptr */
195
196/*
197 * Flags copied when copying m_pkthdr.
198 */

--- 101 unchanged lines hidden (view full) ---

300/*
301 * String names of mbuf-related UMA(9) and malloc(9) types. Exposed to
302 * !_KERNEL so that monitoring tools can look up the zones with
303 * libmemstat(3).
304 */
305#define MBUF_MEM_NAME "mbuf"
306#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster"
307#define MBUF_PACKET_MEM_NAME "mbuf_packet"
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
197/*
198 * Flags copied when copying m_pkthdr.
199 */

--- 101 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"
308#define MBUF_JUMBO9_MEM_NAME "mbuf_jumbo_9k"
309#define MBUF_JUMBO16_MEM_NAME "mbuf_jumbo_16k"
310#define MBUF_TAG_MEM_NAME "mbuf_tag"
311#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt"
312
313#ifdef _KERNEL
314
315#ifdef WITNESS

--- 10 unchanged lines hidden (view full) ---

326 * Network buffer allocation API
327 *
328 * The rest of it is defined in kern/kern_mbuf.c
329 */
330
331extern uma_zone_t zone_mbuf;
332extern uma_zone_t zone_clust;
333extern 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;
334extern uma_zone_t zone_jumbo9;
335extern uma_zone_t zone_jumbo16;
336extern uma_zone_t zone_ext_refcnt;
337
338static __inline struct mbuf *m_get(int how, short type);
339static __inline struct mbuf *m_gethdr(int how, short type);
340static __inline struct mbuf *m_getcl(int how, short type, int flags);
337extern uma_zone_t zone_jumbo9;
338extern uma_zone_t zone_jumbo16;
339extern uma_zone_t zone_ext_refcnt;
340
341static __inline struct mbuf *m_get(int how, short type);
342static __inline struct mbuf *m_gethdr(int how, short type);
343static __inline struct mbuf *m_getcl(int how, short type, int flags);
344static __inline struct mbuf *m_getjcl(int how, short type, int flags, int size);
341static __inline struct mbuf *m_getclr(int how, short type); /* XXX */
342static __inline struct mbuf *m_free(struct mbuf *m);
343static __inline void m_clget(struct mbuf *m, int how);
345static __inline struct mbuf *m_getclr(int how, short type); /* XXX */
346static __inline struct mbuf *m_free(struct mbuf *m);
347static __inline void m_clget(struct mbuf *m, int how);
348static __inline void *m_cljget(struct mbuf *m, int how, int size);
344static __inline void m_chtype(struct mbuf *m, short new_type);
345void mb_free_ext(struct mbuf *);
346
347static __inline
348struct mbuf *
349m_get(int how, short type)
350{
351 struct mb_args args;

--- 36 unchanged lines hidden (view full) ---

388{
389 struct mb_args args;
390
391 args.flags = flags;
392 args.type = type;
393 return (uma_zalloc_arg(zone_pack, &args, how));
394}
395
349static __inline void m_chtype(struct mbuf *m, short new_type);
350void mb_free_ext(struct mbuf *);
351
352static __inline
353struct mbuf *
354m_get(int how, short type)
355{
356 struct mb_args args;

--- 36 unchanged lines hidden (view full) ---

393{
394 struct mb_args args;
395
396 args.flags = flags;
397 args.type = type;
398 return (uma_zalloc_arg(zone_pack, &args, how));
399}
400
401/*
402 * m_getjcl() returns an mbuf with a cluster of the specified size attached.
403 * For size it takes MCLBYTES, MJUM4BYTES, MJUM9BYTES, MJUM16BYTES.
404 */
405static __inline /* XXX: This is rather large, should be real function maybe. */
406struct mbuf *
407m_getjcl(int how, short type, int flags, int size)
408{
409 struct mb_args args;
410 struct mbuf *m, *n;
411 uma_zone_t zone;
412
413 args.flags = flags;
414 args.type = type;
415
416 m = uma_zalloc_arg(zone_mbuf, &args, how);
417 if (m == NULL)
418 return NULL;
419
420 switch (size) {
421 case MCLBYTES:
422 zone = zone_clust;
423 break;
424 case MJUM4BYTES:
425 zone = zone_jumbo4;
426 break;
427 case MJUM9BYTES:
428 zone = zone_jumbo9;
429 break;
430 case MJUM16BYTES:
431 zone = zone_jumbo16;
432 break;
433 default:
434 panic("%s: m_getjcl: invalid cluster type", __func__);
435 }
436 n = uma_zalloc_arg(zone, m, how);
437 if (n == NULL)
438 uma_zfree(zone_mbuf, m);
439 return n;
440}
441
396static __inline
397struct mbuf *
398m_free(struct mbuf *m)
399{
400 struct mbuf *n = m->m_next;
401
402 if (m->m_flags & M_EXT)
403 mb_free_ext(m);

--- 7 unchanged lines hidden (view full) ---

411m_clget(struct mbuf *m, int how)
412{
413 if (m->m_flags & M_EXT)
414 printf("%s: %p mbuf already has cluster\n", __func__, m);
415 m->m_ext.ext_buf = NULL;
416 uma_zalloc_arg(zone_clust, m, how);
417}
418
442static __inline
443struct mbuf *
444m_free(struct mbuf *m)
445{
446 struct mbuf *n = m->m_next;
447
448 if (m->m_flags & M_EXT)
449 mb_free_ext(m);

--- 7 unchanged lines hidden (view full) ---

457m_clget(struct mbuf *m, int how)
458{
459 if (m->m_flags & M_EXT)
460 printf("%s: %p mbuf already has cluster\n", __func__, m);
461 m->m_ext.ext_buf = NULL;
462 uma_zalloc_arg(zone_clust, m, how);
463}
464
465/*
466 * m_cljget() is different from m_clget() as it can allocate clusters
467 * without attaching them to an mbuf. In that case the return value
468 * is the pointer to the cluster of the requested size. If an mbuf was
469 * specified, it gets the cluster attached to it and the return value
470 * can be safely ignored.
471 * For size it takes MCLBYTES, MJUM4BYTES, MJUM9BYTES, MJUM16BYTES.
472 */
419static __inline
473static __inline
474void *
475m_cljget(struct mbuf *m, int how, int size)
476{
477 uma_zone_t zone;
478
479 if (m && m->m_flags & M_EXT)
480 printf("%s: %p mbuf already has cluster\n", __func__, m);
481 if (m != NULL)
482 m->m_ext.ext_buf = NULL;
483
484 switch (size) {
485 case MCLBYTES:
486 zone = zone_clust;
487 break;
488 case MJUM4BYTES:
489 zone = zone_jumbo4;
490 break;
491 case MJUM9BYTES:
492 zone = zone_jumbo9;
493 break;
494 case MJUM16BYTES:
495 zone = zone_jumbo16;
496 break;
497 default:
498 panic("%s: m_getjcl: invalid cluster type", __func__);
499 }
500
501 return (uma_zalloc_arg(zone, m, how));
502}
503
504static __inline
420void
421m_chtype(struct mbuf *m, short new_type)
422{
423 m->m_type = new_type;
424}
425
426/*
427 * mbuf, cluster, and external object allocation macros

--- 342 unchanged lines hidden ---
505void
506m_chtype(struct mbuf *m, short new_type)
507{
508 m->m_type = new_type;
509}
510
511/*
512 * mbuf, cluster, and external object allocation macros

--- 342 unchanged lines hidden ---