DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tejasree Kondoj <ktejasree@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>
Cc: Rupesh Chiluka <rchiluka@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>,
	 Vidya Sagar Velumuri <vvelumuri@marvell.com>,
	Ankur Dwivedi <adwivedi@marvell.com>,
	Nithin Dabilpuram <ndabilpuram@marvell.com>, <dev@dpdk.org>
Subject: [PATCH 15/16] crypto/cnxk: add cq_ena devarg for CPT CQ mode
Date: Mon, 19 Oct 2026 18:37:56 +0530	[thread overview]
Message-ID: <20261019130759.2181566-16-ktejasree@marvell.com> (raw)
In-Reply-To: <20261019130759.2181566-1-ktejasree@marvell.com>

From: Rupesh Chiluka <rchiluka@marvell.com>

Add a cq_ena devarg (0 or 1, default 0) to control whether the CPT
completion queue is used on CN20K crypto queue pairs. When set to
0, completions are written to res_addr. When set to 1, completions
are reported through the CPT CQ for all instructions.

Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
Signed-off-by: Rupesh Chiluka <rchiluka@marvell.com>
---
 doc/guides/cryptodevs/cnxk.rst               | 16 +++++++++++
 drivers/common/cnxk/roc_cpt.c                | 10 ++++---
 drivers/crypto/cnxk/cn20k_cryptodev_ops.c    |  2 +-
 drivers/crypto/cnxk/cnxk_cryptodev.h         |  1 +
 drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 28 +++++++++++++++++++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c     |  3 ++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h     |  2 ++
 7 files changed, 55 insertions(+), 7 deletions(-)

diff --git a/doc/guides/cryptodevs/cnxk.rst b/doc/guides/cryptodevs/cnxk.rst
index c0392f4f9c..3c90a12dca 100644
--- a/doc/guides/cryptodevs/cnxk.rst
+++ b/doc/guides/cryptodevs/cnxk.rst
@@ -211,6 +211,22 @@ Runtime Config Options
   With the above configuration, CPT initial context fetch size
   will be set to ``4+1`` 128 bytes blocks.
 
+- ``CPT completion queue enable`` (default ``0``)
+
+  Controls whether the CPT completion queue (CQ) is used for all instructions
+  on CN20K. Can be configured during runtime by using ``cq_ena`` ``devargs``
+  parameter. Accepted values are ``0`` and ``1``.
+
+  When set to ``1``, completions of all instructions are reported through the
+  CQ. When set to ``0``, completions are written to the result address
+  (``res_addr``) of the instruction instead.
+
+  For example::
+
+      -a 0002:20:00.1,cq_ena=1
+
+  With the above configuration, CPT completions are reported through the CPT CQ.
+
 Debugging Options
 -----------------
 
diff --git a/drivers/common/cnxk/roc_cpt.c b/drivers/common/cnxk/roc_cpt.c
index eae3f134e9..645c205480 100644
--- a/drivers/common/cnxk/roc_cpt.c
+++ b/drivers/common/cnxk/roc_cpt.c
@@ -704,10 +704,12 @@ cpt_lf_cq_init(struct roc_cpt_lf *lf)
 	/* Disable CPT completion queue */
 	roc_cpt_cq_disable(lf);
 
-	/* Set completion queue (CQ) base address */
-	len = lf->cq_size;
-	if (roc_model_is_cn20k() && lf->cq_all)
-		len++;
+	/* Set completion queue (CQ) base address.
+	 * On CN20K the pending-queue pointer (req_queue) is always positioned
+	 * at cq_vaddr + 1 entry so that the hardware-managed reserved slot
+	 * sits at cq_vaddr[0].  Allocate the extra entry unconditionally.
+	 */
+	len = lf->cq_size + 1;
 	len = PLT_ALIGN(len * (ROC_CPT_CQ_ENTRY_SIZE_UNIT << lf->cq_entry_size), ROC_ALIGN);
 	lf->cq_vaddr = plt_zmalloc(len, ROC_ALIGN);
 	if (lf->cq_vaddr == NULL)
diff --git a/drivers/crypto/cnxk/cn20k_cryptodev_ops.c b/drivers/crypto/cnxk/cn20k_cryptodev_ops.c
index bb3384023f..c654dbf88d 100644
--- a/drivers/crypto/cnxk/cn20k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn20k_cryptodev_ops.c
@@ -261,7 +261,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 	}
 
 	inst[0].res_addr = (uint64_t)&infl_req->res;
-	inst[0].cq_ena = 1;
+	inst[0].cq_ena = qp->inst_cq_ena;
 	rte_atomic_store_explicit((RTE_ATOMIC(uint64_t) *)(&infl_req->res.u64[0]), res.u64[0],
 				  rte_memory_order_relaxed);
 	infl_req->cop = op;
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev.h b/drivers/crypto/cnxk/cnxk_cryptodev.h
index bdc5752905..4ce2cb255a 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev.h
@@ -39,6 +39,7 @@ struct cnxk_cpt_vf {
 	uint16_t max_qps_limit;
 	uint16_t rx_inject_qp;
 	uint8_t ctx_ilen;
+	bool cq_ena;
 };
 
 uint64_t cnxk_cpt_default_ff_get(void);
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c b/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
index 3623e5aa76..ff0ddb6ed8 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_devargs.c
@@ -14,6 +14,7 @@
 #define CNXK_RX_INJECT_QP      "rx_inject_qp"
 #define CNXK_CPT_CTX_ILEN      "ctx_ilen"
 #define CNXK_MAX_CPT_CTX_ILEN  7
+#define CNXK_CPT_CQ_ENA	       "cq_ena"
 
 static int
 parse_rx_inject_qp(const char *key, const char *value, void *extra_args)
@@ -82,6 +83,21 @@ parse_cpt_ctx_ilen(const char *key, const char *value, void *extra_args)
 	return 0;
 }
 
+static int
+parse_cpt_cq_ena(const char *key, const char *value, void *extra_args)
+{
+	RTE_SET_USED(key);
+	uint32_t val;
+
+	val = atoi(value);
+	if (val > 1)
+		return -EINVAL;
+
+	*(bool *)extra_args = val ? true : false;
+
+	return 0;
+}
+
 int
 cnxk_cpt_parse_devargs(struct rte_devargs *devargs, struct cnxk_cpt_vf *vf)
 {
@@ -89,6 +105,7 @@ cnxk_cpt_parse_devargs(struct rte_devargs *devargs, struct cnxk_cpt_vf *vf)
 	struct rte_kvargs *kvlist;
 	uint16_t rx_inject_qp;
 	uint16_t ctx_ilen = 0;
+	bool cq_ena = false;
 	int rc;
 
 	/* Set to max value as default so that the feature is disabled by default. */
@@ -126,16 +143,25 @@ cnxk_cpt_parse_devargs(struct rte_devargs *devargs, struct cnxk_cpt_vf *vf)
 		goto exit;
 	}
 
+	rc = rte_kvargs_process(kvlist, CNXK_CPT_CQ_ENA, parse_cpt_cq_ena, &cq_ena);
+	if (rc < 0) {
+		plt_err("cq_ena should be 0 or 1");
+		rte_kvargs_free(kvlist);
+		goto exit;
+	}
+
 	rte_kvargs_free(kvlist);
 
 null_devargs:
 	vf->max_qps_limit = max_qps_limit;
 	vf->rx_inject_qp = rx_inject_qp;
 	vf->cpt.ctx_ilen = ctx_ilen;
+	vf->cq_ena = cq_ena;
 	return 0;
 
 exit:
 	return -EINVAL;
 }
 
-RTE_PMD_REGISTER_PARAM_STRING(crypto_cnxk, CNXK_MAX_QPS_LIMIT "=<1-63>");
+RTE_PMD_REGISTER_PARAM_STRING(crypto_cnxk, CNXK_MAX_QPS_LIMIT "=<1-63> " CNXK_CPT_CQ_ENA
+							      "=<0-1> " CNXK_CPT_CTX_ILEN "=<0-7>");
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
index 95f64a79ae..a5b8aff146 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.c
@@ -535,7 +535,8 @@ cnxk_cpt_queue_pair_setup(struct rte_cryptodev *dev, uint16_t qp_id,
 		/* CQ entry size is 128B(32 << 2) */
 		qp->lf.cq_entry_size = 2;
 		qp->lf.cq_size = nb_desc;
-		qp->lf.cq_all = true;
+		qp->lf.cq_all = vf->cq_ena;
+		qp->inst_cq_ena = vf->cq_ena;
 	}
 
 	ret = roc_cpt_lf_init(roc_cpt, &qp->lf);
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
index 7bf26d67dc..6c4265f339 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_ops.h
@@ -108,6 +108,8 @@ struct crypto_adpter_info {
 struct cnxk_cpt_qp {
 	struct roc_cpt_lf lf;
 	/**< Crypto LF */
+	bool inst_cq_ena;
+	/**< Set CQ enable bit on instructions */
 	struct pending_queue pend_q;
 	/**< Pending queue */
 	struct roc_cpt_lmtline lmtline;
-- 
2.43.0


  parent reply	other threads:[~2026-10-19 13:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 13:07 [PATCH 00/16] fixes and improvements to cnxk crypto PMD Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 01/16] common/cnxk: use context invalidate for cn20k Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 02/16] crypto/cnxk: return HW CPTR from cptr_get " Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 03/16] crypto/cnxk: enable cq_all and allocate extra CQ line Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 04/16] common/cnxk: validate cipher key length in IPsec SA fill Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 05/16] crypto/cnxk: reject truncated TLS records in decrypt Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 06/16] crypto/cnxk: fix CN20K CPT error recovery Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 07/16] crypto/cnxk: validate TLS xform and keys before SA key copy Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 08/16] crypto/cnxk: reject oversized SG vectors in raw datapath Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 09/16] crypto/cnxk: guard trim len bounds in TLS 1.2 MAC trim Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 10/16] crypto/cnxk: enable ctx cache for cn20k crypto Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 11/16] crypto/cnxk: guard trim len in TLS 1.2 MAC trim for CN20K Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 12/16] crypto/cnxk: validate TLS 1.2 MAC trim lengths Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 13/16] crypto/cnxk: bound SG segment count in packet iov builders Tejasree Kondoj
2026-10-19 13:07 ` [PATCH 14/16] crypto/cnxk: bound SG iovec index in mbuf walk Tejasree Kondoj
2026-10-19 13:07 ` Tejasree Kondoj [this message]
2026-10-19 13:07 ` [PATCH 16/16] crypto/cnxk: size CN20K IPsec SA by context length Tejasree Kondoj
2026-10-22 18:46 ` [PATCH 00/16] fixes and improvements to cnxk crypto PMD 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=20261019130759.2181566-16-ktejasree@marvell.com \
    --to=ktejasree@marvell.com \
    --cc=adwivedi@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=rchiluka@marvell.com \
    --cc=vvelumuri@marvell.com \
    /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