From: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
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 <ovidiu.panait.rb@renesas.com>
Subject: [PATCH net v4 7/7] selftests: drv-net: Add VLAN test
Date: Tue, 8 Sep 2026 16:43:09 +0000 [thread overview]
Message-ID: <20260908164309.59282-8-ovidiu.panait.rb@renesas.com> (raw)
In-Reply-To: <20260908164309.59282-1-ovidiu.panait.rb@renesas.com>
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 test is xfailed when a specific feature cannot be changed.
VLAN insertion offloads are not tested for now.
NETIF=end1 LOCAL_V4=172.16.0.2 REMOTE_V4=172.16.0.3 \
REMOTE_TYPE=ssh REMOTE_ARGS=root@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: end1, 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 # XFAIL Device does not support rx-vlan-stag-hw-parse
# ok 4 vlan.test.8021ad_sw
# ok 5 vlan.test.qinq_hw # XFAIL Device does not support rx-vlan-stag-hw-parse
# ok 6 vlan.test.qinq_sw
# # Totals: pass:4 fail:0 xfail:2 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 <ovidiu.panait.rb@renesas.com>
---
v4 changes:
- Toggle rx-vlan-stag-hw-parse for the 802.1ad and QinQ variants.
- Updated the commit message and docstrings.
v3 changes:
- Moved the selftest to drivers/net/hw, as the _hw variants couldn't run
under netdevsim.
- Fixed "ruff check" and "pylint --disable=R" warnings.
- Added CONFIG_VLAN_8021Q=m to configs file.
v2 changes:
- New patch.
.../testing/selftests/drivers/net/hw/Makefile | 1 +
tools/testing/selftests/drivers/net/hw/config | 1 +
.../testing/selftests/drivers/net/hw/vlan.py | 112 ++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/hw/vlan.py
diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index 78bb0169350b..886a4222c6cf 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -49,6 +49,7 @@ TEST_PROGS = \
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=y
CONFIG_SYNC_FILE=y
CONFIG_UDMABUF=y
CONFIG_USER_NS=y
+CONFIG_VLAN_8021Q=m
CONFIG_VXLAN=y
CONFIG_XFRM_USER=y
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..61fa452b95bd
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/vlan.py
@@ -0,0 +1,112 @@
+#!/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.
+
+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,
+ NetDrvEpEnv,
+ cmd,
+ defer,
+ ethtool,
+ ip,
+ ksft_exit,
+ ksft_run,
+ ksft_variants,
+ set_ethtool_feat,
+)
+
+OUTER_DEV = f"vlout{os.getpid()}"
+INNER_DEV = f"vlin{os.getpid()}"
+
+OUTER_VID = 100
+INNER_VID = 200
+
+LOCAL_IP = "198.51.100.1"
+REMOTE_IP = "198.51.100.2"
+
+
+def _vlan_add(base, name, proto, vid, host=None):
+ """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=host)
+ defer(ip, f"link del {name}", host=host)
+ ip(f"link set {name} up", host=host)
+
+
+def _vlan_setup(base, addr, outer_proto, inner_proto, host=None):
+ """Create VLAN interfaces on base and set an IP on the innermost one."""
+
+ _vlan_add(base, OUTER_DEV, outer_proto, OUTER_VID, host=host)
+ if inner_proto:
+ _vlan_add(OUTER_DEV, INNER_DEV, inner_proto, INNER_VID, host=host)
+
+ dev = INNER_DEV if inner_proto else OUTER_DEV
+ ip(f"addr add {addr}/24 dev {dev}", host=host)
+
+
+def _setup(cfg, outer_proto, inner_proto, hw_strip):
+ """Configure VLAN stripping and create the VLAN interfaces."""
+
+ feat = ethtool(f"-k {cfg.ifname}", json=True)[0]
+ feats = {"rx-vlan-offload": hw_strip}
+ if outer_proto == "802.1ad":
+ feats["rx-vlan-stag-hw-parse"] = hw_strip
+ 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=cfg.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"""
+
+ cfg.require_ipver("4")
+
+ _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=[test], args=(cfg, ))
+ ksft_exit()
+
+
+if __name__ == "__main__":
+ main()
--
2.34.1
next prev parent reply other threads:[~2026-09-08 16:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 16:43 [PATCH net v4 0/7] net: stmmac: Fix double VLAN 802.1ad tag handling Ovidiu Panait
2026-09-08 16:43 ` [PATCH net v4 1/7] net: stmmac: Remove VLAN perfect matching dead code Ovidiu Panait
2026-09-10 23:45 ` netdev-bot+sashiko
2026-09-08 16:43 ` [PATCH net v4 2/7] net: stmmac: Stop toggling the EDVLP bit Ovidiu Panait
2026-09-10 23:45 ` netdev-bot+sashiko
2026-09-08 16:43 ` [PATCH net v4 3/7] net: stmmac: Rework S-VLAN handling Ovidiu Panait
2026-09-10 23:46 ` netdev-bot+sashiko
2026-09-08 16:43 ` [PATCH net v4 4/7] net: stmmac: Do not advertise S-VLAN stripping when it is disabled Ovidiu Panait
2026-09-10 23:46 ` netdev-bot+sashiko
2026-09-08 16:43 ` [PATCH net v4 5/7] net: stmmac: Disable S-Tag processing on dwmac4 Ovidiu Panait
2026-09-09 12:19 ` Maxime Chevallier
2026-09-10 23:46 ` netdev-bot+sashiko
2026-09-08 16:43 ` [PATCH net v4 6/7] selftests: drv-net: Move _set_ethtool_feat() into lib Ovidiu Panait
2026-09-10 23:42 ` Jakub Kicinski
2026-09-08 16:43 ` Ovidiu Panait [this message]
2026-09-10 23:46 ` [PATCH net v4 7/7] selftests: drv-net: Add VLAN test netdev-bot+sashiko
2026-09-10 23:52 ` Jakub Kicinski
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=20260908164309.59282-8-ovidiu.panait.rb@renesas.com \
--to=ovidiu.panait.rb@renesas.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=jun.ann.lai@intel.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=recv.jo@gmail.com \
--cc=shuah@kernel.org \
--cc=yi.fang.gan@intel.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