DPDK patches and discussions
 help / color / mirror / Atom feed
From: Zhangfei Gao <zhangfei.gao@linaro.org>
To: Akhil Goyal <gakhil@marvell.com>,
	Declan Doherty <declan.doherty@intel.com>,
	Fan Zhang <royzhang1980@gmail.com>,
	Ashish Gupta <ashish.gupta@marvell.com>,
	Ray Kinsella <mdr@ashroe.eu>,
	"thomas@monjalon.net" <thomas@monjalon.net>
Cc: dev@dpdk.org, acc@openeuler.org, Zhangfei Gao <zhangfei.gao@linaro.org>
Subject: [PATCH v6 3/6] crypto/uadk: support enqueue/dequeue operations
Date: Wed, 26 Oct 2022 18:54:26 +0800	[thread overview]
Message-ID: <20221026105429.1899867-4-zhangfei.gao@linaro.org> (raw)
In-Reply-To: <20221026105429.1899867-1-zhangfei.gao@linaro.org>

This commit adds the enqueue and dequeue operations.

Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org>
---
 drivers/crypto/uadk/uadk_crypto_pmd.c | 53 ++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/uadk/uadk_crypto_pmd.c b/drivers/crypto/uadk/uadk_crypto_pmd.c
index b383029a45..b889dac8b0 100644
--- a/drivers/crypto/uadk/uadk_crypto_pmd.c
+++ b/drivers/crypto/uadk/uadk_crypto_pmd.c
@@ -208,6 +208,55 @@ static struct rte_cryptodev_ops uadk_crypto_pmd_ops = {
 		.sym_session_clear	= NULL,
 };
 
+static uint16_t
+uadk_crypto_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
+			  uint16_t nb_ops)
+{
+	struct uadk_qp *qp = queue_pair;
+	struct rte_crypto_op *op;
+	uint16_t enqd = 0;
+	int i, ret;
+
+	for (i = 0; i < nb_ops; i++) {
+		op = ops[i];
+		op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+		if (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
+			op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+		if (op->status != RTE_CRYPTO_OP_STATUS_ERROR) {
+			ret = rte_ring_enqueue(qp->processed_pkts, (void *)op);
+			if (ret < 0)
+				goto enqueue_err;
+			qp->qp_stats.enqueued_count++;
+			enqd++;
+		} else {
+			/* increment count if failed to enqueue op */
+			qp->qp_stats.enqueue_err_count++;
+		}
+	}
+
+	return enqd;
+
+enqueue_err:
+	qp->qp_stats.enqueue_err_count++;
+	return enqd;
+}
+
+static uint16_t
+uadk_crypto_dequeue_burst(void *queue_pair, struct rte_crypto_op **ops,
+			  uint16_t nb_ops)
+{
+	struct uadk_qp *qp = queue_pair;
+	unsigned int nb_dequeued;
+
+	nb_dequeued = rte_ring_dequeue_burst(qp->processed_pkts,
+			(void **)ops, nb_ops, NULL);
+	qp->qp_stats.dequeued_count += nb_dequeued;
+
+	return nb_dequeued;
+}
+
 static int
 uadk_cryptodev_probe(struct rte_vdev_device *vdev)
 {
@@ -244,8 +293,8 @@ uadk_cryptodev_probe(struct rte_vdev_device *vdev)
 
 	dev->dev_ops = &uadk_crypto_pmd_ops;
 	dev->driver_id = uadk_cryptodev_driver_id;
-	dev->dequeue_burst = NULL;
-	dev->enqueue_burst = NULL;
+	dev->dequeue_burst = uadk_crypto_dequeue_burst;
+	dev->enqueue_burst = uadk_crypto_enqueue_burst;
 	dev->feature_flags = RTE_CRYPTODEV_FF_HW_ACCELERATED;
 	priv = dev->data->dev_private;
 	priv->version = version;
-- 
2.38.1


  parent reply	other threads:[~2022-10-26 11:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 10:54 [PATCH v6 0/6] crypto/uadk: introduce uadk crypto driver Zhangfei Gao
2022-10-26 10:54 ` [PATCH v6 1/6] " Zhangfei Gao
2022-10-26 10:54 ` [PATCH v6 2/6] crypto/uadk: support basic operations Zhangfei Gao
2022-10-26 10:54 ` Zhangfei Gao [this message]
2022-10-26 10:54 ` [PATCH v6 4/6] crypto/uadk: support cipher algorithms Zhangfei Gao
2022-10-26 10:54 ` [PATCH v6 5/6] crypto/uadk: support auth algorithms Zhangfei Gao
2022-10-26 15:43   ` [EXT] " Akhil Goyal
2022-10-27  4:00     ` Zhangfei Gao
2022-10-26 10:54 ` [PATCH v6 6/6] test/crypto: support uadk PMD Zhangfei Gao

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=20221026105429.1899867-4-zhangfei.gao@linaro.org \
    --to=zhangfei.gao@linaro.org \
    --cc=acc@openeuler.org \
    --cc=ashish.gupta@marvell.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=mdr@ashroe.eu \
    --cc=royzhang1980@gmail.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).