Skip to content

Commit d61df9e

Browse files
josh8551021opsiff
authored andcommitted
gve: handle overflow when reporting TX consumed descriptors
commit 15970e1 upstream. When the tx tail is less than the head (in cases of wraparound), the TX consumed descriptor statistic in DQ will be reported as UINT32_MAX - head + tail, which is incorrect. Mask the difference of head and tail according to the ring size when reporting the statistic. Cc: [email protected] Fixes: 2c91983 ("gve: Add consumed counts to ethtool stats") Signed-off-by: Joshua Washington <[email protected]> Signed-off-by: Harshitha Ramamurthy <[email protected]> Reviewed-by: Michal Swiatkowski <[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: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 504464f)
1 parent 675c9e5 commit d61df9e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/ethernet/google/gve/gve_ethtool.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ gve_get_ethtool_stats(struct net_device *netdev,
356356
*/
357357
data[i++] = 0;
358358
data[i++] = 0;
359-
data[i++] = tx->dqo_tx.tail - tx->dqo_tx.head;
359+
data[i++] =
360+
(tx->dqo_tx.tail - tx->dqo_tx.head) &
361+
tx->mask;
360362
}
361363
do {
362364
start =

0 commit comments

Comments
 (0)