Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2017 Intel Corporation
3 : : */
4 : :
5 : : #include <stdio.h>
6 : : #include <string.h>
7 : : #include <stdint.h>
8 : : #include <stdbool.h>
9 : : #include <errno.h>
10 : : #include <stdarg.h>
11 : : #include <inttypes.h>
12 : : #include <sys/queue.h>
13 : : #include <stdlib.h>
14 : : #include <getopt.h>
15 : : #include <unistd.h>
16 : : #include <strings.h>
17 : :
18 : : #include <rte_eal.h>
19 : : #include <rte_common.h>
20 : : #include <rte_debug.h>
21 : : #include <rte_ethdev.h>
22 : : #include <rte_malloc.h>
23 : : #include <rte_memory.h>
24 : : #include <rte_memzone.h>
25 : : #include <rte_launch.h>
26 : : #include <rte_tailq.h>
27 : : #include <rte_per_lcore.h>
28 : : #include <rte_lcore.h>
29 : : #include <rte_log.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_string_fns.h>
32 : : #ifdef RTE_LIB_METRICS
33 : : #include <rte_metrics.h>
34 : : #endif
35 : : #include <rte_cycles.h>
36 : : #ifdef RTE_LIB_SECURITY
37 : : #include <rte_security.h>
38 : : #endif
39 : : #include <rte_cryptodev.h>
40 : : #include <rte_tm.h>
41 : : #include <rte_hexdump.h>
42 : : #include <rte_version.h>
43 : : #include <rte_eventdev.h>
44 : :
45 : : /* Maximum long option length for option parsing. */
46 : : #define MAX_LONG_OPT_SZ 64
47 : : #define MAX_STRING_LEN 256
48 : :
49 : : #define ETHDEV_FWVERS_LEN 32
50 : : #define RTE_RETA_CONF_GROUP_NUM 32
51 : : #define EEPROM_DUMP_CHUNKSIZE 1024
52 : :
53 : : #define STATS_BDR_FMT "========================================"
54 : : #define STATS_BDR_STR(w, s) printf("%.*s%s%.*s\n", w, \
55 : : STATS_BDR_FMT, s, w, STATS_BDR_FMT)
56 : :
57 : : /* mask of enabled ports */
58 : : static unsigned long enabled_port_mask;
59 : : /* Enable stats. */
60 : : static uint32_t enable_stats;
61 : : /* Enable xstats. */
62 : : static uint32_t enable_xstats;
63 : : static uint32_t enable_xstats_hide_zero;
64 : : /* Enable collectd format */
65 : : static uint32_t enable_collectd_format;
66 : : /* FD to send collectd format messages to STDOUT */
67 : : static int stdout_fd;
68 : : /* Host id process is running on */
69 : : static char host_id[MAX_LONG_OPT_SZ];
70 : : #ifdef RTE_LIB_METRICS
71 : : /* Enable metrics. */
72 : : static uint32_t enable_metrics;
73 : : #endif
74 : : /* Enable stats reset. */
75 : : static uint32_t reset_stats;
76 : : /* Enable xstats reset. */
77 : : static uint32_t reset_xstats;
78 : : /* Enable memory info. */
79 : : static uint32_t mem_info;
80 : : /* Enable displaying xstat name. */
81 : : static uint32_t enable_xstats_name;
82 : : static char *xstats_name;
83 : :
84 : : /* Enable xstats by ids. */
85 : : #define MAX_NB_XSTATS_IDS 1024
86 : : static uint32_t nb_xstats_ids;
87 : : static uint64_t xstats_ids[MAX_NB_XSTATS_IDS];
88 : :
89 : : /* show border */
90 : : static char bdr_str[MAX_STRING_LEN];
91 : :
92 : : /* Enable show port. */
93 : : static uint32_t enable_shw_port;
94 : : /* Enable show port private info. */
95 : : static uint32_t enable_shw_port_priv;
96 : : /* Enable show tm. */
97 : : static uint32_t enable_shw_tm;
98 : : /* Enable show crypto. */
99 : : static uint32_t enable_shw_crypto;
100 : : /* Enable show ring. */
101 : : static uint32_t enable_shw_ring;
102 : : static char *ring_name;
103 : : /* Enable show mempool. */
104 : : static uint32_t enable_shw_mempool;
105 : : static char *mempool_name;
106 : : /* Enable iter mempool. */
107 : : static uint32_t enable_iter_mempool;
108 : : static char *mempool_iter_name;
109 : : /* Enable dump regs. */
110 : : static uint32_t enable_dump_regs;
111 : : static char *dump_regs_file_prefix;
112 : : /* Enable show DPDK version. */
113 : : static uint32_t enable_shw_version;
114 : : /* Enable show ethdev firmware version. */
115 : : static uint32_t enable_shw_fw_version;
116 : : /* Enable show RSS reta. */
117 : : static uint32_t enable_shw_rss_reta;
118 : : /* Enable show module eeprom information. */
119 : : static uint32_t enable_shw_module_eeprom;
120 : :
121 : : /* Enable dump Rx/Tx descriptor. */
122 : : static uint32_t enable_shw_rx_desc_dump;
123 : : static uint32_t enable_shw_tx_desc_dump;
124 : :
125 : : /* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
126 : : * 256 ports and queues for event_Dev
127 : : */
128 : : #define MAX_PORTS_QUEUES 256
129 : :
130 : : struct eventdev_params {
131 : : uint16_t ports[MAX_PORTS_QUEUES];
132 : : uint16_t queues[MAX_PORTS_QUEUES];
133 : : uint16_t num_queues;
134 : : uint16_t num_ports;
135 : : uint8_t shw_all_queues:1,
136 : : shw_all_ports:1,
137 : : dump_xstats:1,
138 : : reset_xstats:1,
139 : : shw_device_xstats:1;
140 : : };
141 : :
142 : : static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
143 : :
144 : : #define DESC_PARAM_NUM 3
145 : :
146 : : struct desc_param {
147 : : uint16_t queue_id; /* A queue identifier on this port. */
148 : : uint16_t offset; /* The offset of the descriptor starting from tail. */
149 : : uint16_t num; /* The number of the descriptors to dump. */
150 : : };
151 : :
152 : : static struct desc_param rx_desc_param;
153 : : static struct desc_param tx_desc_param;
154 : :
155 : : #define RSS_HASH_KEY_SIZE 64
156 : :
157 : : /* display usage */
158 : : static void
159 : : proc_info_usage(const char *prgname)
160 : : {
161 : : printf("%s [EAL options] -- -p PORTMASK\n"
162 : : " -m to display DPDK memory zones, segments and TAILQ information\n"
163 : : " -p PORTMASK: hexadecimal bitmask of ports to retrieve stats for\n"
164 : : " --stats: to display port statistics, enabled by default\n"
165 : : " --xstats[=hide_zero]: to display extended port statistics, disabled by default, "
166 : : "support hide zero.\n"
167 : : #ifdef RTE_LIB_METRICS
168 : : " --metrics: to display derived metrics of the ports, disabled by "
169 : : "default\n"
170 : : #endif
171 : : " --xstats-name NAME: to display single xstat id by NAME\n"
172 : : " --xstats-ids IDLIST: to display xstat values by id. "
173 : : "The argument is comma-separated list of xstat ids to print out.\n"
174 : : " --stats-reset: to reset port statistics\n"
175 : : " --xstats-reset: to reset port extended statistics\n"
176 : : " --collectd-format: to print statistics to STDOUT in expected by collectd format\n"
177 : : " --host-id STRING: host id used to identify the system process is running on\n"
178 : : " --show-port: to display ports information\n"
179 : : " --show-port-private: to display ports private information\n"
180 : : " --show-tm: to display traffic manager information for ports\n"
181 : : " --show-crypto: to display crypto information\n"
182 : : " --show-ring[=name]: to display ring information\n"
183 : : " --show-mempool[=name]: to display mempool information\n"
184 : : " --version: to display DPDK version\n"
185 : : " --firmware-version: to display ethdev firmware version\n"
186 : : " --show-rss-reta: to display ports redirection table\n"
187 : : " --show-module-eeprom: to display ports module eeprom information\n"
188 : : " --show-rx-descriptor queue_id:offset:num to display ports Rx descriptor information. "
189 : : "queue_id: A Rx queue identifier on this port. "
190 : : "offset: The offset of the descriptor starting from tail. "
191 : : "num: The number of the descriptors to dump.\n"
192 : : " --show-tx-descriptor queue_id:offset:num to display ports Tx descriptor information. "
193 : : "queue_id: A Tx queue identifier on this port. "
194 : : "offset: The offset of the descriptor starting from tail. "
195 : : "num: The number of the descriptors to dump.\n"
196 : : " --iter-mempool=name: iterate mempool elements to display content\n"
197 : : " --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
198 : : " --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
199 : : " --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
200 : : " --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
201 : : " --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
202 : : " --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
203 : : prgname);
204 : 0 : }
205 : :
206 : : /*
207 : : * Parse the portmask provided at run time.
208 : : */
209 : : static int
210 : 0 : parse_portmask(const char *portmask)
211 : : {
212 : 0 : char *end = NULL;
213 : :
214 : 0 : errno = 0;
215 : :
216 : : /* parse hexadecimal string */
217 : 0 : enabled_port_mask = strtoul(portmask, &end, 16);
218 : 0 : if (portmask[0] == '\0' || end == NULL || *end != '\0' || errno != 0) {
219 : 0 : fprintf(stderr, "Invalid portmask '%s'\n", portmask);
220 : 0 : return -1;
221 : : }
222 : :
223 : : return 0;
224 : : }
225 : :
226 : : /*
227 : : * Parse ids value list into array
228 : : */
229 : : static int
230 : 0 : parse_xstats_ids(char *list, uint64_t *ids, int limit) {
231 : : int length;
232 : : char *token;
233 : 0 : char *ctx = NULL;
234 : : char *endptr;
235 : :
236 : : length = 0;
237 : 0 : token = strtok_r(list, ",", &ctx);
238 : 0 : while (token != NULL) {
239 : 0 : ids[length] = strtoull(token, &endptr, 10);
240 : 0 : if (*endptr != '\0')
241 : : return -EINVAL;
242 : :
243 : 0 : length++;
244 : 0 : if (length >= limit)
245 : : return -E2BIG;
246 : :
247 : 0 : token = strtok_r(NULL, ",", &ctx);
248 : : }
249 : :
250 : : return length;
251 : : }
252 : :
253 : : static int
254 : : parse_descriptor_param(char *list, struct desc_param *desc)
255 : : {
256 : : int ret;
257 : :
258 : 0 : ret = sscanf(list, "%hu:%hu:%hu", &desc->queue_id, &desc->offset,
259 : : &desc->num);
260 : 0 : if (ret != DESC_PARAM_NUM)
261 : : return -EINVAL;
262 : :
263 : : return 0;
264 : : }
265 : :
266 : : static int
267 : 0 : parse_eventdev_id(const char *str)
268 : : {
269 : : unsigned long evdev_id;
270 : : char *endp;
271 : :
272 : 0 : evdev_id = strtoul(str, &endp, 0);
273 : :
274 : 0 : if (*str == '\0' || *endp != '\0' || evdev_id >= rte_event_dev_count()) {
275 : 0 : fprintf(stderr, "Invalid eventdev id: %s\n", str);
276 : 0 : return -1;
277 : : }
278 : :
279 : 0 : return evdev_id;
280 : : }
281 : :
282 : : static int
283 : : parse_eventdev_dump_xstats_params(const char *list)
284 : : {
285 : 0 : int evdev_id = parse_eventdev_id(list);
286 : :
287 : 0 : if (evdev_id < 0)
288 : : return -EINVAL;
289 : :
290 : 0 : eventdev_var[evdev_id].dump_xstats = 1;
291 : :
292 : : return 0;
293 : : }
294 : :
295 : : static int
296 : : parse_eventdev_reset_xstats_params(const char *list)
297 : : {
298 : 0 : int evdev_id = parse_eventdev_id(list);
299 : :
300 : 0 : if (evdev_id < 0)
301 : : return -EINVAL;
302 : :
303 : 0 : eventdev_var[evdev_id].reset_xstats = 1;
304 : :
305 : : return 0;
306 : : }
307 : :
308 : : static int
309 : : parse_eventdev_device_xstats_params(const char *list)
310 : : {
311 : 0 : int evdev_id = parse_eventdev_id(list);
312 : :
313 : 0 : if (evdev_id < 0)
314 : : return -EINVAL;
315 : :
316 : 0 : eventdev_var[evdev_id].shw_device_xstats = 1;
317 : :
318 : : return 0;
319 : : }
320 : :
321 : : static int
322 : 0 : parse_eventdev_queue_xstats_params(const char *list)
323 : : {
324 : : uint16_t queue_id;
325 : : uint16_t evdev_id;
326 : :
327 : 0 : if (sscanf(list, "*:%hu", &evdev_id) == 1) {
328 : 0 : if (evdev_id >= rte_event_dev_count()) {
329 : 0 : printf("Invalid eventdev id: %hu\n", evdev_id);
330 : 0 : return -EINVAL;
331 : : }
332 : 0 : eventdev_var[evdev_id].shw_all_queues = 1;
333 : 0 : } else if (sscanf(list, "%hu:%hu", &queue_id, &evdev_id) == 2) {
334 : 0 : if (evdev_id >= rte_event_dev_count()) {
335 : 0 : printf("Invalid eventdev id: %hu\n", evdev_id);
336 : 0 : return -EINVAL;
337 : : }
338 : :
339 : 0 : if (queue_id >= MAX_PORTS_QUEUES) {
340 : 0 : printf("Invalid queue_id: %hu\n", queue_id);
341 : 0 : return -EINVAL;
342 : : }
343 : :
344 : 0 : eventdev_var[evdev_id].queues[eventdev_var[evdev_id].num_queues] = queue_id;
345 : 0 : eventdev_var[evdev_id].num_queues++;
346 : : } else {
347 : : return -EINVAL;
348 : : }
349 : :
350 : : return 0;
351 : : }
352 : :
353 : : static int
354 : 0 : parse_eventdev_port_xstats_params(const char *list)
355 : : {
356 : : uint16_t port_id;
357 : : uint16_t evdev_id;
358 : :
359 : 0 : if (sscanf(list, "*:%hu", &evdev_id) == 1) {
360 : 0 : if (evdev_id >= rte_event_dev_count()) {
361 : 0 : printf("Invalid eventdev id: %hu\n", evdev_id);
362 : 0 : return -EINVAL;
363 : : }
364 : 0 : eventdev_var[evdev_id].shw_all_ports = 1;
365 : 0 : } else if (sscanf(list, "%hu:%hu", &port_id, &evdev_id) == 2) {
366 : 0 : if (evdev_id >= rte_event_dev_count()) {
367 : 0 : printf("Invalid eventdev id: %hu\n", evdev_id);
368 : 0 : return -EINVAL;
369 : : }
370 : :
371 : 0 : if (port_id >= MAX_PORTS_QUEUES) {
372 : 0 : printf("Invalid port_id: %hu\n", port_id);
373 : 0 : return -EINVAL;
374 : : }
375 : :
376 : 0 : eventdev_var[evdev_id].ports[eventdev_var[evdev_id].num_ports] = port_id;
377 : 0 : eventdev_var[evdev_id].num_ports++;
378 : : } else {
379 : : return -EINVAL;
380 : : }
381 : :
382 : : return 0;
383 : : }
384 : :
385 : : static int
386 : 0 : proc_info_preparse_args(int argc, char **argv)
387 : : {
388 : 0 : char *prgname = argv[0];
389 : : int i;
390 : :
391 : 0 : for (i = 0; i < argc; i++) {
392 : : /* Print stats or xstats to STDOUT in collectd format */
393 : 0 : if (!strncmp(argv[i], "--collectd-format", MAX_LONG_OPT_SZ)) {
394 : 0 : enable_collectd_format = 1;
395 : 0 : stdout_fd = dup(STDOUT_FILENO);
396 : 0 : close(STDOUT_FILENO);
397 : : }
398 : 0 : if (!strncmp(argv[i], "--host-id", MAX_LONG_OPT_SZ)) {
399 : 0 : if ((i + 1) == argc) {
400 : : printf("Invalid host id or not specified\n");
401 : : proc_info_usage(prgname);
402 : 0 : return -1;
403 : : }
404 : 0 : strlcpy(host_id, argv[i + 1], sizeof(host_id));
405 : : }
406 : : }
407 : :
408 : 0 : if (!strlen(host_id)) {
409 : : int err = gethostname(host_id, MAX_LONG_OPT_SZ-1);
410 : :
411 : 0 : if (err)
412 : : strlcpy(host_id, "unknown", sizeof(host_id));
413 : : }
414 : :
415 : : return 0;
416 : : }
417 : :
418 : : /* Parse the argument given in the command line of the application */
419 : : static int
420 : 0 : proc_info_parse_args(int argc, char **argv)
421 : : {
422 : : int opt;
423 : : int option_index;
424 : 0 : char *prgname = argv[0];
425 : : static struct option long_option[] = {
426 : : {"stats", 0, NULL, 0},
427 : : {"stats-reset", 0, NULL, 0},
428 : : {"xstats", optional_argument, NULL, 0},
429 : : #ifdef RTE_LIB_METRICS
430 : : {"metrics", 0, NULL, 0},
431 : : #endif
432 : : {"xstats-reset", 0, NULL, 0},
433 : : {"xstats-name", required_argument, NULL, 1},
434 : : {"collectd-format", 0, NULL, 0},
435 : : {"xstats-ids", 1, NULL, 1},
436 : : {"host-id", 0, NULL, 0},
437 : : {"show-port", 0, NULL, 0},
438 : : {"show-port-private", 0, NULL, 0},
439 : : {"show-tm", 0, NULL, 0},
440 : : {"show-crypto", 0, NULL, 0},
441 : : {"show-ring", optional_argument, NULL, 0},
442 : : {"show-mempool", optional_argument, NULL, 0},
443 : : {"iter-mempool", required_argument, NULL, 0},
444 : : {"dump-regs", required_argument, NULL, 0},
445 : : {"version", 0, NULL, 0},
446 : : {"firmware-version", 0, NULL, 0},
447 : : {"show-rss-reta", 0, NULL, 0},
448 : : {"show-module-eeprom", 0, NULL, 0},
449 : : {"show-rx-descriptor", required_argument, NULL, 1},
450 : : {"show-tx-descriptor", required_argument, NULL, 1},
451 : : {"show-edev-queue-xstats", required_argument, NULL, 0},
452 : : {"show-edev-port-xstats", required_argument, NULL, 0},
453 : : {"edev-dump-xstats", required_argument, NULL, 0},
454 : : {"edev-reset-xstats", required_argument, NULL, 0},
455 : : {"show-edev-device-xstats", required_argument, NULL, 0},
456 : : {NULL, 0, 0, 0}
457 : : };
458 : :
459 : 0 : if (argc == 1)
460 : : proc_info_usage(prgname);
461 : :
462 : : /* Parse command line */
463 : 0 : while ((opt = getopt_long(argc, argv, "p:m",
464 : 0 : long_option, &option_index)) != EOF) {
465 : 0 : switch (opt) {
466 : : /* portmask */
467 : 0 : case 'p':
468 : 0 : if (parse_portmask(optarg) < 0) {
469 : : proc_info_usage(prgname);
470 : 0 : return -1;
471 : : }
472 : : break;
473 : 0 : case 'm':
474 : 0 : mem_info = 1;
475 : 0 : break;
476 : 0 : case 0:
477 : : /* Print stats */
478 : 0 : if (!strncmp(long_option[option_index].name, "stats",
479 : : MAX_LONG_OPT_SZ)) {
480 : 0 : enable_stats = 1;
481 : : /* Print xstats */
482 : 0 : } else if (!strncmp(long_option[option_index].name, "xstats",
483 : : MAX_LONG_OPT_SZ)) {
484 : 0 : enable_xstats = 1;
485 : 0 : if (optarg != NULL && !strncmp(optarg, "hide_zero",
486 : : MAX_LONG_OPT_SZ))
487 : 0 : enable_xstats_hide_zero = 1;
488 : :
489 : : }
490 : : #ifdef RTE_LIB_METRICS
491 : 0 : else if (!strncmp(long_option[option_index].name,
492 : : "metrics",
493 : : MAX_LONG_OPT_SZ))
494 : 0 : enable_metrics = 1;
495 : : #endif
496 : : /* Reset stats */
497 : 0 : if (!strncmp(long_option[option_index].name, "stats-reset",
498 : : MAX_LONG_OPT_SZ))
499 : 0 : reset_stats = 1;
500 : : /* Reset xstats */
501 : 0 : else if (!strncmp(long_option[option_index].name, "xstats-reset",
502 : : MAX_LONG_OPT_SZ))
503 : 0 : reset_xstats = 1;
504 : 0 : else if (!strncmp(long_option[option_index].name,
505 : : "show-port", MAX_LONG_OPT_SZ))
506 : 0 : enable_shw_port = 1;
507 : 0 : else if (!strncmp(long_option[option_index].name,
508 : : "show-port-private", MAX_LONG_OPT_SZ))
509 : 0 : enable_shw_port_priv = 1;
510 : 0 : else if (!strncmp(long_option[option_index].name,
511 : : "show-tm", MAX_LONG_OPT_SZ))
512 : 0 : enable_shw_tm = 1;
513 : 0 : else if (!strncmp(long_option[option_index].name,
514 : : "show-crypto", MAX_LONG_OPT_SZ))
515 : 0 : enable_shw_crypto = 1;
516 : 0 : else if (!strncmp(long_option[option_index].name,
517 : : "show-ring", MAX_LONG_OPT_SZ)) {
518 : 0 : enable_shw_ring = 1;
519 : 0 : ring_name = optarg;
520 : 0 : } else if (!strncmp(long_option[option_index].name,
521 : : "show-mempool", MAX_LONG_OPT_SZ)) {
522 : 0 : enable_shw_mempool = 1;
523 : 0 : mempool_name = optarg;
524 : 0 : } else if (!strncmp(long_option[option_index].name,
525 : : "iter-mempool", MAX_LONG_OPT_SZ)) {
526 : 0 : enable_iter_mempool = 1;
527 : 0 : mempool_iter_name = optarg;
528 : 0 : } else if (!strncmp(long_option[option_index].name,
529 : : "dump-regs", MAX_LONG_OPT_SZ)) {
530 : 0 : enable_dump_regs = 1;
531 : 0 : dump_regs_file_prefix = optarg;
532 : 0 : } else if (!strncmp(long_option[option_index].name,
533 : : "version", MAX_LONG_OPT_SZ))
534 : 0 : enable_shw_version = 1;
535 : 0 : else if (!strncmp(long_option[option_index].name,
536 : : "firmware-version", MAX_LONG_OPT_SZ))
537 : 0 : enable_shw_fw_version = 1;
538 : 0 : else if (!strncmp(long_option[option_index].name,
539 : : "show-rss-reta", MAX_LONG_OPT_SZ))
540 : 0 : enable_shw_rss_reta = 1;
541 : 0 : else if (!strncmp(long_option[option_index].name,
542 : : "show-module-eeprom", MAX_LONG_OPT_SZ))
543 : 0 : enable_shw_module_eeprom = 1;
544 : 0 : else if (!strncmp(long_option[option_index].name,
545 : : "edev-dump-xstats", MAX_LONG_OPT_SZ)) {
546 : 0 : int ret = parse_eventdev_dump_xstats_params(optarg);
547 : : if (ret < 0) {
548 : 0 : fprintf(stderr, "Error parsing eventdev dump xstats params: %s\n",
549 : : strerror(-ret));
550 : 0 : return -1;
551 : : }
552 : 0 : } else if (!strncmp(long_option[option_index].name,
553 : : "edev-reset-xstats", MAX_LONG_OPT_SZ)) {
554 : 0 : int ret = parse_eventdev_reset_xstats_params(optarg);
555 : : if (ret < 0) {
556 : 0 : fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
557 : : strerror(-ret));
558 : 0 : return -1;
559 : : }
560 : 0 : } else if (!strncmp(long_option[option_index].name,
561 : : "show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
562 : 0 : int ret = parse_eventdev_device_xstats_params(optarg);
563 : : if (ret < 0) {
564 : 0 : fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
565 : : strerror(-ret));
566 : 0 : return -1;
567 : : }
568 : 0 : } else if (!strncmp(long_option[option_index].name,
569 : : "show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
570 : 0 : int ret = parse_eventdev_queue_xstats_params(optarg);
571 : 0 : if (ret < 0) {
572 : 0 : fprintf(stderr, "Error parsing eventdev queue xstats params: %s\n",
573 : : strerror(-ret));
574 : 0 : return -1;
575 : : }
576 : 0 : } else if (!strncmp(long_option[option_index].name,
577 : : "show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
578 : 0 : int ret = parse_eventdev_port_xstats_params(optarg);
579 : 0 : if (ret < 0) {
580 : 0 : fprintf(stderr, "Error parsing eventdev port xstats params: %s\n",
581 : : strerror(-ret));
582 : 0 : return -1;
583 : : }
584 : : }
585 : : break;
586 : 0 : case 1:
587 : : /* Print xstat single value given by name*/
588 : 0 : if (!strncmp(long_option[option_index].name,
589 : : "xstats-name", MAX_LONG_OPT_SZ)) {
590 : 0 : enable_xstats_name = 1;
591 : 0 : xstats_name = optarg;
592 : : printf("name:%s:%s\n",
593 : : long_option[option_index].name,
594 : : optarg);
595 : 0 : } else if (!strncmp(long_option[option_index].name,
596 : : "xstats-ids",
597 : : MAX_LONG_OPT_SZ)) {
598 : 0 : int ret = parse_xstats_ids(optarg,
599 : : xstats_ids, MAX_NB_XSTATS_IDS);
600 : 0 : if (ret <= 0) {
601 : : printf("xstats-id list parse error.\n");
602 : 0 : return -1;
603 : : }
604 : 0 : nb_xstats_ids = ret;
605 : 0 : } else if (!strncmp(long_option[option_index].name,
606 : : "show-rx-descriptor", MAX_LONG_OPT_SZ)) {
607 : 0 : int ret = parse_descriptor_param(optarg,
608 : : &rx_desc_param);
609 : : if (ret < 0) {
610 : 0 : fprintf(stderr, "Error parsing Rx descriptor param: %s\n",
611 : : strerror(-ret));
612 : 0 : return -1;
613 : : }
614 : 0 : enable_shw_rx_desc_dump = 1;
615 : 0 : } else if (!strncmp(long_option[option_index].name,
616 : : "show-tx-descriptor", MAX_LONG_OPT_SZ)) {
617 : 0 : int ret = parse_descriptor_param(optarg,
618 : : &tx_desc_param);
619 : : if (ret < 0) {
620 : 0 : fprintf(stderr, "Error parsing Tx descriptor param: %s\n",
621 : : strerror(-ret));
622 : 0 : return -1;
623 : : }
624 : 0 : enable_shw_tx_desc_dump = 1;
625 : : }
626 : : break;
627 : : default:
628 : : proc_info_usage(prgname);
629 : 0 : return -1;
630 : : }
631 : : }
632 : : return 0;
633 : : }
634 : :
635 : : static void
636 : 0 : meminfo_display(void)
637 : : {
638 : : printf("----------- MEMORY_SEGMENTS -----------\n");
639 : 0 : rte_dump_physmem_layout(stdout);
640 : : printf("--------- END_MEMORY_SEGMENTS ---------\n");
641 : :
642 : : printf("------------ MEMORY_ZONES -------------\n");
643 : 0 : rte_memzone_dump(stdout);
644 : : printf("---------- END_MEMORY_ZONES -----------\n");
645 : :
646 : : printf("---------- MALLOC_HEAP_DUMP -----------\n");
647 : 0 : rte_malloc_dump_heaps(stdout);
648 : : printf("-------- END_MALLOC_HEAP_DUMP ---------\n");
649 : :
650 : : printf("------------- TAIL_QUEUES -------------\n");
651 : 0 : rte_dump_tailq(stdout);
652 : : printf("---------- END_TAIL_QUEUES ------------\n");
653 : 0 : }
654 : :
655 : : static void
656 : 0 : nic_stats_display(uint16_t port_id)
657 : : {
658 : : struct rte_eth_stats stats;
659 : :
660 : : static const char *nic_stats_border = "########################";
661 : :
662 : 0 : rte_eth_stats_get(port_id, &stats);
663 : 0 : printf("\n %s NIC statistics for port %-2d %s\n",
664 : : nic_stats_border, port_id, nic_stats_border);
665 : :
666 : 0 : printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
667 : : " RX-bytes: %-10"PRIu64"\n", stats.ipackets, stats.ierrors,
668 : : stats.ibytes);
669 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf);
670 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64
671 : : " TX-bytes: %-10"PRIu64"\n", stats.opackets, stats.oerrors,
672 : : stats.obytes);
673 : :
674 : 0 : printf(" %s############################%s\n",
675 : : nic_stats_border, nic_stats_border);
676 : 0 : }
677 : :
678 : : static void
679 : 0 : nic_stats_clear(uint16_t port_id)
680 : : {
681 : 0 : printf("\n Clearing NIC stats for port %d\n", port_id);
682 : 0 : rte_eth_stats_reset(port_id);
683 : : printf("\n NIC statistics for port %d cleared\n", port_id);
684 : 0 : }
685 : :
686 : 0 : static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
687 : : const char *cnt_name) {
688 : 0 : const char *type_end = strrchr(cnt_name, '_');
689 : :
690 : 0 : if ((type_end != NULL) &&
691 : 0 : (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
692 : 0 : if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
693 : : strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
694 : 0 : else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
695 : : strlcpy(cnt_type, "if_rx_dropped", cnt_type_len);
696 : 0 : else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
697 : : strlcpy(cnt_type, "if_rx_octets", cnt_type_len);
698 : 0 : else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
699 : : strlcpy(cnt_type, "if_rx_packets", cnt_type_len);
700 : 0 : else if (strncmp(type_end, "_placement",
701 : : strlen("_placement")) == 0)
702 : : strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
703 : 0 : else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
704 : : strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
705 : : else
706 : : /* Does not fit obvious type: use a more generic one */
707 : : strlcpy(cnt_type, "derive", cnt_type_len);
708 : 0 : } else if ((type_end != NULL) &&
709 : 0 : (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
710 : 0 : if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
711 : : strlcpy(cnt_type, "if_tx_errors", cnt_type_len);
712 : 0 : else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
713 : : strlcpy(cnt_type, "if_tx_dropped", cnt_type_len);
714 : 0 : else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
715 : : strlcpy(cnt_type, "if_tx_octets", cnt_type_len);
716 : 0 : else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
717 : : strlcpy(cnt_type, "if_tx_packets", cnt_type_len);
718 : : else
719 : : /* Does not fit obvious type: use a more generic one */
720 : : strlcpy(cnt_type, "derive", cnt_type_len);
721 : 0 : } else if ((type_end != NULL) &&
722 : 0 : (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
723 : 0 : if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
724 : : strlcpy(cnt_type, "filter_result", cnt_type_len);
725 : 0 : else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
726 : : strlcpy(cnt_type, "errors", cnt_type_len);
727 : 0 : } else if ((type_end != NULL) &&
728 : 0 : (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
729 : 0 : if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
730 : : strlcpy(cnt_type, "errors", cnt_type_len);
731 : : } else {
732 : : /* Does not fit obvious type, or strrchr error: */
733 : : /* use a more generic type */
734 : : strlcpy(cnt_type, "derive", cnt_type_len);
735 : : }
736 : 0 : }
737 : :
738 : : static void
739 : 0 : nic_xstats_by_name_display(uint16_t port_id, char *name)
740 : : {
741 : : uint64_t id;
742 : :
743 : 0 : printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
744 : : port_id, name);
745 : :
746 : 0 : if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
747 : 0 : printf("%s: %"PRIu64"\n", name, id);
748 : : else
749 : : printf("Statistic not found...\n");
750 : :
751 : 0 : }
752 : :
753 : : static void
754 : 0 : nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
755 : : {
756 : : struct rte_eth_xstat_name *xstats_names;
757 : : uint64_t *values;
758 : : int ret, i;
759 : : static const char *nic_stats_border = "########################";
760 : :
761 : 0 : values = malloc(sizeof(*values) * len);
762 : 0 : if (values == NULL) {
763 : : printf("Cannot allocate memory for xstats\n");
764 : 0 : return;
765 : : }
766 : :
767 : 0 : xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
768 : 0 : if (xstats_names == NULL) {
769 : : printf("Cannot allocate memory for xstat names\n");
770 : 0 : free(values);
771 : 0 : return;
772 : : }
773 : :
774 : 0 : if (len != rte_eth_xstats_get_names_by_id(
775 : : port_id, xstats_names, len, ids)) {
776 : : printf("Cannot get xstat names\n");
777 : 0 : goto err;
778 : : }
779 : :
780 : : printf("###### NIC extended statistics for port %-2d #########\n",
781 : : port_id);
782 : 0 : printf("%s############################\n", nic_stats_border);
783 : 0 : ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
784 : 0 : if (ret < 0 || ret > len) {
785 : : printf("Cannot get xstats\n");
786 : 0 : goto err;
787 : : }
788 : :
789 : 0 : for (i = 0; i < len; i++)
790 : 0 : printf("%s: %"PRIu64"\n",
791 : 0 : xstats_names[i].name,
792 : 0 : values[i]);
793 : :
794 : 0 : printf("%s############################\n", nic_stats_border);
795 : 0 : err:
796 : 0 : free(values);
797 : 0 : free(xstats_names);
798 : : }
799 : :
800 : : static void
801 : 0 : nic_xstats_display(uint16_t port_id)
802 : : {
803 : : struct rte_eth_xstat_name *xstats_names;
804 : : uint64_t *values;
805 : : int len, ret, i;
806 : : static const char *nic_stats_border = "########################";
807 : :
808 : 0 : len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
809 : 0 : if (len < 0) {
810 : : printf("Cannot get xstats count\n");
811 : 0 : return;
812 : : }
813 : 0 : values = malloc(sizeof(*values) * len);
814 : 0 : if (values == NULL) {
815 : : printf("Cannot allocate memory for xstats\n");
816 : 0 : return;
817 : : }
818 : :
819 : 0 : xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
820 : 0 : if (xstats_names == NULL) {
821 : : printf("Cannot allocate memory for xstat names\n");
822 : 0 : free(values);
823 : 0 : return;
824 : : }
825 : 0 : if (len != rte_eth_xstats_get_names_by_id(
826 : : port_id, xstats_names, len, NULL)) {
827 : : printf("Cannot get xstat names\n");
828 : 0 : goto err;
829 : : }
830 : :
831 : : printf("###### NIC extended statistics for port %-2d #########\n",
832 : : port_id);
833 : 0 : printf("%s############################\n",
834 : : nic_stats_border);
835 : 0 : ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
836 : 0 : if (ret < 0 || ret > len) {
837 : : printf("Cannot get xstats\n");
838 : 0 : goto err;
839 : : }
840 : :
841 : 0 : for (i = 0; i < len; i++) {
842 : 0 : if (enable_xstats_hide_zero && values[i] == 0)
843 : 0 : continue;
844 : 0 : if (enable_collectd_format) {
845 : : char counter_type[MAX_STRING_LEN];
846 : : char buf[MAX_STRING_LEN];
847 : : size_t n;
848 : :
849 : 0 : collectd_resolve_cnt_type(counter_type,
850 : : sizeof(counter_type),
851 : 0 : xstats_names[i].name);
852 : 0 : n = snprintf(buf, MAX_STRING_LEN,
853 : : "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
854 : : PRIu64"\n", host_id, port_id, counter_type,
855 : 0 : xstats_names[i].name, values[i]);
856 : : if (n > sizeof(buf) - 1)
857 : : n = sizeof(buf) - 1;
858 : 0 : ret = write(stdout_fd, buf, n);
859 : 0 : if (ret < 0)
860 : 0 : goto err;
861 : : } else {
862 : 0 : printf("%s: %"PRIu64"\n", xstats_names[i].name,
863 : 0 : values[i]);
864 : : }
865 : : }
866 : :
867 : 0 : printf("%s############################\n",
868 : : nic_stats_border);
869 : 0 : err:
870 : 0 : free(values);
871 : 0 : free(xstats_names);
872 : : }
873 : :
874 : : static void
875 : 0 : nic_xstats_clear(uint16_t port_id)
876 : : {
877 : : int ret;
878 : :
879 : 0 : printf("\n Clearing NIC xstats for port %d\n", port_id);
880 : 0 : ret = rte_eth_xstats_reset(port_id);
881 : 0 : if (ret != 0) {
882 : 0 : printf("\n Error clearing xstats for port %d: %s\n", port_id,
883 : : strerror(-ret));
884 : 0 : return;
885 : : }
886 : :
887 : : printf("\n NIC extended statistics for port %d cleared\n", port_id);
888 : : }
889 : :
890 : : #ifdef RTE_LIB_METRICS
891 : : static void
892 : 0 : metrics_display(int port_id)
893 : : {
894 : : struct rte_metric_value *metrics;
895 : : struct rte_metric_name *names;
896 : : int len, ret;
897 : : static const char *nic_stats_border = "########################";
898 : :
899 : 0 : len = rte_metrics_get_names(NULL, 0);
900 : 0 : if (len < 0) {
901 : : printf("Cannot get metrics count\n");
902 : 0 : return;
903 : : }
904 : 0 : if (len == 0) {
905 : : printf("No metrics to display (none have been registered)\n");
906 : 0 : return;
907 : : }
908 : :
909 : 0 : metrics = malloc(sizeof(struct rte_metric_value) * len);
910 : 0 : if (metrics == NULL) {
911 : : printf("Cannot allocate memory for metrics\n");
912 : 0 : return;
913 : : }
914 : :
915 : 0 : names = malloc(sizeof(struct rte_metric_name) * len);
916 : 0 : if (names == NULL) {
917 : : printf("Cannot allocate memory for metrics names\n");
918 : 0 : free(metrics);
919 : 0 : return;
920 : : }
921 : :
922 : 0 : if (len != rte_metrics_get_names(names, len)) {
923 : : printf("Cannot get metrics names\n");
924 : 0 : free(metrics);
925 : 0 : free(names);
926 : 0 : return;
927 : : }
928 : :
929 : 0 : if (port_id == RTE_METRICS_GLOBAL)
930 : : printf("###### Non port specific metrics #########\n");
931 : : else
932 : : printf("###### metrics for port %-2d #########\n", port_id);
933 : 0 : printf("%s############################\n", nic_stats_border);
934 : 0 : ret = rte_metrics_get_values(port_id, metrics, len);
935 : 0 : if (ret < 0 || ret > len) {
936 : : printf("Cannot get metrics values\n");
937 : 0 : free(metrics);
938 : 0 : free(names);
939 : 0 : return;
940 : : }
941 : :
942 : : int i;
943 : 0 : for (i = 0; i < len; i++)
944 : 0 : printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
945 : :
946 : 0 : printf("%s############################\n", nic_stats_border);
947 : 0 : free(metrics);
948 : 0 : free(names);
949 : : }
950 : : #endif
951 : :
952 : : static void
953 : 0 : show_security_context(uint16_t portid, bool inline_offload)
954 : : {
955 : : void *p_ctx;
956 : : const struct rte_security_capability *s_cap;
957 : :
958 : 0 : if (inline_offload)
959 : 0 : p_ctx = rte_eth_dev_get_sec_ctx(portid);
960 : : else
961 : 0 : p_ctx = rte_cryptodev_get_sec_ctx(portid);
962 : :
963 : 0 : if (p_ctx == NULL)
964 : : return;
965 : :
966 : : printf(" - crypto context\n");
967 : : printf("\t -- security context - %p\n", p_ctx);
968 : 0 : printf("\t -- size %u\n",
969 : : rte_security_session_get_size(p_ctx));
970 : :
971 : 0 : s_cap = rte_security_capabilities_get(p_ctx);
972 : 0 : if (s_cap) {
973 : : printf("\t -- action (0x%x), protocol (0x%x),"
974 : : " offload flags (0x%x)\n",
975 : 0 : s_cap->action,
976 : 0 : s_cap->protocol,
977 : 0 : s_cap->ol_flags);
978 : : printf("\t -- capabilities - oper type %x\n",
979 : 0 : s_cap->crypto_capabilities->op);
980 : : }
981 : : }
982 : :
983 : : static void
984 : 0 : show_offloads(uint64_t offloads,
985 : : const char *(show_offload)(uint64_t))
986 : : {
987 : : printf(" offloads :");
988 : 0 : while (offloads != 0) {
989 : 0 : uint64_t offload_flag = 1ULL << rte_ctz64(offloads);
990 : 0 : printf(" %s", show_offload(offload_flag));
991 : 0 : offloads &= ~offload_flag;
992 : : }
993 : 0 : }
994 : :
995 : : static void
996 : 0 : show_port(void)
997 : : {
998 : : int i, ret, j, k;
999 : :
1000 : : snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD ");
1001 : : STATS_BDR_STR(10, bdr_str);
1002 : :
1003 : 0 : for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
1004 : 0 : uint16_t mtu = 0;
1005 : : struct rte_eth_link link;
1006 : : struct rte_eth_dev_info dev_info;
1007 : : struct rte_eth_rss_conf rss_conf;
1008 : : char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
1009 : : struct rte_eth_fc_conf fc_conf;
1010 : : struct rte_ether_addr mac;
1011 : : struct rte_eth_dev_owner owner;
1012 : : uint8_t rss_key[RSS_HASH_KEY_SIZE];
1013 : :
1014 : : /* Skip if port is not in mask */
1015 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1016 : 0 : continue;
1017 : :
1018 : : /* Skip if port is unused */
1019 : 0 : if (!rte_eth_dev_is_valid_port(i))
1020 : 0 : continue;
1021 : :
1022 : : memset(&rss_conf, 0, sizeof(rss_conf));
1023 : :
1024 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
1025 : : STATS_BDR_STR(5, bdr_str);
1026 : : printf(" - generic config\n");
1027 : :
1028 : 0 : ret = rte_eth_dev_info_get(i, &dev_info);
1029 : 0 : if (ret != 0) {
1030 : 0 : printf("Error during getting device info: %s\n",
1031 : : strerror(-ret));
1032 : 0 : return;
1033 : : }
1034 : :
1035 : 0 : printf("\t -- driver %s device %s socket %d\n",
1036 : 0 : dev_info.driver_name, rte_dev_name(dev_info.device),
1037 : : rte_eth_dev_socket_id(i));
1038 : :
1039 : 0 : ret = rte_eth_dev_owner_get(i, &owner);
1040 : 0 : if (ret == 0 && owner.id != RTE_ETH_DEV_NO_OWNER)
1041 : : printf("\t -- owner %#"PRIx64":%s\n",
1042 : : owner.id, owner.name);
1043 : :
1044 : 0 : ret = rte_eth_link_get(i, &link);
1045 : 0 : if (ret < 0) {
1046 : 0 : printf("Link get failed (port %u): %s\n",
1047 : : i, rte_strerror(-ret));
1048 : : } else {
1049 : 0 : rte_eth_link_to_str(link_status_text,
1050 : : sizeof(link_status_text),
1051 : : &link);
1052 : : printf("\t%s\n", link_status_text);
1053 : : }
1054 : :
1055 : 0 : ret = rte_eth_dev_flow_ctrl_get(i, &fc_conf);
1056 : 0 : if (ret == 0 && fc_conf.mode != RTE_ETH_FC_NONE) {
1057 : 0 : printf("\t -- flow control mode %s%s high %u low %u pause %u%s%s\n",
1058 : : fc_conf.mode == RTE_ETH_FC_RX_PAUSE ? "rx " :
1059 : 0 : fc_conf.mode == RTE_ETH_FC_TX_PAUSE ? "tx " :
1060 : 0 : fc_conf.mode == RTE_ETH_FC_FULL ? "full" : "???",
1061 : 0 : fc_conf.autoneg ? " auto" : "",
1062 : : fc_conf.high_water,
1063 : : fc_conf.low_water,
1064 : 0 : fc_conf.pause_time,
1065 : 0 : fc_conf.send_xon ? " xon" : "",
1066 : 0 : fc_conf.mac_ctrl_frame_fwd ? " mac_ctrl" : "");
1067 : : }
1068 : :
1069 : 0 : ret = rte_eth_macaddr_get(i, &mac);
1070 : 0 : if (ret == 0) {
1071 : : char ebuf[RTE_ETHER_ADDR_FMT_SIZE];
1072 : :
1073 : 0 : rte_ether_format_addr(ebuf, sizeof(ebuf), &mac);
1074 : : printf("\t -- mac %s\n", ebuf);
1075 : : }
1076 : :
1077 : 0 : ret = rte_eth_promiscuous_get(i);
1078 : 0 : if (ret >= 0)
1079 : 0 : printf("\t -- promiscuous mode %s\n",
1080 : : ret > 0 ? "enabled" : "disabled");
1081 : :
1082 : 0 : ret = rte_eth_allmulticast_get(i);
1083 : 0 : if (ret >= 0)
1084 : 0 : printf("\t -- all multicast mode %s\n",
1085 : : ret > 0 ? "enabled" : "disabled");
1086 : :
1087 : 0 : ret = rte_eth_dev_get_mtu(i, &mtu);
1088 : 0 : if (ret == 0)
1089 : 0 : printf("\t -- mtu (%d)\n", mtu);
1090 : :
1091 : 0 : for (j = 0; j < dev_info.nb_rx_queues; j++) {
1092 : : struct rte_eth_rxq_info queue_info;
1093 : : struct rte_eth_burst_mode mode;
1094 : : int count;
1095 : :
1096 : 0 : ret = rte_eth_rx_queue_info_get(i, j, &queue_info);
1097 : 0 : if (ret != 0)
1098 : : break;
1099 : :
1100 : 0 : if (j == 0)
1101 : : printf(" - rx queue\n");
1102 : :
1103 : : printf("\t -- %d descriptors ", j);
1104 : : count = rte_eth_rx_queue_count(i, j);
1105 : 0 : if (count >= 0)
1106 : : printf("%d/", count);
1107 : 0 : printf("%u", queue_info.nb_desc);
1108 : :
1109 : 0 : if (queue_info.scattered_rx)
1110 : : printf(" scattered");
1111 : :
1112 : 0 : if (queue_info.conf.rx_drop_en)
1113 : : printf(" drop_en");
1114 : :
1115 : 0 : if (queue_info.conf.rx_deferred_start)
1116 : : printf(" deferred_start");
1117 : :
1118 : 0 : if (queue_info.rx_buf_size != 0)
1119 : 0 : printf(" rx buffer size %u",
1120 : : queue_info.rx_buf_size);
1121 : :
1122 : 0 : printf(" mempool %s socket %d",
1123 : 0 : queue_info.mp->name,
1124 : 0 : queue_info.mp->socket_id);
1125 : :
1126 : 0 : if (queue_info.conf.offloads != 0)
1127 : 0 : show_offloads(queue_info.conf.offloads, rte_eth_dev_rx_offload_name);
1128 : :
1129 : 0 : if (rte_eth_rx_burst_mode_get(i, j, &mode) == 0)
1130 : 0 : printf(" burst mode : %s%s",
1131 : : mode.info,
1132 : 0 : mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ?
1133 : : " (per queue)" : "");
1134 : :
1135 : : printf("\n");
1136 : : }
1137 : :
1138 : 0 : for (j = 0; j < dev_info.nb_tx_queues; j++) {
1139 : : struct rte_eth_txq_info queue_info;
1140 : : struct rte_eth_burst_mode mode;
1141 : :
1142 : 0 : ret = rte_eth_tx_queue_info_get(i, j, &queue_info);
1143 : 0 : if (ret != 0)
1144 : : break;
1145 : :
1146 : 0 : if (j == 0)
1147 : : printf(" - tx queue\n");
1148 : :
1149 : 0 : printf("\t -- %d descriptors %d",
1150 : 0 : j, queue_info.nb_desc);
1151 : :
1152 : 0 : printf(" thresh %u/%u",
1153 : 0 : queue_info.conf.tx_rs_thresh,
1154 : 0 : queue_info.conf.tx_free_thresh);
1155 : :
1156 : 0 : if (queue_info.conf.tx_deferred_start)
1157 : : printf(" deferred_start");
1158 : :
1159 : 0 : if (queue_info.conf.offloads != 0)
1160 : 0 : show_offloads(queue_info.conf.offloads, rte_eth_dev_tx_offload_name);
1161 : :
1162 : 0 : if (rte_eth_tx_burst_mode_get(i, j, &mode) == 0)
1163 : 0 : printf(" burst mode : %s%s",
1164 : : mode.info,
1165 : 0 : mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ?
1166 : : " (per queue)" : "");
1167 : :
1168 : : printf("\n");
1169 : : }
1170 : :
1171 : 0 : rss_conf.rss_key = rss_key;
1172 : 0 : rss_conf.rss_key_len = dev_info.hash_key_size;
1173 : 0 : ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
1174 : 0 : if (ret == 0) {
1175 : : printf(" - RSS info\n");
1176 : 0 : printf("\t -- key len : %u\n",
1177 : 0 : rss_conf.rss_key_len);
1178 : : printf("\t -- key (hex) : ");
1179 : 0 : for (k = 0; k < rss_conf.rss_key_len; k++)
1180 : 0 : printf("%02x", rss_conf.rss_key[k]);
1181 : 0 : printf("\n\t -- hash function : 0x%"PRIx64"\n",
1182 : : rss_conf.rss_hf);
1183 : 0 : printf("\t -- hash algorithm : %s\n",
1184 : : rte_eth_dev_rss_algo_name(rss_conf.algorithm));
1185 : : }
1186 : :
1187 : : #ifdef RTE_LIB_SECURITY
1188 : 0 : show_security_context(i, true);
1189 : : #endif
1190 : : }
1191 : : }
1192 : :
1193 : : static void
1194 : 0 : show_port_private_info(void)
1195 : : {
1196 : : int i;
1197 : :
1198 : : snprintf(bdr_str, MAX_STRING_LEN, " Dump - Ports private information");
1199 : : STATS_BDR_STR(10, bdr_str);
1200 : :
1201 : 0 : RTE_ETH_FOREACH_DEV(i) {
1202 : : /* Skip if port is not in mask */
1203 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1204 : 0 : continue;
1205 : :
1206 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
1207 : : STATS_BDR_STR(5, bdr_str);
1208 : 0 : rte_eth_dev_priv_dump(i, stdout);
1209 : : }
1210 : 0 : }
1211 : :
1212 : : static void
1213 : 0 : display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
1214 : : {
1215 : 0 : if (cap == NULL)
1216 : : return;
1217 : :
1218 : 0 : if (!is_leaf) {
1219 : 0 : printf("\t -- nonleaf sched max:\n"
1220 : : "\t\t + children (%u)\n"
1221 : : "\t\t + sp priorities (%u)\n"
1222 : : "\t\t + wfq children per group (%u)\n"
1223 : : "\t\t + wfq groups (%u)\n"
1224 : : "\t\t + wfq weight (%u)\n",
1225 : : cap->nonleaf.sched_n_children_max,
1226 : : cap->nonleaf.sched_sp_n_priorities_max,
1227 : : cap->nonleaf.sched_wfq_n_children_per_group_max,
1228 : : cap->nonleaf.sched_wfq_n_groups_max,
1229 : : cap->nonleaf.sched_wfq_weight_max);
1230 : : } else {
1231 : 0 : printf("\t -- leaf cman support:\n"
1232 : : "\t\t + wred pkt mode (%d)\n"
1233 : : "\t\t + wred byte mode (%d)\n"
1234 : : "\t\t + head drop (%d)\n"
1235 : : "\t\t + wred context private (%d)\n"
1236 : : "\t\t + wred context shared (%u)\n",
1237 : : cap->leaf.cman_wred_packet_mode_supported,
1238 : : cap->leaf.cman_wred_byte_mode_supported,
1239 : : cap->leaf.cman_head_drop_supported,
1240 : : cap->leaf.cman_wred_context_private_supported,
1241 : : cap->leaf.cman_wred_context_shared_n_max);
1242 : : }
1243 : : }
1244 : :
1245 : : static void
1246 : 0 : display_levelcap_info(int is_leaf, struct rte_tm_level_capabilities *cap)
1247 : : {
1248 : 0 : if (cap == NULL)
1249 : : return;
1250 : :
1251 : 0 : if (!is_leaf) {
1252 : 0 : printf("\t -- shaper private: (%d) dual rate (%d)\n",
1253 : : cap->nonleaf.shaper_private_supported,
1254 : : cap->nonleaf.shaper_private_dual_rate_supported);
1255 : 0 : printf("\t -- shaper share: (%u)\n",
1256 : : cap->nonleaf.shaper_shared_n_max);
1257 : 0 : printf("\t -- non leaf sched MAX:\n"
1258 : : "\t\t + children (%u)\n"
1259 : : "\t\t + sp (%u)\n"
1260 : : "\t\t + wfq children per group (%u)\n"
1261 : : "\t\t + wfq groups (%u)\n"
1262 : : "\t\t + wfq weight (%u)\n",
1263 : : cap->nonleaf.sched_n_children_max,
1264 : : cap->nonleaf.sched_sp_n_priorities_max,
1265 : : cap->nonleaf.sched_wfq_n_children_per_group_max,
1266 : : cap->nonleaf.sched_wfq_n_groups_max,
1267 : : cap->nonleaf.sched_wfq_weight_max);
1268 : : } else {
1269 : 0 : printf("\t -- shaper private: (%d) dual rate (%d)\n",
1270 : : cap->leaf.shaper_private_supported,
1271 : : cap->leaf.shaper_private_dual_rate_supported);
1272 : 0 : printf("\t -- shaper share: (%u)\n",
1273 : : cap->leaf.shaper_shared_n_max);
1274 : 0 : printf(" -- leaf cman support:\n"
1275 : : "\t\t + wred pkt mode (%d)\n"
1276 : : "\t\t + wred byte mode (%d)\n"
1277 : : "\t\t + head drop (%d)\n"
1278 : : "\t\t + wred context private (%d)\n"
1279 : : "\t\t + wred context shared (%u)\n",
1280 : : cap->leaf.cman_wred_packet_mode_supported,
1281 : : cap->leaf.cman_wred_byte_mode_supported,
1282 : : cap->leaf.cman_head_drop_supported,
1283 : : cap->leaf.cman_wred_context_private_supported,
1284 : : cap->leaf.cman_wred_context_shared_n_max);
1285 : : }
1286 : : }
1287 : :
1288 : : static void
1289 : 0 : show_tm(void)
1290 : : {
1291 : 0 : int ret = 0, check_for_leaf = 0, is_leaf = 0;
1292 : : unsigned int j, k;
1293 : : uint16_t i = 0;
1294 : :
1295 : : snprintf(bdr_str, MAX_STRING_LEN, " show - TM PMD ");
1296 : : STATS_BDR_STR(10, bdr_str);
1297 : :
1298 : 0 : RTE_ETH_FOREACH_DEV(i) {
1299 : : struct rte_eth_dev_info dev_info;
1300 : : struct rte_tm_capabilities cap;
1301 : : struct rte_tm_error error;
1302 : : struct rte_tm_node_capabilities capnode;
1303 : : struct rte_tm_level_capabilities caplevel;
1304 : 0 : uint32_t n_leaf_nodes = 0;
1305 : :
1306 : : memset(&cap, 0, sizeof(cap));
1307 : : memset(&error, 0, sizeof(error));
1308 : :
1309 : 0 : ret = rte_eth_dev_info_get(i, &dev_info);
1310 : 0 : if (ret != 0) {
1311 : 0 : printf("Error during getting device (port %u) info: %s\n",
1312 : : i, strerror(-ret));
1313 : 0 : return;
1314 : : }
1315 : :
1316 : 0 : printf(" - Generic for port (%u)\n"
1317 : : "\t -- driver name %s\n"
1318 : : "\t -- max vf (%u)\n"
1319 : : "\t -- max tx queues (%u)\n"
1320 : : "\t -- number of tx queues (%u)\n",
1321 : : i,
1322 : : dev_info.driver_name,
1323 : 0 : dev_info.max_vfs,
1324 : 0 : dev_info.max_tx_queues,
1325 : 0 : dev_info.nb_tx_queues);
1326 : :
1327 : 0 : ret = rte_tm_capabilities_get(i, &cap, &error);
1328 : 0 : if (ret)
1329 : 0 : continue;
1330 : :
1331 : 0 : printf(" - MAX: nodes (%u) levels (%u) children (%u)\n",
1332 : : cap.n_nodes_max,
1333 : : cap.n_levels_max,
1334 : : cap.sched_n_children_max);
1335 : :
1336 : 0 : printf(" - identical nodes: non leaf (%d) leaf (%d)\n",
1337 : : cap.non_leaf_nodes_identical,
1338 : : cap.leaf_nodes_identical);
1339 : :
1340 : 0 : printf(" - Shaper MAX:\n"
1341 : : "\t -- total (%u)\n"
1342 : : "\t -- private (%u) private dual (%d)\n"
1343 : : "\t -- shared (%u) shared dual (%u)\n",
1344 : : cap.shaper_n_max,
1345 : : cap.shaper_private_n_max,
1346 : : cap.shaper_private_dual_rate_n_max,
1347 : : cap.shaper_shared_n_max,
1348 : : cap.shaper_shared_dual_rate_n_max);
1349 : :
1350 : : printf(" - mark support:\n");
1351 : 0 : printf("\t -- vlan dei: GREEN (%d) YELLOW (%d) RED (%d)\n",
1352 : : cap.mark_vlan_dei_supported[RTE_COLOR_GREEN],
1353 : : cap.mark_vlan_dei_supported[RTE_COLOR_YELLOW],
1354 : : cap.mark_vlan_dei_supported[RTE_COLOR_RED]);
1355 : 0 : printf("\t -- ip ecn tcp: GREEN (%d) YELLOW (%d) RED (%d)\n",
1356 : : cap.mark_ip_ecn_tcp_supported[RTE_COLOR_GREEN],
1357 : : cap.mark_ip_ecn_tcp_supported[RTE_COLOR_YELLOW],
1358 : : cap.mark_ip_ecn_tcp_supported[RTE_COLOR_RED]);
1359 : 0 : printf("\t -- ip ecn sctp: GREEN (%d) YELLOW (%d) RED (%d)\n",
1360 : : cap.mark_ip_ecn_sctp_supported[RTE_COLOR_GREEN],
1361 : : cap.mark_ip_ecn_sctp_supported[RTE_COLOR_YELLOW],
1362 : : cap.mark_ip_ecn_sctp_supported[RTE_COLOR_RED]);
1363 : 0 : printf("\t -- ip dscp: GREEN (%d) YELLOW (%d) RED (%d)\n",
1364 : : cap.mark_ip_dscp_supported[RTE_COLOR_GREEN],
1365 : : cap.mark_ip_dscp_supported[RTE_COLOR_YELLOW],
1366 : : cap.mark_ip_dscp_supported[RTE_COLOR_RED]);
1367 : :
1368 : 0 : printf(" - mask stats (0x%"PRIx64")"
1369 : : " dynamic update (0x%"PRIx64")\n",
1370 : : cap.stats_mask,
1371 : : cap.dynamic_update_mask);
1372 : :
1373 : 0 : printf(" - sched MAX:\n"
1374 : : "\t -- total (%u)\n"
1375 : : "\t -- sp levels (%u)\n"
1376 : : "\t -- wfq children per group (%u)\n"
1377 : : "\t -- wfq groups (%u)\n"
1378 : : "\t -- wfq weight (%u)\n",
1379 : : cap.sched_sp_n_priorities_max,
1380 : : cap.sched_sp_n_priorities_max,
1381 : : cap.sched_wfq_n_children_per_group_max,
1382 : : cap.sched_wfq_n_groups_max,
1383 : : cap.sched_wfq_weight_max);
1384 : :
1385 : 0 : printf(" - CMAN support:\n"
1386 : : "\t -- WRED mode: pkt (%d) byte (%d)\n"
1387 : : "\t -- head drop (%d)\n",
1388 : : cap.cman_wred_packet_mode_supported,
1389 : : cap.cman_wred_byte_mode_supported,
1390 : : cap.cman_head_drop_supported);
1391 : 0 : printf("\t -- MAX WRED CONTEXT:"
1392 : : " total (%u) private (%u) shared (%u)\n",
1393 : : cap.cman_wred_context_n_max,
1394 : : cap.cman_wred_context_private_n_max,
1395 : : cap.cman_wred_context_shared_n_max);
1396 : :
1397 : 0 : for (j = 0; j < cap.n_nodes_max; j++) {
1398 : : memset(&capnode, 0, sizeof(capnode));
1399 : 0 : ret = rte_tm_node_capabilities_get(i, j,
1400 : : &capnode, &error);
1401 : 0 : if (ret)
1402 : 0 : continue;
1403 : :
1404 : : check_for_leaf = 1;
1405 : :
1406 : : printf(" NODE %u\n", j);
1407 : 0 : printf("\t - shaper private: (%d) dual rate (%d)\n",
1408 : : capnode.shaper_private_supported,
1409 : : capnode.shaper_private_dual_rate_supported);
1410 : 0 : printf("\t - shaper shared max: (%u)\n",
1411 : : capnode.shaper_shared_n_max);
1412 : 0 : printf("\t - stats mask %"PRIx64"\n",
1413 : : capnode.stats_mask);
1414 : :
1415 : 0 : ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
1416 : 0 : if (ret)
1417 : 0 : continue;
1418 : :
1419 : 0 : display_nodecap_info(is_leaf, &capnode);
1420 : : }
1421 : :
1422 : 0 : for (j = 0; j < cap.n_levels_max; j++) {
1423 : : memset(&caplevel, 0, sizeof(caplevel));
1424 : 0 : ret = rte_tm_level_capabilities_get(i, j,
1425 : : &caplevel, &error);
1426 : 0 : if (ret)
1427 : 0 : continue;
1428 : :
1429 : : printf(" - Level %u\n", j);
1430 : 0 : printf("\t -- node MAX: %u non leaf %u leaf %u\n",
1431 : : caplevel.n_nodes_max,
1432 : : caplevel.n_nodes_nonleaf_max,
1433 : : caplevel.n_nodes_leaf_max);
1434 : 0 : printf("\t -- identical: non leaf %u leaf %u\n",
1435 : : caplevel.non_leaf_nodes_identical,
1436 : : caplevel.leaf_nodes_identical);
1437 : :
1438 : 0 : for (k = 0; k < caplevel.n_nodes_max; k++) {
1439 : 0 : ret = rte_tm_node_type_get(i, k,
1440 : : &is_leaf, &error);
1441 : 0 : if (ret)
1442 : 0 : continue;
1443 : :
1444 : 0 : display_levelcap_info(is_leaf, &caplevel);
1445 : : }
1446 : : }
1447 : :
1448 : 0 : if (check_for_leaf) {
1449 : 0 : ret = rte_tm_get_number_of_leaf_nodes(i,
1450 : : &n_leaf_nodes, &error);
1451 : 0 : if (ret == 0)
1452 : 0 : printf(" - leaf nodes (%u)\n", n_leaf_nodes);
1453 : : }
1454 : :
1455 : 0 : for (j = 0; j < n_leaf_nodes; j++) {
1456 : : struct rte_tm_node_stats stats;
1457 : : memset(&stats, 0, sizeof(stats));
1458 : :
1459 : 0 : ret = rte_tm_node_stats_read(i, j,
1460 : : &stats, &cap.stats_mask, 0, &error);
1461 : 0 : if (ret)
1462 : 0 : continue;
1463 : :
1464 : : printf(" - STATS for node (%u)\n", j);
1465 : 0 : printf(" -- pkts (%"PRIu64") bytes (%"PRIu64")\n",
1466 : : stats.n_pkts, stats.n_bytes);
1467 : :
1468 : 0 : ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
1469 : 0 : if (ret || (!is_leaf))
1470 : 0 : continue;
1471 : :
1472 : 0 : printf(" -- leaf queued:"
1473 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n",
1474 : : stats.leaf.n_pkts_queued,
1475 : : stats.leaf.n_bytes_queued);
1476 : 0 : printf(" - dropped:\n"
1477 : : "\t -- GREEN:"
1478 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n"
1479 : : "\t -- YELLOW:"
1480 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n"
1481 : : "\t -- RED:"
1482 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n",
1483 : : stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN],
1484 : : stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN],
1485 : : stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW],
1486 : : stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW],
1487 : : stats.leaf.n_pkts_dropped[RTE_COLOR_RED],
1488 : : stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
1489 : : }
1490 : : }
1491 : : }
1492 : :
1493 : : static void
1494 : 0 : display_crypto_feature_info(uint64_t x)
1495 : : {
1496 : 0 : if (x == 0)
1497 : : return;
1498 : :
1499 : : printf("\t -- feature flags\n");
1500 : 0 : printf("\t\t + symmetric (%c), asymmetric (%c)\n"
1501 : : "\t\t + symmetric operation chaining (%c)\n",
1502 : 0 : (x & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ? 'y' : 'n',
1503 : 0 : (x & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) ? 'y' : 'n',
1504 : 0 : (x & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING) ? 'y' : 'n');
1505 : 0 : printf("\t\t + CPU: SSE (%c), AVX (%c), AVX2 (%c), AVX512 (%c)\n",
1506 : 0 : (x & RTE_CRYPTODEV_FF_CPU_SSE) ? 'y' : 'n',
1507 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AVX) ? 'y' : 'n',
1508 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AVX2) ? 'y' : 'n',
1509 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AVX512) ? 'y' : 'n');
1510 : 0 : printf("\t\t + AESNI: CPU (%c), HW (%c)\n",
1511 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AESNI) ? 'y' : 'n',
1512 : 0 : (x & RTE_CRYPTODEV_FF_HW_ACCELERATED) ? 'y' : 'n');
1513 : 0 : printf("\t\t + SECURITY OFFLOAD (%c)\n",
1514 : 0 : (x & RTE_CRYPTODEV_FF_SECURITY) ? 'y' : 'n');
1515 : 0 : printf("\t\t + ARM: NEON (%c), CE (%c)\n",
1516 : 0 : (x & RTE_CRYPTODEV_FF_CPU_NEON) ? 'y' : 'n',
1517 : 0 : (x & RTE_CRYPTODEV_FF_CPU_ARM_CE) ? 'y' : 'n');
1518 : : printf("\t -- buffer offload\n");
1519 : 0 : printf("\t\t + IN_PLACE_SGL (%c)\n",
1520 : 0 : (x & RTE_CRYPTODEV_FF_IN_PLACE_SGL) ? 'y' : 'n');
1521 : 0 : printf("\t\t + OOP_SGL_IN_SGL_OUT (%c)\n",
1522 : 0 : (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT) ? 'y' : 'n');
1523 : 0 : printf("\t\t + OOP_SGL_IN_LB_OUT (%c)\n",
1524 : 0 : (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT) ? 'y' : 'n');
1525 : 0 : printf("\t\t + OOP_LB_IN_SGL_OUT (%c)\n",
1526 : 0 : (x & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT) ? 'y' : 'n');
1527 : 0 : printf("\t\t + OOP_LB_IN_LB_OUT (%c)\n",
1528 : 0 : (x & RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT) ? 'y' : 'n');
1529 : : }
1530 : :
1531 : : static void
1532 : 0 : show_crypto(void)
1533 : : {
1534 : 0 : uint8_t crypto_dev_count = rte_cryptodev_count(), i;
1535 : :
1536 : : snprintf(bdr_str, MAX_STRING_LEN, " show - CRYPTO PMD ");
1537 : : STATS_BDR_STR(10, bdr_str);
1538 : :
1539 : 0 : for (i = 0; i < crypto_dev_count; i++) {
1540 : : struct rte_cryptodev_info dev_info;
1541 : : struct rte_cryptodev_stats stats;
1542 : :
1543 : 0 : rte_cryptodev_info_get(i, &dev_info);
1544 : :
1545 : : printf(" - device (%u)\n", i);
1546 : 0 : printf("\t -- name (%s)\n"
1547 : : "\t -- driver (%s)\n"
1548 : : "\t -- id (%u) on socket (%d)\n"
1549 : : "\t -- queue pairs (%d)\n",
1550 : : rte_cryptodev_name_get(i),
1551 : : dev_info.driver_name,
1552 : 0 : dev_info.driver_id,
1553 : 0 : rte_dev_numa_node(dev_info.device),
1554 : 0 : rte_cryptodev_queue_pair_count(i));
1555 : :
1556 : 0 : display_crypto_feature_info(dev_info.feature_flags);
1557 : :
1558 : 0 : if (rte_cryptodev_stats_get(i, &stats) == 0) {
1559 : : printf("\t -- stats\n");
1560 : 0 : printf("\t\t + enqueue count (%"PRIu64")"
1561 : : " error (%"PRIu64")\n",
1562 : : stats.enqueued_count,
1563 : : stats.enqueue_err_count);
1564 : 0 : printf("\t\t + dequeue count (%"PRIu64")"
1565 : : " error (%"PRIu64")\n",
1566 : : stats.dequeued_count,
1567 : : stats.dequeue_err_count);
1568 : : }
1569 : :
1570 : : #ifdef RTE_LIB_SECURITY
1571 : 0 : show_security_context(i, false);
1572 : : #endif
1573 : : }
1574 : 0 : }
1575 : :
1576 : : static void
1577 : 0 : show_ring(char *name)
1578 : : {
1579 : : snprintf(bdr_str, MAX_STRING_LEN, " show - RING ");
1580 : : STATS_BDR_STR(10, bdr_str);
1581 : :
1582 : 0 : if (name != NULL) {
1583 : 0 : struct rte_ring *ptr = rte_ring_lookup(name);
1584 : 0 : if (ptr != NULL) {
1585 : 0 : printf(" - Name (%s) on socket (%d)\n"
1586 : : " - flags:\n"
1587 : : "\t -- Single Producer Enqueue (%u)\n"
1588 : : "\t -- Single Consumer Dequeue (%u)\n",
1589 : 0 : ptr->name,
1590 : 0 : ptr->memzone->socket_id,
1591 : : ptr->flags & RING_F_SP_ENQ,
1592 : 0 : ptr->flags & RING_F_SC_DEQ);
1593 : 0 : printf(" - size (%u) mask (0x%x) capacity (%u)\n",
1594 : : ptr->size,
1595 : : ptr->mask,
1596 : : ptr->capacity);
1597 : : printf(" - count (%u) free count (%u)\n",
1598 : : rte_ring_count(ptr),
1599 : : rte_ring_free_count(ptr));
1600 : : printf(" - full (%d) empty (%d)\n",
1601 : : rte_ring_full(ptr),
1602 : : rte_ring_empty(ptr));
1603 : :
1604 : : STATS_BDR_STR(50, "");
1605 : 0 : return;
1606 : : }
1607 : : }
1608 : :
1609 : 0 : rte_ring_list_dump(stdout);
1610 : : }
1611 : :
1612 : : static void
1613 : 0 : show_mempool(char *name)
1614 : : {
1615 : : snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL ");
1616 : : STATS_BDR_STR(10, bdr_str);
1617 : :
1618 : 0 : if (name != NULL) {
1619 : 0 : struct rte_mempool *ptr = rte_mempool_lookup(name);
1620 : 0 : if (ptr != NULL) {
1621 : : struct rte_mempool_ops *ops;
1622 : 0 : uint64_t flags = ptr->flags;
1623 : :
1624 : 0 : ops = rte_mempool_get_ops(ptr->ops_index);
1625 : 0 : printf(" - Name: %s on socket %d\n"
1626 : : " - flags:\n"
1627 : : "\t -- No spread (%c)\n"
1628 : : "\t -- No cache align (%c)\n"
1629 : : "\t -- SP put (%c), SC get (%c)\n"
1630 : : "\t -- Pool created (%c)\n"
1631 : : "\t -- No IOVA config (%c)\n"
1632 : : "\t -- Not used for IO (%c)\n",
1633 : 0 : ptr->name,
1634 : : ptr->socket_id,
1635 : : (flags & RTE_MEMPOOL_F_NO_SPREAD) ? 'y' : 'n',
1636 : : (flags & RTE_MEMPOOL_F_NO_CACHE_ALIGN) ? 'y' : 'n',
1637 : : (flags & RTE_MEMPOOL_F_SP_PUT) ? 'y' : 'n',
1638 : : (flags & RTE_MEMPOOL_F_SC_GET) ? 'y' : 'n',
1639 : : (flags & RTE_MEMPOOL_F_POOL_CREATED) ? 'y' : 'n',
1640 : : (flags & RTE_MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n',
1641 : : (flags & RTE_MEMPOOL_F_NON_IO) ? 'y' : 'n');
1642 : 0 : printf(" - Size %u Cache %u element %u\n"
1643 : : " - header %u trailer %u\n"
1644 : : " - private data size %u\n",
1645 : : ptr->size,
1646 : : ptr->cache_size,
1647 : : ptr->elt_size,
1648 : : ptr->header_size,
1649 : : ptr->trailer_size,
1650 : : ptr->private_data_size);
1651 : : printf(" - memezone - socket %d\n",
1652 : 0 : ptr->mz->socket_id);
1653 : 0 : printf(" - Count: avail (%u), in use (%u)\n",
1654 : : rte_mempool_avail_count(ptr),
1655 : : rte_mempool_in_use_count(ptr));
1656 : 0 : printf(" - ops_index %d ops_name %s\n",
1657 : : ptr->ops_index, ops ? ops->name : "NA");
1658 : :
1659 : 0 : return;
1660 : : }
1661 : : }
1662 : :
1663 : 0 : rte_mempool_list_dump(stdout);
1664 : : }
1665 : :
1666 : : static void
1667 : 0 : mempool_itr_obj(struct rte_mempool *mp, void *opaque,
1668 : : void *obj, unsigned int obj_idx)
1669 : : {
1670 : : printf(" - obj_idx %u opaque %p obj %p\n",
1671 : : obj_idx, opaque, obj);
1672 : :
1673 : 0 : if (obj)
1674 : 0 : rte_hexdump(stdout, " Obj Content",
1675 : 0 : obj, (mp->elt_size > 256)?256:mp->elt_size);
1676 : 0 : }
1677 : :
1678 : : static void
1679 : 0 : iter_mempool(char *name)
1680 : : {
1681 : : snprintf(bdr_str, MAX_STRING_LEN, " iter - MEMPOOL ");
1682 : : STATS_BDR_STR(10, bdr_str);
1683 : :
1684 : 0 : if (name != NULL) {
1685 : 0 : struct rte_mempool *ptr = rte_mempool_lookup(name);
1686 : 0 : if (ptr != NULL) {
1687 : : /* iterate each object */
1688 : 0 : uint32_t ret = rte_mempool_obj_iter(ptr,
1689 : : mempool_itr_obj, NULL);
1690 : : printf("\n - iterated %u objects\n", ret);
1691 : 0 : return;
1692 : : }
1693 : : }
1694 : : }
1695 : :
1696 : : static void
1697 : 0 : dump_regs(char *file_prefix)
1698 : : {
1699 : : #define MAX_FILE_NAME_SZ (MAX_LONG_OPT_SZ + 10)
1700 : : char file_name[MAX_FILE_NAME_SZ];
1701 : : struct rte_dev_reg_info reg_info;
1702 : : struct rte_eth_dev_info dev_info;
1703 : : unsigned char *buf_data;
1704 : : size_t buf_size;
1705 : : FILE *fp_regs;
1706 : : uint16_t i;
1707 : : int ret;
1708 : :
1709 : : snprintf(bdr_str, MAX_STRING_LEN, " dump - Port REG");
1710 : : STATS_BDR_STR(10, bdr_str);
1711 : :
1712 : 0 : RTE_ETH_FOREACH_DEV(i) {
1713 : : /* Skip if port is not in mask */
1714 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1715 : 0 : continue;
1716 : :
1717 : : snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
1718 : : STATS_BDR_STR(5, bdr_str);
1719 : :
1720 : 0 : ret = rte_eth_dev_info_get(i, &dev_info);
1721 : 0 : if (ret) {
1722 : : printf("Error getting device info: %d\n", ret);
1723 : 0 : continue;
1724 : : }
1725 : :
1726 : : memset(®_info, 0, sizeof(reg_info));
1727 : 0 : ret = rte_eth_dev_get_reg_info(i, ®_info);
1728 : 0 : if (ret) {
1729 : : printf("Error getting device reg info: %d\n", ret);
1730 : 0 : continue;
1731 : : }
1732 : :
1733 : 0 : buf_size = reg_info.length * reg_info.width;
1734 : 0 : buf_data = malloc(buf_size);
1735 : 0 : if (buf_data == NULL) {
1736 : : printf("Error allocating %zu bytes buffer\n", buf_size);
1737 : 0 : continue;
1738 : : }
1739 : :
1740 : 0 : reg_info.data = buf_data;
1741 : 0 : reg_info.length = 0;
1742 : 0 : ret = rte_eth_dev_get_reg_info(i, ®_info);
1743 : 0 : if (ret) {
1744 : : printf("Error getting regs from device: %d\n", ret);
1745 : 0 : free(buf_data);
1746 : 0 : continue;
1747 : : }
1748 : :
1749 : : snprintf(file_name, MAX_FILE_NAME_SZ, "%s-port%u",
1750 : : file_prefix, i);
1751 : 0 : fp_regs = fopen(file_name, "wb");
1752 : 0 : if (fp_regs == NULL) {
1753 : 0 : printf("Error during opening '%s' for writing: %s\n",
1754 : 0 : file_name, strerror(errno));
1755 : : } else {
1756 : : size_t nr_written;
1757 : :
1758 : 0 : nr_written = fwrite(buf_data, 1, buf_size, fp_regs);
1759 : 0 : if (nr_written != buf_size)
1760 : 0 : printf("Error during writing %s: %s\n",
1761 : 0 : file_prefix, strerror(errno));
1762 : : else
1763 : 0 : printf("Device (%s) regs dumped successfully, "
1764 : : "driver:%s version:0X%08X\n",
1765 : 0 : rte_dev_name(dev_info.device),
1766 : : dev_info.driver_name, reg_info.version);
1767 : :
1768 : 0 : fclose(fp_regs);
1769 : : }
1770 : :
1771 : 0 : free(buf_data);
1772 : : }
1773 : 0 : }
1774 : :
1775 : : static void
1776 : 0 : show_version(void)
1777 : : {
1778 : : snprintf(bdr_str, MAX_STRING_LEN, " show - DPDK version ");
1779 : : STATS_BDR_STR(10, bdr_str);
1780 : 0 : printf("DPDK version: %s\n", rte_version());
1781 : 0 : }
1782 : :
1783 : : static void
1784 : 0 : show_firmware_version(void)
1785 : : {
1786 : : char fw_version[ETHDEV_FWVERS_LEN];
1787 : : uint16_t i;
1788 : :
1789 : : snprintf(bdr_str, MAX_STRING_LEN, " show - firmware version ");
1790 : : STATS_BDR_STR(10, bdr_str);
1791 : :
1792 : 0 : RTE_ETH_FOREACH_DEV(i) {
1793 : : /* Skip if port is not in mask */
1794 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1795 : 0 : continue;
1796 : :
1797 : 0 : if (rte_eth_dev_fw_version_get(i, fw_version,
1798 : : ETHDEV_FWVERS_LEN) == 0)
1799 : : printf("Ethdev port %u firmware version: %s\n", i,
1800 : : fw_version);
1801 : : else
1802 : : printf("Ethdev port %u firmware version: %s\n", i,
1803 : : "not available");
1804 : : }
1805 : 0 : }
1806 : :
1807 : : static void
1808 : 0 : show_port_rss_reta_info(void)
1809 : : {
1810 : : struct rte_eth_rss_reta_entry64 reta_conf[RTE_RETA_CONF_GROUP_NUM + 1];
1811 : : struct rte_eth_dev_info dev_info;
1812 : : uint16_t i, idx, shift;
1813 : : uint16_t num;
1814 : : uint16_t id;
1815 : : int ret;
1816 : :
1817 : 0 : RTE_ETH_FOREACH_DEV(id) {
1818 : : /* Skip if port is not in mask */
1819 : 0 : if ((enabled_port_mask & (1ul << id)) == 0)
1820 : 0 : continue;
1821 : :
1822 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", id);
1823 : : STATS_BDR_STR(5, bdr_str);
1824 : :
1825 : 0 : ret = rte_eth_dev_info_get(id, &dev_info);
1826 : 0 : if (ret != 0) {
1827 : 0 : fprintf(stderr, "Error getting device info: %s\n",
1828 : : strerror(-ret));
1829 : 0 : return;
1830 : : }
1831 : :
1832 : 0 : num = RTE_DIV_ROUND_UP(dev_info.reta_size, RTE_ETH_RETA_GROUP_SIZE);
1833 : : memset(reta_conf, 0, sizeof(reta_conf));
1834 : 0 : for (i = 0; i < num; i++)
1835 : 0 : reta_conf[i].mask = ~0ULL;
1836 : :
1837 : 0 : ret = rte_eth_dev_rss_reta_query(id, reta_conf, dev_info.reta_size);
1838 : 0 : if (ret != 0) {
1839 : 0 : fprintf(stderr, "Error getting RSS RETA info: %s\n",
1840 : : strerror(-ret));
1841 : 0 : return;
1842 : : }
1843 : :
1844 : 0 : for (i = 0; i < dev_info.reta_size; i++) {
1845 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
1846 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
1847 : 0 : printf("RSS RETA configuration: hash index=%u, queue=%u\n",
1848 : 0 : i, reta_conf[idx].reta[shift]);
1849 : : }
1850 : : }
1851 : : }
1852 : :
1853 : : static void
1854 : 0 : show_module_eeprom_info(void)
1855 : : {
1856 : : unsigned char bytes_eeprom[EEPROM_DUMP_CHUNKSIZE];
1857 : : struct rte_eth_dev_module_info module_info;
1858 : : struct rte_dev_eeprom_info eeprom_info;
1859 : : uint16_t i;
1860 : : int ret;
1861 : :
1862 : 0 : RTE_ETH_FOREACH_DEV(i) {
1863 : : /* Skip if port is not in mask */
1864 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1865 : 0 : continue;
1866 : :
1867 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
1868 : : STATS_BDR_STR(5, bdr_str);
1869 : :
1870 : 0 : ret = rte_eth_dev_get_module_info(i, &module_info);
1871 : 0 : if (ret != 0) {
1872 : 0 : fprintf(stderr, "Module EEPROM information read error: %s\n",
1873 : : strerror(-ret));
1874 : 0 : return;
1875 : : }
1876 : :
1877 : 0 : eeprom_info.offset = 0;
1878 : 0 : eeprom_info.length = module_info.eeprom_len;
1879 : 0 : eeprom_info.data = bytes_eeprom;
1880 : :
1881 : 0 : ret = rte_eth_dev_get_module_eeprom(i, &eeprom_info);
1882 : 0 : if (ret != 0) {
1883 : 0 : fprintf(stderr, "Module EEPROM read error: %s\n",
1884 : : strerror(-ret));
1885 : 0 : return;
1886 : : }
1887 : :
1888 : 0 : rte_hexdump(stdout, "hexdump", eeprom_info.data,
1889 : : eeprom_info.length);
1890 : 0 : printf("Finish -- Port: %u MODULE EEPROM length: %d bytes\n",
1891 : : i, eeprom_info.length);
1892 : : }
1893 : : }
1894 : :
1895 : : static void
1896 : 0 : nic_rx_descriptor_display(uint16_t port_id, struct desc_param *desc)
1897 : : {
1898 : 0 : uint16_t queue_id = desc->queue_id;
1899 : 0 : uint16_t offset = desc->offset;
1900 : 0 : uint16_t num = desc->num;
1901 : : int ret;
1902 : :
1903 : : snprintf(bdr_str, MAX_STRING_LEN, " show - Rx descriptor ");
1904 : : STATS_BDR_STR(10, bdr_str);
1905 : :
1906 : 0 : printf("Dump ethdev Rx descriptor for port %u, queue %u, offset %u, num %u\n",
1907 : : port_id, queue_id, offset, num);
1908 : :
1909 : 0 : ret = rte_eth_rx_descriptor_dump(port_id, queue_id, offset, num,
1910 : : stdout);
1911 : 0 : if (ret < 0)
1912 : 0 : fprintf(stderr, "Error dumping ethdev Rx descriptor: %s\n",
1913 : : strerror(-ret));
1914 : 0 : }
1915 : :
1916 : : static void
1917 : 0 : nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
1918 : : {
1919 : 0 : uint16_t queue_id = desc->queue_id;
1920 : 0 : uint16_t offset = desc->offset;
1921 : 0 : uint16_t num = desc->num;
1922 : : int ret;
1923 : :
1924 : : snprintf(bdr_str, MAX_STRING_LEN, " show - Tx descriptor ");
1925 : : STATS_BDR_STR(10, bdr_str);
1926 : :
1927 : 0 : printf("Dump ethdev Tx descriptor for port %u, queue %u, offset %u, num %u\n",
1928 : : port_id, queue_id, offset, num);
1929 : :
1930 : 0 : ret = rte_eth_tx_descriptor_dump(port_id, queue_id, offset, num,
1931 : : stdout);
1932 : 0 : if (ret < 0)
1933 : 0 : fprintf(stderr, "Error dumping ethdev Tx descriptor: %s\n",
1934 : : strerror(-ret));
1935 : 0 : }
1936 : :
1937 : : static void
1938 : 0 : xstats_display(uint8_t dev_id,
1939 : : enum rte_event_dev_xstats_mode mode,
1940 : : uint8_t queue_port_id)
1941 : : {
1942 : : int ret;
1943 : : struct rte_event_dev_xstats_name *xstats_names;
1944 : : uint64_t *ids;
1945 : : uint64_t *values;
1946 : : int size;
1947 : : int i;
1948 : :
1949 : 0 : size = rte_event_dev_xstats_names_get(dev_id,
1950 : : mode,
1951 : : queue_port_id,
1952 : : NULL, /* names */
1953 : : NULL, /* ids */
1954 : : 0); /* num */
1955 : :
1956 : 0 : if (size < 0)
1957 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
1958 : :
1959 : 0 : if (size == 0) {
1960 : : printf(
1961 : : "No stats available for this item, mode=%d, queue_port_id=%d\n",
1962 : : mode, queue_port_id);
1963 : 0 : return;
1964 : : }
1965 : :
1966 : : /* Get memory to hold stat names, IDs, and values */
1967 : 0 : xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
1968 : 0 : ids = malloc(sizeof(unsigned int) * size);
1969 : :
1970 : 0 : if (!xstats_names || !ids)
1971 : 0 : rte_panic("unable to alloc memory for stats retrieval\n");
1972 : :
1973 : 0 : ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
1974 : : xstats_names, ids,
1975 : : (unsigned int)size);
1976 : 0 : if (ret != size)
1977 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
1978 : :
1979 : 0 : values = malloc(sizeof(uint64_t) * size);
1980 : 0 : if (!values)
1981 : 0 : rte_panic("unable to alloc memory for stats retrieval\n");
1982 : :
1983 : 0 : ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
1984 : : ids, values, size);
1985 : :
1986 : 0 : if (ret != size)
1987 : 0 : rte_panic("rte_event_dev_xstats_get err %d\n", ret);
1988 : :
1989 : 0 : for (i = 0; i < size; i++) {
1990 : 0 : printf("id %"PRIu64" %s = %"PRIu64"\n",
1991 : 0 : ids[i], &xstats_names[i].name[0], values[i]);
1992 : : }
1993 : :
1994 : 0 : free(values);
1995 : 0 : free(xstats_names);
1996 : 0 : free(ids);
1997 : :
1998 : : }
1999 : :
2000 : : static void
2001 : 0 : xstats_reset(uint8_t dev_id,
2002 : : enum rte_event_dev_xstats_mode mode,
2003 : : uint8_t queue_port_id)
2004 : : {
2005 : : int ret;
2006 : : struct rte_event_dev_xstats_name *xstats_names;
2007 : : uint64_t *ids;
2008 : : int size;
2009 : :
2010 : 0 : size = rte_event_dev_xstats_names_get(dev_id,
2011 : : mode,
2012 : : queue_port_id,
2013 : : NULL, /* names */
2014 : : NULL, /* ids */
2015 : : 0); /* num */
2016 : :
2017 : 0 : if (size < 0)
2018 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
2019 : :
2020 : 0 : if (size == 0) {
2021 : : printf(
2022 : : "No stats available for this item, mode=%d, queue_port_id=%d\n",
2023 : : mode, queue_port_id);
2024 : 0 : return;
2025 : : }
2026 : :
2027 : : /* Get memory to hold stat names, IDs, and values */
2028 : 0 : xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
2029 : 0 : ids = malloc(sizeof(unsigned int) * size);
2030 : :
2031 : 0 : if (!xstats_names || !ids)
2032 : 0 : rte_panic("unable to alloc memory for stats retrieval\n");
2033 : :
2034 : 0 : ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
2035 : : xstats_names, ids,
2036 : : (unsigned int)size);
2037 : 0 : if (ret != size)
2038 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
2039 : :
2040 : 0 : rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
2041 : : ids, size);
2042 : :
2043 : 0 : free(xstats_names);
2044 : 0 : free(ids);
2045 : :
2046 : : }
2047 : :
2048 : : static unsigned int
2049 : 0 : eventdev_xstats(void)
2050 : : {
2051 : : unsigned int count = 0;
2052 : : int i, j;
2053 : :
2054 : 0 : for (i = 0; i < rte_event_dev_count(); i++) {
2055 : :
2056 : 0 : if (eventdev_var[i].dump_xstats) {
2057 : 0 : ++count;
2058 : 0 : int ret = rte_event_dev_dump(i, stdout);
2059 : :
2060 : 0 : if (ret)
2061 : 0 : rte_panic("dump failed with err=%d\n", ret);
2062 : : }
2063 : :
2064 : 0 : if (eventdev_var[i].shw_device_xstats == 1) {
2065 : 0 : ++count;
2066 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
2067 : :
2068 : 0 : if (eventdev_var[i].reset_xstats == 1)
2069 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
2070 : : }
2071 : :
2072 : 0 : if (eventdev_var[i].shw_all_ports == 1) {
2073 : 0 : ++count;
2074 : 0 : for (j = 0; j < MAX_PORTS_QUEUES; j++) {
2075 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
2076 : :
2077 : 0 : if (eventdev_var[i].reset_xstats == 1)
2078 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
2079 : : }
2080 : : } else {
2081 : 0 : if (eventdev_var[i].num_ports > 0)
2082 : 0 : ++count;
2083 : 0 : for (j = 0; j < eventdev_var[i].num_ports; j++) {
2084 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
2085 : 0 : eventdev_var[i].ports[j]);
2086 : :
2087 : 0 : if (eventdev_var[i].reset_xstats == 1)
2088 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
2089 : 0 : eventdev_var[i].ports[j]);
2090 : : }
2091 : : }
2092 : :
2093 : 0 : if (eventdev_var[i].shw_all_queues == 1) {
2094 : 0 : ++count;
2095 : 0 : for (j = 0; j < MAX_PORTS_QUEUES; j++) {
2096 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
2097 : :
2098 : 0 : if (eventdev_var[i].reset_xstats == 1)
2099 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
2100 : : }
2101 : : } else {
2102 : 0 : if (eventdev_var[i].num_queues > 0)
2103 : 0 : ++count;
2104 : 0 : for (j = 0; j < eventdev_var[i].num_queues; j++) {
2105 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
2106 : 0 : eventdev_var[i].queues[j]);
2107 : :
2108 : 0 : if (eventdev_var[i].reset_xstats == 1)
2109 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
2110 : 0 : eventdev_var[i].queues[j]);
2111 : : }
2112 : : }
2113 : : }
2114 : :
2115 : 0 : return count;
2116 : : }
2117 : :
2118 : : int
2119 : 0 : main(int argc, char **argv)
2120 : 0 : {
2121 : : int ret;
2122 : : int i;
2123 : 0 : char c_flag[] = "-l0";
2124 : 0 : char n_flag[] = "-n4";
2125 : 0 : char mp_flag[] = "--proc-type=secondary";
2126 : 0 : char log_flag[] = "--log-level=6";
2127 : 0 : char *argp[argc + 4];
2128 : : uint16_t nb_ports;
2129 : :
2130 : : /* preparse app arguments */
2131 : 0 : ret = proc_info_preparse_args(argc, argv);
2132 : 0 : if (ret < 0) {
2133 : : printf("Failed to parse arguments\n");
2134 : 0 : return -1;
2135 : : }
2136 : :
2137 : 0 : argp[0] = argv[0];
2138 : 0 : argp[1] = c_flag;
2139 : 0 : argp[2] = n_flag;
2140 : 0 : argp[3] = mp_flag;
2141 : 0 : argp[4] = log_flag;
2142 : :
2143 : 0 : for (i = 1; i < argc; i++)
2144 : 0 : argp[i + 4] = argv[i];
2145 : :
2146 : : argc += 4;
2147 : :
2148 : 0 : ret = rte_eal_init(argc, argp);
2149 : 0 : if (ret < 0)
2150 : 0 : rte_panic("Cannot init EAL\n");
2151 : :
2152 : 0 : argc -= ret;
2153 : 0 : argv += ret - 4;
2154 : :
2155 : 0 : if (!rte_eal_primary_proc_alive(NULL))
2156 : 0 : rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
2157 : :
2158 : : /* parse app arguments */
2159 : 0 : ret = proc_info_parse_args(argc, argv);
2160 : 0 : if (ret < 0)
2161 : 0 : rte_exit(EXIT_FAILURE, "Invalid argument\n");
2162 : :
2163 : 0 : if (mem_info) {
2164 : 0 : meminfo_display();
2165 : 0 : goto cleanup;
2166 : : }
2167 : :
2168 : 0 : if (eventdev_xstats() > 0)
2169 : 0 : goto cleanup;
2170 : :
2171 : 0 : nb_ports = rte_eth_dev_count_avail();
2172 : 0 : if (nb_ports == 0)
2173 : 0 : rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
2174 : :
2175 : : /* If no port mask was specified, then show all non-owned ports */
2176 : 0 : if (enabled_port_mask == 0) {
2177 : 0 : RTE_ETH_FOREACH_DEV(i)
2178 : 0 : enabled_port_mask |= 1ul << i;
2179 : : }
2180 : :
2181 : 0 : for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
2182 : :
2183 : : /* Skip if port is not in mask */
2184 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
2185 : 0 : continue;
2186 : :
2187 : : /* Skip if port is unused */
2188 : 0 : if (!rte_eth_dev_is_valid_port(i))
2189 : 0 : continue;
2190 : :
2191 : 0 : if (enable_stats)
2192 : 0 : nic_stats_display(i);
2193 : 0 : else if (enable_xstats)
2194 : 0 : nic_xstats_display(i);
2195 : 0 : else if (reset_stats)
2196 : 0 : nic_stats_clear(i);
2197 : 0 : else if (reset_xstats)
2198 : 0 : nic_xstats_clear(i);
2199 : 0 : else if (enable_xstats_name)
2200 : 0 : nic_xstats_by_name_display(i, xstats_name);
2201 : 0 : else if (nb_xstats_ids > 0)
2202 : 0 : nic_xstats_by_ids_display(i, xstats_ids,
2203 : : nb_xstats_ids);
2204 : : #ifdef RTE_LIB_METRICS
2205 : 0 : else if (enable_metrics)
2206 : 0 : metrics_display(i);
2207 : : #endif
2208 : :
2209 : 0 : if (enable_shw_rx_desc_dump)
2210 : 0 : nic_rx_descriptor_display(i, &rx_desc_param);
2211 : 0 : if (enable_shw_tx_desc_dump)
2212 : 0 : nic_tx_descriptor_display(i, &tx_desc_param);
2213 : : }
2214 : :
2215 : : #ifdef RTE_LIB_METRICS
2216 : : /* print port independent stats */
2217 : 0 : if (enable_metrics)
2218 : 0 : metrics_display(RTE_METRICS_GLOBAL);
2219 : : #endif
2220 : :
2221 : : /* show information for PMD */
2222 : 0 : if (enable_shw_port)
2223 : 0 : show_port();
2224 : 0 : if (enable_shw_port_priv)
2225 : 0 : show_port_private_info();
2226 : 0 : if (enable_shw_tm)
2227 : 0 : show_tm();
2228 : 0 : if (enable_shw_crypto)
2229 : 0 : show_crypto();
2230 : 0 : if (enable_shw_ring)
2231 : 0 : show_ring(ring_name);
2232 : 0 : if (enable_shw_mempool)
2233 : 0 : show_mempool(mempool_name);
2234 : 0 : if (enable_iter_mempool)
2235 : 0 : iter_mempool(mempool_iter_name);
2236 : 0 : if (enable_dump_regs)
2237 : 0 : dump_regs(dump_regs_file_prefix);
2238 : 0 : if (enable_shw_version)
2239 : 0 : show_version();
2240 : 0 : if (enable_shw_fw_version)
2241 : 0 : show_firmware_version();
2242 : 0 : if (enable_shw_rss_reta)
2243 : 0 : show_port_rss_reta_info();
2244 : 0 : if (enable_shw_module_eeprom)
2245 : 0 : show_module_eeprom_info();
2246 : :
2247 : 0 : RTE_ETH_FOREACH_DEV(i)
2248 : 0 : rte_eth_dev_close(i);
2249 : :
2250 : 0 : cleanup:
2251 : 0 : ret = rte_eal_cleanup();
2252 : 0 : if (ret)
2253 : : printf("Error from rte_eal_cleanup(), %d\n", ret);
2254 : :
2255 : : return 0;
2256 : : }
|