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.
Signed-off-by: Mohan Prasad J mohan.prasad@microchip.com
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
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.
Signed-off-by: Mohan Prasad J mohan.prasad@microchip.com --- 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
diff --git a/MAINTAINERS b/MAINTAINERS index baf88e74c..461f94ae0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c
MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead bryan.whitehead@microchip.com +M: Mohan Prasad J mohan.prasad@microchip.com M: UNGLinuxDriver@microchip.com L: netdev@vger.kernel.org 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 arun.ramadoss@microchip.com diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a5f1c0c27..8059529c9 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -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 diff --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..542128678 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile @@ -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 diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py new file mode 100755 index 000000000..f1ad97dc2 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.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/__init__.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py new file mode 100644 index 000000000..e571631af --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__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)
On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
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__.py file. Include /microchip/lan743x as a target in Makefile. Updated MAINTAINERS list.
Signed-off-by: Mohan Prasad J mohan.prasad@microchip.com
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
diff --git a/MAINTAINERS b/MAINTAINERS index baf88e74c..461f94ae0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c
MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead bryan.whitehead@microchip.com +M: Mohan Prasad J mohan.prasad@microchip.com
It seems like updating the maintainers list should be a separate patch.
Thanks,
Brett
M: UNGLinuxDriver@microchip.com L: netdev@vger.kernel.org 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 arun.ramadoss@microchip.com diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a5f1c0c27..8059529c9 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -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 diff --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..542128678 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile @@ -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 diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py new file mode 100755 index 000000000..f1ad97dc2 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.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/__init__.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py new file mode 100644 index 000000000..e571631af --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__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
Hi Brett,
Thank you for the review comments.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
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__.py file. Include /microchip/lan743x as a target in Makefile. Updated MAINTAINERS list.
Signed-off-by: Mohan Prasad J mohan.prasad@microchip.com
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
diff --git a/MAINTAINERS b/MAINTAINERS index baf88e74c..461f94ae0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c
MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead bryan.whitehead@microchip.com +M: Mohan Prasad J mohan.prasad@microchip.com
It seems like updating the maintainers list should be a separate patch.
I will update it in the next version.
Thanks,
Brett
M: UNGLinuxDriver@microchip.com L: netdev@vger.kernel.org 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 arun.ramadoss@microchip.com diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a5f1c0c27..8059529c9 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -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 diff --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..542128678 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefil +++ 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.mk diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py new file mode 100755 index 000000000..f1ad97dc2 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x +++ .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__.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__in it__.py new file mode 100644 index 000000000..e571631af --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/ +++ __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
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 mohan.prasad@microchip.com --- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index f1ad97dc2..59f0be2a7 100755 --- a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -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,))
On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
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 mohan.prasad@microchip.com
.../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index f1ad97dc2..59f0be2a7 100755 --- a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -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}")
How does "output" get used here?
- 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
- 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
Hi Brett,
Thank you for the review comments.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
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 mohan.prasad@microchip.com
.../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index f1ad97dc2..59f0be2a7 100755
a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x +++ .py @@ -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}")
How does "output" get used here?
"output" is not used anywhere, I will remove this in the next version.
- 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.
Thanks,
Brett
- 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
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 mohan.prasad@microchip.com --- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index 59f0be2a7..a3dcf7896 100755 --- a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -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,))
On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
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 mohan.prasad@microchip.com
.../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index 59f0be2a7..a3dcf7896 100755 --- a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -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")
IMO it would be best to do these checks separately so the failure is immediately obvious.
Thanks,
Brett
- def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))
-- 2.43.0
Hi Brett,
Thank you for the review comments.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On 9/3/2024 3:15 PM, Mohan Prasad J wrote:
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 mohan.prasad@microchip.com
.../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index 59f0be2a7..a3dcf7896 100755
a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x +++ .py @@ -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,
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.
I will separate these checks in the next version.
Thanks,
Brett
- def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))
-- 2.43.0
On Wed, Sep 04, 2024 at 03:45:46AM +0530, Mohan Prasad J wrote:
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.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On Wed, Sep 04, 2024 at 03:45:46AM +0530, Mohan Prasad J wrote:
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.
As suggested, I will change the testcases to generic form and document them accordingly in the next version.
Andrew
On Fri, Sep 06, 2024 at 06:45:53AM +0000, Mohan.Prasad@microchip.com wrote:
Hello Andrew,
Thank you for your review comments.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On Wed, Sep 04, 2024 at 03:45:46AM +0530, Mohan Prasad J wrote:
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.
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.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On Fri, Sep 06, 2024 at 06:45:53AM +0000, Mohan.Prasad@microchip.com wrote:
Hello Andrew,
Thank you for your review comments.
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
On Wed, Sep 04, 2024 at 03:45:46AM +0530, Mohan Prasad J wrote:
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.
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.
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.
Andrew
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
linux-kselftest-mirror@lists.linaro.org