net/bnxt: support conditional execution of mapper tables
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Thu, 2 Jul 2020 23:28:26 +0000 (16:28 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:27 +0000 (23:38 +0200)
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 <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_mapper.c
drivers/net/bnxt/tf_ulp/ulp_mapper.h
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index 8cc5b23..10e7186 100644 (file)
@@ -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 = &regfile;
        parms.hdr_field = cparms->hdr_field;
        parms.comp_fld = cparms->comp_fld;
index b159081..1913483 100644 (file)
@@ -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;
index 41ac77c..8fffaec 100644 (file)
@@ -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 {
index 3168d29..27628a5 100644 (file)
@@ -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 {
index 5a7a7b9..df999b1 100644 (file)
@@ -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;