Skip to contentSkip to conversation

common/cpt: rework pending queue

PATCH Applied Anoob Joseph 2 participants 2 messages Sep 24, 2021 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/cpt: rework pending queue

From: David George <[email protected]>

Replace pending queue with one that allows concurrent single producer and single consumer. This relaxes the restriction of only allowing a single lcore to operate on a given queue pair.

---
 doc/guides/cryptodevs/octeontx.rst                 |   6 --
 doc/guides/cryptodevs/octeontx2.rst                |   6 --
 drivers/common/cpt/cpt_common.h                    |  73 +++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  19 ++--
 drivers/crypto/octeontx/otx_cryptodev_hw_access.h  |  14 ++-
 drivers/crypto/octeontx/otx_cryptodev_ops.c        |  75 +++++++---------
 .../crypto/octeontx2/otx2_cryptodev_hw_access.h    |   8 +-
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c      | 100 ++++++++++++---------
 8 files changed, 179 insertions(+), 122 deletions(-)
doc/guides/cryptodevs/octeontx.rst +0 -6
index 4972274..a39f3f3 100644
@@ -135,9 +135,3 @@ application:
 
         ./dpdk-test
         RTE>>cryptodev_octeontx_asym_autotest
-
-Limitations
------------
-
-Multiple lcores may not operate on the same crypto queue pair. The lcore that
-enqueues to a queue pair is the one that must dequeue from it.
doc/guides/cryptodevs/octeontx2.rst +0 -6
index f0beb92..811e61a 100644
@@ -186,9 +186,3 @@ Features supported
 * AES-128/192/256-GCM
 * AES-128/192/256-CBC-SHA1-HMAC
 * AES-128/192/256-CBC-SHA256-128-HMAC
-
-Limitations
------------
-
-Multiple lcores may not operate on the same crypto queue pair. The lcore that
-enqueues to a queue pair is the one that must dequeue from it.
drivers/common/cpt/cpt_common.h +68 -5

92 lines not on this page · raw message

drivers/crypto/octeontx/otx_cryptodev_hw_access.c +8 -11
index ab335c6..7b89a62 100644
@@ -527,10 +527,10 @@ otx_cpt_get_resource(const struct rte_cryptodev *dev, uint8_t group,
 	memset(&cptvf->pqueue, 0, sizeof(cptvf->pqueue));
 
 	/* Chunks are of fixed size buffers */
+
+	qlen = DEFAULT_CMD_QLEN;
 	chunks = DEFAULT_CMD_QCHUNKS;
 	chunk_len = DEFAULT_CMD_QCHUNK_SIZE;
-
-	qlen = chunks * chunk_len;
 	/* Chunk size includes 8 bytes of next chunk ptr */
 	chunk_size = chunk_len * CPT_INST_SIZE + CPT_NEXT_CHUNK_PTR_SIZE;
 
@@ -538,7 +538,7 @@ otx_cpt_get_resource(const struct rte_cryptodev *dev, uint8_t group,
 	len = chunks * RTE_ALIGN(sizeof(struct command_chunk), 8);
 
 	/* For pending queue */
-	len += qlen * sizeof(uintptr_t);
+	len += qlen * RTE_ALIGN(sizeof(cptvf->pqueue.rid_queue[0]), 8);
 
 	/* So that instruction queues start as pg size aligned */
 	len = RTE_ALIGN(len, pg_sz);
@@ -573,14 +573,11 @@ otx_cpt_get_resource(const struct rte_cryptodev *dev, uint8_t group,
 	}
 
 	/* Pending queue setup */
-	cptvf->pqueue.req_queue = (uintptr_t *)mem;
-	cptvf->pqueue.enq_tail = 0;
-	cptvf->pqueue.deq_head = 0;
-	cptvf->pqueue.pending_count = 0;
-
-	mem +=  qlen * sizeof(uintptr_t);
-	len -=  qlen * sizeof(uintptr_t);
-	dma_addr += qlen * sizeof(uintptr_t);
+	cptvf->pqueue.rid_queue = (void **)mem;
+
+	mem +=  qlen * RTE_ALIGN(sizeof(cptvf->pqueue.rid_queue[0]), 8);
+	len -=  qlen * RTE_ALIGN(sizeof(cptvf->pqueue.rid_queue[0]), 8);
+	dma_addr += qlen * RTE_ALIGN(sizeof(cptvf->pqueue.rid_queue[0]), 8);
 
 	/* Alignment wastage */
 	used_len = alloc_len - len;
drivers/crypto/octeontx/otx_cryptodev_hw_access.h +10 -4
index f7b1e93..7c6b1e4 100644
@@ -23,10 +23,16 @@
 #define CPT_INTR_POLL_INTERVAL_MS	(50)
 
 /* Default command queue length */
-#define DEFAULT_CMD_QCHUNKS		2
-#define DEFAULT_CMD_QCHUNK_SIZE		1023
-#define DEFAULT_CMD_QLEN \
-		(DEFAULT_CMD_QCHUNK_SIZE * DEFAULT_CMD_QCHUNKS)
+#define DEFAULT_CMD_QLEN	2048
+#define DEFAULT_CMD_QCHUNKS	2
+
+/* Instruction memory benefits from being 1023, so introduce
+ * reserved entries so we can't overrun the instruction queue
+ */
+#define DEFAULT_CMD_QRSVD_SLOTS DEFAULT_CMD_QCHUNKS
+#define DEFAULT_CMD_QCHUNK_SIZE \
+		((DEFAULT_CMD_QLEN - DEFAULT_CMD_QRSVD_SLOTS) / \
+		DEFAULT_CMD_QCHUNKS)
 
 #define CPT_CSR_REG_BASE(cpt)		((cpt)->reg_base)
 
drivers/crypto/octeontx/otx_cryptodev_ops.c +31 -44

180 lines not on this page · raw message

drivers/crypto/octeontx2/otx2_cryptodev_hw_access.h +4 -4
index f9981ea..90a338e 100644
@@ -17,10 +17,10 @@
 #include "otx2_dev.h"
 #include "otx2_cryptodev_qp.h"
 
-/* CPT instruction queue length */
-#define OTX2_CPT_IQ_LEN			8200
-
-#define OTX2_CPT_DEFAULT_CMD_QLEN	OTX2_CPT_IQ_LEN
+/* CPT instruction queue length.
+ * Use queue size as power of 2 for aiding in pending queue calculations.
+ */
+#define OTX2_CPT_DEFAULT_CMD_QLEN	8192
 
 /* Mask which selects all engine groups */
 #define OTX2_CPT_ENG_GRPS_MASK		0xFF
drivers/crypto/octeontx2/otx2_cryptodev_ops.c +58 -42

240 lines not on this page · raw message

Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 17 lines

From: David George <[email protected]>

Replace pending queue with one that allows concurrent single producer and single consumer. This relaxes the restriction of only allowing a single lcore to operate on a given queue pair.

---
 doc/guides/cryptodevs/octeontx.rst                 |   6 --
 doc/guides/cryptodevs/octeontx2.rst                |   6 --
 drivers/common/cpt/cpt_common.h                    |  73 +++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  19 ++--
 drivers/crypto/octeontx/otx_cryptodev_hw_access.h  |  14 ++-
 drivers/crypto/octeontx/otx_cryptodev_ops.c        |  75 +++++++---------
 .../crypto/octeontx2/otx2_cryptodev_hw_access.h    |   8 +-
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c      | 100 ++++++++++++------
Quoted 1 line

---

Applied to dpdk-next-crypto

Thanks.