Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/mbuf.h
Show All 32 Lines | |||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _SYS_MBUF_H_ | #ifndef _SYS_MBUF_H_ | ||||
#define _SYS_MBUF_H_ | #define _SYS_MBUF_H_ | ||||
/* XXX: These includes suck. Sorry! */ | /* XXX: These includes suck. Sorry! */ | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#ifdef _KERNEL | #if defined(_KERNEL) || defined(_KERNEL_UT) | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/refcount.h> | #include <sys/refcount.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#ifdef WITNESS | #ifdef WITNESS | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#endif | #endif | ||||
#endif | #endif | ||||
#ifdef _KERNEL | #if defined(_KERNEL) || defined(_KERNEL_UT) | ||||
vangyzen: You could remove this `#endif / #if` pair. | |||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#define MBUF_PROBE1(probe, arg0) \ | #define MBUF_PROBE1(probe, arg0) \ | ||||
SDT_PROBE1(sdt, , , probe, arg0) | SDT_PROBE1(sdt, , , probe, arg0) | ||||
#define MBUF_PROBE2(probe, arg0, arg1) \ | #define MBUF_PROBE2(probe, arg0, arg1) \ | ||||
SDT_PROBE2(sdt, , , probe, arg0, arg1) | SDT_PROBE2(sdt, , , probe, arg0, arg1) | ||||
#define MBUF_PROBE3(probe, arg0, arg1, arg2) \ | #define MBUF_PROBE3(probe, arg0, arg1, arg2) \ | ||||
SDT_PROBE3(sdt, , , probe, arg0, arg1, arg2) | SDT_PROBE3(sdt, , , probe, arg0, arg1, arg2) | ||||
Show All 10 Lines | |||||
SDT_PROBE_DECLARE(sdt, , , m__getcl); | SDT_PROBE_DECLARE(sdt, , , m__getcl); | ||||
SDT_PROBE_DECLARE(sdt, , , m__getjcl); | SDT_PROBE_DECLARE(sdt, , , m__getjcl); | ||||
SDT_PROBE_DECLARE(sdt, , , m__clget); | SDT_PROBE_DECLARE(sdt, , , m__clget); | ||||
SDT_PROBE_DECLARE(sdt, , , m__cljget); | SDT_PROBE_DECLARE(sdt, , , m__cljget); | ||||
SDT_PROBE_DECLARE(sdt, , , m__cljset); | SDT_PROBE_DECLARE(sdt, , , m__cljset); | ||||
SDT_PROBE_DECLARE(sdt, , , m__free); | SDT_PROBE_DECLARE(sdt, , , m__free); | ||||
SDT_PROBE_DECLARE(sdt, , , m__freem); | SDT_PROBE_DECLARE(sdt, , , m__freem); | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL || _KERNEL_UT */ | ||||
/* | /* | ||||
* Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead. | * Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead. | ||||
* An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in | * An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in | ||||
* sys/param.h), which has no additional overhead and is used instead of the | * sys/param.h), which has no additional overhead and is used instead of the | ||||
* internal data area; this is done when at least MINCLSIZE of data must be | * internal data area; this is done when at least MINCLSIZE of data must be | ||||
* stored. Additionally, it is possible to allocate a separate buffer | * stored. Additionally, it is possible to allocate a separate buffer | ||||
* externally and attach it to the mbuf in a way similar to that of mbuf | * externally and attach it to the mbuf in a way similar to that of mbuf | ||||
Show All 13 Lines | |||||
struct mbuf; | struct mbuf; | ||||
#define MHSIZE offsetof(struct mbuf, m_dat) | #define MHSIZE offsetof(struct mbuf, m_dat) | ||||
#define MPKTHSIZE offsetof(struct mbuf, m_pktdat) | #define MPKTHSIZE offsetof(struct mbuf, m_pktdat) | ||||
#define MLEN ((int)(MSIZE - MHSIZE)) | #define MLEN ((int)(MSIZE - MHSIZE)) | ||||
#define MHLEN ((int)(MSIZE - MPKTHSIZE)) | #define MHLEN ((int)(MSIZE - MPKTHSIZE)) | ||||
#define MINCLSIZE (MHLEN + 1) | #define MINCLSIZE (MHLEN + 1) | ||||
#define M_NODOM 255 | #define M_NODOM 255 | ||||
#ifdef _KERNEL | #if defined(_KERNEL) || defined(_KERNEL_UT) | ||||
/*- | /*- | ||||
* Macro for type conversion: convert mbuf pointer to data pointer of correct | * Macro for type conversion: convert mbuf pointer to data pointer of correct | ||||
* type: | * type: | ||||
* | * | ||||
* mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. | * mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. | ||||
* mtodo(m, o) -- Same as above but with offset 'o' into data. | * mtodo(m, o) -- Same as above but with offset 'o' into data. | ||||
*/ | */ | ||||
#define mtod(m, t) ((t)((m)->m_data)) | #define mtod(m, t) ((t)((m)->m_data)) | ||||
#define mtodo(m, o) ((void *)(((m)->m_data) + (o))) | #define mtodo(m, o) ((void *)(((m)->m_data) + (o))) | ||||
/* | /* | ||||
* Argument structure passed to UMA routines during mbuf and packet | * Argument structure passed to UMA routines during mbuf and packet | ||||
* allocations. | * allocations. | ||||
*/ | */ | ||||
struct mb_args { | struct mb_args { | ||||
int flags; /* Flags for mbuf being allocated */ | int flags; /* Flags for mbuf being allocated */ | ||||
short type; /* Type of mbuf being allocated */ | short type; /* Type of mbuf being allocated */ | ||||
}; | }; | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL || _KERNEL_UT */ | ||||
/* | /* | ||||
* Packet tag structure (see below for details). | * Packet tag structure (see below for details). | ||||
*/ | */ | ||||
struct m_tag { | struct m_tag { | ||||
SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ | SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ | ||||
u_int16_t m_tag_id; /* Tag ID */ | u_int16_t m_tag_id; /* Tag ID */ | ||||
u_int16_t m_tag_len; /* Length of data */ | u_int16_t m_tag_len; /* Length of data */ | ||||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Lines | #define EPG_FLAG_2FREE 0x2 /* Scheduled for free. */ | ||||
/* M_PKTHDR set, neither M_EXT nor M_EXTPG. */ | /* M_PKTHDR set, neither M_EXT nor M_EXTPG. */ | ||||
char m_pktdat[0]; | char m_pktdat[0]; | ||||
}; | }; | ||||
}; | }; | ||||
char m_dat[0]; /* !M_PKTHDR, !M_EXT */ | char m_dat[0]; /* !M_PKTHDR, !M_EXT */ | ||||
}; | }; | ||||
}; | }; | ||||
#ifdef _KERNEL | #if defined(_KERNEL) || defined(_KERNEL_UT) | ||||
static inline int | static inline int | ||||
m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) | m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff) | ||||
{ | { | ||||
KASSERT(pgoff == 0 || pidx == 0, | KASSERT(pgoff == 0 || pidx == 0, | ||||
("page %d with non-zero offset %d in %p", pidx, pgoff, m)); | ("page %d with non-zero offset %d in %p", pidx, pgoff, m)); | ||||
if (pidx == m->m_epg_npgs - 1) { | if (pidx == m->m_epg_npgs - 1) { | ||||
▲ Show 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | |||||
#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" | #define MBUF_EXTPGS_MEM_NAME "mbuf_extpgs" | ||||
#ifdef _KERNEL | #if defined(_KERNEL) || defined(_KERNEL_UT) | ||||
union if_snd_tag_alloc_params; | union if_snd_tag_alloc_params; | ||||
#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) | ||||
▲ Show 20 Lines • Show All 892 Lines • ▼ Show 20 Lines | mbuf_has_tls_session(struct mbuf *m) | ||||
if (m->m_flags & M_EXTPG) { | if (m->m_flags & M_EXTPG) { | ||||
if (m->m_epg_tls != NULL) { | if (m->m_epg_tls != NULL) { | ||||
return (true); | return (true); | ||||
} | } | ||||
} | } | ||||
return (false); | return (false); | ||||
} | } | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL || _KERNEL_UT */ | ||||
#endif /* !_SYS_MBUF_H_ */ | #endif /* !_SYS_MBUF_H_ */ |
You could remove this #endif / #if pair.