Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/mbuf.h
Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Lines | |||||
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_ext_refcnt; | extern uma_zone_t zone_ext_refcnt; | ||||
void mb_dupcl(struct mbuf *, const struct mbuf *); | void mb_dupcl(struct mbuf *, const struct mbuf *); | ||||
void mb_free_ext(struct mbuf *); | void mb_free_ext(struct mbuf *); | ||||
void m_adj(struct mbuf *, int); | |||||
int m_apply(struct mbuf *, int, int, | |||||
int (*)(void *, void *, u_int), void *); | |||||
int m_append(struct mbuf *, int, c_caddr_t); | |||||
void m_cat(struct mbuf *, struct mbuf *); | |||||
void m_catpkt(struct mbuf *, struct mbuf *); | |||||
int m_clget(struct mbuf *m, int how); | |||||
void *m_cljget(struct mbuf *m, int how, int size); | |||||
struct mbuf *m_collapse(struct mbuf *, int, int); | |||||
void m_copyback(struct mbuf *, int, int, c_caddr_t); | |||||
void m_copydata(const struct mbuf *, int, int, caddr_t); | |||||
struct mbuf *m_copym(const struct mbuf *, int, int, int); | |||||
struct mbuf *m_copypacket(struct mbuf *, int); | |||||
void m_copy_pkthdr(struct mbuf *, struct mbuf *); | |||||
struct mbuf *m_copyup(struct mbuf *, int, int); | |||||
struct mbuf *m_defrag(struct mbuf *, int); | |||||
void m_demote_pkthdr(struct mbuf *); | |||||
void m_demote(struct mbuf *, int, int); | |||||
struct mbuf *m_devget(char *, int, int, struct ifnet *, | |||||
void (*)(char *, caddr_t, u_int)); | |||||
struct mbuf *m_dup(const struct mbuf *, int); | |||||
int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int); | |||||
int m_extadd(struct mbuf *, caddr_t, u_int, | |||||
void (*)(struct mbuf *, void *, void *), void *, void *, | |||||
int, int, int); | |||||
u_int m_fixhdr(struct mbuf *); | |||||
struct mbuf *m_fragment(struct mbuf *, int, int); | |||||
void m_freem(struct mbuf *); | |||||
struct mbuf *m_get2(int, int, short, int); | |||||
struct mbuf *m_getjcl(int, short, int, int); | |||||
struct mbuf *m_getm2(struct mbuf *, int, int, short, int); | |||||
struct mbuf *m_getptr(struct mbuf *, int, int *); | |||||
u_int m_length(struct mbuf *, struct mbuf **); | |||||
int m_mbuftouio(struct uio *, struct mbuf *, int); | |||||
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); | |||||
void m_print(const struct mbuf *, int); | |||||
struct mbuf *m_pulldown(struct mbuf *, int, int, int *); | |||||
struct mbuf *m_pullup(struct mbuf *, int); | |||||
int m_sanity(struct mbuf *, int); | |||||
struct mbuf *m_split(struct mbuf *, int, int); | |||||
struct mbuf *m_uiotombuf(struct uio *, int, int, int, int); | |||||
struct mbuf *m_unshare(struct mbuf *, int); | |||||
static __inline int | static __inline int | ||||
m_gettype(int size) | m_gettype(int size) | ||||
{ | { | ||||
int type; | int type; | ||||
switch (size) { | switch (size) { | ||||
case MSIZE: | case MSIZE: | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct mb_args args; | struct mb_args args; | ||||
args.flags = flags; | args.flags = flags; | ||||
args.type = type; | args.type = type; | ||||
return (uma_zalloc_arg(zone_pack, &args, how)); | return (uma_zalloc_arg(zone_pack, &args, how)); | ||||
} | } | ||||
static __inline int | |||||
m_clget(struct mbuf *m, int how) | |||||
{ | |||||
KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT", | |||||
__func__, m)); | |||||
m->m_ext.ext_buf = (char *)NULL; | |||||
uma_zalloc_arg(zone_clust, m, how); | |||||
/* | |||||
* On a cluster allocation failure, drain the packet zone and retry, | |||||
* we might be able to loosen a few clusters up on the drain. | |||||
*/ | |||||
if ((how & M_NOWAIT) && (m->m_ext.ext_buf == NULL)) { | |||||
zone_drain(zone_pack); | |||||
uma_zalloc_arg(zone_clust, m, how); | |||||
} | |||||
return (m->m_flags & M_EXT); | |||||
} | |||||
/* | |||||
* m_cljget() is different from m_clget() as it can allocate clusters without | |||||
* attaching them to an mbuf. In that case the return value is the pointer | |||||
* to the cluster of the requested size. If an mbuf was specified, it gets | |||||
* the cluster attached to it and the return value can be safely ignored. | |||||
* For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES. | |||||
*/ | |||||
static __inline void * | |||||
m_cljget(struct mbuf *m, int how, int size) | |||||
{ | |||||
uma_zone_t zone; | |||||
if (m != NULL) { | |||||
KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT", | |||||
__func__, m)); | |||||
m->m_ext.ext_buf = NULL; | |||||
} | |||||
zone = m_getzone(size); | |||||
return (uma_zalloc_arg(zone, m, how)); | |||||
} | |||||
static __inline void | static __inline void | ||||
m_cljset(struct mbuf *m, void *cl, int type) | m_cljset(struct mbuf *m, void *cl, int type) | ||||
{ | { | ||||
uma_zone_t zone; | uma_zone_t zone; | ||||
int size; | int size; | ||||
switch (type) { | switch (type) { | ||||
case EXT_CLUSTER: | case EXT_CLUSTER: | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
/* Compatibility with 4.3. */ | /* Compatibility with 4.3. */ | ||||
#define m_copy(m, o, l) m_copym((m), (o), (l), M_NOWAIT) | #define m_copy(m, o, l) m_copym((m), (o), (l), M_NOWAIT) | ||||
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 */ | ||||
struct uio; | |||||
void m_adj(struct mbuf *, int); | |||||
int m_apply(struct mbuf *, int, int, | |||||
int (*)(void *, void *, u_int), void *); | |||||
int m_append(struct mbuf *, int, c_caddr_t); | |||||
void m_cat(struct mbuf *, struct mbuf *); | |||||
void m_catpkt(struct mbuf *, struct mbuf *); | |||||
int m_extadd(struct mbuf *, caddr_t, u_int, | |||||
void (*)(struct mbuf *, void *, void *), void *, void *, | |||||
int, int, int); | |||||
struct mbuf *m_collapse(struct mbuf *, int, int); | |||||
void m_copyback(struct mbuf *, int, int, c_caddr_t); | |||||
void m_copydata(const struct mbuf *, int, int, caddr_t); | |||||
struct mbuf *m_copym(const struct mbuf *, int, int, int); | |||||
struct mbuf *m_copypacket(struct mbuf *, int); | |||||
void m_copy_pkthdr(struct mbuf *, struct mbuf *); | |||||
struct mbuf *m_copyup(struct mbuf *, int, int); | |||||
struct mbuf *m_defrag(struct mbuf *, int); | |||||
void m_demote_pkthdr(struct mbuf *); | |||||
void m_demote(struct mbuf *, int, int); | |||||
struct mbuf *m_devget(char *, int, int, struct ifnet *, | |||||
void (*)(char *, caddr_t, u_int)); | |||||
struct mbuf *m_dup(const struct mbuf *, int); | |||||
int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int); | |||||
u_int m_fixhdr(struct mbuf *); | |||||
struct mbuf *m_fragment(struct mbuf *, int, int); | |||||
void m_freem(struct mbuf *); | |||||
struct mbuf *m_get2(int, int, short, int); | |||||
struct mbuf *m_getjcl(int, short, int, int); | |||||
struct mbuf *m_getm2(struct mbuf *, int, int, short, int); | |||||
struct mbuf *m_getptr(struct mbuf *, int, int *); | |||||
u_int m_length(struct mbuf *, struct mbuf **); | |||||
int m_mbuftouio(struct uio *, struct mbuf *, int); | |||||
void m_move_pkthdr(struct mbuf *, struct mbuf *); | |||||
struct mbuf *m_prepend(struct mbuf *, int, int); | |||||
void m_print(const struct mbuf *, int); | |||||
struct mbuf *m_pulldown(struct mbuf *, int, int, int *); | |||||
struct mbuf *m_pullup(struct mbuf *, int); | |||||
int m_sanity(struct mbuf *, int); | |||||
struct mbuf *m_split(struct mbuf *, int, int); | |||||
struct mbuf *m_uiotombuf(struct uio *, int, int, int, int); | |||||
struct mbuf *m_unshare(struct mbuf *, int); | |||||
/*- | /*- | ||||
* 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 318 Lines • Show Last 20 Lines |