From: Jakub Kicinski kuba@kernel.org
[ Upstream commit c378c497f3fe8dc8f08b487fce49c3d96e4cada8 ]
The Device Under Test should always be the local system. While the Rx test gets this right the Tx test is sending from remote to local. So Tx of DMABUF memory happens on remote.
These tests never run in NIPA since we don't have a compatible device so we haven't caught this.
Reviewed-by: Joe Damato joe@dama.to Reviewed-by: Mina Almasry almasrymina@google.com Acked-by: Stanislav Fomichev sdf@fomichev.me Link: https://patch.msgid.link/20250811231334.561137-6-kuba@kernel.org Signed-off-by: Jakub Kicinski kuba@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
Explanation
- Fixes a real test bug - The commit corrects the Tx direction so the Device Under Test (DUT) is always the local system, matching the stated intent. Previously, the Tx path was exercised on the remote host, defeating the purpose of the test.
- Precise changes and their effect - tools/testing/selftests/drivers/net/hw/devmem.py: check_tx - Before: local ran the listener; remote invoked the devmem binary (Tx ran on remote) - `with bkg(listen_cmd) as socat:` - `wait_port_listen(port)` - `cmd(... {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port}, host=cfg.remote, ...)` - After: remote runs the listener; local invokes the devmem binary (Tx runs on local) - `with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat` - `wait_port_listen(port, host=cfg.remote)` - `cmd(... {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port}, ...)` - Key corrections: - Move the listener to the remote host via `host=cfg.remote`, aligning with how Rx is validated (DUT local, peer remote). - Run the devmem-capable sender locally by switching `{cfg.bin_remote}` → `{cfg.bin_local}`. - Fix the server IP argument from `{cfg.addr}` (local) → `{cfg.remote_addr}` (remote). - Add `exit_wait=True` to ensure proper capture of remote `socat` output for assertion. - tools/testing/selftests/drivers/net/hw/devmem.py: check_tx_chunks - Applies the same direction flip as `check_tx`, and keeps the chunking parameter (`-z 3`) intact: - Listener moved to remote: `with bkg(listen_cmd, host=cfg.remote, exit_wait=True) ...` - Sender is local: `{cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port} -z 3` - tools/testing/selftests/drivers/net/hw/devmem.py: check_rx - Unchanged; already had the DUT local, running `ncdevmem -l` and receiving data from remote via `socat`, consistent with the intended direction.
- Why this fits stable rules - Important test fix: Corrects which system is being tested for Tx, preventing false confidence and misattribution of failures/successes. - Small and contained: Touches a single selftest file and only flips host roles and parameters; no kernel code changes. - Minimal regression risk: Uses established helpers (`bkg(..., host=cfg.remote, exit_wait=True)`, `wait_port_listen(..., host=cfg.remote)`) already used elsewhere (e.g., `tools/testing/selftests/drivers/net/ping.py`) and preserves the test assertions (`ksft_eq(socat.stdout.strip(), "hello\nworld")`). - No features or architectural changes: Pure test orchestration fix. - Broader impact: Improves reliability of selftests for NET_DEVMEM/DMABUF Tx validation.
- Dependencies and applicability - Assumes the selftest suite already contains `devmem.py` and a version of the `ncdevmem` tool that supports the usage invoked here (client-side send without `-l`). Branches lacking this test or the necessary `ncdevmem` capabilities do not need this backport. - For branches where `devmem.py` exists with the original bug, this change is directly applicable and beneficial.
Given it is a minimal, clearly correct selftest-only bugfix that aligns the Tx test with stated DUT semantics, it is suitable for stable backporting where the test exists.
tools/testing/selftests/drivers/net/hw/devmem.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hw/devmem.py b/tools/testing/selftests/drivers/net/hw/devmem.py index 0a2533a3d6d60..45c2d49d55b61 100755 --- a/tools/testing/selftests/drivers/net/hw/devmem.py +++ b/tools/testing/selftests/drivers/net/hw/devmem.py @@ -42,9 +42,9 @@ def check_tx(cfg) -> None: port = rand_port() listen_cmd = f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
- with bkg(listen_cmd) as socat: - wait_port_listen(port) - cmd(f"echo -e "hello\nworld"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port}", host=cfg.remote, shell=True) + with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat: + wait_port_listen(port, host=cfg.remote) + cmd(f"echo -e "hello\nworld"| {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port}", shell=True)
ksft_eq(socat.stdout.strip(), "hello\nworld")
@@ -56,9 +56,9 @@ def check_tx_chunks(cfg) -> None: port = rand_port() listen_cmd = f"socat -U - TCP{cfg.addr_ipver}-LISTEN:{port}"
- with bkg(listen_cmd, exit_wait=True) as socat: - wait_port_listen(port) - cmd(f"echo -e "hello\nworld"| {cfg.bin_remote} -f {cfg.ifname} -s {cfg.addr} -p {port} -z 3", host=cfg.remote, shell=True) + with bkg(listen_cmd, host=cfg.remote, exit_wait=True) as socat: + wait_port_listen(port, host=cfg.remote) + cmd(f"echo -e "hello\nworld"| {cfg.bin_local} -f {cfg.ifname} -s {cfg.remote_addr} -p {port} -z 3", shell=True)
ksft_eq(socat.stdout.strip(), "hello\nworld")