DPDK patches and discussions
 help / color / mirror / Atom feed
* [v1] crypto/cnxk: add support for fixed point multiplication
@ 2022-09-27  7:59 Gowrishankar Muthukrishnan
  2022-10-07 11:47 ` Anoob Joseph
  0 siblings, 1 reply; 3+ messages in thread
From: Gowrishankar Muthukrishnan @ 2022-09-27  7:59 UTC (permalink / raw)
  To: dev
  Cc: Anoob Joseph, Ankur Dwivedi, Tejasree Kondoj, Akhil Goyal,
	jerinj, Kiran Kumar K, Gowrishankar Muthukrishnan

Add fixed point multiplication for EC curve in CNXK.

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/common/cnxk/roc_ae.h                  |  1 +
 drivers/crypto/cnxk/cnxk_ae.h                 | 69 +++++++++++++++++++
 .../crypto/cnxk/cnxk_cryptodev_capabilities.c | 10 +++
 3 files changed, 80 insertions(+)

diff --git a/drivers/common/cnxk/roc_ae.h b/drivers/common/cnxk/roc_ae.h
index 9c637d67ef..c972878eff 100644
--- a/drivers/common/cnxk/roc_ae.h
+++ b/drivers/common/cnxk/roc_ae.h
@@ -18,6 +18,7 @@
 #define ROC_AE_MINOR_OP_ECDSA_SIGN   0x01
 #define ROC_AE_MINOR_OP_ECDSA_VERIFY 0x02
 #define ROC_AE_MINOR_OP_ECC_UMP	     0x03
+#define ROC_AE_MINOR_OP_ECC_FPM	     0x04
 
 /**
  * Enumeration roc_ae_ec_id
diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index 0562f72270..4a7ce0bf40 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -181,6 +181,7 @@ cnxk_ae_fill_session_parameters(struct cnxk_ae_sess *sess,
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
 	case RTE_CRYPTO_ASYM_XFORM_ECPM:
+	case RTE_CRYPTO_ASYM_XFORM_ECFPM:
 		ret = cnxk_ae_fill_ec_params(sess, xform);
 		break;
 	default:
@@ -207,6 +208,7 @@ cnxk_ae_free_session_parameters(struct cnxk_ae_sess *sess)
 	case RTE_CRYPTO_ASYM_XFORM_ECDSA:
 		/* Fall through */
 	case RTE_CRYPTO_ASYM_XFORM_ECPM:
+	case RTE_CRYPTO_ASYM_XFORM_ECFPM:
 		break;
 	default:
 		break;
@@ -600,6 +602,64 @@ cnxk_ae_enqueue_ecdsa_op(struct rte_crypto_op *op,
 	return 0;
 }
 
+static __rte_always_inline int
+cnxk_ae_ecfpm_prep(struct rte_crypto_ecpm_op_param *ecpm,
+		   struct roc_ae_buf_ptr *meta_buf, uint64_t *fpm_iova,
+		   struct roc_ae_ec_group *ec_grp, uint8_t curveid,
+		   struct cpt_inst_s *inst)
+{
+	uint16_t scalar_align, p_align;
+	uint16_t dlen, prime_len;
+	uint64_t fpm_table_iova;
+	union cpt_inst_w4 w4;
+	uint8_t *dptr;
+
+	prime_len = ec_grp->prime.length;
+	fpm_table_iova = (uint64_t)fpm_iova[curveid];
+
+	/* Input buffer */
+	dptr = meta_buf->vaddr;
+	inst->dptr = (uintptr_t)dptr;
+
+	p_align = RTE_ALIGN_CEIL(prime_len, 8);
+	scalar_align = RTE_ALIGN_CEIL(ecpm->scalar.length, 8);
+
+	/*
+	 * Set dlen = sum(ROUNDUP8(input point(x and y coordinates), prime,
+	 * scalar length),
+	 * Please note point length is equivalent to prime of the curve
+	 */
+	dlen = sizeof(fpm_table_iova) + 3 * p_align + scalar_align;
+
+	memset(dptr, 0, dlen);
+
+	*(uint64_t *)dptr = fpm_table_iova;
+	dptr += sizeof(fpm_table_iova);
+
+	/* Copy scalar, prime */
+	memcpy(dptr, ecpm->scalar.data, ecpm->scalar.length);
+	dptr += scalar_align;
+	memcpy(dptr, ec_grp->prime.data, ec_grp->prime.length);
+	dptr += p_align;
+	memcpy(dptr, ec_grp->consta.data, ec_grp->consta.length);
+	dptr += p_align;
+	memcpy(dptr, ec_grp->constb.data, ec_grp->constb.length);
+	dptr += p_align;
+
+	/* Setup opcodes */
+	w4.s.opcode_major = ROC_AE_MAJOR_OP_ECC;
+	w4.s.opcode_minor = ROC_AE_MINOR_OP_ECC_FPM;
+
+	w4.s.param1 = curveid | (1 << 8);
+	w4.s.param2 = ecpm->scalar.length;
+	w4.s.dlen = dlen;
+
+	inst->w4.u64 = w4.u64;
+	inst->rptr = (uintptr_t)dptr;
+
+	return 0;
+}
+
 static __rte_always_inline int
 cnxk_ae_ecpm_prep(struct rte_crypto_ecpm_op_param *ecpm,
 		  struct roc_ae_buf_ptr *meta_buf,
@@ -811,6 +871,14 @@ cnxk_ae_enqueue(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		if (unlikely(ret))
 			goto req_fail;
 		break;
+	case RTE_CRYPTO_ASYM_XFORM_ECFPM:
+		ret = cnxk_ae_ecfpm_prep(&asym_op->ecpm, &meta_buf,
+					 sess->cnxk_fpm_iova,
+					 sess->ec_grp[sess->ec_ctx.curveid],
+					 sess->ec_ctx.curveid, inst);
+		if (unlikely(ret))
+			goto req_fail;
+		break;
 	default:
 		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 		ret = -EINVAL;
@@ -845,6 +913,7 @@ cnxk_ae_post_process(struct rte_crypto_op *cop, struct cnxk_ae_sess *sess,
 					 sess->ec_grp);
 		break;
 	case RTE_CRYPTO_ASYM_XFORM_ECPM:
+	case RTE_CRYPTO_ASYM_XFORM_ECFPM:
 		cnxk_ae_dequeue_ecpm_op(&op->ecpm, rptr, &sess->ec_ctx,
 					sess->ec_grp);
 		break;
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
index 705d67e91f..e32f476dd9 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
@@ -82,6 +82,16 @@ static const struct rte_cryptodev_capabilities caps_mul[] = {
 			},
 		}
 	},
+	{	/* ECFPM */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xform_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_ECFPM,
+				.op_types = 0
+				}
+			},
+		}
+	},
 };
 
 static const struct rte_cryptodev_capabilities caps_sha1_sha2[] = {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [v1] crypto/cnxk: add support for fixed point multiplication
  2022-09-27  7:59 [v1] crypto/cnxk: add support for fixed point multiplication Gowrishankar Muthukrishnan
@ 2022-10-07 11:47 ` Anoob Joseph
  2022-10-07 12:52   ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Anoob Joseph @ 2022-10-07 11:47 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Ankur Dwivedi, Tejasree Kondoj, Akhil Goyal,
	Jerin Jacob Kollanukkaran, Kiran Kumar Kokkilagadda,
	Gowrishankar Muthukrishnan

> 
> Add fixed point multiplication for EC curve in CNXK.
> 
> Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Acked-by: Anoob Joseph <anoobj@marvell.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [v1] crypto/cnxk: add support for fixed point multiplication
  2022-10-07 11:47 ` Anoob Joseph
@ 2022-10-07 12:52   ` Akhil Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2022-10-07 12:52 UTC (permalink / raw)
  To: Anoob Joseph, Gowrishankar Muthukrishnan, dev
  Cc: Ankur Dwivedi, Tejasree Kondoj, Jerin Jacob Kollanukkaran,
	Kiran Kumar Kokkilagadda, Gowrishankar Muthukrishnan

> Subject: RE: [v1] crypto/cnxk: add support for fixed point multiplication
Add support for -> support

> 
> >
> > Add fixed point multiplication for EC curve in CNXK.
> >
> > Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> 
> Acked-by: Anoob Joseph <anoobj@marvell.com>
> 
Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-07 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27  7:59 [v1] crypto/cnxk: add support for fixed point multiplication Gowrishankar Muthukrishnan
2022-10-07 11:47 ` Anoob Joseph
2022-10-07 12:52   ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).