DPDK patches and discussions
 help / color / mirror / Atom feed
From: Somnath Kotur <somnath.kotur@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 20/20] net/bnxt: use byte/pkt count shift/masks from the device template
Date: Mon,  6 Jul 2020 13:55:02 +0530	[thread overview]
Message-ID: <20200706082502.26935-21-somnath.kotur@broadcom.com> (raw)
In-Reply-To: <20200706082502.26935-1-somnath.kotur@broadcom.com>

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 <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 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 <rte_common.h>
+#include <rte_cycles.h>
 #include <rte_malloc.h>
 #include <rte_log.h>
 #include <rte_alarm.h>
@@ -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


      parent reply	other threads:[~2020-07-06  8:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06  8:24 [dpdk-dev] [PATCH 00/20] bnxt patches Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 01/20] net/bnxt: vxlan encap and decap with src property enabled Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 02/20] net/bnxt: add support vlan header bitmap Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 03/20] net/bnxt: add support for negative conditional opcodes Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 04/20] net/bnxt: add validations to dpdk port id and phy port parsing Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 05/20] net/bnxt: add support for index opcode constant Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 06/20] net/bnxt: updated hsi_struct_def_dpdk.h Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 07/20] nxt/bnxt: added HWRM support for global cfg Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 08/20] net/bnxt: cleanup and refactoring Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 09/20] net/bnxt: add support for vlan push and vlan pop actions Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 10/20] net/bnxt: remove vnic and vport act bits from template matching Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 11/20] net/bnxt: fix vxlan outer ip protocol id encapsulation Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 12/20] net/bnxt: add number of vlan tags in the computed field list Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 13/20] net/bnxt: enable support for PF and VF port action items Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 14/20] net/bnxt: port configuration changes to support full offload Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 15/20] net/bnxt: add support for conditional opcodes for mapper result table Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 16/20] net/bnxt: add support for nat rte action items Somnath Kotur
2020-07-06  8:24 ` [dpdk-dev] [PATCH 17/20] net/bnxt: add support for tp src/dst " Somnath Kotur
2020-07-06  8:25 ` [dpdk-dev] [PATCH 18/20] net/bnxt: use VF vnic when port action is for a VF rep port Somnath Kotur
2020-07-06  8:25 ` [dpdk-dev] [PATCH 19/20] net/bnxt: enable flow ctrl ops for the VF-rep device Somnath Kotur
2020-07-06  8:25 ` Somnath Kotur [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200706082502.26935-21-somnath.kotur@broadcom.com \
    --to=somnath.kotur@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).