Skip to contentSkip to conversation

app/eventdev_dump: introduce eventdev_dump application

PATCH In review Timothy McDaniel 6 participants 55 messages Apr 9, 2022 – Jul 8, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/eventdev_dump: introduce eventdev_dump application

The eventdev_dump application provides an easy way to query and display xstats and pmd dump data. It should work with all eventdevs. See the help usage for the full set of supported queries.

---
 app/eventdev_dump/main.c      | 284 ++++++++++++++++++++++++++++++++++
 app/eventdev_dump/meson.build |   5 +
 app/meson.build               |   1 +
 3 files changed, 290 insertions(+)
 create mode 100644 app/eventdev_dump/main.c
 create mode 100644 app/eventdev_dump/meson.build
app/eventdev_dump/main.c new file +284 -0
new file mode 100644
index 0000000000..c80baa4c45
@@ -0,0 +1,284 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2019 Intel Corporation
+ */
+
+#include <getopt.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+
+#include <rte_eal.h>
+#include <rte_debug.h>
+#include <rte_eventdev.h>
+
+/* Note - port_queue_id in xstats APIs is 8 bits,   so we have a maximum of
+ * 256 ports and queues
+ */
+#define MAX_PORTS_QUEUES 256
+int num_ports;
+uint8_t ports[MAX_PORTS_QUEUES];
+int num_queues;
+uint8_t queues[MAX_PORTS_QUEUES];
+
+int evdev_id;
+bool do_dump;
+bool do_device_stats;
+bool do_all_ports;
+bool do_all_queues;
+bool do_reset;
+
+/* No required options */
+static struct option long_options[] = {
+	{0, 0, 0, 0}
+};
+
+static void
+usage(void)
+{
+	const char *usage_str =
+		"Usage: eventdev_dump [options]\n"
+		"Options:\n"
+		" -i <dev_id>		Eventdev id, default is 0\n"
+		" -D			Dump\n"
+		" -P			Get port stats for all ports\n"
+		" -p <port num>		Get port stats for specified port\n"
+		" -Q			Get queue stats for all queues\n"
+		" -q <queue num>	Get queue stats for specified queue\n"
+		" -r			Reset stats after reading them\n"
+		"\n";
+
+	printf("%s\n", usage_str);
+	exit(1);
+}
+
+static void
+parse_app_args(int argc, char **argv)
+{
+	/* Parse cli options*/
+	int option_index;
+	int c;
+	opterr = 0;
+
+	for (;;) {
+		c = getopt_long(argc, argv, "dDi:p:Pq:Qr", long_options,
+				&option_index);
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 'd':
+			do_device_stats = true;
+			break;
+		case 'D':
+			do_dump = true;
+			break;
+		case 'i':
+			evdev_id = atoi(optarg);
+			break;
+		case 'p':
+			ports[num_ports] = atoi(optarg);
+			num_ports++;
+			break;
+		case 'P':
+			do_all_ports = true;
+			break;
+		case 'q':
+			queues[num_queues] = atoi(optarg);
+			num_queues++;
+			break;
+		case 'Q':
+			do_all_queues = true;
+			break;
+		case 'r':
+			do_reset = true;
+			break;
+		default:
+			usage();
+		}
+	}
+}
+
+static int
+dump_all(int evdev_id)
+{
+	int ret = 0;
+
+	ret = rte_event_dev_dump(evdev_id, stdout);
+	return ret;
+}
+
+static void
+get_stats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	unsigned int *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id (%u) %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_stats(bool reset)
+{
+	int i;
+
+	if (do_device_stats) {
+		get_stats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (do_all_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (do_all_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
+int
+main(int argc, char **argv)
+{
+	int diag;
+	int ret;
+	int i;
+	char c_flag[] = "-c1";
+	char n_flag[] = "-n4";
+	char mp_flag[] = "--proc-type=secondary";
+	char *argp[argc + 3];
+
+	argp[0] = argv[0];
+	argp[1] = c_flag;
+	argp[2] = n_flag;
+	argp[3] = mp_flag;
+
+	for (i = 1; i < argc; i++)
+		argp[i + 3] = argv[i];
+
+	argc += 3;
+
+	diag = rte_eal_init(argc, argp);
+	if (diag < 0)
+		rte_panic("Cannot init EAL\n");
+
+	argc -= diag;
+	argv += (diag - 3);
+
+	/* Parse cli options*/
+	parse_app_args(argc, argv);
+
+	const uint8_t ndevs = rte_event_dev_count();
+	if (ndevs == 0)
+		rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+	if (ndevs > 1)
+		printf("Warning: More than one event dev, but using idx 0\n");
+
+	if (do_dump) {
+		ret = dump_all(evdev_id);
+		if (ret)
+			rte_panic("dump failed with err=%d\n", ret);
+	}
+
+	/* Get and output any stats requested on the command line */
+	process_stats(false);
+
+	/* Reset the stats we just output? */
+	if (do_reset)
+		process_stats(true);
+
+	return 0;
+}
app/eventdev_dump/meson.build new file +5 -0
new file mode 100644
index 0000000000..70d7db52d1
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation
+
+sources = files('main.c')
+deps += ['eventdev']
app/meson.build +1 -0
index 93d8c15032..06aecefca3 100644
@@ -18,6 +18,7 @@ apps = [
         'test-pmd',
         'test-regex',
         'test-sad',
+	'eventdev_dump',
 ]
 
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Timothy McDaniel

The eventdev_dump application provides an easy way to query and display xstats and pmd dump data. It should work with all eventdevs. See the help usage for the full set of supported queries.

+ [email protected], [email protected]
Why add another app? Please extend app/proc-info/ which does the same thing for ethdev so that we can reuse parsing and adapter info if needed.

#2 lore raw
Quoted 19 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Sunday, April 10, 2022 1:49 AM
To: McDaniel, Timothy <[email protected]>; Maryam Tahhan <[email protected]>; Pattan, Reshma <[email protected]>
Cc: Jerin Jacob <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [PATCH] app/eventdev_dump: introduce eventdev_dump application

Quoted 5 lines · Timothy McDaniel

The eventdev_dump application provides an easy way to query and display xstats and pmd dump data. It should work with all eventdevs. See the help usage for the full set of supported queries.

Quoted 4 lines

+ [email protected], [email protected]
Why add another app? Please extend app/proc-info/ which does the same thing for ethdev so that we can reuse parsing and adapter info if needed.

Thanks for the feedback, Jerin. That sounds like a good idea. I'll take a look at that.

Tim

#3 lore raw

PATCH v2 1/1 app/procinfo: display eventdev xstats for PMD data

In reply to Timothy McDaniel

This commit extends proc-info application to display xstats and PMD dump data for the eventdev devices.

New command line arguments are introduced to display stats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
dpdk-proc-info -- --edev-stats-enable --edev-port=1

edev-stats-enable: This parameters enables proc-info to display xstats for eventdev devices. If the parameter is enabled through proc-info command line, proc-info will only dump event_dev data and exit.
Users should not enable this flag if they desire to dump other proc-info data suc as Rx/Tx descriptor dump. More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 208 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  45 ++++++-
 3 files changed, 252 insertions(+), 3 deletions(-)
app/proc-info/main.c +207 -1
index 53e852a07c..25b36205d0 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,19 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_eventdev_stats;
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev;
+static uint32_t enable_eventdev_reset_stats;
+static uint32_t enable_shw_eventdev_device_stats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +191,15 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --edev-stats-enable to enable stats for all event_dev queues, ports, device etc;\n"
+		"  --all-edev-queues to get stats for all event_dev queues;\n"
+		"  --edev-queue=queue_num to get queue stats for specified queue;\n"
+		"  --all-edev-ports to get stats for all event_dev ports;\n"
+		"  --edev-port=port_num to get queue stats for specified port;\n"
+		"  --edev-dump to dump all event_dev stats;\n"
+		"  --edev-reset to reset event_dev stats after reading;\n"
+		"  --edev-device-stats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +329,14 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"edev-stats-enable", 0, NULL, 0},
+		{"all-edev-queues", 0, NULL, 0},
+		{"edev-queue", required_argument, NULL, 0},
+		{"all-edev-ports", 0, NULL, 0},
+		{"edev-port", required_argument, NULL, 0},
+		{"edev-dump", 0, NULL, 0},
+		{"edev-reset", 0, NULL, 0},
+		{"edev-device-stats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +420,33 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-stats-enable", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-queues", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_queues = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-ports", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_ports = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-dump", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-device-stats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-queue", MAX_LONG_OPT_SZ)) {
+				queues[num_queues] = atoi(optarg);
+				num_queues++;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-port", MAX_LONG_OPT_SZ)) {
+				ports[num_ports] = atoi(optarg);
+				num_ports++;
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1806,126 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+get_eventdev_stats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_stats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_stats) {
+		get_eventdev_stats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1976,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (enable_eventdev_stats) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_stats(false);
+
+		if (enable_eventdev_reset_stats)
+			process_eventdev_stats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +44 -1

57 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

PATCH v3 1/1 app/procinfo: display eventdev xstats for PMD data

In reply to Timothy McDaniel

This commit extends proc-info application to display xstats and PMD dump data for the eventdev devices.

New command line arguments are introduced to display stats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
dpdk-proc-info -- --edev-stats-enable --edev-port=1

edev-stats-enable: This parameters enables proc-info to display xstats for eventdev devices. If the parameter is enabled through proc-info command line, proc-info will only dump event_dev data and exit.
Users should not enable this flag if they desire to dump other proc-info data suc as Rx/Tx descriptor dump. More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 208 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  42 ++++++-
 3 files changed, 249 insertions(+), 3 deletions(-)
app/proc-info/main.c +207 -1
index 53e852a07c..25b36205d0 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,19 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_eventdev_stats;
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev;
+static uint32_t enable_eventdev_reset_stats;
+static uint32_t enable_shw_eventdev_device_stats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +191,15 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --edev-stats-enable to enable stats for all event_dev queues, ports, device etc;\n"
+		"  --all-edev-queues to get stats for all event_dev queues;\n"
+		"  --edev-queue=queue_num to get queue stats for specified queue;\n"
+		"  --all-edev-ports to get stats for all event_dev ports;\n"
+		"  --edev-port=port_num to get queue stats for specified port;\n"
+		"  --edev-dump to dump all event_dev stats;\n"
+		"  --edev-reset to reset event_dev stats after reading;\n"
+		"  --edev-device-stats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +329,14 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"edev-stats-enable", 0, NULL, 0},
+		{"all-edev-queues", 0, NULL, 0},
+		{"edev-queue", required_argument, NULL, 0},
+		{"all-edev-ports", 0, NULL, 0},
+		{"edev-port", required_argument, NULL, 0},
+		{"edev-dump", 0, NULL, 0},
+		{"edev-reset", 0, NULL, 0},
+		{"edev-device-stats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +420,33 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-stats-enable", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-queues", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_queues = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-ports", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_ports = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-dump", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-device-stats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-queue", MAX_LONG_OPT_SZ)) {
+				queues[num_queues] = atoi(optarg);
+				num_queues++;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-port", MAX_LONG_OPT_SZ)) {
+				ports[num_ports] = atoi(optarg);
+				num_ports++;
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1806,126 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+get_eventdev_stats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_stats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_stats) {
+		get_eventdev_stats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1976,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (enable_eventdev_stats) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_stats(false);
+
+		if (enable_eventdev_reset_stats)
+			process_eventdev_stats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +41 -1

54 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

app/proc-info/main.c nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc) · line 1849

Quoted 11 lines · On Mon, 6 Feb 2023 17:05:05 -0600 Abdullah Sevincer…
app/proc-info/main.c +11 -0
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");

You might want to use calloc() here.

Seems like lots of extra blank lines.

#6 lore raw

RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Thanks Stephen,
I will remove extra line there.

Instead malloc using of calloc is required or just suggestion?
I can see allocation is done in same way with malloc in lib\eventdev\rte_eventdev.c (reference to eventdev_build_telemetry_data function). I will keep malloc as it is if there is no opposition.

Thanks,
Abdullah.

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, February 6, 2023 4:22 PM
To: Sevincer, Abdullah <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

app/proc-info/main.c nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc) · line 1849

Quoted 11 lines · On Mon, 6 Feb 2023 17:05:05 -0600 Abdullah Sevincer…
app/proc-info/main.c +11 -0
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");

You might want to use calloc() here.

Seems like lots of extra blank lines.

#7 lore raw

RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Hi folks,

Any chance to look at this commit? Any other feedback before I push V6? (will remove extra line there below in the commit)

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>
Sent: Sunday, February 12, 2023 11:44 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Thanks Stephen,
I will remove extra line there.

Instead malloc using of calloc is required or just suggestion?
I can see allocation is done in same way with malloc in lib\eventdev\rte_eventdev.c (reference to eventdev_build_telemetry_data function). I will keep malloc as it is if there is no opposition.

Thanks,
Abdullah.

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Monday, February 6, 2023 4:22 PM
To: Sevincer, Abdullah <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

app/proc-info/main.c nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc) · line 1849

Quoted 11 lines · On Mon, 6 Feb 2023 17:05:05 -0600 Abdullah Sevincer…
app/proc-info/main.c +11 -0
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");

You might want to use calloc() here.

Seems like lots of extra blank lines.

#8 lore raw

Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Quoted 6 lines · Abdullah

From: Sevincer, Abdullah <[email protected]>
Sent: Sunday, February 12, 2023 11:44 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Quoted 6 lines

Thanks Stephen,
I will remove extra line there.

Instead malloc using of calloc is required or just suggestion?
I can see allocation is done in same way with malloc in lib\eventdev\rte_eventdev.c (reference to eventdev_build_telemetry_data function). I will keep malloc as it is if there is no opposition.

It doesn't matter much if you use malloc vs calloc.
But there are some static analysis tools that might look at calloc as way to determine number of elememts for later array checks.

Also, the kernel checkpatch warns when kmalloc is used but kcalloc or kmalloc_array could be used instead. That is Linux kernel specific but same idea applies.

#9 lore raw

RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Got it. Looking at forums and made some reading, like you said it does not matter much. I will keep consistency with other call methods so keep malloc.

I will push another patch removing extra line.

Thanks.

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, February 17, 2023 8:33 AM
To: Sevincer, Abdullah <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Quoted 7 lines · Abdullah

From: Sevincer, Abdullah <[email protected]>
Sent: Sunday, February 12, 2023 11:44 AM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

Quoted 6 lines

Thanks Stephen,
I will remove extra line there.

Instead malloc using of calloc is required or just suggestion?
I can see allocation is done in same way with malloc in lib\eventdev\rte_eventdev.c (reference to eventdev_build_telemetry_data function). I will keep malloc as it is if there is no opposition.

It doesn't matter much if you use malloc vs calloc.
But there are some static analysis tools that might look at calloc as way to determine number of elememts for later array checks.

Also, the kernel checkpatch warns when kmalloc is used but kcalloc or kmalloc_array could be used instead. That is Linux kernel specific but same idea applies.

#10 lore raw

PATCH v4 1/1 app/procinfo: display eventdev xstats for PMD data

In reply to Timothy McDaniel

This commit extends proc-info application to display xstats and PMD dump data for the eventdev devices.

New command line arguments are introduced to display stats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
dpdk-proc-info -- --edev-stats-enable --edev-port=1

edev-stats-enable: This parameters enables proc-info to display xstats for eventdev devices. If the parameter is enabled through proc-info command line, proc-info will only dump event_dev data and exit.
Users should not enable this flag if they desire to dump other proc-info data suc as Rx/Tx descriptor dump. More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 208 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  42 ++++++-
 3 files changed, 249 insertions(+), 3 deletions(-)
app/proc-info/main.c +207 -1
index 53e852a07c..25b36205d0 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,19 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_eventdev_stats;
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev;
+static uint32_t enable_eventdev_reset_stats;
+static uint32_t enable_shw_eventdev_device_stats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +191,15 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --edev-stats-enable to enable stats for all event_dev queues, ports, device etc;\n"
+		"  --all-edev-queues to get stats for all event_dev queues;\n"
+		"  --edev-queue=queue_num to get queue stats for specified queue;\n"
+		"  --all-edev-ports to get stats for all event_dev ports;\n"
+		"  --edev-port=port_num to get queue stats for specified port;\n"
+		"  --edev-dump to dump all event_dev stats;\n"
+		"  --edev-reset to reset event_dev stats after reading;\n"
+		"  --edev-device-stats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +329,14 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"edev-stats-enable", 0, NULL, 0},
+		{"all-edev-queues", 0, NULL, 0},
+		{"edev-queue", required_argument, NULL, 0},
+		{"all-edev-ports", 0, NULL, 0},
+		{"edev-port", required_argument, NULL, 0},
+		{"edev-dump", 0, NULL, 0},
+		{"edev-reset", 0, NULL, 0},
+		{"edev-device-stats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +420,33 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-stats-enable", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-queues", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_queues = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-ports", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_ports = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-dump", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-device-stats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-queue", MAX_LONG_OPT_SZ)) {
+				queues[num_queues] = atoi(optarg);
+				num_queues++;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-port", MAX_LONG_OPT_SZ)) {
+				ports[num_ports] = atoi(optarg);
+				num_ports++;
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1806,126 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+get_eventdev_stats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_stats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_stats) {
+		get_eventdev_stats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1976,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (enable_eventdev_stats) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_stats(false);
+
+		if (enable_eventdev_reset_stats)
+			process_eventdev_stats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +41 -1

54 lines not on this page · raw message

Signature · 1 line
2.25.1
#11 lore raw

PATCH v5 1/1 app/procinfo: display eventdev xstats for PMD data

In reply to Timothy McDaniel

This commit extends proc-info application to display xstats and PMD dump data for the eventdev devices.

New command line arguments are introduced to display stats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
dpdk-proc-info -- --edev-stats-enable --edev-port=1

edev-stats-enable: This parameters enables proc-info to display xstats for eventdev devices. If the parameter is enabled through proc-info command line, proc-info will only dump event_dev data and exit.
Users should not enable this flag if they desire to dump other proc-info data suc as Rx/Tx descriptor dump. More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 208 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  42 ++++++-
 3 files changed, 249 insertions(+), 3 deletions(-)
app/proc-info/main.c +207 -1
index 53e852a07c..25b36205d0 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,19 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_eventdev_stats;
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev;
+static uint32_t enable_eventdev_reset_stats;
+static uint32_t enable_shw_eventdev_device_stats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +191,15 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --edev-stats-enable to enable stats for all event_dev queues, ports, device etc;\n"
+		"  --all-edev-queues to get stats for all event_dev queues;\n"
+		"  --edev-queue=queue_num to get queue stats for specified queue;\n"
+		"  --all-edev-ports to get stats for all event_dev ports;\n"
+		"  --edev-port=port_num to get queue stats for specified port;\n"
+		"  --edev-dump to dump all event_dev stats;\n"
+		"  --edev-reset to reset event_dev stats after reading;\n"
+		"  --edev-device-stats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +329,14 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"edev-stats-enable", 0, NULL, 0},
+		{"all-edev-queues", 0, NULL, 0},
+		{"edev-queue", required_argument, NULL, 0},
+		{"all-edev-ports", 0, NULL, 0},
+		{"edev-port", required_argument, NULL, 0},
+		{"edev-dump", 0, NULL, 0},
+		{"edev-reset", 0, NULL, 0},
+		{"edev-device-stats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +420,33 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-stats-enable", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-queues", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_queues = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-ports", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_ports = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-dump", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-device-stats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-queue", MAX_LONG_OPT_SZ)) {
+				queues[num_queues] = atoi(optarg);
+				num_queues++;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-port", MAX_LONG_OPT_SZ)) {
+				ports[num_ports] = atoi(optarg);
+				num_ports++;
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1806,126 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+get_eventdev_stats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_stats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_stats) {
+		get_eventdev_stats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1976,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (enable_eventdev_stats) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_stats(false);
+
+		if (enable_eventdev_reset_stats)
+			process_eventdev_stats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +41 -1

54 lines not on this page · raw message

Signature · 1 line
2.25.1
#12 lore raw

PATCH v6 1/1 app/procinfo: display eventdev xstats for PMD data

In reply to Timothy McDaniel

This commit extends proc-info application to display xstats and PMD dump data for the eventdev devices.

New command line arguments are introduced to display stats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
dpdk-proc-info -- --edev-stats-enable --edev-port=1

edev-stats-enable: This parameters enables proc-info to display xstats for eventdev devices. If the parameter is enabled through proc-info command line, proc-info will only dump event_dev data and exit.
Users should not enable this flag if they desire to dump other proc-info data suc as Rx/Tx descriptor dump. More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 207 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  42 ++++++-
 3 files changed, 248 insertions(+), 3 deletions(-)
app/proc-info/main.c +206 -1
index 53e852a07c..00bcd35fad 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,19 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_eventdev_stats;
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev;
+static uint32_t enable_eventdev_reset_stats;
+static uint32_t enable_shw_eventdev_device_stats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +191,15 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --edev-stats-enable to enable stats for all event_dev queues, ports, device etc;\n"
+		"  --all-edev-queues to get stats for all event_dev queues;\n"
+		"  --edev-queue=queue_num to get queue stats for specified queue;\n"
+		"  --all-edev-ports to get stats for all event_dev ports;\n"
+		"  --edev-port=port_num to get queue stats for specified port;\n"
+		"  --edev-dump to dump all event_dev stats;\n"
+		"  --edev-reset to reset event_dev stats after reading;\n"
+		"  --edev-device-stats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +329,14 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"edev-stats-enable", 0, NULL, 0},
+		{"all-edev-queues", 0, NULL, 0},
+		{"edev-queue", required_argument, NULL, 0},
+		{"all-edev-ports", 0, NULL, 0},
+		{"edev-port", required_argument, NULL, 0},
+		{"edev-dump", 0, NULL, 0},
+		{"edev-reset", 0, NULL, 0},
+		{"edev-device-stats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +420,33 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-stats-enable", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-queues", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_queues = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"all-edev-ports", MAX_LONG_OPT_SZ)) {
+				enable_shw_all_eventdev_ports = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-dump", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-device-stats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_stats = 1;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-queue", MAX_LONG_OPT_SZ)) {
+				queues[num_queues] = atoi(optarg);
+				num_queues++;
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-port", MAX_LONG_OPT_SZ)) {
+				ports[num_ports] = atoi(optarg);
+				num_ports++;
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1806,125 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+get_eventdev_stats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_stats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_stats) {
+		get_eventdev_stats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_stats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1975,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (enable_eventdev_stats) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_stats(false);
+
+		if (enable_eventdev_reset_stats)
+			process_eventdev_stats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +41 -1

54 lines not on this page · raw message

Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

Quoted 20 lines · Abdullah Sevincer

This commit extends proc-info application to display xstats and PMD dump data for the eventdev devices.

New command line arguments are introduced to display stats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
dpdk-proc-info -- --edev-stats-enable --edev-port=1

edev-stats-enable: This parameters enables proc-info to display xstats for eventdev devices. If the parameter is enabled through proc-info command line, proc-info will only dump event_dev data and exit.
Users should not enable this flag if they desire to dump other proc-info data suc as Rx/Tx descriptor dump. More information can be found in proc-info app doc.

Quoted 1 line

Please CC the maintainers.

@[email protected] @[email protected]
Please review

Quoted 347 lines
---
 app/proc-info/main.c           | 207 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  42 ++++++-
 3 files changed, 248 insertions(+), 3 deletions(-)
app/proc-info/main.c +206 -1
index 53e852a07c..00bcd35fad 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,19 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_eventdev_stats;
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev;
+static uint32_t enable_eventdev_reset_stats;
+static uint32_t enable_shw_eventdev_device_stats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +191,15 @@ proc_info_usage(const char *prgname)
                        "offset: The offset of the descriptor starting from tail. "
                        "num: The number of the descriptors to dump.\n"
                "  --iter-mempool=name: iterate mempool elements to display content\n"
-               "  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+               "  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+               "  --edev-stats-enable to enable stats for all event_dev queues, ports, device etc;\n"
+               "  --all-edev-queues to get stats for all event_dev queues;\n"
+               "  --edev-queue=queue_num to get queue stats for specified queue;\n"
+               "  --all-edev-ports to get stats for all event_dev ports;\n"
+               "  --edev-port=port_num to get queue stats for specified port;\n"
+               "  --edev-dump to dump all event_dev stats;\n"
+               "  --edev-reset to reset event_dev stats after reading;\n"
+               "  --edev-device-stats to get event_dev device stats;\n",
                prgname);
 }
 
@@ -302,6 +329,14 @@ proc_info_parse_args(int argc, char **argv)
                {"show-module-eeprom", 0, NULL, 0},
                {"show-rx-descriptor", required_argument, NULL, 1},
                {"show-tx-descriptor", required_argument, NULL, 1},
+               {"edev-stats-enable", 0, NULL, 0},
+               {"all-edev-queues", 0, NULL, 0},
+               {"edev-queue", required_argument, NULL, 0},
+               {"all-edev-ports", 0, NULL, 0},
+               {"edev-port", required_argument, NULL, 0},
+               {"edev-dump", 0, NULL, 0},
+               {"edev-reset", 0, NULL, 0},
+               {"edev-device-stats", 0, NULL, 0},
                {NULL, 0, 0, 0}
        };
 
@@ -385,6 +420,33 @@ proc_info_parse_args(int argc, char **argv)
                        else if (!strncmp(long_option[option_index].name,
                                        "show-module-eeprom", MAX_LONG_OPT_SZ))
                                enable_shw_module_eeprom = 1;
+                       else if (!strncmp(long_option[option_index].name,
+                                       "edev-stats-enable", MAX_LONG_OPT_SZ)) {
+                               enable_eventdev_stats = 1;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "all-edev-queues", MAX_LONG_OPT_SZ)) {
+                               enable_shw_all_eventdev_queues = 1;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "all-edev-ports", MAX_LONG_OPT_SZ)) {
+                               enable_shw_all_eventdev_ports = 1;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "edev-dump", MAX_LONG_OPT_SZ)) {
+                               enable_dump_eventdev = 1;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "edev-reset", MAX_LONG_OPT_SZ)) {
+                               enable_eventdev_reset_stats = 1;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "edev-device-stats", MAX_LONG_OPT_SZ)) {
+                               enable_shw_eventdev_device_stats = 1;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "edev-queue", MAX_LONG_OPT_SZ)) {
+                               queues[num_queues] = atoi(optarg);
+                               num_queues++;
+                       } else if (!strncmp(long_option[option_index].name,
+                                       "edev-port", MAX_LONG_OPT_SZ)) {
+                               ports[num_ports] = atoi(optarg);
+                               num_ports++;
+                       }
                        break;
                case 1:
                        /* Print xstat single value given by name*/
@@ -1744,6 +1806,125 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
                        strerror(-ret));
 }
 
+static void
+get_eventdev_stats(uint8_t dev_id,
+         enum rte_event_dev_xstats_mode mode,
+         uint8_t queue_port_id,
+         bool reset)
+{
+       int ret;
+       struct rte_event_dev_xstats_name *xstats_names;
+       uint64_t *ids;
+       unsigned int size;
+       int i;
+
+
+       /* Get amount of storage required */
+       ret = rte_event_dev_xstats_names_get(dev_id,
+                                            mode,
+                                            queue_port_id,
+                                            NULL, /* names */
+                                            NULL, /* ids */
+                                            0);   /* num */
+
+       if (ret < 0)
+               rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+       if (ret == 0) {
+               printf(
+               "No stats available for this item, mode=%d, queue_port_id=%d\n",
+                       mode, queue_port_id);
+               return;
+       }
+
+       size = (unsigned int)ret; /* number of names */
+
+       /* Get memory to hold stat names, IDs, and values */
+
+       xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+       ids = malloc(sizeof(unsigned int) * size);
+
+       if (!xstats_names || !ids)
+               rte_panic("unable to alloc memory for stats retrieval\n");
+
+       ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+                                            xstats_names, ids,
+                                            size);
+       if (ret != (int)size)
+               rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+       if (!reset) {
+               uint64_t *values;
+
+               values = malloc(sizeof(uint64_t) * size);
+               if (!values)
+                       rte_panic("unable to alloc memory for stats retrieval\n");
+
+               ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+                                              ids, values, size);
+
+               if (ret != (int)size)
+                       rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+               for (i = 0; i < (int)size; i++) {
+                       printf("id %"PRIu64"  %s = %"PRIu64"\n",
+                               ids[i], &xstats_names[i].name[0], values[i]);
+               }
+
+               free(values);
+       } else
+               rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+                                          ids, size);
+
+       free(xstats_names);
+       free(ids);
+}
+
+static void
+process_eventdev_stats(bool reset)
+{
+       int i;
+
+       if (enable_shw_eventdev_device_stats) {
+               get_eventdev_stats(evdev_id,
+                         RTE_EVENT_DEV_XSTATS_DEVICE,
+                         0,
+                         reset);
+       }
+
+       if (enable_shw_all_eventdev_ports) {
+               for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+                       get_eventdev_stats(evdev_id,
+                                 RTE_EVENT_DEV_XSTATS_PORT,
+                                 i,
+                                 reset);
+               }
+       } else {
+               for (i = 0; i < num_ports; i++) {
+                       get_eventdev_stats(evdev_id,
+                                 RTE_EVENT_DEV_XSTATS_PORT,
+                                 ports[i],
+                                 reset);
+               }
+       }
+
+       if (enable_shw_all_eventdev_queues) {
+               for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+                       get_eventdev_stats(evdev_id,
+                                 RTE_EVENT_DEV_XSTATS_QUEUE,
+                                 i,
+                                 reset);
+               }
+       } else {
+               for (i = 0; i < num_queues; i++) {
+                       get_eventdev_stats(evdev_id,
+                                 RTE_EVENT_DEV_XSTATS_QUEUE,
+                                 queues[i],
+                                 reset);
+               }
+       }
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1975,30 @@ main(int argc, char **argv)
                return 0;
        }
 
+       if (enable_eventdev_stats) {
+               const uint8_t ndevs = rte_event_dev_count();
+
+               if (ndevs == 0)
+                       rte_panic("No event devs found. Do you need"
+                         " to pass in a --vdev flag?\n");
+
+               if (ndevs > 1)
+                       printf("Warning: More than one event dev, but using idx 0\n");
+
+               if (enable_dump_eventdev) {
+                       ret = rte_event_dev_dump(evdev_id, stdout);
+                       if (ret)
+                               rte_panic("dump failed with err=%d\n", ret);
+               }
+
+               process_eventdev_stats(false);
+
+               if (enable_eventdev_reset_stats)
+                       process_eventdev_stats(true);
+
+               return 0;
+       }
+
        nb_ports = rte_eth_dev_count_avail();
        if (nb_ports == 0)
                rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +41 -2
index cf3502a8cb..59d8ff2490 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --edev-stats-enable |
+   --all-edev-queues | --edev-queue=queue_num | --all-edev-ports |
+   --edev-port=port_num | --edev-dump | --edev-reset | --edev-device-stats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,44 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--edev-stats-enable**
+The edev-stats-enable parameter enables proc-info application
+to display stats for eventdev devices. If the parameter is entered
+through proc-info application command line, proc-info application will
+only dump eventdev data and exit from the application. Hence,
+this parameter is required and a must  with other eventdev parameters
+explained below. Users should not enable this flag if they desire to dump
+other proc-info application stats such as Rx/Tx descriptor dump.
+
+**--all-edev-queues**
+The all-edev-queues parameter enables stats for all eventdev queues.
+
+**--edev-queue**
+The edev-queue parameter enables stats for specified queue.
+queue_num: The queue number to get queue stats for this specified queue.
+
+**--all-edev-ports**
+The all-edev-ports parameter enables stats for all eventdev ports.
+
+**--edev-port**
+The edev-port parameter enables stats for specified port.
+queue_num: The port number to get port stats for this specified port.
+
+**--edev-dump**
+The edev-dump parameter dumps all eventdev stats.
+
+**--edev-reset**
+The edev-reset parameter resets eventdev stats after reading.
+
+**--edev-device-stats**
+The edev-device-stats parameter displays eventdev device stats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --edev-stats-enable --edev-port=1
+
 Limitations
 -----------
 
--

2.25.1

#14 lore raw

RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

In reply to Abdullah Sevincer
Quoted 8 lines

-----Original Message-----
From: Abdullah Sevincer <[email protected]>

Subject: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

I see you are supporting evendev stats print. You can make the heading clear by removing "PMD data"

doc/guides/tools/proc_info.rst The application has a number of command line options: · line 29

Quoted 11 lines

+++ b/doc/guides/tools/proc_info.rst

doc/guides/tools/proc_info.rst +4 -1
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --edev-stats-enable |
+   --all-edev-queues | --edev-queue=queue_num | --all-edev-ports |
+   --edev-port=port_num | --edev-dump | --edev-reset |
+ --edev-device-stats]
 

On the design , I guess command line parameters can be simplified. So you can simplify the code also.

1) What is the difference between "--edev-stats-enable" and "--edev-device-stats" ?

2) You no need to have 2 parameters to specify the port info "--edev-port=port_num" and "--all-edev-ports"

3)Similarly no need to have 2 parameters to specify queue info "--all-edev-queues and --edev-queue=queue_num"

4) No need of "--edev-stats-enable".

5)You can perhaps have only 2 commands as below in place of all above commands.
In the below commands user can pass which "eventdev id" and "queue id" the stats should be displayed for.

Example:
a)show-eventdev-stats=(eventdev id, queue)

	show-eventdev-stats=(*,*)   => Display all stats for all queues of all eventdev ids
	show-eventdev-stats=(*,1)   => Display stats of queue 1of  all eventdev ids 
	show-eventdev-stats=(1,*)   => Display stats of all queues of eventdev id 1 
	show-eventdev-stats=(1,1)   => Display stats of queue1 of eventdev id 1 

b)reset-eventdev-stats=( eventdev id, queue)

Thanks,
Reshma

#15 lore raw

RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

1) What is the difference between "--edev-stats-enable" and "--edev-device-stats" ?
--edev-stats-enable enables xstats for evendev and exits from proc-info application (when this flag is enabled) after displaying xstats. It is like show mempool flag so we don't want bunch of different information is dumped to the console. The intent of the flag is distinguish dump information between eventdev and eth dev. If this flag is not passed no eventdev info will be displayed. --edev-device-stats is a flag that dumps device stats like the other flags/commands introduced with this change.

2)Too all other comments following to simplify the code:
Indeed all other commands in proc-info can be simplified but with below style we wanted easiness for user to remember commands and pass chain of commands. It is a trade of for user need to remember the format instead passing a name. I agree there is too much command in proc-info now. I will try to simplify command and code also considering something easy to remember from the users perspective.

Thanks.

-----Original Message-----
From: Pattan, Reshma <[email protected]>
Sent: Friday, March 3, 2023 2:58 AM
To: Sevincer, Abdullah <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Sevincer, Abdullah <[email protected]>
Subject: RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

Quoted 6 lines

-----Original Message-----
From: Abdullah Sevincer <[email protected]>

Subject: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

I see you are supporting evendev stats print. You can make the heading clear by removing "PMD data"

doc/guides/tools/proc_info.rst The application has a number of command line options: · line 29

Quoted 11 lines

+++ b/doc/guides/tools/proc_info.rst

doc/guides/tools/proc_info.rst +4 -1
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --edev-stats-enable |
+   --all-edev-queues | --edev-queue=queue_num | --all-edev-ports |
+   --edev-port=port_num | --edev-dump | --edev-reset | 
+ --edev-device-stats]
 

On the design , I guess command line parameters can be simplified. So you can simplify the code also.

1) What is the difference between "--edev-stats-enable" and "--edev-device-stats" ?

2) You no need to have 2 parameters to specify the port info "--edev-port=port_num" and "--all-edev-ports"

3)Similarly no need to have 2 parameters to specify queue info "--all-edev-queues and --edev-queue=queue_num"

4) No need of "--edev-stats-enable".

5)You can perhaps have only 2 commands as below in place of all above commands.
In the below commands user can pass which "eventdev id" and "queue id" the stats should be displayed for.

Example:
a)show-eventdev-stats=(eventdev id, queue)

	show-eventdev-stats=(*,*)   => Display all stats for all queues of all eventdev ids
	show-eventdev-stats=(*,1)   => Display stats of queue 1of  all eventdev ids 
	show-eventdev-stats=(1,*)   => Display stats of all queues of eventdev id 1 
	show-eventdev-stats=(1,1)   => Display stats of queue1 of eventdev id 1 

b)reset-eventdev-stats=( eventdev id, queue)

Thanks,
Reshma

#16 lore raw

RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data

Quoted 12 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>
1) What is the difference between "--edev-stats-enable" and "--edev-device- stats" ?
--edev-stats-enable enables xstats for evendev and exits from proc-info
application (when this flag is enabled) after displaying xstats. It is like show mempool flag so we don't want bunch of different information is dumped to the console. The intent of the flag is distinguish dump information between eventdev and eth dev. If this flag is not passed no eventdev info will be displayed.

So you are displaying xstats. I guess the naming of the commands should be renamed. Should start with "show" something like show_evdev_xtsats

Quoted 1 line

--edev-device-stats is a flag that dumps device stats like the other flags/commands introduced with this change.

Can you please clarify a little bit on which flags and commands this display? Is this like help command for eventdev commands that you have added? However this also should start with show_evdev_flags something like that.

--snip--

Quoted 10 lines

2)Too all other comments following to simplify the code:
Indeed all other commands in proc-info can be simplified but with
below style we wanted easiness for user to remember commands and pass chain of commands. It is a trade of for user need to remember the format instead passing a name. I agree there is too much command in proc-info now. I will try to simplify command and code also considering something easy to remember from the users perspective.

In my opinion I see scope for simplifying this .
if not what I have suggested earlier about command format, you can follow the other existing command format like below , to pass on the port and queue information to your eventdev commands.
Ex: --show-tx-descriptor queue_id:offset:num

---snip---

Also, please do inreply to the email , do not reply on top of the email thread.

Regards,
Reshma

#17 lore raw

PATCH v7 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 211 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  27 ++++-
 3 files changed, 237 insertions(+), 3 deletions(-)
app/proc-info/main.c +210 -1
index 53e852a07c..c004f63e2c 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,18 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev_xstats;
+static uint32_t enable_eventdev_reset_xstats;
+static uint32_t enable_shw_eventdev_device_xstats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +190,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num or * to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num or * to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats to dump all event_dev xstats;\n"
+		"  --edev-reset-xstats to reset event_dev stats after reading;\n"
+		"  --show-edev-device-xstats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +325,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", 0, NULL, 0},
+		{"edev-reset-xstats", 0, NULL, 0},
+		{"show-edev-device-xstats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +413,32 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ))
+				enable_dump_eventdev_xstats = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ))
+				enable_eventdev_reset_xstats = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ))
+				enable_shw_eventdev_device_xstats = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				if (strcmp("*", optarg) == 0) {
+					enable_shw_all_eventdev_queues = 1;
+				} else {
+					queues[num_queues] = atoi(optarg);
+					num_queues++;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				if (strcmp("*", optarg) == 0) {
+					enable_shw_all_eventdev_ports = 1;
+				} else {
+					ports[num_ports] = atoi(optarg);
+					num_ports++;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1798,137 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static bool
+show_edev_xstats(void)
+{
+	/* Check if any event dev xstats requested from command line */
+	if (enable_shw_all_eventdev_queues || enable_shw_all_eventdev_ports
+		|| enable_dump_eventdev_xstats || enable_eventdev_reset_xstats ||
+		enable_shw_eventdev_device_xstats || num_ports > 0 || num_queues > 0)
+		return true;
+
+	return false;
+}
+
+static void
+get_eventdev_xstats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_xstats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_xstats) {
+		get_eventdev_xstats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1979,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats(false);
+
+		if (enable_eventdev_reset_xstats)
+			process_eventdev_xstats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +26 -1
index cf3502a8cb..ad6d2e8aeb 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num |
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-xstats |
+   --show-edev-device-xstats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,29 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue stats for this specified queue or * for all queues.
+
+**--show-edev-port-xstats**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+queue_num: The port number to get port stats for this specified port or * for all ports.
+
+**--edev-dump-xstats**
+The edev-dump-xstats parameter dumps all eventdev stats.
+
+**--edev-reset-xstats**
+The edev-reset-xstats parameter resets eventdev stats after reading.
+
+**--show-edev-device-xstats**
+The show-edev-device-xstats parameter displays eventdev device stats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#18 lore raw

Re: [PATCH v7] app/procinfo: display eventdev xstats

app/proc-info/main.c line 53

Quoted 6 lines · On Thu, 9 Mar 2023 12:27:58 -0600 Abdullah Sevincer…
app/proc-info/main.c +5 -0
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+

There is a goal of removing the per-queue stats part in generic stats. And in the process removing that limit.

#19 lore raw

RE: [PATCH v7] app/procinfo: display eventdev xstats

From: Stephen Hemminger <[email protected]>
Sent: Thursday, March 9, 2023 12:32 PM
To: Sevincer, Abdullah <[email protected]>
Cc: [email protected]; [email protected]; Pattan, Reshma <[email protected]>
Subject: Re: [PATCH v7] app/procinfo: display eventdev xstats

Quoted 9 lines · On Thu, 9 Mar 2023 12:27:58 -0600 Abdullah Sevincer…
(quoted diff) +5 -0
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum 
+of
+ * 256 ports and queues for event_Dev  */ #define MAX_PORTS_QUEUES 
+256
+

There is a goal of removing the per-queue stats part in generic stats. And in the process removing that limit.

Thanks Stephen,

When this is expected?, if so putting per-queue stats not needed.

#20 lore raw

Re: [PATCH v7] app/procinfo: display eventdev xstats

Quoted 7 lines · Abdullah
Quoted 6 lines
(quoted diff) +5 -0
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum 
+of
+ * 256 ports and queues for event_Dev  */ #define MAX_PORTS_QUEUES 
+256
+  
Quoted 6 lines
Quoted 2 lines

There is a goal of removing the per-queue stats part in generic stats. And in the process removing that limit.

Thanks Stephen,

When this is expected?, if so putting per-queue stats not needed.

I don't think it will happen this year.

#21 lore raw

RE: [PATCH v7] app/procinfo: display eventdev xstats

Quoted 11 lines
Quoted 10 lines
(quoted diff) +5 -0
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a 
+maximum of
+ * 256 ports and queues for event_Dev  */ #define MAX_PORTS_QUEUES
+256
+  

There is a goal of removing the per-queue stats part in generic stats. And in the process removing that limit.

Quoted 6 lines

Thanks Stephen,

When this is expected?, if so putting per-queue stats not needed.

I don't think it will happen this year.

Okay, if patch is accepted and per-queue stats removed(not until next year) it will require extra work to remove all per-queue changes (not only this one though or other places the api is used). What is your suggestion?

#22 lore raw

PATCH v8 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 210 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  27 ++++-
 3 files changed, 236 insertions(+), 3 deletions(-)
app/proc-info/main.c +209 -1
index 53e852a07c..6ead43a439 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,18 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev_xstats;
+static uint32_t enable_eventdev_reset_xstats;
+static uint32_t enable_shw_eventdev_device_xstats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +190,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num or * to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num or * to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats to dump all event_dev xstats;\n"
+		"  --edev-reset-xstats to reset event_dev stats after reading;\n"
+		"  --show-edev-device-xstats to get event_dev device stats;\n",
 		prgname);
 }
 
@@ -302,6 +325,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", 0, NULL, 0},
+		{"edev-reset-xstats", 0, NULL, 0},
+		{"show-edev-device-xstats", 0, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +413,32 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ))
+				enable_dump_eventdev_xstats = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ))
+				enable_eventdev_reset_xstats = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ))
+				enable_shw_eventdev_device_xstats = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				if (strcmp("*", optarg) == 0) {
+					enable_shw_all_eventdev_queues = 1;
+				} else {
+					queues[num_queues] = atoi(optarg);
+					num_queues++;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				if (strcmp("*", optarg) == 0) {
+					enable_shw_all_eventdev_ports = 1;
+				} else {
+					ports[num_ports] = atoi(optarg);
+					num_ports++;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1798,136 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static bool
+show_edev_xstats(void)
+{
+	/* Check if any event dev xstats requested from command line */
+	if (enable_shw_all_eventdev_queues || enable_shw_all_eventdev_ports
+		|| enable_dump_eventdev_xstats || enable_eventdev_reset_xstats ||
+		enable_shw_eventdev_device_xstats || num_ports > 0 || num_queues > 0)
+		return true;
+
+	return false;
+}
+
+static void
+get_eventdev_xstats(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id,
+	  bool reset)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+	int i;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (ret == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	size = (unsigned int)ret; /* number of names */
+
+	/* Get memory to hold stat names, IDs, and values */
+
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	if (!reset) {
+		uint64_t *values;
+
+		values = malloc(sizeof(uint64_t) * size);
+		if (!values)
+			rte_panic("unable to alloc memory for stats retrieval\n");
+
+		ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					       ids, values, size);
+
+		if (ret != (int)size)
+			rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+		for (i = 0; i < (int)size; i++) {
+			printf("id %"PRIu64"  %s = %"PRIu64"\n",
+				ids[i], &xstats_names[i].name[0], values[i]);
+		}
+
+		free(values);
+	} else
+		rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+}
+
+static void
+process_eventdev_xstats(bool reset)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_xstats) {
+		get_eventdev_xstats(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0,
+			  reset);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i],
+				  reset);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i,
+				  reset);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			get_eventdev_xstats(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i],
+				  reset);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +1978,30 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using idx 0\n");
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats(false);
+
+		if (enable_eventdev_reset_xstats)
+			process_eventdev_xstats(true);
+
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +26 -1
index cf3502a8cb..ad6d2e8aeb 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num |
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-xstats |
+   --show-edev-device-xstats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,29 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue stats for this specified queue or * for all queues.
+
+**--show-edev-port-xstats**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+queue_num: The port number to get port stats for this specified port or * for all ports.
+
+**--edev-dump-xstats**
+The edev-dump-xstats parameter dumps all eventdev stats.
+
+**--edev-reset-xstats**
+The edev-reset-xstats parameter resets eventdev stats after reading.
+
+**--show-edev-device-xstats**
+The show-edev-device-xstats parameter displays eventdev device stats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#23 lore raw

RE: [PATCH v8] app/procinfo: display eventdev xstats

app/proc-info/main.c proc_info_parse_args(int argc, char **argv) · line 332

Quoted 7 lines

-----Original Message-----

 app/proc-info/main.c           | 210 ++++++++++++++++++++++++++++++++-
app/proc-info/main.c +2 -0
+		{"edev-reset-xstats", 0, NULL, 0},
+		{"show-edev-device-xstats", 0, NULL, 0},

We should support the eventdev id as argument to this command and display stats for the given eventdev id.

Quoted 10 lines
app/proc-info/main.c +9 -0
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		if (ndevs > 1)
+			printf("Warning: More than one event dev, but using

idx 0\n");

Why do we need to restrict to only eventdev 0? .I guess you should support displaying stats for any eventdev, not only the eventdev with index0.

Quoted 6 lines
doc/guides/tools/proc_info.rst +1 -0
 
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-

xstats |
+ --show-edev-device-xstats]

For "--show-evdev-device-xstats" why don't we have eventdev id as argument ? There can be more than one eventdev can exists right on the system?

Quoted 3 lines
doc/guides/tools/proc_info.rst +2 -0
+**--show-edev-queue-xstats**
+The show-edev-queue-xstats parameter enables stats for specified queue or

all queues.

Here and in below text replace "stats" to "xstats", because stats and xstats are different.

#24 lore raw

RE: [PATCH v8] app/procinfo: display eventdev xstats

From: Pattan, Reshma <[email protected]>
Sent: Wednesday, March 15, 2023 4:57 AM
To: Sevincer, Abdullah <[email protected]>; [email protected]
Cc: [email protected]
Subject: RE: [PATCH v8] app/procinfo: display eventdev xstats

->Why do we need to restrict to only eventdev 0? .I guess you should support displaying stats for any eventdev, not only the eventdev with index0. The intent is only display one eventdev in use (id being zero), displaying multiple eventdevs was not in the scope.

#25 lore raw

RE: [PATCH v8] app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

app/proc-info/main.c nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc) · line 1814

Quoted 8 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>

app/proc-info/main.c +2 -0
+static void
+get_eventdev_xstats(uint8_t dev_id,

You can separate this function (basically the code inside this function) into 3 functions, one for reset and one for display stats values.
And move the common code(stats storage calculation logic and getting stats name logic) to a another function, so you can call that function from reset and display functions.

app/proc-info/main.c main(int argc, char **argv) · line 2000

Quoted 11 lines
app/proc-info/main.c +11 -0
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats(false);
+
+		if (enable_eventdev_reset_xstats)
+			process_eventdev_xstats(true);

For easy code readability, I would say have a sperate function for reset stats, do not mix display and resets by just passing reset bool value.

Thanks,
Reshma

#26 lore raw

RE: [PATCH v8] app/procinfo: display eventdev xstats

Review

Quoted 9 lines
(quoted diff) +4 -0
+static void
+get_eventdev_xstats(uint8_t dev_id,
 
 
+You can separate this function (basically the code inside this function) into 3 functions, one for reset and one for display stats values.
+And move the common code(stats storage calculation logic and getting stats name  logic) to a another function, so you can call that function from reset and display functions.

This can be done, but we will have 2 API calls for each now, if we have this flag we will be able to reset withing one API call.

app/proc-info/main.c main(int argc, char **argv)

Quoted 13 lines
app/proc-info/main.c +12 -0
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats(false);
+
+		if (enable_eventdev_reset_xstats)
+			process_eventdev_xstats(true);
 
+For easy code readability, I would say have a sperate function for reset stats, do not mix display and resets by just passing reset bool value. 

Same for this one as above, one API call to the xstats instead of two separate calls if we use this flag.

Thanks,
Reshma

#27 lore raw

PATCH v9 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 297 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  32 +++-
 3 files changed, 328 insertions(+), 3 deletions(-)
app/proc-info/main.c +296 -1
index 53e852a07c..c6a854c993 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,18 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev_xstats;
+static uint32_t enable_eventdev_reset_xstats;
+static uint32_t enable_shw_eventdev_device_xstats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +190,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +259,41 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_queue_params(char *list)
+{
+	int queue_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_queues = 1;
+	} else if (sscanf(list, "%d:%hhu", &queue_id, &evdev_id) == 2) {
+		queues[num_queues] = queue_id;
+		num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_params(char *list)
+{
+	int port_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_ports = 1;
+	} else if (sscanf(list, "%d:%hhu", &port_id, &evdev_id) == 2) {
+		ports[num_ports] = port_id;
+		num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +360,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +448,35 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1836,187 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static bool
+show_edev_xstats(void)
+{
+	/* Check if any event dev xstats requested from command line */
+	if (enable_shw_all_eventdev_queues || enable_shw_all_eventdev_ports
+		|| enable_dump_eventdev_xstats || enable_eventdev_reset_xstats ||
+		enable_shw_eventdev_device_xstats || num_ports > 0 || num_queues > 0)
+		return true;
+
+	return false;
+}
+
+static unsigned int
+xstats_get_names_and_ids_size(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+
+	int ret;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	return (unsigned int)ret;
+
+}
+
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < (int)size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+
+static void
+process_eventdev_xstats(void)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_xstats) {
+		xstats_display(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0);
+		if (enable_eventdev_reset_xstats)
+			xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, i);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, ports[i]);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, i);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, queues[i]);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2067,28 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		/* Verify the command line options */
+		if (evdev_id >= rte_event_dev_count())
+			rte_panic("invalid event device %hhu\n", evdev_id);
+
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats();
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +31 -1
index cf3502a8cb..f0a7d37e41 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num |
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-xstats |
+   --show-edev-device-xstats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,34 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#28 lore raw

PATCH v10 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 297 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  32 +++-
 3 files changed, 328 insertions(+), 3 deletions(-)
app/proc-info/main.c +296 -1
index 53e852a07c..c6a854c993 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,18 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev_xstats;
+static uint32_t enable_eventdev_reset_xstats;
+static uint32_t enable_shw_eventdev_device_xstats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +190,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +259,41 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_queue_params(char *list)
+{
+	int queue_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_queues = 1;
+	} else if (sscanf(list, "%d:%hhu", &queue_id, &evdev_id) == 2) {
+		queues[num_queues] = queue_id;
+		num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_params(char *list)
+{
+	int port_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_ports = 1;
+	} else if (sscanf(list, "%d:%hhu", &port_id, &evdev_id) == 2) {
+		ports[num_ports] = port_id;
+		num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +360,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +448,35 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1836,187 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static bool
+show_edev_xstats(void)
+{
+	/* Check if any event dev xstats requested from command line */
+	if (enable_shw_all_eventdev_queues || enable_shw_all_eventdev_ports
+		|| enable_dump_eventdev_xstats || enable_eventdev_reset_xstats ||
+		enable_shw_eventdev_device_xstats || num_ports > 0 || num_queues > 0)
+		return true;
+
+	return false;
+}
+
+static unsigned int
+xstats_get_names_and_ids_size(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+
+	int ret;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	return (unsigned int)ret;
+
+}
+
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < (int)size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+
+static void
+process_eventdev_xstats(void)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_xstats) {
+		xstats_display(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0);
+		if (enable_eventdev_reset_xstats)
+			xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, i);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, ports[i]);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, i);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, queues[i]);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2067,28 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		/* Verify the command line options */
+		if (evdev_id >= rte_event_dev_count())
+			rte_panic("invalid event device %hhu\n", evdev_id);
+
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats();
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +31 -1
index cf3502a8cb..f0a7d37e41 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num |
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-xstats |
+   --show-edev-device-xstats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,34 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#29 lore raw

PATCH v11 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 296 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  32 +++-
 3 files changed, 327 insertions(+), 3 deletions(-)
app/proc-info/main.c +295 -1
index 53e852a07c..ceed525b3e 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,18 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev_xstats;
+static uint32_t enable_eventdev_reset_xstats;
+static uint32_t enable_shw_eventdev_device_xstats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +190,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +259,41 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_queue_params(char *list)
+{
+	int queue_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_queues = 1;
+	} else if (sscanf(list, "%d:%hhu", &queue_id, &evdev_id) == 2) {
+		queues[num_queues] = queue_id;
+		num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_params(char *list)
+{
+	int port_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_ports = 1;
+	} else if (sscanf(list, "%d:%hhu", &port_id, &evdev_id) == 2) {
+		ports[num_ports] = port_id;
+		num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +360,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +448,35 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1836,187 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static bool
+show_edev_xstats(void)
+{
+	/* Check if any event dev xstats requested from command line */
+	if (enable_shw_all_eventdev_queues || enable_shw_all_eventdev_ports
+		|| enable_dump_eventdev_xstats || enable_eventdev_reset_xstats ||
+		enable_shw_eventdev_device_xstats || num_ports > 0 || num_queues > 0)
+		return true;
+
+	return false;
+}
+
+static unsigned int
+xstats_get_names_and_ids_size(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+
+	int ret;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	return (unsigned int)ret;
+
+}
+
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < (int)size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+
+static void
+process_eventdev_xstats(void)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_xstats) {
+		xstats_display(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0);
+		if (enable_eventdev_reset_xstats)
+			xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, i);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, ports[i]);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, i);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, queues[i]);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2067,27 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		/* Verify the command line options */
+		if (evdev_id >= rte_event_dev_count())
+			rte_panic("invalid event device %hhu\n", evdev_id);
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats();
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +31 -1
index cf3502a8cb..f0a7d37e41 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num |
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-xstats |
+   --show-edev-device-xstats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,34 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#30 lore raw

PATCH v12 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 294 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  32 +++-
 3 files changed, 325 insertions(+), 3 deletions(-)
app/proc-info/main.c +293 -1
index 53e852a07c..0e0d8ab4ce 100644
@@ -40,11 +40,17 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
 #define MAX_STRING_LEN 256
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
 #define ETHDEV_FWVERS_LEN 32
 #define RTE_RETA_CONF_GROUP_NUM 32
 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
@@ -121,6 +127,18 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+static uint32_t enable_shw_all_eventdev_queues;
+static uint32_t enable_shw_all_eventdev_ports;
+static uint32_t enable_dump_eventdev_xstats;
+static uint32_t enable_eventdev_reset_xstats;
+static uint32_t enable_shw_eventdev_device_xstats;
+
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +190,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +259,40 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_queue_params(char *list)
+{
+	int queue_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_queues = 1;
+	} else if (sscanf(list, "%d:%hhu", &queue_id, &evdev_id) == 2) {
+		queues[num_queues] = queue_id;
+		num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_params(char *list)
+{
+	int port_id;
+
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		enable_shw_all_eventdev_ports = 1;
+	} else if (sscanf(list, "%d:%hhu", &port_id, &evdev_id) == 2) {
+		ports[num_ports] = port_id;
+		num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +359,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +447,35 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				enable_dump_eventdev_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				enable_eventdev_reset_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				enable_shw_eventdev_device_xstats = 1;
+				evdev_id = (uint8_t)atoi(optarg);
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1835,186 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static bool
+show_edev_xstats(void)
+{
+	/* Check if any event dev xstats requested from command line */
+	if (enable_shw_all_eventdev_queues || enable_shw_all_eventdev_ports
+		|| enable_dump_eventdev_xstats || enable_eventdev_reset_xstats ||
+		enable_shw_eventdev_device_xstats || num_ports > 0 || num_queues > 0)
+		return true;
+
+	return false;
+}
+
+static unsigned int
+xstats_get_names_and_ids_size(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+
+	int ret;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	return (unsigned int)ret;
+
+}
+
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < (int)size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+process_eventdev_xstats(void)
+{
+	int i;
+
+	if (enable_shw_eventdev_device_xstats) {
+		xstats_display(evdev_id,
+			  RTE_EVENT_DEV_XSTATS_DEVICE,
+			  0);
+		if (enable_eventdev_reset_xstats)
+			xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+	}
+
+	if (enable_shw_all_eventdev_ports) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, i);
+		}
+	} else {
+		for (i = 0; i < num_ports; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_PORT,
+				  ports[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_PORT, ports[i]);
+		}
+	}
+
+	if (enable_shw_all_eventdev_queues) {
+		for (i = 0; i < MAX_PORTS_QUEUES; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  i);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, i);
+		}
+	} else {
+		for (i = 0; i < num_queues; i++) {
+			xstats_display(evdev_id,
+				  RTE_EVENT_DEV_XSTATS_QUEUE,
+				  queues[i]);
+			if (enable_eventdev_reset_xstats)
+				xstats_reset(evdev_id, RTE_EVENT_DEV_XSTATS_QUEUE, queues[i]);
+		}
+	}
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2065,27 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (show_edev_xstats()) {
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		/* Verify the command line options */
+		if (evdev_id >= rte_event_dev_count())
+			rte_panic("invalid event device %hhu\n", evdev_id);
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		process_eventdev_xstats();
+		return 0;
+	}
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +31 -1
index cf3502a8cb..f0a7d37e41 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num |
+   --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-xstats |
+   --show-edev-device-xstats]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,34 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#31 lore raw

RE: [PATCH v12] app/procinfo: display eventdev xstats

Quoted 11 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>

app/proc-info/main.c +6 -0
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES]; 
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES];
+static uint32_t enable_shw_all_eventdev_queues; static uint32_t

<snip>

Review

Quoted 4 lines
(quoted diff) +4 -0
+enable_shw_all_eventdev_ports; static uint32_t
+enable_dump_eventdev_xstats; static uint32_t
+enable_eventdev_reset_xstats; static uint32_t
+enable_shw_eventdev_device_xstats;

How about keeping a struct to maintain all the data together that way you know on which all ports and queues of eventdev we have requested display.
You can refer the existing code "struct desc_param" to see how this is done
Then you can declare global variables of type struct eventdev_params eventdev_var[MAX_EVENTDEV_DEV] to handle data of all evendev ids as an array, instead of keeping many global variables. .

Ex:

struct eventdev_params {
           	unit8_t eventdev_id;
           	unit8_t ports[MAX_PORTS_QUEUES]
          	 unit8_t queues[MAX_PORTS_QUEUES]
          	 static uint8_t num_queues
          	 static uint8_t num_ports

	static uint32_t enable_shw_all_eventdev_queues;
	static uint32_t enable_shw_all_eventdev_ports;
	static uint32_t enable_dump_eventdev_xstats;
	static uint32_t enable_eventdev_reset_xstats;
	static uint32_t enable_shw_eventdev_device_xstats;
}

app/proc-info/main.c main(int argc, char **argv) · line 2068

Quoted 1 line
app/proc-info/main.c +1 -0
+	if (show_edev_xstats()) {

I don't think we really need the show_edev_xstats() function. You can directly call process_eventdev_xstats() here.

app/proc-info/main.c main(int argc, char **argv) · line 2077

Quoted 9 lines
app/proc-info/main.c +9 -0
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		/* Verify the command line options */
+		if (evdev_id >= rte_event_dev_count())
+			rte_panic("invalid event device %hhu\n", evdev_id);

Also, You can move above eventdev id validation code to a small separate function().
That new function can be called from parse_eventdev_queue_params() and parse_eventdev_port_params(), to validate the event dev id. So you no need to do this eventdev validation here.

app/proc-info/main.c main(int argc, char **argv) · line 2083

Quoted 6 lines
app/proc-info/main.c +6 -0
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}

Also I guess you can move the below piece of code to be part of the process_eventdev_xstats()

Quoted 11 lines
doc/guides/tools/proc_info.rst +1 -1
index cf3502a8cb..f0a7d37e41 100644
 
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-

xstats=queue_num |

+ --show-edev-port-xstats=port_num | --edev-dump-xstats | --edev-reset-
xstats |
+ --show-edev-device-xstats]

Need to edit these eventdev commands to show the new format port:eventdevid, queue:eventdevid and eventdev id.

Thanks,
Reshma

#32 lore raw

RE: [PATCH v12] app/procinfo: display eventdev xstats

+>How about keeping a struct to maintain all the data together that way you know on which all ports and queues of eventdev we have requested display.
+>You can refer the existing code "struct desc_param" to see how this is done Then you can declare global variables of type struct eventdev_params eventdev_var[MAX_EVENTDEV_DEV] to handle data of all evendev ids as an array, instead of keeping +>many global variables. This is very good idea, there are other global variables as well which can be put in the structure. I think many global variables declared in this file can follow this approach. However, I haven't scoped this within this release timeline as we have reached almost end of it.

Review

Quoted 3 lines
(quoted diff) +2 -0
+	if (show_edev_xstats()) {
 
+I don't think we really need the show_edev_xstats() function.  You can directly call process_eventdev_xstats() here.

I think we need this here because we want to exit from the app after displaying xstats for eventdev. We don't want to mix rte_eventdev data displayed (if we don't exit rest of the program continues to display other stats for rte, e.g. check show mempool command line)

app/proc-info/main.c main(int argc, char **argv)

Quoted 13 lines
app/proc-info/main.c +12 -0
+		const uint8_t ndevs = rte_event_dev_count();
+
+		if (ndevs == 0)
+			rte_panic("No event devs found. Do you need"
+			  " to pass in a --vdev flag?\n");
+
+		/* Verify the command line options */
+		if (evdev_id >= rte_event_dev_count())
+			rte_panic("invalid event device %hhu\n", evdev_id);
 
+Also, You can move above eventdev id validation code to  a small separate function().  
+That new function can be called from parse_eventdev_queue_params() and parse_eventdev_port_params(), to validate the event dev id.
+So you no need to do this eventdev validation here.

I think consolidating this call(checking the validation after evdevid is passed) in here is better, it seems more consolidated compared to have call at each parameter read in the parse function.

app/proc-info/main.c main(int argc, char **argv)

Quoted 9 lines
app/proc-info/main.c +7 -0
+
+		if (enable_dump_eventdev_xstats) {
+			ret = rte_event_dev_dump(evdev_id, stdout);
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
 
 
+Also I guess you can move the below piece of code to be part of the process_eventdev_xstats()

Okay, I will move this inside process_eventdev_xstats().

Quoted 1 line

+Need to edit these eventdev commands to show the new format port:eventdevid, queue:eventdevid and eventdev id.

Will do.

Thanks,
Abdullah

#33 lore raw

RE: [PATCH v12] app/procinfo: display eventdev xstats

In reply to Pattan, Reshma
Quoted 12 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>

app/proc-info/main.c +6 -0
+static uint8_t evdev_id;
+static uint8_t num_ports;
+static uint8_t ports[MAX_PORTS_QUEUES];
+static uint8_t num_queues;
+static uint8_t queues[MAX_PORTS_QUEUES]; static uint32_t 
+enable_shw_all_eventdev_queues; static uint32_t

<snip>

Review

Quoted 7 lines
(quoted diff) +6 -0
+enable_shw_all_eventdev_ports; static uint32_t 
+enable_dump_eventdev_xstats; static uint32_t 
+enable_eventdev_reset_xstats; static uint32_t 
+enable_shw_eventdev_device_xstats;
 
+How about keeping  a struct to maintain  all the data together that way you know on which all ports and queues of eventdev we have requested display. 
+You can refer the existing code "struct desc_param" to see how this is done Then you can declare global variables of type struct eventdev_params eventdev_var[MAX_EVENTDEV_DEV] to handle data of all evendev ids as an array, instead of keeping >+many global variables.

.

Quoted 4 lines
(quoted diff) +4 -0
+Ex: 
+struct eventdev_params {
+           	unit8_t eventdev_id;
+           	unit8_t ports[MAX_PORTS_QUEUES]

Review

Quoted 10 lines
(quoted diff) +10 -0
+          	 unit8_t queues[MAX_PORTS_QUEUES]
+          	 static uint8_t num_queues
+          	 static uint8_t num_ports
+
+	static uint32_t enable_shw_all_eventdev_queues;
+	static uint32_t enable_shw_all_eventdev_ports;
+	static uint32_t enable_dump_eventdev_xstats;
+	static uint32_t enable_eventdev_reset_xstats;
+	static uint32_t enable_shw_eventdev_device_xstats;
+}

Also, all global variables are tied to a command itself like "static uint32_t enable_shw_port_priv" or "static uint32_t enable_shw_ring" . I also want the same for eventdev params to be called a command like the others in the file. If user wants he/she can chain commands. The "struct desc_param" is handling one command only but its 3 parameters (queue_id, offset and num) are put in the structure, for easy parsing. None of the command line arguments, hence global variables are handled/put in a structure. Would you like to change that for proc app going forward?

#34 lore raw

RE: [PATCH v12] app/procinfo: display eventdev xstats

Quoted 19 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>

Quoted 4 lines
(quoted diff) +4 -0
+Ex:
+struct eventdev_params {
+           	unit8_t eventdev_id;
+           	unit8_t ports[MAX_PORTS_QUEUES]

Review

Quoted 10 lines
(quoted diff) +10 -0
+          	 unit8_t queues[MAX_PORTS_QUEUES]
+          	 static uint8_t num_queues
+          	 static uint8_t num_ports
+
+	static uint32_t enable_shw_all_eventdev_queues;
+	static uint32_t enable_shw_all_eventdev_ports;
+	static uint32_t enable_dump_eventdev_xstats;
+	static uint32_t enable_eventdev_reset_xstats;
+	static uint32_t enable_shw_eventdev_device_xstats;
+}
Quoted 9 lines

Also, all global variables are tied to a command itself like "static uint32_t enable_shw_port_priv" or "static uint32_t enable_shw_ring" . I also want the same for eventdev params to be called a command like the others in the file. If user wants he/she can chain commands. The "struct desc_param" is handling one command only but its 3 parameters (queue_id, offset and num) are put in the structure, for easy parsing. None of the command line arguments, hence global variables are handled/put in a structure. Would you like to change that for proc app going forward?

Having structure like suggested not only help-s simple data handling but also would help for the cases like below , where you need to maintain different event ids in the code. With the current patch version the below scenario is not possible as you have only one global variable for the eventdev id which always holds the latest evet id in the command , from below example evetdev id 2.

Ex 1: Where you want to show queue 0 xstats of eventdev 2 and port0 xstats of eventdev 1 ./proc --show-evendev-port-xtstas=0:1 --show-evendev-queue-xsats=0:2

Thanks.
Reshma

#35 lore raw

RE: [PATCH v12] app/procinfo: display eventdev xstats

Review

Quoted 11 lines
(quoted diff) +5 -0
+Having structure like suggested not only help-s simple data handling but also would help for the cases like below , where you need to maintain different event ids in the code. 
+With the current patch version the below scenario is not possible as you have only one global variable for the eventdev id which always holds the latest evet id in the command , from below example evetdev id 2.
 
 
+Ex 1: Where you want to show queue 0 xstats of eventdev 2 and port0 xstats of eventdev 1 ./proc --show-evendev-port-xtstas=0:1 --show-evendev-queue-xsats=0:2
 
+Thanks.
+Reshma

Thanks Reshma, now I understood the point. The intent is only display one event dev data with the same eventdev id being passed. Therefore I can change the patch
Passing another command line parameter --eventid and instead of taking two parameters from --show-evendev-port-xtstas=0:1 just take the port number (same for other command types). If no eventid is passed Eventid defaults to 0.

If you want your approach of maintaining and displaying mix of more eventdevs with different ids, your suggestion is the way to go. Let me know.

#36 lore raw

RE: [PATCH v12] app/procinfo: display eventdev xstats

Quoted 9 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>

Quoted 3 lines
(quoted diff) +3 -0
+Ex 1: Where you want to show queue 0 xstats of eventdev 2 and port0
+xstats of eventdev 1 ./proc --show-evendev-port-xtstas=0:1
+--show-evendev-queue-xsats=0:2
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+Thanks.
+Reshma

If you want your approach of maintaining and displaying mix of more eventdevs with different ids, your suggestion is the way to go. Let me know.

Will go with my suggestion, I feel it will be more maintenance friendly going forward.

#37 lore raw

PATCH v13 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 386 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  32 ++-
 3 files changed, 417 insertions(+), 3 deletions(-)
app/proc-info/main.c +385 -1
index 53e852a07c..80d5d33a22 100644
@@ -40,6 +40,7 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
@@ -121,6 +122,26 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
+struct eventdev_params {
+	uint32_t show_eventdev;
+	uint8_t ports[MAX_PORTS_QUEUES];
+	uint8_t queues[MAX_PORTS_QUEUES];
+	uint8_t num_queues;
+	uint8_t num_ports;
+	uint32_t shw_all_queues;
+	uint32_t shw_all_ports;
+	uint32_t dump_xstats;
+	uint32_t reset_xstats;
+	uint32_t shw_device_xstats;
+};
+
+static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +193,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +262,123 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_dump_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].dump_xstats = 1;
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_reset_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].reset_xstats = 1;
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_device_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].shw_device_xstats = 1;
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_queue_xstats_params(char *list)
+{
+	uint8_t queue_id;
+	uint8_t evdev_id;
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_queues = 1;
+	} else if (sscanf(list, "%hhu:%hhu", &queue_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].queues[eventdev_var[evdev_id].num_queues] = queue_id;
+		eventdev_var[evdev_id].num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_xstats_params(char *list)
+{
+	uint8_t port_id;
+	uint8_t evdev_id;
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_ports = 1;
+	} else if (sscanf(list, "%hhu:%hhu", &port_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].ports[eventdev_var[evdev_id].num_ports] = port_id;
+		eventdev_var[evdev_id].num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +445,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +533,47 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_dump_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev dump xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_reset_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_device_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1933,198 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static unsigned int
+xstats_get_names_and_ids_size(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+
+	int ret;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	return (unsigned int)ret;
+
+}
+
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < (int)size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+static int
+process_eventdev_xstats(void)
+{
+	int i;
+	int j;
+	int processing_eventdev_xstats = 0;
+
+	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
+		if (eventdev_var[i].show_eventdev == 1) {
+
+			if (!processing_eventdev_xstats)
+				processing_eventdev_xstats = 1;
+
+			if (i >= rte_event_dev_count())
+				rte_panic("invalid event device %hhu\n", i);
+
+			if (eventdev_var[i].dump_xstats) {
+				int ret = rte_event_dev_dump(i, stdout);
+				if (ret)
+					rte_panic("dump failed with err=%d\n", ret);
+			}
+
+			if (eventdev_var[i].shw_device_xstats == 1) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+			}
+
+			if (eventdev_var[i].shw_all_ports == 1) {
+				for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+				}
+			} else {
+				for (j = 0; j < eventdev_var[i].num_ports; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
+					eventdev_var[i].ports[j]);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
+								eventdev_var[i].ports[j]);
+				}
+			}
+
+			if (eventdev_var[i].shw_all_queues == 1) {
+				for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+				}
+			} else {
+				for (j = 0; j < eventdev_var[i].num_queues; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+							eventdev_var[i].queues[j]);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+								eventdev_var[i].queues[j]);
+				}
+			}
+
+		}
+	}
+
+	if (processing_eventdev_xstats)
+		return 1;
+
+	return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2175,9 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (process_eventdev_xstats())
+		return 0;
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +31 -1
index cf3502a8cb..a79e504d67 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num:evdev_id |
+   --show-edev-port-xstats=port_num :evdev_id | --edev-dump-xstats=evdev_id |
+   --edev-reset-xstats=evdev_id | --show-edev-device-xstats=evdev_id]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,34 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#38 lore raw

PATCH v14 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 386 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  32 ++-
 3 files changed, 417 insertions(+), 3 deletions(-)
app/proc-info/main.c +385 -1
index 53e852a07c..9975d6a646 100644
@@ -40,6 +40,7 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
@@ -121,6 +122,26 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
+struct eventdev_params {
+	uint32_t show_eventdev;
+	uint8_t ports[MAX_PORTS_QUEUES];
+	uint8_t queues[MAX_PORTS_QUEUES];
+	uint8_t num_queues;
+	uint8_t num_ports;
+	uint32_t shw_all_queues;
+	uint32_t shw_all_ports;
+	uint32_t dump_xstats;
+	uint32_t reset_xstats;
+	uint32_t shw_device_xstats;
+};
+
+static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +193,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +262,123 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_dump_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].dump_xstats = 1;
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_reset_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].reset_xstats = 1;
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_device_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].shw_device_xstats = 1;
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_queue_xstats_params(char *list)
+{
+	uint8_t queue_id;
+	uint8_t evdev_id;
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_queues = 1;
+	} else if (sscanf(list, "%hhu:%hhu", &queue_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].queues[eventdev_var[evdev_id].num_queues] = queue_id;
+		eventdev_var[evdev_id].num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_xstats_params(char *list)
+{
+	uint8_t port_id;
+	uint8_t evdev_id;
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_ports = 1;
+	} else if (sscanf(list, "%hhu:%hhu", &port_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 - %d\n",
+			RTE_EVENT_MAX_DEVS-1);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].ports[eventdev_var[evdev_id].num_ports] = port_id;
+		eventdev_var[evdev_id].num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +445,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +533,47 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_dump_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev dump xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_reset_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_device_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1933,198 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static unsigned int
+xstats_get_names_and_ids_size(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+
+	int ret;
+
+	/* Get amount of storage required */
+	ret = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (ret < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	return (unsigned int)ret;
+
+}
+
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < (int)size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	unsigned int size;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+static int
+process_eventdev_xstats(void)
+{
+	int i;
+	int j;
+	int processing_eventdev_xstats = 0;
+
+	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
+		if (eventdev_var[i].show_eventdev == 1) {
+
+			if (!processing_eventdev_xstats)
+				processing_eventdev_xstats = 1;
+
+			if (i >= rte_event_dev_count())
+				rte_panic("invalid event device %d\n", i);
+
+			if (eventdev_var[i].dump_xstats) {
+				int ret = rte_event_dev_dump(i, stdout);
+				if (ret)
+					rte_panic("dump failed with err=%d\n", ret);
+			}
+
+			if (eventdev_var[i].shw_device_xstats == 1) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+			}
+
+			if (eventdev_var[i].shw_all_ports == 1) {
+				for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+				}
+			} else {
+				for (j = 0; j < eventdev_var[i].num_ports; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
+					eventdev_var[i].ports[j]);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
+								eventdev_var[i].ports[j]);
+				}
+			}
+
+			if (eventdev_var[i].shw_all_queues == 1) {
+				for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+				}
+			} else {
+				for (j = 0; j < eventdev_var[i].num_queues; j++) {
+					xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+							eventdev_var[i].queues[j]);
+
+					if (eventdev_var[i].reset_xstats == 1)
+						xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+								eventdev_var[i].queues[j]);
+				}
+			}
+
+		}
+	}
+
+	if (processing_eventdev_xstats)
+		return 1;
+
+	return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2175,9 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (process_eventdev_xstats())
+		return 0;
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +31 -1
index cf3502a8cb..a79e504d67 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num:evdev_id |
+   --show-edev-port-xstats=port_num :evdev_id | --edev-dump-xstats=evdev_id |
+   --edev-reset-xstats=evdev_id | --show-edev-device-xstats=evdev_id]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,34 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#39 lore raw

Re: [PATCH v14] app/procinfo: display eventdev xstats

app/proc-info/main.c parse_descriptor_param(char *list, struct desc_param *desc) · line 274

Quoted 10 lines · On Wed, 17 May 2023 17:37:24 -0500 Abdullah Sevincer…
app/proc-info/main.c +10 -0
+static int
+parse_eventdev_dump_xstats_params(char *list)
+{
+	uint8_t evdev_id;
+	evdev_id = (uint8_t)atoi(list);
+
+	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
+		return -EINVAL;
+	}

The cast will cause truncation of large values, so this might be a nop. If you really want to check, then something like:

	unsigned long evdev_id;
	char *endp;

	evdev_id = strtoul(list, &endp, 0);
	if (!*list || !*endp || evdev_id >= RTE_EVENT_MAX_DEVS) {
	    fprintf(stderr, "Invalid eventdev id: %s\n", list);
	    return -EINVAL;
	}
#40 lore raw

RE: [PATCH v14] app/procinfo: display eventdev xstats

Review

Quoted 12 lines
(quoted diff) +9 -0
+The cast will cause truncation of large values, so this might be a nop.
+If you really want to check, then something like:
 
+	unsigned long evdev_id;
+	char *endp;
 
+	evdev_id = strtoul(list, &endp, 0);
+	if (!*list || !*endp || evdev_id >= RTE_EVENT_MAX_DEVS) {
+	    fprintf(stderr, "Invalid eventdev id: %s\n", list);
+	    return -EINVAL;
+	}

Thanks Stephen, you are right it will truncate large values, RTE_EVENT_MAX_DEVS is 16, so I thought Uint8_t is enough to hold the id. I am not sure if we will have a large number of evdevs, so ids.

But your suggestion seems better I will change it.

#41 lore raw

RE: [PATCH v14] app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer
Quoted 4 lines

-----Original Message-----
From: Sevincer, Abdullah <[email protected]>

The code looks better now, however if you can make below changes that would be great.

app/proc-info/main.c static uint32_t enable_shw_module_eeprom; · line 131

Quoted 3 lines
app/proc-info/main.c +3 -0
+
+struct eventdev_params {
+	uint32_t show_eventdev;

Can't we get rid of the "show_eventdev", and just rely below flags

<snip>

Quoted 10 lines
app/proc-info/main.c +8 -0
+	uint8_t num_queues;
+	uint8_t num_ports;
+	uint32_t shw_all_queues;
+	uint32_t shw_all_ports;
+	uint32_t dump_xstats;
+	uint32_t reset_xstats;
+	uint32_t shw_device_xstats;
 
 
+parse_eventdev_dump_xstats_params(char *list) {

<snip>

app/proc-info/main.c parse_descriptor_param(char *list, struct desc_param *desc) · line 279

Quoted 3 lines
app/proc-info/main.c +3 -0
+
+	if (!eventdev_var[evdev_id].show_eventdev)
+		eventdev_var[evdev_id].show_eventdev = 1;

You can set the " eventdev_var[evdev_id].show_eventdev = 1;" without the if check. Here and in other places. However , you don't need to have show_eventdev=1. You can think of getting rid of the "show_eventdev" altogether. Here and other places.

<snip>

Quoted 7 lines
app/proc-info/main.c +6 -0
+parse_eventdev_port_xstats_params(char *list) {
+	uint8_t port_id;
+	uint8_t evdev_id;
+	if (sscanf(list, "*:%hhu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id, id should be between 0 -

%d\n",

Do you need to validate the port id and queue ids here and in below functions.

<snip>

Quoted 26 lines
app/proc-info/main.c +16 -0
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	unsigned int size;
+	int i;
+
+	size = xstats_get_names_and_ids_size(dev_id, mode, queue_port_id);
 
 
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d,

queue_port_id=%d\n",

app/proc-info/main.c +6 -0
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) *

size);

app/proc-info/main.c nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc) · line 1989

Quoted 8 lines
app/proc-info/main.c +8 -0
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     size);

You need size in unsigned int form only to pass to the function rte_event_dev_xstats_names_get() , so why not use unsigned int(size) here and remove the cast of size in function xstats_get_names_and_ids_size().

I also feel you don't need xstats_get_names_and_ids_size(), just call rte_event_dev_xstats_names_get() directly in this function , to get the size in int, use int size everywhere else,
and use it with cast while passing to rte_event_dev_xstats_names_get() again. It makes easy to follow the code .

This way You no need to do (int)size in below code too.

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret != (int)size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);

<snip>

doc/guides/tools/proc_info.rst queue_id: A Tx queue identifier on this port. · line 132

Quoted 6 lines
doc/guides/tools/proc_info.rst +6 -0
+
+A typical command line usage for eventdev stats:
+
+    .. code-block:: console
+
+       ./dpdk-proc-info -- --show-edev-port-xstats=1:0

If you want to provide the command examples, you can give example under each command section, else you can remove this as well.

#42 lore raw

PATCH v15 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 386 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  26 ++-
 3 files changed, 411 insertions(+), 3 deletions(-)
app/proc-info/main.c +385 -1
index 53e852a07c..8fb4aea4c0 100644
@@ -40,6 +40,7 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
@@ -121,6 +122,25 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
+struct eventdev_params {
+	uint8_t ports[MAX_PORTS_QUEUES];
+	uint8_t queues[MAX_PORTS_QUEUES];
+	uint8_t num_queues;
+	uint8_t num_ports;
+	uint32_t shw_all_queues;
+	uint32_t shw_all_ports;
+	uint32_t dump_xstats;
+	uint32_t reset_xstats;
+	uint32_t shw_device_xstats;
+};
+
+static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +192,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +261,136 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_dump_xstats_params(char *list)
+{
+	uint16_t evdev_id;
+
+	if (sscanf(list, "%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+	}
+
+	eventdev_var[evdev_id].dump_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
+static int
+parse_eventdev_reset_xstats_params(char *list)
+{
+	uint16_t evdev_id;
+
+	if (sscanf(list, "%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+	}
+
+	eventdev_var[evdev_id].reset_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
+static int
+parse_eventdev_device_xstats_params(char *list)
+{
+	uint16_t evdev_id;
+
+	if (sscanf(list, "%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+	}
+
+	eventdev_var[evdev_id].shw_device_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
+static int
+parse_eventdev_queue_xstats_params(char *list)
+{
+	uint16_t queue_id;
+	uint16_t evdev_id;
+
+	if (sscanf(list, "*:%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_queues = 1;
+	} else if (sscanf(list, "%hu:%hu", &queue_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+
+		if (queue_id >= MAX_PORTS_QUEUES) {
+			printf("Invalid queue_id: %d\n", queue_id);
+			return -EINVAL;
+		}
+
+		eventdev_var[evdev_id].queues[eventdev_var[evdev_id].num_queues] = queue_id;
+		eventdev_var[evdev_id].num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_xstats_params(char *list)
+{
+	uint16_t port_id;
+	uint16_t evdev_id;
+
+	if (sscanf(list, "*:%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_ports = 1;
+	} else if (sscanf(list, "%hu:%hu", &port_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+
+		if (port_id >= MAX_PORTS_QUEUES) {
+			printf("Invalid port_id: %d\n", port_id);
+			return -EINVAL;
+		}
+
+		eventdev_var[evdev_id].ports[eventdev_var[evdev_id].num_ports] = port_id;
+		eventdev_var[evdev_id].num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +457,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +545,47 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_dump_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev dump xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_reset_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_device_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1945,186 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	int size;
+	int i;
+
+	size = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (size < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     (unsigned int)size);
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	int size;
+
+	size = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (size < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     (unsigned int)size);
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+static int
+process_eventdev_xstats(void)
+{
+	int i;
+	int j;
+	int processing_eventdev_xstats = 0;
+
+	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
+
+		if (!processing_eventdev_xstats)
+			processing_eventdev_xstats = 1;
+
+		if (eventdev_var[i].dump_xstats) {
+			int ret = rte_event_dev_dump(i, stdout);
+
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		if (eventdev_var[i].shw_device_xstats == 1) {
+			xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+
+			if (eventdev_var[i].reset_xstats == 1)
+				xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+		}
+
+		if (eventdev_var[i].shw_all_ports == 1) {
+			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+			}
+		} else {
+			for (j = 0; j < eventdev_var[i].num_ports; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
+					eventdev_var[i].ports[j]);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
+							eventdev_var[i].ports[j]);
+			}
+		}
+
+		if (eventdev_var[i].shw_all_queues == 1) {
+			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+			}
+		} else {
+			for (j = 0; j < eventdev_var[i].num_queues; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+						eventdev_var[i].queues[j]);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+							eventdev_var[i].queues[j]);
+			}
+		}
+	}
+
+	if (processing_eventdev_xstats)
+		return 1;
+
+	return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2175,9 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (process_eventdev_xstats())
+		return 0;
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +25 -1
index cf3502a8cb..bb483afbce 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num:evdev_id |
+   --show-edev-port-xstats=port_num :evdev_id | --edev-dump-xstats=evdev_id |
+   --edev-reset-xstats=evdev_id | --show-edev-device-xstats=evdev_id]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,28 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#43 lore raw

Re: [PATCH v15] app/procinfo: display eventdev xstats

Quoted 14 lines · On Thu, 25 May 2023 01:08:51 -0500 Abdullah Sevincer…

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Quoted 7 lines

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---

Looks good, here are some minor touchup feedbacks.

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int
+parse_eventdev_reset_xstats_params(char *list)

Could be "const char *list" here

app/proc-info/main.c parse_descriptor_param(char *list, struct desc_param *desc) · line 269

Quoted 4 lines
app/proc-info/main.c +4 -0
+{
+	uint16_t evdev_id;
+
+	if (sscanf(list, "%hu", &evdev_id) == 1) {

sscanf has less error checking than other methods. It also allows inputs like "0A" to be confused as 0 followed by A ignored.

Better to use strtoul() and have one fuction rather than copy paste the same code in three places.

Quoted 14 lines
app/proc-info/main.c +14 -0
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %d\n", evdev_id);
+			return -EINVAL;
+		}
+	}
+
+	eventdev_var[evdev_id].reset_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
#44 lore raw

PATCH v16 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 389 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  26 ++-
 3 files changed, 414 insertions(+), 3 deletions(-)
app/proc-info/main.c +388 -1
index 53e852a07c..f53fab2e33 100644
@@ -40,6 +40,7 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
@@ -121,6 +122,25 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
+struct eventdev_params {
+	uint16_t ports[MAX_PORTS_QUEUES];
+	uint16_t queues[MAX_PORTS_QUEUES];
+	uint16_t num_queues;
+	uint16_t num_ports;
+	uint32_t shw_all_queues;
+	uint32_t shw_all_ports;
+	uint32_t dump_xstats;
+	uint32_t reset_xstats;
+	uint32_t shw_device_xstats;
+};
+
+static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +192,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +261,139 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_dump_xstats_params(char *list)
+{
+	unsigned long evdev_id;
+	char *endp;
+
+	evdev_id = strtoul(list, &endp, 0);
+
+	if (*list == '\0' || *endp != '\0' || evdev_id >= RTE_EVENT_MAX_DEVS) {
+		fprintf(stderr, "Invalid eventdev id: %s\n", list);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].dump_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("Invalid eventdev id: %s\n", list);
+
+	return 0;
+}
+
+static int
+parse_eventdev_reset_xstats_params(char *list)
+{
+	unsigned long evdev_id;
+	char *endp;
+
+	evdev_id = strtoul(list, &endp, 0);
+
+	if (*list == '\0' || *endp != '\0' || evdev_id >= RTE_EVENT_MAX_DEVS) {
+		fprintf(stderr, "Invalid eventdev id: %s\n", list);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].reset_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("Invalid eventdev id: %s\n", list);
+
+	return 0;
+}
+
+static int
+parse_eventdev_device_xstats_params(char *list)
+{
+	unsigned long evdev_id;
+	char *endp;
+
+	evdev_id = strtoul(list, &endp, 0);
+
+	if (*list == '\0' || *endp != '\0' || evdev_id >= RTE_EVENT_MAX_DEVS) {
+		fprintf(stderr, "Invalid eventdev id: %s\n", list);
+		return -EINVAL;
+	}
+
+	eventdev_var[evdev_id].shw_device_xstats = 1;
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("Invalid eventdev id: %s\n", list);
+
+	return 0;
+}
+
+static int
+parse_eventdev_queue_xstats_params(char *list)
+{
+	uint16_t queue_id;
+	uint16_t evdev_id;
+
+	if (sscanf(list, "*:%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_queues = 1;
+	} else if (sscanf(list, "%hu:%hu", &queue_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+
+		if (queue_id >= MAX_PORTS_QUEUES) {
+			printf("Invalid queue_id: %hu\n", queue_id);
+			return -EINVAL;
+		}
+
+		eventdev_var[evdev_id].queues[eventdev_var[evdev_id].num_queues] = queue_id;
+		eventdev_var[evdev_id].num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_xstats_params(char *list)
+{
+	uint16_t port_id;
+	uint16_t evdev_id;
+
+	if (sscanf(list, "*:%hu", &evdev_id) == 1) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_ports = 1;
+	} else if (sscanf(list, "%hu:%hu", &port_id, &evdev_id) == 2) {
+		if (evdev_id >= RTE_EVENT_MAX_DEVS) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+
+		if (port_id >= MAX_PORTS_QUEUES) {
+			printf("Invalid port_id: %hu\n", port_id);
+			return -EINVAL;
+		}
+
+		eventdev_var[evdev_id].ports[eventdev_var[evdev_id].num_ports] = port_id;
+		eventdev_var[evdev_id].num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	if (evdev_id >= rte_event_dev_count())
+		rte_panic("invalid event device %hu\n", evdev_id);
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +460,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +548,47 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_dump_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev dump xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_reset_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_device_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1948,186 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	int size;
+	int i;
+
+	size = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (size < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     (unsigned int)size);
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	int size;
+
+	size = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (size < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     (unsigned int)size);
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+static int
+process_eventdev_xstats(void)
+{
+	int i;
+	int j;
+	int processing_eventdev_xstats = 0;
+
+	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
+
+		if (!processing_eventdev_xstats)
+			processing_eventdev_xstats = 1;
+
+		if (eventdev_var[i].dump_xstats) {
+			int ret = rte_event_dev_dump(i, stdout);
+
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		if (eventdev_var[i].shw_device_xstats == 1) {
+			xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+
+			if (eventdev_var[i].reset_xstats == 1)
+				xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+		}
+
+		if (eventdev_var[i].shw_all_ports == 1) {
+			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+			}
+		} else {
+			for (j = 0; j < eventdev_var[i].num_ports; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
+					eventdev_var[i].ports[j]);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
+							eventdev_var[i].ports[j]);
+			}
+		}
+
+		if (eventdev_var[i].shw_all_queues == 1) {
+			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+			}
+		} else {
+			for (j = 0; j < eventdev_var[i].num_queues; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+						eventdev_var[i].queues[j]);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+							eventdev_var[i].queues[j]);
+			}
+		}
+	}
+
+	if (processing_eventdev_xstats)
+		return 1;
+
+	return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2178,9 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (process_eventdev_xstats())
+		return 0;
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +25 -1
index cf3502a8cb..bb483afbce 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num:evdev_id |
+   --show-edev-port-xstats=port_num :evdev_id | --edev-dump-xstats=evdev_id |
+   --edev-reset-xstats=evdev_id | --show-edev-device-xstats=evdev_id]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,28 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
#45 lore raw

Re: [PATCH v16] app/procinfo: display eventdev xstats

Quoted 14 lines · On Thu, 25 May 2023 11:41:27 -0500 Abdullah Sevincer…

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Quoted 6 lines

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

I was thinking of helper function and using const strings. Don't need to panic on invalid eventdev.

Also the flags could be just bitfield to save some space.

Something like this. Untested since I have no hardware with eventdevs.

app/proc-info/main.c +27 -41
index f53fab2e3346..d330afd6815e 100644
@@ -132,11 +132,11 @@ struct eventdev_params {
 	uint16_t queues[MAX_PORTS_QUEUES];
 	uint16_t num_queues;
 	uint16_t num_ports;
-	uint32_t shw_all_queues;
-	uint32_t shw_all_ports;
-	uint32_t dump_xstats;
-	uint32_t reset_xstats;
-	uint32_t shw_device_xstats;
+	uint8_t shw_all_queues:1,
+		shw_all_ports:1,
+		dump_xstats:1,
+		reset_xstats:1,
+		shw_device_xstats:1;
 };
 
 static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
@@ -261,71 +261,57 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
-static int
-parse_eventdev_dump_xstats_params(char *list)
+static uint16_t parse_eventdev(const char *str)
 {
 	unsigned long evdev_id;
 	char *endp;
 
-	evdev_id = strtoul(list, &endp, 0);
-
-	if (*list == '\0' || *endp != '\0' || evdev_id >= RTE_EVENT_MAX_DEVS) {
-		fprintf(stderr, "Invalid eventdev id: %s\n", list);
-		return -EINVAL;
+	evdev_id = strtoul(str, &endp, 0);
+	if (*str == '\0' || *endp != '\0' || evdev_id >= rte_event_dev_count()) {
+		fprintf(stderr, "Invalid eventdev id: %s\n", str);
+		return -1;
 	}
+	return evdev_id;
+}
 
-	eventdev_var[evdev_id].dump_xstats = 1;
+static int
+parse_eventdev_dump_xstats_params(const char *list)
+{
+	int evdev_id = parse_eventdev(list);
 
-	if (evdev_id >= rte_event_dev_count())
-		rte_panic("Invalid eventdev id: %s\n", list);
+	if (evdev_id < 0)
+		return -EINVAL;
 
+	eventdev_var[evdev_id].dump_xstats = 1;
 	return 0;
 }
 
 static int
-parse_eventdev_reset_xstats_params(char *list)
+parse_eventdev_reset_xstats_params(const char *list)
 {
-	unsigned long evdev_id;
-	char *endp;
-
-	evdev_id = strtoul(list, &endp, 0);
+	int evdev_id = parse_eventdev(list);
 
-	if (*list == '\0' || *endp != '\0' || evdev_id >= RTE_EVENT_MAX_DEVS) {
-		fprintf(stderr, "Invalid eventdev id: %s\n", list);
+	if (evdev_id < 0)
 		return -EINVAL;
-	}
 
 	eventdev_var[evdev_id].reset_xstats = 1;
-
-	if (evdev_id >= rte_event_dev_count())
-		rte_panic("Invalid eventdev id: %s\n", list);
-
 	return 0;
 }
 
 static int
-parse_eventdev_device_xstats_params(char *list)
+parse_eventdev_device_xstats_params(const char *list)
 {
-	unsigned long evdev_id;
-	char *endp;
-
-	evdev_id = strtoul(list, &endp, 0);
+	int evdev_id = parse_eventdev(list);
 
-	if (*list == '\0' || *endp != '\0' || evdev_id >= RTE_EVENT_MAX_DEVS) {
-		fprintf(stderr, "Invalid eventdev id: %s\n", list);
+	if (evdev_id < 0)
 		return -EINVAL;
-	}
 
 	eventdev_var[evdev_id].shw_device_xstats = 1;
-
-	if (evdev_id >= rte_event_dev_count())
-		rte_panic("Invalid eventdev id: %s\n", list);
-
 	return 0;
 }
 
 static int
-parse_eventdev_queue_xstats_params(char *list)
+parse_eventdev_queue_xstats_params(const char *list)
 {
 	uint16_t queue_id;
 	uint16_t evdev_id;
@@ -353,7 +339,7 @@ parse_eventdev_queue_xstats_params(char *list)
 		return -EINVAL;
 	}
 
-	if (evdev_id >= rte_event_dev_count())
+
 		rte_panic("invalid event device %hu\n", evdev_id);
 
 	return 0;
#46 lore raw

RE: [PATCH v16] app/procinfo: display eventdev xstats

Quoted 7 lines

+ I was thinking of helper function and using const strings.
+ Don't need to panic on invalid eventdev.

+ Also the flags could be just bitfield to save some space.

+ Something like this. Untested since I have no hardware with
+ eventdevs.

Thanks Stephen,

Let me revise more with your suggestions, I will try bitfields also. I have the event device 😊

#47 lore raw

PATCH v17 1/1 app/procinfo: display eventdev xstats

In reply to Abdullah Sevincer

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

---
 app/proc-info/main.c           | 375 ++++++++++++++++++++++++++++++++-
 app/proc-info/meson.build      |   2 +-
 doc/guides/tools/proc_info.rst |  26 ++-
 3 files changed, 400 insertions(+), 3 deletions(-)
app/proc-info/main.c +374 -1
index 53e852a07c..be63eace69 100644
@@ -40,6 +40,7 @@
 #include <rte_tm.h>
 #include <rte_hexdump.h>
 #include <rte_version.h>
+#include <rte_eventdev.h>
 
 /* Maximum long option length for option parsing. */
 #define MAX_LONG_OPT_SZ 64
@@ -121,6 +122,25 @@ static uint32_t enable_shw_module_eeprom;
 static uint32_t enable_shw_rx_desc_dump;
 static uint32_t enable_shw_tx_desc_dump;
 
+/* Note: Port_queue_id in xstats APIs is 8 bits, so we have a maximum of
+ * 256 ports and queues for event_Dev
+ */
+#define MAX_PORTS_QUEUES 256
+
+struct eventdev_params {
+	uint16_t ports[MAX_PORTS_QUEUES];
+	uint16_t queues[MAX_PORTS_QUEUES];
+	uint16_t num_queues;
+	uint16_t num_ports;
+	uint8_t shw_all_queues:1,
+		shw_all_ports:1,
+		dump_xstats:1,
+		reset_xstats:1,
+		shw_device_xstats:1;
+};
+
+static struct eventdev_params eventdev_var[RTE_EVENT_MAX_DEVS];
+
 #define DESC_PARAM_NUM 3
 
 struct desc_param {
@@ -172,7 +192,12 @@ proc_info_usage(const char *prgname)
 			"offset: The offset of the descriptor starting from tail. "
 			"num: The number of the descriptors to dump.\n"
 		"  --iter-mempool=name: iterate mempool elements to display content\n"
-		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
+		"  --dump-regs=file-prefix: dump registers to file with the file-prefix\n"
+		"  --show-edev-queue-xstats=queue_num:evdev_id or *:evdev_id to get queue xstats for specified queue or all queues;\n"
+		"  --show-edev-port-xstats=port_num:evdev_id or *:evdev_id to get queue xstats for specified port or all ports;\n"
+		"  --edev-dump-xstats=evdev_id to dump all event_dev xstats for specified eventdev device;\n"
+		"  --edev-reset-xstats=evdev_id to reset event_dev xstats after reading;\n"
+		"  --show-edev-device-xstats=evdev_id to get event_dev device xstats for specified eventdev device;\n",
 		prgname);
 }
 
@@ -236,6 +261,125 @@ parse_descriptor_param(char *list, struct desc_param *desc)
 	return 0;
 }
 
+static int
+parse_eventdev_id(const char *str)
+{
+	unsigned long evdev_id;
+	char *endp;
+
+	evdev_id = strtoul(str, &endp, 0);
+
+	if (*str == '\0' || *endp != '\0' || evdev_id >= rte_event_dev_count()) {
+		fprintf(stderr, "Invalid eventdev id: %s\n", str);
+		return -1;
+	}
+
+	return evdev_id;
+}
+
+static int
+parse_eventdev_dump_xstats_params(const char *list)
+{
+	int evdev_id = parse_eventdev_id(list);
+
+	if (evdev_id < 0)
+		return -EINVAL;
+
+	eventdev_var[evdev_id].dump_xstats = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_reset_xstats_params(const char *list)
+{
+	int evdev_id = parse_eventdev_id(list);
+
+	if (evdev_id < 0)
+		return -EINVAL;
+
+	eventdev_var[evdev_id].reset_xstats = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_device_xstats_params(const char *list)
+{
+	int evdev_id = parse_eventdev_id(list);
+
+	if (evdev_id < 0)
+		return -EINVAL;
+
+	eventdev_var[evdev_id].shw_device_xstats = 1;
+
+	return 0;
+}
+
+static int
+parse_eventdev_queue_xstats_params(const char *list)
+{
+	uint16_t queue_id;
+	uint16_t evdev_id;
+
+	if (sscanf(list, "*:%hu", &evdev_id) == 1) {
+		if (evdev_id >= rte_event_dev_count()) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_queues = 1;
+	} else if (sscanf(list, "%hu:%hu", &queue_id, &evdev_id) == 2) {
+		if (evdev_id >= rte_event_dev_count()) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+
+		if (queue_id >= MAX_PORTS_QUEUES) {
+			printf("Invalid queue_id: %hu\n", queue_id);
+			return -EINVAL;
+		}
+
+		eventdev_var[evdev_id].queues[eventdev_var[evdev_id].num_queues] = queue_id;
+		eventdev_var[evdev_id].num_queues++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int
+parse_eventdev_port_xstats_params(const char *list)
+{
+	uint16_t port_id;
+	uint16_t evdev_id;
+
+	if (sscanf(list, "*:%hu", &evdev_id) == 1) {
+		if (evdev_id >= rte_event_dev_count()) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+		eventdev_var[evdev_id].shw_all_ports = 1;
+	} else if (sscanf(list, "%hu:%hu", &port_id, &evdev_id) == 2) {
+		if (evdev_id >= rte_event_dev_count()) {
+			printf("Invalid eventdev id: %hu\n", evdev_id);
+			return -EINVAL;
+		}
+
+		if (port_id >= MAX_PORTS_QUEUES) {
+			printf("Invalid port_id: %hu\n", port_id);
+			return -EINVAL;
+		}
+
+		eventdev_var[evdev_id].ports[eventdev_var[evdev_id].num_ports] = port_id;
+		eventdev_var[evdev_id].num_ports++;
+	} else {
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int
 proc_info_preparse_args(int argc, char **argv)
 {
@@ -302,6 +446,11 @@ proc_info_parse_args(int argc, char **argv)
 		{"show-module-eeprom", 0, NULL, 0},
 		{"show-rx-descriptor", required_argument, NULL, 1},
 		{"show-tx-descriptor", required_argument, NULL, 1},
+		{"show-edev-queue-xstats", required_argument, NULL, 0},
+		{"show-edev-port-xstats", required_argument, NULL, 0},
+		{"edev-dump-xstats", required_argument, NULL, 0},
+		{"edev-reset-xstats", required_argument, NULL, 0},
+		{"show-edev-device-xstats", required_argument, NULL, 0},
 		{NULL, 0, 0, 0}
 	};
 
@@ -385,6 +534,47 @@ proc_info_parse_args(int argc, char **argv)
 			else if (!strncmp(long_option[option_index].name,
 					"show-module-eeprom", MAX_LONG_OPT_SZ))
 				enable_shw_module_eeprom = 1;
+			else if (!strncmp(long_option[option_index].name,
+					"edev-dump-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_dump_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev dump xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"edev-reset-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_reset_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-device-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_device_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev reset xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-queue-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_queue_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev queue xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			} else if (!strncmp(long_option[option_index].name,
+					"show-edev-port-xstats", MAX_LONG_OPT_SZ)) {
+				int ret = parse_eventdev_port_xstats_params(optarg);
+				if (ret < 0) {
+					fprintf(stderr, "Error parsing eventdev port xstats params: %s\n",
+						strerror(-ret));
+					return -1;
+				}
+			}
 			break;
 		case 1:
 			/* Print xstat single value given by name*/
@@ -1744,6 +1934,186 @@ nic_tx_descriptor_display(uint16_t port_id, struct desc_param *desc)
 			strerror(-ret));
 }
 
+static void
+xstats_display(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	uint64_t *values;
+	int size;
+	int i;
+
+	size = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (size < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     (unsigned int)size);
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	values = malloc(sizeof(uint64_t) * size);
+	if (!values)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_get(dev_id, mode, queue_port_id,
+					    ids, values, size);
+
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_get err %d\n", ret);
+
+	for (i = 0; i < size; i++) {
+		printf("id %"PRIu64"  %s = %"PRIu64"\n",
+			ids[i], &xstats_names[i].name[0], values[i]);
+	}
+
+	free(values);
+	free(xstats_names);
+	free(ids);
+
+}
+
+static void
+xstats_reset(uint8_t dev_id,
+	  enum rte_event_dev_xstats_mode mode,
+	  uint8_t queue_port_id)
+{
+	int ret;
+	struct rte_event_dev_xstats_name *xstats_names;
+	uint64_t *ids;
+	int size;
+
+	size = rte_event_dev_xstats_names_get(dev_id,
+					     mode,
+					     queue_port_id,
+					     NULL, /* names */
+					     NULL, /* ids */
+					     0);   /* num */
+
+	if (size < 0)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", size);
+
+	if (size == 0) {
+		printf(
+		"No stats available for this item, mode=%d, queue_port_id=%d\n",
+			mode, queue_port_id);
+		return;
+	}
+
+	/* Get memory to hold stat names, IDs, and values */
+	xstats_names = malloc(sizeof(struct rte_event_dev_xstats_name) * (unsigned int)size);
+	ids = malloc(sizeof(unsigned int) * size);
+
+	if (!xstats_names || !ids)
+		rte_panic("unable to alloc memory for stats retrieval\n");
+
+	ret = rte_event_dev_xstats_names_get(dev_id, mode, queue_port_id,
+					     xstats_names, ids,
+					     (unsigned int)size);
+	if (ret != size)
+		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);
+
+	rte_event_dev_xstats_reset(dev_id, mode, queue_port_id,
+					   ids, size);
+
+	free(xstats_names);
+	free(ids);
+
+}
+
+static int
+process_eventdev_xstats(void)
+{
+	int i;
+	int j;
+	int processing_eventdev_xstats = 0;
+
+	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
+
+		if (!processing_eventdev_xstats)
+			processing_eventdev_xstats = 1;
+
+		if (eventdev_var[i].dump_xstats) {
+			int ret = rte_event_dev_dump(i, stdout);
+
+			if (ret)
+				rte_panic("dump failed with err=%d\n", ret);
+		}
+
+		if (eventdev_var[i].shw_device_xstats == 1) {
+			xstats_display(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+
+			if (eventdev_var[i].reset_xstats == 1)
+				xstats_reset(i, RTE_EVENT_DEV_XSTATS_DEVICE, 0);
+		}
+
+		if (eventdev_var[i].shw_all_ports == 1) {
+			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT, j);
+			}
+		} else {
+			for (j = 0; j < eventdev_var[i].num_ports; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_PORT,
+					eventdev_var[i].ports[j]);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_PORT,
+							eventdev_var[i].ports[j]);
+			}
+		}
+
+		if (eventdev_var[i].shw_all_queues == 1) {
+			for (j = 0; j < MAX_PORTS_QUEUES; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE, j);
+			}
+		} else {
+			for (j = 0; j < eventdev_var[i].num_queues; j++) {
+				xstats_display(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+						eventdev_var[i].queues[j]);
+
+				if (eventdev_var[i].reset_xstats == 1)
+					xstats_reset(i, RTE_EVENT_DEV_XSTATS_QUEUE,
+							eventdev_var[i].queues[j]);
+			}
+		}
+	}
+
+	if (processing_eventdev_xstats)
+		return 1;
+
+	return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1794,6 +2164,9 @@ main(int argc, char **argv)
 		return 0;
 	}
 
+	if (process_eventdev_xstats())
+		return 0;
+
 	nb_ports = rte_eth_dev_count_avail();
 	if (nb_ports == 0)
 		rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
app/proc-info/meson.build +1 -1
index 1563ce656a..4f83f29a64 100644
@@ -8,7 +8,7 @@ if is_windows
 endif
 
 sources = files('main.c')
-deps += ['ethdev', 'security']
+deps += ['ethdev', 'security', 'eventdev']
 if dpdk_conf.has('RTE_LIB_METRICS')
     deps += 'metrics'
 endif
doc/guides/tools/proc_info.rst +25 -1
index cf3502a8cb..bb483afbce 100644
@@ -22,7 +22,9 @@ The application has a number of command line options:
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
    --show-module-eeprom | --show-rx-descriptor queue_id:offset:num |
-   --show-tx-descriptor queue_id:offset:num ]
+   --show-tx-descriptor queue_id:offset:num | --show-edev-queue-xstats=queue_num:evdev_id |
+   --show-edev-port-xstats=port_num :evdev_id | --edev-dump-xstats=evdev_id |
+   --edev-reset-xstats=evdev_id | --show-edev-device-xstats=evdev_id]
 
 Parameters
 ~~~~~~~~~~
@@ -101,6 +103,28 @@ queue_id: A Tx queue identifier on this port.
 offset: The offset of the descriptor starting from tail.
 num: The number of the descriptors to dump.
 
+**--show-edev-queue-xstats queue_num:evdev_id**
+The show-edev-queue-xstats parameter enables stats for specified queue or all queues.
+queue_num: The queue number to get queue xstats for this specified queue or * for all queues.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-port-xstats port_num:evdev_id**
+The show-edev-port-xstats parameter enables stats for specified port or all ports.
+port_num: The port number to get port xstats for this specified port or * for all ports.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-dump-xstats evdev_id**
+The edev-dump-xstats parameter dumps all eventdev stats.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--edev-reset-xstats evdev_id**
+The edev-reset-xstats parameter resets eventdev xstats after reading.
+evdev_id: Id of the eventdev device to display xstats.
+
+**--show-edev-device-xstats evdev_id**
+The show-edev-device-xstats parameter displays eventdev device xstats.
+evdev_id: Id of the eventdev device to display xstats.
+
 Limitations
 -----------
 
Signature · 1 line
2.25.1
Acked-by on v17 1/1
#48 lore raw

Re: [PATCH v17] app/procinfo: display eventdev xstats

Quoted 14 lines · On Thu, 25 May 2023 13:47:31 -0500 Abdullah Sevincer…

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Quoted 6 lines

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

#49 lore raw

Re: [PATCH v17] app/procinfo: display eventdev xstats

25/05/2023 22:07, Stephen Hemminger:

Quoted 17 lines
Quoted 14 lines · On Thu, 25 May 2023 13:47:31 -0500 Abdullah Sevincer…

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Quoted 8 lines
Quoted 6 lines

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

Applied, thanks.

#50 lore raw

Re: [PATCH v17] app/procinfo: display eventdev xstats

Quoted 23 lines · On Fri, 07 Jul 2023 11:15:22 +0200 Thomas Monjalon <[email protected]> wrote:

25/05/2023 22:07, Stephen Hemminger:

Quoted 22 lines
Quoted 19 lines · On Thu, 25 May 2023 13:47:31 -0500 Abdullah Sevincer…

This commit extends proc-info application to display xstats for the eventdev devices.

New command line arguments are introduced to display xstats for eventdev devices. The command example is like:

For displaying a specific port stats (e.g. port 1):
./dpdk-proc-info -- --show-edev-port-xstats=1:0

If any xstats parameters for eventdev passed through proc-info command line, proc-info will only display requested eventdev data and exit.

Users should not pass any eventdev xstats parameters if they desire to dump other proc-info data such as Rx/Tx descriptor dump.
More information can be found in proc-info app doc.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks.

Has new coverity issue.
The reason is the boolean is set every time because it gets every time.

Looks like code goes over eventdev_var[] even if no eventdevs are present. Should only look for the number of eventdevs

*** CID 395458: Control flow issues (DEADCODE) /app/proc-info/main.c: 2114 in process_eventdev_xstats()
2108 }
2109 }
2110
2111 if (processing_eventdev_xstats)
2112 return 1;
2113

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 395458: Control flow issues (DEADCODE) Execution cannot reach this statement: "return 0;".

2114 return 0;
2115 }
2116

2117     int
2118     main(int argc, char **argv)
2119     {
#51 lore raw

RE: [PATCH v17] app/procinfo: display eventdev xstats

Review

Quoted 6 lines
(quoted diff) +4 -0
+Has new coverity issue.
+The reason is the boolean is set every time because it gets every time.
 
+Looks like code goes over eventdev_var[] even if no eventdevs are present.
+Should only look for the number of eventdevs

Thanks Stephen, I will add a condition at the top of the function like:

evdevs = rte_event_dev_count();
	if (!evdevs)
		return 0;

This will ensure if there is no eventdev device function returns.

I will also change the for loop to iterate only with the count of evdevs like:
for (i = 0; i < evdevs; i++) {....... instead of for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {.

I still need that flag to be set when a user sets a value from command line for a queue or port. The flag is needed to display and exit from the program.

if (process_eventdev_xstats())

		return 0;
#52 lore raw

Re: [PATCH v17] app/procinfo: display eventdev xstats

Quoted 14 lines · Abdullah

Review

Quoted 5 lines
(quoted diff) +4 -0
+Has new coverity issue.
+The reason is the boolean is set every time because it gets every time.  
 
+Looks like code goes over eventdev_var[] even if no eventdevs are present.
+Should only look for the number of eventdevs  

Thanks Stephen, I will add a condition at the top of the function like:

evdevs = rte_event_dev_count();
	if (!evdevs)
		return 0;

This will ensure if there is no eventdev device function returns.

Quoted 9 lines

I will also change the for loop to iterate only with the count of evdevs like:
for (i = 0; i < evdevs; i++) {....... instead of for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {.

I still need that flag to be set when a user sets a value from command line for a queue or port. The flag is needed to display and exit from the program.

if (process_eventdev_xstats())

		return 0;

Maybe something like this:

PS: also shortened variable names for clarity

app/proc-info/main.c +8 -15
index be63eace6909..e3d2578c39dc 100644
@@ -2045,18 +2045,13 @@ xstats_reset(uint8_t dev_id,
 
 }
 
-static int
-process_eventdev_xstats(void)
+static unsigned int
+eventdev_xstats(void)
 {
-	int i;
-	int j;
-	int processing_eventdev_xstats = 0;
-
-	for (i = 0; i < RTE_EVENT_MAX_DEVS; i++) {
-
-		if (!processing_eventdev_xstats)
-			processing_eventdev_xstats = 1;
+	unsigned int count = 0;
+	int i, j;
 
+	for (i = 0; i < rte_event_dev_count(); i++) {
 		if (eventdev_var[i].dump_xstats) {
 			int ret = rte_event_dev_dump(i, stdout);
 
@@ -2106,12 +2101,10 @@ process_eventdev_xstats(void)
 							eventdev_var[i].queues[j]);
 			}
 		}
+		++count;
 	}
 
-	if (processing_eventdev_xstats)
-		return 1;
-
-	return 0;
+	return count;
 }
 
 int
@@ -2164,7 +2157,7 @@ main(int argc, char **argv)
 		return 0;
 	}
 
-	if (process_eventdev_xstats())
+	if (eventdev_xstats() > 0)
 		return 0;
 
 	nb_ports = rte_eth_dev_count_avail();