summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIoana Ciornei <ioana.ciornei@nxp.com>2026-06-10 18:09:10 +0300
committerJakub Kicinski <kuba@kernel.org>2026-06-14 03:50:50 +0300
commite31f457ac7dae80fe70245dba8f42829f27ff8d7 (patch)
tree45f646e2ac260493c261b1c06d08f68b7c8f8718
parent5617bf8538ec16e2a81c9188f5ad1abb9f726e10 (diff)
downloadlinux-e31f457ac7dae80fe70245dba8f42829f27ff8d7.tar.xz
dpaa2-switch: move FDB selection for join path into a helper
The dpaa2_switch_port_set_fdb() function handles the setup of the FDB for both changeupper cases: join and leave. Move the code block which handles the join path into a new helper - dpaa2_switch_fdb_for_join() - with the hope that the entire function will become easier to read and extend with other use cases in the future. This new helper just determines and returns what FDB should be used for a specific port, the cleanup of the old FDB and the actual setup in the per port structure remains in the dpaa2_switch_port_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-4-ioana.ciornei@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 3052a1c63c2d..158d0f510eae 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -67,15 +67,43 @@ static bool dpaa2_switch_fdb_in_use_by_others(struct ethsw_core *ethsw,
return false;
}
+static struct dpaa2_switch_fdb *
+dpaa2_switch_fdb_for_join(struct ethsw_port_priv *port_priv,
+ struct net_device *upper_dev)
+{
+ struct ethsw_port_priv *other_port_priv;
+ struct net_device *other_dev;
+ struct list_head *iter;
+
+ /* The below call to netdev_for_each_lower_dev() demands the RTNL lock
+ * being held. Assert on it so that it's easier to catch new code
+ * paths that reach this point without the RTNL lock.
+ */
+ ASSERT_RTNL();
+
+ /* If part of a bridge, use the FDB of the first dpaa2 switch interface
+ * to be present in that bridge
+ */
+ netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
+ if (!dpaa2_switch_port_dev_check(other_dev))
+ continue;
+
+ if (other_dev == port_priv->netdev)
+ continue;
+
+ other_port_priv = netdev_priv(other_dev);
+ return other_port_priv->fdb;
+ }
+
+ return port_priv->fdb;
+}
+
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 ethsw_port_priv *other_port_priv = NULL;
- struct dpaa2_switch_fdb *fdb;
- struct net_device *other_dev;
- struct list_head *iter;
+ struct dpaa2_switch_fdb *new_fdb, *fdb;
/* If we leave a bridge, find an unused FDB and use that. */
if (!linking) {
@@ -102,30 +130,12 @@ static void dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv,
return;
}
- /* The below call to netdev_for_each_lower_dev() demands the RTNL lock
- * being held. Assert on it so that it's easier to catch new code
- * paths that reach this point without the RTNL lock.
- */
- ASSERT_RTNL();
-
- /* If part of a bridge, use the FDB of the first dpaa2 switch interface
- * to be present in that bridge
- */
- netdev_for_each_lower_dev(upper_dev, other_dev, iter) {
- if (!dpaa2_switch_port_dev_check(other_dev))
- continue;
-
- if (other_dev == port_priv->netdev)
- continue;
-
- other_port_priv = netdev_priv(other_dev);
- break;
- }
+ new_fdb = dpaa2_switch_fdb_for_join(port_priv, upper_dev);
/* The current port is about to change its FDB to the one used by the
* first port that joined the bridge.
*/
- if (other_port_priv) {
+ if (port_priv->fdb != new_fdb) {
/* The previous FDB is about to become unused, since the
* interface is no longer standalone.
*/
@@ -133,7 +143,7 @@ static void dpaa2_switch_port_set_fdb(struct ethsw_port_priv *port_priv,
port_priv->fdb->bridge_dev = NULL;
/* Get a reference to the new FDB */
- port_priv->fdb = other_port_priv->fdb;
+ port_priv->fdb = new_fdb;
}
/* Keep track of the new upper bridge device */