1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
11 #include <sys/queue.h>
17 #include <rte_common.h>
18 #include <rte_debug.h>
19 #include <rte_ethdev.h>
20 #include <rte_malloc.h>
21 #include <rte_memory.h>
22 #include <rte_memzone.h>
23 #include <rte_launch.h>
24 #include <rte_tailq.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
28 #include <rte_atomic.h>
29 #include <rte_branch_prediction.h>
30 #include <rte_string_fns.h>
31 #include <rte_metrics.h>
32 #include <rte_cycles.h>
33 #include <rte_security.h>
34 #include <rte_cryptodev.h>
37 /* Maximum long option length for option parsing. */
38 #define MAX_LONG_OPT_SZ 64
39 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
41 #define MAX_STRING_LEN 256
43 #define STATS_BDR_FMT "========================================"
44 #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
45 STATS_BDR_FMT, s, w, STATS_BDR_FMT)
47 /**< mask of enabled ports */
48 static uint32_t enabled_port_mask;
50 static uint32_t enable_stats;
51 /**< Enable xstats. */
52 static uint32_t enable_xstats;
53 /**< Enable collectd format*/
54 static uint32_t enable_collectd_format;
55 /**< FD to send collectd format messages to STDOUT*/
57 /**< Host id process is running on */
58 static char host_id[MAX_LONG_OPT_SZ];
59 /**< Enable metrics. */
60 static uint32_t enable_metrics;
61 /**< Enable stats reset. */
62 static uint32_t reset_stats;
63 /**< Enable xstats reset. */
64 static uint32_t reset_xstats;
65 /**< Enable memory info. */
66 static uint32_t mem_info;
67 /**< Enable displaying xstat name. */
68 static uint32_t enable_xstats_name;
69 static char *xstats_name;
71 /**< Enable xstats by ids. */
72 #define MAX_NB_XSTATS_IDS 1024
73 static uint32_t nb_xstats_ids;
74 static uint64_t xstats_ids[MAX_NB_XSTATS_IDS];
77 static char bdr_str[MAX_STRING_LEN];
79 /**< Enable show port. */
80 static uint32_t enable_shw_port;
81 /**< Enable show tm. */
82 static uint32_t enable_shw_tm;
83 /**< Enable show crypto. */
84 static uint32_t enable_shw_crypto;
85 /**< Enable show ring. */
86 static uint32_t enable_shw_ring;
87 static char *ring_name;
88 /**< Enable show mempool. */
89 static uint32_t enable_shw_mempool;
90 static char *mempool_name;
94 proc_info_usage(const char *prgname)
96 printf("%s [EAL options] -- -p PORTMASK\n"
97 " -m to display DPDK memory zones, segments and TAILQ information\n"
98 " -p PORTMASK: hexadecimal bitmask of ports to retrieve stats for\n"
99 " --stats: to display port statistics, enabled by default\n"
100 " --xstats: to display extended port statistics, disabled by "
102 " --metrics: to display derived metrics of the ports, disabled by "
104 " --xstats-name NAME: to display single xstat id by NAME\n"
105 " --xstats-ids IDLIST: to display xstat values by id. "
106 "The argument is comma-separated list of xstat ids to print out.\n"
107 " --stats-reset: to reset port statistics\n"
108 " --xstats-reset: to reset port extended statistics\n"
109 " --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
110 " --host-id STRING: host id used to identify the system process is running on\n"
111 " --show-port: to display ports information\n"
112 " --show-tm: to display traffic manager information for ports\n"
113 " --show-crypto: to display crypto information\n"
114 " --show-ring[=name]: to display ring information\n"
115 " --show-mempool[=name]: to display mempool information\n",
120 * Parse the portmask provided at run time.
123 parse_portmask(const char *portmask)
130 /* parse hexadecimal string */
131 pm = strtoul(portmask, &end, 16);
132 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') ||
134 printf("%s ERROR parsing the port mask\n", __func__);
146 * Parse ids value list into array
149 parse_xstats_ids(char *list, uint64_t *ids, int limit) {
156 token = strtok_r(list, ",", &ctx);
157 while (token != NULL) {
158 ids[length] = strtoull(token, &endptr, 10);
166 token = strtok_r(NULL, ",", &ctx);
173 proc_info_preparse_args(int argc, char **argv)
175 char *prgname = argv[0];
178 for (i = 0; i < argc; i++) {
179 /* Print stats or xstats to STDOUT in collectd format */
180 if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
181 enable_collectd_format = 1;
182 stdout_fd = dup(STDOUT_FILENO);
183 close(STDOUT_FILENO);
185 if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
186 if ((i + 1) == argc) {
187 printf("Invalid host id or not specified\n");
188 proc_info_usage(prgname);
191 snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
195 if (!strlen(host_id)) {
196 int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
199 strcpy(host_id, "unknown");
205 /* Parse the argument given in the command line of the application */
207 proc_info_parse_args(int argc, char **argv)
211 char *prgname = argv[0];
212 static struct option long_option[] = {
213 {"stats", 0, NULL, 0},
214 {"stats-reset", 0, NULL, 0},
215 {"xstats", 0, NULL, 0},
216 {"metrics", 0, NULL, 0},
217 {"xstats-reset", 0, NULL, 0},
218 {"xstats-name", required_argument, NULL, 1},
219 {"collectd-format", 0, NULL, 0},
220 {"xstats-ids", 1, NULL, 1},
221 {"host-id", 0, NULL, 0},
222 {"show-port", 0, NULL, 0},
223 {"show-tm", 0, NULL, 0},
224 {"show-crypto", 0, NULL, 0},
225 {"show-ring", optional_argument, NULL, 0},
226 {"show-mempool", optional_argument, NULL, 0},
231 proc_info_usage(prgname);
233 /* Parse command line */
234 while ((opt = getopt_long(argc, argv, "p:m",
235 long_option, &option_index)) != EOF) {
239 enabled_port_mask = parse_portmask(optarg);
240 if (enabled_port_mask == 0) {
241 printf("invalid portmask\n");
242 proc_info_usage(prgname);
251 if (!strncmp(long_option[option_index].name, "stats",
255 else if (!strncmp(long_option[option_index].name, "xstats",
258 else if (!strncmp(long_option[option_index].name,
263 if (!strncmp(long_option[option_index].name, "stats-reset",
267 else if (!strncmp(long_option[option_index].name, "xstats-reset",
270 else if (!strncmp(long_option[option_index].name,
271 "show-port", MAX_LONG_OPT_SZ))
273 else if (!strncmp(long_option[option_index].name,
274 "show-tm", MAX_LONG_OPT_SZ))
276 else if (!strncmp(long_option[option_index].name,
277 "show-crypto", MAX_LONG_OPT_SZ))
278 enable_shw_crypto = 1;
279 else if (!strncmp(long_option[option_index].name,
280 "show-ring", MAX_LONG_OPT_SZ)) {
283 } else if (!strncmp(long_option[option_index].name,
284 "show-mempool", MAX_LONG_OPT_SZ)) {
285 enable_shw_mempool = 1;
286 mempool_name = optarg;
290 /* Print xstat single value given by name*/
291 if (!strncmp(long_option[option_index].name,
292 "xstats-name", MAX_LONG_OPT_SZ)) {
293 enable_xstats_name = 1;
294 xstats_name = optarg;
295 printf("name:%s:%s\n",
296 long_option[option_index].name,
298 } else if (!strncmp(long_option[option_index].name,
301 nb_xstats_ids = parse_xstats_ids(optarg,
302 xstats_ids, MAX_NB_XSTATS_IDS);
304 if (nb_xstats_ids <= 0) {
305 printf("xstats-id list parse error.\n");
312 proc_info_usage(prgname);
320 meminfo_display(void)
322 printf("----------- MEMORY_SEGMENTS -----------\n");
323 rte_dump_physmem_layout(stdout);
324 printf("--------- END_MEMORY_SEGMENTS ---------\n");
326 printf("------------ MEMORY_ZONES -------------\n");
327 rte_memzone_dump(stdout);
328 printf("---------- END_MEMORY_ZONES -----------\n");
330 printf("------------- TAIL_QUEUES -------------\n");
331 rte_dump_tailq(stdout);
332 printf("---------- END_TAIL_QUEUES ------------\n");
336 nic_stats_display(uint16_t port_id)
338 struct rte_eth_stats stats;
341 static const char *nic_stats_border = "########################";
343 rte_eth_stats_get(port_id, &stats);
344 printf("\n %s NIC statistics for port %-2d %s\n",
345 nic_stats_border, port_id, nic_stats_border);
347 printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
348 " RX-bytes: %-10"PRIu64"\n", stats.ipackets, stats.ierrors,
350 printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf);
351 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64
352 " TX-bytes: %-10"PRIu64"\n", stats.opackets, stats.oerrors,
356 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
357 printf(" Stats reg %2d RX-packets: %-10"PRIu64
358 " RX-errors: %-10"PRIu64
359 " RX-bytes: %-10"PRIu64"\n",
360 i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]);
364 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
365 printf(" Stats reg %2d TX-packets: %-10"PRIu64
366 " TX-bytes: %-10"PRIu64"\n",
367 i, stats.q_opackets[i], stats.q_obytes[i]);
370 printf(" %s############################%s\n",
371 nic_stats_border, nic_stats_border);
375 nic_stats_clear(uint16_t port_id)
377 printf("\n Clearing NIC stats for port %d\n", port_id);
378 rte_eth_stats_reset(port_id);
379 printf("\n NIC statistics for port %d cleared\n", port_id);
382 static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
383 const char *cnt_name) {
384 char *type_end = strrchr(cnt_name, '_');
386 if ((type_end != NULL) &&
387 (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
388 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
389 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
390 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
391 strncpy(cnt_type, "if_rx_dropped", cnt_type_len);
392 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
393 strncpy(cnt_type, "if_rx_octets", cnt_type_len);
394 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
395 strncpy(cnt_type, "if_rx_packets", cnt_type_len);
396 else if (strncmp(type_end, "_placement",
397 strlen("_placement")) == 0)
398 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
399 else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
400 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
402 /* Does not fit obvious type: use a more generic one */
403 strncpy(cnt_type, "derive", cnt_type_len);
404 } else if ((type_end != NULL) &&
405 (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
406 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
407 strncpy(cnt_type, "if_tx_errors", cnt_type_len);
408 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
409 strncpy(cnt_type, "if_tx_dropped", cnt_type_len);
410 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
411 strncpy(cnt_type, "if_tx_octets", cnt_type_len);
412 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
413 strncpy(cnt_type, "if_tx_packets", cnt_type_len);
415 /* Does not fit obvious type: use a more generic one */
416 strncpy(cnt_type, "derive", cnt_type_len);
417 } else if ((type_end != NULL) &&
418 (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
419 if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
420 strncpy(cnt_type, "operations", cnt_type_len);
421 else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
422 strncpy(cnt_type, "errors", cnt_type_len);
423 else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
424 strncpy(cnt_type, "filter_result", cnt_type_len);
425 } else if ((type_end != NULL) &&
426 (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
427 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
428 strncpy(cnt_type, "errors", cnt_type_len);
430 /* Does not fit obvious type, or strrchr error: */
431 /* use a more generic type */
432 strncpy(cnt_type, "derive", cnt_type_len);
437 nic_xstats_by_name_display(uint16_t port_id, char *name)
441 printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
444 if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
445 printf("%s: %"PRIu64"\n", name, id);
447 printf("Statistic not found...\n");
452 nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
454 struct rte_eth_xstat_name *xstats_names;
457 static const char *nic_stats_border = "########################";
459 values = malloc(sizeof(*values) * len);
460 if (values == NULL) {
461 printf("Cannot allocate memory for xstats\n");
465 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
466 if (xstats_names == NULL) {
467 printf("Cannot allocate memory for xstat names\n");
472 if (len != rte_eth_xstats_get_names_by_id(
473 port_id, xstats_names, len, ids)) {
474 printf("Cannot get xstat names\n");
478 printf("###### NIC extended statistics for port %-2d #########\n",
480 printf("%s############################\n", nic_stats_border);
481 ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
482 if (ret < 0 || ret > len) {
483 printf("Cannot get xstats\n");
487 for (i = 0; i < len; i++)
488 printf("%s: %"PRIu64"\n",
489 xstats_names[i].name,
492 printf("%s############################\n", nic_stats_border);
499 nic_xstats_display(uint16_t port_id)
501 struct rte_eth_xstat_name *xstats_names;
504 static const char *nic_stats_border = "########################";
506 len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
508 printf("Cannot get xstats count\n");
511 values = malloc(sizeof(*values) * len);
512 if (values == NULL) {
513 printf("Cannot allocate memory for xstats\n");
517 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
518 if (xstats_names == NULL) {
519 printf("Cannot allocate memory for xstat names\n");
523 if (len != rte_eth_xstats_get_names_by_id(
524 port_id, xstats_names, len, NULL)) {
525 printf("Cannot get xstat names\n");
529 printf("###### NIC extended statistics for port %-2d #########\n",
531 printf("%s############################\n",
533 ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
534 if (ret < 0 || ret > len) {
535 printf("Cannot get xstats\n");
539 for (i = 0; i < len; i++) {
540 if (enable_collectd_format) {
541 char counter_type[MAX_STRING_LEN];
542 char buf[MAX_STRING_LEN];
545 collectd_resolve_cnt_type(counter_type,
546 sizeof(counter_type),
547 xstats_names[i].name);
548 n = snprintf(buf, MAX_STRING_LEN,
549 "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
550 PRIu64"\n", host_id, port_id, counter_type,
551 xstats_names[i].name, values[i]);
552 if (n > sizeof(buf) - 1)
554 ret = write(stdout_fd, buf, n);
558 printf("%s: %"PRIu64"\n", xstats_names[i].name,
563 printf("%s############################\n",
571 nic_xstats_clear(uint16_t port_id)
573 printf("\n Clearing NIC xstats for port %d\n", port_id);
574 rte_eth_xstats_reset(port_id);
575 printf("\n NIC extended statistics for port %d cleared\n", port_id);
579 metrics_display(int port_id)
581 struct rte_metric_value *metrics;
582 struct rte_metric_name *names;
584 static const char *nic_stats_border = "########################";
586 len = rte_metrics_get_names(NULL, 0);
588 printf("Cannot get metrics count\n");
592 printf("No metrics to display (none have been registered)\n");
596 metrics = rte_malloc("proc_info_metrics",
597 sizeof(struct rte_metric_value) * len, 0);
598 if (metrics == NULL) {
599 printf("Cannot allocate memory for metrics\n");
603 names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
605 printf("Cannot allocate memory for metrcis names\n");
610 if (len != rte_metrics_get_names(names, len)) {
611 printf("Cannot get metrics names\n");
617 if (port_id == RTE_METRICS_GLOBAL)
618 printf("###### Non port specific metrics #########\n");
620 printf("###### metrics for port %-2d #########\n", port_id);
621 printf("%s############################\n", nic_stats_border);
622 ret = rte_metrics_get_values(port_id, metrics, len);
623 if (ret < 0 || ret > len) {
624 printf("Cannot get metrics values\n");
631 for (i = 0; i < len; i++)
632 printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
634 printf("%s############################\n", nic_stats_border);
645 snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD %"PRIu64,
647 STATS_BDR_STR(10, bdr_str);
649 RTE_ETH_FOREACH_DEV(i) {
651 struct rte_eth_link link;
652 struct rte_eth_dev_info dev_info;
653 struct rte_eth_rxq_info queue_info;
654 struct rte_eth_rss_conf rss_conf;
656 memset(&rss_conf, 0, sizeof(rss_conf));
658 snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
659 STATS_BDR_STR(5, bdr_str);
660 printf(" - generic config\n");
662 printf("\t -- Socket %d\n", rte_eth_dev_socket_id(i));
663 rte_eth_link_get(i, &link);
664 printf("\t -- link speed %d duplex %d,"
665 " auto neg %d status %d\n",
670 printf("\t -- promiscuous (%d)\n",
671 rte_eth_promiscuous_get(i));
672 ret = rte_eth_dev_get_mtu(i, &mtu);
674 printf("\t -- mtu (%d)\n", mtu);
676 rte_eth_dev_info_get(i, &dev_info);
678 printf(" - queue\n");
679 for (j = 0; j < dev_info.nb_rx_queues; j++) {
680 ret = rte_eth_rx_queue_info_get(i, j, &queue_info);
682 printf("\t -- queue %d rx scatter %d"
684 " offloads 0x%"PRIx64
685 " mempool socket %d\n",
687 queue_info.scattered_rx,
689 queue_info.conf.offloads,
690 queue_info.mp->socket_id);
694 ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
696 if (rss_conf.rss_key) {
698 printf("\t -- RSS len %u key (hex):",
699 rss_conf.rss_key_len);
700 for (k = 0; k < rss_conf.rss_key_len; k++)
701 printf(" %x", rss_conf.rss_key[k]);
702 printf("\t -- hf 0x%"PRIx64"\n",
707 printf(" - cyrpto context\n");
708 void *p_ctx = rte_eth_dev_get_sec_ctx(i);
709 printf("\t -- security context - %p\n", p_ctx);
712 printf("\t -- size %u\n",
713 rte_security_session_get_size(p_ctx));
714 const struct rte_security_capability *s_cap =
715 rte_security_capabilities_get(p_ctx);
717 printf("\t -- action (0x%x), protocol (0x%x),"
718 " offload flags (0x%x)\n",
722 printf("\t -- capabilities - oper type %x\n",
723 s_cap->crypto_capabilities->op);
728 STATS_BDR_STR(50, "");
732 display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
738 printf("\t -- nonleaf sched max:\n"
739 "\t\t + children (%u)\n"
740 "\t\t + sp priorities (%u)\n"
741 "\t\t + wfq children per group (%u)\n"
742 "\t\t + wfq groups (%u)\n"
743 "\t\t + wfq weight (%u)\n",
744 cap->nonleaf.sched_n_children_max,
745 cap->nonleaf.sched_sp_n_priorities_max,
746 cap->nonleaf.sched_wfq_n_children_per_group_max,
747 cap->nonleaf.sched_wfq_n_groups_max,
748 cap->nonleaf.sched_wfq_weight_max);
750 printf("\t -- leaf cman support:\n"
751 "\t\t + wred pkt mode (%d)\n"
752 "\t\t + wred byte mode (%d)\n"
753 "\t\t + head drop (%d)\n"
754 "\t\t + wred context private (%d)\n"
755 "\t\t + wred context shared (%u)\n",
756 cap->leaf.cman_wred_packet_mode_supported,
757 cap->leaf.cman_wred_byte_mode_supported,
758 cap->leaf.cman_head_drop_supported,
759 cap->leaf.cman_wred_context_private_supported,
760 cap->leaf.cman_wred_context_shared_n_max);
765 display_levelcap_info(int is_leaf, struct rte_tm_level_capabilities *cap)
771 printf("\t -- shaper private: (%d) dual rate (%d)\n",
772 cap->nonleaf.shaper_private_supported,
773 cap->nonleaf.shaper_private_dual_rate_supported);
774 printf("\t -- shaper share: (%u)\n",
775 cap->nonleaf.shaper_shared_n_max);
776 printf("\t -- non leaf sched MAX:\n"
777 "\t\t + children (%u)\n"
779 "\t\t + wfq children per group (%u)\n"
780 "\t\t + wfq groups (%u)\n"
781 "\t\t + wfq weight (%u)\n",
782 cap->nonleaf.sched_n_children_max,
783 cap->nonleaf.sched_sp_n_priorities_max,
784 cap->nonleaf.sched_wfq_n_children_per_group_max,
785 cap->nonleaf.sched_wfq_n_groups_max,
786 cap->nonleaf.sched_wfq_weight_max);
788 printf("\t -- shaper private: (%d) dual rate (%d)\n",
789 cap->leaf.shaper_private_supported,
790 cap->leaf.shaper_private_dual_rate_supported);
791 printf("\t -- shaper share: (%u)\n",
792 cap->leaf.shaper_shared_n_max);
793 printf(" -- leaf cman support:\n"
794 "\t\t + wred pkt mode (%d)\n"
795 "\t\t + wred byte mode (%d)\n"
796 "\t\t + head drop (%d)\n"
797 "\t\t + wred context private (%d)\n"
798 "\t\t + wred context shared (%u)\n",
799 cap->leaf.cman_wred_packet_mode_supported,
800 cap->leaf.cman_wred_byte_mode_supported,
801 cap->leaf.cman_head_drop_supported,
802 cap->leaf.cman_wred_context_private_supported,
803 cap->leaf.cman_wred_context_shared_n_max);
810 int ret = 0, check_for_leaf = 0, is_leaf = 0;
814 snprintf(bdr_str, MAX_STRING_LEN, " show - TM PMD %"PRIu64,
816 STATS_BDR_STR(10, bdr_str);
818 RTE_ETH_FOREACH_DEV(i) {
819 struct rte_eth_dev_info dev_info;
820 struct rte_tm_capabilities cap;
821 struct rte_tm_error error;
822 struct rte_tm_node_capabilities capnode;
823 struct rte_tm_level_capabilities caplevel;
824 uint32_t n_leaf_nodes = 0;
826 memset(&cap, 0, sizeof(cap));
827 memset(&error, 0, sizeof(error));
829 rte_eth_dev_info_get(i, &dev_info);
830 printf(" - Generic for port (%u)\n"
831 "\t -- driver name %s\n"
832 "\t -- max vf (%u)\n"
833 "\t -- max tx queues (%u)\n"
834 "\t -- number of tx queues (%u)\n",
836 dev_info.driver_name,
838 dev_info.max_tx_queues,
839 dev_info.nb_tx_queues);
841 ret = rte_tm_capabilities_get(i, &cap, &error);
845 printf(" - MAX: nodes (%u) levels (%u) children (%u)\n",
848 cap.sched_n_children_max);
850 printf(" - identical nodes: non leaf (%d) leaf (%d)\n",
851 cap.non_leaf_nodes_identical,
852 cap.leaf_nodes_identical);
854 printf(" - Shaper MAX:\n"
856 "\t -- private (%u) private dual (%d)\n"
857 "\t -- shared (%u) shared dual (%u)\n",
859 cap.shaper_private_n_max,
860 cap.shaper_private_dual_rate_n_max,
861 cap.shaper_shared_n_max,
862 cap.shaper_shared_dual_rate_n_max);
864 printf(" - mark support:\n");
865 printf("\t -- vlan dei: GREEN (%d) YELLOW (%d) RED (%d)\n",
866 cap.mark_vlan_dei_supported[RTE_TM_GREEN],
867 cap.mark_vlan_dei_supported[RTE_TM_YELLOW],
868 cap.mark_vlan_dei_supported[RTE_TM_RED]);
869 printf("\t -- ip ecn tcp: GREEN (%d) YELLOW (%d) RED (%d)\n",
870 cap.mark_ip_ecn_tcp_supported[RTE_TM_GREEN],
871 cap.mark_ip_ecn_tcp_supported[RTE_TM_YELLOW],
872 cap.mark_ip_ecn_tcp_supported[RTE_TM_RED]);
873 printf("\t -- ip ecn sctp: GREEN (%d) YELLOW (%d) RED (%d)\n",
874 cap.mark_ip_ecn_sctp_supported[RTE_TM_GREEN],
875 cap.mark_ip_ecn_sctp_supported[RTE_TM_YELLOW],
876 cap.mark_ip_ecn_sctp_supported[RTE_TM_RED]);
877 printf("\t -- ip dscp: GREEN (%d) YELLOW (%d) RED (%d)\n",
878 cap.mark_ip_dscp_supported[RTE_TM_GREEN],
879 cap.mark_ip_dscp_supported[RTE_TM_YELLOW],
880 cap.mark_ip_dscp_supported[RTE_TM_RED]);
882 printf(" - mask stats (0x%"PRIx64")"
883 " dynamic update (0x%"PRIx64")\n",
885 cap.dynamic_update_mask);
887 printf(" - sched MAX:\n"
889 "\t -- sp levels (%u)\n"
890 "\t -- wfq children per group (%u)\n"
891 "\t -- wfq groups (%u)\n"
892 "\t -- wfq weight (%u)\n",
893 cap.sched_sp_n_priorities_max,
894 cap.sched_sp_n_priorities_max,
895 cap.sched_wfq_n_children_per_group_max,
896 cap.sched_wfq_n_groups_max,
897 cap.sched_wfq_weight_max);
899 printf(" - CMAN support:\n"
900 "\t -- WRED mode: pkt (%d) byte (%d)\n"
901 "\t -- head drop (%d)\n",
902 cap.cman_wred_packet_mode_supported,
903 cap.cman_wred_byte_mode_supported,
904 cap.cman_head_drop_supported);
905 printf("\t -- MAX WRED CONTEXT:"
906 " total (%u) private (%u) shared (%u)\n",
907 cap.cman_wred_context_n_max,
908 cap.cman_wred_context_private_n_max,
909 cap.cman_wred_context_shared_n_max);
911 for (j = 0; j < cap.n_nodes_max; j++) {
912 memset(&capnode, 0, sizeof(capnode));
913 ret = rte_tm_node_capabilities_get(i, j,
920 printf(" NODE %u\n", j);
921 printf("\t - shaper private: (%d) dual rate (%d)\n",
922 capnode.shaper_private_supported,
923 capnode.shaper_private_dual_rate_supported);
924 printf("\t - shaper shared max: (%u)\n",
925 capnode.shaper_shared_n_max);
926 printf("\t - stats mask %"PRIx64"\n",
929 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
933 display_nodecap_info(is_leaf, &capnode);
936 for (j = 0; j < cap.n_levels_max; j++) {
937 memset(&caplevel, 0, sizeof(caplevel));
938 ret = rte_tm_level_capabilities_get(i, j,
943 printf(" - Level %u\n", j);
944 printf("\t -- node MAX: %u non leaf %u leaf %u\n",
945 caplevel.n_nodes_max,
946 caplevel.n_nodes_nonleaf_max,
947 caplevel.n_nodes_leaf_max);
948 printf("\t -- indetical: non leaf %u leaf %u\n",
949 caplevel.non_leaf_nodes_identical,
950 caplevel.leaf_nodes_identical);
952 for (k = 0; k < caplevel.n_nodes_max; k++) {
953 ret = rte_tm_node_type_get(i, k,
958 display_levelcap_info(is_leaf, &caplevel);
962 if (check_for_leaf) {
963 ret = rte_tm_get_number_of_leaf_nodes(i,
964 &n_leaf_nodes, &error);
966 printf(" - leaf nodes (%u)\n", n_leaf_nodes);
969 for (j = 0; j < n_leaf_nodes; j++) {
970 struct rte_tm_node_stats stats;
971 memset(&stats, 0, sizeof(stats));
973 ret = rte_tm_node_stats_read(i, j,
974 &stats, &cap.stats_mask, 0, &error);
978 printf(" - STATS for node (%u)\n", j);
979 printf(" -- pkts (%"PRIu64") bytes (%"PRIu64")\n",
980 stats.n_pkts, stats.n_bytes);
982 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
983 if (ret || (!is_leaf))
986 printf(" -- leaf queued:"
987 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
988 stats.leaf.n_pkts_queued,
989 stats.leaf.n_bytes_queued);
990 printf(" - dropped:\n"
992 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
994 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
996 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
997 stats.leaf.n_pkts_dropped[RTE_TM_GREEN],
998 stats.leaf.n_bytes_dropped[RTE_TM_GREEN],
999 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW],
1000 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW],
1001 stats.leaf.n_pkts_dropped[RTE_TM_RED],
1002 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
1006 STATS_BDR_STR(50, "");
1010 display_crypto_feature_info(uint64_t x)
1015 printf("\t -- feature flags\n");
1016 printf("\t\t + symmetric (%c), asymmetric (%c)\n"
1017 "\t\t + symmetric operation chaining (%c)\n",
1018 (x & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ? 'y' : 'n',
1019 (x & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) ? 'y' : 'n',
1020 (x & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING) ? 'y' : 'n');
1021 printf("\t\t + CPU: SSE (%c), AVX (%c), AVX2 (%c), AVX512 (%c)\n",
1022 (x & RTE_CRYPTODEV_FF_CPU_SSE) ? 'y' : 'n',
1023 (x & RTE_CRYPTODEV_FF_CPU_AVX) ? 'y' : 'n',
1024 (x & RTE_CRYPTODEV_FF_CPU_AVX2) ? 'y' : 'n',
1025 (x & RTE_CRYPTODEV_FF_CPU_AVX512) ? 'y' : 'n');
1026 printf("\t\t + AESNI: CPU (%c), HW (%c)\n",
1027 (x & RTE_CRYPTODEV_FF_CPU_AESNI) ? 'y' : 'n',
1028 (x & RTE_CRYPTODEV_FF_HW_ACCELERATED) ? 'y' : 'n');
1029 printf("\t\t + INLINE (%c)\n",
1030 (x & RTE_CRYPTODEV_FF_SECURITY) ? 'y' : 'n');
1031 printf("\t\t + ARM: NEON (%c), CE (%c)\n",
1032 (x & RTE_CRYPTODEV_FF_CPU_NEON) ? 'y' : 'n',
1033 (x & RTE_CRYPTODEV_FF_CPU_ARM_CE) ? 'y' : 'n');
1034 printf("\t -- buffer offload\n");
1035 printf("\t\t + IN_PLACE_SGL (%c)\n",
1036 (x & RTE_CRYPTODEV_FF_IN_PLACE_SGL) ? 'y' : 'n');
1037 printf("\t\t + OOP_SGL_IN_SGL_OUT (%c)\n",
1038 (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT) ? 'y' : 'n');
1039 printf("\t\t + OOP_SGL_IN_LB_OUT (%c)\n",
1040 (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT) ? 'y' : 'n');
1041 printf("\t\t + OOP_LB_IN_SGL_OUT (%c)\n",
1042 (x & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT) ? 'y' : 'n');
1043 printf("\t\t + OOP_LB_IN_LB_OUT (%c)\n",
1044 (x & RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT) ? 'y' : 'n');
1050 uint8_t crypto_dev_count = rte_cryptodev_count(), i;
1052 snprintf(bdr_str, MAX_STRING_LEN, " show - CRYPTO PMD %"PRIu64,
1054 STATS_BDR_STR(10, bdr_str);
1056 for (i = 0; i < crypto_dev_count; i++) {
1057 struct rte_cryptodev_info dev_info;
1058 struct rte_cryptodev_stats stats;
1060 rte_cryptodev_info_get(i, &dev_info);
1062 printf(" - device (%u)\n", i);
1063 printf("\t -- name (%s)\n"
1064 "\t -- driver (%s)\n"
1065 "\t -- id (%u) on socket (%d)\n"
1066 "\t -- queue pairs (%d)\n",
1067 rte_cryptodev_name_get(i),
1068 dev_info.driver_name,
1070 dev_info.device->numa_node,
1071 rte_cryptodev_queue_pair_count(i));
1073 display_crypto_feature_info(dev_info.feature_flags);
1075 memset(&stats, 0, sizeof(0));
1076 if (rte_cryptodev_stats_get(i, &stats) == 0) {
1077 printf("\t -- stats\n");
1078 printf("\t\t + enqueue count (%"PRIu64")"
1079 " error (%"PRIu64")\n",
1080 stats.enqueued_count,
1081 stats.enqueue_err_count);
1082 printf("\t\t + dequeue count (%"PRIu64")"
1083 " error (%"PRIu64")\n",
1084 stats.dequeued_count,
1085 stats.dequeue_err_count);
1089 STATS_BDR_STR(50, "");
1093 show_ring(char *name)
1095 snprintf(bdr_str, MAX_STRING_LEN, " show - RING %"PRIu64,
1097 STATS_BDR_STR(10, bdr_str);
1100 struct rte_ring *ptr = rte_ring_lookup(name);
1102 printf(" - Name (%s) on socket (%d)\n"
1104 "\t -- Single Producer Enqueue (%u)\n"
1105 "\t -- Single Consmer Dequeue (%u)\n",
1107 ptr->memzone->socket_id,
1108 ptr->flags & RING_F_SP_ENQ,
1109 ptr->flags & RING_F_SC_DEQ);
1110 printf(" - size (%u) mask (0x%x) capacity (%u)\n",
1114 printf(" - count (%u) free count (%u)\n",
1115 rte_ring_count(ptr),
1116 rte_ring_free_count(ptr));
1117 printf(" - full (%d) empty (%d)\n",
1119 rte_ring_empty(ptr));
1121 STATS_BDR_STR(50, "");
1126 rte_ring_list_dump(stdout);
1127 STATS_BDR_STR(50, "");
1131 show_mempool(char *name)
1135 snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL %"PRIu64,
1137 STATS_BDR_STR(10, bdr_str);
1140 struct rte_mempool *ptr = rte_mempool_lookup(name);
1143 printf(" - Name: %s on socket %d\n"
1145 "\t -- No spread (%c)\n"
1146 "\t -- No cache align (%c)\n"
1147 "\t -- SP put (%c), SC get (%c)\n"
1148 "\t -- Pool created (%c)\n"
1149 "\t -- No IOVA config (%c)\n",
1152 (flags & MEMPOOL_F_NO_SPREAD) ? 'y' : 'n',
1153 (flags & MEMPOOL_F_NO_CACHE_ALIGN) ? 'y' : 'n',
1154 (flags & MEMPOOL_F_SP_PUT) ? 'y' : 'n',
1155 (flags & MEMPOOL_F_SC_GET) ? 'y' : 'n',
1156 (flags & MEMPOOL_F_POOL_CREATED) ? 'y' : 'n',
1157 (flags & MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n');
1158 printf(" - Size %u Cache %u element %u\n"
1159 " - header %u trailer %u\n"
1160 " - private data size %u\n",
1166 ptr->private_data_size);
1167 printf(" - memezone - socket %d\n",
1168 ptr->mz->socket_id);
1169 printf(" - Count: avail (%u), in use (%u)\n",
1170 rte_mempool_avail_count(ptr),
1171 rte_mempool_in_use_count(ptr));
1173 STATS_BDR_STR(50, "");
1178 rte_mempool_list_dump(stdout);
1179 STATS_BDR_STR(50, "");
1183 main(int argc, char **argv)
1187 char c_flag[] = "-c1";
1188 char n_flag[] = "-n4";
1189 char mp_flag[] = "--proc-type=secondary";
1190 char *argp[argc + 3];
1193 /* preparse app arguments */
1194 ret = proc_info_preparse_args(argc, argv);
1196 printf("Failed to parse arguments\n");
1205 for (i = 1; i < argc; i++)
1206 argp[i + 3] = argv[i];
1210 ret = rte_eal_init(argc, argp);
1212 rte_panic("Cannot init EAL\n");
1217 if (!rte_eal_primary_proc_alive(NULL))
1218 rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
1220 /* parse app arguments */
1221 ret = proc_info_parse_args(argc, argv);
1223 rte_exit(EXIT_FAILURE, "Invalid argument\n");
1230 nb_ports = rte_eth_dev_count_avail();
1232 rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
1234 /* If no port mask was specified*/
1235 if (enabled_port_mask == 0)
1236 enabled_port_mask = 0xffff;
1238 RTE_ETH_FOREACH_DEV(i) {
1239 if (enabled_port_mask & (1 << i)) {
1241 nic_stats_display(i);
1242 else if (enable_xstats)
1243 nic_xstats_display(i);
1244 else if (reset_stats)
1246 else if (reset_xstats)
1247 nic_xstats_clear(i);
1248 else if (enable_xstats_name)
1249 nic_xstats_by_name_display(i, xstats_name);
1250 else if (nb_xstats_ids > 0)
1251 nic_xstats_by_ids_display(i, xstats_ids,
1253 else if (enable_metrics)
1258 /* print port independent stats */
1260 metrics_display(RTE_METRICS_GLOBAL);
1262 /* show information for PMD */
1263 if (enable_shw_port)
1267 if (enable_shw_crypto)
1269 if (enable_shw_ring)
1270 show_ring(ring_name);
1271 if (enable_shw_mempool)
1272 show_mempool(mempool_name);
1274 ret = rte_eal_cleanup();
1276 printf("Error from rte_eal_cleanup(), %d\n", ret);
1278 snprintf(bdr_str, MAX_STRING_LEN, " ");
1279 STATS_BDR_STR(50, bdr_str);