From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78909C79F82 for ; Tue, 8 Sep 2026 16:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gWAD8qw5BaN/waNwxRr5RIrv8DsM0KLGkweaYwneCbg=; b=NkkgV3nH9i8ASqs4RAFurWcmb/ 9atYAy6A3zgQDFTzc/6p+MQIQOs2fb8P2RhDXcg0BzkFsqPT5oM4rC9XWYf6X/xjM64XgGnoamRlu KxQlJgpmjhh67el973VxL/zVBNIdPVT7pDH/6tObYA2ZB9JGnisQeGSI8TFdknU7lydlvywoX9tbp bCUIu5gNLF98zmhNT/OyjMERPWJU4J+SdPJ44ym5ha5eK9djNgMcqWo+keCcxOlXsjv2CGOmUNG6G nlEwFN4KymGT1XvWkz1k3kZU5b6oqaxxtrIBFHhR86pjfG6ROn4cF81i2fv7e2jmIO3La0mYqGGz+ 0dEHBu9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x3yvw-00000009iYs-3Y6t; Tue, 08 Sep 2026 16:44:32 +0000 Received: from mail-japanwestazlp170100003.outbound.protection.outlook.com ([2a01:111:f403:c407::3] helo=OS0P286CU011.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x3yvl-00000009iRT-09KL for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2026 16:44:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L1eUFVUdiGAJ8XcPfzRxOk5is4lSlAMP8Aytdp2yvafPiz4HHnO/68sAjbTGCkr5PF6AqOLbOYMrScJsBbQNciNoIwC9xHIeMwiIxGKt2vg8WBYaVcaAKWY3AKfAX6O+A33gkhlK9E7t3EZ4GxDS050tXF6vcfXepcapAkz6Qz7naZNx28keVupmizxIcAgdohgZss8oiTzo0ooEk8MROaxz8FXet0saUx+suG316zhITxInZ6aMzaRqPM24Kxjsd4VV7V20JNQ1tmXVbTVP/KheMoRk9T4zd6u4r/RwFIZ4I+dUJ4FMV1YbQGtbIHdWOGqw+S5eGy3V6+iQa1aL/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gWAD8qw5BaN/waNwxRr5RIrv8DsM0KLGkweaYwneCbg=; b=aYoBTJCJdx2XDgpYRgzmvFgqQJ3MGqNi1a8AqwZYgpiszIq2uwWjTx/oSfARWyO//u5QpeWaL9kWFWaF+9P2bKsK7ON/irRQaA9telF7t4qnLu1ciz1rx8eStFDMkRGHZrEqIfoOmRqDkBWZpN6DYBLbWNFVscwiBTCgzvCC0gFelecCH+O/BroH0PcYT5K4nmdbfMkZS0JdLi+inK1faXPuZN488AuZUO8i34EQAz540JTNUC8SAmzRm1GCWBTwWL6ThHSg7rCe05UpjmqoJT3zoMbJPyRVy2PD6/E8Zzom/lNWXyCnPqLeHQGjOOXue8eQV5Fq+pFg+MwxZ3abgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 8.62.32.50) smtp.rcpttodomain=bootlin.com smtp.mailfrom=renesas.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=renesas.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gWAD8qw5BaN/waNwxRr5RIrv8DsM0KLGkweaYwneCbg=; b=Zr8YpSSkZ33tj/BERxtY/LG7zVR6uhHO+zmQNXj5D8XUzxhaIZ9w354eGpiZGmY//72c9nnOqYbdbKVxektuGeEAcUiRJipsoY9PpAShhn+ZhchQfP1ECS+2FFalYh8gArfL9KPiU21NP0xi2OLA3pyry+aMYqPfn91f2R6kgfo= Received: from TYCP301CA0063.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:7d::8) by OS7PR01MB17560.jpnprd01.prod.outlook.com (2603:1096:604:443::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.6; Tue, 8 Sep 2026 16:44:16 +0000 Received: from TY2PEPF00005622.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:7d:cafe::8d) by TYCP301CA0063.outlook.office365.com (2603:1096:405:7d::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.7 via Frontend Transport; Tue, 8 Sep 2026 16:44:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 8.62.32.50) smtp.mailfrom=renesas.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=renesas.com; Received-SPF: Pass (protection.outlook.com: domain of renesas.com designates 8.62.32.50 as permitted sender) receiver=protection.outlook.com; client-ip=8.62.32.50; helo=ejcrelay005p.adwin.renesas.com; pr=E Received: from ejcrelay005p.adwin.renesas.com (8.62.32.50) by TY2PEPF00005622.mail.protection.outlook.com (10.167.240.53) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.5 via Frontend Transport; Tue, 8 Sep 2026 16:44:15 +0000 Received: from vm01.adwin.renesas.com (DEU-5CG20946WF.adwin.renesas.com [10.226.92.55]) by ejcrelay005p.adwin.renesas.com (Postfix) with ESMTP id B178B30001C0; Wed, 9 Sep 2026 01:44:09 +0900 (JST) From: Ovidiu Panait To: maxime.chevallier@bootlin.com, recv.jo@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, shuah@kernel.org, joabreu@synopsys.com, yi.fang.gan@intel.com, jun.ann.lai@intel.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Ovidiu Panait Subject: [PATCH net v4 6/7] selftests: drv-net: Move _set_ethtool_feat() into lib Date: Tue, 8 Sep 2026 16:43:08 +0000 Message-ID: <20260908164309.59282-7-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260908164309.59282-1-ovidiu.panait.rb@renesas.com> References: <20260908164309.59282-1-ovidiu.panait.rb@renesas.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY2PEPF00005622:EE_|OS7PR01MB17560:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 832820ef-ad43-443c-3b56-08df0dc86b52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|23010399003|36860700016|82310400026|921020|6133799003|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: WXQwnaIArYSnWPaUGzZuTDsmzoCf05kh2zDFj9WRlhzAYnDtOLvtM+AurXP7mc9kU4L//tJGmMDFv71Ny8nAo4F1lsdlc85Z3fS3sPui04QYJeUDoZNE89CKpb+BiuTeDO6QCErzzdKgAsdPpSp+8q79vtbFjWn1yUXF1ogqcSqUSMQzSEBSkGa/YAXX7APILCU4ENSvotTS9Xq8IO/DVyxX9hyThE3+LvcsZuQKYP3s4WV5O9SM0tRot86cltstu4iyBbtoxVOZhw5FQlX6hKdYI2gFwr+H9t1uFqRtJZVQ1fFEE6f9KH13WeMthlUlF/gp/ShbecgBZRJ1kdTMXsNGxkWr6dd2m3DngUwj3KryjqdHxPITsHSC6IJ76QmSEVlO8jMzQglwKFw3CC3Z0jucD0AIFptTVwNRCXFlADu8jdpJ0UVbVW/K9Ak55fqbMk+LlTL9z2QOO0OIWaiGdpAsCKVQuW7ZE9HIkvEXvGtyvtfQr0yZLCAJhqV/3OGK7nvMIkyUncGH6De1htqfcRMgaf2Bnk/diS5IZh/GrYnksxlay+IUnZ8aXQI3TQoSXDbVICHcqOFHGdnJJ6qklZd28z0kevVT4rSIOxJUYNPi+8lTQ9oz/dJJY9Q49nom7ilr7athuxIeCFq01aW3OdS6yeDrN2M+8NVeP7w6F6d3PQvnFe6xJEjt9wqs//cMzsd7DChmoSRhosvyX3PBhHFcwOI1nsfzPF0WsVqOffS2YDgnHjPH69vx8VEtxYyO X-Forefront-Antispam-Report: CIP:8.62.32.50;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:ejcrelay005p.adwin.renesas.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(23010399003)(36860700016)(82310400026)(921020)(6133799003)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fDanfeSoWNgSSnsrVvigQ0+HlGiugkeAW2jG4CR/CdkXDAre/T1z/dtjIgK42VeJLUPtKmMQ7Sy7sN/Wa51XrmNf+Qi+dial5eVZr1/26erDWFFYNbYhHI55fPkKMKz8kAgRj+c7ceo1VttabZY2aryrzSawmgPbCFsr8S6n6GAM8R1LRnNHEO0XdDz6Gi7pgW0vgjCKCVR/NieN38HrL5ZNj0TdgOWSA1oF83ZEMobr/7TpwIx3ht/nBceRfvNLPX2yIZqNeBHiHDWF9yUEvfB8Kv4PS5o18KvZjmMnBWYPMr9hnPMYo115FGlZ6FdCXd7jGHLgkGD4Ozj5BNoB1eeFhNCdHHs28jnBhA/2yCLV0FYOzKknVqXaHeE1x/dSByM2BoEZOTEoMdIi3jiknd7tahL3R5wHukfAWXjCqF6fvLkkZSHPb0W4JBB4D3Wp X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2026 16:44:15.4572 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 832820ef-ad43-443c-3b56-08df0dc86b52 X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=53d82571-da19-47e4-9cb4-625a166a4a2a;Ip=[8.62.32.50];Helo=[ejcrelay005p.adwin.renesas.com] X-MS-Exchange-CrossTenant-AuthSource: TY2PEPF00005622.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS7PR01MB17560 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260908_094422_680172_7869F500 X-CRM114-Status: GOOD ( 16.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move the _set_ethtool_feat() helper from gro.py into lib, so that it can be reused by the VLAN test added in the next commit. Drop the leading underscore, now that the helper is exported. Signed-off-by: Ovidiu Panait --- v4 changes: None. v3 changes: - Fixed "ruff check" and "pylint --disable=R" warnings reported for tools/testing/selftests/drivers/net/lib/py/feat.py. v2 changes: - New patch. tools/testing/selftests/drivers/net/gro.py | 65 ++++++------------- .../drivers/net/hw/lib/py/__init__.py | 3 +- .../selftests/drivers/net/lib/py/__init__.py | 3 +- .../selftests/drivers/net/lib/py/feat.py | 35 ++++++++++ 4 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/lib/py/feat.py diff --git a/tools/testing/selftests/drivers/net/gro.py b/tools/testing/selftests/drivers/net/gro.py index 6ab8c97880d1..051a3b2d0ead 100755 --- a/tools/testing/selftests/drivers/net/gro.py +++ b/tools/testing/selftests/drivers/net/gro.py @@ -42,7 +42,7 @@ import re from lib.py import ksft_run, ksft_exit, ksft_pr from lib.py import NetDrvEpEnv, KsftFailEx, KsftXfailEx from lib.py import NetdevFamily, EthtoolFamily -from lib.py import bkg, cmd, defer, ethtool, ip +from lib.py import bkg, cmd, defer, ethtool, ip, set_ethtool_feat from lib.py import ksft_variants, KsftNamedVariant @@ -96,31 +96,6 @@ def _set_mtu_restore(dev, mtu, host): defer(ip, f"link set dev {dev['ifname']} mtu {dev['mtu']}", host=host) -def _set_ethtool_feat(dev, current, feats, host=None): - s2n = {True: "on", False: "off"} - - new = ["-K", dev] - old = ["-K", dev] - no_change = True - for name, state in feats.items(): - new += [name, s2n[state]] - old += [name, s2n[current[name]["active"]]] - - if current[name]["active"] != state: - no_change = False - if current[name]["fixed"]: - raise KsftXfailEx(f"Device does not support {name}") - if no_change: - return - - eth_cmd = ethtool(" ".join(new), host=host) - defer(ethtool, " ".join(old), host=host) - - # If ethtool printed something kernel must have modified some features - if eth_cmd.stdout: - ksft_pr(eth_cmd) - - def _get_queue_stats(cfg, queue_id): """Get stats for a specific Rx queue.""" cfg.wait_hw_stats_settle() @@ -247,15 +222,15 @@ def _setup(cfg, mode, test_name): _write_defer_restore(cfg, flush_path, "200000", defer_undo=True) _write_defer_restore(cfg, irq_path, "10", defer_undo=True) - _set_ethtool_feat(cfg.ifname, cfg.feat, - {"generic-receive-offload": True, - "rx-gro-hw": False, - "large-receive-offload": False}) + set_ethtool_feat(cfg.ifname, cfg.feat, + {"generic-receive-offload": True, + "rx-gro-hw": False, + "large-receive-offload": False}) elif mode == "hw": - _set_ethtool_feat(cfg.ifname, cfg.feat, - {"generic-receive-offload": False, - "rx-gro-hw": True, - "large-receive-offload": False}) + set_ethtool_feat(cfg.ifname, cfg.feat, + {"generic-receive-offload": False, + "rx-gro-hw": True, + "large-receive-offload": False}) # Some NICs treat HW GRO as a GRO sub-feature so disabling GRO # will also clear HW GRO. Use a hack of installing XDP generic @@ -270,27 +245,27 @@ def _setup(cfg, mode, test_name): # Attaching XDP may change features, fetch the latest state feat = ethtool(f"-k {cfg.ifname}", json=True)[0] - _set_ethtool_feat(cfg.ifname, feat, - {"generic-receive-offload": True, - "rx-gro-hw": True, - "large-receive-offload": False}) + set_ethtool_feat(cfg.ifname, feat, + {"generic-receive-offload": True, + "rx-gro-hw": True, + "large-receive-offload": False}) elif mode == "lro": # netdevsim advertises LRO for feature inheritance testing with # bonding/team tests but it doesn't actually perform the offload cfg.require_nsim(nsim_test=False) - _set_ethtool_feat(cfg.ifname, cfg.feat, - {"generic-receive-offload": False, - "rx-gro-hw": False, - "large-receive-offload": True}) + set_ethtool_feat(cfg.ifname, cfg.feat, + {"generic-receive-offload": False, + "rx-gro-hw": False, + "large-receive-offload": True}) try: # Disable TSO for local tests cfg.require_nsim() # will raise KsftXfailEx if not running on nsim - _set_ethtool_feat(cfg.remote_ifname, cfg.remote_feat, - {"tcp-segmentation-offload": False}, - host=cfg.remote) + set_ethtool_feat(cfg.remote_ifname, cfg.remote_feat, + {"tcp-segmentation-offload": False}, + host=cfg.remote) except KsftXfailEx: pass diff --git a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py index 8a58cb17cc06..eea45d01cf7b 100644 --- a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +++ b/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py @@ -31,6 +31,7 @@ try: ksft_setup, ksft_variants, KsftNamedVariant from net.lib.py import ksft_eq, ksft_ge, ksft_in, ksft_is, ksft_lt, \ ksft_ne, ksft_not_in, ksft_raises, ksft_true, ksft_gt, ksft_not_none + from drivers.net.lib.py import set_ethtool_feat from drivers.net.lib.py import GenerateTraffic, Remote, Iperf3Runner from drivers.net.lib.py import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv @@ -49,7 +50,7 @@ try: "ksft_ne", "ksft_not_in", "ksft_raises", "ksft_true", "ksft_gt", "ksft_not_none", "ksft_not_none", "NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", - "Remote", "Iperf3Runner"] + "Remote", "Iperf3Runner", "set_ethtool_feat"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources") print(str(e)) diff --git a/tools/testing/selftests/drivers/net/lib/py/__init__.py b/tools/testing/selftests/drivers/net/lib/py/__init__.py index ee903bcf3207..c261aac2b976 100644 --- a/tools/testing/selftests/drivers/net/lib/py/__init__.py +++ b/tools/testing/selftests/drivers/net/lib/py/__init__.py @@ -48,11 +48,12 @@ try: "ksft_not_none", "ksft_not_none"] from .env import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv + from .feat import set_ethtool_feat from .load import GenerateTraffic, Iperf3Runner from .remote import Remote __all__ += ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTraffic", - "Remote", "Iperf3Runner"] + "Remote", "Iperf3Runner", "set_ethtool_feat"] except ModuleNotFoundError as e: print("Failed importing `net` library from kernel sources") print(str(e)) diff --git a/tools/testing/selftests/drivers/net/lib/py/feat.py b/tools/testing/selftests/drivers/net/lib/py/feat.py new file mode 100644 index 000000000000..014971c82b4b --- /dev/null +++ b/tools/testing/selftests/drivers/net/lib/py/feat.py @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-2.0 + +""" +Netdev feature helper utilities for kernel selftests. + +Provides common operations for changing device features via ethtool. +""" + +from lib.py import KsftXfailEx, defer, ethtool, ksft_pr + + +def set_ethtool_feat(dev, current, feats, host=None): + """Set ethtool features with defer to restore original state.""" + s2n = {True: "on", False: "off"} + + new = ["-K", dev] + old = ["-K", dev] + no_change = True + for name, state in feats.items(): + new += [name, s2n[state]] + old += [name, s2n[current[name]["active"]]] + + if current[name]["active"] != state: + no_change = False + if current[name]["fixed"]: + raise KsftXfailEx(f"Device does not support {name}") + if no_change: + return + + eth_cmd = ethtool(" ".join(new), host=host) + defer(ethtool, " ".join(old), host=host) + + # If ethtool printed something kernel must have modified some features + if eth_cmd.stdout: + ksft_pr(eth_cmd) -- 2.34.1