net: mtip: Add support for MTIP imx287 L2 switch driver
Subsystems (5)
v6 cover net: mtip: Add support for MTIP imx287 L2 switch driver
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 floowing 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 down4. 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.
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
Lukasz Majewski (7):
dt-bindings: net: Add MTIP L2 switch description
ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch
net: mtip: The L2 switch driver for imx287
ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE
ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1
ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2
switch
.../bindings/net/nxp,imx28-mtip-switch.yaml | 148 ++ MAINTAINERS | 7 + arch/arm/boot/dts/nxp/mxs/imx28-xea.dts | 56 + arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 9 +- arch/arm/configs/mxs_defconfig | 13 +- drivers/net/ethernet/freescale/Kconfig | 1 + drivers/net/ethernet/freescale/Makefile | 1 + drivers/net/ethernet/freescale/mtipsw/Kconfig | 13 + .../net/ethernet/freescale/mtipsw/Makefile | 3 + .../net/ethernet/freescale/mtipsw/mtipl2sw.c | 1989 +++++++++++++++++ .../net/ethernet/freescale/mtipsw/mtipl2sw.h | 788 +++++++ .../ethernet/freescale/mtipsw/mtipl2sw_br.c | 120 + .../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 449 ++++ 13 files changed, 3586 insertions(+), 11 deletions(-) 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
Signature · 1 line
2.39.5
PATCH v6 1/7 dt-bindings: net: Add MTIP L2 switch description
This patch provides description of the MTIP L2 switch available in some NXP's SOCs - e.g. imx287.
---
Changes for v2:
- Rename the file to match exactly the compatible
(nxp,imx287-mtip-switch)
Changes for v3:
- Remove '-' from const:'nxp,imx287-mtip-switch'
- Use '^port@[12]+$' for port patternProperties
- Drop status = "okay";
- Provide proper indentation for 'example' binding (replace 8 spaces with 4 spaces)
- Remove smsc,disable-energy-detect; property
- Remove interrupt-parent and interrupts properties as not required
- Remove #address-cells and #size-cells from required properties check
- remove description from reg:
- Add $ref: ethernet-switch.yaml#
Changes for v4:
- Use $ref: ethernet-switch.yaml#/$defs/ethernet-ports and remove already referenced properties
- Rename file to nxp,imx28-mtip-switch.yaml
Changes for v5:
- Provide proper description for 'ethernet-port' node
Changes for v6:
- Proper usage of
$ref: ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties when specifying the 'ethernet-ports' property
- Add description and check for interrupt-names property
--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +148 -0
@@ -0,0 +1,148 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/nxp,imx28-mtip-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP SoC Ethernet Switch Controller (L2 MoreThanIP switch) + +maintainers: + - Lukasz Majewski <[email protected]> + +description: + The 2-port switch ethernet subsystem provides ethernet packet (L2) + communication and can be configured as an ethernet switch. It provides the + reduced media independent interface (RMII), the management data input + output (MDIO) for physical layer device (PHY) management. + +properties: + compatible: + const: nxp,imx28-mtip-switch + + reg: + maxItems: 1 + + phy-supply: + description: + Regulator that powers Ethernet PHYs. + + clocks: + items: + - description: Register accessing clock + - description: Bus access clock + - description: Output clock for external device - e.g. PHY source clock + - description: IEEE1588 timer clock + + clock-names: + items: + - const: ipg + - const: ahb + - const: enet_out + - const: ptp + + interrupts: + items: + - description: Switch interrupt + - description: ENET0 interrupt + - description: ENET1 interrupt + + interrupt-names: + items: + - const: mtipl2sw + - const: enet0 + - const: enet1 + + pinctrl-names: true + + ethernet-ports: + type: object + $ref: ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties + additionalProperties: true + + patternProperties: + '^ethernet-port@[12]$': + type: object + additionalProperties: true + properties: + reg: + items: + - enum: [1, 2] + description: MTIP L2 switch port number + + required: + - reg + - label + - phy-mode + - phy-handle + + mdio: + type: object + $ref: mdio.yaml# + unevaluatedProperties: false + description: + Specifies the mdio bus in the switch, used as a container for phy nodes. + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - mdio + - ethernet-ports + +unevaluatedProperties: false + +examples: + - | + #include<dt-bindings/interrupt-controller/irq.h> + switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + pinctrl-names = "default"; + pinctrl-0 = <&mac0_pins_a>, <&mac1_pins_a>; + phy-supply = <®_fec_3v3>; + interrupts = <100>, <101>, <102>; + interrupt-names = "mtipl2sw", "enet0", "enet1"; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + mtip_port1: ethernet-port@1 { + reg = <1>; + label = "lan0"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy0>; + }; + + mtip_port2: ethernet-port@2 { + reg = <2>; + label = "lan1"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy1>; + }; + }; + + mdio_sw: mdio { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&gpio2 13 0>; + reset-delay-us = <25000>; + reset-post-delay-us = <10000>; + + ethphy0: ethernet-phy@0 { + reg = <0>; + }; + + ethphy1: ethernet-phy@1 { + reg = <1>; + }; + }; + };
Signature · 1 line
2.39.5
Re: [net-next v6 1/7] dt-bindings: net: Add MTIP L2 switch description
Am 18.04.25 um 08:07 schrieb Lukasz Majewski:
Quoted 86 lines
This patch provides description of the MTIP L2 switch available in some NXP's SOCs - e.g. imx287.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Rename the file to match exactly the compatible
(nxp,imx287-mtip-switch)Changes for v3:
- Remove '-' from const:'nxp,imx287-mtip-switch'
- Use '^port@[12]+$' for port patternProperties
- Drop status = "okay";
- Provide proper indentation for 'example' binding (replace 8 spaces with 4 spaces)
- Remove smsc,disable-energy-detect; property
- Remove interrupt-parent and interrupts properties as not required
- Remove #address-cells and #size-cells from required properties check
- remove description from reg:
- Add $ref: ethernet-switch.yaml#Changes for v4:
- Use $ref: ethernet-switch.yaml#/$defs/ethernet-ports and remove already referenced properties
- Rename file to nxp,imx28-mtip-switch.yamlChanges for v5:
- Provide proper description for 'ethernet-port' nodeChanges for v6:
- Proper usage of
$ref: ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties when specifying the 'ethernet-ports' property
- Add description and check for interrupt-names property--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+)create mode 100644
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yamlDocumentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +41
-0@@ -0,0 +1,148 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/nxp,imx28-mtip-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP SoC Ethernet Switch Controller (L2 MoreThanIP switch) + +maintainers: + - Lukasz Majewski <[email protected]> + +description: + The 2-port switch ethernet subsystem provides ethernet packet (L2) + communication and can be configured as an ethernet switch. It provides the + reduced media independent interface (RMII), the management data input + output (MDIO) for physical layer device (PHY) management. + +properties: + compatible: + const: nxp,imx28-mtip-switch + + reg: + maxItems: 1 + + phy-supply: + description: + Regulator that powers Ethernet PHYs. + + clocks: + items: + - description: Register accessing clock + - description: Bus access clock + - description: Output clock for external device - e.g. PHY source clock + - description: IEEE1588 timer clock + + clock-names: + items: + - const: ipg + - const: ahb + - const: enet_out + - const: ptp
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +10
-0+ + interrupts: + items: + - description: Switch interrupt + - description: ENET0 interrupt + - description: ENET1 interrupt + + interrupt-names: + items: + - const: mtipl2sw
Sorry for nitpicking, but could we name it similiar to something from the i.MX28 reference manual like "switch" or "enet_switch"
Re: [net-next v6 1/7] dt-bindings: net: Add MTIP L2 switch description
Hi Stefan,
Quoted 98 lines
Am 18.04.25 um 08:07 schrieb Lukasz Majewski:
Quoted 97 lines
This patch provides description of the MTIP L2 switch available in some NXP's SOCs - e.g. imx287.
Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:
- Rename the file to match exactly the compatible
(nxp,imx287-mtip-switch)Changes for v3:
- Remove '-' from const:'nxp,imx287-mtip-switch'
- Use '^port@[12]+$' for port patternProperties
- Drop status = "okay";
- Provide proper indentation for 'example' binding (replace 8 spaces with 4 spaces)
- Remove smsc,disable-energy-detect; property
- Remove interrupt-parent and interrupts properties as not required
- Remove #address-cells and #size-cells from required properties check
- remove description from reg:
- Add $ref: ethernet-switch.yaml#Changes for v4:
- Use $ref: ethernet-switch.yaml#/$defs/ethernet-ports and remove already referenced properties
- Rename file to nxp,imx28-mtip-switch.yamlChanges for v5:
- Provide proper description for 'ethernet-port' nodeChanges for v6:
- Proper usage of
$ref:
ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties when specifying the 'ethernet-ports' property
- Add description and check for interrupt-names property--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 148++++++++++++++++++ 1 file changed, 148 insertions(+)
create mode 100644Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yamldiff --git
a/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yamlb/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yamlnew file mode 100644 index 000000000000..3e2d724074d5 ---/dev/null
+++b/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml(quoted diff) +0
-0@@ -0,0 +1,148 @@ +# SPDX-License-Identifier: (GPL-2.0-only ORBSD-2-Clause) +%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/nxp,imx28-mtip-switch.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +8
-0+ +title: NXP SoC Ethernet Switch Controller (L2 MoreThanIP switch) + +maintainers: + - Lukasz Majewski <[email protected]> + +description: + The 2-port switch ethernet subsystem provides ethernet packet(L2)
+ communication and can be configured as an ethernet switch. It provides the
+ reduced media independent interface (RMII), the management data inputDocumentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +18
-0+ output (MDIO) for physical layer device (PHY) management. + +properties: + compatible: + const: nxp,imx28-mtip-switch + + reg: + maxItems: 1 + + phy-supply: + description: + Regulator that powers Ethernet PHYs. + + clocks: + items: + - description: Register accessing clock + - description: Bus access clock + - description: Output clock for external device - e.g. PHYsource clock
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +12
-0+ - description: IEEE1588 timer clock + + clock-names: + items: + - const: ipg + - const: ahb + - const: enet_out + - const: ptp + + interrupts: + items: + - description: Switch interrupt
Quoted 8 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 51
Quoted 6 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +6
-0+ - description: ENET0 interrupt + - description: ENET1 interrupt + + interrupt-names: + items: + - const: mtipl2swSorry for nitpicking, but could we name it similiar to something from the i.MX28 reference manual like "switch" or "
enet_switch"
I think that "enet_switch" may be OK.
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH v6 2/7 ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
In reply to Lukasz MajewskiThe current range of 'reg' property is too small to allow full control of the L2 switch on imx287.
As this IP block also uses ENET-MAC blocks for its operation, the address range for it must be included as well.
Moreover, some SoC common properties (like compatible, clocks, interrupts numbers) have been moved to this node.
---
Changes for v2:
- adding extra properties (like compatible, clocks, interupts)
Changes for v3:
- None
Changes for v4:
- Rename imx287 with imx28 (as the former is not used in kernel anymore)
Changes for v5:
- None
Changes for v6:
- Add interrupt-names property
--- arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +7 -2
@@ -1321,8 +1321,13 @@ mac1: ethernet@800f4000 { status = "disabled"; }; - eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + interrupt-names = "mtipl2sw", "enet0", "enet1"; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; status = "disabled"; }; };
Signature · 1 line
2.39.5
PATCH v6 3/7 ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch
In reply to Lukasz MajewskiThe description is similar to the one used with the new CPSW driver.
---
Changes for v2:
- Remove properties which are common for the imx28(7) SoC
- Use mdio properties to perform L2 switch reset (avoid using deprecated properties)
Changes for v3:
- Replace IRQ_TYPE_EDGE_FALLING with IRQ_TYPE_LEVEL_LOW
- Update comment regarding PHY interrupts s/AND/OR/g
Changes for v4:
- Use GPIO_ACTIVE_LOW instead of 0 in 'reset-gpios'
- Replace port@[12] with ethernet-port@[12]
Changes for v5:
- Add proper multiline comment for IRQs description
Changes for v6:
- None
--- arch/arm/boot/dts/nxp/mxs/imx28-xea.dts | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
arch/arm/boot/dts/nxp/mxs/imx28-xea.dts +56 -0
@@ -5,6 +5,7 @@ */ /dts-v1/; +#include<dt-bindings/interrupt-controller/irq.h> #include "imx28-lwe.dtsi" / {
@@ -90,6 +91,61 @@ ®_usb_5v { gpio = <&gpio0 2 0>; }; +ð_switch { + pinctrl-names = "default"; + pinctrl-0 = <&mac0_pins_a>, <&mac1_pins_a>; + phy-supply = <®_fec_3v3>; + status = "okay"; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + mtip_port1: ethernet-port@1 { + reg = <1>; + label = "lan0"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy0>; + }; + + mtip_port2: ethernet-port@2 { + reg = <2>; + label = "lan1"; + local-mac-address = [ 00 00 00 00 00 00 ]; + phy-mode = "rmii"; + phy-handle = <ðphy1>; + }; + }; + + mdio_sw: mdio { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&gpio3 21 GPIO_ACTIVE_LOW>; + reset-delay-us = <25000>; + reset-post-delay-us = <10000>; + + ethphy0: ethernet-phy@0 { + reg = <0>; + smsc,disable-energy-detect; + /* + * Both PHYs (i.e. 0,1) have the same, single GPIO, + * line to handle both, their interrupts (OR'ed) + */ + interrupt-parent = <&gpio4>; + interrupts = <13 IRQ_TYPE_LEVEL_LOW>; + }; + + ethphy1: ethernet-phy@1 { + reg = <1>; + smsc,disable-energy-detect; + interrupt-parent = <&gpio4>; + interrupts = <13 IRQ_TYPE_LEVEL_LOW>; + }; + }; +}; + &spi2_pins_a { fsl,pinmux-ids = < MX28_PAD_SSP2_SCK__SSP2_SCK
Signature · 1 line
2.39.5
PATCH v6 4/7 net: mtip: The L2 switch driver for imx287
In reply to Lukasz MajewskiThis 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).
---
Changes for v2:
- Remove not needed comments
- Restore udelay(10) for switch reset (such delay is explicitly specifed in the documentation
- Add COMPILE_TEST
- replace pr_* with dev_*
- Use for_each_available_child_of_node_scoped()
- Use devm_* function for memory allocation
- Remove printing information about the HW and SW revision of the driver
- Use devm_regulator_get_optional()
- Change compatible prefix from 'fsl' to more up to date 'nxp'
- Remove .owner = THIS_MODULE
- Use devm_platform_ioremap_resource(pdev, 0);
- Use devm_request_irq()
- Use devm_regulator_get_enable_optional()
- Replace clk_prepare_enable() and devm_clk_get() with single call to devm_clk_get_optional_enabled()
- Cleanup error patch when function calls in probe fail
- Refactor the mtip_reset_phy() to serve as mdio bus reset callback
- Add myself as the MTIP L2 switch maintainer (squashed the separated commit)
- More descriptive help paragraphs (> 4 lines)
Changes for v3:
- Remove 'bridge_offloading' module parameter (to bridge ports just after probe)
- Remove forward references
- Fix reverse christmas tree formatting in functions
- Convert eligible comments to kernel doc format
- Remove extra MAC address validation check at esw_mac_addr_static()
- Remove mtip_print_link_status() and replace it with phy_print_status()
- Avoid changing phy device state in the driver (instead use functions exported by the phy API)
- Do not print extra information regarding PHY (which is printed by phylib) - e.g. net lan0: lan0: MTIP eth L2 switch 1e:ce:a5:0b:4c:12
- Remove VERSION from the driver - now we rely on the SHA1 in Linux mainline tree
- Remove zeroing of the net device private area (shall be already done during allocation)
- Refactor the code to remove mtip_ndev_setup()
- Use -ENOMEM instead of -1 return code when allocation fails
- Replace dev_info() with dev_dbg() to reduce number of information print on normal operation
- Return ret instead of 0 from mtip_ndev_init()
- Remove fep->mii_timeout flag from the driver
- Remove not used stop_gpr_* fields in mtip_devinfo struct
- Remove platform_device_id description for mtipl2sw driver
- Add MODULE_DEVICE_TABLE() for mtip_of_match
- Remove MODULE_ALIAS()
Changes for v4:
- Rename imx287 with imx28 (as the former is not used in kernel anymore)
- Reorder the place where ENET interface is initialized - without this change the enet_out clock has default (25 MHz) value, which causes issues during reset (RMII's 50 MHz is required for proper PHY reset).
- Use PAUR instead of PAUR register to program MAC address
- Replace eth_mac_addr() with eth_hw_addr_set()
- Write to HW the randomly generated MAC address (if required)
- Adjust the reset code
- s/read_atable/mtip_read_atable/g and s/write_atable/mtip_write_atable/g
- Add clk_disable() and netif_napi_del() when errors occur during mtip_open() - refactor the error handling path.
- Refactor the mtip_set_multicast_list() to write (now) correct values to ENET-FEC registers.
- Replace dev_warn() with dev_err()
- Use GPIO_ACTIVE_LOW to indicate polarity in DTS
- Refactor code to check if network device is the switch device
- Remove mtip_port_dev_check()
- Refactor mtip_ndev_port_link() avoid starting HW offloading for bridge when MTIP ports are parts of two distinct bridges
- Replace del_timer() with timer_delete_sync()
Changes for v5:
- Fix spelling in Kconfig
- Replace tmp with reg or register name
- Replace tmpaddr with mac_addr
- Use mac address assignment (from registers) code similar to fec_main.c (as it shall handle properly generic endianess)
- Add description for fep: in the mtip_update_atable_static() kernel doc
- Replace writel(bdp, &fep->cur_rx) with fep->cur_rx = bdp;
- Fix spelling of transmit
- Remove not needed white spaces in mtipl2sw.h
- Remove '_t' from struct mtip_addr_table_t
- Provide proper alignment in the mtipl2sw.h
- Add blank line after local header in mtipl2sw_br.c
- Use %p instead of %x (and cast) for fep in debug message
- Disable L2 switch in-HW offloading when only one
of eligible ports is removed from the bridge
- Sort includes in the patch set alphabethically
- Introduce FEC_QUIRK_SWAP_FRAME to avoid #ifdef for imx28 proper operation
- Move 'mtip_port_info g_info' to struct switch_enet_private
- Replace some unsigned int with u32 (on data fields with 32 bit size)
- Remove not relevant comments from mtip_enet_init()
- Refactor functions definitions to be void when no other
value than 0 is returned.
- Use capital letters in HEX constants
- Use u32 instead of unsigned int when applicable
- Add error handling code after the dma_map_single() is called
- The MCF_FEC_MSCR register can be written unconditionally
for all supported platforms.
- Use IS_ENABLED() instead of #ifdef in mtip_timeout()
- Replace dev_info() with dev_warn_ratelimited() in mtip_switch_rx()
- Add code to handle situation when there is no memory
- Remove kfree(fep->mii_bus->irq)
- Provide more verbose output of mdio_{read|write} functions
- Handle error when clk_enable() fails in mtip_open()
- Use dev_dbg() at mtip_set_multicast_list()
- Simplify the mtip_is_switch_netdev_port() function to return condition check value
- Add dev_dbg() when of_get_mac_address() fails (as it may not be provided)
- Remove return ret; in mtip_register_notifiers()
- Replace int to bool in mtipl2sw_mgnt.c file's function definitions
- Replace unsigned int/long with u32 where applicable (where access to 32 bit registers is performed)
- Refactor code in mtip_{read|write}_atable() to be more readable
- Remove code added for not (yet) supported IMX's vf610 SoC
- Remove do { } while(); loop from mtip_interrupt() function
- Introduce MTIP_PORT_FORWARDING_INIT to indicate intial value for port forwarding
- Replace 'unsigned long' to 'u32' in mtipl2sw.h
- Replace 'unsigned short' to 'u16' in mtipl2sw.h
- use %#x in dev_dbg()
- Call SET_NETDEV_DEV() macro to set network device' parent - otherwise phy_attach_direct() will fail.
Changes for v6:
- Use dev_name(&pdev->dev) when requesting IRQ (to be in sync with other subsystems)
- Use platform_get_irq_byname() for beter readability
- Replace ARCH_MXS with SOC_IMX28
- Replace 2048 with MTIP_ATABLE_MEM_NUM_ENTRIES
- Remove check if fep == NULL in mtip_aging_timer() as timer can be setup only after the fep structure is allocated and already filled durring probe() execution
--- 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 | 3 + .../net/ethernet/freescale/mtipsw/mtipl2sw.c | 1989 +++++++++++++++++ .../net/ethernet/freescale/mtipsw/mtipl2sw.h | 788 +++++++ .../ethernet/freescale/mtipsw/mtipl2sw_br.c | 120 + .../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 449 ++++ 9 files changed, 3371 insertions(+) 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
MAINTAINERS +7 -0
@@ -9449,6 +9449,13 @@ S: Maintained F: Documentation/devicetree/bindings/i2c/i2c-mpc.yaml F: drivers/i2c/busses/i2c-mpc.c +FREESCALE MTIP ETHERNET SWITCH DRIVER +M: Lukasz Majewski <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml +F: drivers/net/ethernet/freescale/mtipsw/* + FREESCALE QORIQ DPAA ETHERNET DRIVER M: Madalin Bucur <[email protected]> L: [email protected]
drivers/net/ethernet/freescale/Kconfig +1 -0
@@ -60,6 +60,7 @@ config FEC_MPC52xx_MDIO source "drivers/net/ethernet/freescale/fs_enet/Kconfig" source "drivers/net/ethernet/freescale/fman/Kconfig" +source "drivers/net/ethernet/freescale/mtipsw/Kconfig" config FSL_PQ_MDIO tristate "Freescale PQ MDIO"
drivers/net/ethernet/freescale/Makefile +1 -0
@@ -25,3 +25,4 @@ obj-$(CONFIG_FSL_DPAA_ETH) += dpaa/ obj-$(CONFIG_FSL_DPAA2_ETH) += dpaa2/ obj-y += enetc/ +obj-y += mtipsw/
drivers/net/ethernet/freescale/mtipsw/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +config FEC_MTIP_L2SW + tristate "MoreThanIP L2 switch support to FEC driver" + 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 + hardware and allows switch management with standard Linux tools. + This switch driver can be used interchangeable with the already + available FEC driver, depending on the use case's requirements.
drivers/net/ethernet/freescale/mtipsw/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_FEC_MTIP_L2SW) += mtipl2sw.o mtipl2sw_mgnt.o mtipl2sw_br.o
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c new file +1989 -0
1,989 lines not on this page · raw message
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.h new file +788 -0
788 lines not on this page · raw message
drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.c new file +120 -0
120 lines not on this page · raw message
drivers/net/ethernet/freescale/mtipsw/mtipl2sw_mgnt.c new file +449 -0
63 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.5
Part of the diff is not shown here. View the raw message.
Re: [net-next v6 4/7] net: mtip: The L2 switch driver for imx287
Am 18.04.25 um 08:07 schrieb Lukasz Majewski:
Quoted 9 lines
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.
Quoted 6 lines
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 <[email protected]>
After changing the IRQ name part mention in patch 1, you can add
Thanks
Re: [net-next v6 4/7] net: mtip: The L2 switch driver for imx287
Hi Stefan,
Quoted 16 lines
Am 18.04.25 um 08:07 schrieb Lukasz Majewski:
Quoted 15 lines
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).
Quoted 5 lines
Quoted 1 line
Signed-off-by Lukasz Majewski <[email protected]>After changing the IRQ name part mention in patch 1, you can add
Reviewed-by Stefan Wahren <[email protected]>
Shall I add RoB tag to all patches?
I will wait for ACK from at least Andrew and then reset the v7 with all tags collected.
Quoted 1 line
Thanks
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]
Re: [net-next v6 4/7] net: mtip: The L2 switch driver for imx287
Am 18.04.25 um 11:02 schrieb Lukasz Majewski:
Quoted 18 lines
Hi Stefan,
Quoted 16 lines
Am 18.04.25 um 08:07 schrieb Lukasz Majewski:
Quoted 15 lines
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).
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Lukasz Majewski <[email protected]>After changing the IRQ name part mention in patch 1, you can add
Reviewed-by Stefan Wahren <[email protected]>Shall I add RoB tag to all patches?
In case you mean Reviewed-by: yes
Quoted 17 lines
I will wait for ACK from at least Andrew and then reset the v7 with all tags collected.
Quoted 1 line
Thanks
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH v6 5/7 ARM: mxs_defconfig: Enable CONFIG_NFS_FSCACHE
In reply to Lukasz MajewskiIt is not possible to enable by user the CONFIG_NETFS_SUPPORT anymore and hence it depends on CONFIG_NFS_FSCACHE being enabled.
This patch fixes potential performance regression for NFS on the mxs devices.
---
Changes for v6:
- New patch
--- arch/arm/configs/mxs_defconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm/configs/mxs_defconfig +1 -2
@@ -138,8 +138,6 @@ CONFIG_PWM_MXS=y CONFIG_NVMEM_MXS_OCOTP=y CONFIG_EXT4_FS=y # CONFIG_DNOTIFY is not set -CONFIG_NETFS_SUPPORT=m -CONFIG_FSCACHE=y CONFIG_FSCACHE_STATS=y CONFIG_CACHEFILES=m CONFIG_VFAT_FS=y
@@ -155,6 +153,7 @@ CONFIG_NFS_FS=y CONFIG_NFS_V3_ACL=y CONFIG_NFS_V4=y CONFIG_ROOT_NFS=y +CONFIG_NFS_FSCACHE=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_CODEPAGE_850=y CONFIG_NLS_ISO8859_1=y
Signature · 1 line
2.39.5
PATCH v6 6/7 ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1
In reply to Lukasz MajewskiThis file is the updated version of mxs_defconfig for the v6.15-rc1 linux-next.
Detailed description of removed configuration entries:
-CONFIG_MTD_M25P80=y -> it has been replaced MTD_SPI_NOR (which is enabled) -CONFIG_SMSC_PHY=y -> is enabled implicit by USB_NET_SMSC95XX -CONFIG_GPIO_SYSFS=y -> it has been deprecated by moving to EXPERT and
its replacement GPIO_CDEV is enabled by default
---
Changes for v5:
- New patch
Changes for v6:
- Add detailed description on the removed configuration options after update
--- arch/arm/configs/mxs_defconfig | 7 ------- 1 file changed, 7 deletions(-)
arch/arm/configs/mxs_defconfig +0 -7
@@ -32,9 +32,6 @@ CONFIG_INET=y CONFIG_IP_PNP=y CONFIG_IP_PNP_DHCP=y CONFIG_SYN_COOKIES=y -# CONFIG_INET_XFRM_MODE_TRANSPORT is not set -# CONFIG_INET_XFRM_MODE_TUNNEL is not set -# CONFIG_INET_XFRM_MODE_BEET is not set # CONFIG_INET_DIAG is not set # CONFIG_IPV6 is not set CONFIG_CAN=m
@@ -45,7 +42,6 @@ CONFIG_MTD=y CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_BLOCK=y CONFIG_MTD_DATAFLASH=y -CONFIG_MTD_M25P80=y CONFIG_MTD_SST25L=y CONFIG_MTD_RAW_NAND=y CONFIG_MTD_NAND_GPMI_NAND=y
@@ -60,7 +56,6 @@ CONFIG_ENC28J60=y CONFIG_ICPLUS_PHY=y CONFIG_MICREL_PHY=y CONFIG_REALTEK_PHY=y -CONFIG_SMSC_PHY=y CONFIG_CAN_FLEXCAN=m CONFIG_USB_USBNET=y CONFIG_USB_NET_SMSC95XX=y
@@ -77,13 +72,11 @@ CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y CONFIG_SERIAL_MXS_AUART=y # CONFIG_HW_RANDOM is not set -# CONFIG_I2C_COMPAT is not set CONFIG_I2C_CHARDEV=y CONFIG_I2C_MXS=y CONFIG_SPI=y CONFIG_SPI_GPIO=m CONFIG_SPI_MXS=y -CONFIG_GPIO_SYSFS=y # CONFIG_HWMON is not set CONFIG_WATCHDOG=y CONFIG_STMP3XXX_RTC_WATCHDOG=y
Signature · 1 line
2.39.5
PATCH v6 7/7 ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch
In reply to Lukasz MajewskiThis patch enables support for More Than IP L2 switch available on some imx28[7] devices.
Moreover, it also enables CONFIG_SWITCHDEV and CONFIG_BRIDGE required by this driver for correct operation.
---
Changes for v4:
- New patch
Changes for v5:
- Apply this patch on top of patch, which updates mxs_defconfig to v6.15-rc1
- Add more verbose commit message with explanation why SWITCHDEV and BRIDGE must be enabled as well
Changes for v6:
- None
--- arch/arm/configs/mxs_defconfig | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/configs/mxs_defconfig +3 -0
@@ -34,6 +34,8 @@ CONFIG_IP_PNP_DHCP=y CONFIG_SYN_COOKIES=y # CONFIG_INET_DIAG is not set # CONFIG_IPV6 is not set +CONFIG_BRIDGE=y +CONFIG_NET_SWITCHDEV=y CONFIG_CAN=m # CONFIG_WIRELESS is not set CONFIG_DEVTMPFS=y
@@ -52,6 +54,7 @@ CONFIG_EEPROM_AT24=y CONFIG_SCSI=y CONFIG_BLK_DEV_SD=y CONFIG_NETDEVICES=y +CONFIG_FEC_MTIP_L2SW=y CONFIG_ENC28J60=y CONFIG_ICPLUS_PHY=y CONFIG_MICREL_PHY=y
Signature · 1 line
2.39.5