From 9d422a38be596d571270efc7e2d7b25a877e8beb Mon Sep 17 00:00:00 2001 From: Srujana Challa Date: Fri, 1 Oct 2021 19:10:18 +0530 Subject: [PATCH] net/cnxk: update ethertype for mixed IPsec tunnel versions Adds support to update ethertype for mixed IPsec tunnel versions. And also sets et_overwr for inbound IPsec. Signed-off-by: Srujana Challa Acked-by: Jerin Jacob --- 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 --git a/drivers/common/cnxk/cnxk_security.c b/drivers/common/cnxk/cnxk_security.c index c117fa70d0..0039a9d6ab 100644 --- a/drivers/common/cnxk/cnxk_security.c +++ b/drivers/common/cnxk/cnxk_security.c @@ -344,6 +344,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 200cd9356f..c2a46ad7ec 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 dae5ea7aa2..c66730aa37 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 52bb71d27f..ad84464727 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;