On some devices, such as 82599, GORC is a 36-bit clear-on-read counter,
while GPRC is a 32-bit clear-on-read counter.
ixgbe_read_stats_registers() accumulates GORC in a 64-bit software
counter and, when CRC stripping is disabled, subtracts the CRC bytes
accounted for each received packet.
The driver does not read GPRC directly. Due to an erratum, it derives
the good packet delta from the sum of per-queue packet receives instead.
The 32-bit QPRC registers are used for this purpose.
delta_gprc is used as an accumulator for those per-queue deltas and is
then used to compute the CRC-byte adjustment. Keeping it 32-bit may wrap
the accumulated packet delta before it is used to adjust the 64-bit GORC
counter.
Make delta_gprc 64-bit so the accumulated packet delta and the CRC-byte
adjustment are computed without 32-bit overflow.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: c03fcee9abbd ("ixgbe: remove CRC size from byte counters")
Cc: [email protected]
Signed-off-by: Daniil Iskhakov <[email protected]>
---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index 57d929cf2c..71243610ee 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -3182,7 +3182,7 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw,
uint64_t *total_qprc, uint64_t *total_qprdc)
{
uint32_t bprc, lxon, lxoff, total;
- uint32_t delta_gprc = 0;
+ uint64_t delta_gprc = 0;
unsigned i;
/* Workaround for RX byte count not including CRC bytes when CRC
* strip is enabled. CRC bytes are removed from counters when crc_strip
--
2.43.0