From: Bobby Eshleman <[email protected]> Add nk_devmem.py with four tests for TCP devmem through a netkit device:
These tests are just duplicates of the original devmem tests, with some adjusted parameters such as telling ncdevmem to avoid device setup (since it only has access to netkit, not a phys device). Each test uses NetDrvContEnv with primary_rx_redirect=True to set up the BPF redirect program on the primary netkit interface. The NIC (HDS, RSS, queue lease) is configured once in main() before ksft_run() and torn down in a finally block via cleanup_nic(), mirroring the nk_qlease.py pattern. This avoids re-toggling NIC settings around every test case. Signed-off-by: Bobby Eshleman <[email protected]> --- Changes in v4: - Call configure_nic()/cleanup_nic() once around ksft_run() rather than relying on per-test configuration inside the run_* helpers. Changes in v3: - Reorder os.path expressions - Drop @ksft_disruptive from check_nk_rx_hds to mirror the original check_rx_hds in devmem.py Changes in v2: - Add nk_devmem.py to TEST_PROGS in Makefile (Sashiko) --- tools/testing/selftests/drivers/net/hw/Makefile | 1 + .../testing/selftests/drivers/net/hw/nk_devmem.py | 55 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile index 85ca4d1ecf9e..2f78c6aec397 100644 --- a/tools/testing/selftests/drivers/net/hw/Makefile +++ b/tools/testing/selftests/drivers/net/hw/Makefile @@ -34,6 +34,7 @@ TEST_PROGS = \ irq.py \ loopback.sh \ nic_timestamp.py \ + nk_devmem.py \ nk_netns.py \ nk_qlease.py \ ntuple.py \ diff --git a/tools/testing/selftests/drivers/net/hw/nk_devmem.py b/tools/testing/selftests/drivers/net/hw/nk_devmem.py new file mode 100755 index 000000000000..0e36a0fa9688 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/nk_devmem.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +"""Test devmem TCP with netkit.""" + +import os +from lib.py import ksft_run, ksft_exit, ksft_disruptive +from lib.py import NetDrvContEnv +from lib.py.devmem import (setup_test, require_devmem, configure_nic, + cleanup_nic, run_rx, run_tx, run_tx_chunks, + run_rx_hds) + + +@ksft_disruptive +def check_nk_rx(cfg) -> None: + """Run the devmem RX test through netkit.""" + run_rx(cfg) + + +@ksft_disruptive +def check_nk_tx(cfg) -> None: + """Run the devmem TX test through netkit.""" + run_tx(cfg) + + +@ksft_disruptive +def check_nk_tx_chunks(cfg) -> None: + """Run the devmem TX chunking test through netkit.""" + run_tx_chunks(cfg) + + +def check_nk_rx_hds(cfg) -> None: + """Run the HDS test through netkit.""" + run_rx_hds(cfg) + + +def main() -> None: + """Configure the NIC once, then run the netkit devmem test cases.""" + with NetDrvContEnv(__file__, rxqueues=2, primary_rx_redirect=True) as cfg: + setup_test(cfg, + os.path.join(os.path.dirname(os.path.abspath(__file__)), + "ncdevmem")) + + require_devmem(cfg) + configure_nic(cfg) + try: + ksft_run([check_nk_rx, check_nk_tx, check_nk_tx_chunks, + check_nk_rx_hds], args=(cfg,)) + finally: + cleanup_nic(cfg) + + ksft_exit() + + +if __name__ == "__main__": + main() -- 2.53.0-Meta

