mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed
@ 2026-11-28 10:17 Maxime Chevallier (Netdev Foundation)
  2026-11-28 17:07 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Maxime Chevallier (Netdev Foundation) @ 2026-11-28 10:17 UTC (permalink / raw)
  To: Andrew Lunn, Jakub Kicinski, davem, Eric Dumazet,
	Willem de Bruijn, Paolo Abeni, Simon Horman, Russell King,
	Shuah Khan, Bobby Eshleman, Stanislav Fomichev, Breno Leitao,
	matttbe
  Cc: Maxime Chevallier (Netdev Foundation),
	thomas.petazzoni, netdev, linux-kernel, linux-kselftest

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@bootlin.com>
---
 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


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

* Re: [PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed
  2026-11-28 10:17 [PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed Maxime Chevallier (Netdev Foundation)
@ 2026-11-28 17:07 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2026-11-28 17:07 UTC (permalink / raw)
  To: Maxime Chevallier (Netdev Foundation)
  Cc: Jakub Kicinski, davem, Eric Dumazet, Willem de Bruijn,
	Paolo Abeni, Simon Horman, Russell King, Shuah Khan,
	Bobby Eshleman, Stanislav Fomichev, Breno Leitao, matttbe,
	thomas.petazzoni, netdev, linux-kernel, linux-kselftest

> 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.

The logic of the patch makes sense. So i've no problems with the patch
itself.

I'm just curious about not being able to see it. Autoneg, at 1G, take
a little over 1 second. So if you can poll at 0.5s intervals, you
should see it. Is ssh to this machine really slow? Or is the Intel
i350-T4 driver doing something odd? Slow at reporting the down? Fast a
reporting the up?

	Andrew

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

end of thread, other threads:[~2026-11-28 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28 10:17 [PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed Maxime Chevallier (Netdev Foundation)
2026-11-28 17:07 ` Andrew Lunn

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

all inboxes | Powered by JetHome®