From: Julius Bairaktaris <julius@bairaktaris.de>
To: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Pablo Neira Ayuso <pablo@netfilter.org>
Subject: [PATCH net-next v2] net: dsa: offer a flowtable to the switch before the conduit
Date: Fri, 4 Sep 2026 11:27:18 +0200 [thread overview]
Message-ID: <20260904092719.534318-1-julius@bairaktaris.de> (raw)
A flowtable bound to a DSA user port is forwarded to the conduit netdev
by dsa_user_setup_ft_block(), for a flow engine that sits on the
conduit as mtk_eth's does. It does not go through
ds->ops->port_setup_tc, so a switch that owns its flow engine is never
offered the flowtable.
Offer TC_SETUP_FT to the switch first and forward it to the conduit
only when the switch answers -EOPNOTSUPP. The side that takes the bind
is recorded on the port so that the unbind goes to the same side. Every
in-tree .port_setup_tc returns -EOPNOTSUPP for TC_SETUP_FT, so a
conduit-side flow engine is reached as before.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
v2:
- decide the target on FLOW_BLOCK_BIND and record it on the port, so
the unbind goes to the side that holds the block callback
- reword the comment
v1: https://lore.kernel.org/netdev/20260901092546.369232-1-julius@bairaktaris.de/
Tested on IPQ8074 with an out-of-tree DSA switch driver that handles
TC_SETUP_FT (openwrt/openwrt#24806): three flowtable unbind/bind cycles,
hardware offload of routed flows after each.
include/net/dsa.h | 6 ++++++
net/dsa/user.c | 25 ++++++++++++++++++++-----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 7507d632e7c6..dbcb02de06fc 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -297,6 +297,12 @@ struct dsa_port {
u8 setup:1;
+ /* Flowtable blocks on this user port go to the switch, not the
+ * conduit; decided at bind time. Written without rtnl, so not one of
+ * the bit fields above.
+ */
+ bool ft_on_switch;
+
struct device_node *dn;
unsigned int ageing_time;
diff --git a/net/dsa/user.c b/net/dsa/user.c
index 041f9060c8ef..f4cd48df2519 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -1718,15 +1718,30 @@ static int dsa_user_setup_tc_block(struct net_device *dev,
}
}
-static int dsa_user_setup_ft_block(struct dsa_switch *ds, int port,
- void *type_data)
+static int dsa_user_setup_ft_block(struct dsa_port *dp,
+ struct flow_block_offload *bo)
{
- struct net_device *conduit = dsa_port_to_conduit(dsa_to_port(ds, port));
+ struct net_device *conduit = dsa_port_to_conduit(dp);
+ struct dsa_switch *ds = dp->ds;
+ int err;
+
+ /* The unbind goes to the side that took the bind. */
+ if (bo->command == FLOW_BLOCK_BIND) {
+ err = -EOPNOTSUPP;
+ if (ds->ops->port_setup_tc)
+ err = ds->ops->port_setup_tc(ds, dp->index, TC_SETUP_FT,
+ bo);
+ dp->ft_on_switch = err != -EOPNOTSUPP;
+ if (dp->ft_on_switch)
+ return err;
+ } else if (dp->ft_on_switch) {
+ return ds->ops->port_setup_tc(ds, dp->index, TC_SETUP_FT, bo);
+ }
if (!conduit->netdev_ops->ndo_setup_tc)
return -EOPNOTSUPP;
- return conduit->netdev_ops->ndo_setup_tc(conduit, TC_SETUP_FT, type_data);
+ return conduit->netdev_ops->ndo_setup_tc(conduit, TC_SETUP_FT, bo);
}
static int dsa_user_setup_tc(struct net_device *dev, enum tc_setup_type type,
@@ -1739,7 +1754,7 @@ static int dsa_user_setup_tc(struct net_device *dev, enum tc_setup_type type,
case TC_SETUP_BLOCK:
return dsa_user_setup_tc_block(dev, type_data);
case TC_SETUP_FT:
- return dsa_user_setup_ft_block(ds, dp->index, type_data);
+ return dsa_user_setup_ft_block(dp, type_data);
default:
break;
}
--
2.53.0
next reply other threads:[~2026-09-04 9:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 9:27 Julius Bairaktaris [this message]
2026-09-05 1:23 ` [PATCH net-next v2] net: dsa: offer a flowtable to the switch before the conduit Jakub Kicinski
-- strict thread matches above, loose matches on Subject: below --
2026-09-04 9:24 Julius Bairaktaris
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=20260904092719.534318-1-julius@bairaktaris.de \
--to=julius@bairaktaris.de \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/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