net/bnxt: refactor and rename some fields and enums
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Fri, 12 Jun 2020 12:50:08 +0000 (18:20 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 30 Jun 2020 12:52:30 +0000 (14:52 +0200)
- rename regfile_wr_idx to regfile_idx
  The regfile index shall be used for both write and read operations.
  Hence the field is renamed.
- remove the unused enum BNXT_ULP_REGFILE_INDEX_CACHE_ENTRY_PTR
- rename the enums in the bnxt_ulp_resource_sub_type
  The enums in the bnxt_ulp_resource_sub_type are renamed to reflect
  the table types explicitly.
- rename an enum in the regfile index
  The BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN is renamed to
  BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR since it is the main
  action pointer.
- remove cache_tbl_id enums
  The bnxt_ulp_cache_tbl_id enums are not required any longer
  since the index is now calculated using resource sub type
  and direction.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Signed-off-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_template_db.c
drivers/net/bnxt/tf_ulp/ulp_template_db.h
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index 9c53451..b0bdfbf 100644 (file)
@@ -540,7 +540,7 @@ ulp_mapper_ident_process(struct bnxt_ulp_mapper_parms *parms,
                return -EINVAL;
        }
 
-       idx = ident->regfile_wr_idx;
+       idx = ident->regfile_idx;
 
        iparms.ident_type = ident->ident_type;
        iparms.dir = tbl->direction;
@@ -956,7 +956,7 @@ ulp_mapper_mark_act_ptr_process(struct bnxt_ulp_mapper_parms *parms,
        mark = tfp_be_to_cpu_32(mark);
 
        if (!ulp_regfile_read(parms->regfile,
-                             BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN,
+                             BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR,
                              &val64)) {
                BNXT_TF_DBG(ERR, "read action ptr main failed\n");
                return -EINVAL;
@@ -1465,10 +1465,10 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 
        /* Always storing values in Regfile in BE */
        idx = tfp_cpu_to_be_64(idx);
-       rc = ulp_regfile_write(parms->regfile, tbl->regfile_wr_idx, idx);
+       rc = ulp_regfile_write(parms->regfile, tbl->regfile_idx, idx);
        if (!rc) {
                BNXT_TF_DBG(ERR, "Write regfile[%d] failed\n",
-                           tbl->regfile_wr_idx);
+                           tbl->regfile_idx);
                goto error;
        }
 
@@ -1624,7 +1624,7 @@ ulp_mapper_cache_tbl_process(struct bnxt_ulp_mapper_parms *parms,
                for (i = 0; i < num_idents; i++) {
                        regval = (uint64_t)cache_entry->idents[i];
                        if (!ulp_regfile_write(parms->regfile,
-                                              idents[i].regfile_wr_idx,
+                                              idents[i].regfile_idx,
                                               tfp_cpu_to_be_64(regval))) {
                                BNXT_TF_DBG(ERR,
                                            "Failed to write to regfile\n");
index 5bc6b25..809bc75 100644 (file)
@@ -294,18 +294,6 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = {
 };
 
 struct bnxt_ulp_cache_tbl_params ulp_cache_tbl_params[] = {
-       [BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_INGRESS] = {
-               .num_entries             = 16384
-       },
-       [BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_EGRESS] = {
-               .num_entries             = 16384
-       },
-       [BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_INGRESS] = {
-               .num_entries             = 16384
-       },
-       [BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_EGRESS] = {
-               .num_entries             = 16384
-       }
 };
 
 struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
@@ -591,7 +579,8 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE,
        .resource_type = TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
-       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_TT_L2_CNTXT_TCAM_CACHE,
+       .resource_sub_type =
+               BNXT_ULP_RESOURCE_SUB_TYPE_CACHE_TYPE_L2_CNTXT_TCAM,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_NOT_USED,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -607,12 +596,13 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .ident_nums = 1,
        .mark_enable = BNXT_ULP_MARK_ENABLE_NO,
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
        .resource_type = TF_TCAM_TBL_TYPE_L2_CTXT_TCAM,
-       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
+       .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,
@@ -628,12 +618,13 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .ident_nums = 0,
        .mark_enable = BNXT_ULP_MARK_ENABLE_NO,
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE,
        .resource_type = TF_TCAM_TBL_TYPE_PROF_TCAM,
-       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_TT_PROFILE_TCAM_CACHE,
+       .resource_sub_type =
+               BNXT_ULP_RESOURCE_SUB_TYPE_CACHE_TYPE_PROFILE_TCAM,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_NOT_USED,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -649,12 +640,13 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .ident_nums = 1,
        .mark_enable = BNXT_ULP_MARK_ENABLE_NO,
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
        .resource_type = TF_TCAM_TBL_TYPE_PROF_TCAM,
-       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_TT_PROFILE_TCAM_CACHE,
+       .resource_sub_type =
+               BNXT_ULP_RESOURCE_SUB_TYPE_CACHE_TYPE_PROFILE_TCAM,
        .direction = TF_DIR_RX,
        .priority = BNXT_ULP_PRIORITY_LEVEL_0,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
@@ -670,12 +662,13 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .ident_nums = 0,
        .mark_enable = BNXT_ULP_MARK_ENABLE_NO,
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
        .resource_type = TF_MEM_EXTERNAL,
-       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
+       .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,
@@ -691,7 +684,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .ident_nums = 0,
        .mark_enable = BNXT_ULP_MARK_ENABLE_YES,
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_YES,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_NOT_USED
        }
 };
 
@@ -1532,8 +1525,8 @@ struct bnxt_ulp_mapper_result_field_info ulp_class_result_field_list[] = {
        {
        .field_bit_size = 33,
        .result_opcode = BNXT_ULP_RESULT_OPC_SET_TO_REGFILE,
-       .result_operand = {(BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN >> 8) & 0xff,
-               BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN & 0xff,
+       .result_operand = {(BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR >> 8) & 0xff,
+               BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR & 0xff,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
        },
@@ -1593,14 +1586,14 @@ struct bnxt_ulp_mapper_ident_info ulp_ident_list[] = {
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_IDENTIFIER,
        .ident_type = TF_IDENT_TYPE_L2_CTXT,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_L2_CNTXT_ID_0,
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_L2_CNTXT_ID_0,
        .ident_bit_size = 10,
        .ident_bit_pos = 0
        },
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_IDENTIFIER,
        .ident_type = TF_IDENT_TYPE_EM_PROF,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_EM_PROFILE_ID_0,
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_EM_PROFILE_ID_0,
        .ident_bit_size = 10,
        .ident_bit_pos = 0
        }
@@ -1619,14 +1612,15 @@ struct bnxt_ulp_mapper_tbl_info ulp_act_tbl_list[] = {
        {
        .resource_func = BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE,
        .resource_type = TF_TBL_TYPE_EXT,
-       .resource_sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_IT_NORMAL,
+       .resource_sub_type =
+               BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_NORMAL,
        .direction = TF_DIR_RX,
        .srch_b4_alloc = BNXT_ULP_SEARCH_BEFORE_ALLOC_NO,
        .result_start_idx = 0,
        .result_bit_size = 128,
        .result_num_fields = 26,
        .encap_num_fields = 0,
-       .regfile_wr_idx = BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN
+       .regfile_idx = BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR
        }
 };
 
index dd0c42a..8acf76e 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef ULP_TEMPLATE_DB_H_
 #define ULP_TEMPLATE_DB_H_
 
-#define BNXT_ULP_REGFILE_MAX_SZ 16
+#define BNXT_ULP_REGFILE_MAX_SZ 15
 #define BNXT_ULP_MAX_NUM_DEVICES 4
 #define BNXT_ULP_LOG2_MAX_NUM_DEV 2
 #define BNXT_ULP_CACHE_TBL_MAX_SZ 4
@@ -88,14 +88,6 @@ enum bnxt_ulp_byte_order {
        BNXT_ULP_BYTE_ORDER_LAST = 2
 };
 
-enum bnxt_ulp_cache_tbl_id {
-       BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_INGRESS = 0,
-       BNXT_ULP_CACHE_TBL_ID_L2_CNTXT_TCAM_EGRESS = 1,
-       BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_INGRESS = 2,
-       BNXT_ULP_CACHE_TBL_ID_PROFILE_TCAM_EGRESS = 3,
-       BNXT_ULP_CACHE_TBL_ID_LAST = 4
-};
-
 enum bnxt_ulp_cf_idx {
        BNXT_ULP_CF_IDX_MPLS_TAG_NUM = 0,
        BNXT_ULP_CF_IDX_O_VTAG_NUM = 1,
@@ -205,14 +197,13 @@ enum bnxt_ulp_regfile_index {
        BNXT_ULP_REGFILE_INDEX_EM_PROFILE_ID_1 = 6,
        BNXT_ULP_REGFILE_INDEX_WC_PROFILE_ID_0 = 7,
        BNXT_ULP_REGFILE_INDEX_WC_PROFILE_ID_1 = 8,
-       BNXT_ULP_REGFILE_INDEX_ACTION_PTR_MAIN = 9,
+       BNXT_ULP_REGFILE_INDEX_MAIN_ACTION_PTR = 9,
        BNXT_ULP_REGFILE_INDEX_ACTION_PTR_0 = 10,
        BNXT_ULP_REGFILE_INDEX_ENCAP_PTR_0 = 11,
        BNXT_ULP_REGFILE_INDEX_ENCAP_PTR_1 = 12,
        BNXT_ULP_REGFILE_INDEX_CRITICAL_RESOURCE = 13,
-       BNXT_ULP_REGFILE_INDEX_CACHE_ENTRY_PTR = 14,
-       BNXT_ULP_REGFILE_INDEX_NOT_USED = 15,
-       BNXT_ULP_REGFILE_INDEX_LAST = 16
+       BNXT_ULP_REGFILE_INDEX_NOT_USED = 14,
+       BNXT_ULP_REGFILE_INDEX_LAST = 15
 };
 
 enum bnxt_ulp_result_opc {
@@ -295,13 +286,13 @@ enum bnxt_ulp_resource_func {
 };
 
 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
+       BNXT_ULP_RESOURCE_SUB_TYPE_CACHE_TYPE_L2_CNTXT_TCAM = 0,
+       BNXT_ULP_RESOURCE_SUB_TYPE_CACHE_TYPE_PROFILE_TCAM = 1,
+       BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_EXT_CNT_IDX = 3,
+       BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_CNT_IDX = 2,
+       BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_NORMAL = 0,
+       BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_ACT_IDX = 1,
+       BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED = 0
 };
 
 enum bnxt_ulp_sym {
index 86a0e5c..4ca6049 100644 (file)
@@ -183,6 +183,7 @@ struct bnxt_ulp_mapper_tbl_info {
 
        uint8_t         mark_enable;
        enum bnxt_ulp_regfile_index     regfile_wr_idx;
+       enum bnxt_ulp_regfile_index     regfile_idx;
 };
 
 struct bnxt_ulp_mapper_class_key_field_info {
@@ -208,7 +209,7 @@ struct bnxt_ulp_mapper_ident_info {
        uint16_t        ident_type;
        uint16_t        ident_bit_size;
        uint16_t        ident_bit_pos;
-       enum bnxt_ulp_regfile_index     regfile_wr_idx;
+       enum bnxt_ulp_regfile_index     regfile_idx;
 };
 
 struct bnxt_ulp_glb_resource_info {