Skip to contentSkip to conversation

net/ixgbe: fix good octets CRC adjustment

PATCH Applied Daniil Iskhakov 2 participants 3 messages May 5 – May 6 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ixgbe: fix good octets CRC adjustment

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]
Cc: [email protected]
Cc: [email protected]

---
 drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/ixgbe/ixgbe_ethdev.c +1 -1
index 57d929cf2c..71243610ee 100644
@@ -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
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · Daniil Iskhakov

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.

Quoted 6 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes c03fcee9abbd ("ixgbe: remove CRC size from byte counters")
#2 lore raw
Quoted 19 lines · Bruce Richardson
Quoted 18 lines · Daniil Iskhakov

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.

Quoted 7 lines
Quoted 6 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes c03fcee9abbd ("ixgbe: remove CRC size from byte counters")

Applied to dpdk-next-net-intel.
Thanks,
/Bruce