DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, jerinj@marvell.com, jiayu.hu@intel.com,
	Bruce Richardson <bruce.richardson@intel.com>,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [dpdk-dev] [PATCH v4 8/9] raw/ioat: add statistics functions
Date: Mon,  1 Jul 2019 16:55:59 +0100	[thread overview]
Message-ID: <20190701155600.43695-9-bruce.richardson@intel.com> (raw)
In-Reply-To: <20190701155600.43695-1-bruce.richardson@intel.com>

Add stats functions to track what is happening in the driver, and put
unit tests to check those.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
---
V4: pulled in memory leak fixes from next patch
V2: test cases moved to self-test routine
---
 doc/guides/rawdevs/ioat_rawdev.rst  | 14 +++++++++
 drivers/raw/ioat/ioat_rawdev.c      | 44 ++++++++++++++++++++++++++++
 drivers/raw/ioat/ioat_rawdev_test.c | 45 +++++++++++++++++++++++++++++
 drivers/raw/ioat/rte_ioat_rawdev.h  |  6 ++++
 4 files changed, 109 insertions(+)

diff --git a/doc/guides/rawdevs/ioat_rawdev.rst b/doc/guides/rawdevs/ioat_rawdev.rst
index a0594d2cb..40210b3f9 100644
--- a/doc/guides/rawdevs/ioat_rawdev.rst
+++ b/doc/guides/rawdevs/ioat_rawdev.rst
@@ -149,3 +149,17 @@ The following code shows how the device is configured in
 
 Once configured, the device can then be made ready for use by calling the
 ``rte_rawdev_start()`` API.
+
+Querying Device Statistics
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The statistics from the IOAT rawdev device can be got via the xstats
+functions in the ``rte_rawdev`` library, i.e.
+``rte_rawdev_xstats_names_get()``, ``rte_rawdev_xstats_get()`` and
+``rte_rawdev_xstats_by_name_get``. The statistics returned for each device
+instance are:
+
+* ``failed_enqueues``
+* ``successful_enqueues``
+* ``copies_started``
+* ``copies_completed``
diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawdev.c
index 7eeb42f89..06639aa69 100644
--- a/drivers/raw/ioat/ioat_rawdev.c
+++ b/drivers/raw/ioat/ioat_rawdev.c
@@ -4,6 +4,7 @@
 
 #include <rte_cycles.h>
 #include <rte_bus_pci.h>
+#include <rte_string_fns.h>
 #include <rte_rawdev_pmd.h>
 
 #include "rte_ioat_rawdev.h"
@@ -119,6 +120,47 @@ ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info)
 		cfg->ring_size = ioat->ring_size;
 }
 
+static const char * const xstat_names[] = {
+		"failed_enqueues", "successful_enqueues",
+		"copies_started", "copies_completed"
+};
+
+static int
+ioat_xstats_get(const struct rte_rawdev *dev, const unsigned int ids[],
+		uint64_t values[], unsigned int n)
+{
+	const struct rte_ioat_rawdev *ioat = dev->dev_private;
+	unsigned int i;
+
+	for (i = 0; i < n; i++) {
+		switch (ids[i]) {
+		case 0: values[i] = ioat->enqueue_failed; break;
+		case 1: values[i] = ioat->enqueued; break;
+		case 2: values[i] = ioat->started; break;
+		case 3: values[i] = ioat->completed; break;
+		default: values[i] = 0; break;
+		}
+	}
+	return n;
+}
+
+static int
+ioat_xstats_get_names(const struct rte_rawdev *dev,
+		struct rte_rawdev_xstats_name *names,
+		unsigned int size)
+{
+	unsigned int i;
+
+	RTE_SET_USED(dev);
+	if (size < RTE_DIM(xstat_names))
+		return RTE_DIM(xstat_names);
+
+	for (i = 0; i < RTE_DIM(xstat_names); i++)
+		strlcpy(names[i].name, xstat_names[i], sizeof(names[i]));
+
+	return RTE_DIM(xstat_names);
+}
+
 int ioat_rawdev_test(uint16_t dev_id);
 
 static int
@@ -129,6 +171,8 @@ ioat_rawdev_create(const char *name, struct rte_pci_device *dev)
 			.dev_start = ioat_dev_start,
 			.dev_stop = ioat_dev_stop,
 			.dev_info_get = ioat_dev_info_get,
+			.xstats_get = ioat_xstats_get,
+			.xstats_get_names = ioat_xstats_get_names,
 			.dev_selftest = ioat_rawdev_test,
 	};
 
diff --git a/drivers/raw/ioat/ioat_rawdev_test.c b/drivers/raw/ioat/ioat_rawdev_test.c
index 5375da26c..ab671816d 100644
--- a/drivers/raw/ioat/ioat_rawdev_test.c
+++ b/drivers/raw/ioat/ioat_rawdev_test.c
@@ -2,6 +2,7 @@
  * Copyright(c) 2019 Intel Corporation
  */
 
+#include <inttypes.h>
 #include "rte_rawdev.h"
 #include "rte_ioat_rawdev.h"
 
@@ -13,6 +14,11 @@ ioat_rawdev_test(uint16_t dev_id)
 #define IOAT_TEST_RINGSIZE 512
 	struct rte_ioat_rawdev_config p = { .ring_size = -1 };
 	struct rte_rawdev_info info = { .dev_private = &p };
+	struct rte_rawdev_xstats_name *snames = NULL;
+	uint64_t *stats = NULL;
+	unsigned int *ids = NULL;
+	unsigned int nb_xstats;
+	unsigned int i;
 
 	rte_rawdev_info_get(dev_id, &info);
 	if (p.ring_size != 0) {
@@ -37,5 +43,44 @@ ioat_rawdev_test(uint16_t dev_id)
 		printf("Error with rte_rawdev_start()\n");
 		return -1;
 	}
+
+	/* allocate memory for xstats names and values */
+	nb_xstats = rte_rawdev_xstats_names_get(dev_id, NULL, 0);
+
+	snames = malloc(sizeof(*snames) * nb_xstats);
+	if (snames == NULL) {
+		printf("Error allocating xstat names memory\n");
+		goto err;
+	}
+	rte_rawdev_xstats_names_get(dev_id, snames, nb_xstats);
+
+	ids = malloc(sizeof(*ids) * nb_xstats);
+	if (ids == NULL) {
+		printf("Error allocating xstat ids memory\n");
+		goto err;
+	}
+	for (i = 0; i < nb_xstats; i++)
+		ids[i] = i;
+
+	stats = malloc(sizeof(*stats) * nb_xstats);
+	if (stats == NULL) {
+		printf("Error allocating xstat memory\n");
+		goto err;
+	}
+
+	rte_rawdev_xstats_get(dev_id, ids, stats, nb_xstats);
+	for (i = 0; i < nb_xstats; i++)
+		printf("%s: %"PRIu64"   ", snames[i].name, stats[i]);
+	printf("\n");
+
+	free(snames);
+	free(stats);
+	free(ids);
 	return 0;
+
+err:
+	free(snames);
+	free(stats);
+	free(ids);
+	return -1;
 }
diff --git a/drivers/raw/ioat/rte_ioat_rawdev.h b/drivers/raw/ioat/rte_ioat_rawdev.h
index f2cf98cd9..d5326813c 100644
--- a/drivers/raw/ioat/rte_ioat_rawdev.h
+++ b/drivers/raw/ioat/rte_ioat_rawdev.h
@@ -54,6 +54,12 @@ struct rte_ioat_rawdev {
 	struct rte_ioat_generic_hw_desc *desc_ring;
 	__m128i *hdls; /* completion handles for returning to user */
 
+	/* some statistics for tracking, if added/changed update xstats fns*/
+	uint64_t enqueue_failed __rte_cache_aligned;
+	uint64_t enqueued;
+	uint64_t started;
+	uint64_t completed;
+
 	/* to report completions, the device will write status back here */
 	volatile uint64_t status __rte_cache_aligned;
 };
-- 
2.21.0


  parent reply	other threads:[~2019-07-01 15:57 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 21:25 [dpdk-dev] [PATCH 0/8] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 1/8] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 2/8] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 3/8] raw/ioat: add register definition file Bruce Richardson
2019-05-30 23:53   ` Stephen Hemminger
2019-06-06 13:19     ` Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 4/8] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 5/8] raw/ioat: add device info function Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 6/8] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 7/8] raw/ioat: add statistics functions Bruce Richardson
2019-05-30 21:25 ` [dpdk-dev] [PATCH 8/8] raw/ioat: add local API to perform copies Bruce Richardson
2019-06-03 14:44   ` Thomas Monjalon
2019-06-04 12:23     ` Bruce Richardson
2019-06-05 13:52   ` Jerin Jacob Kollanukkaran
2019-06-05 13:57     ` Bruce Richardson
2019-06-25 14:58 ` [dpdk-dev] [PATCH v2 0/8] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 1/8] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 2/8] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 3/8] raw/ioat: add register definition file Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 4/8] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 5/8] raw/ioat: add device info function Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 6/8] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 7/8] raw/ioat: add statistics functions Bruce Richardson
2019-06-25 14:58   ` [dpdk-dev] [PATCH v2 8/8] raw/ioat: add local API to perform copies Bruce Richardson
2019-06-27 10:40 ` [dpdk-dev] [PATCH v3 0/8] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 1/8] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-06-27 11:55     ` Burakov, Anatoly
2019-06-28 12:43       ` Bruce Richardson
2019-07-01  7:38     ` Hu, Jiayu
2019-07-01  7:51       ` Thomas Monjalon
2019-07-01  8:29     ` Hu, Jiayu
2019-07-01 14:30       ` Bruce Richardson
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 2/8] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-06-27 11:57     ` Burakov, Anatoly
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 3/8] raw/ioat: add register definition file Bruce Richardson
2019-06-27 12:01     ` Burakov, Anatoly
2019-06-28 12:44       ` Bruce Richardson
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 4/8] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-06-27 12:09     ` Burakov, Anatoly
2019-06-28 16:21       ` Bruce Richardson
2019-06-27 12:28     ` Burakov, Anatoly
2019-06-28 12:46       ` Bruce Richardson
2019-06-28 12:59         ` Burakov, Anatoly
2019-06-28 13:15           ` Bruce Richardson
2019-06-28 13:28             ` Burakov, Anatoly
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 5/8] raw/ioat: add device info function Bruce Richardson
2019-06-27 12:16     ` Burakov, Anatoly
2019-06-28 21:09       ` Bruce Richardson
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 6/8] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-06-27 12:29     ` Burakov, Anatoly
2019-06-27 16:37     ` Pattan, Reshma
2019-06-28 21:21       ` Bruce Richardson
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 7/8] raw/ioat: add statistics functions Bruce Richardson
2019-06-27 12:38     ` Burakov, Anatoly
2019-07-01 10:11     ` Pattan, Reshma
2019-07-01 12:56       ` Bruce Richardson
2019-06-27 10:40   ` [dpdk-dev] [PATCH v3 8/8] raw/ioat: add local API to perform copies Bruce Richardson
2019-06-27 12:45     ` Burakov, Anatoly
2019-06-27 15:34   ` [dpdk-dev] [PATCH v3 0/8] raw/ioat: driver for Intel QuickData Technology Van Haaren, Harry
2019-07-01 15:55 ` [dpdk-dev] [PATCH v4 0/9] " Bruce Richardson
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 1/9] rawdev: allow devices to skip extra memory allocation Bruce Richardson
2019-07-02 11:34     ` Hemant Agrawal
2019-07-02 11:43     ` Shreyansh Jain
2019-07-02 12:41       ` Bruce Richardson
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 2/9] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 3/9] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 4/9] raw/ioat: add register definition file Bruce Richardson
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 5/9] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-07-02  9:39     ` Burakov, Anatoly
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 6/9] raw/ioat: add device info function Bruce Richardson
2019-07-02  2:33     ` Hu, Jiayu
2019-07-02  8:28       ` Bruce Richardson
2019-07-02  9:40     ` Burakov, Anatoly
2019-07-01 15:55   ` [dpdk-dev] [PATCH v4 7/9] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-07-02  9:49     ` Burakov, Anatoly
2019-07-02  9:59       ` Bruce Richardson
2019-07-01 15:55   ` Bruce Richardson [this message]
2019-07-02  9:50     ` [dpdk-dev] [PATCH v4 8/9] raw/ioat: add statistics functions Burakov, Anatoly
2019-07-01 15:56   ` [dpdk-dev] [PATCH v4 9/9] raw/ioat: add local API to perform copies Bruce Richardson
2019-07-01 15:58   ` [dpdk-dev] [PATCH v4 0/9] raw/ioat: driver for Intel QuickData Technology Bruce Richardson
2019-07-02 14:12 ` [dpdk-dev] [PATCH v5 " Bruce Richardson
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 1/9] rawdev: allow devices to skip extra memory allocation Bruce Richardson
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 2/9] raw/ioat: add initial support for ioat rawdev driver Bruce Richardson
2019-07-03  1:53     ` Hu, Jiayu
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 3/9] usertools/dpdk-devbind.py: add support for IOAT devices Bruce Richardson
2019-07-03  1:54     ` Hu, Jiayu
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 4/9] raw/ioat: add register definition file Bruce Richardson
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 5/9] raw/ioat: create device on probe and destroy on release Bruce Richardson
2019-07-03  1:57     ` Hu, Jiayu
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 6/9] raw/ioat: add device info function Bruce Richardson
2019-07-03  1:58     ` Hu, Jiayu
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 7/9] raw/ioat: add configure, start and stop functions Bruce Richardson
2019-07-03  1:59     ` Hu, Jiayu
2019-07-03 16:21     ` Aaron Conole
2019-07-03 16:44       ` Bruce Richardson
2019-07-03 20:26         ` Aaron Conole
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 8/9] raw/ioat: add statistics functions Bruce Richardson
2019-07-03  2:00     ` Hu, Jiayu
2019-07-02 14:12   ` [dpdk-dev] [PATCH v5 9/9] raw/ioat: add local API to perform copies Bruce Richardson
2019-07-03  2:01     ` Hu, Jiayu
2019-07-04  7:45   ` [dpdk-dev] [PATCH v5 0/9] raw/ioat: driver for Intel QuickData Technology Thomas Monjalon
2019-07-04 22:17   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190701155600.43695-9-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.com \
    --cc=jerinj@marvell.com \
    --cc=jiayu.hu@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).