40 #ifndef included_vlib_buffer_h 41 #define included_vlib_buffer_h 50 #include <vlib/config.h> 51 #define VLIB_BUFFER_DATA_SIZE (2048) 52 #define VLIB_BUFFER_PRE_DATA_SIZE __PRE_DATA_SIZE 57 #define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE (128) 60 #define VLIB_BUFFER_CLONE_HEAD_SIZE (256) 74 #define foreach_vlib_buffer_flag \ 75 _( 0, NON_DEFAULT_FREELIST, "non-default-fl") \ 77 _( 2, NEXT_PRESENT, 0) \ 78 _( 3, TOTAL_LENGTH_VALID, 0) \ 79 _( 4, EXT_HDR_VALID, "ext-hdr-valid") 86 #define _(bit, name, v) VLIB_BUFFER_##name = (1 << (bit)), 93 #define _(bit, name, v) VLIB_BUFFER_LOG2_##name = (bit), 99 #define LOG2_VLIB_BUFFER_FLAG_USER(n) (32 - (n)) 100 #define VLIB_BUFFER_FLAG_USER(n) (1 << LOG2_VLIB_BUFFER_FLAG_USER(n)) 178 #define VLIB_BUFFER_HDR_SIZE (sizeof(vlib_buffer_t) - VLIB_BUFFER_PRE_DATA_SIZE) 187 #define vlib_prefetch_buffer_header(b,type) CLIB_PREFETCH (b, 64, type) 192 ASSERT (
sizeof (b[0]) % 64 == 0);
224 ASSERT ((b->
flags & VLIB_BUFFER_NEXT_PRESENT) == 0 ||
261 return (
void *) b->
opaque;
353 vlib_buffer_free_list_index_t
index;
384 uword min_free_buffers);
388 u32 * buffers,
u32 n_buffers);
397 uword n_packet_data_bytes,
399 min_n_buffers_each_physmem_alloc,
402 vlib_buffer_free_list_index_t
439 u32 n_buffers,
u32 follow_buffer_next);
440 #define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX (0) 441 #define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES VLIB_BUFFER_DATA_SIZE 538 #define VLIB_BUFFER_TRACE_TRAJECTORY 0 540 #if VLIB_BUFFER_TRACE_TRAJECTORY > 0 542 extern void (*vlib_buffer_trace_trajectory_init_cb) (
vlib_buffer_t * b);
543 extern void vlib_buffer_trace_trajectory_init (
vlib_buffer_t * b);
544 #define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b) \ 545 vlib_buffer_trace_trajectory_init (b); 547 #define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b) 552 #define VLIB_BUFFER_REGISTER_CALLBACKS(x,...) \ 553 __VA_ARGS__ vlib_buffer_callbacks_t __##x##_buffer_callbacks; \ 554 static void __vlib_add_buffer_callbacks_t_##x (void) \ 555 __attribute__((__constructor__)) ; \ 556 static void __vlib_add_buffer_callbacks_t_##x (void) \ 558 if (vlib_buffer_callbacks) \ 559 clib_panic ("vlib buffer callbacks already registered"); \ 560 vlib_buffer_callbacks = &__##x##_buffer_callbacks; \ 562 static void __vlib_rm_buffer_callbacks_t_##x (void) \ 563 __attribute__((__destructor__)) ; \ 564 static void __vlib_rm_buffer_callbacks_t_##x (void) \ 565 { vlib_buffer_callbacks = 0; } \ 566 __VA_ARGS__ vlib_buffer_callbacks_t __##x##_buffer_callbacks
vlib_physmem_region_index_t physmem_region
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
static u8 * vlib_buffer_get_tail(vlib_buffer_t *b)
Get pointer to the end of buffer's data.
u32 max_n_data_bytes_per_chain
static void vlib_buffer_reset(vlib_buffer_t *b)
Reset current header & length to state they were in when packet was received.
u32 current_config_index
Used by feature subgraph arcs to visit enabled feature nodes.
vlib_buffer_free_list_index_t free_list_index
u32 opaque[10]
Opaque data used by sub-graphs for their own purposes.
vlib_buffer_callbacks_t cb
vlib_buffer_t buffer_init_template
struct vlib_main_t * vlib_main
#define VLIB_BUFFER_PRE_DATA_SIZE
u8 buffer_pool_index
index of buffer pool this buffer belongs.
#define STRUCT_MARK(mark)
u32 recycle_count
Used by L2 path recycle code.
void unserialize_open_vlib_buffer(serialize_main_t *m, struct vlib_main_t *vm, vlib_serialize_buffer_main_t *sm)
void unserialize_close_vlib_buffer(serialize_main_t *m)
void( vlib_buffer_free_cb_t)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
vlib_buffer_free_list_index_t index
u32 serialize_close_vlib_buffer(serialize_main_t *m)
u8 vlib_buffer_pool_create(struct vlib_main_t *vm, vlib_physmem_region_index_t region, u16 buffer_size)
vlib_buffer_main_t buffer_main
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define static_always_inline
void(* buffer_init_function)(struct vlib_main_t *vm, struct vlib_buffer_free_list_t *fl, u32 *buffers, u32 n_buffers)
void serialize_open_vlib_buffer(serialize_main_t *m, struct vlib_main_t *vm, vlib_serialize_buffer_main_t *sm)
void * vlib_set_buffer_free_callback(struct vlib_main_t *vm, void *fp)
vlib_buffer_free_no_next_cb_t * vlib_buffer_free_no_next_cb
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 pre_data[VLIB_BUFFER_PRE_DATA_SIZE]
Space for inserting data before buffer start.
static u32 serialize_vlib_buffer_n_bytes(serialize_main_t *m)
u16 current_length
Nbytes between current data and the end of this buffer.
static void * vlib_buffer_make_headroom(vlib_buffer_t *b, u8 size)
Make head room, typically for packet headers.
static void * vlib_buffer_put_uninit(vlib_buffer_t *b, u8 size)
Append uninitialized data to buffer.
uword ready_one_time_event
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vlib_buffer_pool_t * buffer_pools
vlib_error_t error
Error code for buffers to be enqueued to error handler.
serialize_stream_t stream
clib_spinlock_t buffer_known_hash_lockp
vlib_buffer_fill_free_list_cb_t * vlib_buffer_fill_free_list_cb
u32 flow_id
Generic flow identifier.
static void * vlib_get_buffer_opaque2(vlib_buffer_t *b)
Get pointer to buffer's opaque2 data array.
uword data_function_opaque
void( vlib_buffer_free_no_next_cb_t)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
#define uword_to_pointer(u, type)
vlib_buffer_free_cb_t * vlib_buffer_free_cb
u32 next_buffer
Next buffer for this linked-list of buffers.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
u8 n_add_refs
Number of additional references to this buffer.
struct vlib_serialize_buffer_main_t::@32::@34 tx
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
static void * vlib_buffer_push_uninit(vlib_buffer_t *b, u8 size)
Prepend uninitialized data to buffer.
static u8 vlib_buffer_has_space(vlib_buffer_t *b, word l)
Check if there is enough space in buffer to advance.
u32 opaque2[12]
More opaque data, see ../vnet/vnet/buffer.h.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 min_n_buffers_each_alloc
static void * vlib_get_buffer_opaque(vlib_buffer_t *b)
Get pointer to buffer's opaque data array.
uword * buffer_known_hash
#define VLIB_BUFFER_MIN_CHAIN_SEG_SIZE
clib_error_t * vlib_buffer_main_init(struct vlib_main_t *vm)
static void * vlib_buffer_pull(vlib_buffer_t *b, u8 size)
Retrieve bytes from buffer head.
static_always_inline vlib_buffer_pool_t * vlib_buffer_pool_get(u8 buffer_pool_index)
u8 vlib_buffer_free_list_index_t
#define foreach_vlib_buffer_flag
Buffer Flags.
uword buffer_init_function_opaque
uword( vlib_buffer_fill_free_list_cb_t)(struct vlib_main_t *vm, vlib_buffer_free_list_t *fl, uword min_free_buffers)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
u8 vlib_physmem_region_index_t
static void vlib_buffer_struct_is_sane(vlib_buffer_t *b)
u32 trace_index
Specifies index into trace buffer if VLIB_PACKET_IS_TRACED flag is set.
uword * free_list_by_size
vlib_buffer_callbacks_t * vlib_buffer_callbacks
vlib_buffer_free_list_index_t free_list_index