lan743x: This series of patches are for lan743x driver testing
Subsystems (3)
cover lan743x: This series of patches are for lan743x driver testing
This series of patches are for testing the lan743x network driver. Testing comprises autonegotiation, speed, duplex and throughput checks. Tools such as ethtool, iperf3 are used in the testing process. Performance test is done for TCP streams at different speeds.
Mohan Prasad J (3):
selftests: lan743x: Add testfile for lan743x network driver
selftests: lan743x: Add testcase to check speed and duplex state of
lan743x
selftests: lan743x: Add testcase to check throughput of lan743x
MAINTAINERS | 2 + tools/testing/selftests/Makefile | 2 +- .../drivers/net/hw/microchip/lan743x/Makefile | 7 ++ .../net/hw/microchip/lan743x/lan743x.py | 117 ++++++++++++++++++ .../hw/microchip/lan743x/lib/py/__init__.py | 16 +++ 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile create mode 100755 tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py create mode 100644 tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py
Signature · 1 line
2.43.0
PATCH 1/3 selftests: lan743x: Add testfile for lan743x network driver
Add testfile for lan743x network driver.
Testfile includes the verification of status of autonegotiation. Ksft modules and ethtool are used for the testing. net/lib libraries are included for testing.
Add the __init__.py file.
Include /microchip/lan743x as a target in Makefile. Updated MAINTAINERS list.
--- MAINTAINERS | 2 + tools/testing/selftests/Makefile | 2 +- .../drivers/net/hw/microchip/lan743x/Makefile | 7 +++ .../net/hw/microchip/lan743x/lan743x.py | 51 +++++++++++++++++++ .../hw/microchip/lan743x/lib/py/__init__.py | 16 ++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile create mode 100755 tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py create mode 100644 tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py
MAINTAINERS +2 -0
@@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead <[email protected]> +M: Mohan Prasad J <[email protected]> M: [email protected] L: [email protected] S: Maintained F: drivers/net/ethernet/microchip/lan743x_* +F: tools/testing/selftests/drivers/net/hw/microchip/lan743x/ MICROCHIP LAN87xx/LAN937x T1 PHY DRIVER M: Arun Ramadoss <[email protected]>
tools/testing/selftests/Makefile +1 -1
@@ -122,7 +122,7 @@ TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG += memory-hotplug # Networking tests want the net/lib target, include it automatically -ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),) +ifneq ($(filter net drivers/net drivers/net/hw drivers/net/hw/microchip/lan743x,$(TARGETS)),) ifeq ($(filter net/lib,$(TARGETS)),) INSTALL_DEP_TARGETS := net/lib endif
tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_INCLUDES := $(wildcard lib/py/*.py ../../../lib/py/*.py) + +TEST_PROGS := lan743x.py + +include ../../../../../lib.mk
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py new file +51 -0
51 lines not on this page · raw message
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 + +import sys +from pathlib import Path + +KSFT_DIR = (Path(__file__).parent / "../../../../../../..").resolve() + +try: + sys.path.append(KSFT_DIR.as_posix()) + from net.lib.py import * + from drivers.net.lib.py import * +except ModuleNotFoundError as e: + ksft_pr("Failed importing `net` library from kernel sources") + ksft_pr(str(e)) + ktap_result(True, comment="SKIP") + sys.exit(4)
Signature · 1 line
2.43.0
Re: [PATCH net-next 1/3] selftests: lan743x: Add testfile for lan743x network driver
Quoted 28 lines · Mohan Prasad J
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Add testfile for lan743x network driver.
Testfile includes the verification of status of autonegotiation. Ksft modules and ethtool are used for the testing. net/lib libraries are included for testing.
Add the__init__.pyfile.
Include /microchip/lan743x as a target inMakefile. UpdatedMAINTAINERSlist.Signed-off-by Mohan Prasad J <[email protected]>--- MAINTAINERS | 2 + tools/testing/selftests/Makefile | 2 +- .../drivers/net/hw/microchip/lan743x/Makefile | 7 +++ .../net/hw/microchip/lan743x/lan743x.py | 51 +++++++++++++++++++ .../hw/microchip/lan743x/lib/py/__init__.py | 16 ++++++ 5 files changed, 77 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefilecreate mode 100755tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pycreate mode 100644tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.pyMAINTAINERS +0
-0
MAINTAINERS F: net/dsa/tag_ksz.c · line 14963
Quoted 4 lines
MAINTAINERS +1
-0@@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead <[email protected]> +M: Mohan Prasad J <[email protected]>
It seems like updating the maintainers list should be a separate patch.
Thanks,
Brett
Quoted 116 lines
MAINTAINERS +1
-0M: [email protected] L: [email protected] S: Maintained F: drivers/net/ethernet/microchip/lan743x_* +F: tools/testing/selftests/drivers/net/hw/microchip/lan743x/ MICROCHIP LAN87xx/LAN937x T1 PHY DRIVER M: Arun Ramadoss <[email protected]>tools/testing/selftests/Makefile +1
-1@@ -122,7 +122,7 @@ TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG += memory-hotplug # Networking tests want the net/lib target, include it automatically -ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),) +ifneq ($(filter net drivers/net drivers/net/hw drivers/net/hw/microchip/lan743x,$(TARGETS)),) ifeq ($(filter net/lib,$(TARGETS)),) INSTALL_DEP_TARGETS := net/lib endiftools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile new file +7
-0@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_INCLUDES := $(wildcard lib/py/*.py ../../../lib/py/*.py) + +TEST_PROGS := lan743x.py + +include ../../../../../lib.mktools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py new file +51
-0@@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import time +import re +from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq +from lib.py import KsftFailEx, KsftSkipEx +from lib.py import NetDrvEpEnv +from lib.py import cmd +from lib.py import ethtool + +def verify_link_up(ifname: str) -> None: + """Verify whether the link is up initially""" + with open(f"/sys/class/net/{ifname}/operstate", "r") as fp: + link_state = fp.read().strip() + + if link_state == "down": + raise KsftSkipEx(f"Link state of interface {ifname} is DOWN") + +def set_autonegotiation_state(ifname: str, state: str) -> None: + """Set the autonegotiation state for the interface""" + process = ethtool(f"-s {ifname} speed 10 duplex half autoneg {state}") + if process.ret != 0: + raise KsftFailEx(f"Not able to set autoneg parameter for {ifname}") + ksft_pr(f"Autoneg set as {state} for {ifname}") + +def verify_autonegotiation(ifname: str, expected_state: str) -> None: + verify_link_up(ifname) + """Verifying the autonegotiation state""" + output = ethtool(f"{ifname}") + autoneg_match = re.search(r'Auto-negotiation:\s+(\w+)', output.stdout) + + if not autoneg_match: + raise KsftFailEx("Failed to find autonegotiation information in ethtool output.") + + actual_state = autoneg_match.group(1) + ksft_eq(actual_state, expected_state) + +def test_autonegotiation(cfg) -> None: + for state in ["off", "on"]: + set_autonegotiation_state(cfg.ifname, state) + time.sleep(5) + verify_autonegotiation(cfg.ifname, state) + +def main() -> None: + with NetDrvEpEnv(__file__) as cfg: + ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) + ksft_exit() + +if __name__ == "__main__": + main()tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py new file +16
-1@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 + +import sys +from pathlib import Path + +KSFT_DIR = (Path(__file__).parent / "../../../../../../..").resolve() + +try: + sys.path.append(KSFT_DIR.as_posix()) + from net.lib.py import * + from drivers.net.lib.py import * +except ModuleNotFoundError as e: + ksft_pr("Failed importing `net` library from kernel sources") + ksft_pr(str(e)) + ktap_result(True, comment="SKIP") + sys.exit(4) --2.43.0
RE: [PATCH net-next 1/3] selftests: lan743x: Add testfile for lan743x network driver
Hi Brett,
Thank you for the review comments.
Quoted 38 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 1 line · Mohan Prasad J
Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.
Quoted 11 lines
Add testfile for lan743x network driver.
Testfile includes the verification of status of autonegotiation. Ksft modules and ethtool are used for the testing. net/lib libraries are included for testing.
Add the__init__.pyfile.
Include /microchip/lan743x as a target inMakefile. UpdatedMAINTAINERSlist.Signed-off-by Mohan Prasad J <[email protected]>Quoted 8 lines
--- MAINTAINERS | 2 + tools/testing/selftests/Makefile | 2 +- .../drivers/net/hw/microchip/lan743x/Makefile | 7 +++ .../net/hw/microchip/lan743x/lan743x.py | 51 +++++++++++++++++++ .../hw/microchip/lan743x/lib/py/__init__.py | 16 ++++++ 5 files changed, 77 insertions(+), 1 deletion(-)create mode 100644
tools/testing/selftests/drivers/net/hw/microchip/lan743x/MakefileQuoted 1 line
create mode 100755
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pyQuoted 10 lines
create mode 100644
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.pyMAINTAINERS index baf88e74c..461f94ae0 renamed from MAINTAINERS +0
-0100644
MAINTAINERS +0
-0@@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c
Quoted 5 lines
MAINTAINERS F: net/dsa/tag_ksz.c · line 14963
Quoted 3 lines
MAINTAINERS +1
-0MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead <[email protected]> +M: Mohan Prasad J <[email protected]>It seems like updating the maintainers list should be a separate patch.
I will update it in the next version.
Quoted 134 lines
Thanks,
Brett
Quoted 129 lines
MAINTAINERS +1
-0M: [email protected] L: [email protected] S: Maintained F: drivers/net/ethernet/microchip/lan743x_* +F: tools/testing/selftests/drivers/net/hw/microchip/lan743x/ MICROCHIP LAN87xx/LAN937x T1 PHY DRIVER M: Arun Ramadoss <[email protected]>tools/testing/selftests/Makefile +2
-1@@ -122,7 +122,7 @@ TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG += memory-hotplug # Networking tests want the net/lib target, include it automatically -ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),) +ifneq ($(filter net drivers/net drivers/net/hw +drivers/net/hw/microchip/lan743x,$(TARGETS)),) ifeq ($(filter net/lib,$(TARGETS)),) INSTALL_DEP_TARGETS := net/lib endifdiff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile new file mode 100644
index 000000000..542128678tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefil new file +8
-0+++ e@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_INCLUDES := $(wildcard lib/py/*.py ../../../lib/py/*.py) + +TEST_PROGS := lan743x.py + +include ../../../../../lib.mkdiff --git
a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pyb/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pynew file mode 100755
index 000000000..f1ad97dc2tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x new file +52
-0+++ .py@@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import time +import re +from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq from lib.py +import KsftFailEx, KsftSkipEx from lib.py import NetDrvEpEnv from +lib.py import cmd from lib.py import ethtool + +def verify_link_up(ifname: str) -> None: + """Verify whether the link is up initially""" + with open(f"/sys/class/net/{ifname}/operstate", "r") as fp: + link_state = fp.read().strip() + + if link_state == "down": + raise KsftSkipEx(f"Link state of interface {ifname} is DOWN") + +def set_autonegotiation_state(ifname: str, state: str) -> None: + """Set the autonegotiation state for the interface""" + process = ethtool(f"-s {ifname} speed 10 duplex half autoneg {state}") + if process.ret != 0: + raise KsftFailEx(f"Not able to set autoneg parameter for {ifname}") + ksft_pr(f"Autoneg set as {state} for {ifname}") + +def verify_autonegotiation(ifname: str, expected_state: str) -> None: + verify_link_up(ifname) + """Verifying the autonegotiation state""" + output = ethtool(f"{ifname}") + autoneg_match = re.search(r'Auto-negotiation:\s+(\w+)', +output.stdout) + + if not autoneg_match: + raise KsftFailEx("Failed to find autonegotiation information + in ethtool output.") + + actual_state = autoneg_match.group(1) + ksft_eq(actual_state, expected_state) + +def test_autonegotiation(cfg) -> None: + for state in ["off", "on"]: + set_autonegotiation_state(cfg.ifname, state) + time.sleep(5) + verify_autonegotiation(cfg.ifname, state) + +def main() -> None: + with NetDrvEpEnv(__file__) as cfg: + ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) + ksft_exit() + +if __name__ == "__main__": + main()diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__in
it__.pyb/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py
new file mode 100644
index 000000000..e571631aftools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/ new file +17
-1+++ __init__.py@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 + +import sys +from pathlib import Path + +KSFT_DIR = (Path(__file__).parent / "../../../../../../..").resolve() + +try: + sys.path.append(KSFT_DIR.as_posix()) + from net.lib.py import * + from drivers.net.lib.py import * +except ModuleNotFoundError as e: + ksft_pr("Failed importing `net` library from kernel sources") + ksft_pr(str(e)) + ktap_result(True, comment="SKIP") + sys.exit(4) --2.43.0
PATCH 2/3 selftests: lan743x: Add testcase to check speed and duplex state of lan743x
In reply to Mohan Prasad JAdd testcase for checking speed and duplex states for lan743x network driver.
Testcase comprises of varying the network speed and duplex state to 10/100/1000Mbps and half/full via ethtool.
--- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +33 -0
@@ -36,12 +36,45 @@ def verify_autonegotiation(ifname: str, expected_state: str) -> None: actual_state = autoneg_match.group(1) ksft_eq(actual_state, expected_state) +def set_speed_and_duplex(ifname: str, speed: str, duplex: str) -> None: + """Set the speed and duplex state for the interface""" + process = ethtool(f"--change {ifname} speed {speed} duplex {duplex} autoneg on") + + if process.ret != 0: + raise KsftFailEx(f"Not able to set speeed and duplex parameters for {ifname}") + ksft_pr(f"Speed: {speed} Mbps, Duplex: {duplex} set for Interface: {ifname}") + +def verify_speed_and_duplex(ifname: str, expected_speed: str, expected_duplex: str) -> None: + verify_link_up(ifname) + """Verifying the speed and duplex state for the interface""" + output = ethtool(f"{ifname}") + with open(f"/sys/class/net/{ifname}/speed", "r") as fp: + actual_speed = fp.read().strip() + with open(f"/sys/class/net/{ifname}/duplex", "r") as fp: + actual_duplex = fp.read().strip() + + ksft_eq(actual_speed, expected_speed) + ksft_eq(actual_duplex, expected_duplex) + def test_autonegotiation(cfg) -> None: for state in ["off", "on"]: set_autonegotiation_state(cfg.ifname, state) time.sleep(5) verify_autonegotiation(cfg.ifname, state) +def test_network_speed(cfg) -> None: + speeds = ["10", "100", "1000"] + duplex_modes = ["half", "full"] + + for speed in speeds: + for duplex in duplex_modes: + # Skip for speed = 1000Mbps, duplex = Half + if speed == "1000" and duplex == "half": + continue + set_speed_and_duplex(cfg.ifname, speed, duplex) + time.sleep(5) + verify_speed_and_duplex(cfg.ifname, speed, duplex) + def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))
Signature · 1 line
2.43.0
Re: [PATCH net-next 2/3] selftests: lan743x: Add testcase to check speed and duplex state of lan743x
Quoted 23 lines · Mohan Prasad J
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Add testcase for checking speed and duplex states for lan743x network driver.
Testcase comprises of varying the network speed and duplex state to 10/100/1000Mbps and half/full via ethtool.Signed-off-by Mohan Prasad J <[email protected]>--- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +2
-0@@ -36,12 +36,45 @@ def verify_autonegotiation(ifname: str, expected_state: str) -> None: actual_state = autoneg_match.group(1) ksft_eq(actual_state, expected_state) +def set_speed_and_duplex(ifname: str, speed: str, duplex: str) -> None: + """Set the speed and duplex state for the interface"""
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def verify_autonegotiation(ifname: str, expected_state: str) -> None: · line 50
Quoted 10 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +10
-0+ process = ethtool(f"--change {ifname} speed {speed} duplex {duplex} autoneg on") + + if process.ret != 0: + raise KsftFailEx(f"Not able to set speeed and duplex parameters for {ifname}") + ksft_pr(f"Speed: {speed} Mbps, Duplex: {duplex} set for Interface: {ifname}") + +def verify_speed_and_duplex(ifname: str, expected_speed: str, expected_duplex: str) -> None: + verify_link_up(ifname) + """Verifying the speed and duplex state for the interface""" + output = ethtool(f"{ifname}")
How does "output" get used here?
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def verify_autonegotiation(ifname: str, expected_state: str) -> None: · line 54
Quoted 4 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +4
-0+ with open(f"/sys/class/net/{ifname}/speed", "r") as fp: + actual_speed = fp.read().strip() + with open(f"/sys/class/net/{ifname}/duplex", "r") as fp: + actual_duplex = fp.read().strip()
Should you check speed/duplex from both sysfs and ethtool? Maybe that's overkill.
Thanks,
Brett
Quoted 28 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +17
-1+ + ksft_eq(actual_speed, expected_speed) + ksft_eq(actual_duplex, expected_duplex) + def test_autonegotiation(cfg) -> None: for state in ["off", "on"]: set_autonegotiation_state(cfg.ifname, state) time.sleep(5) verify_autonegotiation(cfg.ifname, state) +def test_network_speed(cfg) -> None: + speeds = ["10", "100", "1000"] + duplex_modes = ["half", "full"] + + for speed in speeds: + for duplex in duplex_modes: + # Skip for speed = 1000Mbps, duplex = Half + if speed == "1000" and duplex == "half": + continue + set_speed_and_duplex(cfg.ifname, speed, duplex) + time.sleep(5) + verify_speed_and_duplex(cfg.ifname, speed, duplex) + > def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) --2.43.0
RE: [PATCH net-next 2/3] selftests: lan743x: Add testcase to check speed and duplex state of lan743x
Hi Brett,
Thank you for the review comments.
Quoted 44 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 1 line · Mohan Prasad J
Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.
Review def verify_autonegotiation(ifname: str,
Quoted 21 lines
Add testcase for checking speed and duplex states for lan743x network driver.
Testcase comprises of varying the network speed and duplex state to 10/100/1000Mbps and half/full via ethtool.Signed-off-by Mohan Prasad J <[email protected]>--- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)diff --git
a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pyb/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pyindexf1ad97dc2..59f0be2a7100755
---a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py+++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x +++ .py(quoted diff) +0
-0@@ -36,12 +36,45 @@ def verify_autonegotiation(ifname: str,
expected_state: str) -> None:tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def verify_autonegotiation(ifname: str, expected_state: str) -> None:
Quoted 10 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +7
-0actual_state = autoneg_match.group(1) ksft_eq(actual_state, expected_state) +def set_speed_and_duplex(ifname: str, speed: str, duplex: str) -> None: + """Set the speed and duplex state for the interface""" + process = ethtool(f"--change {ifname} speed {speed} duplex +{duplex} autoneg on") + + if process.ret != 0: + raise KsftFailEx(f"Not able to set speeed and duplex parameters for{ifname}")
Review def verify_autonegotiation(ifname: str, · line 49
Quoted 4 lines
(quoted diff) +4
-0+ ksft_pr(f"Speed: {speed} Mbps, Duplex: {duplex} set for + Interface: {ifname}") + +def verify_speed_and_duplex(ifname: str, expected_speed: str,
expected_duplex: str) -> None:
Quoted 5 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def verify_autonegotiation(ifname: str, expected_state: str) -> None: · line 50
Quoted 3 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +3
-0+ verify_link_up(ifname) + """Verifying the speed and duplex state for the interface""" + output = ethtool(f"{ifname}")How does "output" get used here?
"output" is not used anywhere, I will remove this in the next version.
Quoted 8 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def verify_autonegotiation(ifname: str, expected_state: str) -> None: · line 54
Quoted 5 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +4
-0+ with open(f"/sys/class/net/{ifname}/speed", "r") as fp: + actual_speed = fp.read().strip() + with open(f"/sys/class/net/{ifname}/duplex", "r") as fp: + actual_duplex = fp.read().strip()Should you check speed/duplex from both sysfs and ethtool? Maybe that's overkill.
I will remove the ethtool dependency here in the next version.
Quoted 33 lines
Thanks,
Brett
Quoted 28 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +17
-1+ + ksft_eq(actual_speed, expected_speed) + ksft_eq(actual_duplex, expected_duplex) + def test_autonegotiation(cfg) -> None: for state in ["off", "on"]: set_autonegotiation_state(cfg.ifname, state) time.sleep(5) verify_autonegotiation(cfg.ifname, state) +def test_network_speed(cfg) -> None: + speeds = ["10", "100", "1000"] + duplex_modes = ["half", "full"] + + for speed in speeds: + for duplex in duplex_modes: + # Skip for speed = 1000Mbps, duplex = Half + if speed == "1000" and duplex == "half": + continue + set_speed_and_duplex(cfg.ifname, speed, duplex) + time.sleep(5) + verify_speed_and_duplex(cfg.ifname, speed, duplex) + > def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) --2.43.0
PATCH 3/3 selftests: lan743x: Add testcase to check throughput of lan743x
In reply to Mohan Prasad JAdd testcase to check TCP throughput of lan743x network driver. Test uses iperf3 to do performance testing of the driver. TCP data at different speeds is sent, received and verified.
--- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +33 -0
@@ -3,6 +3,7 @@ import time import re +import json from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq from lib.py import KsftFailEx, KsftSkipEx from lib.py import NetDrvEpEnv
@@ -75,6 +76,38 @@ def test_network_speed(cfg) -> None: time.sleep(5) verify_speed_and_duplex(cfg.ifname, speed, duplex) +def test_tcp_throughput(cfg) -> None: + speeds = ["10", "100", "1000"] + """Test duration in seconds""" + test_duration = 5 + target_ip = cfg.remote_addr + + for speed in speeds: + set_speed_and_duplex(cfg.ifname, speed, 'full') + time.sleep(5) + verify_link_up(cfg.ifname) + send_command=f"iperf3 -c {target_ip} -t {test_duration} --json" + receive_command=f"iperf3 -c {target_ip} -t {test_duration} --reverse --json" + send_result = cmd(send_command) + receive_result = cmd(receive_command) + if send_result.ret != 0 or receive_result.ret != 0: + raise KsftSkipEx("No server is running") + + send_output = send_result.stdout + receive_output = receive_result.stdout + + send_data = json.loads(send_output) + receive_data = json.loads(receive_output) + """Convert throughput to Mbps""" + send_throughput = round(send_data['end']['sum_sent']['bits_per_second'] / 1e6, 2) + receive_throughput = round(receive_data['end']['sum_received']['bits_per_second'] / 1e6, 2) + + ksft_pr(f"Send throughput: {send_throughput} Mbps, Receive throughput: {receive_throughput} Mbps") + """Check whether throughput is not below 0.9 times the set speed""" + threshold = float(speed) * 0.9 + if send_throughput < threshold or receive_throughput < threshold: + raise KsftFailEx("Throughput is below threshold") + def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))
Signature · 1 line
2.43.0
Re: [PATCH net-next 3/3] selftests: lan743x: Add testcase to check throughput of lan743x
Quoted 49 lines · Mohan Prasad J
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Add testcase to check TCP throughput of lan743x network driver. Test uses iperf3 to do performance testing of the driver. TCP data at different speeds is sent, received and verified.
Signed-off-by Mohan Prasad J <[email protected]>--- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +22
-0@@ -3,6 +3,7 @@ import time import re +import json from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq from lib.py import KsftFailEx, KsftSkipEx from lib.py import NetDrvEpEnv@@ -75,6 +76,38 @@ def test_network_speed(cfg) -> None: time.sleep(5) verify_speed_and_duplex(cfg.ifname, speed, duplex) +def test_tcp_throughput(cfg) -> None: + speeds = ["10", "100", "1000"] + """Test duration in seconds""" + test_duration = 5 + target_ip = cfg.remote_addr + + for speed in speeds: + set_speed_and_duplex(cfg.ifname, speed, 'full') + time.sleep(5) + verify_link_up(cfg.ifname) + send_command=f"iperf3 -c {target_ip} -t {test_duration} --json" + receive_command=f"iperf3 -c {target_ip} -t {test_duration} --reverse --json" + send_result = cmd(send_command) + receive_result = cmd(receive_command) + if send_result.ret != 0 or receive_result.ret != 0: + raise KsftSkipEx("No server is running") + + send_output = send_result.stdout + receive_output = receive_result.stdout + + send_data = json.loads(send_output)
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def test_network_speed(cfg) -> None: · line 109
Quoted 10 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +10
-0+ receive_data = json.loads(receive_output) + """Convert throughput to Mbps""" + send_throughput = round(send_data['end']['sum_sent']['bits_per_second'] / 1e6, 2) + receive_throughput = round(receive_data['end']['sum_received']['bits_per_second'] / 1e6, 2) + + ksft_pr(f"Send throughput: {send_throughput} Mbps, Receive throughput: {receive_throughput} Mbps") + """Check whether throughput is not below 0.9 times the set speed""" + threshold = float(speed) * 0.9 + if send_throughput < threshold or receive_throughput < threshold: + raise KsftFailEx("Throughput is below threshold")
IMO it would be best to do these checks separately so the failure is immediately obvious.
Thanks,
Brett
Quoted 7 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +1
-1+ def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) --2.43.0
RE: [PATCH net-next 3/3] selftests: lan743x: Add testcase to check throughput of lan743x
Hi Brett,
Thank you for the review comments.
Quoted 68 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 1 line · Mohan Prasad J
Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.
Quoted 33 lines
Add testcase to check TCP throughput of lan743x network driver. Test uses iperf3 to do performance testing of the driver. TCP data at different speeds is sent, received and verified.
Signed-off-by Mohan Prasad J <[email protected]>--- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)diff --git
a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pyb/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.pyindex59f0be2a7..a3dcf7896100755
---a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py+++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x +++ .pytools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +3
-0@@ -3,6 +3,7 @@ import time import re +import json from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq from lib.py import KsftFailEx, KsftSkipEx from lib.py import NetDrvEpEnv@@ -75,6 +76,38 @@ def test_network_speed(cfg) -> None: time.sleep(5) verify_speed_and_duplex(cfg.ifname, speed, duplex) +def test_tcp_throughput(cfg) -> None: + speeds = ["10", "100", "1000"]tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def test_network_speed(cfg) -> None: · line 90
Quoted 10 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +10
-0+ """Test duration in seconds""" + test_duration = 5 + target_ip = cfg.remote_addr + + for speed in speeds: + set_speed_and_duplex(cfg.ifname, speed, 'full') + time.sleep(5) + verify_link_up(cfg.ifname) + send_command=f"iperf3 -c {target_ip} -t {test_duration} --json" + receive_command=f"iperf3 -c {target_ip} -t {test_duration} --reverse --json"
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def test_network_speed(cfg) -> None:
Quoted 12 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +12
-0+ send_result = cmd(send_command) + receive_result = cmd(receive_command) + if send_result.ret != 0 or receive_result.ret != 0: + raise KsftSkipEx("No server is running") + + send_output = send_result.stdout + receive_output = receive_result.stdout + + send_data = json.loads(send_output) + receive_data = json.loads(receive_output) + """Convert throughput to Mbps""" + send_throughput =
round(send_data['end']['sum_sent']['bits_per_second'] / 1e6, 2)Review def test_network_speed(cfg) -> None: · line 107
Quoted 5 lines
(quoted diff) +5
-0+ receive_throughput = + round(receive_data['end']['sum_received']['bits_per_second'] / 1e6, + 2) + + ksft_pr(f"Send throughput: {send_throughput} Mbps, Receive
Quoted 8 lines
throughput: {
receive_throughput} Mbps")tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py def test_network_speed(cfg) -> None: · line 109
Quoted 4 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +4
-0+ """Check whether throughput is not below 0.9 times the set speed""" + threshold = float(speed) * 0.9 + if send_throughput < threshold or receive_throughput < threshold: + raise KsftFailEx("Throughput is below threshold")IMO it would be best to do these checks separately so the failure is immediately obvious.
I will separate these checks in the next version.
Quoted 11 lines
Thanks,
Brett
Quoted 7 lines
tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +1
-1+ def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) --2.43.0
Quoted 4 lines · Mohan Prasad J
This series of patches are for testing the lan743x network driver. Testing comprises autonegotiation, speed, duplex and throughput checks. Tools such as ethtool, iperf3 are used in the testing process. Performance test is done for TCP streams at different speeds.
What is specific to lan743x? Why won't the autoneg test work for any interface which says it supports autoneg? Is duplex somehow special on the lan743x?
Where possible, please try to make these tests generic, usable on any NIC. Or clearly document why they cannot be generic.
Andrew
Hello Andrew,
Thank you for your review comments.
Quoted 9 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 4 lines · Mohan Prasad J
This series of patches are for testing the lan743x network driver. Testing comprises autonegotiation, speed, duplex and throughput checks. Tools such as ethtool, iperf3 are used in the testing process. Performance test is done for TCP streams at different speeds.
Quoted 7 lines
What is specific to lan743x? Why won't the autoneg test work for any interface which says it supports autoneg? Is duplex somehow special on the lan743x?
Where possible, please try to make these tests generic, usable on any NIC. Or clearly document why they cannot be generic.
As suggested, I will change the testcases to generic form and document them accordingly in the next version.
Quoted 1 line
Andrew
Quoted 17 lines · On Fri, Sep 06, 2024 at 06:45:53AM +0000, [email protected] wrote:
Hello Andrew,
Thank you for your review comments.
Quoted 13 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 4 lines · Mohan Prasad J
This series of patches are for testing the lan743x network driver. Testing comprises autonegotiation, speed, duplex and throughput checks. Tools such as ethtool, iperf3 are used in the testing process. Performance test is done for TCP streams at different speeds.
What is specific to lan743x? Why won't the autoneg test work for any interface which says it supports autoneg? Is duplex somehow special on the lan743x?
Quoted 5 lines
Quoted 3 lines
Where possible, please try to make these tests generic, usable on any NIC. Or clearly document why they cannot be generic.
As suggested, I will change the testcases to generic form and document them accordingly in the next version.
Great.
How much time do you have?
ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full
Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Full
You can see that both the local device and the peer support auto-neg. You can see what link modes both the local and peer supports. The local device has 1000BaseT/Half where the peer does not, which is reasonably common. So you could use this as a basis for the test, ensurer 5 link modes do pass auto-neg, and one fails.
If you can, please try to avoid hard coding any link modes. There will be some data centre NICs with a lowest speed to 10GBaseX, for example. There are some automotive devices with 10BaseT-1L which does not support autp-neg etc. It would be nice if the test could be used on any interface and the test will decide itself what can be tested, or if it should skip everything?
And by the way, thanks for working on tests. We need more people like you contributing to them.
Andrew
Hello Andrew,
Thank you very much for the feedback and the brief explanation.
Quoted 59 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 10 lines · On Fri, Sep 06, 2024 at 06:45:53AM +0000, [email protected] wrote:
Hello Andrew,
Thank you for your review comments.
Quoted 6 lines
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 2 lines · Mohan Prasad J
This series of patches are for testing the lan743x network driver. Testing comprises autonegotiation, speed, duplex and throughput
checks.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Tools such as ethtool, iperf3 are used in the testing process. Performance test is done for TCP streams at different speeds.
What is specific to lan743x? Why won't the autoneg test work for any interface which says it supports autoneg? Is duplex somehow special on the lan743x?
Quoted 5 lines
Quoted 3 lines
Where possible, please try to make these tests generic, usable on any NIC. Or clearly document why they cannot be generic.
As suggested, I will change the testcases to generic form and document
them accordingly in the next version.
Great.
How much time do you have?
ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full
Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full 1000baseT/FullYou can see that both the local device and the peer support auto-neg. You can see what link modes both the local and peer supports. The local device has 1000BaseT/Half where the peer does not, which is reasonably common. So you could use this as a basis for the test, ensurer 5 link modes do pass auto-neg, and one fails.
Quoted 9 lines
If you can, please try to avoid hard coding any link modes. There will be some data centre NICs with a lowest speed to 10GBaseX, for example. There are some automotive devices with 10BaseT-1L which does not support autp-neg etc. It would be nice if the test could be used on any interface and the test will decide itself what can be tested, or if it should skip everything?
And by the way, thanks for working on tests. We need more people like you contributing to them.
I am currently working on this and would rework as soon as possible.
The feedback that you provided is highly helpful and I will remodel the implementation with these points in mind. Hopefully you can see that in the next version.
Quoted 1 line
Andrew
Quoted 3 lines
I am currently working on this and would rework as soon as possible.
The feedback that you provided is highly helpful and I will remodel the implementation with these points in mind. Hopefully you can see that in the next version.
Great.
Don't worry too much about link speeds you cannot test yourself. If your tests happen to fail on a 10G card, i would expect the Maintainer of the 10G card to debug if its the driver for the card or the test which is broken, and then help fix the test if its the test.
Andrew