ibmvnic: Fix hardcoded NUM_RX_STATS/NUM_TX_STATS with dynamic sizeof
PATCH 1/1 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.
--- drivers/net/ethernet/ibm/ibmvnic.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/ibm/ibmvnic.h +6 -2
@@ -211,7 +211,6 @@ struct ibmvnic_statistics {u8 reserved[72 ]; } __packed__aligned(8) ; -#define NUM_TX_STATS 3struct ibmvnic_tx_queue_stats {u64 batched_packets;u64 direct_packets;
@@ -219,13 +218,18 @@ struct ibmvnic_tx_queue_stats {u64 dropped_packets; }; -#define NUM_RX_STATS 3 +#define NUM_TX_STATS \ + (sizeof(struct ibmvnic_tx_queue_stats) / sizeof(u64)) +struct ibmvnic_rx_queue_stats {u64 packets;u64 bytes;u64 interrupts; }; +#define NUM_RX_STATS \ + (sizeof(struct ibmvnic_rx_queue_stats) / sizeof(u64)) +struct ibmvnic_acl_buffer {__be32 len;__be32 version;
Signature · 1 line
2.39.3 (Apple Git-146)
Quoted 12 lines · Mingming Cao
The previous hardcoded definitions of
NUM_RX_STATSandNUM_TX_STATSwere not updated when new fields were added to the ibmvnic_{rx,tx}_queue_stats structures. Specifically, commit2ee73c54a615("ibmvnic: Add stat for tx direct vs tx batched") added a fourth TX stat, butNUM_TX_STATSremained 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.
Quoted 4 lines
Fixes 2ee73c54a615 ("ibmvnic: Add stat for tx direct vs tx batched")Signed-off-by Mingming Cao <[email protected]>Reviewed-by Dave Marquardt <[email protected]>Reviewed-by Haren Myneni <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 9 Jul 2025 08:33:32 -0700 you wrote:
The previous hardcoded definitions of
NUM_RX_STATSandNUM_TX_STATSwere not updated when new fields were added to the ibmvnic_{rx,tx}_queue_stats structures. Specifically, commit2ee73c54a615("ibmvnic: Add stat for tx direct vs tx batched") added a fourth TX stat, butNUM_TX_STATSremained 3, leading to a mismatch.[...]
Here is the summary with links:
- [net] ibmvnic: Fix hardcoded NUM_RX_STATS/NUM_TX_STATS with dynamic sizeof
https://git.kernel.org/netdev/net/c/01b8114b432d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html