DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akhil Goyal <gakhil@marvell.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <david.marchand@redhat.com>,
	<hemant.agrawal@nxp.com>, <anoobj@marvell.com>,
	<pablo.de.lara.guarch@intel.com>, <fiona.trahe@intel.com>,
	<declan.doherty@intel.com>, <matan@nvidia.com>, <g.singh@nxp.com>,
	<fanzhang.oss@gmail.com>, <jianjay.zhou@huawei.com>,
	<asomalap@amd.com>, <ruifeng.wang@arm.com>,
	<konstantin.v.ananyev@yandex.ru>, <radu.nicolau@intel.com>,
	<ajit.khaparde@broadcom.com>, <rnagadheeraj@marvell.com>,
	<ciara.power@intel.com>, Akhil Goyal <gakhil@marvell.com>
Subject: [PATCH v2 1/3] cryptodev: add API to get used queue pair depth
Date: Fri, 12 Apr 2024 17:27:20 +0530	[thread overview]
Message-ID: <20240412115722.3709194-2-gakhil@marvell.com> (raw)
In-Reply-To: <20240412115722.3709194-1-gakhil@marvell.com>

Added a new fast path API to get used queue pair
descriptors of a specific queue pair of a device.
Applications may monitor the depth used and enqueue
crypto ops accordingly.

Signed-off-by: Akhil Goyal <gakhil@marvell.com>
---
 devtools/libabigail.abignore           |  3 ++
 lib/cryptodev/cryptodev_pmd.c          |  1 +
 lib/cryptodev/cryptodev_pmd.h          |  2 ++
 lib/cryptodev/cryptodev_trace_points.c |  3 ++
 lib/cryptodev/rte_cryptodev.h          | 45 ++++++++++++++++++++++++++
 lib/cryptodev/rte_cryptodev_core.h     |  7 +++-
 lib/cryptodev/rte_cryptodev_trace_fp.h |  7 ++++
 lib/cryptodev/version.map              |  3 ++
 8 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore
index 645d289a77..bd63f42008 100644
--- a/devtools/libabigail.abignore
+++ b/devtools/libabigail.abignore
@@ -37,3 +37,6 @@
 [suppress_type]
 	name = rte_eth_fp_ops
 	has_data_member_inserted_between = {offset_of(reserved2), end}
+[suppress_type]
+	name = rte_crypto_fp_ops
+	has_data_member_inserted_between = {offset_of(reserved), end}
diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c
index d8073a601d..87ced122b4 100644
--- a/lib/cryptodev/cryptodev_pmd.c
+++ b/lib/cryptodev/cryptodev_pmd.c
@@ -236,6 +236,7 @@ cryptodev_fp_ops_set(struct rte_crypto_fp_ops *fp_ops,
 	fp_ops->qp.data = dev->data->queue_pairs;
 	fp_ops->qp.enq_cb = dev->enq_cbs;
 	fp_ops->qp.deq_cb = dev->deq_cbs;
+	fp_ops->qp_depth_used = dev->qp_depth_used;
 }
 
 void *
diff --git a/lib/cryptodev/cryptodev_pmd.h b/lib/cryptodev/cryptodev_pmd.h
index d195b81771..c22cc0908d 100644
--- a/lib/cryptodev/cryptodev_pmd.h
+++ b/lib/cryptodev/cryptodev_pmd.h
@@ -117,6 +117,8 @@ struct __rte_cache_aligned rte_cryptodev {
 	struct rte_cryptodev_cb_rcu *enq_cbs;
 	/** User application callback for post dequeue processing */
 	struct rte_cryptodev_cb_rcu *deq_cbs;
+	/** Pointer to PMD function to get used queue pair depth */
+	crypto_qp_depth_used_t qp_depth_used;
 };
 
 /** Global structure used for maintaining state of allocated crypto devices */
diff --git a/lib/cryptodev/cryptodev_trace_points.c b/lib/cryptodev/cryptodev_trace_points.c
index 8c47ab1e78..7403412553 100644
--- a/lib/cryptodev/cryptodev_trace_points.c
+++ b/lib/cryptodev/cryptodev_trace_points.c
@@ -194,3 +194,6 @@ RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_op_pool_create,
 
 RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_count,
 	lib.cryptodev.count)
+
+RTE_TRACE_POINT_REGISTER(rte_cryptodev_trace_qp_depth_used,
+	lib.cryptodev.qp_depth_used)
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index 00ba6a234a..d6d7938f84 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -2005,6 +2005,51 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
 	return fp_ops->enqueue_burst(qp, ops, nb_ops);
 }
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Get the number of used descriptors or depth of a cryptodev queue pair.
+ *
+ * This function retrieves the number of used descriptors in a crypto queue.
+ * Applications can use this API in the fast path to inspect QP occupancy and
+ * take appropriate action.
+ *
+ * Since it is a fast-path function, no check is performed on dev_id and qp_id.
+ * Caller must therefore ensure that the device is enabled and queue pair is setup.
+ *
+ * @param	dev_id		The identifier of the device.
+ * @param	qp_id		The index of the queue pair for which used descriptor
+ *				count is to be retrieved. The value
+ *				must be in the range [0, nb_queue_pairs - 1]
+ *				previously supplied to *rte_cryptodev_configure*.
+ *
+ * @return
+ *  The number of used descriptors on the specified queue pair, or:
+ *   - (-ENOTSUP) if the device does not support this function.
+ */
+
+__rte_experimental
+static inline int
+rte_cryptodev_qp_depth_used(uint8_t dev_id, uint16_t qp_id)
+{
+	const struct rte_crypto_fp_ops *fp_ops;
+	void *qp;
+	int rc;
+
+	fp_ops = &rte_crypto_fp_ops[dev_id];
+	qp = fp_ops->qp.data[qp_id];
+
+	if (fp_ops->qp_depth_used == NULL) {
+		rc = -ENOTSUP;
+		goto out;
+	}
+
+	rc = fp_ops->qp_depth_used(qp);
+out:
+	rte_cryptodev_trace_qp_depth_used(dev_id, qp_id);
+	return rc;
+}
 
 
 #ifdef __cplusplus
diff --git a/lib/cryptodev/rte_cryptodev_core.h b/lib/cryptodev/rte_cryptodev_core.h
index 8d7e58d76d..9d68a026d9 100644
--- a/lib/cryptodev/rte_cryptodev_core.h
+++ b/lib/cryptodev/rte_cryptodev_core.h
@@ -24,6 +24,9 @@ typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
 		struct rte_crypto_op **ops,	uint16_t nb_ops);
 /**< Enqueue packets for processing on queue pair of a device. */
 
+typedef uint32_t (*crypto_qp_depth_used_t)(void *qp);
+/**< Get used descriptor depth in a queue pair of a device. */
+
 /**
  * @internal
  * Structure used to hold opaque pointers to internal ethdev Rx/Tx
@@ -47,8 +50,10 @@ struct __rte_cache_aligned rte_crypto_fp_ops {
 	dequeue_pkt_burst_t dequeue_burst;
 	/** Internal queue pair data pointers. */
 	struct rte_cryptodev_qpdata qp;
+	/** Get the number of used queue pair descriptors. */
+	crypto_qp_depth_used_t qp_depth_used;
 	/** Reserved for future ops. */
-	uintptr_t reserved[3];
+	uintptr_t reserved[2];
 };
 
 extern struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS];
diff --git a/lib/cryptodev/rte_cryptodev_trace_fp.h b/lib/cryptodev/rte_cryptodev_trace_fp.h
index 9218997c14..dbfbc7b2e5 100644
--- a/lib/cryptodev/rte_cryptodev_trace_fp.h
+++ b/lib/cryptodev/rte_cryptodev_trace_fp.h
@@ -31,6 +31,13 @@ RTE_TRACE_POINT_FP(
 	rte_trace_point_emit_u16(nb_ops);
 )
 
+RTE_TRACE_POINT_FP(
+	rte_cryptodev_trace_qp_depth_used,
+	RTE_TRACE_POINT_ARGS(uint8_t dev_id, uint16_t qp_id),
+	rte_trace_point_emit_u8(dev_id);
+	rte_trace_point_emit_u16(qp_id);
+)
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index 54360a5da5..fdac0d876e 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -84,6 +84,9 @@ EXPERIMENTAL {
 	rte_cryptodev_get_auth_algo_string;
 	rte_cryptodev_get_cipher_algo_string;
 	rte_cryptodev_queue_pair_event_error_query;
+
+	# added in 24.03
+	__rte_cryptodev_trace_qp_depth_used;
 };
 
 INTERNAL {
-- 
2.25.1


  reply	other threads:[~2024-04-12 11:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  8:22 [PATCH 0/3] " Akhil Goyal
2024-04-11  8:22 ` [PATCH 1/3] " Akhil Goyal
2024-04-11  8:22 ` [PATCH 2/3] crypto/cnxk: support queue pair depth API Akhil Goyal
2024-04-11  8:22 ` [PATCH 3/3] test/crypto: add QP depth used count case Akhil Goyal
2024-04-12 11:57 ` [PATCH v2 0/3] cryptodev: add API to get used queue pair depth Akhil Goyal
2024-04-12 11:57   ` Akhil Goyal [this message]
2024-04-12 11:57   ` [PATCH v2 2/3] crypto/cnxk: support queue pair depth API Akhil Goyal
2024-04-12 11:57   ` [PATCH v2 3/3] test/crypto: add QP depth used count case 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=20240412115722.3709194-2-gakhil@marvell.com \
    --to=gakhil@marvell.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=anoobj@marvell.com \
    --cc=asomalap@amd.com \
    --cc=ciara.power@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=fiona.trahe@intel.com \
    --cc=g.singh@nxp.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=matan@nvidia.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=radu.nicolau@intel.com \
    --cc=rnagadheeraj@marvell.com \
    --cc=ruifeng.wang@arm.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).