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;
91 proc_info_usage(const char *prgname)
93 printf("%s [EAL options] -- -p PORTMASK\n"
94 " -m to display DPDK memory zones, segments and TAILQ information\n"
95 " -p PORTMASK: hexadecimal bitmask of ports to retrieve stats for\n"
96 " --stats: to display port statistics, enabled by default\n"
97 " --xstats: to display extended port statistics, disabled by "
99 " --metrics: to display derived metrics of the ports, disabled by "
101 " --xstats-name NAME: to display single xstat id by NAME\n"
102 " --xstats-ids IDLIST: to display xstat values by id. "
103 "The argument is comma-separated list of xstat ids to print out.\n"
104 " --stats-reset: to reset port statistics\n"
105 " --xstats-reset: to reset port extended statistics\n"
106 " --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
107 " --host-id STRING: host id used to identify the system process is running on\n"
108 " --show-port: to display ports information\n"
109 " --show-tm: to display traffic manager information for ports\n"
110 " --show-crypto: to display crypto information\n"
111 " --show-ring[=name]: to display ring information\n",
116 * Parse the portmask provided at run time.
119 parse_portmask(const char *portmask)
126 /* parse hexadecimal string */
127 pm = strtoul(portmask, &end, 16);
128 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') ||
130 printf("%s ERROR parsing the port mask\n", __func__);
142 * Parse ids value list into array
145 parse_xstats_ids(char *list, uint64_t *ids, int limit) {
152 token = strtok_r(list, ",", &ctx);
153 while (token != NULL) {
154 ids[length] = strtoull(token, &endptr, 10);
162 token = strtok_r(NULL, ",", &ctx);
169 proc_info_preparse_args(int argc, char **argv)
171 char *prgname = argv[0];
174 for (i = 0; i < argc; i++) {
175 /* Print stats or xstats to STDOUT in collectd format */
176 if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
177 enable_collectd_format = 1;
178 stdout_fd = dup(STDOUT_FILENO);
179 close(STDOUT_FILENO);
181 if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
182 if ((i + 1) == argc) {
183 printf("Invalid host id or not specified\n");
184 proc_info_usage(prgname);
187 snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
191 if (!strlen(host_id)) {
192 int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
195 strcpy(host_id, "unknown");
201 /* Parse the argument given in the command line of the application */
203 proc_info_parse_args(int argc, char **argv)
207 char *prgname = argv[0];
208 static struct option long_option[] = {
209 {"stats", 0, NULL, 0},
210 {"stats-reset", 0, NULL, 0},
211 {"xstats", 0, NULL, 0},
212 {"metrics", 0, NULL, 0},
213 {"xstats-reset", 0, NULL, 0},
214 {"xstats-name", required_argument, NULL, 1},
215 {"collectd-format", 0, NULL, 0},
216 {"xstats-ids", 1, NULL, 1},
217 {"host-id", 0, NULL, 0},
218 {"show-port", 0, NULL, 0},
219 {"show-tm", 0, NULL, 0},
220 {"show-crypto", 0, NULL, 0},
221 {"show-ring", optional_argument, NULL, 0},
226 proc_info_usage(prgname);
228 /* Parse command line */
229 while ((opt = getopt_long(argc, argv, "p:m",
230 long_option, &option_index)) != EOF) {
234 enabled_port_mask = parse_portmask(optarg);
235 if (enabled_port_mask == 0) {
236 printf("invalid portmask\n");
237 proc_info_usage(prgname);
246 if (!strncmp(long_option[option_index].name, "stats",
250 else if (!strncmp(long_option[option_index].name, "xstats",
253 else if (!strncmp(long_option[option_index].name,
258 if (!strncmp(long_option[option_index].name, "stats-reset",
262 else if (!strncmp(long_option[option_index].name, "xstats-reset",
265 else if (!strncmp(long_option[option_index].name,
266 "show-port", MAX_LONG_OPT_SZ))
268 else if (!strncmp(long_option[option_index].name,
269 "show-tm", MAX_LONG_OPT_SZ))
271 else if (!strncmp(long_option[option_index].name,
272 "show-crypto", MAX_LONG_OPT_SZ))
273 enable_shw_crypto = 1;
274 else if (!strncmp(long_option[option_index].name,
275 "show-ring", MAX_LONG_OPT_SZ)) {
281 /* Print xstat single value given by name*/
282 if (!strncmp(long_option[option_index].name,
283 "xstats-name", MAX_LONG_OPT_SZ)) {
284 enable_xstats_name = 1;
285 xstats_name = optarg;
286 printf("name:%s:%s\n",
287 long_option[option_index].name,
289 } else if (!strncmp(long_option[option_index].name,
292 nb_xstats_ids = parse_xstats_ids(optarg,
293 xstats_ids, MAX_NB_XSTATS_IDS);
295 if (nb_xstats_ids <= 0) {
296 printf("xstats-id list parse error.\n");
303 proc_info_usage(prgname);
311 meminfo_display(void)
313 printf("----------- MEMORY_SEGMENTS -----------\n");
314 rte_dump_physmem_layout(stdout);
315 printf("--------- END_MEMORY_SEGMENTS ---------\n");
317 printf("------------ MEMORY_ZONES -------------\n");
318 rte_memzone_dump(stdout);
319 printf("---------- END_MEMORY_ZONES -----------\n");
321 printf("------------- TAIL_QUEUES -------------\n");
322 rte_dump_tailq(stdout);
323 printf("---------- END_TAIL_QUEUES ------------\n");
327 nic_stats_display(uint16_t port_id)
329 struct rte_eth_stats stats;
332 static const char *nic_stats_border = "########################";
334 rte_eth_stats_get(port_id, &stats);
335 printf("\n %s NIC statistics for port %-2d %s\n",
336 nic_stats_border, port_id, nic_stats_border);
338 printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
339 " RX-bytes: %-10"PRIu64"\n", stats.ipackets, stats.ierrors,
341 printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf);
342 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64
343 " TX-bytes: %-10"PRIu64"\n", stats.opackets, stats.oerrors,
347 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
348 printf(" Stats reg %2d RX-packets: %-10"PRIu64
349 " RX-errors: %-10"PRIu64
350 " RX-bytes: %-10"PRIu64"\n",
351 i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]);
355 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
356 printf(" Stats reg %2d TX-packets: %-10"PRIu64
357 " TX-bytes: %-10"PRIu64"\n",
358 i, stats.q_opackets[i], stats.q_obytes[i]);
361 printf(" %s############################%s\n",
362 nic_stats_border, nic_stats_border);
366 nic_stats_clear(uint16_t port_id)
368 printf("\n Clearing NIC stats for port %d\n", port_id);
369 rte_eth_stats_reset(port_id);
370 printf("\n NIC statistics for port %d cleared\n", port_id);
373 static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
374 const char *cnt_name) {
375 char *type_end = strrchr(cnt_name, '_');
377 if ((type_end != NULL) &&
378 (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
379 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
380 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
381 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
382 strncpy(cnt_type, "if_rx_dropped", cnt_type_len);
383 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
384 strncpy(cnt_type, "if_rx_octets", cnt_type_len);
385 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
386 strncpy(cnt_type, "if_rx_packets", cnt_type_len);
387 else if (strncmp(type_end, "_placement",
388 strlen("_placement")) == 0)
389 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
390 else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
391 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
393 /* Does not fit obvious type: use a more generic one */
394 strncpy(cnt_type, "derive", cnt_type_len);
395 } else if ((type_end != NULL) &&
396 (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
397 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
398 strncpy(cnt_type, "if_tx_errors", cnt_type_len);
399 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
400 strncpy(cnt_type, "if_tx_dropped", cnt_type_len);
401 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
402 strncpy(cnt_type, "if_tx_octets", cnt_type_len);
403 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
404 strncpy(cnt_type, "if_tx_packets", cnt_type_len);
406 /* Does not fit obvious type: use a more generic one */
407 strncpy(cnt_type, "derive", cnt_type_len);
408 } else if ((type_end != NULL) &&
409 (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
410 if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
411 strncpy(cnt_type, "operations", cnt_type_len);
412 else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
413 strncpy(cnt_type, "errors", cnt_type_len);
414 else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
415 strncpy(cnt_type, "filter_result", cnt_type_len);
416 } else if ((type_end != NULL) &&
417 (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
418 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
419 strncpy(cnt_type, "errors", cnt_type_len);
421 /* Does not fit obvious type, or strrchr error: */
422 /* use a more generic type */
423 strncpy(cnt_type, "derive", cnt_type_len);
428 nic_xstats_by_name_display(uint16_t port_id, char *name)
432 printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
435 if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
436 printf("%s: %"PRIu64"\n", name, id);
438 printf("Statistic not found...\n");
443 nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
445 struct rte_eth_xstat_name *xstats_names;
448 static const char *nic_stats_border = "########################";
450 values = malloc(sizeof(*values) * len);
451 if (values == NULL) {
452 printf("Cannot allocate memory for xstats\n");
456 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
457 if (xstats_names == NULL) {
458 printf("Cannot allocate memory for xstat names\n");
463 if (len != rte_eth_xstats_get_names_by_id(
464 port_id, xstats_names, len, ids)) {
465 printf("Cannot get xstat names\n");
469 printf("###### NIC extended statistics for port %-2d #########\n",
471 printf("%s############################\n", nic_stats_border);
472 ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
473 if (ret < 0 || ret > len) {
474 printf("Cannot get xstats\n");
478 for (i = 0; i < len; i++)
479 printf("%s: %"PRIu64"\n",
480 xstats_names[i].name,
483 printf("%s############################\n", nic_stats_border);
490 nic_xstats_display(uint16_t port_id)
492 struct rte_eth_xstat_name *xstats_names;
495 static const char *nic_stats_border = "########################";
497 len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
499 printf("Cannot get xstats count\n");
502 values = malloc(sizeof(*values) * len);
503 if (values == NULL) {
504 printf("Cannot allocate memory for xstats\n");
508 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
509 if (xstats_names == NULL) {
510 printf("Cannot allocate memory for xstat names\n");
514 if (len != rte_eth_xstats_get_names_by_id(
515 port_id, xstats_names, len, NULL)) {
516 printf("Cannot get xstat names\n");
520 printf("###### NIC extended statistics for port %-2d #########\n",
522 printf("%s############################\n",
524 ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
525 if (ret < 0 || ret > len) {
526 printf("Cannot get xstats\n");
530 for (i = 0; i < len; i++) {
531 if (enable_collectd_format) {
532 char counter_type[MAX_STRING_LEN];
533 char buf[MAX_STRING_LEN];
536 collectd_resolve_cnt_type(counter_type,
537 sizeof(counter_type),
538 xstats_names[i].name);
539 n = snprintf(buf, MAX_STRING_LEN,
540 "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
541 PRIu64"\n", host_id, port_id, counter_type,
542 xstats_names[i].name, values[i]);
543 if (n > sizeof(buf) - 1)
545 ret = write(stdout_fd, buf, n);
549 printf("%s: %"PRIu64"\n", xstats_names[i].name,
554 printf("%s############################\n",
562 nic_xstats_clear(uint16_t port_id)
564 printf("\n Clearing NIC xstats for port %d\n", port_id);
565 rte_eth_xstats_reset(port_id);
566 printf("\n NIC extended statistics for port %d cleared\n", port_id);
570 metrics_display(int port_id)
572 struct rte_metric_value *metrics;
573 struct rte_metric_name *names;
575 static const char *nic_stats_border = "########################";
577 len = rte_metrics_get_names(NULL, 0);
579 printf("Cannot get metrics count\n");
583 printf("No metrics to display (none have been registered)\n");
587 metrics = rte_malloc("proc_info_metrics",
588 sizeof(struct rte_metric_value) * len, 0);
589 if (metrics == NULL) {
590 printf("Cannot allocate memory for metrics\n");
594 names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
596 printf("Cannot allocate memory for metrcis names\n");
601 if (len != rte_metrics_get_names(names, len)) {
602 printf("Cannot get metrics names\n");
608 if (port_id == RTE_METRICS_GLOBAL)
609 printf("###### Non port specific metrics #########\n");
611 printf("###### metrics for port %-2d #########\n", port_id);
612 printf("%s############################\n", nic_stats_border);
613 ret = rte_metrics_get_values(port_id, metrics, len);
614 if (ret < 0 || ret > len) {
615 printf("Cannot get metrics values\n");
622 for (i = 0; i < len; i++)
623 printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
625 printf("%s############################\n", nic_stats_border);
636 snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD %"PRIu64,
638 STATS_BDR_STR(10, bdr_str);
640 RTE_ETH_FOREACH_DEV(i) {
642 struct rte_eth_link link;
643 struct rte_eth_dev_info dev_info;
644 struct rte_eth_rxq_info queue_info;
645 struct rte_eth_rss_conf rss_conf;
647 memset(&rss_conf, 0, sizeof(rss_conf));
649 snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
650 STATS_BDR_STR(5, bdr_str);
651 printf(" - generic config\n");
653 printf("\t -- Socket %d\n", rte_eth_dev_socket_id(i));
654 rte_eth_link_get(i, &link);
655 printf("\t -- link speed %d duplex %d,"
656 " auto neg %d status %d\n",
661 printf("\t -- promiscuous (%d)\n",
662 rte_eth_promiscuous_get(i));
663 ret = rte_eth_dev_get_mtu(i, &mtu);
665 printf("\t -- mtu (%d)\n", mtu);
667 rte_eth_dev_info_get(i, &dev_info);
669 printf(" - queue\n");
670 for (j = 0; j < dev_info.nb_rx_queues; j++) {
671 ret = rte_eth_rx_queue_info_get(i, j, &queue_info);
673 printf("\t -- queue %d rx scatter %d"
675 " offloads 0x%"PRIx64
676 " mempool socket %d\n",
678 queue_info.scattered_rx,
680 queue_info.conf.offloads,
681 queue_info.mp->socket_id);
685 ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
687 if (rss_conf.rss_key) {
689 printf("\t -- RSS len %u key (hex):",
690 rss_conf.rss_key_len);
691 for (k = 0; k < rss_conf.rss_key_len; k++)
692 printf(" %x", rss_conf.rss_key[k]);
693 printf("\t -- hf 0x%"PRIx64"\n",
698 printf(" - cyrpto context\n");
699 void *p_ctx = rte_eth_dev_get_sec_ctx(i);
700 printf("\t -- security context - %p\n", p_ctx);
703 printf("\t -- size %u\n",
704 rte_security_session_get_size(p_ctx));
705 const struct rte_security_capability *s_cap =
706 rte_security_capabilities_get(p_ctx);
708 printf("\t -- action (0x%x), protocol (0x%x),"
709 " offload flags (0x%x)\n",
713 printf("\t -- capabilities - oper type %x\n",
714 s_cap->crypto_capabilities->op);
719 STATS_BDR_STR(50, "");
723 display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
729 printf("\t -- nonleaf sched max:\n"
730 "\t\t + children (%u)\n"
731 "\t\t + sp priorities (%u)\n"
732 "\t\t + wfq children per group (%u)\n"
733 "\t\t + wfq groups (%u)\n"
734 "\t\t + wfq weight (%u)\n",
735 cap->nonleaf.sched_n_children_max,
736 cap->nonleaf.sched_sp_n_priorities_max,
737 cap->nonleaf.sched_wfq_n_children_per_group_max,
738 cap->nonleaf.sched_wfq_n_groups_max,
739 cap->nonleaf.sched_wfq_weight_max);
741 printf("\t -- leaf cman support:\n"
742 "\t\t + wred pkt mode (%d)\n"
743 "\t\t + wred byte mode (%d)\n"
744 "\t\t + head drop (%d)\n"
745 "\t\t + wred context private (%d)\n"
746 "\t\t + wred context shared (%u)\n",
747 cap->leaf.cman_wred_packet_mode_supported,
748 cap->leaf.cman_wred_byte_mode_supported,
749 cap->leaf.cman_head_drop_supported,
750 cap->leaf.cman_wred_context_private_supported,
751 cap->leaf.cman_wred_context_shared_n_max);
756 display_levelcap_info(int is_leaf, struct rte_tm_level_capabilities *cap)
762 printf("\t -- shaper private: (%d) dual rate (%d)\n",
763 cap->nonleaf.shaper_private_supported,
764 cap->nonleaf.shaper_private_dual_rate_supported);
765 printf("\t -- shaper share: (%u)\n",
766 cap->nonleaf.shaper_shared_n_max);
767 printf("\t -- non leaf sched MAX:\n"
768 "\t\t + children (%u)\n"
770 "\t\t + wfq children per group (%u)\n"
771 "\t\t + wfq groups (%u)\n"
772 "\t\t + wfq weight (%u)\n",
773 cap->nonleaf.sched_n_children_max,
774 cap->nonleaf.sched_sp_n_priorities_max,
775 cap->nonleaf.sched_wfq_n_children_per_group_max,
776 cap->nonleaf.sched_wfq_n_groups_max,
777 cap->nonleaf.sched_wfq_weight_max);
779 printf("\t -- shaper private: (%d) dual rate (%d)\n",
780 cap->leaf.shaper_private_supported,
781 cap->leaf.shaper_private_dual_rate_supported);
782 printf("\t -- shaper share: (%u)\n",
783 cap->leaf.shaper_shared_n_max);
784 printf(" -- leaf cman support:\n"
785 "\t\t + wred pkt mode (%d)\n"
786 "\t\t + wred byte mode (%d)\n"
787 "\t\t + head drop (%d)\n"
788 "\t\t + wred context private (%d)\n"
789 "\t\t + wred context shared (%u)\n",
790 cap->leaf.cman_wred_packet_mode_supported,
791 cap->leaf.cman_wred_byte_mode_supported,
792 cap->leaf.cman_head_drop_supported,
793 cap->leaf.cman_wred_context_private_supported,
794 cap->leaf.cman_wred_context_shared_n_max);
801 int ret = 0, check_for_leaf = 0, is_leaf = 0;
805 snprintf(bdr_str, MAX_STRING_LEN, " show - TM PMD %"PRIu64,
807 STATS_BDR_STR(10, bdr_str);
809 RTE_ETH_FOREACH_DEV(i) {
810 struct rte_eth_dev_info dev_info;
811 struct rte_tm_capabilities cap;
812 struct rte_tm_error error;
813 struct rte_tm_node_capabilities capnode;
814 struct rte_tm_level_capabilities caplevel;
815 uint32_t n_leaf_nodes = 0;
817 memset(&cap, 0, sizeof(cap));
818 memset(&error, 0, sizeof(error));
820 rte_eth_dev_info_get(i, &dev_info);
821 printf(" - Generic for port (%u)\n"
822 "\t -- driver name %s\n"
823 "\t -- max vf (%u)\n"
824 "\t -- max tx queues (%u)\n"
825 "\t -- number of tx queues (%u)\n",
827 dev_info.driver_name,
829 dev_info.max_tx_queues,
830 dev_info.nb_tx_queues);
832 ret = rte_tm_capabilities_get(i, &cap, &error);
836 printf(" - MAX: nodes (%u) levels (%u) children (%u)\n",
839 cap.sched_n_children_max);
841 printf(" - identical nodes: non leaf (%d) leaf (%d)\n",
842 cap.non_leaf_nodes_identical,
843 cap.leaf_nodes_identical);
845 printf(" - Shaper MAX:\n"
847 "\t -- private (%u) private dual (%d)\n"
848 "\t -- shared (%u) shared dual (%u)\n",
850 cap.shaper_private_n_max,
851 cap.shaper_private_dual_rate_n_max,
852 cap.shaper_shared_n_max,
853 cap.shaper_shared_dual_rate_n_max);
855 printf(" - mark support:\n");
856 printf("\t -- vlan dei: GREEN (%d) YELLOW (%d) RED (%d)\n",
857 cap.mark_vlan_dei_supported[RTE_TM_GREEN],
858 cap.mark_vlan_dei_supported[RTE_TM_YELLOW],
859 cap.mark_vlan_dei_supported[RTE_TM_RED]);
860 printf("\t -- ip ecn tcp: GREEN (%d) YELLOW (%d) RED (%d)\n",
861 cap.mark_ip_ecn_tcp_supported[RTE_TM_GREEN],
862 cap.mark_ip_ecn_tcp_supported[RTE_TM_YELLOW],
863 cap.mark_ip_ecn_tcp_supported[RTE_TM_RED]);
864 printf("\t -- ip ecn sctp: GREEN (%d) YELLOW (%d) RED (%d)\n",
865 cap.mark_ip_ecn_sctp_supported[RTE_TM_GREEN],
866 cap.mark_ip_ecn_sctp_supported[RTE_TM_YELLOW],
867 cap.mark_ip_ecn_sctp_supported[RTE_TM_RED]);
868 printf("\t -- ip dscp: GREEN (%d) YELLOW (%d) RED (%d)\n",
869 cap.mark_ip_dscp_supported[RTE_TM_GREEN],
870 cap.mark_ip_dscp_supported[RTE_TM_YELLOW],
871 cap.mark_ip_dscp_supported[RTE_TM_RED]);
873 printf(" - mask stats (0x%"PRIx64")"
874 " dynamic update (0x%"PRIx64")\n",
876 cap.dynamic_update_mask);
878 printf(" - sched MAX:\n"
880 "\t -- sp levels (%u)\n"
881 "\t -- wfq children per group (%u)\n"
882 "\t -- wfq groups (%u)\n"
883 "\t -- wfq weight (%u)\n",
884 cap.sched_sp_n_priorities_max,
885 cap.sched_sp_n_priorities_max,
886 cap.sched_wfq_n_children_per_group_max,
887 cap.sched_wfq_n_groups_max,
888 cap.sched_wfq_weight_max);
890 printf(" - CMAN support:\n"
891 "\t -- WRED mode: pkt (%d) byte (%d)\n"
892 "\t -- head drop (%d)\n",
893 cap.cman_wred_packet_mode_supported,
894 cap.cman_wred_byte_mode_supported,
895 cap.cman_head_drop_supported);
896 printf("\t -- MAX WRED CONTEXT:"
897 " total (%u) private (%u) shared (%u)\n",
898 cap.cman_wred_context_n_max,
899 cap.cman_wred_context_private_n_max,
900 cap.cman_wred_context_shared_n_max);
902 for (j = 0; j < cap.n_nodes_max; j++) {
903 memset(&capnode, 0, sizeof(capnode));
904 ret = rte_tm_node_capabilities_get(i, j,
911 printf(" NODE %u\n", j);
912 printf("\t - shaper private: (%d) dual rate (%d)\n",
913 capnode.shaper_private_supported,
914 capnode.shaper_private_dual_rate_supported);
915 printf("\t - shaper shared max: (%u)\n",
916 capnode.shaper_shared_n_max);
917 printf("\t - stats mask %"PRIx64"\n",
920 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
924 display_nodecap_info(is_leaf, &capnode);
927 for (j = 0; j < cap.n_levels_max; j++) {
928 memset(&caplevel, 0, sizeof(caplevel));
929 ret = rte_tm_level_capabilities_get(i, j,
934 printf(" - Level %u\n", j);
935 printf("\t -- node MAX: %u non leaf %u leaf %u\n",
936 caplevel.n_nodes_max,
937 caplevel.n_nodes_nonleaf_max,
938 caplevel.n_nodes_leaf_max);
939 printf("\t -- indetical: non leaf %u leaf %u\n",
940 caplevel.non_leaf_nodes_identical,
941 caplevel.leaf_nodes_identical);
943 for (k = 0; k < caplevel.n_nodes_max; k++) {
944 ret = rte_tm_node_type_get(i, k,
949 display_levelcap_info(is_leaf, &caplevel);
953 if (check_for_leaf) {
954 ret = rte_tm_get_number_of_leaf_nodes(i,
955 &n_leaf_nodes, &error);
957 printf(" - leaf nodes (%u)\n", n_leaf_nodes);
960 for (j = 0; j < n_leaf_nodes; j++) {
961 struct rte_tm_node_stats stats;
962 memset(&stats, 0, sizeof(stats));
964 ret = rte_tm_node_stats_read(i, j,
965 &stats, &cap.stats_mask, 0, &error);
969 printf(" - STATS for node (%u)\n", j);
970 printf(" -- pkts (%"PRIu64") bytes (%"PRIu64")\n",
971 stats.n_pkts, stats.n_bytes);
973 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
974 if (ret || (!is_leaf))
977 printf(" -- leaf queued:"
978 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
979 stats.leaf.n_pkts_queued,
980 stats.leaf.n_bytes_queued);
981 printf(" - dropped:\n"
983 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
985 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
987 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
988 stats.leaf.n_pkts_dropped[RTE_TM_GREEN],
989 stats.leaf.n_bytes_dropped[RTE_TM_GREEN],
990 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW],
991 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW],
992 stats.leaf.n_pkts_dropped[RTE_TM_RED],
993 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
997 STATS_BDR_STR(50, "");
1001 display_crypto_feature_info(uint64_t x)
1006 printf("\t -- feature flags\n");
1007 printf("\t\t + symmetric (%c), asymmetric (%c)\n"
1008 "\t\t + symmetric operation chaining (%c)\n",
1009 (x & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ? 'y' : 'n',
1010 (x & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) ? 'y' : 'n',
1011 (x & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING) ? 'y' : 'n');
1012 printf("\t\t + CPU: SSE (%c), AVX (%c), AVX2 (%c), AVX512 (%c)\n",
1013 (x & RTE_CRYPTODEV_FF_CPU_SSE) ? 'y' : 'n',
1014 (x & RTE_CRYPTODEV_FF_CPU_AVX) ? 'y' : 'n',
1015 (x & RTE_CRYPTODEV_FF_CPU_AVX2) ? 'y' : 'n',
1016 (x & RTE_CRYPTODEV_FF_CPU_AVX512) ? 'y' : 'n');
1017 printf("\t\t + AESNI: CPU (%c), HW (%c)\n",
1018 (x & RTE_CRYPTODEV_FF_CPU_AESNI) ? 'y' : 'n',
1019 (x & RTE_CRYPTODEV_FF_HW_ACCELERATED) ? 'y' : 'n');
1020 printf("\t\t + INLINE (%c)\n",
1021 (x & RTE_CRYPTODEV_FF_SECURITY) ? 'y' : 'n');
1022 printf("\t\t + ARM: NEON (%c), CE (%c)\n",
1023 (x & RTE_CRYPTODEV_FF_CPU_NEON) ? 'y' : 'n',
1024 (x & RTE_CRYPTODEV_FF_CPU_ARM_CE) ? 'y' : 'n');
1025 printf("\t -- buffer offload\n");
1026 printf("\t\t + IN_PLACE_SGL (%c)\n",
1027 (x & RTE_CRYPTODEV_FF_IN_PLACE_SGL) ? 'y' : 'n');
1028 printf("\t\t + OOP_SGL_IN_SGL_OUT (%c)\n",
1029 (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT) ? 'y' : 'n');
1030 printf("\t\t + OOP_SGL_IN_LB_OUT (%c)\n",
1031 (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT) ? 'y' : 'n');
1032 printf("\t\t + OOP_LB_IN_SGL_OUT (%c)\n",
1033 (x & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT) ? 'y' : 'n');
1034 printf("\t\t + OOP_LB_IN_LB_OUT (%c)\n",
1035 (x & RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT) ? 'y' : 'n');
1041 uint8_t crypto_dev_count = rte_cryptodev_count(), i;
1043 snprintf(bdr_str, MAX_STRING_LEN, " show - CRYPTO PMD %"PRIu64,
1045 STATS_BDR_STR(10, bdr_str);
1047 for (i = 0; i < crypto_dev_count; i++) {
1048 struct rte_cryptodev_info dev_info;
1049 struct rte_cryptodev_stats stats;
1051 rte_cryptodev_info_get(i, &dev_info);
1053 printf(" - device (%u)\n", i);
1054 printf("\t -- name (%s)\n"
1055 "\t -- driver (%s)\n"
1056 "\t -- id (%u) on socket (%d)\n"
1057 "\t -- queue pairs (%d)\n",
1058 rte_cryptodev_name_get(i),
1059 dev_info.driver_name,
1061 dev_info.device->numa_node,
1062 rte_cryptodev_queue_pair_count(i));
1064 display_crypto_feature_info(dev_info.feature_flags);
1066 memset(&stats, 0, sizeof(0));
1067 if (rte_cryptodev_stats_get(i, &stats) == 0) {
1068 printf("\t -- stats\n");
1069 printf("\t\t + enqueue count (%"PRIu64")"
1070 " error (%"PRIu64")\n",
1071 stats.enqueued_count,
1072 stats.enqueue_err_count);
1073 printf("\t\t + dequeue count (%"PRIu64")"
1074 " error (%"PRIu64")\n",
1075 stats.dequeued_count,
1076 stats.dequeue_err_count);
1080 STATS_BDR_STR(50, "");
1084 show_ring(char *name)
1086 snprintf(bdr_str, MAX_STRING_LEN, " show - RING %"PRIu64,
1088 STATS_BDR_STR(10, bdr_str);
1091 struct rte_ring *ptr = rte_ring_lookup(name);
1093 printf(" - Name (%s) on socket (%d)\n"
1095 "\t -- Single Producer Enqueue (%u)\n"
1096 "\t -- Single Consmer Dequeue (%u)\n",
1098 ptr->memzone->socket_id,
1099 ptr->flags & RING_F_SP_ENQ,
1100 ptr->flags & RING_F_SC_DEQ);
1101 printf(" - size (%u) mask (0x%x) capacity (%u)\n",
1105 printf(" - count (%u) free count (%u)\n",
1106 rte_ring_count(ptr),
1107 rte_ring_free_count(ptr));
1108 printf(" - full (%d) empty (%d)\n",
1110 rte_ring_empty(ptr));
1112 STATS_BDR_STR(50, "");
1117 rte_ring_list_dump(stdout);
1118 STATS_BDR_STR(50, "");
1122 main(int argc, char **argv)
1126 char c_flag[] = "-c1";
1127 char n_flag[] = "-n4";
1128 char mp_flag[] = "--proc-type=secondary";
1129 char *argp[argc + 3];
1132 /* preparse app arguments */
1133 ret = proc_info_preparse_args(argc, argv);
1135 printf("Failed to parse arguments\n");
1144 for (i = 1; i < argc; i++)
1145 argp[i + 3] = argv[i];
1149 ret = rte_eal_init(argc, argp);
1151 rte_panic("Cannot init EAL\n");
1156 if (!rte_eal_primary_proc_alive(NULL))
1157 rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
1159 /* parse app arguments */
1160 ret = proc_info_parse_args(argc, argv);
1162 rte_exit(EXIT_FAILURE, "Invalid argument\n");
1169 nb_ports = rte_eth_dev_count_avail();
1171 rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
1173 /* If no port mask was specified*/
1174 if (enabled_port_mask == 0)
1175 enabled_port_mask = 0xffff;
1177 RTE_ETH_FOREACH_DEV(i) {
1178 if (enabled_port_mask & (1 << i)) {
1180 nic_stats_display(i);
1181 else if (enable_xstats)
1182 nic_xstats_display(i);
1183 else if (reset_stats)
1185 else if (reset_xstats)
1186 nic_xstats_clear(i);
1187 else if (enable_xstats_name)
1188 nic_xstats_by_name_display(i, xstats_name);
1189 else if (nb_xstats_ids > 0)
1190 nic_xstats_by_ids_display(i, xstats_ids,
1192 else if (enable_metrics)
1197 /* print port independent stats */
1199 metrics_display(RTE_METRICS_GLOBAL);
1201 /* show information for PMD */
1202 if (enable_shw_port)
1206 if (enable_shw_crypto)
1208 if (enable_shw_ring)
1209 show_ring(ring_name);
1211 ret = rte_eal_cleanup();
1213 printf("Error from rte_eal_cleanup(), %d\n", ret);
1215 snprintf(bdr_str, MAX_STRING_LEN, " ");
1216 STATS_BDR_STR(50, bdr_str);