* [net-next v23 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver
@ 2026-02-04 23:21 Lukasz Majewski
[not found] ` <20260204232135.1024665-3-lukasz.majewski@mailbox.org>
0 siblings, 1 reply; 6+ messages in thread
From: Lukasz Majewski @ 2026-02-04 23:21 UTC (permalink / raw)
To: Andrew Lunn, davem, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo
Cc: Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Richard Cochran, netdev, devicetree, linux-kernel, imx,
linux-arm-kernel, Stefan Wahren, Simon Horman, Lukasz Majewski
This patch series adds support for More Than IP's L2 switch driver embedded
in some NXP's SoCs. This one has been tested on imx287, but is also available
in the vf610.
In the past there has been performed some attempts to upstream this driver:
1. The 4.19-cip based one [1]
2. DSA based one for 5.12 [2] - i.e. the switch itself was treat as a DSA switch
with NO tag appended.
3. The extension for FEC driver for 5.12 [3] - the trick here was to fully reuse
FEC when the in-HW switching is disabled. When bridge offloading is enabled,
the driver uses already configured MAC and PHY to also configure PHY.
All three approaches were not accepted as eligible for upstreaming.
The driver from this series has following features:
1. It is fully separated from fec_main - i.e. can be used interchangeable
with it. To be more specific - one can build them as modules and
if required switch between them when e.g. bridge offloading is required.
To be more specific:
- Use FEC_MAIN: When one needs support for two ETH ports with separate
uDMAs used for both and bridging can be realized in SW.
- Use MTIPL2SW: When it is enough to support two ports with only uDMA0
attached to switch and bridging shall be offloaded to HW.
2. This driver uses MTIP's L2 switch internal VLAN feature to provide port
separation at boot time. Port separation is disabled when bridging is
required.
3. Example usage:
Configuration:
ip link set lan0 up; sleep 1;
ip link set lan1 up; sleep 1;
ip link add name br0 type bridge;
ip link set br0 up; sleep 1;
ip link set lan0 master br0;
ip link set lan1 master br0;
bridge link;
ip addr add 192.168.2.17/24 dev br0;
ping -c 5 192.168.2.222
Removal:
ip link set br0 down;
ip link delete br0 type bridge;
ip link set dev lan1 down
ip link set dev lan0 down
4. Limitations:
- Driver enables and disables switch operation with learning and ageing.
- Missing is the advanced configuration (e.g. adding entries to FBD). This is
on purpose, as up till now we didn't had consensus about how the driver
shall be added to Linux.
However, on top of this patch set the code with SWITCHDEV support (v6.6.
PREEMPT_RT enabled) has been implemented in [4].
5. Clang build:
make LLVM_SUFFIX=-19 LLVM=1 mrproper
cp ./arch/arm/configs/mxs_defconfig .config
make ARCH=arm LLVM_SUFFIX=-19 LLVM=1 W=1 menuconfig
make ARCH=arm LLVM_SUFFIX=-19 LLVM=1 W=1 -j8 LOADADDR=0x40008000 uImage dtbs
make LLVM_SUFFIX=-19 LLVM=1 mrproper
make LLVM_SUFFIX=-19 LLVM=1 allmodconfig
make LLVM_SUFFIX=-19 LLVM=1 W=1 drivers/net/ethernet/freescale/mtipsw/ | tee llvm_build.log
make LLVM_SUFFIX=-19 LLVM=1 W=1 -j8 | tee llvm_build.log
6. Kernel compliance checks:
make coccicheck MODE=report J=4 M=drivers/net/ethernet/freescale/mtipsw/
make allmodconfig; ~/work/src/smatch/smatch_scripts/kchecker drivers/net/ethernet/freescale/mtipsw/
7. GCC:
make mrproper
make allmodconfig
make W=1 drivers/net/ethernet/freescale/mtipsw/
[source OE/Yocto SDK build environment]
CROSS_COMPILE=arm-poky-linux-gnueabi- ARCH=arm make mrproper
cp ./arch/arm/configs/mxs_defconfig .config
CROSS_COMPILE=arm-poky-linux-gnueabi- ARCH=arm make menuconfig
CROSS_COMPILE=arm-poky-linux-gnueabi- ARCH=arm make -j8 LOADADDR=0x40008000 uImage dtbs
8. DT_SCHEMA checks:
source ~/.venv/bin/activate
source /opt/poky/3.1.31/environment-setup-armv5e-poky-linux-gnueabi
make dt_binding_check DT_SCHEMA_FILES=nxp,imx28-mtip-switch.yaml
make CHECK_DTBS=y DT_SCHEMA_FILES=nxp,imx28-mtip-switch.yaml nxp/mxs/imx28-xea.dtb
Links:
[1] - https://github.com/lmajewski/linux-imx28-l2switch/commits/master
[2] - https://github.com/lmajewski/linux-imx28-l2switch/tree/imx28-v5.12-L2-upstream-RFC_v1
[3] - https://source.denx.de/linux/linux-imx28-l2switch/-/tree/imx28-v5.12-L2-upstream-switchdev-RFC_v1?ref_type=heads
[4] - https://github.com/lmajewski/linux-imx28-l2switch/commits/vf610-linux-6.6.y-mtipl2sw
Lukasz Majewski (7):
dt-bindings: net: Add MTIP L2 switch description
net: mtip: The L2 switch driver for imx287
net: mtip: Add buffers management functions to the L2 switch driver
net: mtip: Add net_device_ops functions to the L2 switch driver
net: mtip: Add mtip_switch_{rx|tx} functions to the L2 switch driver
net: mtip: Extend the L2 switch driver with management operations
net: mtip: Extend the L2 switch driver for imx287 with bridge
operations
.../bindings/net/nxp,imx28-mtip-switch.yaml | 150 ++
MAINTAINERS | 7 +
drivers/net/ethernet/freescale/Kconfig | 1 +
drivers/net/ethernet/freescale/Makefile | 1 +
drivers/net/ethernet/freescale/mtipsw/Kconfig | 13 +
.../net/ethernet/freescale/mtipsw/Makefile | 4 +
.../net/ethernet/freescale/mtipsw/mtipl2sw.c | 2032 +++++++++++++++++
.../net/ethernet/freescale/mtipsw/mtipl2sw.h | 648 ++++++
.../ethernet/freescale/mtipsw/mtipl2sw_br.c | 138 ++
.../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 442 ++++
10 files changed, 3436 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml
create mode 100644 drivers/net/ethernet/freescale/mtipsw/Kconfig
create mode 100644 drivers/net/ethernet/freescale/mtipsw/Makefile
create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c
create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw.h
create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c
create mode 100644 drivers/net/ethernet/freescale/mtipsw/mtipl2sw_mgnt.c
--
2.39.5
^ permalink raw reply [flat|nested] 6+ messages in thread[parent not found: <20260204232135.1024665-3-lukasz.majewski@mailbox.org>]
* Re: [net-next,v23,2/7] net: mtip: The L2 switch driver for imx287 [not found] ` <20260204232135.1024665-3-lukasz.majewski@mailbox.org> @ 2026-02-06 2:26 ` Jakub Kicinski 2026-02-06 2:28 ` [net-next v23 2/7] " Jakub Kicinski 1 sibling, 0 replies; 6+ messages in thread From: Jakub Kicinski @ 2026-02-06 2:26 UTC (permalink / raw) To: lukasz.majewski Cc: Jakub Kicinski, imx, andrew+netdev, linux-kernel, krzk+dt, davem, kernel, devicetree, horms, festevam, andrew, conor+dt, pabeni, shawnguo, linux-arm-kernel, wahrenst, richardcochran, s.hauer, netdev, edumazet, robh 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: The L2 switch driver for imx287 This patch provides support for More Than IP L2 switch embedded in the imx287 SoC, a two port switch placed between uDMA[01] and MAC-NET[01] for offloading network traffic. > diff --git a/drivers/net/ethernet/freescale/mtipsw/Kconfig b/drivers/net/ethernet/freescale/mtipsw/Kconfig > new file mode 100644 > index 000000000000..7767bd7c707b > --- /dev/null > +++ b/drivers/net/ethernet/freescale/mtipsw/Kconfig > @@ -0,0 +1,13 @@ > +# SPDX-License-Identifier: GPL-2.0-only > +config FEC_MTIP_L2SW > + tristate "MoreThanIP L2 switch support to FEC driver" This isn't a bug, but the vendor name formatting is inconsistent between the description line ("MoreThanIP") and the help text below ("MoreThan IP"). The vendor should be consistently named throughout the file. > + depends on OF > + depends on NET_SWITCHDEV > + depends on BRIDGE > + depends on SOC_IMX28 || COMPILE_TEST > + help > + This enables support for the MoreThan IP L2 switch on i.MX > + SoCs (e.g. iMX287). It offloads bridging to this IP block's The SoC name "iMX287" should be "i.MX287" to match NXP's standard naming convention used throughout the kernel for i.MX SoCs. > diff --git a/drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c b/drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c > new file mode 100644 > index 000000000000..0a193a12e160 > --- /dev/null > +++ b/drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c [ ... ] > +static void mtip_mgnt_timer(struct timer_list *t) > +{ > + struct switch_enet_private *fep = timer_container_of(fep, t, > + timer_mgnt); Does this code cause undefined behavior? The timer_container_of macro expands to container_of(t, typeof(*fep), timer_mgnt), which dereferences the uninitialized 'fep' variable in the typeof() expression. This is the first statement in the function where 'fep' is being declared and assigned simultaneously. Looking at how other timer callbacks use this macro, shouldn't this be: struct switch_enet_private *fep = container_of(t, struct switch_enet_private, timer_mgnt); This will cause a crash when the timer fires at the mod_timer() call site in mtip_config_switch(). [ ... ] > +static void mtip_switch_tx(struct switch_enet_private *fep) > +{ > +} > + > +static int mtip_switch_rx(struct net_device *dev, int budget) > +{ > + return -ENOMEM; > +} Can the driver actually send or receive packets with these implementations? Looking at the call chain: mtip_interrupt() schedules NAPI on RX interrupt -> mtip_rx_napi() calls mtip_switch_rx() -> mtip_switch_rx() always returns -ENOMEM This means all receive interrupts are treated as out-of-memory conditions and no packets are ever delivered to the network stack. Similarly, mtip_switch_tx() is an empty stub that does nothing. The commit message states "It can be used interchangeably with current FEC driver" which suggests a functional driver, but the network interface cannot actually send or receive packets. Should the commit message clarify this is an incomplete implementation, or are these functions missing their implementation? [ ... ] > +static int mtip_parse_of(struct switch_enet_private *fep, > + struct device_node *np) > +{ > + struct device_node *p; > + unsigned int port_num; > + int ret = 0; > + > + p = of_get_child_by_name(np, "ethernet-ports"); > + > + for_each_available_child_of_node_scoped(p, port) { > + if (of_property_read_u32(port, "reg", &port_num)) > + continue; > + > + if (!(port_num == 1 || port_num == 2)) { > + dev_err(&fep->pdev->dev, > + "%s: The switch supports up to %d ports!\n", > + __func__, SWITCH_EPORT_NUMBER); > + goto of_get_err; > + } > + > + fep->n_ports = port_num; > + ret = of_get_mac_address(port, &fep->mac[port_num - 1][0]); > + if (ret) > + dev_dbg(&fep->pdev->dev, > + "of_get_mac_address(%pOF) failed (%d)!\n", > + port, ret); > + > + ret = of_property_read_string(port, "label", > + &fep->ndev_name[port_num - 1]); > + if (ret < 0) { > + dev_err(&fep->pdev->dev, > + "%s: Cannot get ethernet port name (%d)!\n", > + __func__, ret); > + goto of_get_err; > + } > + > + ret = of_get_phy_mode(port, &fep->phy_interface[port_num - 1]); > + if (ret < 0) { > + dev_err(&fep->pdev->dev, > + "%s: Cannot get PHY mode (%d)!\n", __func__, > + ret); > + goto of_get_err; > + } > + > + fep->phy_np[port_num - 1] = of_parse_phandle(port, > + "phy-handle", 0); Can this code leak OF node references? If the first port (port_num=1) successfully obtains its PHY handle via of_parse_phandle() and stores the reference in phy_np[0], but a subsequent port fails during of_property_read_string() for the 'label' property or of_get_phy_mode(), the error path jumps to of_get_err which only releases the parent node 'p'. The PHY handle reference obtained for the first port is never released. The error path returns to mtip_sw_probe() which returns error without calling mtip_parse_of_cleanup(), leaking the phy_np[0] reference. Note that line 1191 correctly calls mtip_parse_of_cleanup(fep) before goto, showing the cleanup is needed for these earlier error paths too. > + if (!fep->phy_np[port_num - 1]) { > + mtip_parse_of_cleanup(fep); > + dev_err(&fep->pdev->dev, > + "%s: PHY handle not defined!\n", __func__); > + ret = -ENODEV; > + goto of_get_err; > + } > + } > + > + of_get_err: > + of_node_put(p); -- pw-bot: cr ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v23 2/7] net: mtip: The L2 switch driver for imx287 [not found] ` <20260204232135.1024665-3-lukasz.majewski@mailbox.org> 2026-02-06 2:26 ` [net-next,v23,2/7] net: mtip: The L2 switch driver for imx287 Jakub Kicinski @ 2026-02-06 2:28 ` Jakub Kicinski 2026-02-06 10:24 ` Łukasz Majewski 1 sibling, 1 reply; 6+ messages in thread From: Jakub Kicinski @ 2026-02-06 2:28 UTC (permalink / raw) To: Lukasz Majewski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn On Thu, 5 Feb 2026 00:21:30 +0100 Lukasz Majewski wrote: > This patch series provides support for More Than IP L2 switch embedded > in the imx287 SoC. > > This is a two port switch (placed between uDMA[01] and MAC-NET[01]), > which can be used for offloading the network traffic. > > It can be used interchangeably with current FEC driver - to be more > specific: one can use either of it, depending on the requirements. > > The biggest difference is the usage of DMA - when FEC is used, separate > DMAs are available for each ENET-MAC block. > However, with switch enabled - only the DMA0 is used to send/receive data > to/form switch (and then switch sends them to respecitive ports). > > Signed-off-by: Lukasz Majewski <lukasz.majewski@mailbox.org> > Reviewed-by: Stefan Wahren <wahrenst@gmx.net> > Reviewed-by: Andrew Lunn <andrew@lunn.ch> Transient build failure here: drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1072:32: warning: variable ‘priv’ set but not used [-Wunused-but-set-variable] 1072 | struct mtip_ndev_priv *priv; | ^~~~ I sent out the AI code reviews while at it, without looking at them. So please approach them with caution.. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v23 2/7] net: mtip: The L2 switch driver for imx287 2026-02-06 2:28 ` [net-next v23 2/7] " Jakub Kicinski @ 2026-02-06 10:24 ` Łukasz Majewski 2026-02-16 9:23 ` Łukasz Majewski 0 siblings, 1 reply; 6+ messages in thread From: Łukasz Majewski @ 2026-02-06 10:24 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn Hi Jakub, > On Thu, 5 Feb 2026 00:21:30 +0100 Lukasz Majewski wrote: > > This patch series provides support for More Than IP L2 switch > > embedded in the imx287 SoC. > > > > This is a two port switch (placed between uDMA[01] and MAC-NET[01]), > > which can be used for offloading the network traffic. > > > > It can be used interchangeably with current FEC driver - to be more > > specific: one can use either of it, depending on the requirements. > > > > The biggest difference is the usage of DMA - when FEC is used, > > separate DMAs are available for each ENET-MAC block. > > However, with switch enabled - only the DMA0 is used to > > send/receive data to/form switch (and then switch sends them to > > respecitive ports). > > > > Signed-off-by: Lukasz Majewski <lukasz.majewski@mailbox.org> > > Reviewed-by: Stefan Wahren <wahrenst@gmx.net> > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > Transient build failure here: > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1072:32: warning: > variable ‘priv’ set but not used [-Wunused-but-set-variable] 1072 | > struct mtip_ndev_priv *priv; | > ^~~~ > > I sent out the AI code reviews while at it, without looking at them. > So please approach them with caution.. IMHO, issues pointed with AI review have been at discussed and (to my best knowledge) addressed. Shall I prepare next version of this patch set? -- Best regards, Łukasz Majewski ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v23 2/7] net: mtip: The L2 switch driver for imx287 2026-02-06 10:24 ` Łukasz Majewski @ 2026-02-16 9:23 ` Łukasz Majewski 2026-02-17 21:59 ` Jakub Kicinski 0 siblings, 1 reply; 6+ messages in thread From: Łukasz Majewski @ 2026-02-16 9:23 UTC (permalink / raw) To: Jakub Kicinski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn Hi Jakub, > Hi Jakub, > > > On Thu, 5 Feb 2026 00:21:30 +0100 Lukasz Majewski wrote: > > > This patch series provides support for More Than IP L2 switch > > > embedded in the imx287 SoC. > > > > > > This is a two port switch (placed between uDMA[01] and > > > MAC-NET[01]), which can be used for offloading the network > > > traffic. > > > > > > It can be used interchangeably with current FEC driver - to be > > > more specific: one can use either of it, depending on the > > > requirements. > > > > > > The biggest difference is the usage of DMA - when FEC is used, > > > separate DMAs are available for each ENET-MAC block. > > > However, with switch enabled - only the DMA0 is used to > > > send/receive data to/form switch (and then switch sends them to > > > respecitive ports). > > > > > > Signed-off-by: Lukasz Majewski <lukasz.majewski@mailbox.org> > > > Reviewed-by: Stefan Wahren <wahrenst@gmx.net> > > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > > > Transient build failure here: > > > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1072:32: warning: > > variable ‘priv’ set but not used [-Wunused-but-set-variable] 1072 | > > struct mtip_ndev_priv *priv; | > > ^~~~ > > > > I sent out the AI code reviews while at it, without looking at them. > > So please approach them with caution.. > > IMHO, issues pointed with AI review have been at discussed and > (to my best knowledge) addressed. > > Shall I prepare next version of this patch set? > I'm a bit confused regarding the next steps for this driver. There was no reply regarding my last question - and I don't know how I shall proceed... -- Best regards, Łukasz Majewski ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v23 2/7] net: mtip: The L2 switch driver for imx287 2026-02-16 9:23 ` Łukasz Majewski @ 2026-02-17 21:59 ` Jakub Kicinski 0 siblings, 0 replies; 6+ messages in thread From: Jakub Kicinski @ 2026-02-17 21:59 UTC (permalink / raw) To: Łukasz Majewski Cc: Andrew Lunn, davem, Eric Dumazet, Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, Richard Cochran, netdev, devicetree, linux-kernel, imx, linux-arm-kernel, Stefan Wahren, Simon Horman, Andrew Lunn On Mon, 16 Feb 2026 10:23:59 +0100 Łukasz Majewski wrote: > > > Transient build failure here: > > > > > > drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c:1072:32: warning: > > > variable ‘priv’ set but not used [-Wunused-but-set-variable] 1072 | > > > struct mtip_ndev_priv *priv; | > > > ^~~~ > > > > > > I sent out the AI code reviews while at it, without looking at them. > > > So please approach them with caution.. > > > > IMHO, issues pointed with AI review have been at discussed and > > (to my best knowledge) addressed. > > > > Shall I prepare next version of this patch set? > > I'm a bit confused regarding the next steps for this driver. 1. This version didn't build, so it's out. 2. Take the AI review under consideration. 3. Address issues from 1+2. 4. Post v24 Well before posting: 4a) wait for net-next to open up, it's close right now > There was no reply regarding my last question - and I don't know how I > shall proceed... Hope above clarifies. I strongly advise you to follow the ML so you have a better understanding of the process. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-17 22:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04 23:21 [net-next v23 0/7] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski
[not found] ` <20260204232135.1024665-3-lukasz.majewski@mailbox.org>
2026-02-06 2:26 ` [net-next,v23,2/7] net: mtip: The L2 switch driver for imx287 Jakub Kicinski
2026-02-06 2:28 ` [net-next v23 2/7] " Jakub Kicinski
2026-02-06 10:24 ` Łukasz Majewski
2026-02-16 9:23 ` Łukasz Majewski
2026-02-17 21:59 ` Jakub Kicinski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox