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 : : uint8_t i;
661 : :
662 : : static const char *nic_stats_border = "########################";
663 : :
664 : 0 : rte_eth_stats_get(port_id, &stats);
665 : 0 : printf("\n %s NIC statistics for port %-2d %s\n",
666 : : nic_stats_border, port_id, nic_stats_border);
667 : :
668 : 0 : printf(" RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
669 : : " RX-bytes: %-10"PRIu64"\n", stats.ipackets, stats.ierrors,
670 : : stats.ibytes);
671 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf);
672 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64
673 : : " TX-bytes: %-10"PRIu64"\n", stats.opackets, stats.oerrors,
674 : : stats.obytes);
675 : :
676 : : printf("\n");
677 : 0 : for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
678 : 0 : printf(" Stats reg %2d RX-packets: %-10"PRIu64
679 : : " RX-errors: %-10"PRIu64
680 : : " RX-bytes: %-10"PRIu64"\n",
681 : : i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]);
682 : : }
683 : :
684 : : printf("\n");
685 : 0 : for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) {
686 : 0 : printf(" Stats reg %2d TX-packets: %-10"PRIu64
687 : : " TX-bytes: %-10"PRIu64"\n",
688 : : i, stats.q_opackets[i], stats.q_obytes[i]);
689 : : }
690 : :
691 : 0 : printf(" %s############################%s\n",
692 : : nic_stats_border, nic_stats_border);
693 : 0 : }
694 : :
695 : : static void
696 : 0 : nic_stats_clear(uint16_t port_id)
697 : : {
698 : 0 : printf("\n Clearing NIC stats for port %d\n", port_id);
699 : 0 : rte_eth_stats_reset(port_id);
700 : : printf("\n NIC statistics for port %d cleared\n", port_id);
701 : 0 : }
702 : :
703 : 0 : static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
704 : : const char *cnt_name) {
705 : 0 : char *type_end = strrchr(cnt_name, '_');
706 : :
707 : 0 : if ((type_end != NULL) &&
708 : 0 : (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) {
709 : 0 : if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
710 : : strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
711 : 0 : else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
712 : : strlcpy(cnt_type, "if_rx_dropped", cnt_type_len);
713 : 0 : else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
714 : : strlcpy(cnt_type, "if_rx_octets", cnt_type_len);
715 : 0 : else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
716 : : strlcpy(cnt_type, "if_rx_packets", cnt_type_len);
717 : 0 : else if (strncmp(type_end, "_placement",
718 : : strlen("_placement")) == 0)
719 : : strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
720 : 0 : else if (strncmp(type_end, "_buff", strlen("_buff")) == 0)
721 : : strlcpy(cnt_type, "if_rx_errors", cnt_type_len);
722 : : else
723 : : /* Does not fit obvious type: use a more generic one */
724 : : strlcpy(cnt_type, "derive", cnt_type_len);
725 : 0 : } else if ((type_end != NULL) &&
726 : 0 : (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) {
727 : 0 : if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
728 : : strlcpy(cnt_type, "if_tx_errors", cnt_type_len);
729 : 0 : else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0)
730 : : strlcpy(cnt_type, "if_tx_dropped", cnt_type_len);
731 : 0 : else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0)
732 : : strlcpy(cnt_type, "if_tx_octets", cnt_type_len);
733 : 0 : else if (strncmp(type_end, "_packets", strlen("_packets")) == 0)
734 : : strlcpy(cnt_type, "if_tx_packets", cnt_type_len);
735 : : else
736 : : /* Does not fit obvious type: use a more generic one */
737 : : strlcpy(cnt_type, "derive", cnt_type_len);
738 : 0 : } else if ((type_end != NULL) &&
739 : 0 : (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
740 : 0 : if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
741 : : strlcpy(cnt_type, "filter_result", cnt_type_len);
742 : 0 : else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
743 : : strlcpy(cnt_type, "errors", cnt_type_len);
744 : 0 : } else if ((type_end != NULL) &&
745 : 0 : (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
746 : 0 : if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
747 : : strlcpy(cnt_type, "errors", cnt_type_len);
748 : : } else {
749 : : /* Does not fit obvious type, or strrchr error: */
750 : : /* use a more generic type */
751 : : strlcpy(cnt_type, "derive", cnt_type_len);
752 : : }
753 : 0 : }
754 : :
755 : : static void
756 : 0 : nic_xstats_by_name_display(uint16_t port_id, char *name)
757 : : {
758 : : uint64_t id;
759 : :
760 : 0 : printf("###### NIC statistics for port %-2d, statistic name '%s':\n",
761 : : port_id, name);
762 : :
763 : 0 : if (rte_eth_xstats_get_id_by_name(port_id, name, &id) == 0)
764 : 0 : printf("%s: %"PRIu64"\n", name, id);
765 : : else
766 : : printf("Statistic not found...\n");
767 : :
768 : 0 : }
769 : :
770 : : static void
771 : 0 : nic_xstats_by_ids_display(uint16_t port_id, uint64_t *ids, int len)
772 : : {
773 : : struct rte_eth_xstat_name *xstats_names;
774 : : uint64_t *values;
775 : : int ret, i;
776 : : static const char *nic_stats_border = "########################";
777 : :
778 : 0 : values = malloc(sizeof(*values) * len);
779 : 0 : if (values == NULL) {
780 : : printf("Cannot allocate memory for xstats\n");
781 : 0 : return;
782 : : }
783 : :
784 : 0 : xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
785 : 0 : if (xstats_names == NULL) {
786 : : printf("Cannot allocate memory for xstat names\n");
787 : 0 : free(values);
788 : 0 : return;
789 : : }
790 : :
791 : 0 : if (len != rte_eth_xstats_get_names_by_id(
792 : : port_id, xstats_names, len, ids)) {
793 : : printf("Cannot get xstat names\n");
794 : 0 : goto err;
795 : : }
796 : :
797 : : printf("###### NIC extended statistics for port %-2d #########\n",
798 : : port_id);
799 : 0 : printf("%s############################\n", nic_stats_border);
800 : 0 : ret = rte_eth_xstats_get_by_id(port_id, ids, values, len);
801 : 0 : if (ret < 0 || ret > len) {
802 : : printf("Cannot get xstats\n");
803 : 0 : goto err;
804 : : }
805 : :
806 : 0 : for (i = 0; i < len; i++)
807 : 0 : printf("%s: %"PRIu64"\n",
808 : 0 : xstats_names[i].name,
809 : 0 : values[i]);
810 : :
811 : 0 : printf("%s############################\n", nic_stats_border);
812 : 0 : err:
813 : 0 : free(values);
814 : 0 : free(xstats_names);
815 : : }
816 : :
817 : : static void
818 : 0 : nic_xstats_display(uint16_t port_id)
819 : : {
820 : : struct rte_eth_xstat_name *xstats_names;
821 : : uint64_t *values;
822 : : int len, ret, i;
823 : : static const char *nic_stats_border = "########################";
824 : :
825 : 0 : len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL);
826 : 0 : if (len < 0) {
827 : : printf("Cannot get xstats count\n");
828 : 0 : return;
829 : : }
830 : 0 : values = malloc(sizeof(*values) * len);
831 : 0 : if (values == NULL) {
832 : : printf("Cannot allocate memory for xstats\n");
833 : 0 : return;
834 : : }
835 : :
836 : 0 : xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
837 : 0 : if (xstats_names == NULL) {
838 : : printf("Cannot allocate memory for xstat names\n");
839 : 0 : free(values);
840 : 0 : return;
841 : : }
842 : 0 : if (len != rte_eth_xstats_get_names_by_id(
843 : : port_id, xstats_names, len, NULL)) {
844 : : printf("Cannot get xstat names\n");
845 : 0 : goto err;
846 : : }
847 : :
848 : : printf("###### NIC extended statistics for port %-2d #########\n",
849 : : port_id);
850 : 0 : printf("%s############################\n",
851 : : nic_stats_border);
852 : 0 : ret = rte_eth_xstats_get_by_id(port_id, NULL, values, len);
853 : 0 : if (ret < 0 || ret > len) {
854 : : printf("Cannot get xstats\n");
855 : 0 : goto err;
856 : : }
857 : :
858 : 0 : for (i = 0; i < len; i++) {
859 : 0 : if (enable_xstats_hide_zero && values[i] == 0)
860 : 0 : continue;
861 : 0 : if (enable_collectd_format) {
862 : : char counter_type[MAX_STRING_LEN];
863 : : char buf[MAX_STRING_LEN];
864 : : size_t n;
865 : :
866 : 0 : collectd_resolve_cnt_type(counter_type,
867 : : sizeof(counter_type),
868 : 0 : xstats_names[i].name);
869 : 0 : n = snprintf(buf, MAX_STRING_LEN,
870 : : "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
871 : : PRIu64"\n", host_id, port_id, counter_type,
872 : 0 : xstats_names[i].name, values[i]);
873 : : if (n > sizeof(buf) - 1)
874 : : n = sizeof(buf) - 1;
875 : 0 : ret = write(stdout_fd, buf, n);
876 : 0 : if (ret < 0)
877 : 0 : goto err;
878 : : } else {
879 : 0 : printf("%s: %"PRIu64"\n", xstats_names[i].name,
880 : 0 : values[i]);
881 : : }
882 : : }
883 : :
884 : 0 : printf("%s############################\n",
885 : : nic_stats_border);
886 : 0 : err:
887 : 0 : free(values);
888 : 0 : free(xstats_names);
889 : : }
890 : :
891 : : static void
892 : 0 : nic_xstats_clear(uint16_t port_id)
893 : : {
894 : : int ret;
895 : :
896 : 0 : printf("\n Clearing NIC xstats for port %d\n", port_id);
897 : 0 : ret = rte_eth_xstats_reset(port_id);
898 : 0 : if (ret != 0) {
899 : 0 : printf("\n Error clearing xstats for port %d: %s\n", port_id,
900 : : strerror(-ret));
901 : 0 : return;
902 : : }
903 : :
904 : : printf("\n NIC extended statistics for port %d cleared\n", port_id);
905 : : }
906 : :
907 : : #ifdef RTE_LIB_METRICS
908 : : static void
909 : 0 : metrics_display(int port_id)
910 : : {
911 : : struct rte_metric_value *metrics;
912 : : struct rte_metric_name *names;
913 : : int len, ret;
914 : : static const char *nic_stats_border = "########################";
915 : :
916 : 0 : len = rte_metrics_get_names(NULL, 0);
917 : 0 : if (len < 0) {
918 : : printf("Cannot get metrics count\n");
919 : 0 : return;
920 : : }
921 : 0 : if (len == 0) {
922 : : printf("No metrics to display (none have been registered)\n");
923 : 0 : return;
924 : : }
925 : :
926 : 0 : metrics = malloc(sizeof(struct rte_metric_value) * len);
927 : 0 : if (metrics == NULL) {
928 : : printf("Cannot allocate memory for metrics\n");
929 : 0 : return;
930 : : }
931 : :
932 : 0 : names = malloc(sizeof(struct rte_metric_name) * len);
933 : 0 : if (names == NULL) {
934 : : printf("Cannot allocate memory for metrics names\n");
935 : 0 : free(metrics);
936 : 0 : return;
937 : : }
938 : :
939 : 0 : if (len != rte_metrics_get_names(names, len)) {
940 : : printf("Cannot get metrics names\n");
941 : 0 : free(metrics);
942 : 0 : free(names);
943 : 0 : return;
944 : : }
945 : :
946 : 0 : if (port_id == RTE_METRICS_GLOBAL)
947 : : printf("###### Non port specific metrics #########\n");
948 : : else
949 : : printf("###### metrics for port %-2d #########\n", port_id);
950 : 0 : printf("%s############################\n", nic_stats_border);
951 : 0 : ret = rte_metrics_get_values(port_id, metrics, len);
952 : 0 : if (ret < 0 || ret > len) {
953 : : printf("Cannot get metrics values\n");
954 : 0 : free(metrics);
955 : 0 : free(names);
956 : 0 : return;
957 : : }
958 : :
959 : : int i;
960 : 0 : for (i = 0; i < len; i++)
961 : 0 : printf("%s: %"PRIu64"\n", names[i].name, metrics[i].value);
962 : :
963 : 0 : printf("%s############################\n", nic_stats_border);
964 : 0 : free(metrics);
965 : 0 : free(names);
966 : : }
967 : : #endif
968 : :
969 : : static void
970 : 0 : show_security_context(uint16_t portid, bool inline_offload)
971 : : {
972 : : void *p_ctx;
973 : : const struct rte_security_capability *s_cap;
974 : :
975 : 0 : if (inline_offload)
976 : 0 : p_ctx = rte_eth_dev_get_sec_ctx(portid);
977 : : else
978 : 0 : p_ctx = rte_cryptodev_get_sec_ctx(portid);
979 : :
980 : 0 : if (p_ctx == NULL)
981 : : return;
982 : :
983 : : printf(" - crypto context\n");
984 : : printf("\t -- security context - %p\n", p_ctx);
985 : 0 : printf("\t -- size %u\n",
986 : : rte_security_session_get_size(p_ctx));
987 : :
988 : 0 : s_cap = rte_security_capabilities_get(p_ctx);
989 : 0 : if (s_cap) {
990 : : printf("\t -- action (0x%x), protocol (0x%x),"
991 : : " offload flags (0x%x)\n",
992 : 0 : s_cap->action,
993 : 0 : s_cap->protocol,
994 : 0 : s_cap->ol_flags);
995 : : printf("\t -- capabilities - oper type %x\n",
996 : 0 : s_cap->crypto_capabilities->op);
997 : : }
998 : : }
999 : :
1000 : : static void
1001 : 0 : show_offloads(uint64_t offloads,
1002 : : const char *(show_offload)(uint64_t))
1003 : : {
1004 : : printf(" offloads :");
1005 : 0 : while (offloads != 0) {
1006 : 0 : uint64_t offload_flag = 1ULL << rte_ctz64(offloads);
1007 : 0 : printf(" %s", show_offload(offload_flag));
1008 : 0 : offloads &= ~offload_flag;
1009 : : }
1010 : 0 : }
1011 : :
1012 : : static void
1013 : 0 : show_port(void)
1014 : : {
1015 : : int i, ret, j, k;
1016 : :
1017 : : snprintf(bdr_str, MAX_STRING_LEN, " show - Port PMD ");
1018 : : STATS_BDR_STR(10, bdr_str);
1019 : :
1020 : 0 : for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
1021 : 0 : uint16_t mtu = 0;
1022 : : struct rte_eth_link link;
1023 : : struct rte_eth_dev_info dev_info;
1024 : : struct rte_eth_rss_conf rss_conf;
1025 : : char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
1026 : : struct rte_eth_fc_conf fc_conf;
1027 : : struct rte_ether_addr mac;
1028 : : struct rte_eth_dev_owner owner;
1029 : : uint8_t rss_key[RSS_HASH_KEY_SIZE];
1030 : :
1031 : : /* Skip if port is not in mask */
1032 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1033 : 0 : continue;
1034 : :
1035 : : /* Skip if port is unused */
1036 : 0 : if (!rte_eth_dev_is_valid_port(i))
1037 : 0 : continue;
1038 : :
1039 : : memset(&rss_conf, 0, sizeof(rss_conf));
1040 : :
1041 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
1042 : : STATS_BDR_STR(5, bdr_str);
1043 : : printf(" - generic config\n");
1044 : :
1045 : 0 : ret = rte_eth_dev_info_get(i, &dev_info);
1046 : 0 : if (ret != 0) {
1047 : 0 : printf("Error during getting device info: %s\n",
1048 : : strerror(-ret));
1049 : 0 : return;
1050 : : }
1051 : :
1052 : 0 : printf("\t -- driver %s device %s socket %d\n",
1053 : 0 : dev_info.driver_name, rte_dev_name(dev_info.device),
1054 : : rte_eth_dev_socket_id(i));
1055 : :
1056 : 0 : ret = rte_eth_dev_owner_get(i, &owner);
1057 : 0 : if (ret == 0 && owner.id != RTE_ETH_DEV_NO_OWNER)
1058 : : printf("\t -- owner %#"PRIx64":%s\n",
1059 : : owner.id, owner.name);
1060 : :
1061 : 0 : ret = rte_eth_link_get(i, &link);
1062 : 0 : if (ret < 0) {
1063 : 0 : printf("Link get failed (port %u): %s\n",
1064 : : i, rte_strerror(-ret));
1065 : : } else {
1066 : 0 : rte_eth_link_to_str(link_status_text,
1067 : : sizeof(link_status_text),
1068 : : &link);
1069 : : printf("\t%s\n", link_status_text);
1070 : : }
1071 : :
1072 : 0 : ret = rte_eth_dev_flow_ctrl_get(i, &fc_conf);
1073 : 0 : if (ret == 0 && fc_conf.mode != RTE_ETH_FC_NONE) {
1074 : 0 : printf("\t -- flow control mode %s%s high %u low %u pause %u%s%s\n",
1075 : : fc_conf.mode == RTE_ETH_FC_RX_PAUSE ? "rx " :
1076 : 0 : fc_conf.mode == RTE_ETH_FC_TX_PAUSE ? "tx " :
1077 : 0 : fc_conf.mode == RTE_ETH_FC_FULL ? "full" : "???",
1078 : 0 : fc_conf.autoneg ? " auto" : "",
1079 : : fc_conf.high_water,
1080 : : fc_conf.low_water,
1081 : 0 : fc_conf.pause_time,
1082 : 0 : fc_conf.send_xon ? " xon" : "",
1083 : 0 : fc_conf.mac_ctrl_frame_fwd ? " mac_ctrl" : "");
1084 : : }
1085 : :
1086 : 0 : ret = rte_eth_macaddr_get(i, &mac);
1087 : 0 : if (ret == 0) {
1088 : : char ebuf[RTE_ETHER_ADDR_FMT_SIZE];
1089 : :
1090 : 0 : rte_ether_format_addr(ebuf, sizeof(ebuf), &mac);
1091 : : printf("\t -- mac %s\n", ebuf);
1092 : : }
1093 : :
1094 : 0 : ret = rte_eth_promiscuous_get(i);
1095 : 0 : if (ret >= 0)
1096 : 0 : printf("\t -- promiscuous mode %s\n",
1097 : : ret > 0 ? "enabled" : "disabled");
1098 : :
1099 : 0 : ret = rte_eth_allmulticast_get(i);
1100 : 0 : if (ret >= 0)
1101 : 0 : printf("\t -- all multicast mode %s\n",
1102 : : ret > 0 ? "enabled" : "disabled");
1103 : :
1104 : 0 : ret = rte_eth_dev_get_mtu(i, &mtu);
1105 : 0 : if (ret == 0)
1106 : 0 : printf("\t -- mtu (%d)\n", mtu);
1107 : :
1108 : 0 : for (j = 0; j < dev_info.nb_rx_queues; j++) {
1109 : : struct rte_eth_rxq_info queue_info;
1110 : : struct rte_eth_burst_mode mode;
1111 : : int count;
1112 : :
1113 : 0 : ret = rte_eth_rx_queue_info_get(i, j, &queue_info);
1114 : 0 : if (ret != 0)
1115 : : break;
1116 : :
1117 : 0 : if (j == 0)
1118 : : printf(" - rx queue\n");
1119 : :
1120 : : printf("\t -- %d descriptors ", j);
1121 : : count = rte_eth_rx_queue_count(i, j);
1122 : 0 : if (count >= 0)
1123 : : printf("%d/", count);
1124 : 0 : printf("%u", queue_info.nb_desc);
1125 : :
1126 : 0 : if (queue_info.scattered_rx)
1127 : : printf(" scattered");
1128 : :
1129 : 0 : if (queue_info.conf.rx_drop_en)
1130 : : printf(" drop_en");
1131 : :
1132 : 0 : if (queue_info.conf.rx_deferred_start)
1133 : : printf(" deferred_start");
1134 : :
1135 : 0 : if (queue_info.rx_buf_size != 0)
1136 : 0 : printf(" rx buffer size %u",
1137 : : queue_info.rx_buf_size);
1138 : :
1139 : 0 : printf(" mempool %s socket %d",
1140 : 0 : queue_info.mp->name,
1141 : 0 : queue_info.mp->socket_id);
1142 : :
1143 : 0 : if (queue_info.conf.offloads != 0)
1144 : 0 : show_offloads(queue_info.conf.offloads, rte_eth_dev_rx_offload_name);
1145 : :
1146 : 0 : if (rte_eth_rx_burst_mode_get(i, j, &mode) == 0)
1147 : 0 : printf(" burst mode : %s%s",
1148 : : mode.info,
1149 : 0 : mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ?
1150 : : " (per queue)" : "");
1151 : :
1152 : : printf("\n");
1153 : : }
1154 : :
1155 : 0 : for (j = 0; j < dev_info.nb_tx_queues; j++) {
1156 : : struct rte_eth_txq_info queue_info;
1157 : : struct rte_eth_burst_mode mode;
1158 : :
1159 : 0 : ret = rte_eth_tx_queue_info_get(i, j, &queue_info);
1160 : 0 : if (ret != 0)
1161 : : break;
1162 : :
1163 : 0 : if (j == 0)
1164 : : printf(" - tx queue\n");
1165 : :
1166 : 0 : printf("\t -- %d descriptors %d",
1167 : 0 : j, queue_info.nb_desc);
1168 : :
1169 : 0 : printf(" thresh %u/%u",
1170 : 0 : queue_info.conf.tx_rs_thresh,
1171 : 0 : queue_info.conf.tx_free_thresh);
1172 : :
1173 : 0 : if (queue_info.conf.tx_deferred_start)
1174 : : printf(" deferred_start");
1175 : :
1176 : 0 : if (queue_info.conf.offloads != 0)
1177 : 0 : show_offloads(queue_info.conf.offloads, rte_eth_dev_tx_offload_name);
1178 : :
1179 : 0 : if (rte_eth_tx_burst_mode_get(i, j, &mode) == 0)
1180 : 0 : printf(" burst mode : %s%s",
1181 : : mode.info,
1182 : 0 : mode.flags & RTE_ETH_BURST_FLAG_PER_QUEUE ?
1183 : : " (per queue)" : "");
1184 : :
1185 : : printf("\n");
1186 : : }
1187 : :
1188 : 0 : rss_conf.rss_key = rss_key;
1189 : 0 : rss_conf.rss_key_len = dev_info.hash_key_size;
1190 : 0 : ret = rte_eth_dev_rss_hash_conf_get(i, &rss_conf);
1191 : 0 : if (ret == 0) {
1192 : : printf(" - RSS info\n");
1193 : 0 : printf("\t -- key len : %u\n",
1194 : 0 : rss_conf.rss_key_len);
1195 : : printf("\t -- key (hex) : ");
1196 : 0 : for (k = 0; k < rss_conf.rss_key_len; k++)
1197 : 0 : printf("%02x", rss_conf.rss_key[k]);
1198 : 0 : printf("\n\t -- hash function : 0x%"PRIx64"\n",
1199 : : rss_conf.rss_hf);
1200 : 0 : printf("\t -- hash algorithm : %s\n",
1201 : : rte_eth_dev_rss_algo_name(rss_conf.algorithm));
1202 : : }
1203 : :
1204 : : #ifdef RTE_LIB_SECURITY
1205 : 0 : show_security_context(i, true);
1206 : : #endif
1207 : : }
1208 : : }
1209 : :
1210 : : static void
1211 : 0 : show_port_private_info(void)
1212 : : {
1213 : : int i;
1214 : :
1215 : : snprintf(bdr_str, MAX_STRING_LEN, " Dump - Ports private information");
1216 : : STATS_BDR_STR(10, bdr_str);
1217 : :
1218 : 0 : RTE_ETH_FOREACH_DEV(i) {
1219 : : /* Skip if port is not in mask */
1220 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1221 : 0 : continue;
1222 : :
1223 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
1224 : : STATS_BDR_STR(5, bdr_str);
1225 : 0 : rte_eth_dev_priv_dump(i, stdout);
1226 : : }
1227 : 0 : }
1228 : :
1229 : : static void
1230 : 0 : display_nodecap_info(int is_leaf, struct rte_tm_node_capabilities *cap)
1231 : : {
1232 : 0 : if (cap == NULL)
1233 : : return;
1234 : :
1235 : 0 : if (!is_leaf) {
1236 : 0 : printf("\t -- nonleaf sched max:\n"
1237 : : "\t\t + children (%u)\n"
1238 : : "\t\t + sp priorities (%u)\n"
1239 : : "\t\t + wfq children per group (%u)\n"
1240 : : "\t\t + wfq groups (%u)\n"
1241 : : "\t\t + wfq weight (%u)\n",
1242 : : cap->nonleaf.sched_n_children_max,
1243 : : cap->nonleaf.sched_sp_n_priorities_max,
1244 : : cap->nonleaf.sched_wfq_n_children_per_group_max,
1245 : : cap->nonleaf.sched_wfq_n_groups_max,
1246 : : cap->nonleaf.sched_wfq_weight_max);
1247 : : } else {
1248 : 0 : printf("\t -- leaf cman support:\n"
1249 : : "\t\t + wred pkt mode (%d)\n"
1250 : : "\t\t + wred byte mode (%d)\n"
1251 : : "\t\t + head drop (%d)\n"
1252 : : "\t\t + wred context private (%d)\n"
1253 : : "\t\t + wred context shared (%u)\n",
1254 : : cap->leaf.cman_wred_packet_mode_supported,
1255 : : cap->leaf.cman_wred_byte_mode_supported,
1256 : : cap->leaf.cman_head_drop_supported,
1257 : : cap->leaf.cman_wred_context_private_supported,
1258 : : cap->leaf.cman_wred_context_shared_n_max);
1259 : : }
1260 : : }
1261 : :
1262 : : static void
1263 : 0 : display_levelcap_info(int is_leaf, struct rte_tm_level_capabilities *cap)
1264 : : {
1265 : 0 : if (cap == NULL)
1266 : : return;
1267 : :
1268 : 0 : if (!is_leaf) {
1269 : 0 : printf("\t -- shaper private: (%d) dual rate (%d)\n",
1270 : : cap->nonleaf.shaper_private_supported,
1271 : : cap->nonleaf.shaper_private_dual_rate_supported);
1272 : 0 : printf("\t -- shaper share: (%u)\n",
1273 : : cap->nonleaf.shaper_shared_n_max);
1274 : 0 : printf("\t -- non leaf sched MAX:\n"
1275 : : "\t\t + children (%u)\n"
1276 : : "\t\t + sp (%u)\n"
1277 : : "\t\t + wfq children per group (%u)\n"
1278 : : "\t\t + wfq groups (%u)\n"
1279 : : "\t\t + wfq weight (%u)\n",
1280 : : cap->nonleaf.sched_n_children_max,
1281 : : cap->nonleaf.sched_sp_n_priorities_max,
1282 : : cap->nonleaf.sched_wfq_n_children_per_group_max,
1283 : : cap->nonleaf.sched_wfq_n_groups_max,
1284 : : cap->nonleaf.sched_wfq_weight_max);
1285 : : } else {
1286 : 0 : printf("\t -- shaper private: (%d) dual rate (%d)\n",
1287 : : cap->leaf.shaper_private_supported,
1288 : : cap->leaf.shaper_private_dual_rate_supported);
1289 : 0 : printf("\t -- shaper share: (%u)\n",
1290 : : cap->leaf.shaper_shared_n_max);
1291 : 0 : printf(" -- leaf cman support:\n"
1292 : : "\t\t + wred pkt mode (%d)\n"
1293 : : "\t\t + wred byte mode (%d)\n"
1294 : : "\t\t + head drop (%d)\n"
1295 : : "\t\t + wred context private (%d)\n"
1296 : : "\t\t + wred context shared (%u)\n",
1297 : : cap->leaf.cman_wred_packet_mode_supported,
1298 : : cap->leaf.cman_wred_byte_mode_supported,
1299 : : cap->leaf.cman_head_drop_supported,
1300 : : cap->leaf.cman_wred_context_private_supported,
1301 : : cap->leaf.cman_wred_context_shared_n_max);
1302 : : }
1303 : : }
1304 : :
1305 : : static void
1306 : 0 : show_tm(void)
1307 : : {
1308 : 0 : int ret = 0, check_for_leaf = 0, is_leaf = 0;
1309 : : unsigned int j, k;
1310 : : uint16_t i = 0;
1311 : :
1312 : : snprintf(bdr_str, MAX_STRING_LEN, " show - TM PMD ");
1313 : : STATS_BDR_STR(10, bdr_str);
1314 : :
1315 : 0 : RTE_ETH_FOREACH_DEV(i) {
1316 : : struct rte_eth_dev_info dev_info;
1317 : : struct rte_tm_capabilities cap;
1318 : : struct rte_tm_error error;
1319 : : struct rte_tm_node_capabilities capnode;
1320 : : struct rte_tm_level_capabilities caplevel;
1321 : 0 : uint32_t n_leaf_nodes = 0;
1322 : :
1323 : : memset(&cap, 0, sizeof(cap));
1324 : : memset(&error, 0, sizeof(error));
1325 : :
1326 : 0 : ret = rte_eth_dev_info_get(i, &dev_info);
1327 : 0 : if (ret != 0) {
1328 : 0 : printf("Error during getting device (port %u) info: %s\n",
1329 : : i, strerror(-ret));
1330 : 0 : return;
1331 : : }
1332 : :
1333 : 0 : printf(" - Generic for port (%u)\n"
1334 : : "\t -- driver name %s\n"
1335 : : "\t -- max vf (%u)\n"
1336 : : "\t -- max tx queues (%u)\n"
1337 : : "\t -- number of tx queues (%u)\n",
1338 : : i,
1339 : : dev_info.driver_name,
1340 : 0 : dev_info.max_vfs,
1341 : 0 : dev_info.max_tx_queues,
1342 : 0 : dev_info.nb_tx_queues);
1343 : :
1344 : 0 : ret = rte_tm_capabilities_get(i, &cap, &error);
1345 : 0 : if (ret)
1346 : 0 : continue;
1347 : :
1348 : 0 : printf(" - MAX: nodes (%u) levels (%u) children (%u)\n",
1349 : : cap.n_nodes_max,
1350 : : cap.n_levels_max,
1351 : : cap.sched_n_children_max);
1352 : :
1353 : 0 : printf(" - identical nodes: non leaf (%d) leaf (%d)\n",
1354 : : cap.non_leaf_nodes_identical,
1355 : : cap.leaf_nodes_identical);
1356 : :
1357 : 0 : printf(" - Shaper MAX:\n"
1358 : : "\t -- total (%u)\n"
1359 : : "\t -- private (%u) private dual (%d)\n"
1360 : : "\t -- shared (%u) shared dual (%u)\n",
1361 : : cap.shaper_n_max,
1362 : : cap.shaper_private_n_max,
1363 : : cap.shaper_private_dual_rate_n_max,
1364 : : cap.shaper_shared_n_max,
1365 : : cap.shaper_shared_dual_rate_n_max);
1366 : :
1367 : : printf(" - mark support:\n");
1368 : 0 : printf("\t -- vlan dei: GREEN (%d) YELLOW (%d) RED (%d)\n",
1369 : : cap.mark_vlan_dei_supported[RTE_COLOR_GREEN],
1370 : : cap.mark_vlan_dei_supported[RTE_COLOR_YELLOW],
1371 : : cap.mark_vlan_dei_supported[RTE_COLOR_RED]);
1372 : 0 : printf("\t -- ip ecn tcp: GREEN (%d) YELLOW (%d) RED (%d)\n",
1373 : : cap.mark_ip_ecn_tcp_supported[RTE_COLOR_GREEN],
1374 : : cap.mark_ip_ecn_tcp_supported[RTE_COLOR_YELLOW],
1375 : : cap.mark_ip_ecn_tcp_supported[RTE_COLOR_RED]);
1376 : 0 : printf("\t -- ip ecn sctp: GREEN (%d) YELLOW (%d) RED (%d)\n",
1377 : : cap.mark_ip_ecn_sctp_supported[RTE_COLOR_GREEN],
1378 : : cap.mark_ip_ecn_sctp_supported[RTE_COLOR_YELLOW],
1379 : : cap.mark_ip_ecn_sctp_supported[RTE_COLOR_RED]);
1380 : 0 : printf("\t -- ip dscp: GREEN (%d) YELLOW (%d) RED (%d)\n",
1381 : : cap.mark_ip_dscp_supported[RTE_COLOR_GREEN],
1382 : : cap.mark_ip_dscp_supported[RTE_COLOR_YELLOW],
1383 : : cap.mark_ip_dscp_supported[RTE_COLOR_RED]);
1384 : :
1385 : 0 : printf(" - mask stats (0x%"PRIx64")"
1386 : : " dynamic update (0x%"PRIx64")\n",
1387 : : cap.stats_mask,
1388 : : cap.dynamic_update_mask);
1389 : :
1390 : 0 : printf(" - sched MAX:\n"
1391 : : "\t -- total (%u)\n"
1392 : : "\t -- sp levels (%u)\n"
1393 : : "\t -- wfq children per group (%u)\n"
1394 : : "\t -- wfq groups (%u)\n"
1395 : : "\t -- wfq weight (%u)\n",
1396 : : cap.sched_sp_n_priorities_max,
1397 : : cap.sched_sp_n_priorities_max,
1398 : : cap.sched_wfq_n_children_per_group_max,
1399 : : cap.sched_wfq_n_groups_max,
1400 : : cap.sched_wfq_weight_max);
1401 : :
1402 : 0 : printf(" - CMAN support:\n"
1403 : : "\t -- WRED mode: pkt (%d) byte (%d)\n"
1404 : : "\t -- head drop (%d)\n",
1405 : : cap.cman_wred_packet_mode_supported,
1406 : : cap.cman_wred_byte_mode_supported,
1407 : : cap.cman_head_drop_supported);
1408 : 0 : printf("\t -- MAX WRED CONTEXT:"
1409 : : " total (%u) private (%u) shared (%u)\n",
1410 : : cap.cman_wred_context_n_max,
1411 : : cap.cman_wred_context_private_n_max,
1412 : : cap.cman_wred_context_shared_n_max);
1413 : :
1414 : 0 : for (j = 0; j < cap.n_nodes_max; j++) {
1415 : : memset(&capnode, 0, sizeof(capnode));
1416 : 0 : ret = rte_tm_node_capabilities_get(i, j,
1417 : : &capnode, &error);
1418 : 0 : if (ret)
1419 : 0 : continue;
1420 : :
1421 : : check_for_leaf = 1;
1422 : :
1423 : : printf(" NODE %u\n", j);
1424 : 0 : printf("\t - shaper private: (%d) dual rate (%d)\n",
1425 : : capnode.shaper_private_supported,
1426 : : capnode.shaper_private_dual_rate_supported);
1427 : 0 : printf("\t - shaper shared max: (%u)\n",
1428 : : capnode.shaper_shared_n_max);
1429 : 0 : printf("\t - stats mask %"PRIx64"\n",
1430 : : capnode.stats_mask);
1431 : :
1432 : 0 : ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
1433 : 0 : if (ret)
1434 : 0 : continue;
1435 : :
1436 : 0 : display_nodecap_info(is_leaf, &capnode);
1437 : : }
1438 : :
1439 : 0 : for (j = 0; j < cap.n_levels_max; j++) {
1440 : : memset(&caplevel, 0, sizeof(caplevel));
1441 : 0 : ret = rte_tm_level_capabilities_get(i, j,
1442 : : &caplevel, &error);
1443 : 0 : if (ret)
1444 : 0 : continue;
1445 : :
1446 : : printf(" - Level %u\n", j);
1447 : 0 : printf("\t -- node MAX: %u non leaf %u leaf %u\n",
1448 : : caplevel.n_nodes_max,
1449 : : caplevel.n_nodes_nonleaf_max,
1450 : : caplevel.n_nodes_leaf_max);
1451 : 0 : printf("\t -- identical: non leaf %u leaf %u\n",
1452 : : caplevel.non_leaf_nodes_identical,
1453 : : caplevel.leaf_nodes_identical);
1454 : :
1455 : 0 : for (k = 0; k < caplevel.n_nodes_max; k++) {
1456 : 0 : ret = rte_tm_node_type_get(i, k,
1457 : : &is_leaf, &error);
1458 : 0 : if (ret)
1459 : 0 : continue;
1460 : :
1461 : 0 : display_levelcap_info(is_leaf, &caplevel);
1462 : : }
1463 : : }
1464 : :
1465 : 0 : if (check_for_leaf) {
1466 : 0 : ret = rte_tm_get_number_of_leaf_nodes(i,
1467 : : &n_leaf_nodes, &error);
1468 : 0 : if (ret == 0)
1469 : 0 : printf(" - leaf nodes (%u)\n", n_leaf_nodes);
1470 : : }
1471 : :
1472 : 0 : for (j = 0; j < n_leaf_nodes; j++) {
1473 : : struct rte_tm_node_stats stats;
1474 : : memset(&stats, 0, sizeof(stats));
1475 : :
1476 : 0 : ret = rte_tm_node_stats_read(i, j,
1477 : : &stats, &cap.stats_mask, 0, &error);
1478 : 0 : if (ret)
1479 : 0 : continue;
1480 : :
1481 : : printf(" - STATS for node (%u)\n", j);
1482 : 0 : printf(" -- pkts (%"PRIu64") bytes (%"PRIu64")\n",
1483 : : stats.n_pkts, stats.n_bytes);
1484 : :
1485 : 0 : ret = rte_tm_node_type_get(i, j, &is_leaf, &error);
1486 : 0 : if (ret || (!is_leaf))
1487 : 0 : continue;
1488 : :
1489 : 0 : printf(" -- leaf queued:"
1490 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n",
1491 : : stats.leaf.n_pkts_queued,
1492 : : stats.leaf.n_bytes_queued);
1493 : 0 : printf(" - dropped:\n"
1494 : : "\t -- GREEN:"
1495 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n"
1496 : : "\t -- YELLOW:"
1497 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n"
1498 : : "\t -- RED:"
1499 : : " pkts (%"PRIu64") bytes (%"PRIu64")\n",
1500 : : stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN],
1501 : : stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN],
1502 : : stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW],
1503 : : stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW],
1504 : : stats.leaf.n_pkts_dropped[RTE_COLOR_RED],
1505 : : stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
1506 : : }
1507 : : }
1508 : : }
1509 : :
1510 : : static void
1511 : 0 : display_crypto_feature_info(uint64_t x)
1512 : : {
1513 : 0 : if (x == 0)
1514 : : return;
1515 : :
1516 : : printf("\t -- feature flags\n");
1517 : 0 : printf("\t\t + symmetric (%c), asymmetric (%c)\n"
1518 : : "\t\t + symmetric operation chaining (%c)\n",
1519 : 0 : (x & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ? 'y' : 'n',
1520 : 0 : (x & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) ? 'y' : 'n',
1521 : 0 : (x & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING) ? 'y' : 'n');
1522 : 0 : printf("\t\t + CPU: SSE (%c), AVX (%c), AVX2 (%c), AVX512 (%c)\n",
1523 : 0 : (x & RTE_CRYPTODEV_FF_CPU_SSE) ? 'y' : 'n',
1524 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AVX) ? 'y' : 'n',
1525 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AVX2) ? 'y' : 'n',
1526 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AVX512) ? 'y' : 'n');
1527 : 0 : printf("\t\t + AESNI: CPU (%c), HW (%c)\n",
1528 : 0 : (x & RTE_CRYPTODEV_FF_CPU_AESNI) ? 'y' : 'n',
1529 : 0 : (x & RTE_CRYPTODEV_FF_HW_ACCELERATED) ? 'y' : 'n');
1530 : 0 : printf("\t\t + SECURITY OFFLOAD (%c)\n",
1531 : 0 : (x & RTE_CRYPTODEV_FF_SECURITY) ? 'y' : 'n');
1532 : 0 : printf("\t\t + ARM: NEON (%c), CE (%c)\n",
1533 : 0 : (x & RTE_CRYPTODEV_FF_CPU_NEON) ? 'y' : 'n',
1534 : 0 : (x & RTE_CRYPTODEV_FF_CPU_ARM_CE) ? 'y' : 'n');
1535 : : printf("\t -- buffer offload\n");
1536 : 0 : printf("\t\t + IN_PLACE_SGL (%c)\n",
1537 : 0 : (x & RTE_CRYPTODEV_FF_IN_PLACE_SGL) ? 'y' : 'n');
1538 : 0 : printf("\t\t + OOP_SGL_IN_SGL_OUT (%c)\n",
1539 : 0 : (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT) ? 'y' : 'n');
1540 : 0 : printf("\t\t + OOP_SGL_IN_LB_OUT (%c)\n",
1541 : 0 : (x & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT) ? 'y' : 'n');
1542 : 0 : printf("\t\t + OOP_LB_IN_SGL_OUT (%c)\n",
1543 : 0 : (x & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT) ? 'y' : 'n');
1544 : 0 : printf("\t\t + OOP_LB_IN_LB_OUT (%c)\n",
1545 : 0 : (x & RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT) ? 'y' : 'n');
1546 : : }
1547 : :
1548 : : static void
1549 : 0 : show_crypto(void)
1550 : : {
1551 : 0 : uint8_t crypto_dev_count = rte_cryptodev_count(), i;
1552 : :
1553 : : snprintf(bdr_str, MAX_STRING_LEN, " show - CRYPTO PMD ");
1554 : : STATS_BDR_STR(10, bdr_str);
1555 : :
1556 : 0 : for (i = 0; i < crypto_dev_count; i++) {
1557 : : struct rte_cryptodev_info dev_info;
1558 : : struct rte_cryptodev_stats stats;
1559 : :
1560 : 0 : rte_cryptodev_info_get(i, &dev_info);
1561 : :
1562 : : printf(" - device (%u)\n", i);
1563 : 0 : printf("\t -- name (%s)\n"
1564 : : "\t -- driver (%s)\n"
1565 : : "\t -- id (%u) on socket (%d)\n"
1566 : : "\t -- queue pairs (%d)\n",
1567 : : rte_cryptodev_name_get(i),
1568 : : dev_info.driver_name,
1569 : 0 : dev_info.driver_id,
1570 : 0 : rte_dev_numa_node(dev_info.device),
1571 : 0 : rte_cryptodev_queue_pair_count(i));
1572 : :
1573 : 0 : display_crypto_feature_info(dev_info.feature_flags);
1574 : :
1575 : 0 : if (rte_cryptodev_stats_get(i, &stats) == 0) {
1576 : : printf("\t -- stats\n");
1577 : 0 : printf("\t\t + enqueue count (%"PRIu64")"
1578 : : " error (%"PRIu64")\n",
1579 : : stats.enqueued_count,
1580 : : stats.enqueue_err_count);
1581 : 0 : printf("\t\t + dequeue count (%"PRIu64")"
1582 : : " error (%"PRIu64")\n",
1583 : : stats.dequeued_count,
1584 : : stats.dequeue_err_count);
1585 : : }
1586 : :
1587 : : #ifdef RTE_LIB_SECURITY
1588 : 0 : show_security_context(i, false);
1589 : : #endif
1590 : : }
1591 : 0 : }
1592 : :
1593 : : static void
1594 : 0 : show_ring(char *name)
1595 : : {
1596 : : snprintf(bdr_str, MAX_STRING_LEN, " show - RING ");
1597 : : STATS_BDR_STR(10, bdr_str);
1598 : :
1599 : 0 : if (name != NULL) {
1600 : 0 : struct rte_ring *ptr = rte_ring_lookup(name);
1601 : 0 : if (ptr != NULL) {
1602 : 0 : printf(" - Name (%s) on socket (%d)\n"
1603 : : " - flags:\n"
1604 : : "\t -- Single Producer Enqueue (%u)\n"
1605 : : "\t -- Single Consumer Dequeue (%u)\n",
1606 : 0 : ptr->name,
1607 : 0 : ptr->memzone->socket_id,
1608 : : ptr->flags & RING_F_SP_ENQ,
1609 : 0 : ptr->flags & RING_F_SC_DEQ);
1610 : 0 : printf(" - size (%u) mask (0x%x) capacity (%u)\n",
1611 : : ptr->size,
1612 : : ptr->mask,
1613 : : ptr->capacity);
1614 : : printf(" - count (%u) free count (%u)\n",
1615 : : rte_ring_count(ptr),
1616 : : rte_ring_free_count(ptr));
1617 : : printf(" - full (%d) empty (%d)\n",
1618 : : rte_ring_full(ptr),
1619 : : rte_ring_empty(ptr));
1620 : :
1621 : : STATS_BDR_STR(50, "");
1622 : 0 : return;
1623 : : }
1624 : : }
1625 : :
1626 : 0 : rte_ring_list_dump(stdout);
1627 : : }
1628 : :
1629 : : static void
1630 : 0 : show_mempool(char *name)
1631 : : {
1632 : : snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL ");
1633 : : STATS_BDR_STR(10, bdr_str);
1634 : :
1635 : 0 : if (name != NULL) {
1636 : 0 : struct rte_mempool *ptr = rte_mempool_lookup(name);
1637 : 0 : if (ptr != NULL) {
1638 : : struct rte_mempool_ops *ops;
1639 : 0 : uint64_t flags = ptr->flags;
1640 : :
1641 : 0 : ops = rte_mempool_get_ops(ptr->ops_index);
1642 : 0 : printf(" - Name: %s on socket %d\n"
1643 : : " - flags:\n"
1644 : : "\t -- No spread (%c)\n"
1645 : : "\t -- No cache align (%c)\n"
1646 : : "\t -- SP put (%c), SC get (%c)\n"
1647 : : "\t -- Pool created (%c)\n"
1648 : : "\t -- No IOVA config (%c)\n"
1649 : : "\t -- Not used for IO (%c)\n",
1650 : 0 : ptr->name,
1651 : : ptr->socket_id,
1652 : : (flags & RTE_MEMPOOL_F_NO_SPREAD) ? 'y' : 'n',
1653 : : (flags & RTE_MEMPOOL_F_NO_CACHE_ALIGN) ? 'y' : 'n',
1654 : : (flags & RTE_MEMPOOL_F_SP_PUT) ? 'y' : 'n',
1655 : : (flags & RTE_MEMPOOL_F_SC_GET) ? 'y' : 'n',
1656 : : (flags & RTE_MEMPOOL_F_POOL_CREATED) ? 'y' : 'n',
1657 : : (flags & RTE_MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n',
1658 : : (flags & RTE_MEMPOOL_F_NON_IO) ? 'y' : 'n');
1659 : 0 : printf(" - Size %u Cache %u element %u\n"
1660 : : " - header %u trailer %u\n"
1661 : : " - private data size %u\n",
1662 : : ptr->size,
1663 : : ptr->cache_size,
1664 : : ptr->elt_size,
1665 : : ptr->header_size,
1666 : : ptr->trailer_size,
1667 : : ptr->private_data_size);
1668 : : printf(" - memezone - socket %d\n",
1669 : 0 : ptr->mz->socket_id);
1670 : 0 : printf(" - Count: avail (%u), in use (%u)\n",
1671 : : rte_mempool_avail_count(ptr),
1672 : : rte_mempool_in_use_count(ptr));
1673 : 0 : printf(" - ops_index %d ops_name %s\n",
1674 : : ptr->ops_index, ops ? ops->name : "NA");
1675 : :
1676 : 0 : return;
1677 : : }
1678 : : }
1679 : :
1680 : 0 : rte_mempool_list_dump(stdout);
1681 : : }
1682 : :
1683 : : static void
1684 : 0 : mempool_itr_obj(struct rte_mempool *mp, void *opaque,
1685 : : void *obj, unsigned int obj_idx)
1686 : : {
1687 : : printf(" - obj_idx %u opaque %p obj %p\n",
1688 : : obj_idx, opaque, obj);
1689 : :
1690 : 0 : if (obj)
1691 : 0 : rte_hexdump(stdout, " Obj Content",
1692 : 0 : obj, (mp->elt_size > 256)?256:mp->elt_size);
1693 : 0 : }
1694 : :
1695 : : static void
1696 : 0 : iter_mempool(char *name)
1697 : : {
1698 : : snprintf(bdr_str, MAX_STRING_LEN, " iter - MEMPOOL ");
1699 : : STATS_BDR_STR(10, bdr_str);
1700 : :
1701 : 0 : if (name != NULL) {
1702 : 0 : struct rte_mempool *ptr = rte_mempool_lookup(name);
1703 : 0 : if (ptr != NULL) {
1704 : : /* iterate each object */
1705 : 0 : uint32_t ret = rte_mempool_obj_iter(ptr,
1706 : : mempool_itr_obj, NULL);
1707 : : printf("\n - iterated %u objects\n", ret);
1708 : 0 : return;
1709 : : }
1710 : : }
1711 : : }
1712 : :
1713 : : static void
1714 : 0 : dump_regs(char *file_prefix)
1715 : : {
1716 : : #define MAX_FILE_NAME_SZ (MAX_LONG_OPT_SZ + 10)
1717 : : char file_name[MAX_FILE_NAME_SZ];
1718 : : struct rte_dev_reg_info reg_info;
1719 : : struct rte_eth_dev_info dev_info;
1720 : : unsigned char *buf_data;
1721 : : size_t buf_size;
1722 : : FILE *fp_regs;
1723 : : uint16_t i;
1724 : : int ret;
1725 : :
1726 : : snprintf(bdr_str, MAX_STRING_LEN, " dump - Port REG");
1727 : : STATS_BDR_STR(10, bdr_str);
1728 : :
1729 : 0 : RTE_ETH_FOREACH_DEV(i) {
1730 : : /* Skip if port is not in mask */
1731 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1732 : 0 : continue;
1733 : :
1734 : : snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
1735 : : STATS_BDR_STR(5, bdr_str);
1736 : :
1737 : 0 : ret = rte_eth_dev_info_get(i, &dev_info);
1738 : 0 : if (ret) {
1739 : : printf("Error getting device info: %d\n", ret);
1740 : 0 : continue;
1741 : : }
1742 : :
1743 : : memset(®_info, 0, sizeof(reg_info));
1744 : 0 : ret = rte_eth_dev_get_reg_info(i, ®_info);
1745 : 0 : if (ret) {
1746 : : printf("Error getting device reg info: %d\n", ret);
1747 : 0 : continue;
1748 : : }
1749 : :
1750 : 0 : buf_size = reg_info.length * reg_info.width;
1751 : 0 : buf_data = malloc(buf_size);
1752 : 0 : if (buf_data == NULL) {
1753 : : printf("Error allocating %zu bytes buffer\n", buf_size);
1754 : 0 : continue;
1755 : : }
1756 : :
1757 : 0 : reg_info.data = buf_data;
1758 : 0 : reg_info.length = 0;
1759 : 0 : ret = rte_eth_dev_get_reg_info(i, ®_info);
1760 : 0 : if (ret) {
1761 : : printf("Error getting regs from device: %d\n", ret);
1762 : 0 : free(buf_data);
1763 : 0 : continue;
1764 : : }
1765 : :
1766 : : snprintf(file_name, MAX_FILE_NAME_SZ, "%s-port%u",
1767 : : file_prefix, i);
1768 : 0 : fp_regs = fopen(file_name, "wb");
1769 : 0 : if (fp_regs == NULL) {
1770 : 0 : printf("Error during opening '%s' for writing: %s\n",
1771 : 0 : file_name, strerror(errno));
1772 : : } else {
1773 : : size_t nr_written;
1774 : :
1775 : 0 : nr_written = fwrite(buf_data, 1, buf_size, fp_regs);
1776 : 0 : if (nr_written != buf_size)
1777 : 0 : printf("Error during writing %s: %s\n",
1778 : 0 : file_prefix, strerror(errno));
1779 : : else
1780 : 0 : printf("Device (%s) regs dumped successfully, "
1781 : : "driver:%s version:0X%08X\n",
1782 : 0 : rte_dev_name(dev_info.device),
1783 : : dev_info.driver_name, reg_info.version);
1784 : :
1785 : 0 : fclose(fp_regs);
1786 : : }
1787 : :
1788 : 0 : free(buf_data);
1789 : : }
1790 : 0 : }
1791 : :
1792 : : static void
1793 : 0 : show_version(void)
1794 : : {
1795 : : snprintf(bdr_str, MAX_STRING_LEN, " show - DPDK version ");
1796 : : STATS_BDR_STR(10, bdr_str);
1797 : 0 : printf("DPDK version: %s\n", rte_version());
1798 : 0 : }
1799 : :
1800 : : static void
1801 : 0 : show_firmware_version(void)
1802 : : {
1803 : : char fw_version[ETHDEV_FWVERS_LEN];
1804 : : uint16_t i;
1805 : :
1806 : : snprintf(bdr_str, MAX_STRING_LEN, " show - firmware version ");
1807 : : STATS_BDR_STR(10, bdr_str);
1808 : :
1809 : 0 : RTE_ETH_FOREACH_DEV(i) {
1810 : : /* Skip if port is not in mask */
1811 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1812 : 0 : continue;
1813 : :
1814 : 0 : if (rte_eth_dev_fw_version_get(i, fw_version,
1815 : : ETHDEV_FWVERS_LEN) == 0)
1816 : : printf("Ethdev port %u firmware version: %s\n", i,
1817 : : fw_version);
1818 : : else
1819 : : printf("Ethdev port %u firmware version: %s\n", i,
1820 : : "not available");
1821 : : }
1822 : 0 : }
1823 : :
1824 : : static void
1825 : 0 : show_port_rss_reta_info(void)
1826 : : {
1827 : : struct rte_eth_rss_reta_entry64 reta_conf[RTE_RETA_CONF_GROUP_NUM + 1];
1828 : : struct rte_eth_dev_info dev_info;
1829 : : uint16_t i, idx, shift;
1830 : : uint16_t num;
1831 : : uint16_t id;
1832 : : int ret;
1833 : :
1834 : 0 : RTE_ETH_FOREACH_DEV(id) {
1835 : : /* Skip if port is not in mask */
1836 : 0 : if ((enabled_port_mask & (1ul << id)) == 0)
1837 : 0 : continue;
1838 : :
1839 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", id);
1840 : : STATS_BDR_STR(5, bdr_str);
1841 : :
1842 : 0 : ret = rte_eth_dev_info_get(id, &dev_info);
1843 : 0 : if (ret != 0) {
1844 : 0 : fprintf(stderr, "Error getting device info: %s\n",
1845 : : strerror(-ret));
1846 : 0 : return;
1847 : : }
1848 : :
1849 : 0 : num = DIV_ROUND_UP(dev_info.reta_size, RTE_ETH_RETA_GROUP_SIZE);
1850 : : memset(reta_conf, 0, sizeof(reta_conf));
1851 : 0 : for (i = 0; i < num; i++)
1852 : 0 : reta_conf[i].mask = ~0ULL;
1853 : :
1854 : 0 : ret = rte_eth_dev_rss_reta_query(id, reta_conf, dev_info.reta_size);
1855 : 0 : if (ret != 0) {
1856 : 0 : fprintf(stderr, "Error getting RSS RETA info: %s\n",
1857 : : strerror(-ret));
1858 : 0 : return;
1859 : : }
1860 : :
1861 : 0 : for (i = 0; i < dev_info.reta_size; i++) {
1862 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
1863 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
1864 : 0 : printf("RSS RETA configuration: hash index=%u, queue=%u\n",
1865 : 0 : i, reta_conf[idx].reta[shift]);
1866 : : }
1867 : : }
1868 : : }
1869 : :
1870 : : static void
1871 : 0 : show_module_eeprom_info(void)
1872 : : {
1873 : : unsigned char bytes_eeprom[EEPROM_DUMP_CHUNKSIZE];
1874 : : struct rte_eth_dev_module_info module_info;
1875 : : struct rte_dev_eeprom_info eeprom_info;
1876 : : uint16_t i;
1877 : : int ret;
1878 : :
1879 : 0 : RTE_ETH_FOREACH_DEV(i) {
1880 : : /* Skip if port is not in mask */
1881 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
1882 : 0 : continue;
1883 : :
1884 : : snprintf(bdr_str, MAX_STRING_LEN, " Port %u ", i);
1885 : : STATS_BDR_STR(5, bdr_str);
1886 : :
1887 : 0 : ret = rte_eth_dev_get_module_info(i, &module_info);
1888 : 0 : if (ret != 0) {
1889 : 0 : fprintf(stderr, "Module EEPROM information read error: %s\n",
1890 : : strerror(-ret));
1891 : 0 : return;
1892 : : }
1893 : :
1894 : 0 : eeprom_info.offset = 0;
1895 : 0 : eeprom_info.length = module_info.eeprom_len;
1896 : 0 : eeprom_info.data = bytes_eeprom;
1897 : :
1898 : 0 : ret = rte_eth_dev_get_module_eeprom(i, &eeprom_info);
1899 : 0 : if (ret != 0) {
1900 : 0 : fprintf(stderr, "Module EEPROM read error: %s\n",
1901 : : strerror(-ret));
1902 : 0 : return;
1903 : : }
1904 : :
1905 : 0 : rte_hexdump(stdout, "hexdump", eeprom_info.data,
1906 : : eeprom_info.length);
1907 : 0 : printf("Finish -- Port: %u MODULE EEPROM length: %d bytes\n",
1908 : : i, eeprom_info.length);
1909 : : }
1910 : : }
1911 : :
1912 : : static void
1913 : 0 : nic_rx_descriptor_display(uint16_t port_id, struct desc_param *desc)
1914 : : {
1915 : 0 : uint16_t queue_id = desc->queue_id;
1916 : 0 : uint16_t offset = desc->offset;
1917 : 0 : uint16_t num = desc->num;
1918 : : int ret;
1919 : :
1920 : : snprintf(bdr_str, MAX_STRING_LEN, " show - Rx descriptor ");
1921 : : STATS_BDR_STR(10, bdr_str);
1922 : :
1923 : 0 : printf("Dump ethdev Rx descriptor for port %u, queue %u, offset %u, num %u\n",
1924 : : port_id, queue_id, offset, num);
1925 : :
1926 : 0 : ret = rte_eth_rx_descriptor_dump(port_id, queue_id, offset, num,
1927 : : stdout);
1928 : 0 : if (ret < 0)
1929 : 0 : fprintf(stderr, "Error dumping ethdev Rx descriptor: %s\n",
1930 : : strerror(-ret));
1931 : 0 : }
1932 : :
1933 : : static void
1934 : 0 : nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
1935 : : {
1936 : 0 : uint16_t queue_id = desc->queue_id;
1937 : 0 : uint16_t offset = desc->offset;
1938 : 0 : uint16_t num = desc->num;
1939 : : int ret;
1940 : :
1941 : : snprintf(bdr_str, MAX_STRING_LEN, " show - Tx descriptor ");
1942 : : STATS_BDR_STR(10, bdr_str);
1943 : :
1944 : 0 : printf("Dump ethdev Tx descriptor for port %u, queue %u, offset %u, num %u\n",
1945 : : port_id, queue_id, offset, num);
1946 : :
1947 : 0 : ret = rte_eth_tx_descriptor_dump(port_id, queue_id, offset, num,
1948 : : stdout);
1949 : 0 : if (ret < 0)
1950 : 0 : fprintf(stderr, "Error dumping ethdev Tx descriptor: %s\n",
1951 : : strerror(-ret));
1952 : 0 : }
1953 : :
1954 : : static void
1955 : 0 : xstats_display(uint8_t dev_id,
1956 : : enum rte_event_dev_xstats_mode mode,
1957 : : uint8_t queue_port_id)
1958 : : {
1959 : : int ret;
1960 : : struct rte_event_dev_xstats_name *xstats_names;
1961 : : uint64_t *ids;
1962 : : uint64_t *values;
1963 : : int size;
1964 : : int i;
1965 : :
1966 : 0 : size = rte_event_dev_xstats_names_get(dev_id,
1967 : : mode,
1968 : : queue_port_id,
1969 : : NULL, /* names */
1970 : : NULL, /* ids */
1971 : : 0); /* num */
1972 : :
1973 : 0 : if (size < 0)
1974 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
1975 : :
1976 : 0 : if (size == 0) {
1977 : : printf(
1978 : : "No stats available for this item, mode=%d, queue_port_id=%d\n",
1979 : : mode, queue_port_id);
1980 : 0 : return;
1981 : : }
1982 : :
1983 : : /* Get memory to hold stat names, IDs, and values */
1984 : 0 : xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
1985 : 0 : ids = malloc(sizeof(unsigned int) * size);
1986 : :
1987 : 0 : if (!xstats_names || !ids)
1988 : 0 : rte_panic("unable to alloc memory for stats retrieval\n");
1989 : :
1990 : 0 : ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
1991 : : xstats_names, ids,
1992 : : (unsigned int)size);
1993 : 0 : if (ret != size)
1994 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
1995 : :
1996 : 0 : values = malloc(sizeof(uint64_t) * size);
1997 : 0 : if (!values)
1998 : 0 : rte_panic("unable to alloc memory for stats retrieval\n");
1999 : :
2000 : 0 : ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
2001 : : ids, values, size);
2002 : :
2003 : 0 : if (ret != size)
2004 : 0 : rte_panic("rte_event_dev_xstats_get err %d\n", ret);
2005 : :
2006 : 0 : for (i = 0; i < size; i++) {
2007 : 0 : printf("id %"PRIu64" %s = %"PRIu64"\n",
2008 : 0 : ids[i], &xstats_names[i].name[0], values[i]);
2009 : : }
2010 : :
2011 : 0 : free(values);
2012 : 0 : free(xstats_names);
2013 : 0 : free(ids);
2014 : :
2015 : : }
2016 : :
2017 : : static void
2018 : 0 : xstats_reset(uint8_t dev_id,
2019 : : enum rte_event_dev_xstats_mode mode,
2020 : : uint8_t queue_port_id)
2021 : : {
2022 : : int ret;
2023 : : struct rte_event_dev_xstats_name *xstats_names;
2024 : : uint64_t *ids;
2025 : : int size;
2026 : :
2027 : 0 : size = rte_event_dev_xstats_names_get(dev_id,
2028 : : mode,
2029 : : queue_port_id,
2030 : : NULL, /* names */
2031 : : NULL, /* ids */
2032 : : 0); /* num */
2033 : :
2034 : 0 : if (size < 0)
2035 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
2036 : :
2037 : 0 : if (size == 0) {
2038 : : printf(
2039 : : "No stats available for this item, mode=%d, queue_port_id=%d\n",
2040 : : mode, queue_port_id);
2041 : 0 : return;
2042 : : }
2043 : :
2044 : : /* Get memory to hold stat names, IDs, and values */
2045 : 0 : xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
2046 : 0 : ids = malloc(sizeof(unsigned int) * size);
2047 : :
2048 : 0 : if (!xstats_names || !ids)
2049 : 0 : rte_panic("unable to alloc memory for stats retrieval\n");
2050 : :
2051 : 0 : ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
2052 : : xstats_names, ids,
2053 : : (unsigned int)size);
2054 : 0 : if (ret != size)
2055 : 0 : rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
2056 : :
2057 : 0 : rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
2058 : : ids, size);
2059 : :
2060 : 0 : free(xstats_names);
2061 : 0 : free(ids);
2062 : :
2063 : : }
2064 : :
2065 : : static unsigned int
2066 : 0 : eventdev_xstats(void)
2067 : : {
2068 : : unsigned int count = 0;
2069 : : int i, j;
2070 : :
2071 : 0 : for (i = 0; i < rte_event_dev_count(); i++) {
2072 : :
2073 : 0 : if (eventdev_var[i].dump_xstats) {
2074 : 0 : ++count;
2075 : 0 : int ret = rte_event_dev_dump(i, stdout);
2076 : :
2077 : 0 : if (ret)
2078 : 0 : rte_panic("dump failed with err=%d\n", ret);
2079 : : }
2080 : :
2081 : 0 : if (eventdev_var[i].shw_device_xstats == 1) {
2082 : 0 : ++count;
2083 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
2084 : :
2085 : 0 : if (eventdev_var[i].reset_xstats == 1)
2086 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
2087 : : }
2088 : :
2089 : 0 : if (eventdev_var[i].shw_all_ports == 1) {
2090 : 0 : ++count;
2091 : 0 : for (j = 0; j < MAX_PORTS_QUEUES; j++) {
2092 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
2093 : :
2094 : 0 : if (eventdev_var[i].reset_xstats == 1)
2095 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
2096 : : }
2097 : : } else {
2098 : 0 : if (eventdev_var[i].num_ports > 0)
2099 : 0 : ++count;
2100 : 0 : for (j = 0; j < eventdev_var[i].num_ports; j++) {
2101 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
2102 : 0 : eventdev_var[i].ports[j]);
2103 : :
2104 : 0 : if (eventdev_var[i].reset_xstats == 1)
2105 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
2106 : 0 : eventdev_var[i].ports[j]);
2107 : : }
2108 : : }
2109 : :
2110 : 0 : if (eventdev_var[i].shw_all_queues == 1) {
2111 : 0 : ++count;
2112 : 0 : for (j = 0; j < MAX_PORTS_QUEUES; j++) {
2113 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
2114 : :
2115 : 0 : if (eventdev_var[i].reset_xstats == 1)
2116 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
2117 : : }
2118 : : } else {
2119 : 0 : if (eventdev_var[i].num_queues > 0)
2120 : 0 : ++count;
2121 : 0 : for (j = 0; j < eventdev_var[i].num_queues; j++) {
2122 : 0 : xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
2123 : 0 : eventdev_var[i].queues[j]);
2124 : :
2125 : 0 : if (eventdev_var[i].reset_xstats == 1)
2126 : 0 : xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
2127 : 0 : eventdev_var[i].queues[j]);
2128 : : }
2129 : : }
2130 : : }
2131 : :
2132 : 0 : return count;
2133 : : }
2134 : :
2135 : : int
2136 : 0 : main(int argc, char **argv)
2137 : 0 : {
2138 : : int ret;
2139 : : int i;
2140 : 0 : char c_flag[] = "-c1";
2141 : 0 : char n_flag[] = "-n4";
2142 : 0 : char mp_flag[] = "--proc-type=secondary";
2143 : 0 : char log_flag[] = "--log-level=6";
2144 : 0 : char *argp[argc + 4];
2145 : : uint16_t nb_ports;
2146 : :
2147 : : /* preparse app arguments */
2148 : 0 : ret = proc_info_preparse_args(argc, argv);
2149 : 0 : if (ret < 0) {
2150 : : printf("Failed to parse arguments\n");
2151 : 0 : return -1;
2152 : : }
2153 : :
2154 : 0 : argp[0] = argv[0];
2155 : 0 : argp[1] = c_flag;
2156 : 0 : argp[2] = n_flag;
2157 : 0 : argp[3] = mp_flag;
2158 : 0 : argp[4] = log_flag;
2159 : :
2160 : 0 : for (i = 1; i < argc; i++)
2161 : 0 : argp[i + 4] = argv[i];
2162 : :
2163 : : argc += 4;
2164 : :
2165 : 0 : ret = rte_eal_init(argc, argp);
2166 : 0 : if (ret < 0)
2167 : 0 : rte_panic("Cannot init EAL\n");
2168 : :
2169 : 0 : argc -= ret;
2170 : 0 : argv += ret - 4;
2171 : :
2172 : 0 : if (!rte_eal_primary_proc_alive(NULL))
2173 : 0 : rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n");
2174 : :
2175 : : /* parse app arguments */
2176 : 0 : ret = proc_info_parse_args(argc, argv);
2177 : 0 : if (ret < 0)
2178 : 0 : rte_exit(EXIT_FAILURE, "Invalid argument\n");
2179 : :
2180 : 0 : if (mem_info) {
2181 : 0 : meminfo_display();
2182 : 0 : goto cleanup;
2183 : : }
2184 : :
2185 : 0 : if (eventdev_xstats() > 0)
2186 : 0 : goto cleanup;
2187 : :
2188 : 0 : nb_ports = rte_eth_dev_count_avail();
2189 : 0 : if (nb_ports == 0)
2190 : 0 : rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
2191 : :
2192 : : /* If no port mask was specified, then show all non-owned ports */
2193 : 0 : if (enabled_port_mask == 0) {
2194 : 0 : RTE_ETH_FOREACH_DEV(i)
2195 : 0 : enabled_port_mask |= 1ul << i;
2196 : : }
2197 : :
2198 : 0 : for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
2199 : :
2200 : : /* Skip if port is not in mask */
2201 : 0 : if ((enabled_port_mask & (1ul << i)) == 0)
2202 : 0 : continue;
2203 : :
2204 : : /* Skip if port is unused */
2205 : 0 : if (!rte_eth_dev_is_valid_port(i))
2206 : 0 : continue;
2207 : :
2208 : 0 : if (enable_stats)
2209 : 0 : nic_stats_display(i);
2210 : 0 : else if (enable_xstats)
2211 : 0 : nic_xstats_display(i);
2212 : 0 : else if (reset_stats)
2213 : 0 : nic_stats_clear(i);
2214 : 0 : else if (reset_xstats)
2215 : 0 : nic_xstats_clear(i);
2216 : 0 : else if (enable_xstats_name)
2217 : 0 : nic_xstats_by_name_display(i, xstats_name);
2218 : 0 : else if (nb_xstats_ids > 0)
2219 : 0 : nic_xstats_by_ids_display(i, xstats_ids,
2220 : : nb_xstats_ids);
2221 : : #ifdef RTE_LIB_METRICS
2222 : 0 : else if (enable_metrics)
2223 : 0 : metrics_display(i);
2224 : : #endif
2225 : :
2226 : 0 : if (enable_shw_rx_desc_dump)
2227 : 0 : nic_rx_descriptor_display(i, &rx_desc_param);
2228 : 0 : if (enable_shw_tx_desc_dump)
2229 : 0 : nic_tx_descriptor_display(i, &tx_desc_param);
2230 : : }
2231 : :
2232 : : #ifdef RTE_LIB_METRICS
2233 : : /* print port independent stats */
2234 : 0 : if (enable_metrics)
2235 : 0 : metrics_display(RTE_METRICS_GLOBAL);
2236 : : #endif
2237 : :
2238 : : /* show information for PMD */
2239 : 0 : if (enable_shw_port)
2240 : 0 : show_port();
2241 : 0 : if (enable_shw_port_priv)
2242 : 0 : show_port_private_info();
2243 : 0 : if (enable_shw_tm)
2244 : 0 : show_tm();
2245 : 0 : if (enable_shw_crypto)
2246 : 0 : show_crypto();
2247 : 0 : if (enable_shw_ring)
2248 : 0 : show_ring(ring_name);
2249 : 0 : if (enable_shw_mempool)
2250 : 0 : show_mempool(mempool_name);
2251 : 0 : if (enable_iter_mempool)
2252 : 0 : iter_mempool(mempool_iter_name);
2253 : 0 : if (enable_dump_regs)
2254 : 0 : dump_regs(dump_regs_file_prefix);
2255 : 0 : if (enable_shw_version)
2256 : 0 : show_version();
2257 : 0 : if (enable_shw_fw_version)
2258 : 0 : show_firmware_version();
2259 : 0 : if (enable_shw_rss_reta)
2260 : 0 : show_port_rss_reta_info();
2261 : 0 : if (enable_shw_module_eeprom)
2262 : 0 : show_module_eeprom_info();
2263 : :
2264 : 0 : RTE_ETH_FOREACH_DEV(i)
2265 : 0 : rte_eth_dev_close(i);
2266 : :
2267 : 0 : cleanup:
2268 : 0 : ret = rte_eal_cleanup();
2269 : 0 : if (ret)
2270 : : printf("Error from rte_eal_cleanup(), %d\n", ret);
2271 : :
2272 : : return 0;
2273 : : }
|