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;
88 proc_info_usage(const char *prgname)
90 printf("%s [EAL options] -- -p PORTMASK\n"
91 " -m to display DPDK memory zones, segments and TAILQ information\n"
92 " -p PORTMASK: hexadecimal bitmask of ports to retrieve stats for\n"
93 " --stats: to display port statistics, enabled by default\n"
94 " --xstats: to display extended port statistics, disabled by "
96 " --metrics: to display derived metrics of the ports, disabled by "
98 " --xstats-name NAME: to display single xstat id by NAME\n"
99 " --xstats-ids IDLIST: to display xstat values by id. "
100 "The argument is comma-separated list of xstat ids to print out.\n"
101 " --stats-reset: to reset port statistics\n"
102 " --xstats-reset: to reset port extended statistics\n"
103 " --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
104 " --host-id STRING: host id used to identify the system process is running on\n"
105 " --show-port: to display ports information\n"
106 " --show-tm: to display traffic manager information for ports\n"
107 " --show-crypto: to display crypto information\n",
112 * Parse the portmask provided at run time.
115 parse_portmask(const char *portmask)
122 /* parse hexadecimal string */
123 pm = strtoul(portmask, &end, 16);
124 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') ||
126 printf("%s ERROR parsing the port mask\n", __func__);
138 * Parse ids value list into array
141 parse_xstats_ids(char *list, uint64_t *ids, int limit) {
148 token = strtok_r(list, ",", &ctx);
149 while (token != NULL) {
150 ids[length] = strtoull(token, &endptr, 10);
158 token = strtok_r(NULL, ",", &ctx);
165 proc_info_preparse_args(int argc, char **argv)
167 char *prgname = argv[0];
170 for (i = 0; i < argc; i++) {
171 /* Print stats or xstats to STDOUT in collectd format */
172 if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
173 enable_collectd_format = 1;
174 stdout_fd = dup(STDOUT_FILENO);
175 close(STDOUT_FILENO);
177 if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
178 if ((i + 1) == argc) {
179 printf("Invalid host id or not specified\n");
180 proc_info_usage(prgname);
183 snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
187 if (!strlen(host_id)) {
188 int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
191 strcpy(host_id, "unknown");
197 /* Parse the argument given in the command line of the application */
199 proc_info_parse_args(int argc, char **argv)
203 char *prgname = argv[0];
204 static struct option long_option[] = {
205 {"stats", 0, NULL, 0},
206 {"stats-reset", 0, NULL, 0},
207 {"xstats", 0, NULL, 0},
208 {"metrics", 0, NULL, 0},
209 {"xstats-reset", 0, NULL, 0},
210 {"xstats-name", required_argument, NULL, 1},
211 {"collectd-format", 0, NULL, 0},
212 {"xstats-ids", 1, NULL, 1},
213 {"host-id", 0, NULL, 0},
214 {"show-port", 0, NULL, 0},
215 {"show-tm", 0, NULL, 0},
216 {"show-crypto", 0, NULL, 0},
221 proc_info_usage(prgname);
223 /* Parse command line */
224 while ((opt = getopt_long(argc, argv, "p:m",
225 long_option, &option_index)) != EOF) {
229 enabled_port_mask = parse_portmask(optarg);
230 if (enabled_port_mask == 0) {
231 printf("invalid portmask\n");
232 proc_info_usage(prgname);
241 if (!strncmp(long_option[option_index].name, "stats",
245 else if (!strncmp(long_option[option_index].name, "xstats",
248 else if (!strncmp(long_option[option_index].name,
253 if (!strncmp(long_option[option_index].name, "stats-reset",
257 else if (!strncmp(long_option[option_index].name, "xstats-reset",
260 else if (!strncmp(long_option[option_index].name,
261 "show-port", MAX_LONG_OPT_SZ))
263 else if (!strncmp(long_option[option_index].name,
264 "show-tm", MAX_LONG_OPT_SZ))
266 else if (!strncmp(long_option[option_index].name,
267 "show-crypto", MAX_LONG_OPT_SZ))
268 enable_shw_crypto = 1;
271 /* Print xstat single value given by name*/
272 if (!strncmp(long_option[option_index].name,
273 "xstats-name", MAX_LONG_OPT_SZ)) {
274 enable_xstats_name = 1;
275 xstats_name = optarg;
276 printf("name:%s:%s\n",
277 long_option[option_index].name,
279 } else if (!strncmp(long_option[option_index].name,
282 nb_xstats_ids = parse_xstats_ids(optarg,
283 xstats_ids, MAX_NB_XSTATS_IDS);
285 if (nb_xstats_ids <= 0) {
286 printf("xstats-id list parse error.\n");
293 proc_info_usage(prgname);
301 meminfo_display(void)
303 printf("----------- MEMORY_SEGMENTS -----------\n");
304 rte_dump_physmem_layout(stdout);
305 printf("--------- END_MEMORY_SEGMENTS ---------\n");
307 printf("------------ MEMORY_ZONES -------------\n");
308 rte_memzone_dump(stdout);
309 printf("---------- END_MEMORY_ZONES -----------\n");
311 printf("------------- TAIL_QUEUES -------------\n");
312 rte_dump_tailq(stdout);
313 printf("---------- END_TAIL_QUEUES ------------\n");
317 nic_stats_display(uint16_t port_id)
319 struct rte_eth_stats stats;
322 static const char *nic_stats_border = "########################";
324 rte_eth_stats_get(port_id, &stats);
325 printf("\n %s NIC statistics for port %-2d %s\n",
326 nic_stats_border, port_id, nic_stats_border);
328 printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
329 " RX-bytes: %-10"PRIu64"\n", stats.ipackets, stats.ierrors,
331 printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf);
332 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64
333 " TX-bytes: %-10"PRIu64"\n", stats.opackets, stats.oerrors,
337 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
338 printf(" Stats reg %2d RX-packets: %-10"PRIu64
339 " RX-errors: %-10"PRIu64
340 " RX-bytes: %-10"PRIu64"\n",
341 i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]);
345 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
346 printf(" Stats reg %2d TX-packets: %-10"PRIu64
347 " TX-bytes: %-10"PRIu64"\n",
348 i, stats.q_opackets[i], stats.q_obytes[i]);
351 printf(" %s############################%s\n",
352 nic_stats_border, nic_stats_border);
356 nic_stats_clear(uint16_t port_id)
358 printf("\n Clearing NIC stats for port %d\n", port_id);
359 rte_eth_stats_reset(port_id);
360 printf("\n NIC statistics for port %d cleared\n", port_id);
363 static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
364 const char *cnt_name) {
365 char *type_end = strrchr(cnt_name, '_');
367 if ((type_end != NULL) &&
368 (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
369 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
370 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
371 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
372 strncpy(cnt_type, "if_rx_dropped", cnt_type_len);
373 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
374 strncpy(cnt_type, "if_rx_octets", cnt_type_len);
375 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
376 strncpy(cnt_type, "if_rx_packets", cnt_type_len);
377 else if (strncmp(type_end, "_placement",
378 strlen("_placement")) == 0)
379 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
380 else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
381 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
383 /* Does not fit obvious type: use a more generic one */
384 strncpy(cnt_type, "derive", cnt_type_len);
385 } else if ((type_end != NULL) &&
386 (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
387 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
388 strncpy(cnt_type, "if_tx_errors", cnt_type_len);
389 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
390 strncpy(cnt_type, "if_tx_dropped", cnt_type_len);
391 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
392 strncpy(cnt_type, "if_tx_octets", cnt_type_len);
393 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
394 strncpy(cnt_type, "if_tx_packets", cnt_type_len);
396 /* Does not fit obvious type: use a more generic one */
397 strncpy(cnt_type, "derive", cnt_type_len);
398 } else if ((type_end != NULL) &&
399 (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
400 if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
401 strncpy(cnt_type, "operations", cnt_type_len);
402 else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
403 strncpy(cnt_type, "errors", cnt_type_len);
404 else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
405 strncpy(cnt_type, "filter_result", cnt_type_len);
406 } else if ((type_end != NULL) &&
407 (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
408 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
409 strncpy(cnt_type, "errors", cnt_type_len);
411 /* Does not fit obvious type, or strrchr error: */
412 /* use a more generic type */
413 strncpy(cnt_type, "derive", cnt_type_len);
418 nic_xstats_by_name_display(uint16_t port_id, char *name)
422 printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
425 if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
426 printf("%s: %"PRIu64"\n", name, id);
428 printf("Statistic not found...\n");
433 nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
435 struct rte_eth_xstat_name *xstats_names;
438 static const char *nic_stats_border = "########################";
440 values = malloc(sizeof(*values) * len);
441 if (values == NULL) {
442 printf("Cannot allocate memory for xstats\n");
446 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
447 if (xstats_names == NULL) {
448 printf("Cannot allocate memory for xstat names\n");
453 if (len != rte_eth_xstats_get_names_by_id(
454 port_id, xstats_names, len, ids)) {
455 printf("Cannot get xstat names\n");
459 printf("###### NIC extended statistics for port %-2d #########\n",
461 printf("%s############################\n", nic_stats_border);
462 ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
463 if (ret < 0 || ret > len) {
464 printf("Cannot get xstats\n");
468 for (i = 0; i < len; i++)
469 printf("%s: %"PRIu64"\n",
470 xstats_names[i].name,
473 printf("%s############################\n", nic_stats_border);
480 nic_xstats_display(uint16_t port_id)
482 struct rte_eth_xstat_name *xstats_names;
485 static const char *nic_stats_border = "########################";
487 len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
489 printf("Cannot get xstats count\n");
492 values = malloc(sizeof(*values) * len);
493 if (values == NULL) {
494 printf("Cannot allocate memory for xstats\n");
498 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
499 if (xstats_names == NULL) {
500 printf("Cannot allocate memory for xstat names\n");
504 if (len != rte_eth_xstats_get_names_by_id(
505 port_id, xstats_names, len, NULL)) {
506 printf("Cannot get xstat names\n");
510 printf("###### NIC extended statistics for port %-2d #########\n",
512 printf("%s############################\n",
514 ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
515 if (ret < 0 || ret > len) {
516 printf("Cannot get xstats\n");
520 for (i = 0; i < len; i++) {
521 if (enable_collectd_format) {
522 char counter_type[MAX_STRING_LEN];
523 char buf[MAX_STRING_LEN];
526 collectd_resolve_cnt_type(counter_type,
527 sizeof(counter_type),
528 xstats_names[i].name);
529 n = snprintf(buf, MAX_STRING_LEN,
530 "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
531 PRIu64"\n", host_id, port_id, counter_type,
532 xstats_names[i].name, values[i]);
533 if (n > sizeof(buf) - 1)
535 ret = write(stdout_fd, buf, n);
539 printf("%s: %"PRIu64"\n", xstats_names[i].name,
544 printf("%s############################\n",
552 nic_xstats_clear(uint16_t port_id)
554 printf("\n Clearing NIC xstats for port %d\n", port_id);
555 rte_eth_xstats_reset(port_id);
556 printf("\n NIC extended statistics for port %d cleared\n", port_id);
560 metrics_display(int port_id)
562 struct rte_metric_value *metrics;
563 struct rte_metric_name *names;
565 static const char *nic_stats_border = "########################";
567 len = rte_metrics_get_names(NULL, 0);
569 printf("Cannot get metrics count\n");
573 printf("No metrics to display (none have been registered)\n");
577 metrics = rte_malloc("proc_info_metrics",
578 sizeof(struct rte_metric_value) * len, 0);
579 if (metrics == NULL) {
580 printf("Cannot allocate memory for metrics\n");
584 names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
586 printf("Cannot allocate memory for metrcis names\n");
591 if (len != rte_metrics_get_names(names, len)) {
592 printf("Cannot get metrics names\n");
598 if (port_id == RTE_METRICS_GLOBAL)
599 printf("###### Non port specific metrics #########\n");
601 printf("###### metrics for port %-2d #########\n", port_id);
602 printf("%s############################\n", nic_stats_border);
603 ret = rte_metrics_get_values(port_id, metrics, len);
604 if (ret < 0 || ret > len) {
605 printf("Cannot get metrics values\n");
612 for (i = 0; i < len; i++)
613 printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
615 printf("%s############################\n", nic_stats_border);
626 snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD %"PRIu64,
628 STATS_BDR_STR(10, bdr_str);
630 RTE_ETH_FOREACH_DEV(i) {
632 struct rte_eth_link link;
633 struct rte_eth_dev_info dev_info;
634 struct rte_eth_rxq_info queue_info;
635 struct rte_eth_rss_conf rss_conf;
637 memset(&rss_conf, 0, sizeof(rss_conf));
639 snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
640 STATS_BDR_STR(5, bdr_str);
641 printf(" - generic config\n");
643 printf("\t -- Socket %d\n", rte_eth_dev_socket_id(i));
644 rte_eth_link_get(i, &link);
645 printf("\t -- link speed %d duplex %d,"
646 " auto neg %d status %d\n",
651 printf("\t -- promiscuous (%d)\n",
652 rte_eth_promiscuous_get(i));
653 ret = rte_eth_dev_get_mtu(i, &mtu);
655 printf("\t -- mtu (%d)\n", mtu);
657 rte_eth_dev_info_get(i, &dev_info);
659 printf(" - queue\n");
660 for (j = 0; j < dev_info.nb_rx_queues; j++) {
661 ret = rte_eth_rx_queue_info_get(i, j, &queue_info);
663 printf("\t -- queue %d rx scatter %d"
665 " offloads 0x%"PRIx64
666 " mempool socket %d\n",
668 queue_info.scattered_rx,
670 queue_info.conf.offloads,
671 queue_info.mp->socket_id);
675 ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
677 if (rss_conf.rss_key) {
679 printf("\t -- RSS len %u key (hex):",
680 rss_conf.rss_key_len);
681 for (k = 0; k < rss_conf.rss_key_len; k++)
682 printf(" %x", rss_conf.rss_key[k]);
683 printf("\t -- hf 0x%"PRIx64"\n",
688 printf(" - cyrpto context\n");
689 void *p_ctx = rte_eth_dev_get_sec_ctx(i);
690 printf("\t -- security context - %p\n", p_ctx);
693 printf("\t -- size %u\n",
694 rte_security_session_get_size(p_ctx));
695 const struct rte_security_capability *s_cap =
696 rte_security_capabilities_get(p_ctx);
698 printf("\t -- action (0x%x), protocol (0x%x),"
699 " offload flags (0x%x)\n",
703 printf("\t -- capabilities - oper type %x\n",
704 s_cap->crypto_capabilities->op);
709 STATS_BDR_STR(50, "");
713 display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
719 printf("\t -- nonleaf sched max:\n"
720 "\t\t + children (%u)\n"
721 "\t\t + sp priorities (%u)\n"
722 "\t\t + wfq children per group (%u)\n"
723 "\t\t + wfq groups (%u)\n"
724 "\t\t + wfq weight (%u)\n",
725 cap->nonleaf.sched_n_children_max,
726 cap->nonleaf.sched_sp_n_priorities_max,
727 cap->nonleaf.sched_wfq_n_children_per_group_max,
728 cap->nonleaf.sched_wfq_n_groups_max,
729 cap->nonleaf.sched_wfq_weight_max);
731 printf("\t -- leaf cman support:\n"
732 "\t\t + wred pkt mode (%d)\n"
733 "\t\t + wred byte mode (%d)\n"
734 "\t\t + head drop (%d)\n"
735 "\t\t + wred context private (%d)\n"
736 "\t\t + wred context shared (%u)\n",
737 cap->leaf.cman_wred_packet_mode_supported,
738 cap->leaf.cman_wred_byte_mode_supported,
739 cap->leaf.cman_head_drop_supported,
740 cap->leaf.cman_wred_context_private_supported,
741 cap->leaf.cman_wred_context_shared_n_max);
746 display_levelcap_info(int is_leaf, struct rte_tm_level_capabilities *cap)
752 printf("\t -- shaper private: (%d) dual rate (%d)\n",
753 cap->nonleaf.shaper_private_supported,
754 cap->nonleaf.shaper_private_dual_rate_supported);
755 printf("\t -- shaper share: (%u)\n",
756 cap->nonleaf.shaper_shared_n_max);
757 printf("\t -- non leaf sched MAX:\n"
758 "\t\t + children (%u)\n"
760 "\t\t + wfq children per group (%u)\n"
761 "\t\t + wfq groups (%u)\n"
762 "\t\t + wfq weight (%u)\n",
763 cap->nonleaf.sched_n_children_max,
764 cap->nonleaf.sched_sp_n_priorities_max,
765 cap->nonleaf.sched_wfq_n_children_per_group_max,
766 cap->nonleaf.sched_wfq_n_groups_max,
767 cap->nonleaf.sched_wfq_weight_max);
769 printf("\t -- shaper private: (%d) dual rate (%d)\n",
770 cap->leaf.shaper_private_supported,
771 cap->leaf.shaper_private_dual_rate_supported);
772 printf("\t -- shaper share: (%u)\n",
773 cap->leaf.shaper_shared_n_max);
774 printf(" -- leaf cman support:\n"
775 "\t\t + wred pkt mode (%d)\n"
776 "\t\t + wred byte mode (%d)\n"
777 "\t\t + head drop (%d)\n"
778 "\t\t + wred context private (%d)\n"
779 "\t\t + wred context shared (%u)\n",
780 cap->leaf.cman_wred_packet_mode_supported,
781 cap->leaf.cman_wred_byte_mode_supported,
782 cap->leaf.cman_head_drop_supported,
783 cap->leaf.cman_wred_context_private_supported,
784 cap->leaf.cman_wred_context_shared_n_max);
791 int ret = 0, check_for_leaf = 0, is_leaf = 0;
795 snprintf(bdr_str, MAX_STRING_LEN, " show - TM PMD %"PRIu64,
797 STATS_BDR_STR(10, bdr_str);
799 RTE_ETH_FOREACH_DEV(i) {
800 struct rte_eth_dev_info dev_info;
801 struct rte_tm_capabilities cap;
802 struct rte_tm_error error;
803 struct rte_tm_node_capabilities capnode;
804 struct rte_tm_level_capabilities caplevel;
805 uint32_t n_leaf_nodes = 0;
807 memset(&cap, 0, sizeof(cap));
808 memset(&error, 0, sizeof(error));
810 rte_eth_dev_info_get(i, &dev_info);
811 printf(" - Generic for port (%u)\n"
812 "\t -- driver name %s\n"
813 "\t -- max vf (%u)\n"
814 "\t -- max tx queues (%u)\n"
815 "\t -- number of tx queues (%u)\n",
817 dev_info.driver_name,
819 dev_info.max_tx_queues,
820 dev_info.nb_tx_queues);
822 ret = rte_tm_capabilities_get(i, &cap, &error);
826 printf(" - MAX: nodes (%u) levels (%u) children (%u)\n",
829 cap.sched_n_children_max);
831 printf(" - identical nodes: non leaf (%d) leaf (%d)\n",
832 cap.non_leaf_nodes_identical,
833 cap.leaf_nodes_identical);
835 printf(" - Shaper MAX:\n"
837 "\t -- private (%u) private dual (%d)\n"
838 "\t -- shared (%u) shared dual (%u)\n",
840 cap.shaper_private_n_max,
841 cap.shaper_private_dual_rate_n_max,
842 cap.shaper_shared_n_max,
843 cap.shaper_shared_dual_rate_n_max);
845 printf(" - mark support:\n");
846 printf("\t -- vlan dei: GREEN (%d) YELLOW (%d) RED (%d)\n",
847 cap.mark_vlan_dei_supported[RTE_TM_GREEN],
848 cap.mark_vlan_dei_supported[RTE_TM_YELLOW],
849 cap.mark_vlan_dei_supported[RTE_TM_RED]);
850 printf("\t -- ip ecn tcp: GREEN (%d) YELLOW (%d) RED (%d)\n",
851 cap.mark_ip_ecn_tcp_supported[RTE_TM_GREEN],
852 cap.mark_ip_ecn_tcp_supported[RTE_TM_YELLOW],
853 cap.mark_ip_ecn_tcp_supported[RTE_TM_RED]);
854 printf("\t -- ip ecn sctp: GREEN (%d) YELLOW (%d) RED (%d)\n",
855 cap.mark_ip_ecn_sctp_supported[RTE_TM_GREEN],
856 cap.mark_ip_ecn_sctp_supported[RTE_TM_YELLOW],
857 cap.mark_ip_ecn_sctp_supported[RTE_TM_RED]);
858 printf("\t -- ip dscp: GREEN (%d) YELLOW (%d) RED (%d)\n",
859 cap.mark_ip_dscp_supported[RTE_TM_GREEN],
860 cap.mark_ip_dscp_supported[RTE_TM_YELLOW],
861 cap.mark_ip_dscp_supported[RTE_TM_RED]);
863 printf(" - mask stats (0x%"PRIx64")"
864 " dynamic update (0x%"PRIx64")\n",
866 cap.dynamic_update_mask);
868 printf(" - sched MAX:\n"
870 "\t -- sp levels (%u)\n"
871 "\t -- wfq children per group (%u)\n"
872 "\t -- wfq groups (%u)\n"
873 "\t -- wfq weight (%u)\n",
874 cap.sched_sp_n_priorities_max,
875 cap.sched_sp_n_priorities_max,
876 cap.sched_wfq_n_children_per_group_max,
877 cap.sched_wfq_n_groups_max,
878 cap.sched_wfq_weight_max);
880 printf(" - CMAN support:\n"
881 "\t -- WRED mode: pkt (%d) byte (%d)\n"
882 "\t -- head drop (%d)\n",
883 cap.cman_wred_packet_mode_supported,
884 cap.cman_wred_byte_mode_supported,
885 cap.cman_head_drop_supported);
886 printf("\t -- MAX WRED CONTEXT:"
887 " total (%u) private (%u) shared (%u)\n",
888 cap.cman_wred_context_n_max,
889 cap.cman_wred_context_private_n_max,
890 cap.cman_wred_context_shared_n_max);
892 for (j = 0; j < cap.n_nodes_max; j++) {
893 memset(&capnode, 0, sizeof(capnode));
894 ret = rte_tm_node_capabilities_get(i, j,
901 printf(" NODE %u\n", j);
902 printf("\t - shaper private: (%d) dual rate (%d)\n",
903 capnode.shaper_private_supported,
904 capnode.shaper_private_dual_rate_supported);
905 printf("\t - shaper shared max: (%u)\n",
906 capnode.shaper_shared_n_max);
907 printf("\t - stats mask %"PRIx64"\n",
910 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
914 display_nodecap_info(is_leaf, &capnode);
917 for (j = 0; j < cap.n_levels_max; j++) {
918 memset(&caplevel, 0, sizeof(caplevel));
919 ret = rte_tm_level_capabilities_get(i, j,
924 printf(" - Level %u\n", j);
925 printf("\t -- node MAX: %u non leaf %u leaf %u\n",
926 caplevel.n_nodes_max,
927 caplevel.n_nodes_nonleaf_max,
928 caplevel.n_nodes_leaf_max);
929 printf("\t -- indetical: non leaf %u leaf %u\n",
930 caplevel.non_leaf_nodes_identical,
931 caplevel.leaf_nodes_identical);
933 for (k = 0; k < caplevel.n_nodes_max; k++) {
934 ret = rte_tm_node_type_get(i, k,
939 display_levelcap_info(is_leaf, &caplevel);
943 if (check_for_leaf) {
944 ret = rte_tm_get_number_of_leaf_nodes(i,
945 &n_leaf_nodes, &error);
947 printf(" - leaf nodes (%u)\n", n_leaf_nodes);
950 for (j = 0; j < n_leaf_nodes; j++) {
951 struct rte_tm_node_stats stats;
952 memset(&stats, 0, sizeof(stats));
954 ret = rte_tm_node_stats_read(i, j,
955 &stats, &cap.stats_mask, 0, &error);
959 printf(" - STATS for node (%u)\n", j);
960 printf(" -- pkts (%"PRIu64") bytes (%"PRIu64")\n",
961 stats.n_pkts, stats.n_bytes);
963 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
964 if (ret || (!is_leaf))
967 printf(" -- leaf queued:"
968 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
969 stats.leaf.n_pkts_queued,
970 stats.leaf.n_bytes_queued);
971 printf(" - dropped:\n"
973 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
975 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
977 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
978 stats.leaf.n_pkts_dropped[RTE_TM_GREEN],
979 stats.leaf.n_bytes_dropped[RTE_TM_GREEN],
980 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW],
981 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW],
982 stats.leaf.n_pkts_dropped[RTE_TM_RED],
983 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
987 STATS_BDR_STR(50, "");
991 display_crypto_feature_info(uint64_t x)
996 printf("\t -- feature flags\n");
997 printf("\t\t + symmetric (%c), asymmetric (%c)\n"
998 "\t\t + symmetric operation chaining (%c)\n",
999 (x & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ? 'y' : 'n',
1000 (x & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) ? 'y' : 'n',
1001 (x & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING) ? 'y' : 'n');
1002 printf("\t\t + CPU: SSE (%c), AVX (%c), AVX2 (%c), AVX512 (%c)\n",
1003 (x & RTE_CRYPTODEV_FF_CPU_SSE) ? 'y' : 'n',
1004 (x & RTE_CRYPTODEV_FF_CPU_AVX) ? 'y' : 'n',
1005 (x & RTE_CRYPTODEV_FF_CPU_AVX2) ? 'y' : 'n',
1006 (x & RTE_CRYPTODEV_FF_CPU_AVX512) ? 'y' : 'n');
1007 printf("\t\t + AESNI: CPU (%c), HW (%c)\n",
1008 (x & RTE_CRYPTODEV_FF_CPU_AESNI) ? 'y' : 'n',
1009 (x & RTE_CRYPTODEV_FF_HW_ACCELERATED) ? 'y' : 'n');
1010 printf("\t\t + INLINE (%c)\n",
1011 (x & RTE_CRYPTODEV_FF_SECURITY) ? 'y' : 'n');
1012 printf("\t\t + ARM: NEON (%c), CE (%c)\n",
1013 (x & RTE_CRYPTODEV_FF_CPU_NEON) ? 'y' : 'n',
1014 (x & RTE_CRYPTODEV_FF_CPU_ARM_CE) ? 'y' : 'n');
1015 printf("\t -- buffer offload\n");
1016 printf("\t\t + IN_PLACE_SGL (%c)\n",
1017 (x & RTE_CRYPTODEV_FF_IN_PLACE_SGL) ? 'y' : 'n');
1018 printf("\t\t + OOP_SGL_IN_SGL_OUT (%c)\n",
1019 (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT) ? 'y' : 'n');
1020 printf("\t\t + OOP_SGL_IN_LB_OUT (%c)\n",
1021 (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT) ? 'y' : 'n');
1022 printf("\t\t + OOP_LB_IN_SGL_OUT (%c)\n",
1023 (x & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT) ? 'y' : 'n');
1024 printf("\t\t + OOP_LB_IN_LB_OUT (%c)\n",
1025 (x & RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT) ? 'y' : 'n');
1031 uint8_t crypto_dev_count = rte_cryptodev_count(), i;
1033 snprintf(bdr_str, MAX_STRING_LEN, " show - CRYPTO PMD %"PRIu64,
1035 STATS_BDR_STR(10, bdr_str);
1037 for (i = 0; i < crypto_dev_count; i++) {
1038 struct rte_cryptodev_info dev_info;
1039 struct rte_cryptodev_stats stats;
1041 rte_cryptodev_info_get(i, &dev_info);
1043 printf(" - device (%u)\n", i);
1044 printf("\t -- name (%s)\n"
1045 "\t -- driver (%s)\n"
1046 "\t -- id (%u) on socket (%d)\n"
1047 "\t -- queue pairs (%d)\n",
1048 rte_cryptodev_name_get(i),
1049 dev_info.driver_name,
1051 dev_info.device->numa_node,
1052 rte_cryptodev_queue_pair_count(i));
1054 display_crypto_feature_info(dev_info.feature_flags);
1056 memset(&stats, 0, sizeof(0));
1057 if (rte_cryptodev_stats_get(i, &stats) == 0) {
1058 printf("\t -- stats\n");
1059 printf("\t\t + enqueue count (%"PRIu64")"
1060 " error (%"PRIu64")\n",
1061 stats.enqueued_count,
1062 stats.enqueue_err_count);
1063 printf("\t\t + dequeue count (%"PRIu64")"
1064 " error (%"PRIu64")\n",
1065 stats.dequeued_count,
1066 stats.dequeue_err_count);
1070 STATS_BDR_STR(50, "");
1074 main(int argc, char **argv)
1078 char c_flag[] = "-c1";
1079 char n_flag[] = "-n4";
1080 char mp_flag[] = "--proc-type=secondary";
1081 char *argp[argc + 3];
1084 /* preparse app arguments */
1085 ret = proc_info_preparse_args(argc, argv);
1087 printf("Failed to parse arguments\n");
1096 for (i = 1; i < argc; i++)
1097 argp[i + 3] = argv[i];
1101 ret = rte_eal_init(argc, argp);
1103 rte_panic("Cannot init EAL\n");
1108 if (!rte_eal_primary_proc_alive(NULL))
1109 rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
1111 /* parse app arguments */
1112 ret = proc_info_parse_args(argc, argv);
1114 rte_exit(EXIT_FAILURE, "Invalid argument\n");
1121 nb_ports = rte_eth_dev_count_avail();
1123 rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
1125 /* If no port mask was specified*/
1126 if (enabled_port_mask == 0)
1127 enabled_port_mask = 0xffff;
1129 RTE_ETH_FOREACH_DEV(i) {
1130 if (enabled_port_mask & (1 << i)) {
1132 nic_stats_display(i);
1133 else if (enable_xstats)
1134 nic_xstats_display(i);
1135 else if (reset_stats)
1137 else if (reset_xstats)
1138 nic_xstats_clear(i);
1139 else if (enable_xstats_name)
1140 nic_xstats_by_name_display(i, xstats_name);
1141 else if (nb_xstats_ids > 0)
1142 nic_xstats_by_ids_display(i, xstats_ids,
1144 else if (enable_metrics)
1149 /* print port independent stats */
1151 metrics_display(RTE_METRICS_GLOBAL);
1153 /* show information for PMD */
1154 if (enable_shw_port)
1158 if (enable_shw_crypto)
1161 ret = rte_eal_cleanup();
1163 printf("Error from rte_eal_cleanup(), %d\n", ret);
1165 snprintf(bdr_str, MAX_STRING_LEN, " ");
1166 STATS_BDR_STR(50, bdr_str);