* Re: [net-next,v20,7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations [not found] <20260126103400.1683125-8-lukasz.majewski@mailbox.org> @ 2026-01-28 2:26 ` Jakub Kicinski 2026-01-28 22:58 ` Łukasz Majewski 0 siblings, 1 reply; 2+ messages in thread From: Jakub Kicinski @ 2026-01-28 2:26 UTC (permalink / raw) To: lukasz.majewski Cc: Jakub Kicinski, festevam, linux-arm-kernel, s.hauer, kernel, horms, shawnguo, imx, linux-kernel, conor+dt, devicetree, wahrenst, pabeni, davem, netdev, richardcochran, edumazet, andrew+netdev, robh, krzk+dt, andrew 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. > diff --git a/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c b/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 [ ... ] > +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. > + } > + > + 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? [ ... ] > +static int mtip_netdevice_event(struct notifier_block *unused, > + unsigned long event, void *ptr) > +{ [ ... ] > + return notifier_from_errno(ret); > +} [ ... ] ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [net-next,v20,7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations 2026-01-28 2:26 ` [net-next,v20,7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations Jakub Kicinski @ 2026-01-28 22:58 ` Łukasz Majewski 0 siblings, 0 replies; 2+ messages in thread From: Łukasz Majewski @ 2026-01-28 22:58 UTC (permalink / raw) To: Jakub Kicinski Cc: festevam, linux-arm-kernel, s.hauer, kernel, horms, shawnguo, imx, linux-kernel, conor+dt, devicetree, wahrenst, pabeni, davem, netdev, richardcochran, edumazet, andrew+netdev, robh, krzk+dt, andrew 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. > > > diff --git a/drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c > > b/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 > > [ ... ] > > > +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. > > + } > > + > > + 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). > [ ... ] > > > +static int mtip_netdevice_event(struct notifier_block *unused, > > + unsigned long event, void *ptr) > > +{ > > [ ... ] > > > + return notifier_from_errno(ret); > > +} > > [ ... ] -- Best regards, Łukasz Majewski ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-28 22:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260126103400.1683125-8-lukasz.majewski@mailbox.org>
2026-01-28 2:26 ` [net-next,v20,7/7] net: mtip: Extend the L2 switch driver for imx287 with bridge operations Jakub Kicinski
2026-01-28 22:58 ` Łukasz Majewski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox