X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fbnxt%2Ftf_ulp%2Fulp_fc_mgr.c;h=13f71ed83b2edf87f14e12ff5e5fc89222689a4f;hb=48fbc1be82b551e41c58e94de780fdd2ffaaeb78;hp=9a771323850b55306c1ad24df43926576ce29025;hpb=d75b55121bcd618a958128489ae4cbeb243f413c;p=dpdk.git diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c index 9a77132385..13f71ed83b 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c @@ -80,12 +80,6 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt) return -EINVAL; } - if (!dparms->flow_count_db_entries) { - BNXT_TF_DBG(DEBUG, "flow counter support is not enabled\n"); - bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, NULL); - return 0; - } - ulp_fc_info = rte_zmalloc("ulp_fc_info", sizeof(*ulp_fc_info), 0); if (!ulp_fc_info) goto error; @@ -99,6 +93,13 @@ ulp_fc_mgr_init(struct bnxt_ulp_context *ctxt) /* Add the FC info tbl to the ulp context. */ bnxt_ulp_cntxt_ptr2_fc_info_set(ctxt, ulp_fc_info); + ulp_fc_info->num_counters = dparms->flow_count_db_entries; + if (!ulp_fc_info->num_counters) { + /* No need for software counters, call fw directly */ + BNXT_TF_DBG(DEBUG, "Sw flow counter support not enabled\n"); + return 0; + } + sw_acc_cntr_tbl_sz = sizeof(struct sw_acc_counter) * dparms->flow_count_db_entries; @@ -138,6 +139,7 @@ int32_t ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt) { struct bnxt_ulp_fc_info *ulp_fc_info; + struct hw_fc_mem_info *shd_info; int i; ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt); @@ -149,11 +151,15 @@ ulp_fc_mgr_deinit(struct bnxt_ulp_context *ctxt) pthread_mutex_destroy(&ulp_fc_info->fc_lock); - for (i = 0; i < TF_DIR_MAX; i++) - rte_free(ulp_fc_info->sw_acc_tbl[i]); + if (ulp_fc_info->num_counters) { + for (i = 0; i < TF_DIR_MAX; i++) + rte_free(ulp_fc_info->sw_acc_tbl[i]); - for (i = 0; i < TF_DIR_MAX; i++) - ulp_fc_mgr_shadow_mem_free(&ulp_fc_info->shadow_hw_tbl[i]); + for (i = 0; i < TF_DIR_MAX; i++) { + shd_info = &ulp_fc_info->shadow_hw_tbl[i]; + ulp_fc_mgr_shadow_mem_free(shd_info); + } + } rte_free(ulp_fc_info); @@ -291,6 +297,74 @@ ulp_bulk_get_flow_stats(struct tf *tfp, return rc; } +static int32_t +ulp_fc_tf_flow_stat_get(struct bnxt_ulp_context *ctxt, + struct ulp_flow_db_res_params *res, + struct rte_flow_query_count *qcount) +{ + struct tf *tfp; + struct bnxt_ulp_device_params *dparms; + struct tf_get_tbl_entry_parms parms = { 0 }; + struct tf_set_tbl_entry_parms sparms = { 0 }; + enum tf_tbl_type stype = TF_TBL_TYPE_ACT_STATS_64; + uint64_t stats = 0; + uint32_t dev_id = 0; + int32_t rc = 0; + + tfp = bnxt_ulp_cntxt_tfp_get(ctxt, BNXT_ULP_SHARED_SESSION_NO); + if (!tfp) { + BNXT_TF_DBG(ERR, "Failed to get the truflow pointer\n"); + return -EINVAL; + } + + if (bnxt_ulp_cntxt_dev_id_get(ctxt, &dev_id)) { + BNXT_TF_DBG(DEBUG, "Failed to get device id\n"); + bnxt_ulp_cntxt_entry_release(); + return -EINVAL; + } + + dparms = bnxt_ulp_device_params_get(dev_id); + if (!dparms) { + BNXT_TF_DBG(DEBUG, "Failed to device parms\n"); + bnxt_ulp_cntxt_entry_release(); + return -EINVAL; + } + parms.dir = res->direction; + parms.type = stype; + parms.idx = res->resource_hndl; + parms.data_sz_in_bytes = sizeof(uint64_t); + parms.data = (uint8_t *)&stats; + rc = tf_get_tbl_entry(tfp, &parms); + if (rc) { + PMD_DRV_LOG(ERR, + "Get failed for id:0x%x rc:%d\n", + parms.idx, rc); + return rc; + } + qcount->hits = FLOW_CNTR_PKTS(stats, dparms); + if (qcount->hits) + qcount->hits_set = 1; + qcount->bytes = FLOW_CNTR_BYTES(stats, dparms); + if (qcount->bytes) + qcount->bytes_set = 1; + + if (qcount->reset) { + stats = 0; + sparms.dir = res->direction; + sparms.type = stype; + sparms.idx = res->resource_hndl; + sparms.data = (uint8_t *)&stats; + sparms.data_sz_in_bytes = sizeof(uint64_t); + rc = tf_set_tbl_entry(tfp, &sparms); + if (rc) { + PMD_DRV_LOG(ERR, "Set failed for id:0x%x rc:%d\n", + sparms.idx, rc); + return rc; + } + } + return rc; +} + static int ulp_get_single_flow_stat(struct bnxt_ulp_context *ctxt, struct tf *tfp, struct bnxt_ulp_fc_info *fc_info, @@ -540,6 +614,9 @@ int32_t ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir, if (!ulp_fc_info) return -EIO; + if (!ulp_fc_info->num_counters) + return 0; + pthread_mutex_lock(&ulp_fc_info->fc_lock); sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx; ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = true; @@ -572,6 +649,9 @@ int32_t ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, enum tf_dir dir, if (!ulp_fc_info) return -EIO; + if (!ulp_fc_info->num_counters) + return 0; + pthread_mutex_lock(&ulp_fc_info->fc_lock); sw_cntr_idx = hw_cntr_id - ulp_fc_info->shadow_hw_tbl[dir].start_idx; ulp_fc_info->sw_acc_tbl[dir][sw_cntr_idx].valid = false; @@ -644,6 +724,9 @@ int ulp_fc_mgr_query_count_get(struct bnxt_ulp_context *ctxt, hw_cntr_id = params.resource_hndl; if (params.resource_sub_type == BNXT_ULP_RESOURCE_SUB_TYPE_INDEX_TABLE_INT_COUNT) { + if (!ulp_fc_info->num_counters) + return ulp_fc_tf_flow_stat_get(ctxt, ¶ms, count); + /* TODO: * Think about optimizing with try_lock later */