From: Koral Ilgun <koralilgun@gmail.com>
To: Jiri Pirko <jiri@resnulli.us>,
Nikolay Aleksandrov <razor@blackwall.org>,
Ido Schimmel <idosch@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Daniel Machon <daniel.machon@microchip.com>,
bridge@lists.linux.dev, netdev@vger.kernel.org,
Koral Ilgun <koral.ilgun@adtran.com>
Subject: [PATCH net v3 0/3] net: bridge: switchdev: fix the hwdom state of a port that stops the offload
Date: Fri, 4 Dec 2026 18:49:39 -0800 [thread overview]
Message-ID: <20261205024943.3657727-1-koralilgun@gmail.com> (raw)
From: Koral Ilgun <koral.ilgun@adtran.com>
When the last offload of a bridge port stops while the port stays in
the bridge, the bridge keeps the hwdom of the port. Patch 3 clears it,
as v1 and v2 did. Patch 2 keeps offload_count at 0 after -EBUSY, a case
that patch 3 makes reachable for a port that stays in the bridge.
Patch 1 makes rocker fail a bridge join whose offload fails, so the
count patch does not make the WARN_ON() in nbp_switchdev_del()
reachable on rocker. The other callers of
switchdev_bridge_port_offload() pass the error on (read of the
source).
For rocker, a flag in struct ofdpa_port that skips the unoffload after
a failed offload would be smaller. But the port would then stay in the
bridge without a hwdom, as on net/main. A failed join matches DSA and
mlxsw. Only a bridge master gets the error back, because
ofdpa_port_ovs_changed() sets bridge_dev before the calls that can fail
and has no clean undo.
Daniel Machon reported that the fault reproduces on lan969x and that
v1 clears it, while he prepares a LAG series for sparx5/lan969x:
https://lore.kernel.org/netdev/20261202123828.3dcba7xv7hah56yz@DEN-DL-M70577.microsemi.net/
Test: net/main e9d78fc6741a plus a local change with empty LAG ops in
dsa_loop, x86_64 in QEMU (TCG), dsa_loop with tag protocol none, and a
QEMU rocker device with one port, cabled to a virtio NIC. A local knob
made nbp_switchdev_hwdom_set() return -EBUSY as with all hwdoms busy,
and a local trace printed offload_count and the hwdom. The tests ran on
net/main, on v2, on patch 2 alone, on patch 3 alone, and after each
patch of the series; each commit message gives its results. W=1 builds
of net/bridge/ and drivers/net/ethernet/rocker/ with allmodconfig,
allyesconfig and an x86_64_defconfig-based config show no warnings on
net/main and after each patch, and neither does sparse (C=2) on the
three changed files with the x86_64_defconfig-based config.
Not tested: a frame that a switch marked with offload_fwd_mark, so also
the LAG leave window and the dsa_port_change_conduit() window; a port
with TX forwarding offload (mv88e6xxx, tag_8021q); a real -EBUSY (the
knob replaces a full busy_hwdoms); a failure of the first
ofdpa_port_vlan_del() or of ofdpa_port_vlan_add() in the rocker join;
rocker with OVS; an offload from a second switch;
dsa_port_change_conduit(); mlxsw and the other drivers that call
switchdev_bridge_port_unoffload(); team; bridge VLAN filtering; the
error path of br_switchdev_port_offload(); an unoffload while frames go
through the bridge; the kernel selftests; lockdep, KASAN and KCSAN.
Stable: patch 1 applies to v5.15 and later (git apply --check).
Patches 2 and 3 do not apply before v7.2. Both have context from
f76ae12b6ba3 ("net: bridge: use atomic ops to read/change p->flags
(III)"), so older trees need a backport that adapts that context.
Claude Code (Anthropic) drafted this cover letter under my direction,
and I reviewed it.
v3:
- new patch 1: rocker fails the bridge join when the offload fails,
undoes its join state, and ignores an STP state while the port is not
bridged (Sashiko, Medium, on v2 1/2)
- patch 2: the rocker paragraph names patch 1
- not taken: Sashiko's Low point on v2 2/2, not to match a src_hwdom of
0 in nbp_switchdev_allowed_egress(). adin1110, icssm, qtnfmac and
icssg mark frames from ports without a hwdom, and the match of hwdom 0
stops their duplicates.
- new test: the rocker join with the knob
- rebased on net/main e9d78fc6741a
v2: https://lore.kernel.org/netdev/20261203002451.517879-1-koralilgun@gmail.com/
v2:
- new patch 1: count an offload only after its hwdom is set
- patch 2: describe the receive side of the LAG leave window and the
window in dsa_port_change_conduit(); read the hwdom once with
READ_ONCE() in nbp_switchdev_frame_mark() and
nbp_switchdev_allowed_egress(); name the mlxsw cases; add the tests
of the self match and of frames through the bridge
- rebased on net/main c1c39137dcc3
v1: https://lore.kernel.org/netdev/20261124011639.990261-1-koralilgun@gmail.com/
Koral Ilgun (3):
rocker: fail the bridge join when the offload fails
net: bridge: switchdev: count an offload only after its hwdom is set
net: bridge: switchdev: clear the hwdom of a port that stops the
offload
drivers/net/ethernet/rocker/rocker_main.c | 8 ++-
drivers/net/ethernet/rocker/rocker_ofdpa.c | 24 +++++++-
net/bridge/br_switchdev.c | 70 +++++++++++++++-------
3 files changed, 77 insertions(+), 25 deletions(-)
base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a
--
2.43.0
next reply other threads:[~2026-12-05 2:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 2:49 Koral Ilgun [this message]
2026-12-05 2:49 ` [PATCH net v3 1/3] rocker: fail the bridge join when the offload fails Koral Ilgun
2026-12-05 2:49 ` [PATCH net v3 2/3] net: bridge: switchdev: count an offload only after its hwdom is set Koral Ilgun
2026-12-05 2:49 ` [PATCH net v3 3/3] net: bridge: switchdev: clear the hwdom of a port that stops the offload Koral Ilgun
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=20261205024943.3657727-1-koralilgun@gmail.com \
--to=koralilgun@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=bridge@lists.linux.dev \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ioana.ciornei@nxp.com \
--cc=jiri@resnulli.us \
--cc=koral.ilgun@adtran.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=vladimir.oltean@nxp.com \
--cc=willemb@google.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