FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
buffer.h File Reference

vlib buffer structure definition and a few select access methods. More...

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

Go to the source code of this file.

Data Structures

struct  vlib_buffer_t
 
struct  vlib_buffer_free_list_t
 
struct  vlib_buffer_callbacks_t
 
struct  vlib_buffer_main_t
 
struct  vlib_serialize_buffer_main_t
 

Macros

#define VLIB_BUFFER_DATA_SIZE   (2048)
 
#define VLIB_BUFFER_PRE_DATA_SIZE   __PRE_DATA_SIZE
 
#define VLIB_BUFFER_FREE_LIST_INDEX_MASK   ((1 << 5) - 1)
 
#define VLIB_BUFFER_IS_TRACED   (1 << 5)
 
#define VLIB_BUFFER_LOG2_NEXT_PRESENT   (6)
 
#define VLIB_BUFFER_NEXT_PRESENT   (1 << VLIB_BUFFER_LOG2_NEXT_PRESENT)
 
#define VLIB_BUFFER_IS_RECYCLED   (1 << 7)
 
#define VLIB_BUFFER_TOTAL_LENGTH_VALID   (1 << 8)
 
#define VLIB_BUFFER_REPL_FAIL   (1 << 9)
 
#define VLIB_BUFFER_RECYCLE   (1 << 10)
 
#define VLIB_BUFFER_FLOW_REPORT   (1 << 11)
 
#define VLIB_BUFFER_EXT_HDR_VALID   (1 << 12)
 
#define LOG2_VLIB_BUFFER_FLAG_USER(n)   (32 - (n))
 
#define VLIB_BUFFER_FLAG_USER(n)   (1 << LOG2_VLIB_BUFFER_FLAG_USER(n))
 
#define VLIB_BUFFER_HDR_SIZE   (sizeof(vlib_buffer_t) - VLIB_BUFFER_PRE_DATA_SIZE)
 
#define vlib_prefetch_buffer_header(b, type)   CLIB_PREFETCH (b, 64, type)
 Prefetch buffer metadata. More...
 
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX   (0)
 
#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES   VLIB_BUFFER_DATA_SIZE
 
#define VLIB_BUFFER_TRACE_TRAJECTORY   0
 Compile time buffer trajectory tracing option Turn this on if you run into "bad monkey" contexts, and you want to know exactly which nodes they've visited... More...
 
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
 
#define VLIB_BUFFER_REGISTER_CALLBACKS(x, ...)
 

Typedefs

typedef struct vlib_buffer_free_list_t vlib_buffer_free_list_t
 

Functions

static vlib_buffer_tvlib_buffer_next_contiguous (vlib_buffer_t *b, u32 buffer_bytes)
 
static void vlib_buffer_struct_is_sane (vlib_buffer_t *b)
 
static void * vlib_buffer_get_current (vlib_buffer_t *b)
 Get pointer to current data to process. More...
 
static void vlib_buffer_advance (vlib_buffer_t *b, word l)
 Advance current data pointer by the supplied (signed!) amount. More...
 
static u8 vlib_buffer_has_space (vlib_buffer_t *b, word l)
 Check if there is enough space in buffer to advance. More...
 
static void vlib_buffer_reset (vlib_buffer_t *b)
 Reset current header & length to state they were in when packet was received. More...
 
static void * vlib_get_buffer_opaque (vlib_buffer_t *b)
 Get pointer to buffer's opaque data array. More...
 
static void * vlib_get_buffer_opaque2 (vlib_buffer_t *b)
 Get pointer to buffer's opaque2 data array. More...
 
static u8vlib_buffer_get_tail (vlib_buffer_t *b)
 Get pointer to the end of buffer's data. More...
 
static void * vlib_buffer_put_uninit (vlib_buffer_t *b, u8 size)
 Append uninitialized data to buffer. More...
 
static void * vlib_buffer_push_uninit (vlib_buffer_t *b, u8 size)
 Prepend uninitialized data to buffer. More...
 
static void * vlib_buffer_make_headroom (vlib_buffer_t *b, u8 size)
 Make head room, typically for packet headers. More...
 
static void * vlib_buffer_pull (vlib_buffer_t *b, u8 size)
 Retrieve bytes from buffer head. More...
 
void vlib_buffer_add_mem_range (struct vlib_main_t *vm, uword start, uword size)
 
clib_error_tvlib_buffer_main_init (struct vlib_main_t *vm)
 
void serialize_open_vlib_buffer (serialize_main_t *m, struct vlib_main_t *vm, vlib_serialize_buffer_main_t *sm)
 
void unserialize_open_vlib_buffer (serialize_main_t *m, struct 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)
 
void * vlib_set_buffer_free_callback (struct vlib_main_t *vm, void *fp)
 
static u32 serialize_vlib_buffer_n_bytes (serialize_main_t *m)
 

Variables

vlib_buffer_callbacks_tvlib_buffer_callbacks
 

Detailed Description

vlib buffer structure definition and a few select access methods.

This structure and the buffer allocation mechanism should perhaps live in vnet, but it would take a lot of typing to make it so.

Definition in file buffer.h.

Macro Definition Documentation

#define LOG2_VLIB_BUFFER_FLAG_USER (   n)    (32 - (n))

Definition at line 104 of file buffer.h.

#define VLIB_BUFFER_DATA_SIZE   (2048)

Definition at line 51 of file buffer.h.

#define VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES   VLIB_BUFFER_DATA_SIZE

Definition at line 423 of file buffer.h.

#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX   (0)

Definition at line 422 of file buffer.h.

#define VLIB_BUFFER_EXT_HDR_VALID   (1 << 12)

Definition at line 101 of file buffer.h.

#define VLIB_BUFFER_FLAG_USER (   n)    (1 << LOG2_VLIB_BUFFER_FLAG_USER(n))

Definition at line 105 of file buffer.h.

#define VLIB_BUFFER_FLOW_REPORT   (1 << 11)

Definition at line 100 of file buffer.h.

#define VLIB_BUFFER_FREE_LIST_INDEX_MASK   ((1 << 5) - 1)

Definition at line 91 of file buffer.h.

#define VLIB_BUFFER_HDR_SIZE   (sizeof(vlib_buffer_t) - VLIB_BUFFER_PRE_DATA_SIZE)

Definition at line 160 of file buffer.h.

#define VLIB_BUFFER_IS_RECYCLED   (1 << 7)

Definition at line 96 of file buffer.h.

#define VLIB_BUFFER_IS_TRACED   (1 << 5)

Definition at line 93 of file buffer.h.

#define VLIB_BUFFER_LOG2_NEXT_PRESENT   (6)

Definition at line 94 of file buffer.h.

#define VLIB_BUFFER_NEXT_PRESENT   (1 << VLIB_BUFFER_LOG2_NEXT_PRESENT)

Definition at line 95 of file buffer.h.

#define VLIB_BUFFER_PRE_DATA_SIZE   __PRE_DATA_SIZE

Definition at line 52 of file buffer.h.

#define VLIB_BUFFER_RECYCLE   (1 << 10)

Definition at line 99 of file buffer.h.

#define VLIB_BUFFER_REGISTER_CALLBACKS (   x,
  ... 
)
Value:
__VA_ARGS__ vlib_buffer_callbacks_t __##x##_buffer_callbacks; \
static void __vlib_add_buffer_callbacks_t_##x (void) \
__attribute__((__constructor__)) ; \
static void __vlib_add_buffer_callbacks_t_##x (void) \
{ \
clib_panic ("vlib buffer callbacks already registered"); \
vlib_buffer_callbacks = &__##x##_buffer_callbacks; \
} \
__VA_ARGS__ vlib_buffer_callbacks_t __##x##_buffer_callbacks
#define clib_panic(format, args...)
Definition: error.h:72
vlib_buffer_callbacks_t * vlib_buffer_callbacks
Definition: buffer.c:49

Definition at line 522 of file buffer.h.

#define VLIB_BUFFER_REPL_FAIL   (1 << 9)

Definition at line 98 of file buffer.h.

#define VLIB_BUFFER_TOTAL_LENGTH_VALID   (1 << 8)

Definition at line 97 of file buffer.h.

#define VLIB_BUFFER_TRACE_TRAJECTORY   0

Compile time buffer trajectory tracing option Turn this on if you run into "bad monkey" contexts, and you want to know exactly which nodes they've visited...

See vlib/main.c...

Definition at line 512 of file buffer.h.

#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT (   b)

Definition at line 517 of file buffer.h.

#define vlib_prefetch_buffer_header (   b,
  type 
)    CLIB_PREFETCH (b, 64, type)

Prefetch buffer metadata.

The first 64 bytes of buffer contains most header information

Parameters
b- (vlib_buffer_t *) pointer to the buffer
type- LOAD, STORE. In most cases, STORE is the right answer

Definition at line 169 of file buffer.h.

Typedef Documentation

Function Documentation

u32 serialize_close_vlib_buffer ( serialize_main_t m)

Definition at line 204 of file buffer_serialize.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,
struct vlib_main_t vm,
vlib_serialize_buffer_main_t sm 
)

Definition at line 190 of file buffer_serialize.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 serialize_vlib_buffer_n_bytes ( serialize_main_t m)
inlinestatic

Definition at line 494 of file buffer.h.

+ Here is the caller graph for this function:

void unserialize_close_vlib_buffer ( serialize_main_t m)

Definition at line 229 of file buffer_serialize.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,
struct vlib_main_t vm,
vlib_serialize_buffer_main_t sm 
)

Definition at line 197 of file buffer_serialize.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vlib_buffer_add_mem_range ( struct vlib_main_t vm,
uword  start,
uword  size 
)

Definition at line 964 of file buffer.c.

+ Here is the caller graph for this function:

static void vlib_buffer_advance ( vlib_buffer_t b,
word  l 
)
inlinestatic

Advance current data pointer by the supplied (signed!) amount.

Parameters
b- (vlib_buffer_t *) pointer to the buffer
l- (word) signed increment

Definition at line 206 of file buffer.h.

static void* vlib_buffer_get_current ( vlib_buffer_t b)
inlinestatic

Get pointer to current data to process.

Parameters
b- (vlib_buffer_t *) pointer to the buffer
Returns
- (void *) (b->data + b->current_data)

Definition at line 193 of file buffer.h.

static u8* vlib_buffer_get_tail ( vlib_buffer_t b)
inlinestatic

Get pointer to the end of buffer's data.

Parameters
bpointer to the buffer
Returns
pointer to tail of packet's data

Definition at line 265 of file buffer.h.

+ Here is the caller graph for this function:

static u8 vlib_buffer_has_space ( vlib_buffer_t b,
word  l 
)
inlinestatic

Check if there is enough space in buffer to advance.

Parameters
b- (vlib_buffer_t *) pointer to the buffer
l- (word) size to check
Returns
- 0 if there is less space than 'l' in buffer

Definition at line 220 of file buffer.h.

+ Here is the caller graph for this function:

clib_error_t* vlib_buffer_main_init ( struct vlib_main_t vm)

Definition at line 1057 of file buffer.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* vlib_buffer_make_headroom ( vlib_buffer_t b,
u8  size 
)
inlinestatic

Make head room, typically for packet headers.

Parameters
bpointer to the buffer
sizenumber of head room bytes
Returns
pointer to start of buffer (current data)

Definition at line 305 of file buffer.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static vlib_buffer_t* vlib_buffer_next_contiguous ( vlib_buffer_t b,
u32  buffer_bytes 
)
inlinestatic

Definition at line 172 of file buffer.h.

+ Here is the caller graph for this function:

static void* vlib_buffer_pull ( vlib_buffer_t b,
u8  size 
)
inlinestatic

Retrieve bytes from buffer head.

Parameters
bpointer to the buffer
sizenumber of bytes to pull
Returns
pointer to start of buffer (current data)

Definition at line 318 of file buffer.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* vlib_buffer_push_uninit ( vlib_buffer_t b,
u8  size 
)
inlinestatic

Prepend uninitialized data to buffer.

Parameters
bpointer to the buffer
sizenumber of uninitialized bytes
Returns
pointer to beginning of uninitialized data

Definition at line 290 of file buffer.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void* vlib_buffer_put_uninit ( vlib_buffer_t b,
u8  size 
)
inlinestatic

Append uninitialized data to buffer.

Parameters
bpointer to the buffer
sizenumber of uninitialized bytes
Returns
pointer to beginning of uninitialized data

Definition at line 276 of file buffer.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void vlib_buffer_reset ( vlib_buffer_t b)
inlinestatic

Reset current header & length to state they were in when packet was received.

Parameters
b- (vlib_buffer_t *) pointer to the buffer

Definition at line 232 of file buffer.h.

+ Here is the caller graph for this function:

static void vlib_buffer_struct_is_sane ( vlib_buffer_t b)
inlinestatic

Definition at line 178 of file buffer.h.

static void* vlib_get_buffer_opaque ( vlib_buffer_t b)
inlinestatic

Get pointer to buffer's opaque data array.

Parameters
b- (vlib_buffer_t *) pointer to the buffer
Returns
- (void *) b->opaque

Definition at line 244 of file buffer.h.

static void* vlib_get_buffer_opaque2 ( vlib_buffer_t b)
inlinestatic

Get pointer to buffer's opaque2 data array.

Parameters
b- (vlib_buffer_t *) pointer to the buffer
Returns
- (void *) b->opaque2

Definition at line 255 of file buffer.h.

void* vlib_set_buffer_free_callback ( struct vlib_main_t vm,
void *  fp 
)

Definition at line 655 of file buffer.c.

Variable Documentation

vlib_buffer_callbacks_t* vlib_buffer_callbacks

Definition at line 49 of file buffer.c.