DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/ixgbe: fix queue received bytes CRC adjustment
@ 2026-05-04 12:26 Daniil Iskhakov
  2026-05-06 15:59 ` Bruce Richardson
  0 siblings, 1 reply; 2+ messages in thread
From: Daniil Iskhakov @ 2026-05-04 12:26 UTC (permalink / raw)
  To: Anatoly Burakov, Vladimir Medvedkin, Konstantin Ananyev,
	Harry van Haaren
  Cc: dev, stable, Daniil Iskhakov, sdl.dpdk, rrv

For 82599, QBRC is a 36-bit clear-on-read counter, while
QPRC is a 32-bit clear-on-read counter. ixgbe_read_stats_registers()
accumulates QBRC in a 64-bit software counter and, when CRC stripping
is disabled, subtracts the CRC bytes accounted for each received packet.

The CRC adjustment is computed as:

	delta_qprc * RTE_ETHER_CRC_LEN

Since delta_qprc is 32-bit, the multiplication is performed in 32 bits
and may wrap before the result is subtracted from the 64-bit QBRC
accumulator. A full 32-bit packet delta needs more than 32 bits to
represent the CRC-byte adjustment.

Cast delta_qprc to uint64_t before the multiplication so the adjustment
is computed with the same effective width as the byte counter.

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

Fixes: c03fcee9abbd ("ixgbe: remove CRC size from byte counters")
Cc: stable@dpdk.org

Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
---
Cc: harry.van.haaren@intel.com
Cc: sdl.dpdk@linuxtesting.org
Cc: rrv@amicon.ru
---
 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..c17ce70810 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -3237,7 +3237,7 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw,
 		hw_stats->qbrc[i] +=
 		    ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
 		if (crc_strip == 0)
-			hw_stats->qbrc[i] -= delta_qprc * RTE_ETHER_CRC_LEN;
+			hw_stats->qbrc[i] -= (uint64_t)delta_qprc * RTE_ETHER_CRC_LEN;
 
 		hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
 		hw_stats->qbtc[i] +=
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/ixgbe: fix queue received bytes CRC adjustment
  2026-05-04 12:26 [PATCH] net/ixgbe: fix queue received bytes CRC adjustment Daniil Iskhakov
@ 2026-05-06 15:59 ` Bruce Richardson
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Richardson @ 2026-05-06 15:59 UTC (permalink / raw)
  To: Daniil Iskhakov
  Cc: Anatoly Burakov, Vladimir Medvedkin, Konstantin Ananyev, dev,
	stable, sdl.dpdk, rrv

On Mon, May 04, 2026 at 03:26:23PM +0300, Daniil Iskhakov wrote:
> For 82599, QBRC is a 36-bit clear-on-read counter, while
> QPRC is a 32-bit clear-on-read counter. ixgbe_read_stats_registers()
> accumulates QBRC in a 64-bit software counter and, when CRC stripping
> is disabled, subtracts the CRC bytes accounted for each received packet.
> 
> The CRC adjustment is computed as:
> 
> 	delta_qprc * RTE_ETHER_CRC_LEN
> 
> Since delta_qprc is 32-bit, the multiplication is performed in 32 bits
> and may wrap before the result is subtracted from the 64-bit QBRC
> accumulator. A full 32-bit packet delta needs more than 32 bits to
> represent the CRC-byte adjustment.
> 
> Cast delta_qprc to uint64_t before the multiplication so the adjustment
> is computed with the same effective width as the byte counter.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: c03fcee9abbd ("ixgbe: remove CRC size from byte counters")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Daniil Iskhakov <dish@amicon.ru>
> ---

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied to dpdk-next-net-intel.

Thanks,
/Bruce


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-06 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 12:26 [PATCH] net/ixgbe: fix queue received bytes CRC adjustment Daniil Iskhakov
2026-05-06 15:59 ` Bruce Richardson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox