Repository navigation
mt7620: enable DSA support for external switches - #23933
Conversation
openwrt-ai
left a comment
There was a problem hiding this comment.
Reviewed 5 commits (fresh review). The functional changes look sound: the GSW_REG_GMACCR relocation (0x30E0 -> 0x3FE0) sits correctly next to the SMACCR/CKGCR registers, the MT7620A_GDMA offset cleanup matches the commit rationale, the fe_change_mtu rework correctly applies register changes while the interface is down without calling fe_open on a stopped device, and fe_features_check reasonably disables checksum/GSO offload for non-MTK (or stacked) DSA tags. Commit messages all match their diffs. Two minor nits inline.
Generated by Claude Code
f4a6201 to
51762e1
Compare
openwrt-ai
left a comment
There was a problem hiding this comment.
Reviewed the changes since my last review (force-push 26a66da → 51762e1); no new issues found. All three prior review threads were addressed correctly: the magic 0x00000010 is now the named REG_ESW_PORT_PSC_SA_DIS BIT(4) (value matches), of_property_read_bool → of_property_present, and the two identical max_mtu = 2048 blocks were folded into one condition.
Generated by Claude Code
openwrt-ai
left a comment
There was a problem hiding this comment.
Reviewed the changes since my last review (force-push 51762e1 → c7e4a2a); no new issues found. The series was rebased onto current main and the mediatek,no-swconfig commit message was expanded (clarifying that disabling MAC learning is only required for DSA). The only code change is cosmetic: the dev_err/pr_info strings in mt7530_probe now use swdev->name instead of a literal "mt7530", and the REG_ESW_PORT_PSC_SA_DIS BIT(4) / of_property_present / single max_mtu = 2048 fixes from the prior round remain in place. Commit messages still match their diffs.
Generated by Claude Code
mt7620 can forward jumbo frames up to 2048. The fe_change_mtu() was already compatible except for the GDM_FWD_CFG address. An MTU greater than 1500 is required to use DSA tags with a stacked switch chip. This patch enables jumbo frame support by default. Signed-off-by: Andrey Melnikov <[email protected]> Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
Registers in MT7620A_GDMA_OFFSET range were incorrect, except for the first one GDM_FWD_CFG (which is actually the only one in use). The next and last register is GDM_SHPR_CFG. All others are not mentioned in docs. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
fe_change_mtu didn't update the registers if the interface was down. DSA increases the CPU port MTU to accommodate the CPU tag. As this happens while the CPU port was still down, the chip regs didn't get updated and larger frames were dropped. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
DSA copies the driver features to slave device, including offload capabilites. Once a packet is sent though a DSA slave interface, according to its features, the kernel does not calculate checksums, expecting that the HW will fill the gaps. DSA adds the defined DSA tag and sends the tagged packet through the master device. Ethertype DSA tags expect the driver to calculate checksum based on the csum_start/csum_offset. However, mtk_eth_soc does not use that info. mtk_eth_soc checks the network header and decides if the HW can manage that packet, unaware that mac layer now contains an extra DSA tag. When that tag is the Mediatek CPU tag, offload will work as expected. When it is an incompatible DSA tag (all but Mediatek) or if DSA is stacking two incompatible DSA tags, the driver will still count on the HW offload. In this case, packets go to the network with an incorrect checksum. This patch adds an extra check and disables offloading when DSA tag is in use and it is not Mediatek. Offloading is also disabled even when DSA tag is Mediatek but there is something else increasing the mac layer region (possibly another stacked tag). Mediatek tag can encode 802.1Q info and using vlan tags will still use offloading. Other mac layer protocols that are not supported by Mediatek will disable HW offloading. PPPoE was not tested but it is expected that it will disable offloading. This code is heuristically trying to keep HW offload enable with DSA tags. Anyway, in the worse case, offloading is disabled and there is an increase in overhead, which is better than packet with wrong checksum. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
Skip swconfig registration and disable MAC learning when the "mediatek,no-swconfig" property is set. This is needed for MT7620 devices using the internal switch as a transparent bridge to an external RGMII switch, where ports 0-4 are unused. The no-swconfig property itself is valid for both DSA and non-DSA setups. However, disabling MAC learning is only required for DSA, where multiple CPU-facing interfaces would otherwise cause an incorrect ARL table to be built. Non-DSA setups work correctly without disabling MAC learning. Signed-off-by: Mieczyslaw Nalewaj <[email protected]> Link: openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
|
Thanks! Rebased on top of main and merged! |
|
Thanks, @namiltd . |
mt7620 can forward jumbo frames up to 2048. The fe_change_mtu() was already compatible except for the GDM_FWD_CFG address. An MTU greater than 1500 is required to use DSA tags with a stacked switch chip. This patch enables jumbo frame support by default. Signed-off-by: Andrey Melnikov <[email protected]> Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt/openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
Registers in MT7620A_GDMA_OFFSET range were incorrect, except for the first one GDM_FWD_CFG (which is actually the only one in use). The next and last register is GDM_SHPR_CFG. All others are not mentioned in docs. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt/openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
fe_change_mtu didn't update the registers if the interface was down. DSA increases the CPU port MTU to accommodate the CPU tag. As this happens while the CPU port was still down, the chip regs didn't get updated and larger frames were dropped. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt/openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
DSA copies the driver features to slave device, including offload capabilites. Once a packet is sent though a DSA slave interface, according to its features, the kernel does not calculate checksums, expecting that the HW will fill the gaps. DSA adds the defined DSA tag and sends the tagged packet through the master device. Ethertype DSA tags expect the driver to calculate checksum based on the csum_start/csum_offset. However, mtk_eth_soc does not use that info. mtk_eth_soc checks the network header and decides if the HW can manage that packet, unaware that mac layer now contains an extra DSA tag. When that tag is the Mediatek CPU tag, offload will work as expected. When it is an incompatible DSA tag (all but Mediatek) or if DSA is stacking two incompatible DSA tags, the driver will still count on the HW offload. In this case, packets go to the network with an incorrect checksum. This patch adds an extra check and disables offloading when DSA tag is in use and it is not Mediatek. Offloading is also disabled even when DSA tag is Mediatek but there is something else increasing the mac layer region (possibly another stacked tag). Mediatek tag can encode 802.1Q info and using vlan tags will still use offloading. Other mac layer protocols that are not supported by Mediatek will disable HW offloading. PPPoE was not tested but it is expected that it will disable offloading. This code is heuristically trying to keep HW offload enable with DSA tags. Anyway, in the worse case, offloading is disabled and there is an increase in overhead, which is better than packet with wrong checksum. Signed-off-by: Luiz Angelo Daros de Luca <[email protected]> Link: openwrt/openwrt#23933 Signed-off-by: Robert Marko <[email protected]>
Skip swconfig registration and disable MAC learning when the "mediatek,no-swconfig" property is set. This is needed for MT7620 devices using the internal switch as a transparent bridge to an external RGMII switch, where ports 0-4 are unused. The no-swconfig property itself is valid for both DSA and non-DSA setups. However, disabling MAC learning is only required for DSA, where multiple CPU-facing interfaces would otherwise cause an incorrect ARL table to be built. Non-DSA setups work correctly without disabling MAC learning. Signed-off-by: Mieczyslaw Nalewaj <[email protected]> Link: openwrt/openwrt#23933 Signed-off-by: Robert Marko <[email protected]>

This PR adds prerequisite changes to mt7620 that enable connecting external switches via DSA.
The mt7620 internal switch itself does not support DSA. These changes allow the SoC to work correctly with external DSA-capable switches connected via RGMII.
Changes:
MT7620A_GDMA_OFFSETrangemediatek,no-swconfigproperty support — skips swconfig registration and disables MAC learning for transparent bridge setupsTested on:
For both routers there are versions with the RTL8367S or RTL8367S-VB switch. The transition to DSA is on hold for them until RTL8367S-VB support is also implemented. Link: #19397