Skip to contentSkip to conversation

improvements to OCTEON TX crypto PMDs

PATCH In review Anoob Joseph 2 participants 9 messages May 16, 2020 – May 18, 2020

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

cover improvements to OCTEON TX crypto PMDs

This series adds multiple optimizations and improvements to OCTEON TX crypto PMDs and OCTEON TX2 security support.

Ankur Dwivedi (2):
crypto/octeontx2: enable non-byte aligned data feature crypto/octeontx: enable non-byte aligned data feature

Anoob Joseph (3):
common/octeontx2: fix out of bounds access crypto/octeontx2: improve error handling in session configure crypto/octeontx: redesign sym sessionless code path

Tejasree Kondoj (1):
net/octeontx2: increase max packet length for Inline IPsec Rx

 doc/guides/cryptodevs/features/octeontx.ini   |   1 +
 doc/guides/cryptodevs/features/octeontx2.ini  |   1 +
 drivers/common/cpt/cpt_ucode.h                |  75 ---------
 drivers/common/octeontx2/otx2_sec_idev.c      |   4 +-
 drivers/crypto/octeontx/otx_cryptodev_ops.c   | 210 ++++++++++++++------------
 drivers/crypto/octeontx2/otx2_cryptodev.c     |   1 +
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c |  43 +++++-
 drivers/net/octeontx2/otx2_ethdev_sec.c       |   4 +-
 8 files changed, 160 insertions(+), 179 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/6 common/octeontx2: fix out of bounds access

Coverity issue: 354230, 354231

Fixes f44e71637755 ("net/octeontx2: add security session operations")
Fixes 3fe4d07d1678 ("crypto/octeontx2: enable CPT to share QP with ethdev")
---
 drivers/common/octeontx2/otx2_sec_idev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/common/octeontx2/otx2_sec_idev.c +2 -2
index 4e65ce2..6e9643c 100644
@@ -55,7 +55,7 @@ otx2_sec_idev_tx_cpt_qp_add(uint16_t port_id, struct otx2_cpt_qp *qp)
 	struct otx2_sec_idev_cfg *cfg;
 	int i, ret;
 
-	if (qp == NULL || port_id > OTX2_MAX_INLINE_PORTS)
+	if (qp == NULL || port_id >= OTX2_MAX_INLINE_PORTS)
 		return -EINVAL;
 
 	cfg = &sec_cfg[port_id];
@@ -126,7 +126,7 @@ otx2_sec_idev_tx_cpt_qp_get(uint16_t port_id, struct otx2_cpt_qp **qp)
 	uint16_t index;
 	int i, ret;
 
-	if (port_id > OTX2_MAX_INLINE_PORTS || qp == NULL)
+	if (port_id >= OTX2_MAX_INLINE_PORTS || qp == NULL)
 		return -EINVAL;
 
 	cfg = &sec_cfg[port_id];
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/6 net/octeontx2: increase max packet length for Inline IPsec Rx

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Update max packet length supported by Inline IPsec Rx to NIX_MAX_FRS

---
 drivers/net/octeontx2/otx2_ethdev_sec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/octeontx2/otx2_ethdev_sec.c +1 -3
index 3858218..5f6140f 100644
@@ -20,8 +20,6 @@
 #include "otx2_ipsec_fp.h"
 #include "otx2_sec_idev.h"
 
-#define ETH_SEC_MAX_PKT_LEN	1450
-
 #define AH_HDR_LEN	12
 #define AES_GCM_IV_LEN	8
 #define AES_GCM_MAC_LEN	16
@@ -745,7 +743,7 @@ eth_sec_ipsec_cfg(struct rte_eth_dev *eth_dev, uint8_t tt)
 
 	req->ipsec_cfg0.sa_pow2_size =
 			rte_log2_u32(sizeof(struct otx2_ipsec_fp_in_sa));
-	req->ipsec_cfg0.lenm1_max = ETH_SEC_MAX_PKT_LEN - 1;
+	req->ipsec_cfg0.lenm1_max = NIX_MAX_FRS - 1;
 
 	req->ipsec_cfg1.sa_idx_w = rte_log2_u32(dev->ipsec_in_max_spi);
 	req->ipsec_cfg1.sa_idx_max = dev->ipsec_in_max_spi - 1;
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/6 crypto/octeontx2: enable non-byte aligned data feature

In reply to Anoob Joseph

From: Ankur Dwivedi <[email protected]>

The OCTEON TX2 crypto PMD supports non-byte aligned data as input for SNOW and ZUC algos. Adding the same to the feature list.

---
 doc/guides/cryptodevs/features/octeontx2.ini | 1 +
 drivers/crypto/octeontx2/otx2_cryptodev.c    | 1 +
 2 files changed, 2 insertions(+)
doc/guides/cryptodevs/features/octeontx2.ini +1 -0
index e9ce26c..cdcaf70 100644
@@ -13,6 +13,7 @@ OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
 RSA PRIV OP KEY QT     = Y
 Symmetric sessionless  = Y
+Non-Byte aligned data  = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx2' crypto driver.
drivers/crypto/octeontx2/otx2_cryptodev.c +1 -0
index 7cda077..6ffbc2e 100644
@@ -104,6 +104,7 @@ otx2_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT |
+			     RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
 
 	return 0;
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/6 crypto/octeontx2: improve error handling in session configure

In reply to Anoob Joseph

Session configure should return -ENOTSUP in case of unsupported xform requests. Moving the validation of combinations out of cpt, as the feature support will not be same across OCTEON TX and OCTEON TX2.

---
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 43 +++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 5 deletions(-)
drivers/crypto/octeontx2/otx2_cryptodev_ops.c +38 -5
index 0ae04c5..ad292a0 100644
@@ -312,6 +312,41 @@ otx2_cpt_qp_destroy(const struct rte_cryptodev *dev, struct otx2_cpt_qp *qp)
 }
 
 static int
+sym_xform_verify(struct rte_crypto_sym_xform *xform)
+{
+	if (xform->next) {
+		if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
+		    xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
+		    xform->next->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
+			return -ENOTSUP;
+
+		if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
+		    xform->cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT &&
+		    xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH)
+			return -ENOTSUP;
+
+		if (xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
+		    xform->cipher.algo == RTE_CRYPTO_CIPHER_3DES_CBC &&
+		    xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
+		    xform->next->auth.algo == RTE_CRYPTO_AUTH_SHA1)
+			return -ENOTSUP;
+
+		if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
+		    xform->auth.algo == RTE_CRYPTO_AUTH_SHA1 &&
+		    xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER &&
+		    xform->next->cipher.algo == RTE_CRYPTO_CIPHER_3DES_CBC)
+			return -ENOTSUP;
+
+	} else {
+		if (xform->type == RTE_CRYPTO_SYM_XFORM_AUTH &&
+		    xform->auth.algo == RTE_CRYPTO_AUTH_NULL &&
+		    xform->auth.op == RTE_CRYPTO_AUTH_OP_VERIFY)
+			return -ENOTSUP;
+	}
+	return 0;
+}
+
+static int
 sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform,
 		      struct rte_cryptodev_sym_session *sess,
 		      struct rte_mempool *pool)
@@ -320,10 +355,9 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform,
 	void *priv;
 	int ret;
 
-	if (unlikely(cpt_is_algo_supported(xform))) {
-		CPT_LOG_ERR("Crypto xform not supported");
-		return -ENOTSUP;
-	}
+	ret = sym_xform_verify(xform);
+	if (unlikely(ret))
+		return ret;
 
 	if (unlikely(rte_mempool_get(pool, &priv))) {
 		CPT_LOG_ERR("Could not allocate session private data");
@@ -373,7 +407,6 @@ sym_session_configure(int driver_id, struct rte_crypto_sym_xform *xform,
 priv_put:
 	rte_mempool_put(pool, priv);
 
-	CPT_LOG_ERR("Crypto xform not supported");
 	return -ENOTSUP;
 }
 
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/6 crypto/octeontx: enable non-byte aligned data feature

In reply to Anoob Joseph

From: Ankur Dwivedi <[email protected]>

The OCTEON TX crypto PMD supports non-byte aligned data as input for SNOW and ZUC algos. Adding the same to the feature list.

---
 doc/guides/cryptodevs/features/octeontx.ini | 1 +
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 1 +
 2 files changed, 2 insertions(+)
doc/guides/cryptodevs/features/octeontx.ini +1 -0
index 4ce4ff1..09affb2 100644
@@ -13,6 +13,7 @@ OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
 RSA PRIV OP KEY QT     = Y
 Symmetric sessionless  = Y
+Non-Byte aligned data  = Y
 
 ;
 ; Supported crypto algorithms of 'octeontx' crypto driver.
drivers/crypto/octeontx/otx_cryptodev_ops.c +1 -0
index 3fbf5d5..7097499 100644
@@ -968,6 +968,7 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev)
 				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_NON_BYTE_ALIGNED_DATA |
 				RTE_CRYPTODEV_FF_SYM_SESSIONLESS;
 		break;
 	default:
Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/6 crypto/octeontx: redesign sym sessionless code path

In reply to Anoob Joseph

Cleanup sessionless code path and improve error handling.

---
 drivers/common/cpt/cpt_ucode.h              |  75 ----------
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 209 +++++++++++++++-------------
 2 files changed, 115 insertions(+), 169 deletions(-)
drivers/common/cpt/cpt_ucode.h +0 -75
index 0d3a01b..34ccd08 100644
@@ -22,38 +22,6 @@ static uint8_t zuc_d[32] = {
 	0x5E, 0x26, 0x3C, 0x4D, 0x78, 0x9A, 0x47, 0xAC
 };
 
-static __rte_always_inline int
-cpt_is_algo_supported(struct rte_crypto_sym_xform *xform)
-{
-	/*
-	 * Microcode only supports the following combination.
-	 * Encryption followed by authentication
-	 * Authentication followed by decryption
-	 */
-	if (xform->next) {
-		if ((xform->type == RTE_CRYPTO_SYM_XFORM_AUTH) &&
-		    (xform->next->type == RTE_CRYPTO_SYM_XFORM_CIPHER) &&
-		    (xform->next->cipher.op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)) {
-			/* Unsupported as of now by microcode */
-			CPT_LOG_DP_ERR("Unsupported combination");
-			return -1;
-		}
-		if ((xform->type == RTE_CRYPTO_SYM_XFORM_CIPHER) &&
-		    (xform->next->type == RTE_CRYPTO_SYM_XFORM_AUTH) &&
-		    (xform->cipher.op == RTE_CRYPTO_CIPHER_OP_DECRYPT)) {
-			/* For GMAC auth there is no cipher operation */
-			if (xform->aead.algo != RTE_CRYPTO_AEAD_AES_GCM ||
-			    xform->next->auth.algo !=
-			    RTE_CRYPTO_AUTH_AES_GMAC) {
-				/* Unsupported as of now by microcode */
-				CPT_LOG_DP_ERR("Unsupported combination");
-				return -1;
-			}
-		}
-	}
-	return 0;
-}
-
 static __rte_always_inline void
 gen_key_snow3g(const uint8_t *ck, uint32_t *keyx)
 {
@@ -3333,49 +3301,6 @@ compl_auth_verify(struct rte_crypto_op *op,
 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 }
 
-static __rte_always_inline int
-instance_session_cfg(struct rte_crypto_sym_xform *xform, void *sess)
-{
-	struct rte_crypto_sym_xform *chain;
-
-	CPT_PMD_INIT_FUNC_TRACE();
-
-	if (cpt_is_algo_supported(xform))
-		goto err;
-
-	chain = xform;
-	while (chain) {
-		switch (chain->type) {
-		case RTE_CRYPTO_SYM_XFORM_AEAD:
-			if (fill_sess_aead(chain, sess))
-				goto err;
-			break;
-		case RTE_CRYPTO_SYM_XFORM_CIPHER:
-			if (fill_sess_cipher(chain, sess))
-				goto err;
-			break;
-		case RTE_CRYPTO_SYM_XFORM_AUTH:
-			if (chain->auth.algo == RTE_CRYPTO_AUTH_AES_GMAC) {
-				if (fill_sess_gmac(chain, sess))
-					goto err;
-			} else {
-				if (fill_sess_auth(chain, sess))
-					goto err;
-			}
-			break;
-		default:
-			CPT_LOG_DP_ERR("Invalid crypto xform type");
-			break;
-		}
-		chain = chain->next;
-	}
-
-	return 0;
-
-err:
-	return -1;
-}
-
 static __rte_always_inline void
 find_kasumif9_direction_and_length(uint8_t *src,
 				   uint32_t counter_num_bytes,
drivers/crypto/octeontx/otx_cryptodev_ops.c +115 -94

263 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw
In reply to Anoob Joseph

Hi Anoob,

This patch series is pretty late for the RC3, specially your last patch. However the patches looks good to me, I have applied them to dpdk-next-crypto with some modifications in the commit titles and descriptions.

Please send the fixes a bit earlier from next time.

Regards,
Akhil

Quoted 30 lines

This series adds multiple optimizations and improvements to OCTEON TX crypto PMDs
and OCTEON TX2 security support.

Ankur Dwivedi (2):
crypto/octeontx2: enable non-byte aligned data feature crypto/octeontx: enable non-byte aligned data feature

Anoob Joseph (3):
common/octeontx2: fix out of bounds access crypto/octeontx2: improve error handling in session configure crypto/octeontx: redesign sym sessionless code path

Tejasree Kondoj (1):
net/octeontx2: increase max packet length for Inline IPsec Rx

 doc/guides/cryptodevs/features/octeontx.ini   |   1 +
 doc/guides/cryptodevs/features/octeontx2.ini  |   1 +
 drivers/common/cpt/cpt_ucode.h                |  75 ---------
 drivers/common/octeontx2/otx2_sec_idev.c      |   4 +-
 drivers/crypto/octeontx/otx_cryptodev_ops.c   | 210 ++++++++++++++-----------
-
 drivers/crypto/octeontx2/otx2_cryptodev.c     |   1 +
 drivers/crypto/octeontx2/otx2_cryptodev_ops.c |  43 +++++-
 drivers/net/octeontx2/otx2_ethdev_sec.c       |   4 +-
 8 files changed, 160 insertions(+), 179 deletions(-)

--
2.7.4

#8 lore raw

Hi Akhil,

Quoted 8 lines

Hi Anoob,

This patch series is pretty late for the RC3, specially your last patch. However the patches looks good to me, I have applied them to dpdk-next- crypto with some modifications in the commit titles and descriptions.

Please send the fixes a bit earlier from next time.

[Anoob] Sure. The rework of the test application etc mandated the changes in the PMD. I wanted to send one series with all the changes from our end (in the PMD) rather than sending multiple patches. Next time, will try to send before RC2. Hope that would do.

Thanks,
Anoob