59 .short_help =
"Show commands",
67 .short_help =
"Clear commands",
75 .short_help =
"Set commands",
83 .short_help =
"Test commands",
186 if (c ==
'{' &&
unformat (i,
"%v", &s))
211 uword *match_bitmap, is_unique, index;
229 u8 *c1 = *(
u8 **) a1;
230 u8 *c2 = *(
u8 **) a2;
242 uword *match_bitmap = 0;
243 uword index, is_unique, help_next_level;
250 while (
vec_len (input.buffer) >= 2 &&
251 isspace (input.buffer[
vec_len (input.buffer) - 1]) &&
252 isspace (input.buffer[
vec_len (input.buffer) - 2]))
258 if (
vec_len (input.buffer) == 0 ||
259 (
vec_len (input.buffer) == 1 && isspace (input.buffer[0])))
276 if (match_bitmap == 0)
285 if (input.index >=
vec_len (input.buffer) - 1)
304 help_next_level = (
vec_len (str) == 0) || isspace (str[
vec_len (str) - 1]);
307 if (help_next_level && is_unique) {
332 int is_long = va_arg (*args,
int);
347 s =
format (s,
"%v", path);
388 uword parent_command_index)
397 if (is_main_dispatch &&
unformat (input,
"help"))
399 uword help_at_end_of_line,
i;
401 help_at_end_of_line =
419 if (!help_at_end_of_line)
441 for (i = 0; i <
vec_len (subs); i++)
447 (vm,
" %-30v %U", subs[i].
name,
455 else if (is_main_dispatch
460 subs =
all_subs (cm, 0, parent_command_index);
469 else if (
unformat (input,
"comment %v", &
string))
474 else if (
unformat (input,
"uncomment %U",
479 parent_command_index);
482 else if (
unformat (input,
"leak-check %U",
497 parent_command_index);
520 uword has_sub_commands =
527 if (has_sub_commands)
530 if (has_sub_commands && !error)
552 .format =
"cli-cmd: %s",
578 .format =
"cli-cmd: %s %s",
579 .format_args =
"T4T4",
593 _vec_len (c_error->
what) -= 1;
640 __attribute__ ((weak));
656 uword save_function_arg;
678 rv = error->
code != 0 ? error->
code : -1;
735 int verbose __attribute__ ((unused)) = 0;
736 int api_segment = 0, stats_segment = 0, main_heap = 0, numa_heaps = 0;
748 else if (
unformat (input,
"api-segment"))
750 else if (
unformat (input,
"stats-segment"))
752 else if (
unformat (input,
"main-heap"))
754 else if (
unformat (input,
"numa-heaps"))
764 if ((api_segment + stats_segment + main_heap + numa_heaps) == 0)
766 (0,
"Need one of api-segment, stats-segment, main-heap or numa-heaps");
872 .path =
"show memory",
873 .short_help =
"show memory [api-segment][stats-segment][verbose]\n" 883 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c); 887 _(
"Base frequency",
"%.2f GHz",
907 .short_help =
"Show cpu information",
920 int stats_segment = 0;
932 else if (
unformat (line_input,
"api-segment"))
934 else if (
unformat (line_input,
"stats-segment"))
936 else if (
unformat (line_input,
"main-heap"))
938 else if (
unformat (line_input,
"numa-heap %d", &numa_id))
948 if ((api_segment + stats_segment + main_heap + (enable == 0)
949 + (numa_id != ~0)) == 0)
952 (0,
"Need one of main-heap, stats-segment, api-segment,\n" 953 "numa-heap <nn> or disable");
1019 .path =
"memory-trace",
1020 .short_help =
"memory-trace on|off [api-segment][stats-segment][main-heap]\n" 1021 " [numa-heap <numa-id>]\n",
1034 extern char **environ;
1040 if (f->file_descriptor > 2)
1041 close(f->file_descriptor);
1046 execve (vm->
name, (
char **) vm->
argv, environ);
1054 .short_help =
"restart process",
1070 u16 my_id = rand ();
1072 vlib_cli_output (vm,
"Starting 10 seconds sleep with id %u\n", my_id);
1074 for (i = 0; i < 10; i++)
1085 .path =
"test sleep",
1086 .function = sleep_ten_seconds,
1087 .short_help =
"Sleep for 10 seconds",
1098 uword index_of_last_space = ~0;
1110 if (l > 0 && s[l - 1] !=
' ')
1118 if (l > 0 && s[l - 1] ==
' ')
1119 index_of_last_space =
vec_len (s);
1127 if (l > 0 && s[l - 1] ==
' ')
1131 return index_of_last_space;
1138 for (i =
vec_len (path) - 1; i >= 0; i--)
1167 if (sub_name[0] ==
'%')
1177 sizeof (sub_name[0]),
1190 sr->
name = sub_name;
1198 sizeof (c->
path[0]),
1209 sub_c->
index = child_index;
1210 sub_c->
name = sub_name;
1242 uword p_len, pi, *p;
1269 parent->
path = p_path;
1299 char *normalized_path;
1308 sizeof (c->
path[0]),
1363 c->
path = normalized_path;
1386 if (!cm->parse_rule_index_by_name)
1388 sizeof (r->
name[0]),
1394 if ((p =
hash_get_mem (cm->parse_rule_index_by_name, r_name)))
1403 r->
name = (
char *) r_name;
1414 __attribute__ ((unused))
1421 if (!r->
name || strlen (r->
name) == 0)
1443 int api = 0, cli = 0, barrier = 0, dispatch = 0, circuit = 0;
1444 u32 circuit_node_index;
1453 else if (
unformat (line_input,
"dispatch"))
1455 else if (
unformat (line_input,
"circuit-node %U",
1458 else if (
unformat (line_input,
"cli"))
1460 else if (
unformat (line_input,
"barrier"))
1462 else if (
unformat (line_input,
"disable"))
1464 else if (
unformat (line_input,
"enable"))
1488 if (dispatch || circuit)
1501 (vm,
" Event log API message trace: %s\n CLI command trace: %s",
1505 (vm,
" Barrier sync trace: %s",
1508 (vm,
" Graph Dispatch: %s",
1511 (vm,
" Graph Circuit: %s",
1539 .path =
"elog trace",
1540 .short_help =
"elog trace [api][cli][barrier][dispatch]\n" 1541 "[circuit-node <name> e.g. ethernet-input][disable]",
1558 .short_help =
"suspend debug CLI for 30ms",
1581 for (i = 0; i < lmin; i++)
1585 else if (c1->
path[i] > c2->
path[i])
1642 int show_mp_safe = va_arg (*args,
int);
1643 int show_not_mp_safe = va_arg (*args,
int);
1644 int show_hit = va_arg (*args,
int);
1645 int clear_hit = va_arg (*args,
int);
1649 char *format_string =
"\n%v";
1652 format_string =
"\n%v: %u";
1681 int show_mp_safe = 0;
1682 int show_not_mp_safe = 0;
1690 if (
unformat (input,
"not-mp-safe"))
1691 show_not_mp_safe = 1;
1694 else if (
unformat (input,
"clear-hit"))
1701 if (clear_hit == 0 && (show_mp_safe + show_not_mp_safe) == 0)
1702 show_mp_safe = show_not_mp_safe = 1;
1705 show_mp_safe, show_not_mp_safe, show_hit, clear_hit);
1756 .short_help =
"show cli [mp-safe][not-mp-safe][hit][clear-hit]",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
uword output_function_arg
void * clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]
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...
format_function_t format_vlib_node_name
int elog_trace_cli_commands
vlib_cli_command_t * commands
int vl_api_get_elog_trace_api_messages(void)
static clib_error_t * show_cli_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_cpu_flags
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static int vlib_cli_cmp_strings(void *a1, void *a2)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
uword * sub_rule_index_by_name
#define hash_set_mem(h, key, value)
DLMALLOC_EXPORT struct dlmallinfo mspace_mallinfo(mspace msp)
int vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
void * vlib_stats_push_heap(void *)
static clib_error_t * enable_disable_memory_trace(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_bitmap_dup(v)
Duplicate a bitmap.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vlib_worker_thread_barrier_sync(X)
clib_error_t * vlib_cli_register_parse_rule(struct vlib_main_t *vm, vlib_cli_parse_rule_t *c)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static u8 * format_mp_safe(u8 *s, va_list *args)
MALLINFO_FIELD_TYPE arena
#define VLIB_INIT_FUNCTION(x)
void vlib_unix_error_report(vlib_main_t *, clib_error_t *)
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 uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
uword * command_index_by_path
clib_file_main_t file_main
static int vlib_cli_cmp_rule(void *a1, void *a2)
static void * current_traced_heap
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
void * clib_per_numa_mheaps[CLIB_MAX_NUMAS]
static uword vlib_cli_normalize_path(char *input, char **result)
static u8 * format_vlib_cli_path(u8 *s, va_list *args)
#define vlib_call_init_function(vm, x)
uword clib_mem_trace_enable_disable(uword enable)
static clib_error_t * show_memory_usage(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * show_cpu(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_mheap(u8 *s, va_list *va)
vlib_worker_thread_t * vlib_worker_threads
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
static void add_sub_command(vlib_cli_main_t *cm, uword parent_index, uword child_index)
#define vec_insert(V, N, M)
Insert N vector elements starting at element M, initialize new elements to zero (no header...
void vl_msg_pop_heap(void *oldheap)
vlib_cli_command_function_t * function
static uword clib_bitmap_first_set(uword *ai)
Return the lowest numbered set bit in a bitmap.
static vlib_cli_command_t * get_sub_command(vlib_cli_main_t *cm, vlib_cli_command_t *parent, u32 si)
vlib_cli_sub_rule_t * sub_rules
static int vlib_cli_cmp_command(void *a1, void *a2)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
elog_event_t * event_ring
Vector of events (circular buffer).
#define vec_del1(v, i)
Delete the element at index I.
static void vlib_cli_make_parent(vlib_cli_main_t *cm, uword ci)
#define foreach_vlib_main(body)
void * vl_msg_push_heap(void)
clib_error_t * vlib_cli_register(vlib_main_t *vm, vlib_cli_command_t *c)
static uword * vlib_cli_sub_command_match(vlib_cli_command_t *c, unformat_input_t *input)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
vlib_cli_sub_command_t * sub_commands
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
int elog_trace_graph_dispatch
sll srl srl sll sra u16x4 i
int vl_api_set_elog_trace_api_messages(int enable)
#define vec_free(V)
Free vector's memory (no header).
static void * clib_mem_set_heap(void *heap)
static uword * clib_bitmap_andnot(uword *ai, uword *bi)
Logical operator across two bitmaps.
static uword parent_path_len(char *path)
static clib_error_t * vlib_cli_init(vlib_main_t *vm)
#define ELOG_TYPE_DECLARE(f)
u32 n_total_events_disable_limit
When count reaches limit logging is disabled.
static void * clib_mem_get_heap(void)
#define VLIB_CLI_COMMAND(x,...)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
#define clib_elf_section_data_next(a, extra)
static clib_error_t * suspend_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
#define clib_bitmap_free(v)
Free a bitmap.
static int sort_cmds_by_path(void *a1, void *a2)
uword * sub_command_index_by_name
u32 elog_trace_graph_circuit_node_index
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
static uword pointer_to_uword(const void *p)
static vlib_main_t * vlib_get_main(void)
static vlib_cli_command_t * all_subs(vlib_cli_main_t *cm, vlib_cli_command_t *subs, u32 command_index)
static uword clib_bitmap_count_set_bits(uword *ai)
Return the number of set bits in a bitmap.
struct vlib_cli_command_t * next_cli_command
#define hash_create_vec(elts, key_bytes, value_bytes)
static uword unformat_vlib_cli_sub_command(unformat_input_t *i, va_list *args)
u32 elog_string(elog_main_t *em, char *fmt,...)
add a string to the event-log string table
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u8 * format_vlib_cli_command_help(u8 *s, va_list *args)
static void cli_recursive_walk(vlib_cli_walk_args_t *aa)
static uword vlib_cli_command_is_empty(vlib_cli_command_t *c)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
format_function_t format_cpu_uarch
#define clib_error_free(e)
unformat_function_t unformat_vlib_node
#define hash_get_mem(h, key)
static clib_error_t * elog_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_cli_command_t * cli_command_registrations
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
#define vec_foreach(var, vec)
Vector iterator.
vlib_cli_parse_position_t * sub_command_positions
u32 n_total_events
Total number of events in buffer.
void() vlib_cli_output_function_t(uword arg, u8 *buffer, uword buffer_bytes)
vlib_cli_output_function_t * output_function
void clib_mem_trace(int enable)
import vnet interface_types api
static clib_error_t * restart_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_cpu_model_name
DLMALLOC_EXPORT void * mspace_least_addr(mspace msp)
int elog_trace_graph_circuit
static uword * clib_bitmap_and(uword *ai, uword *bi)
Logical operator across two bitmaps.
u8 ** vlib_cli_get_possible_completions(u8 *str)