Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/mbuf.h
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | union { | ||||
* shadow copy and we use pointer 'ext_cnt'. The original | * shadow copy and we use pointer 'ext_cnt'. The original | ||||
* mbuf is responsible to carry the pointer to free routine | * mbuf is responsible to carry the pointer to free routine | ||||
* and its arguments. They aren't copied into shadows in | * and its arguments. They aren't copied into shadows in | ||||
* mb_dupcl() to avoid dereferencing next cachelines. | * mb_dupcl() to avoid dereferencing next cachelines. | ||||
*/ | */ | ||||
volatile u_int ext_count; | volatile u_int ext_count; | ||||
volatile u_int *ext_cnt; | volatile u_int *ext_cnt; | ||||
}; | }; | ||||
char *ext_buf; /* start of buffer */ | union { | ||||
/* | |||||
* If ext_type == EXT_PGS, 'ext_pgs' points to a | |||||
* structure describing the buffer. Otherwise, | |||||
* 'ext_buf' points to the start of the buffer. | |||||
*/ | |||||
struct mbuf_ext_pgs *ext_pgs; | |||||
char *ext_buf; | |||||
}; | |||||
uint32_t ext_size; /* size of buffer, for ext_free */ | uint32_t ext_size; /* size of buffer, for ext_free */ | ||||
uint32_t ext_type:8, /* type of external storage */ | uint32_t ext_type:8, /* type of external storage */ | ||||
ext_flags:24; /* external storage mbuf flags */ | ext_flags:24; /* external storage mbuf flags */ | ||||
/* | /* | ||||
* Fields below store the free context for the external storage. | * Fields below store the free context for the external storage. | ||||
* They are valid only in the refcount carrying mbuf, the one with | * They are valid only in the refcount carrying mbuf, the one with | ||||
* EXT_FLAG_EMBREF flag, with exclusion for EXT_EXTREF type, where | * EXT_FLAG_EMBREF flag, with exclusion for EXT_EXTREF type, where | ||||
* the free context is copied into all mbufs that use same external | * the free context is copied into all mbufs that use same external | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | struct { | ||||
struct m_ext m_ext; /* M_EXT set */ | struct m_ext m_ext; /* M_EXT set */ | ||||
char m_pktdat[0]; | char m_pktdat[0]; | ||||
}; | }; | ||||
}; | }; | ||||
char m_dat[0]; /* !M_PKTHDR, !M_EXT */ | char m_dat[0]; /* !M_PKTHDR, !M_EXT */ | ||||
}; | }; | ||||
}; | }; | ||||
struct socket; | |||||
/* | /* | ||||
* TLS records for TLS 1.0-1.2 can have the following header lengths: | |||||
* - 5 (AES-CBC with implicit IV) | |||||
* - 21 (AES-CBC with explicit IV) | |||||
* - 13 (AES-GCM with 8 byte explicit IV) | |||||
*/ | |||||
#define MBUF_PEXT_HDR_LEN 24 | |||||
/* | |||||
* TLS records for TLS 1.0-1.2 can have the following maximum trailer | |||||
* lengths: | |||||
* - 16 (AES-GCM) | |||||
* - 36 (AES-CBC with SHA1 and up to 16 bytes of padding) | |||||
* - 48 (AES-CBC with SHA2-256 and up to 16 bytes of padding) | |||||
* - 64 (AES-CBC with SHA2-384 and up to 16 bytes of padding) | |||||
*/ | |||||
#define MBUF_PEXT_TRAIL_LEN 64 | |||||
#ifdef __LP64__ | |||||
#define MBUF_PEXT_MAX_PGS (152 / sizeof(vm_paddr_t)) | |||||
hselasky: Where does 152 and 156 come from? | |||||
Not Done Inline ActionsIt is the amount of space left over when subtracting the size of the rest of the structure from 256 bytes (so as to make a nicely sized structure for the uma allocator). gallatin: It is the amount of space left over when subtracting the size of the rest of the structure from… | |||||
Done Inline ActionsAnd to be clear, the static assertion for the size will catch if this is wrong. jhb: And to be clear, the static assertion for the size will catch if this is wrong. | |||||
#else | |||||
#define MBUF_PEXT_MAX_PGS (156 / sizeof(vm_paddr_t)) | |||||
#endif | |||||
#define MBUF_PEXT_MAX_BYTES \ | |||||
(MBUF_PEXT_MAX_PGS * PAGE_SIZE + MBUF_PEXT_HDR_LEN + MBUF_PEXT_TRAIL_LEN) | |||||
/* | |||||
* This struct is 256 bytes in size and is arranged so that the most | |||||
* common case (accessing the first 4 pages of a 16KB TLS record) will | |||||
* fit in a single 64 byte cacheline. | |||||
*/ | |||||
struct mbuf_ext_pgs { | |||||
uint8_t npgs; /* Number of attached pages */ | |||||
uint8_t nrdy; /* Pages with I/O pending */ | |||||
uint8_t hdr_len; /* TLS header length */ | |||||
uint8_t trail_len; /* TLS trailer length */ | |||||
uint16_t first_pg_off; /* Offset into 1st page */ | |||||
uint16_t last_pg_len; /* Length of last page */ | |||||
vm_paddr_t pa[MBUF_PEXT_MAX_PGS]; /* phys addrs of pages */ | |||||
char hdr[MBUF_PEXT_HDR_LEN]; /* TLS header */ | |||||
void *tls; /* TLS session */ | |||||
#if defined(__i386__) || \ | |||||
(defined(__powerpc__) && !defined(__powerpc64__) && defined(BOOKE)) | |||||
/* | |||||
* i386 and Book-E PowerPC have 64-bit vm_paddr_t, so there is | |||||
* a 4 byte remainder from the space allocated for pa[]. | |||||
*/ | |||||
uint32_t pad; | |||||
#endif | |||||
union { | |||||
char trail[MBUF_PEXT_TRAIL_LEN]; /* TLS trailer */ | |||||
struct { | |||||
struct socket *so; | |||||
void *mbuf; | |||||
uint64_t seqno; | |||||
STAILQ_ENTRY(mbuf_ext_pgs) stailq; | |||||
}; | |||||
}; | |||||
}; | |||||
#ifdef _KERNEL | |||||
static inline int | |||||
mbuf_ext_pg_len(struct mbuf_ext_pgs *ext_pgs, int pidx, int pgoff) | |||||
{ | |||||
KASSERT(pgoff == 0 || pidx == 0, | |||||
("page %d with non-zero offset %d in %p", pidx, pgoff, ext_pgs)); | |||||
if (pidx == ext_pgs->npgs - 1) { | |||||
return (ext_pgs->last_pg_len); | |||||
} else { | |||||
return (PAGE_SIZE - pgoff); | |||||
} | |||||
} | |||||
#ifdef INVARIANT_SUPPORT | |||||
void mb_ext_pgs_check(struct mbuf_ext_pgs *ext_pgs); | |||||
#endif | |||||
#ifdef INVARIANTS | |||||
#define MBUF_EXT_PGS_ASSERT_SANITY(ext_pgs) mb_ext_pgs_check((ext_pgs)) | |||||
Not Done Inline ActionsExtra ()'s: ((ext_pgs)) -> (ext_pgs) hselasky: Extra ()'s:
((ext_pgs)) -> (ext_pgs) | |||||
Done Inline ActionsThis is a normal safety measure for C pre-processor macro definitions. jhb: This is a normal safety measure for C pre-processor macro definitions. | |||||
#else | |||||
#define MBUF_EXT_PGS_ASSERT_SANITY(ext_pgs) | |||||
#endif | |||||
#endif | |||||
/* | |||||
* mbuf flags of global significance and layer crossing. | * mbuf flags of global significance and layer crossing. | ||||
* Those of only protocol/layer specific significance are to be mapped | * Those of only protocol/layer specific significance are to be mapped | ||||
* to M_PROTO[1-12] and cleared at layer handoff boundaries. | * to M_PROTO[1-12] and cleared at layer handoff boundaries. | ||||
* NB: Limited to the lower 24 bits. | * NB: Limited to the lower 24 bits. | ||||
*/ | */ | ||||
#define M_EXT 0x00000001 /* has associated external storage */ | #define M_EXT 0x00000001 /* has associated external storage */ | ||||
#define M_PKTHDR 0x00000002 /* start of record */ | #define M_PKTHDR 0x00000002 /* start of record */ | ||||
#define M_EOR 0x00000004 /* end of record */ | #define M_EOR 0x00000004 /* end of record */ | ||||
#define M_RDONLY 0x00000008 /* associated data is marked read-only */ | #define M_RDONLY 0x00000008 /* associated data is marked read-only */ | ||||
#define M_BCAST 0x00000010 /* send/received as link-level broadcast */ | #define M_BCAST 0x00000010 /* send/received as link-level broadcast */ | ||||
#define M_MCAST 0x00000020 /* send/received as link-level multicast */ | #define M_MCAST 0x00000020 /* send/received as link-level multicast */ | ||||
#define M_PROMISC 0x00000040 /* packet was not for us */ | #define M_PROMISC 0x00000040 /* packet was not for us */ | ||||
#define M_VLANTAG 0x00000080 /* ether_vtag is valid */ | #define M_VLANTAG 0x00000080 /* ether_vtag is valid */ | ||||
#define M_NOMAP 0x00000100 /* mbuf data is unmapped (soon from Drew) */ | #define M_NOMAP 0x00000100 /* mbuf data is unmapped */ | ||||
#define M_NOFREE 0x00000200 /* do not free mbuf, embedded in cluster */ | #define M_NOFREE 0x00000200 /* do not free mbuf, embedded in cluster */ | ||||
#define M_TSTMP 0x00000400 /* rcv_tstmp field is valid */ | #define M_TSTMP 0x00000400 /* rcv_tstmp field is valid */ | ||||
#define M_TSTMP_HPREC 0x00000800 /* rcv_tstmp is high-prec, typically | #define M_TSTMP_HPREC 0x00000800 /* rcv_tstmp is high-prec, typically | ||||
hw-stamped on port (useful for IEEE 1588 | hw-stamped on port (useful for IEEE 1588 | ||||
and 802.1AS) */ | and 802.1AS) */ | ||||
#define M_PROTO1 0x00001000 /* protocol-specific */ | #define M_PROTO1 0x00001000 /* protocol-specific */ | ||||
#define M_PROTO2 0x00002000 /* protocol-specific */ | #define M_PROTO2 0x00002000 /* protocol-specific */ | ||||
Show All 24 Lines | #define M_COPYFLAGS \ | ||||
(M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG|M_TSTMP| \ | (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG|M_TSTMP| \ | ||||
M_TSTMP_HPREC|M_PROTOFLAGS) | M_TSTMP_HPREC|M_PROTOFLAGS) | ||||
/* | /* | ||||
* Mbuf flag description for use with printf(9) %b identifier. | * Mbuf flag description for use with printf(9) %b identifier. | ||||
*/ | */ | ||||
#define M_FLAG_BITS \ | #define M_FLAG_BITS \ | ||||
"\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ | "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ | ||||
"\7M_PROMISC\10M_VLANTAG\13M_TSTMP\14M_TSTMP_HPREC" | "\7M_PROMISC\10M_VLANTAG\11M_NOMAP\12M_NOFREE\13M_TSTMP\14M_TSTMP_HPREC" | ||||
#define M_FLAG_PROTOBITS \ | #define M_FLAG_PROTOBITS \ | ||||
"\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ | "\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ | ||||
"\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ | "\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ | ||||
"\27M_PROTO11\30M_PROTO12" | "\27M_PROTO11\30M_PROTO12" | ||||
#define M_FLAG_PRINTF (M_FLAG_BITS M_FLAG_PROTOBITS) | #define M_FLAG_PRINTF (M_FLAG_BITS M_FLAG_PROTOBITS) | ||||
/* | /* | ||||
* Network interface cards are able to hash protocol fields (such as IPv4 | * Network interface cards are able to hash protocol fields (such as IPv4 | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
#define EXT_CLUSTER 1 /* mbuf cluster */ | #define EXT_CLUSTER 1 /* mbuf cluster */ | ||||
#define EXT_SFBUF 2 /* sendfile(2)'s sf_buf */ | #define EXT_SFBUF 2 /* sendfile(2)'s sf_buf */ | ||||
#define EXT_JUMBOP 3 /* jumbo cluster page sized */ | #define EXT_JUMBOP 3 /* jumbo cluster page sized */ | ||||
#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ | #define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ | ||||
#define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ | #define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ | ||||
#define EXT_PACKET 6 /* mbuf+cluster from packet zone */ | #define EXT_PACKET 6 /* mbuf+cluster from packet zone */ | ||||
#define EXT_MBUF 7 /* external mbuf reference */ | #define EXT_MBUF 7 /* external mbuf reference */ | ||||
#define EXT_RXRING 8 /* data in NIC receive ring */ | #define EXT_RXRING 8 /* data in NIC receive ring */ | ||||
#define EXT_PGS 9 /* array of unmapped pages */ | |||||
#define EXT_VENDOR1 224 /* for vendor-internal use */ | #define EXT_VENDOR1 224 /* for vendor-internal use */ | ||||
#define EXT_VENDOR2 225 /* for vendor-internal use */ | #define EXT_VENDOR2 225 /* for vendor-internal use */ | ||||
#define EXT_VENDOR3 226 /* for vendor-internal use */ | #define EXT_VENDOR3 226 /* for vendor-internal use */ | ||||
#define EXT_VENDOR4 227 /* for vendor-internal use */ | #define EXT_VENDOR4 227 /* for vendor-internal use */ | ||||
#define EXT_EXP1 244 /* for experimental use */ | #define EXT_EXP1 244 /* for experimental use */ | ||||
#define EXT_EXP2 245 /* for experimental use */ | #define EXT_EXP2 245 /* for experimental use */ | ||||
Show All 28 Lines | |||||
* EXT flag description for use with printf(9) %b identifier. | * EXT flag description for use with printf(9) %b identifier. | ||||
*/ | */ | ||||
#define EXT_FLAG_BITS \ | #define EXT_FLAG_BITS \ | ||||
"\20\1EXT_FLAG_EMBREF\2EXT_FLAG_EXTREF\5EXT_FLAG_NOFREE" \ | "\20\1EXT_FLAG_EMBREF\2EXT_FLAG_EXTREF\5EXT_FLAG_NOFREE" \ | ||||
"\21EXT_FLAG_VENDOR1\22EXT_FLAG_VENDOR2\23EXT_FLAG_VENDOR3" \ | "\21EXT_FLAG_VENDOR1\22EXT_FLAG_VENDOR2\23EXT_FLAG_VENDOR3" \ | ||||
"\24EXT_FLAG_VENDOR4\25EXT_FLAG_EXP1\26EXT_FLAG_EXP2\27EXT_FLAG_EXP3" \ | "\24EXT_FLAG_VENDOR4\25EXT_FLAG_EXP1\26EXT_FLAG_EXP2\27EXT_FLAG_EXP3" \ | ||||
"\30EXT_FLAG_EXP4" | "\30EXT_FLAG_EXP4" | ||||
#define MBUF_EXT_PGS_ASSERT(m) \ | |||||
KASSERT((((m)->m_flags & M_EXT) != 0) && \ | |||||
((m)->m_ext.ext_type == EXT_PGS), \ | |||||
("%s: m %p !M_EXT or !EXT_PGS", __func__, m)) | |||||
/* | /* | ||||
* Flags indicating checksum, segmentation and other offload work to be | * Flags indicating checksum, segmentation and other offload work to be | ||||
* done, or already done, by hardware or lower layers. It is split into | * done, or already done, by hardware or lower layers. It is split into | ||||
* separate inbound and outbound flags. | * separate inbound and outbound flags. | ||||
* | * | ||||
* Outbound flags that are set by upper protocol layers requesting lower | * Outbound flags that are set by upper protocol layers requesting lower | ||||
* layers, or ideally the hardware, to perform these offloading tasks. | * layers, or ideally the hardware, to perform these offloading tasks. | ||||
* For outbound packets this field and its flags can be directly tested | * For outbound packets this field and its flags can be directly tested | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
#define MBUF_MEM_NAME "mbuf" | #define MBUF_MEM_NAME "mbuf" | ||||
#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster" | #define MBUF_CLUSTER_MEM_NAME "mbuf_cluster" | ||||
#define MBUF_PACKET_MEM_NAME "mbuf_packet" | #define MBUF_PACKET_MEM_NAME "mbuf_packet" | ||||
#define MBUF_JUMBOP_MEM_NAME "mbuf_jumbo_page" | #define MBUF_JUMBOP_MEM_NAME "mbuf_jumbo_page" | ||||
#define MBUF_JUMBO9_MEM_NAME "mbuf_jumbo_9k" | #define MBUF_JUMBO9_MEM_NAME "mbuf_jumbo_9k" | ||||
#define MBUF_JUMBO16_MEM_NAME "mbuf_jumbo_16k" | #define MBUF_JUMBO16_MEM_NAME "mbuf_jumbo_16k" | ||||
#define MBUF_TAG_MEM_NAME "mbuf_tag" | #define MBUF_TAG_MEM_NAME "mbuf_tag" | ||||
#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt" | #define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt" | ||||
#define MBUF_EXTPGS_MEM_NAME "mbuf_extpgs" | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#ifdef WITNESS | #ifdef WITNESS | ||||
#define MBUF_CHECKSLEEP(how) do { \ | #define MBUF_CHECKSLEEP(how) do { \ | ||||
if (how == M_WAITOK) \ | if (how == M_WAITOK) \ | ||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ | WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ | ||||
"Sleeping in \"%s\"", __func__); \ | "Sleeping in \"%s\"", __func__); \ | ||||
} while (0) | } while (0) | ||||
#else | #else | ||||
#define MBUF_CHECKSLEEP(how) | #define MBUF_CHECKSLEEP(how) | ||||
#endif | #endif | ||||
/* | /* | ||||
* Network buffer allocation API | * Network buffer allocation API | ||||
* | * | ||||
* The rest of it is defined in kern/kern_mbuf.c | * The rest of it is defined in kern/kern_mbuf.c | ||||
*/ | */ | ||||
extern uma_zone_t zone_mbuf; | extern uma_zone_t zone_mbuf; | ||||
extern uma_zone_t zone_clust; | extern uma_zone_t zone_clust; | ||||
extern uma_zone_t zone_pack; | extern uma_zone_t zone_pack; | ||||
extern uma_zone_t zone_jumbop; | extern uma_zone_t zone_jumbop; | ||||
extern uma_zone_t zone_jumbo9; | extern uma_zone_t zone_jumbo9; | ||||
extern uma_zone_t zone_jumbo16; | extern uma_zone_t zone_jumbo16; | ||||
extern uma_zone_t zone_extpgs; | |||||
void mb_dupcl(struct mbuf *, struct mbuf *); | void mb_dupcl(struct mbuf *, struct mbuf *); | ||||
void mb_free_ext(struct mbuf *); | void mb_free_ext(struct mbuf *); | ||||
void mb_free_mext_pgs(struct mbuf *); | |||||
struct mbuf *mb_alloc_ext_pgs(int, bool, m_ext_free_t); | |||||
int mb_unmapped_compress(struct mbuf *m); | |||||
struct mbuf *mb_unmapped_to_ext(struct mbuf *m); | |||||
void mb_free_notready(struct mbuf *m, int count); | |||||
void m_adj(struct mbuf *, int); | void m_adj(struct mbuf *, int); | ||||
int m_apply(struct mbuf *, int, int, | int m_apply(struct mbuf *, int, int, | ||||
int (*)(void *, void *, u_int), void *); | int (*)(void *, void *, u_int), void *); | ||||
int m_append(struct mbuf *, int, c_caddr_t); | int m_append(struct mbuf *, int, c_caddr_t); | ||||
void m_cat(struct mbuf *, struct mbuf *); | void m_cat(struct mbuf *, struct mbuf *); | ||||
void m_catpkt(struct mbuf *, struct mbuf *); | void m_catpkt(struct mbuf *, struct mbuf *); | ||||
int m_clget(struct mbuf *m, int how); | int m_clget(struct mbuf *m, int how); | ||||
void *m_cljget(struct mbuf *m, int how, int size); | void *m_cljget(struct mbuf *m, int how, int size); | ||||
Show All 18 Lines | |||||
struct mbuf *m_fragment(struct mbuf *, int, int); | struct mbuf *m_fragment(struct mbuf *, int, int); | ||||
void m_freem(struct mbuf *); | void m_freem(struct mbuf *); | ||||
struct mbuf *m_get2(int, int, short, int); | struct mbuf *m_get2(int, int, short, int); | ||||
struct mbuf *m_getjcl(int, short, int, int); | struct mbuf *m_getjcl(int, short, int, int); | ||||
struct mbuf *m_getm2(struct mbuf *, int, int, short, int); | struct mbuf *m_getm2(struct mbuf *, int, int, short, int); | ||||
struct mbuf *m_getptr(struct mbuf *, int, int *); | struct mbuf *m_getptr(struct mbuf *, int, int *); | ||||
u_int m_length(struct mbuf *, struct mbuf **); | u_int m_length(struct mbuf *, struct mbuf **); | ||||
int m_mbuftouio(struct uio *, const struct mbuf *, int); | int m_mbuftouio(struct uio *, const struct mbuf *, int); | ||||
int m_unmappedtouio(const struct mbuf *, int, struct uio *, int); | |||||
void m_move_pkthdr(struct mbuf *, struct mbuf *); | void m_move_pkthdr(struct mbuf *, struct mbuf *); | ||||
int m_pkthdr_init(struct mbuf *, int); | int m_pkthdr_init(struct mbuf *, int); | ||||
struct mbuf *m_prepend(struct mbuf *, int, int); | struct mbuf *m_prepend(struct mbuf *, int, int); | ||||
void m_print(const struct mbuf *, int); | void m_print(const struct mbuf *, int); | ||||
struct mbuf *m_pulldown(struct mbuf *, int, int, int *); | struct mbuf *m_pulldown(struct mbuf *, int, int, int *); | ||||
struct mbuf *m_pullup(struct mbuf *, int); | struct mbuf *m_pullup(struct mbuf *, int); | ||||
int m_sanity(struct mbuf *, int); | int m_sanity(struct mbuf *, int); | ||||
struct mbuf *m_split(struct mbuf *, int, int); | struct mbuf *m_split(struct mbuf *, int, int); | ||||
▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | |||||
#define m_getm(m, len, how, type) \ | #define m_getm(m, len, how, type) \ | ||||
m_getm2((m), (len), (how), (type), M_PKTHDR) | m_getm2((m), (len), (how), (type), M_PKTHDR) | ||||
/* | /* | ||||
* Evaluate TRUE if it's safe to write to the mbuf m's data region (this can | * Evaluate TRUE if it's safe to write to the mbuf m's data region (this can | ||||
* be both the local data payload, or an external buffer area, depending on | * be both the local data payload, or an external buffer area, depending on | ||||
* whether M_EXT is set). | * whether M_EXT is set). | ||||
*/ | */ | ||||
#define M_WRITABLE(m) (!((m)->m_flags & M_RDONLY) && \ | #define M_WRITABLE(m) (((m)->m_flags & (M_RDONLY | M_NOMAP)) == 0 && \ | ||||
(!(((m)->m_flags & M_EXT)) || \ | (!(((m)->m_flags & M_EXT)) || \ | ||||
(m_extrefcnt(m) == 1))) | (m_extrefcnt(m) == 1))) | ||||
/* Check if the supplied mbuf has a packet header, or else panic. */ | /* Check if the supplied mbuf has a packet header, or else panic. */ | ||||
#define M_ASSERTPKTHDR(m) \ | #define M_ASSERTPKTHDR(m) \ | ||||
KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \ | KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \ | ||||
("%s: no mbuf packet header!", __func__)) | ("%s: no mbuf packet header!", __func__)) | ||||
/* | /* | ||||
* Ensure that the supplied mbuf is a valid, non-free mbuf. | * Ensure that the supplied mbuf is a valid, non-free mbuf. | ||||
* | * | ||||
* XXX: Broken at the moment. Need some UMA magic to make it work again. | * XXX: Broken at the moment. Need some UMA magic to make it work again. | ||||
*/ | */ | ||||
#define M_ASSERTVALID(m) \ | #define M_ASSERTVALID(m) \ | ||||
KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \ | KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \ | ||||
("%s: attempted use of a free mbuf!", __func__)) | ("%s: attempted use of a free mbuf!", __func__)) | ||||
/* | /* | ||||
* Return the address of the start of the buffer associated with an mbuf, | * Return the address of the start of the buffer associated with an mbuf, | ||||
* handling external storage, packet-header mbufs, and regular data mbufs. | * handling external storage, packet-header mbufs, and regular data mbufs. | ||||
*/ | */ | ||||
#define M_START(m) \ | #define M_START(m) \ | ||||
(((m)->m_flags & M_EXT) ? (m)->m_ext.ext_buf : \ | (((m)->m_flags & M_NOMAP) ? NULL : \ | ||||
((m)->m_flags & M_EXT) ? (m)->m_ext.ext_buf : \ | |||||
((m)->m_flags & M_PKTHDR) ? &(m)->m_pktdat[0] : \ | ((m)->m_flags & M_PKTHDR) ? &(m)->m_pktdat[0] : \ | ||||
&(m)->m_dat[0]) | &(m)->m_dat[0]) | ||||
/* | /* | ||||
* Return the size of the buffer associated with an mbuf, handling external | * Return the size of the buffer associated with an mbuf, handling external | ||||
* storage, packet-header mbufs, and regular data mbufs. | * storage, packet-header mbufs, and regular data mbufs. | ||||
*/ | */ | ||||
#define M_SIZE(m) \ | #define M_SIZE(m) \ | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
/* Length to m_copy to copy all. */ | /* Length to m_copy to copy all. */ | ||||
#define M_COPYALL 1000000000 | #define M_COPYALL 1000000000 | ||||
extern int max_datalen; /* MHLEN - max_hdr */ | extern int max_datalen; /* MHLEN - max_hdr */ | ||||
extern int max_hdr; /* Largest link + protocol header */ | extern int max_hdr; /* Largest link + protocol header */ | ||||
extern int max_linkhdr; /* Largest link-level header */ | extern int max_linkhdr; /* Largest link-level header */ | ||||
extern int max_protohdr; /* Largest protocol header */ | extern int max_protohdr; /* Largest protocol header */ | ||||
extern int nmbclusters; /* Maximum number of clusters */ | extern int nmbclusters; /* Maximum number of clusters */ | ||||
extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */ | |||||
/*- | /*- | ||||
* Network packets may have annotations attached by affixing a list of | * Network packets may have annotations attached by affixing a list of | ||||
* "packet tags" to the pkthdr structure. Packet tags are dynamically | * "packet tags" to the pkthdr structure. Packet tags are dynamically | ||||
* allocated semi-opaque data structures that have a fixed header | * allocated semi-opaque data structures that have a fixed header | ||||
* (struct m_tag) that specifies the size of the memory block and a | * (struct m_tag) that specifies the size of the memory block and a | ||||
* <cookie,type> pair that identifies it. The cookie is a 32-bit unique | * <cookie,type> pair that identifies it. The cookie is a 32-bit unique | ||||
* unsigned value used to identify a module or ABI. By convention this value | * unsigned value used to identify a module or ABI. By convention this value | ||||
▲ Show 20 Lines • Show All 369 Lines • Show Last 20 Lines |
Where does 152 and 156 come from?