Deleted Added
full compact
mbuf.h (295482) mbuf.h (295547)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
31 * $FreeBSD: head/sys/sys/mbuf.h 295482 2016-02-10 18:54:18Z glebius $
31 * $FreeBSD: head/sys/sys/mbuf.h 295547 2016-02-11 21:32:23Z glebius $
32 */
33
34#ifndef _SYS_MBUF_H_
35#define _SYS_MBUF_H_
36
37/* XXX: These includes suck. Sorry! */
38#include <sys/queue.h>
39#ifdef _KERNEL

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

523extern uma_zone_t zone_pack;
524extern uma_zone_t zone_jumbop;
525extern uma_zone_t zone_jumbo9;
526extern uma_zone_t zone_jumbo16;
527extern uma_zone_t zone_ext_refcnt;
528
529void mb_dupcl(struct mbuf *, const struct mbuf *);
530void mb_free_ext(struct mbuf *);
32 */
33
34#ifndef _SYS_MBUF_H_
35#define _SYS_MBUF_H_
36
37/* XXX: These includes suck. Sorry! */
38#include <sys/queue.h>
39#ifdef _KERNEL

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

523extern uma_zone_t zone_pack;
524extern uma_zone_t zone_jumbop;
525extern uma_zone_t zone_jumbo9;
526extern uma_zone_t zone_jumbo16;
527extern uma_zone_t zone_ext_refcnt;
528
529void mb_dupcl(struct mbuf *, const struct mbuf *);
530void mb_free_ext(struct mbuf *);
531void m_adj(struct mbuf *, int);
532int m_apply(struct mbuf *, int, int,
533 int (*)(void *, void *, u_int), void *);
534int m_append(struct mbuf *, int, c_caddr_t);
535void m_cat(struct mbuf *, struct mbuf *);
536void m_catpkt(struct mbuf *, struct mbuf *);
537int m_clget(struct mbuf *m, int how);
538void *m_cljget(struct mbuf *m, int how, int size);
539struct mbuf *m_collapse(struct mbuf *, int, int);
540void m_copyback(struct mbuf *, int, int, c_caddr_t);
541void m_copydata(const struct mbuf *, int, int, caddr_t);
542struct mbuf *m_copym(const struct mbuf *, int, int, int);
543struct mbuf *m_copypacket(struct mbuf *, int);
544void m_copy_pkthdr(struct mbuf *, struct mbuf *);
545struct mbuf *m_copyup(struct mbuf *, int, int);
546struct mbuf *m_defrag(struct mbuf *, int);
547void m_demote_pkthdr(struct mbuf *);
548void m_demote(struct mbuf *, int, int);
549struct mbuf *m_devget(char *, int, int, struct ifnet *,
550 void (*)(char *, caddr_t, u_int));
551struct mbuf *m_dup(const struct mbuf *, int);
552int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int);
553int m_extadd(struct mbuf *, caddr_t, u_int,
554 void (*)(struct mbuf *, void *, void *), void *, void *,
555 int, int, int);
556u_int m_fixhdr(struct mbuf *);
557struct mbuf *m_fragment(struct mbuf *, int, int);
558void m_freem(struct mbuf *);
559struct mbuf *m_get2(int, int, short, int);
560struct mbuf *m_getjcl(int, short, int, int);
561struct mbuf *m_getm2(struct mbuf *, int, int, short, int);
562struct mbuf *m_getptr(struct mbuf *, int, int *);
563u_int m_length(struct mbuf *, struct mbuf **);
564int m_mbuftouio(struct uio *, struct mbuf *, int);
565void m_move_pkthdr(struct mbuf *, struct mbuf *);
531int m_pkthdr_init(struct mbuf *, int);
566int m_pkthdr_init(struct mbuf *, int);
567struct mbuf *m_prepend(struct mbuf *, int, int);
568void m_print(const struct mbuf *, int);
569struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
570struct mbuf *m_pullup(struct mbuf *, int);
571int m_sanity(struct mbuf *, int);
572struct mbuf *m_split(struct mbuf *, int, int);
573struct mbuf *m_uiotombuf(struct uio *, int, int, int, int);
574struct mbuf *m_unshare(struct mbuf *, int);
532
533static __inline int
534m_gettype(int size)
535{
536 int type;
537
538 switch (size) {
539 case MSIZE:

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

661{
662 struct mb_args args;
663
664 args.flags = flags;
665 args.type = type;
666 return (uma_zalloc_arg(zone_pack, &args, how));
667}
668
575
576static __inline int
577m_gettype(int size)
578{
579 int type;
580
581 switch (size) {
582 case MSIZE:

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

704{
705 struct mb_args args;
706
707 args.flags = flags;
708 args.type = type;
709 return (uma_zalloc_arg(zone_pack, &args, how));
710}
711
669static __inline int
670m_clget(struct mbuf *m, int how)
671{
672
673 KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT",
674 __func__, m));
675 m->m_ext.ext_buf = (char *)NULL;
676 uma_zalloc_arg(zone_clust, m, how);
677 /*
678 * On a cluster allocation failure, drain the packet zone and retry,
679 * we might be able to loosen a few clusters up on the drain.
680 */
681 if ((how & M_NOWAIT) && (m->m_ext.ext_buf == NULL)) {
682 zone_drain(zone_pack);
683 uma_zalloc_arg(zone_clust, m, how);
684 }
685 return (m->m_flags & M_EXT);
686}
687
688/*
689 * m_cljget() is different from m_clget() as it can allocate clusters without
690 * attaching them to an mbuf. In that case the return value is the pointer
691 * to the cluster of the requested size. If an mbuf was specified, it gets
692 * the cluster attached to it and the return value can be safely ignored.
693 * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES.
694 */
695static __inline void *
696m_cljget(struct mbuf *m, int how, int size)
697{
698 uma_zone_t zone;
699
700 if (m != NULL) {
701 KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT",
702 __func__, m));
703 m->m_ext.ext_buf = NULL;
704 }
705
706 zone = m_getzone(size);
707 return (uma_zalloc_arg(zone, m, how));
708}
709
710static __inline void
711m_cljset(struct mbuf *m, void *cl, int type)
712{
713 uma_zone_t zone;
714 int size;
715
716 switch (type) {
717 case EXT_CLUSTER:

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

919#define m_copy(m, o, l) m_copym((m), (o), (l), M_NOWAIT)
920
921extern int max_datalen; /* MHLEN - max_hdr */
922extern int max_hdr; /* Largest link + protocol header */
923extern int max_linkhdr; /* Largest link-level header */
924extern int max_protohdr; /* Largest protocol header */
925extern int nmbclusters; /* Maximum number of clusters */
926
712static __inline void
713m_cljset(struct mbuf *m, void *cl, int type)
714{
715 uma_zone_t zone;
716 int size;
717
718 switch (type) {
719 case EXT_CLUSTER:

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

921#define m_copy(m, o, l) m_copym((m), (o), (l), M_NOWAIT)
922
923extern int max_datalen; /* MHLEN - max_hdr */
924extern int max_hdr; /* Largest link + protocol header */
925extern int max_linkhdr; /* Largest link-level header */
926extern int max_protohdr; /* Largest protocol header */
927extern int nmbclusters; /* Maximum number of clusters */
928
927struct uio;
928
929void m_adj(struct mbuf *, int);
930int m_apply(struct mbuf *, int, int,
931 int (*)(void *, void *, u_int), void *);
932int m_append(struct mbuf *, int, c_caddr_t);
933void m_cat(struct mbuf *, struct mbuf *);
934void m_catpkt(struct mbuf *, struct mbuf *);
935int m_extadd(struct mbuf *, caddr_t, u_int,
936 void (*)(struct mbuf *, void *, void *), void *, void *,
937 int, int, int);
938struct mbuf *m_collapse(struct mbuf *, int, int);
939void m_copyback(struct mbuf *, int, int, c_caddr_t);
940void m_copydata(const struct mbuf *, int, int, caddr_t);
941struct mbuf *m_copym(const struct mbuf *, int, int, int);
942struct mbuf *m_copypacket(struct mbuf *, int);
943void m_copy_pkthdr(struct mbuf *, struct mbuf *);
944struct mbuf *m_copyup(struct mbuf *, int, int);
945struct mbuf *m_defrag(struct mbuf *, int);
946void m_demote_pkthdr(struct mbuf *);
947void m_demote(struct mbuf *, int, int);
948struct mbuf *m_devget(char *, int, int, struct ifnet *,
949 void (*)(char *, caddr_t, u_int));
950struct mbuf *m_dup(const struct mbuf *, int);
951int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int);
952u_int m_fixhdr(struct mbuf *);
953struct mbuf *m_fragment(struct mbuf *, int, int);
954void m_freem(struct mbuf *);
955struct mbuf *m_get2(int, int, short, int);
956struct mbuf *m_getjcl(int, short, int, int);
957struct mbuf *m_getm2(struct mbuf *, int, int, short, int);
958struct mbuf *m_getptr(struct mbuf *, int, int *);
959u_int m_length(struct mbuf *, struct mbuf **);
960int m_mbuftouio(struct uio *, struct mbuf *, int);
961void m_move_pkthdr(struct mbuf *, struct mbuf *);
962struct mbuf *m_prepend(struct mbuf *, int, int);
963void m_print(const struct mbuf *, int);
964struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
965struct mbuf *m_pullup(struct mbuf *, int);
966int m_sanity(struct mbuf *, int);
967struct mbuf *m_split(struct mbuf *, int, int);
968struct mbuf *m_uiotombuf(struct uio *, int, int, int, int);
969struct mbuf *m_unshare(struct mbuf *, int);
970
971/*-
972 * Network packets may have annotations attached by affixing a list of
973 * "packet tags" to the pkthdr structure. Packet tags are dynamically
974 * allocated semi-opaque data structures that have a fixed header
975 * (struct m_tag) that specifies the size of the memory block and a
976 * <cookie,type> pair that identifies it. The cookie is a 32-bit unique
977 * unsigned value used to identify a module or ABI. By convention this value
978 * is chosen as the date+time that the module is created, expressed as the

--- 317 unchanged lines hidden ---
929/*-
930 * Network packets may have annotations attached by affixing a list of
931 * "packet tags" to the pkthdr structure. Packet tags are dynamically
932 * allocated semi-opaque data structures that have a fixed header
933 * (struct m_tag) that specifies the size of the memory block and a
934 * <cookie,type> pair that identifies it. The cookie is a 32-bit unique
935 * unsigned value used to identify a module or ABI. By convention this value
936 * is chosen as the date+time that the module is created, expressed as the

--- 317 unchanged lines hidden ---