Skip to contentSkip to conversation

Add rte_security in crypto_cn10k PMD

PATCH Superseded Anoob Joseph 2 participants 24 messages Jun 2, 2021 – Jun 29, 2021

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

cover Add rte_security in crypto_cn10k PMD

Add rte_security (lookaside protocol - IPsec) support in crypto_cn10k.

IPsec operations can be offloaded to CPT's SE and IE engines, which can process IPsec protcol operations including atomic sequence number increment (for outbound operations) and anti replay window check (for inbound operations).

Depends-on: series-17212 ("Add CPT in Marvell CNXK common driver")
Depends-on: series-17213 ("Add Marvell CNXK crypto PMDs")

Anoob Joseph (1):
crypto/cnxk: add security capabilities

Srujana Challa (1):
crypto/cnxk: add security ctx skeleton

Tejasree Kondoj (2):
crypto/cnxk: add security session ops crypto/cnxk: add security handling in datapath ops

 drivers/crypto/cnxk/cn10k_cryptodev.c             |  12 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c         |  78 +++-
 drivers/crypto/cnxk/cn10k_ipsec.c                 | 520 ++++++++++++++++++++++
 drivers/crypto/cnxk/cn10k_ipsec.h                 |  38 ++
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h          |  74 +++
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   4 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 114 +++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   9 +-
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c          |  48 ++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h          |  14 +
 drivers/crypto/cnxk/cnxk_ipsec.h                  |  18 +
 drivers/crypto/cnxk/meson.build                   |   4 +-
 12 files changed, 930 insertions(+), 3 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ipsec.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 crypto/cnxk: add security ctx skeleton

From: Srujana Challa <[email protected]>

Add security ctx in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c    | 10 +++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c | 47 ++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h | 14 ++++++++++
 drivers/crypto/cnxk/meson.build          |  3 +-
 4 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +10 -0
index ca3adea..b58d390 100644
@@ -14,6 +14,7 @@
 #include "cn10k_cryptodev_ops.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
+#include "cnxk_cryptodev_sec.h"
 
 #include "roc_api.h"
 
@@ -75,6 +76,11 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			plt_err("Failed to add engine group rc=%d", rc);
 			goto dev_fini;
 		}
+
+		/* Create security context */
+		rc = cnxk_crypto_sec_ctx_create(dev);
+		if (rc)
+			goto dev_fini;
 	}
 
 	cnxk_cpt_caps_populate(vf);
@@ -87,6 +93,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
+			     RTE_CRYPTODEV_FF_SECURITY |
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
@@ -121,6 +128,9 @@ cn10k_cpt_pci_remove(struct rte_pci_device *pci_dev)
 	if (dev == NULL)
 		return -ENODEV;
 
+	/* Destroy security context */
+	cnxk_crypto_sec_ctx_destroy(dev);
+
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		vf = dev->data->dev_private;
 		ret = roc_cpt_dev_fini(&vf->cpt);
drivers/crypto/cnxk/cnxk_cryptodev_sec.c new file +47 -0

47 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_sec.h new file +14 -0
new file mode 100644
index 0000000..9ab0e9e
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CNXK_CRYPTODEV_SEC_H__
+#define __CNXK_CRYPTODEV_SEC_H__
+
+#include <rte_cryptodev.h>
+
+int cnxk_crypto_sec_ctx_create(struct rte_cryptodev *crypto_dev);
+
+void cnxk_crypto_sec_ctx_destroy(struct rte_cryptodev *crypto_dev);
+
+#endif /* __CNXK_CRYPTODEV_SEC_H__ */
drivers/crypto/cnxk/meson.build +2 -1
index b0aa3c0..ab45483 100644
@@ -17,6 +17,7 @@ sources = files(
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
+        'cnxk_cryptodev_sec.c',
 )
 
-deps += ['bus_pci', 'common_cnxk']
+deps += ['bus_pci', 'common_cnxk', 'security']
Signature · 1 line
2.7.4
#2 lore raw

Re: [dpdk-dev] [PATCH 1/4] crypto/cnxk: add security ctx skeleton

Quoted 44 lines

From: Srujana Challa <[email protected]>

Add security ctx in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c    | 10 +++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c | 47
++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h | 14 ++++++++++
 drivers/crypto/cnxk/meson.build          |  3 +-
 4 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +6 -0
index ca3adea..b58d390 100644
@@ -14,6 +14,7 @@
 #include "cn10k_cryptodev_ops.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
+#include "cnxk_cryptodev_sec.h"
 
 #include "roc_api.h"
 
@@ -75,6 +76,11 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv
 __rte_unused,
 			plt_err("Failed to add engine group rc=%d", rc);
 			goto dev_fini;
 		}
+
+		/* Create security context */
+		rc = cnxk_crypto_sec_ctx_create(dev);
+		if (rc)
+			goto dev_fini;
 	}
 
drivers/crypto/cnxk/cn10k_cryptodev.c +0 -0
 	cnxk_cpt_caps_populate(vf);

drivers/crypto/cnxk/cn10k_cryptodev.c cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv · line 98

Quoted 6 lines
drivers/crypto/cnxk/cn10k_cryptodev.c +1 -0
@@ -87,6 +93,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv
 __rte_unused,
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
+			     RTE_CRYPTODEV_FF_SECURITY |
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;

Corresponding change in .ini file missing. Moreover, you should add it in Last patch of this series when your feature is complete.
Both feature flag and documentation in .ini should be in same patch.

#3 lore raw

v2 cover Add rte_security in crypto_cn10k PMD

In reply to Anoob Joseph

Add rte_security (lookaside protocol - IPsec) support in crypto_cn10k.

IPsec operations can be offloaded to CPT's SE and IE engines, which can process IPsec protcol operations including atomic sequence number increment (for outbound operations) and anti replay window check (for inbound operations).

Depends-on: series-17482 ("Add CPT in Marvell CNXK common driver")
Depends-on: series-17483 ("Add Marvell CNXK crypto PMDs")

Changes in v2:
- Rearranged capability additions & feature flag updates as suggested by Akhil
- Rebased on v2 of dependant series

Anoob Joseph (1):
crypto/cnxk: add security capabilities

Srujana Challa (1):
crypto/cnxk: add security ctx skeleton

Tejasree Kondoj (2):
crypto/cnxk: add security session ops crypto/cnxk: add security handling in datapath ops

 doc/guides/cryptodevs/cnxk.rst                    |  24 ++
 doc/guides/cryptodevs/features/cn10k.ini          |   1 +
 drivers/crypto/cnxk/cn10k_cryptodev.c             |  12 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c         |  78 +++++-
 drivers/crypto/cnxk/cn10k_ipsec.c                 | 275 ++++++++++++++++++++++
 drivers/crypto/cnxk/cn10k_ipsec.h                 |  36 +++
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h          |  74 ++++++
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   4 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 114 +++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   9 +-
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c          |  48 ++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h          |  14 ++
 drivers/crypto/cnxk/cnxk_ipsec.h                  |  20 ++
 drivers/crypto/cnxk/meson.build                   |   6 +-
 14 files changed, 712 insertions(+), 3 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ipsec.h
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 1/4 crypto/cnxk: add security ctx skeleton

From: Srujana Challa <[email protected]>

Add security ctx in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c    |  9 ++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c | 47 ++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h | 14 ++++++++++
 drivers/crypto/cnxk/meson.build          |  3 +-
 4 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +9 -0
index 559aaef..ffe654c 100644
@@ -14,6 +14,7 @@
 #include "cn10k_cryptodev_ops.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
+#include "cnxk_cryptodev_sec.h"
 
 #include "roc_api.h"
 
@@ -77,6 +78,11 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			plt_err("Failed to add engine group rc=%d", rc);
 			goto dev_fini;
 		}
+
+		/* Create security context */
+		rc = cnxk_crypto_sec_ctx_create(dev);
+		if (rc)
+			goto dev_fini;
 	}
 
 	cnxk_cpt_caps_populate(vf);
@@ -126,6 +132,9 @@ cn10k_cpt_pci_remove(struct rte_pci_device *pci_dev)
 	if (dev == NULL)
 		return -ENODEV;
 
+	/* Destroy security context */
+	cnxk_crypto_sec_ctx_destroy(dev);
+
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		vf = dev->data->dev_private;
 		ret = roc_cpt_dev_fini(&vf->cpt);
drivers/crypto/cnxk/cnxk_cryptodev_sec.c new file +47 -0

47 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_sec.h new file +14 -0
new file mode 100644
index 0000000..9ab0e9e
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CNXK_CRYPTODEV_SEC_H__
+#define __CNXK_CRYPTODEV_SEC_H__
+
+#include <rte_cryptodev.h>
+
+int cnxk_crypto_sec_ctx_create(struct rte_cryptodev *crypto_dev);
+
+void cnxk_crypto_sec_ctx_destroy(struct rte_cryptodev *crypto_dev);
+
+#endif /* __CNXK_CRYPTODEV_SEC_H__ */
drivers/crypto/cnxk/meson.build +2 -1
index fa6be06..a2b461e 100644
@@ -16,6 +16,7 @@ sources = files(
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
+        'cnxk_cryptodev_sec.c',
 )
 
-deps += ['bus_pci', 'common_cnxk']
+deps += ['bus_pci', 'common_cnxk', 'security']
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 2/4 crypto/cnxk: add security session ops

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add security session ops in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c |   2 +
 drivers/crypto/cnxk/cn10k_ipsec.c     | 275 ++++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cn10k_ipsec.h     |  36 +++++
 drivers/crypto/cnxk/cnxk_ipsec.h      |  20 +++
 drivers/crypto/cnxk/meson.build       |   3 +
 5 files changed, 336 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ipsec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +2 -0
index ffe654c..cacf9c2 100644
@@ -12,6 +12,7 @@
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cn10k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
@@ -101,6 +102,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
+	cn10k_sec_ops_override();
 
 	return 0;
 
drivers/crypto/cnxk/cn10k_ipsec.c new file +275 -0

275 lines not on this page · raw message

drivers/crypto/cnxk/cn10k_ipsec.h new file +36 -0
new file mode 100644
index 0000000..668282f
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CN10K_IPSEC_H__
+#define __CN10K_IPSEC_H__
+
+#include <rte_security.h>
+
+#include "cnxk_ipsec.h"
+
+#define CN10K_IPSEC_SA_CTX_HDR_SIZE 1
+
+struct cn10k_ipsec_sa {
+	union {
+		/** Inbound SA */
+		struct roc_ot_ipsec_inb_sa in_sa;
+		/** Outbound SA */
+		struct roc_ot_ipsec_outb_sa out_sa;
+	};
+	/** Pre-populated CPT inst words */
+	struct cnxk_cpt_inst_tmpl inst;
+	uint8_t partial_len;
+	uint8_t roundup_len;
+	uint8_t roundup_byte;
+};
+
+struct cn10k_sec_session {
+	struct cn10k_ipsec_sa sa;
+	void *userdata;
+	/**< Userdata registered by the application */
+} __rte_cache_aligned;
+
+void cn10k_sec_ops_override(void);
+
+#endif /* __CN10K_IPSEC_H__ */
drivers/crypto/cnxk/cnxk_ipsec.h new file +20 -0
new file mode 100644
index 0000000..f6897a0
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+#ifndef __CNXK_IPSEC_H__
+#define __CNXK_IPSEC_H__
+
+#include <rte_security.h>
+#include <rte_security_driver.h>
+
+#include "roc_api.h"
+
+extern struct rte_security_ops cnxk_sec_ops;
+
+struct cnxk_cpt_inst_tmpl {
+	uint64_t w2;
+	uint64_t w4;
+	uint64_t w7;
+};
+
+#endif /* __CNXK_IPSEC_H__ */
drivers/crypto/cnxk/meson.build +3 -0
index a2b461e..c56d6cf 100644
@@ -13,6 +13,7 @@ sources = files(
         'cn9k_cryptodev_ops.c',
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
+        'cn10k_ipsec.c',
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
@@ -20,3 +21,5 @@ sources = files(
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security']
+
+includes += include_directories('../../../lib/net')
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 3/4 crypto/cnxk: add security handling in datapath ops

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add security handling in enqueue dequeue ops.

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 78 ++++++++++++++++++++++++++++++-
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h  | 74 +++++++++++++++++++++++++++++
 2 files changed, 151 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +77 -1
index 6207627..29525cd 100644
@@ -4,9 +4,12 @@
 
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
+#include <rte_ip.h>
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cn10k_ipsec_la_ops.h"
+#include "cn10k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
 #include "cnxk_se.h"
@@ -42,6 +45,38 @@ cn10k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op)
 }
 
 static __rte_always_inline int __rte_hot
+cpt_sec_inst_fill(struct rte_crypto_op *op, struct cn10k_sec_session *sess,
+		  struct cpt_inflight_req *infl_req, struct cpt_inst_s *inst)
+{
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	union roc_ot_ipsec_sa_word2 *w2;
+	struct cn10k_ipsec_sa *sa;
+	int ret;
+
+	if (unlikely(sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {
+		plt_dp_err("Out of place is not supported");
+		return -ENOTSUP;
+	}
+
+	if (unlikely(!rte_pktmbuf_is_contiguous(sym_op->m_src))) {
+		plt_dp_err("Scatter Gather mode is not supported");
+		return -ENOTSUP;
+	}
+
+	sa = &sess->sa;
+	w2 = (union roc_ot_ipsec_sa_word2 *)&sa->in_sa.w2;
+
+	if (w2->s.dir == ROC_IE_OT_SA_DIR_OUTBOUND)
+		ret = process_outb_sa(op, sa, inst);
+	else {
+		infl_req->op_flags |= CPT_OP_FLAGS_IPSEC_DIR_INBOUND;
+		ret = process_inb_sa(op, sa, inst);
+	}
+
+	return ret;
+}
+
+static __rte_always_inline int __rte_hot
 cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		  struct cnxk_se_sess *sess, struct cpt_inflight_req *infl_req,
 		  struct cpt_inst_s *inst)
@@ -64,6 +99,7 @@ static inline int
 cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 		    struct cpt_inst_s inst[], struct cpt_inflight_req *infl_req)
 {
+	struct cn10k_sec_session *sec_sess;
 	struct rte_crypto_sym_op *sym_op;
 	struct cnxk_se_sess *sess;
 	struct rte_crypto_op *op;
@@ -79,7 +115,15 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 	sym_op = op->sym;
 
 	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
-		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			sec_sess = get_sec_session_private_data(
+				sym_op->sec_session);
+			ret = cpt_sec_inst_fill(op, sec_sess, infl_req,
+						&inst[0]);
+			if (unlikely(ret))
+				return 0;
+			w7 = sec_sess->sa.inst.w7;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sess = get_sym_session_private_data(
 				sym_op->session, cn10k_cryptodev_driver_id);
 			ret = cpt_sym_inst_fill(qp, op, sess, infl_req,
@@ -196,6 +240,34 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 }
 
 static inline void
+cn10k_cpt_sec_post_process(struct rte_crypto_op *cop,
+			   struct cpt_inflight_req *infl_req)
+{
+	struct rte_crypto_sym_op *sym_op = cop->sym;
+	struct rte_mbuf *m = sym_op->m_src;
+	struct rte_ipv6_hdr *ip6;
+	struct rte_ipv4_hdr *ip;
+	uint16_t m_len;
+
+	if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) {
+		ip = (struct rte_ipv4_hdr *)rte_pktmbuf_mtod(m, char *);
+
+		if (((ip->version_ihl & 0xf0) >> RTE_IPV4_IHL_MULTIPLIER) ==
+		    IPVERSION) {
+			m_len = rte_be_to_cpu_16(ip->total_length);
+		} else {
+			PLT_ASSERT(((ip->version_ihl & 0xf0) >>
+				    RTE_IPV4_IHL_MULTIPLIER) == IPV6_VERSION);
+			ip6 = (struct rte_ipv6_hdr *)ip;
+			m_len = rte_be_to_cpu_16(ip6->payload_len) +
+				sizeof(struct rte_ipv6_hdr);
+		}
+		m->data_len = m_len;
+		m->pkt_len = m_len;
+	}
+}
+
+static inline void
 cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 			       struct rte_crypto_op *cop,
 			       struct cpt_inflight_req *infl_req)
@@ -219,6 +291,10 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 
 		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+				cn10k_cpt_sec_post_process(cop, infl_req);
+				return;
+			}
 
 			/* Verify authentication data if required */
 			if (unlikely(infl_req->op_flags &
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.7.4
#7 lore raw

PATCH v2 4/4 crypto/cnxk: add security capabilities

In reply to Anoob Joseph

Add security capabilities supported by crypto cn10k PMD.

---
 doc/guides/cryptodevs/cnxk.rst                    |  24 +++++
 doc/guides/cryptodevs/features/cn10k.ini          |   1 +
 drivers/crypto/cnxk/cn10k_cryptodev.c             |   1 +
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   4 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 114 ++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   9 +-
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c          |   3 +-
 7 files changed, 154 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/cnxk.rst +24 -0
index 66b0b63..db949fa 100644
@@ -185,6 +185,30 @@ running the test application:
     ./dpdk-test
     RTE>>cryptodev_cn10k_autotest
 
+Lookaside IPsec Support
+-----------------------
+
+The OCTEON cnxk SoCs can accelerate IPsec traffic in lookaside protocol mode,
+with its **cryptographic accelerator (CPT)**. ``OCTEON cnxk crypto PMD`` implements
+this as an ``RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL`` offload.
+
+Refer to :doc:`../prog_guide/rte_security` for more details on protocol offloads.
+
+This feature can be tested with ipsec-secgw sample application.
+
+Supported OCTEON cnxk SoCs
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+- CN10XX
+
+Features supported
+~~~~~~~~~~~~~~~~~~
+
+* IPv4
+* ESP
+* Tunnel mode
+* AES-128/192/256-GCM
+
 Limitations
 -----------
 
doc/guides/cryptodevs/features/cn10k.ini +1 -0
index 77c4a2d..b268f84 100644
@@ -7,6 +7,7 @@
 Symmetric crypto       = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
+Protocol offload       = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
drivers/crypto/cnxk/cn10k_cryptodev.c +1 -0
index cacf9c2..22ae810 100644
@@ -99,6 +99,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
+			     RTE_CRYPTODEV_FF_SECURITY |
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
drivers/crypto/cnxk/cnxk_cryptodev.h +4 -0
index 03af4af..6760c13 100644
@@ -6,6 +6,7 @@
 #define _CNXK_CRYPTODEV_H_
 
 #include <rte_cryptodev.h>
+#include <rte_security.h>
 
 #include "roc_cpt.h"
 
@@ -19,6 +20,9 @@
 struct cnxk_cpt_vf {
 	struct roc_cpt cpt;
 	struct rte_cryptodev_capabilities crypto_caps[CNXK_CPT_MAX_CAPS];
+	struct rte_cryptodev_capabilities
+		sec_crypto_caps[CNXK_SEC_CRYPTO_MAX_CAPS];
+	struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
 };
 
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +114 -0

140 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h +8 -1
index 85f5ad2..fe07e43 100644
@@ -10,7 +10,7 @@
 #include "cnxk_cryptodev.h"
 
 /*
- * Initialize crypto capabilities for the device
+ * Initialize crypto and IPsec capabilities for the device
  *
  */
 void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
@@ -22,4 +22,11 @@ void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
 const struct rte_cryptodev_capabilities *
 cnxk_crypto_capabilities_get(struct cnxk_cpt_vf *vf);
 
+/*
+ * Get security capabilities list for the device
+ *
+ */
+const struct rte_security_capability *
+cnxk_crypto_sec_capabilities_get(void *device);
+
 #endif /* _CNXK_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/cnxk/cnxk_cryptodev_sec.c +2 -1
index f03d2ed..8d04d4b 100644
@@ -7,6 +7,7 @@
 #include <rte_security.h>
 #include <rte_security_driver.h>
 
+#include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
 
 /* Common security ops */
@@ -16,7 +17,7 @@ struct rte_security_ops cnxk_sec_ops = {
 	.session_get_size = NULL,
 	.set_pkt_metadata = NULL,
 	.get_userdata = NULL,
-	.capabilities_get = NULL,
+	.capabilities_get = cnxk_crypto_sec_capabilities_get
 };
 
 int
Signature · 1 line
2.7.4
#8 lore raw

v3 cover Add lookaside IPsec and asymmetric in cnxk crypto PMDs

In reply to Anoob Joseph

Add rte_security (lookaside protocol - IPsec) support in crypto_cn10k.

IPsec operations can be offloaded to CPT's SE and IE engines, which can process IPsec protcol operations including atomic sequence number increment (for outbound operations) and anti replay window check (for inbound operations).

Add support for asymmetric operations in crypto cnxk PMDs. Following operations are supported,
- RSA
- DSA
- ECDSA
- ECPM
- Modular Exponentation

Anoob Joseph (2):
crypto/cnxk: add security capabilities
crypto/cnxk: add asymmetric capabilities

Kiran Kumar K (3):
crypto/cnxk: add asymmetric session ops
crypto/cnxk: add asymmetric datapath ops
test/crypto: add cnxk for asymmetric cases

Srujana Challa (1):
crypto/cnxk: add security ctx skeleton

Tejasree Kondoj (2):
crypto/cnxk: add security session ops crypto/cnxk: add security handling in datapath ops

Changes in v3:
- Rebased on dpdk-next-crypto ToT
- Merged asymmetric & lookaside IPsec series

Changes in v2:
- Added documentation
- Added asymmetric capabilities as separate patch

 app/test/test_cryptodev_asym.c                    |  30 +
 doc/guides/cryptodevs/cnxk.rst                    |  47 ++
 doc/guides/cryptodevs/features/cn10k.ini          |  14 +
 doc/guides/cryptodevs/features/cn9k.ini           |  13 +
 doc/guides/rel_notes/release_21_08.rst            |   4 +
 drivers/crypto/cnxk/cn10k_cryptodev.c             |  14 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c         | 111 ++-
 drivers/crypto/cnxk/cn10k_ipsec.c                 | 275 +++++++
 drivers/crypto/cnxk/cn10k_ipsec.h                 |  36 +
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h          |  74 ++
 drivers/crypto/cnxk/cn9k_cryptodev.c              |   4 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c          |  35 +-
 drivers/crypto/cnxk/cnxk_ae.h                     | 836 ++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   8 +-
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 170 +++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   9 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c          | 106 +++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h          |   8 +
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c          |  48 ++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h          |  14 +
 drivers/crypto/cnxk/cnxk_ipsec.h                  |  20 +
 drivers/crypto/cnxk/meson.build                   |   6 +-
 22 files changed, 1869 insertions(+), 13 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ae.h
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ipsec.h
Signature · 1 line
2.7.4
#9 lore raw

PATCH v3 1/8 crypto/cnxk: add security ctx skeleton

From: Srujana Challa <[email protected]>

Add security ctx in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c    |  9 ++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c | 47 ++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_sec.h | 14 ++++++++++
 drivers/crypto/cnxk/meson.build          |  3 +-
 4 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.c
 create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_sec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +9 -0
index 559aaef..ffe654c 100644
@@ -14,6 +14,7 @@
 #include "cn10k_cryptodev_ops.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
+#include "cnxk_cryptodev_sec.h"
 
 #include "roc_api.h"
 
@@ -77,6 +78,11 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			plt_err("Failed to add engine group rc=%d", rc);
 			goto dev_fini;
 		}
+
+		/* Create security context */
+		rc = cnxk_crypto_sec_ctx_create(dev);
+		if (rc)
+			goto dev_fini;
 	}
 
 	cnxk_cpt_caps_populate(vf);
@@ -126,6 +132,9 @@ cn10k_cpt_pci_remove(struct rte_pci_device *pci_dev)
 	if (dev == NULL)
 		return -ENODEV;
 
+	/* Destroy security context */
+	cnxk_crypto_sec_ctx_destroy(dev);
+
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		vf = dev->data->dev_private;
 		ret = roc_cpt_dev_fini(&vf->cpt);
drivers/crypto/cnxk/cnxk_cryptodev_sec.c new file +47 -0

47 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_sec.h new file +14 -0
new file mode 100644
index 0000000..9ab0e9e
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CNXK_CRYPTODEV_SEC_H__
+#define __CNXK_CRYPTODEV_SEC_H__
+
+#include <rte_cryptodev.h>
+
+int cnxk_crypto_sec_ctx_create(struct rte_cryptodev *crypto_dev);
+
+void cnxk_crypto_sec_ctx_destroy(struct rte_cryptodev *crypto_dev);
+
+#endif /* __CNXK_CRYPTODEV_SEC_H__ */
drivers/crypto/cnxk/meson.build +2 -1
index fa6be06..a2b461e 100644
@@ -16,6 +16,7 @@ sources = files(
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
+        'cnxk_cryptodev_sec.c',
 )
 
-deps += ['bus_pci', 'common_cnxk']
+deps += ['bus_pci', 'common_cnxk', 'security']
Signature · 1 line
2.7.4
#10 lore raw

PATCH v3 2/8 crypto/cnxk: add security session ops

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add security session ops in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c |   2 +
 drivers/crypto/cnxk/cn10k_ipsec.c     | 275 ++++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cn10k_ipsec.h     |  36 +++++
 drivers/crypto/cnxk/cnxk_ipsec.h      |  20 +++
 drivers/crypto/cnxk/meson.build       |   3 +
 5 files changed, 336 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ipsec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +2 -0
index ffe654c..cacf9c2 100644
@@ -12,6 +12,7 @@
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cn10k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
@@ -101,6 +102,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
+	cn10k_sec_ops_override();
 
 	return 0;
 
drivers/crypto/cnxk/cn10k_ipsec.c new file +275 -0

275 lines not on this page · raw message

drivers/crypto/cnxk/cn10k_ipsec.h new file +36 -0
new file mode 100644
index 0000000..668282f
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CN10K_IPSEC_H__
+#define __CN10K_IPSEC_H__
+
+#include <rte_security.h>
+
+#include "cnxk_ipsec.h"
+
+#define CN10K_IPSEC_SA_CTX_HDR_SIZE 1
+
+struct cn10k_ipsec_sa {
+	union {
+		/** Inbound SA */
+		struct roc_ot_ipsec_inb_sa in_sa;
+		/** Outbound SA */
+		struct roc_ot_ipsec_outb_sa out_sa;
+	};
+	/** Pre-populated CPT inst words */
+	struct cnxk_cpt_inst_tmpl inst;
+	uint8_t partial_len;
+	uint8_t roundup_len;
+	uint8_t roundup_byte;
+};
+
+struct cn10k_sec_session {
+	struct cn10k_ipsec_sa sa;
+	void *userdata;
+	/**< Userdata registered by the application */
+} __rte_cache_aligned;
+
+void cn10k_sec_ops_override(void);
+
+#endif /* __CN10K_IPSEC_H__ */
drivers/crypto/cnxk/cnxk_ipsec.h new file +20 -0
new file mode 100644
index 0000000..f6897a0
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+#ifndef __CNXK_IPSEC_H__
+#define __CNXK_IPSEC_H__
+
+#include <rte_security.h>
+#include <rte_security_driver.h>
+
+#include "roc_api.h"
+
+extern struct rte_security_ops cnxk_sec_ops;
+
+struct cnxk_cpt_inst_tmpl {
+	uint64_t w2;
+	uint64_t w4;
+	uint64_t w7;
+};
+
+#endif /* __CNXK_IPSEC_H__ */
drivers/crypto/cnxk/meson.build +3 -0
index a2b461e..c56d6cf 100644
@@ -13,6 +13,7 @@ sources = files(
         'cn9k_cryptodev_ops.c',
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
+        'cn10k_ipsec.c',
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
         'cnxk_cryptodev_ops.c',
@@ -20,3 +21,5 @@ sources = files(
 )
 
 deps += ['bus_pci', 'common_cnxk', 'security']
+
+includes += include_directories('../../../lib/net')
Signature · 1 line
2.7.4
#11 lore raw

PATCH v3 3/8 crypto/cnxk: add security handling in datapath ops

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add security handling in enqueue dequeue ops.

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 78 ++++++++++++++++++++++++++++++-
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h  | 74 +++++++++++++++++++++++++++++
 2 files changed, 151 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +77 -1
index 1a30908..8005a25 100644
@@ -4,9 +4,12 @@
 
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
+#include <rte_ip.h>
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cn10k_ipsec_la_ops.h"
+#include "cn10k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
 #include "cnxk_se.h"
@@ -42,6 +45,38 @@ cn10k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op)
 }
 
 static __rte_always_inline int __rte_hot
+cpt_sec_inst_fill(struct rte_crypto_op *op, struct cn10k_sec_session *sess,
+		  struct cpt_inflight_req *infl_req, struct cpt_inst_s *inst)
+{
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	union roc_ot_ipsec_sa_word2 *w2;
+	struct cn10k_ipsec_sa *sa;
+	int ret;
+
+	if (unlikely(sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {
+		plt_dp_err("Out of place is not supported");
+		return -ENOTSUP;
+	}
+
+	if (unlikely(!rte_pktmbuf_is_contiguous(sym_op->m_src))) {
+		plt_dp_err("Scatter Gather mode is not supported");
+		return -ENOTSUP;
+	}
+
+	sa = &sess->sa;
+	w2 = (union roc_ot_ipsec_sa_word2 *)&sa->in_sa.w2;
+
+	if (w2->s.dir == ROC_IE_OT_SA_DIR_OUTBOUND)
+		ret = process_outb_sa(op, sa, inst);
+	else {
+		infl_req->op_flags |= CPT_OP_FLAGS_IPSEC_DIR_INBOUND;
+		ret = process_inb_sa(op, sa, inst);
+	}
+
+	return ret;
+}
+
+static __rte_always_inline int __rte_hot
 cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		  struct cnxk_se_sess *sess, struct cpt_inflight_req *infl_req,
 		  struct cpt_inst_s *inst)
@@ -64,6 +99,7 @@ static inline int
 cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 		    struct cpt_inst_s inst[], struct cpt_inflight_req *infl_req)
 {
+	struct cn10k_sec_session *sec_sess;
 	struct rte_crypto_sym_op *sym_op;
 	struct cnxk_se_sess *sess;
 	struct rte_crypto_op *op;
@@ -79,7 +115,15 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 	sym_op = op->sym;
 
 	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
-		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			sec_sess = get_sec_session_private_data(
+				sym_op->sec_session);
+			ret = cpt_sec_inst_fill(op, sec_sess, infl_req,
+						&inst[0]);
+			if (unlikely(ret))
+				return 0;
+			w7 = sec_sess->sa.inst.w7;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sess = get_sym_session_private_data(
 				sym_op->session, cn10k_cryptodev_driver_id);
 			ret = cpt_sym_inst_fill(qp, op, sess, infl_req,
@@ -196,6 +240,34 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 }
 
 static inline void
+cn10k_cpt_sec_post_process(struct rte_crypto_op *cop,
+			   struct cpt_inflight_req *infl_req)
+{
+	struct rte_crypto_sym_op *sym_op = cop->sym;
+	struct rte_mbuf *m = sym_op->m_src;
+	struct rte_ipv6_hdr *ip6;
+	struct rte_ipv4_hdr *ip;
+	uint16_t m_len;
+
+	if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) {
+		ip = (struct rte_ipv4_hdr *)rte_pktmbuf_mtod(m, char *);
+
+		if (((ip->version_ihl & 0xf0) >> RTE_IPV4_IHL_MULTIPLIER) ==
+		    IPVERSION) {
+			m_len = rte_be_to_cpu_16(ip->total_length);
+		} else {
+			PLT_ASSERT(((ip->version_ihl & 0xf0) >>
+				    RTE_IPV4_IHL_MULTIPLIER) == IPV6_VERSION);
+			ip6 = (struct rte_ipv6_hdr *)ip;
+			m_len = rte_be_to_cpu_16(ip6->payload_len) +
+				sizeof(struct rte_ipv6_hdr);
+		}
+		m->data_len = m_len;
+		m->pkt_len = m_len;
+	}
+}
+
+static inline void
 cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 			       struct rte_crypto_op *cop,
 			       struct cpt_inflight_req *infl_req)
@@ -219,6 +291,10 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 
 		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+				cn10k_cpt_sec_post_process(cop, infl_req);
+				return;
+			}
 
 			/* Verify authentication data if required */
 			if (unlikely(infl_req->op_flags &
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.7.4
#12 lore raw

PATCH v3 4/8 crypto/cnxk: add security capabilities

In reply to Anoob Joseph

Add security capabilities supported by crypto cn10k PMD.

---
 doc/guides/cryptodevs/cnxk.rst                    |  24 +++++
 doc/guides/cryptodevs/features/cn10k.ini          |   1 +
 drivers/crypto/cnxk/cn10k_cryptodev.c             |   1 +
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   4 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 114 ++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   9 +-
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c          |   3 +-
 7 files changed, 154 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/cnxk.rst +24 -0
index 66b0b63..db949fa 100644
@@ -185,6 +185,30 @@ running the test application:
     ./dpdk-test
     RTE>>cryptodev_cn10k_autotest
 
+Lookaside IPsec Support
+-----------------------
+
+The OCTEON cnxk SoCs can accelerate IPsec traffic in lookaside protocol mode,
+with its **cryptographic accelerator (CPT)**. ``OCTEON cnxk crypto PMD`` implements
+this as an ``RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL`` offload.
+
+Refer to :doc:`../prog_guide/rte_security` for more details on protocol offloads.
+
+This feature can be tested with ipsec-secgw sample application.
+
+Supported OCTEON cnxk SoCs
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+- CN10XX
+
+Features supported
+~~~~~~~~~~~~~~~~~~
+
+* IPv4
+* ESP
+* Tunnel mode
+* AES-128/192/256-GCM
+
 Limitations
 -----------
 
doc/guides/cryptodevs/features/cn10k.ini +1 -0
index 77c4a2d..b268f84 100644
@@ -7,6 +7,7 @@
 Symmetric crypto       = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
+Protocol offload       = Y
 In Place SGL           = Y
 OOP SGL In LB  Out     = Y
 OOP SGL In SGL Out     = Y
drivers/crypto/cnxk/cn10k_cryptodev.c +1 -0
index cacf9c2..22ae810 100644
@@ -99,6 +99,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
+			     RTE_CRYPTODEV_FF_SECURITY |
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
drivers/crypto/cnxk/cnxk_cryptodev.h +4 -0
index 03af4af..6760c13 100644
@@ -6,6 +6,7 @@
 #define _CNXK_CRYPTODEV_H_
 
 #include <rte_cryptodev.h>
+#include <rte_security.h>
 
 #include "roc_cpt.h"
 
@@ -19,6 +20,9 @@
 struct cnxk_cpt_vf {
 	struct roc_cpt cpt;
 	struct rte_cryptodev_capabilities crypto_caps[CNXK_CPT_MAX_CAPS];
+	struct rte_cryptodev_capabilities
+		sec_crypto_caps[CNXK_SEC_CRYPTO_MAX_CAPS];
+	struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
 };
 
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +114 -0

140 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h +8 -1
index 85f5ad2..fe07e43 100644
@@ -10,7 +10,7 @@
 #include "cnxk_cryptodev.h"
 
 /*
- * Initialize crypto capabilities for the device
+ * Initialize crypto and IPsec capabilities for the device
  *
  */
 void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
@@ -22,4 +22,11 @@ void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
 const struct rte_cryptodev_capabilities *
 cnxk_crypto_capabilities_get(struct cnxk_cpt_vf *vf);
 
+/*
+ * Get security capabilities list for the device
+ *
+ */
+const struct rte_security_capability *
+cnxk_crypto_sec_capabilities_get(void *device);
+
 #endif /* _CNXK_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/cnxk/cnxk_cryptodev_sec.c +2 -1
index f03d2ed..8d04d4b 100644
@@ -7,6 +7,7 @@
 #include <rte_security.h>
 #include <rte_security_driver.h>
 
+#include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
 
 /* Common security ops */
@@ -16,7 +17,7 @@ struct rte_security_ops cnxk_sec_ops = {
 	.session_get_size = NULL,
 	.set_pkt_metadata = NULL,
 	.get_userdata = NULL,
-	.capabilities_get = NULL,
+	.capabilities_get = cnxk_crypto_sec_capabilities_get
 };
 
 int
Signature · 1 line
2.7.4
#13 lore raw

PATCH v3 5/8 crypto/cnxk: add asymmetric session ops

In reply to Anoob Joseph

From: Kiran Kumar K <[email protected]>

Add asymmetric crypto session ops.

---
 doc/guides/cryptodevs/features/cn10k.ini  |  13 ++
 doc/guides/cryptodevs/features/cn9k.ini   |  13 ++
 drivers/crypto/cnxk/cn10k_cryptodev.c     |   2 +
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |   6 +-
 drivers/crypto/cnxk/cn9k_cryptodev.c      |   4 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |   6 +-
 drivers/crypto/cnxk/cnxk_ae.h             | 211 ++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev.h      |   4 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c  | 106 +++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h  |   8 ++
 10 files changed, 365 insertions(+), 8 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cnxk_ae.h
doc/guides/cryptodevs/features/cn10k.ini +13 -0
index b268f84..f5552fe 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 Protocol offload       = Y
@@ -65,3 +66,15 @@ AES GCM (128)     = Y
 AES GCM (192)     = Y
 AES GCM (256)     = Y
 CHACHA20-POLY1305 = Y
+
+;
+; Supported Asymmetric algorithms of the 'cn10k' crypto driver.
+;
+[Asymmetric]
+RSA                     = Y
+DSA                     =
+Modular Exponentiation  = Y
+Modular Inversion       =
+Diffie-hellman          =
+ECDSA                   = Y
+ECPM                    = Y
doc/guides/cryptodevs/features/cn9k.ini +13 -0
index 7b310e6..d69dbe8 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Symmetric crypto       = Y
+Asymmetric crypto      = Y
 Sym operation chaining = Y
 HW Accelerated         = Y
 In Place SGL           = Y
@@ -64,3 +65,15 @@ AES GCM (128)     = Y
 AES GCM (192)     = Y
 AES GCM (256)     = Y
 CHACHA20-POLY1305 = Y
+
+;
+; Supported Asymmetric algorithms of the 'cn9k' crypto driver.
+;
+[Asymmetric]
+RSA                     = Y
+DSA                     =
+Modular Exponentiation  = Y
+Modular Inversion       =
+Diffie-hellman          =
+ECDSA                   = Y
+ECPM                    = Y
drivers/crypto/cnxk/cn10k_cryptodev.c +2 -0
index 22ae810..10a621f 100644
@@ -92,7 +92,9 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	dev->driver_id = cn10k_cryptodev_driver_id;
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+			     RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
+			     RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT |
 			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			     RTE_CRYPTODEV_FF_IN_PLACE_SGL |
 			     RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +3 -3
index 8005a25..aa615b2 100644
@@ -426,8 +426,8 @@ struct rte_cryptodev_ops cn10k_cpt_ops = {
 	.sym_session_clear = cnxk_cpt_sym_session_clear,
 
 	/* Asymmetric crypto ops */
-	.asym_session_get_size = NULL,
-	.asym_session_configure = NULL,
-	.asym_session_clear = NULL,
+	.asym_session_get_size = cnxk_ae_session_size_get,
+	.asym_session_configure = cnxk_ae_session_cfg,
+	.asym_session_clear = cnxk_ae_session_clear,
 
 };
drivers/crypto/cnxk/cn9k_cryptodev.c +3 -1
index d3dc084..e74e739 100644
@@ -83,6 +83,7 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	cnxk_cpt_caps_populate(vf);
 
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
+			     RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO |
 			     RTE_CRYPTODEV_FF_HW_ACCELERATED |
 			     RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			     RTE_CRYPTODEV_FF_IN_PLACE_SGL |
@@ -90,7 +91,8 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
 			     RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT |
 			     RTE_CRYPTODEV_FF_SYM_SESSIONLESS |
-			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
+			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED |
+			     RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT;
 
 	cn9k_cpt_set_enqdeq_fns(dev);
 
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +3 -3
index b939d99..6d1537b 100644
@@ -312,8 +312,8 @@ struct rte_cryptodev_ops cn9k_cpt_ops = {
 	.sym_session_clear = cnxk_cpt_sym_session_clear,
 
 	/* Asymmetric crypto ops */
-	.asym_session_get_size = NULL,
-	.asym_session_configure = NULL,
-	.asym_session_clear = NULL,
+	.asym_session_get_size = cnxk_ae_session_size_get,
+	.asym_session_configure = cnxk_ae_session_cfg,
+	.asym_session_clear = cnxk_ae_session_clear,
 
 };
drivers/crypto/cnxk/cnxk_ae.h new file +211 -0

211 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev.h +3 -1
index 6760c13..5e38933 100644
@@ -13,7 +13,7 @@
 #define CNXK_CPT_MAX_CAPS	 34
 #define CNXK_SEC_CRYPTO_MAX_CAPS 4
 #define CNXK_SEC_MAX_CAPS	 3
-
+#define CNXK_AE_EC_ID_MAX	 5
 /**
  * Device private data
  */
@@ -23,6 +23,8 @@ struct cnxk_cpt_vf {
 	struct rte_cryptodev_capabilities
 		sec_crypto_caps[CNXK_SEC_CRYPTO_MAX_CAPS];
 	struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
+	uint64_t cnxk_fpm_iova[CNXK_AE_EC_ID_MAX];
+	struct roc_ae_ec_group *ec_grp[CNXK_AE_EC_ID_MAX];
 };
 
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +106 -0

144 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_ops.h +8 -0
index 7995959..c317f40 100644
@@ -105,4 +105,12 @@ void cnxk_cpt_sym_session_clear(struct rte_cryptodev *dev,
 
 void sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess);
 
+unsigned int cnxk_ae_session_size_get(struct rte_cryptodev *dev __rte_unused);
+
+void cnxk_ae_session_clear(struct rte_cryptodev *dev,
+			   struct rte_cryptodev_asym_session *sess);
+int cnxk_ae_session_cfg(struct rte_cryptodev *dev,
+			struct rte_crypto_asym_xform *xform,
+			struct rte_cryptodev_asym_session *sess,
+			struct rte_mempool *pool);
 #endif /* _CNXK_CRYPTODEV_OPS_H_ */
Signature · 1 line
2.7.4
#14 lore raw

PATCH v3 6/8 crypto/cnxk: add asymmetric datapath ops

In reply to Anoob Joseph

From: Kiran Kumar K <[email protected]>

Add asymmetric crypto datapath ops.

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c |  27 ++
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |  29 +-
 drivers/crypto/cnxk/cnxk_ae.h             | 625 ++++++++++++++++++++++++++++++
 3 files changed, 679 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +27 -0
index aa615b2..6d322a9 100644
@@ -10,6 +10,7 @@
 #include "cn10k_cryptodev_ops.h"
 #include "cn10k_ipsec_la_ops.h"
 #include "cn10k_ipsec.h"
+#include "cnxk_ae.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
 #include "cnxk_se.h"
@@ -100,7 +101,9 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 		    struct cpt_inst_s inst[], struct cpt_inflight_req *infl_req)
 {
 	struct cn10k_sec_session *sec_sess;
+	struct rte_crypto_asym_op *asym_op;
 	struct rte_crypto_sym_op *sym_op;
+	struct cnxk_ae_sess *ae_sess;
 	struct cnxk_se_sess *sess;
 	struct rte_crypto_op *op;
 	uint64_t w7;
@@ -148,6 +151,21 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 			}
 			w7 = sess->cpt_inst_w7;
 		}
+	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+
+		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+			asym_op = op->asym;
+			ae_sess = get_asym_session_private_data(
+				asym_op->session, cn10k_cryptodev_driver_id);
+			ret = cnxk_ae_enqueue(qp, op, infl_req, &inst[0],
+					      ae_sess);
+			if (unlikely(ret))
+				return 0;
+			w7 = ae_sess->cpt_inst_w7;
+		} else {
+			plt_dp_err("Not supported Asym op without session");
+			return 0;
+		}
 	} else {
 		plt_dp_err("Unsupported op type");
 		return 0;
@@ -303,6 +321,15 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 				compl_auth_verify(cop, (uint8_t *)rsp[0],
 						  rsp[1]);
 			}
+		} else if (cop->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+			struct rte_crypto_asym_op *op = cop->asym;
+			uintptr_t *mdata = infl_req->mdata;
+			struct cnxk_ae_sess *sess;
+
+			sess = get_asym_session_private_data(
+				op->session, cn10k_cryptodev_driver_id);
+
+			cnxk_ae_post_process(cop, sess, (uint8_t *)mdata[0]);
 		}
 	} else {
 		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +27 -2
index 6d1537b..724965b 100644
@@ -7,6 +7,7 @@
 
 #include "cn9k_cryptodev.h"
 #include "cn9k_cryptodev_ops.h"
+#include "cnxk_ae.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
 #include "cnxk_se.h"
@@ -65,11 +66,11 @@ static uint16_t
 cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 {
 	struct cpt_inflight_req *infl_req;
+	struct rte_crypto_asym_op *asym_op;
 	struct rte_crypto_sym_op *sym_op;
 	uint16_t nb_allowed, count = 0;
 	struct cnxk_cpt_qp *qp = qptr;
 	struct pending_queue *pend_q;
-	struct cnxk_se_sess *sess;
 	struct rte_crypto_op *op;
 	struct cpt_inst_s inst;
 	uint64_t lmt_status;
@@ -95,6 +96,8 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 		infl_req->op_flags = 0;
 
 		if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			struct cnxk_se_sess *sess;
+
 			if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 				sym_op = op->sym;
 				sess = get_sym_session_private_data(
@@ -120,6 +123,20 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 							op->sym->session);
 				}
 			}
+			inst.w7.u64 = sess->cpt_inst_w7;
+		} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+			struct cnxk_ae_sess *sess;
+
+			ret = -EINVAL;
+			if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+				asym_op = op->asym;
+				sess = get_asym_session_private_data(
+					asym_op->session,
+					cn9k_cryptodev_driver_id);
+				ret = cnxk_ae_enqueue(qp, op, infl_req, &inst,
+						      sess);
+				inst.w7.u64 = sess->cpt_inst_w7;
+			}
 		} else {
 			plt_dp_err("Unsupported op type");
 			break;
@@ -134,7 +151,6 @@ cn9k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 
 		infl_req->res.cn9k.compcode = CPT_COMP_NOT_DONE;
 		inst.res_addr = (uint64_t)&infl_req->res;
-		inst.w7.u64 = sess->cpt_inst_w7;
 
 		do {
 			/* Copy CPT command to LMTLINE */
@@ -189,6 +205,15 @@ cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop,
 				compl_auth_verify(cop, (uint8_t *)rsp[0],
 						  rsp[1]);
 			}
+		} else if (cop->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+			struct rte_crypto_asym_op *op = cop->asym;
+			uintptr_t *mdata = infl_req->mdata;
+			struct cnxk_ae_sess *sess;
+
+			sess = get_asym_session_private_data(
+				op->session, cn9k_cryptodev_driver_id);
+
+			cnxk_ae_post_process(cop, sess, (uint8_t *)mdata[0]);
 		}
 	} else {
 		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
drivers/crypto/cnxk/cnxk_ae.h +625 -0

629 lines not on this page · raw message

Signature · 1 line
2.7.4
#15 lore raw

PATCH v3 7/8 crypto/cnxk: add asymmetric capabilities

In reply to Anoob Joseph

Add asymmetric capabilities supported.

---
 doc/guides/cryptodevs/cnxk.rst                    |  6 +++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 56 +++++++++++++++++++++++
 2 files changed, 62 insertions(+)
doc/guides/cryptodevs/cnxk.rst +6 -0
index db949fa..bbc6daa 100644
@@ -67,6 +67,12 @@ AEAD algorithms:
 * ``RTE_CRYPTO_AEAD_AES_GCM``
 * ``RTE_CRYPTO_AEAD_CHACHA20_POLY1305``
 
+Asymmetric Crypto Algorithms
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* ``RTE_CRYPTO_ASYM_XFORM_RSA``
+* ``RTE_CRYPTO_ASYM_XFORM_MODEX``
+
 Installation
 ------------
 
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +56 -0

68 lines not on this page · raw message

Signature · 1 line
2.7.4
#16 lore raw

PATCH v3 8/8 test/crypto: add cnxk for asymmetric cases

In reply to Anoob Joseph

From: Kiran Kumar K <[email protected]>

Adding autotest for cn9k and cn10k.

---
 app/test/test_cryptodev_asym.c         | 30 ++++++++++++++++++++++++++++++
 doc/guides/cryptodevs/cnxk.rst         | 17 +++++++++++++++++
 doc/guides/rel_notes/release_21_08.rst |  4 ++++
 3 files changed, 51 insertions(+)
app/test/test_cryptodev_asym.c +30 -0
index b36eec9..847b074 100644
@@ -2390,6 +2390,34 @@ test_cryptodev_octeontx2_asym(void)
 	return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
 }
 
+static int
+test_cryptodev_cn9k_asym(void)
+{
+	gbl_driver_id = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "CN9K PMD must be loaded.\n");
+		return TEST_FAILED;
+	}
+
+	/* Use test suite registered for crypto_octeontx PMD */
+	return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
+}
+
+static int
+test_cryptodev_cn10k_asym(void)
+{
+	gbl_driver_id = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "CN10K PMD must be loaded.\n");
+		return TEST_FAILED;
+	}
+
+	/* Use test suite registered for crypto_octeontx PMD */
+	return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
+}
+
 REGISTER_TEST_COMMAND(cryptodev_openssl_asym_autotest,
 					  test_cryptodev_openssl_asym);
 
@@ -2400,3 +2428,5 @@ REGISTER_TEST_COMMAND(cryptodev_octeontx_asym_autotest,
 
 REGISTER_TEST_COMMAND(cryptodev_octeontx2_asym_autotest,
 					  test_cryptodev_octeontx2_asym);
+REGISTER_TEST_COMMAND(cryptodev_cn9k_asym_autotest, test_cryptodev_cn9k_asym);
+REGISTER_TEST_COMMAND(cryptodev_cn10k_asym_autotest, test_cryptodev_cn10k_asym);
doc/guides/cryptodevs/cnxk.rst +17 -0
index bbc6daa..98c7118 100644
@@ -191,6 +191,23 @@ running the test application:
     ./dpdk-test
     RTE>>cryptodev_cn10k_autotest
 
+The asymmetric crypto operations on OCTEON cnxk crypto PMD may be verified by
+running the test application:
+
+``CN9K``
+
+.. code-block:: console
+
+    ./dpdk-test
+    RTE>>cryptodev_cn9k_asym_autotest
+
+``CN10K``
+
+.. code-block:: console
+
+    ./dpdk-test
+    RTE>>cryptodev_cn10k_asym_autotest
+
 Lookaside IPsec Support
 -----------------------
 
doc/guides/rel_notes/release_21_08.rst +4 -0
index 72652ac..cd51b49 100644
@@ -59,6 +59,10 @@ New Features
 
   * Added cnxk crypto PMD which provides support for an integrated
     crypto driver for CN9K and CN10K series of SOCs.
+  * Added 'cn9k_crypto' PMD which supports symmetric & asymmetric
+    offloads
+  * Added 'cn10k_crypto' PMD which supports symmetric, asymmetric
+    and lookaside protocol (IPsec) offloads.
 
 
 Removed Items
Signature · 1 line
2.7.4
Applied
#17 lore raw

Re: [dpdk-dev] [PATCH v3 0/8] Add lookaside IPsec and asymmetric in cnxk crypto PMDs

In reply to Anoob Joseph
Quoted 8 lines

Add rte_security (lookaside protocol - IPsec) support in crypto_cn10k.

IPsec operations can be offloaded to CPT's SE and IE engines, which can process IPsec protcol operations including atomic sequence number increment (for outbound operations) and anti replay window check (for inbound operations).

Quoted 8 lines

Add support for asymmetric operations in crypto cnxk PMDs. Following operations are supported,
- RSA
- DSA
- ECDSA
- ECPM
- Modular Exponentation

Series Acked-by: Akhil Goyal <[email protected]>

Applied to dpdk-next-crypto

Release notes and patch title/description updated while merging.

#18 lore raw

PATCH 2/4 crypto/cnxk: add security capabilities

In reply to Anoob Joseph

Add security capabilities supported by crypto cn10k PMD.

---
 drivers/crypto/cnxk/cnxk_cryptodev.h              |   4 +
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 114 ++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h |   9 +-
 drivers/crypto/cnxk/cnxk_cryptodev_sec.c          |   3 +-
 4 files changed, 128 insertions(+), 2 deletions(-)
drivers/crypto/cnxk/cnxk_cryptodev.h +4 -0
index dcbdc53..1568be3 100644
@@ -6,6 +6,7 @@
 #define _CNXK_CRYPTODEV_H_
 
 #include <rte_cryptodev.h>
+#include <rte_security.h>
 
 #include "roc_cpt.h"
 
@@ -31,6 +32,9 @@
 struct cnxk_cpt_vf {
 	struct roc_cpt cpt;
 	struct rte_cryptodev_capabilities crypto_caps[CNXK_CPT_MAX_CAPS];
+	struct rte_cryptodev_capabilities
+		sec_crypto_caps[CNXK_SEC_CRYPTO_MAX_CAPS];
+	struct rte_security_capability sec_caps[CNXK_SEC_MAX_CAPS];
 };
 
 int cnxk_cpt_eng_grp_add(struct roc_cpt *roc_cpt);
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +114 -0

140 lines not on this page · raw message

drivers/crypto/cnxk/cnxk_cryptodev_capabilities.h +8 -1
index 85f5ad2..fe07e43 100644
@@ -10,7 +10,7 @@
 #include "cnxk_cryptodev.h"
 
 /*
- * Initialize crypto capabilities for the device
+ * Initialize crypto and IPsec capabilities for the device
  *
  */
 void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
@@ -22,4 +22,11 @@ void cnxk_cpt_caps_populate(struct cnxk_cpt_vf *vf);
 const struct rte_cryptodev_capabilities *
 cnxk_crypto_capabilities_get(struct cnxk_cpt_vf *vf);
 
+/*
+ * Get security capabilities list for the device
+ *
+ */
+const struct rte_security_capability *
+cnxk_crypto_sec_capabilities_get(void *device);
+
 #endif /* _CNXK_CRYPTODEV_CAPABILITIES_H_ */
drivers/crypto/cnxk/cnxk_cryptodev_sec.c +2 -1
index f03d2ed..8d04d4b 100644
@@ -7,6 +7,7 @@
 #include <rte_security.h>
 #include <rte_security_driver.h>
 
+#include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
 
 /* Common security ops */
@@ -16,7 +17,7 @@ struct rte_security_ops cnxk_sec_ops = {
 	.session_get_size = NULL,
 	.set_pkt_metadata = NULL,
 	.get_userdata = NULL,
-	.capabilities_get = NULL,
+	.capabilities_get = cnxk_crypto_sec_capabilities_get
 };
 
 int
Signature · 1 line
2.7.4
#19 lore raw

PATCH 3/4 crypto/cnxk: add security session ops

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add security session ops in cn10k crypto PMD.

---
 drivers/crypto/cnxk/cn10k_cryptodev.c |   2 +
 drivers/crypto/cnxk/cn10k_ipsec.c     | 520 ++++++++++++++++++++++++++++++++++
 drivers/crypto/cnxk/cn10k_ipsec.h     |  38 +++
 drivers/crypto/cnxk/cnxk_ipsec.h      |  18 ++
 drivers/crypto/cnxk/meson.build       |   3 +-
 5 files changed, 580 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cnxk_ipsec.h
drivers/crypto/cnxk/cn10k_cryptodev.c +2 -0
index b58d390..9517e62 100644
@@ -12,6 +12,7 @@
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cn10k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
@@ -97,6 +98,7 @@ cn10k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED;
 
 	cn10k_cpt_set_enqdeq_fns(dev);
+	cn10k_sec_ops_override();
 
 	return 0;
 
drivers/crypto/cnxk/cn10k_ipsec.c new file +520 -0

520 lines not on this page · raw message

drivers/crypto/cnxk/cn10k_ipsec.h new file +38 -0
new file mode 100644
index 0000000..6e36e67
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CN10K_IPSEC_H__
+#define __CN10K_IPSEC_H__
+
+#include <rte_security.h>
+
+#include "roc_platform.h"
+#include "roc_ie_ot.h"
+#include "cnxk_ipsec.h"
+
+#define CN10K_IPSEC_SA_CTX_HDR_SIZE 1
+
+struct cn10k_ipsec_sa {
+	union {
+		/** Inbound SA */
+		struct roc_ot_ipsec_inb_sa in_sa;
+		/** Outbound SA */
+		struct roc_ot_ipsec_outb_sa out_sa;
+	};
+	/** Pre-populated CPT inst words */
+	struct cnxk_cpt_inst_tmpl inst;
+	uint8_t partial_len;
+	uint8_t roundup_len;
+	uint8_t roundup_byte;
+};
+
+struct cn10k_sec_session {
+	struct cn10k_ipsec_sa sa;
+	void *userdata;
+	/**< Userdata registered by the application */
+} __rte_cache_aligned;
+
+void cn10k_sec_ops_override(void);
+
+#endif /* __CN10K_IPSEC_H__ */
drivers/crypto/cnxk/cnxk_ipsec.h new file +18 -0
new file mode 100644
index 0000000..8b9500d
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+#ifndef __CNXK_IPSEC_H__
+#define __CNXK_IPSEC_H__
+
+#include <rte_security.h>
+#include <rte_security_driver.h>
+
+extern struct rte_security_ops cnxk_sec_ops;
+
+struct cnxk_cpt_inst_tmpl {
+	uint64_t w2;
+	uint64_t w4;
+	uint64_t w7;
+};
+
+#endif /* __CNXK_IPSEC_H__ */
drivers/crypto/cnxk/meson.build +2 -1
index ab45483..eea08fa 100644
@@ -13,6 +13,7 @@ sources = files(
         'cn9k_cryptodev_ops.c',
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
+        'cn10k_ipsec.c',
         'cnxk_cpt_ops_helper.c',
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',
@@ -20,4 +21,4 @@ sources = files(
         'cnxk_cryptodev_sec.c',
 )
 
-deps += ['bus_pci', 'common_cnxk', 'security']
+deps += ['bus_pci', 'common_cnxk', 'security', 'rte_net']
Signature · 1 line
2.7.4
#20 lore raw

Re: [dpdk-dev] [PATCH 3/4] crypto/cnxk: add security session ops

Quoted 14 lines
drivers/crypto/cnxk/meson.build +1 -0
index ab45483..eea08fa 100644
@@ -13,6 +13,7 @@ sources = files(
         'cn9k_cryptodev_ops.c',
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
+        'cn10k_ipsec.c',
         'cnxk_cpt_ops_helper.c',
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c',

drivers/crypto/cnxk/meson.build sources = files(

Quoted 6 lines
drivers/crypto/cnxk/meson.build +1 -2
@@ -20,4 +21,4 @@ sources = files(
         'cnxk_cryptodev_sec.c',
 )
 
-deps += ['bus_pci', 'common_cnxk', 'security']
+deps += ['bus_pci', 'common_cnxk', 'security', 'rte_net']
--

This should be 'net' and not 'rte_net'.
Do we really need this dependency?

#21 lore raw

Re: [dpdk-dev] [PATCH 3/4] crypto/cnxk: add security session ops

Hi Akhil,

Please see inline.

Thanks,
Anoob

Quoted 27 lines

-----Original Message-----
From: Akhil Goyal <[email protected]>
Sent: Thursday, June 17, 2021 1:41 AM
To: Anoob Joseph <[email protected]>; Thomas Monjalon <[email protected]>
Cc: Tejasree Kondoj <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>; [email protected]; Anoob Joseph <[email protected]>; Archana Muniganti <[email protected]>; Srujana Challa <[email protected]>
Subject: RE: [PATCH 3/4] crypto/cnxk: add security session ops

Quoted 16 lines
(quoted diff) +0 -0

b/drivers/crypto/cnxk/meson.build index ab45483..eea08fa 100644

drivers/crypto/cnxk/meson.build +1 -0
@@ -13,6 +13,7 @@ sources = files(
         'cn9k_cryptodev_ops.c',
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
+        'cn10k_ipsec.c',
         'cnxk_cpt_ops_helper.c',
         'cnxk_cryptodev.c',
         'cnxk_cryptodev_capabilities.c', @@ -20,4 +21,4 @@ sources =

files(

         'cnxk_cryptodev_sec.c',

)

Quoted 5 lines

drivers/crypto/cnxk/meson.build sources = files(

Quoted 3 lines
drivers/crypto/cnxk/meson.build +1 -2
-deps += ['bus_pci', 'common_cnxk', 'security']
+deps += ['bus_pci', 'common_cnxk', 'security', 'rte_net']
--

This should be 'net' and not 'rte_net'. Do we really need this dependency?

[Anoob] It was required since we had a dependency on rte_esp.h. But, as you said, we don't need to make it as dependency on 'net'. Something like,

includes += include_directories('../../../lib/net')

Is good enough. Will have this changed so.

#22 lore raw

PATCH 4/4 crypto/cnxk: add security handling in datapath ops

In reply to Anoob Joseph

From: Tejasree Kondoj <[email protected]>

Add security handling in enqueue dequeue ops.

---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 78 ++++++++++++++++++++++++++++++-
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h  | 74 +++++++++++++++++++++++++++++
 2 files changed, 151 insertions(+), 1 deletion(-)
 create mode 100644 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
drivers/crypto/cnxk/cn10k_cryptodev_ops.c +77 -1
index 22704df..68093ea 100644
@@ -4,9 +4,12 @@
 
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
+#include <rte_ip.h>
 
 #include "cn10k_cryptodev.h"
 #include "cn10k_cryptodev_ops.h"
+#include "cn10k_ipsec_la_ops.h"
+#include "cn10k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
 #include "cnxk_se.h"
@@ -42,6 +45,38 @@ cn10k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op)
 }
 
 static __rte_always_inline int __rte_hot
+cpt_sec_inst_fill(struct rte_crypto_op *op, struct cn10k_sec_session *sess,
+		  struct cpt_inflight_req *infl_req, struct cpt_inst_s *inst)
+{
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	union roc_ot_ipsec_sa_word2 *w2;
+	struct cn10k_ipsec_sa *sa;
+	int ret;
+
+	if (unlikely(sym_op->m_dst && sym_op->m_dst != sym_op->m_src)) {
+		CPT_LOG_DP_ERR("Out of place is not supported");
+		return -ENOTSUP;
+	}
+
+	if (unlikely(!rte_pktmbuf_is_contiguous(sym_op->m_src))) {
+		CPT_LOG_DP_ERR("Scatter Gather mode is not supported");
+		return -ENOTSUP;
+	}
+
+	sa = &sess->sa;
+	w2 = (union roc_ot_ipsec_sa_word2 *)&sa->in_sa.w2;
+
+	if (w2->s.dir == ROC_IE_OT_SA_DIR_OUTBOUND)
+		ret = process_outb_sa(op, sa, inst);
+	else {
+		infl_req->op_flags |= CPT_OP_FLAGS_IPSEC_DIR_INBOUND;
+		ret = process_inb_sa(op, sa, inst);
+	}
+
+	return ret;
+}
+
+static __rte_always_inline int __rte_hot
 cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 		  struct cnxk_se_sess *sess, struct cpt_inflight_req *infl_req,
 		  struct cpt_inst_s *inst)
@@ -64,6 +99,7 @@ static inline int
 cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 		    struct cpt_inst_s inst[], struct cpt_inflight_req *infl_req)
 {
+	struct cn10k_sec_session *sec_sess;
 	struct rte_crypto_sym_op *sym_op;
 	struct cnxk_se_sess *sess;
 	struct rte_crypto_op *op;
@@ -79,7 +115,15 @@ cn10k_cpt_fill_inst(struct cnxk_cpt_qp *qp, struct rte_crypto_op *ops[],
 	sym_op = op->sym;
 
 	if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
-		if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+		if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+			sec_sess = get_sec_session_private_data(
+				sym_op->sec_session);
+			ret = cpt_sec_inst_fill(op, sec_sess, infl_req,
+						&inst[0]);
+			if (unlikely(ret))
+				return 0;
+			w7 = sec_sess->sa.inst.w7;
+		} else if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
 			sess = get_sym_session_private_data(
 				sym_op->session, cn10k_cryptodev_driver_id);
 			ret = cpt_sym_inst_fill(qp, op, sess, infl_req,
@@ -196,6 +240,34 @@ cn10k_cpt_enqueue_burst(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 }
 
 static inline void
+cn10k_cpt_sec_post_process(struct rte_crypto_op *cop,
+			   struct cpt_inflight_req *infl_req)
+{
+	struct rte_crypto_sym_op *sym_op = cop->sym;
+	struct rte_mbuf *m = sym_op->m_src;
+	struct rte_ipv6_hdr *ip6;
+	struct rte_ipv4_hdr *ip;
+	uint16_t m_len;
+
+	if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) {
+		ip = (struct rte_ipv4_hdr *)rte_pktmbuf_mtod(m, char *);
+
+		if (((ip->version_ihl & 0xf0) >> RTE_IPV4_IHL_MULTIPLIER) ==
+		    IPVERSION) {
+			m_len = rte_be_to_cpu_16(ip->total_length);
+		} else {
+			PLT_ASSERT(((ip->version_ihl & 0xf0) >>
+				    RTE_IPV4_IHL_MULTIPLIER) == IPV6_VERSION);
+			ip6 = (struct rte_ipv6_hdr *)ip;
+			m_len = rte_be_to_cpu_16(ip6->payload_len) +
+				sizeof(struct rte_ipv6_hdr);
+		}
+		m->data_len = m_len;
+		m->pkt_len = m_len;
+	}
+}
+
+static inline void
 cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 			       struct rte_crypto_op *cop,
 			       struct cpt_inflight_req *infl_req)
@@ -219,6 +291,10 @@ cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp,
 
 		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+				cn10k_cpt_sec_post_process(cop, infl_req);
+				return;
+			}
 
 			/* Verify authentication data if required */
 			if (unlikely(infl_req->op_flags &
drivers/crypto/cnxk/cn10k_ipsec_la_ops.h new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
2.7.4
#23 lore raw
In reply to Anoob Joseph
Quoted 10 lines

Add rte_security (lookaside protocol - IPsec) support in crypto_cn10k.

IPsec operations can be offloaded to CPT's SE and IE engines, which can process IPsec protcol operations including atomic sequence number increment (for outbound operations) and anti replay window check (for inbound operations).

Depends-on: series-17212 ("Add CPT in Marvell CNXK common driver")
Depends-on: series-17213 ("Add Marvell CNXK crypto PMDs")

Do you need any update in the documentation of the PMD for this patchset. Please also update release notes appropriately.