net/bnxt: add resource subtype to class and action tables
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Fri, 12 Jun 2020 12:49:59 +0000 (18:19 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 30 Jun 2020 12:52:30 +0000 (14:52 +0200)
Added support for resource sub type to class and action tables
renamed table id to resource type.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_mapper.c
drivers/net/bnxt/tf_ulp/ulp_template_db.c
drivers/net/bnxt/tf_ulp/ulp_template_db.h
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index 0fc2bff..c3c96d8 100644 (file)
@@ -889,7 +889,7 @@ ulp_mapper_action_alloc_and_set(struct bnxt_ulp_mapper_parms *parms,
 
        /* Set the allocation parameters for the table*/
        alloc_parms.dir = atbls->direction;
-       alloc_parms.type = atbls->table_type;
+       alloc_parms.type = atbls->resource_type;
        alloc_parms.search_enable = atbls->srch_b4_alloc;
        alloc_parms.result = ulp_blob_data_get(blob,
                                               &alloc_parms.result_sz_in_bytes);
@@ -910,7 +910,7 @@ ulp_mapper_action_alloc_and_set(struct bnxt_ulp_mapper_parms *parms,
        /* Need to calculate the idx for the result record */
        uint64_t tmpidx = alloc_parms.idx;
 
-       if (atbls->table_type == TF_TBL_TYPE_EXT)
+       if (atbls->resource_type == TF_TBL_TYPE_EXT)
                tmpidx = TF_ACT_REC_OFFSET_2_PTR(alloc_parms.idx);
        else
                tmpidx = alloc_parms.idx;
@@ -935,7 +935,7 @@ ulp_mapper_action_alloc_and_set(struct bnxt_ulp_mapper_parms *parms,
                uint16_t        length;
 
                set_parm.dir    = atbls->direction;
-               set_parm.type   = atbls->table_type;
+               set_parm.type   = atbls->resource_type;
                set_parm.idx    = alloc_parms.idx;
                set_parm.data   = ulp_blob_data_get(blob, &length);
                set_parm.data_sz_in_bytes = length / 8;
@@ -958,7 +958,7 @@ ulp_mapper_action_alloc_and_set(struct bnxt_ulp_mapper_parms *parms,
        memset(&fid_parms, 0, sizeof(fid_parms));
        fid_parms.direction             = atbls->direction;
        fid_parms.resource_func         = atbls->resource_func;
-       fid_parms.resource_type         = atbls->table_type;
+       fid_parms.resource_type         = atbls->resource_type;
        fid_parms.resource_hndl         = alloc_parms.idx;
        fid_parms.critical_resource     = 0;
 
@@ -1114,7 +1114,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        }
 
        aparms.dir              = tbl->direction;
-       aparms.tcam_tbl_type    = tbl->table_type;
+       aparms.tcam_tbl_type    = tbl->resource_type;
        aparms.search_enable    = tbl->srch_b4_alloc;
        aparms.key_sz_in_bits   = tbl->key_bit_size;
        aparms.key              = ulp_blob_data_get(&key, &tmplen);
@@ -1239,7 +1239,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        if (parms->tcam_tbl_opc == BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL) {
                fid_parms.direction = tbl->direction;
                fid_parms.resource_func = tbl->resource_func;
-               fid_parms.resource_type = tbl->table_type;
+               fid_parms.resource_type = tbl->resource_type;
                fid_parms.critical_resource = tbl->critical_resource;
                fid_parms.resource_hndl = aparms.idx;
                rc = ulp_flow_db_resource_add(parms->ulp_ctx,
@@ -1266,12 +1266,12 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 error:
        parms->tcam_tbl_opc = BNXT_ULP_MAPPER_TCAM_TBL_OPC_NORMAL;
        free_parms.dir                  = tbl->direction;
-       free_parms.tcam_tbl_type        = tbl->table_type;
+       free_parms.tcam_tbl_type        = tbl->resource_type;
        free_parms.idx                  = aparms.idx;
        trc = tf_free_tcam_entry(tfp, &free_parms);
        if (trc)
                BNXT_TF_DBG(ERR, "Failed to free tcam[%d][%d][%d] on failure\n",
-                           tbl->table_type, tbl->direction, aparms.idx);
+                           tbl->resource_type, tbl->direction, aparms.idx);
 
        return rc;
 }
@@ -1286,7 +1286,6 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        uint32_t i, num_kflds, num_dflds;
        uint16_t tmplen;
        struct tf *tfp = bnxt_ulp_cntxt_tfp_get(parms->ulp_ctx);
-       struct ulp_rte_act_prop  *a_prop = parms->act_prop;
        struct ulp_flow_db_res_params   fid_parms = { 0 };
        struct tf_insert_em_entry_parms iparms = { 0 };
        struct tf_delete_em_entry_parms free_parms = { 0 };
@@ -1359,7 +1358,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
         */
        iparms.dup_check                = 0;
        iparms.dir                      = tbl->direction;
-       iparms.mem                      = tbl->table_type;
+       iparms.mem                      = tbl->resource_type;
        iparms.key                      = ulp_blob_data_get(&key, &tmplen);
        iparms.key_sz_in_bits           = tbl->key_bit_size;
        iparms.em_record                = ulp_blob_data_get(&data, &tmplen);
@@ -1371,63 +1370,11 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
                return rc;
        }
 
-       if (tbl->mark_enable &&
-           ULP_BITMAP_ISSET(parms->act_bitmap->bits,
-                            BNXT_ULP_ACTION_BIT_MARK)) {
-               uint32_t val, mark, gfid, flag;
-               /* TBD: Need to determine if GFID is enabled globally */
-               if (sizeof(val) != BNXT_ULP_ACT_PROP_SZ_MARK) {
-                       BNXT_TF_DBG(ERR, "Mark size (%d) != expected (%zu)\n",
-                                   BNXT_ULP_ACT_PROP_SZ_MARK, sizeof(val));
-                       rc = -EINVAL;
-                       goto error;
-               }
-
-               memcpy(&val,
-                      &a_prop->act_details[BNXT_ULP_ACT_PROP_IDX_MARK],
-                      sizeof(val));
-
-               mark = tfp_be_to_cpu_32(val);
-
-               TF_GET_GFID_FROM_FLOW_ID(iparms.flow_id, gfid);
-               flag = BNXT_ULP_MARK_GLOBAL_HW_FID;
-               rc = ulp_mark_db_mark_add(parms->ulp_ctx,
-                                         flag,
-                                         gfid,
-                                         mark);
-               if (rc) {
-                       BNXT_TF_DBG(ERR, "Failed to add mark to flow\n");
-                       goto error;
-               }
-
-               /*
-                * Link the mark resource to the flow in the flow db
-                * The mark is never the critical resource, so it is 0.
-                */
-               memset(&fid_parms, 0, sizeof(fid_parms));
-               fid_parms.direction     = tbl->direction;
-               fid_parms.resource_func = BNXT_ULP_RESOURCE_FUNC_HW_FID;
-               fid_parms.resource_type = flag;
-               fid_parms.resource_hndl = gfid;
-               fid_parms.critical_resource = 0;
-
-               rc = ulp_flow_db_resource_add(parms->ulp_ctx,
-                                             parms->tbl_idx,
-                                             parms->fid,
-                                             &fid_parms);
-               if (rc) {
-                       BNXT_TF_DBG(ERR, "Fail to link res to flow rc = %d\n",
-                                   rc);
-                       /* Need to free the identifier, so goto error */
-                       goto error;
-               }
-       }
-
        /* Link the EM resource to the flow in the flow db */
        memset(&fid_parms, 0, sizeof(fid_parms));
        fid_parms.direction             = tbl->direction;
        fid_parms.resource_func         = tbl->resource_func;
-       fid_parms.resource_type         = tbl->table_type;
+       fid_parms.resource_type         = tbl->resource_type;
        fid_parms.critical_resource     = tbl->critical_resource;
        fid_parms.resource_hndl         = iparms.flow_handle;
 
@@ -1499,7 +1446,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        }
 
        aparms.dir              = tbl->direction;
-       aparms.type             = tbl->table_type;
+       aparms.type             = tbl->resource_type;
        aparms.search_enable    = tbl->srch_b4_alloc;
        aparms.result           = ulp_blob_data_get(&data, &tmplen);
        aparms.result_sz_in_bytes = ULP_SZ_BITS2BYTES(tbl->result_bit_size);
@@ -1509,7 +1456,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        rc = tf_alloc_tbl_entry(tfp, &aparms);
        if (rc) {
                BNXT_TF_DBG(ERR, "Alloc table[%d][%s] failed rc=%d\n",
-                           tbl->table_type,
+                           tbl->resource_type,
                            (tbl->direction == TF_DIR_RX) ? "RX" : "TX",
                            rc);
                return rc;
@@ -1526,7 +1473,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
        if (!tbl->srch_b4_alloc) {
                sparms.dir              = tbl->direction;
-               sparms.type             = tbl->table_type;
+               sparms.type             = tbl->resource_type;
                sparms.data             = ulp_blob_data_get(&data, &tmplen);
                sparms.data_sz_in_bytes =
                        ULP_SZ_BITS2BYTES(tbl->result_bit_size);
@@ -1536,7 +1483,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
                rc = tf_set_tbl_entry(tfp, &sparms);
                if (rc) {
                        BNXT_TF_DBG(ERR, "Set table[%d][%s][%d] failed rc=%d\n",
-                                   tbl->table_type,
+                                   tbl->resource_type,
                                    (tbl->direction == TF_DIR_RX) ? "RX" : "TX",
                                    sparms.idx,
                                    rc);
@@ -1549,7 +1496,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        memset(&fid_parms, 0, sizeof(fid_parms));
        fid_parms.direction     = tbl->direction;
        fid_parms.resource_func = tbl->resource_func;
-       fid_parms.resource_type = tbl->table_type;
+       fid_parms.resource_type = tbl->resource_type;
        fid_parms.resource_hndl = aparms.idx;
        fid_parms.critical_resource     = 0;
 
@@ -1570,7 +1517,7 @@ error:
         * write to the entry or link the flow
         */
        free_parms.dir  = tbl->direction;
-       free_parms.type = tbl->table_type;
+       free_parms.type = tbl->resource_type;
        free_parms.idx  = aparms.idx;
        free_parms.tbl_scope_id = tbl_scope_id;
 
@@ -1697,7 +1644,7 @@ ulp_mapper_cache_tbl_process(struct bnxt_ulp_mapper_parms *parms,
         * need to set it appropriately via setter.
         */
        ulp_mapper_cache_res_type_set(&fid_parms,
-                                     tbl->table_type,
+                                     tbl->resource_type,
                                      tbl->cache_tbl_id);
        fid_parms.resource_hndl = (uint64_t)*ckey;
        fid_parms.critical_resource = tbl->critical_resource;
index c6b1b9b..9b793a2 100644 (file)
@@ -590,7 +590,8 @@ struct bnxt_ulp_mapper_tbl_list_info ulp_class_tmpl_list[] = {
 struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE,
-       .table_type = TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
+       .resource_type = TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
+       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_TT_L2_CNTXT_TCAM_CACHE,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_NOT_USED,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -610,7 +611,8 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
-       .table_type = TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
+       .resource_type = TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
+       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_LEVEL_0,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -630,7 +632,8 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE,
-       .table_type = TF_TCAM_TBL_TYPE_PROF_TCAM,
+       .resource_type = TF_TCAM_TBL_TYPE_PROF_TCAM,
+       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_TT_PROFILE_TCAM_CACHE,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_NOT_USED,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -650,7 +653,8 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
-       .table_type = TF_TCAM_TBL_TYPE_PROF_TCAM,
+       .resource_type = TF_TCAM_TBL_TYPE_PROF_TCAM,
+       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_TT_PROFILE_TCAM_CACHE,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_LEVEL_0,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -670,7 +674,8 @@ struct bnxt_ulp_mapper_class_tbl_info ulp_class_tbl_list[] = {
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
-       .table_type = TF_MEM_EXTERNAL,
+       .resource_type = TF_MEM_EXTERNAL,
+       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_NOT_USED,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -1613,7 +1618,8 @@ struct bnxt_ulp_mapper_tbl_list_info ulp_act_tmpl_list[] = {
 struct bnxt_ulp_mapper_act_tbl_info ulp_act_tbl_list[] = {
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE,
-       .table_type = TF_TBL_TYPE_EXT,
+       .resource_type = TF_TBL_TYPE_EXT,
+       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_IT_NORMAL,
        .direction = TF_DIR_RX,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
        .result_start_idx = 0,
index 8c527bc..a2cb11d 100644 (file)
@@ -209,19 +209,6 @@ enum bnxt_ulp_regfile_index {
        BNXT_ULP_REGFILE_INDEX_LAST = 16
 };
 
-enum bnxt_ulp_resource_func {
-       BNXT_ULP_RESOURCE_FUNC_INVALID = 0x00,
-       BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 0x20,
-       BNXT_ULP_RESOURCE_FUNC_RSVD1 = 0x40,
-       BNXT_ULP_RESOURCE_FUNC_RSVD2 = 0x60,
-       BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0x80,
-       BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 0x81,
-       BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE = 0x82,
-       BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 0x83,
-       BNXT_ULP_RESOURCE_FUNC_IF_TABLE = 0x84,
-       BNXT_ULP_RESOURCE_FUNC_HW_FID = 0x85
-};
-
 enum bnxt_ulp_result_opc {
        BNXT_ULP_RESULT_OPC_SET_TO_CONSTANT = 0,
        BNXT_ULP_RESULT_OPC_SET_TO_ACT_PROP = 1,
@@ -287,6 +274,29 @@ enum bnxt_ulp_match_type_bitmask {
        BNXT_ULP_MATCH_TYPE_BITMASK_WM = 0x0000000000000001
 };
 
+enum bnxt_ulp_resource_func {
+       BNXT_ULP_RESOURCE_FUNC_INVALID = 0x00,
+       BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 0x20,
+       BNXT_ULP_RESOURCE_FUNC_RSVD1 = 0x40,
+       BNXT_ULP_RESOURCE_FUNC_RSVD2 = 0x60,
+       BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0x80,
+       BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 0x81,
+       BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE = 0x82,
+       BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 0x83,
+       BNXT_ULP_RESOURCE_FUNC_IF_TABLE = 0x84,
+       BNXT_ULP_RESOURCE_FUNC_HW_FID = 0x85
+};
+
+enum bnxt_ulp_resource_sub_type {
+       BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED = 0,
+       BNXT_ULP_RESOURCE_SUB_TYPE_IT_NORMAL = 0,
+       BNXT_ULP_RESOURCE_SUB_TYPE_IT_VFR_ACT_IDX = 1,
+       BNXT_ULP_RESOURCE_SUB_TYPE_IT_INT_CNT_IDX = 2,
+       BNXT_ULP_RESOURCE_SUB_TYPE_IT_EXT_CNT_IDX = 3,
+       BNXT_ULP_RESOURCE_SUB_TYPE_TT_L2_CNTXT_TCAM_CACHE = 0,
+       BNXT_ULP_RESOURCE_SUB_TYPE_TT_PROFILE_TCAM_CACHE = 1
+};
+
 enum bnxt_ulp_sym {
        BNXT_ULP_SYM_BIG_ENDIAN = 0,
        BNXT_ULP_SYM_DECAP_FUNC_NONE = 0,
index 3cbed24..ce449d0 100644 (file)
@@ -157,7 +157,8 @@ struct bnxt_ulp_mapper_tbl_list_info {
 
 struct bnxt_ulp_mapper_class_tbl_info {
        enum bnxt_ulp_resource_func     resource_func;
-       uint32_t        table_type;
+       uint32_t                        resource_type; /* TF_ enum type */
+       enum bnxt_ulp_resource_sub_type resource_sub_type;
        uint8_t         direction;
        uint32_t        priority;
        uint8_t         srch_b4_alloc;
@@ -187,7 +188,8 @@ struct bnxt_ulp_mapper_class_tbl_info {
 
 struct bnxt_ulp_mapper_act_tbl_info {
        enum bnxt_ulp_resource_func     resource_func;
-       enum tf_tbl_type table_type;
+       uint32_t                        resource_type; /* TF_ enum type */
+       enum bnxt_ulp_resource_sub_type resource_sub_type;
        uint8_t         direction;
        uint8_t         srch_b4_alloc;
        uint32_t        result_start_idx;