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 <schalla@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
This commit is contained in:
Srujana Challa 2021-10-01 19:10:18 +05:30 committed by Jerin Jacob
parent 34639f305e
commit 9d422a38be
4 changed files with 24 additions and 1 deletions

View 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();

View 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;

View 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;

View 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;