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