All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Akhil Goyal <akhil.goyal@nxp.com>,
	Pablo de Lara <pablo.de.lara.guarch@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>
Cc: Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>,
	Narayana Prasad <pathreya@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>,
	Fiona Trahe <fiona.trahe@intel.com>,
	Shally Verma <shallyv@marvell.com>,
	Sunila Sahu <ssahu@marvell.com>, <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 3/6] crypto/octeontx2: add asymmetric session operations
Date: Mon, 9 Sep 2019 20:56:36 +0530	[thread overview]
Message-ID: <1568042799-25982-4-git-send-email-anoobj@marvell.com> (raw)
In-Reply-To: <1568042799-25982-1-git-send-email-anoobj@marvell.com>

From: Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>

This patch adds asymmetric session setup and free routines.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>
Signed-off-by: Sunila Sahu <ssahu@marvell.com>
---
 drivers/crypto/octeontx2/otx2_cryptodev.c     |  3 +-
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 67 +++++++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/octeontx2/otx2_cryptodev.c b/drivers/crypto/octeontx2/otx2_cryptodev.c
index 490e7a1..fbfaf55 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev.c
@@ -103,7 +103,8 @@ otx2_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_IN_PLACE_SGL |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
-			     RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
+			     RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
+			     RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
 
 	return 0;
 
diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c
index 6050b18..9a1d0e7 100644
--- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c
+++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c
@@ -11,6 +11,7 @@
 #include "cpt_pmd_logs.h"
 #include "cpt_pmd_ops_helper.h"
 #include "cpt_ucode.h"
+#include "cpt_ucode_asym.h"
 
 #include "otx2_cryptodev.h"
 #include "otx2_cryptodev_capabilities.h"
@@ -833,6 +834,66 @@ otx2_cpt_sym_session_clear(struct rte_cryptodev *dev,
 	return sym_session_clear(dev->driver_id, sess);
 }
 
+static unsigned int
+otx2_cpt_asym_session_size_get(struct rte_cryptodev *dev __rte_unused)
+{
+	return sizeof(struct cpt_asym_sess_misc);
+}
+
+static int
+otx2_cpt_asym_session_cfg(struct rte_cryptodev *dev,
+			  struct rte_crypto_asym_xform *xform,
+			  struct rte_cryptodev_asym_session *sess,
+			  struct rte_mempool *pool)
+{
+	struct cpt_asym_sess_misc *priv;
+	int ret;
+
+	CPT_PMD_INIT_FUNC_TRACE();
+
+	if (rte_mempool_get(pool, (void **)&priv)) {
+		CPT_LOG_ERR("Could not allocate session_private_data");
+		return -ENOMEM;
+	}
+
+	memset(priv, 0, sizeof(struct cpt_asym_sess_misc));
+
+	ret = cpt_fill_asym_session_parameters(priv, xform);
+	if (ret) {
+		CPT_LOG_ERR("Could not configure session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(pool, priv);
+		return ret;
+	}
+
+	set_asym_session_private_data(sess, dev->driver_id, priv);
+	return 0;
+}
+
+static void
+otx2_cpt_asym_session_clear(struct rte_cryptodev *dev,
+			    struct rte_cryptodev_asym_session *sess)
+{
+	struct cpt_asym_sess_misc *priv;
+	struct rte_mempool *sess_mp;
+
+	CPT_PMD_INIT_FUNC_TRACE();
+
+	priv = get_asym_session_private_data(sess, dev->driver_id);
+	if (priv == NULL)
+		return;
+
+	/* Free resources allocated in session_cfg */
+	cpt_free_asym_session_parameters(priv);
+
+	/* Reset and free object back to pool */
+	memset(priv, 0, otx2_cpt_asym_session_size_get(dev));
+	sess_mp = rte_mempool_from_obj(priv);
+	set_asym_session_private_data(sess, dev->driver_id, NULL);
+	rte_mempool_put(sess_mp, priv);
+}
+
 struct rte_cryptodev_ops otx2_cpt_ops = {
 	/* Device control ops */
 	.dev_configure = otx2_cpt_dev_config,
@@ -851,4 +912,10 @@ struct rte_cryptodev_ops otx2_cpt_ops = {
 	.sym_session_get_size = otx2_cpt_sym_session_get_size,
 	.sym_session_configure = otx2_cpt_sym_session_configure,
 	.sym_session_clear = otx2_cpt_sym_session_clear,
+
+	/* Asymmetric crypto ops */
+	.asym_session_get_size = otx2_cpt_asym_session_size_get,
+	.asym_session_configure = otx2_cpt_asym_session_cfg,
+	.asym_session_clear = otx2_cpt_asym_session_clear,
+
 };
-- 
2.7.4


  parent reply	other threads:[~2019-09-09 15:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 15:26 [dpdk-dev] [PATCH 0/6] add asymmetric support in crypto_octeontx2 PMD Anoob Joseph
2019-09-09 15:26 ` [dpdk-dev] [PATCH 1/6] crypto/octeontx2: add RSA and modexp asym capabilities Anoob Joseph
2019-09-09 15:26 ` [dpdk-dev] [PATCH 2/6] crypto/octeontx2: allocate memory for asymmetric operation Anoob Joseph
2019-09-09 15:26 ` Anoob Joseph [this message]
2019-09-09 15:26 ` [dpdk-dev] [PATCH 4/6] crypto/octeontx2: add asymmetric in enqueue/dequeue ops Anoob Joseph
2019-10-01 14:11   ` Akhil Goyal
2019-10-02 10:55     ` Anoob Joseph
2019-09-09 15:26 ` [dpdk-dev] [PATCH 5/6] app/test: register octeontx2 PMD to asym testsuite Anoob Joseph
2019-10-01 14:13   ` Akhil Goyal
2019-10-02 10:52     ` Anoob Joseph
2019-09-09 15:26 ` [dpdk-dev] [PATCH 6/6] doc: add documentation for OCTEON TX2 crypto asym support Anoob Joseph
2019-09-10  4:13   ` Jerin Jacob Kollanukkaran
2019-09-10  6:12     ` Anoob Joseph
2019-09-10  6:30     ` Thomas Monjalon
2019-09-10 11:33       ` Anoob Joseph
2019-09-10 11:39         ` Akhil Goyal
2019-09-10 12:23           ` Anoob Joseph
2019-09-10 11:41         ` Thomas Monjalon
2019-09-09 16:25 ` [dpdk-dev] [PATCH 0/6] add asymmetric support in crypto_octeontx2 PMD Shally Verma

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=1568042799-25982-4-git-send-email-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=fiona.trahe@intel.com \
    --cc=jerinj@marvell.com \
    --cc=kkotamarthy@marvell.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=pathreya@marvell.com \
    --cc=shallyv@marvell.com \
    --cc=ssahu@marvell.com \
    --cc=thomas@monjalon.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.