* [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation
@ 2026-08-08 16:36 Jakub Kicinski
2026-08-08 16:36 ` [PATCH net-next 2/2] selftests: drv-net: let ethtool stats settle before reading Jakub Kicinski
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jakub Kicinski @ 2026-08-08 16:36 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
andrew, shuah, petrm, ioana.ciornei, linux-kselftest
mausezahn defaults to sending packets back to back at the maximum rate,
which can cause packet loss, especially if receiver is running a debug
kernel. Space the generated packets out (-d 10usec), like ethtool_rmon
already does.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andrew@lunn.ch
CC: shuah@kernel.org
CC: petrm@nvidia.com
CC: ioana.ciornei@nxp.com
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh b/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh
index c085d2a4c989..1b329b3f60c2 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh
@@ -43,10 +43,10 @@ traffic_test()
done
# shellcheck disable=SC2086 # needs split options
- run_on "$iface" "$MZ" "$iface" -q -c "$num_tx" $pkt_format
+ run_on "$iface" "$MZ" "$iface" -q -d 10usec -c "$num_tx" $pkt_format
# shellcheck disable=SC2086 # needs split options
- run_on "$neigh" "$MZ" "$neigh" -q -c "$num_rx" $pkt_format
+ run_on "$neigh" "$MZ" "$neigh" -q -d 10usec -c "$num_rx" $pkt_format
for i in "${!counters[@]}"; do
read -r int grp cnt target exact_check xfail_message \
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH net-next 2/2] selftests: drv-net: let ethtool stats settle before reading
2026-08-08 16:36 [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation Jakub Kicinski
@ 2026-08-08 16:36 ` Jakub Kicinski
2026-08-08 16:52 ` Andrew Lunn
[not found] ` <87ecg6cnm7.fsf@pmachata.org>
2026-08-11 0:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2026-08-08 16:36 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
andrew, shuah, dsahern, idosch, ioana.ciornei, petrm,
linux-kselftest
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.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: andrew@lunn.ch
CC: shuah@kernel.org
CC: dsahern@kernel.org
CC: idosch@nvidia.com
CC: ioana.ciornei@nxp.com
CC: petrm@nvidia.com
CC: linux-kselftest@vger.kernel.org
---
.../selftests/drivers/net/hw/ethtool_rmon.sh | 2 ++
.../selftests/drivers/net/hw/ethtool_std_stats.sh | 2 ++
tools/testing/selftests/net/forwarding/lib.sh | 15 +++++++++++++++
3 files changed, 19 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh b/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
index 2ec19edddfaa..a074834cbe59 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh
@@ -65,6 +65,8 @@ bucket_test()
run_on "$iface" \
"$MZ" "$iface" -q -c "$num_tx" -p "$len" -a own -b bcast -d 10us
+ hw_stats_settle "$iface"
+
after=$(run_on "$iface" ethtool --json -S "$iface" --groups rmon | \
jq -r ".[0].rmon[\"${set}-pktsNtoM\"][$bucket].val")
diff --git a/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh b/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh
index 1b329b3f60c2..09f8128c51f3 100755
--- a/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh
+++ b/tools/testing/selftests/drivers/net/hw/ethtool_std_stats.sh
@@ -48,6 +48,8 @@ traffic_test()
# shellcheck disable=SC2086 # needs split options
run_on "$neigh" "$MZ" "$neigh" -q -d 10usec -c "$num_rx" $pkt_format
+ hw_stats_settle "$int"
+
for i in "${!counters[@]}"; do
read -r int grp cnt target exact_check xfail_message \
<<< "${counters[$i]}"
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index ac8358bcb22c..05acd4011456 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -406,6 +406,21 @@ get_ifname_by_ip()
__run_on "$target" ip -j addr show to "$ip_addr" | jq -r '.[].ifname'
}
+# Wait for the device to refresh its HW statistics. Devices latch the stats
+# reported via ethtool only every stats-block-usecs, so sample after that.
+hw_stats_settle()
+{
+ local iface=$1; shift
+ local usecs
+
+ # Match only a non-zero integer; 0 or "n/a" use default (20msec)
+ usecs=$(run_on "$iface" ethtool -c "$iface" 2>/dev/null | \
+ sed -n 's/^stats-block-usecs:[[:space:]]*\([1-9][0-9]*\)$/\1/p')
+ usecs=${usecs:-20000}
+
+ sleep "$(echo "$usecs * 1.25 / 1000 / 1000" | bc -l)"
+}
+
# Whether the test is conforming to the requirements and usage described in
# drivers/net/README.rst.
: "${DRIVER_TEST_CONFORMANT:=no}"
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net-next 2/2] selftests: drv-net: let ethtool stats settle before reading
2026-08-08 16:36 ` [PATCH net-next 2/2] selftests: drv-net: let ethtool stats settle before reading Jakub Kicinski
@ 2026-08-08 16:52 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2026-08-08 16:52 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
dsahern, idosch, ioana.ciornei, petrm, linux-kselftest
On Sat, Aug 08, 2026 at 09:36:53AM -0700, Jakub Kicinski wrote:
> Some devices refresh the statistics exposed via ethtool only
> periodically, every stats-block-usecs (as reported by ethtool -c).
Interesting. I did not know that existed. Which also suggests not many
drivers actually set it.
I will keep an eye out for drivers which should set this, but don't.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <87ecg6cnm7.fsf@pmachata.org>]
* Re: [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation
[not found] ` <87ecg6cnm7.fsf@pmachata.org>
@ 2026-08-10 23:48 ` Jakub Kicinski
2026-08-11 7:23 ` Petr Machata
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2026-08-10 23:48 UTC (permalink / raw)
To: netdev; +Cc: Petr Machata
On Mon, 10 Aug 2026 11:48:32 +0200 Petr Machata wrote:
> Jakub Kicinski <kuba@kernel.org> writes:
> > mausezahn defaults to sending packets back to back at the maximum rate,
> > which can cause packet loss, especially if receiver is running a debug
> > kernel. Space the generated packets out (-d 10usec), like ethtool_rmon
> > already does.
> >
> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
FTR Petr send me a review tag on this off-list ;)
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation
2026-08-10 23:48 ` [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation Jakub Kicinski
@ 2026-08-11 7:23 ` Petr Machata
0 siblings, 0 replies; 6+ messages in thread
From: Petr Machata @ 2026-08-11 7:23 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netdev, Petr Machata
Jakub Kicinski <kuba@kernel.org> writes:
> On Mon, 10 Aug 2026 11:48:32 +0200 Petr Machata wrote:
>> Jakub Kicinski <kuba@kernel.org> writes:
>> > mausezahn defaults to sending packets back to back at the maximum rate,
>> > which can cause packet loss, especially if receiver is running a debug
>> > kernel. Space the generated packets out (-d 10usec), like ethtool_rmon
>> > already does.
>> >
>> > Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>>
>> Reviewed-by: Petr Machata <petrm@nvidia.com>
>
> FTR Petr send me a review tag on this off-list ;)
Oops, that was not the intention.
My mailer setup is currently in a bit of a flux :-|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation
2026-08-08 16:36 [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation Jakub Kicinski
2026-08-08 16:36 ` [PATCH net-next 2/2] selftests: drv-net: let ethtool stats settle before reading Jakub Kicinski
[not found] ` <87ecg6cnm7.fsf@pmachata.org>
@ 2026-08-11 0:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-11 0:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, andrew,
shuah, petrm, ioana.ciornei, linux-kselftest
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 8 Aug 2026 09:36:52 -0700 you wrote:
> mausezahn defaults to sending packets back to back at the maximum rate,
> which can cause packet loss, especially if receiver is running a debug
> kernel. Space the generated packets out (-d 10usec), like ethtool_rmon
> already does.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> [...]
Here is the summary with links:
- [net-next,1/2] selftests: drv-net: pace ethtool_std_stats packet generation
https://git.kernel.org/netdev/net-next/c/f4cf60568747
- [net-next,2/2] selftests: drv-net: let ethtool stats settle before reading
https://git.kernel.org/netdev/net-next/c/855631afe0f5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-11 7:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08 16:36 [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation Jakub Kicinski
2026-08-08 16:36 ` [PATCH net-next 2/2] selftests: drv-net: let ethtool stats settle before reading Jakub Kicinski
2026-08-08 16:52 ` Andrew Lunn
[not found] ` <87ecg6cnm7.fsf@pmachata.org>
2026-08-10 23:48 ` [PATCH net-next 1/2] selftests: drv-net: pace ethtool_std_stats packet generation Jakub Kicinski
2026-08-11 7:23 ` Petr Machata
2026-08-11 0:00 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.