Skip to contentSkip to conversation

add asym support in crypto_octeontx PMD

PATCH Superseded Anoob Joseph 3 participants 31 messages Sep 9, 2019 – Oct 16, 2019 Crypto API

lore
Share & tools
lore
#0 lore raw

cover add asym support in crypto_octeontx PMD

This series adds asymmetric crypto support in 'crypto_octeontx' PMD.

Features supported: RSA & modular exponentiation

Kanaka Durga Kotamarthy (4):
crypto/octeontx: add device type mailbox routine crypto/octeontx: add RSA and modexp asym capabilities crypto/octeontx: add asymmetric session operations common/cpt: add helper functions for asymmetric crypto

Sunila Sahu (4):
crypto/octeontx: add asymmetric op enqueue function crypto/octeontx: add asymmetric op dequeue function app/test: register octeontx PMD to asym testsuite
doc: update octeontx asymmetric features

 app/test/test_cryptodev_asym.c                     |  31 ++
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  25 ++
 drivers/common/cpt/cpt_common.h                    |   4 +-
 drivers/common/cpt/cpt_mcode_defines.h             |  29 ++
 drivers/common/cpt/cpt_pmd_ops_helper.c            |  15 +
 drivers/common/cpt/cpt_pmd_ops_helper.h            |   9 +
 drivers/common/cpt/cpt_ucode_asym.h                | 451 +++++++++++++++++++++
 drivers/common/cpt/rte_common_cpt_version.map      |   8 +
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 ++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  44 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.c       |  26 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.h       |  20 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c        | 260 +++++++++++-
 drivers/crypto/octeontx/otx_cryptodev_ops.h        |   2 +
 16 files changed, 944 insertions(+), 38 deletions(-)
 create mode 100644 drivers/common/cpt/cpt_ucode_asym.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/8 crypto/octeontx: add device type mailbox routine

From: Kanaka Durga Kotamarthy <[email protected]>

Add mailbox communication to query symmetric or asymmetric device type

---
 drivers/common/cpt/cpt_common.h                   |  3 ---
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 12 ++++-----
 drivers/crypto/octeontx/otx_cryptodev_mbox.c      | 26 ++++++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_mbox.h      | 20 ++++++++++++++
 drivers/crypto/octeontx/otx_cryptodev_ops.c       | 33 ++++++++++++++++++-----
 drivers/crypto/octeontx/otx_cryptodev_ops.h       |  2 ++
 6 files changed, 78 insertions(+), 18 deletions(-)
drivers/common/cpt/cpt_common.h +0 -3
index 32f23ac..7ef6b29 100644
@@ -19,9 +19,6 @@
 #define CPT_COUNT_THOLD		32
 #define CPT_TIMER_THOLD		0x3F
 
-#define AE_TYPE 1
-#define SE_TYPE 2
-
 #ifndef ROUNDUP4
 #define ROUNDUP4(val)	(((val) + 3) & 0xfffffffc)
 #endif
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +6 -6
index eba6293..ad64bf4 100644
@@ -386,6 +386,12 @@ otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name)
 		return -1;
 	}
 
+	/* Gets device type */
+	if (otx_cpt_get_dev_type(cptvf)) {
+		CPT_LOG_ERR("Failed to get device type");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -653,12 +659,6 @@ otx_cpt_start_device(void *dev)
 		return -EFAULT;
 	}
 
-	if ((cptvf->vftype != SE_TYPE) && (cptvf->vftype != AE_TYPE)) {
-		CPT_LOG_ERR("Fatal error, unexpected vf type %u, for CPT VF "
-			    "device %s", cptvf->vftype, cptvf->dev_name);
-		return -ENOENT;
-	}
-
 	return 0;
 }
 
drivers/crypto/octeontx/otx_cryptodev_mbox.c +24 -2
index daba776..a884ad6 100644
@@ -42,11 +42,19 @@ otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf)
 	case OTX_CPT_MSG_QBIND_GRP:
 		cptvf->pf_acked = true;
 		cptvf->vftype = mbx.data;
-		CPT_LOG_DP_DEBUG("%s: VF %d type %s group %d",
+		CPT_LOG_DP_DEBUG("%s: VF %d group %d",
 				 cptvf->dev_name, cptvf->vfid,
-				 ((mbx.data == SE_TYPE) ? "SE" : "AE"),
 				 cptvf->vfgrp);
 		break;
+	case OTX_CPT_MSG_PF_TYPE:
+		cptvf->pf_acked = true;
+		if (mbx.data == OTX_CPT_PF_TYPE_AE)
+			cptvf->vftype = OTX_CPT_VF_TYPE_AE;
+		else if (mbx.data == OTX_CPT_PF_TYPE_SE)
+			cptvf->vftype = OTX_CPT_VF_TYPE_SE;
+		else
+			cptvf->vftype = OTX_CPT_VF_TYPE_INVALID;
+		break;
 	case OTX_CPT_MBOX_MSG_TYPE_ACK:
 		cptvf->pf_acked = true;
 		break;
@@ -120,6 +128,20 @@ otx_cpt_check_pf_ready(struct cpt_vf *cptvf)
 }
 
 int
+otx_cpt_get_dev_type(struct cpt_vf *cptvf)
+{
+	struct cpt_mbox mbx = {0, 0};
+
+	mbx.msg = OTX_CPT_MSG_PF_TYPE;
+	if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) {
+		CPT_LOG_ERR("%s: PF didn't respond to query msg",
+			    cptvf->dev_name);
+		return 1;
+	}
+	return 0;
+}
+
+int
 otx_cpt_send_vq_size_msg(struct cpt_vf *cptvf)
 {
 	struct cpt_mbox mbx = {0, 0};
drivers/crypto/octeontx/otx_cryptodev_mbox.h +20 -0
index 2d2e0e6..508f3af 100644
@@ -23,6 +23,20 @@ struct cpt_mbox {
 	uint64_t data;
 };
 
+/* CPT PF types */
+enum otx_cpt_pf_type {
+	OTX_CPT_PF_TYPE_INVALID = 0,
+	OTX_CPT_PF_TYPE_AE = 2,
+	OTX_CPT_PF_TYPE_SE,
+};
+
+/* CPT VF types */
+enum otx_cpt_vf_type {
+	OTX_CPT_VF_TYPE_AE = 1,
+	OTX_CPT_VF_TYPE_SE,
+	OTX_CPT_VF_TYPE_INVALID,
+};
+
 /* PF-VF message opcodes */
 enum otx_cpt_mbox_opcode {
 	OTX_CPT_MSG_VF_UP = 1,
@@ -63,6 +77,12 @@ int
 otx_cpt_check_pf_ready(struct cpt_vf *cptvf);
 
 /*
+ * Communicate to PF to get VF type
+ */
+int
+otx_cpt_get_dev_type(struct cpt_vf *cptvf);
+
+/*
  * Communicate VQs size to PF to program CPT(0)_PF_Q(0-15)_CTL of the VF.
  * Must be ACKed.
  */
drivers/crypto/octeontx/otx_cryptodev_ops.c +26 -7
index 9628ffa..88efed3 100644
@@ -16,6 +16,7 @@
 #include "otx_cryptodev.h"
 #include "otx_cryptodev_capabilities.h"
 #include "otx_cryptodev_hw_access.h"
+#include "otx_cryptodev_mbox.h"
 #include "otx_cryptodev_ops.h"
 
 /* Forward declarations */
@@ -630,6 +631,28 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 		goto fail;
 	}
 
+	switch (cptvf->vftype) {
+	case OTX_CPT_VF_TYPE_AE:
+		/* Set asymmetric cpt feature flags */
+		c_dev->feature_flags = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
+				RTE_CRYPTODEV_FF_HW_ACCELERATED;
+		break;
+	case OTX_CPT_VF_TYPE_SE:
+		/* Set symmetric cpt feature flags */
+		c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+				RTE_CRYPTODEV_FF_HW_ACCELERATED |
+				RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+				RTE_CRYPTODEV_FF_IN_PLACE_SGL |
+				RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
+				RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
+		break;
+	default:
+		/* Feature not supported. Abort */
+		CPT_LOG_ERR("VF type not supported by %s", dev_name);
+		ret = -EIO;
+		goto deinit_dev;
+	}
+
 	/* Start off timer for mailbox interrupts */
 	otx_cpt_periodic_alarm_start(cptvf);
 
@@ -638,18 +661,14 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 	c_dev->enqueue_burst = otx_cpt_pkt_enqueue;
 	c_dev->dequeue_burst = otx_cpt_pkt_dequeue;
 
-	c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
-			RTE_CRYPTODEV_FF_HW_ACCELERATED |
-			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
-			RTE_CRYPTODEV_FF_IN_PLACE_SGL |
-			RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
-			RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
-
 	/* Save dev private data */
 	c_dev->data->dev_private = cptvf;
 
 	return 0;
 
+deinit_dev:
+	otx_cpt_deinit_device(cptvf);
+
 fail:
 	if (cptvf) {
 		/* Free private data allocated */
drivers/crypto/octeontx/otx_cryptodev_ops.h +2 -0
index 768ec4f..fac8a3c 100644
@@ -5,6 +5,8 @@
 #ifndef _OTX_CRYPTODEV_OPS_H_
 #define _OTX_CRYPTODEV_OPS_H_
 
+#include <rte_cryptodev.h>
+
 #define OTX_CPT_MIN_HEADROOM_REQ	(24)
 #define OTX_CPT_MIN_TAILROOM_REQ	(8)
 #define CPT_NUM_QS_PER_VF		(1)
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/8 crypto/octeontx: add RSA and modexp asym capabilities

In reply to Anoob Joseph

From: Kanaka Durga Kotamarthy <[email protected]>

Add RSA and modexp capabilities supported by octeontx crypto PMD

---
 .../crypto/octeontx/otx_cryptodev_capabilities.c   | 47 ++++++++++++++++++++--
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |  5 +--
 drivers/crypto/octeontx/otx_cryptodev_ops.c        |  5 ++-
 3 files changed, 49 insertions(+), 8 deletions(-)
drivers/crypto/octeontx/otx_cryptodev_capabilities.c +44 -3
index c6d94c9..8c0358f 100644
@@ -6,7 +6,7 @@
 
 #include "otx_cryptodev_capabilities.h"
 
-static const struct rte_cryptodev_capabilities otx_capabilities[] = {
+static const struct rte_cryptodev_capabilities otx_sym_capabilities[] = {
 	/* Symmetric capabilities */
 	{	/* NULL (AUTH) */
 		.op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
@@ -597,8 +597,49 @@ static const struct rte_cryptodev_capabilities otx_capabilities[] = {
 	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
 
+static const struct rte_cryptodev_capabilities otx_asym_capabilities[] = {
+	/* Asymmetric capabilities */
+	{	/* RSA */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xform_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
+				.op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+					(1 << RTE_CRYPTO_ASYM_OP_VERIFY) |
+					(1 << RTE_CRYPTO_ASYM_OP_ENCRYPT) |
+					(1 << RTE_CRYPTO_ASYM_OP_DECRYPT)),
+				{.modlen = {
+					.min = 17,
+					.max = 1024,
+					.increment = 1
+				}, }
+			}
+		}, }
+	},
+	{	/* MOD_EXP */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xform_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+				.op_types = 0,
+				{.modlen = {
+					.min = 17,
+					.max = 1024,
+					.increment = 1
+				}, }
+			}
+		}, }
+	},
+	/* End of asymmetric capabilities */
+	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
+};
+
 const struct rte_cryptodev_capabilities *
-otx_get_capabilities(void)
+otx_get_capabilities(uint64_t flags)
 {
-	return otx_capabilities;
+	if (flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)
+		return otx_asym_capabilities;
+	else
+		return otx_sym_capabilities;
+
 }
drivers/crypto/octeontx/otx_cryptodev_capabilities.h +2 -3
index fc62821..439b50e 100644
@@ -8,10 +8,9 @@
 #include <rte_cryptodev.h>
 
 /*
- * Get capabilities list for the device
- *
+ * Get capabilities list for the device, based on device type
  */
 const struct rte_cryptodev_capabilities *
-otx_get_capabilities(void);
+otx_get_capabilities(uint64_t flags);
 
 #endif /* _OTX_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/octeontx/otx_cryptodev_ops.c +3 -2
index 88efed3..b59a001 100644
@@ -105,7 +105,7 @@ otx_cpt_dev_info_get(struct rte_cryptodev *dev, struct rte_cryptodev_info *info)
 	if (info != NULL) {
 		info->max_nb_queue_pairs = CPT_NUM_QS_PER_VF;
 		info->feature_flags = dev->feature_flags;
-		info->capabilities = otx_get_capabilities();
+		info->capabilities = otx_get_capabilities(info->feature_flags);
 		info->sym.max_nb_sessions = 0;
 		info->driver_id = otx_cryptodev_driver_id;
 		info->min_mbuf_headroom_req = OTX_CPT_MIN_HEADROOM_REQ;
@@ -635,7 +635,8 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 	case OTX_CPT_VF_TYPE_AE:
 		/* Set asymmetric cpt feature flags */
 		c_dev->feature_flags = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
-				RTE_CRYPTODEV_FF_HW_ACCELERATED;
+				RTE_CRYPTODEV_FF_HW_ACCELERATED |
+				RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
 		break;
 	case OTX_CPT_VF_TYPE_SE:
 		/* Set symmetric cpt feature flags */
Signature · 1 line
2.7.4
#3 lore raw

Re: [dpdk-dev] [PATCH 2/8] crypto/octeontx: add RSA and modexp asym capabilities

Hi Anoob,

drivers/crypto/octeontx/otx_cryptodev_capabilities.c static const struct rte_cryptodev_capabilities otx_capabilities[] = { · line 645

Quoted 11 lines

const struct rte_cryptodev_capabilities *

drivers/crypto/octeontx/otx_cryptodev_capabilities.c +6 -2
-otx_get_capabilities(void)
+otx_get_capabilities(uint64_t flags)
 {
-	return otx_capabilities;
+	if (flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)
+		return otx_asym_capabilities;
+	else
+		return otx_sym_capabilities;
+
 }

I believe this will give Asym capabilities always. As the feature flag RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO will always be set, as the flags are set in init.

It will never go in else.

Quoted 47 lines
drivers/crypto/octeontx/otx_cryptodev_capabilities.h +2 -3
index fc62821..439b50e 100644
@@ -8,10 +8,9 @@
 #include <rte_cryptodev.h>
 
 /*
- * Get capabilities list for the device
- *
+ * Get capabilities list for the device, based on device type
  */
 const struct rte_cryptodev_capabilities *
-otx_get_capabilities(void);
+otx_get_capabilities(uint64_t flags);
 
 #endif /* _OTX_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/octeontx/otx_cryptodev_ops.c +1 -1
index 88efed3..b59a001 100644
@@ -105,7 +105,7 @@ otx_cpt_dev_info_get(struct rte_cryptodev *dev, struct
 rte_cryptodev_info *info)
 	if (info != NULL) {
 		info->max_nb_queue_pairs = CPT_NUM_QS_PER_VF;
 		info->feature_flags = dev->feature_flags;
-		info->capabilities = otx_get_capabilities();
+		info->capabilities = otx_get_capabilities(info->feature_flags);
 		info->sym.max_nb_sessions = 0;
 		info->driver_id = otx_cryptodev_driver_id;

info->min_mbuf_headroom_req =
OTX_CPT_MIN_HEADROOM_REQ;

drivers/crypto/octeontx/otx_cryptodev_ops.c +0 -0
@@ -635,7 +635,8 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 	case OTX_CPT_VF_TYPE_AE:
 		/* Set asymmetric cpt feature flags */
 		c_dev->feature_flags =

RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |

drivers/crypto/octeontx/otx_cryptodev_ops.c +2 -2
-				RTE_CRYPTODEV_FF_HW_ACCELERATED;
+				RTE_CRYPTODEV_FF_HW_ACCELERATED |
+				RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
 		break;
 	case OTX_CPT_VF_TYPE_SE:
 		/* Set symmetric cpt feature flags */
--

2.7.4

#4 lore raw

Re: [dpdk-dev] [PATCH 2/8] crypto/octeontx: add RSA and modexp asym capabilities

Hi Akhil,

Please see inline.

Thanks,
Anoob

Quoted 30 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, October 1, 2019 6:08 PM
To: Anoob Joseph <[email protected]>; Pablo de Lara <[email protected]>
Cc: Kanaka Durga Kotamarthy <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Shally Verma <[email protected]>; Sunila Sahu <[email protected]>; [email protected]
Subject: RE: [PATCH 2/8] crypto/octeontx: add RSA and modexp asym capabilities

Hi Anoob,

drivers/crypto/octeontx/otx_cryptodev_capabilities.c static const struct rte_cryptodev_capabilities otx_capabilities[] = { · line 645

Quoted 11 lines

const struct rte_cryptodev_capabilities *

drivers/crypto/octeontx/otx_cryptodev_capabilities.c +6 -2
-otx_get_capabilities(void)
+otx_get_capabilities(uint64_t flags)
 {
-	return otx_capabilities;
+	if (flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)
+		return otx_asym_capabilities;
+	else
+		return otx_sym_capabilities;
+
 }

I believe this will give Asym capabilities always. As the feature flag RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO will always be set, as the flags are set in init.

Quoted 1 line

It will never go in else.

[Anoob] The flags is set based on the type of underlying device. The crypto module on OCTEONTX exposes two kinds of VFs. One which does only symmetric and one which does only asymmetric. Both are never supported together for a VF, and hence the if...else.

From the first patch, crypto/octeontx: add device type mailbox routine

	switch (cptvf->vftype) {
	case OTX_CPT_VF_TYPE_AE:
		/* Set asymmetric cpt feature flags */
		c_dev->feature_flags = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
				RTE_CRYPTODEV_FF_HW_ACCELERATED;
		break;
	case OTX_CPT_VF_TYPE_SE:
		/* Set symmetric cpt feature flags */
		c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
				RTE_CRYPTODEV_FF_HW_ACCELERATED |
				RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
				RTE_CRYPTODEV_FF_IN_PLACE_SGL |
				RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
				RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
		break;

Hope this clarifies.

Quoted 48 lines
Quoted 48 lines
drivers/crypto/octeontx/otx_cryptodev_capabilities.h +2 -3
index fc62821..439b50e 100644
@@ -8,10 +8,9 @@
 #include <rte_cryptodev.h>
 
 /*
- * Get capabilities list for the device
- *
+ * Get capabilities list for the device, based on device type
  */
 const struct rte_cryptodev_capabilities *
-otx_get_capabilities(void);
+otx_get_capabilities(uint64_t flags);
 
 #endif /* _OTX_CRYPTODEV_CAPABILITIES_H_ */ diff --git

a/drivers/crypto/octeontx/otx_cryptodev_ops.c
b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index 88efed3..b59a001 100644

drivers/crypto/octeontx/otx_cryptodev_ops.c +1 -1
@@ -105,7 +105,7 @@ otx_cpt_dev_info_get(struct rte_cryptodev *dev,
 struct rte_cryptodev_info *info)
 	if (info != NULL) {
 		info->max_nb_queue_pairs = CPT_NUM_QS_PER_VF;
 		info->feature_flags = dev->feature_flags;
-		info->capabilities = otx_get_capabilities();
+		info->capabilities = otx_get_capabilities(info->feature_flags);
 		info->sym.max_nb_sessions = 0;
 		info->driver_id = otx_cryptodev_driver_id;

info->min_mbuf_headroom_req =
OTX_CPT_MIN_HEADROOM_REQ;

drivers/crypto/octeontx/otx_cryptodev_ops.c +0 -0
@@ -635,7 +635,8 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 	case OTX_CPT_VF_TYPE_AE:
 		/* Set asymmetric cpt feature flags */
 		c_dev->feature_flags =

RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |

drivers/crypto/octeontx/otx_cryptodev_ops.c +2 -2
-				RTE_CRYPTODEV_FF_HW_ACCELERATED;
+				RTE_CRYPTODEV_FF_HW_ACCELERATED |
+				RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
 		break;
 	case OTX_CPT_VF_TYPE_SE:
 		/* Set symmetric cpt feature flags */
--

2.7.4

#5 lore raw

Re: [dpdk-dev] [PATCH 2/8] crypto/octeontx: add RSA and modexp asym capabilities

Quoted 18 lines
Quoted 17 lines

Hi Anoob,

drivers/crypto/octeontx/otx_cryptodev_capabilities.c static const struct rte_cryptodev_capabilities otx_capabilities[] = { · line 645

Quoted 11 lines

const struct rte_cryptodev_capabilities *

drivers/crypto/octeontx/otx_cryptodev_capabilities.c +6 -2
-otx_get_capabilities(void)
+otx_get_capabilities(uint64_t flags)
 {
-	return otx_capabilities;
+	if (flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)
+		return otx_asym_capabilities;
+	else
+		return otx_sym_capabilities;
+
 }

I believe this will give Asym capabilities always. As the feature flag RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO will always be set, as the flags

are

Quoted 8 lines
Quoted 3 lines

set in init.

It will never go in else.

[Anoob] The flags is set based on the type of underlying device. The crypto module on OCTEONTX exposes two kinds of VFs. One which does only symmetric and one which does only asymmetric. Both are never supported together for a VF, and hence the if...else.

OK probably a comment should be added to avoid this confusion while calling infos_get. And add this info in doc as well if not already there.

Quoted 72 lines

From the first patch, crypto/octeontx: add device type mailbox routine

	switch (cptvf->vftype) {
	case OTX_CPT_VF_TYPE_AE:
		/* Set asymmetric cpt feature flags */
		c_dev->feature_flags =
RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
				RTE_CRYPTODEV_FF_HW_ACCELERATED;
		break;
	case OTX_CPT_VF_TYPE_SE:
		/* Set symmetric cpt feature flags */
		c_dev->feature_flags =
RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
				RTE_CRYPTODEV_FF_HW_ACCELERATED |

	RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
				RTE_CRYPTODEV_FF_IN_PLACE_SGL |
				RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
				RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
		break;

Hope this clarifies.

Quoted 48 lines
Quoted 48 lines
drivers/crypto/octeontx/otx_cryptodev_capabilities.h +2 -3
index fc62821..439b50e 100644
@@ -8,10 +8,9 @@
 #include <rte_cryptodev.h>
 
 /*
- * Get capabilities list for the device
- *
+ * Get capabilities list for the device, based on device type
  */
 const struct rte_cryptodev_capabilities *
-otx_get_capabilities(void);
+otx_get_capabilities(uint64_t flags);
 
 #endif /* _OTX_CRYPTODEV_CAPABILITIES_H_ */ diff --git

a/drivers/crypto/octeontx/otx_cryptodev_ops.c
b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index 88efed3..b59a001 100644

drivers/crypto/octeontx/otx_cryptodev_ops.c +1 -1
@@ -105,7 +105,7 @@ otx_cpt_dev_info_get(struct rte_cryptodev *dev,
 struct rte_cryptodev_info *info)
 	if (info != NULL) {
 		info->max_nb_queue_pairs = CPT_NUM_QS_PER_VF;
 		info->feature_flags = dev->feature_flags;
-		info->capabilities = otx_get_capabilities();
+		info->capabilities = otx_get_capabilities(info->feature_flags);
 		info->sym.max_nb_sessions = 0;
 		info->driver_id = otx_cryptodev_driver_id;

info->min_mbuf_headroom_req =
OTX_CPT_MIN_HEADROOM_REQ;

drivers/crypto/octeontx/otx_cryptodev_ops.c +0 -0
@@ -635,7 +635,8 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 	case OTX_CPT_VF_TYPE_AE:
 		/* Set asymmetric cpt feature flags */
 		c_dev->feature_flags =

RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |

drivers/crypto/octeontx/otx_cryptodev_ops.c +2 -2
-				RTE_CRYPTODEV_FF_HW_ACCELERATED;
+				RTE_CRYPTODEV_FF_HW_ACCELERATED |
+				RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
 		break;
 	case OTX_CPT_VF_TYPE_SE:
 		/* Set symmetric cpt feature flags */
--

2.7.4

#6 lore raw

PATCH 3/8 crypto/octeontx: add asymmetric session operations

In reply to Anoob Joseph

From: Kanaka Durga Kotamarthy <[email protected]>

Add asymmetric session setup and free functions

---
 drivers/common/cpt/cpt_mcode_defines.h      |   9 ++
 drivers/common/cpt/cpt_ucode_asym.h         | 169 ++++++++++++++++++++++++++++
 drivers/crypto/octeontx/otx_cryptodev_ops.c |  66 ++++++++++-
 3 files changed, 243 insertions(+), 1 deletion(-)
 create mode 100644 drivers/common/cpt/cpt_ucode_asym.h
drivers/common/cpt/cpt_mcode_defines.h +9 -0
index c197c7b..3a373ee 100644
@@ -6,6 +6,7 @@
 #define _CPT_MCODE_DEFINES_H_
 
 #include <rte_byteorder.h>
+#include <rte_crypto_asym.h>
 #include <rte_memory.h>
 
 /*
@@ -316,6 +317,14 @@ struct cpt_ctx {
 	uint8_t  auth_key[64];
 };
 
+struct cpt_asym_sess_misc {
+	enum rte_crypto_asym_xform_type xfrm_type;
+	union {
+		struct rte_crypto_rsa_xform rsa_ctx;
+		struct rte_crypto_modex_xform mod_ctx;
+	};
+};
+
 /* Buffer pointer */
 typedef struct buf_ptr {
 	void *vaddr;
drivers/common/cpt/cpt_ucode_asym.h new file +169 -0

169 lines not on this page · raw message

drivers/crypto/octeontx/otx_cryptodev_ops.c +65 -1

84 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

Re: [dpdk-dev] [PATCH 3/8] crypto/octeontx: add asymmetric session operations

Hi Anoob,

Just a couple of nits

drivers/common/cpt/cpt_ucode_asym.h line 19

Quoted 7 lines
drivers/common/cpt/cpt_ucode_asym.h new file +7 -0
+
+static __rte_always_inline void
+cpt_modex_param_normalize(uint8_t **data, size_t *len)
+{
+	size_t i;
+
+	/* Strip leading NUL bytes */

Typo NULL

Quoted 10 lines
drivers/common/cpt/cpt_ucode_asym.h new file +10 -0
+
+	for (i = 0; i < *len; i++) {
+		if ((*data)[i] != 0)
+			break;
+	}
+
+	*data += i;
+	*len -= i;
+}
+

<.snip.>

Quoted 9 lines
drivers/common/cpt/cpt_ucode_asym.h new file +9 -0
+static __rte_always_inline void
+cpt_free_asym_session_parameters(struct cpt_asym_sess_misc *sess)
+{
+	struct rte_crypto_modex_xform *mod;
+	struct rte_crypto_rsa_xform *rsa;
+
+	switch (sess->xfrm_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+		rsa = &sess->rsa_ctx;

drivers/common/cpt/cpt_ucode_asym.h line 165

Quoted 10 lines
drivers/common/cpt/cpt_ucode_asym.h new file +10 -0
+		if (rsa->n.data)
+			rte_free(rsa->n.data);
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		mod = &sess->mod_ctx;
+		if (mod->modulus.data)
+			rte_free(mod->modulus.data);
+		break;
+	default:
+		break;

Do we need an error print here?

Quoted 3 lines
drivers/common/cpt/cpt_ucode_asym.h new file +3 -0
+	}
+}
+
#8 lore raw

Re: [dpdk-dev] [PATCH 3/8] crypto/octeontx: add asymmetric session operations

Hi Akhil,

Please see inline.

Thanks,
Anoob

Quoted 15 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, October 1, 2019 6:27 PM
To: Anoob Joseph <[email protected]>; Pablo de Lara <[email protected]>
Cc: Kanaka Durga Kotamarthy <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Shally Verma <[email protected]>; Sunila Sahu <[email protected]>; [email protected]
Subject: RE: [PATCH 3/8] crypto/octeontx: add asymmetric session operations

Hi Anoob,

Just a couple of nits

Quoted 8 lines

drivers/common/cpt/cpt_ucode_asym.h line 19

Quoted 6 lines
drivers/common/cpt/cpt_ucode_asym.h new file +6 -0
+
+static __rte_always_inline void
+cpt_modex_param_normalize(uint8_t **data, size_t *len) {
+	size_t i;
+
+	/* Strip leading NUL bytes */

Typo NULL

[Anoob] It is intentional.

"NUL is a ASCII character which ascii value is 0 whereas NULL is a macro defined in stddef.h and several more header file with value of ((void *)0)."

Quoted 27 lines
Quoted 11 lines
drivers/common/cpt/cpt_ucode_asym.h new file +10 -0
+
+	for (i = 0; i < *len; i++) {
+		if ((*data)[i] != 0)
+			break;
+	}
+
+	*data += i;
+	*len -= i;
+}
+

<.snip.>

Quoted 13 lines
drivers/common/cpt/cpt_ucode_asym.h new file +13 -0
+static __rte_always_inline void
+cpt_free_asym_session_parameters(struct cpt_asym_sess_misc *sess) {
+	struct rte_crypto_modex_xform *mod;
+	struct rte_crypto_rsa_xform *rsa;
+
+	switch (sess->xfrm_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+		rsa = &sess->rsa_ctx;
+		if (rsa->n.data)
+			rte_free(rsa->n.data);
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		mod = &sess->mod_ctx;
Quoted 8 lines

drivers/common/cpt/cpt_ucode_asym.h line 165

Quoted 5 lines
drivers/common/cpt/cpt_ucode_asym.h new file +5 -0
+		if (mod->modulus.data)
+			rte_free(mod->modulus.data);
+		break;
+	default:
+		break;

Do we need an error print here?

[Anoob] I'll add DP logs here.

Quoted 4 lines
Quoted 4 lines
drivers/common/cpt/cpt_ucode_asym.h new file +3 -0
+	}
+}
+
#9 lore raw

PATCH 4/8 common/cpt: add helper functions for asymmetric crypto

In reply to Anoob Joseph

From: Kanaka Durga Kotamarthy <[email protected]>

Add helper functions to get meta len for asymmetric operations

---
 drivers/common/cpt/cpt_pmd_ops_helper.c           | 15 +++++++++++
 drivers/common/cpt/cpt_pmd_ops_helper.h           |  9 +++++++
 drivers/common/cpt/rte_common_cpt_version.map     |  8 ++++++
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 32 +++++++++++++++--------
 4 files changed, 53 insertions(+), 11 deletions(-)
drivers/common/cpt/cpt_pmd_ops_helper.c +15 -0
index 1c18180..09b762f 100644
@@ -11,6 +11,8 @@
 
 #define CPT_MAX_IV_LEN 16
 #define CPT_OFFSET_CONTROL_BYTES 8
+#define CPT_MAX_ASYM_OP_NUM_PARAMS 5
+#define CPT_MAX_ASYM_OP_MOD_LEN 1024
 
 int32_t
 cpt_pmd_ops_helper_get_mlen_direct_mode(void)
@@ -39,3 +41,16 @@ cpt_pmd_ops_helper_get_mlen_sg_mode(void)
 	len += 2 * sizeof(cpt_res_s_t);
 	return len;
 }
+
+int
+cpt_pmd_ops_helper_asym_get_mlen(void)
+{
+	uint32_t len;
+
+	/* Get meta len for linear buffer (direct) mode */
+	len = cpt_pmd_ops_helper_get_mlen_direct_mode();
+
+	/* Get meta len for asymmetric operations */
+	len += CPT_MAX_ASYM_OP_NUM_PARAMS * CPT_MAX_ASYM_OP_MOD_LEN;
+	return len;
+}
drivers/common/cpt/cpt_pmd_ops_helper.h +9 -0
index dd32f9a..24c3559 100644
@@ -31,4 +31,13 @@ cpt_pmd_ops_helper_get_mlen_direct_mode(void);
  */
 int
 cpt_pmd_ops_helper_get_mlen_sg_mode(void);
+
+/*
+ * Get size of meta buffer to be allocated for asymmetric crypto operations
+ *
+ * @return
+ *  - length
+ */
+int
+cpt_pmd_ops_helper_asym_get_mlen(void);
 #endif /* _CPT_PMD_OPS_HELPER_H_ */
drivers/common/cpt/rte_common_cpt_version.map +8 -0
index dec614f..382ec4b 100644
@@ -4,3 +4,11 @@ DPDK_18.11 {
 	cpt_pmd_ops_helper_get_mlen_direct_mode;
 	cpt_pmd_ops_helper_get_mlen_sg_mode;
 };
+
+DPDK_19.11 {
+	global:
+
+	cpt_pmd_ops_helper_asym_get_mlen;
+
+	local: *;
+};
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +21 -11
index ad64bf4..0543494 100644
@@ -412,24 +412,34 @@ otx_cpt_metabuf_mempool_create(const struct rte_cryptodev *dev,
 			       int nb_elements)
 {
 	char mempool_name[RTE_MEMPOOL_NAMESIZE];
-	int sg_mlen, lb_mlen, max_mlen, ret;
 	struct cpt_qp_meta_info *meta_info;
 	struct rte_mempool *pool;
+	int max_mlen = 0;
+	int sg_mlen = 0;
+	int lb_mlen = 0;
+	int ret;
 
-	/* Get meta len for scatter gather mode */
-	sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
+	if (dev->feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) {
 
-	/* Extra 32B saved for future considerations */
-	sg_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for scatter gather mode */
+		sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
 
-	/* Get meta len for linear buffer (direct) mode */
-	lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
+		/* Extra 32B saved for future considerations */
+		sg_mlen += 4 * sizeof(uint64_t);
 
-	/* Extra 32B saved for future considerations */
-	lb_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for linear buffer (direct) mode */
+		lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
 
-	/* Check max requirement for meta buffer */
-	max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+		/* Extra 32B saved for future considerations */
+		lb_mlen += 4 * sizeof(uint64_t);
+
+		/* Check max requirement for meta buffer */
+		max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+	} else if (dev->feature_flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
+
+		/* Get meta len for asymmetric operations */
+		max_mlen = cpt_pmd_ops_helper_asym_get_mlen();
+	}
 
 	/* Allocate mempool */
 
Signature · 1 line
2.7.4
#10 lore raw

Re: [dpdk-dev] [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto

Hi Anoob,

Quoted 9 lines

From: Kanaka Durga Kotamarthy <[email protected]>

Add helper functions to get meta len for asymmetric operations

---

<snip>

Quoted 40 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +12 -11
index ad64bf4..0543494 100644
@@ -412,24 +412,34 @@ otx_cpt_metabuf_mempool_create(const struct
 rte_cryptodev *dev,
 			       int nb_elements)
 {
 	char mempool_name[RTE_MEMPOOL_NAMESIZE];
-	int sg_mlen, lb_mlen, max_mlen, ret;
 	struct cpt_qp_meta_info *meta_info;
 	struct rte_mempool *pool;
+	int max_mlen = 0;
+	int sg_mlen = 0;
+	int lb_mlen = 0;
+	int ret;
 
-	/* Get meta len for scatter gather mode */
-	sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
+	if (dev->feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) {
 
-	/* Extra 32B saved for future considerations */
-	sg_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for scatter gather mode */
+		sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
 
-	/* Get meta len for linear buffer (direct) mode */
-	lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
+		/* Extra 32B saved for future considerations */
+		sg_mlen += 4 * sizeof(uint64_t);
 
-	/* Extra 32B saved for future considerations */
-	lb_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for linear buffer (direct) mode */
+		lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
 
-	/* Check max requirement for meta buffer */
-	max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+		/* Extra 32B saved for future considerations */

drivers/crypto/octeontx/otx_cryptodev_hw_access.c otx_cpt_metabuf_mempool_create(const struct · line 444

Quoted 10 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +9 -0
+		lb_mlen += 4 * sizeof(uint64_t);
+
+		/* Check max requirement for meta buffer */
+		max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+	} else if (dev->feature_flags &
 RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
+
+		/* Get meta len for asymmetric operations */
+		max_mlen = cpt_pmd_ops_helper_asym_get_mlen();
+	}

I am not sure how this is working.
In your octeontx device, you will have both RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO and RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO will be set together. So it will not go in else in any case.
Please check in rest of the PMD also if this assumption is made somewhere else also.

Quoted 5 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +0 -1
 	/* Allocate mempool */
 
--

2.7.4

#11 lore raw

Re: [dpdk-dev] [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto

Hi Akhil,

Please see inline.

Thanks,
Anoob

Quoted 76 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, October 1, 2019 6:35 PM
To: Anoob Joseph <[email protected]>; Pablo de Lara <[email protected]>
Cc: Kanaka Durga Kotamarthy <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Shally Verma <[email protected]>; Sunila Sahu <[email protected]>; [email protected]
Subject: RE: [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto

Hi Anoob,

Quoted 9 lines

From: Kanaka Durga Kotamarthy <[email protected]>

Add helper functions to get meta len for asymmetric operations

---

<snip>

Quoted 40 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +12 -11
index ad64bf4..0543494 100644
@@ -412,24 +412,34 @@ otx_cpt_metabuf_mempool_create(const struct
 rte_cryptodev *dev,
 			       int nb_elements)
 {
 	char mempool_name[RTE_MEMPOOL_NAMESIZE];
-	int sg_mlen, lb_mlen, max_mlen, ret;
 	struct cpt_qp_meta_info *meta_info;
 	struct rte_mempool *pool;
+	int max_mlen = 0;
+	int sg_mlen = 0;
+	int lb_mlen = 0;
+	int ret;
 
-	/* Get meta len for scatter gather mode */
-	sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
+	if (dev->feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) {
 
-	/* Extra 32B saved for future considerations */
-	sg_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for scatter gather mode */
+		sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
 
-	/* Get meta len for linear buffer (direct) mode */
-	lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
+		/* Extra 32B saved for future considerations */
+		sg_mlen += 4 * sizeof(uint64_t);
 
-	/* Extra 32B saved for future considerations */
-	lb_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for linear buffer (direct) mode */
+		lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
 
-	/* Check max requirement for meta buffer */
-	max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+		/* Extra 32B saved for future considerations */

drivers/crypto/octeontx/otx_cryptodev_hw_access.c otx_cpt_metabuf_mempool_create(const struct · line 444

Quoted 10 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +9 -0
+		lb_mlen += 4 * sizeof(uint64_t);
+
+		/* Check max requirement for meta buffer */
+		max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+	} else if (dev->feature_flags &
 RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
+
+		/* Get meta len for asymmetric operations */
+		max_mlen = cpt_pmd_ops_helper_asym_get_mlen();
+	}
Quoted 8 lines

I am not sure how this is working.
In your octeontx device, you will have both RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO
and RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO will be set together. So it will not go in else in any case.
Please check in rest of the PMD also if this assumption is made somewhere else also.

[Anoob] The crypto VFs on octeontx would be either sym/asym and cannot be both. Hence the above would work. But, you are right. In the above, it should be,

sym_lens = 0;
asym_lens = 0;

If (SYM) {
    /* set various lens for sym */
}
If (ASYM) {
    /* set various lens for asym */
}

len = MAX(sym_len, asym_len);

I'll make the required changes in v2. Hope this clarifies.

Quoted 5 lines
Quoted 5 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +0 -1
 	/* Allocate mempool */
 
--

2.7.4

#12 lore raw

Re: [dpdk-dev] [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto

Hi Akhil,

Minor correction. Please see inline.

Thanks,
Anoob

Quoted 120 lines

-----Original Message-----
From: Anoob Joseph
Sent: Wednesday, October 2, 2019 4:44 PM
To: Akhil Goyal <[email protected]>; Pablo de Lara <[email protected]>
Cc: Kanaka Durga Kotamarthy <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Shally Verma <[email protected]>; Sunila Sahu <[email protected]>; [email protected]
Subject: RE: [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto

Hi Akhil,

Please see inline.

Thanks,
Anoob

Quoted 24 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, October 1, 2019 6:35 PM
To: Anoob Joseph <[email protected]>; Pablo de Lara <[email protected]>
Cc: Kanaka Durga Kotamarthy <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Shally Verma <[email protected]>; Sunila Sahu <[email protected]>; [email protected]
Subject: RE: [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto

Hi Anoob,

Quoted 9 lines

From: Kanaka Durga Kotamarthy <[email protected]>

Add helper functions to get meta len for asymmetric operations

---

Quoted 8 lines

<snip>

drivers/crypto/octeontx/otx_cryptodev_hw_access.c otx_cpt_metabuf_mempool_create(const

Quoted 6 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +0 -0
index ad64bf4..0543494 100644
@@ -412,24 +412,34 @@ otx_cpt_metabuf_mempool_create(const

struct

Quoted 12 lines
Quoted 12 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +4 -1
 rte_cryptodev *dev,
 			       int nb_elements)
 {
 	char mempool_name[RTE_MEMPOOL_NAMESIZE];
-	int sg_mlen, lb_mlen, max_mlen, ret;
 	struct cpt_qp_meta_info *meta_info;
 	struct rte_mempool *pool;
+	int max_mlen = 0;
+	int sg_mlen = 0;
+	int lb_mlen = 0;
+	int ret;
 
Quoted 3 lines

drivers/crypto/octeontx/otx_cryptodev_hw_access.c otx_cpt_metabuf_mempool_create(const struct rte_cryptodev *dev,

Quoted 3 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +1 -2
-	/* Get meta len for scatter gather mode */
-	sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
+	if (dev->feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)

{

Quoted 26 lines
Quoted 26 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +13 -8
-	/* Extra 32B saved for future considerations */
-	sg_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for scatter gather mode */
+		sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
 
-	/* Get meta len for linear buffer (direct) mode */
-	lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
+		/* Extra 32B saved for future considerations */
+		sg_mlen += 4 * sizeof(uint64_t);
 
-	/* Extra 32B saved for future considerations */
-	lb_mlen += 4 * sizeof(uint64_t);
+		/* Get meta len for linear buffer (direct) mode */
+		lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
 
-	/* Check max requirement for meta buffer */
-	max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+		/* Extra 32B saved for future considerations */
+		lb_mlen += 4 * sizeof(uint64_t);
+
+		/* Check max requirement for meta buffer */
+		max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+	} else if (dev->feature_flags &
 RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
+
Quoted 8 lines

drivers/crypto/octeontx/otx_cryptodev_hw_access.c otx_cpt_metabuf_mempool_create(const struct rte_cryptodev *dev, · line 442

Quoted 3 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +3 -0
+		/* Get meta len for asymmetric operations */
+		max_mlen = cpt_pmd_ops_helper_asym_get_mlen();
+	}

I am not sure how this is working.
In your octeontx device, you will have both RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO
and RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO will be set together. So it

will

Quoted 4 lines

not go in else in any case.
Please check in rest of the PMD also if this assumption is made somewhere else also.

[Anoob] The crypto VFs on octeontx would be either sym/asym and cannot be both. Hence the above would work. But, you are right. In the above, it should be,

sym_lens = 0;
asym_lens = 0;

If (SYM) {
    /* set various lens for sym */
}
Quoted 7 lines
If (ASYM) {
    /* set various lens for asym */
}

len = MAX(sym_len, asym_len);

I'll make the required changes in v2. Hope this clarifies.

[Anoob] The above code snippet is only applicable for crypto_octeontx PMD. And hence the current code should be fine. Initially, I mistook that the suggestion was for a common routine. Nevertheless, I'll add a comment stating that only one feature is supported.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +0 -1
 	/* Allocate mempool */
 
--

2.7.4

#13 lore raw

PATCH 5/8 crypto/octeontx: add asymmetric op enqueue function

In reply to Anoob Joseph

From: Sunila Sahu <[email protected]>

Add asymmetric crypto op enqueue routine

---
 drivers/common/cpt/cpt_common.h             |   1 +
 drivers/common/cpt/cpt_mcode_defines.h      |  20 ++
 drivers/common/cpt/cpt_ucode_asym.h         | 282 ++++++++++++++++++++++++++++
 drivers/crypto/octeontx/otx_cryptodev_ops.c |  70 +++++++
 4 files changed, 373 insertions(+)
drivers/common/cpt/cpt_common.h +1 -0
index 7ef6b29..dff45f0 100644
@@ -75,6 +75,7 @@ struct cpt_request_info {
 		uint64_t ei2;
 		uint64_t ei3;
 	} ist;
+	uint8_t *rptr;
 
 	/** Control path fields */
 	uint64_t time_out;
drivers/common/cpt/cpt_mcode_defines.h +20 -0
index 3a373ee..f356e62 100644
@@ -21,6 +21,18 @@
 #define CPT_MAJOR_OP_KASUMI	0x38
 #define CPT_MAJOR_OP_MISC	0x01
 
+/* AE opcodes */
+#define CPT_MAJOR_OP_MODEX	0x03
+#define CPT_MINOR_OP_MODEX	0x01
+#define CPT_MINOR_OP_PKCS_ENC	0x02
+#define CPT_MINOR_OP_PKCS_ENC_CRT	0x03
+#define CPT_MINOR_OP_PKCS_DEC	0x04
+#define CPT_MINOR_OP_PKCS_DEC_CRT	0x05
+#define CPT_MINOR_OP_MODEX_CRT	0x06
+
+#define CPT_BLOCK_TYPE1 0
+#define CPT_BLOCK_TYPE2 1
+
 #define CPT_BYTE_16		16
 #define CPT_BYTE_24		24
 #define CPT_BYTE_32		32
@@ -369,6 +381,14 @@ typedef struct fc_params {
 } fc_params_t;
 
 /*
+ * Parameters for asymmetric operations
+ */
+struct asym_op_params {
+	struct cpt_request_info *req;
+	phys_addr_t meta_buf;
+};
+
+/*
  * Parameters for digest
  * generate requests
  * Only src_iov, op, ctx_buf, mac_buf, prep_req
drivers/common/cpt/cpt_ucode_asym.h +282 -0

292 lines not on this page · raw message

drivers/crypto/octeontx/otx_cryptodev_ops.c +70 -0

82 lines not on this page · raw message

Signature · 1 line
2.7.4
#14 lore raw

PATCH 6/8 crypto/octeontx: add asymmetric op dequeue function

In reply to Anoob Joseph

From: Sunila Sahu <[email protected]>

Add asymmetric crypto op dequeue routine

---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 88 +++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
drivers/crypto/octeontx/otx_cryptodev_ops.c +88 -0
index 1f42fe8..ab1ee7e 100644
@@ -591,6 +591,87 @@ otx_cpt_pkt_enqueue(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 }
 
 static __rte_always_inline void
+otx_cpt_asym_rsa_op(struct rte_crypto_op *cop, struct cpt_request_info *req,
+		    struct rte_crypto_rsa_xform *rsa_ctx)
+
+{
+	struct rte_crypto_rsa_op_param *rsa = &cop->asym->rsa;
+
+	switch (rsa->op_type) {
+	case RTE_CRYPTO_ASYM_OP_ENCRYPT:
+		rsa->cipher.length = rsa_ctx->n.length;
+		memcpy(rsa->cipher.data, req->rptr, rsa->cipher.length);
+		break;
+	case RTE_CRYPTO_ASYM_OP_DECRYPT:
+		if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE)
+			rsa->message.length = rsa_ctx->n.length;
+		else {
+			/* Get length of decrypted output */
+			rsa->message.length = rte_cpu_to_be_16
+					(*((uint16_t *)req->rptr));
+
+			/* Offset data pointer by length fields */
+			req->rptr += 2;
+		}
+		memcpy(rsa->message.data, req->rptr, rsa->message.length);
+		break;
+	case RTE_CRYPTO_ASYM_OP_SIGN:
+		rsa->sign.length = rsa_ctx->n.length;
+		memcpy(rsa->sign.data, req->rptr, rsa->sign.length);
+		break;
+	case RTE_CRYPTO_ASYM_OP_VERIFY:
+		if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE)
+			rsa->sign.length = rsa_ctx->n.length;
+		else {
+			/* Get length of decrypted output */
+			rsa->sign.length = rte_cpu_to_be_16
+					(*((uint16_t *)req->rptr));
+
+			/* Offset data pointer by length fields */
+			req->rptr += 2;
+		}
+		memcpy(rsa->sign.data, req->rptr, rsa->sign.length);
+
+		if (memcmp(rsa->sign.data, rsa->message.data,
+			   rsa->message.length)) {
+			CPT_LOG_DP_ERR("RSA verification failed");
+			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		}
+		break;
+	default:
+		CPT_LOG_DP_DEBUG("Invalid RSA operation type");
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		break;
+	}
+}
+
+static void
+otx_cpt_asym_post_process(struct rte_crypto_op *cop,
+			  struct cpt_request_info *req)
+{
+	struct rte_crypto_asym_op *op = cop->asym;
+	struct cpt_asym_sess_misc *sess;
+
+	sess = get_asym_session_private_data(op->session,
+					     otx_cryptodev_driver_id);
+
+	switch (sess->xfrm_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+		otx_cpt_asym_rsa_op(cop, req, &sess->rsa_ctx);
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		op->modex.result.length = sess->mod_ctx.modulus.length;
+		memcpy(op->modex.result.data, req->rptr,
+		       op->modex.result.length);
+		break;
+	default:
+		CPT_LOG_DP_DEBUG("Invalid crypto xform type");
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		break;
+	}
+}
+
+static __rte_always_inline void
 otx_cpt_dequeue_post_process(struct rte_crypto_op *cop, uintptr_t *rsp)
 {
 	/* H/w has returned success */
@@ -604,6 +685,13 @@ otx_cpt_dequeue_post_process(struct rte_crypto_op *cop, uintptr_t *rsp)
 			compl_auth_verify(cop, (uint8_t *)rsp[2], rsp[3]);
 		return;
 	}
+
+	if (cop->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		rsp = RTE_PTR_ADD(rsp, 4 * sizeof(uintptr_t));
+		otx_cpt_asym_post_process(cop, (struct cpt_request_info *)rsp);
+	}
+
+	return;
 }
 
 static uint16_t
Signature · 1 line
2.7.4
#15 lore raw

PATCH 7/8 app/test: register octeontx PMD to asym testsuite

In reply to Anoob Joseph

From: Sunila Sahu <[email protected]>

Updated asymmetric crypto unit-test application to test asymmetric crypto operations in octeontx PMD

---
 app/test/test_cryptodev_asym.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
app/test/test_cryptodev_asym.c +31 -0
index e8177e7..241c384 100644
@@ -1791,6 +1791,19 @@ static struct unit_test_suite cryptodev_qat_asym_testsuite  = {
 	}
 };
 
+static struct unit_test_suite cryptodev_octeontx_asym_testsuite  = {
+	.suite_name = "Crypto Device OCTEONTX ASYM Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup, ut_teardown, test_capability),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static int
 test_cryptodev_openssl_asym(void)
 {
@@ -1823,7 +1836,25 @@ test_cryptodev_qat_asym(void)
 	return unit_test_suite_runner(&cryptodev_qat_asym_testsuite);
 }
 
+static int
+test_cryptodev_octeontx_asym(void)
+{
+	gbl_driver_id = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
+				"enabled in config file to run this "
+				"testsuite.\n");
+		return TEST_FAILED;
+	}
+	return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_openssl_asym_autotest,
 					  test_cryptodev_openssl_asym);
 
 REGISTER_TEST_COMMAND(cryptodev_qat_asym_autotest, test_cryptodev_qat_asym);
+
+REGISTER_TEST_COMMAND(cryptodev_octeontx_asym_autotest,
+					  test_cryptodev_octeontx_asym);
Signature · 1 line
2.7.4
#16 lore raw

PATCH 8/8 doc: update octeontx asymmetric features

In reply to Anoob Joseph

From: Sunila Sahu <[email protected]>

Update documentation with supported asymmetric features for octeontx

---
 doc/guides/cryptodevs/features/octeontx.ini |  6 +++++-
 doc/guides/cryptodevs/octeontx.rst          | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/features/octeontx.ini +5 -1
index 1735b8f..1c036c5 100644
@@ -5,11 +5,13 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
+RSA PRIV OP KEY QT     = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx' crypto driver.
@@ -64,4 +66,6 @@ AES GCM (256) = Y
 ;
 ; Supported Asymmetric algorithms of the 'octeontx' crypto driver.
 ;
-[Asymmetric]
\ No newline at end of file
+[Asymmetric]
+RSA                    = Y
+Modular Exponentiation = Y
doc/guides/cryptodevs/octeontx.rst +25 -0
index 1600a56..a26882b 100644
@@ -53,6 +53,12 @@ AEAD Algorithms
 
 * ``RTE_CRYPTO_AEAD_AES_GCM``
 
+Asymmetric Crypto Algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* ``RTE_CRYPTO_ASYM_XFORM_RSA``
+* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
+
 Config flags
 ------------
 
@@ -120,3 +126,22 @@ OCTEON TX crypto PMD.
 
         ./build/ipsec-secgw --log-level=8 -c 0xff -- -P -p 0x3 -u 0x2 --config
         "(1,0,0),(0,0,0)" -f ep1.cfg
+
+Testing
+-------
+
+The symmetric crypto operations on OCTEON TX crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_autotest
+
+The asymmetric crypto operations on OCTEON TX crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_asym_autotest
Signature · 1 line
2.7.4
#17 lore raw

Re: [dpdk-dev] [PATCH 8/8] doc: update octeontx asymmetric features

Hi Anoob,

Quoted 47 lines

From: Sunila Sahu <[email protected]>

Update documentation with supported asymmetric features for octeontx

---
 doc/guides/cryptodevs/features/octeontx.ini |  6 +++++-
 doc/guides/cryptodevs/octeontx.rst          | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/features/octeontx.ini +5 -1
index 1735b8f..1c036c5 100644
@@ -5,11 +5,13 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
+RSA PRIV OP KEY QT     = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx' crypto driver.
@@ -64,4 +66,6 @@ AES GCM (256) = Y
 ;
 ; Supported Asymmetric algorithms of the 'octeontx' crypto driver.
 ;
-[Asymmetric]
\ No newline at end of file
+[Asymmetric]
+RSA                    = Y
+Modular Exponentiation = Y
doc/guides/cryptodevs/octeontx.rst +0 -0
index 1600a56..a26882b 100644

doc/guides/cryptodevs/octeontx.rst AEAD Algorithms · line 57

Quoted 5 lines
doc/guides/cryptodevs/octeontx.rst +2 -0
@@ -53,6 +53,12 @@ AEAD Algorithms
 
 * ``RTE_CRYPTO_AEAD_AES_GCM``
 
+Asymmetric Crypto Algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Probably you should have some heading to specify Symmetric crypto Algorithms also.

Quoted 34 lines
doc/guides/cryptodevs/octeontx.rst +9 -0
+
+* ``RTE_CRYPTO_ASYM_XFORM_RSA``
+* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
+
 Config flags
 ------------
 
@@ -120,3 +126,22 @@ OCTEON TX crypto PMD.
 
         ./build/ipsec-secgw --log-level=8 -c 0xff -- -P -p 0x3 -u 0x2 --config
         "(1,0,0),(0,0,0)" -f ep1.cfg
+
+Testing
+-------
+
+The symmetric crypto operations on OCTEON TX crypto PMD may be verified

by running the test

doc/guides/cryptodevs/octeontx.rst +8 -0
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_autotest
+
+The asymmetric crypto operations on OCTEON TX crypto PMD may be verified

by running the test

doc/guides/cryptodevs/octeontx.rst +6 -1
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_asym_autotest
--

2.7.4

#18 lore raw

Re: [dpdk-dev] [PATCH 8/8] doc: update octeontx asymmetric features

Hi Akhil,

Please see inline.

Thanks,
Anoob

Quoted 62 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, October 1, 2019 6:58 PM
To: Anoob Joseph <[email protected]>; Pablo de Lara <[email protected]>
Cc: Sunila Sahu <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Kanaka Durga Kotamarthy <[email protected]>; Shally Verma <[email protected]>; [email protected]
Subject: RE: [PATCH 8/8] doc: update octeontx asymmetric features

Hi Anoob,

Quoted 48 lines

From: Sunila Sahu <[email protected]>

Update documentation with supported asymmetric features for octeontx

---
 doc/guides/cryptodevs/features/octeontx.ini |  6 +++++-
 doc/guides/cryptodevs/octeontx.rst          | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/features/octeontx.ini +5 -1
index 1735b8f..1c036c5 100644
@@ -5,11 +5,13 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
+RSA PRIV OP KEY QT     = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx' crypto driver.
@@ -64,4 +66,6 @@ AES GCM (256) = Y
 ;
 ; Supported Asymmetric algorithms of the 'octeontx' crypto driver.
 ;
-[Asymmetric]
\ No newline at end of file
+[Asymmetric]
+RSA                    = Y
+Modular Exponentiation = Y
doc/guides/cryptodevs/octeontx.rst +0 -0
index 1600a56..a26882b 100644
@@ -53,6 +53,12 @@ AEAD Algorithms
 
Quoted 7 lines

doc/guides/cryptodevs/octeontx.rst AEAD Algorithms · line 57

Quoted 4 lines
doc/guides/cryptodevs/octeontx.rst +2 -0
 * ``RTE_CRYPTO_AEAD_AES_GCM``
 
+Asymmetric Crypto Algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Probably you should have some heading to specify Symmetric crypto Algorithms also.

[Anoob] Do you recommend adding that change also in this patch or should I submit a separate patch for redesigning that. FYI. For crypto_octeontx2, following is the list we are adding. Do you suggest a similar change there also?

The OCTEON TX2 crypto PMD has support for:

Cipher algorithms:

* ``RTE_CRYPTO_CIPHER_NULL``
* ``RTE_CRYPTO_CIPHER_3DES_CBC``
* ``RTE_CRYPTO_CIPHER_3DES_ECB``
* ``RTE_CRYPTO_CIPHER_AES_CBC``
* ``RTE_CRYPTO_CIPHER_AES_CTR``
* ``RTE_CRYPTO_CIPHER_AES_XTS``
* ``RTE_CRYPTO_CIPHER_DES_CBC``
* ``RTE_CRYPTO_CIPHER_KASUMI_F8``
* ``RTE_CRYPTO_CIPHER_SNOW3G_UEA2``
* ``RTE_CRYPTO_CIPHER_ZUC_EEA3``

Hash algorithms:

* ``RTE_CRYPTO_AUTH_NULL``
* ``RTE_CRYPTO_AUTH_AES_GMAC``
* ``RTE_CRYPTO_AUTH_KASUMI_F9``
* ``RTE_CRYPTO_AUTH_MD5``
* ``RTE_CRYPTO_AUTH_MD5_HMAC``
* ``RTE_CRYPTO_AUTH_SHA1``
* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
* ``RTE_CRYPTO_AUTH_SHA224``
* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
* ``RTE_CRYPTO_AUTH_SHA256``
* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
* ``RTE_CRYPTO_AUTH_SHA384``
* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
* ``RTE_CRYPTO_AUTH_SHA512``
* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
* ``RTE_CRYPTO_AUTH_SNOW3G_UIA2``
* ``RTE_CRYPTO_AUTH_ZUC_EIA3``

AEAD algorithms:

* ``RTE_CRYPTO_AEAD_AES_GCM``

Asymmetric algorithms:

* ``RTE_CRYPTO_ASYM_XFORM_RSA``
* ``RTE_CRYPTO_ASYM_XFORM_MODEX``

Quoted 36 lines
Quoted 18 lines
doc/guides/cryptodevs/octeontx.rst +9 -0
+
+* ``RTE_CRYPTO_ASYM_XFORM_RSA``
+* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
+
 Config flags
 ------------
 
@@ -120,3 +126,22 @@ OCTEON TX crypto PMD.
 
         ./build/ipsec-secgw --log-level=8 -c 0xff -- -P -p 0x3 -u 0x2 --config
         "(1,0,0),(0,0,0)" -f ep1.cfg
+
+Testing
+-------
+
+The symmetric crypto operations on OCTEON TX crypto PMD may be verified

by running the test

doc/guides/cryptodevs/octeontx.rst OCTEON TX crypto PMD.

Quoted 8 lines
doc/guides/cryptodevs/octeontx.rst +8 -0
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_autotest
+
+The asymmetric crypto operations on OCTEON TX crypto PMD may be

verified

Quoted 9 lines

by running the test

doc/guides/cryptodevs/octeontx.rst +6 -1
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_asym_autotest
--

2.7.4

#19 lore raw

Re: [dpdk-dev] [PATCH 8/8] doc: update octeontx asymmetric features

Quoted 59 lines
Quoted 15 lines

Hi Anoob,

Quoted 11 lines

From: Sunila Sahu <[email protected]>

Update documentation with supported asymmetric features for octeontx

---
 doc/guides/cryptodevs/features/octeontx.ini |  6 +++++-
 doc/guides/cryptodevs/octeontx.rst          | 25

+++++++++++++++++++++++++

Quoted 37 lines
Quoted 37 lines
 2 files changed, 30 insertions(+), 1 deletion(-)
doc/guides/cryptodevs/features/octeontx.ini +5 -1
index 1735b8f..1c036c5 100644
@@ -5,11 +5,13 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
+RSA PRIV OP KEY QT     = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx' crypto driver.
@@ -64,4 +66,6 @@ AES GCM (256) = Y
 ;
 ; Supported Asymmetric algorithms of the 'octeontx' crypto driver.
 ;
-[Asymmetric]
\ No newline at end of file
+[Asymmetric]
+RSA                    = Y
+Modular Exponentiation = Y
doc/guides/cryptodevs/octeontx.rst +0 -0
index 1600a56..a26882b 100644
@@ -53,6 +53,12 @@ AEAD Algorithms
 
Quoted 6 lines

doc/guides/cryptodevs/octeontx.rst AEAD Algorithms · line 57

Quoted 4 lines
doc/guides/cryptodevs/octeontx.rst +2 -0
 * ``RTE_CRYPTO_AEAD_AES_GCM``
 
+Asymmetric Crypto Algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Probably you should have some heading to specify Symmetric crypto

Quoted 6 lines

Algorithms

Quoted 1 line

also.

[Anoob] Do you recommend adding that change also in this patch or should I submit a separate patch for redesigning that. FYI. For crypto_octeontx2, following is the list we are adding. Do you suggest a similar change there also?

You can refer to qat.rst.
I believe it will not be a big change and is totally relevant in this patchset, so you can have That in this patchset.
Yes you should do this in octeontx2 as well.

Quoted 82 lines

The OCTEON TX2 crypto PMD has support for:

Cipher algorithms:

* ``RTE_CRYPTO_CIPHER_NULL``
* ``RTE_CRYPTO_CIPHER_3DES_CBC``
* ``RTE_CRYPTO_CIPHER_3DES_ECB``
* ``RTE_CRYPTO_CIPHER_AES_CBC``
* ``RTE_CRYPTO_CIPHER_AES_CTR``
* ``RTE_CRYPTO_CIPHER_AES_XTS``
* ``RTE_CRYPTO_CIPHER_DES_CBC``
* ``RTE_CRYPTO_CIPHER_KASUMI_F8``
* ``RTE_CRYPTO_CIPHER_SNOW3G_UEA2``
* ``RTE_CRYPTO_CIPHER_ZUC_EEA3``

Hash algorithms:

* ``RTE_CRYPTO_AUTH_NULL``
* ``RTE_CRYPTO_AUTH_AES_GMAC``
* ``RTE_CRYPTO_AUTH_KASUMI_F9``
* ``RTE_CRYPTO_AUTH_MD5``
* ``RTE_CRYPTO_AUTH_MD5_HMAC``
* ``RTE_CRYPTO_AUTH_SHA1``
* ``RTE_CRYPTO_AUTH_SHA1_HMAC``
* ``RTE_CRYPTO_AUTH_SHA224``
* ``RTE_CRYPTO_AUTH_SHA224_HMAC``
* ``RTE_CRYPTO_AUTH_SHA256``
* ``RTE_CRYPTO_AUTH_SHA256_HMAC``
* ``RTE_CRYPTO_AUTH_SHA384``
* ``RTE_CRYPTO_AUTH_SHA384_HMAC``
* ``RTE_CRYPTO_AUTH_SHA512``
* ``RTE_CRYPTO_AUTH_SHA512_HMAC``
* ``RTE_CRYPTO_AUTH_SNOW3G_UIA2``
* ``RTE_CRYPTO_AUTH_ZUC_EIA3``

AEAD algorithms:

* ``RTE_CRYPTO_AEAD_AES_GCM``

Asymmetric algorithms:

* ``RTE_CRYPTO_ASYM_XFORM_RSA``
* ``RTE_CRYPTO_ASYM_XFORM_MODEX``

Quoted 10 lines
Quoted 10 lines
doc/guides/cryptodevs/octeontx.rst +4 -0
+
+* ``RTE_CRYPTO_ASYM_XFORM_RSA``
+* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
+
 Config flags
 ------------
 
@@ -120,3 +126,22 @@ OCTEON TX crypto PMD.
 
Quoted 7 lines

doc/guides/cryptodevs/octeontx.rst OCTEON TX crypto PMD.

Quoted 7 lines
doc/guides/cryptodevs/octeontx.rst +5 -0
         ./build/ipsec-secgw --log-level=8 -c 0xff -- -P -p 0x3 -u 0x2 --config
         "(1,0,0),(0,0,0)" -f ep1.cfg
+
+Testing
+-------
+
+The symmetric crypto operations on OCTEON TX crypto PMD may be

verified

Quoted 19 lines

doc/guides/cryptodevs/octeontx.rst OCTEON TX crypto PMD.

Quoted 9 lines

by running the test

doc/guides/cryptodevs/octeontx.rst +8 -0
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_autotest
+
+The asymmetric crypto operations on OCTEON TX crypto PMD may be

verified

Quoted 9 lines

by running the test

doc/guides/cryptodevs/octeontx.rst +6 -1
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_asym_autotest
--

2.7.4

#20 lore raw
In reply to Anoob Joseph
Quoted 49 lines

-----Original Message-----
From: Anoob Joseph <[email protected]>
Sent: Monday, September 9, 2019 6:58 PM
To: Akhil Goyal <[email protected]>; Pablo de Lara <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Anoob Joseph <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Fiona Trahe <[email protected]>; Kanaka Durga Kotamarthy <[email protected]>; Shally Verma <[email protected]>; Sunila Sahu <[email protected]>; [email protected]
Subject: [PATCH 0/8] add asym support in crypto_octeontx PMD

This series adds asymmetric crypto support in 'crypto_octeontx' PMD.

Features supported: RSA & modular exponentiation

Kanaka Durga Kotamarthy (4):
crypto/octeontx: add device type mailbox routine crypto/octeontx: add RSA and modexp asym capabilities crypto/octeontx: add asymmetric session operations common/cpt: add helper functions for asymmetric crypto

Sunila Sahu (4):
crypto/octeontx: add asymmetric op enqueue function crypto/octeontx: add asymmetric op dequeue function app/test: register octeontx PMD to asym testsuite
doc: update octeontx asymmetric features

 app/test/test_cryptodev_asym.c                     |  31 ++
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  25 ++
 drivers/common/cpt/cpt_common.h                    |   4 +-
 drivers/common/cpt/cpt_mcode_defines.h             |  29 ++
 drivers/common/cpt/cpt_pmd_ops_helper.c            |  15 +
 drivers/common/cpt/cpt_pmd_ops_helper.h            |   9 +
 drivers/common/cpt/cpt_ucode_asym.h                | 451
+++++++++++++++++++++
 drivers/common/cpt/rte_common_cpt_version.map      |   8 +
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 ++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  44 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.c       |  26 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.h       |  20 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c        | 260 +++++++++++-
 drivers/crypto/octeontx/otx_cryptodev_ops.h        |   2 +
 16 files changed, 944 insertions(+), 38 deletions(-)  create mode 100644
Quoted 4 lines

drivers/common/cpt/cpt_ucode_asym.h

--
2.7.4

Series Ack-by: Shally Verma <[email protected]>

#21 lore raw

v2 cover add asym support in crypto_octeontx PMD

In reply to Anoob Joseph

This series adds asymmetric crypto support in 'crypto_octoentx' PMD.

Changes in v2:
* Squashed patches as directed by Akhil
* Split the doc patch and added documentation along with feature
* Added check for ASYM SESSIONLESS (not supported currently)
* Made separate enqueue & dequeue routines for sym & asym
* Minor updates to documentation

Kanaka Durga Kotamarthy (3):
crypto/octeontx: add device type mailbox routine crypto/octeontx: add asymmetric session operations common/cpt: add helper functions for asymmetric crypto

Sunila Sahu (2):
crypto/octeontx: add asymmetric enqueue/dequeue ops app/test: register octeontx PMD to asym testsuite

 app/test/test_cryptodev_asym.c                     |  31 ++
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  29 +-
 drivers/common/cpt/cpt_common.h                    |   4 +-
 drivers/common/cpt/cpt_mcode_defines.h             |  29 ++
 drivers/common/cpt/cpt_pmd_ops_helper.c            |  15 +
 drivers/common/cpt/cpt_pmd_ops_helper.h            |   9 +
 drivers/common/cpt/cpt_ucode_asym.h                | 453 +++++++++++++++++++++
 drivers/common/cpt/rte_common_cpt_version.map      |   8 +
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 ++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  51 ++-
 drivers/crypto/octeontx/otx_cryptodev_mbox.c       |  26 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.h       |  20 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c        | 338 +++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_ops.h        |   2 +
 16 files changed, 1016 insertions(+), 57 deletions(-)
 create mode 100644 drivers/common/cpt/cpt_ucode_asym.h
Signature · 1 line
2.7.4
#22 lore raw

PATCH v2 1/5 crypto/octeontx: add device type mailbox routine

From: Kanaka Durga Kotamarthy <[email protected]>

Add mailbox communication to query symmetric or asymmetric device type

---
 drivers/common/cpt/cpt_common.h                   |  3 ---
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 12 ++++-----
 drivers/crypto/octeontx/otx_cryptodev_mbox.c      | 26 ++++++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_mbox.h      | 20 ++++++++++++++
 drivers/crypto/octeontx/otx_cryptodev_ops.c       | 33 ++++++++++++++++++-----
 drivers/crypto/octeontx/otx_cryptodev_ops.h       |  2 ++
 6 files changed, 78 insertions(+), 18 deletions(-)
drivers/common/cpt/cpt_common.h +0 -3
index 32f23ac..7ef6b29 100644
@@ -19,9 +19,6 @@
 #define CPT_COUNT_THOLD		32
 #define CPT_TIMER_THOLD		0x3F
 
-#define AE_TYPE 1
-#define SE_TYPE 2
-
 #ifndef ROUNDUP4
 #define ROUNDUP4(val)	(((val) + 3) & 0xfffffffc)
 #endif
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +6 -6
index eba6293..ad64bf4 100644
@@ -386,6 +386,12 @@ otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name)
 		return -1;
 	}
 
+	/* Gets device type */
+	if (otx_cpt_get_dev_type(cptvf)) {
+		CPT_LOG_ERR("Failed to get device type");
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -653,12 +659,6 @@ otx_cpt_start_device(void *dev)
 		return -EFAULT;
 	}
 
-	if ((cptvf->vftype != SE_TYPE) && (cptvf->vftype != AE_TYPE)) {
-		CPT_LOG_ERR("Fatal error, unexpected vf type %u, for CPT VF "
-			    "device %s", cptvf->vftype, cptvf->dev_name);
-		return -ENOENT;
-	}
-
 	return 0;
 }
 
drivers/crypto/octeontx/otx_cryptodev_mbox.c +24 -2
index daba776..a884ad6 100644
@@ -42,11 +42,19 @@ otx_cpt_handle_mbox_intr(struct cpt_vf *cptvf)
 	case OTX_CPT_MSG_QBIND_GRP:
 		cptvf->pf_acked = true;
 		cptvf->vftype = mbx.data;
-		CPT_LOG_DP_DEBUG("%s: VF %d type %s group %d",
+		CPT_LOG_DP_DEBUG("%s: VF %d group %d",
 				 cptvf->dev_name, cptvf->vfid,
-				 ((mbx.data == SE_TYPE) ? "SE" : "AE"),
 				 cptvf->vfgrp);
 		break;
+	case OTX_CPT_MSG_PF_TYPE:
+		cptvf->pf_acked = true;
+		if (mbx.data == OTX_CPT_PF_TYPE_AE)
+			cptvf->vftype = OTX_CPT_VF_TYPE_AE;
+		else if (mbx.data == OTX_CPT_PF_TYPE_SE)
+			cptvf->vftype = OTX_CPT_VF_TYPE_SE;
+		else
+			cptvf->vftype = OTX_CPT_VF_TYPE_INVALID;
+		break;
 	case OTX_CPT_MBOX_MSG_TYPE_ACK:
 		cptvf->pf_acked = true;
 		break;
@@ -120,6 +128,20 @@ otx_cpt_check_pf_ready(struct cpt_vf *cptvf)
 }
 
 int
+otx_cpt_get_dev_type(struct cpt_vf *cptvf)
+{
+	struct cpt_mbox mbx = {0, 0};
+
+	mbx.msg = OTX_CPT_MSG_PF_TYPE;
+	if (otx_cpt_send_msg_to_pf_timeout(cptvf, &mbx)) {
+		CPT_LOG_ERR("%s: PF didn't respond to query msg",
+			    cptvf->dev_name);
+		return 1;
+	}
+	return 0;
+}
+
+int
 otx_cpt_send_vq_size_msg(struct cpt_vf *cptvf)
 {
 	struct cpt_mbox mbx = {0, 0};
drivers/crypto/octeontx/otx_cryptodev_mbox.h +20 -0
index 2d2e0e6..508f3af 100644
@@ -23,6 +23,20 @@ struct cpt_mbox {
 	uint64_t data;
 };
 
+/* CPT PF types */
+enum otx_cpt_pf_type {
+	OTX_CPT_PF_TYPE_INVALID = 0,
+	OTX_CPT_PF_TYPE_AE = 2,
+	OTX_CPT_PF_TYPE_SE,
+};
+
+/* CPT VF types */
+enum otx_cpt_vf_type {
+	OTX_CPT_VF_TYPE_AE = 1,
+	OTX_CPT_VF_TYPE_SE,
+	OTX_CPT_VF_TYPE_INVALID,
+};
+
 /* PF-VF message opcodes */
 enum otx_cpt_mbox_opcode {
 	OTX_CPT_MSG_VF_UP = 1,
@@ -63,6 +77,12 @@ int
 otx_cpt_check_pf_ready(struct cpt_vf *cptvf);
 
 /*
+ * Communicate to PF to get VF type
+ */
+int
+otx_cpt_get_dev_type(struct cpt_vf *cptvf);
+
+/*
  * Communicate VQs size to PF to program CPT(0)_PF_Q(0-15)_CTL of the VF.
  * Must be ACKed.
  */
drivers/crypto/octeontx/otx_cryptodev_ops.c +26 -7
index 118168a..4c6e266 100644
@@ -13,6 +13,7 @@
 #include "otx_cryptodev.h"
 #include "otx_cryptodev_capabilities.h"
 #include "otx_cryptodev_hw_access.h"
+#include "otx_cryptodev_mbox.h"
 #include "otx_cryptodev_ops.h"
 
 #include "cpt_pmd_logs.h"
@@ -630,6 +631,28 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 		goto fail;
 	}
 
+	switch (cptvf->vftype) {
+	case OTX_CPT_VF_TYPE_AE:
+		/* Set asymmetric cpt feature flags */
+		c_dev->feature_flags = RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
+				RTE_CRYPTODEV_FF_HW_ACCELERATED;
+		break;
+	case OTX_CPT_VF_TYPE_SE:
+		/* Set symmetric cpt feature flags */
+		c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+				RTE_CRYPTODEV_FF_HW_ACCELERATED |
+				RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
+				RTE_CRYPTODEV_FF_IN_PLACE_SGL |
+				RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
+				RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
+		break;
+	default:
+		/* Feature not supported. Abort */
+		CPT_LOG_ERR("VF type not supported by %s", dev_name);
+		ret = -EIO;
+		goto deinit_dev;
+	}
+
 	/* Start off timer for mailbox interrupts */
 	otx_cpt_periodic_alarm_start(cptvf);
 
@@ -638,18 +661,14 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 	c_dev->enqueue_burst = otx_cpt_pkt_enqueue;
 	c_dev->dequeue_burst = otx_cpt_pkt_dequeue;
 
-	c_dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
-			RTE_CRYPTODEV_FF_HW_ACCELERATED |
-			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
-			RTE_CRYPTODEV_FF_IN_PLACE_SGL |
-			RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
-			RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
-
 	/* Save dev private data */
 	c_dev->data->dev_private = cptvf;
 
 	return 0;
 
+deinit_dev:
+	otx_cpt_deinit_device(cptvf);
+
 fail:
 	if (cptvf) {
 		/* Free private data allocated */
drivers/crypto/octeontx/otx_cryptodev_ops.h +2 -0
index 768ec4f..fac8a3c 100644
@@ -5,6 +5,8 @@
 #ifndef _OTX_CRYPTODEV_OPS_H_
 #define _OTX_CRYPTODEV_OPS_H_
 
+#include <rte_cryptodev.h>
+
 #define OTX_CPT_MIN_HEADROOM_REQ	(24)
 #define OTX_CPT_MIN_TAILROOM_REQ	(8)
 #define CPT_NUM_QS_PER_VF		(1)
Signature · 1 line
2.7.4
#23 lore raw

PATCH v2 2/5 crypto/octeontx: add asymmetric session operations

In reply to Anoob Joseph

From: Kanaka Durga Kotamarthy <[email protected]>

Add asymmetric session setup and free functions. RSA and modexp operations are supported.

---
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  10 +-
 drivers/common/cpt/cpt_mcode_defines.h             |   9 ++
 drivers/common/cpt/cpt_ucode_asym.h                | 171 +++++++++++++++++++++
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 +++++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_ops.c        |  71 ++++++++-
 7 files changed, 307 insertions(+), 12 deletions(-)
 create mode 100644 drivers/common/cpt/cpt_ucode_asym.h
doc/guides/cryptodevs/features/octeontx.ini +5 -1
index 1735b8f..1c036c5 100644
@@ -5,11 +5,13 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
+RSA PRIV OP KEY QT     = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx' crypto driver.
@@ -64,4 +66,6 @@ AES GCM (256) = Y
 ;
 ; Supported Asymmetric algorithms of the 'octeontx' crypto driver.
 ;
-[Asymmetric]
\ No newline at end of file
+[Asymmetric]
+RSA                    = Y
+Modular Exponentiation = Y
doc/guides/cryptodevs/octeontx.rst +8 -2
index 1600a56..8f8126b 100644
@@ -10,8 +10,8 @@ cryptographic operations to cryptographic accelerator units on
 poll mode driver enqueues the crypto request to this accelerator and dequeues
 the response once the operation is completed.
 
-Supported Algorithms
---------------------
+Supported Symmetric Crypto Algorithms
+-------------------------------------
 
 Cipher Algorithms
 ~~~~~~~~~~~~~~~~~
@@ -53,6 +53,12 @@ AEAD Algorithms
 
 * ``RTE_CRYPTO_AEAD_AES_GCM``
 
+Supported Asymmetric Crypto Algorithms
+--------------------------------------
+
+* ``RTE_CRYPTO_ASYM_XFORM_RSA``
+* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
+
 Config flags
 ------------
 
drivers/common/cpt/cpt_mcode_defines.h +9 -0
index b7c3feb..d5b3c59 100644
@@ -6,6 +6,7 @@
 #define _CPT_MCODE_DEFINES_H_
 
 #include <rte_byteorder.h>
+#include <rte_crypto_asym.h>
 #include <rte_memory.h>
 
 /*
@@ -314,6 +315,14 @@ struct cpt_ctx {
 	uint8_t  auth_key[64];
 };
 
+struct cpt_asym_sess_misc {
+	enum rte_crypto_asym_xform_type xfrm_type;
+	union {
+		struct rte_crypto_rsa_xform rsa_ctx;
+		struct rte_crypto_modex_xform mod_ctx;
+	};
+};
+
 /* Buffer pointer */
 typedef struct buf_ptr {
 	void *vaddr;
drivers/common/cpt/cpt_ucode_asym.h new file +171 -0

171 lines not on this page · raw message

drivers/crypto/octeontx/otx_cryptodev_capabilities.c +44 -3

59 lines not on this page · raw message

drivers/crypto/octeontx/otx_cryptodev_capabilities.h +2 -3
index fc62821..439b50e 100644
@@ -8,10 +8,9 @@
 #include <rte_cryptodev.h>
 
 /*
- * Get capabilities list for the device
- *
+ * Get capabilities list for the device, based on device type
  */
 const struct rte_cryptodev_capabilities *
-otx_get_capabilities(void);
+otx_get_capabilities(uint64_t flags);
 
 #endif /* _OTX_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/octeontx/otx_cryptodev_ops.c +68 -3

101 lines not on this page · raw message

Signature · 1 line
2.7.4
#24 lore raw

PATCH v2 3/5 common/cpt: add helper functions for asymmetric crypto

In reply to Anoob Joseph

From: Kanaka Durga Kotamarthy <[email protected]>

Add helper functions to get meta len for asymmetric operations

---
 drivers/common/cpt/cpt_pmd_ops_helper.c           | 15 +++++++++
 drivers/common/cpt/cpt_pmd_ops_helper.h           |  9 ++++++
 drivers/common/cpt/rte_common_cpt_version.map     |  8 +++++
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 39 ++++++++++++++++-------
 4 files changed, 60 insertions(+), 11 deletions(-)
drivers/common/cpt/cpt_pmd_ops_helper.c +15 -0
index 1c18180..09b762f 100644
@@ -11,6 +11,8 @@
 
 #define CPT_MAX_IV_LEN 16
 #define CPT_OFFSET_CONTROL_BYTES 8
+#define CPT_MAX_ASYM_OP_NUM_PARAMS 5
+#define CPT_MAX_ASYM_OP_MOD_LEN 1024
 
 int32_t
 cpt_pmd_ops_helper_get_mlen_direct_mode(void)
@@ -39,3 +41,16 @@ cpt_pmd_ops_helper_get_mlen_sg_mode(void)
 	len += 2 * sizeof(cpt_res_s_t);
 	return len;
 }
+
+int
+cpt_pmd_ops_helper_asym_get_mlen(void)
+{
+	uint32_t len;
+
+	/* Get meta len for linear buffer (direct) mode */
+	len = cpt_pmd_ops_helper_get_mlen_direct_mode();
+
+	/* Get meta len for asymmetric operations */
+	len += CPT_MAX_ASYM_OP_NUM_PARAMS * CPT_MAX_ASYM_OP_MOD_LEN;
+	return len;
+}
drivers/common/cpt/cpt_pmd_ops_helper.h +9 -0
index dd32f9a..24c3559 100644
@@ -31,4 +31,13 @@ cpt_pmd_ops_helper_get_mlen_direct_mode(void);
  */
 int
 cpt_pmd_ops_helper_get_mlen_sg_mode(void);
+
+/*
+ * Get size of meta buffer to be allocated for asymmetric crypto operations
+ *
+ * @return
+ *  - length
+ */
+int
+cpt_pmd_ops_helper_asym_get_mlen(void);
 #endif /* _CPT_PMD_OPS_HELPER_H_ */
drivers/common/cpt/rte_common_cpt_version.map +8 -0
index dec614f..382ec4b 100644
@@ -4,3 +4,11 @@ DPDK_18.11 {
 	cpt_pmd_ops_helper_get_mlen_direct_mode;
 	cpt_pmd_ops_helper_get_mlen_sg_mode;
 };
+
+DPDK_19.11 {
+	global:
+
+	cpt_pmd_ops_helper_asym_get_mlen;
+
+	local: *;
+};
drivers/crypto/octeontx/otx_cryptodev_hw_access.c +28 -11
index ad64bf4..ce546c2 100644
@@ -412,24 +412,41 @@ otx_cpt_metabuf_mempool_create(const struct rte_cryptodev *dev,
 			       int nb_elements)
 {
 	char mempool_name[RTE_MEMPOOL_NAMESIZE];
-	int sg_mlen, lb_mlen, max_mlen, ret;
 	struct cpt_qp_meta_info *meta_info;
 	struct rte_mempool *pool;
+	int max_mlen = 0;
+	int sg_mlen = 0;
+	int lb_mlen = 0;
+	int ret;
 
-	/* Get meta len for scatter gather mode */
-	sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
+	/*
+	 * Calculate metabuf length required. The 'crypto_octeontx' device
+	 * would be either SYMMETRIC or ASYMMETRIC.
+	 */
 
-	/* Extra 32B saved for future considerations */
-	sg_mlen += 4 * sizeof(uint64_t);
+	if (dev->feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) {
 
-	/* Get meta len for linear buffer (direct) mode */
-	lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
+		/* Get meta len for scatter gather mode */
+		sg_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode();
 
-	/* Extra 32B saved for future considerations */
-	lb_mlen += 4 * sizeof(uint64_t);
+		/* Extra 32B saved for future considerations */
+		sg_mlen += 4 * sizeof(uint64_t);
 
-	/* Check max requirement for meta buffer */
-	max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+		/* Get meta len for linear buffer (direct) mode */
+		lb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode();
+
+		/* Extra 32B saved for future considerations */
+		lb_mlen += 4 * sizeof(uint64_t);
+
+		/* Check max requirement for meta buffer */
+		max_mlen = RTE_MAX(lb_mlen, sg_mlen);
+	} else {
+
+		/* Asymmetric device */
+
+		/* Get meta len for asymmetric operations */
+		max_mlen = cpt_pmd_ops_helper_asym_get_mlen();
+	}
 
 	/* Allocate mempool */
 
Signature · 1 line
2.7.4
#25 lore raw

PATCH v2 4/5 crypto/octeontx: add asymmetric enqueue/dequeue ops

In reply to Anoob Joseph

From: Sunila Sahu <[email protected]>

Add asymmetric crypto op enqueue & dequeue routines

---
 drivers/common/cpt/cpt_common.h             |   1 +
 drivers/common/cpt/cpt_mcode_defines.h      |  20 ++
 drivers/common/cpt/cpt_ucode_asym.h         | 282 ++++++++++++++++++++++++++++
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 236 +++++++++++++++++++++--
 4 files changed, 522 insertions(+), 17 deletions(-)
drivers/common/cpt/cpt_common.h +1 -0
index 7ef6b29..dff45f0 100644
@@ -75,6 +75,7 @@ struct cpt_request_info {
 		uint64_t ei2;
 		uint64_t ei3;
 	} ist;
+	uint8_t *rptr;
 
 	/** Control path fields */
 	uint64_t time_out;
drivers/common/cpt/cpt_mcode_defines.h +20 -0
index d5b3c59..91d30a5 100644
@@ -21,6 +21,18 @@
 #define CPT_MAJOR_OP_KASUMI	0x38
 #define CPT_MAJOR_OP_MISC	0x01
 
+/* AE opcodes */
+#define CPT_MAJOR_OP_MODEX	0x03
+#define CPT_MINOR_OP_MODEX	0x01
+#define CPT_MINOR_OP_PKCS_ENC	0x02
+#define CPT_MINOR_OP_PKCS_ENC_CRT	0x03
+#define CPT_MINOR_OP_PKCS_DEC	0x04
+#define CPT_MINOR_OP_PKCS_DEC_CRT	0x05
+#define CPT_MINOR_OP_MODEX_CRT	0x06
+
+#define CPT_BLOCK_TYPE1 0
+#define CPT_BLOCK_TYPE2 1
+
 #define CPT_BYTE_16		16
 #define CPT_BYTE_24		24
 #define CPT_BYTE_32		32
@@ -367,6 +379,14 @@ typedef struct fc_params {
 } fc_params_t;
 
 /*
+ * Parameters for asymmetric operations
+ */
+struct asym_op_params {
+	struct cpt_request_info *req;
+	phys_addr_t meta_buf;
+};
+
+/*
  * Parameters for digest
  * generate requests
  * Only src_iov, op, ctx_buf, mac_buf, prep_req
drivers/common/cpt/cpt_ucode_asym.h +282 -0

292 lines not on this page · raw message

drivers/crypto/octeontx/otx_cryptodev_ops.c +219 -17

301 lines not on this page · raw message

Signature · 1 line
2.7.4
#26 lore raw

PATCH v2 5/5 app/test: register octeontx PMD to asym testsuite

In reply to Anoob Joseph

From: Sunila Sahu <[email protected]>

Updated asymmetric crypto unit-test application to test asymmetric crypto operations in octeontx PMD

---
 app/test/test_cryptodev_asym.c     | 31 +++++++++++++++++++++++++++++++
 doc/guides/cryptodevs/octeontx.rst | 19 +++++++++++++++++++
 2 files changed, 50 insertions(+)
app/test/test_cryptodev_asym.c +31 -0
index e8177e7..241c384 100644
@@ -1791,6 +1791,19 @@ static struct unit_test_suite cryptodev_qat_asym_testsuite  = {
 	}
 };
 
+static struct unit_test_suite cryptodev_octeontx_asym_testsuite  = {
+	.suite_name = "Crypto Device OCTEONTX ASYM Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup, ut_teardown, test_capability),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
 static int
 test_cryptodev_openssl_asym(void)
 {
@@ -1823,7 +1836,25 @@ test_cryptodev_qat_asym(void)
 	return unit_test_suite_runner(&cryptodev_qat_asym_testsuite);
 }
 
+static int
+test_cryptodev_octeontx_asym(void)
+{
+	gbl_driver_id = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
+				"enabled in config file to run this "
+				"testsuite.\n");
+		return TEST_FAILED;
+	}
+	return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_openssl_asym_autotest,
 					  test_cryptodev_openssl_asym);
 
 REGISTER_TEST_COMMAND(cryptodev_qat_asym_autotest, test_cryptodev_qat_asym);
+
+REGISTER_TEST_COMMAND(cryptodev_octeontx_asym_autotest,
+					  test_cryptodev_octeontx_asym);
doc/guides/cryptodevs/octeontx.rst +19 -0
index 8f8126b..4fa199e 100644
@@ -126,3 +126,22 @@ OCTEON TX crypto PMD.
 
         ./build/ipsec-secgw --log-level=8 -c 0xff -- -P -p 0x3 -u 0x2 --config
         "(1,0,0),(0,0,0)" -f ep1.cfg
+
+Testing
+-------
+
+The symmetric crypto operations on OCTEON TX crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_autotest
+
+The asymmetric crypto operations on OCTEON TX crypto PMD may be verified by running the test
+application:
+
+.. code-block:: console
+
+        ./test
+        RTE>>cryptodev_octeontx_asym_autotest
Signature · 1 line
2.7.4
#27 lore raw
In reply to Anoob Joseph

Hi Anoob,

I believe this should also be updated in the release notes. If yes, please reply to this mail with appropriate description. I will update it while merging.

Quoted 41 lines

This series adds asymmetric crypto support in 'crypto_octoentx' PMD.

Changes in v2:
* Squashed patches as directed by Akhil
* Split the doc patch and added documentation along with feature
* Added check for ASYM SESSIONLESS (not supported currently)
* Made separate enqueue & dequeue routines for sym & asym
* Minor updates to documentation

Kanaka Durga Kotamarthy (3):
crypto/octeontx: add device type mailbox routine crypto/octeontx: add asymmetric session operations common/cpt: add helper functions for asymmetric crypto

Sunila Sahu (2):
crypto/octeontx: add asymmetric enqueue/dequeue ops app/test: register octeontx PMD to asym testsuite

 app/test/test_cryptodev_asym.c                     |  31 ++
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  29 +-
 drivers/common/cpt/cpt_common.h                    |   4 +-
 drivers/common/cpt/cpt_mcode_defines.h             |  29 ++
 drivers/common/cpt/cpt_pmd_ops_helper.c            |  15 +
 drivers/common/cpt/cpt_pmd_ops_helper.h            |   9 +
 drivers/common/cpt/cpt_ucode_asym.h                | 453
+++++++++++++++++++++
 drivers/common/cpt/rte_common_cpt_version.map      |   8 +
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 ++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  51 ++-
 drivers/crypto/octeontx/otx_cryptodev_mbox.c       |  26 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.h       |  20 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c        | 338 +++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_ops.h        |   2 +
 16 files changed, 1016 insertions(+), 57 deletions(-)
 create mode 100644 drivers/common/cpt/cpt_ucode_asym.h

--
2.7.4

#28 lore raw
Quoted 9 lines

Hi Anoob,

I believe this should also be updated in the release notes. If yes, please reply to this mail with appropriate description. I will update it while merging.

Please send the release note update. I will squash the change with this patchset. Applied to dpdk-next-crypto

Thanks.

Quoted 41 lines
Quoted 41 lines

This series adds asymmetric crypto support in 'crypto_octoentx' PMD.

Changes in v2:
* Squashed patches as directed by Akhil
* Split the doc patch and added documentation along with feature
* Added check for ASYM SESSIONLESS (not supported currently)
* Made separate enqueue & dequeue routines for sym & asym
* Minor updates to documentation

Kanaka Durga Kotamarthy (3):
crypto/octeontx: add device type mailbox routine crypto/octeontx: add asymmetric session operations common/cpt: add helper functions for asymmetric crypto

Sunila Sahu (2):
crypto/octeontx: add asymmetric enqueue/dequeue ops app/test: register octeontx PMD to asym testsuite

 app/test/test_cryptodev_asym.c                     |  31 ++
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  29 +-
 drivers/common/cpt/cpt_common.h                    |   4 +-
 drivers/common/cpt/cpt_mcode_defines.h             |  29 ++
 drivers/common/cpt/cpt_pmd_ops_helper.c            |  15 +
 drivers/common/cpt/cpt_pmd_ops_helper.h            |   9 +
 drivers/common/cpt/cpt_ucode_asym.h                | 453
+++++++++++++++++++++
 drivers/common/cpt/rte_common_cpt_version.map      |   8 +
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 ++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  51 ++-
 drivers/crypto/octeontx/otx_cryptodev_mbox.c       |  26 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.h       |  20 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c        | 338 +++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_ops.h        |   2 +
 16 files changed, 1016 insertions(+), 57 deletions(-)
 create mode 100644 drivers/common/cpt/cpt_ucode_asym.h

--
2.7.4

#29 lore raw
In reply to Akhil Goyal

Hi Akhil

You can use the following description.

+* **Added asymmetric support to Marvell OCTEON TX crypto PMD.**
+
+ Added support for asymmetric operations in Marvell OCTEON TX cypto PMD. Supports RSA
+ and modexp operations.
+

Thanks,
Anoob

Quoted 62 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Tuesday, October 15, 2019 6:17 PM
To: Anoob Joseph <[email protected]>; Pablo de Lara <[email protected]>
Cc: Jerin Jacob Kollanukkaran <[email protected]>; Narayana Prasad Raju Athreya <[email protected]>; Kanaka Durga Kotamarthy <[email protected]>; Sunila Sahu <[email protected]>; Shally Verma <[email protected]>; Fiona Trahe <[email protected]>; [email protected]
Subject: [EXT] RE: [PATCH v2 0/5] add asym support in crypto_octeontx PMD

External Email

----------------------------------------------------------------------
Hi Anoob,

I believe this should also be updated in the release notes. If yes, please reply to this mail with appropriate description. I will update it while merging.

Quoted 41 lines

This series adds asymmetric crypto support in 'crypto_octoentx' PMD.

Changes in v2:
* Squashed patches as directed by Akhil
* Split the doc patch and added documentation along with feature
* Added check for ASYM SESSIONLESS (not supported currently)
* Made separate enqueue & dequeue routines for sym & asym
* Minor updates to documentation

Kanaka Durga Kotamarthy (3):
crypto/octeontx: add device type mailbox routine crypto/octeontx: add asymmetric session operations common/cpt: add helper functions for asymmetric crypto

Sunila Sahu (2):
crypto/octeontx: add asymmetric enqueue/dequeue ops app/test: register octeontx PMD to asym testsuite

 app/test/test_cryptodev_asym.c                     |  31 ++
 doc/guides/cryptodevs/features/octeontx.ini        |   6 +-
 doc/guides/cryptodevs/octeontx.rst                 |  29 +-
 drivers/common/cpt/cpt_common.h                    |   4 +-
 drivers/common/cpt/cpt_mcode_defines.h             |  29 ++
 drivers/common/cpt/cpt_pmd_ops_helper.c            |  15 +
 drivers/common/cpt/cpt_pmd_ops_helper.h            |   9 +
 drivers/common/cpt/cpt_ucode_asym.h                | 453
+++++++++++++++++++++
 drivers/common/cpt/rte_common_cpt_version.map      |   8 +
 .../crypto/octeontx/otx_cryptodev_capabilities.c   |  47 ++-
 .../crypto/octeontx/otx_cryptodev_capabilities.h   |   5 +-
 drivers/crypto/octeontx/otx_cryptodev_hw_access.c  |  51 ++-
 drivers/crypto/octeontx/otx_cryptodev_mbox.c       |  26 +-
 drivers/crypto/octeontx/otx_cryptodev_mbox.h       |  20 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c        | 338 +++++++++++++--
 drivers/crypto/octeontx/otx_cryptodev_ops.h        |   2 +
 16 files changed, 1016 insertions(+), 57 deletions(-)  create mode

100644 drivers/common/cpt/cpt_ucode_asym.h

--
2.7.4

#30 lore raw
Quoted 12 lines

Hi Akhil

You can use the following description.

(quoted diff) +3 -0
+* **Added asymmetric support to Marvell OCTEON TX crypto PMD.**
+
+  Added support for asymmetric operations in Marvell OCTEON TX cypto PMD.

Supports RSA

Review

Quoted 2 lines
(quoted diff) +2 -0
+  and modexp operations.
+

Updated with enq/deq patch.

Thanks.