|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
51 #define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA 16384
52 #define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV 8192
54 #ifdef CLIB_HAVE_VEC128
64 u16 __vlib_buffer_external_hdr_size = 0;
84 while (
b->
flags & VLIB_BUFFER_NEXT_PRESENT)
90 b_first->
flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
101 #define _(bit, name, v) \
102 if (v && (b->flags & VLIB_BUFFER_##name)) \
103 a = format (a, "%s ", v);
106 s =
format (s,
"current data %d, length %d, buffer-pool %d, "
110 if (
b->
flags & VLIB_BUFFER_TOTAL_LENGTH_VALID)
111 s =
format (s,
", totlen-nifb %d",
114 if (
b->
flags & VLIB_BUFFER_IS_TRACED)
133 while (
b->
flags & VLIB_BUFFER_NEXT_PRESENT)
139 format (s,
"\n%Unext-buffer 0x%x, segment length %d, ref-count %u",
172 t =
"known-allocated";
184 return format (s,
"%s", t);
196 if (!(
b->
flags & VLIB_BUFFER_NEXT_PRESENT))
207 uword follow_buffer_next,
uword ** unique_hash)
223 if (follow_buffer_next && (
b->
flags & VLIB_BUFFER_NEXT_PRESENT))
230 return format (0,
"next 0x%x: %U",
263 uword next_buffer_stride,
266 uword follow_buffer_next)
269 u32 bi, *
b = buffers;
271 u8 *msg = 0, *result = 0;
277 b += next_buffer_stride;
282 msg =
format (0,
"not unique");
287 if (k != known_state)
289 msg =
format (0,
"is %U; expected %U",
305 result =
format (0,
"0x%x: %v", bi, msg);
341 if (known != expected_state)
343 clib_panic (
"%s %U buffer 0x%x", is_free ?
"freeing" :
"allocating",
358 uword n_packet_data_bytes,
359 uword min_n_buffers_each_alloc,
char *
fmt, ...)
401 u32 n_buffer_bytes,
n_left, n_left_this_buffer, bi;
414 b->
flags &= ~VLIB_BUFFER_TOTAL_LENGTH_VALID;
417 while (
b->
flags & VLIB_BUFFER_NEXT_PRESENT)
439 b->
flags |= VLIB_BUFFER_NEXT_PRESENT;
468 first->buffer_pool_index))
499 u32 physmem_map_index)
507 u32 alloc_size, n_alloc_per_page;
519 else if (start < bm->buffer_mem_start)
536 clib_panic (
"buffer memory size out of range!");
562 for (j = 0; j < m->
n_pages; j++)
563 for (
i = 0;
i < n_alloc_per_page;
i++)
600 return format (s,
"%-20s%=6s%=6s%=6s%=11s%=6s%=8s%=8s%=8s",
601 "Pool Name",
"Index",
"NUMA",
"Size",
"Data Size",
602 "Total",
"Avail",
"Cached",
"Used");
609 s =
format (s,
"%-20s%=6d%=6d%=6u%=11u%=6u%=8u%=8u%=8u",
643 .path =
"show buffers",
644 .short_help =
"Show packet buffer allocation",
672 u32 * physmem_map_index,
680 uword n_pages, pagesize;
689 if (buffer_size > pagesize)
691 "size (%llu)", buffer_size, pagesize);
693 if (buffers_per_numa == 0)
697 name =
format (0,
"buffers-numa-%d%c", numa_node, 0);
698 n_pages = (buffers_per_numa - 1) / (pagesize / buffer_size) + 1;
712 u32 physmem_map_index;
723 goto buffer_pool_create;
727 "numa[%u] falling back to non-hugepage backed "
842 u8 *
name = 0, first_valid_buffer_pool_index = ~0;
856 if ((err =
clib_sysfs_read (
"/sys/devices/system/node/has_memory",
"%U",
860 if (bmp && bmp_has_memory)
868 clib_panic (
"system have more than %u NUMA nodes",
883 if (first_valid_buffer_pool_index == 0xff)
884 first_valid_buffer_pool_index =
index[0];
888 if (first_valid_buffer_pool_index == (
u8) ~ 0)
899 first_valid_buffer_pool_index;
948 else if (
unformat (input,
"default data-size %u",
961 #if VLIB_BUFFER_ALLOC_FAULT_INJECTOR > 0
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void clib_spinlock_init(clib_spinlock_t *p)
u32 next_buffer
Next buffer for this linked-list of buffers.
u8 buffer_pool_index
index of buffer pool this buffer belongs.
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
u16 vlib_buffer_chain_append_data_with_alloc(vlib_main_t *vm, vlib_buffer_t *first, vlib_buffer_t **last, void *data, u16 data_len)
#define hash_set(h, key, value)
static void vlib_buffer_chain_increase_length(vlib_buffer_t *first, vlib_buffer_t *last, i32 len)
u8 vlib_buffer_pool_create(vlib_main_t *vm, char *name, u32 data_size, u32 physmem_map_index)
#define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV
static vlib_buffer_pool_t * buffer_get_by_index(vlib_buffer_main_t *bm, u32 index)
@ CLIB_MEM_PAGE_SZ_DEFAULT_HUGE
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static uword pointer_to_uword(const void *p)
static clib_error_t * vlib_buffer_main_init_numa_node(struct vlib_main_t *vm, u32 numa_node, u8 *index)
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
__clib_export int vlib_buffer_set_alloc_free_callback(vlib_main_t *vm, vlib_buffer_alloc_free_callback_t *alloc_callback_fn, vlib_buffer_alloc_free_callback_t *free_callback_fn)
#define clib_error_return(e, args...)
#define vlib_log_warn(...)
static heap_elt_t * first(heap_header_t *h)
u8 * format_vlib_buffer_contents(u8 *s, va_list *va)
static void buffer_gauges_update_cached_fn(stat_segment_directory_entry_t *e, u32 index)
vlib_buffer_main_t * buffer_main
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static_always_inline uword clib_mem_page_bytes(clib_mem_page_sz_t log2_page_size)
static clib_error_t * vlib_buffers_configure(vlib_main_t *vm, unformat_input_t *input)
vl_api_dhcp_client_state_t state
void vlib_buffer_main_alloc(vlib_main_t *vm)
vlib_physmem_map_t * vlib_physmem_get_map(vlib_main_t *vm, u32 index)
u32 trace_handle
Specifies trace buffer handle if VLIB_PACKET_IS_TRACED flag is set.
#define VLIB_BUFFER_DEFAULT_DATA_SIZE
#define clib_error_report(e)
vnet_hw_if_output_node_runtime_t * r
static vlib_buffer_known_state_t vlib_buffer_is_known(vlib_main_t *vm, u32 buffer_index)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
clib_mem_page_sz_t log2_page_size
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
f64 buffer_alloc_success_rate
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
static u8 * format_vlib_buffer_known_state(u8 *s, va_list *args)
__clib_export clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
vlib_buffer_pool_thread_t * threads
STATIC_ASSERT_OFFSET_OF(vlib_buffer_t, template_end, 64)
u32 buffer_alloc_success_seed
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA
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_buffer_next)
static clib_error_t * show_buffers(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 min_n_buffers_each_alloc
#define CLIB_CACHE_LINE_ROUND(x)
static __clib_warn_unused_result u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
vlib_log_class_t log_default
static uword vlib_buffer_alloc_size(uword ext_hdr_size, uword data_size)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 * format_vlib_buffer_pool_all(u8 *s, va_list *va)
vlib_buffer_t buffer_template
#define vlib_worker_thread_barrier_sync(X)
#define STATIC_ASSERT_FITS_IN(s, e, o)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define VLIB_BUFFER_MAX_NUMA_NODES
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static_always_inline void clib_spinlock_lock(clib_spinlock_t *p)
static heap_elt_t * last(heap_header_t *h)
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
u8 default_buffer_pool_index_for_numa[VLIB_BUFFER_MAX_NUMA_NODES]
clib_error_t * vlib_buffer_worker_init(vlib_main_t *vm)
clib_error_t * stat_segment_register_gauge(u8 *names, stat_segment_update_fn update_fn, u32 index)
static_always_inline void vlib_buffer_copy_template(vlib_buffer_t *b, vlib_buffer_t *bt)
VLIB_WORKER_INIT_FUNCTION(vlib_buffer_worker_init)
#define VLIB_CLI_COMMAND(x,...)
volatile u8 ref_count
Reference count for this buffer.
clib_spinlock_t buffer_known_hash_lockp
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap.
u32() vlib_buffer_alloc_free_callback_t(struct vlib_main_t *vm, u8 buffer_pool_index, u32 *buffers, u32 n_buffers)
#define CLIB_CACHE_LINE_BYTES
clib_error_t * vlib_physmem_shared_map_create(vlib_main_t *vm, char *name, uword size, u32 log2_page_sz, u32 numa_node, u32 *map_index)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u16 current_length
Nbytes between current data and the end of this buffer.
static uword * clib_bitmap_and(uword *ai, uword *bi)
Logical operator across two bitmaps.
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_free(V)
Free vector's memory (no header).
static u8 * vlib_validate_buffer_helper(vlib_main_t *vm, u32 bi, uword follow_buffer_next, uword **unique_hash)
void * vlib_packet_template_get_packet(vlib_main_t *vm, vlib_packet_template_t *t, u32 *bi_result)
vlib_buffer_pool_t * buffer_pools
static vlib_cli_command_t show_buffers_command
(constructor) VLIB_CLI_COMMAND (show_buffers_command)
description fragment has unexpected format
static clib_error_t * vlib_buffer_main_init_numa_alloc(struct vlib_main_t *vm, u32 numa_node, u32 *physmem_map_index, clib_mem_page_sz_t log2_page_size, u8 unpriv)
#define VLIB_BUFFER_PRE_DATA_SIZE
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
u8 * format_vlib_buffer_no_chain(u8 *s, va_list *args)
@ CLIB_MEM_PAGE_SZ_DEFAULT
vlib_buffer_alloc_free_callback_t * alloc_callback_fn
uword * buffer_known_hash
#define CLIB_LOG2_CACHE_LINE_BYTES
#define vec_foreach(var, vec)
Vector iterator.
@ foreach_vlib_buffer_flag
static vlib_buffer_t * vlib_buffer_chain_buffer(vlib_main_t *vm, vlib_buffer_t *last, u32 next_bi)
static void buffer_gauges_update_used_fn(stat_segment_directory_entry_t *e, u32 index)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static uword clib_bitmap_last_set(uword *ai)
Return the higest numbered set bit in a bitmap.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_buffer_known_state_t
static u32 vlib_get_n_threads()
static vlib_main_t * vlib_get_main(void)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void vlib_buffer_validate_alloc_free(vlib_main_t *vm, u32 *buffers, uword n_buffers, vlib_buffer_known_state_t expected_state)
u8 * format_vlib_buffer(u8 *s, va_list *args)
u8 * vlib_validate_buffer(vlib_main_t *vm, u32 bi, uword follow_buffer_next)
#define clib_warning(format, args...)
static void * clib_mem_alloc_aligned(uword size, uword align)
#define clib_error_free(e)
static u8 * format_vlib_buffer_pool(u8 *s, va_list *va)
@ VLIB_BUFFER_KNOWN_ALLOCATED
u8 * format_vlib_buffer_and_data(u8 *s, va_list *args)
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_alloc, char *fmt,...)
clib_error_t * vlib_buffer_main_init(struct vlib_main_t *vm)
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
int vlib_buffer_add_data(vlib_main_t *vm, u32 *buffer_index, void *data, u32 n_data_bytes)
#define clib_panic(format, args...)
static uword min_log2(uword x)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
#define hash_create(elts, value_bytes)
@ CLIB_MEM_PAGE_SZ_UNKNOWN
static __clib_warn_unused_result u32 vlib_buffer_alloc_from_pool(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u8 buffer_pool_index)
Allocate buffers from specific pool into supplied array.
static void * clib_mem_alloc(uword size)
vlib_buffer_alloc_free_callback_t * free_callback_fn
__clib_export uword unformat_bitmap_list(unformat_input_t *input, va_list *va)
unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )
#define hash_set1(h, key)
static void buffer_gauges_update_available_fn(stat_segment_directory_entry_t *e, u32 index)
static u32 buffer_get_cached(vlib_buffer_pool_t *bp)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
uword vlib_buffer_length_in_chain_slow_path(vlib_main_t *vm, vlib_buffer_t *b_first)
vl_api_wireguard_peer_flags_t flags