Skip to contentSkip to conversation

add cn9k lookaside IPsec support

PATCH Superseded Archana Muniganti 2 participants 10 messages Sep 2, 2021 – Sep 6, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover add cn9k lookaside IPsec support

This series adds lookaside IPsec support in crypto_cn9k PMD.

Depends on:
http://patches.dpdk.org/project/dpdk/list/?series=18628

Archana Muniganti (8):
crypto/cnxk: add cn9k security ctx
common/cnxk: add cn9k IPsec microcode defines crypto/cnxk: add cn9k IPsec session related functions crypto/cnxk: add cn9k IPsec outbound session create function crypto/cnxk: add cn9k IPsec inbound session create function crypto/cnxk: add cn9k lookaside IPsec datapath crypto/cnxk: update tailroom requirement crypto/cnxk: update feature flag for cn9k lookaside IPsec

 doc/guides/cryptodevs/cnxk.rst           |  14 +-
 doc/guides/cryptodevs/features/cn9k.ini  |   1 +
 doc/guides/rel_notes/release_21_11.rst   |   3 +
 drivers/common/cnxk/roc_cpt.h            |   1 +
 drivers/common/cnxk/roc_ie_on.h          | 158 +++++-
 drivers/crypto/cnxk/cn9k_cryptodev.c     |  11 +
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c |  78 ++-
 drivers/crypto/cnxk/cn9k_ipsec.c         | 612 +++++++++++++++++++++++
 drivers/crypto/cnxk/cn9k_ipsec.h         |  46 ++
 drivers/crypto/cnxk/cn9k_ipsec_la_ops.h  |  90 ++++
 drivers/crypto/cnxk/cnxk_cryptodev.c     |   6 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c |   2 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h |   1 +
 drivers/crypto/cnxk/meson.build          |   1 +
 14 files changed, 1006 insertions(+), 18 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cn9k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn9k_ipsec.h
 create mode 100644 drivers/crypto/cnxk/cn9k_ipsec_la_ops.h
Signature · 1 line
2.22.0
#1 lore raw

PATCH 1/8 crypto/cnxk: add cn9k security ctx

Add security ctx in cn9k crypto PMD.

---
 drivers/crypto/cnxk/cn9k_cryptodev.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/crypto/cnxk/cn9k_cryptodev.c +9 -0
index 9ff2383d98..db2e085161 100644
@@ -14,6 +14,7 @@
 #include "cn9k_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 @@ cn9k_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;
 	}
 
 	dev->dev_ops = &cn9k_cpt_ops;
@@ -117,6 +123,9 @@ cn9k_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);
Signature · 1 line
2.22.0
#2 lore raw

PATCH 2/8 common/cnxk: add cn9k IPsec microcode defines

In reply to Archana Muniganti

Microcode IE opcodes support IPsec operations. Add defines and structs defined by microcode.

---
 drivers/common/cnxk/roc_cpt.h   |   1 +
 drivers/common/cnxk/roc_ie_on.h | 158 ++++++++++++++++++++++++++++++--
 2 files changed, 150 insertions(+), 9 deletions(-)
drivers/common/cnxk/roc_cpt.h +1 -0
index f0f505a8c2..9e63073a52 100644
@@ -47,6 +47,7 @@
 #define ROC_CPT_AES_GCM_MAC_LEN	 16
 #define ROC_CPT_AES_CBC_IV_LEN	 16
 #define ROC_CPT_SHA1_HMAC_LEN	 12
+#define ROC_CPT_SHA2_HMAC_LEN	 16
 #define ROC_CPT_AUTH_KEY_LEN_MAX 64
 
 #define ROC_CPT_DES3_KEY_LEN	  24
drivers/common/cnxk/roc_ie_on.h +149 -9

173 lines not on this page · raw message

Signature · 1 line
2.22.0
#3 lore raw

PATCH 3/8 crypto/cnxk: add cn9k IPsec session related functions

In reply to Archana Muniganti

Add helper functions useful in implementing IPsec outbound and inbound session create apis.

---
 drivers/crypto/cnxk/cn9k_cryptodev.c |   2 +
 drivers/crypto/cnxk/cn9k_ipsec.c     | 425 +++++++++++++++++++++++++++
 drivers/crypto/cnxk/cn9k_ipsec.h     |  29 ++
 drivers/crypto/cnxk/meson.build      |   1 +
 4 files changed, 457 insertions(+)
 create mode 100644 drivers/crypto/cnxk/cn9k_ipsec.c
 create mode 100644 drivers/crypto/cnxk/cn9k_ipsec.h
drivers/crypto/cnxk/cn9k_cryptodev.c +2 -0
index db2e085161..e60b352fac 100644
@@ -12,6 +12,7 @@
 
 #include "cn9k_cryptodev.h"
 #include "cn9k_cryptodev_ops.h"
+#include "cn9k_ipsec.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_capabilities.h"
 #include "cnxk_cryptodev_sec.h"
@@ -92,6 +93,7 @@ cn9k_cpt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	cnxk_cpt_caps_populate(vf);
 
 	cn9k_cpt_set_enqdeq_fns(dev);
+	cn9k_sec_ops_override();
 
 	return 0;
 
drivers/crypto/cnxk/cn9k_ipsec.c new file +425 -0

425 lines not on this page · raw message

drivers/crypto/cnxk/cn9k_ipsec.h new file +29 -0
new file mode 100644
index 0000000000..0fe78df49b
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(C) 2021 Marvell.
+ */
+
+#ifndef __CN9K_IPSEC_H__
+#define __CN9K_IPSEC_H__
+
+#include "cnxk_ipsec.h"
+
+struct cn9k_ipsec_sa {
+	union {
+		/** Inbound SA */
+		struct roc_ie_on_inb_sa in_sa;
+		/** Outbound SA */
+		struct roc_ie_on_outb_sa out_sa;
+	};
+	/** IPsec SA direction */
+	enum rte_security_ipsec_sa_direction dir;
+	/** Pre-populated CPT inst words */
+	struct cnxk_cpt_inst_tmpl inst;
+};
+
+struct cn9k_sec_session {
+	struct cn9k_ipsec_sa sa;
+} __rte_cache_aligned;
+
+void cn9k_sec_ops_override(void);
+
+#endif /* __CN9K_IPSEC_H__ */
drivers/crypto/cnxk/meson.build +1 -0
index e076783629..e40d132f80 100644
@@ -11,6 +11,7 @@ endif
 sources = files(
         'cn9k_cryptodev.c',
         'cn9k_cryptodev_ops.c',
+        'cn9k_ipsec.c',
         'cn10k_cryptodev.c',
         'cn10k_cryptodev_ops.c',
         'cn10k_ipsec.c',
Signature · 1 line
2.22.0
#4 lore raw

Re: [dpdk-dev] [PATCH 3/8] crypto/cnxk: add cn9k IPsec session related functions

Quoted 7 lines

Add helper functions useful in implementing IPsec outbound and inbound session create apis.

---

Clang compilation broken on this patch

../drivers/crypto/cnxk/cn9k_ipsec.c:18:1: error: unused function 'cn9k_cpt_enq_sa_write' [-Werror,-Wunused-function] cn9k_cpt_enq_sa_write(struct cn9k_ipsec_sa *sa, struct cnxk_cpt_qp *qp,
^
../drivers/crypto/cnxk/cn9k_ipsec.c:236:1: error: unused function 'fill_ipsec_common_sa' [-Werror,-Wunused-function] fill_ipsec_common_sa(struct rte_security_ipsec_xform *ipsec,

#5 lore raw

PATCH 4/8 crypto/cnxk: add cn9k IPsec outbound session create function

In reply to Archana Muniganti

Adding logic for IPsec outbound session creation.

---
 drivers/crypto/cnxk/cn9k_ipsec.c | 143 +++++++++++++++++++++++++++++--
 drivers/crypto/cnxk/cn9k_ipsec.h |  17 ++++
 2 files changed, 155 insertions(+), 5 deletions(-)
drivers/crypto/cnxk/cn9k_ipsec.c +138 -5
index dd02cc7764..52fbc5e350 100644
@@ -3,6 +3,7 @@
  */
 
 #include <rte_cryptodev.h>
+#include <rte_ip.h>
 #include <rte_security.h>
 #include <rte_security_driver.h>
 
@@ -275,12 +276,144 @@ cn9k_ipsec_outb_sa_create(struct cnxk_cpt_qp *qp,
 			  struct rte_crypto_sym_xform *crypto_xform,
 			  struct rte_security_session *sec_sess)
 {
-	RTE_SET_USED(qp);
-	RTE_SET_USED(ipsec);
-	RTE_SET_USED(crypto_xform);
-	RTE_SET_USED(sec_sess);
+	struct rte_crypto_sym_xform *auth_xform = crypto_xform->next;
+	struct roc_ie_on_ip_template *template = NULL;
+	struct cnxk_cpt_inst_tmpl *inst_tmpl;
+	struct roc_ie_on_outb_sa *out_sa;
+	struct cn9k_sec_session *sess;
+	struct roc_ie_on_sa_ctl *ctl;
+	struct cn9k_ipsec_sa *sa;
+	struct rte_ipv6_hdr *ip6;
+	struct rte_ipv4_hdr *ip4;
+	const uint8_t *auth_key;
+	union cpt_inst_w4 w4;
+	union cpt_inst_w7 w7;
+	int auth_key_len = 0;
+	size_t ctx_len;
+	int ret;
 
-	return 0;
+	sess = get_sec_session_private_data(sec_sess);
+	sa = &sess->sa;
+	out_sa = &sa->out_sa;
+	ctl = &out_sa->common_sa.ctl;
+
+	memset(sa, 0, sizeof(struct cn9k_ipsec_sa));
+
+	/* Initialize lookaside IPsec private data */
+	sa->dir = RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
+	/* Start ip id from 1 */
+	sa->ip_id = 1;
+	sa->seq_lo = 1;
+	sa->seq_hi = 0;
+
+	ret = fill_ipsec_common_sa(ipsec, crypto_xform, &out_sa->common_sa);
+	if (ret)
+		return ret;
+
+	ret = cnxk_ipsec_outb_rlens_get(&sa->rlens, ipsec, crypto_xform);
+	if (ret)
+		return ret;
+
+	if (ctl->enc_type == ROC_IE_ON_SA_ENC_AES_GCM) {
+		template = &out_sa->aes_gcm.template;
+		ctx_len = offsetof(struct roc_ie_on_outb_sa, aes_gcm.template);
+	} else if (ctl->auth_type == ROC_IE_ON_SA_AUTH_SHA1) {
+		template = &out_sa->sha1.template;
+		ctx_len = offsetof(struct roc_ie_on_outb_sa, sha1.template);
+	} else if (ctl->auth_type == ROC_IE_ON_SA_AUTH_SHA2_256) {
+		template = &out_sa->sha2.template;
+		ctx_len = offsetof(struct roc_ie_on_outb_sa, sha2.template);
+	} else {
+		return -EINVAL;
+	}
+
+	ip4 = (struct rte_ipv4_hdr *)&template->ip4.ipv4_hdr;
+	if (ipsec->options.udp_encap) {
+		ip4->next_proto_id = IPPROTO_UDP;
+		template->ip4.udp_src = rte_be_to_cpu_16(4500);
+		template->ip4.udp_dst = rte_be_to_cpu_16(4500);
+	} else {
+		ip4->next_proto_id = IPPROTO_ESP;
+	}
+
+	if (ipsec->mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
+		if (ipsec->tunnel.type == RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
+			ctx_len += sizeof(template->ip4);
+
+			ip4->version_ihl = RTE_IPV4_VHL_DEF;
+			ip4->time_to_live = ipsec->tunnel.ipv4.ttl;
+			ip4->type_of_service |= (ipsec->tunnel.ipv4.dscp << 2);
+			if (ipsec->tunnel.ipv4.df)
+				ip4->fragment_offset = BIT(14);
+			memcpy(&ip4->src_addr, &ipsec->tunnel.ipv4.src_ip,
+			       sizeof(struct in_addr));
+			memcpy(&ip4->dst_addr, &ipsec->tunnel.ipv4.dst_ip,
+			       sizeof(struct in_addr));
+		} else if (ipsec->tunnel.type ==
+			   RTE_SECURITY_IPSEC_TUNNEL_IPV6) {
+			ctx_len += sizeof(template->ip6);
+
+			ip6 = (struct rte_ipv6_hdr *)&template->ip6.ipv6_hdr;
+			if (ipsec->options.udp_encap) {
+				ip6->proto = IPPROTO_UDP;
+				template->ip6.udp_src = rte_be_to_cpu_16(4500);
+				template->ip6.udp_dst = rte_be_to_cpu_16(4500);
+			} else {
+				ip6->proto = (ipsec->proto ==
+					      RTE_SECURITY_IPSEC_SA_PROTO_ESP) ?
+						     IPPROTO_ESP :
+						     IPPROTO_AH;
+			}
+			ip6->vtc_flow =
+				rte_cpu_to_be_32(0x60000000 |
+						 ((ipsec->tunnel.ipv6.dscp
+						   << RTE_IPV6_HDR_TC_SHIFT) &
+						  RTE_IPV6_HDR_TC_MASK) |
+						 ((ipsec->tunnel.ipv6.flabel
+						   << RTE_IPV6_HDR_FL_SHIFT) &
+						  RTE_IPV6_HDR_FL_MASK));
+			ip6->hop_limits = ipsec->tunnel.ipv6.hlimit;
+			memcpy(&ip6->src_addr, &ipsec->tunnel.ipv6.src_addr,
+			       sizeof(struct in6_addr));
+			memcpy(&ip6->dst_addr, &ipsec->tunnel.ipv6.dst_addr,
+			       sizeof(struct in6_addr));
+		}
+	} else
+		ctx_len += sizeof(template->ip4);
+
+	ctx_len += RTE_ALIGN_CEIL(ctx_len, 8);
+
+	if (crypto_xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
+		sa->cipher_iv_off = crypto_xform->aead.iv.offset;
+		sa->cipher_iv_len = crypto_xform->aead.iv.length;
+	} else {
+		sa->cipher_iv_off = crypto_xform->cipher.iv.offset;
+		sa->cipher_iv_len = crypto_xform->cipher.iv.length;
+
+		auth_key = auth_xform->auth.key.data;
+		auth_key_len = auth_xform->auth.key.length;
+
+		if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA1_HMAC)
+			memcpy(out_sa->sha1.hmac_key, auth_key, auth_key_len);
+		else if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA256_HMAC)
+			memcpy(out_sa->sha2.hmac_key, auth_key, auth_key_len);
+	}
+
+	inst_tmpl = &sa->inst;
+
+	w4.u64 = 0;
+	w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC;
+	w4.s.opcode_minor = ctx_len >> 3;
+	w4.s.param1 = ROC_IE_ON_PER_PKT_IV;
+	inst_tmpl->w4 = w4.u64;
+
+	w7.u64 = 0;
+	w7.s.egrp = ROC_CPT_DFLT_ENG_GRP_SE;
+	w7.s.cptr = rte_mempool_virt2iova(out_sa);
+	inst_tmpl->w7 = w7.u64;
+
+	return cn9k_cpt_enq_sa_write(
+		sa, qp, ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_OUTBOUND, ctx_len);
 }
 
 static int
drivers/crypto/cnxk/cn9k_ipsec.h +17 -0
index 0fe78df49b..13d522ec6f 100644
@@ -6,6 +6,7 @@
 #define __CN9K_IPSEC_H__
 
 #include "cnxk_ipsec.h"
+#include "cnxk_security.h"
 
 struct cn9k_ipsec_sa {
 	union {
@@ -18,6 +19,22 @@ struct cn9k_ipsec_sa {
 	enum rte_security_ipsec_sa_direction dir;
 	/** Pre-populated CPT inst words */
 	struct cnxk_cpt_inst_tmpl inst;
+	/** Cipher IV offset in bytes */
+	uint16_t cipher_iv_off;
+	/** Cipher IV length in bytes */
+	uint8_t cipher_iv_len;
+	/** Response length calculation data */
+	struct cnxk_ipsec_outb_rlens rlens;
+	/** Outbound IP-ID */
+	uint16_t ip_id;
+	/** ESN */
+	union {
+		uint64_t esn;
+		struct {
+			uint32_t seq_lo;
+			uint32_t seq_hi;
+		};
+	};
 };
 
 struct cn9k_sec_session {
Signature · 1 line
2.22.0
#6 lore raw

PATCH 5/8 crypto/cnxk: add cn9k IPsec inbound session create function

In reply to Archana Muniganti

Adding logic for IPsec inbound session creation.

---
 drivers/crypto/cnxk/cn9k_ipsec.c | 64 +++++++++++++++++++++++++++++---
 1 file changed, 59 insertions(+), 5 deletions(-)
drivers/crypto/cnxk/cn9k_ipsec.c +59 -5
index 52fbc5e350..76d81e83a5 100644
@@ -422,12 +422,66 @@ cn9k_ipsec_inb_sa_create(struct cnxk_cpt_qp *qp,
 			 struct rte_crypto_sym_xform *crypto_xform,
 			 struct rte_security_session *sec_sess)
 {
-	RTE_SET_USED(qp);
-	RTE_SET_USED(ipsec);
-	RTE_SET_USED(crypto_xform);
-	RTE_SET_USED(sec_sess);
+	struct rte_crypto_sym_xform *auth_xform = crypto_xform;
+	struct cnxk_cpt_inst_tmpl *inst_tmpl;
+	struct roc_ie_on_inb_sa *in_sa;
+	struct cn9k_sec_session *sess;
+	struct cn9k_ipsec_sa *sa;
+	const uint8_t *auth_key;
+	union cpt_inst_w4 w4;
+	union cpt_inst_w7 w7;
+	int auth_key_len = 0;
+	size_t ctx_len = 0;
+	int ret;
 
-	return 0;
+	sess = get_sec_session_private_data(sec_sess);
+	sa = &sess->sa;
+	in_sa = &sa->in_sa;
+
+	memset(sa, 0, sizeof(struct cn9k_ipsec_sa));
+
+	sa->dir = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
+
+	ret = fill_ipsec_common_sa(ipsec, crypto_xform, &in_sa->common_sa);
+	if (ret)
+		return ret;
+
+	if (crypto_xform->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
+		ctx_len = offsetof(struct roc_ie_on_inb_sa,
+				   sha1_or_gcm.hmac_key[0]);
+	} else {
+		auth_key = auth_xform->auth.key.data;
+		auth_key_len = auth_xform->auth.key.length;
+
+		if (auth_xform->auth.algo == RTE_CRYPTO_AUTH_SHA1_HMAC) {
+			memcpy(in_sa->sha1_or_gcm.hmac_key, auth_key,
+			       auth_key_len);
+			ctx_len = offsetof(struct roc_ie_on_inb_sa,
+					   sha1_or_gcm.selector);
+		} else if (auth_xform->auth.algo ==
+			   RTE_CRYPTO_AUTH_SHA256_HMAC) {
+			memcpy(in_sa->sha2.hmac_key, auth_key, auth_key_len);
+			ctx_len = offsetof(struct roc_ie_on_inb_sa,
+					   sha2.selector);
+		}
+	}
+
+	inst_tmpl = &sa->inst;
+
+	w4.u64 = 0;
+	w4.s.opcode_major = ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC;
+	w4.s.opcode_minor = ctx_len >> 3;
+	inst_tmpl->w4 = w4.u64;
+
+	w7.u64 = 0;
+	w7.s.egrp = ROC_CPT_DFLT_ENG_GRP_SE;
+	w7.s.cptr = rte_mempool_virt2iova(in_sa);
+	inst_tmpl->w7 = w7.u64;
+
+	ret = cn9k_cpt_enq_sa_write(
+		sa, qp, ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_INBOUND, ctx_len);
+
+	return ret;
 }
 
 static inline int
Signature · 1 line
2.22.0
#7 lore raw

PATCH 6/8 crypto/cnxk: add cn9k lookaside IPsec datapath

In reply to Archana Muniganti

Adds support for cn9k lookaside enqueue and dequeue operations.

---
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c | 78 +++++++++++++++++++-
 drivers/crypto/cnxk/cn9k_ipsec_la_ops.h  | 90 ++++++++++++++++++++++++
 2 files changed, 166 insertions(+), 2 deletions(-)
 create mode 100644 drivers/crypto/cnxk/cn9k_ipsec_la_ops.h
drivers/crypto/cnxk/cn9k_cryptodev_ops.c +76 -2
index 8ade1977e1..40109acc3f 100644
@@ -5,10 +5,13 @@
 #include <rte_cryptodev.h>
 #include <rte_cryptodev_pmd.h>
 #include <rte_event_crypto_adapter.h>
+#include <rte_ip.h>
 #include <rte_vect.h>
 
 #include "cn9k_cryptodev.h"
 #include "cn9k_cryptodev_ops.h"
+#include "cn9k_ipsec.h"
+#include "cn9k_ipsec_la_ops.h"
 #include "cnxk_ae.h"
 #include "cnxk_cryptodev.h"
 #include "cnxk_cryptodev_ops.h"
@@ -34,6 +37,36 @@ cn9k_cpt_sym_inst_fill(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 	return ret;
 }
 
+static __rte_always_inline int __rte_hot
+cn9k_cpt_sec_inst_fill(struct rte_crypto_op *op,
+		       struct cpt_inflight_req *infl_req,
+		       struct cpt_inst_s *inst)
+{
+	struct rte_crypto_sym_op *sym_op = op->sym;
+	struct cn9k_sec_session *priv;
+	struct cn9k_ipsec_sa *sa;
+
+	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;
+	}
+
+	priv = get_sec_session_private_data(op->sym->sec_session);
+	sa = &priv->sa;
+
+	if (sa->dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
+		return process_outb_sa(op, sa, inst);
+
+	infl_req->op_flags |= CPT_OP_FLAGS_IPSEC_DIR_INBOUND;
+
+	return process_inb_sa(op, sa, inst);
+}
+
 static inline struct cnxk_se_sess *
 cn9k_cpt_sym_temp_sess_create(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op)
 {
@@ -80,7 +113,10 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 				sym_op->session, cn9k_cryptodev_driver_id);
 			ret = cn9k_cpt_sym_inst_fill(qp, op, sess, infl_req,
 						     inst);
-		} else {
+			inst->w7.u64 = sess->cpt_inst_w7;
+		} else if (op->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION)
+			ret = cn9k_cpt_sec_inst_fill(op, infl_req, inst);
+		else {
 			sess = cn9k_cpt_sym_temp_sess_create(qp, op);
 			if (unlikely(sess == NULL)) {
 				plt_dp_err("Could not create temp session");
@@ -94,8 +130,8 @@ cn9k_cpt_inst_prep(struct cnxk_cpt_qp *qp, struct rte_crypto_op *op,
 						  op->sym->session);
 				rte_mempool_put(qp->sess_mp, op->sym->session);
 			}
+			inst->w7.u64 = sess->cpt_inst_w7;
 		}
-		inst->w7.u64 = sess->cpt_inst_w7;
 	} else if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
 		struct rte_crypto_asym_op *asym_op;
 		struct cnxk_ae_sess *sess;
@@ -348,6 +384,39 @@ cn9k_cpt_crypto_adapter_enqueue(uintptr_t tag_op, struct rte_crypto_op *op)
 	return 1;
 }
 
+static inline void
+cn9k_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 = 0;
+	char *data;
+
+	if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) {
+		data = rte_pktmbuf_mtod(m, char *);
+
+		ip = (struct rte_ipv4_hdr *)(data + ROC_IE_ON_INB_RPTR_HDR);
+
+		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) == 6);
+			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;
+		m->data_off += ROC_IE_ON_INB_RPTR_HDR;
+	}
+}
+
 static inline void
 cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop,
 			      struct cpt_inflight_req *infl_req)
@@ -370,6 +439,11 @@ cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop,
 
 		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 		if (cop->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			if (cop->sess_type == RTE_CRYPTO_OP_SECURITY_SESSION) {
+				cn9k_cpt_sec_post_process(cop, infl_req);
+				return;
+			}
+
 			/* Verify authentication data if required */
 			if (unlikely(infl_req->op_flags &
 				     CPT_OP_FLAGS_AUTH_VERIFY)) {
drivers/crypto/cnxk/cn9k_ipsec_la_ops.h new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.22.0
#8 lore raw

PATCH 7/8 crypto/cnxk: update tailroom requirement

In reply to Archana Muniganti

Update min tailroom to reflect IPsec additions.
PMD crypto_cn9k & crypto_cn10k would have packet
grow into tailroom post IPsec processing.

---
 drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 2 +-
 drivers/crypto/cnxk/cnxk_cryptodev_ops.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/cnxk/cnxk_cryptodev_ops.c +1 -1
index 440dbc3adb..957c78063f 100644
@@ -155,7 +155,7 @@ cnxk_cpt_dev_info_get(struct rte_cryptodev *dev,
 	info->capabilities = cnxk_crypto_capabilities_get(vf);
 	info->sym.max_nb_sessions = 0;
 	info->min_mbuf_headroom_req = CNXK_CPT_MIN_HEADROOM_REQ;
-	info->min_mbuf_tailroom_req = 0;
+	info->min_mbuf_tailroom_req = CNXK_CPT_MIN_TAILROOM_REQ;
 }
 
 static void
drivers/crypto/cnxk/cnxk_cryptodev_ops.h +1 -0
index 0d02d44799..c5332dec53 100644
@@ -11,6 +11,7 @@
 #include "roc_api.h"
 
 #define CNXK_CPT_MIN_HEADROOM_REQ 24
+#define CNXK_CPT_MIN_TAILROOM_REQ 102
 
 /* Default command timeout in seconds */
 #define DEFAULT_COMMAND_TIMEOUT 4
Signature · 1 line
2.22.0
#9 lore raw

PATCH 8/8 crypto/cnxk: update feature flag for cn9k lookaside IPsec

In reply to Archana Muniganti

Update device feature flag to support lookaside IPsec for cn9k.

---
 doc/guides/cryptodevs/cnxk.rst          | 14 ++++++++++++--
 doc/guides/cryptodevs/features/cn9k.ini |  1 +
 doc/guides/rel_notes/release_21_11.rst  |  3 +++
 drivers/crypto/cnxk/cnxk_cryptodev.c    |  6 ++----
 4 files changed, 18 insertions(+), 6 deletions(-)
doc/guides/cryptodevs/cnxk.rst +12 -2
index 1eb72282db..752316fd37 100644
@@ -222,10 +222,20 @@ This feature can be tested with ipsec-secgw sample application.
 Supported OCTEON cnxk SoCs
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+- CN9XX
 - CN10XX
 
-Features supported
-~~~~~~~~~~~~~~~~~~
+CN9XX Features supported
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+* IPv4
+* ESP
+* Tunnel mode
+* UDP Encapsulation
+* AES-128/192/256-GCM
+
+CN10XX Features supported
+~~~~~~~~~~~~~~~~~~~~~~~~~
 
 * IPv4
 * ESP
doc/guides/cryptodevs/features/cn9k.ini +1 -0
index d69dbe8512..dd935d439d 100644
@@ -8,6 +8,7 @@ Symmetric crypto       = Y
 Asymmetric 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
doc/guides/rel_notes/release_21_11.rst +3 -0
index 70dd1c52f7..96adb93cff 100644
@@ -61,6 +61,9 @@ New Features
   * Added transport mode in lookaside protocol (IPsec).
   * Added UDP encapsulation in lookaside protocol (IPsec).
 
+* **Updated Marvell cn9k_crypto PMD.**
+
+  * Added support for lookaside protocol (IPsec) offload.
 
 Removed Items
 -------------
drivers/crypto/cnxk/cnxk_cryptodev.c +2 -4
index 9c7dc6297a..5c7801ec48 100644
@@ -21,10 +21,8 @@ cnxk_cpt_default_ff_get(void)
 		      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;
-
-	if (roc_model_is_cn10k())
-		ff |= RTE_CRYPTODEV_FF_SECURITY;
+		      RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED |
+		      RTE_CRYPTODEV_FF_SECURITY;
 
 	return ff;
 }
Signature · 1 line
2.22.0