net/bnxt: support internal exact match entries
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Thu, 2 Jul 2020 23:28:25 +0000 (16:28 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 7 Jul 2020 21:38:27 +0000 (23:38 +0200)
Added support for the internal exact match entries.

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/bnxt_ulp.c
drivers/net/bnxt/tf_ulp/ulp_flow_db.c
drivers/net/bnxt/tf_ulp/ulp_mapper.c
drivers/net/bnxt/tf_ulp/ulp_mark_mgr.c
drivers/net/bnxt/tf_ulp/ulp_template_db_class.c
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index 4835b95..1b52861 100644 (file)
@@ -213,8 +213,27 @@ static int32_t
 ulp_eem_tbl_scope_init(struct bnxt *bp)
 {
        struct tf_alloc_tbl_scope_parms params = {0};
+       uint32_t dev_id;
+       struct bnxt_ulp_device_params *dparms;
        int rc;
 
+       /* Get the dev specific number of flows that needed to be supported. */
+       if (bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id)) {
+               BNXT_TF_DBG(ERR, "Invalid device id\n");
+               return -EINVAL;
+       }
+
+       dparms = bnxt_ulp_device_params_get(dev_id);
+       if (!dparms) {
+               BNXT_TF_DBG(ERR, "could not fetch the device params\n");
+               return -ENODEV;
+       }
+
+       if (dparms->flow_mem_type != BNXT_ULP_FLOW_MEM_TYPE_EXT) {
+               BNXT_TF_DBG(INFO, "Table Scope alloc is not required\n");
+               return 0;
+       }
+
        bnxt_init_tbl_scope_parms(bp, &params);
 
        rc = tf_alloc_tbl_scope(&bp->tfp, &params);
@@ -240,6 +259,8 @@ ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx)
        struct tf_free_tbl_scope_parms  params = {0};
        struct tf                       *tfp;
        int32_t                         rc = 0;
+       struct bnxt_ulp_device_params *dparms;
+       uint32_t dev_id;
 
        if (!ulp_ctx || !ulp_ctx->cfg_data)
                return -EINVAL;
@@ -254,6 +275,23 @@ ulp_eem_tbl_scope_deinit(struct bnxt *bp, struct bnxt_ulp_context *ulp_ctx)
                return -EINVAL;
        }
 
+       /* Get the dev specific number of flows that needed to be supported. */
+       if (bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id)) {
+               BNXT_TF_DBG(ERR, "Invalid device id\n");
+               return -EINVAL;
+       }
+
+       dparms = bnxt_ulp_device_params_get(dev_id);
+       if (!dparms) {
+               BNXT_TF_DBG(ERR, "could not fetch the device params\n");
+               return -ENODEV;
+       }
+
+       if (dparms->flow_mem_type != BNXT_ULP_FLOW_MEM_TYPE_EXT) {
+               BNXT_TF_DBG(INFO, "Table Scope free is not required\n");
+               return 0;
+       }
+
        rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp_ctx, &params.tbl_scope_id);
        if (rc) {
                BNXT_TF_DBG(ERR, "Failed to get the table scope id\n");
index 384dc5b..7696de2 100644 (file)
@@ -114,7 +114,8 @@ ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info *resource_info,
        }
 
        /* Store the handle as 64bit only for EM table entries */
-       if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
+       if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE &&
+           params->resource_func != BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
                resource_info->resource_hndl = (uint32_t)params->resource_hndl;
                resource_info->resource_type = params->resource_type;
                resource_info->resource_sub_type = params->resource_sub_type;
@@ -145,7 +146,8 @@ ulp_flow_db_res_info_to_params(struct ulp_fdb_resource_info *resource_info,
        /* use the helper function to get the resource func */
        params->resource_func = ulp_flow_db_resource_func_get(resource_info);
 
-       if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
+       if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
+           params->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
                params->resource_hndl = resource_info->resource_em_handle;
        } else if (params->resource_func & ULP_FLOW_DB_RES_FUNC_NEED_LOWER) {
                params->resource_hndl = resource_info->resource_hndl;
@@ -908,7 +910,9 @@ ulp_flow_db_resource_hndl_get(struct bnxt_ulp_context *ulp_ctx,
                                }
 
                        } else if (resource_func ==
-                                  BNXT_ULP_RESOURCE_FUNC_EM_TABLE){
+                                  BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
+                                  resource_func ==
+                                  BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE) {
                                *res_hndl = fid_res->resource_em_handle;
                                return 0;
                        }
@@ -966,7 +970,8 @@ static void ulp_flow_db_res_dump(struct ulp_fdb_resource_info       *r,
 
        BNXT_TF_DBG(DEBUG, "Resource func = %x, nxt_resource_idx = %x\n",
                    res_func, (ULP_FLOW_DB_RES_NXT_MASK & r->nxt_resource_idx));
-       if (res_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE)
+       if (res_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE ||
+           res_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE)
                BNXT_TF_DBG(DEBUG, "EM Handle = 0x%016" PRIX64 "\n",
                            r->resource_em_handle);
        else
index 6e8820d..8cc5b23 100644 (file)
@@ -556,15 +556,18 @@ ulp_mapper_index_entry_free(struct bnxt_ulp_context *ulp,
 }
 
 static inline int32_t
-ulp_mapper_eem_entry_free(struct bnxt_ulp_context *ulp,
-                         struct tf *tfp,
-                         struct ulp_flow_db_res_params *res)
+ulp_mapper_em_entry_free(struct bnxt_ulp_context *ulp,
+                        struct tf *tfp,
+                        struct ulp_flow_db_res_params *res)
 {
        struct tf_delete_em_entry_parms fparms = { 0 };
        int32_t rc;
 
        fparms.dir              = res->direction;
-       fparms.mem              = TF_MEM_EXTERNAL;
+       if (res->resource_func == BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE)
+               fparms.mem = TF_MEM_EXTERNAL;
+       else
+               fparms.mem = TF_MEM_INTERNAL;
        fparms.flow_handle      = res->resource_hndl;
 
        rc = bnxt_ulp_cntxt_tbl_scope_id_get(ulp, &fparms.tbl_scope_id);
@@ -1443,7 +1446,7 @@ ulp_mapper_em_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 #endif
 
        /* do the transpose for the internal EM keys */
-       if (tbl->resource_type == TF_MEM_INTERNAL)
+       if (tbl->resource_func == BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE)
                ulp_blob_perform_byte_reverse(&key);
 
        rc = bnxt_ulp_cntxt_tbl_scope_id_get(parms->ulp_ctx,
@@ -2066,7 +2069,8 @@ ulp_mapper_class_tbls_process(struct bnxt_ulp_mapper_parms *parms)
                case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
                        rc = ulp_mapper_tcam_tbl_process(parms, tbl);
                        break;
-               case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
+               case BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE:
+               case BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE:
                        rc = ulp_mapper_em_tbl_process(parms, tbl);
                        break;
                case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
@@ -2119,8 +2123,9 @@ ulp_mapper_resource_free(struct bnxt_ulp_context *ulp,
        case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
                rc = ulp_mapper_tcam_entry_free(ulp, tfp, res);
                break;
-       case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
-               rc = ulp_mapper_eem_entry_free(ulp, tfp, res);
+       case BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE:
+       case BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE:
+               rc = ulp_mapper_em_entry_free(ulp, tfp, res);
                break;
        case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
                rc = ulp_mapper_index_entry_free(ulp, tfp, res);
index 5174223..b3527ec 100644 (file)
@@ -87,6 +87,9 @@ ulp_mark_db_init(struct bnxt_ulp_context *ctxt)
 
        /* Need to allocate 2 * Num flows to account for hash type bit */
        mark_tbl->gfid_num_entries = dparms->mark_db_gfid_entries;
+       if (!mark_tbl->gfid_num_entries)
+               goto gfid_not_required;
+
        mark_tbl->gfid_tbl = rte_zmalloc("ulp_rx_eem_flow_mark_table",
                                         mark_tbl->gfid_num_entries *
                                         sizeof(struct bnxt_gfid_mark_info),
@@ -109,6 +112,7 @@ ulp_mark_db_init(struct bnxt_ulp_context *ctxt)
                    mark_tbl->gfid_num_entries - 1,
                    mark_tbl->gfid_mask);
 
+gfid_not_required:
        /* Add the mark tbl to the ulp context. */
        bnxt_ulp_cntxt_ptr2_mark_db_set(ctxt, mark_tbl);
        return 0;
index d4c7bfa..8eb5590 100644 (file)
@@ -179,7 +179,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO
        },
        {
-       .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
+       .resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE,
        .resource_type = TF_MEM_EXTERNAL,
        .resource_sub_type =
                BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
@@ -284,7 +284,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO
        },
        {
-       .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
+       .resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE,
        .resource_type = TF_MEM_EXTERNAL,
        .resource_sub_type =
                BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
@@ -389,7 +389,7 @@ struct bnxt_ulp_mapper_tbl_info ulp_class_tbl_list[] = {
        .critical_resource = BNXT_ULP_CRITICAL_RESOURCE_NO
        },
        {
-       .resource_func = BNXT_ULP_RESOURCE_FUNC_EM_TABLE,
+       .resource_func = BNXT_ULP_RESOURCE_FUNC_EXT_EM_TABLE,
        .resource_type = TF_MEM_EXTERNAL,
        .resource_sub_type =
                BNXT_ULP_RESOURCE_SUB_TYPE_NOT_USED,
index 7c0dc5e..3168d29 100644 (file)
@@ -149,10 +149,11 @@ enum bnxt_ulp_flow_mem_type {
 };
 
 enum bnxt_ulp_glb_regfile_index {
-       BNXT_ULP_GLB_REGFILE_INDEX_GLB_PROF_FUNC_ID = 0,
-       BNXT_ULP_GLB_REGFILE_INDEX_GLB_L2_CNTXT_ID = 1,
-       BNXT_ULP_GLB_REGFILE_INDEX_GLB_LOOPBACK_AREC_INDEX = 2,
-       BNXT_ULP_GLB_REGFILE_INDEX_LAST = 3
+       BNXT_ULP_GLB_REGFILE_INDEX_NOT_USED = 0,
+       BNXT_ULP_GLB_REGFILE_INDEX_GLB_PROF_FUNC_ID = 1,
+       BNXT_ULP_GLB_REGFILE_INDEX_GLB_L2_CNTXT_ID = 2,
+       BNXT_ULP_GLB_REGFILE_INDEX_GLB_LB_AREC_PTR = 3,
+       BNXT_ULP_GLB_REGFILE_INDEX_LAST = 4
 };
 
 enum bnxt_ulp_hdr_type {
@@ -257,8 +258,8 @@ enum bnxt_ulp_match_type_bitmask {
 
 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_EXT_EM_TABLE = 0x20,
+       BNXT_ULP_RESOURCE_FUNC_INT_EM_TABLE = 0x40,
        BNXT_ULP_RESOURCE_FUNC_RSVD2 = 0x60,
        BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0x80,
        BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 0x81,
index beca3ba..7c440e3 100644 (file)
@@ -321,7 +321,12 @@ struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
        .mark_db_gfid_entries   = 65536,
        .flow_count_db_entries  = 16384,
        .num_resources_per_flow = 8,
-       .num_phy_ports          = 2
+       .num_phy_ports          = 2,
+       .ext_cntr_table_type    = 0,
+       .byte_count_mask        = 0x00000003ffffffff,
+       .packet_count_mask      = 0xfffffffc00000000,
+       .byte_count_shift       = 0,
+       .packet_count_shift     = 36
        }
 };
 
index 4bcd02b..5a7a7b9 100644 (file)
@@ -146,6 +146,11 @@ struct bnxt_ulp_device_params {
        uint64_t                        flow_db_num_entries;
        uint32_t                        flow_count_db_entries;
        uint32_t                        num_resources_per_flow;
+       uint32_t                        ext_cntr_table_type;
+       uint64_t                        byte_count_mask;
+       uint64_t                        packet_count_mask;
+       uint32_t                        byte_count_shift;
+       uint32_t                        packet_count_shift;
 };
 
 /* Flow Mapper */