40 #ifndef included_vlib_buffer_funcs_h 41 #define included_vlib_buffer_funcs_h 133 uword content_len = 0;
156 (((
uword) buffer_index) <<
170 #define vlib_prefetch_buffer_with_index(vm,bi,type) \ 172 vlib_buffer_t * _b = vlib_get_buffer (vm, bi); \ 173 vlib_prefetch_buffer_header (_b, type); \ 184 #define vlib_buffer_foreach_allocated(vm,bi,body) \ 186 vlib_main_t * _vmain = (vm); \ 187 vlib_buffer_main_t * _bmain = &_vmain->buffer_main; \ 188 hash_pair_t * _vbpair; \ 189 hash_foreach_pair(_vbpair, _bmain->buffer_known_hash, ({ \ 190 if (VLIB_BUFFER_KNOWN_ALLOCATED == _vbpair->value[0]) { \ 191 (bi) = _vbpair->key; \ 271 u32 n_buffers,
u32 free_list_index)
361 uword n_unaligned_buffers);
370 return p ? p[0] : ~0;
471 u32 buffer_index,
void *data,
u32 n_data_bytes);
478 uword n_alloc, n_buffers = 1;
488 u32 new_buffers[n_buffers];
513 for (i = 1; i < n_buffers; i++)
544 u8 n_buffers,
u16 head_end_offset)
554 buffers[0] = src_buffer;
555 for (i = 1; i < n_buffers; i++)
571 buffers[0] = src_buffer;
575 for (i = 0; i < n_buffers; i++)
702 void *data,
u16 data_len);
729 uword n_packet_data_bytes,
730 uword min_n_buffers_each_physmem_alloc,
766 n += vlib_buffer_index_length_in_chain (vm, f[0]);
801 #define _(f) ASSERT (dst->f == src->f); 814 u32 buffer_index,
u8 do_init)
848 #define _(f) ASSERT (dst0->f == src->f); ASSERT( dst1->f == src->f) 888 if (p[0] != expected)
901 p[0] ?
"busy" :
"free", expected ?
"busy" :
"free");
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
static u64 vlib_physmem_virtual_to_physical(vlib_main_t *vm, void *mem)
u32 vlib_buffer_get_or_create_free_list(vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
uword vlib_buffer_length_in_chain_slow_path(vlib_main_t *vm, vlib_buffer_t *b_first)
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static void vlib_buffer_set_known_state(vlib_main_t *vm, u32 buffer_index, vlib_buffer_known_state_t state)
#define STRUCT_MARK_PTR(v, f)
format_function_t format_vlib_buffer_contents
static void * vlib_physmem_alloc(vlib_main_t *vm, clib_error_t **error, uword n_bytes)
u32 free_list_index
Buffer free list that this buffer was allocated from and will be freed to.
vlib_physmem_main_t physmem_main
format_function_t format_vlib_buffer
vlib_buffer_callbacks_t cb
void vlib_buffer_merge_free_lists(vlib_buffer_free_list_t *dst, vlib_buffer_free_list_t *src)
static void vlib_buffer_attach_clone(vlib_main_t *vm, vlib_buffer_t *head, vlib_buffer_t *tail)
Attach cloned tail to the buffer.
static 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)
static void vlib_validate_buffer_in_use(vlib_buffer_t *b, u32 expected)
static vlib_buffer_t * vlib_buffer_chain_buffer(vlib_main_t *vm, vlib_buffer_t *first, vlib_buffer_t *last, u32 next_bi)
static f64 vlib_time_now(vlib_main_t *vm)
static void vlib_buffer_chain_increase_length(vlib_buffer_t *first, vlib_buffer_t *last, i32 len)
vlib_buffer_t buffer_init_template
struct vlib_main_t * vlib_main
#define CLIB_LOG2_CACHE_LINE_BYTES
struct vlib_serialize_buffer_main_t::@23::@26 rx
vlib_buffer_main_t * buffer_main
#define STRUCT_OFFSET_OF(t, f)
static u8 vlib_buffer_clone(vlib_main_t *vm, u32 src_buffer, u32 *buffers, u8 n_buffers, u16 head_end_offset)
Create multiple clones of buffer and store them in the supplied array.
static vlib_buffer_known_state_t vlib_buffer_is_known(vlib_main_t *vm, u32 buffer_index)
uword * vlib_buffer_state_validation_hash
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static u64 vlib_get_buffer_data_physical_address(vlib_main_t *vm, u32 buffer_index)
static vlib_buffer_t * vlib_buffer_copy(vlib_main_t *vm, vlib_buffer_t *b)
clib_error_t * vlib_buffer_pool_create(vlib_main_t *vm, unsigned num_mbufs, unsigned socket_id)
static void vlib_buffer_delete_free_list(vlib_main_t *vm, u32 free_list_index)
static void vlib_physmem_free(vlib_main_t *vm, void *mem)
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,...)
#define vec_add1_aligned(V, E, A)
Add 1 element to end of vector (alignment specified).
#define VLIB_BUFFER_NEXT_PRESENT
static void * vlib_physmem_at_offset(vlib_physmem_main_t *pm, uword offset)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
void vlib_aligned_memcpy(void *_dst, void *_src, int n_bytes)
#define clib_error_return(e, args...)
u32 * vlib_buffer_state_validation_lock
static void vlib_copy_buffers(u32 *dst, u32 *src, u32 n)
static uword pointer_to_uword(const void *p)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
u8 * vlib_validate_buffer(vlib_main_t *vm, u32 buffer_index, uword follow_chain)
vlib_main_t vlib_global_main
static u32 vlib_buffer_get_free_list_with_size(vlib_main_t *vm, u32 size)
format_function_t format_vlib_buffer_and_data
static u64 vlib_physmem_offset_to_physical(vlib_physmem_main_t *pm, uword o)
uword os_get_cpu_number(void)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void(* vlib_buffer_delete_free_list_cb)(struct vlib_main_t *vm, u32 free_list_index)
static u32 vlib_buffer_free_list_buffer_size(vlib_main_t *vm, u32 free_list_index)
#define clib_fifo_foreach(v, f, body)
static void vlib_buffer_add_to_free_list(vlib_main_t *vm, vlib_buffer_free_list_t *f, u32 buffer_index, u8 do_init)
void(* vlib_buffer_free_cb)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
void(* vlib_buffer_free_no_next_cb)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
#define uword_to_pointer(u, type)
static uword vlib_buffer_contents(vlib_main_t *vm, u32 buffer_index, u8 *contents)
Copy buffer contents to memory.
static void vlib_buffer_chain_init(vlib_buffer_t *first)
serialize_stream_t stream
static 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.
void *(* os_physmem_alloc_aligned)(vlib_physmem_main_t *pm, uword n_bytes, uword alignment)
void vlib_buffer_chain_validate(vlib_main_t *vm, vlib_buffer_t *first)
#define vec_free(V)
Free vector's memory (no header).
static void * clib_mem_set_heap(void *heap)
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
static 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.
static 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.
static uword round_pow2(uword x, uword pow2)
vlib_buffer_known_state_t
uword data_function_opaque
static void vlib_validate_buffer_set_in_use(vlib_buffer_t *b, u32 expected)
static void * vlib_physmem_alloc_aligned(vlib_main_t *vm, clib_error_t **error, uword n_bytes, uword alignment)
static uword vlib_physmem_offset_of(vlib_physmem_main_t *pm, void *p)
u32(* vlib_buffer_alloc_cb)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers)
u32(* vlib_buffer_alloc_from_free_list_cb)(struct vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
void vlib_buffer_free_list_fill_unaligned(vlib_main_t *vm, vlib_buffer_free_list_t *free_list, uword n_unaligned_buffers)
vhost_vring_state_t state
static vlib_buffer_free_list_t * vlib_buffer_get_buffer_free_list(vlib_main_t *vm, vlib_buffer_t *b, u32 *index)
u32 next_buffer
Next buffer for this linked-list of buffers.
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)
u32 vlib_buffer_add_data(vlib_main_t *vm, u32 free_list_index, u32 buffer_index, void *data, u32 n_data_bytes)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static uword vlib_buffer_index_length_in_chain(vlib_main_t *vm, u32 bi)
Get length in bytes of the buffer index buffer chain.
void(* os_physmem_free)(void *x)
u8 n_add_refs
Number of additional references to this buffer.
void * vlib_buffer_state_heap
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
template key/value backing page structure
vlib_buffer_free_list_t * buffer_free_list_pool
static void vlib_buffer_init_two_for_free_list(vlib_buffer_t *dst0, vlib_buffer_t *dst1, vlib_buffer_free_list_t *fl)
uword * buffer_known_hash
u32 opaque[8]
Opaque data used by sub-graphs for their own purposes.
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
static void vlib_buffer_init_for_free_list(vlib_buffer_t *dst, vlib_buffer_free_list_t *fl)
#define VLIB_BUFFER_EXT_HDR_VALID
vlib_physmem_region_t virtual
#define CLIB_MEMORY_BARRIER()
static void vlib_packet_template_free(vlib_main_t *vm, vlib_packet_template_t *t)
static void vlib_buffer_free_one(vlib_main_t *vm, u32 buffer_index)
Free one buffer Shorthand to free a single buffer chain.
void vlib_packet_template_get_packet_helper(vlib_main_t *vm, vlib_packet_template_t *t)
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
u32 min_n_buffers_each_physmem_alloc
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
uword * free_list_by_size
u32 vlib_buffer_create_free_list(vlib_main_t *vm, u32 n_data_bytes, char *fmt,...)
static u32 vlib_buffer_round_size(u32 size)
static u32 unserialize_vlib_buffer_n_bytes(serialize_main_t *m)