DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rebecca Troy <rebecca.troy@intel.com>
To: dev@dpdk.org
Cc: ciara.power@intel.com, roy.fan.zhang@intel.com,
	Rebecca Troy <rebecca.troy@intel.com>,
	Akhil Goyal <gakhil@marvell.com>,
	Declan Doherty <declan.doherty@intel.com>
Subject: [dpdk-dev] [PATCH v6] cryptodev: add telemetry callbacks
Date: Tue, 26 Oct 2021 12:00:45 +0000
Message-ID: <20211026120045.297653-1-rebecca.troy@intel.com> (raw)
In-Reply-To: <20211013152206.148589-1-rebecca.troy@intel.com>

The cryptodev library now registers commands with telemetry, and
implements the corresponding callback functions. These commands
allow a list of cryptodevs to be queried, as well as info and stats
for the corresponding cryptodev.

An example usage can be seen below:

Connecting to /var/run/dpdk/rte/dpdk_telemetry.v2
{"version": "DPDK 21.11.0-rc0", "pid": 1135019, "max_output_len": 16384}
--> /
{"/": ["/", "/cryptodev/info", "/cryptodev/list", "/cryptodev/stats", ...]}
--> /cryptodev/list
{"/cryptodev/list": [0,1,2,3]}
--> /cryptodev/info,0
{"/cryptodev/info": {"device_name": "0000:1c:01.0_qat_sym", \
	 "max_nb_queue_pairs": 2}}
--> /cryptodev/stats,0
{"/cryptodev/stats": {"enqueued_count": 0, "dequeued_count": 0, \
	"enqueue_err_count": 0, "dequeue_err_count": 0}}

Signed-off-by: Rebecca Troy <rebecca.troy@intel.com>
Acked-by: Ciara Power <ciara.power@intel.com>

---
v6:
 - Replaced missed -1 return value
v5:
 - Added missing telemetry dependency to meson.build.
v4:
  - Corrected doc heading underline and link.
  - Replaced remaining -1 return values with -EINVAL.
v3:
  - Added missing version tag to patch.
v2:
  - Added documentation and release notes.
  - Changed the /cryptodev/list command to list the devices as an
	array of IDs, rather than as names and IDs.
  - Added the /cryptodev/info command as described above.
---
 doc/guides/prog_guide/cryptodev_lib.rst | 28 ++++++++
 doc/guides/rel_notes/release_21_11.rst  |  5 ++
 lib/cryptodev/meson.build               |  2 +-
 lib/cryptodev/rte_cryptodev.c           | 92 +++++++++++++++++++++++++
 4 files changed, 126 insertions(+), 1 deletion(-)

diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst
index 9b1cf8d49f..25663e552e 100644
--- a/doc/guides/prog_guide/cryptodev_lib.rst
+++ b/doc/guides/prog_guide/cryptodev_lib.rst
@@ -1282,3 +1282,31 @@ Asymmetric Crypto Device API
 
 The cryptodev Library API is described in the
 `DPDK API Reference <https://doc.dpdk.org/api/>`_
+
+
+Device Statistics
+-----------------
+
+The Cryptodev library has support for displaying Crypto device information
+through the Telemetry interface. Telemetry commands that can be used
+are shown below.
+
+#. Get the list of available Crypto devices by ID::
+
+     --> /cryptodev/list
+     {"/cryptodev/list": [0, 1, 2, 3]}
+
+#. Get general information from a Crypto device::
+
+     --> /cryptodev/info,0
+     {"/cryptodev/info": {"device_name": "0000:1c:01.0_qat_sym",
+     "max_nb_queue_pairs": 2}}
+
+#. Get the statistics for a particular Crypto device::
+
+     --> /cryptodev/stats,0
+     {"/cryptodev/stats": {"enqueued_count": 0, "dequeued_count": 0,
+     "enqueue_err_count": 0, "dequeue_err_count": 0}}
+
+For more information on how to use the Telemetry interface, see
+the :doc:`../howto/telemetry`.
diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst
index 1ccac87b73..ee1e557309 100644
--- a/doc/guides/rel_notes/release_21_11.rst
+++ b/doc/guides/rel_notes/release_21_11.rst
@@ -269,6 +269,11 @@ New Features
   * Added support for SA telemetry.
   * Added support for setting a non default starting ESN value.
 
+* **Added Telemetry callbacks to Cryptodev library.**
+
+  Added Telemetry callback functions which allow a list of Crypto devices,
+  stats for a Crypto device, and other device information to be queried.
+
 * **Added multi-process support for testpmd.**
 
   Added command-line options to specify total number of processes and
diff --git a/lib/cryptodev/meson.build b/lib/cryptodev/meson.build
index 289b66ab76..19de3073bb 100644
--- a/lib/cryptodev/meson.build
+++ b/lib/cryptodev/meson.build
@@ -21,4 +21,4 @@ driver_sdk_headers += files(
         'cryptodev_pmd.h',
 )
 
-deps += ['kvargs', 'mbuf', 'rcu']
+deps += ['kvargs', 'mbuf', 'rcu', 'telemetry']
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 305e013ebb..3b01a4bfbc 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -35,6 +35,7 @@
 #include <rte_errno.h>
 #include <rte_spinlock.h>
 #include <rte_string_fns.h>
+#include <rte_telemetry.h>
 
 #include "rte_crypto.h"
 #include "rte_cryptodev.h"
@@ -2430,3 +2431,94 @@ RTE_INIT(cryptodev_init_fp_ops)
 	for (i = 0; i != RTE_DIM(rte_crypto_fp_ops); i++)
 		cryptodev_fp_ops_reset(rte_crypto_fp_ops + i);
 }
+
+static int
+cryptodev_handle_dev_list(const char *cmd __rte_unused,
+		const char *params __rte_unused,
+		struct rte_tel_data *d)
+{
+	int dev_id;
+
+	if (rte_cryptodev_count() < 1)
+		return -EINVAL;
+
+	rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_is_valid_dev(dev_id))
+			rte_tel_data_add_array_int(d, dev_id);
+
+	return 0;
+}
+
+static int
+cryptodev_handle_dev_info(const char *cmd __rte_unused,
+		const char *params, struct rte_tel_data *d)
+{
+	struct rte_cryptodev_info cryptodev_info;
+	int dev_id;
+	char *end_param;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	rte_cryptodev_info_get(dev_id, &cryptodev_info);
+
+	rte_tel_data_start_dict(d);
+	rte_tel_data_add_dict_string(d, "device_name",
+		cryptodev_info.device->name);
+	rte_tel_data_add_dict_int(d, "max_nb_queue_pairs",
+		cryptodev_info.max_nb_queue_pairs);
+
+	return 0;
+}
+
+#define ADD_DICT_STAT(s) rte_tel_data_add_dict_u64(d, #s, cryptodev_stats.s)
+
+static int
+cryptodev_handle_dev_stats(const char *cmd __rte_unused,
+		const char *params,
+		struct rte_tel_data *d)
+{
+	struct rte_cryptodev_stats cryptodev_stats;
+	int dev_id, ret;
+	char *end_param;
+
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to command, ignoring");
+	if (!rte_cryptodev_is_valid_dev(dev_id))
+		return -EINVAL;
+
+	ret = rte_cryptodev_stats_get(dev_id, &cryptodev_stats);
+	if (ret < 0)
+		return ret;
+
+	rte_tel_data_start_dict(d);
+	ADD_DICT_STAT(enqueued_count);
+	ADD_DICT_STAT(dequeued_count);
+	ADD_DICT_STAT(enqueue_err_count);
+	ADD_DICT_STAT(dequeue_err_count);
+
+	return 0;
+}
+
+RTE_INIT(cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cryptodev/info", cryptodev_handle_dev_info,
+			"Returns information for a cryptodev. Parameters: int dev_id");
+	rte_telemetry_register_cmd("/cryptodev/list",
+			cryptodev_handle_dev_list,
+			"Returns list of available crypto devices by IDs. No parameters.");
+	rte_telemetry_register_cmd("/cryptodev/stats",
+			cryptodev_handle_dev_stats,
+			"Returns the stats for a cryptodev. Parameters: int dev_id");
+}
-- 
2.25.1


  parent reply	other threads:[~2021-10-26 12:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 10:21 [dpdk-dev] [PATCH] " Rebecca Troy
2021-08-20 12:59 ` Zhang, Roy Fan
2021-09-28 10:47 ` [dpdk-dev] [EXT] " Akhil Goyal
2021-09-28 10:48 ` Akhil Goyal
2021-09-29  5:14 ` Gowrishankar Muthukrishnan
2021-09-29  7:51   ` Bruce Richardson
2021-10-07 10:17 ` [dpdk-dev] " Rebecca Troy
2021-10-07 14:11   ` [dpdk-dev] [PATCH v3] " Rebecca Troy
2021-10-12 14:30     ` Power, Ciara
2021-10-13 10:22     ` [dpdk-dev] [PATCH v4] " Rebecca Troy
2021-10-13 10:57       ` Power, Ciara
2021-10-13 12:15       ` Tal Shnaiderman
2021-10-13 15:22       ` [dpdk-dev] [PATCH v5] " Rebecca Troy
2021-10-13 16:08         ` Bruce Richardson
2021-10-25  4:32         ` [dpdk-dev] [EXT] " Akhil Goyal
2021-10-26  8:22           ` Troy, Rebecca
2021-10-26 12:00         ` Rebecca Troy [this message]
2021-10-26 14:37           ` [dpdk-dev] [EXT] [PATCH v6] " Akhil Goyal

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=20211026120045.297653-1-rebecca.troy@intel.com \
    --to=rebecca.troy@intel.com \
    --cc=ciara.power@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=roy.fan.zhang@intel.com \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git