|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
20 #include <sys/types.h>
39 if (total_counts == 0)
48 percent = ((f64) vector_rate_histogram[SLEEP_##n##_US]) \
49 / (f64) total_counts; \
51 vlib_cli_output (vm, "Sleep %3d us: %llu, %.2f%%",n, \
52 vector_rate_histogram[SLEEP_##n##_US], \
67 .path =
"show api histogram",
68 .short_help =
"show api histogram",
91 .path =
"clear api histogram",
92 .short_help =
"clear api histogram",
105 u32 *confused_indices = 0;
111 "Name",
"PID",
"Queue Length",
"Queue VA",
"Health");
121 health =
"questionable";
128 regp->
name, q->consumer_pid, q->cursize,
134 regpp -
am->vl_clients);
135 vec_add1 (confused_indices, regpp -
am->vl_clients);
144 for (
i = 0;
i <
vec_len (confused_indices);
i++)
151 if (
am->missing_clients)
153 am->missing_clients);
167 if (
am->rx_trace == 0)
173 if (
am->rx_trace->enabled == 0)
179 if (
am->tx_trace == 0)
185 if (
am->tx_trace->enabled == 0)
198 .short_help =
"Show API information",
208 .path =
"show api clients",
209 .short_help =
"Client information",
220 .path =
"show api trace-status",
221 .short_help =
"Display API trace status",
250 am->msg_names[
i] ?
am->msg_names[
i] :
256 am->msg_names[
i] ?
am->msg_names[
i] :
257 " [no handler]",
am->message_bounce[
i],
271 .path =
"show api message-table",
272 .short_help =
"Message Table",
280 int len0, len1, clen;
284 clen = len0 < len1 ? len0 : len1;
285 return (strncmp ((
char *) a0->
name, (
char *) a1->
name, clen));
294 s =
format (s,
"%-50s%9s%9s",
"Name",
"First-ID",
"Last-ID");
338 .path =
"show api plugin",
339 .short_help =
"show api plugin",
363 trace_name =
"TX trace";
368 trace_name =
"RX trace";
377 s =
format (s,
"%s: not yet configured.\n", trace_name);
381 s =
format (s,
"%s: used %d of %d items, %s enabled, %s wrapped\n",
389 u32 first_index,
u32 last_index,
392 vl_api_trace_file_header_t *hp;
399 u32 nitems, nitems_msgtbl;
401 fd = open ((
char *) filename, O_RDONLY);
409 if (fstat (fd, &statb) < 0)
416 if (!(statb.st_mode & S_IFREG) || (statb.st_size < sizeof (*hp)))
423 file_size = statb.st_size;
424 file_size = (file_size + 4095) & ~(4095);
426 hp = mmap (0, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
428 if (hp == (vl_api_trace_file_header_t *) MAP_FAILED)
438 nitems = ntohl (hp->nitems);
440 if (last_index == (
u32) ~ 0)
442 last_index = nitems - 1;
445 if (first_index >= nitems || last_index >= nitems)
448 first_index, last_index, nitems - 1);
449 munmap (hp, file_size);
454 "Note: wrapped/incomplete trace, results may vary\n");
456 msg = (
u8 *) (hp + 1);
460 u32 msgtbl_size = ntohl (hp->msgtbl_size);
466 for (
i = 0;
i < nitems_msgtbl;
i++)
472 msgid_vec[msg_index] = msg_index2;
477 for (
i = 0;
i < first_index;
i++)
483 size = clib_host_to_net_u32 (*(
u32 *) msg);
487 if (msg_id <
vec_len (msgid_vec))
488 msg_id = msgid_vec[msg_id];
489 cfgp =
am->api_trace_cfg + msg_id;
493 munmap (hp, file_size);
500 am->replay_in_progress = 1;
502 for (;
i <= last_index;
i++)
511 size = clib_host_to_net_u32 (*(
u32 *) msg);
515 if (msg_id <
vec_len (msgid_vec))
517 msg_id = msgid_vec[msg_id];
520 cfgp =
am->api_trace_cfg + msg_id;
524 munmap (hp, file_size);
526 am->replay_in_progress = 0;
541 void (*endian_fp) (
void *);
542 if (msg_id >=
vec_len (
am->msg_endian_handlers)
543 || (
am->msg_endian_handlers[msg_id] == 0))
546 munmap (hp, file_size);
548 am->replay_in_progress = 0;
551 endian_fp =
am->msg_endian_handlers[msg_id];
552 (*endian_fp) (tmpbuf +
sizeof (
uword));
565 if (msg_id <
vec_len (
am->msg_print_handlers) &&
566 am->msg_print_handlers[msg_id])
568 u8 *(*print_fp) (
void *,
void *);
570 print_fp = (
void *)
am->msg_print_handlers[msg_id];
571 (*print_fp) (tmpbuf +
sizeof (
uword),
vm);
582 if (msg_id <
vec_len (
am->msg_print_handlers) &&
583 am->msg_print_handlers[msg_id])
587 u8 *(*print_fp) (
void *,
void *);
589 print_fp = (
void *)
am->msg_print_handlers[msg_id];
593 (*print_fp) (tmpbuf +
sizeof (
uword),
vm);
596 s =
format (0,
"static u8 * vl_api_%s_%d[%d] = {",
597 am->msg_names[msg_id],
i,
598 am->api_trace_cfg[msg_id].size);
600 for (j = 0; j <
am->api_trace_cfg[msg_id].size; j++)
604 s =
format (s,
"0x%02x,", tmpbuf[
sizeof (
uword) + j]);
606 s =
format (s,
"\n};\n%c", 0);
613 if (msg_id <
vec_len (
am->msg_print_handlers) &&
618 handler = (
void *)
am->msg_handlers[msg_id];
620 if (!
am->is_mp_safe[msg_id])
622 (*handler) (tmpbuf +
sizeof (
uword),
vm);
623 if (!
am->is_mp_safe[msg_id])
636 _vec_len (tmpbuf) = 0;
640 munmap (hp, file_size);
642 am->replay_in_progress = 0;
660 u32 nitems = 256 << 10;
664 u8 *chroot_filename = 0;
678 if (
unformat (line_input,
"nitems %d", &nitems))
685 else if (
unformat (line_input,
"off"))
691 else if (
unformat (line_input,
"save %s", &filename))
693 if (strstr ((
char *) filename,
"..")
694 ||
index ((
char *) filename,
'/'))
701 chroot_filename =
format (0,
"/tmp/%s%c", filename, 0);
705 fp = fopen ((
char *) chroot_filename,
"w");
725 "Error while writing end of buffer trace to file\n");
728 "Error while writing start of buffer trace to file\n");
735 else if (
unformat (line_input,
"dump %s", &filename))
739 else if (
unformat (line_input,
"replay %s", &filename))
743 else if (
unformat (line_input,
"initializers %s", &filename))
747 else if (
unformat (line_input,
"tx"))
759 else if (
unformat (line_input,
"status"))
764 else if (
unformat (line_input,
"free"))
771 else if (
unformat (line_input,
"post-mortem-on"))
773 else if (
unformat (line_input,
"post-mortem-off"))
793 .short_help =
"api trace [on|off][first <n>][last <n>][status][free]"
794 "[post-mortem-on][dump|save|replay <file>]",
812 else if (
unformat (input,
"tx nitems %u", &nitems)
842 else if (
unformat (input,
"debug on"))
844 am->msg_print_flag = 1;
846 else if (
unformat (input,
"debug off"))
848 am->msg_print_flag = 0;
872 .path =
"set api-trace",
873 .short_help =
"API trace [on][on tx][on rx][off][free][debug on][debug off]",
881 u32 nitems = 256 << 10;
889 if (
unformat (input,
"nitems %d", &nitems))
895 else if (
unformat (input,
"save-api-table %s",
896 &
am->save_msg_table_filename))
921 if (
unformat (input,
"length %d", &nitems) ||
922 (
unformat (input,
"len %d", &nitems)))
925 am->vlib_input_queue_length = nitems;
927 clib_warning (
"vlib input queue length %d too small, ignored",
1012 int compare_current = 0;
1013 int numeric_sort = 0;
1016 u32 ndifferences = 0;
1020 if (
unformat (input,
"file %s", &filename))
1022 else if (
unformat (input,
"compare-current")
1024 compare_current = 1;
1025 else if (
unformat (input,
"numeric"))
1032 if (numeric_sort && compare_current)
1034 (0,
"Comparison and numeric sorting are incompatible");
1048 for (
i = 0;
i < nmsgs;
i++)
1053 item->msg_index = msg_index;
1054 item->name_and_crc = name_and_crc;
1062 if (compare_current)
1070 for (
i = 0;
i < nmsgs;
i++)
1076 item->msg_index = msg_index;
1077 item->name_and_crc = name_and_crc;
1091 if (compare_current)
1118 ((
char *) table[
i].name_and_crc,
1119 (
char *) table[
i + 1].name_and_crc,
1130 || strcmp ((
char *) table[
i].
name, (
char *) table[
i + 1].
name))
1143 if (ndifferences == 0)
1209 .path =
"show api dump",
1210 .short_help =
"show api dump file <filename> [numeric | compare-current]",
static u8 * extract_name(u8 *s)
static clib_error_t * vl_api_status_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
void vl_msg_api_barrier_release(void)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
static vlib_cli_command_t cli_show_api_histogram_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_histogram_command)
#define clib_memcpy(d, s, n)
u8 * name
name of the plugin
static vlib_cli_command_t cli_show_api_status_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_status_command)
static vlib_cli_command_t cli_show_api_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_command)
#define clib_error_return(e, args...)
#define foreach_histogram_bucket
struct _svm_queue svm_queue_t
static heap_elt_t * first(heap_header_t *h)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
#define vec_delete(V, N, M)
Delete N elements starting at element M.
vl_api_trace_which_t
Trace RX / TX enum.
u16 last_msg_id
last assigned message ID
__clib_export void serialize_open_vector(serialize_main_t *m, u8 *vector)
static clib_error_t * api_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
api_trace_command_fn - control the binary API trace / replay feature
#define pool_put_index(p, i)
Free pool element with given index.
static vlib_cli_command_t api_trace_command
(constructor) VLIB_CLI_COMMAND (api_trace_command)
static int table_name_and_crc_cmp(void *a1, void *a2)
#define VLIB_CONFIG_FUNCTION(x, n,...)
u8 enabled
trace is enabled
static clib_error_t * vl_api_show_plugin_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
#define pool_foreach(VAR, POOL)
Iterate through pool.
int vl_msg_api_trace_save(api_main_t *am, vl_api_trace_which_t which, FILE *fp)
static vlib_cli_command_t dump_api_table_file
(constructor) VLIB_CLI_COMMAND (dump_api_table_file)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Trace configuration for a single message.
int vl_msg_api_trace_configure(api_main_t *am, vl_api_trace_which_t which, u32 nitems)
#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).
__clib_export clib_error_t * unserialize_open_clib_file(serialize_main_t *m, char *file)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
static clib_error_t * dump_api_table_file_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vlib_worker_thread_barrier_sync(X)
An API client registration, only in vpp/vlib.
static clib_error_t * api_trace_config_fn(vlib_main_t *vm, unformat_input_t *input)
static vlib_cli_command_t cli_show_api_plugin_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_plugin_command)
static void unserialize_integer(serialize_main_t *m, void *x, u32 n_bytes)
static heap_elt_t * last(heap_header_t *h)
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
static api_main_t * vlibapi_get_main(void)
u32 vl_msg_api_get_msg_index(u8 *name_and_crc)
void vl_sock_api_dump_clients(vlib_main_t *vm, api_main_t *am)
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
#define VLIB_CLI_COMMAND(x,...)
static vlib_cli_command_t cli_clear_api_histogram_command
(constructor) VLIB_CLI_COMMAND (cli_clear_api_histogram_command)
static clib_error_t * vl_api_trace_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static clib_error_t * vl_api_show_histogram_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
__clib_export void unserialize_open_data(serialize_main_t *m, u8 *data, uword n_data_bytes)
API main structure, used by both vpp and binary API clients.
static clib_error_t * vl_api_clear_histogram_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
__clib_export void unserialize_cstring(serialize_main_t *m, char **s)
#define vec_free(V)
Free vector's memory (no header).
static u8 * format_api_msg_range(u8 *s, va_list *args)
static int range_compare(vl_api_msg_range_t *a0, vl_api_msg_range_t *a1)
u32 nitems
Number of trace records.
u8 wrapped
trace has wrapped
int vl_msg_api_trace_free(api_main_t *am, vl_api_trace_which_t which)
description fragment has unexpected format
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Message range (belonging to a plugin)
u8 * format_vl_msg_api_trace_status(u8 *s, va_list *args)
u64 vector_rate_histogram[]
#define CLIB_MEM_UNPOISON(a, s)
static clib_error_t * vl_api_client_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static clib_error_t * vl_api_message_table_command(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cli_cmd)
static int table_id_cmp(void *a1, void *a2)
u16 first_msg_id
first assigned message ID
static vlib_cli_command_t cli_show_api_clients_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_clients_command)
static uword pool_elts(void *v)
Number of active elements in a pool.
int replay_enable
This message can be replayed
void vl_msg_api_post_mortem_dump_enable_disable(int enable)
#define clib_arch_is_little_endian
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
__clib_export void unserialize_close(serialize_main_t *m)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
#define clib_warning(format, args...)
static u64 unserialize_likely_small_unsigned_integer(serialize_main_t *m)
static void cleanup(void)
static void vl_msg_api_process_file(vlib_main_t *vm, u8 *filename, u32 first_index, u32 last_index, vl_api_replay_t which)
int vl_msg_api_trace_onoff(api_main_t *am, vl_api_trace_which_t which, int onoff)
static clib_error_t * api_queue_config_fn(vlib_main_t *vm, unformat_input_t *input)
void vl_msg_api_barrier_sync(void)
static u8 * extract_crc(u8 *s)
static vlib_cli_command_t cli_show_api_message_table_command
(constructor) VLIB_CLI_COMMAND (cli_show_api_message_table_command)