netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, kuba@kernel.org
Subject: [PATCH net-next v2 03/10] bnxt_en: Use macros to define port statistics size and offset.
Date: Mon, 27 Jul 2020 05:40:38 -0400	[thread overview]
Message-ID: <1595842845-19403-4-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1595842845-19403-1-git-send-email-michael.chan@broadcom.com>

The port statistics structures have hard coded padding and offset.
Define macros to make this look cleaner.

Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++----
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 8 +++++++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index cd794b0..b4a387c 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3780,8 +3780,7 @@ static int bnxt_alloc_stats(struct bnxt *bp)
 	if (bp->hw_rx_port_stats)
 		goto alloc_ext_stats;
 
-	bp->hw_port_stats_size = sizeof(struct rx_port_stats) +
-				 sizeof(struct tx_port_stats) + 1024;
+	bp->hw_port_stats_size = BNXT_PORT_STATS_SIZE;
 
 	bp->hw_rx_port_stats =
 		dma_alloc_coherent(&pdev->dev, bp->hw_port_stats_size,
@@ -3790,9 +3789,10 @@ static int bnxt_alloc_stats(struct bnxt *bp)
 	if (!bp->hw_rx_port_stats)
 		return -ENOMEM;
 
-	bp->hw_tx_port_stats = (void *)(bp->hw_rx_port_stats + 1) + 512;
+	bp->hw_tx_port_stats = (void *)bp->hw_rx_port_stats +
+			       BNXT_TX_PORT_STATS_BYTE_OFFSET;
 	bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map +
-				   sizeof(struct rx_port_stats) + 512;
+				   BNXT_TX_PORT_STATS_BYTE_OFFSET;
 	bp->flags |= BNXT_FLAG_PORT_STATS;
 
 alloc_ext_stats:
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 306636d..df62897 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1926,12 +1926,18 @@ struct bnxt {
 	struct device		*hwmon_dev;
 };
 
+#define BNXT_PORT_STATS_SIZE				\
+	(sizeof(struct rx_port_stats) + sizeof(struct tx_port_stats) + 1024)
+
+#define BNXT_TX_PORT_STATS_BYTE_OFFSET			\
+	(sizeof(struct rx_port_stats) + 512)
+
 #define BNXT_RX_STATS_OFFSET(counter)			\
 	(offsetof(struct rx_port_stats, counter) / 8)
 
 #define BNXT_TX_STATS_OFFSET(counter)			\
 	((offsetof(struct tx_port_stats, counter) +	\
-	  sizeof(struct rx_port_stats) + 512) / 8)
+	  BNXT_TX_PORT_STATS_BYTE_OFFSET) / 8)
 
 #define BNXT_RX_STATS_EXT_OFFSET(counter)		\
 	(offsetof(struct rx_port_stats_ext, counter) / 8)
-- 
1.8.3.1


  parent reply	other threads:[~2020-07-27  9:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27  9:40 [PATCH net-next v2 00/10] bnxt_en update Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 01/10] bnxt_en: Remove PCIe non-counters from ethtool statistics Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 02/10] bnxt_en: Update firmware interface to 1.10.1.54 Michael Chan
2020-07-27  9:40 ` Michael Chan [this message]
2020-07-27  9:40 ` [PATCH net-next v2 04/10] bnxt_en: Refactor statistics code and structures Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 05/10] bnxt_en: Allocate additional memory for all statistics blocks Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 06/10] bnxt_en: Retrieve hardware counter masks from firmware if available Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 07/10] bnxt_en: Retrieve hardware masks for port counters Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 08/10] bnxt_en: Accumulate all counters Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 09/10] bnxt_en: Switch over to use the 64-bit software accumulated counters Michael Chan
2020-07-27  9:40 ` [PATCH net-next v2 10/10] bnxt_en: Add support for 'ethtool -d' Michael Chan
2020-07-27 18:49 ` [PATCH net-next v2 00/10] bnxt_en update David Miller

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=1595842845-19403-4-git-send-email-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).