net/bnxt: allow usage of more resources in flow DB
authorMike Baucom <michael.baucom@broadcom.com>
Wed, 15 Apr 2020 14:49:07 +0000 (20:19 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:09 +0000 (13:57 +0200)
Allow the flow db resources to be more effectively utilized.

Signed-off-by: Mike Baucom <michael.baucom@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_flow_db.c

index aed5078..e99e94a 100644 (file)
@@ -331,6 +331,10 @@ int32_t ulp_flow_db_fid_alloc(struct bnxt_ulp_context              *ulp_ctxt,
                BNXT_TF_DBG(ERR, "Flow database has reached max flows\n");
                return -ENOMEM;
        }
+       if (flow_tbl->tail_index <= (flow_tbl->head_index + 1)) {
+               BNXT_TF_DBG(ERR, "Flow database has reached max resources\n");
+               return -ENOMEM;
+       }
        *fid = flow_tbl->flow_tbl_stack[flow_tbl->head_index];
        flow_tbl->head_index++;
        ulp_flow_db_active_flow_set(flow_tbl, *fid, 1);
@@ -385,7 +389,7 @@ int32_t     ulp_flow_db_resource_add(struct bnxt_ulp_context        *ulp_ctxt,
        }
 
        /* check for max resource */
-       if ((flow_tbl->num_flows + 1) >= flow_tbl->tail_index) {
+       if ((flow_tbl->head_index + 1) >= flow_tbl->tail_index) {
                BNXT_TF_DBG(ERR, "Flow db has reached max resources\n");
                return -ENOMEM;
        }