net/bnxt: fix port default rule create/destroy
[dpdk.git] / drivers / net / bnxt / tf_ulp / ulp_flow_db.c
index fc4c4da..7144517 100644 (file)
@@ -10,6 +10,7 @@
 #include "ulp_utils.h"
 #include "ulp_template_struct.h"
 #include "ulp_mapper.h"
+#include "ulp_fc_mgr.h"
 
 #define ULP_FLOW_DB_RES_DIR_BIT                31
 #define ULP_FLOW_DB_RES_DIR_MASK       0x80000000
@@ -114,7 +115,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 +147,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;
@@ -300,7 +303,7 @@ int32_t     ulp_flow_db_init(struct bnxt_ulp_context *ulp_ctxt)
 
        /* Populate the regular flow table limits. */
        flow_tbl = &flow_db->flow_tbl[BNXT_ULP_REGULAR_FLOW_TABLE];
-       flow_tbl->num_flows = dparms->num_flows + 1;
+       flow_tbl->num_flows = dparms->flow_db_num_entries + 1;
        flow_tbl->num_resources = (flow_tbl->num_flows *
                                   dparms->num_resources_per_flow);
 
@@ -317,7 +320,7 @@ int32_t     ulp_flow_db_init(struct bnxt_ulp_context *ulp_ctxt)
                goto error_free;
 
        /* add 1 since we are not using index 0 for flow id */
-       flow_db->func_id_tbl_size = dparms->num_flows + 1;
+       flow_db->func_id_tbl_size = dparms->flow_db_num_entries + 1;
        /* Allocate the function Id table */
        flow_db->func_id_tbl = rte_zmalloc("bnxt_ulp_flow_db_func_id_table",
                                           flow_db->func_id_tbl_size *
@@ -482,6 +485,21 @@ int32_t    ulp_flow_db_resource_add(struct bnxt_ulp_context        *ulp_ctxt,
                ulp_flow_db_res_params_to_info(fid_resource, params);
        }
 
+       if (params->resource_type == TF_TBL_TYPE_ACT_STATS_64 &&
+           params->resource_sub_type ==
+           BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
+               /* Store the first HW counter ID for this table */
+               if (!ulp_fc_mgr_start_idx_isset(ulp_ctxt, params->direction))
+                       ulp_fc_mgr_start_idx_set(ulp_ctxt, params->direction,
+                                                params->resource_hndl);
+
+               ulp_fc_mgr_cntr_set(ulp_ctxt, params->direction,
+                                   params->resource_hndl);
+
+               if (!ulp_fc_mgr_thread_isstarted(ulp_ctxt))
+                       ulp_fc_mgr_thread_start(ulp_ctxt);
+       }
+
        /* all good, return success */
        return 0;
 }
@@ -572,6 +590,17 @@ int32_t    ulp_flow_db_resource_del(struct bnxt_ulp_context        *ulp_ctxt,
                                        nxt_idx);
        }
 
+       /* Now that the HW Flow counter resource is deleted, reset it's
+        * corresponding slot in the SW accumulation table in the Flow Counter
+        * manager
+        */
+       if (params->resource_type == TF_TBL_TYPE_ACT_STATS_64 &&
+           params->resource_sub_type ==
+           BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_INT_COUNT) {
+               ulp_fc_mgr_cntr_reset(ulp_ctxt, params->direction,
+                                     params->resource_hndl);
+       }
+
        /* all good, return success */
        return 0;
 }
@@ -908,7 +937,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;
                        }
@@ -931,9 +962,9 @@ ulp_flow_db_resource_hndl_get(struct bnxt_ulp_context *ulp_ctx,
 int32_t
 ulp_default_flow_db_cfa_action_get(struct bnxt_ulp_context *ulp_ctx,
                                   uint32_t flow_id,
-                                  uint32_t *cfa_action)
+                                  uint16_t *cfa_action)
 {
-       uint8_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_ACT_IDX;
+       uint8_t sub_type = BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TYPE_VFR_CFA_ACTION;
        uint64_t hndl;
        int32_t rc;
 
@@ -966,7 +997,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