From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19A6AA00C5; Mon, 6 Jul 2020 10:34:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D398E1DB3B; Mon, 6 Jul 2020 10:30:30 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id 2ED2B1D594 for ; Mon, 6 Jul 2020 10:30:09 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id B90392982AB; Mon, 6 Jul 2020 01:30:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com B90392982AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1594024208; bh=b9aAqE5EsK/GspGkp7WdyUzyeC5TuaLw2ylwKqFcMA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pefoMY6wbAomABC1RGJjekBV8G8uFjQ/HJPEaVxESNIE7TUtgw+pYzs6BQUIYRjBe 9B1QptUeiiKP/zd3JEgEbVmeYS5rpZT1M9TrHTse2LoOjxUixUQlnzaLLKksAgm5vB i46tUm4pa0/IHIDrtae23izWSDFlwfk9Un7FfcBU= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Mon, 6 Jul 2020 13:55:02 +0530 Message-Id: <20200706082502.26935-21-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200706082502.26935-1-somnath.kotur@broadcom.com> References: <20200706082502.26935-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 20/20] net/bnxt: use byte/pkt count shift/masks from the device template X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Instead of using hardcoded values for the byte/pkt value shifts/masks to read from the HW counters, use the shift/mask values from the device template params Reviewed-by: Venkat Duvvuru Signed-off-by: Somnath Kotur --- drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 27 ++++++++++++++++----------- drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h | 6 ++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c index 9944e9e..e90b962 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -227,9 +228,11 @@ void ulp_fc_mgr_thread_cancel(struct bnxt_ulp_context *ctxt) * num_counters [in] The number of counters * */ -__rte_unused static int32_t ulp_bulk_get_flow_stats(struct tf *tfp, - struct bnxt_ulp_fc_info *fc_info, - enum tf_dir dir, uint32_t num_counters) +__rte_unused static int32_t +ulp_bulk_get_flow_stats(struct tf *tfp, + struct bnxt_ulp_fc_info *fc_info, + enum tf_dir dir, + struct bnxt_ulp_device_params *dparms) /* MARK AS UNUSED FOR NOW TO AVOID COMPILATION ERRORS TILL API is RESOLVED */ { int rc = 0; @@ -242,7 +245,7 @@ __rte_unused static int32_t ulp_bulk_get_flow_stats(struct tf *tfp, parms.dir = dir; parms.type = stype; parms.starting_idx = fc_info->shadow_hw_tbl[dir].start_idx; - parms.num_entries = num_counters; + parms.num_entries = dparms->flow_count_db_entries / 2; /* direction */ /* * TODO: * Size of an entry needs to obtained from template @@ -266,13 +269,14 @@ __rte_unused static int32_t ulp_bulk_get_flow_stats(struct tf *tfp, return rc; } - for (i = 0; i < num_counters; i++) { + for (i = 0; i < parms.num_entries; i++) { /* TBD - Get PKT/BYTE COUNT SHIFT/MASK from Template */ sw_acc_tbl_entry = &fc_info->sw_acc_tbl[dir][i]; if (!sw_acc_tbl_entry->valid) continue; - sw_acc_tbl_entry->pkt_count += FLOW_CNTR_PKTS(stats[i]); - sw_acc_tbl_entry->byte_count += FLOW_CNTR_BYTES(stats[i]); + sw_acc_tbl_entry->pkt_count += FLOW_CNTR_PKTS(stats[i], dparms); + sw_acc_tbl_entry->byte_count += FLOW_CNTR_BYTES(stats[i], + dparms); } return rc; @@ -281,7 +285,8 @@ __rte_unused static int32_t ulp_bulk_get_flow_stats(struct tf *tfp, static int ulp_get_single_flow_stat(struct tf *tfp, struct bnxt_ulp_fc_info *fc_info, enum tf_dir dir, - uint32_t hw_cntr_id) + uint32_t hw_cntr_id, + struct bnxt_ulp_device_params *dparms) { int rc = 0; struct tf_get_tbl_entry_parms parms = { 0 }; @@ -310,8 +315,8 @@ static int ulp_get_single_flow_stat(struct tf *tfp, /* TBD - Get PKT/BYTE COUNT SHIFT/MASK from Template */ sw_cntr_indx = hw_cntr_id - fc_info->shadow_hw_tbl[dir].start_idx; sw_acc_tbl_entry = &fc_info->sw_acc_tbl[dir][sw_cntr_indx]; - sw_acc_tbl_entry->pkt_count += FLOW_CNTR_PKTS(stats); - sw_acc_tbl_entry->byte_count += FLOW_CNTR_BYTES(stats); + sw_acc_tbl_entry->pkt_count += FLOW_CNTR_PKTS(stats, dparms); + sw_acc_tbl_entry->byte_count += FLOW_CNTR_BYTES(stats, dparms); return rc; } @@ -385,7 +390,7 @@ ulp_fc_mgr_alarm_cb(void *arg) continue; hw_cntr_id = ulp_fc_info->sw_acc_tbl[i][j].hw_cntr_id; rc = ulp_get_single_flow_stat(tfp, ulp_fc_info, i, - hw_cntr_id); + hw_cntr_id, dparms); if (rc) break; } diff --git a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h index 2072670..9c317b0 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h +++ b/drivers/net/bnxt/tf_ulp/ulp_fc_mgr.h @@ -16,8 +16,10 @@ #define FLOW_CNTR_BYTE_WIDTH 36 #define FLOW_CNTR_BYTE_MASK (((uint64_t)1 << FLOW_CNTR_BYTE_WIDTH) - 1) -#define FLOW_CNTR_PKTS(v) ((v) >> FLOW_CNTR_BYTE_WIDTH) -#define FLOW_CNTR_BYTES(v) ((v) & FLOW_CNTR_BYTE_MASK) +#define FLOW_CNTR_PKTS(v, d) (((v) & (d)->packet_count_mask) >> \ + (d)->packet_count_shift) +#define FLOW_CNTR_BYTES(v, d) (((v) & (d)->byte_count_mask) >> \ + (d)->byte_count_shift) struct sw_acc_counter { uint64_t pkt_count; -- 2.7.4