From 4c4e86fa15229aa9bfd0fe73e5f8688257141965 Mon Sep 17 00:00:00 2001 From: Kishore Padmanabha Date: Thu, 2 Jul 2020 16:28:26 -0700 Subject: [PATCH] net/bnxt: support conditional execution of mapper tables Added support for conditional execution of the mapper tables so that actions like count will have table processed only if action count is configured. Signed-off-by: Kishore Padmanabha Signed-off-by: Venkat Duvvuru Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/ulp_mapper.c | 45 +++++++++++++++++++ drivers/net/bnxt/tf_ulp/ulp_mapper.h | 1 + drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 8 ++++ .../net/bnxt/tf_ulp/ulp_template_db_enum.h | 12 ++++- drivers/net/bnxt/tf_ulp/ulp_template_struct.h | 2 + 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c index 8cc5b23bb0..10e7186c50 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c @@ -2008,6 +2008,44 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx, return rc; } +/* + * Function to process the conditional opcode of the mapper table. + * returns 1 to skip the table. + * return 0 to continue processing the table. + */ +static int32_t +ulp_mapper_tbl_cond_opcode_process(struct bnxt_ulp_mapper_parms *parms, + struct bnxt_ulp_mapper_tbl_info *tbl) +{ + int32_t rc = 1; + + switch (tbl->cond_opcode) { + case BNXT_ULP_COND_OPCODE_NOP: + rc = 0; + break; + case BNXT_ULP_COND_OPCODE_COMP_FIELD: + if (tbl->cond_operand < BNXT_ULP_CF_IDX_LAST && + ULP_COMP_FLD_IDX_RD(parms, tbl->cond_operand)) + rc = 0; + break; + case BNXT_ULP_COND_OPCODE_ACTION_BIT: + if (ULP_BITMAP_ISSET(parms->act_bitmap->bits, + tbl->cond_operand)) + rc = 0; + break; + case BNXT_ULP_COND_OPCODE_HDR_BIT: + if (ULP_BITMAP_ISSET(parms->hdr_bitmap->bits, + tbl->cond_operand)) + rc = 0; + break; + default: + BNXT_TF_DBG(ERR, + "Invalid arg in mapper tbl for cond opcode\n"); + break; + } + return rc; +} + /* * Function to process the action template. Iterate through the list * action info templates and process it. @@ -2027,6 +2065,9 @@ ulp_mapper_action_tbls_process(struct bnxt_ulp_mapper_parms *parms) for (i = 0; i < parms->num_atbls; i++) { tbl = &parms->atbls[i]; + if (ulp_mapper_tbl_cond_opcode_process(parms, tbl)) + continue; + switch (tbl->resource_func) { case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE: rc = ulp_mapper_index_tbl_process(parms, tbl, false); @@ -2065,6 +2106,9 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms) for (i = 0; i < parms->num_ctbls; i++) { struct bnxt_ulp_mapper_tbl_info *tbl = &parms->ctbls[i]; + if (ulp_mapper_tbl_cond_opcode_process(parms, tbl)) + continue; + switch (tbl->resource_func) { case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE: rc = ulp_mapper_tcam_tbl_process(parms, tbl); @@ -2326,6 +2370,7 @@ ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx, memset(&parms, 0, sizeof(parms)); parms.act_prop = cparms->act_prop; parms.act_bitmap = cparms->act; + parms.hdr_bitmap = cparms->hdr_bitmap; parms.regfile = ®file; parms.hdr_field = cparms->hdr_field; parms.comp_fld = cparms->comp_fld; diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h index b159081b18..19134830a3 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h @@ -62,6 +62,7 @@ struct bnxt_ulp_mapper_parms { uint32_t num_ctbls; struct ulp_rte_act_prop *act_prop; struct ulp_rte_act_bitmap *act_bitmap; + struct ulp_rte_hdr_bitmap *hdr_bitmap; struct ulp_rte_hdr_field *hdr_field; uint32_t *comp_fld; struct ulp_regfile *regfile; diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 41ac77c6fe..8fffaeccee 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -1128,6 +1128,10 @@ ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item, memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE], &ip_type, sizeof(uint32_t)); + /* update the computed field to notify it is ipv4 header */ + ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG, + 1); + if (!ulp_rte_item_skip_void(&item, 1)) return BNXT_TF_RC_ERROR; } else if (item->type == RTE_FLOW_ITEM_TYPE_IPV6) { @@ -1148,6 +1152,10 @@ ulp_rte_vxlan_encap_act_handler(const struct rte_flow_action *action_item, memcpy(&ap->act_details[BNXT_ULP_ACT_PROP_IDX_ENCAP_L3_TYPE], &ip_type, sizeof(uint32_t)); + /* update the computed field to notify it is ipv6 header */ + ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG, + 1); + if (!ulp_rte_item_skip_void(&item, 1)) return BNXT_TF_RC_ERROR; } else { 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 3168d29a9a..27628a510d 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h @@ -118,7 +118,17 @@ enum bnxt_ulp_cf_idx { BNXT_ULP_CF_IDX_PHY_PORT_SPIF = 26, BNXT_ULP_CF_IDX_PHY_PORT_PARIF = 27, BNXT_ULP_CF_IDX_PHY_PORT_VPORT = 28, - BNXT_ULP_CF_IDX_LAST = 29 + BNXT_ULP_CF_IDX_ACT_ENCAP_IPV4_FLAG = 29, + BNXT_ULP_CF_IDX_ACT_ENCAP_IPV6_FLAG = 30, + BNXT_ULP_CF_IDX_LAST = 31 +}; + +enum bnxt_ulp_cond_opcode { + BNXT_ULP_COND_OPCODE_NOP = 0, + BNXT_ULP_COND_OPCODE_COMP_FIELD = 1, + BNXT_ULP_COND_OPCODE_ACTION_BIT = 2, + BNXT_ULP_COND_OPCODE_HDR_BIT = 3, + BNXT_ULP_COND_OPCODE_LAST = 4 }; enum bnxt_ulp_critical_resource { diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h index 5a7a7b910a..df999b18c6 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h +++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h @@ -165,6 +165,8 @@ struct bnxt_ulp_mapper_tbl_info { enum bnxt_ulp_resource_func resource_func; uint32_t resource_type; /* TF_ enum type */ enum bnxt_ulp_resource_sub_type resource_sub_type; + enum bnxt_ulp_cond_opcode cond_opcode; + uint32_t cond_operand; uint8_t direction; uint32_t priority; uint8_t srch_b4_alloc; -- 2.20.1