40 #include <sys/types.h> 77 for (i = 0; i <
vec_len (nodes); i++)
88 .path =
"show vlib graph",
89 .short_help =
"Show packet processing node graph",
100 u8 *chroot_filename = 0;
112 open ((
char *) chroot_filename, O_CREAT | O_TRUNC | O_WRONLY, 0664);
115 #define format__(vm__, fd__, ...) \ 118 vlib_cli_output((vm__), ## __VA_ARGS__); \ 122 fdformat((fd__), ## __VA_ARGS__); \ 125 format__ (vm, fd,
"%s",
"digraph {\n");
130 for (i = 0; i <
vec_len (nodes); i++)
132 for (j = 0; j <
vec_len (nodes[i]->next_nodes); j++)
149 "vlib graph dumped into `%s'. Run eg. `fdp -Tsvg -O %s'.",
150 chroot_filename, chroot_filename);
163 .path =
"show vlib graphviz",
164 .short_help =
"Dump packet processing node graph as a graphviz dotfile",
194 state =
"event wait";
206 if (n->
state == VLIB_NODE_STATE_DISABLED)
208 else if (n->
state == VLIB_NODE_STATE_INTERRUPT)
209 state =
"interrupt wait";
212 return format (s,
"%s", state);
220 int max = va_arg (*va,
int);
234 "%=30s%=17s%=16s%=16s%=16s%=16s",
235 "Name",
"Max Node Clocks",
"Vectors at Max",
236 "Max Clocks",
"Avg Clocks",
"Avg Vectors/Call");
239 "%=30s%=12s%=16s%=16s%=16s%=16s%=16s",
240 "Name",
"State",
"Calls",
"Vectors",
"Suspends",
241 "Clocks",
"Vectors/Call");
268 v = (double) p / (
double)
c;
279 misc_info =
format (misc_info,
"events pending, ");
284 s =
format (s,
"%-30v%=17.2e%=16d%=16.2e%=16.2e%=16.2e",
285 ns, maxc, maxn, maxcn, x, v);
287 s =
format (s,
"%-30v%=12U%16Ld%16Ld%16Ld%16.2e%16.2f", ns,
311 f64 *vectors_per_main_loop = 0;
312 f64 *last_vector_length_per_node = 0;
328 u64 n_input, n_output, n_drop, n_punt;
329 u64 n_internal_vectors, n_internal_calls;
330 u64 n_clocks, l, v,
c, d;
356 for (j = 0; j <
vec_len (stat_vms); j++)
358 stat_vm = stat_vms[j];
359 nm = &stat_vm->node_main;
372 vec_add1 (last_vector_length_per_node,
378 for (j = 0; j <
vec_len (stat_vms); j++)
380 stat_vm = stat_vms[j];
381 nodes = node_dups[j];
385 n_input = n_output = n_drop = n_punt = n_clocks = 0;
386 n_internal_vectors = n_internal_calls = 0;
387 for (i = 0; i <
vec_len (nodes); i++)
408 n_internal_vectors += v;
409 n_internal_calls +=
c;
437 "Time %.1f, average vectors/node %.2f, last %d main loops %.2f per node %.2f" 438 "\n vector rates in %.4e, out %.4e, drop %.4e, punt %.4e",
440 (n_internal_calls > 0
441 ? (
f64) n_internal_vectors / (
f64) n_internal_calls
444 vectors_per_main_loop[j],
445 last_vector_length_per_node[j],
447 (
f64) n_output / dt, (
f64) n_drop / dt, (
f64) n_punt / dt);
450 for (i = 0; i <
vec_len (nodes); i++)
458 if (c || d || !brief)
469 vec_free (last_vector_length_per_node);
477 .path =
"show runtime",
478 .short_help =
"Show packet processing runtime",
503 for (j = 0; j <
vec_len (stat_vms); j++)
505 stat_vm = stat_vms[j];
506 nm = &stat_vm->node_main;
530 .path =
"clear runtime",
531 .short_help =
"Clear packet processing runtime statistics",
545 u32 i, node_index = ~0;
547 u8 valid_node_name = 0;
554 if (
unformat (line_input,
"index %u", &node_index))
559 else if (!valid_node_name)
581 type_str =
"internal";
587 type_str =
"pre-input";
590 type_str =
"process";
593 type_str =
"unknown";
610 s =
format (s,
"\n %-15s %=8s %6s",
611 "Name",
"Priority",
"Active");
612 s =
format (s,
"\n %-15s %=8u %=6s", fnr->name, fnr->priority,
613 fnr->function == n->
function ?
"yes" :
"");
614 fnr = fnr->next_registration;
618 s =
format (s,
"\n default only");
630 if (vec_len (s) == 0)
631 s =
format (s,
"\n %10s %10s %=30s %8s",
632 "next-index",
"node-index",
"Node",
"Vectors");
638 if (vec_len (s) == 0)
639 s =
format (s,
"\n none");
648 vlib_node_t *pn = vlib_get_node (vm, i);
650 s = format (s,
"\n ");
651 s2 = format (s2,
"%v (%u)", pn->name, i);
652 s = format (s,
"%-35v", s2);
653 vec_reset_length (s2);
657 if (vec_len (s) == 0)
658 s =
format (s,
"\n none");
671 .short_help =
"show node [index] <node-name | node-index>",
694 if (!
unformat (line_input,
"%s", &variant))
713 if (!strncmp (fnr->name, (
char *) variant,
vec_len (variant) - 1))
727 fnr = fnr->next_registration;
740 .path =
"set node function",
741 .short_help =
"set node function <node-name> <variant-name>",
static f64 vlib_last_vectors_per_main_loop_as_f64(vlib_main_t *vm)
u32 max_clock
Maximum clock cycle for an invocation.
static clib_error_t * show_node_graphviz(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static f64 vlib_time_now(vlib_main_t *vm)
static int node_cmp(void *a1, void *a2)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define VLIB_NODE_FLAG_IS_PUNT
vlib_main_t ** vlib_mains
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
vlib_node_function_t * function
#define vlib_worker_thread_barrier_sync(X)
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
vlib_node_stats_t stats_last_clear
static clib_error_t * show_node_runtime(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_function_t * function
Node function to call.
#define VLIB_INVALID_NODE_INDEX
static uword clib_bitmap_is_zero(uword *ai)
predicate function; is an entire bitmap empty?
#define VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE
#define clib_error_return(e, args...)
struct _vlib_node_fn_registration vlib_node_fn_registration_t
vhost_vring_state_t state
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_CLOCK
static clib_error_t * show_node(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_PROCESS_IS_RUNNING
static u8 * format_vlib_node_stats(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.
vlib_node_stats_t stats_total
f64 time_last_runtime_stats_clear
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static clib_error_t * set_node_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u64 * n_vectors_by_next_node
#define format__(vm__, fd__,...)
#define vec_free(V)
Free vector's memory (no header).
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
static u8 * format_vlib_node_state(u8 *s, va_list *va)
vlib_node_fn_registration_t * node_fn_registrations
#define VLIB_CLI_COMMAND(x,...)
static clib_error_t * clear_node_runtime(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_node_cli_reference(void)
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
void vlib_node_sync_stats(vlib_main_t *vm, vlib_node_t *n)
#define vec_elt(v, i)
Get vector value at index i.
#define VLIB_NODE_FLAG_IS_HANDOFF
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_main_t node_main
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static clib_error_t * show_node_graph(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t unformat_vlib_node
#define VLIB_NODE_FLAG_IS_DROP
static vlib_process_t * vlib_get_process_from_node(vlib_main_t *vm, vlib_node_t *node)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
#define VLIB_NODE_FLAG_IS_OUTPUT
#define VLIB_PROCESS_IS_SUSPENDED_WAITING_FOR_EVENT
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
format_function_t format_vlib_node_graph
uword * non_empty_event_type_bitmap