From patchwork Tue Sep 3 22:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohan Prasad J X-Patchwork-Id: 13789709 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 A232F58ABC; Wed, 4 Sep 2024 05:14:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725426882; cv=none; b=dHldoHGQOFXn0R3rekb0pRfsRr5ny3kLTweL1GOmjYqNrY8nzrXWy01hxIgyj23fTKAxKun4fw1wY036RZCbpQdACRgSEN2AeikZECB5Z/cJjAvCEo+z/hBMsBdFSMzDLHXjH2tUJIskNSbaymGoMPtvMFdBmuoEsflc66V8XAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725426882; c=relaxed/simple; bh=mtlfEanAfYMSUSoIVuuAooYcKIUWTEVrlYHzkqcJItY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E7AZkg02qwzKmj3A6fHsgrpcmHo+QwggQ1/+5Oz3OX1eGWmc53DOqujLEbFsu5tCEaVmWkjAOQt7buKsF8ZWnU9P6Mn4hv2wvvKy6ztvooJJMtGLO6UBTzmqjaClpqQcnwDsYeRxiwEzczVSDgDRMbDgwYm4dtgcdBAlCiR/5mg= 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=y/zsa4gI; arc=none smtp.client-ip=68.232.153.233 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="y/zsa4gI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725426881; x=1756962881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mtlfEanAfYMSUSoIVuuAooYcKIUWTEVrlYHzkqcJItY=; b=y/zsa4gIm7e7gycScKUWF3MqR8hhqVM5MxfbBa7+sMGm+g5cRG3n1oWu CzKQusNuiMgOI5UkpGjSLzFJ6ke0eEEam0qRywtwJ0Dqitnrh/YgyERbu znamgPKrDF+4ShXcju80IH6mAMw9dEDO+PkQws9LxWSsDSt2XKBv8/BI8 iEY7xQIeyGBrQ/kzYDCk6DzcWW/owfcPRkIcLLF5DHP1SncBjaclzV7cv podzGnAeN1I1iohCLD/ufYk4GVYy6NkoyZC+pHBnFpgSe8NoTy1uIvb+F vu9+TftAEDG4YQ8twam0/VdsqBqq0Fg5gfpMJfyU5+gmbwusgawMVHkQk Q==; X-CSE-ConnectionGUID: tj+/ggMhS4S42i0wyHIlFg== X-CSE-MsgGUID: tLL4u5EjSTaBoGqPeJnSvA== X-IronPort-AV: E=Sophos;i="6.10,200,1719903600"; d="scan'208";a="31271671" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 03 Sep 2024 22:14:40 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 3 Sep 2024 22:14:20 -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; Tue, 3 Sep 2024 22:14:15 -0700 From: Mohan Prasad J To: , , CC: , , , , , , , , , , Subject: [PATCH net-next 1/3] selftests: lan743x: Add testfile for lan743x network driver Date: Wed, 4 Sep 2024 03:45:47 +0530 Message-ID: <20240903221549.1215842-2-mohan.prasad@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240903221549.1215842-1-mohan.prasad@microchip.com> References: <20240903221549.1215842-1-mohan.prasad@microchip.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add testfile for lan743x network driver. Testfile includes the verification of status of autonegotiation. Ksft modules and ethtool are used for the testing. net/lib libraries are included for testing. Add the __init__.py file. Include /microchip/lan743x as a target in Makefile. Updated MAINTAINERS list. Signed-off-by: Mohan Prasad J --- MAINTAINERS | 2 + tools/testing/selftests/Makefile | 2 +- .../drivers/net/hw/microchip/lan743x/Makefile | 7 +++ .../net/hw/microchip/lan743x/lan743x.py | 51 +++++++++++++++++++ .../hw/microchip/lan743x/lib/py/__init__.py | 16 ++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile create mode 100755 tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py create mode 100644 tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py diff --git a/MAINTAINERS b/MAINTAINERS index baf88e74c..461f94ae0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14960,10 +14960,12 @@ F: net/dsa/tag_ksz.c MICROCHIP LAN743X ETHERNET DRIVER M: Bryan Whitehead +M: Mohan Prasad J M: UNGLinuxDriver@microchip.com L: netdev@vger.kernel.org S: Maintained F: drivers/net/ethernet/microchip/lan743x_* +F: tools/testing/selftests/drivers/net/hw/microchip/lan743x/ MICROCHIP LAN87xx/LAN937x T1 PHY DRIVER M: Arun Ramadoss diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a5f1c0c27..8059529c9 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -122,7 +122,7 @@ TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG += memory-hotplug # Networking tests want the net/lib target, include it automatically -ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),) +ifneq ($(filter net drivers/net drivers/net/hw drivers/net/hw/microchip/lan743x,$(TARGETS)),) ifeq ($(filter net/lib,$(TARGETS)),) INSTALL_DEP_TARGETS := net/lib endif diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile new file mode 100644 index 000000000..542128678 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_INCLUDES := $(wildcard lib/py/*.py ../../../lib/py/*.py) + +TEST_PROGS := lan743x.py + +include ../../../../../lib.mk diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py new file mode 100755 index 000000000..f1ad97dc2 --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +import time +import re +from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq +from lib.py import KsftFailEx, KsftSkipEx +from lib.py import NetDrvEpEnv +from lib.py import cmd +from lib.py import ethtool + +def verify_link_up(ifname: str) -> None: + """Verify whether the link is up initially""" + with open(f"/sys/class/net/{ifname}/operstate", "r") as fp: + link_state = fp.read().strip() + + if link_state == "down": + raise KsftSkipEx(f"Link state of interface {ifname} is DOWN") + +def set_autonegotiation_state(ifname: str, state: str) -> None: + """Set the autonegotiation state for the interface""" + process = ethtool(f"-s {ifname} speed 10 duplex half autoneg {state}") + if process.ret != 0: + raise KsftFailEx(f"Not able to set autoneg parameter for {ifname}") + ksft_pr(f"Autoneg set as {state} for {ifname}") + +def verify_autonegotiation(ifname: str, expected_state: str) -> None: + verify_link_up(ifname) + """Verifying the autonegotiation state""" + output = ethtool(f"{ifname}") + autoneg_match = re.search(r'Auto-negotiation:\s+(\w+)', output.stdout) + + if not autoneg_match: + raise KsftFailEx("Failed to find autonegotiation information in ethtool output.") + + actual_state = autoneg_match.group(1) + ksft_eq(actual_state, expected_state) + +def test_autonegotiation(cfg) -> None: + for state in ["off", "on"]: + set_autonegotiation_state(cfg.ifname, state) + time.sleep(5) + verify_autonegotiation(cfg.ifname, state) + +def main() -> None: + with NetDrvEpEnv(__file__) as cfg: + ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) + ksft_exit() + +if __name__ == "__main__": + main() diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py new file mode 100644 index 000000000..e571631af --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lib/py/__init__.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 + +import sys +from pathlib import Path + +KSFT_DIR = (Path(__file__).parent / "../../../../../../..").resolve() + +try: + sys.path.append(KSFT_DIR.as_posix()) + from net.lib.py import * + from drivers.net.lib.py import * +except ModuleNotFoundError as e: + ksft_pr("Failed importing `net` library from kernel sources") + ksft_pr(str(e)) + ktap_result(True, comment="SKIP") + sys.exit(4) From patchwork Tue Sep 3 22:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohan Prasad J X-Patchwork-Id: 13789710 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 D3B8883A17; Wed, 4 Sep 2024 05:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725426884; cv=none; b=bRvHnbJSdybDO0mOXIgdzCRSANsjuffQ3qyMGlhvFBaOYEDhojE2dwQE3hjNN9xUx2mDmIh341+4+nYpf279BN23Fk9+6ysOf5LJN1DSFnKNdwSR2ksNyL6bA4Nvoj5mwFqjTghfKGyNVBDoY5tgNTsLJnIHlwdORdFb4M/CJnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725426884; c=relaxed/simple; bh=Hja1n0/1fpHUQJXWD1EiDmFTR3ZmSeBBZwUB2XpF/qQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mkgcTlrskYRF2mhAkGfBFl0r6MvuloCAeYg2dzNnddLp8JILHFL4qe0ijQcbUYcBHXkuu//pm9pdNoL4KRiZXBpMuTBjexvu7c+Kbe+n36yuZ3iwC6ONKBYf0Rglh8irumVzwMNLcIHeiFVLRoeuDr/wY3nZXltyqdXqi8JPw9A= 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=bj7kBhKd; arc=none smtp.client-ip=68.232.153.233 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="bj7kBhKd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725426883; x=1756962883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hja1n0/1fpHUQJXWD1EiDmFTR3ZmSeBBZwUB2XpF/qQ=; b=bj7kBhKdDmYlDg+7hwvP2taibCU8lpeg0M8zC9kDRwDyGfMxDD341YuP CFlNwn8cmIbYzFnV825sO3BJcf7u9C4HcwIWej6XYlnWIo66g3RPnuRYs sbzQ1VlxEC24LNWd0K7v0W8H/rF4SFY8kBuySbooywKq1S9kygRgmORHp SD/b/v9fDPNTXIseprnhjmb3Y1L6F+72QyIFHSbL5U3Xx61daIgdFsR+g cbwXaYqYBUuTpDuj4AkU4r7rSnoS6UK22JH9ydGxtPUQfdgK5RIS0U1g3 o6UW/muy3j6/kTwM+QDCLCHv10TnM3UiyyeUrAp00V9eleaAHwi2k+Vh1 g==; X-CSE-ConnectionGUID: tj+/ggMhS4S42i0wyHIlFg== X-CSE-MsgGUID: LQZgLfUNTE+Pkb8U6gRTkg== X-IronPort-AV: E=Sophos;i="6.10,200,1719903600"; d="scan'208";a="31271672" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 03 Sep 2024 22:14:40 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 3 Sep 2024 22:14:29 -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; Tue, 3 Sep 2024 22:14:24 -0700 From: Mohan Prasad J To: , , CC: , , , , , , , , , , Subject: [PATCH net-next 2/3] selftests: lan743x: Add testcase to check speed and duplex state of lan743x Date: Wed, 4 Sep 2024 03:45:48 +0530 Message-ID: <20240903221549.1215842-3-mohan.prasad@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240903221549.1215842-1-mohan.prasad@microchip.com> References: <20240903221549.1215842-1-mohan.prasad@microchip.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add testcase for checking speed and duplex states for lan743x network driver. Testcase comprises of varying the network speed and duplex state to 10/100/1000Mbps and half/full via ethtool. Signed-off-by: Mohan Prasad J --- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index f1ad97dc2..59f0be2a7 100755 --- a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -36,12 +36,45 @@ def verify_autonegotiation(ifname: str, expected_state: str) -> None: actual_state = autoneg_match.group(1) ksft_eq(actual_state, expected_state) +def set_speed_and_duplex(ifname: str, speed: str, duplex: str) -> None: + """Set the speed and duplex state for the interface""" + process = ethtool(f"--change {ifname} speed {speed} duplex {duplex} autoneg on") + + if process.ret != 0: + raise KsftFailEx(f"Not able to set speeed and duplex parameters for {ifname}") + ksft_pr(f"Speed: {speed} Mbps, Duplex: {duplex} set for Interface: {ifname}") + +def verify_speed_and_duplex(ifname: str, expected_speed: str, expected_duplex: str) -> None: + verify_link_up(ifname) + """Verifying the speed and duplex state for the interface""" + output = ethtool(f"{ifname}") + with open(f"/sys/class/net/{ifname}/speed", "r") as fp: + actual_speed = fp.read().strip() + with open(f"/sys/class/net/{ifname}/duplex", "r") as fp: + actual_duplex = fp.read().strip() + + ksft_eq(actual_speed, expected_speed) + ksft_eq(actual_duplex, expected_duplex) + def test_autonegotiation(cfg) -> None: for state in ["off", "on"]: set_autonegotiation_state(cfg.ifname, state) time.sleep(5) verify_autonegotiation(cfg.ifname, state) +def test_network_speed(cfg) -> None: + speeds = ["10", "100", "1000"] + duplex_modes = ["half", "full"] + + for speed in speeds: + for duplex in duplex_modes: + # Skip for speed = 1000Mbps, duplex = Half + if speed == "1000" and duplex == "half": + continue + set_speed_and_duplex(cfg.ifname, speed, duplex) + time.sleep(5) + verify_speed_and_duplex(cfg.ifname, speed, duplex) + def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,)) From patchwork Tue Sep 3 22:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohan Prasad J X-Patchwork-Id: 13789711 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 7E92F84A32; Wed, 4 Sep 2024 05:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725426885; cv=none; b=ey6vLWyY6PPulnBnSAYHR/TGZiNi32qHLjmm83Mv+co+TDboPkWCiPSdwjlLkwrKrTcd8bwJeOejZHC8cNeKwNWbN1iM6dq5kdJ944zSaQaTE2taODmypVIW683KuS67b+VwWcfjvI5mtd90pkmPpHug7DosnjNWC74iy+dMHKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725426885; c=relaxed/simple; bh=JlZSM40ifyeZNoN07U6vpgyOTY7VOt2WsqMUA0RUAzQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=knAWIzTrOfMPpZUntjioJZS0b0Ev1+mzPuNZ3Y+ruZllQyQAaOCGPJoQXj229nHd3IBoTivDEAyx0M+a3bcLk8ZSMI98OVE/8MFd3pexu1OLYoT5D0++9gtjf3tKo3d3mryFFyEtKanSXd1RS0mvwrYjOuiNxD1EHfAAg3CB2XY= 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=vjjo8xqP; arc=none smtp.client-ip=68.232.153.233 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="vjjo8xqP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1725426884; x=1756962884; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JlZSM40ifyeZNoN07U6vpgyOTY7VOt2WsqMUA0RUAzQ=; b=vjjo8xqPp7IBde3Bj/NCJN7W0goDpviVEK30WojDmTPdAjoFVEUmBG1S XO85J6yNlePf7apamrzKi0Di6rkzCs5xFyws+vzAuPIca9FPFFkDqeWHp CwbxxXwIjSAQvH1uHiUicGWImBqT9LXuQKCiyykvSZxk/7uYuq8srfHS6 Jvx2NRTBH9c9Saf7qQ48p7MyfvfjNK1GoAMYS+I4CW6J1G6AH0zZCv6n8 UdXh07lCaWcyruFa1pCMLhc9jAvqy9piaIgFWwNyUwAFzM4BCxrRoeO6z 5we+aBqGBG62wfvmRHEmC+50vkMnEZpSjtDLHFQawLZecUz7/no6KxpGB g==; X-CSE-ConnectionGUID: tj+/ggMhS4S42i0wyHIlFg== X-CSE-MsgGUID: S0xlivOhTbSTLcOJjjSDLw== X-IronPort-AV: E=Sophos;i="6.10,200,1719903600"; d="scan'208";a="31271673" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 03 Sep 2024 22:14:40 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 3 Sep 2024 22:14:35 -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; Tue, 3 Sep 2024 22:14:31 -0700 From: Mohan Prasad J To: , , CC: , , , , , , , , , , Subject: [PATCH net-next 3/3] selftests: lan743x: Add testcase to check throughput of lan743x Date: Wed, 4 Sep 2024 03:45:49 +0530 Message-ID: <20240903221549.1215842-4-mohan.prasad@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240903221549.1215842-1-mohan.prasad@microchip.com> References: <20240903221549.1215842-1-mohan.prasad@microchip.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add testcase to check TCP throughput of lan743x network driver. Test uses iperf3 to do performance testing of the driver. TCP data at different speeds is sent, received and verified. Signed-off-by: Mohan Prasad J --- .../net/hw/microchip/lan743x/lan743x.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py index 59f0be2a7..a3dcf7896 100755 --- a/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py +++ b/tools/testing/selftests/drivers/net/hw/microchip/lan743x/lan743x.py @@ -3,6 +3,7 @@ import time import re +import json from lib.py import ksft_run, ksft_exit, ksft_pr, ksft_eq from lib.py import KsftFailEx, KsftSkipEx from lib.py import NetDrvEpEnv @@ -75,6 +76,38 @@ def test_network_speed(cfg) -> None: time.sleep(5) verify_speed_and_duplex(cfg.ifname, speed, duplex) +def test_tcp_throughput(cfg) -> None: + speeds = ["10", "100", "1000"] + """Test duration in seconds""" + test_duration = 5 + target_ip = cfg.remote_addr + + for speed in speeds: + set_speed_and_duplex(cfg.ifname, speed, 'full') + time.sleep(5) + verify_link_up(cfg.ifname) + send_command=f"iperf3 -c {target_ip} -t {test_duration} --json" + receive_command=f"iperf3 -c {target_ip} -t {test_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 0.9 times the set speed""" + threshold = float(speed) * 0.9 + if send_throughput < threshold or receive_throughput < threshold: + raise KsftFailEx("Throughput is below threshold") + def main() -> None: with NetDrvEpEnv(__file__) as cfg: ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg,))