cryptodev: add telemetry callbacks

Message ID 20210819102157.1190022-1-rebecca.troy@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series cryptodev: add telemetry callbacks |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing fail Testing issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Rebecca Troy Aug. 19, 2021, 10:21 a.m. UTC
  The cryptodev library now registers commands with telemetry, and
implements the corresponding callback functions. These commands
allow a list of cryptodevs and stats for a cryptodev to be
queried.

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/list", "/cryptodev/stats", ...]}
--> /cryptodev/list
{"/cryptodev/list": {"0000:1a:01.0_qat_sym": 0, "0000:1a:01.0_qat_asym": \
	1}}
--> /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>
---
 lib/cryptodev/rte_cryptodev.c | 62 +++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
  

Comments

Fan Zhang Aug. 20, 2021, 12:59 p.m. UTC | #1
> -----Original Message-----
> From: Troy, Rebecca <rebecca.troy@intel.com>
> Sent: Thursday, August 19, 2021 11:22 AM
> To: dev@dpdk.org
> Cc: Zhang, Roy Fan <roy.fan.zhang@intel.com>; Power, Ciara
> <ciara.power@intel.com>; Troy, Rebecca <rebecca.troy@intel.com>; Akhil
> Goyal <gakhil@marvell.com>; Doherty, Declan <declan.doherty@intel.com>
> Subject: [PATCH] cryptodev: add telemetry callbacks
> 
> The cryptodev library now registers commands with telemetry, and
> implements the corresponding callback functions. These commands
> allow a list of cryptodevs and stats for a cryptodev to be
> queried.
> 
> 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/list", "/cryptodev/stats", ...]}
> --> /cryptodev/list
> {"/cryptodev/list": {"0000:1a:01.0_qat_sym": 0, "0000:1a:01.0_qat_asym": \
> 	1}}
> --> /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: Fan Zhang <roy.fan.zhang@intel.com>
  
Akhil Goyal Sept. 28, 2021, 10:47 a.m. UTC | #2
> The cryptodev library now registers commands with telemetry, and
> implements the corresponding callback functions. These commands
> allow a list of cryptodevs and stats for a cryptodev to be
> queried.
> 
> 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/list", "/cryptodev/stats", ...]}
> --> /cryptodev/list
> {"/cryptodev/list": {"0000:1a:01.0_qat_sym": 0, "0000:1a:01.0_qat_asym": \
> 	1}}
> --> /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>
> ---
Can we add documentation in cryptodevs.rst?
  
Akhil Goyal Sept. 28, 2021, 10:48 a.m. UTC | #3
> The cryptodev library now registers commands with telemetry, and
> implements the corresponding callback functions. These commands
> allow a list of cryptodevs and stats for a cryptodev to be
> queried.
> 
> 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/list", "/cryptodev/stats", ...]}
> --> /cryptodev/list
> {"/cryptodev/list": {"0000:1a:01.0_qat_sym": 0, "0000:1a:01.0_qat_asym": \
> 	1}}
> --> /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>
> ---
>  lib/cryptodev/rte_cryptodev.c | 62
> +++++++++++++++++++++++++++++++++++
Release notes also missing.
  
Gowrishankar Muthukrishnan Sept. 29, 2021, 5:14 a.m. UTC | #4
> 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/list", "/cryptodev/stats", ...]}
> --> /cryptodev/list
> {"/cryptodev/list": {"0000:1a:01.0_qat_sym": 0, "0000:1a:01.0_qat_asym": \
> 	1}}

Will this be better if we list keys by port ID, as port ID is used as param in appropriate endpoints ?
Just a suggestion.

> --> /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>
> ---
>  lib/cryptodev/rte_cryptodev.c | 62 +++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)
> 
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index
> 447aa9d519..1e3ab633cc 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -36,6 +36,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"
> @@ -2427,3 +2428,64 @@ rte_cryptodev_allocate_driver(struct
> cryptodev_driver *crypto_drv,
> 
>  	return nb_drivers++;
>  }
> +
> +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 -1;
> +
> +	rte_tel_data_start_dict(d);
> +	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
> +		if (rte_cryptodev_pmd_is_valid_dev(dev_id))

This is broken now. Correct function is rte_cryptodev_is_valid_dev() .

Thanks,
Gowrishankar
  
Bruce Richardson Sept. 29, 2021, 7:51 a.m. UTC | #5
On Wed, Sep 29, 2021 at 05:14:38AM +0000, Gowrishankar Muthukrishnan wrote:
> > 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/list", "/cryptodev/stats", ...]}
> > --> /cryptodev/list
> > {"/cryptodev/list": {"0000:1a:01.0_qat_sym": 0, "0000:1a:01.0_qat_asym": \
> > 	1}}
> 
> Will this be better if we list keys by port ID, as port ID is used as param in appropriate endpoints ?
> Just a suggestion.
>
+1 to that suggestion
  

Patch

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 447aa9d519..1e3ab633cc 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -36,6 +36,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"
@@ -2427,3 +2428,64 @@  rte_cryptodev_allocate_driver(struct cryptodev_driver *crypto_drv,
 
 	return nb_drivers++;
 }
+
+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 -1;
+
+	rte_tel_data_start_dict(d);
+	for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++)
+		if (rte_cryptodev_pmd_is_valid_dev(dev_id))
+			rte_tel_data_add_dict_int(d,
+				rte_cryptodev_name_get(dev_id), dev_id);
+
+	return 0;
+}
+
+#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_u64(d, #s, 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 -1;
+
+	dev_id = strtoul(params, &end_param, 0);
+	if (*end_param != '\0')
+		CDEV_LOG_ERR("Extra parameters passed to cryptodev telemetry command, ignoring");
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+		return -1;
+
+	ret = rte_cryptodev_stats_get(dev_id, &cryptodev_stats);
+	if (ret < 0)
+		return -1;
+
+	rte_tel_data_start_dict(d);
+	ADD_DICT_STAT(cryptodev_stats, enqueued_count);
+	ADD_DICT_STAT(cryptodev_stats, dequeued_count);
+	ADD_DICT_STAT(cryptodev_stats, enqueue_err_count);
+	ADD_DICT_STAT(cryptodev_stats, dequeue_err_count);
+
+	return 0;
+}
+
+RTE_INIT(cryptodev_init_telemetry)
+{
+	rte_telemetry_register_cmd("/cryptodev/list", cryptodev_handle_dev_list,
+			"Returns list of available cryptodev names and IDs.");
+	rte_telemetry_register_cmd("/cryptodev/stats",
+			cryptodev_handle_dev_stats,
+			"Returns the stats for a cryptodev. Parameters: int dev_id");
+}