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;
86 proc_info_usage(const char *prgname)
88 printf("%s [EAL options] -- -p PORTMASK\n"
89 " -m to display DPDK memory zones, segments and TAILQ information\n"
90 " -p PORTMASK: hexadecimal bitmask of ports to retrieve stats for\n"
91 " --stats: to display port statistics, enabled by default\n"
92 " --xstats: to display extended port statistics, disabled by "
94 " --metrics: to display derived metrics of the ports, disabled by "
96 " --xstats-name NAME: to display single xstat id by NAME\n"
97 " --xstats-ids IDLIST: to display xstat values by id. "
98 "The argument is comma-separated list of xstat ids to print out.\n"
99 " --stats-reset: to reset port statistics\n"
100 " --xstats-reset: to reset port extended statistics\n"
101 " --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
102 " --host-id STRING: host id used to identify the system process is running on\n"
103 " --show-port: to display ports information\n"
104 " --show-tm: to display traffic manager information for ports\n",
109 * Parse the portmask provided at run time.
112 parse_portmask(const char *portmask)
119 /* parse hexadecimal string */
120 pm = strtoul(portmask, &end, 16);
121 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') ||
123 printf("%s ERROR parsing the port mask\n", __func__);
135 * Parse ids value list into array
138 parse_xstats_ids(char *list, uint64_t *ids, int limit) {
145 token = strtok_r(list, ",", &ctx);
146 while (token != NULL) {
147 ids[length] = strtoull(token, &endptr, 10);
155 token = strtok_r(NULL, ",", &ctx);
162 proc_info_preparse_args(int argc, char **argv)
164 char *prgname = argv[0];
167 for (i = 0; i < argc; i++) {
168 /* Print stats or xstats to STDOUT in collectd format */
169 if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
170 enable_collectd_format = 1;
171 stdout_fd = dup(STDOUT_FILENO);
172 close(STDOUT_FILENO);
174 if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
175 if ((i + 1) == argc) {
176 printf("Invalid host id or not specified\n");
177 proc_info_usage(prgname);
180 snprintf(host_id, sizeof(host_id), "%s", argv[i+1]);
184 if (!strlen(host_id)) {
185 int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
188 strcpy(host_id, "unknown");
194 /* Parse the argument given in the command line of the application */
196 proc_info_parse_args(int argc, char **argv)
200 char *prgname = argv[0];
201 static struct option long_option[] = {
202 {"stats", 0, NULL, 0},
203 {"stats-reset", 0, NULL, 0},
204 {"xstats", 0, NULL, 0},
205 {"metrics", 0, NULL, 0},
206 {"xstats-reset", 0, NULL, 0},
207 {"xstats-name", required_argument, NULL, 1},
208 {"collectd-format", 0, NULL, 0},
209 {"xstats-ids", 1, NULL, 1},
210 {"host-id", 0, NULL, 0},
211 {"show-port", 0, NULL, 0},
212 {"show-tm", 0, NULL, 0},
217 proc_info_usage(prgname);
219 /* Parse command line */
220 while ((opt = getopt_long(argc, argv, "p:m",
221 long_option, &option_index)) != EOF) {
225 enabled_port_mask = parse_portmask(optarg);
226 if (enabled_port_mask == 0) {
227 printf("invalid portmask\n");
228 proc_info_usage(prgname);
237 if (!strncmp(long_option[option_index].name, "stats",
241 else if (!strncmp(long_option[option_index].name, "xstats",
244 else if (!strncmp(long_option[option_index].name,
249 if (!strncmp(long_option[option_index].name, "stats-reset",
253 else if (!strncmp(long_option[option_index].name, "xstats-reset",
256 else if (!strncmp(long_option[option_index].name,
257 "show-port", MAX_LONG_OPT_SZ))
259 else if (!strncmp(long_option[option_index].name,
260 "show-tm", MAX_LONG_OPT_SZ))
264 /* Print xstat single value given by name*/
265 if (!strncmp(long_option[option_index].name,
266 "xstats-name", MAX_LONG_OPT_SZ)) {
267 enable_xstats_name = 1;
268 xstats_name = optarg;
269 printf("name:%s:%s\n",
270 long_option[option_index].name,
272 } else if (!strncmp(long_option[option_index].name,
275 nb_xstats_ids = parse_xstats_ids(optarg,
276 xstats_ids, MAX_NB_XSTATS_IDS);
278 if (nb_xstats_ids <= 0) {
279 printf("xstats-id list parse error.\n");
286 proc_info_usage(prgname);
294 meminfo_display(void)
296 printf("----------- MEMORY_SEGMENTS -----------\n");
297 rte_dump_physmem_layout(stdout);
298 printf("--------- END_MEMORY_SEGMENTS ---------\n");
300 printf("------------ MEMORY_ZONES -------------\n");
301 rte_memzone_dump(stdout);
302 printf("---------- END_MEMORY_ZONES -----------\n");
304 printf("------------- TAIL_QUEUES -------------\n");
305 rte_dump_tailq(stdout);
306 printf("---------- END_TAIL_QUEUES ------------\n");
310 nic_stats_display(uint16_t port_id)
312 struct rte_eth_stats stats;
315 static const char *nic_stats_border = "########################";
317 rte_eth_stats_get(port_id, &stats);
318 printf("\n %s NIC statistics for port %-2d %s\n",
319 nic_stats_border, port_id, nic_stats_border);
321 printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
322 " RX-bytes: %-10"PRIu64"\n", stats.ipackets, stats.ierrors,
324 printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf);
325 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64
326 " TX-bytes: %-10"PRIu64"\n", stats.opackets, stats.oerrors,
330 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
331 printf(" Stats reg %2d RX-packets: %-10"PRIu64
332 " RX-errors: %-10"PRIu64
333 " RX-bytes: %-10"PRIu64"\n",
334 i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]);
338 for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
339 printf(" Stats reg %2d TX-packets: %-10"PRIu64
340 " TX-bytes: %-10"PRIu64"\n",
341 i, stats.q_opackets[i], stats.q_obytes[i]);
344 printf(" %s############################%s\n",
345 nic_stats_border, nic_stats_border);
349 nic_stats_clear(uint16_t port_id)
351 printf("\n Clearing NIC stats for port %d\n", port_id);
352 rte_eth_stats_reset(port_id);
353 printf("\n NIC statistics for port %d cleared\n", port_id);
356 static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
357 const char *cnt_name) {
358 char *type_end = strrchr(cnt_name, '_');
360 if ((type_end != NULL) &&
361 (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
362 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
363 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
364 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
365 strncpy(cnt_type, "if_rx_dropped", cnt_type_len);
366 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
367 strncpy(cnt_type, "if_rx_octets", cnt_type_len);
368 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
369 strncpy(cnt_type, "if_rx_packets", cnt_type_len);
370 else if (strncmp(type_end, "_placement",
371 strlen("_placement")) == 0)
372 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
373 else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
374 strncpy(cnt_type, "if_rx_errors", cnt_type_len);
376 /* Does not fit obvious type: use a more generic one */
377 strncpy(cnt_type, "derive", cnt_type_len);
378 } else if ((type_end != NULL) &&
379 (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
380 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
381 strncpy(cnt_type, "if_tx_errors", cnt_type_len);
382 else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
383 strncpy(cnt_type, "if_tx_dropped", cnt_type_len);
384 else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
385 strncpy(cnt_type, "if_tx_octets", cnt_type_len);
386 else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
387 strncpy(cnt_type, "if_tx_packets", cnt_type_len);
389 /* Does not fit obvious type: use a more generic one */
390 strncpy(cnt_type, "derive", cnt_type_len);
391 } else if ((type_end != NULL) &&
392 (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
393 if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
394 strncpy(cnt_type, "operations", cnt_type_len);
395 else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
396 strncpy(cnt_type, "errors", cnt_type_len);
397 else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
398 strncpy(cnt_type, "filter_result", cnt_type_len);
399 } else if ((type_end != NULL) &&
400 (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
401 if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
402 strncpy(cnt_type, "errors", cnt_type_len);
404 /* Does not fit obvious type, or strrchr error: */
405 /* use a more generic type */
406 strncpy(cnt_type, "derive", cnt_type_len);
411 nic_xstats_by_name_display(uint16_t port_id, char *name)
415 printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
418 if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
419 printf("%s: %"PRIu64"\n", name, id);
421 printf("Statistic not found...\n");
426 nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
428 struct rte_eth_xstat_name *xstats_names;
431 static const char *nic_stats_border = "########################";
433 values = malloc(sizeof(*values) * len);
434 if (values == NULL) {
435 printf("Cannot allocate memory for xstats\n");
439 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
440 if (xstats_names == NULL) {
441 printf("Cannot allocate memory for xstat names\n");
446 if (len != rte_eth_xstats_get_names_by_id(
447 port_id, xstats_names, len, ids)) {
448 printf("Cannot get xstat names\n");
452 printf("###### NIC extended statistics for port %-2d #########\n",
454 printf("%s############################\n", nic_stats_border);
455 ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
456 if (ret < 0 || ret > len) {
457 printf("Cannot get xstats\n");
461 for (i = 0; i < len; i++)
462 printf("%s: %"PRIu64"\n",
463 xstats_names[i].name,
466 printf("%s############################\n", nic_stats_border);
473 nic_xstats_display(uint16_t port_id)
475 struct rte_eth_xstat_name *xstats_names;
478 static const char *nic_stats_border = "########################";
480 len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
482 printf("Cannot get xstats count\n");
485 values = malloc(sizeof(*values) * len);
486 if (values == NULL) {
487 printf("Cannot allocate memory for xstats\n");
491 xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
492 if (xstats_names == NULL) {
493 printf("Cannot allocate memory for xstat names\n");
497 if (len != rte_eth_xstats_get_names_by_id(
498 port_id, xstats_names, len, NULL)) {
499 printf("Cannot get xstat names\n");
503 printf("###### NIC extended statistics for port %-2d #########\n",
505 printf("%s############################\n",
507 ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
508 if (ret < 0 || ret > len) {
509 printf("Cannot get xstats\n");
513 for (i = 0; i < len; i++) {
514 if (enable_collectd_format) {
515 char counter_type[MAX_STRING_LEN];
516 char buf[MAX_STRING_LEN];
519 collectd_resolve_cnt_type(counter_type,
520 sizeof(counter_type),
521 xstats_names[i].name);
522 n = snprintf(buf, MAX_STRING_LEN,
523 "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
524 PRIu64"\n", host_id, port_id, counter_type,
525 xstats_names[i].name, values[i]);
526 if (n > sizeof(buf) - 1)
528 ret = write(stdout_fd, buf, n);
532 printf("%s: %"PRIu64"\n", xstats_names[i].name,
537 printf("%s############################\n",
545 nic_xstats_clear(uint16_t port_id)
547 printf("\n Clearing NIC xstats for port %d\n", port_id);
548 rte_eth_xstats_reset(port_id);
549 printf("\n NIC extended statistics for port %d cleared\n", port_id);
553 metrics_display(int port_id)
555 struct rte_metric_value *metrics;
556 struct rte_metric_name *names;
558 static const char *nic_stats_border = "########################";
560 len = rte_metrics_get_names(NULL, 0);
562 printf("Cannot get metrics count\n");
566 printf("No metrics to display (none have been registered)\n");
570 metrics = rte_malloc("proc_info_metrics",
571 sizeof(struct rte_metric_value) * len, 0);
572 if (metrics == NULL) {
573 printf("Cannot allocate memory for metrics\n");
577 names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
579 printf("Cannot allocate memory for metrcis names\n");
584 if (len != rte_metrics_get_names(names, len)) {
585 printf("Cannot get metrics names\n");
591 if (port_id == RTE_METRICS_GLOBAL)
592 printf("###### Non port specific metrics #########\n");
594 printf("###### metrics for port %-2d #########\n", port_id);
595 printf("%s############################\n", nic_stats_border);
596 ret = rte_metrics_get_values(port_id, metrics, len);
597 if (ret < 0 || ret > len) {
598 printf("Cannot get metrics values\n");
605 for (i = 0; i < len; i++)
606 printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
608 printf("%s############################\n", nic_stats_border);
619 snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD %"PRIu64,
621 STATS_BDR_STR(10, bdr_str);
623 RTE_ETH_FOREACH_DEV(i) {
625 struct rte_eth_link link;
626 struct rte_eth_dev_info dev_info;
627 struct rte_eth_rxq_info queue_info;
628 struct rte_eth_rss_conf rss_conf;
630 memset(&rss_conf, 0, sizeof(rss_conf));
632 snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
633 STATS_BDR_STR(5, bdr_str);
634 printf(" - generic config\n");
636 printf("\t -- Socket %d\n", rte_eth_dev_socket_id(i));
637 rte_eth_link_get(i, &link);
638 printf("\t -- link speed %d duplex %d,"
639 " auto neg %d status %d\n",
644 printf("\t -- promiscuous (%d)\n",
645 rte_eth_promiscuous_get(i));
646 ret = rte_eth_dev_get_mtu(i, &mtu);
648 printf("\t -- mtu (%d)\n", mtu);
650 rte_eth_dev_info_get(i, &dev_info);
652 printf(" - queue\n");
653 for (j = 0; j < dev_info.nb_rx_queues; j++) {
654 ret = rte_eth_rx_queue_info_get(i, j, &queue_info);
656 printf("\t -- queue %d rx scatter %d"
658 " offloads 0x%"PRIx64
659 " mempool socket %d\n",
661 queue_info.scattered_rx,
663 queue_info.conf.offloads,
664 queue_info.mp->socket_id);
668 ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
670 if (rss_conf.rss_key) {
672 printf("\t -- RSS len %u key (hex):",
673 rss_conf.rss_key_len);
674 for (k = 0; k < rss_conf.rss_key_len; k++)
675 printf(" %x", rss_conf.rss_key[k]);
676 printf("\t -- hf 0x%"PRIx64"\n",
681 printf(" - cyrpto context\n");
682 void *p_ctx = rte_eth_dev_get_sec_ctx(i);
683 printf("\t -- security context - %p\n", p_ctx);
686 printf("\t -- size %u\n",
687 rte_security_session_get_size(p_ctx));
688 const struct rte_security_capability *s_cap =
689 rte_security_capabilities_get(p_ctx);
691 printf("\t -- action (0x%x), protocol (0x%x),"
692 " offload flags (0x%x)\n",
696 printf("\t -- capabilities - oper type %x\n",
697 s_cap->crypto_capabilities->op);
702 STATS_BDR_STR(50, "");
706 display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
712 printf("\t -- nonleaf sched max:\n"
713 "\t\t + children (%u)\n"
714 "\t\t + sp priorities (%u)\n"
715 "\t\t + wfq children per group (%u)\n"
716 "\t\t + wfq groups (%u)\n"
717 "\t\t + wfq weight (%u)\n",
718 cap->nonleaf.sched_n_children_max,
719 cap->nonleaf.sched_sp_n_priorities_max,
720 cap->nonleaf.sched_wfq_n_children_per_group_max,
721 cap->nonleaf.sched_wfq_n_groups_max,
722 cap->nonleaf.sched_wfq_weight_max);
724 printf("\t -- leaf cman support:\n"
725 "\t\t + wred pkt mode (%d)\n"
726 "\t\t + wred byte mode (%d)\n"
727 "\t\t + head drop (%d)\n"
728 "\t\t + wred context private (%d)\n"
729 "\t\t + wred context shared (%u)\n",
730 cap->leaf.cman_wred_packet_mode_supported,
731 cap->leaf.cman_wred_byte_mode_supported,
732 cap->leaf.cman_head_drop_supported,
733 cap->leaf.cman_wred_context_private_supported,
734 cap->leaf.cman_wred_context_shared_n_max);
739 display_levelcap_info(int is_leaf, struct rte_tm_level_capabilities *cap)
745 printf("\t -- shaper private: (%d) dual rate (%d)\n",
746 cap->nonleaf.shaper_private_supported,
747 cap->nonleaf.shaper_private_dual_rate_supported);
748 printf("\t -- shaper share: (%u)\n",
749 cap->nonleaf.shaper_shared_n_max);
750 printf("\t -- non leaf sched MAX:\n"
751 "\t\t + children (%u)\n"
753 "\t\t + wfq children per group (%u)\n"
754 "\t\t + wfq groups (%u)\n"
755 "\t\t + wfq weight (%u)\n",
756 cap->nonleaf.sched_n_children_max,
757 cap->nonleaf.sched_sp_n_priorities_max,
758 cap->nonleaf.sched_wfq_n_children_per_group_max,
759 cap->nonleaf.sched_wfq_n_groups_max,
760 cap->nonleaf.sched_wfq_weight_max);
762 printf("\t -- shaper private: (%d) dual rate (%d)\n",
763 cap->leaf.shaper_private_supported,
764 cap->leaf.shaper_private_dual_rate_supported);
765 printf("\t -- shaper share: (%u)\n",
766 cap->leaf.shaper_shared_n_max);
767 printf(" -- leaf cman support:\n"
768 "\t\t + wred pkt mode (%d)\n"
769 "\t\t + wred byte mode (%d)\n"
770 "\t\t + head drop (%d)\n"
771 "\t\t + wred context private (%d)\n"
772 "\t\t + wred context shared (%u)\n",
773 cap->leaf.cman_wred_packet_mode_supported,
774 cap->leaf.cman_wred_byte_mode_supported,
775 cap->leaf.cman_head_drop_supported,
776 cap->leaf.cman_wred_context_private_supported,
777 cap->leaf.cman_wred_context_shared_n_max);
784 int ret = 0, check_for_leaf = 0, is_leaf = 0;
788 snprintf(bdr_str, MAX_STRING_LEN, " show - TM PMD %"PRIu64,
790 STATS_BDR_STR(10, bdr_str);
792 RTE_ETH_FOREACH_DEV(i) {
793 struct rte_eth_dev_info dev_info;
794 struct rte_tm_capabilities cap;
795 struct rte_tm_error error;
796 struct rte_tm_node_capabilities capnode;
797 struct rte_tm_level_capabilities caplevel;
798 uint32_t n_leaf_nodes = 0;
800 memset(&cap, 0, sizeof(cap));
801 memset(&error, 0, sizeof(error));
803 rte_eth_dev_info_get(i, &dev_info);
804 printf(" - Generic for port (%u)\n"
805 "\t -- driver name %s\n"
806 "\t -- max vf (%u)\n"
807 "\t -- max tx queues (%u)\n"
808 "\t -- number of tx queues (%u)\n",
810 dev_info.driver_name,
812 dev_info.max_tx_queues,
813 dev_info.nb_tx_queues);
815 ret = rte_tm_capabilities_get(i, &cap, &error);
819 printf(" - MAX: nodes (%u) levels (%u) children (%u)\n",
822 cap.sched_n_children_max);
824 printf(" - identical nodes: non leaf (%d) leaf (%d)\n",
825 cap.non_leaf_nodes_identical,
826 cap.leaf_nodes_identical);
828 printf(" - Shaper MAX:\n"
830 "\t -- private (%u) private dual (%d)\n"
831 "\t -- shared (%u) shared dual (%u)\n",
833 cap.shaper_private_n_max,
834 cap.shaper_private_dual_rate_n_max,
835 cap.shaper_shared_n_max,
836 cap.shaper_shared_dual_rate_n_max);
838 printf(" - mark support:\n");
839 printf("\t -- vlan dei: GREEN (%d) YELLOW (%d) RED (%d)\n",
840 cap.mark_vlan_dei_supported[RTE_TM_GREEN],
841 cap.mark_vlan_dei_supported[RTE_TM_YELLOW],
842 cap.mark_vlan_dei_supported[RTE_TM_RED]);
843 printf("\t -- ip ecn tcp: GREEN (%d) YELLOW (%d) RED (%d)\n",
844 cap.mark_ip_ecn_tcp_supported[RTE_TM_GREEN],
845 cap.mark_ip_ecn_tcp_supported[RTE_TM_YELLOW],
846 cap.mark_ip_ecn_tcp_supported[RTE_TM_RED]);
847 printf("\t -- ip ecn sctp: GREEN (%d) YELLOW (%d) RED (%d)\n",
848 cap.mark_ip_ecn_sctp_supported[RTE_TM_GREEN],
849 cap.mark_ip_ecn_sctp_supported[RTE_TM_YELLOW],
850 cap.mark_ip_ecn_sctp_supported[RTE_TM_RED]);
851 printf("\t -- ip dscp: GREEN (%d) YELLOW (%d) RED (%d)\n",
852 cap.mark_ip_dscp_supported[RTE_TM_GREEN],
853 cap.mark_ip_dscp_supported[RTE_TM_YELLOW],
854 cap.mark_ip_dscp_supported[RTE_TM_RED]);
856 printf(" - mask stats (0x%"PRIx64")"
857 " dynamic update (0x%"PRIx64")\n",
859 cap.dynamic_update_mask);
861 printf(" - sched MAX:\n"
863 "\t -- sp levels (%u)\n"
864 "\t -- wfq children per group (%u)\n"
865 "\t -- wfq groups (%u)\n"
866 "\t -- wfq weight (%u)\n",
867 cap.sched_sp_n_priorities_max,
868 cap.sched_sp_n_priorities_max,
869 cap.sched_wfq_n_children_per_group_max,
870 cap.sched_wfq_n_groups_max,
871 cap.sched_wfq_weight_max);
873 printf(" - CMAN support:\n"
874 "\t -- WRED mode: pkt (%d) byte (%d)\n"
875 "\t -- head drop (%d)\n",
876 cap.cman_wred_packet_mode_supported,
877 cap.cman_wred_byte_mode_supported,
878 cap.cman_head_drop_supported);
879 printf("\t -- MAX WRED CONTEXT:"
880 " total (%u) private (%u) shared (%u)\n",
881 cap.cman_wred_context_n_max,
882 cap.cman_wred_context_private_n_max,
883 cap.cman_wred_context_shared_n_max);
885 for (j = 0; j < cap.n_nodes_max; j++) {
886 memset(&capnode, 0, sizeof(capnode));
887 ret = rte_tm_node_capabilities_get(i, j,
894 printf(" NODE %u\n", j);
895 printf("\t - shaper private: (%d) dual rate (%d)\n",
896 capnode.shaper_private_supported,
897 capnode.shaper_private_dual_rate_supported);
898 printf("\t - shaper shared max: (%u)\n",
899 capnode.shaper_shared_n_max);
900 printf("\t - stats mask %"PRIx64"\n",
903 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
907 display_nodecap_info(is_leaf, &capnode);
910 for (j = 0; j < cap.n_levels_max; j++) {
911 memset(&caplevel, 0, sizeof(caplevel));
912 ret = rte_tm_level_capabilities_get(i, j,
917 printf(" - Level %u\n", j);
918 printf("\t -- node MAX: %u non leaf %u leaf %u\n",
919 caplevel.n_nodes_max,
920 caplevel.n_nodes_nonleaf_max,
921 caplevel.n_nodes_leaf_max);
922 printf("\t -- indetical: non leaf %u leaf %u\n",
923 caplevel.non_leaf_nodes_identical,
924 caplevel.leaf_nodes_identical);
926 for (k = 0; k < caplevel.n_nodes_max; k++) {
927 ret = rte_tm_node_type_get(i, k,
932 display_levelcap_info(is_leaf, &caplevel);
936 if (check_for_leaf) {
937 ret = rte_tm_get_number_of_leaf_nodes(i,
938 &n_leaf_nodes, &error);
940 printf(" - leaf nodes (%u)\n", n_leaf_nodes);
943 for (j = 0; j < n_leaf_nodes; j++) {
944 struct rte_tm_node_stats stats;
945 memset(&stats, 0, sizeof(stats));
947 ret = rte_tm_node_stats_read(i, j,
948 &stats, &cap.stats_mask, 0, &error);
952 printf(" - STATS for node (%u)\n", j);
953 printf(" -- pkts (%"PRIu64") bytes (%"PRIu64")\n",
954 stats.n_pkts, stats.n_bytes);
956 ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
957 if (ret || (!is_leaf))
960 printf(" -- leaf queued:"
961 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
962 stats.leaf.n_pkts_queued,
963 stats.leaf.n_bytes_queued);
964 printf(" - dropped:\n"
966 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
968 " pkts (%"PRIu64") bytes (%"PRIu64")\n"
970 " pkts (%"PRIu64") bytes (%"PRIu64")\n",
971 stats.leaf.n_pkts_dropped[RTE_TM_GREEN],
972 stats.leaf.n_bytes_dropped[RTE_TM_GREEN],
973 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW],
974 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW],
975 stats.leaf.n_pkts_dropped[RTE_TM_RED],
976 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
980 STATS_BDR_STR(50, "");
984 main(int argc, char **argv)
988 char c_flag[] = "-c1";
989 char n_flag[] = "-n4";
990 char mp_flag[] = "--proc-type=secondary";
991 char *argp[argc + 3];
994 /* preparse app arguments */
995 ret = proc_info_preparse_args(argc, argv);
997 printf("Failed to parse arguments\n");
1006 for (i = 1; i < argc; i++)
1007 argp[i + 3] = argv[i];
1011 ret = rte_eal_init(argc, argp);
1013 rte_panic("Cannot init EAL\n");
1018 if (!rte_eal_primary_proc_alive(NULL))
1019 rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
1021 /* parse app arguments */
1022 ret = proc_info_parse_args(argc, argv);
1024 rte_exit(EXIT_FAILURE, "Invalid argument\n");
1031 nb_ports = rte_eth_dev_count_avail();
1033 rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
1035 /* If no port mask was specified*/
1036 if (enabled_port_mask == 0)
1037 enabled_port_mask = 0xffff;
1039 RTE_ETH_FOREACH_DEV(i) {
1040 if (enabled_port_mask & (1 << i)) {
1042 nic_stats_display(i);
1043 else if (enable_xstats)
1044 nic_xstats_display(i);
1045 else if (reset_stats)
1047 else if (reset_xstats)
1048 nic_xstats_clear(i);
1049 else if (enable_xstats_name)
1050 nic_xstats_by_name_display(i, xstats_name);
1051 else if (nb_xstats_ids > 0)
1052 nic_xstats_by_ids_display(i, xstats_ids,
1054 else if (enable_metrics)
1059 /* print port independent stats */
1061 metrics_display(RTE_METRICS_GLOBAL);
1063 /* show information for PMD */
1064 if (enable_shw_port)
1069 ret = rte_eal_cleanup();
1071 printf("Error from rte_eal_cleanup(), %d\n", ret);
1073 snprintf(bdr_str, MAX_STRING_LEN, " ");
1074 STATS_BDR_STR(50, bdr_str);