selftests: Add selftest for link layer and performance testing
Subsystems (3)
v4 cover selftests: Add selftest for link layer and performance testing
The series of patches are for doing basic tests of NIC driver. Test comprises checks for auto-negotiation, speed, duplex state and throughput between local NIC and partner. Tools such as ethtool, iperf3 are used.
---
Changes in v4:
- Type hints are added for arguments and return types.
- Test values can be modified through command line.
- Minor code improvements.
- GenerateTraffic class extended for throughput test.
- Protocol testcases separated.
Changes in v3:
Link to v3: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
- LinkConfig class is included in the hw library. This contains
generic APIs for doing link layer operations.
- Auto-negotiation checks involve changing the auto-neg state
both in local and partner NIC.
- Link layer test and performance test are separated to
different selftest files.
- Resetting of NIC driver done after test completion.
Changes in v2:
Link to v2: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
- Changed the hardcoded implementation of speed, duplex states,
throughput to generic values, in order to support all type
of NIC drivers.
- Test executes based on the supported link modes between local
NIC driver and partner.
- Instead of lan743x directory, selftest file is now relocated
to /selftests/drivers/net/hw.
Link to v1: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
---
Mohan Prasad J (3):
selftests: nic_link_layer: Add link layer selftest for NIC driver
selftests: nic_link_layer: Add selftest case for speed and duplex
states
selftests: nic_performance: Add selftest for performance of NIC driver
.../testing/selftests/drivers/net/hw/Makefile | 6 +- .../drivers/net/hw/lib/py/__init__.py | 1 + .../drivers/net/hw/lib/py/linkconfig.py | 222 ++++++++++++++++++ .../drivers/net/hw/nic_link_layer.py | 113 +++++++++ .../drivers/net/hw/nic_performance.py | 137 +++++++++++ .../selftests/drivers/net/lib/py/load.py | 20 +- 6 files changed, 496 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/hw/lib/py/linkconfig.py create mode 100644 tools/testing/selftests/drivers/net/hw/nic_link_layer.py create mode 100644 tools/testing/selftests/drivers/net/hw/nic_performance.py
Signature · 1 line
2.43.0
PATCH v4 1/3 selftests: nic_link_layer: Add link layer selftest for NIC driver
Add selftest file for the link layer tests of a NIC driver. Test for auto-negotiation is added.
Add LinkConfig class for changing link layer configs. Selftest makes use of ksft modules and ethtool. Include selftest file in the Makefile.
--- .../testing/selftests/drivers/net/hw/Makefile | 5 +- .../drivers/net/hw/lib/py/__init__.py | 1 + .../drivers/net/hw/lib/py/linkconfig.py | 222 ++++++++++++++++++ .../drivers/net/hw/nic_link_layer.py | 91 +++++++ 4 files changed, 317 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/hw/lib/py/linkconfig.py create mode 100644 tools/testing/selftests/drivers/net/hw/nic_link_layer.py
tools/testing/selftests/drivers/net/hw/Makefile +1 -0
@@ -11,6 +11,7 @@ TEST_PROGS = \ hw_stats_l3.sh \ hw_stats_l3_gre.sh \ loopback.sh \ + nic_link_layer.py \ pp_alloc_fail.py \ rss_ctx.py \ #
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +1 -0
@@ -9,6 +9,7 @@ try: sys.path.append(KSFT_DIR.as_posix()) from net.lib.py import * from drivers.net.lib.py import * + from .linkconfig import LinkConfig except ModuleNotFoundError as e: ksft_pr("Failed importing `net` library from kernel sources") ksft_pr(str(e))
tools/testing/selftests/drivers/net/hw/lib/py/linkconfig.py new file +222 -0
222 lines not on this page · raw message
tools/testing/selftests/drivers/net/hw/nic_link_layer.py new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v4 2/3 selftests: nic_link_layer: Add selftest case for speed and duplex states
In reply to Mohan Prasad JAdd selftest case for testing the speed and duplex state of local NIC driver and the partner based on the supported link modes obtained from the ethtool. Speed and duplex states are varied and verified using ethtool.
--- .../drivers/net/hw/nic_link_layer.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+)
tools/testing/selftests/drivers/net/hw/nic_link_layer.py +22 -0
@@ -76,6 +76,28 @@ def test_autonegotiation(cfg: object, link_config: LinkConfig, time_delay: int) time.sleep(time_delay) verify_autonegotiation(cfg, state, link_config) +def test_network_speed(cfg: object, link_config: LinkConfig, time_delay: int) -> None: + _pre_test_checks(cfg, link_config) + common_link_modes = link_config.common_link_modes + if not common_link_modes: + KsftSkipEx("No common link modes exist") + speeds, duplex_modes = link_config.get_speed_duplex_values(common_link_modes) + + if speeds and duplex_modes and len(speeds) == len(duplex_modes): + for idx in range(len(speeds)): + speed = speeds[idx] + duplex = duplex_modes[idx] + if not link_config.set_speed_and_duplex(speed, duplex): + raise KsftFailEx(f"Unable to set speed and duplex parameters for {cfg.ifname}") + time.sleep(time_delay) + if not link_config.verify_speed_and_duplex(speed, duplex): + raise KsftSkipEx(f"Error occurred while verifying speed and duplex states for interface {cfg.ifname}") + else: + if not speeds or not duplex_modes: + KsftSkipEx(f"No supported speeds or duplex modes found for interface {cfg.ifname}") + else: + KsftSkipEx("Mismatch in the number of speeds and duplex modes") + def main() -> None: parser = argparse.ArgumentParser(description="Run basic link layer tests for NIC driver") parser.add_argument('--time-delay', type=int, default=8, help='Time taken to wait for transitions to happen(in seconds). Default is 8 seconds.')
Signature · 1 line
2.43.0
PATCH v4 3/3 selftests: nic_performance: Add selftest for performance of NIC driver
In reply to Mohan Prasad JAdd selftest case to check the send and receive throughput. Supported link modes between local NIC driver and partner are varied. Then send and receive throughput is captured and verified. Test uses iperf3 tool.
Add iperf3 server/client function in GenerateTraffic class.
--- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../drivers/net/hw/nic_performance.py | 137 ++++++++++++++++++ .../selftests/drivers/net/lib/py/load.py | 20 ++- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/drivers/net/hw/nic_performance.py
tools/testing/selftests/drivers/net/hw/Makefile +1 -0
@@ -12,6 +12,7 @@ TEST_PROGS = \ hw_stats_l3_gre.sh \ loopback.sh \ nic_link_layer.py \ + nic_performance.py \ pp_alloc_fail.py \ rss_ctx.py \ #
tools/testing/selftests/drivers/net/hw/nic_performance.py new file +137 -0
137 lines not on this page · raw message
tools/testing/selftests/drivers/net/lib/py/load.py +19 -1
@@ -2,7 +2,7 @@ import time -from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen +from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen, bkg class GenerateTraffic: def __init__(self, env, port=None):
@@ -23,6 +23,24 @@ class GenerateTraffic: self.stop(verbose=True) raise Exception("iperf3 traffic did not ramp up") + def run_remote_test(self, env: object, port=None, command=None): + if port is None: + port = rand_port() + try: + server_cmd = f"iperf3 -s 1 -p {port} --one-off" + with bkg(server_cmd, host=env.remote): + #iperf3 opens TCP connection as default in server + #-u to be specified in client command for UDP + wait_port_listen(port, host=env.remote) + except Exception as e: + raise Exception(f"Unexpected error occurred while running server command: {e}") + try: + client_cmd = f"iperf3 -c {env.remote_addr} -p {port} {command}" + proc = cmd(client_cmd) + return proc + except Exception as e: + raise Exception(f"Unexpected error occurred while running client command: {e}") + def _wait_pkts(self, pkt_cnt=None, pps=None): """ Wait until we've seen pkt_cnt or until traffic ramps up to pps.
Signature · 1 line
2.43.0
Paolo Abeni
maintainerRe: [PATCH net-next v4 3/3] selftests: nic_performance: Add selftest for performance of NIC driver
Quoted 14 lines · Mohan Prasad J
tools/testing/selftests/drivers/net/hw/nic_performance.py new file +14
-0+#Setup: +#Connect the DUT PC with NIC card to partner pc back via ethernet medium of your choice(RJ45, T1) +# +# DUT PC Partner PC +#┌───────────────────────┐ ┌──────────────────────────┐ +#│ │ │ │ +#│ │ │ │ +#│ ┌───────────┐ │ │ +#│ │DUT NIC │ Eth │ │ +#│ │Interface ─┼─────────────────────────┼─ any eth Interface │ +#│ └───────────┘ │ │ +#│ │ │ │ +#│ │ │ │ +#└───────────────────────┘ └──────────────────────────┘
tools/testing/selftests/drivers/net/hw/nic_performance.py line 31
Quoted 10 lines
tools/testing/selftests/drivers/net/hw/nic_performance.py new file +10
-0+# +#Configurations: +#To prevent interruptions, Add ethtool, ip to the sudoers list in remote PC and get the ssh key from remote. +#Required minimum ethtool version is 6.10 +#Change the below configuration based on your hw needs. +# """Default values""" +#time_delay = 8 #time taken to wait for transitions to happen, in seconds. +#test_duration = 10 #performance test duration for the throughput check, in seconds. +#send_throughput_threshold = 80 #percentage of send throughput required to pass the check +#receive_throughput_threshold = 50 #percentage of receive throughput required to pass the check
Very likely we will have to tune the thresholds and possibly make them dependent on the H/W and S/W setup (Kconf), but overall I think it makes sense as a first step.
Thanks,
Paolo
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Fri, 15 Nov 2024 00:55:17 +0530 you wrote:
The series of patches are for doing basic tests of NIC driver. Test comprises checks for auto-negotiation, speed, duplex state and throughput between local NIC and partner. Tools such as ethtool, iperf3 are used.
Signed-off-by Mohan Prasad J <[email protected]>[...]
Here is the summary with links:
- [net-next,v4,1/3] selftests: nic_link_layer: Add link layer selftest for NIC driver
https://git.kernel.org/netdev/net-next/c/6116075e18f7 - [net-next,v4,2/3] selftests: nic_link_layer: Add selftest case for speed and duplex states https://git.kernel.org/netdev/net-next/c/c087dc54394b - [net-next,v4,3/3] selftests: nic_performance: Add selftest for performance of NIC driver https://git.kernel.org/netdev/net-next/c/fbbf93556f0c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html