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