Skip to contentSkip to conversation

crypto/cnxk: add ML crypto support

PATCH Superseded Gowrishankar Muthukrishnan 3 participants 5 messages May 29 – Jun 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto/cnxk: add ML crypto support

Add ML-KEM and ML-DSA support.

---
 doc/guides/cryptodevs/features/cn20k.ini      |   3 +
 doc/guides/cryptodevs/features/default.ini    |   1 +
 doc/guides/rel_notes/release_26_07.rst        |   3 +
 drivers/common/cnxk/hw/cpt.h                  |   1 +
 drivers/common/cnxk/meson.build               |   1 +
 drivers/common/cnxk/roc_cpt.c                 |   4 +
 drivers/common/cnxk/roc_platform.h            |   5 +
 .../common/cnxk/roc_platform_base_symbols.c   |   2 +
 drivers/common/cnxk/roc_re.h                  |  31 ++
 drivers/common/cnxk/roc_re_ml_tables.c        | 248 +++++++++++
 drivers/common/cnxk/roc_re_ml_tables.h        |  19 +
 drivers/crypto/cnxk/cnxk_ae.h                 | 399 +++++++++++++++++-
 drivers/crypto/cnxk/cnxk_cryptodev.c          |  11 +
 drivers/crypto/cnxk/cnxk_cryptodev.h          |   4 +-
 .../crypto/cnxk/cnxk_cryptodev_capabilities.c |  62 ++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c      |  45 +-
 16 files changed, 817 insertions(+), 22 deletions(-)
 create mode 100644 drivers/common/cnxk/roc_re.h
 create mode 100644 drivers/common/cnxk/roc_re_ml_tables.c
 create mode 100644 drivers/common/cnxk/roc_re_ml_tables.h
doc/guides/cryptodevs/features/cn20k.ini +3 -0
index d4c52082c6..8180128744 100644
@@ -21,6 +21,7 @@ Asymmetric sessionless = Y
 Sym raw data path API  = Y
 Inner checksum         = Y
 Rx inject              = Y
+ML-DSA sign prehash    = Y
 
 ;
 ; Supported crypto algorithms of 'cn20k' crypto driver.
@@ -110,6 +111,8 @@ ECDSA                   = Y
 ECPM                    = Y
 SM2                     = Y
 EdDSA                   = Y
+ML-DSA                  = Y
+ML-KEM                  = Y
 
 ;
 ; Supported Operating systems of the 'cn20k' crypto driver.
doc/guides/cryptodevs/features/default.ini +1 -0
index d8026c3750..be4ee777fb 100644
@@ -35,6 +35,7 @@ Cipher multiple data units =
 Cipher wrapped key     =
 Inner checksum         =
 Rx inject              =
+ML-DSA sign prehash    =
 
 ;
 ; Supported crypto algorithms of a default crypto driver.
doc/guides/rel_notes/release_26_07.rst +3 -0
index 8b4f8401e2..67c1842afe 100644
@@ -87,6 +87,9 @@ New Features
   Added AGENTS.md file for AI review
   and supporting scripts to review patches and documentation.
 
+* **Updated Marvell cnxk crypto driver.**
+
+  * Added support for ML-KEM and ML-DSA on CN20K platform.
 
 Removed Items
 -------------
drivers/common/cnxk/hw/cpt.h +1 -0
index eb795f61ac..12aeb4d054 100644
@@ -58,6 +58,7 @@ enum cpt_eng_type {
 	CPT_ENG_TYPE_AE = 1,
 	CPT_ENG_TYPE_SE = 2,
 	CPT_ENG_TYPE_IE = 3,
+	CPT_ENG_TYPE_RE = 4,
 	CPT_MAX_ENG_TYPES,
 };
 
drivers/common/cnxk/meson.build +1 -0
index 9db77a9702..3303ad9354 100644
@@ -65,6 +65,7 @@ sources = files(
         'roc_npc_utils.c',
         'roc_platform.c',
         'roc_platform_base_symbols.c',
+        'roc_re_ml_tables.c',
         'roc_se.c',
         'roc_sso.c',
         'roc_sso_debug.c',
drivers/common/cnxk/roc_cpt.c +4 -0
index 21d5e7f2ba..686c9eae7e 100644
@@ -632,6 +632,9 @@ 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_model_is_cn20k())
+		eng_grpmsk |= (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_RE]);
+
 	if (roc_errata_cpt_has_ctx_fetch_issue()) {
 		ctx_ilen_valid = true;
 		/* Inbound SA size is max context size */
@@ -1097,6 +1100,7 @@ roc_cpt_eng_grp_add(struct roc_cpt *roc_cpt, enum cpt_eng_type eng_type)
 	case CPT_ENG_TYPE_AE:
 	case CPT_ENG_TYPE_SE:
 	case CPT_ENG_TYPE_IE:
+	case CPT_ENG_TYPE_RE:
 		break;
 	default:
 		ret = -EINVAL;
drivers/common/cnxk/roc_platform.h +5 -0
index e22a50d47a..19f1d6005b 100644
@@ -41,6 +41,7 @@
 	".arch_extension lse\n"
 #endif
 
+#define PLT_ATOMIC		 RTE_ATOMIC
 #define PLT_ASSERT		 RTE_ASSERT
 #define PLT_VERIFY		 RTE_VERIFY
 #define PLT_MEMZONE_NAMESIZE	 RTE_MEMZONE_NAMESIZE
@@ -217,6 +218,10 @@ plt_thread_is_valid(plt_thread_t thr)
 #define plt_memory_order_release  rte_memory_order_release
 #define plt_memory_order_acquire  rte_memory_order_acquire
 #define plt_memory_order_relaxed  rte_memory_order_relaxed
+#define plt_memory_order_seq_cst  rte_memory_order_seq_cst
+
+#define plt_atomic_fetch_add_explicit rte_atomic_fetch_add_explicit
+#define plt_atomic_fetch_sub_explicit rte_atomic_fetch_sub_explicit
 
 #define plt_bit_relaxed_get32   rte_bit_relaxed_get32
 #define plt_bit_relaxed_set32   rte_bit_relaxed_set32
drivers/common/cnxk/roc_platform_base_symbols.c +2 -0
index cf080b1bdc..75775fbe09 100644
@@ -497,6 +497,8 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_aged_flow_ctx_get)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_defrag_mcam_banks)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_get_key_type)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_flow_mcam_dump)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_re_ml_zeta_get)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_re_ml_zeta_put)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_ree_queues_attach)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_ree_queues_detach)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_ree_msix_offsets_get)
drivers/common/cnxk/roc_re.h new file +31 -0
new file mode 100644
index 0000000000..a8cbda41c0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2026 Marvell.
+ */
+
+#ifndef __ROC_RE_H__
+#define __ROC_RE_H__
+
+/* RE ML opcodes */
+#define ROC_RE_MAJOR_OP_MLKEM        0x1A
+#define ROC_RE_MAJOR_OP_MLDSA        0x1B
+#define ROC_RE_MINOR_OP_MLKEM_KEYGEN 0x00
+#define ROC_RE_MINOR_OP_MLKEM_ENCAP  0x01
+#define ROC_RE_MINOR_OP_MLKEM_DECAP  0x02
+#define ROC_RE_MINOR_OP_MLDSA_KEYGEN 0x00
+#define ROC_RE_MINOR_OP_MLDSA_SIGN   0x01
+#define ROC_RE_MINOR_OP_MLDSA_VERIFY 0x02
+
+/* ML-KEM param2 fields */
+#define ROC_RE_ML_KEM_PARAM2_INMSG_BIT  4
+#define ROC_RE_ML_KEM_PARAM2_INSEED_BIT 5
+
+/* ML-DSA param2 fields */
+#define ROC_RE_ML_DSA_PARAM2_SIGN_BIT   4
+#define ROC_RE_ML_DSA_PARAM2_SEED_BIT   5
+#define ROC_RE_ML_DSA_PARAM2_CTXN_BIT   8
+
+/* ML-DSA minor op fields */
+#define ROC_RE_ML_DSA_MINOR_SIGN_TYPE_BIT 2
+#define ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT  4
+
+#endif /* __ROC_RE_H__ */
drivers/common/cnxk/roc_re_ml_tables.c new file +248 -0

248 lines not on this page · raw message

drivers/common/cnxk/roc_re_ml_tables.h new file +19 -0
new file mode 100644
index 0000000000..0a425f711d
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2026 Marvell.
+ */
+
+#ifndef _ROC_RE_ML_TABLES_H_
+#define _ROC_RE_ML_TABLES_H_
+
+#include "roc_platform.h"
+
+enum roc_re_ml_zeta_idx {
+	ROC_RE_ML_ZETA_IDX_KEM = 0,
+	ROC_RE_ML_ZETA_IDX_DSA,
+	ROC_RE_ML_ZETA_IDX_MAX
+};
+
+int __roc_api roc_re_ml_zeta_get(uint64_t *tbl);
+void __roc_api roc_re_ml_zeta_put(void);
+
+#endif /* _ROC_RE_ML_TABLES_H_ */
drivers/crypto/cnxk/cnxk_ae.h +383 -16

495 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev.c +11 -0
index 5828a502e4..de27c4a580 100644
@@ -28,6 +28,9 @@ cnxk_cpt_default_ff_get(void)
 	if (roc_model_is_cn10ka_b0() || roc_model_is_cn10kb() || roc_model_is_cn20k())
 		ff |= RTE_CRYPTODEV_FF_SECURITY_RX_INJECT;
 
+	if (roc_model_is_cn20k())
+		ff |= RTE_CRYPTODEV_FF_MLDSA_SIGN_PREHASH;
+
 	return ff;
 }
 
@@ -56,6 +59,14 @@ cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt)
 		return -ENOTSUP;
 	}
 
+	if (roc_model_is_cn20k()) {
+		ret = roc_cpt_eng_grp_add(roc_cpt, CPT_ENG_TYPE_RE);
+		if (ret < 0) {
+			plt_err("Could not add CPT RE engines");
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
drivers/crypto/cnxk/cnxk_cryptodev.h +3 -1
index f88162ad3c..bdc5752905 100644
@@ -10,8 +10,9 @@
 
 #include "roc_ae.h"
 #include "roc_cpt.h"
+#include "roc_re_ml_tables.h"
 
-#define CNXK_CPT_MAX_CAPS		 60
+#define CNXK_CPT_MAX_CAPS		 62
 #define CNXK_SEC_IPSEC_CRYPTO_MAX_CAPS	 16
 #define CNXK_SEC_TLS_1_3_CRYPTO_MAX_CAPS 3
 #define CNXK_SEC_TLS_1_2_CRYPTO_MAX_CAPS 7
@@ -33,6 +34,7 @@ struct cnxk_cpt_vf {
 		sec_dtls_1_2_crypto_caps[CNXK_SEC_TLS_1_2_CRYPTO_MAX_CAPS];
 	struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
 	uint64_t cnxk_fpm_iova[ROC_AE_EC_ID_PMAX];
+	uint64_t cnxk_ml_iova[ROC_RE_ML_ZETA_IDX_MAX];
 	struct roc_ae_ec_group *ec_grp[ROC_AE_EC_ID_PMAX];
 	uint16_t max_qps_limit;
 	uint16_t rx_inject_qp;
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +61 -1

77 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.c +41 -4

93 lines not on this page · raw message

Signature · 1 line
2.37.1
#1 lore raw

drivers/common/cnxk/roc_re_ml_tables.c line 15

Quoted 5 lines · On Fri, 29 May 2026 14:43:26 +0530 Gowrishankar Muthukrishnan…
drivers/common/cnxk/roc_re_ml_tables.c new file +5 -0
+/* ML table address and length */
+struct re_ml_entry {
+	const uint8_t *data;
+	int len;
+};

Better to use unsigned for size like size_t

drivers/common/cnxk/roc_re_ml_tables.c line 22

Quoted 7 lines
drivers/common/cnxk/roc_re_ml_tables.c new file +7 -0
+
+struct re_ml_tbl {
+	PLT_ATOMIC(uint64_t) refcount;
+	uint8_t ml_tbl[];
+};
+
+const uint8_t re_mlkem_zeta_tbl[RE_MLKEM_ZETA_LEN] = {

Tables should be local to file so static?

#2 lore raw
In reply to Gowrishankar Muthukrishnan

drivers/common/cnxk/roc_re_ml_tables.c line 202

Quoted 5 lines · On Fri, 29 May 2026 14:43:26 +0530 Gowrishankar Muthukrishnan…
drivers/common/cnxk/roc_re_ml_tables.c new file +5 -0
+
+int
+roc_re_ml_zeta_get(uint64_t *tbl)
+{
+	int len = (RE_MLKEM_ZETA_LEN + RE_MLDSA_ZETA_LEN);

Unneeded paraens.

Quoted 7 lines
drivers/common/cnxk/roc_re_ml_tables.c new file +7 -0
+	const char name[] = RE_ML_TBL_NAME;
+	const struct plt_memzone *mz;
+	struct re_ml_tbl *ml;
+	uint8_t *data;
+
+	if (tbl == NULL)
+		return -EINVAL;

drivers/common/cnxk/roc_re_ml_tables.c line 219

Quoted 10 lines
drivers/common/cnxk/roc_re_ml_tables.c new file +10 -0
+
+	mz = plt_memzone_lookup(name);
+	if (mz == NULL) {
+		/* Create memzone first time */
+		mz = plt_memzone_reserve_cache_align(name, sizeof(struct re_ml_tbl) + len);
+		if (mz == NULL)
+			return -ENOMEM;
+	}
+
+	ml = (struct re_ml_tbl *)mz->addr;

mz->addr is void * so cast here is unnecessary.

Quoted 15 lines
drivers/common/cnxk/roc_re_ml_tables.c new file +13 -0
+	if (plt_atomic_fetch_add_explicit(&ml->refcount, 1, plt_memory_order_seq_cst) != 0)
+		return 0;
 
 
+
+	data = PLT_PTR_ADD(mz->addr, sizeof(uint64_t));
+	memcpy(data, re_ml_zeta_tbl[0].data, re_ml_zeta_tbl[0].len);
+	tbl[0] = plt_cpu_to_be_64((uintptr_t)data);
+
+	data = PLT_PTR_ADD(data, re_ml_zeta_tbl[0].len);
+	memcpy(data, re_ml_zeta_tbl[1].data, re_ml_zeta_tbl[1].len);
+	tbl[1] = plt_cpu_to_be_64((uintptr_t)data);
+
+	return 0;
+}
#3 lore raw

PATCH v2 1/1 crypto/cnxk: add ML crypto support

In reply to Gowrishankar Muthukrishnan

Add ML-KEM and ML-DSA support.

---
v2:
- Addressed comments from v1.

---
 doc/guides/cryptodevs/features/cn20k.ini      |   3 +
 doc/guides/cryptodevs/features/default.ini    |   1 +
 doc/guides/rel_notes/release_26_07.rst        |   3 +
 drivers/common/cnxk/hw/cpt.h                  |   1 +
 drivers/common/cnxk/meson.build               |   1 +
 drivers/common/cnxk/roc_cpt.c                 |   4 +
 drivers/common/cnxk/roc_platform.h            |   5 +
 .../common/cnxk/roc_platform_base_symbols.c   |   2 +
 drivers/common/cnxk/roc_re.h                  |  31 ++
 drivers/common/cnxk/roc_re_ml_tables.c        | 248 +++++++++++
 drivers/common/cnxk/roc_re_ml_tables.h        |  19 +
 drivers/crypto/cnxk/cnxk_ae.h                 | 399 +++++++++++++++++-
 drivers/crypto/cnxk/cnxk_cryptodev.c          |  11 +
 drivers/crypto/cnxk/cnxk_cryptodev.h          |   4 +-
 .../crypto/cnxk/cnxk_cryptodev_capabilities.c |  62 ++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c      |  45 +-
 16 files changed, 817 insertions(+), 22 deletions(-)
 create mode 100644 drivers/common/cnxk/roc_re.h
 create mode 100644 drivers/common/cnxk/roc_re_ml_tables.c
 create mode 100644 drivers/common/cnxk/roc_re_ml_tables.h
doc/guides/cryptodevs/features/cn20k.ini +3 -0
index d4c52082c6..8180128744 100644
@@ -21,6 +21,7 @@ Asymmetric sessionless = Y
 Sym raw data path API  = Y
 Inner checksum         = Y
 Rx inject              = Y
+ML-DSA sign prehash    = Y
 
 ;
 ; Supported crypto algorithms of 'cn20k' crypto driver.
@@ -110,6 +111,8 @@ ECDSA                   = Y
 ECPM                    = Y
 SM2                     = Y
 EdDSA                   = Y
+ML-DSA                  = Y
+ML-KEM                  = Y
 
 ;
 ; Supported Operating systems of the 'cn20k' crypto driver.
doc/guides/cryptodevs/features/default.ini +1 -0
index d8026c3750..be4ee777fb 100644
@@ -35,6 +35,7 @@ Cipher multiple data units =
 Cipher wrapped key     =
 Inner checksum         =
 Rx inject              =
+ML-DSA sign prehash    =
 
 ;
 ; Supported crypto algorithms of a default crypto driver.
doc/guides/rel_notes/release_26_07.rst +3 -0
index 5d7aa8d1bf..13ffc487b1 100644
@@ -155,6 +155,9 @@ New Features
   Added AGENTS.md file for AI review
   and supporting scripts to review patches and documentation.
 
+* **Updated Marvell cnxk crypto driver.**
+
+  * Added support for ML-KEM and ML-DSA on CN20K platform.
 
 Removed Items
 -------------
drivers/common/cnxk/hw/cpt.h +1 -0
index eb795f61ac..12aeb4d054 100644
@@ -58,6 +58,7 @@ enum cpt_eng_type {
 	CPT_ENG_TYPE_AE = 1,
 	CPT_ENG_TYPE_SE = 2,
 	CPT_ENG_TYPE_IE = 3,
+	CPT_ENG_TYPE_RE = 4,
 	CPT_MAX_ENG_TYPES,
 };
 
drivers/common/cnxk/meson.build +1 -0
index 9db77a9702..3303ad9354 100644
@@ -65,6 +65,7 @@ sources = files(
         'roc_npc_utils.c',
         'roc_platform.c',
         'roc_platform_base_symbols.c',
+        'roc_re_ml_tables.c',
         'roc_se.c',
         'roc_sso.c',
         'roc_sso_debug.c',
drivers/common/cnxk/roc_cpt.c +4 -0
index 21d5e7f2ba..686c9eae7e 100644
@@ -632,6 +632,9 @@ 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_model_is_cn20k())
+		eng_grpmsk |= (1 << roc_cpt->eng_grp[CPT_ENG_TYPE_RE]);
+
 	if (roc_errata_cpt_has_ctx_fetch_issue()) {
 		ctx_ilen_valid = true;
 		/* Inbound SA size is max context size */
@@ -1097,6 +1100,7 @@ roc_cpt_eng_grp_add(struct roc_cpt *roc_cpt, enum cpt_eng_type eng_type)
 	case CPT_ENG_TYPE_AE:
 	case CPT_ENG_TYPE_SE:
 	case CPT_ENG_TYPE_IE:
+	case CPT_ENG_TYPE_RE:
 		break;
 	default:
 		ret = -EINVAL;
drivers/common/cnxk/roc_platform.h +5 -0
index 73cc12e567..ac4f76473f 100644
@@ -41,6 +41,7 @@
 	".arch_extension lse\n"
 #endif
 
+#define PLT_ATOMIC		 RTE_ATOMIC
 #define PLT_ASSERT		 RTE_ASSERT
 #define PLT_VERIFY		 RTE_VERIFY
 #define PLT_MEMZONE_NAMESIZE	 RTE_MEMZONE_NAMESIZE
@@ -218,6 +219,10 @@ plt_thread_is_valid(plt_thread_t thr)
 #define plt_memory_order_release  rte_memory_order_release
 #define plt_memory_order_acquire  rte_memory_order_acquire
 #define plt_memory_order_relaxed  rte_memory_order_relaxed
+#define plt_memory_order_seq_cst  rte_memory_order_seq_cst
+
+#define plt_atomic_fetch_add_explicit rte_atomic_fetch_add_explicit
+#define plt_atomic_fetch_sub_explicit rte_atomic_fetch_sub_explicit
 
 #define plt_bit_relaxed_get32   rte_bit_relaxed_get32
 #define plt_bit_relaxed_set32   rte_bit_relaxed_set32
drivers/common/cnxk/roc_platform_base_symbols.c +2 -0
index ed34d4b05b..ece28d3885 100644
@@ -500,6 +500,8 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_aged_flow_ctx_get)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_defrag_mcam_banks)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_get_key_type)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_npc_flow_mcam_dump)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_re_ml_zeta_get)
+RTE_EXPORT_INTERNAL_SYMBOL(roc_re_ml_zeta_put)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_ree_queues_attach)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_ree_queues_detach)
 RTE_EXPORT_INTERNAL_SYMBOL(roc_ree_msix_offsets_get)
drivers/common/cnxk/roc_re.h new file +31 -0
new file mode 100644
index 0000000000..a8cbda41c0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2026 Marvell.
+ */
+
+#ifndef __ROC_RE_H__
+#define __ROC_RE_H__
+
+/* RE ML opcodes */
+#define ROC_RE_MAJOR_OP_MLKEM        0x1A
+#define ROC_RE_MAJOR_OP_MLDSA        0x1B
+#define ROC_RE_MINOR_OP_MLKEM_KEYGEN 0x00
+#define ROC_RE_MINOR_OP_MLKEM_ENCAP  0x01
+#define ROC_RE_MINOR_OP_MLKEM_DECAP  0x02
+#define ROC_RE_MINOR_OP_MLDSA_KEYGEN 0x00
+#define ROC_RE_MINOR_OP_MLDSA_SIGN   0x01
+#define ROC_RE_MINOR_OP_MLDSA_VERIFY 0x02
+
+/* ML-KEM param2 fields */
+#define ROC_RE_ML_KEM_PARAM2_INMSG_BIT  4
+#define ROC_RE_ML_KEM_PARAM2_INSEED_BIT 5
+
+/* ML-DSA param2 fields */
+#define ROC_RE_ML_DSA_PARAM2_SIGN_BIT   4
+#define ROC_RE_ML_DSA_PARAM2_SEED_BIT   5
+#define ROC_RE_ML_DSA_PARAM2_CTXN_BIT   8
+
+/* ML-DSA minor op fields */
+#define ROC_RE_ML_DSA_MINOR_SIGN_TYPE_BIT 2
+#define ROC_RE_ML_DSA_MINOR_MSG_TYPE_BIT  4
+
+#endif /* __ROC_RE_H__ */
drivers/common/cnxk/roc_re_ml_tables.c new file +248 -0

248 lines not on this page · raw message

drivers/common/cnxk/roc_re_ml_tables.h new file +19 -0
new file mode 100644
index 0000000000..0a425f711d
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2026 Marvell.
+ */
+
+#ifndef _ROC_RE_ML_TABLES_H_
+#define _ROC_RE_ML_TABLES_H_
+
+#include "roc_platform.h"
+
+enum roc_re_ml_zeta_idx {
+	ROC_RE_ML_ZETA_IDX_KEM = 0,
+	ROC_RE_ML_ZETA_IDX_DSA,
+	ROC_RE_ML_ZETA_IDX_MAX
+};
+
+int __roc_api roc_re_ml_zeta_get(uint64_t *tbl);
+void __roc_api roc_re_ml_zeta_put(void);
+
+#endif /* _ROC_RE_ML_TABLES_H_ */
drivers/crypto/cnxk/cnxk_ae.h +383 -16

495 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev.c +11 -0
index 5828a502e4..de27c4a580 100644
@@ -28,6 +28,9 @@ cnxk_cpt_default_ff_get(void)
 	if (roc_model_is_cn10ka_b0() || roc_model_is_cn10kb() || roc_model_is_cn20k())
 		ff |= RTE_CRYPTODEV_FF_SECURITY_RX_INJECT;
 
+	if (roc_model_is_cn20k())
+		ff |= RTE_CRYPTODEV_FF_MLDSA_SIGN_PREHASH;
+
 	return ff;
 }
 
@@ -56,6 +59,14 @@ cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt)
 		return -ENOTSUP;
 	}
 
+	if (roc_model_is_cn20k()) {
+		ret = roc_cpt_eng_grp_add(roc_cpt, CPT_ENG_TYPE_RE);
+		if (ret < 0) {
+			plt_err("Could not add CPT RE engines");
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
drivers/crypto/cnxk/cnxk_cryptodev.h +3 -1
index f88162ad3c..bdc5752905 100644
@@ -10,8 +10,9 @@
 
 #include "roc_ae.h"
 #include "roc_cpt.h"
+#include "roc_re_ml_tables.h"
 
-#define CNXK_CPT_MAX_CAPS		 60
+#define CNXK_CPT_MAX_CAPS		 62
 #define CNXK_SEC_IPSEC_CRYPTO_MAX_CAPS	 16
 #define CNXK_SEC_TLS_1_3_CRYPTO_MAX_CAPS 3
 #define CNXK_SEC_TLS_1_2_CRYPTO_MAX_CAPS 7
@@ -33,6 +34,7 @@ struct cnxk_cpt_vf {
 		sec_dtls_1_2_crypto_caps[CNXK_SEC_TLS_1_2_CRYPTO_MAX_CAPS];
 	struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
 	uint64_t cnxk_fpm_iova[ROC_AE_EC_ID_PMAX];
+	uint64_t cnxk_ml_iova[ROC_RE_ML_ZETA_IDX_MAX];
 	struct roc_ae_ec_group *ec_grp[ROC_AE_EC_ID_PMAX];
 	uint16_t max_qps_limit;
 	uint16_t rx_inject_qp;
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +61 -1

77 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.c +41 -4

93 lines not on this page · raw message

Signature · 1 line
2.37.1
Acked-by on v2 1/1 Applied
#4 lore raw
Quoted 21 lines

Subject: [v2] crypto/cnxk: add ML crypto support

Add ML-KEM and ML-DSA support.

---
v2:
- Addressed comments from v1.

---
 doc/guides/cryptodevs/features/cn20k.ini      |   3 +
 doc/guides/cryptodevs/features/default.ini    |   1 +
 doc/guides/rel_notes/release_26_07.rst        |   3 +
 drivers/common/cnxk/hw/cpt.h                  |   1 +
 drivers/common/cnxk/meson.build               |   1 +
 drivers/common/cnxk/roc_cpt.c                 |   4 +
 drivers/common/cnxk/roc_platform.h            |   5 +
 .../common/cnxk/roc_platform_base_symbols.c   |   2 +
 drivers/common/cnxk/roc_re.h                  |  31 ++
 drivers/common/cnxk/roc_re_ml_tables.c        | 248 +++++++++++
 drivers/common/cnxk/roc_re_ml_tables.h        |  19 +
 drivers/crypto/cnxk/cnxk_ae.h                 | 399 +++++++++++++++++-
Quoted 8 lines
 drivers/crypto/cnxk/cnxk_cryptodev.c          |  11 +
 drivers/crypto/cnxk/cnxk_cryptodev.h          |   4 +-
 .../crypto/cnxk/cnxk_cryptodev_capabilities.c |  62 ++-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c      |  45 +-
 16 files changed, 817 insertions(+), 22 deletions(-)
 create mode 100644 drivers/common/cnxk/roc_re.h
 create mode 100644 drivers/common/cnxk/roc_re_ml_tables.c
 create mode 100644 drivers/common/cnxk/roc_re_ml_tables.h

Applied to dpdk-next-crypto