From nobody Tue Nov 26 19:45:34 2024 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F5D01791EB; Thu, 17 Oct 2024 04:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729140482; cv=none; b=XeewoW5kvP5BxgS6UEHSDvMPsGqnttz/m0rXsKmGKjkHE1dWRJCMHSYcPOafcGDwfUjQYUJbdoGqJRdEH9scoGDnfPsyLSvqslQ+VLDAhDEAuQo8KbHxmmsffJpYJ5eiz2eMXnINoBYXODNUlaKivYnCEj8IvtbSzQntsIyMKfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729140482; c=relaxed/simple; bh=hGoy1m3iAmRAPhSfvDXhU4J22za0qmzPoPvGb1PP6Ek=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m/nic+XFrVd/O/YoOvGKdqRFQP8EE5cw8OoyjPHfn4DAFB/piJ01BUZL1ymiWqWwSUo9XllPSKN40dx1OdHHWQ3MB9SxYsdGOK++ENqyOsFW5HjhG5aNXVgOHFJznDzwhgLu/oSIMFon3qUu36XjCqja7b25bxmhu2ckM9gFMvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=Y9EDVH5S; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="Y9EDVH5S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1729140479; x=1760676479; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hGoy1m3iAmRAPhSfvDXhU4J22za0qmzPoPvGb1PP6Ek=; b=Y9EDVH5Sj/hXkAiJEpVHr1TlbdlUYxpBgOKiwDou3dzmVTt3ZkTseHFi 7EXVWn1zIjbi1IxGEP2d6Z1lFInGywj8oihGohodwma5sGelhB8xD1tsM lUf/OKHE2P1jmr+78muUx1UCcNxzoWgXV9vfPBs5JiOTiuTplPlV94d+7 T5AeiqQ7LHE4A/vcm6XopmmLmt694lOP8MzkD70kHVltROF4qOAfdfWJ3 mc32mllk5ZRp9TuTVx6f/RMl7552pzkd/u0ptLYSLzFRcrhEa9k7ZOpNb Mzwyaqm3+Kxk/m+ga/YyeDv3/8xp/IGb2qak7A0sHwmvd8SmjvH0Q7B+t A==; X-CSE-ConnectionGUID: 8pbTCNeqT7aHxiJ1HBLGWw== X-CSE-MsgGUID: JcJNttygRZG6oNzePtkFsw== X-IronPort-AV: E=Sophos;i="6.11,210,1725346800"; d="scan'208";a="200553968" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 16 Oct 2024 21:47:51 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 16 Oct 2024 21:47:41 -0700 Received: from nisar-OptiPlex-9020.microchip.com (10.10.85.11) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 16 Oct 2024 21:47:36 -0700 From: Mohan Prasad J To: , , , CC: , , , , , , , , , , , Subject: [PATCH net-next v3 3/3] selftests: nic_performance: Add selftest for performance of NIC driver Date: Thu, 17 Oct 2024 03:20:07 +0530 Message-ID: <20241016215014.401476-4-mohan.prasad@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241016215014.401476-1-mohan.prasad@microchip.com> References: <20241016215014.401476-1-mohan.prasad@microchip.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 --- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../drivers/net/hw/nic_performance.py | 121 ++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/hw/nic_performance.= py diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testin= g/selftests/drivers/net/hw/Makefile index 0dac40c4e..289512092 100644 --- a/tools/testing/selftests/drivers/net/hw/Makefile +++ b/tools/testing/selftests/drivers/net/hw/Makefile @@ -11,6 +11,7 @@ TEST_PROGS =3D \ hw_stats_l3_gre.sh \ loopback.sh \ nic_link_layer.py \ + nic_performance.py \ pp_alloc_fail.py \ rss_ctx.py \ # diff --git a/tools/testing/selftests/drivers/net/hw/nic_performance.py b/to= ols/testing/selftests/drivers/net/hw/nic_performance.py new file mode 100644 index 000000000..152c62511 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/nic_performance.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +#Introduction: +#This file has basic performance test for generic NIC drivers. +#The test comprises of throughput check for TCP and UDP streams. +# +#Setup: +#Connect the DUT PC with NIC card to partner pc back via ethernet medium o= f your choice(RJ45, T1) +# +# DUT PC Partner PC +#=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =90 =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 +#=E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 +#=E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 +#=E2=94=82 =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=90 = =E2=94=82 =E2=94=82 +#=E2=94=82 =E2=94=82DUT NIC =E2=94=82 Eth = =E2=94=82 =E2=94=82 +#=E2=94=82 =E2=94=82Interface =E2=94=80=E2=94=BC=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94= =80 any eth Interface =E2=94=82 +#=E2=94=82 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98 = =E2=94=82 =E2=94=82 +#=E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 +#=E2=94=82 =E2=94=82 =E2=94= =82 =E2=94=82 +#=E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =98 =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98 +# +#Configurations: +#To prevent interruptions, Add ethtool, ip to the sudoers list in remote P= C 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 =3D 8 #time taken to wait for transitions to happen, in seconds. +test_duration =3D 10 #performance test duration for the throughput check,= in seconds. +send_throughput_threshold =3D 80 #percentage of send throughput required t= o pass the check +receive_throughput_threshold =3D 50 #percentage of receive throughput requ= ired to pass the check + +import time +import json +from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_true +from lib.py import KsftFailEx, KsftSkipEx +from lib.py import NetDrvEpEnv +from lib.py import cmd +from lib.py import LinkConfig + +def verify_throughput(cfg, link_config) -> None: + protocols =3D ["TCP", "UDP"] + common_link_modes =3D link_config.common_link_modes + speeds, duplex_modes =3D link_config.get_speed_duplex_values(common_li= nk_modes) + """Test duration in seconds""" + duration =3D test_duration + target_ip =3D cfg.remote_addr + + for protocol in protocols: + ksft_pr(f"{protocol} test") + test_type =3D "-u" if protocol =3D=3D "UDP" else "" + send_throughput =3D [] + receive_throughput =3D [] + for idx in range(0, len(speeds)): + bit_rate =3D f"-b {speeds[idx]}M" if protocol =3D=3D "UDP" els= e "" + if link_config.set_speed_and_duplex(speeds[idx], duplex_modes[= idx]) =3D=3D False: + raise KsftFailEx(f"Not able to set speed and duplex parame= ters for {cfg.ifname}") + time.sleep(time_delay) + if link_config.verify_link_up() =3D=3D False: + raise KsftSkipEx(f"Link state of interface {cfg.ifname} is= DOWN") + send_command=3Df"iperf3 {test_type} -c {target_ip} {bit_rate} = -t {duration} --json" + receive_command=3Df"iperf3 {test_type} -c {target_ip} {bit_rat= e} -t {duration} --reverse --json" + send_result =3D cmd(send_command) + receive_result =3D cmd(receive_command) + if send_result.ret !=3D 0 or receive_result.ret !=3D 0: + raise KsftSkipEx("Unexpected error occurred during transmi= t/receive") + + send_output =3D send_result.stdout + receive_output =3D receive_result.stdout + + send_data =3D json.loads(send_output) + receive_data =3D json.loads(receive_output) + """Convert throughput to Mbps""" + send_throughput.append(round(send_data['end']['sum_sent']['bit= s_per_second'] / 1e6, 2)) + receive_throughput.append(round(receive_data['end']['sum_recei= ved']['bits_per_second'] / 1e6, 2)) + + ksft_pr(f"{protocol}: Send throughput: {send_throughput[idx]} = Mbps, Receive throughput: {receive_throughput[idx]} Mbps") + + """Check whether throughput is not below the threshold (default va= lues set at start)""" + for idx in range(0, len(speeds)): + send_threshold =3D float(speeds[idx]) * float(send_throughput_= threshold / 100) + receive_threshold =3D float(speeds[idx]) * float(receive_throu= ghput_threshold / 100) + ksft_true(send_throughput[idx] >=3D send_threshold, f"{protoco= l}: Send throughput is below threshold for {speeds[idx]} Mbps in {duplex_mo= des[idx]} duplex") + ksft_true(receive_throughput[idx] >=3D receive_threshold, f"{p= rotocol}: Receive throughput is below threshold for {speeds[idx]} Mbps in {= duplex_modes[idx]} duplex") + +def test_throughput(cfg, link_config) -> None: + common_link_modes =3D link_config.common_link_modes + if not common_link_modes: + KsftSkipEx("No common link modes found") + if link_config.partner_netif =3D=3D None: + KsftSkipEx("Partner interface name not available") + if link_config.check_autoneg_supported() and link_config.check_autoneg= _supported(remote=3DTrue): + KsftSkipEx("Auto-negotiation not supported by local or remote") + cfg.require_cmd("iperf3", remote=3DTrue) + try: + """iperf3 server to be run in the remote pc""" + command =3D "iperf3 -s -D" + process =3D cmd(command, host=3Dcfg.remote) + if "Address already in use" in process.stdout: + ksft_pr("Iperf server already running in remote") + elif process.ret !=3D 0: + raise KsftSkipEx("Unable to start server in remote PC") + verify_throughput(cfg, link_config) + except Exception as e: + raise KsftSkipEx(f"Unexpected error occurred: {e}") + finally: + """Kill existing iperf server in remote pc""" + try: + cmd("pkill iperf3", host=3Dcfg.remote) + except Exception as e: + ksft_pr("Unable to stop iperf3 server in remote") + +def main() -> None: + with NetDrvEpEnv(__file__, nsim_test=3DFalse) as cfg: + link_config =3D LinkConfig(cfg) + ksft_run(globs=3Dglobals(), case_pfx=3D{"test_"}, args=3D(cfg, lin= k_config,)) + link_config.reset_interface() + ksft_exit() + +if __name__ =3D=3D "__main__": + main() --=20 2.43.0