FD.io VPP  v16.06
Vector Packet Processing
buffer_funcs.h File Reference

vlib buffer access methods. More...

+ Include dependency graph for buffer_funcs.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vlib_packet_template_t
 
union  vlib_buffer_union_t
 

Macros

#define vlib_prefetch_buffer_with_index(vm, bi, type)
 Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header information. More...
 

Enumerations

enum  vlib_buffer_known_state_t { VLIB_BUFFER_UNKNOWN, VLIB_BUFFER_KNOWN_FREE, VLIB_BUFFER_KNOWN_ALLOCATED }
 

Functions

always_inline vlib_buffer_tvlib_get_buffer (vlib_main_t *vm, u32 buffer_index)
 Translate buffer index into buffer pointer. More...
 
always_inline u32 vlib_get_buffer_index (vlib_main_t *vm, void *p)
 Translate buffer pointer into buffer index. More...
 
always_inline vlib_buffer_tvlib_get_next_buffer (vlib_main_t *vm, vlib_buffer_t *b)
 Get next buffer in buffer linklist, or zero for end of list. More...
 
uword vlib_buffer_length_in_chain_slow_path (vlib_main_t *vm, vlib_buffer_t *b_first)
 
always_inline uword vlib_buffer_length_in_chain (vlib_main_t *vm, vlib_buffer_t *b)
 Get length in bytes of the buffer chain. More...
 
always_inline uword vlib_buffer_index_length_in_chain (vlib_main_t *vm, u32 bi)
 Get length in bytes of the buffer index buffer chain. More...
 
always_inline uword vlib_buffer_contents (vlib_main_t *vm, u32 buffer_index, u8 *contents)
 Copy buffer contents to memory. More...
 
always_inline u64 vlib_get_buffer_data_physical_address (vlib_main_t *vm, u32 buffer_index)
 
always_inline vlib_buffer_known_state_t vlib_buffer_is_known (vlib_main_t *vm, u32 buffer_index)
 
always_inline void vlib_buffer_set_known_state (vlib_main_t *vm, u32 buffer_index, vlib_buffer_known_state_t state)
 
u8vlib_validate_buffer (vlib_main_t *vm, u32 buffer_index, uword follow_chain)
 
u8vlib_validate_buffers (vlib_main_t *vm, u32 *buffers, uword next_buffer_stride, uword n_buffers, vlib_buffer_known_state_t known_state, uword follow_chain)
 
clib_error_tvlib_buffer_pool_create (vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
 
u32 vlib_buffer_alloc (vlib_main_t *vm, u32 *buffers, u32 n_buffers)
 Allocate buffers into supplied array. More...
 
always_inline u32 vlib_buffer_round_size (u32 size)
 
u32 vlib_buffer_alloc_from_free_list (vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
 Allocate buffers from specific freelist into supplied array. More...
 
void vlib_buffer_free (vlib_main_t *vm, u32 *buffers, u32 n_buffers)
 Free buffers Frees the entire buffer chain for each buffer. More...
 
void vlib_buffer_free_no_next (vlib_main_t *vm, u32 *buffers, u32 n_buffers)
 Free buffers, does not free the buffer chain for each buffer. More...
 
always_inline void vlib_buffer_free_one (vlib_main_t *vm, u32 buffer_index)
 Free one buffer Shorthand to free a single buffer chain. More...
 
u32 vlib_buffer_create_free_list (vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
 
void vlib_buffer_delete_free_list (vlib_main_t *vm, u32 free_list_index)
 
u32 vlib_buffer_get_or_create_free_list (vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
 
always_inline vlib_buffer_free_list_tvlib_buffer_get_free_list (vlib_main_t *vm, u32 free_list_index)
 
always_inline u32 vlib_buffer_free_list_buffer_size (vlib_main_t *vm, u32 free_list_index)
 
void vlib_aligned_memcpy (void *_dst, void *_src, int n_bytes)
 
always_inline void vlib_copy_buffers (u32 *dst, u32 *src, u32 n)
 
always_inline voidvlib_physmem_alloc_aligned (vlib_main_t *vm, clib_error_t **error, uword n_bytes, uword alignment)
 
always_inline voidvlib_physmem_alloc (vlib_main_t *vm, clib_error_t **error, uword n_bytes)
 
always_inline void vlib_physmem_free (vlib_main_t *vm, void *mem)
 
always_inline u64 vlib_physmem_virtual_to_physical (vlib_main_t *vm, void *mem)
 
u32 vlib_buffer_add_data (vlib_main_t *vm, u32 free_list_index, u32 buffer_index, void *data, u32 n_data_bytes)
 
always_inline void vlib_buffer_chain_init (vlib_buffer_t *first)
 
always_inline vlib_buffer_tvlib_buffer_chain_buffer (vlib_main_t *vm, vlib_buffer_t *first, vlib_buffer_t *last, u32 next_bi)
 
always_inline void vlib_buffer_chain_increase_length (vlib_buffer_t *first, vlib_buffer_t *last, i32 len)
 
always_inline u16 vlib_buffer_chain_append_data (vlib_main_t *vm, u32 free_list_index, vlib_buffer_t *first, vlib_buffer_t *last, void *data, u16 data_len)
 
u16 vlib_buffer_chain_append_data_with_alloc (vlib_main_t *vm, u32 free_list_index, vlib_buffer_t *first, vlib_buffer_t **last, void *data, u16 data_len)
 
void vlib_buffer_chain_validate (vlib_main_t *vm, vlib_buffer_t *first)
 
void vlib_packet_template_get_packet_helper (vlib_main_t *vm, vlib_packet_template_t *t)
 
void vlib_packet_template_init (vlib_main_t *vm, vlib_packet_template_t *t, void *packet_data, uword n_packet_data_bytes, uword min_n_buffers_each_physmem_alloc, char *fmt,...)
 
voidvlib_packet_template_get_packet (vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
 
always_inline void vlib_packet_template_free (vlib_main_t *vm, vlib_packet_template_t *t)
 
always_inline u32 unserialize_vlib_buffer_n_bytes (serialize_main_t *m)
 
always_inline void vlib_buffer_init_for_free_list (vlib_buffer_t *_dst, vlib_buffer_free_list_t *fl)
 
always_inline void vlib_buffer_init_two_for_free_list (vlib_buffer_t *_dst0, vlib_buffer_t *_dst1, vlib_buffer_free_list_t *fl)
 
static void vlib_validate_buffer_in_use (vlib_buffer_t *b, u32 expected)
 
static void vlib_validate_buffer_set_in_use (vlib_buffer_t *b, u32 expected)
 

Variables

format_function_t format_vlib_buffer
 
format_function_t format_vlib_buffer_and_data
 
format_function_t format_vlib_buffer_contents
 
u32vlib_buffer_state_validation_lock
 
uwordvlib_buffer_state_validation_hash
 
voidvlib_buffer_state_heap
 

Detailed Description

vlib buffer access methods.

Definition in file buffer_funcs.h.

Macro Definition Documentation

#define vlib_prefetch_buffer_with_index (   vm,
  bi,
  type 
)
Value:
do { \
vlib_buffer_t * _b = vlib_get_buffer (vm, bi); \
} while (0)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:162
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69

Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header information.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
bi- (u32) buffer index
type- LOAD, STORE. In most cases, STORE is the right answer

Definition at line 181 of file buffer_funcs.h.

Enumeration Type Documentation

Enumerator
VLIB_BUFFER_UNKNOWN 
VLIB_BUFFER_KNOWN_FREE 
VLIB_BUFFER_KNOWN_ALLOCATED 

Definition at line 211 of file buffer_funcs.h.

Function Documentation

always_inline u32 unserialize_vlib_buffer_n_bytes ( serialize_main_t m)

Definition at line 556 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_aligned_memcpy ( void _dst,
void _src,
int  n_bytes 
)

Definition at line 293 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 vlib_buffer_add_data ( vlib_main_t vm,
u32  free_list_index,
u32  buffer_index,
void data,
u32  n_data_bytes 
)

Definition at line 1169 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 vlib_buffer_alloc ( vlib_main_t vm,
u32 buffers,
u32  n_buffers 
)

Allocate buffers into supplied array.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
buffers- (u32 * ) buffer index array
n_buffers- (u32) number of buffers requested
Returns
- (u32) number of buffers actually allocated, may be less than the number requested or zero

Definition at line 770 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 vlib_buffer_alloc_from_free_list ( vlib_main_t vm,
u32 buffers,
u32  n_buffers,
u32  free_list_index 
)

Allocate buffers from specific freelist into supplied array.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
buffers- (u32 * ) buffer index array
n_buffers- (u32) number of buffers requested
Returns
- (u32) number of buffers actually allocated, may be less than the number requested or zero

Definition at line 782 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline u16 vlib_buffer_chain_append_data ( vlib_main_t vm,
u32  free_list_index,
vlib_buffer_t first,
vlib_buffer_t last,
void data,
u16  data_len 
)

Definition at line 485 of file buffer_funcs.h.

+ Here is the call graph for this function:

u16 vlib_buffer_chain_append_data_with_alloc ( vlib_main_t vm,
u32  free_list_index,
vlib_buffer_t first,
vlib_buffer_t **  last,
void data,
u16  data_len 
)

Definition at line 1224 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline vlib_buffer_t* vlib_buffer_chain_buffer ( vlib_main_t vm,
vlib_buffer_t first,
vlib_buffer_t last,
u32  next_bi 
)

Definition at line 435 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vlib_buffer_chain_increase_length ( vlib_buffer_t first,
vlib_buffer_t last,
i32  len 
)

Definition at line 466 of file buffer_funcs.h.

+ Here is the caller graph for this function:

always_inline void vlib_buffer_chain_init ( vlib_buffer_t first)

Definition at line 420 of file buffer_funcs.h.

+ Here is the caller graph for this function:

void vlib_buffer_chain_validate ( vlib_main_t vm,
vlib_buffer_t first 
)

Definition at line 1254 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword vlib_buffer_contents ( vlib_main_t vm,
u32  buffer_index,
u8 contents 
)

Copy buffer contents to memory.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
bi- (u32) buffer index
contents- (u8 *) memory, must be large enough
Returns
- (uword) length of buffer chain

Definition at line 143 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 vlib_buffer_create_free_list ( vlib_main_t vm,
u32  n_data_bytes,
char *  fmt,
  ... 
)

Definition at line 495 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_buffer_delete_free_list ( vlib_main_t vm,
u32  free_list_index 
)

Definition at line 548 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_buffer_free ( vlib_main_t vm,
u32 buffers,
u32  n_buffers 
)

Free buffers Frees the entire buffer chain for each buffer.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
buffers- (u32 * ) buffer index array
n_buffers- (u32) number of buffers to free

Definition at line 1060 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline u32 vlib_buffer_free_list_buffer_size ( vlib_main_t vm,
u32  free_list_index 
)

Definition at line 346 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_buffer_free_no_next ( vlib_main_t vm,
u32 buffers,
u32  n_buffers 
)

Free buffers, does not free the buffer chain for each buffer.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
buffers- (u32 * ) buffer index array
n_buffers- (u32) number of buffers to free

Definition at line 1067 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vlib_buffer_free_one ( vlib_main_t vm,
u32  buffer_index 
)

Free one buffer Shorthand to free a single buffer chain.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
buffer_index- (u32) buffer index to free

Definition at line 319 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline vlib_buffer_free_list_t* vlib_buffer_get_free_list ( vlib_main_t vm,
u32  free_list_index 
)

Definition at line 332 of file buffer_funcs.h.

+ Here is the caller graph for this function:

u32 vlib_buffer_get_or_create_free_list ( vlib_main_t vm,
u32  n_data_bytes,
char *  fmt,
  ... 
)

Definition at line 511 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword vlib_buffer_index_length_in_chain ( vlib_main_t vm,
u32  bi 
)

Get length in bytes of the buffer index buffer chain.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
bi- (u32) buffer index
Returns
- (uword) length of buffer chain

Definition at line 129 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vlib_buffer_init_for_free_list ( vlib_buffer_t _dst,
vlib_buffer_free_list_t fl 
)

Definition at line 591 of file buffer_funcs.h.

+ Here is the caller graph for this function:

always_inline void vlib_buffer_init_two_for_free_list ( vlib_buffer_t _dst0,
vlib_buffer_t _dst1,
vlib_buffer_free_list_t fl 
)

Definition at line 623 of file buffer_funcs.h.

+ Here is the caller graph for this function:

always_inline vlib_buffer_known_state_t vlib_buffer_is_known ( vlib_main_t vm,
u32  buffer_index 
)

Definition at line 221 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline uword vlib_buffer_length_in_chain ( vlib_main_t vm,
vlib_buffer_t b 
)

Get length in bytes of the buffer chain.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
b- (void *) buffer pointer
Returns
- (uword) length of buffer chain

Definition at line 112 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uword vlib_buffer_length_in_chain_slow_path ( vlib_main_t vm,
vlib_buffer_t b_first 
)

Definition at line 42 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

clib_error_t* vlib_buffer_pool_create ( vlib_main_t vm,
unsigned  num_mbufs,
unsigned  socket_id 
)

Definition at line 934 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline u32 vlib_buffer_round_size ( u32  size)

Definition at line 269 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vlib_buffer_set_known_state ( vlib_main_t vm,
u32  buffer_index,
vlib_buffer_known_state_t  state 
)

Definition at line 231 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vlib_copy_buffers ( u32 dst,
u32 src,
u32  n 
)

Definition at line 357 of file buffer_funcs.h.

+ Here is the caller graph for this function:

always_inline vlib_buffer_t* vlib_get_buffer ( vlib_main_t vm,
u32  buffer_index 
)

Translate buffer index into buffer pointer.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
buffer_index- (u32) buffer index
Returns
- (vlib_buffer_t *) buffer pointer

Definition at line 69 of file buffer_funcs.h.

+ Here is the call graph for this function:

always_inline u64 vlib_get_buffer_data_physical_address ( vlib_main_t vm,
u32  buffer_index 
)

Definition at line 165 of file buffer_funcs.h.

+ Here is the call graph for this function:

always_inline u32 vlib_get_buffer_index ( vlib_main_t vm,
void p 
)

Translate buffer pointer into buffer index.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
b- (void *) buffer pointer
Returns
- (u32) buffer index

Definition at line 82 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline vlib_buffer_t* vlib_get_next_buffer ( vlib_main_t vm,
vlib_buffer_t b 
)

Get next buffer in buffer linklist, or zero for end of list.

Parameters
vm- (vlib_main_t *) vlib main data structure pointer
b- (void *) buffer pointer
Returns
- (vlib_buffer_t *) next buffer, or NULL

Definition at line 96 of file buffer_funcs.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void vlib_packet_template_free ( vlib_main_t vm,
vlib_packet_template_t t 
)

Definition at line 550 of file buffer_funcs.h.

void* vlib_packet_template_get_packet ( vlib_main_t vm,
vlib_packet_template_t t,
u32 bi_result 
)

Definition at line 1133 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_packet_template_get_packet_helper ( vlib_main_t vm,
vlib_packet_template_t t 
)

Definition at line 1153 of file buffer.c.

+ Here is the call graph for this function:

void vlib_packet_template_init ( vlib_main_t vm,
vlib_packet_template_t t,
void packet_data,
uword  n_packet_data_bytes,
uword  min_n_buffers_each_physmem_alloc,
char *  fmt,
  ... 
)

Definition at line 1093 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

always_inline void* vlib_physmem_alloc ( vlib_main_t vm,
clib_error_t **  error,
uword  n_bytes 
)

Definition at line 392 of file buffer_funcs.h.

+ Here is the call graph for this function:

always_inline void* vlib_physmem_alloc_aligned ( vlib_main_t vm,
clib_error_t **  error,
uword  n_bytes,
uword  alignment 
)

Definition at line 379 of file buffer_funcs.h.

+ Here is the caller graph for this function:

always_inline void vlib_physmem_free ( vlib_main_t vm,
void mem 
)

Definition at line 396 of file buffer_funcs.h.

always_inline u64 vlib_physmem_virtual_to_physical ( vlib_main_t vm,
void mem 
)

Definition at line 400 of file buffer_funcs.h.

+ Here is the call graph for this function:

u8* vlib_validate_buffer ( vlib_main_t vm,
u32  buffer_index,
uword  follow_chain 
)

Definition at line 189 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_validate_buffer_in_use ( vlib_buffer_t b,
u32  expected 
)
inlinestatic

Definition at line 659 of file buffer_funcs.h.

+ Here is the call graph for this function:

static void vlib_validate_buffer_set_in_use ( vlib_buffer_t b,
u32  expected 
)
inlinestatic

Definition at line 704 of file buffer_funcs.h.

+ Here is the call graph for this function:

u8* vlib_validate_buffers ( vlib_main_t vm,
u32 buffers,
uword  next_buffer_stride,
uword  n_buffers,
vlib_buffer_known_state_t  known_state,
uword  follow_chain 
)

Definition at line 193 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

format_function_t format_vlib_buffer

Definition at line 516 of file buffer_funcs.h.

format_function_t format_vlib_buffer_and_data

Definition at line 516 of file buffer_funcs.h.

format_function_t format_vlib_buffer_contents

Definition at line 516 of file buffer_funcs.h.

void* vlib_buffer_state_heap

Definition at line 655 of file buffer_funcs.h.

uword* vlib_buffer_state_validation_hash

Definition at line 654 of file buffer_funcs.h.

u32* vlib_buffer_state_validation_lock

Definition at line 653 of file buffer_funcs.h.