[PATCH net-next v2 2/4] selftests: drv-net: add a closed-loop request-response test

From: Stanislav Fomichev

Date: Mon Nov 30 2026 - 12:46:20 EST


From: Stanislav Fomichev <sdf@xxxxxxxxxxx>

Add rr.py, which measures back-to-back transactions of a kilobyte each
way, which fits in a 1500 byte MTU, over one connection with kperf, and
reports their rate and the latency percentiles and maximum which kperf
reports.

Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
---
.../selftests/drivers/net/perf/Makefile | 1 +
.../testing/selftests/drivers/net/perf/rr.py | 47 +++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/perf/rr.py

diff --git a/tools/testing/selftests/drivers/net/perf/Makefile b/tools/testing/selftests/drivers/net/perf/Makefile
index 1a90537d2726..91feb0d62a7b 100644
--- a/tools/testing/selftests/drivers/net/perf/Makefile
+++ b/tools/testing/selftests/drivers/net/perf/Makefile
@@ -3,6 +3,7 @@
TEST_PROGS := \
devmem.py \
iperf.py \
+ rr.py \
# end of TEST_PROGS

TEST_INCLUDES := \
diff --git a/tools/testing/selftests/drivers/net/perf/rr.py b/tools/testing/selftests/drivers/net/perf/rr.py
new file mode 100755
index 000000000000..1dff0c476390
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/perf/rr.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Measure TCP request-response performance with kperf."""
+
+from lib.py import KperfRunner, NetDrvEpEnv, ksft_exit, ksft_metric, ksft_run
+
+
+# One connection, a kilobyte each way, which fits in a 1500 byte MTU, and
+# latency percentiles
+RR_ARGS = [
+ "--time", "10",
+ "--warmup", "100",
+ "--num-connections", "1",
+ "--req-size", "1024",
+ "--resp-size", "1024",
+ "--time-stats", "2",
+ "--validate", "no",
+]
+
+
+def _report(result) -> None:
+ ksft_metric("rate", result.rate, goal="higher")
+ ksft_metric("latency_p25", result.p25, goal="lower")
+ ksft_metric("latency_p50", result.p50, goal="lower")
+ ksft_metric("latency_p90", result.p90, goal="lower")
+ ksft_metric("latency_p99", result.p99, goal="lower")
+ ksft_metric("latency_p999", result.p999, goal="lower")
+ ksft_metric("latency_p9999", result.p9999, goal="lower")
+ ksft_metric("latency_max", result.lat_max, goal="lower")
+
+
+def closed_loop(cfg) -> None:
+ """Measure back-to-back transactions."""
+ with KperfRunner(cfg) as runner:
+ _report(runner.run(RR_ARGS))
+
+
+def main() -> None:
+ """Run the request-response performance tests."""
+ with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
+ ksft_run([closed_loop], args=(cfg,))
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.53.1-Meta