Skip to content

Commit 2ab276a

Browse files
author
Mamatha Inamdar
committed
ibmvnic: Fix hardcoded NUM_RX_STATS/NUM_TX_STATS with dynamic sizeof
JIRA: https://issues.redhat.com/browse/RHEL-104119 commit 01b8114 Author: Mingming Cao <mmc@linux.ibm.com> Date: Wed Jul 9 08:33:32 2025 -0700 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 2ee73c5 ("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: 2ee73c5 ("ibmvnic: Add stat for tx direct vs tx batched") Signed-off-by: Mingming Cao <mmc@linux.ibm.com> Reviewed-by: Dave Marquardt <davemarq@linux.ibm.com> Reviewed-by: Haren Myneni <haren@linux.ibm.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250709153332.73892-1-mmc@linux.ibm.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Mamatha Inamdar <minamdar@redhat.com>
1 parent b848bbf commit 2ab276a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/ethernet/ibm/ibmvnic.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,25 @@ struct ibmvnic_statistics {
175175
u8 reserved[72];
176176
} __packed __aligned(8);
177177

178-
#define NUM_TX_STATS 3
179178
struct ibmvnic_tx_queue_stats {
180179
u64 batched_packets;
181180
u64 direct_packets;
182181
u64 bytes;
183182
u64 dropped_packets;
184183
};
185184

186-
#define NUM_RX_STATS 3
185+
#define NUM_TX_STATS \
186+
(sizeof(struct ibmvnic_tx_queue_stats) / sizeof(u64))
187+
187188
struct ibmvnic_rx_queue_stats {
188189
u64 packets;
189190
u64 bytes;
190191
u64 interrupts;
191192
};
192193

194+
#define NUM_RX_STATS \
195+
(sizeof(struct ibmvnic_rx_queue_stats) / sizeof(u64))
196+
193197
struct ibmvnic_acl_buffer {
194198
__be32 len;
195199
__be32 version;

0 commit comments

Comments
 (0)