diff mbox series

[v7,3/6] crypto/uadk: support enqueue/dequeue operations

Message ID 20221027032505.1948351-4-zhangfei.gao@linaro.org
State Accepted
Commit be2874cd4bd2f4b97b5b0954bbc73e278a4b09e1
Headers show
Series crypto/uadk: introduce uadk crypto driver | expand

Commit Message

Zhangfei Gao Oct. 27, 2022, 3:25 a.m. UTC
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 mbox series

Patch

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;