mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 00:35:00 -04:00
Some devices refresh the statistics exposed via ethtool only periodically, every stats-block-usecs (as reported by ethtool -c). ethtool_std_stats and ethtool_rmon sample the counters immediately after generating traffic, so on such devices they can read stale values and fail with a delta short of the packets just sent. Add a hw_stats_settle() helper which sleeps for 1.25x the configured stats-block-usecs (defaulting to 20ms when the device reports no, or a zero, period). Use it for ethtool std stats and RMON. The 1.25x/20msec heuristic matches what the Python tests do. Reviewed-by: Petr Machata <petrm@nvidia.com> Link: https://patch.msgid.link/20260808163653.2460381-2-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>