|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
40 #ifndef included_vlib_buffer_h
41 #define included_vlib_buffer_h
50 #include <vlib/config.h>
51 #define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE
53 #define VLIB_BUFFER_DEFAULT_DATA_SIZE (2048)
58 #define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE (128)
61 #define VLIB_BUFFER_CLONE_HEAD_SIZE (256)
73 #define foreach_vlib_buffer_flag \
75 _( 1, NEXT_PRESENT, "next-present") \
76 _( 2, TOTAL_LENGTH_VALID, 0) \
77 _( 3, EXT_HDR_VALID, "ext-hdr-valid")
84 #define _(bit, name, v) VLIB_BUFFER_##name = (1 << (bit)),
91 #define _(bit, name, v) VLIB_BUFFER_LOG2_##name = (bit),
97 #define LOG2_VLIB_BUFFER_FLAG_USER(n) (32 - (n))
98 #define VLIB_BUFFER_FLAG_USER(n) (1 << LOG2_VLIB_BUFFER_FLAG_USER(n))
99 #define VLIB_BUFFER_FLAGS_ALL (0x0f)
106 #ifndef VLIB_BUFFER_TRACE_TRAJECTORY
107 #define VLIB_BUFFER_TRACE_TRAJECTORY 0
181 #if VLIB_BUFFER_TRACE_TRAJECTORY > 0
184 #define VLIB_BUFFER_TRACE_TRAJECTORY_MAX 31
185 #define VLIB_BUFFER_TRACE_TRAJECTORY_SZ 64
186 #define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b) (b)->trajectory_nb = 0
189 u16 trajectory_trace[VLIB_BUFFER_TRACE_TRAJECTORY_MAX];
191 #define VLIB_BUFFER_TRACE_TRAJECTORY_SZ 0
192 #define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
206 #ifdef CLIB_HAVE_VEC128
209 #ifdef CLIB_HAVE_VEC256
212 #ifdef CLIB_HAVE_VEC512
220 "VLIB_BUFFER_PRE_DATA_SIZE must be divisible by cache line size");
222 #define VLIB_BUFFER_HDR_SIZE (sizeof(vlib_buffer_t) - VLIB_BUFFER_PRE_DATA_SIZE)
231 #define vlib_prefetch_buffer_header(b,type) CLIB_PREFETCH (b, 64, type)
232 #define vlib_prefetch_buffer_data(b,type) \
233 CLIB_PREFETCH (vlib_buffer_get_current(b), CLIB_CACHE_LINE_BYTES, type)
238 ASSERT (
sizeof (
b[0]) % 64 == 0);
394 ASSERT (pool_index < 0x00FFFFFF);
395 rv = (
thread << 24) | (pool_index & 0x00FFFFFF);
408 return trace_handle >> 24;
419 return trace_handle & 0x00FFFFFF;
441 #define VLIB_BUFFER_POOL_PER_THREAD_CACHE_SZ 512
473 #define VLIB_BUFFER_MAX_NUMA_NODES 32
504 extern u16 __vlib_buffer_external_hdr_size;
505 #define VLIB_BUFFER_SET_EXT_HDR_SIZE(x) \
506 static void __clib_constructor \
507 vnet_buffer_set_ext_hdr_size() \
509 if (__vlib_buffer_external_hdr_size) \
510 clib_error ("buffer external header space already set"); \
511 __vlib_buffer_external_hdr_size = CLIB_CACHE_LINE_ROUND (x); \
u32 next_buffer
Next buffer for this linked-list of buffers.
u8 buffer_pool_index
index of buffer pool this buffer belongs.
static void * vlib_get_buffer_opaque2(vlib_buffer_t *b)
Get pointer to buffer's opaque2 data array.
static void * vlib_buffer_put_uninit(vlib_buffer_t *b, u16 size)
Append uninitialized data to buffer.
#define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE
#define VLIB_BUFFER_TRACE_TRAJECTORY_SZ
static uword pointer_to_uword(const void *p)
clib_error_t * vlib_buffer_main_init(struct vlib_main_t *vm)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
static void * vlib_buffer_pull(vlib_buffer_t *b, u8 size)
Retrieve bytes from buffer head.
static void * vlib_get_buffer_opaque(vlib_buffer_t *b)
Get pointer to buffer's opaque data array.
pthread_t thread[MAX_CONNS]
static void vlib_buffer_struct_is_sane(vlib_buffer_t *b)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
u32 trace_handle
Specifies trace buffer handle if VLIB_PACKET_IS_TRACED flag is set.
static u32 vlib_buffer_get_trace_thread(vlib_buffer_t *b)
Extract the thread id from a trace handle.
clib_mem_page_sz_t log2_page_size
#define CLIB_ALIGN_MARK(name, alignment)
static uword vlib_buffer_get_va(vlib_buffer_t *b)
static u8 vlib_buffer_has_space(vlib_buffer_t *b, word l)
Check if there is enough space in buffer to advance.
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
vlib_buffer_pool_thread_t * threads
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
vlib_log_class_t log_default
STATIC_ASSERT(((VNET_BUFFER_FLAGS_ALL_AVAIL &VLIB_BUFFER_FLAGS_ALL)==0), "VLIB / VNET buffer flags overlap")
vlib_buffer_t buffer_template
#define VLIB_BUFFER_MAX_NUMA_NODES
volatile u8 ref_count
Reference count for this buffer.
clib_spinlock_t buffer_known_hash_lockp
u32 flow_id
Generic flow identifier.
#define CLIB_CACHE_LINE_BYTES
u16 current_length
Nbytes between current data and the end of this buffer.
static u32 vlib_buffer_make_trace_handle(u32 thread, u32 pool_index)
Construct a trace handle from thread and pool index.
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
static void * vlib_buffer_push_uninit(vlib_buffer_t *b, u8 size)
Prepend uninitialized data to buffer.
#define foreach_vlib_buffer_flag
Buffer Flags.
vlib_buffer_pool_t * buffer_pools
static u8 * vlib_buffer_get_tail(vlib_buffer_t *b)
Get pointer to the end of buffer's data.
#define VLIB_BUFFER_PRE_DATA_SIZE
static void * vlib_buffer_make_headroom(vlib_buffer_t *b, u8 size)
Make head room, typically for packet headers.
uword * buffer_known_hash
#define STRUCT_MARK(mark)
static uword vlib_buffer_get_current_va(vlib_buffer_t *b)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
static void vlib_buffer_reset(vlib_buffer_t *b)
Reset current header & length to state they were in when packet was received.
static u32 vlib_buffer_get_trace_index(vlib_buffer_t *b)
Extract the trace (pool) index from a trace handle.
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
u32 opaque[10]
Opaque data used by sub-graphs for their own purposes.
STATIC_ASSERT_SIZEOF(vlib_buffer_t, 128+VLIB_BUFFER_TRACE_TRAJECTORY_SZ+VLIB_BUFFER_PRE_DATA_SIZE)
#define VLIB_BUFFER_POOL_PER_THREAD_CACHE_SZ
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.