net: mtip: Add support for MTIP imx287 L2 switch driver
Subsystems (5)
v5 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 (6):
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: 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 | 141 ++ MAINTAINERS | 7 + arch/arm/boot/dts/nxp/mxs/imx28-xea.dts | 56 + arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 8 +- arch/arm/configs/mxs_defconfig | 14 +- 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 | 1990 +++++++++++++++++ .../net/ethernet/freescale/mtipsw/mtipl2sw.h | 788 +++++++ .../ethernet/freescale/mtipsw/mtipl2sw_br.c | 120 + .../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 449 ++++ 13 files changed, 3578 insertions(+), 13 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 v5 1/6 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
--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +141 -0
@@ -0,0 +1,141 @@ +# 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. + +$ref: ethernet-switch.yaml#/$defs/ethernet-ports + +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 + + pinctrl-names: true + + ethernet-ports: + type: object + additionalProperties: true + properties: + ethernet-port: + type: object + unevaluatedProperties: false + + 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 + - 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>; + 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
Rob Herring
maintainerRe: [net-next v5 1/6] dt-bindings: net: Add MTIP L2 switch description
Quoted 88 lines · Lukasz Majewski
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' node--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yamlDocumentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +49
-0@@ -0,0 +1,141 @@ +# 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. + +$ref: ethernet-switch.yaml#/$defs/ethernet-ports + +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
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 59
Quoted 10 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +10
-0+ + pinctrl-names: true + + ethernet-ports: + type: object + additionalProperties: true + properties: + ethernet-port: + type: object + unevaluatedProperties: false
This is going to fail if you have any property other than 'reg'. But then it will never be applied because you never have a node called 'ethernet-port' since you have more than 1 child node. You need this under 'patternProperties' and 'additionalProperties: true' instead. And please test some of the requirements here. Like a reg value of 3 or remove 'phy-mode'.
Quoted 12 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +12
-0+ + properties: + reg: + items: + - enum: [1, 2] + description: MTIP L2 switch port number + + required: + - reg + - label + - phy-mode + - phy-handle
Re: [net-next v5 1/6] dt-bindings: net: Add MTIP L2 switch description
Hi Rob,
Quoted 99 lines · Lukasz Majewski
Quoted 98 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' node--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644
Documentation/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..6f2b5a277ac2 ---/dev/null
+++b/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml(quoted diff) +0
-0@@ -0,0 +1,141 @@ +# 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 +20
-0+ output (MDIO) for physical layer device (PHY) management. + +$ref: ethernet-switch.yaml#/$defs/ethernet-ports + +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 +18
-0+ - 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 + + pinctrl-names: true + + ethernet-ports:
Quoted 8 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 59
Quoted 6 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +6
-0+ type: object + additionalProperties: true + properties: + ethernet-port: + type: object + unevaluatedProperties: falseThis is going to fail if you have any property other than 'reg'.
The DT schema check shall fail when reg is not equal to 1 or 2, as this switch has only two ports.
Quoted 7 lines
But
then it will never be applied because you never have a node called 'ethernet-port' since you have more than 1 child node. You need this
under 'patternProperties' and 'additionalProperties: true' instead. And please test some of the requirements here. Like a reg value of 3 or remove 'phy-mode'.
In linux-next we now also have realtek,rtl9301-switch.yaml which uses just:
properties:
ethernet-ports:
type: object
but when in "examples" I do remove for example "phy-handle" the command:
make dt_binding_check DT_SCHEMA_FILES=realtek,rtl9301-switch.yaml
is executed without errors.
IMHO the problem is with proper usage of
$ref: ethernet-switch.yaml#/$defs/ethernet-ports
which shall in my case be extended to have:
$ref: ethernet-switch.yaml#/$defs/ethernet-ports/patternProperties
In the case of MTIP - the following SCHEMA description shall be used:
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
And then, when I remove from 'example:' the 'label':
make dt_binding_check DT_SCHEMA_FILES=nxp,imx28-mtip-switch.yaml /Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.example.dtb:
switch@800f0000: ethernet-ports:ethernet-port@2: 'label' is a required property from schema $id:
http://devicetree.org/schemas/net/nxp,imx28-mtip-switch.yaml#
/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.example.dtb:
switch@800f0000: Unevaluated properties are not allowed ('ethernet-ports' was unexpected) from schema $id:
http://devicetree.org/schemas/net/nxp,imx28-mtip-switch.yaml#
or when reg = <3>;
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.example.dtb:
switch@800f0000: ethernet-ports:ethernet-port@2:reg:0:0: 3 is not one of [1, 2]
When I do use the untouched example: node - it compiles without errors.
I do guess that this is the expected behaviour... :-)
Quoted 13 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 71
Quoted 13 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +12
-0+ + properties: + reg: + items: + - enum: [1, 2] + description: MTIP L2 switch port number + + required: + - reg + - label + - phy-mode + - phy-handle
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 v5 1/6] dt-bindings: net: Add MTIP L2 switch description
In reply to Lukasz MajewskiHi Lukasz,
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 78 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' node--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+)create mode 100644
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yamlDocumentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +39
-0@@ -0,0 +1,141 @@ +# 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. + +$ref: ethernet-switch.yaml#/$defs/ethernet-ports + +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:
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 49
Quoted 10 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +10
-0+ - const: ipg + - const: ahb + - const: enet_out + - const: ptp + + interrupts: + items: + - description: Switch interrupt + - description: ENET0 interrupt + - description: ENET1 interrupt
sorry for the late suggestion, but can we have additional interrupt-names here, please?
Re: [net-next v5 1/6] dt-bindings: net: Add MTIP L2 switch description
Hi Stefan,
Quoted 91 lines
Hi Lukasz,
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 88 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' node--- .../bindings/net/nxp,imx28-mtip-switch.yaml | 141++++++++++++++++++ 1 file changed, 141 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..6f2b5a277ac2 ---/dev/null
+++b/Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml(quoted diff) +0
-0@@ -0,0 +1,141 @@ +# 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 +20
-0+ output (MDIO) for physical layer device (PHY) management. + +$ref: ethernet-switch.yaml#/$defs/ethernet-ports + +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 +8
-0+ - description: IEEE1588 timer clock + + clock-names: + items: + - const: ipg + - const: ahb + - const: enet_out + - const: ptp
Quoted 8 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml line 49
Quoted 6 lines
Documentation/devicetree/bindings/net/nxp,imx28-mtip-switch.yaml new file +6
-0+ + interrupts: + items: + - description: Switch interrupt + - description: ENET0 interrupt + - description: ENET1 interruptsorry for the late suggestion, but can we have additional interrupt-names here, please?
I've extended the proper *.yaml file and modified the driver to use platform_get_irq_byname().
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 v5 2/6 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
--- arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +6 -2
@@ -1321,8 +1321,12 @@ 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>; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; status = "disabled"; }; };
Signature · 1 line
2.39.5
Re: [net-next v5 2/6] ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
Hi Lukasz,
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 35 lines
The 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.
Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Andrew Lunn <[email protected]>---
Changes for v2:
- adding extra properties (like compatible, clocks, interupts)Changes for v3:
- NoneChanges for v4:
- Rename imx287 with imx28 (as the former is not used in kernel anymore)Changes for v5:
- None--- arch/arm/boot/dts/nxp/mxs/imx28.dtsi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)arch/arm/boot/dts/nxp/mxs/imx28.dtsi +0
-0@@ -1321,8 +1321,12 @@ mac1: ethernet@800f4000 { status = "disabled"; };
arch/arm/boot/dts/nxp/mxs/imx28.dtsi mac1: ethernet@800f4000 { · line 1330
Quoted 10 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +6
-2- eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; status = "disabled";
from my understanding of device tree this file should describe the hardware, not the software implementation. After this change the switch memory region overlaps the existing mac0 and mac1 nodes.
Definition in the i.MX28 reference manual:
ENET MAC0 ENET 0x800F0000 - 0x800F3FFF 16KB
ENET MAC1 ENET 0x800F4000 - 0x800F7FFF 16KB
ENT Switch SWITCH 0x800F8000 - 0x800FFFFF 32KB
I'm not the expert how to solve this properly. Maybe two node references to mac0 and mac1 under eth_switch in order to allocate the memory regions separately.
Sorry, if i missed a possible discussion about this before.
Regards
Quoted 2 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +0
-0}; };
Re: [net-next v5 2/6] ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
Quoted 13 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi mac1: ethernet@800f4000 { · line 1330
Quoted 9 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +6
-2- eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; status = "disabled";from my understanding of device tree this file should describe the hardware, not the software implementation. After this change the switch memory region overlaps the existing mac0 and mac1 nodes.
Quoted 8 lines
Definition in the i.MX28 reference manual:
ENET MAC0 ENET0x800F0000-0x800F3FFF16KB
ENET MAC1 ENET0x800F4000-0x800F7FFF16KB
ENT Switch SWITCH0x800F8000-0x800FFFFF32KBI'm not the expert how to solve this properly. Maybe two node references to mac0 and mac1 under
eth_switchin order to allocate the memory regions separately.
I get what you are saying about describing the hardware, but...
The hardware can be used in two different ways.
1) Two FEC devices, and the switch it left unused.
For this, it makes sense that each FEC has its own memory range, there are two entries, and each has a compatible, since there are two devices.
2) A switch and MAC conglomerate device, which makes use of all three blocks in a single driver.
The three hardware blocks have to be used as one consistent whole, by a single driver. There is one compatible for the whole. Given the ranges are contiguous, it makes little sense to map them individually, it would just make the driver needlessly more complex.
It should also be noted that 1) and 2) are mutually exclusive, so i don't think it matters the address ranges overlap. Bad things are going to happen independent of this if you enable both at once.
Andrew
Re: [net-next v5 2/6] ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
Hi Andrew,
Am 16.04.25 um 23:58 schrieb Andrew Lunn:
Quoted 39 lines
Quoted 13 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi mac1: ethernet@800f4000 { · line 1330
Quoted 9 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +6
-2- eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + clocks = <&clks 57>, <&clks 57>, <&clks 64>, <&clks 35>; + clock-names = "ipg", "ahb", "enet_out", "ptp"; status = "disabled";from my understanding of device tree this file should describe the hardware, not the software implementation. After this change the switch memory region overlaps the existing mac0 and mac1 nodes.
Quoted 8 lines
Definition in the i.MX28 reference manual:
ENET MAC0 ENET0x800F0000-0x800F3FFF16KB
ENET MAC1 ENET0x800F4000-0x800F7FFF16KB
ENT Switch SWITCH0x800F8000-0x800FFFFF32KBI'm not the expert how to solve this properly. Maybe two node references to mac0 and mac1 under
eth_switchin order to allocate the memory regions separately.I get what you are saying about describing the hardware, but...
The hardware can be used in two different ways.
1) Two FEC devices, and the switch it left unused.
For this, it makes sense that each FEC has its own memory range, there are two entries, and each has a compatible, since there are two devices.
2) A switch and MAC conglomerate device, which makes use of all three blocks in a single driver.
The three hardware blocks have to be used as one consistent whole, by a single driver. There is one compatible for the whole. Given the ranges are contiguous, it makes little sense to map them individually, it would just make the driver needlessly more complex.
Quoted 5 lines
It should also be noted that 1) and 2) are mutually exclusive, so i don't think it matters the address ranges overlap. Bad things are going to happen independent of this if you enable both at once.
Andrew
i wasn't aware how critical possible overlapping memory regions are. I was just surprised because it wasn't mention in the commit message. As long as everyone is fine with this approach, please ignore my last comment.
Regards
Re: [net-next v5 2/6] ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
Hi Stefan,
Quoted 47 lines
Hi Andrew,
Am 16.04.25 um 23:58 schrieb Andrew Lunn:
Quoted 44 lines
Quoted 14 lines
Quoted 10 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +5
-2- eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + clocks = <&clks 57>, <&clks 57>, <&clks64>, <&clks 35>;
(quoted diff) +1
-0+ clock-names = "ipg", "ahb", "enet_out","ptp"; status = "disabled";
from my understanding of device tree this file should describe the hardware, not the software implementation. After this change the switch memory region overlaps the existing mac0 and mac1 nodes.
Quoted 8 lines
Definition in the i.MX28 reference manual:
ENET MAC0 ENET0x800F0000-0x800F3FFF16KB
ENET MAC1 ENET0x800F4000-0x800F7FFF16KB
ENT Switch SWITCH0x800F8000-0x800FFFFF32KBI'm not the expert how to solve this properly. Maybe two node references to mac0 and mac1 under
eth_switchin order to allocate the memory regions separately.I get what you are saying about describing the hardware, but...
The hardware can be used in two different ways.
1) Two FEC devices, and the switch it left unused.
For this, it makes sense that each FEC has its own memory range, there are two entries, and each has a compatible, since there are two devices.
2) A switch and MAC conglomerate device, which makes use of all three blocks in a single driver.
The three hardware blocks have to be used as one consistent whole, by a single driver. There is one compatible for the whole. Given the ranges are contiguous, it makes little sense to map them individually, it would just make the driver needlessly more complex.
It should also be noted that 1) and 2) are mutually exclusive, so i don't think it matters the address ranges overlap. Bad things are going to happen independent of this if you enable both at once.
Quoted 6 lines
Quoted 1 line
Andrew
i wasn't aware how critical possible overlapping memory regions are. I was just surprised because it wasn't mention in the commit message. As long as everyone is fine with this approach, please ignore my last comment.
Just for the record - there was an attempt to "re-use" FEC enet driver in switch [1], but this approach has been rejected as one not very robust and "clear by design" (i.e. similar to cpsw_new.c driver).
And I do agree with Andrew - that approach presented in this patch set is the correct one.
Links:
[1] -
https://source.denx.de/linux/linux-imx28-l2switch/-/commits/imx28-v5.12-L2-upstream-switchdev-RFC_v1
Quoted 2 lines
Regards
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 v5 2/6] ARM: dts: nxp: mxs: Adjust the imx28.dtsi L2 switch description
In reply to Andrew LunnHi Andrew,
Quoted 36 lines
Quoted 14 lines
Quoted 10 lines
arch/arm/boot/dts/nxp/mxs/imx28.dtsi +5
-2- eth_switch: switch@800f8000 { - reg = <0x800f8000 0x8000>; + eth_switch: switch@800f0000 { + compatible = "nxp,imx28-mtip-switch"; + reg = <0x800f0000 0x20000>; + interrupts = <100>, <101>, <102>; + clocks = <&clks 57>, <&clks 57>, <&clks64>, <&clks 35>;
(quoted diff) +1
-0+ clock-names = "ipg", "ahb", "enet_out","ptp"; status = "disabled";
from my understanding of device tree this file should describe the hardware, not the software implementation. After this change the switch memory region overlaps the existing mac0 and mac1 nodes.
Quoted 8 lines
Definition in the i.MX28 reference manual:
ENET MAC0 ENET0x800F0000-0x800F3FFF16KB
ENET MAC1 ENET0x800F4000-0x800F7FFF16KB
ENT Switch SWITCH0x800F8000-0x800FFFFF32KBI'm not the expert how to solve this properly. Maybe two node references to mac0 and mac1 under
eth_switchin order to allocate the memory regions separately.I get what you are saying about describing the hardware, but...
The hardware can be used in two different ways.
1) Two FEC devices, and the switch it left unused.
For this, it makes sense that each FEC has its own memory range, there are two entries, and each has a compatible, since there are two devices.
2) A switch and MAC conglomerate device, which makes use of all three blocks in a single driver.
Quoted 9 lines
The three hardware blocks have to be used as one consistent whole, by a single driver. There is one compatible for the whole. Given the ranges are contiguous, it makes little sense to map them individually, it would just make the driver needlessly more complex.
It should also be noted that 1) and 2) are mutually exclusive, so i don't think it matters the address ranges overlap. Bad things are going to happen independent of this if you enable both at once.
+1
Quoted 1 line
Andrew
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 v5 3/6 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
--- 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
Re: [net-next v5 3/6] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 4 lines
The description is similar to the one used with the new CPSW driver.
Signed-off-by Lukasz Majewski <[email protected]>Reviewed-by Andrew Lunn <[email protected]>
PATCH v5 4/6 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.
--- 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 | 1990 +++++++++++++++++ .../net/ethernet/freescale/mtipsw/mtipl2sw.h | 788 +++++++ .../ethernet/freescale/mtipsw/mtipl2sw_br.c | 120 + .../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 449 ++++ 9 files changed, 3372 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
@@ -9448,6 +9448,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 ARCH_MXS || 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 +1990 -0
1,990 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
62 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 v5 4/6] net: mtip: The L2 switch driver for imx287
Quoted 9 lines · Lukasz Majewski
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]>
Andrew
Re: [net-next v5 4/6] net: mtip: The L2 switch driver for imx287
In reply to Lukasz MajewskiHi Lukasz,
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 202 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).Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v2:- Remove not needed comments
- Restore udelay(10) for switch reset (such delay is explicitly specifed in the documentation
- AddCOMPILE_TEST
- replace pr_* with dev_*
- Usefor_each_available_child_of_node_scoped()
- Use devm_* function for memory allocation
- Remove printing information about the HW and SW revision of the driver
- Usedevm_regulator_get_optional()
- Change compatible prefix from 'fsl' to more up to date 'nxp'
- Remove .owner =THIS_MODULE
- Usedevm_platform_ioremap_resource(pdev, 0);
- Usedevm_request_irq()
- Usedevm_regulator_get_enable_optional()
- Replaceclk_prepare_enable()anddevm_clk_get()with single call todevm_clk_get_optional_enabled()
- Cleanup error patch when function calls in probe fail
- Refactor themtip_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 atesw_mac_addr_static()
- Removemtip_print_link_status()and replace it withphy_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 removemtip_ndev_setup()
- Use-ENOMEMinstead of -1 return code when allocation fails
- Replacedev_info()withdev_dbg()to reduce number of information print on normal operation
- Return ret instead of 0 frommtip_ndev_init()
- Removefep->mii_timeoutflag from the driver
- Remove not used stop_gpr_* fields inmtip_devinfostruct
- Removeplatform_device_iddescription for mtipl2sw driver
- AddMODULE_DEVICE_TABLE()formtip_of_match
- RemoveMODULE_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 theenet_outclock 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
- Replaceeth_mac_addr()witheth_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
- Addclk_disable()andnetif_napi_del()when errors occur duringmtip_open()- refactor the error handling path.
- Refactor themtip_set_multicast_list()to write (now) correct values to ENET-FEC registers.
- Replacedev_warn()withdev_err()
- UseGPIO_ACTIVE_LOWto indicate polarity in DTS
- Refactor code to check if network device is the switch device
- Removemtip_port_dev_check()
- Refactormtip_ndev_port_link()avoid starting HW offloading for bridge when MTIP ports are parts of two distinct bridges
- Replacedel_timer()withtimer_delete_sync()Changes for v5:
- Fix spelling inKconfig
- Replace tmp with reg or register name
- Replace tmpaddr withmac_addr
- Use mac address assignment (from registers) code similar tofec_main.c(as it shall handle properly generic endianess)
- Add description for fep: in themtip_update_atable_static()kernel doc
- Replacewritel(bdp, &fep->cur_rx)withfep->cur_rx= bdp;
- Fix spelling of transmit
- Remove not needed white spaces inmtipl2sw.h
- Remove '_t' from structmtip_addr_table_t
- Provide proper alignment in themtipl2sw.h
- Add blank line after local header inmtipl2sw_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
- IntroduceFEC_QUIRK_SWAP_FRAMEto avoid #ifdef for imx28 proper operation
- Move 'mtip_port_infog_info' to structswitch_enet_private
- Replace some unsigned int with u32 (on data fields with 32 bit size)
- Remove not relevant comments frommtip_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 thedma_map_single()is called
- TheMCF_FEC_MSCRregister can be written unconditionally
for all supported platforms.
- UseIS_ENABLED()instead of #ifdef inmtip_timeout()
- Replacedev_info()withdev_warn_ratelimited()inmtip_switch_rx()
- Add code to handle situation when there is no memory
- Removekfree(fep->mii_bus->irq)
- Provide more verbose output of mdio_{read|write} functions
- Handle error whenclk_enable()fails inmtip_open()
- Usedev_dbg()atmtip_set_multicast_list()
- Simplify themtip_is_switch_netdev_port()function to return condition check value
- Adddev_dbg()whenof_get_mac_address()fails (as it may not be provided)
- Remove return ret; inmtip_register_notifiers()
- Replace int to bool inmtipl2sw_mgnt.cfile'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 frommtip_interrupt()function
- IntroduceMTIP_PORT_FORWARDING_INITto indicate intial value for port forwarding
- Replace 'unsigned long' to 'u32' inmtipl2sw.h
- Replace 'unsigned short' to 'u16' inmtipl2sw.h
- use %#x indev_dbg()
- CallSET_NETDEV_DEV()macro to set network device' parent - otherwisephy_attach_direct()will fail.--- 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 | 1990 +++++++++++++++++ .../net/ethernet/freescale/mtipsw/mtipl2sw.h | 788 +++++++ .../ethernet/freescale/mtipsw/mtipl2sw_br.c | 120 + .../ethernet/freescale/mtipsw/mtipl2sw_mgnt.c | 449 ++++ 9 files changed, 3372 insertions(+)create mode 100644
drivers/net/ethernet/freescale/mtipsw/Kconfigcreate mode 100644drivers/net/ethernet/freescale/mtipsw/Makefilecreate mode 100644drivers/net/ethernet/freescale/mtipsw/mtipl2sw.ccreate mode 100644drivers/net/ethernet/freescale/mtipsw/mtipl2sw.hcreate mode 100644drivers/net/ethernet/freescale/mtipsw/mtipl2sw_br.ccreate mode 100644drivers/net/ethernet/freescale/mtipsw/mtipl2sw_mgnt.cMAINTAINERS +7
-0@@ -9448,6 +9448,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 +0
-0
drivers/net/ethernet/freescale/mtipsw/Kconfig line 7
Quoted 7 lines
drivers/net/ethernet/freescale/mtipsw/Kconfig new file +7
-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 ARCH_MXS || COMPILE_TEST
I think we should align the dependencies with FEC:
depends on SOC_IMX28 || COMPILE_TEST
Quoted 273 lines
drivers/net/ethernet/freescale/mtipsw/Kconfig new file +6
-0+ 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.odrivers/net/ethernet/freescale/mtipsw/mtipl2sw.c new file +252
-0@@ -0,0 +1,1990 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* L2 switch Controller (Ethernet L2 switch) driver for MTIP block. +* +* Copyright (C) 2025 DENX Software Engineering GmbH +* Lukasz Majewski <[email protected]> +* +* Based on a previous work by: +* +* Copyright 2010-2012 Freescale Semiconductor, Inc. +* Alison Wang ([email protected]) +* Jason Jin ([email protected]) +* +* Copyright (C) 2010-2013 Freescale Semiconductor, Inc. All Rights Reserved. +* Shrek Wu ([email protected]) +*/ + +#include <linux/bitops.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/errno.h> +#include <linux/etherdevice.h> +#include <linux/gpio/consumer.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/of_mdio.h> +#include <linux/of_net.h> +#include <linux/of_platform.h> +#include <linux/phy.h> +#include <linux/platform_device.h> +#include <linux/regulator/consumer.h> +#include <linux/rtnetlink.h> +#include <linux/skbuff.h> +#include <linux/slab.h> +#include <linux/spinlock.h> +#include <linux/string.h> + +#include "mtipl2sw.h" + +static void swap_buffer (void *bufaddr,int len) +{ +int i; +unsigned int *buf = bufaddr; + +for (i =0 ; i < len; i +=4 , buf++) +swab32s (buf); +} + +struct mtip_devinfo { +u32 quirks; +}; + +static void mtip_enet_init (struct switch_enet_private *fep,int port) +{ +void __iomem *enet_addr = fep->enet_addr; +u32 mii_speed, holdtime, reg; + +if (port ==2 ) + enet_addr +=MCF_ESW_ENET_PORT_OFFSET ; + + reg =MCF_FEC_RCR_PROM |MCF_FEC_RCR_MII_MODE | +MCF_FEC_RCR_MAX_FL (1522 ); + +if (fep->phy_interface[port -1 ] ==PHY_INTERFACE_MODE_RMII ) + reg |=MCF_FEC_RCR_RMII_MODE ; + +writel (reg, enet_addr +MCF_FEC_RCR ); + +writel (MCF_FEC_TCR_FDEN , enet_addr +MCF_FEC_TCR ); +writel (MCF_FEC_ECR_ETHER_EN , enet_addr +MCF_FEC_ECR ); + + mii_speed =DIV_ROUND_UP (clk_get_rate (fep->clk_ipg),5000000 ); + mii_speed--; + + holdtime =DIV_ROUND_UP (clk_get_rate (fep->clk_ipg),100000000 ) -1 ; + + fep->phy_speed = mii_speed <<1 | holdtime <<8 ; + +writel (fep->phy_speed, enet_addr +MCF_FEC_MSCR ); +} + +static void mtip_setup_mac (struct net_device *dev) +{ +struct mtip_ndev_priv *priv =netdev_priv (dev); +struct switch_enet_private *fep = priv->fep; +unsigned char *iap, mac_addr[ETH_ALEN ]; + +/* Use MAC address from DTS */ + iap = &fep->mac[priv->portnum -1 ][0 ]; + +/* Use MAC address set by bootloader */ +if (!is_valid_ether_addr (iap)) { + *((__be32 *)&mac_addr[0 ]) = +cpu_to_be32 (readl (fep->enet_addr +MCF_FEC_PALR )); + *((__be16 *)&mac_addr[4 ]) = +cpu_to_be16 (readl (fep->enet_addr + +MCF_FEC_PAUR ) >>16 ); + iap = &mac_addr[0 ]; + } + +/* Use random MAC address */ +if (!is_valid_ether_addr (iap)) { +eth_hw_addr_random (dev); +dev_info (&fep->pdev->dev,"Using random MAC address: %pM\n" , + dev->dev_addr); + iap = (unsigned char *)dev->dev_addr; + } + +/* Adjust MAC if using macaddr (and increment if needed) */ +eth_hw_addr_gen (dev, iap, priv->portnum -1 ); +} + +/** +* crc8_calc - calculate CRC for MAC storage +* +* @pmacaddress: A 6-byte array with the MAC address. The first byte is +* the first byte transmitted. +* +* Calculate Galois Field Arithmetic CRC for Polynom x^8+x^2+x+1. +* It omits the final shift in of 8 zeroes a "normal" CRC would do +* (getting the remainder). +* +* Examples (hexadecimal values):<br> +* 10-11-12-13-14-15 => CRC=0xc2 +* 10-11-cc-dd-ee-00 => CRC=0xe6 +* +* Return: The 8-bit CRC in bits 7:0 +*/ +static int crc8_calc (unsigned char *pmacaddress) +{ +int byt;/* byte index */ +int bit;/* bit index */ +int crc =0x12 ; +int inval; + +for (byt =0 ; byt <ETH_ALEN ; byt++) { + inval = (((int )pmacaddress[byt]) &0xFF ); +/* shift bit 0 to bit 8 so all our bits +* travel through bit 8 +* (simplifies below calc) +*/ + inval <<=8 ; + +for (bit =0 ; bit <8 ; bit++) { +/* next input bit comes into d7 after shift */ + crc |= inval &0x100 ; +if (crc &0x01 ) +/* before shift */ + crc ^=0x1C0 ; + + crc >>=1 ; + inval >>=1 ; + } + } +/* upper bits are clean as we shifted in zeroes! */ +return crc; +} + +static void mtip_read_atable (struct switch_enet_private *fep,int index, +u32 *read_lo,u32 *read_hi) +{ +struct addr_table64b_entry *atable_base = + fep->hwentry->mtip_table64b_entry; + + *read_lo =readl (&atable_base[index].lo); + *read_hi =readl (&atable_base[index].hi); +} + +static void mtip_write_atable (struct switch_enet_private *fep,int index, +u32 write_lo,u32 write_hi) +{ +struct addr_table64b_entry *atable_base = + fep->hwentry->mtip_table64b_entry; + +writel (write_lo, &atable_base[index].lo); +writel (write_hi, &atable_base[index].hi); +} + +/** +* mtip_portinfofifo_read - Read element from receive FIFO +* +* @fep: Structure describing switch +* +* Read one element from the HW receive FIFO (Queue) +* if available and return it. +* +* Return: mtip_port_info or NULL if no data is available. +*/ +static +struct mtip_port_info *mtip_portinfofifo_read (struct switch_enet_private *fep) +{ +struct mtip_port_info *info = &fep->g_info; +struct switch_t *fecp = fep->hwp; +u32 reg; + + reg =readl (&fecp->ESW_LSR); +if (reg ==0 ) { +dev_dbg (&fep->pdev->dev,"%s: ESW_LSR = 0x%x\n" , __func__, reg); +return NULL ; + } + +/* read word from FIFO */ + info->maclo =readl (&fecp->ESW_LREC0); +if (info->maclo ==0 ) { +dev_dbg (&fep->pdev->dev,"%s: mac lo 0x%x\n" , __func__, + info->maclo); +return NULL ; + } + +/* read 2nd word from FIFO */ + reg =readl (&fecp->ESW_LREC1); + info->machi = reg &0xFFFF ; + info->hash = (reg >>16 ) &0xFF ; + info->port = (reg >>24 ) &0xF ; + +return info; +} + +static void mtip_atable_get_entry_port_number (struct switch_enet_private *fep, +unsigned char *mac_addr,u8 *port) +{ +int block_index, block_index_end, entry; +u32 mac_addr_lo, mac_addr_hi; +u32 read_lo, read_hi; + + mac_addr_lo = (u32)((mac_addr[3 ] <<24 ) | (mac_addr[2 ] <<16 ) | + (mac_addr[1 ] <<8 ) | mac_addr[0 ]); + mac_addr_hi = (u32)((mac_addr[5 ] <<8 ) | (mac_addr[4 ])); + + block_index =GET_BLOCK_PTR (crc8_calc (mac_addr)); + block_index_end = block_index +ATABLE_ENTRY_PER_SLOT ; + +/* now search all the entries in the selected block */ +for (entry = block_index; entry < block_index_end; entry++) { +mtip_read_atable (fep, entry, &read_lo, &read_hi); + *port =MTIP_PORT_FORWARDING_INIT ; + +if (read_lo == mac_addr_lo && + ((read_hi &0x0000FFFF ) == + (mac_addr_hi &0x0000FFFF ))) { +/* found the correct address */ +if ((read_hi & (1 <<16 )) && (!(read_hi & (1 <<17 )))) + *port =AT_EXTRACT_PORT (read_hi); +break ; + } + } +
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c line 262
Quoted 10 lines
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c new file +10
-0+dev_dbg (&fep->pdev->dev,"%s: MAC: %pM PORT: 0x%x\n" , __func__, + mac_addr, *port); +} + +/* Clear complete MAC Look Up Table */ +void mtip_clear_atable (struct switch_enet_private *fep) +{ +int index; + +for (index =0 ; index <2048 ; index++)
There are a lot of defines for this magic number, please use one of them
Quoted 189 lines
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c new file +189
-0+mtip_write_atable (fep, index,0 ,0 ); +} + +/** +* mtip_update_atable_static - Update switch static address table +* +* @mac_addr: Pointer to the array containing MAC address to +* be put as static entry +* @port: Port bitmask numbers to be added in static entry, +* valid values are 1-7 +* @priority: The priority for the static entry in table +* +* @fep: Pointer to the structure describing the switch +* +* Updates MAC address lookup table with a static entry. +* +* Searches if the MAC address is already there in the block and replaces +* the older entry with the new one. If MAC address is not there then puts +* a new entry in the first empty slot available in the block. +* +* Return: 0 for a successful update else -ENOSPC when no slot available +*/ +static int mtip_update_atable_static (unsigned char *mac_addr,unsigned int port, +unsigned int priority, +struct switch_enet_private *fep) +{ +unsigned long block_index, entry, index_end; +u32 write_lo, write_hi, read_lo, read_hi; + + write_lo = (u32)((mac_addr[3 ] <<24 ) | (mac_addr[2 ] <<16 ) | + (mac_addr[1 ] <<8 ) | mac_addr[0 ]); + write_hi = (u32)(0 | (port << AT_SENTRY_PORTMASK_shift) | + (priority << AT_SENTRY_PRIO_shift) | + (AT_ENTRY_TYPE_STATIC << AT_ENTRY_TYPE_shift) | + (AT_ENTRY_RECORD_VALID << AT_ENTRY_VALID_shift) | + (mac_addr[5 ] <<8 ) | (mac_addr[4 ])); + + block_index =GET_BLOCK_PTR (crc8_calc (mac_addr)); + index_end = block_index +ATABLE_ENTRY_PER_SLOT ; +/* Now search all the entries in the selected block */ +for (entry = block_index; entry < index_end; entry++) { +mtip_read_atable (fep, entry, &read_lo, &read_hi); +/* MAC address matched, so update the +* existing entry +* even if its a dynamic one +*/ +if (read_lo == write_lo && + ((read_hi &0x0000FFFF ) == + (write_hi &0x0000FFFF ))) { +mtip_write_atable (fep, entry, write_lo, write_hi); +return 0 ; + }else if (!(read_hi & (1 <<16 ))) { +/* Fill this empty slot (valid bit zero), +* assuming no holes in the block +*/ +mtip_write_atable (fep, entry, write_lo, write_hi); + fep->at_curr_entries++; +return 0 ; + } + } + +/* No space available for this static entry */ +return -ENOSPC ; +} + +static bool mtip_update_atable_dynamic1 (u32 write_lo,u32 write_hi, +int block_index,unsigned int port, +unsigned int curr_time, +struct switch_enet_private *fep) +{ +unsigned long entry, index_end; +int time, timeold, indexold; +u32 read_lo, read_hi; +unsigned long conf; + +/* prepare update port and timestamp */ + conf =AT_ENTRY_RECORD_VALID << AT_ENTRY_VALID_shift; + conf |=AT_ENTRY_TYPE_DYNAMIC << AT_ENTRY_TYPE_shift; + conf |= curr_time << AT_DENTRY_TIME_shift; + conf |= port << AT_DENTRY_PORT_shift; + conf |= write_hi; + +/* linear search through all slot +* entries and update if found +*/ + index_end = block_index +ATABLE_ENTRY_PER_SLOT ; +/* Now search all the entries in the selected block */ +for (entry = block_index; entry < index_end; entry++) { +mtip_read_atable (fep, entry, &read_lo, &read_hi); +if (read_lo == write_lo && + ((read_hi &0x0000FFFF ) == + (write_hi &0x0000FFFF ))) { +/* found correct address, +* update timestamp. +*/ +mtip_write_atable (fep, entry, write_lo, conf); + +return false; + }else if (!(read_hi & (1 <<16 ))) { +/* slot is empty, then use it +* for new entry +* Note: There are no holes, +* therefore cannot be any +* more that need to be compared. +*/ +mtip_write_atable (fep, entry, write_lo, conf); +/* statistics (we do it between writing +* .hi an .lo due to +* hardware limitation... +*/ + fep->at_curr_entries++; +/* newly inserted */ + +return true; + } + } + +/* No more entry available in block overwrite oldest */ + timeold =0 ; + indexold =0 ; +for (entry = block_index; entry < index_end; entry++) { +mtip_read_atable (fep, entry, &read_lo, &read_hi); + time =AT_EXTRACT_TIMESTAMP (read_hi); +dev_dbg (&fep->pdev->dev,"%s : time %x currtime %x\n" , + __func__, time, curr_time); + time =TIMEDELTA (curr_time, time); +if (time > timeold) { +/* is it older ? */ + timeold = time; + indexold = entry; + } + } + +mtip_write_atable (fep, indexold, write_lo, conf); + +/* Statistics (do it inbetween writing to .lo and .hi */ + fep->at_block_overflows++; +dev_err (&fep->pdev->dev,"%s update time, at_block_overflows %x\n" , + __func__, fep->at_block_overflows); +/* newly inserted */ +return true; +} + +/* dynamicms MAC address table learn and migration */ +static void +mtip_atable_dynamicms_learn_migration (struct switch_enet_private *fep, +int curr_time,unsigned char *mac, +u8 *rx_port) +{ +u8 port =MTIP_PORT_FORWARDING_INIT ; +struct mtip_port_info *port_info; +u32 rx_mac_lo, rx_mac_hi; +unsigned long flags; +int index; + +spin_lock_irqsave (&fep->learn_lock, flags); + +if (mac &&is_valid_ether_addr (mac)) { + rx_mac_lo = (u32)((mac[3 ] <<24 ) | (mac[2 ] <<16 ) | + (mac[1 ] <<8 ) | mac[0 ]); + rx_mac_hi = (u32)((mac[5 ] <<8 ) | (mac[4 ])); + } + + port_info =mtip_portinfofifo_read (fep); +while (port_info) { +/* get block index from lookup table */ + index =GET_BLOCK_PTR (port_info->hash); +mtip_update_atable_dynamic1 (port_info->maclo, port_info->machi, + index, port_info->port, + curr_time, fep); + +if (mac &&is_valid_ether_addr (mac) && + port ==MTIP_PORT_FORWARDING_INIT ) { +if (rx_mac_lo == port_info->maclo && + rx_mac_hi == port_info->machi) { +/* The newly learned MAC is the source of +* our filtered frame. +*/ + port = (u8 )port_info->port; + } + } + port_info =mtip_portinfofifo_read (fep); + } + +if (rx_port) + *rx_port = port; + +spin_unlock_irqrestore (&fep->learn_lock, flags); +}
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c line 461
Quoted 10 lines
drivers/net/ethernet/freescale/mtipsw/mtipl2sw.c new file +10
-0+ +static void mtip_aging_timer (struct timer_list *t) +{ +struct switch_enet_private *fep =from_timer (fep, t, timer_aging); + +if (fep) + fep->curr_time =mtip_timeincrement (fep->curr_time); + +mod_timer (&fep->timer_aging, + jiffies +msecs_to_jiffies (LEARNING_AGING_INTERVAL ));
I'm not sure that fep can actually be NULL. If it's possible please return in order to avoid a NULL pointer deference here, otherwise drop the check.
Thanks
PATCH v5 5/6 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.
---
Changes for v5:
- New patch
--- arch/arm/configs/mxs_defconfig | 11 ----------- 1 file changed, 11 deletions(-)
arch/arm/configs/mxs_defconfig +0 -11
@@ -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
@@ -138,10 +131,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 CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y
Signature · 1 line
2.39.5
Re: [net-next v5 5/6] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1
Hi Lukasz,
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 2 lines
This file is the updated version of
mxs_defconfigfor the v6.15-rc1 linux-next.
thanks for sending this as a separate patch. Unfortunately it's not that simple by replacing the existing mxs_defconfig. We need to double-check all changes to settings, which was enabled before. This should also include a short note for every setting in the commit log, otherwise every reviewer has to do this job. I'll help you here by adding comments ...
Quoted 25 lines
Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v5:
- New patch--- arch/arm/configs/mxs_defconfig | 11 ----------- 1 file changed, 11 deletions(-)arch/arm/configs/mxs_defconfig +0
-3@@ -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
arch/arm/configs/mxs_defconfig CONFIG_MTD=y · line 48
Quoted 4 lines
arch/arm/configs/mxs_defconfig +0
-1@@ -45,7 +42,6 @@ CONFIG_MTD=y CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_BLOCK=y CONFIG_MTD_DATAFLASH=y -CONFIG_MTD_M25P80=y
This is safe because it has been replaced MTD_SPI_NOR, which is still enabled.
arch/arm/configs/mxs_defconfig CONFIG_ENC28J60=y · line 63
Quoted 8 lines
arch/arm/configs/mxs_defconfig +0
-1CONFIG_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
This is okay, because it's enabled implicit by USB_NET_SMSC95XX.
Quoted 4 lines
arch/arm/configs/mxs_defconfig +0
-0CONFIG_CAN_FLEXCAN=m CONFIG_USB_USBNET=y CONFIG_USB_NET_SMSC95XX=y
arch/arm/configs/mxs_defconfig CONFIG_SERIAL_AMBA_PL011=y · line 86
Quoted 10 lines
arch/arm/configs/mxs_defconfig +0
-2@@ -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
This also okay, because it has been deprecated by moving to EXPERT and its replacement GPIO_CDEV is enabled by default.
arch/arm/configs/mxs_defconfig CONFIG_PWM_MXS=y · line 144
Quoted 11 lines
arch/arm/configs/mxs_defconfig +0
-4# CONFIG_HWMON is not set CONFIG_WATCHDOG=y CONFIG_STMP3XXX_RTC_WATCHDOG=y@@ -138,10 +131,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
This is unintended, even it's not your fault Lukasz. NETFS_SUPPORT isn't user select-able anymore, so it's dropped. AFAIU this comes from NFS support, so i think we need to enable CONFIG_NFS_FSCACHE here. Otherwise this caching feature get lost. Since this is a bugfix, this should be separate patch before the syncronization.
@Shawn @Fabio what's your opinion?
Quoted 3 lines
arch/arm/configs/mxs_defconfig +0
-0CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y
Fabio Estevam
reviewerRe: [net-next v5 5/6] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1
Hi Stefan,
Quoted 7 lines · Stefan Wahren
This is unintended, even it's not your fault Lukasz.
NETFS_SUPPORTisn't user select-able anymore, so it's dropped. AFAIU this comes from NFS support, so i think we need to enableCONFIG_NFS_FSCACHEhere. Otherwise this caching feature get lost. Since this is a bugfix, this should be separate patch before the syncronization.@Shawn @Fabio what's your opinion?
Agreed, your suggestions are good ones, thanks.
Re: [net-next v5 5/6] ARM: mxs_defconfig: Update mxs_defconfig to 6.15-rc1
In reply to Stefan WahrenHi Stefan,
Quoted 84 lines
Hi Lukasz,
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 2 lines
This file is the updated version of
mxs_defconfigfor the v6.15-rc1 linux-next.thanks for sending this as a separate patch. Unfortunately it's not that simple by replacing the existing
mxs_defconfig. We need to double-check all changes to settings, which was enabled before. This should also include a short note for every setting in the commit log, otherwise every reviewer has to do this job. I'll help you here by adding comments ...Quoted 25 lines
Signed-off-by Lukasz Majewski <[email protected]>---
Changes for v5:
- New patch--- arch/arm/configs/mxs_defconfig | 11 ----------- 1 file changed, 11 deletions(-)(quoted diff) +0
-0b/arch/arm/configs/mxs_defconfig index
c76d66135abb..91723fdd3c04100644 --- a/arch/arm/configs/mxs_defconfig
+++ b/arch/arm/configs/mxs_defconfigarch/arm/configs/mxs_defconfig +0
-3@@ -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=march/arm/configs/mxs_defconfig CONFIG_MTD=y · line 48
Quoted 4 lines
arch/arm/configs/mxs_defconfig +0
-1@@ -45,7 +42,6 @@ CONFIG_MTD=y CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_BLOCK=y CONFIG_MTD_DATAFLASH=y -CONFIG_MTD_M25P80=yThis is safe because it has been replaced
MTD_SPI_NOR, which is still enabled.arch/arm/configs/mxs_defconfig CONFIG_ENC28J60=y · line 63
Quoted 8 lines
arch/arm/configs/mxs_defconfig +0
-1CONFIG_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=yThis is okay, because it's enabled implicit by
USB_NET_SMSC95XX.Quoted 4 lines
arch/arm/configs/mxs_defconfig +0
-0CONFIG_CAN_FLEXCAN=m CONFIG_USB_USBNET=y CONFIG_USB_NET_SMSC95XX=yarch/arm/configs/mxs_defconfig CONFIG_SERIAL_AMBA_PL011=y · line 86
Quoted 10 lines
arch/arm/configs/mxs_defconfig +0
-2@@ -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=yThis also okay, because it has been deprecated by moving to EXPERT and its replacement
GPIO_CDEVis enabled by default.arch/arm/configs/mxs_defconfig CONFIG_PWM_MXS=y · line 144
Quoted 11 lines
arch/arm/configs/mxs_defconfig +0
-4# CONFIG_HWMON is not set CONFIG_WATCHDOG=y CONFIG_STMP3XXX_RTC_WATCHDOG=y@@ -138,10 +131,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=mThis is unintended, even it's not your fault Lukasz.
NETFS_SUPPORTisn't user select-able anymore, so it's dropped. AFAIU this comes from NFS support, so i think we need to enableCONFIG_NFS_FSCACHEhere. Otherwise this caching feature get lost. Since this is a bugfix, this should be separate patch before the syncronization.
Quoted 5 lines
@Shawn @Fabio what's your opinion?
Quoted 3 lines
arch/arm/configs/mxs_defconfig +0
-0CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_TMPFS_POSIX_ACL=y
Stefan, I will add your comments in next version of this patch. Moreover, I'm going to introduce new patch with the NFS_FSCACHE enabled.
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 v5 6/6 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
--- 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
Re: [net-next v5 6/6] ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch
Am 14.04.25 um 16:01 schrieb Lukasz Majewski:
Quoted 7 lines
This patch enables support for More Than IP L2 switch available on some imx28[7] devices.
Moreover, it also enables
CONFIG_SWITCHDEVandCONFIG_BRIDGErequired by this driver for correct operation.Signed-off-by Lukasz Majewski <[email protected]>