selftests: drv-net: Introduce flow-control selftest
Subsystems (4)
cover selftests: drv-net: Introduce flow-control selftest
Hi,
This series introduces a test suite for Flow Control, to validate that drivers behave correctly according to 802.3, but also in a homogenous way.
Flow control is tricky to get right, for multiple reasons :
- The negotiation process uses Pause + Asym, while the ethtool API to configure pause with TX and RX modes
- It involves multiple drivers :
- The MAC driver implements the actual Pause frame handling and generation by controlling and reporting these settings to/from the hardware. It's also in charge of reporting what the MAC can do.
- The PHY driver does the actual Pause parameters negociation with the LP, and reports that to the MAC
- Some PCS are also involved in pause to some extent.
phylink helps to some extent, as it implements a lot of the 802.3 translation between RX/TX and Pause/Asym, but not all drivers use phylink.
Some PHY drivers also tweak the pause advertising, due to HW issues. For example, KSZ9031 may fail to establish link when advertising Asym Pause.
On top of that, there are 2 toggles for pause autoneg :
- Link-wide autoneg, dictating whether or not we negotiate ANY parameter with the partner
- Pause autoneg, that only dictates the Pause advertising
To top it all off, the Pause autonegotiation isn't a strict "pick modes that match exactly what users requested on both ends of the link", the negotiated pause params may actually differ from what the user asked.
This set of tests is aimed at catching all these issues.
This was tested on a wide variety of HW, some that support Pause + Asym, some that only support Pause, with a peer that can or can't do pause.
Some issues were found, e.g. even with phylink, setting pause tx off rx off aneg on makes the local interface still advertise Pause + Asym.
Tested on Macchiatobin, Espressobin, Turris omnia, and around 10 different boards that run stmmac.
Thanks to the Netdev Foundation for funding that work,
Maxime
Maxime Chevallier (Netdev Foundation) (3):
selftests: drv-net: Introduce a selftest for ethtool flow control
selftests: drv-net: pause: Validate the pause autonegotiation with a
partner
selftests: drv-net: pause: Validate pause autoneg interactions with
link autoneg
.../testing/selftests/drivers/net/hw/Makefile | 1 + .../drivers/net/hw/lib/py/__init__.py | 7 +- .../testing/selftests/drivers/net/hw/pause.py | 973 ++++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 7 +- .../selftests/drivers/net/lib/py/ethtool.py | 205 ++++ 5 files changed, 1191 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/hw/pause.py create mode 100644 tools/testing/selftests/drivers/net/lib/py/ethtool.py
Signature · 1 line
2.55.0
PATCH 1/3 selftests: drv-net: Introduce a selftest for ethtool flow control
Ethernet flow control is a tricky thing to get right, especially when it comes to correctly handling the negotiation of the parameters with a link partner.
One one hand, the userspace API talks in terms of the device's ability to send Pause frames when the device is overwhelmed by ingress traffic (TX pause) and the ability to stop sending traffic upon receiving Pause frames (RX pause).
On the other hand, 802.3 explains that devices can exchange their abilities over link negotiation, but instead of echanging TX and RX abilities, they exchange Pause and Asymmetric Pause capabilities :
RX unable TX unable => None
RX able TX unable => Pause + Asymmetric
RX unable TX able => Asymmetric
RX able TX able => Pause
Introduce a set of Pause selftests that verify that the local interface's supported pause parameters reported from ethtool (in terms of Pause + Asym ) match the accepted parameters from "ethtool -A", corresponding to ethtool's .set_pauseparams() ops, expressed in TX and RX abilities.
The reported Pause and Asym abilities depend both on the MAC, that eventually sends and processes these frames, and the PHY, that advertises these to the partner.
Both MAC and PHYs can have their own limitations, and getting the correct set of supported Pause/Asym parameters is non-trivial, unless the MAC uses phylink, which deals with the complexity.
All the selftests need to set a link's pauseparams, wait for link up, wait for autoneg, configure a peer, etc. Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
--- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../drivers/net/hw/lib/py/__init__.py | 6 +- .../testing/selftests/drivers/net/hw/pause.py | 353 ++++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 6 +- .../selftests/drivers/net/lib/py/ethtool.py | 133 +++++++ 5 files changed, 497 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/hw/pause.py create mode 100644 tools/testing/selftests/drivers/net/lib/py/ethtool.py
tools/testing/selftests/drivers/net/hw/Makefile +1 -0
@@ -44,6 +44,7 @@ TEST_PROGS = \ nk_netns.py \ nk_qlease.py \ ntuple.py \ + pause.py \ pp_alloc_fail.py \ rss_api.py \ rss_ctx.py \
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +5 -1
@@ -33,6 +33,8 @@ try: ksft_ne, ksft_not_in, ksft_raises, ksft_true, ksft_gt, ksft_not_none from drivers.net.lib.py import GenerateTraffic, Remote, Iperf3Runner from drivers.net.lib.py import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv + from drivers.net.lib.py import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ + forced_link_settings __all__ = ["NetNS", "NetNSEnter", "NetdevSimDev", "UserNetNS", "EthtoolFamily", "NetdevFamily", "NetshaperFamily",
@@ -49,7 +51,9 @@ try: "ksft_ne", "ksft_not_in", "ksft_raises", "ksft_true", "ksft_gt", "ksft_not_none", "ksft_not_none", "NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", - "Remote", "Iperf3Runner"] + "Remote", "Iperf3Runner", + "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", + "require_link_autoneg", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources") print(str(e))
tools/testing/selftests/drivers/net/hw/pause.py new file +353 -0
353 lines not on this page · raw message
tools/testing/selftests/drivers/net/lib/py/__init__.py +5 -1
@@ -50,9 +50,13 @@ try: from .env import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv from .load import GenerateTraffic, Iperf3Runner from .remote import Remote + from .ethtool import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ + forced_link_settings __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", - "Remote", "Iperf3Runner"] + "Remote", "Iperf3Runner", + "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", + "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources") print(str(e))
tools/testing/selftests/drivers/net/lib/py/ethtool.py new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.55.0
Jakub Kicinski
maintainerRe: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
Quoted 2 lines · On Sun, 20 Sep 2026 18:47:27 +0200 Maxime Chevallier (Netdev Foundation) wrote:
Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
Please resist the urge to create libraries.
If you're doing this I suspect you didn't even read the README and you expect people to search around for libraries?
Put the code in your test, the duplication doesn't matter. If you _absolutely have to_ you can create a local lib under tools/testing/selftests/drivers/net/hw/ but please think really hard before you do.
Quoted 1 line
+ :param cfg: test config
If you have nothing to say - don't say anything 🤷️
tools/testing/selftests/drivers/net/hw/pause.py line 91
Quoted 5 lines
tools/testing/selftests/drivers/net/hw/pause.py new file +5
-0+ :returns: tuple containing : + - return code of the ethtool command, + - rx status, + - tx status, + - aneg status
Have you seen much code in netdev selftests using this style of comments?
Quoted 1 line
+
defer(cmd, f"ethtool -s {cfg.ifname} autoneg on", fail=False)
Why are you putting fail=False on the defers? IIRC defer errors are logged and ignored. Is ethtool reporting an error when there's nothing to change?
Those are just some things that immediately jump out :) Please also fix the pylint --disable=R issues?
Re: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
Hi Jakub,
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Sun, 20 Sep 2026 18:47:27 +0200 Maxime Chevallier (Netdev Foundation) wrote:
Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
Please resist the urge to create libraries.
If you're doing this I suspect you didn't even read the README and you expect people to search around for libraries?
I did read the README and fought the urge, that was something Andrew was asking for in the previous round :( I'm ok with either TBH.
Quoted 10 lines
Put the code in your test, the duplication doesn't matter. If you
_absolutelyhaveto_you can create a local lib undertools/testing/selftests/drivers/net/hw/but please think really hard before you do.Quoted 1 line
+ :param cfg: test config
If you have nothing to say - don't say anything 🤷️
Quoted 8 lines
tools/testing/selftests/drivers/net/hw/pause.py line 91
Quoted 5 lines
tools/testing/selftests/drivers/net/hw/pause.py new file +5
-0+ :returns: tuple containing : + - return code of the ethtool command, + - rx status, + - tx status, + - aneg statusHave you seen much code in netdev selftests using this style of comments?
Hmm that's a leftover from the previous round that was pretty much only coments, I can trim that down.
Quoted 6 lines
Quoted 2 lines
+
defer(cmd, f"ethtool -s {cfg.ifname} autoneg on", fail=False)Why are you putting fail=False on the defers? IIRC defer errors are logged and ignored. Is ethtool reporting an error when there's nothing to change?
IIRC I had the issue when running that on a USB dongle, it's likely this is something I put there and actually forgot to remove after finding a better solution :(
Quoted 3 lines
Those are just some things that immediately jump out :) Please also fix the pylint --disable=R issues?
Sure no problem,
Thanks a lot for taking a look,
Maxime
Jakub Kicinski
maintainerRe: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
Quoted 6 lines · On Wed, 23 Sep 2026 07:41:13 +0200 Maxime Chevallier wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 2 lines · On Sun, 20 Sep 2026 18:47:27 +0200 Maxime Chevallier (Netdev Foundation) wrote:
Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
Quoted 7 lines
Quoted 4 lines
Please resist the urge to create libraries.
If you're doing this I suspect you didn't even read the README and you expect people to search around for libraries?
I did read the README and fought the urge, that was something Andrew was asking for in the previous round :( I'm ok with either TBH.
I guess it was Andrew that didn't read the docs then :)
Re: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Wed, 23 Sep 2026 07:41:13 +0200 Maxime Chevallier wrote:
Quoted 7 lines · Jakub Kicinski
Quoted 2 lines · On Sun, 20 Sep 2026 18:47:27 +0200 Maxime Chevallier (Netdev Foundation) wrote:
Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
Please resist the urge to create libraries.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If you're doing this I suspect you didn't even read the README and you expect people to search around for libraries?
I did read the README and fought the urge, that was something Andrew was asking for in the previous round :( I'm ok with either TBH.
I guess it was Andrew that didn't read the docs then :)
Yes.
I apply software engineering principles to tests as i would to any other code. It has to be maintained, bug fixed etc. For my $DAY_JOB, i spend as much time maintaining test code as feature code. So i don't really want lots of copy/paste version of the same code.
So, for flow control, lets follow the README. When EEE is implemented, we can see how bad the copy/paste is, and then consider a library.
Andrew
Re: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
Hi,
Quoted 20 lines · Andrew Lunn
Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Wed, 23 Sep 2026 07:41:13 +0200 Maxime Chevallier wrote:
Quoted 7 lines · Jakub Kicinski
Quoted 2 lines · On Sun, 20 Sep 2026 18:47:27 +0200 Maxime Chevallier (Netdev Foundation) wrote:
Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
Please resist the urge to create libraries.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If you're doing this I suspect you didn't even read the README and you expect people to search around for libraries?
I did read the README and fought the urge, that was something Andrew was asking for in the previous round :( I'm ok with either TBH.
I guess it was Andrew that didn't read the docs then :)
Yes.
Quoted 7 lines
I apply software engineering principles to tests as i would to any other code. It has to be maintained, bug fixed etc. For my $DAY_JOB, i spend as much time maintaining test code as feature code. So i don't really want lots of copy/paste version of the same code.
So, for flow control, lets follow the README. When EEE is implemented, we can see how bad the copy/paste is, and then consider a library.
No problem, should be easier to review as well :)
Thank you both,
Maxime
Re: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
In reply to Andrew LunnQuoted 20 lines · Andrew Lunn
Quoted 9 lines · Jakub Kicinski
Quoted 8 lines · On Wed, 23 Sep 2026 07:41:13 +0200 Maxime Chevallier wrote:
Quoted 7 lines · Jakub Kicinski
Quoted 2 lines · On Sun, 20 Sep 2026 18:47:27 +0200 Maxime Chevallier (Netdev Foundation) wrote:
Future ethtool selftests are expected to use the same, these helpers are put in the net selftest lib.
Please resist the urge to create libraries.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
If you're doing this I suspect you didn't even read the README and you expect people to search around for libraries?
I did read the README and fought the urge, that was something Andrew was asking for in the previous round :( I'm ok with either TBH.
I guess it was Andrew that didn't read the docs then :)
Yes.
Quoted 7 lines
I apply software engineering principles to tests as i would to any other code. It has to be maintained, bug fixed etc. For my $DAY_JOB, i spend as much time maintaining test code as feature code. So i don't really want lots of copy/paste version of the same code.
So, for flow control, lets follow the README. When EEE is implemented, we can see how bad the copy/paste is, and then consider a library.
Some side question, as the whole thing goes into the same file, do you prefer that the series stays split into 3 patches, or do you prefer the whole thing in one single patch ?
The diffstat would be :
tools/testing/selftests/drivers/net/hw/Makefile | 1 +tools/testing/selftests/drivers/net/hw/pause.py | 998 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Maxime
Jakub Kicinski
maintainerRe: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
Quoted 8 lines · On Fri, 25 Sep 2026 15:59:27 +0200 Maxime Chevallier wrote:
Some side question, as the whole thing goes into the same file, do you prefer that the series stays split into 3 patches, or do you prefer the whole thing in one single patch ?
The diffstat would be :
tools/testing/selftests/drivers/net/hw/Makefile| 1 +tools/testing/selftests/drivers/net/hw/pause.py| 998 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
You can still split by functionality? No strong preference from me, but I think you were asking Andrew.
Jakub Kicinski
maintainerRe: [PATCH net-next 1/3] selftests: drv-net: Introduce a selftest for ethtool flow control
In reply to Andrew LunnQuoted 4 lines · On Thu, 24 Sep 2026 15:54:36 +0200 Andrew Lunn wrote:
I apply software engineering principles to tests as i would to any other code. It has to be maintained, bug fixed etc. For my $DAY_JOB, i spend as much time maintaining test code as feature code. So i don't really want lots of copy/paste version of the same code.
FTR I disagree. Driver ksft are partially born out of my frustration with people treating "tests as normal software engineering" which somehow always ends up overly complex. Every team or group of people has their own, and it gets rewritten whenever the employee who wrote the initial version quits.
Simple, linear scripts which one can read without digging thru modules are the best possible tests. Even if they are 4x longer.
PATCH 2/3 selftests: drv-net: pause: Validate the pause autonegotiation with a partner
In reply to Maxime Chevallier (Netdev Foundation)Pause autonegotiation behaves differently than the regular link params autonegotiation, in that the user intention may differ from the negotiated pause parameters.
Introduce a test that validates we're correctly resolving pause parameters according to 802.3.
The validation is done based on what the local interface reports in terms of advertised and lp_advertised linkmodes.
If the remote can express what it sees in terms of its own advertised and lp_advertised modes, validate the autoneg results on the peer as well.
--- .../drivers/net/hw/lib/py/__init__.py | 3 +- .../testing/selftests/drivers/net/hw/pause.py | 336 ++++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 3 +- .../selftests/drivers/net/lib/py/ethtool.py | 60 +++- 4 files changed, 399 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +2 -1
@@ -34,6 +34,7 @@ try: from drivers.net.lib.py import GenerateTraffic, Remote, Iperf3Runner from drivers.net.lib.py import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv from drivers.net.lib.py import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ + controllable_lp, require_controllable_lp, \ forced_link_settings __all__ = ["NetNS", "NetNSEnter", "NetdevSimDev", "UserNetNS",
@@ -52,7 +53,7 @@ try: "ksft_not_none", "ksft_not_none", "NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", "Remote", "Iperf3Runner", - "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", + "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", "controllable_lp", "require_controllable_lp", "require_link_autoneg", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources")
tools/testing/selftests/drivers/net/hw/pause.py +336 -0
390 lines not on this page · raw message
tools/testing/selftests/drivers/net/lib/py/__init__.py +2 -1
@@ -51,11 +51,12 @@ try: from .load import GenerateTraffic, Iperf3Runner from .remote import Remote from .ethtool import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ + controllable_lp, require_controllable_lp, \ forced_link_settings __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", "Remote", "Iperf3Runner", - "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", + "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", "controllable_lp", "require_controllable_lp", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources")
tools/testing/selftests/drivers/net/lib/py/ethtool.py +59 -1
72 lines not on this page · raw message
Signature · 1 line
2.55.0
Re: [PATCH net-next 2/3] selftests: drv-net: pause: Validate the pause autonegotiation with a partner
Hi,
Quoted 7 lines · Maxime Chevallier (Netdev Foundation)
Pause autonegotiation behaves differently than the regular link params autonegotiation, in that the user intention may differ from the negotiated pause parameters.
Introduce a test that validates we're correctly resolving pause parameters according to 802.3.
Quoted 8 lines
The validation is done based on what the local interface reports in terms of advertised and
lp_advertisedlinkmodes.If the remote can express what it sees in terms of its own advertised and
lp_advertisedmodes, validate the autoneg results on the peer as well.
Dammit, this patch is duplicate, stale one from 2 format-patch sessions in the same -o folder :(
sorry about that :(
Maxime
PATCH 2/3 selftests: drv-net: pause: tests against a controllable link partner
In reply to Maxime Chevallier (Netdev Foundation)Pause autonegotiation behaves differently than the regular link params autonegotiation, in that the user intention may differ from the negotiated pause parameters.
Introduce a test that validates we're correctly resolving pause parameters according to 802.3.
The validation is done based on what the local interface reports in terms of advertised and lp_advertised linkmodes.
If the remote can express what it sees in terms of its own advertised and lp_advertised modes, validate the autoneg results on the peer as well.
--- .../drivers/net/hw/lib/py/__init__.py | 3 +- .../testing/selftests/drivers/net/hw/pause.py | 336 ++++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 3 +- .../selftests/drivers/net/lib/py/ethtool.py | 60 +++- 4 files changed, 399 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +2 -1
@@ -34,6 +34,7 @@ try: from drivers.net.lib.py import GenerateTraffic, Remote, Iperf3Runner from drivers.net.lib.py import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv from drivers.net.lib.py import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ + controllable_lp, require_controllable_lp, \ forced_link_settings __all__ = ["NetNS", "NetNSEnter", "NetdevSimDev", "UserNetNS",
@@ -52,7 +53,7 @@ try: "ksft_not_none", "ksft_not_none", "NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", "Remote", "Iperf3Runner", - "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", + "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", "controllable_lp", "require_controllable_lp", "require_link_autoneg", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources")
tools/testing/selftests/drivers/net/hw/pause.py +336 -0
390 lines not on this page · raw message
tools/testing/selftests/drivers/net/lib/py/__init__.py +2 -1
@@ -51,11 +51,12 @@ try: from .load import GenerateTraffic, Iperf3Runner from .remote import Remote from .ethtool import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ + controllable_lp, require_controllable_lp, \ forced_link_settings __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", "Remote", "Iperf3Runner", - "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", + "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", "controllable_lp", "require_controllable_lp", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources")
tools/testing/selftests/drivers/net/lib/py/ethtool.py +59 -1
72 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH 3/3 selftests: drv-net: pause: pause autoneg tests
In reply to Maxime Chevallier (Netdev Foundation)Pause autonegotiation happens with the link partner using the same words as the link negotiation, used for speed and duplex exchanges. However, pause and link autonegotiation can be separately toggled :
ethtool -s eth0 autoneg on # Enable link negotiation ethtool -A eth0 autoneg on # Enable Pause negotiation
Pause can't be negotiated if the link autoneg isn't enabled.
Pause autoneg and link autoneg settings must not interfere with one another when user is configuring them :
- If Pause autoneg is on, it must stay on when link autoneg is disabled (even though Pause won't actually be negotiated)
- If Pause autoneg is off, it must stay off when link autoneg is enabled
Introduce a set of tests to verify that pause and link autoneg are behaving correctly, in particular that the user intent is correctly cached when toggling link autoneg.
--- .../drivers/net/hw/lib/py/__init__.py | 2 +- .../testing/selftests/drivers/net/hw/pause.py | 284 ++++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 4 +- .../selftests/drivers/net/lib/py/ethtool.py | 14 + 4 files changed, 301 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +1 -1
@@ -34,7 +34,7 @@ try: from drivers.net.lib.py import GenerateTraffic, Remote, Iperf3Runner from drivers.net.lib.py import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv from drivers.net.lib.py import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ - controllable_lp, require_controllable_lp, \ + controllable_lp, require_controllable_lp, require_link_autoneg, \ forced_link_settings __all__ = ["NetNS", "NetNSEnter", "NetdevSimDev", "UserNetNS",
tools/testing/selftests/drivers/net/hw/pause.py +284 -0
314 lines not on this page · raw message
tools/testing/selftests/drivers/net/lib/py/__init__.py +2 -2
@@ -51,13 +51,13 @@ try: from .load import GenerateTraffic, Iperf3Runner from .remote import Remote from .ethtool import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ - controllable_lp, require_controllable_lp, \ + controllable_lp, require_controllable_lp, require_link_autoneg, \ forced_link_settings __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", "Remote", "Iperf3Runner", "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", "controllable_lp", "require_controllable_lp", - "forced_link_settings"] + "require_link_autoneg", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources") print(str(e))
tools/testing/selftests/drivers/net/lib/py/ethtool.py +14 -0
@@ -175,6 +175,20 @@ def require_controllable_lp(cfg) -> None: if not controllable_lp(cfg): raise KsftSkipEx(f"{cfg.remote_ifname} is not directly connected to {cfg.ifname}") +def require_link_autoneg(cfg) -> None: + """ Skip if local or remote don't support link autoneg + + :param cfg: test config + """ + # Does local device support link aneg + if not ethtool(f"{cfg.ifname}", json=True)[0]["supports-auto-negotiation"]: + raise KsftSkipEx(f"{cfg.ifname} doesn't support link autoneg") + + # Does remote device support link aneg + if not ethtool(f"{cfg.remote_ifname}", + json=True, host=cfg.remote)[0]["supports-auto-negotiation"]: + raise KsftSkipEx(f"Remote {cfg.remote_ifname} doesn't support link autoneg") + def forced_link_settings(cfg) -> str: """ Returns a string to pass to ethtool -s with speed/duplex corresponding to the current settings.
Signature · 1 line
2.55.0
PATCH 3/3 selftests: drv-net: pause: Validate pause autoneg interactions with link autoneg
In reply to Maxime Chevallier (Netdev Foundation)Pause autonegotiation happens with the link partner using the same words as the link negotiation, used for speed and duplex exchanges. However, pause and link autonegotiation can be separately toggled :
ethtool -s eth0 autoneg on # Enable link negotiation ethtool -A eth0 autoneg on # Enable Pause negotiation
Pause can't be negotiated if the link autoneg isn't enabled.
Pause autoneg and link autoneg settings must not interfere with one another when user is configuring them :
- If Pause autoneg is on, it must stay on when link autoneg is disabled (even though Pause won't actually be negotiated)
- If Pause autoneg is off, it must stay off when link autoneg is enabled
Introduce a set of tests to verify that pause and link autoneg are behaving correctly, in particular that the user intent is correctly cached when toggling link autoneg.
--- .../drivers/net/hw/lib/py/__init__.py | 2 +- .../testing/selftests/drivers/net/hw/pause.py | 284 ++++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 4 +- .../selftests/drivers/net/lib/py/ethtool.py | 14 + 4 files changed, 301 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +1 -1
@@ -34,7 +34,7 @@ try: from drivers.net.lib.py import GenerateTraffic, Remote, Iperf3Runner from drivers.net.lib.py import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv from drivers.net.lib.py import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ - controllable_lp, require_controllable_lp, \ + controllable_lp, require_controllable_lp, require_link_autoneg, \ forced_link_settings __all__ = ["NetNS", "NetNSEnter", "NetdevSimDev", "UserNetNS",
tools/testing/selftests/drivers/net/hw/pause.py +284 -0
314 lines not on this page · raw message
tools/testing/selftests/drivers/net/lib/py/__init__.py +2 -2
@@ -51,13 +51,13 @@ try: from .load import GenerateTraffic, Iperf3Runner from .remote import Remote from .ethtool import ethtool_ret, onoff, wait_for_link, wait_for_aneg, \ - controllable_lp, require_controllable_lp, \ + controllable_lp, require_controllable_lp, require_link_autoneg, \ forced_link_settings __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", "Remote", "Iperf3Runner", "ethtool_ret", "onoff", "wait_for_link", "wait_for_aneg", "controllable_lp", "require_controllable_lp", - "forced_link_settings"] + "require_link_autoneg", "forced_link_settings"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources") print(str(e))
tools/testing/selftests/drivers/net/lib/py/ethtool.py +14 -0
@@ -175,6 +175,20 @@ def require_controllable_lp(cfg) -> None: if not controllable_lp(cfg): raise KsftSkipEx(f"{cfg.remote_ifname} is not directly connected to {cfg.ifname}") +def require_link_autoneg(cfg) -> None: + """ Skip if local or remote don't support link autoneg + + :param cfg: test config + """ + # Does local device support link aneg + if not ethtool(f"{cfg.ifname}", json=True)[0]["supports-auto-negotiation"]: + raise KsftSkipEx(f"{cfg.ifname} doesn't support link autoneg") + + # Does remote device support link aneg + if not ethtool(f"{cfg.remote_ifname}", + json=True, host=cfg.remote)[0]["supports-auto-negotiation"]: + raise KsftSkipEx(f"Remote {cfg.remote_ifname} doesn't support link autoneg") + def forced_link_settings(cfg) -> str: """ Returns a string to pass to ethtool -s with speed/duplex corresponding to the current settings.
Signature · 1 line
2.55.0