From nobody Fri Sep 25 11:08:00 2026 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010011.outbound.protection.outlook.com [52.101.229.11]) (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 16C573F4105; Sun, 13 Sep 2026 14:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789310416; cv=fail; b=IbjNLf4KpoZQTTv3xzKLF+T5mUJ98gur6A3hMdqKEdXLKf/c0URRHcZPdf52BlzsFY0bVw2cm9Xgr/frYdGGnevWijWtUxZURNz50BcJKTXWblb7hJpB5ULVCsotuFpeWYvETkBfsF43qoJBT5n8KiElKJuioPKTiK6JlNZIPsI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789310416; c=relaxed/simple; bh=7zlnCGu34tNz939RA5SikChEg4jPdtPa8cCIk21j340=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=exg575TUdgLH2Zf6T07HydZTFHS1S5ur2F2+VIqb17wngLogBbYX7NCPS2EFc/PKL0V1RrdbkOGuaGeXpk8Ig6fzDCWGyPnQf/2ZWH49n1mJ7YHdKPEblePirfl8+Fr1pCze2HoJEJKHTsC99qAcM3TTdfhN5RUp32B+ecKbWhE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b=n6ib19JV; arc=fail smtp.client-ip=52.101.229.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="n6ib19JV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ljp6rJmflXYJlp2p6e4F1E1G0V6Hnm5Ler/UrhBX4LAZP6CNF5mLlvgHxXvA8uAt4s0JuAzNZs1qYQ8Ex4kzTNparXxsRN+0xwGclU8+fqToYuoJ5FV9VMg2Ig6tCQAAMPM2muKB7z+b4CDiKxi42NjFgCRTQsWmotUry/kfy/X2GnBlUm08008RrkuQAatV6DoZR4H05wyG7i9OMspsMi8Vv8nHHWQ1c2zQ9AfIrFsb/bhgTTkghA/loYlTTuRdqXkSX8rmWuciPmU3/MMedGs83sjDP+76dI1pExXkdP/baL1z3sQ+r3skZRL80nz8Ub0V4sAd/4xLcZoHTCxHCA== 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=mOAbmkf5F5WHTinnD7OcK9ffEHYi1r2F55pKGAX7YTU=; b=b/pqP/w11XQgNvnAcaCN98fcH0adqENUaKT6t53Ww/8eP5pPYJ/JO6wKRjGCtnPgh5UaducjRVLwVrwRov4C25CNW5nmtntqoAniKhkse64ZE/RpBT9iPoWtznWsnR/ls/OwGJFkNk2PHZYCZDO9P6QDl1Oo35+Wk9SF8yj2Jh64479uq44KFeq/Mbn/1fNjnmu2VdAl/ra8WG9/ANiQMkkmD2rQEuWwlqfbfdlwgTpL6jwkfKg8+qcEpXhI2vc0gZRvHPlxJihlIPPDUquMxy6RE74Q/jjBjKVFgy0JuW9lu8lK/J6q1eNAmio6hgepZdeXUDi4ssJnlTQgNdFFEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 8.62.32.50) smtp.rcpttodomain=davemloft.net 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=mOAbmkf5F5WHTinnD7OcK9ffEHYi1r2F55pKGAX7YTU=; b=n6ib19JVSZ7ApG+yH26CvtvT0cyYYyRXbN9blLXSQt1kPIq5g50exv5SaItqNYytLN+Wj8D+NAkhtzcjFhNU0x2lApwTX5OPbk4irD2rFNiLZoWgabp8SFpVfgqVUR/nijyF63vMqGjCGwsoD37r8WiwYDWlD/kw6GKUa3YHXt8= Received: from TYWPR01CA0028.jpnprd01.prod.outlook.com (2603:1096:400:aa::15) by OSCPR01MB13441.jpnprd01.prod.outlook.com (2603:1096:604:334::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Sun, 13 Sep 2026 14:40:09 +0000 Received: from TY2PEPF00005624.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:aa:cafe::2b) by TYWPR01CA0028.outlook.office365.com (2603:1096:400:aa::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.10 via Frontend Transport; Sun, 13 Sep 2026 14:40:09 +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 TY2PEPF00005624.mail.protection.outlook.com (10.167.240.55) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.7 via Frontend Transport; Sun, 13 Sep 2026 14:40:08 +0000 Received: from vm01.adwin.renesas.com (DEU-5CG20946WF.adwin.renesas.com [10.226.92.2]) by ejcrelay005p.adwin.renesas.com (Postfix) with ESMTP id 00176300024A; Sun, 13 Sep 2026 23:40:04 +0900 (JST) From: Ovidiu Panait To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Ovidiu Panait Subject: [PATCH net-next 1/2] selftests: drv-net: Move _set_ethtool_feat() into lib Date: Sun, 13 Sep 2026 14:39:25 +0000 Message-ID: <20260913143926.77366-2-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260913143926.77366-1-ovidiu.panait.rb@renesas.com> References: <20260913143926.77366-1-ovidiu.panait.rb@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY2PEPF00005624:EE_|OSCPR01MB13441:EE_ X-MS-Office365-Filtering-Correlation-Id: 92b8ac7d-491a-43b6-948c-08df11a4e871 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|23010399003|376014|36860700016|10067099003|6133799003|22082099003|18002099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: MynKTE6zddyUINgXcSExvU08w7zuUC2Wk/toBAqFE3yuxSe6q0+oP8/w6Imq4nmyHjNiF7i2VWnluam+nAC54clvNerIDRMktQs26nWUjs/HhwzsHbX6IQ2OMboZvsEmhc4udIFqcMvQRrNVG8VWMcg/j/+v2Lk1wKt7FDq4gzgtzyafkuPnVVMdwmto7+GIIcpPRNwkkFeVRwEsvi7oInrCEtkN7LQ9dDKBnyQZosmUbDHL8oS2I/d6b8q87vd+TKTAE9v2hcMiLbaZcH35yh8BZyuLxMDynT9HONflw4LvfvJhrMGMcCvS8oXMde0mjhfhlTAX00vV89VTeLVujlfLcjAynD17TRX6ncd61wUYVYvtLXL5tmFZXSb0HfJ7Rkaoh1/Bl7eFoOWudomkde+8bqGORXC+CP/OuMOnbwW1agIaHuta22hQUnK1roUhg52IY1O2pR6K/tsGkoUZHA+pr40rZ4EPvaP9B+gHyzSdl5FTYnGG1JpwsSTogUQNxMSZKe/M4Ph2SyYB+MtKnP/fIGK8oeUyijSxx00ViVbJ3bwG2l38dk500U+1Hnbhr/yaag5fzNLhVIsd4K+nZFMyqlzmHuB/nfgQPsrnUyHwd54zR20U65673lRWIY6Q3+hxC+IBbjpFlOGc8A2asXbOG7rSoUnAD3BymlOFnkDArEEQfEPl1D1lnynH4AIqL1mJ6hPNn6tz2bt5IHmk3Q== 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)(82310400026)(1800799024)(23010399003)(376014)(36860700016)(10067099003)(6133799003)(22082099003)(18002099003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a6b40EmqOXo6xiFBTTVNGahGQoiWijwhVf5Nx+MajSXFjrg2CsDCElyWrMVzKMYUdLtYdpvxYgm3z8d+6fZuy30bGdRRuDXGyfRl5tTukM/yrSBTPNCdi1fgfv6WlgY1YojOy2NEk8AqNDyxrUvsqeiAFLqaCbNAPRZ8bauLLmUXrt6OzkpHJaX1DtkHonjBUAXWVjC9zhXYcq9AfdzXGD64jnGJidQ742+SWybzNvEGkUcmqaVYtFTg2AL941jWixaXgAjhiFUP4F1aDAuAiGIZpaTI11b4V/bNooD8wbtrhE8agz0YwNBrJGZR3g18NSBjCpLJtBSdDhz+4JpIuKwSsAgEdoi01Jh8ED5bVVhVtI59tMuBt1o7rrUxRJIq73D8+ujBMPU6FxjxHgwmQoGySoU8xtIhZrotNbiCu4n1fYnp3DUlhqU5y3pNboSn X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2026 14:40:08.1471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 92b8ac7d-491a-43b6-948c-08df11a4e871 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: TY2PEPF00005624.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSCPR01MB13441 Content-Type: text/plain; charset="utf-8" Move the _set_ethtool_feat() helper from gro_lib.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 Reviewed-by: Nicolai Buchwitz --- .../testing/selftests/drivers/net/gro_lib.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_lib.py b/tools/testing= /selftests/drivers/net/gro_lib.py index b7ac0660adc0..e9d373cf3483 100644 --- a/tools/testing/selftests/drivers/net/gro_lib.py +++ b/tools/testing/selftests/drivers/net/gro_lib.py @@ -48,7 +48,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, ctl_file_write, defer, ethtool, ip +from lib.py import bkg, cmd, ctl_file_write, defer, ethtool, ip, set_ethto= ol_feat from lib.py import ksft_variants, KsftNamedVariant =20 =20 @@ -91,31 +91,6 @@ def _set_mtu_restore(dev, mtu, host): defer(ip, f"link set dev {dev['ifname']} mtu {dev['mtu']}", host= =3Dhost) =20 =20 -def _set_ethtool_feat(dev, current, feats, host=3DNone): - s2n =3D {True: "on", False: "off"} - - new =3D ["-K", dev] - old =3D ["-K", dev] - no_change =3D True - for name, state in feats.items(): - new +=3D [name, s2n[state]] - old +=3D [name, s2n[current[name]["active"]]] - - if current[name]["active"] !=3D state: - no_change =3D False - if current[name]["fixed"]: - raise KsftXfailEx(f"Device does not support {name}") - if no_change: - return - - eth_cmd =3D ethtool(" ".join(new), host=3Dhost) - defer(ethtool, " ".join(old), host=3Dhost) - - # 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() @@ -242,15 +217,15 @@ def _setup(cfg, mode, test_name): ctl_file_write(flush_path, "200000") ctl_file_write(irq_path, "10") =20 - _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 =3D=3D "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}) =20 # 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 @@ -265,27 +240,27 @@ def _setup(cfg, mode, test_name): # Attaching XDP may change features, fetch the latest state feat =3D ethtool(f"-k {cfg.ifname}", json=3DTrue)[0] =20 - _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 =3D=3D "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=3DFalse) =20 - _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}) =20 try: # Disable TSO for local tests cfg.require_nsim() # will raise KsftXfailEx if not running on nsim =20 - _set_ethtool_feat(cfg.remote_ifname, cfg.remote_feat, - {"tcp-segmentation-offload": False}, - host=3Dcfg.remote) + set_ethtool_feat(cfg.remote_ifname, cfg.remote_feat, + {"tcp-segmentation-offload": False}, + host=3Dcfg.remote) except KsftXfailEx: pass =20 diff --git a/tools/testing/selftests/drivers/net/hw/lib/py/__init__.py b/to= ols/testing/selftests/drivers/net/hw/lib/py/__init__.py index 81e1d1865cd5..4077f5f1a1be 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_no= ne + 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 =20 @@ -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", "GenerateTraff= ic", - "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 591b1e6c7eea..40ccdcf0c378 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"] =20 from .env import NetDrvEnv, NetDrvEpEnv, NetDrvContEnv + from .feat import set_ethtool_feat from .load import GenerateTraffic, Iperf3Runner from .remote import Remote =20 __all__ +=3D ["NetDrvEnv", "NetDrvEpEnv", "NetDrvContEnv", "GenerateTr= affic", - "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/tes= ting/selftests/drivers/net/lib/py/feat.py new file mode 100644 index 000000000000..b94a24214e59 --- /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 . import KsftXfailEx, defer, ethtool, ksft_pr + + +def set_ethtool_feat(dev, current, feats, host=3DNone): + """Set ethtool features with defer to restore original state.""" + s2n =3D {True: "on", False: "off"} + + new =3D ["-K", dev] + old =3D ["-K", dev] + no_change =3D True + for name, state in feats.items(): + new +=3D [name, s2n[state]] + old +=3D [name, s2n[current[name]["active"]]] + + if current[name]["active"] !=3D state: + no_change =3D False + if current[name]["fixed"]: + raise KsftXfailEx(f"Device does not support {name}") + if no_change: + return + + eth_cmd =3D ethtool(" ".join(new), host=3Dhost) + defer(ethtool, " ".join(old), host=3Dhost) + + # If ethtool printed something kernel must have modified some features + if eth_cmd.stdout: + ksft_pr(eth_cmd) --=20 2.34.1 From nobody Fri Sep 25 11:08:00 2026 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010044.outbound.protection.outlook.com [52.101.229.44]) (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 EB36E3F326F; Sun, 13 Sep 2026 14:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789310427; cv=fail; b=CYimQy/pbpBxJd8fLj/rLnuqJoXwBQ65VVFNAOPhzHyzWQbWhXvEhJAaAO6/Abs/pWPHZVfAINnW3tAKos4a0U5JG+JyKS476rpb1+N1ZZPMMz9aiB+n8NgYUlllryq5yjWPep9ENLwHuYF670b+YDrj58x3OSkKY2J/YQPgl+k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789310427; c=relaxed/simple; bh=5FGdyIKQ6AaPlZiG7BcadSmKzqCM/sSOjNnP/kz1Lhc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AU3HDQmZvfASLeWAmPtczUvQNtiP5yIkI5/Z0R8q+/h66AE1UqjCu2ZveWEO1ssE5pnGv8enHhAHDYW1yDOg1or2nA3g1kXtDZ7Kt+pAlv7treo3Oy2/M18IrtNxiK5Da48/kipavL3Kjubx6+hxNvpI3hO9Pn86m11kTsVaS8g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b=dk9U8Xt6; arc=fail smtp.client-ip=52.101.229.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="dk9U8Xt6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fcoPyezXpSbgN0taR+AeOOqB72VWQ2PdXyXVCaTjJHVX/vK1eggzc3GemMY2WOC76mJ9nCNOve18hWO8eHqmyb5A+1iv9xpGb1CgjukHOOJLF7ncjFG11frmYxotEAqcndaV9M60eF1V7xPouaGh/Bm/37cF4m4ZBlJg+3Zj5r86e1w3iMp9FNsrf3KliVm10/HTQO0RZVdulz/sj4wjGyGFN3kegMFATZy/G5SlNCPWDZyjE/fmmDFsU6F8KuG632shT/xmW6EPDEWIsaEldSfBgbqVTGuC6Ni3O/xF8eTaWAwkSNclOtQdxnj+ITG0iQBUm4dvDvxlrJWMTLzaHQ== 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=uiHXHpfATgxDU/U9he/NwvDDsl2A+iJIaNORErOV3wY=; b=w5sMUWOSVg6JzUk56s1NY06mqsW4ltojh3hYwvHG1oERNSIiJxuAS1R+cXYuvD6oPuoae6y4XqM/hvlVX504cYXx0UIDROqcNxGSwzdcObpl4wtIgU30Ocq8nnM5OuTPFgQQzYsHpcGP15Zr1/kLKFY7YxnjjgUaRPdk+B5upNHPJXQhUGSpJ4lETMXw6b5TC09Ai3heygMIgozTSVouObYhd3H6wNbMk5GB3wtzLssgtiHiry0tZ5JmMqI40IH400J1x82x6Dh0sf6/Px6BDCsAqY2Ge9rCbrOpyjlInobZlLjDhsOh1mlb6fKPif+/BP4GKtXcDyHqMWtl+csJoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 8.62.32.50) smtp.rcpttodomain=davemloft.net 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=uiHXHpfATgxDU/U9he/NwvDDsl2A+iJIaNORErOV3wY=; b=dk9U8Xt6BcIuSLi2IhuEchc/ZxuKKL1kOCYQfbJfze1evIzm/1com6+9PqhqzGhF+OgT2LMGDENlCjd5kjIjNJpiIW6Kf+1QmPNkIG5jp7gKduuwyK/L3owG7/xXREsrn6hPgOk7xwXwrc+k4tdRMA9kFqzcHPLRH/REcKqd064= Received: from TYWPR01CA0026.jpnprd01.prod.outlook.com (2603:1096:400:aa::13) by OS7PR01MB13687.jpnprd01.prod.outlook.com (2603:1096:604:35b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.406.12; Sun, 13 Sep 2026 14:40:12 +0000 Received: from TY2PEPF00005624.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:aa:cafe::2d) by TYWPR01CA0026.outlook.office365.com (2603:1096:400:aa::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.7 via Frontend Transport; Sun, 13 Sep 2026 14:40:12 +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 TY2PEPF00005624.mail.protection.outlook.com (10.167.240.55) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.7 via Frontend Transport; Sun, 13 Sep 2026 14:40:11 +0000 Received: from vm01.adwin.renesas.com (DEU-5CG20946WF.adwin.renesas.com [10.226.92.2]) by ejcrelay005p.adwin.renesas.com (Postfix) with ESMTP id 9C207300024B; Sun, 13 Sep 2026 23:40:08 +0900 (JST) From: Ovidiu Panait To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Ovidiu Panait Subject: [PATCH net-next 2/2] selftests: drv-net: Add VLAN test Date: Sun, 13 Sep 2026 14:39:26 +0000 Message-ID: <20260913143926.77366-3-ovidiu.panait.rb@renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260913143926.77366-1-ovidiu.panait.rb@renesas.com> References: <20260913143926.77366-1-ovidiu.panait.rb@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY2PEPF00005624:EE_|OS7PR01MB13687:EE_ X-MS-Office365-Filtering-Correlation-Id: e65ef164-4649-40c7-243f-08df11a4ea99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|23010399003|376014|36860700016|10067099003|6133799003|3023799007|18002099003|22082099003|56012099006|11063799006; X-Microsoft-Antispam-Message-Info: 9rGuPQAuMQVRoUTtyQYsYEx7w0JzeDorexo7WryOARMVJH7F+RIvbGgLahq1xsB+Unke0G80h6KW/DiMg95hwz9TUQvV5oDJ9rok5oxIq4pBRqHExLEqhW3bD2LFpT+YmQ/QQXsXvMIk5TyLG7EP+Tq2O0PlNDdPTj24WsxSpbB40jpe4Wyt0yiMNAHC9pKu701Pc8enHnvoUKJciQ68xkTjNQqkiHh4t59WYvzyGTbZh69AaQSo6ovT8ceqjKX1T0LEyM66LTdUWc1mu8kSdbU8FhKhUQjuzsjV15ZUiShzFKFoOTrYrSAcCFpdSEpjJf6iYc1nVtudmIHf+VNzcnlQ4VICwNEk3giQHj5IJ63mGMuK7CT99+NsM5w/tSTlfIkU2iSKVMlblime4UeoRZxABGbbIGQTx1EuDj1DQlMJDst+zbpySdsf6pgqhQl8dO4F4VDSe7dz5rjq6MiZI9CMtkaO52cZLQiGV0AB+Q/8QiVj0SYYqAINeHfAtRcbS2+PY28i5sbiEUorKAr86lfXhVZ6lSNv8TQ1mj00wtxx/S/syAHGJk5UIZBxkSt7pzWNC6LFbzgchwPlk5XrsdnizesAzzDkEnYoPITnPVo1s5jPf0x1cT/UIZ1wdW8on3ol1Nd/PBVcFgFDeALvvoXIVZbSaRgGsUHlYDovSmXmc6AzpdHHwPj8KVDn6aem6rWkoM+M+lpBnI1TD50/rA== 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)(82310400026)(1800799024)(23010399003)(376014)(36860700016)(10067099003)(6133799003)(3023799007)(18002099003)(22082099003)(56012099006)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nXOjwqJaO+AHH84G1eNO/3Ma39cs01ZmFy36apXWoePHXrpJd6R5C8QjXYI1jwbUQFO1FexTI39D8F6MGN8VbpELor+KUIXL5J9d7+avLNEw2rfeH3KslRtECWcOpbjPIEZ+OKedlHNrwRscLkSGF/mNxPznz4YwuzNoGD0yq/R4yA8wSQ1SgOSs4+2VuLRYpfLs6CVUjQ6hh/pxtSp+HznyhYqwuNJMPGcn6QvypGIOcyZuwPShBH+o7zfiTL115hxHukelARGF02LUuR6gO4P4TLD3RLKvlc2xDlMvOTC3TSGkImNrK9fPFoDBYYJdAcfGgCmJ7iS6KlDdvYEFbE6B0ylw/bjvYhTmsoQgx+1eNt2ORpOciD6CfTcRU12VtGW+Ey23p/D7nNEE8ScPlyPvDkzAdD6REhASnVqTROKC+IJBeWAv5w3e9OJZunyl X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2026 14:40:11.7608 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e65ef164-4649-40c7-243f-08df11a4ea99 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: TY2PEPF00005624.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS7PR01MB13687 Content-Type: text/plain; charset="utf-8" Add a test that validates ping traffic over VLAN interfaces. It aims to catch drivers which mishandle hardware VLAN tag stripping, in particular QinQ. Three VLAN configurations are covered, each with hardware RX VLAN stripping enabled and disabled (via the rx-vlan-offload and rx-vlan-stag-hw-parse features): - a single 802.1q VLAN interface - a single 802.1ad VLAN interface - an 802.1q VLAN stacked on top of an 802.1ad interface The "hw" test variants enable the RX VLAN stripping features supported by the device (rx-vlan-offload and rx-vlan-stag-hw-parse), the "sw" test variants disable all of them. A test is xfailed if the requested configuration is not possible. VLAN insertion offloads are not tested for now. NETIF=3Dend0 LOCAL_V4=3D172.16.0.2 REMOTE_V4=3D172.16.0.3 \ REMOTE_TYPE=3Dssh REMOTE_ARGS=3Droot@172.16.0.3 \ run_kselftest.sh -t drivers/net/hw:vlan.py TAP version 13 1..1 # timeout set to 0 # selftests: drivers/net/hw: vlan.py # # Interface: end0, driver: st_gmac # TAP version 13 # 1..6 # ok 1 vlan.test.8021q_hw # ok 2 vlan.test.8021q_sw # ok 3 vlan.test.8021ad_hw # ok 4 vlan.test.8021ad_sw # ok 5 vlan.test.qinq_hw # ok 6 vlan.test.qinq_sw # # Totals: pass:6 fail:0 xfail:0 xpass:0 skip:0 error:0 ok 1 selftests: drivers/net/hw: vlan.py # Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0 Signed-off-by: Ovidiu Panait --- .../testing/selftests/drivers/net/hw/Makefile | 1 + tools/testing/selftests/drivers/net/hw/config | 1 + .../testing/selftests/drivers/net/hw/vlan.py | 127 ++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/hw/vlan.py diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testin= g/selftests/drivers/net/hw/Makefile index bd3b8d2fa47e..5582b644078e 100644 --- a/tools/testing/selftests/drivers/net/hw/Makefile +++ b/tools/testing/selftests/drivers/net/hw/Makefile @@ -54,6 +54,7 @@ TEST_PROGS =3D \ tso.py \ userns_devmem.py \ uso.py \ + vlan.py \ xdp_metadata.py \ xsk_reconfig.py \ # diff --git a/tools/testing/selftests/drivers/net/hw/config b/tools/testing/= selftests/drivers/net/hw/config index d89a9ba17655..c6c2b64bb712 100644 --- a/tools/testing/selftests/drivers/net/hw/config +++ b/tools/testing/selftests/drivers/net/hw/config @@ -24,5 +24,6 @@ CONFIG_NET_SCH_INGRESS=3Dy CONFIG_SYNC_FILE=3Dy CONFIG_UDMABUF=3Dy CONFIG_USER_NS=3Dy +CONFIG_VLAN_8021Q=3Dm CONFIG_VXLAN=3Dy CONFIG_XFRM_USER=3Dy diff --git a/tools/testing/selftests/drivers/net/hw/vlan.py b/tools/testing= /selftests/drivers/net/hw/vlan.py new file mode 100755 index 000000000000..f514ad3e5dfd --- /dev/null +++ b/tools/testing/selftests/drivers/net/hw/vlan.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 + +""" +VLAN tests. + +Validates that ping traffic is sent and received correctly over 802.1q +and 802.1ad VLAN interfaces, with hardware RX VLAN stripping enabled and +disabled on the local interface. + +The "hw" test variants enable the RX VLAN stripping features supported by +the device, the "sw" test variants disable all of them. A test is xfailed +if the requested configuration is not possible. + +Test cases: + - 8021q_hw: Traffic over a single 802.1q VLAN, HW stripping on + - 8021q_sw: Traffic over a single 802.1q VLAN, HW stripping off + - 8021ad_hw: Traffic over a single 802.1ad VLAN, HW stripping on + - 8021ad_sw: Traffic over a single 802.1ad VLAN, HW stripping off + - qinq_hw: Traffic over an 802.1q VLAN stacked on an 802.1ad VLAN, + HW stripping on + - qinq_sw: Traffic over an 802.1q VLAN stacked on an 802.1ad VLAN, + HW stripping off +""" + +import os + +from lib.py import ( + KsftNamedVariant, + KsftXfailEx, + NetDrvEpEnv, + cmd, + defer, + ethtool, + ip, + ksft_exit, + ksft_run, + ksft_variants, + set_ethtool_feat, +) + +OUTER_DEV =3D f"vlout{os.getpid()}" +INNER_DEV =3D f"vlin{os.getpid()}" + +OUTER_VID =3D 100 +INNER_VID =3D 200 + +LOCAL_IP =3D "198.51.100.1" +REMOTE_IP =3D "198.51.100.2" + + +def _vlan_add(base, name, proto, vid, host=3DNone): + """Create a VLAN device on top of base and bring it up.""" + + ip(f"link add link {base} name {name} type vlan proto {proto} id {vid}= ", + host=3Dhost) + defer(ip, f"link del {name}", host=3Dhost) + ip(f"link set {name} up", host=3Dhost) + + +def _vlan_setup(base, addr, outer_proto, inner_proto, host=3DNone): + """Create VLAN interfaces on base and set an IP on the innermost one."= "" + + _vlan_add(base, OUTER_DEV, outer_proto, OUTER_VID, host=3Dhost) + if inner_proto: + _vlan_add(OUTER_DEV, INNER_DEV, inner_proto, INNER_VID, host=3Dhos= t) + + dev =3D INNER_DEV if inner_proto else OUTER_DEV + ip(f"addr add {addr}/24 dev {dev}", host=3Dhost) + + +def _setup(cfg, outer_proto, inner_proto, hw_strip): + """Configure VLAN stripping and create the VLAN interfaces.""" + + names =3D ["rx-vlan-offload"] + if outer_proto =3D=3D "802.1ad": + names.append("rx-vlan-stag-hw-parse") + + feat =3D ethtool(f"-k {cfg.ifname}", json=3DTrue)[0] + feats =3D {} + for name in names: + # hw: skip the features the device does not support + # sw: request all of them off + if hw_strip and feat[name]["fixed"] and not feat[name]["active"]: + continue + feats[name] =3D hw_strip + + if hw_strip and not feats: + raise KsftXfailEx("Device does not support RX VLAN stripping") + + set_ethtool_feat(cfg.ifname, feat, feats) + + _vlan_setup(cfg.ifname, LOCAL_IP, outer_proto, inner_proto) + _vlan_setup(cfg.remote_ifname, REMOTE_IP, outer_proto, inner_proto, + host=3Dcfg.remote) + + +def _vlan_variants(): + """Generator that yields the VLAN protocols and the stripping mode.""" + + yield KsftNamedVariant("8021q_hw", "802.1q", None, True) + yield KsftNamedVariant("8021q_sw", "802.1q", None, False) + yield KsftNamedVariant("8021ad_hw", "802.1ad", None, True) + yield KsftNamedVariant("8021ad_sw", "802.1ad", None, False) + yield KsftNamedVariant("qinq_hw", "802.1ad", "802.1q", True) + yield KsftNamedVariant("qinq_sw", "802.1ad", "802.1q", False) + + +@ksft_variants(_vlan_variants()) +def test(cfg, outer_proto, inner_proto, hw_strip): + """Run a single VLAN test""" + + _setup(cfg, outer_proto, inner_proto, hw_strip) + + cmd(f"ping -c 1 -W 5 {REMOTE_IP}") + + +def main() -> None: + """ Ksft boiler plate main """ + + with NetDrvEpEnv(__file__) as cfg: + ksft_run(cases=3D[test], args=3D(cfg, )) + ksft_exit() + + +if __name__ =3D=3D "__main__": + main() --=20 2.34.1