diff options
| author | Ioana Ciornei <ioana.ciornei@nxp.com> | 2026-06-10 18:09:11 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-06-14 03:50:51 +0300 |
| commit | 2230a2e62251ddd8b0c02a2ebf27080fd8e730be (patch) | |
| tree | 06d13526b9a4584d831cdebe01fa6d5fdd21a0e7 | |
| parent | e31f457ac7dae80fe70245dba8f42829f27ff8d7 (diff) | |
| download | linux-2230a2e62251ddd8b0c02a2ebf27080fd8e730be.tar.xz | |
dpaa2-switch: move FDB selection for leave path into a helper
Move the FDB selection for when a port leaves bridge into a new helper -
dpaa2_switch_fdb_for_leave(). This will hopefully make the
dpaa2_switch_port_set_fdb() function easier to read and follow. The new
helper only determines the FDB to be used, any updates into the private
port structure still gets done in the set_fdb() function.
No changes in the actual behavior are intended.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Link: https://patch.msgid.link/20260610150912.1788482-5-ioana.ciornei@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 158d0f510eae..09604c84a614 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -98,35 +98,47 @@ dpaa2_switch_fdb_for_join(struct ethsw_port_priv *port_priv, return port_priv->fdb; } +static struct dpaa2_switch_fdb * +dpaa2_switch_fdb_for_leave(struct ethsw_port_priv *port_priv) +{ + struct ethsw_core *ethsw = port_priv->ethsw_data; + + /* If this is the last user of the FDB, just keep using it. */ + if (!dpaa2_switch_fdb_in_use_by_others(ethsw, port_priv->fdb, + port_priv)) { + return port_priv->fdb; + } + + /* Since we are not the last port which leaves a bridge, + * acquire a new FDB and use it. + */ + return dpaa2_switch_fdb_get_unused(ethsw); +} + static void dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv, struct net_device *upper_dev, bool linking) { - struct ethsw_core *ethsw = port_priv->ethsw_data; - struct dpaa2_switch_fdb *new_fdb, *fdb; + struct dpaa2_switch_fdb *new_fdb; /* If we leave a bridge, find an unused FDB and use that. */ if (!linking) { - /* If this is the last user of the FDB, just keep using it. */ - if (!dpaa2_switch_fdb_in_use_by_others(ethsw, port_priv->fdb, - port_priv)) { - port_priv->fdb->bridge_dev = NULL; - return; - } - - /* Since we are not the last port which leaves a bridge, - * acquire a new FDB and use it. The number of FDBs is sized to - * accommodate all switch ports as standalone, each with its - * private FDB, which means that dpaa2_switch_fdb_get_unused() - * must succeed here. WARN if not. + /* The number of FDBs is sized to accommodate all switch ports + * as standalone, each with its private FDB, which means that + * dpaa2_switch_fdb_get_unused() must succeed here. WARN if + * not. */ - fdb = dpaa2_switch_fdb_get_unused(port_priv->ethsw_data); - if (WARN_ON(!fdb)) + new_fdb = dpaa2_switch_fdb_for_leave(port_priv); + if (WARN_ON(!new_fdb)) return; - port_priv->fdb = fdb; - port_priv->fdb->in_use = true; + if (port_priv->fdb != new_fdb) { + port_priv->fdb = new_fdb; + port_priv->fdb->in_use = true; + } + port_priv->fdb->bridge_dev = NULL; + return; } |
