From 40726a9ad54b1fba1bcb5578e23b96214dd7719a Mon Sep 17 00:00:00 2001 From: Sunila Sahu Date: Wed, 15 Jan 2020 18:26:33 +0530 Subject: [PATCH] crypto/octeontx2: support ECPM Add support asymmetric operation EC Point MUltiplication, in crypto_octeontx2 PMD. Signed-off-by: Anoob Joseph Signed-off-by: Balakrishna Bhamidipati Signed-off-by: Sunila Sahu --- doc/guides/cryptodevs/features/octeontx2.ini | 1 + .../octeontx2/otx2_cryptodev_capabilities.c | 10 +++++++++ drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 22 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/doc/guides/cryptodevs/features/octeontx2.ini b/doc/guides/cryptodevs/features/octeontx2.ini index dd6369bd85..4693458865 100644 --- a/doc/guides/cryptodevs/features/octeontx2.ini +++ b/doc/guides/cryptodevs/features/octeontx2.ini @@ -73,3 +73,4 @@ Modular Exponentiation = Y Modular Inversion = Diffie-hellman = ECDSA = Y +ECPM = Y diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c b/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c index f2079e2160..83f885cb70 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_capabilities.c @@ -639,6 +639,16 @@ rte_cryptodev_capabilities otx2_cpt_capabilities[] = { }, } }, + { /* ECPM */ + .op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + {.asym = { + .xform_capa = { + .xform_type = RTE_CRYPTO_ASYM_XFORM_ECPM, + .op_types = 0 + } + }, + } + }, /* End of asymmetric capabilities */ RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() }; diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c index 17c755dc93..ec0e58d127 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c @@ -447,6 +447,12 @@ otx2_cpt_enqueue_asym(struct otx2_cpt_qp *qp, if (unlikely(ret)) goto req_fail; break; + case RTE_CRYPTO_ASYM_XFORM_ECPM: + ret = cpt_ecpm_prep(&asym_op->ecpm, ¶ms, + sess->ec_ctx.curveid); + if (unlikely(ret)) + goto req_fail; + break; default: op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; ret = -EINVAL; @@ -665,6 +671,19 @@ otx2_cpt_asym_dequeue_ecdsa_op(struct rte_crypto_ecdsa_op_param *ecdsa, ecdsa->s.length = prime_len; } +static __rte_always_inline void +otx2_cpt_asym_dequeue_ecpm_op(struct rte_crypto_ecpm_op_param *ecpm, + struct cpt_request_info *req, + struct cpt_asym_ec_ctx *ec) +{ + int prime_len = ec_grp[ec->curveid].prime.length; + + memcpy(ecpm->r.x.data, req->rptr, prime_len); + memcpy(ecpm->r.y.data, req->rptr + ROUNDUP8(prime_len), prime_len); + ecpm->r.x.length = prime_len; + ecpm->r.y.length = prime_len; +} + static void otx2_cpt_asym_post_process(struct rte_crypto_op *cop, struct cpt_request_info *req) @@ -687,6 +706,9 @@ otx2_cpt_asym_post_process(struct rte_crypto_op *cop, case RTE_CRYPTO_ASYM_XFORM_ECDSA: otx2_cpt_asym_dequeue_ecdsa_op(&op->ecdsa, req, &sess->ec_ctx); break; + case RTE_CRYPTO_ASYM_XFORM_ECPM: + otx2_cpt_asym_dequeue_ecpm_op(&op->ecpm, req, &sess->ec_ctx); + break; default: CPT_LOG_DP_DEBUG("Invalid crypto xform type"); cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS; -- 2.20.1