[PATCH 1/3] net/ice: fix Rx packets statistics underflow
Bruce Richardson
bruce.richardson at intel.com
Thu Jun 25 17:57:21 CEST 2026
On Thu, Jun 25, 2026 at 09:36:17AM +0000, Ciara Loftus wrote:
> The number of Rx packets is computed as the sum of the unicast,
> multicast and broadcast packet counters, minus the discarded packet
> count:
>
> ipackets = rx_unicast + rx_multicast + rx_broadcast - rx_discards
>
> The unicast, multicast and broadcast counters already include the
> packets that were subsequently dropped, so subtracting rx_discards
> yields only the packets delivered to the application. However, each of
> these counters is read from a separate hardware register, and the reads
> happen at slightly different instants. Under load, rx_discards (read
> last) can momentarily exceed the sum of the unicast, multicast and
> broadcast counters (read earlier). As ipackets is unsigned, the
> subtraction then wraps to a huge bogus value, reported to the
> application as an enormous Rx packet count and packet rate.
>
> Read the rx_discards register before the unicast, multicast and
> broadcast registers. As all of these counters only ever increase, and
> the unicast, multicast and broadcast counters always include the
> discarded packets, sampling rx_discards first guarantees it can never
> exceed the later sum of the other three, so the subtraction can never
> underflow.
>
> Fixes: a37bde56314d ("net/ice: support statistics")
> Cc: stable at dpdk.org
>
> Signed-off-by: Ciara Loftus <ciara.loftus at intel.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
More information about the dev
mailing list