Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Mohan Prasad J <mohan.prasad@microchip.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<kuba@kernel.org>, <andrew@lunn.ch>
Cc: <edumazet@google.com>, <pabeni@redhat.com>, <shuah@kernel.org>,
	<mohan.prasad@microchip.com>, <linux-kernel@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>, <horms@kernel.org>,
	<brett.creeley@amd.com>, <rosenp@gmail.com>,
	<UNGLinuxDriver@microchip.com>, <willemb@google.com>
Subject: [PATCH net-next v2 3/3] selftests: nic_basic_tests: Add selftest case for throughput check
Date: Tue, 17 Sep 2024 08:04:09 +0530	[thread overview]
Message-ID: <20240917023525.2571082-4-mohan.prasad@microchip.com> (raw)
In-Reply-To: <20240917023525.2571082-1-mohan.prasad@microchip.com>

Add 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.

Signed-off-by: Mohan Prasad J <mohan.prasad@microchip.com>
---
 .../drivers/net/hw/nic_basic_tests.py         | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/tools/testing/selftests/drivers/net/hw/nic_basic_tests.py b/tools/testing/selftests/drivers/net/hw/nic_basic_tests.py
index ff46f2406..ec1f5b6a2 100644
--- a/tools/testing/selftests/drivers/net/hw/nic_basic_tests.py
+++ b/tools/testing/selftests/drivers/net/hw/nic_basic_tests.py
@@ -182,6 +182,45 @@ def test_network_speed(cfg) -> None:
         else:
             KsftSkipEx("Mismatch in the number of speeds and duplex modes")
 
+def test_tcp_throughput(cfg) -> None:
+    check_autonegotiation(cfg.ifname)
+    if not common_link_modes:
+        KsftSkipEx("No common link modes found")
+    cfg.require_cmd("iperf3", remote=True)
+    """iperf3 server to be run in the partner pc"""
+    speeds, duplex_modes = get_speed_duplex(common_link_modes)
+    """Test duration in seconds"""
+    duration = test_duration
+    target_ip = cfg.remote_addr
+
+    for idx in range(len(speeds)-1, -1, -1):
+        set_speed_and_duplex(cfg.ifname, speeds[idx], duplex_modes[idx])
+        time.sleep(sleep_time)
+        verify_link_up(cfg.ifname)
+        send_command=f"iperf3 -c {target_ip} -t {duration} --json"
+        receive_command=f"iperf3 -c {target_ip} -t {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 the threshold (default:80% of set speed)"""
+        threshold = float(speeds[idx]) * float(throughput_threshold)
+        if send_throughput < threshold:
+            raise KsftFailEx("Send throughput is below threshold")
+        elif receive_throughput < threshold:
+            raise KsftFailEx("Receive throughput is below threshold")
+
 def main() -> None:
     with NetDrvEpEnv(__file__) as cfg:
         ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))
-- 
2.43.0


      parent reply	other threads:[~2024-09-17  9:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-17  2:34 [PATCH net-next v2 0/3] nic_basic_tests: Add selftest for doing basic tests of NIC driver Mohan Prasad J
2024-09-17  2:34 ` [PATCH net-next v2 1/3] selftests: nic_basic_tests: Add selftest file for basic tests of NIC Mohan Prasad J
2024-09-17 15:35   ` Andrew Lunn
2024-09-18 10:30     ` Mohan.Prasad
2024-09-18 12:05       ` Andrew Lunn
2024-09-19 10:44         ` Mohan.Prasad
2024-09-19 14:51           ` Andrew Lunn
2024-09-17 15:48   ` Andrew Lunn
2024-09-18 10:32     ` Mohan.Prasad
2024-09-18 12:11       ` Andrew Lunn
2024-09-17 15:56   ` Andrew Lunn
2024-09-18 10:35     ` Mohan.Prasad
2024-09-17  2:34 ` [PATCH net-next v2 2/3] selftests: nic_basic_tests: Add selftest case for speed and duplex state checks Mohan Prasad J
2024-09-18 12:38   ` Willem de Bruijn
2024-09-20  4:56     ` Mohan.Prasad
2024-09-17  2:34 ` Mohan Prasad J [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240917023525.2571082-4-mohan.prasad@microchip.com \
    --to=mohan.prasad@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rosenp@gmail.com \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox