DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/eventdev_dump: introduce eventdev_dump application
@ 2022-04-09 15:30 Timothy McDaniel
  2022-04-10  6:48 ` Jerin Jacob
                   ` (5 more replies)
  0 siblings, 6 replies; 55+ messages in thread
From: Timothy McDaniel @ 2022-04-09 15:30 UTC (permalink / raw)
  To: jerinj; +Cc: dev

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.

Signed-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>
---
 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

diff --git a/app/eventdev_dump/main.c b/app/eventdev_dump/main.c
new file mode 100644
index 0000000000..c80baa4c45
--- /dev/null
+++ b/app/eventdev_dump/main.c
@@ -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;
+}
diff --git a/app/eventdev_dump/meson.build b/app/eventdev_dump/meson.build
new file mode 100644
index 0000000000..70d7db52d1
--- /dev/null
+++ b/app/eventdev_dump/meson.build
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Intel Corporation
+
+sources = files('main.c')
+deps += ['eventdev']
diff --git a/app/meson.build b/app/meson.build
index 93d8c15032..06aecefca3 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -18,6 +18,7 @@ apps = [
         'test-pmd',
         'test-regex',
         'test-sad',
+	'eventdev_dump',
 ]
 
 default_cflags = machine_args + ['-DALLOW_EXPERIMENTAL_API']
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH] app/eventdev_dump: introduce eventdev_dump application
  2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
@ 2022-04-10  6:48 ` Jerin Jacob
  2022-04-10 13:18   ` McDaniel, Timothy
  2023-02-06 18:34 ` [PATCH v2] app/procinfo: display eventdev xstats for PMD data Abdullah Sevincer
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 55+ messages in thread
From: Jerin Jacob @ 2022-04-10  6:48 UTC (permalink / raw)
  To: Timothy McDaniel, Maryam Tahhan, Reshma Pattan; +Cc: Jerin Jacob, dpdk-dev

On Sat, Apr 9, 2022 at 9:01 PM Timothy McDaniel
<timothy.mcdaniel@intel.com> wrote:
>
> 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.

+ maryam.tahhan@intel.com, reshma.pattan@intel.com
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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH] app/eventdev_dump: introduce eventdev_dump application
  2022-04-10  6:48 ` Jerin Jacob
@ 2022-04-10 13:18   ` McDaniel, Timothy
  0 siblings, 0 replies; 55+ messages in thread
From: McDaniel, Timothy @ 2022-04-10 13:18 UTC (permalink / raw)
  To: Jerin Jacob, Maryam Tahhan, Pattan, Reshma; +Cc: Jerin Jacob, dpdk-dev



> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Sunday, April 10, 2022 1:49 AM
> To: McDaniel, Timothy <timothy.mcdaniel@intel.com>; Maryam Tahhan
> <maryam.tahhan@intel.com>; Pattan, Reshma <reshma.pattan@intel.com>
> Cc: Jerin Jacob <jerinj@marvell.com>; dpdk-dev <dev@dpdk.org>
> Subject: Re: [PATCH] app/eventdev_dump: introduce eventdev_dump
> application
> 
> On Sat, Apr 9, 2022 at 9:01 PM Timothy McDaniel
> <timothy.mcdaniel@intel.com> wrote:
> >
> > 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.
> 
> + maryam.tahhan@intel.com, reshma.pattan@intel.com
> 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

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v2] app/procinfo: display eventdev xstats for PMD data
  2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
  2022-04-10  6:48 ` Jerin Jacob
@ 2023-02-06 18:34 ` Abdullah Sevincer
  2023-02-06 23:05 ` [PATCH v3] " Abdullah Sevincer
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-02-06 18:34 UTC (permalink / raw)
  To: dev; +Cc: jerinj, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..25b36205d0 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..1157fca299 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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,47 @@ 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-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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v3] app/procinfo: display eventdev xstats for PMD data
  2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
  2022-04-10  6:48 ` Jerin Jacob
  2023-02-06 18:34 ` [PATCH v2] app/procinfo: display eventdev xstats for PMD data Abdullah Sevincer
@ 2023-02-06 23:05 ` Abdullah Sevincer
  2023-02-07  0:22   ` Stephen Hemminger
  2023-02-07  0:04 ` [PATCH v4] " Abdullah Sevincer
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 55+ messages in thread
From: Abdullah Sevincer @ 2023-02-06 23:05 UTC (permalink / raw)
  To: dev; +Cc: jerinj, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..25b36205d0 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..59d8ff2490 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v4] app/procinfo: display eventdev xstats for PMD data
  2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
                   ` (2 preceding siblings ...)
  2023-02-06 23:05 ` [PATCH v3] " Abdullah Sevincer
@ 2023-02-07  0:04 ` Abdullah Sevincer
  2023-02-07 16:33 ` [PATCH v5] " Abdullah Sevincer
  2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
  5 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-02-07  0:04 UTC (permalink / raw)
  To: dev; +Cc: jerinj, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..25b36205d0 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..59d8ff2490 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data
  2023-02-06 23:05 ` [PATCH v3] " Abdullah Sevincer
@ 2023-02-07  0:22   ` Stephen Hemminger
  2023-02-12 19:43     ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-02-07  0:22 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj

On Mon,  6 Feb 2023 17:05:05 -0600
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> +
> +	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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v5] app/procinfo: display eventdev xstats for PMD data
  2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
                   ` (3 preceding siblings ...)
  2023-02-07  0:04 ` [PATCH v4] " Abdullah Sevincer
@ 2023-02-07 16:33 ` Abdullah Sevincer
  2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
  5 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-02-07 16:33 UTC (permalink / raw)
  To: dev; +Cc: jerinj, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..25b36205d0 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..59d8ff2490 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data
  2023-02-07  0:22   ` Stephen Hemminger
@ 2023-02-12 19:43     ` Sevincer, Abdullah
  2023-02-17 15:58       ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-02-12 19:43 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, jerinj

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 <stephen@networkplumber.org> 
Sent: Monday, February 6, 2023 4:22 PM
To: Sevincer, Abdullah <abdullah.sevincer@intel.com>
Cc: dev@dpdk.org; jerinj@marvell.com
Subject: Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

On Mon,  6 Feb 2023 17:05:05 -0600
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> +
> +	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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data
  2023-02-12 19:43     ` Sevincer, Abdullah
@ 2023-02-17 15:58       ` Sevincer, Abdullah
  2023-02-17 16:33         ` Stephen Hemminger
  0 siblings, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-02-17 15:58 UTC (permalink / raw)
  To: Sevincer, Abdullah, Stephen Hemminger; +Cc: dev, jerinj

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 <abdullah.sevincer@intel.com> 
Sent: Sunday, February 12, 2023 11:44 AM
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org; jerinj@marvell.com
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 <stephen@networkplumber.org> 
Sent: Monday, February 6, 2023 4:22 PM
To: Sevincer, Abdullah <abdullah.sevincer@intel.com>
Cc: dev@dpdk.org; jerinj@marvell.com
Subject: Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

On Mon,  6 Feb 2023 17:05:05 -0600
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> +
> +	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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data
  2023-02-17 15:58       ` Sevincer, Abdullah
@ 2023-02-17 16:33         ` Stephen Hemminger
  2023-02-22  1:54           ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-02-17 16:33 UTC (permalink / raw)
  To: Sevincer, Abdullah; +Cc: dev, jerinj

On Fri, 17 Feb 2023 15:58:52 +0000
"Sevincer, Abdullah" <abdullah.sevincer@intel.com> wrote:

> From: Sevincer, Abdullah <abdullah.sevincer@intel.com> 
> Sent: Sunday, February 12, 2023 11:44 AM
> To: Stephen Hemminger <stephen@networkplumber.org>
> Cc: dev@dpdk.org; jerinj@marvell.com
> 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.

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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v3] app/procinfo: display eventdev xstats for PMD data
  2023-02-17 16:33         ` Stephen Hemminger
@ 2023-02-22  1:54           ` Sevincer, Abdullah
  0 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-02-22  1:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, jerinj

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 <stephen@networkplumber.org> 
Sent: Friday, February 17, 2023 8:33 AM
To: Sevincer, Abdullah <abdullah.sevincer@intel.com>
Cc: dev@dpdk.org; jerinj@marvell.com
Subject: Re: [PATCH v3] app/procinfo: display eventdev xstats for PMD data

On Fri, 17 Feb 2023 15:58:52 +0000
"Sevincer, Abdullah" <abdullah.sevincer@intel.com> wrote:

> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>
> Sent: Sunday, February 12, 2023 11:44 AM
> To: Stephen Hemminger <stephen@networkplumber.org>
> Cc: dev@dpdk.org; jerinj@marvell.com
> 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.

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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v6] app/procinfo: display eventdev xstats for PMD data
  2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
                   ` (4 preceding siblings ...)
  2023-02-07 16:33 ` [PATCH v5] " Abdullah Sevincer
@ 2023-02-23  1:08 ` Abdullah Sevincer
  2023-02-27 16:33   ` Jerin Jacob
                     ` (3 more replies)
  5 siblings, 4 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-02-23  1:08 UTC (permalink / raw)
  To: dev; +Cc: jerinj, stephen, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..00bcd35fad 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..59d8ff2490 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v6] app/procinfo: display eventdev xstats for PMD data
  2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
@ 2023-02-27 16:33   ` Jerin Jacob
  2023-03-03 10:58   ` Pattan, Reshma
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 55+ messages in thread
From: Jerin Jacob @ 2023-02-27 16:33 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, stephen, Maryam Tahhan, Reshma Pattan

On Thu, Feb 23, 2023 at 6:38 AM Abdullah Sevincer
<abdullah.sevincer@intel.com> wrote:
>
> 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.
>
> Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>

Please CC the maintainers.

@maryam.tahhan@intel.com @reshma.pattan@intel.com
Please review
> ---
>  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(-)
>
> diff --git a/app/proc-info/main.c b/app/proc-info/main.c
> index 53e852a07c..00bcd35fad 100644
> --- a/app/proc-info/main.c
> +++ b/app/proc-info/main.c
> @@ -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");
> diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
> index 1563ce656a..4f83f29a64 100644
> --- a/app/proc-info/meson.build
> +++ b/app/proc-info/meson.build
> @@ -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
> diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
> index cf3502a8cb..59d8ff2490 100644
> --- a/doc/guides/tools/proc_info.rst
> +++ b/doc/guides/tools/proc_info.rst
> @@ -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
>

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data
  2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
  2023-02-27 16:33   ` Jerin Jacob
@ 2023-03-03 10:58   ` Pattan, Reshma
  2023-03-03 16:22     ` Sevincer, Abdullah
  2023-03-09 18:27   ` [PATCH v7] app/procinfo: display eventdev xstats Abdullah Sevincer
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
  3 siblings, 1 reply; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-03 10:58 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj, stephen, Sevincer, Abdullah



> -----Original Message-----
> From: Abdullah Sevincer <abdullah.sevincer@intel.com>


> 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"


> +++ b/doc/guides/tools/proc_info.rst
> @@ -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



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data
  2023-03-03 10:58   ` Pattan, Reshma
@ 2023-03-03 16:22     ` Sevincer, Abdullah
  2023-03-04  7:17       ` Pattan, Reshma
  0 siblings, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-03 16:22 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: jerinj, stephen


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 <reshma.pattan@intel.com> 
Sent: Friday, March 3, 2023 2:58 AM
To: Sevincer, Abdullah <abdullah.sevincer@intel.com>; dev@dpdk.org
Cc: jerinj@marvell.com; stephen@networkplumber.org; Sevincer, Abdullah <abdullah.sevincer@intel.com>
Subject: RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data



> -----Original Message-----
> From: Abdullah Sevincer <abdullah.sevincer@intel.com>


> 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"


> +++ b/doc/guides/tools/proc_info.rst
> @@ -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



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v6] app/procinfo: display eventdev xstats for PMD data
  2023-03-03 16:22     ` Sevincer, Abdullah
@ 2023-03-04  7:17       ` Pattan, Reshma
  0 siblings, 0 replies; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-04  7:17 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj, stephen



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>
> 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

 
> --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--


> 
> 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

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v7] app/procinfo: display eventdev xstats
  2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
  2023-02-27 16:33   ` Jerin Jacob
  2023-03-03 10:58   ` Pattan, Reshma
@ 2023-03-09 18:27   ` Abdullah Sevincer
  2023-03-09 20:31     ` Stephen Hemminger
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
  3 siblings, 1 reply; 55+ messages in thread
From: Abdullah Sevincer @ 2023-03-09 18:27 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..c004f63e2c 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..ad6d2e8aeb 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v8] app/procinfo: display eventdev xstats
  2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
                     ` (2 preceding siblings ...)
  2023-03-09 18:27   ` [PATCH v7] app/procinfo: display eventdev xstats Abdullah Sevincer
@ 2023-03-09 18:51   ` Abdullah Sevincer
  2023-03-15 11:56     ` Pattan, Reshma
                       ` (5 more replies)
  3 siblings, 6 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-03-09 18:51 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..6ead43a439 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..ad6d2e8aeb 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v7] app/procinfo: display eventdev xstats
  2023-03-09 18:27   ` [PATCH v7] app/procinfo: display eventdev xstats Abdullah Sevincer
@ 2023-03-09 20:31     ` Stephen Hemminger
  2023-03-10 17:35       ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-03-09 20:31 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, reshma.pattan

On Thu,  9 Mar 2023 12:27:58 -0600
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

>  
> +/* 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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v7] app/procinfo: display eventdev xstats
  2023-03-09 20:31     ` Stephen Hemminger
@ 2023-03-10 17:35       ` Sevincer, Abdullah
  2023-03-10 17:49         ` Stephen Hemminger
  0 siblings, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-10 17:35 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, jerinj, Pattan, Reshma


From: Stephen Hemminger <stephen@networkplumber.org> 
Sent: Thursday, March 9, 2023 12:32 PM
To: Sevincer, Abdullah <abdullah.sevincer@intel.com>
Cc: dev@dpdk.org; jerinj@marvell.com; Pattan, Reshma <reshma.pattan@intel.com>
Subject: Re: [PATCH v7] app/procinfo: display eventdev xstats

On Thu,  9 Mar 2023 12:27:58 -0600
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

>  
> +/* 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.





^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v7] app/procinfo: display eventdev xstats
  2023-03-10 17:35       ` Sevincer, Abdullah
@ 2023-03-10 17:49         ` Stephen Hemminger
  2023-03-10 18:06           ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-03-10 17:49 UTC (permalink / raw)
  To: Sevincer, Abdullah; +Cc: dev, jerinj, Pattan, Reshma

On Fri, 10 Mar 2023 17:35:31 +0000
"Sevincer, Abdullah" <abdullah.sevincer@intel.com> wrote:

> >  
> > +/* 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.


I don't think it will happen this year.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v7] app/procinfo: display eventdev xstats
  2023-03-10 17:49         ` Stephen Hemminger
@ 2023-03-10 18:06           ` Sevincer, Abdullah
  0 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-10 18:06 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, jerinj, Pattan, Reshma


> >  
> > +/* 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.


>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? 

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v8] app/procinfo: display eventdev xstats
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
@ 2023-03-15 11:56     ` Pattan, Reshma
  2023-03-15 19:40       ` Sevincer, Abdullah
  2023-03-15 14:24     ` Pattan, Reshma
                       ` (4 subsequent siblings)
  5 siblings, 1 reply; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-15 11:56 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj



> -----Original Message-----
>  app/proc-info/main.c           | 210 ++++++++++++++++++++++++++++++++-

> +		{"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.

> +	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.
 

> diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst

> +   --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?


> +**--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. 



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v8] app/procinfo: display eventdev xstats
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
  2023-03-15 11:56     ` Pattan, Reshma
@ 2023-03-15 14:24     ` Pattan, Reshma
  2023-03-18 18:49       ` Sevincer, Abdullah
  2023-03-20  2:11     ` [PATCH v9] " Abdullah Sevincer
                       ` (3 subsequent siblings)
  5 siblings, 1 reply; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-15 14:24 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>


> +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.


> +
> +		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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v8] app/procinfo: display eventdev xstats
  2023-03-15 11:56     ` Pattan, Reshma
@ 2023-03-15 19:40       ` Sevincer, Abdullah
  0 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-15 19:40 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: jerinj




From: Pattan, Reshma <reshma.pattan@intel.com> 
Sent: Wednesday, March 15, 2023 4:57 AM
To: Sevincer, Abdullah <abdullah.sevincer@intel.com>; dev@dpdk.org
Cc: jerinj@marvell.com
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. 
 


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v8] app/procinfo: display eventdev xstats
  2023-03-15 14:24     ` Pattan, Reshma
@ 2023-03-18 18:49       ` Sevincer, Abdullah
  0 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-18 18:49 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: jerinj




> +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. 


> +
> +		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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v9] app/procinfo: display eventdev xstats
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
  2023-03-15 11:56     ` Pattan, Reshma
  2023-03-15 14:24     ` Pattan, Reshma
@ 2023-03-20  2:11     ` Abdullah Sevincer
  2023-03-20  2:15     ` [PATCH v10] " Abdullah Sevincer
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-03-20  2:11 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..c6a854c993 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..f0a7d37e41 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v10] app/procinfo: display eventdev xstats
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
                       ` (2 preceding siblings ...)
  2023-03-20  2:11     ` [PATCH v9] " Abdullah Sevincer
@ 2023-03-20  2:15     ` Abdullah Sevincer
  2023-03-20  2:19     ` [PATCH v11] " Abdullah Sevincer
  2023-03-20  2:23     ` [PATCH v12] " Abdullah Sevincer
  5 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-03-20  2:15 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..c6a854c993 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..f0a7d37e41 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v11] app/procinfo: display eventdev xstats
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
                       ` (3 preceding siblings ...)
  2023-03-20  2:15     ` [PATCH v10] " Abdullah Sevincer
@ 2023-03-20  2:19     ` Abdullah Sevincer
  2023-03-20  2:23     ` [PATCH v12] " Abdullah Sevincer
  5 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-03-20  2:19 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..ceed525b3e 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..f0a7d37e41 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
                       ` (4 preceding siblings ...)
  2023-03-20  2:19     ` [PATCH v11] " Abdullah Sevincer
@ 2023-03-20  2:23     ` Abdullah Sevincer
  2023-03-20 17:29       ` Pattan, Reshma
                         ` (2 more replies)
  5 siblings, 3 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-03-20  2:23 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..0e0d8ab4ce 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..f0a7d37e41 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-20  2:23     ` [PATCH v12] " Abdullah Sevincer
@ 2023-03-20 17:29       ` Pattan, Reshma
  2023-03-20 18:01         ` Sevincer, Abdullah
  2023-03-20 18:35         ` Sevincer, Abdullah
  2023-05-17 21:22       ` [PATCH v13] " Abdullah Sevincer
  2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
  2 siblings, 2 replies; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-20 17:29 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>

> +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>

> +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;
}

> +	if (show_edev_xstats()) {

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


> +		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.

> +
> +		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()

> diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
> 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

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-20 17:29       ` Pattan, Reshma
@ 2023-03-20 18:01         ` Sevincer, Abdullah
  2023-03-20 18:35         ` Sevincer, Abdullah
  1 sibling, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-20 18:01 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: jerinj


+>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.


> +	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)


> +		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. 

> +
> +		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().

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

Thanks,
Abdullah

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-20 17:29       ` Pattan, Reshma
  2023-03-20 18:01         ` Sevincer, Abdullah
@ 2023-03-20 18:35         ` Sevincer, Abdullah
  2023-03-21  9:37           ` Pattan, Reshma
  1 sibling, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-20 18:35 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: jerinj




> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>

> +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>

> +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;
>+}

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?



^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-20 18:35         ` Sevincer, Abdullah
@ 2023-03-21  9:37           ` Pattan, Reshma
  2023-03-21 10:20             ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-21  9:37 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>
> >+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;
> >+}
> 
> 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


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-21  9:37           ` Pattan, Reshma
@ 2023-03-21 10:20             ` Sevincer, Abdullah
  2023-03-21 10:27               ` Pattan, Reshma
  0 siblings, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-03-21 10:20 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: jerinj




>+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.




^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v12] app/procinfo: display eventdev xstats
  2023-03-21 10:20             ` Sevincer, Abdullah
@ 2023-03-21 10:27               ` Pattan, Reshma
  0 siblings, 0 replies; 55+ messages in thread
From: Pattan, Reshma @ 2023-03-21 10:27 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>
> 
> >+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
> 
> 
> 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.


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v13] app/procinfo: display eventdev xstats
  2023-03-20  2:23     ` [PATCH v12] " Abdullah Sevincer
  2023-03-20 17:29       ` Pattan, Reshma
@ 2023-05-17 21:22       ` Abdullah Sevincer
  2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
  2 siblings, 0 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-05-17 21:22 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..80d5d33a22 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..a79e504d67 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v14] app/procinfo: display eventdev xstats
  2023-03-20  2:23     ` [PATCH v12] " Abdullah Sevincer
  2023-03-20 17:29       ` Pattan, Reshma
  2023-05-17 21:22       ` [PATCH v13] " Abdullah Sevincer
@ 2023-05-17 22:37       ` Abdullah Sevincer
  2023-05-17 22:45         ` Stephen Hemminger
                           ` (3 more replies)
  2 siblings, 4 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-05-17 22:37 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..9975d6a646 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..a79e504d67 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v14] app/procinfo: display eventdev xstats
  2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
@ 2023-05-17 22:45         ` Stephen Hemminger
  2023-05-17 23:30           ` Sevincer, Abdullah
  2023-05-24 15:09         ` Pattan, Reshma
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-05-17 22:45 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, reshma.pattan

On Wed, 17 May 2023 17:37:24 -0500
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> +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;
	}

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v14] app/procinfo: display eventdev xstats
  2023-05-17 22:45         ` Stephen Hemminger
@ 2023-05-17 23:30           ` Sevincer, Abdullah
  0 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-05-17 23:30 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, jerinj, Pattan, Reshma


> +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.

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v14] app/procinfo: display eventdev xstats
  2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
  2023-05-17 22:45         ` Stephen Hemminger
@ 2023-05-24 15:09         ` Pattan, Reshma
  2023-05-25  6:08         ` [PATCH v15] " Abdullah Sevincer
  2023-05-25 16:41         ` [PATCH v16] " Abdullah Sevincer
  3 siblings, 0 replies; 55+ messages in thread
From: Pattan, Reshma @ 2023-05-24 15:09 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>

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

> +
> +struct eventdev_params {
> +	uint32_t show_eventdev;

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

<snip>
> +	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>
> +
> +	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>

> +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>

> +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);

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.


> +	if (ret != (int)size)
> +		rte_panic("rte_event_dev_xstats_names_get err %d\n", ret);


<snip>


> +
> +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.


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v15] app/procinfo: display eventdev xstats
  2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
  2023-05-17 22:45         ` Stephen Hemminger
  2023-05-24 15:09         ` Pattan, Reshma
@ 2023-05-25  6:08         ` Abdullah Sevincer
  2023-05-25 15:24           ` Stephen Hemminger
  2023-05-25 16:41         ` [PATCH v16] " Abdullah Sevincer
  3 siblings, 1 reply; 55+ messages in thread
From: Abdullah Sevincer @ 2023-05-25  6:08 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..8fb4aea4c0 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..bb483afbce 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v15] app/procinfo: display eventdev xstats
  2023-05-25  6:08         ` [PATCH v15] " Abdullah Sevincer
@ 2023-05-25 15:24           ` Stephen Hemminger
  0 siblings, 0 replies; 55+ messages in thread
From: Stephen Hemminger @ 2023-05-25 15:24 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, reshma.pattan

On Thu, 25 May 2023 01:08:51 -0500
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> 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.
> 
> Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
> ---

Looks good, here are some minor touchup feedbacks.

> +static int
> +parse_eventdev_reset_xstats_params(char *list)

Could be "const char *list" here

> +{
> +	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.

> +		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;
> +}
> +


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v16] app/procinfo: display eventdev xstats
  2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
                           ` (2 preceding siblings ...)
  2023-05-25  6:08         ` [PATCH v15] " Abdullah Sevincer
@ 2023-05-25 16:41         ` Abdullah Sevincer
  2023-05-25 17:35           ` Stephen Hemminger
  2023-05-25 18:47           ` [PATCH v17] " Abdullah Sevincer
  3 siblings, 2 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-05-25 16:41 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..f53fab2e33 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..bb483afbce 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v16] app/procinfo: display eventdev xstats
  2023-05-25 16:41         ` [PATCH v16] " Abdullah Sevincer
@ 2023-05-25 17:35           ` Stephen Hemminger
  2023-05-25 17:56             ` Sevincer, Abdullah
  2023-05-25 18:47           ` [PATCH v17] " Abdullah Sevincer
  1 sibling, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-05-25 17:35 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, reshma.pattan

On Thu, 25 May 2023 11:41:27 -0500
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> 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.
> 
> Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>

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.

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index f53fab2e3346..d330afd6815e 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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;


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v16] app/procinfo: display eventdev xstats
  2023-05-25 17:35           ` Stephen Hemminger
@ 2023-05-25 17:56             ` Sevincer, Abdullah
  0 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-05-25 17:56 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, jerinj, Pattan, Reshma

>+ 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 😊

^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH v17] app/procinfo: display eventdev xstats
  2023-05-25 16:41         ` [PATCH v16] " Abdullah Sevincer
  2023-05-25 17:35           ` Stephen Hemminger
@ 2023-05-25 18:47           ` Abdullah Sevincer
  2023-05-25 20:07             ` Stephen Hemminger
                               ` (2 more replies)
  1 sibling, 3 replies; 55+ messages in thread
From: Abdullah Sevincer @ 2023-05-25 18:47 UTC (permalink / raw)
  To: dev; +Cc: jerinj, reshma.pattan, stephen, 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.

Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
---
 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(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 53e852a07c..be63eace69 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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");
diff --git a/app/proc-info/meson.build b/app/proc-info/meson.build
index 1563ce656a..4f83f29a64 100644
--- a/app/proc-info/meson.build
+++ b/app/proc-info/meson.build
@@ -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
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index cf3502a8cb..bb483afbce 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -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
 -----------
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v17] app/procinfo: display eventdev xstats
  2023-05-25 18:47           ` [PATCH v17] " Abdullah Sevincer
@ 2023-05-25 20:07             ` Stephen Hemminger
  2023-07-07  9:15               ` Thomas Monjalon
  2023-05-26  8:32             ` Pattan, Reshma
  2023-06-08 17:35             ` Sevincer, Abdullah
  2 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-05-25 20:07 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, reshma.pattan

On Thu, 25 May 2023 13:47:31 -0500
Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:

> 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.
> 
> Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v17] app/procinfo: display eventdev xstats
  2023-05-25 18:47           ` [PATCH v17] " Abdullah Sevincer
  2023-05-25 20:07             ` Stephen Hemminger
@ 2023-05-26  8:32             ` Pattan, Reshma
  2023-06-08 17:35             ` Sevincer, Abdullah
  2 siblings, 0 replies; 55+ messages in thread
From: Pattan, Reshma @ 2023-05-26  8:32 UTC (permalink / raw)
  To: Sevincer, Abdullah, dev; +Cc: jerinj, stephen



> -----Original Message-----
> From: Sevincer, Abdullah <abdullah.sevincer@intel.com>
> Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>

Acked-by: Reshma Pattan <reshma.pattan@intel.com>

^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v17] app/procinfo: display eventdev xstats
  2023-05-25 18:47           ` [PATCH v17] " Abdullah Sevincer
  2023-05-25 20:07             ` Stephen Hemminger
  2023-05-26  8:32             ` Pattan, Reshma
@ 2023-06-08 17:35             ` Sevincer, Abdullah
  2 siblings, 0 replies; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-06-08 17:35 UTC (permalink / raw)
  To: dev; +Cc: jerinj, Pattan, Reshma, stephen, thomas

>+Acked-by: Reshma Pattan <reshma.pattan@intel.com>
>+Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Reminder!
What's the plan to merge this patch?

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v17] app/procinfo: display eventdev xstats
  2023-05-25 20:07             ` Stephen Hemminger
@ 2023-07-07  9:15               ` Thomas Monjalon
  2023-07-07 14:55                 ` Stephen Hemminger
  0 siblings, 1 reply; 55+ messages in thread
From: Thomas Monjalon @ 2023-07-07  9:15 UTC (permalink / raw)
  To: Abdullah Sevincer; +Cc: dev, jerinj, reshma.pattan, Stephen Hemminger

25/05/2023 22:07, Stephen Hemminger:
> On Thu, 25 May 2023 13:47:31 -0500
> Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:
> 
> > 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.
> > 
> > Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied, thanks.




^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v17] app/procinfo: display eventdev xstats
  2023-07-07  9:15               ` Thomas Monjalon
@ 2023-07-07 14:55                 ` Stephen Hemminger
  2023-07-08 15:11                   ` Sevincer, Abdullah
  0 siblings, 1 reply; 55+ messages in thread
From: Stephen Hemminger @ 2023-07-07 14:55 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Abdullah Sevincer, dev, jerinj, reshma.pattan

On Fri, 07 Jul 2023 11:15:22 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> 25/05/2023 22:07, Stephen Hemminger:
> > On Thu, 25 May 2023 13:47:31 -0500
> > Abdullah Sevincer <abdullah.sevincer@intel.com> wrote:
> >   
> > > 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.
> > > 
> > > Signed-off-by: Abdullah Sevincer <abdullah.sevincer@intel.com>  
> > 
> > Acked-by: Stephen Hemminger <stephen@networkplumber.org>  
> 
> 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     
>>>     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     {


^ permalink raw reply	[flat|nested] 55+ messages in thread

* RE: [PATCH v17] app/procinfo: display eventdev xstats
  2023-07-07 14:55                 ` Stephen Hemminger
@ 2023-07-08 15:11                   ` Sevincer, Abdullah
  2023-07-08 15:26                     ` Stephen Hemminger
  0 siblings, 1 reply; 55+ messages in thread
From: Sevincer, Abdullah @ 2023-07-08 15:11 UTC (permalink / raw)
  To: Stephen Hemminger, Thomas Monjalon; +Cc: dev, jerinj, Pattan, Reshma


>+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;


^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH v17] app/procinfo: display eventdev xstats
  2023-07-08 15:11                   ` Sevincer, Abdullah
@ 2023-07-08 15:26                     ` Stephen Hemminger
  0 siblings, 0 replies; 55+ messages in thread
From: Stephen Hemminger @ 2023-07-08 15:26 UTC (permalink / raw)
  To: Sevincer, Abdullah; +Cc: Thomas Monjalon, dev, jerinj, Pattan, Reshma

On Sat, 8 Jul 2023 15:11:45 +0000
"Sevincer, Abdullah" <abdullah.sevincer@intel.com> wrote:

> >+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;
> 

Maybe something like this:

PS: also shortened variable names for clarity

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index be63eace6909..e3d2578c39dc 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -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();

^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2023-07-08 15:27 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-09 15:30 [PATCH] app/eventdev_dump: introduce eventdev_dump application Timothy McDaniel
2022-04-10  6:48 ` Jerin Jacob
2022-04-10 13:18   ` McDaniel, Timothy
2023-02-06 18:34 ` [PATCH v2] app/procinfo: display eventdev xstats for PMD data Abdullah Sevincer
2023-02-06 23:05 ` [PATCH v3] " Abdullah Sevincer
2023-02-07  0:22   ` Stephen Hemminger
2023-02-12 19:43     ` Sevincer, Abdullah
2023-02-17 15:58       ` Sevincer, Abdullah
2023-02-17 16:33         ` Stephen Hemminger
2023-02-22  1:54           ` Sevincer, Abdullah
2023-02-07  0:04 ` [PATCH v4] " Abdullah Sevincer
2023-02-07 16:33 ` [PATCH v5] " Abdullah Sevincer
2023-02-23  1:08 ` [PATCH v6] " Abdullah Sevincer
2023-02-27 16:33   ` Jerin Jacob
2023-03-03 10:58   ` Pattan, Reshma
2023-03-03 16:22     ` Sevincer, Abdullah
2023-03-04  7:17       ` Pattan, Reshma
2023-03-09 18:27   ` [PATCH v7] app/procinfo: display eventdev xstats Abdullah Sevincer
2023-03-09 20:31     ` Stephen Hemminger
2023-03-10 17:35       ` Sevincer, Abdullah
2023-03-10 17:49         ` Stephen Hemminger
2023-03-10 18:06           ` Sevincer, Abdullah
2023-03-09 18:51   ` [PATCH v8] " Abdullah Sevincer
2023-03-15 11:56     ` Pattan, Reshma
2023-03-15 19:40       ` Sevincer, Abdullah
2023-03-15 14:24     ` Pattan, Reshma
2023-03-18 18:49       ` Sevincer, Abdullah
2023-03-20  2:11     ` [PATCH v9] " Abdullah Sevincer
2023-03-20  2:15     ` [PATCH v10] " Abdullah Sevincer
2023-03-20  2:19     ` [PATCH v11] " Abdullah Sevincer
2023-03-20  2:23     ` [PATCH v12] " Abdullah Sevincer
2023-03-20 17:29       ` Pattan, Reshma
2023-03-20 18:01         ` Sevincer, Abdullah
2023-03-20 18:35         ` Sevincer, Abdullah
2023-03-21  9:37           ` Pattan, Reshma
2023-03-21 10:20             ` Sevincer, Abdullah
2023-03-21 10:27               ` Pattan, Reshma
2023-05-17 21:22       ` [PATCH v13] " Abdullah Sevincer
2023-05-17 22:37       ` [PATCH v14] " Abdullah Sevincer
2023-05-17 22:45         ` Stephen Hemminger
2023-05-17 23:30           ` Sevincer, Abdullah
2023-05-24 15:09         ` Pattan, Reshma
2023-05-25  6:08         ` [PATCH v15] " Abdullah Sevincer
2023-05-25 15:24           ` Stephen Hemminger
2023-05-25 16:41         ` [PATCH v16] " Abdullah Sevincer
2023-05-25 17:35           ` Stephen Hemminger
2023-05-25 17:56             ` Sevincer, Abdullah
2023-05-25 18:47           ` [PATCH v17] " Abdullah Sevincer
2023-05-25 20:07             ` Stephen Hemminger
2023-07-07  9:15               ` Thomas Monjalon
2023-07-07 14:55                 ` Stephen Hemminger
2023-07-08 15:11                   ` Sevincer, Abdullah
2023-07-08 15:26                     ` Stephen Hemminger
2023-05-26  8:32             ` Pattan, Reshma
2023-06-08 17:35             ` Sevincer, Abdullah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).