Re: [PATCH net-next v4 06/13] dpaa2-switch: add dpaa2_switch_port_to_bridge_port() helper
From: Ioana Ciornei
Date: Tue Jun 30 2026 - 09:51:46 EST
On Mon, Jun 29, 2026 at 02:23:02PM +0300, Ioana Ciornei wrote:
> In preparation for adding offloading support for upper bond devices we
> have to let the switchdev framework know if a specific bridge port is
> offloaded or not, even if that brport is an upper device.
>
> For this to happen, create the dpaa2_switch_port_to_bridge_port function
> which will determine the bridge port corresponding to a particular DPAA2
> switch interface and use it in the switchdev_bridge_port_offload call.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@xxxxxxx>
> ---
> Changes in v4:
> - Split the patch so that the first part only adds the base function and
> its call sites and the logic aroung lag is added later in the patch
> which actually adds the support for LAG.
> - Moved the patch so that it's a preparatory patch
>
> Changes in v3:
> - Access lag field through rtnl_dereference() so that we adapt to the
> __rcu change.
> - Check that the brport is non-NULL before calling
> switchdev_bridge_port_unoffload() on it.
>
> Changes in v2:
> - none
> ---
> .../ethernet/freescale/dpaa2/dpaa2-switch.c | 23 ++++++++++++++++---
> 1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> index d4975d08fa44..88d199befbd9 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
> @@ -2017,6 +2017,15 @@ static int dpaa2_switch_port_attr_set_event(struct net_device *netdev,
> return notifier_from_errno(err);
> }
>
> +static struct net_device *
> +dpaa2_switch_port_to_bridge_port(struct ethsw_port_priv *port_priv)
> +{
> + if (!port_priv->fdb->bridge_dev)
> + return NULL;
> +
> + return port_priv->netdev;
> +}
> +
> static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
> struct net_device *upper_dev,
> struct netlink_ext_ack *extack)
> @@ -2024,6 +2033,7 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
> struct ethsw_port_priv *port_priv = netdev_priv(netdev);
> struct dpaa2_switch_fdb *old_fdb = port_priv->fdb;
> struct ethsw_core *ethsw = port_priv->ethsw_data;
> + struct net_device *brport_dev;
> bool learn_ena;
> int err;
>
> @@ -2035,7 +2045,8 @@ static int dpaa2_switch_port_bridge_join(struct net_device *netdev,
> dpaa2_switch_port_set_fdb(port_priv, upper_dev, true);
sashiko.dev notes:
Does the removal of rtnl_lock() earlier in this patch series
expose port_priv->fdb to a concurrent data race here?
dpaa2_switch_event_work() reads port_priv->fdb without taking
rtnl_lock or using READ_ONCE(), which can race with bridge
join/leave operations that modify it via
dpaa2_switch_port_set_fdb().
No, that is not correct and how was this avoided is explained in the
commit message from patch 2/13:
To avoid this kind of concurency without a rtnl_lock, flush the
event workqueue as the last step from the pre_bridge_leave so
that any in-flight operations targeting the current FDB are
finalized before the bridge layout (and the per port FDB
assignment) changes.
Ioana