|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
60 .short_help =
"Show commands",
68 .short_help =
"Clear commands",
76 .short_help =
"Set commands",
84 .short_help =
"Test commands",
119 if (
i <
vec_len (
c->sub_command_positions)
133 if (
i >=
vec_len (
c->sub_command_positions))
231 u8 *c1 = *(
u8 **) a1;
232 u8 *c2 = *(
u8 **) a2;
244 uword *match_bitmap = 0;
252 while (
vec_len (input.buffer) >= 2 &&
253 isspace (input.buffer[
vec_len (input.buffer) - 1]) &&
254 isspace (input.buffer[
vec_len (input.buffer) - 2]))
260 if (
vec_len (input.buffer) == 0 ||
261 (
vec_len (input.buffer) == 1 && isspace (input.buffer[0])))
278 if (match_bitmap == 0)
287 if (input.index >=
vec_len (input.buffer) - 1)
306 help_next_level = (
vec_len (str) == 0) || isspace (str[
vec_len (str) - 1]);
309 if (help_next_level && is_unique) {
316 sc = &
c->sub_commands[
index];
334 int is_long = va_arg (*args,
int);
335 if (is_long &&
c->long_help)
336 s =
format (s,
"%s",
c->long_help);
337 else if (
c->short_help)
338 s =
format (s,
"%s",
c->short_help);
340 s =
format (s,
"%v commands",
c->path);
390 uword parent_command_index)
400 if (is_main_dispatch &&
unformat (input,
"help"))
402 uword help_at_end_of_line,
i;
404 help_at_end_of_line =
422 if (!help_at_end_of_line)
426 else if (
vec_len (
c->sub_commands) == 0)
450 (
vm,
" %-30v %U", subs[
i].
name,
458 else if (is_main_dispatch
463 subs =
all_subs (
cm, 0, parent_command_index);
472 else if (
unformat (input,
"comment %v", &
string))
477 else if (
unformat (input,
"vpplog %v", &
string))
485 if (
string[
i] !=
' ')
494 else if (
unformat (input,
"uncomment %U",
499 parent_command_index);
502 else if (
unformat (input,
"leak-check %U",
517 parent_command_index);
540 uword has_sub_commands =
547 if (has_sub_commands)
550 if (has_sub_commands && !
error)
553 else if (
c->function)
572 .format =
"cli-cmd: %s",
588 c -
cm->commands, 0 );
591 c_error =
c->function (
vm,
si,
c);
595 c -
cm->commands, 1 );
604 .format =
"cli-cmd: %s %s",
605 .format_args =
"T4T4",
618 (
char *) c_error->
what);
619 _vec_len (c_error->
what) -= 1;
666 __attribute__ ((weak));
683 uword save_function_arg;
768 int verbose __attribute__ ((unused)) = 0;
769 int api_segment = 0, stats_segment = 0, main_heap = 0, numa_heaps = 0;
782 else if (
unformat (input,
"api-segment"))
784 else if (
unformat (input,
"stats-segment"))
786 else if (
unformat (input,
"main-heap"))
788 else if (
unformat (input,
"numa-heaps"))
800 if ((api_segment + stats_segment + main_heap + numa_heaps +
map) == 0)
802 (0,
"Need one of api-segment, stats-segment, main-heap, numa-heaps "
889 s =
format (s,
"\n%-16s%7s%5s%7s%7s",
890 "StartAddr",
"size",
"FD",
"PageSz",
"Pages");
892 s =
format (s,
" Numa%u", numa);
893 s =
format (s,
" NotMap");
901 hdr->log2_page_sz, hdr->num_pages,
903 s =
format (s,
"%016lx%7U",
905 hdr->num_pages << hdr->log2_page_sz);
908 s =
format (s,
"%5d", hdr->fd);
910 s =
format (s,
"%5s",
" ");
918 s =
format (s,
" %s", hdr->name);
930 .path =
"show memory",
931 .short_help =
"show memory [api-segment][stats-segment][verbose]\n"
932 " [numa-heaps][map]",
941 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
945 _(
"Base frequency",
"%.2f GHz",
965 .short_help =
"Show cpu information",
979 int stats_segment = 0;
991 else if (
unformat (line_input,
"api-segment"))
993 else if (
unformat (line_input,
"stats-segment"))
995 else if (
unformat (line_input,
"main-heap"))
997 else if (
unformat (line_input,
"numa-heap %d", &numa_id))
1007 if ((api_segment + stats_segment + main_heap + (enable == 0)
1008 + (numa_id != ~0)) == 0)
1011 (0,
"Need one of main-heap, stats-segment, api-segment,\n"
1012 "numa-heap <nn> or disable");
1078 .path =
"memory-trace",
1079 .short_help =
"memory-trace on|off [api-segment][stats-segment][main-heap]\n"
1080 " [numa-heap <numa-id>]\n",
1094 extern char **environ;
1100 if (
f->file_descriptor > 2)
1101 close(
f->file_descriptor);
1106 execve (vgm->
name, (
char **)
vm->
argv, environ);
1114 .short_help =
"restart process",
1130 u16 my_id = rand ();
1134 for (
i = 0;
i < 10;
i++)
1145 .path =
"test sleep",
1146 .function = sleep_ten_seconds,
1147 .short_help =
"Sleep for 10 seconds",
1158 uword index_of_last_space = ~0;
1170 if (l > 0 && s[l - 1] !=
' ')
1178 if (l > 0 && s[l - 1] ==
' ')
1179 index_of_last_space =
vec_len (s);
1187 if (l > 0 && s[l - 1] ==
' ')
1191 return index_of_last_space;
1230 if (sub_name[0] ==
'%')
1240 sizeof (sub_name[0]),
1253 sr->
name = sub_name;
1261 sizeof (
c->path[0]),
1272 sub_c->
index = child_index;
1273 sub_c->
name = sub_name;
1305 uword p_len, pi, *p;
1332 parent->
path = p_path;
1334 parent -
cm->commands);
1335 pi = parent -
cm->commands;
1353 return (
c->long_help == 0 &&
c->short_help == 0 &&
c->function == 0);
1363 char *normalized_path;
1370 if (!
cm->command_index_by_path)
1372 sizeof (
c->path[0]),
1427 c->path = normalized_path;
1430 c->sub_commands = 0;
1431 c->sub_command_index_by_name = 0;
1432 c->sub_command_positions = 0;
1450 if (!
cm->parse_rule_index_by_name)
1452 sizeof (
r->name[0]),
1467 r->name = (
char *) r_name;
1478 __attribute__ ((unused))
1485 if (!
r->name || strlen (
r->name) == 0)
1508 int api = 0, cli = 0, barrier = 0, dispatch = 0, circuit = 0;
1509 u32 circuit_node_index;
1518 else if (
unformat (line_input,
"dispatch"))
1520 else if (
unformat (line_input,
"circuit-node %U",
1523 else if (
unformat (line_input,
"cli"))
1525 else if (
unformat (line_input,
"barrier"))
1527 else if (
unformat (line_input,
"disable"))
1529 else if (
unformat (line_input,
"enable"))
1553 if (dispatch || circuit)
1566 (
vm,
" Event log API message trace: %s\n CLI command trace: %s",
1570 (
vm,
" Barrier sync trace: %s",
1573 (
vm,
" Graph Dispatch: %s",
1576 (
vm,
" Graph Circuit: %s",
1603 .path =
"event-logger trace",
1604 .short_help =
"event-logger trace [api][cli][barrier][dispatch]\n"
1605 "[circuit-node <name> e.g. ethernet-input][disable]",
1622 .short_help =
"suspend debug CLI for 30ms",
1645 for (
i = 0;
i < lmin;
i++)
1687 vec_add1 (
cm->sort_vector,
a->parent_command_index);
1697 a->parent_command_index = sub->
index;
1706 int show_mp_safe = va_arg (*args,
int);
1707 int show_not_mp_safe = va_arg (*args,
int);
1708 int show_hit = va_arg (*args,
int);
1709 int clear_hit = va_arg (*args,
int);
1713 char *format_string =
"\n%v";
1716 format_string =
"\n%v: %u";
1721 a->parent_command_index = 0;
1722 a->show_mp_safe = show_mp_safe;
1723 a->show_not_mp_safe = show_not_mp_safe;
1724 a->show_hit = show_hit;
1725 a->clear_hit = clear_hit;
1734 s =
format (s, format_string,
c->path,
c->hit_counter);
1746 int show_mp_safe = 0;
1747 int show_not_mp_safe = 0;
1755 if (
unformat (input,
"not-mp-safe"))
1756 show_not_mp_safe = 1;
1759 else if (
unformat (input,
"clear-hit"))
1766 if (clear_hit == 0 && (show_mp_safe + show_not_mp_safe) == 0)
1767 show_mp_safe = show_not_mp_safe = 1;
1770 show_not_mp_safe, show_hit, clear_hit);
1821 .short_help =
"show cli [mp-safe][not-mp-safe][hit][clear-hit]",
1835 cmd =
cm->cli_command_registrations;
1846 "cli",
"log", 0x7FFFFFFF );
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static clib_error_t * vlib_cli_init(vlib_main_t *vm)
clib_file_main_t file_main
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)
struct _clib_mem_vm_map_hdr clib_mem_vm_map_hdr_t
static vlib_cli_command_t show_cpu_command
(constructor) VLIB_CLI_COMMAND (show_cpu_command)
__clib_export clib_mem_vm_map_hdr_t * clib_mem_vm_get_next_map_hdr(clib_mem_vm_map_hdr_t *hdr)
static void * current_traced_heap
static clib_mem_heap_t * clib_mem_get_heap(void)
vlib_cli_output_function_t * output_function
static void add_sub_command(vlib_cli_main_t *cm, uword parent_index, uword child_index)
vlib_cli_sub_rule_t * sub_rules
void * vl_msg_push_heap(void)
vlib_cli_sub_command_t * sub_commands
static int vlib_cli_cmp_strings(void *a1, void *a2)
clib_error_t * vlib_cli_register(vlib_main_t *vm, vlib_cli_command_t *c)
static vlib_cli_command_t vlib_cli_test_command
(constructor) VLIB_CLI_COMMAND (vlib_cli_test_command)
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
u8 ** vlib_cli_get_possible_completions(u8 *str)
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
#define clib_error_return(e, args...)
u8 * format_clib_mem_heap(u8 *s, va_list *va)
clib_error_t * vlib_cli_register_parse_rule(struct vlib_main_t *vm, vlib_cli_parse_rule_t *c)
static clib_error_t * suspend_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_create_vec(elts, key_bytes, value_bytes)
static uword vlib_cli_command_is_empty(vlib_cli_command_t *c)
static clib_error_t * event_logger_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int vl_api_get_elog_trace_api_messages(void)
void * vlib_stats_push_heap(void *)
#define vlib_call_init_function(vm, x)
u32 elog_trace_graph_circuit_node_index
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static vlib_cli_command_t show_cli_command
(constructor) VLIB_CLI_COMMAND (show_cli_command)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
__clib_export u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
vl_api_ikev2_sa_stats_t stats
uword clib_mem_trace_enable_disable(uword enable)
static uword * clib_bitmap_andnot(uword *ai, uword *bi)
Logical operator across two bitmaps.
static uword vlib_cli_normalize_path(char *input, char **result)
vnet_hw_if_output_node_runtime_t * r
__clib_export void clib_mem_get_page_stats(void *start, clib_mem_page_sz_t log2_page_size, uword n_pages, clib_mem_page_stats_t *stats)
vlib_worker_thread_t * vlib_worker_threads
static clib_error_t * restart_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int elog_trace_cli_commands
static vlib_cli_command_t * all_subs(vlib_cli_main_t *cm, vlib_cli_command_t *subs, u32 command_index)
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
static vlib_global_main_t * vlib_get_global_main(void)
Callback multiplex scheme For a fully worked-out example, see .../src/vlib/main.[ch] and ....
elog_event_t * event_ring
Vector of events (circular buffer).
format_function_t format_cpu_model_name
import vnet interface_types api
void vlib_unix_error_report(vlib_main_t *, clib_error_t *)
static u8 * format_vlib_cli_path(u8 *s, va_list *args)
void * per_cpu_mheaps[CLIB_MAX_MHEAPS]
#define foreach_vlib_main()
struct vlib_cli_command_t * next_cli_command
vlib_cli_parse_position_t * sub_command_positions
#define pool_foreach(VAR, POOL)
Iterate through pool.
static vlib_cli_command_t * get_sub_command(vlib_cli_main_t *cm, vlib_cli_command_t *parent, u32 si)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define ELOG_TYPE_DECLARE(f)
int elog_trace_graph_dispatch
u32 n_total_events
Total number of events in buffer.
uword * sub_command_index_by_name
static vlib_cli_command_t vlib_cli_clear_command
(constructor) VLIB_CLI_COMMAND (vlib_cli_clear_command)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static vlib_cli_command_t suspend_command
(constructor) VLIB_CLI_COMMAND (suspend_command)
#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 vlib_cli_command_t show_memory_usage_command
(constructor) VLIB_CLI_COMMAND (show_memory_usage_command)
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
#define vlib_worker_thread_barrier_sync(X)
void * per_numa_mheaps[CLIB_MAX_NUMAS]
vlib_log_class_t vlib_log_register_class_rate_limit(char *class, char *subclass, u32 limit)
unformat_function_t unformat_vlib_node
vlib_global_main_t vlib_global_main
format_function_t format_cpu_flags
#define clib_bitmap_free(v)
Free a bitmap.
static int vlib_cli_cmp_rule(void *a1, void *a2)
int vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
#define hash_set_mem(h, key, value)
static clib_error_t * vlib_cli_dispatch_sub_commands(vlib_main_t *vm, vlib_cli_main_t *cm, unformat_input_t *input, uword parent_command_index)
static elog_main_t * vlib_get_elog_main()
sll srl srl sll sra u16x4 i
static clib_error_t * show_cpu(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_feature_config_main_t * cm
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
void() vlib_cli_output_function_t(uword arg, u8 *buffer, uword buffer_bytes)
static vlib_cli_command_t restart_cmd
(constructor) VLIB_CLI_COMMAND (restart_cmd)
#define ALWAYS_ASSERT(truth)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
static_always_inline int vlib_mem_get_next_numa_node(int numa)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static uword unformat_vlib_cli_sub_command(unformat_input_t *i, va_list *args)
static uword parent_path_len(char *path)
static clib_error_t * show_cli_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword * clib_bitmap_and(uword *ai, uword *bi)
Logical operator across two bitmaps.
#define clib_elf_section_data_next(a, extra)
__clib_export clib_mem_main_t clib_mem_main
int elog_trace_graph_circuit
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * enable_disable_memory_trace(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_vlib_node_name
int vl_api_set_elog_trace_api_messages(int enable)
#define hash_get_mem(h, key)
#define clib_call_callbacks(h,...)
call the specified callback set
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
description fragment has unexpected format
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)
static clib_error_t * show_memory_usage(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_cli_command_t * commands
format_function_t format_cpu_uarch
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
#define vec_foreach(var, vec)
Vector iterator.
uword * sub_rule_index_by_name
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
static vlib_cli_command_t ping_command
(constructor) VLIB_CLI_COMMAND (ping_command)
#define vlib_log_notice(...)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
vlib_cli_command_function_t * function
static u8 * format_mp_safe(u8 *s, va_list *args)
static void vlib_cli_make_parent(vlib_cli_main_t *cm, uword ci)
static vlib_cli_command_t event_logger_trace_command
(constructor) VLIB_CLI_COMMAND (event_logger_trace_command)
void vl_msg_pop_heap(void *oldheap)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
uword output_function_arg
#define clib_error_free(e)
static u8 * format_vlib_cli_command_help(u8 *s, va_list *args)
static vlib_cli_command_t vlib_cli_set_command
(constructor) VLIB_CLI_COMMAND (vlib_cli_set_command)
static void cli_recursive_walk(vlib_cli_walk_args_t *aa)
#define clib_bitmap_foreach(i, ai)
Macro to iterate across set bits in a bitmap.
static int sort_cmds_by_path(void *a1, void *a2)
static uword * vlib_cli_sub_command_match(vlib_cli_command_t *c, unformat_input_t *input)
static clib_mem_heap_t * clib_mem_set_heap(clib_mem_heap_t *heap)
static vlib_cli_command_t enable_disable_memory_trace_command
(constructor) VLIB_CLI_COMMAND (enable_disable_memory_trace_command)
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header,...
void clib_mem_trace(int enable)
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
#define vec_del1(v, i)
Delete the element at index I.
static int vlib_cli_cmp_command(void *a1, void *a2)
#define clib_bitmap_dup(v)
Duplicate a bitmap.
static vlib_cli_command_t vlib_cli_show_command
(constructor) VLIB_CLI_COMMAND (vlib_cli_show_command)