diff mbox series

[23/27] net/cnxk: update ethertype for mixed IPsec tunnel versions

Message ID 20210902021505.17607-24-ndabilpuram@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Jerin Jacob
Headers show
Series net/cnxk: support for inline ipsec | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Nithin Dabilpuram Sept. 2, 2021, 2:15 a.m. UTC
From: Srujana Challa <schalla@marvell.com>

Adds support to update ethertype for mixed IPsec tunnel
versions. And also sets et_overwr for inbound IPsec.

Signed-off-by: Srujana Challa <schalla@marvell.com>
---
 drivers/common/cnxk/cnxk_security.c |  1 +
 drivers/net/cnxk/cn10k_ethdev.h     |  3 ++-
 drivers/net/cnxk/cn10k_ethdev_sec.c |  2 ++
 drivers/net/cnxk/cn10k_tx.h         | 19 +++++++++++++++++++
 4 files changed, 24 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/common/cnxk/cnxk_security.c b/drivers/common/cnxk/cnxk_security.c
index c25b3fd..90b5205 100644
--- a/drivers/common/cnxk/cnxk_security.c
+++ b/drivers/common/cnxk/cnxk_security.c
@@ -239,6 +239,7 @@  cnxk_ot_ipsec_inb_sa_fill(struct roc_ot_ipsec_inb_sa *sa,
 	/* There are two words of CPT_CTX_HW_S for ucode to skip */
 	sa->w0.s.ctx_hdr_size = 1;
 	sa->w0.s.aop_valid = 1;
+	sa->w0.s.et_ovrwr = 1;
 
 	rte_wmb();
 
diff --git a/drivers/net/cnxk/cn10k_ethdev.h b/drivers/net/cnxk/cn10k_ethdev.h
index 200cd93..c2a46ad 100644
--- a/drivers/net/cnxk/cn10k_ethdev.h
+++ b/drivers/net/cnxk/cn10k_ethdev.h
@@ -64,7 +64,8 @@  struct cn10k_sec_sess_priv {
 		struct {
 			uint32_t sa_idx;
 			uint8_t inb_sa : 1;
-			uint8_t rsvd1 : 2;
+			uint8_t outer_ip_ver : 1;
+			uint8_t mode : 1;
 			uint8_t roundup_byte : 5;
 			uint8_t roundup_len;
 			uint16_t partial_len;
diff --git a/drivers/net/cnxk/cn10k_ethdev_sec.c b/drivers/net/cnxk/cn10k_ethdev_sec.c
index dae5ea7..c66730a 100644
--- a/drivers/net/cnxk/cn10k_ethdev_sec.c
+++ b/drivers/net/cnxk/cn10k_ethdev_sec.c
@@ -341,6 +341,8 @@  cn10k_eth_sec_session_create(void *device,
 		sess_priv.roundup_byte = rlens->roundup_byte;
 		sess_priv.roundup_len = rlens->roundup_len;
 		sess_priv.partial_len = rlens->partial_len;
+		sess_priv.mode = outb_sa->w2.s.ipsec_mode;
+		sess_priv.outer_ip_ver = outb_sa->w2.s.outer_ip_ver;
 
 		/* Pointer from eth_sec -> outb_sa */
 		eth_sec->sa = outb_sa;
diff --git a/drivers/net/cnxk/cn10k_tx.h b/drivers/net/cnxk/cn10k_tx.h
index 70ba929..f56aa8e 100644
--- a/drivers/net/cnxk/cn10k_tx.h
+++ b/drivers/net/cnxk/cn10k_tx.h
@@ -302,6 +302,16 @@  cn10k_nix_prep_sec_vec(struct rte_mbuf *m, uint64x2_t *cmd0, uint64x2_t *cmd1,
 	cmd23 = vsetq_lane_u64((uintptr_t)m | 1, cmd23, 1);
 
 	dptr += l2_len;
+
+	if (sess_priv.mode == ROC_IE_SA_MODE_TUNNEL) {
+		if (sess_priv.outer_ip_ver == ROC_IE_SA_IP_VERSION_4)
+			*((uint16_t *)(dptr - 2)) =
+				rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+		else
+			*((uint16_t *)(dptr - 2)) =
+				rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
+	}
+
 	ucode_cmd[1] = dptr;
 	ucode_cmd[2] = dptr;
 
@@ -396,6 +406,15 @@  cn10k_nix_prep_sec(struct rte_mbuf *m, uint64_t *cmd, uintptr_t *nixtx_addr,
 	cmd23 = vsetq_lane_u64((uintptr_t)m | 1, cmd23, 1);
 
 	dptr += l2_len;
+
+	if (sess_priv.mode == ROC_IE_SA_MODE_TUNNEL) {
+		if (sess_priv.outer_ip_ver == ROC_IE_SA_IP_VERSION_4)
+			*((uint16_t *)(dptr - 2)) =
+				rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+		else
+			*((uint16_t *)(dptr - 2)) =
+				rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
+	}
 	ucode_cmd[1] = dptr;
 	ucode_cmd[2] = dptr;