|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
100 next_vector_index =
i;
105 return next_vector_index;
144 memset (e, 0,
sizeof (*e));
159 if (!
cm->name && !
cm->stat_segment_name)
166 char *stat_segment_name =
167 cm->stat_segment_name ?
cm->stat_segment_name :
cm->name;
176 memset (e, 0,
sizeof (*e));
189 char *stat_segment_name;
193 if (!
cm->name && !
cm->stat_segment_name)
205 cm->stat_segment_name ?
cm->stat_segment_name :
cm->name;
216 strncpy (e.
name, stat_segment_name, 128 - 1);
234 char *input = va_arg (*args,
char *);
235 char *modified_input =
vec_dup (input);
239 for (
i = 0;
i < strlen (modified_input);
i++)
240 if (modified_input[
i] ==
'/')
241 modified_input[
i] =
'_';
243 result =
format (s,
"%s", modified_input);
299 strncpy (e->
name, (
char *) new_name, 128 - 1);
348 for (
i = 0;
i <= max1;
i++)
406 memset (&e, 0,
sizeof (e));
430 char *mem_name =
"stat segment";
431 void *heap, *memaddr;
469 shared_header->
base = memaddr;
479 shared_header->
epoch = 1;
484 strcpy(sm->directory_vector[STAT_COUNTER_##E].name, #p "/" #n); \
485 sm->directory_vector[STAT_COUNTER_##E].type = STAT_DIR_TYPE_##t;
504 return strcmp ((
char *) n1->
name, (
char *) n2->
name);
515 format_string =
"%-74s %-10s %10lld";
520 type_name =
"ScalarPtr";
525 type_name =
"CMainPtr";
529 type_name =
"ErrIndex";
533 type_name =
"NameVector";
541 type_name =
"Symlink";
545 type_name =
"illegal!";
549 return format (s, format_string, ep->
name, type_name, 0);
599 .path =
"show statistics segment",
600 .short_help =
"show statistics segment [verbose]",
619 static u32 no_max_nodes = 0;
623 0 , &node_dups, &stat_vms);
626 u8 *symlink_name = 0;
631 if (l > no_max_nodes)
662 #define _(E, t, name, p) \
663 vec_reset_length (symlink_name); \
664 symlink_name = format (symlink_name, "/nodes/%U/" #name "%c", \
665 format_vlib_stats_symlink, s, 0); \
666 vlib_stats_register_symlink (oldheap, symlink_name, STAT_COUNTER_##E, \
677 for (j = 0; j <
vec_len (node_dups); j++)
694 u8 *symlink_new_name = 0;
698 #define _(E, t, name, p) \
699 vec_reset_length (symlink_name); \
700 symlink_name = format (symlink_name, "/nodes/%U/" #name "%c", \
701 format_vlib_stats_symlink, sm->nodes[n->index], 0); \
702 clib_mem_set_heap (oldheap); \
703 vector_index = lookup_hash_index ((u8 *) symlink_name); \
704 clib_mem_set_heap (sm->heap); \
705 vec_reset_length (symlink_new_name); \
706 symlink_new_name = format (symlink_new_name, "/nodes/%U/" #name "%c", \
707 format_vlib_stats_symlink, s, 0); \
708 vlib_stats_rename_symlink (oldheap, vector_index, symlink_new_name);
747 static int num_worker_threads_set;
761 num_worker_threads_set = 1;
836 template.file_descriptor = s->fd;
837 template.description =
format (0,
"stats segment listener %s", s->config);
891 gauge->
fn = update_fn;
910 if (vector_index == ~0)
914 gauge->
fn = update_fn;
927 if (vector_index == ~0)
929 *
index = vector_index;
981 else if (
unformat (input,
"default"))
983 else if (
unformat (input,
"size %U",
986 else if (
unformat (input,
"page-size %U",
989 else if (
unformat (input,
"per-node-counters on"))
991 else if (
unformat (input,
"per-node-counters off"))
1021 u8 *symlink_name = 0;
1040 #define _(E, n, p) \
1041 clib_mem_set_heap (oldheap); \
1042 vector_index = lookup_hash_index ((u8 *) "/" #p "/" #n); \
1043 clib_mem_set_heap (sm->heap); \
1044 vec_reset_length (symlink_name); \
1045 symlink_name = format (symlink_name, "/interfaces/%U/" #n "%c", \
1046 format_vlib_stats_symlink, s, 0); \
1047 vlib_stats_register_symlink (oldheap, symlink_name, vector_index, \
1059 #define _(E, n, p) \
1060 vec_reset_length (symlink_name); \
1061 symlink_name = format (symlink_name, "/interfaces/%U/" #n "%c", \
1062 format_vlib_stats_symlink, s, 0); \
1063 clib_mem_set_heap (oldheap); \
1064 vector_index = lookup_hash_index ((u8 *) symlink_name); \
1065 clib_mem_set_heap (sm->heap); \
1066 vlib_stats_delete_counter (vector_index, oldheap);
1089 .name =
"statseg-collector-process",
1106 .runs_after =
VLIB_INITS (
"unix_input_init"),
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
static void clib_spinlock_init(clib_spinlock_t *p)
void vlib_node_get_nodes(vlib_main_t *vm, u32 max_threads, int include_stats, int barrier_sync, vlib_node_t ****node_dupsp, vlib_main_t ***stat_vmsp)
Get list of nodes.
static clib_error_t * show_stat_segment_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define CLIB_SOCKET_F_IS_SERVER
@ STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED
#define hash_get_pair(h, key)
void * vlib_stats_push_heap(void *old)
clib_file_main_t file_main
#define foreach_stat_segment_counter_name
#define hash_set(h, key, value)
vnet_sw_interface_type_t type
static clib_mem_heap_t * clib_mem_get_heap(void)
stat_segment_shared_header_t * shared_header
void stat_segment_poll_add(u32 vector_index, stat_segment_update_fn update_fn, u32 caller_index, u32 interval)
void(* stat_segment_update_fn)(stat_segment_directory_entry_t *e, u32 i)
static u32 vlib_stats_get_next_vector_index()
stat_segment_directory_entry_t * directory_vector
f64 time_last_runtime_stats_clear
__clib_export void * clib_mem_vm_map_shared(void *base, uword size, int fd, uword offset, char *fmt,...)
@ STAT_COUNTER_INTERFACE_NAMES
@ STAT_DIR_TYPE_NAME_VECTOR
#define hash_create_string(elts, value_bytes)
#define clib_error_return(e, args...)
u8 * format_clib_mem_heap(u8 *s, va_list *va)
stat_segment_gauges_pool_t * gauges
clib_file_function_t * read_function
void vlib_stats_register_symlink(void *oldheap, u8 *name, u32 index1, u32 index2, u8 lock)
@ STAT_COUNTER_INPUT_RATE
void vlib_stats_pop_heap2(u64 *error_vector, u32 thread_index, void *oldheap, int lock)
vlib_node_main_t node_main
@ STAT_COUNTER_NODE_SUSPENDS
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
@ STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE
static u32 lookup_hash_index(u8 *name)
#define clib_error_report(e)
#define CLIB_MEM_VM_MAP_FAILED
#define STAT_SEGMENT_SOCKET_FILENAME
void vlib_stat_segment_unlock(void)
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
#define hash_unset(h, key)
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
#define STAT_SEGMENT_DEFAULT_SIZE
__clib_export int clib_mem_vm_create_fd(clib_mem_page_sz_t log2_page_size, char *fmt,...)
@ STAT_COUNTER_NODE_NAMES
static clib_error_t * stats_segment_socket_exit(vlib_main_t *vm)
static u32 vlib_stats_create_counter(stat_segment_directory_entry_t *e, void *oldheap)
#define pool_foreach(VAR, POOL)
Iterate through pool.
void vlib_stats_pop_heap(void *cm_arg, void *oldheap, u32 cindex, stat_directory_type_t type)
clib_mem_heap_t * clib_mem_create_heap(void *base, uword size, int is_locked, char *fmt,...)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * stat_segment_register_gauge(u8 *name, stat_segment_update_fn update_fn, u32 caller_index)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static clib_error_t * clib_socket_close(clib_socket_t *sock)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
@ STAT_COUNTER_NODE_VECTORS
static void create_hash_index(u8 *name, u32 index)
static clib_error_t * stats_segment_socket_init(void)
static_always_inline uword vlib_get_thread_index(void)
#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)
uint64_t counter_t
64bit counters
void stat_provider_register_vector_rate(u32 num_workers)
@ STAT_COUNTER_LAST_UPDATE
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
static char * vlib_unix_get_runtime_dir(void)
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
static u8 * format_stat_dir_entry(u8 *s, va_list *args)
vnet_feature_config_main_t * cm
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static vlib_cli_command_t show_stat_segment_command
(constructor) VLIB_CLI_COMMAND (show_stat_segment_command)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
@ STAT_COUNTER_NODE_CALLS
static clib_error_t * statseg_init(vlib_main_t *vm)
f64 vlib_get_stat_segment_update_rate(void)
void vlib_stat_segment_lock(void)
static void vlib_stats_delete_counter(u32 index, void *oldheap)
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
__clib_export errno_t strcpy_s(char *__restrict__ dest, rsize_t dmax, const char *__restrict__ src)
copy src string to dest string
u8 * format_vlib_stats_symlink(u8 *s, va_list *args)
static uword stat_segment_collector_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
@ STAT_COUNTER_NUM_WORKER_THREADS
static void stat_validate_counter_vector2(stat_segment_directory_entry_t *ep, u32 max1, u32 max2)
#define vec_free(V)
Free vector's memory (no header).
@ STAT_COUNTER_LAST_STATS_CLEAR
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(statseg_sw_interface_add_del)
description fragment has unexpected format
__clib_export clib_error_t * clib_socket_init(clib_socket_t *s)
stat_segment_update_fn fn
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
#define VLIB_INIT_FUNCTION(x)
@ STAT_DIR_TYPE_SCALAR_INDEX
@ CLIB_MEM_PAGE_SZ_DEFAULT
vlib_node_stats_t stats_total
#define CLIB_SOCKET_F_ALLOW_GROUP_WRITE
clib_error_t * stat_segment_deregister_state_counter(u32 index)
#define STAT_SEGMENT_VERSION
#define foreach_simple_interface_counter_name
static_always_inline uword clib_mem_get_page_size(void)
static_always_inline void clib_spinlock_unlock(clib_spinlock_t *p)
static uword clib_file_add(clib_file_main_t *um, clib_file_t *template)
uword * directory_vector_by_name
static vlib_node_registration_t stat_segment_collector
(constructor) VLIB_REGISTER_NODE (stat_segment_collector)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
#define foreach_stat_segment_node_counter_name
vlib_node_stats_t stats_last_clear
static clib_error_t * statseg_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
A collection of simple counters.
clib_error_t * vlib_map_stat_segment_init(void)
#define STAT_SEGMENT_INDEX_INVALID
vnet_interface_output_runtime_t * rt
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
#define CLIB_SOCKET_F_PASSCRED
clib_mem_page_sz_t log2_page_sz
#define foreach_combined_interface_counter_name
static void update_node_counters(stat_segment_main_t *sm)
static void do_stat_segment_updates(vlib_main_t *vm, stat_segment_main_t *sm)
void vlib_stats_rename_symlink(void *oldheap, u64 index, u8 *new_name)
static f64 vlib_time_now(vlib_main_t *vm)
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x)
@ VNET_SW_INTERFACE_TYPE_HARDWARE
struct _socket_t clib_socket_t
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static vlib_thread_main_t * vlib_get_thread_main()
void stat_segment_set_state_counter(u32 index, u64 value)
void vlib_stats_register_mem_heap(clib_mem_heap_t *heap)
vl_api_interface_index_t sw_if_index
u32 stat_segment_new_entry(u8 *name, stat_directory_type_t t)
static_always_inline clib_error_t * clib_mem_get_last_error(void)
@ CLIB_MEM_PAGE_SZ_UNKNOWN
@ STAT_COUNTER_NODE_CLOCKS
static u64 vnet_get_aggregate_rx_packets(void)
static clib_error_t * statseg_config(vlib_main_t *vm, unformat_input_t *input)
static clib_mem_heap_t * clib_mem_set_heap(clib_mem_heap_t *heap)
volatile u64 ** error_vector
static void * clib_mem_alloc(uword size)
stat_directory_type_t type
void vlib_stats_delete_cm(void *cm_arg)
@ STAT_DIR_TYPE_ERROR_INDEX
void vlib_stats_register_error_index(void *oldheap, u8 *name, u64 *em_vec, u64 index)
clib_spinlock_t * stat_segment_lockp
stat_segment_main_t stat_segment_main
vl_api_fib_path_type_t type
#define vec_foreach_index_backwards(var, v)
Iterate over vector indices (reverse).
static clib_error_t * stats_socket_accept_ready(clib_file_t *uf)
#define CLIB_SOCKET_F_SEQPACKET
static void stat_validate_counter_vector(stat_segment_directory_entry_t *ep, u32 max)
__clib_export clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
#define VLIB_REGISTER_NODE(x,...)
static int name_sort_cmp(void *a1, void *a2)