Skip to contentSkip to conversation

fixes and improvements to cnxk crypto PMD

PATCH Superseded Tejasree Kondoj 2 participants 10 messages Aug 21, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover fixes and improvements to cnxk crypto PMD

Adding fixes and improvements to cnxk crypto PMD.

v2:
- Fixed coding style issues.

Nithinsen Kaithakadan (3):
common/cnxk: get context ilen as devarg
crypto/cnxk: fix compilation error and warnings
crypto/cnxk: align cptr to 256B in cn20k

Sucharitha Sarananaga (3):
crypto/cnxk: add new API to get fpm tbl address crypto/cnxk: add new API to get EC grp tbl address crypto/cnxk: refactor rsa verification

Tejasree Kondoj (2):
crypto/cnxk: align PDCP API with latest firmware crypto/cnxk: support custom metadata with CN20K

 doc/guides/cryptodevs/cnxk.rst               |  11 +
 drivers/common/cnxk/cnxk_security.c          |  20 +-
 drivers/common/cnxk/cnxk_security.h          |  25 +-
 drivers/common/cnxk/hw/cpt.h                 |  14 +-
 drivers/common/cnxk/roc_cpt.c                |   8 +-
 drivers/common/cnxk/roc_cpt.h                |   5 +
 drivers/common/cnxk/roc_se.h                 |  37 +-
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c    |  16 +-
 drivers/crypto/cnxk/cn10k_ipsec.c            |   4 +-
 drivers/crypto/cnxk/cn10k_tls.c              |  16 +-
 drivers/crypto/cnxk/cn20k_cryptodev_ops.c    |  20 +-
 drivers/crypto/cnxk/cn20k_ipsec.c            |  80 +++--
 drivers/crypto/cnxk/cn20k_ipsec.h            |  15 +-
 drivers/crypto/cnxk/cn20k_ipsec_la_ops.h     |  41 ++-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c     |   4 +-
 drivers/crypto/cnxk/cnxk_ae.h                |  15 +-
 drivers/crypto/cnxk/cnxk_cryptodev.h         |   1 +
 drivers/crypto/cnxk/cnxk_cryptodev_devargs.c |  49 +++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c     | 130 ++++++-
 drivers/crypto/cnxk/cnxk_se.h                | 340 +++++++++++++------
 drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h    |  96 ++++++
 drivers/net/cnxk/cn10k_ethdev_sec.c          |  14 +-
 drivers/net/cnxk/cn20k_ethdev_sec.c          |   8 +-
 23 files changed, 725 insertions(+), 244 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/8 common/cnxk: get context ilen as devarg

From: Nithinsen Kaithakadan <[email protected]>

Receive cpt context ilen as devarg parameter
and configure lf.

---
 doc/guides/cryptodevs/cnxk.rst               | 11 +++++
 drivers/common/cnxk/cnxk_security.c          | 20 ++++++--
 drivers/common/cnxk/cnxk_security.h          | 25 +++++-----
 drivers/common/cnxk/roc_cpt.c                |  8 +++-
 drivers/common/cnxk/roc_cpt.h                |  1 +
 drivers/crypto/cnxk/cn10k_ipsec.c            |  4 +-
 drivers/crypto/cnxk/cn10k_tls.c              | 16 +++++--
 drivers/crypto/cnxk/cn20k_ipsec.c            |  4 +-
 drivers/crypto/cnxk/cnxk_cryptodev.h         |  1 +
 drivers/crypto/cnxk/cnxk_cryptodev_devargs.c | 49 ++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c     |  3 ++
 drivers/net/cnxk/cn10k_ethdev_sec.c          | 14 +++---
 drivers/net/cnxk/cn20k_ethdev_sec.c          |  8 ++--
 13 files changed, 126 insertions(+), 38 deletions(-)
doc/guides/cryptodevs/cnxk.rst +11 -0
index 77e6a8e68d..c29a2cbb92 100644
@@ -200,6 +200,17 @@ Runtime Config Options
    With the above configuration, QP 20 will be used by the device for Rx injection
    in security in fallback mechanism scenario.
 
+- ``Context ilen value`` (default ``0``)
+
+  Initial context fetch length value for CPT context.
+
+  For example::
+
+      -a 0002:20:00.1,ctx_ilen=4
+
+  With the above configuration, CPT initial context fetch size will be set to
+  4+1 128 bytes blocks.
+
 Debugging Options
 -----------------
 
drivers/common/cnxk/cnxk_security.c +16 -4
index 0e6777e6ca..600098ae1c 100644
@@ -309,7 +309,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ot_ipsec_inb_sa_fill)
 int
 cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa,
 			  struct rte_security_ipsec_xform *ipsec_xfrm,
-			  struct rte_crypto_sym_xform *crypto_xfrm)
+			  struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen)
 {
 	uint16_t sport = 4500, dport = 4500;
 	union roc_ot_ipsec_sa_word2 w2;
@@ -383,6 +383,9 @@ cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa,
 		 ROC_CTX_UNIT_128B) -
 		1;
 
+	if (sa->w0.s.ctx_size < ctx_ilen)
+		sa->w0.s.ctx_size = ctx_ilen;
+
 	/**
 	 * CPT MC triggers expiry when counter value changes from 2 to 1. To
 	 * mitigate this behaviour add 1 to the life counter values provided.
@@ -419,7 +422,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ot_ipsec_outb_sa_fill)
 int
 cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,
 			   struct rte_security_ipsec_xform *ipsec_xfrm,
-			   struct rte_crypto_sym_xform *crypto_xfrm)
+			   struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen)
 {
 	struct rte_security_ipsec_tunnel_param *tunnel = &ipsec_xfrm->tunnel;
 	uint16_t sport = 4500, dport = 4500;
@@ -541,6 +544,9 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,
 			     ROC_CTX_UNIT_128B) -
 			    1;
 
+	if (sa->w0.s.ctx_size < ctx_ilen)
+		sa->w0.s.ctx_size = ctx_ilen;
+
 	/* IPID gen */
 	sa->w2.s.ipid_gen = 1;
 
@@ -1488,7 +1494,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ow_ipsec_inb_sa_fill)
 int
 cnxk_ow_ipsec_inb_sa_fill(struct roc_ow_ipsec_inb_sa *sa,
 			  struct rte_security_ipsec_xform *ipsec_xfrm,
-			  struct rte_crypto_sym_xform *crypto_xfrm)
+			  struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen)
 {
 	uint16_t sport = 4500, dport = 4500;
 	union roc_ow_ipsec_sa_word2 w2;
@@ -1559,6 +1565,9 @@ cnxk_ow_ipsec_inb_sa_fill(struct roc_ow_ipsec_inb_sa *sa,
 		(PLT_ALIGN_CEIL(ow_ipsec_inb_ctx_size(sa), ROC_CTX_UNIT_128B) / ROC_CTX_UNIT_128B) -
 		1;
 
+	if (sa->w0.s.ctx_size < ctx_ilen)
+		sa->w0.s.ctx_size = ctx_ilen;
+
 	/**
 	 * CPT MC triggers expiry when counter value changes from 2 to 1. To
 	 * mitigate this behaviour add 1 to the life counter values provided.
@@ -1595,7 +1604,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(cnxk_ow_ipsec_outb_sa_fill)
 int
 cnxk_ow_ipsec_outb_sa_fill(struct roc_ow_ipsec_outb_sa *sa,
 			   struct rte_security_ipsec_xform *ipsec_xfrm,
-			   struct rte_crypto_sym_xform *crypto_xfrm)
+			   struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen)
 {
 	struct rte_security_ipsec_tunnel_param *tunnel = &ipsec_xfrm->tunnel;
 	uint16_t sport = 4500, dport = 4500;
@@ -1711,6 +1720,9 @@ cnxk_ow_ipsec_outb_sa_fill(struct roc_ow_ipsec_outb_sa *sa,
 	/* IPID gen */
 	sa->w2.s.ipid_gen = 1;
 
+	if (sa->w0.s.ctx_size < ctx_ilen)
+		sa->w0.s.ctx_size = ctx_ilen;
+
 	/**
 	 * CPT MC triggers expiry when counter value changes from 2 to 1. To
 	 * mitigate this behaviour add 1 to the life counter values provided.
drivers/common/cnxk/cnxk_security.h +12 -13
index e324fa2cb9..3912c8d376 100644
@@ -33,19 +33,17 @@ cnxk_ipsec_icvlen_get(enum rte_crypto_cipher_algorithm c_algo,
 		      enum rte_crypto_auth_algorithm a_algo,
 		      enum rte_crypto_aead_algorithm aead_algo);
 
-uint8_t __roc_api
-cnxk_ipsec_outb_roundup_byte(enum rte_crypto_cipher_algorithm c_algo,
-			     enum rte_crypto_aead_algorithm aead_algo);
+uint8_t __roc_api cnxk_ipsec_outb_roundup_byte(enum rte_crypto_cipher_algorithm c_algo,
+					       enum rte_crypto_aead_algorithm aead_algo);
 
 /* [CN10K] */
-int __roc_api
-cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa,
-			  struct rte_security_ipsec_xform *ipsec_xfrm,
-			  struct rte_crypto_sym_xform *crypto_xfrm);
-int __roc_api
-cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,
-			   struct rte_security_ipsec_xform *ipsec_xfrm,
-			   struct rte_crypto_sym_xform *crypto_xfrm);
+int __roc_api cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa,
+					struct rte_security_ipsec_xform *ipsec_xfrm,
+					struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen);
+int __roc_api cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,
+					 struct rte_security_ipsec_xform *ipsec_xfrm,
+					 struct rte_crypto_sym_xform *crypto_xfrm,
+					 uint8_t ctx_ilen);
 bool __roc_api cnxk_ot_ipsec_inb_sa_valid(struct roc_ot_ipsec_inb_sa *sa);
 bool __roc_api cnxk_ot_ipsec_outb_sa_valid(struct roc_ot_ipsec_outb_sa *sa);
 
@@ -60,10 +58,11 @@ int __roc_api cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipse
 /* [CN20K, .) */
 int __roc_api cnxk_ow_ipsec_inb_sa_fill(struct roc_ow_ipsec_inb_sa *sa,
 					struct rte_security_ipsec_xform *ipsec_xfrm,
-					struct rte_crypto_sym_xform *crypto_xfrm);
+					struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen);
 int __roc_api cnxk_ow_ipsec_outb_sa_fill(struct roc_ow_ipsec_outb_sa *sa,
 					 struct rte_security_ipsec_xform *ipsec_xfrm,
-					 struct rte_crypto_sym_xform *crypto_xfrm);
+					 struct rte_crypto_sym_xform *crypto_xfrm,
+					 uint8_t ctx_ilen);
 bool __roc_api cnxk_ow_ipsec_inb_sa_valid(struct roc_ow_ipsec_inb_sa *sa);
 bool __roc_api cnxk_ow_ipsec_outb_sa_valid(struct roc_ow_ipsec_outb_sa *sa);
 #endif /* _CNXK_SECURITY_H__ */
drivers/common/cnxk/roc_cpt.c +7 -1
index d1ba2b8858..fa040b5f4f 100644
@@ -632,10 +632,16 @@ roc_cpt_dev_configure(struct roc_cpt *roc_cpt, int nb_lf, bool rxc_ena, uint16_t
 		eng_grpmsk = (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_AE]) |
 			     (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_SE]);
 
-	if (roc_errata_cpt_has_ctx_fetch_issue()) {
+	if (roc_cpt->ctx_ilen != 0) {
+		ctx_ilen = roc_cpt->ctx_ilen;
+		ctx_ilen_valid = true;
+	} else if (roc_errata_cpt_has_ctx_fetch_issue()) {
 		ctx_ilen_valid = true;
 		/* Inbound SA size is max context size */
 		ctx_ilen = (PLT_ALIGN(ROC_OT_IPSEC_SA_SZ_MAX, ROC_ALIGN) / 128) - 1;
+	} else if (roc_cpt->ctx_ilen != 0) {
+		ctx_ilen = roc_cpt->ctx_ilen;
+		ctx_ilen_valid = true;
 	}
 
 	rc = cpt_lfs_alloc(&cpt->dev, eng_grpmsk, blkaddr[blknum], false, ctx_ilen_valid, ctx_ilen,
drivers/common/cnxk/roc_cpt.h +1 -0
index 02f49c06b7..aa30f46f04 100644
@@ -169,6 +169,7 @@ struct roc_cpt {
 	uint16_t nb_lf;
 	uint16_t nb_lf_avail;
 	uintptr_t lmt_base;
+	uint8_t ctx_ilen;
 	/**< CPT device capabilities */
 	union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES];
 	uint8_t eng_grp[CPT_MAX_ENG_TYPES];
drivers/crypto/cnxk/cn10k_ipsec.c +2 -2
index 5cd4f5257a..a1207aa7c4 100644
@@ -45,7 +45,7 @@ cn10k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	}
 
 	/* Translate security parameters to SA */
-	ret = cnxk_ot_ipsec_outb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm);
+	ret = cnxk_ot_ipsec_outb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);
 	if (ret) {
 		plt_err("Could not fill outbound session parameters");
 		goto sa_dptr_free;
@@ -176,7 +176,7 @@ cn10k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	}
 
 	/* Translate security parameters to SA */
-	ret = cnxk_ot_ipsec_inb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm);
+	ret = cnxk_ot_ipsec_inb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);
 	if (ret) {
 		plt_err("Could not fill inbound session parameters");
 		goto sa_dptr_free;
drivers/crypto/cnxk/cn10k_tls.c +12 -4
index 49edac8cd6..1a7b87e400 100644
@@ -327,7 +327,8 @@ tls_read_ctx_size(struct roc_ie_ot_tls_read_sa *sa, enum rte_security_tls_versio
 static int
 tls_read_sa_fill(struct roc_ie_ot_tls_read_sa *read_sa,
 		 struct rte_security_tls_record_xform *tls_xfrm,
-		 struct rte_crypto_sym_xform *crypto_xfrm, struct cn10k_tls_opt *tls_opt)
+		 struct rte_crypto_sym_xform *crypto_xfrm, struct cn10k_tls_opt *tls_opt,
+		 uint8_t ctx_ilen)
 {
 	enum rte_security_tls_version tls_ver = tls_xfrm->ver;
 	struct rte_crypto_sym_xform *auth_xfrm, *cipher_xfrm;
@@ -470,6 +471,9 @@ tls_read_sa_fill(struct roc_ie_ot_tls_read_sa *read_sa,
 		 ROC_CTX_UNIT_128B) -
 		1;
 
+	if (read_sa->w0.s.ctx_size < ctx_ilen)
+		read_sa->w0.s.ctx_size = ctx_ilen;
+
 	/* Word offset for HW managed CTX field */
 	read_sa->w0.s.hw_ctx_off = offset / 8;
 	read_sa->w0.s.ctx_push_size = read_sa->w0.s.hw_ctx_off;
@@ -482,7 +486,7 @@ tls_read_sa_fill(struct roc_ie_ot_tls_read_sa *read_sa,
 static int
 tls_write_sa_fill(struct roc_ie_ot_tls_write_sa *write_sa,
 		  struct rte_security_tls_record_xform *tls_xfrm,
-		  struct rte_crypto_sym_xform *crypto_xfrm)
+		  struct rte_crypto_sym_xform *crypto_xfrm, uint8_t ctx_ilen)
 {
 	enum rte_security_tls_version tls_ver = tls_xfrm->ver;
 	struct rte_crypto_sym_xform *auth_xfrm, *cipher_xfrm;
@@ -606,6 +610,9 @@ tls_write_sa_fill(struct roc_ie_ot_tls_write_sa *write_sa,
 		write_sa->w0.s.ctx_size -= 1;
 	}
 
+	if (write_sa->w0.s.ctx_size < ctx_ilen)
+		write_sa->w0.s.ctx_size = ctx_ilen;
+
 	/* Word offset for HW managed CTX field */
 	write_sa->w0.s.hw_ctx_off = offset / 8;
 	write_sa->w0.s.ctx_push_size = write_sa->w0.s.hw_ctx_off;
@@ -655,7 +662,8 @@ cn10k_tls_read_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	}
 
 	/* Translate security parameters to SA */
-	ret = tls_read_sa_fill(sa_dptr, tls_xfrm, crypto_xfrm, &sec_sess->tls_opt);
+	ret = tls_read_sa_fill(sa_dptr, tls_xfrm, crypto_xfrm, &sec_sess->tls_opt,
+			       roc_cpt->ctx_ilen);
 	if (ret) {
 		plt_err("Could not fill read session parameters");
 		goto sa_dptr_free;
@@ -745,7 +753,7 @@ cn10k_tls_write_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	}
 
 	/* Translate security parameters to SA */
-	ret = tls_write_sa_fill(sa_dptr, tls_xfrm, crypto_xfrm);
+	ret = tls_write_sa_fill(sa_dptr, tls_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);
 	if (ret) {
 		plt_err("Could not fill write session parameters");
 		goto sa_dptr_free;
drivers/crypto/cnxk/cn20k_ipsec.c +2 -2
index 1a65438646..8f79033ccc 100644
@@ -45,7 +45,7 @@ cn20k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	}
 
 	/* Translate security parameters to SA */
-	ret = cnxk_ow_ipsec_outb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm);
+	ret = cnxk_ow_ipsec_outb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);
 	if (ret) {
 		plt_err("Could not fill outbound session parameters");
 		goto sa_dptr_free;
@@ -171,7 +171,7 @@ cn20k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf,
 	}
 
 	/* Translate security parameters to SA */
-	ret = cnxk_ow_ipsec_inb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm);
+	ret = cnxk_ow_ipsec_inb_sa_fill(sa_dptr, ipsec_xfrm, crypto_xfrm, roc_cpt->ctx_ilen);
 	if (ret) {
 		plt_err("Could not fill inbound session parameters");
 		goto sa_dptr_free;
drivers/crypto/cnxk/cnxk_cryptodev.h +1 -0
index 5cec64c2e1..088149badb 100644
@@ -36,6 +36,7 @@ struct cnxk_cpt_vf {
 	struct roc_ae_ec_group *ec_grp[ROC_AE_EC_ID_PMAX];
 	uint16_t max_qps_limit;
 	uint16_t rx_inject_qp;
+	uint8_t ctx_ilen;
 };
 
 uint64_t cnxk_cpt_default_ff_get(void);
drivers/crypto/cnxk/cnxk_cryptodev_devargs.c +49 -0

84 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.c +3 -0
index 261e14b418..2bf156bddb 100644
@@ -819,6 +819,9 @@ sym_session_configure(struct roc_cpt *roc_cpt, struct rte_crypto_sym_xform *xfor
 	if (hw_ctx_cache_enable())
 		roc_se_ctx_init(&sess_priv->roc_se_ctx);
 
+	if (sess_priv->roc_se_ctx.se_ctx.w0.s.ctx_size < roc_cpt->ctx_ilen)
+		sess_priv->roc_se_ctx.se_ctx.w0.s.ctx_size = roc_cpt->ctx_ilen;
+
 	return 0;
 
 priv_put:
drivers/net/cnxk/cn10k_ethdev_sec.c +6 -8
index 110630596e..c477b12a30 100644
@@ -845,10 +845,9 @@ cn10k_eth_sec_session_create(void *device,
 		memset(inb_sa_dptr, 0, sizeof(struct roc_ot_ipsec_inb_sa));
 
 		/* Fill inbound sa params */
-		rc = cnxk_ot_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ot_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto, 0);
 		if (rc) {
-			snprintf(tbuf, sizeof(tbuf),
-				 "Failed to init inbound sa, rc=%d", rc);
+			snprintf(tbuf, sizeof(tbuf), "Failed to init inbound sa, rc=%d", rc);
 			goto err;
 		}
 
@@ -936,10 +935,9 @@ cn10k_eth_sec_session_create(void *device,
 		memset(outb_sa_dptr, 0, sizeof(struct roc_ot_ipsec_outb_sa));
 
 		/* Fill outbound sa params */
-		rc = cnxk_ot_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ot_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto, 0);
 		if (rc) {
-			snprintf(tbuf, sizeof(tbuf),
-				 "Failed to init outbound sa, rc=%d", rc);
+			snprintf(tbuf, sizeof(tbuf), "Failed to init outbound sa, rc=%d", rc);
 			rc |= cnxk_eth_outb_sa_idx_put(dev, sa_idx);
 			goto err;
 		}
@@ -1148,7 +1146,7 @@ cn10k_eth_sec_session_update(void *device, struct rte_security_session *sess,
 		inb_sa_dptr = (struct roc_ot_ipsec_inb_sa *)dev->inb.sa_dptr;
 		memset(inb_sa_dptr, 0, sizeof(struct roc_ot_ipsec_inb_sa));
 
-		rc = cnxk_ot_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ot_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto, 0);
 		if (rc)
 			goto err;
 		/* Use cookie for original data */
@@ -1183,7 +1181,7 @@ cn10k_eth_sec_session_update(void *device, struct rte_security_session *sess,
 		outb_sa_dptr = (struct roc_ot_ipsec_outb_sa *)dev->outb.sa_dptr;
 		memset(outb_sa_dptr, 0, sizeof(struct roc_ot_ipsec_outb_sa));
 
-		rc = cnxk_ot_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ot_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto, 0);
 		if (rc)
 			goto err;
 
drivers/net/cnxk/cn20k_ethdev_sec.c +4 -4
index 4284b726ee..5bf7917345 100644
@@ -736,7 +736,7 @@ cn20k_eth_sec_session_create(void *device, struct rte_security_session_conf *con
 		memset(inb_sa_dptr, 0, sizeof(struct roc_ow_ipsec_inb_sa));
 
 		/* Fill inbound sa params */
-		rc = cnxk_ow_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ow_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto, 0);
 		if (rc) {
 			snprintf(tbuf, sizeof(tbuf), "Failed to init inbound sa, rc=%d", rc);
 			goto err;
@@ -814,7 +814,7 @@ cn20k_eth_sec_session_create(void *device, struct rte_security_session_conf *con
 		memset(outb_sa_dptr, 0, sizeof(struct roc_ow_ipsec_outb_sa));
 
 		/* Fill outbound sa params */
-		rc = cnxk_ow_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ow_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto, 0);
 		if (rc) {
 			snprintf(tbuf, sizeof(tbuf), "Failed to init outbound sa, rc=%d", rc);
 			rc |= cnxk_eth_outb_sa_idx_put(dev, sa_idx);
@@ -1000,7 +1000,7 @@ cn20k_eth_sec_session_update(void *device, struct rte_security_session *sess,
 		inb_sa_dptr = (struct roc_ow_ipsec_inb_sa *)dev->inb.sa_dptr;
 		memset(inb_sa_dptr, 0, sizeof(struct roc_ow_ipsec_inb_sa));
 
-		rc = cnxk_ow_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ow_ipsec_inb_sa_fill(inb_sa_dptr, ipsec, crypto, 0);
 		if (rc)
 			return -EINVAL;
 		/* Use cookie for original data */
@@ -1034,7 +1034,7 @@ cn20k_eth_sec_session_update(void *device, struct rte_security_session *sess,
 		outb_sa_dptr = (struct roc_ow_ipsec_outb_sa *)dev->outb.sa_dptr;
 		memset(outb_sa_dptr, 0, sizeof(struct roc_ow_ipsec_outb_sa));
 
-		rc = cnxk_ow_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto);
+		rc = cnxk_ow_ipsec_outb_sa_fill(outb_sa_dptr, ipsec, crypto, 0);
 		if (rc)
 			return -EINVAL;
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/8 crypto/cnxk: fix compilation error and warnings

In reply to Tejasree Kondoj

From: Nithinsen Kaithakadan <[email protected]>

Remove multiple return statements.
Fix compilation error in debug mode.

Fixes 8fc370ee0208 ("crypto/cnxk: add CN20K security skeleton")
---
 drivers/crypto/cnxk/cn20k_ipsec.c | 2 --
 1 file changed, 2 deletions(-)
drivers/crypto/cnxk/cn20k_ipsec.c +0 -2
index 8f79033ccc..0bca863492 100644
@@ -373,6 +373,4 @@ cn20k_ipsec_session_update(struct cnxk_cpt_vf *vf, struct cnxk_cpt_qp *qp,
 
 	return cn20k_ipsec_outb_sa_create(roc_cpt, &qp->lf, &conf->ipsec, conf->crypto_xform,
 					  (struct cn20k_sec_session *)sess);
-
-	return 0;
 }
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/8 crypto/cnxk: add new API to get fpm tbl address

In reply to Tejasree Kondoj

From: Sucharitha Sarananaga <[email protected]>

This patch introduces a new API to get FPM table host address.

---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 23 +++++++++++++++++++++++
 drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 18 ++++++++++++++++++
 2 files changed, 41 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +23 -0
index 2bf156bddb..97c12c6087 100644
@@ -12,6 +12,7 @@
 #endif
 #include <rte_security_driver.h>
 
+#include "roc_ae.h"
 #include "roc_ae_fpm_tables.h"
 #include "roc_cpt.h"
 #include "roc_errata.h"
@@ -995,6 +996,28 @@ rte_pmd_cnxk_crypto_qptr_get(uint8_t dev_id, uint16_t qp_id)
 	return qptr;
 }
 
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_cnxk_ae_fpm_table_get, 25.07)
+const uint64_t *
+rte_pmd_cnxk_ae_fpm_table_get(uint8_t dev_id)
+{
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (dev == NULL) {
+		plt_err("Invalid dev_id %u", dev_id);
+		return NULL;
+	}
+
+	vf = dev->data->dev_private;
+	if (vf == NULL) {
+		plt_err("VF is not initialized");
+		return NULL;
+	}
+
+	return vf->cnxk_fpm_iova;
+}
+
 static inline void
 cnxk_crypto_cn10k_submit(struct rte_pmd_cnxk_crypto_qptr *qptr, void *inst, uint16_t nb_inst)
 {
drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h +18 -0
index 46861ab2cf..cd3ddc9dd1 100644
@@ -213,4 +213,22 @@ __rte_experimental
 int rte_pmd_cnxk_crypto_qp_stats_get(struct rte_pmd_cnxk_crypto_qptr *qptr,
 				     struct rte_pmd_cnxk_crypto_qp_stats *stats);
 
+/**
+ * Retrieves the addresses of the AE FPM (Finite Precision Math) tables.
+ *
+ * This API should be called only after the cryptodev device has been
+ * successfully configured. The returned pointer reference memory that is
+ * valid as long as the device remains configured and is not destroyed or
+ * reconfigured. If the device is reconfigured or destroyed, the memory
+ * referenced by the returned pointer becomes invalid and must not be used.
+ *
+ * @param dev_id
+ *   Device identifier of cryptodev device.
+ * @return
+ *   - On success pointer to the AE FPM table addresses.
+ *   - NULL on error.
+ */
+__rte_experimental 
+const uint64_t *rte_pmd_cnxk_ae_fpm_table_get(uint8_t dev_id);
+
 #endif /* _PMD_CNXK_CRYPTO_H_ */
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 4/8 crypto/cnxk: add new API to get EC grp tbl address

In reply to Tejasree Kondoj

From: Sucharitha Sarananaga <[email protected]>

This patch introduces a new API to get AE EC group table address and added static_assert checks to ensure that each enum value in roc_ae_ec_id matches its expected constant. This helps catch accidental changes or reordering of enum values at compile time.

---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 47 ++++++++++++++
 drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h | 78 +++++++++++++++++++++++
 2 files changed, 125 insertions(+)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +47 -0
index 97c12c6087..8bc7b2c345 100644
@@ -43,6 +43,29 @@
 #define CNXK_CPT_MAX_ASYM_OP_MOD_LEN	 1024
 #define CNXK_CPT_META_BUF_MAX_CACHE_SIZE 128
 
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P192 == (uint16_t)ROC_AE_EC_ID_P192,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P224 == (uint16_t)ROC_AE_EC_ID_P224,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P256 == (uint16_t)ROC_AE_EC_ID_P256,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P384 == (uint16_t)ROC_AE_EC_ID_P384,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P521 == (uint16_t)ROC_AE_EC_ID_P521,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P160 == (uint16_t)ROC_AE_EC_ID_P160,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P320 == (uint16_t)ROC_AE_EC_ID_P320,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_P512 == (uint16_t)ROC_AE_EC_ID_P512,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_SM2 == (uint16_t)ROC_AE_EC_ID_SM2,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_ED25519 == (uint16_t)ROC_AE_EC_ID_ED25519,
+	      "Enum value mismatch");
+static_assert((uint16_t)RTE_PMD_CNXK_AE_EC_ID_ED448 == (uint16_t)ROC_AE_EC_ID_ED448,
+	      "Enum value mismatch");
+
 static int
 cnxk_cpt_get_mlen(void)
 {
@@ -1018,6 +1041,30 @@ rte_pmd_cnxk_ae_fpm_table_get(uint8_t dev_id)
 	return vf->cnxk_fpm_iova;
 }
 
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmd_cnxk_ae_ec_grp_table_get, 25.07)
+const struct rte_pmd_cnxk_crypto_ae_ec_group_params **
+rte_pmd_cnxk_ae_ec_grp_table_get(uint8_t dev_id, uint16_t *nb_max_entries)
+{
+	struct rte_cryptodev *dev;
+	struct cnxk_cpt_vf *vf;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+	if (dev == NULL) {
+		plt_err("Invalid dev_id %u", dev_id);
+		return NULL;
+	}
+
+	vf = dev->data->dev_private;
+	if (vf == NULL) {
+		plt_err("VF is not initialized");
+		return NULL;
+	}
+
+	*nb_max_entries = ROC_AE_EC_ID_PMAX;
+
+	return (const struct rte_pmd_cnxk_crypto_ae_ec_group_params **)(void *)vf->ec_grp;
+}
+
 static inline void
 cnxk_crypto_cn10k_submit(struct rte_pmd_cnxk_crypto_qptr *qptr, void *inst, uint16_t nb_inst)
 {
drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h +78 -0

94 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 5/8 crypto/cnxk: align cptr to 256B in cn20k

In reply to Tejasree Kondoj

From: Nithinsen Kaithakadan <[email protected]>

Change the alignment of cptr to 256 bytes from
128 bytes in cn20k.

---
 drivers/common/cnxk/roc_cpt.h             |   4 +
 drivers/common/cnxk/roc_se.h              |  37 +++----
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |   8 +-
 drivers/crypto/cnxk/cn20k_cryptodev_ops.c |   8 +-
 drivers/crypto/cnxk/cn20k_ipsec.c         |  74 +++++++++----
 drivers/crypto/cnxk/cn20k_ipsec.h         |  15 ++-
 drivers/crypto/cnxk/cn20k_ipsec_la_ops.h  |  41 +++++---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  |  61 ++++++++---
 drivers/crypto/cnxk/cnxk_se.h             | 121 ++++++++++++++++------
 9 files changed, 253 insertions(+), 116 deletions(-)
drivers/common/cnxk/roc_cpt.h +4 -0
index aa30f46f04..37bca8d183 100644
@@ -129,6 +129,10 @@
 	(PLT_ALIGN_CEIL(ROC_AR_WIN_SIZE_MAX, BITS_PER_LONG_LONG) /             \
 	 BITS_PER_LONG_LONG)
 
+/* ROC CPTR Cache */
+#define ROC_CPTR_CACHE_LINE_SZ 256
+#define ROC_CPTR_ALIGN	       ROC_CPTR_CACHE_LINE_SZ
+
 enum {
 	ROC_CPT_REVISION_ID_83XX = 0,
 	ROC_CPT_REVISION_ID_96XX_B0 = 1,
drivers/common/cnxk/roc_se.h +19 -18
index f2c4056169..9afcda8ba4 100644
@@ -314,24 +314,6 @@ struct roc_se_iov_ptr {
 #define ROC_SE_PDCP_CHAIN_CTX_KEY_IV 1
 
 struct roc_se_ctx {
-	/* Below fields are accessed by sw */
-	uint64_t enc_cipher : 8;
-	uint64_t hash_type : 8;
-	uint64_t mac_len : 8;
-	uint64_t auth_key_len : 16;
-	uint64_t fc_type : 4;
-	uint64_t hmac : 1;
-	uint64_t zsk_flags : 3;
-	uint64_t k_ecb : 1;
-	uint64_t pdcp_ci_alg : 2;
-	uint64_t pdcp_auth_alg : 2;
-	uint64_t ciph_then_auth : 1;
-	uint64_t auth_then_ciph : 1;
-	uint64_t eia2 : 1;
-	/* auth_iv_offset passed to PDCP_CHAIN opcode based on FVC bit */
-	uint8_t pdcp_iv_offset;
-	union cpt_inst_w4 template_w4;
-	uint8_t *auth_key;
 	/* Below fields are accessed by hardware */
 	struct se_ctx_s {
 		/* Word0 */
@@ -356,6 +338,25 @@ struct roc_se_ctx {
 			struct roc_se_sm_context sm_ctx;
 		};
 	} se_ctx __plt_aligned(ROC_ALIGN);
+
+	/* Below fields are accessed by sw */
+	uint64_t enc_cipher : 8;
+	uint64_t hash_type : 8;
+	uint64_t mac_len : 8;
+	uint64_t auth_key_len : 16;
+	uint64_t fc_type : 4;
+	uint64_t hmac : 1;
+	uint64_t zsk_flags : 3;
+	uint64_t k_ecb : 1;
+	uint64_t pdcp_ci_alg : 2;
+	uint64_t pdcp_auth_alg : 2;
+	uint64_t ciph_then_auth : 1;
+	uint64_t auth_then_ciph : 1;
+	uint64_t eia2 : 1;
+	/* auth_iv_offset passed to PDCP_CHAIN opcode based on FVC bit */
+	uint8_t pdcp_iv_offset;
+	union cpt_inst_w4 template_w4;
+	uint8_t *auth_key;
 } __plt_aligned(ROC_ALIGN);
 
 struct roc_se_fc_params {
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +4 -4
index 31ec88c7d6..17edf636da 100644
@@ -1928,7 +1928,7 @@ cn10k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (sess_type != RTE_CRYPTO_OP_WITH_SESSION)
 		return -ENOTSUP;
 
-	if (sess == NULL)
+	if (sess == NULL || sess->roc_se_ctx == NULL)
 		return -EINVAL;
 
 	if ((sess->dp_thr_type == CPT_DP_THREAD_TYPE_PDCP) ||
@@ -1938,11 +1938,11 @@ cn10k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,
 		return -ENOTSUP;
 
 	if ((sess->dp_thr_type == CPT_DP_THREAD_AUTH_ONLY) &&
-	    ((sess->roc_se_ctx.fc_type == ROC_SE_KASUMI) ||
-	     (sess->roc_se_ctx.fc_type == ROC_SE_PDCP)))
+	    ((sess->roc_se_ctx->fc_type == ROC_SE_KASUMI) ||
+	     (sess->roc_se_ctx->fc_type == ROC_SE_PDCP)))
 		return -ENOTSUP;
 
-	if (sess->roc_se_ctx.hash_type == ROC_SE_SHA1_TYPE)
+	if (sess->roc_se_ctx->hash_type == ROC_SE_SHA1_TYPE)
 		return -ENOTSUP;
 
 	dp_ctx = (struct cnxk_sym_dp_ctx *)raw_dp_ctx->drv_ctx_data;
drivers/crypto/cnxk/cn20k_cryptodev_ops.c +4 -4
index 6ef7c5bb22..86d02ba5ca 100644
@@ -1675,7 +1675,7 @@ cn20k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,
 	if (sess_type != RTE_CRYPTO_OP_WITH_SESSION)
 		return -ENOTSUP;
 
-	if (sess == NULL)
+	if (sess == NULL || sess->roc_se_ctx == NULL)
 		return -EINVAL;
 
 	if ((sess->dp_thr_type == CPT_DP_THREAD_TYPE_PDCP) ||
@@ -1685,11 +1685,11 @@ cn20k_sym_configure_raw_dp_ctx(struct rte_cryptodev *dev, uint16_t qp_id,
 		return -ENOTSUP;
 
 	if ((sess->dp_thr_type == CPT_DP_THREAD_AUTH_ONLY) &&
-	    ((sess->roc_se_ctx.fc_type == ROC_SE_KASUMI) ||
-	     (sess->roc_se_ctx.fc_type == ROC_SE_PDCP)))
+	    ((sess->roc_se_ctx->fc_type == ROC_SE_KASUMI) ||
+	     (sess->roc_se_ctx->fc_type == ROC_SE_PDCP)))
 		return -ENOTSUP;
 
-	if (sess->roc_se_ctx.hash_type == ROC_SE_SHA1_TYPE)
+	if (sess->roc_se_ctx->hash_type == ROC_SE_SHA1_TYPE)
 		return -ENOTSUP;
 
 	dp_ctx = (struct cnxk_sym_dp_ctx *)raw_dp_ctx->drv_ctx_data;
drivers/crypto/cnxk/cn20k_ipsec.c +53 -21

199 lines not on this page · raw message

drivers/crypto/cnxk/cn20k_ipsec.h +10 -5
index 202d52405d..069142fbc6 100644
@@ -18,13 +18,18 @@
 /* Forward declaration */
 struct cn20k_sec_session;
 
-struct __rte_aligned(ROC_ALIGN) cn20k_ipsec_sa
+struct __rte_aligned(ROC_CPTR_ALIGN) cn20k_ipsec_sa
 {
 	union {
-		/** Inbound SA */
-		struct roc_ow_ipsec_inb_sa in_sa;
-		/** Outbound SA */
-		struct roc_ow_ipsec_outb_sa out_sa;
+		void *sa_ptr;
+		struct {
+			union {
+				/** Inbound SA */
+				struct roc_ow_ipsec_inb_sa *in_sa;
+				/** Outbound SA */
+				struct roc_ow_ipsec_outb_sa *out_sa;
+			};
+		};
 	};
 };
 
drivers/crypto/cnxk/cn20k_ipsec_la_ops.h +25 -16

67 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.c +44 -17

132 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_se.h +90 -31

337 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 6/8 crypto/cnxk: refactor rsa verification

In reply to Tejasree Kondoj

From: Sucharitha Sarananaga <[email protected]>

This patch avoid copying the decrypted message into the signature buffer, which is actually an input to the verify operation. This prevents overwriting the input buffer unnecessarily.

Fixes 6661bedf1605 ("crypto/cnxk: add asymmetric datapath")
---
 drivers/crypto/cnxk/cnxk_ae.h | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/crypto/cnxk/cnxk_ae.h +6 -9
index 8508ab8736..912a2a9496 100644
@@ -1592,20 +1592,17 @@ cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr,
 	case RTE_CRYPTO_ASYM_OP_VERIFY:
 		if (rsa_ctx->padding.type == RTE_CRYPTO_RSA_PADDING_NONE) {
 			rsa->sign.length = rsa_ctx->n.length;
-			memcpy(rsa->sign.data, rptr, rsa->sign.length);
+			if (memcmp(rptr, rsa->message.data, rsa->message.length))
+				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 		} else {
 			/* Get length of signed output */
-			rsa->sign.length =
-				rte_cpu_to_be_16(*((uint16_t *)rptr));
+			rsa->sign.length = rte_cpu_to_be_16(*((uint16_t *)rptr));
 			/*
 			 * Offset output data pointer by length field
-			 * (2 bytes) and copy signed data.
+			 * (2 bytes) and compare signed data.
 			 */
-			memcpy(rsa->sign.data, rptr + 2, rsa->sign.length);
-		}
-		if (memcmp(rsa->sign.data, rsa->message.data,
-			   rsa->message.length)) {
-			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			if (memcmp(rptr + 2, rsa->message.data, rsa->message.length))
+				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
 		}
 		break;
 	default:
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 7/8 crypto/cnxk: align PDCP API with latest firmware

In reply to Tejasree Kondoj

Aligning PDCP API with latest firmware.

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |   8 +-
 drivers/crypto/cnxk/cn20k_cryptodev_ops.c |   8 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |   4 +-
 drivers/crypto/cnxk/cnxk_se.h             | 171 ++++++++++++++--------
 4 files changed, 121 insertions(+), 70 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +5 -3
index 17edf636da..d6b95a14aa 100644
@@ -206,7 +206,8 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 			w7 = sec_sess->inst.w7;
 		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sess = (struct cnxk_se_sess *)(sym_op->session);
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], is_sg_ver2);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], is_sg_ver2,
+						false);
 			if (unlikely(ret))
 				return 0;
 			w7 = sess->cpt_inst_w7;
@@ -217,7 +218,8 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 				return 0;
 			}
 
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], is_sg_ver2);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], is_sg_ver2,
+						false);
 			if (unlikely(ret)) {
 				sym_session_clear(op->sym->session, true);
 				rte_mempool_put(qp->sess_mp, op->sym->session);
@@ -1557,7 +1559,7 @@ cn10k_cpt_raw_fill_inst(struct cnxk_iov *iov, struct cnxk_cpt_qp *qp,
 		break;
 	case CPT_DP_THREAD_AUTH_ONLY:
 		ret = fill_raw_digest_params(iov, sess, &qp->meta_info, infl_req, &inst[0],
-					     is_sg_ver2);
+					     is_sg_ver2, false);
 		break;
 	default:
 		ret = -EINVAL;
drivers/crypto/cnxk/cn20k_cryptodev_ops.c +5 -3
index 86d02ba5ca..30194db4ad 100644
@@ -207,7 +207,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 			w7 = sec_sess->inst.w7;
 		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sess = (struct cnxk_se_sess *)(sym_op->session);
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], true);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], true, true);
 			if (unlikely(ret))
 				return 0;
 			w7 = sess->cpt_inst_w7;
@@ -218,7 +218,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 				return 0;
 			}
 
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], true);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, &inst[0], true, true);
 			if (unlikely(ret)) {
 				sym_session_clear(op->sym->session, true);
 				rte_mempool_put(qp->sess_mp, op->sym->session);
@@ -278,6 +278,7 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 
 	cnxk_cpt_request_data_sgv2_mode_dump((void *)inst[0].dptr, 1, inst[0].w5.s.gather_sz);
 	cnxk_cpt_request_data_sgv2_mode_dump((void *)inst[0].rptr, 0, inst[0].w6.s.scatter_sz);
+
 #endif
 
 	return 1;
@@ -1342,7 +1343,8 @@ cn20k_cpt_raw_fill_inst(struct cnxk_iov *iov, struct cnxk_cpt_qp *qp,
 					 true);
 		break;
 	case CPT_DP_THREAD_AUTH_ONLY:
-		ret = fill_raw_digest_params(iov, sess, &qp->meta_info, infl_req, &inst[0], true);
+		ret = fill_raw_digest_params(iov, sess, &qp->meta_info, infl_req, &inst[0], true,
+					     true);
 		break;
 	default:
 		ret = -EINVAL;
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +2 -2
index c94e9e0f92..5551e40cb0 100644
@@ -117,7 +117,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sym_op = op->sym;
 			sess = (struct cnxk_se_sess *)sym_op->session;
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst, false);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst, false, false);
 			inst->w7.u64 = sess->cpt_inst_w7;
 		} else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
 			ret = cn9k_cpt_sec_inst_fill(qp, op, infl_req, inst);
@@ -128,7 +128,7 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 				return -1;
 			}
 
-			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst, false);
+			ret = cpt_sym_inst_fill(qp, op, sess, infl_req, inst, false, false);
 			if (unlikely(ret)) {
 				sym_session_clear(op->sym->session, true);
 				rte_mempool_put(qp->sess_mp, op->sym->session);
drivers/crypto/cnxk/cnxk_se.h +109 -62

454 lines not on this page · raw message

Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 8/8 crypto/cnxk: support custom metadata with CN20K

In reply to Tejasree Kondoj

Adding support for custom metadata in CN20K PMD.

---
 drivers/common/cnxk/hw/cpt.h              | 14 +++-
 drivers/crypto/cnxk/cn20k_cryptodev_ops.c |  4 +
 drivers/crypto/cnxk/cnxk_se.h             | 94 +++++++++++++++--------
 3 files changed, 78 insertions(+), 34 deletions(-)
drivers/common/cnxk/hw/cpt.h +12 -2
index e542f3a3d4..4079221676 100644
@@ -247,7 +247,13 @@ struct cpt_inst_s {
 			uint64_t nixtxl : 3;
 			uint64_t doneint : 1;
 			uint64_t nixtx_addr : 60;
-		} s;
+		} cn10k;
+		struct {
+			uint64_t nixtxl : 3;
+			uint64_t doneint : 1;
+			uint64_t rsvd : 58;
+			uint64_t pkt_ctl : 2;
+		} cn20k;
 		struct {
 			uint64_t nixtxl : 3;
 			uint64_t doneint : 1;
@@ -260,7 +266,11 @@ struct cpt_inst_s {
 		uint64_t u64;
 	} w0;
 
-	uint64_t res_addr;
+	struct {
+		uint64_t res_addr : 59;
+		uint64_t meta_sz : 4;
+		uint64_t cq_ena : 1;
+	};
 
 	union cpt_inst_w2 {
 		struct {
drivers/crypto/cnxk/cn20k_cryptodev_ops.c +4 -0
index 30194db4ad..b696c28081 100644
@@ -196,6 +196,10 @@ cn20k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[], struct
 	inst[0].w2.u64 = 0;
 	inst[0].w3.u64 = 0;
 
+	inst[0].meta_sz = 0;
+	inst[0].cq_ena = 0;
+	inst[0].res_addr = 0;
+
 	sym_op = op->sym;
 
 	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
drivers/crypto/cnxk/cnxk_se.h +62 -32

191 lines not on this page · raw message

Signature · 1 line
2.25.1
#9 lore raw
In reply to Tejasree Kondoj
Quoted 35 lines · On Thu, 21 Aug 2025 11:43:33 +0530 Tejasree Kondoj <[email protected]>…

Adding fixes and improvements to cnxk crypto PMD.

v2:
- Fixed coding style issues.

Nithinsen Kaithakadan (3):
common/cnxk: get context ilen as devarg
crypto/cnxk: fix compilation error and warnings
crypto/cnxk: align cptr to 256B in cn20k

Sucharitha Sarananaga (3):
crypto/cnxk: add new API to get fpm tbl address crypto/cnxk: add new API to get EC grp tbl address crypto/cnxk: refactor rsa verification

Tejasree Kondoj (2):
crypto/cnxk: align PDCP API with latest firmware crypto/cnxk: support custom metadata with CN20K

 doc/guides/cryptodevs/cnxk.rst               |  11 +
 drivers/common/cnxk/cnxk_security.c          |  20 +-
 drivers/common/cnxk/cnxk_security.h          |  25 +-
 drivers/common/cnxk/hw/cpt.h                 |  14 +-
 drivers/common/cnxk/roc_cpt.c                |   8 +-
 drivers/common/cnxk/roc_cpt.h                |   5 +
 drivers/common/cnxk/roc_se.h                 |  37 +-
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c    |  16 +-
 drivers/crypto/cnxk/cn10k_ipsec.c            |   4 +-
 drivers/crypto/cnxk/cn10k_tls.c              |  16 +-
 drivers/crypto/cnxk/cn20k_cryptodev_ops.c    |  20 +-
 drivers/crypto/cnxk/cn20k_ipsec.c            |  80 +++--
 drivers/crypto/cnxk/cn20k_ipsec.h            |  15 +-
 drivers/crypto/cnxk/cn20k_ipsec_la_ops.h     |  41 ++-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c     |   4 +-
 drivers/crypto/cnxk/cnxk_ae.h                |  15 +-
Quoted 9 lines
 drivers/crypto/cnxk/cnxk_cryptodev.h         |   1 +
 drivers/crypto/cnxk/cnxk_cryptodev_devargs.c |  49 +++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c     | 130 ++++++-
 drivers/crypto/cnxk/cnxk_se.h                | 340 +++++++++++++------
 drivers/crypto/cnxk/rte_pmd_cnxk_crypto.h    |  96 ++++++
 drivers/net/cnxk/cn10k_ethdev_sec.c          |  14 +-
 drivers/net/cnxk/cn20k_ethdev_sec.c          |   8 +-
 23 files changed, 725 insertions(+), 244 deletions(-)

I have been doing test builds with more warnings enabled.
These drivers have a lot of shadowed variables which are often a source of bugs.

In file included from ../drivers/crypto/cnxk/cnxk_cryptodev_ops.c:30:
../drivers/crypto/cnxk/cnxk_se.h: In function ‘cpt_sm_prep’:
../drivers/crypto/cnxk/cnxk_se.h:1160:41: warning: declaration of ‘src’ shadows a previous local [-Wshadow]
1160 | const uint64_t *src = fc_params->iv_buf;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h:1105:24: note: shadowed declaration is here
1105 | const uint8_t *src = NULL;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h: In function ‘cpt_enc_hmac_prep’:
../drivers/crypto/cnxk/cnxk_se.h:1330:41: warning: declaration of ‘src’ shadows a previous local [-Wshadow]
1330 | const uint64_t *src = fc_params->iv_buf;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h:1200:24: note: shadowed declaration is here
1200 | const uint8_t *src = NULL;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h: In function ‘cpt_dec_hmac_prep’:
../drivers/crypto/cnxk/cnxk_se.h:1487:41: warning: declaration of ‘src’ shadows a previous local [-Wshadow]
1487 | const uint64_t *src = fc_params->iv_buf;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h:1369:24: note: shadowed declaration is here
1369 | const uint8_t *src = NULL;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h: In function ‘fill_digest_params’:
../drivers/crypto/cnxk/cnxk_se.h:3233:34: warning: declaration of ‘src’ shadows a previous local [-Wshadow]
3233 | uint8_t *src, direction = 0;
| ^~~
../drivers/crypto/cnxk/cnxk_se.h:3200:14: note: shadowed declaration is here
3200 | char src[SRC_IOV_SIZE];
| ^~~
../drivers/crypto/cnxk/cnxk_se.h:3273:39: warning: declaration of ‘space’ shadows a previous local [-Wshadow]
3273 | int32_t dlen, space;
| ^~~~~
../drivers/crypto/cnxk/cnxk_se.h:3190:18: note: shadowed declaration is here
3190 | uint32_t space = 0;
| ^~~~~
../drivers/crypto/cnxk/cnxk_se.h: In function ‘fill_raw_fc_params’:
../drivers/crypto/cnxk/cnxk_se.h:3576:12: warning: this condition has identical branches [-Wduplicated-branches]
3576 | if (is_kasumi) {
| ^