From: Kishore Padmanabha Date: Fri, 11 Sep 2020 01:55:57 +0000 (-0700) Subject: net/bnxt: enable NAT action with tagged traffic X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a2e216f812e39227056664fa421ea920aed9b905;p=dpdk.git net/bnxt: enable NAT action with tagged traffic Added support for performing L3 or L4 rewrite for VLAN tagged flows. The outer most DMAC, SMAC and VLAN are used to overwrite when NAT operations are performed. Signed-off-by: Kishore Padmanabha Reviewed-by: Mike Baucom Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index eae8884bd2..364853a6e5 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -721,15 +721,11 @@ bnxt_ulp_deinit(struct bnxt *bp, /* Disable NAT feature */ (void)bnxt_ulp_global_cfg_update(bp, TF_DIR_RX, TF_TUNNEL_ENCAP, TF_TUNNEL_ENCAP_NAT, - (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | - BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), - 0); + BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0); (void)bnxt_ulp_global_cfg_update(bp, TF_DIR_TX, TF_TUNNEL_ENCAP, TF_TUNNEL_ENCAP_NAT, - (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | - BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), - 0); + BNXT_ULP_NAT_OUTER_MOST_FLAGS, 0); /* Delete the ulp context and tf session and free the ulp context */ ulp_ctx_deinit(bp, session); @@ -808,8 +804,7 @@ bnxt_ulp_init(struct bnxt *bp, */ rc = bnxt_ulp_global_cfg_update(bp, TF_DIR_RX, TF_TUNNEL_ENCAP, TF_TUNNEL_ENCAP_NAT, - (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | - BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), 1); + BNXT_ULP_NAT_OUTER_MOST_FLAGS, 1); if (rc) { BNXT_TF_DBG(ERR, "Failed to set rx global configuration\n"); goto jump_to_error; @@ -817,8 +812,7 @@ bnxt_ulp_init(struct bnxt *bp, rc = bnxt_ulp_global_cfg_update(bp, TF_DIR_TX, TF_TUNNEL_ENCAP, TF_TUNNEL_ENCAP_NAT, - (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | - BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), 1); + BNXT_ULP_NAT_OUTER_MOST_FLAGS, 1); if (rc) { BNXT_TF_DBG(ERR, "Failed to set tx global configuration\n"); goto jump_to_error; diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h index 5882c545c8..ed978734ac 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h @@ -16,7 +16,13 @@ /* NAT defines to reuse existing inner L2 SMAC and DMAC */ #define BNXT_ULP_NAT_INNER_L2_HEADER_SMAC 0x2000 +#define BNXT_ULP_NAT_OUTER_MOST_L2_HDR_SMAC 0x6000 +#define BNXT_ULP_NAT_OUTER_MOST_L2_VLAN_TAGS 0xc00 #define BNXT_ULP_NAT_INNER_L2_HEADER_DMAC 0x100 +#define BNXT_ULP_NAT_OUTER_MOST_L2_HDR_DMAC 0x300 +#define BNXT_ULP_NAT_OUTER_MOST_FLAGS (BNXT_ULP_NAT_OUTER_MOST_L2_HDR_SMAC |\ + BNXT_ULP_NAT_OUTER_MOST_L2_VLAN_TAGS |\ + BNXT_ULP_NAT_OUTER_MOST_L2_HDR_DMAC) /* defines for the ulp_flags */ #define BNXT_ULP_VF_REP_ENABLED 0x1 diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 6ac4b0f83b..15682673d8 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -783,6 +783,7 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms, uint32_t val_size = 0, field_size = 0; uint64_t act_bit; uint8_t act_val; + uint64_t hdr_bit; switch (fld->result_opcode) { case BNXT_ULP_MAPPER_OPC_SET_TO_CONSTANT: @@ -1033,6 +1034,26 @@ ulp_mapper_result_field_process(struct bnxt_ulp_mapper_parms *parms, return -EINVAL; } break; + case BNXT_ULP_MAPPER_OPC_IF_HDR_BIT_THEN_CONST_ELSE_CONST: + if (!ulp_operand_read(fld->result_operand, + (uint8_t *)&hdr_bit, sizeof(uint64_t))) { + BNXT_TF_DBG(ERR, "%s operand read failed\n", name); + return -EINVAL; + } + hdr_bit = tfp_be_to_cpu_64(hdr_bit); + if (ULP_BITMAP_ISSET(parms->hdr_bitmap->bits, hdr_bit)) { + /* Header bit is set so consider operand_true */ + val = fld->result_operand_true; + } else { + /* Header bit is not set, use the operand false */ + val = fld->result_operand_false; + } + if (!ulp_blob_push(blob, val, fld->field_bit_size)) { + BNXT_TF_DBG(ERR, "%s failed to add field\n", + name); + return -EINVAL; + } + break; default: BNXT_TF_DBG(ERR, "invalid result mapper opcode 0x%x\n", fld->result_opcode); diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c b/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c index cab3445a23..22142c1377 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_act.c @@ -1434,11 +1434,21 @@ struct bnxt_ulp_mapper_result_field_info ulp_act_result_field_list[] = { }, { .field_bit_size = 4, - .result_opcode = BNXT_ULP_MAPPER_OPC_SET_TO_CONSTANT, - .result_operand = { - BNXT_ULP_SYM_DECAP_FUNC_THRU_L2, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + .result_opcode = BNXT_ULP_MAPPER_OPC_IF_HDR_BIT_THEN_CONST_ELSE_CONST, + .result_operand = { + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 56) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 48) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 40) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 32) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 24) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 16) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 8) & 0xff, + (uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN & 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .result_operand_true = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .result_operand_false = {0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, { .field_bit_size = 12, @@ -2336,11 +2346,21 @@ struct bnxt_ulp_mapper_result_field_info ulp_act_result_field_list[] = { }, { .field_bit_size = 4, - .result_opcode = BNXT_ULP_MAPPER_OPC_SET_TO_CONSTANT, - .result_operand = { - BNXT_ULP_SYM_DECAP_FUNC_THRU_L2, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + .result_opcode = BNXT_ULP_MAPPER_OPC_IF_HDR_BIT_THEN_CONST_ELSE_CONST, + .result_operand = { + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 56) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 48) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 40) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 32) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 24) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 16) & 0xff, + ((uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN >> 8) & 0xff, + (uint64_t)BNXT_ULP_HDR_BIT_T_VXLAN & 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .result_operand_true = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .result_operand_false = {0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }, { .field_bit_size = 12, diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h index 4c1161acd2..51758868a2 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h @@ -218,7 +218,8 @@ enum bnxt_ulp_mapper_opc { BNXT_ULP_MAPPER_OPC_IF_ACT_BIT_THEN_ACT_PROP_ELSE_CONST = 9, BNXT_ULP_MAPPER_OPC_IF_ACT_BIT_THEN_CONST_ELSE_CONST = 10, BNXT_ULP_MAPPER_OPC_IF_COMP_FIELD_THEN_CF_ELSE_CF = 11, - BNXT_ULP_MAPPER_OPC_LAST = 12 + BNXT_ULP_MAPPER_OPC_IF_HDR_BIT_THEN_CONST_ELSE_CONST = 12, + BNXT_ULP_MAPPER_OPC_LAST = 13 }; enum bnxt_ulp_mark_db_opcode {