Skip to content

Commit 4e11c4b

Browse files
Mingming Caogregkh
authored andcommitted
ibmvnic: Fix hardcoded NUM_RX_STATS/NUM_TX_STATS with dynamic sizeof
[ Upstream commit 01b8114b432d7baaa5e51ab229c12c4f36b8e2c6 ] 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 <[email protected]> Reviewed-by: Dave Marquardt <[email protected]> Reviewed-by: Haren Myneni <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d2e9f50 commit 4e11c4b

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
@@ -211,21 +211,25 @@ struct ibmvnic_statistics {
211211
u8 reserved[72];
212212
} __packed __aligned(8);
213213

214-
#define NUM_TX_STATS 3
215214
struct ibmvnic_tx_queue_stats {
216215
u64 batched_packets;
217216
u64 direct_packets;
218217
u64 bytes;
219218
u64 dropped_packets;
220219
};
221220

222-
#define NUM_RX_STATS 3
221+
#define NUM_TX_STATS \
222+
(sizeof(struct ibmvnic_tx_queue_stats) / sizeof(u64))
223+
223224
struct ibmvnic_rx_queue_stats {
224225
u64 packets;
225226
u64 bytes;
226227
u64 interrupts;
227228
};
228229

230+
#define NUM_RX_STATS \
231+
(sizeof(struct ibmvnic_rx_queue_stats) / sizeof(u64))
232+
229233
struct ibmvnic_acl_buffer {
230234
__be32 len;
231235
__be32 version;

0 commit comments

Comments
 (0)