net/cnxk: update ethertype for mixed IPsec tunnel versions
authorSrujana Challa <schalla@marvell.com>
Fri, 1 Oct 2021 13:40:18 +0000 (19:10 +0530)
committerJerin Jacob <jerinj@marvell.com>
Sat, 2 Oct 2021 13:45:27 +0000 (15:45 +0200)
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>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/cnxk_security.c
drivers/net/cnxk/cn10k_ethdev.h
drivers/net/cnxk/cn10k_ethdev_sec.c
drivers/net/cnxk/cn10k_tx.h

index c117fa7..0039a9d 100644 (file)
@@ -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();
 
index 200cd93..c2a46ad 100644 (file)
@@ -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;
index dae5ea7..c66730a 100644 (file)
@@ -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;
index 52bb71d..ad84464 100644 (file)
@@ -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;