From: Kishore Padmanabha <kishore.padmana...@broadcom.com>

The stats counter cache memory initialization did not print the
error message on failure, updated the initialization to print
error message on failure.

Signed-off-by: Kishore Padmanabha <kishore.padmana...@broadcom.com>
Reviewed-by: Shuanglin Wang <shuanglin.w...@broadcom.com>
---
 drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c | 35 ++++++++++++++++++----------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c 
b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
index fc4207b36c..b246b90fe2 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_sc_mgr.c
@@ -63,29 +63,30 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
        int i;
 
        if (!ctxt) {
-               BNXT_DRV_DBG(DEBUG, "Invalid ULP CTXT\n");
+               BNXT_DRV_DBG(ERR, "Invalid ULP CTXT\n");
                return -EINVAL;
        }
 
        if (bnxt_ulp_cntxt_dev_id_get(ctxt, &dev_id)) {
-               BNXT_DRV_DBG(DEBUG, "Failed to get device id\n");
+               BNXT_DRV_DBG(ERR, "Failed to get device id\n");
                return -EINVAL;
        }
 
        dparms = bnxt_ulp_device_params_get(dev_id);
        if (!dparms) {
-               BNXT_DRV_DBG(DEBUG, "Failed to device parms\n");
+               BNXT_DRV_DBG(ERR, "Failed to device parms\n");
                return -EINVAL;
        }
 
        sc_ops = bnxt_ulp_sc_ops_get(ctxt);
        if (sc_ops == NULL) {
-               BNXT_DRV_DBG(DEBUG, "Failed to get the counter ops\n");
+               BNXT_DRV_DBG(ERR, "Failed to get the counter ops\n");
                return -EINVAL;
        }
 
        ulp_sc_info = rte_zmalloc("ulp_sc_info", sizeof(*ulp_sc_info), 0);
        if (!ulp_sc_info) {
+               BNXT_DRV_DBG(ERR, "Failed to allocate stats cache container\n");
                rc = -ENOMEM;
                goto error;
        }
@@ -99,8 +100,9 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
        ulp_sc_info->num_counters = dparms->ext_flow_db_num_entries;
        if (!ulp_sc_info->num_counters) {
                /* No need for software counters, call fw directly */
-               BNXT_DRV_DBG(DEBUG, "Sw flow counter support not enabled\n");
-               return 0;
+               BNXT_DRV_DBG(ERR, "Num of flow entries is not configured\n");
+               rc = -EINVAL;
+               goto error;
        }
 
        /*
@@ -115,6 +117,7 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
        ulp_sc_info->stats_cache_tbl = rte_zmalloc("ulp_stats_cache_tbl",
                                                   stats_cache_tbl_sz, 0);
        if (!ulp_sc_info->stats_cache_tbl) {
+               BNXT_DRV_DBG(ERR, "Failed to allocate stats cache table\n");
                rc = -ENOMEM;
                goto error;
        }
@@ -123,7 +126,7 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
                                             ULP_SC_BATCH_SIZE * 
ULP_SC_PAGE_SIZE,
                                             ULP_SC_PAGE_SIZE);
        if (!ulp_sc_info->read_data) {
-               rte_free(ulp_sc_info->stats_cache_tbl);
+               BNXT_DRV_DBG(ERR, "Failed to allocate stats cache data\n");
                rc = -ENOMEM;
                goto error;
        }
@@ -135,10 +138,15 @@ int32_t ulp_sc_mgr_init(struct bnxt_ulp_context *ctxt)
        }
 
        rc = ulp_sc_mgr_thread_start(ctxt);
-       if (rc)
-               BNXT_DRV_DBG(DEBUG, "Stats counter thread start failed\n");
+       if (rc) {
+               BNXT_DRV_DBG(ERR, "Stats cache thread start failed\n");
+               rc = -EIO;
+               goto error;
+       }
 
- error:
+       return 0;
+error:
+       ulp_sc_mgr_deinit(ctxt);
        return rc;
 }
 
@@ -399,8 +407,11 @@ void ulp_sc_mgr_thread_cancel(struct bnxt_ulp_context 
*ctxt)
        if (!ulp_sc_info)
                return;
 
-       ulp_sc_info->flags &= ~ULP_FLAG_SC_THREAD;
-       pthread_cancel(ulp_sc_info->tid);
+       /* if thread started then stop it */
+       if (ulp_sc_info->flags & ULP_FLAG_SC_THREAD) {
+               pthread_cancel((pthread_t)ulp_sc_info->tid.opaque_id);
+               ulp_sc_info->flags &= ~ULP_FLAG_SC_THREAD;
+       }
 }
 
 /*
-- 
2.39.5 (Apple Git-154)

Reply via email to