[PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed
From: Maxime Chevallier (Netdev Foundation)
Date: Sat Nov 28 2026 - 05:17:47 EST
When probing for the kselftest remote in the Pause test, we try to
detect if it is directly connected to the DUT, or if it's reached
through switches.
For that, we trigger a renegotiation on the DUT, and check if the link
flaps on the remote end. The current implementation may hit a race
condition if the link flap happens so fast that we don't see it when
checking on the remote.
Let's rework the logic by measuring the number of link state changes on
the remote, then triggering the renegotiation, then re-checking on the
remote if the link change counter has changed, or changes within the
timeout window.
While at it, do a small refactor to store the "get the link change
counter" command into at dedicated variable that we re-use afterwards.
This has been found while running the stmmac kernel selftest suite
between an imx8mp + ksz9131 PHY and a Intel i350-T4 card, the
renegotiation happened too fast to reliably see it on the intel card
side.
Fixes: 8f897f26ef34 ("selftests: drv-net: pause: Validate the pause autonegotiation with a partner")
Signed-off-by: Maxime Chevallier (Netdev Foundation) <maxime.chevallier@xxxxxxxxxxx>
---
tools/testing/selftests/drivers/net/hw/pause.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/pause.py b/tools/testing/selftests/drivers/net/hw/pause.py
index ca4a55e59c30..5d7518f33e83 100755
--- a/tools/testing/selftests/drivers/net/hw/pause.py
+++ b/tools/testing/selftests/drivers/net/hw/pause.py
@@ -8,6 +8,7 @@ Driver-related behavior tests for Pause-based Flow Control.
import errno
import json
import os
+import time
from lib.py import KsftFailEx, KsftNamedVariant, KsftSkipEx
from lib.py import NetDrvEpEnv
@@ -99,8 +100,8 @@ def controllable_lp(cfg):
if controllable is not None:
return controllable
- before = int(cmd(f"cat /sys/class/net/{cfg.remote_ifname}/carrier_changes",
- host=cfg.remote).stdout)
+ carrier_changes_cmd = f"cat /sys/class/net/{cfg.remote_ifname}/carrier_changes"
+ before = int(cmd(carrier_changes_cmd, host=cfg.remote).stdout)
ret, _ = ethtool_ret(f"-r {cfg.ifname}", is_get=False)
if ret != 0:
@@ -108,8 +109,14 @@ def controllable_lp(cfg):
wait_for_aneg(cfg, link_drop=True)
- cfg.lp_controllable = int(cmd(f"cat /sys/class/net/{cfg.remote_ifname}/carrier_changes",
- host=cfg.remote).stdout) > before
+ link_changed = False
+ end = time.monotonic() + 5
+ while not link_changed and time.monotonic() < end:
+ time.sleep(0.1)
+ after = int(cmd(carrier_changes_cmd, host=cfg.remote).stdout)
+ link_changed = after > before
+
+ cfg.lp_controllable = link_changed
return cfg.lp_controllable
def require_controllable_lp(cfg):
--
2.56.1