Re: [net-next,v20,7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations
From: Łukasz Majewski <hidden>
Date: 2026-01-28 22:59:14
Also in:
imx, linux-arm-kernel, linux-devicetree, lkml
Hi Jakub,
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 patch adds bridge operations support to the MTIP L2 switch driver, enabling hardware offloading for packet switching when a bridge is created on the switch interfaces.quoted
diff --git a/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.cb/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c new file mode 100644 index 000000000000..f961b9cc4e6a--- /dev/null +++ b/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c[ ... ]quoted
+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 notifier_from_errno(-EOPNOTSUPP);^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Should this return -EOPNOTSUPP instead of notifier_from_errno(-EOPNOTSUPP)? The caller mtip_netdevice_event() already wraps the return value with notifier_from_errno(ret), so double-wrapping corrupts the return value. Looking at similar drivers like cpsw_new.c (cpsw_netdevice_port_link), the pattern is to return raw errno values here and let the event handler do the conversion.
Yes, the call to notifier_from_errno() can be removed. I will fix it with v21.
quoted
+ } + + fep->br_offload = 1; + mtip_switch_dis_port_separation(fep); + mtip_clear_atable(fep); + } + + if (!priv->master_dev) + priv->master_dev = br_ndev; + + fep->br_members |= BIT(priv->portnum - 1); + + 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; + }If switchdev_bridge_port_offload() fails, the state changes made earlier in the function (br_offload, br_members, master_dev, and the hardware configuration via mtip_switch_dis_port_separation and mtip_clear_atable) are not rolled back. Looking at cpsw_new.c for reference, it modifies br_members after the switchdev call succeeds, avoiding the need for rollback. Could the state updates here be reordered to happen after switchdev_bridge_port_offload() returns successfully?
I will add to v21: fep->br_members &= ~BIT(priv->portnum - 1); priv->master_dev = NULL; before I return err. (This "rollback" code was missing).
[ ... ]quoted
+static int mtip_netdevice_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{[ ... ]quoted
+ return notifier_from_errno(ret); +}[ ... ]
-- Best regards, Łukasz Majewski