Thread (16 messages) 16 messages, 3 authors, 2026-02-04

Re: [net-next,v22,7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations

From: Jakub Kicinski <kuba@kernel.org>
Date: 2026-02-03 01:44:27
Also in: imx, linux-arm-kernel, linux-devicetree, lkml

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: mtip: Extend the L2 switch driver for imx287 with bridge operations

This commit adds bridge offloading support to the MTIP L2 switch driver,
allowing the switch to offload packet switching when a bridge is
created on its interfaces.
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c b/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c
--- /dev/null
+++ b/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c
@@ -0,0 +1,132 @@
[ ... ]
+static int mtip_ndev_port_link(struct net_device *ndev,
+			       struct net_device *br_ndev,
+			       struct netlink_ext_ack *extack)
+{
+	struct mtip_ndev_priv *priv = netdev_priv(ndev), *other_priv;
+	struct switch_enet_private *fep = priv->fep;
+	struct net_device *other_ndev;
+	int err;
+
+	/* Check if one port of MTIP switch is already bridged */
+	if (fep->br_members && !fep->br_offload) {
+		/* Get the second bridge ndev */
+		other_ndev = fep->ndev[fep->br_members - 1];
+		other_priv = netdev_priv(other_ndev);
+		if (other_priv->master_dev != br_ndev) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "L2 offloading only possible for the same bridge!");
+			return -EOPNOTSUPP;
+		}
+
+		fep->br_offload = 1;
+		mtip_switch_dis_port_separation(fep);
+		mtip_clear_atable(fep);
+	}
+
+	err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL,
+					    false, extack);
+	if (err) {
+		dev_err(&ndev->dev, "can't offload bridge port %s [err: %d]\n",
+			ndev->name, err);
+		return err;
+	}
When switchdev_bridge_port_offload() fails after the second port joins the
same bridge, should the error path also revert br_offload and port
separation state?

In mtip_ndev_port_link() when the second port joins, the code sets
fep->br_offload = 1 and calls mtip_switch_dis_port_separation() before
attempting switchdev_bridge_port_offload(). If that call fails, the error
returns without reverting these changes.

This could leave the hardware with port separation disabled and br_offload
set to 1, even though only one port is actually bridged.

This concern was raised by Jakub Kicinski:
https://lore.kernel.org/netdev/20260131015440.972531-1-kuba@kernel.org/ (local)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help