From: "Maxime Chevallier (Netdev Foundation)" <maxime.chevallier@bootlin.com>
To: Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, Eric Dumazet <edumazet@kernel.org>,
Willem de Bruijn <willemb@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Shuah Khan <skhan@linuxfoundation.org>,
Bobby Eshleman <bobbyeshleman@meta.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Breno Leitao <leitao@debian.org>,
matttbe@kernel.org
Cc: "Maxime Chevallier (Netdev Foundation)"
<maxime.chevallier@bootlin.com>,
thomas.petazzoni@bootlin.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed
Date: Sat, 28 Nov 2026 11:17:24 +0100 [thread overview]
Message-ID: <20261128101725.17398-1-maxime.chevallier@bootlin.com> (raw)
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
next reply other threads:[~2026-11-28 10:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 10:17 Maxime Chevallier (Netdev Foundation) [this message]
2026-11-28 17:07 ` [PATCH net v2] selftests: drv-net: pause: ensure the link partner sees the link when probed Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261128101725.17398-1-maxime.chevallier@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=bobbyeshleman@meta.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=matttbe@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=skhan@linuxfoundation.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox