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

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