Skip to content

mt7620: enable DSA support for external switches - #23933

Merged
openwrt-bot merged 5 commits into
openwrt:mainfrom
namiltd:dsa_new
Jun 29, 2026
Merged

openwrt-bot merged 5 commits into
openwrt:mainfrom
namiltd:dsa_new

Conversation

@namiltd

@namiltd namiltd commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Enable jumbo frame forwarding (up to 2048 bytes) — required for DSA tags with stacked switch chips
  • Fix GDMA register offsets — corrects register definitions in MT7620A_GDMA_OFFSET range
  • Fix MTU update on down interfaces — ensures DSA CPU port tag setup works before interface is brought up
  • Disable HW checksum offloading for incompatible DSA tags — prevents incorrect checksums when non-Mediatek DSA tags are stacked
  • Add mediatek,no-swconfig property support — skips swconfig registration and disables MAC learning for transparent bridge setups

Tested on:

  • TP-Link Archer C5 v4 (RTL8367S version)
  • TP-Link EC220-G5 v2 (RTL8367S version)

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

@namiltd
namiltd marked this pull request as ready for review June 24, 2026 14:11
@github-actions github-actions Bot added kernel pull request/issue with Linux kernel related changes target/ramips pull request/issue for ramips target labels Jun 24, 2026

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@namiltd
namiltd force-pushed the dsa_new branch 2 times, most recently from f4a6201 to 51762e1 Compare June 25, 2026 05:06

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@namiltd

namiltd commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

The patches have been working successfully for several months on the Mercusys AC12G v1 (8M) router (similar to TP-Link Archer C5 v4). Thanks to mediatek,no-swconfig I can finally observe the port status in the general view.

obraz

@namiltd
namiltd marked this pull request as draft June 27, 2026 10:29
@namiltd
namiltd marked this pull request as ready for review June 27, 2026 10:53

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

luizluca and others added 5 commits June 29, 2026 14:54
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]>
@openwrt-bot
openwrt-bot merged commit 0a64c7a into openwrt:main Jun 29, 2026
3 of 4 checks passed
@robimarko

Copy link
Copy Markdown
Contributor

Thanks! Rebased on top of main and merged!

@namiltd
namiltd deleted the dsa_new branch June 29, 2026 13:51
@luizluca

Copy link
Copy Markdown
Contributor

Thanks, @namiltd .

Lienol pushed a commit to Lienol/openwrt that referenced this pull request Jul 11, 2026
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]>
Lienol pushed a commit to Lienol/openwrt that referenced this pull request Jul 11, 2026
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]>
Lienol pushed a commit to Lienol/openwrt that referenced this pull request Jul 11, 2026
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]>
Lienol pushed a commit to Lienol/openwrt that referenced this pull request Jul 11, 2026
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]>
Lienol pushed a commit to Lienol/openwrt that referenced this pull request Jul 11, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel pull request/issue with Linux kernel related changes target/ramips pull request/issue for ramips target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants