FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
dpdk_buffer.c File Reference

Allocate/free network buffers with DPDK. More...

+ Include dependency graph for dpdk_buffer.c:

Go to the source code of this file.

Macros

#define BUFFERS_PER_COPY   (sizeof (vlib_copy_unit_t) / sizeof (u32))
 

Functions

uword vlib_buffer_length_in_chain_slow_path (vlib_main_t *vm, vlib_buffer_t *b_first)
 
u8format_vlib_buffer (u8 *s, va_list *args)
 
u8format_vlib_buffer_and_data (u8 *s, va_list *args)
 
u8format_vlib_buffer_contents (u8 *s, va_list *va)
 
void vlib_aligned_memcpy (void *_dst, void *_src, int n_bytes)
 
static void fill_unaligned (vlib_main_t *vm, vlib_buffer_free_list_t *free_list, uword n_unaligned_buffers)
 
static void trim_aligned (vlib_buffer_free_list_t *f)
 
static void merge_free_lists (vlib_buffer_free_list_t *dst, vlib_buffer_free_list_t *src)
 
static u32 vlib_buffer_get_free_list_with_size (vlib_main_t *vm, u32 size)
 
static u32 vlib_buffer_create_free_list_helper (vlib_main_t *vm, u32 n_data_bytes, u32 is_public, u32 is_default, u8 *name)
 
u32 vlib_buffer_create_free_list (vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
 
u32 vlib_buffer_get_or_create_free_list (vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
 
static void del_free_list (vlib_main_t *vm, vlib_buffer_free_list_t *f)
 
void vlib_buffer_delete_free_list (vlib_main_t *vm, u32 free_list_index)
 
static uword fill_free_list (vlib_main_t *vm, vlib_buffer_free_list_t *fl, uword min_free_buffers)
 
static uword copy_alignment (u32 *x)
 
static u32 alloc_from_free_list (vlib_main_t *vm, vlib_buffer_free_list_t *free_list, u32 *alloc_buffers, u32 n_alloc_buffers)
 
u32 vlib_buffer_alloc (vlib_main_t *vm, u32 *buffers, u32 n_buffers)
 Allocate buffers into supplied array. More...
 
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...
 
static void add_buffer_to_free_list (vlib_main_t *vm, vlib_buffer_free_list_t *f, u32 buffer_index, u8 do_init)
 
static vlib_buffer_free_list_tbuffer_get_free_list (vlib_main_t *vm, vlib_buffer_t *b, u32 *index)
 
void * vlib_set_buffer_free_callback (vlib_main_t *vm, void *fp)
 
static_always_inline void vlib_buffer_free_inline (vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 follow_buffer_next)
 
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...
 
static void vlib_packet_template_buffer_init (vlib_main_t *vm, vlib_buffer_free_list_t *fl, u32 *buffers, u32 n_buffers)
 
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,...)
 
void * vlib_packet_template_get_packet (vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
 
u32 vlib_buffer_add_data (vlib_main_t *vm, u32 free_list_index, u32 buffer_index, void *data, u32 n_data_bytes)
 
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 *b_first)
 
clib_error_tvlib_buffer_pool_create (vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
 
static void vlib_serialize_tx (serialize_main_header_t *m, serialize_stream_t *s)
 
static void vlib_serialize_rx (serialize_main_header_t *m, serialize_stream_t *s)
 
static void serialize_open_vlib_helper (serialize_main_t *m, vlib_main_t *vm, vlib_serialize_buffer_main_t *sm, uword is_read)
 
void serialize_open_vlib_buffer (serialize_main_t *m, vlib_main_t *vm, vlib_serialize_buffer_main_t *sm)
 
void unserialize_open_vlib_buffer (serialize_main_t *m, vlib_main_t *vm, vlib_serialize_buffer_main_t *sm)
 
u32 serialize_close_vlib_buffer (serialize_main_t *m)
 
void unserialize_close_vlib_buffer (serialize_main_t *m)
 
static u8format_vlib_buffer_free_list (u8 *s, va_list *va)
 
static clib_error_tshow_buffers (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
 
static clib_error_tbuffer_state_validation_init (vlib_main_t *vm)
 

Variables

vlib_main_t ** vlib_mains
 
static vlib_cli_command_t show_buffers_command
 (constructor) VLIB_CLI_COMMAND (show_buffers_command) More...
 
u32vlib_buffer_state_validation_lock
 
uwordvlib_buffer_state_validation_hash
 
void * vlib_buffer_state_heap
 

Detailed Description

Allocate/free network buffers with DPDK.

Definition in file dpdk_buffer.c.

Macro Definition Documentation

#define BUFFERS_PER_COPY   (sizeof (vlib_copy_unit_t) / sizeof (u32))

Definition at line 221 of file dpdk_buffer.c.

Function Documentation

static void add_buffer_to_free_list ( vlib_main_t vm,
vlib_buffer_free_list_t f,
u32  buffer_index,
u8  do_init 
)
inlinestatic

Definition at line 666 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 alloc_from_free_list ( vlib_main_t vm,
vlib_buffer_free_list_t free_list,
u32 alloc_buffers,
u32  n_alloc_buffers 
)
static

Definition at line 529 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static vlib_buffer_free_list_t* buffer_get_free_list ( vlib_main_t vm,
vlib_buffer_t b,
u32 index 
)
inlinestatic

Definition at line 679 of file dpdk_buffer.c.

+ Here is the caller graph for this function:

static clib_error_t* buffer_state_validation_init ( vlib_main_t vm)
static

Definition at line 1353 of file dpdk_buffer.c.

+ Here is the call graph for this function:

static uword copy_alignment ( u32 x)
inlinestatic

Definition at line 523 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void del_free_list ( vlib_main_t vm,
vlib_buffer_free_list_t f 
)
static

Definition at line 407 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uword fill_free_list ( vlib_main_t vm,
vlib_buffer_free_list_t fl,
uword  min_free_buffers 
)
static

Definition at line 459 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void fill_unaligned ( vlib_main_t vm,
vlib_buffer_free_list_t free_list,
uword  n_unaligned_buffers 
)
static

Definition at line 225 of file dpdk_buffer.c.

+ Here is the caller graph for this function:

u8* format_vlib_buffer ( u8 s,
va_list *  args 
)

Definition at line 99 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u8* format_vlib_buffer_and_data ( u8 s,
va_list *  args 
)

Definition at line 129 of file dpdk_buffer.c.

+ Here is the call graph for this function:

u8* format_vlib_buffer_contents ( u8 s,
va_list *  va 
)

Definition at line 141 of file dpdk_buffer.c.

+ Here is the call graph for this function:

static u8* format_vlib_buffer_free_list ( u8 s,
va_list *  va 
)
static

Definition at line 1284 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void merge_free_lists ( vlib_buffer_free_list_t dst,
vlib_buffer_free_list_t src 
)
static

Definition at line 279 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 serialize_close_vlib_buffer ( serialize_main_t m)

Definition at line 1246 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void serialize_open_vlib_buffer ( serialize_main_t m,
vlib_main_t vm,
vlib_serialize_buffer_main_t sm 
)

Definition at line 1232 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void serialize_open_vlib_helper ( serialize_main_t m,
vlib_main_t vm,
vlib_serialize_buffer_main_t sm,
uword  is_read 
)
static

Definition at line 1208 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* show_buffers ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 1310 of file dpdk_buffer.c.

+ Here is the call graph for this function:

static void trim_aligned ( vlib_buffer_free_list_t f)
static

Definition at line 251 of file dpdk_buffer.c.

+ Here is the caller graph for this function:

void unserialize_close_vlib_buffer ( serialize_main_t m)

Definition at line 1271 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void unserialize_open_vlib_buffer ( serialize_main_t m,
vlib_main_t vm,
vlib_serialize_buffer_main_t sm 
)

Definition at line 1239 of file dpdk_buffer.c.

+ 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 161 of file dpdk_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 851 of file dpdk_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 643 of file dpdk_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 655 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller 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 908 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_buffer_chain_validate ( vlib_main_t vm,
vlib_buffer_t b_first 
)

Definition at line 946 of file dpdk_buffer.c.

+ 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 366 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 vlib_buffer_create_free_list_helper ( vlib_main_t vm,
u32  n_data_bytes,
u32  is_public,
u32  is_default,
u8 name 
)
static

Definition at line 317 of file dpdk_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 434 of file dpdk_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 766 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static_always_inline void vlib_buffer_free_inline ( vlib_main_t vm,
u32 buffers,
u32  n_buffers,
u32  follow_buffer_next 
)

Definition at line 699 of file dpdk_buffer.c.

+ 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 773 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 vlib_buffer_get_free_list_with_size ( vlib_main_t vm,
u32  size 
)
inlinestatic

Definition at line 306 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ 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 383 of file dpdk_buffer.c.

+ 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 82 of file dpdk_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 968 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_packet_template_buffer_init ( vlib_main_t vm,
vlib_buffer_free_list_t fl,
u32 buffers,
u32  n_buffers 
)
static

Definition at line 782 of file dpdk_buffer.c.

+ Here is the call graph for this function:

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

Definition at line 824 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller 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 801 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_serialize_rx ( serialize_main_header_t m,
serialize_stream_t s 
)
static

Definition at line 1157 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_serialize_tx ( serialize_main_header_t m,
serialize_stream_t s 
)
static

Definition at line 1085 of file dpdk_buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* vlib_set_buffer_free_callback ( vlib_main_t vm,
void *  fp 
)

Definition at line 689 of file dpdk_buffer.c.

Variable Documentation

vlib_cli_command_t show_buffers_command
static
Initial value:
= {
.path = "show buffers",
.short_help = "Show packet buffer allocation",
.function = show_buffers,
}
static clib_error_t * show_buffers(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: dpdk_buffer.c:1310

(constructor) VLIB_CLI_COMMAND (show_buffers_command)

Definition at line 1339 of file dpdk_buffer.c.

void* vlib_buffer_state_heap

Definition at line 1350 of file dpdk_buffer.c.

uword* vlib_buffer_state_validation_hash

Definition at line 1349 of file dpdk_buffer.c.

u32* vlib_buffer_state_validation_lock

Definition at line 1348 of file dpdk_buffer.c.

vlib_main_t** vlib_mains

Definition at line 157 of file dpdk_buffer.c.