[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250702171804.86422-3-mmc@linux.ibm.com>
Date: Wed, 2 Jul 2025 10:18:02 -0700
From: Mingming Cao <mmc@...ux.ibm.com>
To: netdev@...r.kernel.org
Cc: bjking1@...ux.ibm.com, haren@...ux.ibm.com, ricklind@...ux.ibm.com,
davemarq@...ux.ibm.com, mmc@...ux.ibm.com
Subject: [PATCH v2 net-next 2/4] ibmvnic: Fix hardcoded NUM_RX_STATS/NUM_TX_STATS with dynamic sizeof
The previous hardcoded definitions of NUM_RX_STATS and
NUM_TX_STATS were not updated when new fields were added
to the ibmvnic_{rx,tx}_queue_stats structures. Specifically,
commit 2ee73c54a615 ("ibmvnic: Add stat for tx direct vs tx
batched") added a fourth TX stat, but NUM_TX_STATS remained 3,
leading to a mismatch.
This patch replaces the static defines with dynamic sizeof-based
calculations to ensure the stat arrays are correctly sized.
This fixes incorrect indexing and prevents incomplete stat
reporting in tools like ethtool.
Fixes: 2ee73c54a615 ("ibmvnic: Add stat for tx direct vs tx batched")
Signed-off-by: Mingming Cao <mmc@...ux.ibm.com>
Reviewed-by: Dave Marquardt <davemarq@...ux.ibm.com>
Reviewed by: Haren Myneni <haren@...ux.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 9b1693d817..e574eed97c 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -211,7 +211,6 @@ struct ibmvnic_statistics {
u8 reserved[72];
} __packed __aligned(8);
-#define NUM_TX_STATS 3
struct ibmvnic_tx_queue_stats {
atomic64_t batched_packets;
atomic64_t direct_packets;
@@ -219,13 +218,18 @@ struct ibmvnic_tx_queue_stats {
atomic64_t dropped_packets;
};
-#define NUM_RX_STATS 3
+#define NUM_TX_STATS \
+ (sizeof(struct ibmvnic_tx_queue_stats) / sizeof(atomic64_t))
+
struct ibmvnic_rx_queue_stats {
atomic64_t packets;
atomic64_t bytes;
atomic64_t interrupts;
};
+#define NUM_RX_STATS \
+ (sizeof(struct ibmvnic_rx_queue_stats) / sizeof(atomic64_t))
+
struct ibmvnic_acl_buffer {
__be32 len;
__be32 version;
--
2.39.3 (Apple Git-146)
Powered by blists - more mailing lists