Skip to content

ramips: mt7620: add DSA support for integrated switch - #24493

Merged
openwrt-bot merged 2 commits into
openwrt:mainfrom
dormancygrace:mt7620-dsa
Aug 20, 2026
Merged

openwrt-bot merged 2 commits into
openwrt:mainfrom
dormancygrace:mt7620-dsa

Conversation

@dormancygrace

@dormancygrace dormancygrace commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add common DSA support for the seven-port switch integrated in MT7620 while preserving the existing swconfig path for device trees without a ports node.

This PR deliberately migrates no individual boards. A board opts into DSA by describing the switch ports in DT and including kmod-dsa-mt7620 in DEVICE_PACKAGES; existing MT7620 devices continue using swconfig without building DSA or switchdev support.

The data path uses the frame engine's descriptor metadata rather than an in-frame tag: TXD4 carries the forced egress bitmap and RXD4 reports the ingress source port. A ramips-local Ralink metadata tagger exchanges that information through METADATA_HW_PORT_MUX.

Series

  1. Add the ramips-local MT7620 DMA metadata DSA tagger.
  2. Add the MT7620 DSA driver with bridge isolation/STP, VLAN filtering, FDB/MDB offload, ageing, flood controls, phylink, 2026-byte MTU support, and extended hardware MIB counters. Package the driver and tagger as an optional per-device kmod which conflicts with swconfig.

The DSA instance is owned by a bound child of the frame-engine device. This gives the managed conduit device link the correct lifetime across driver unbind/reprobe. The series also fixes MDIO/frame-engine cleanup for deferred probes and reprobes.

The FE-only reset in fe_stop() is deliberately limited to the teardown path where DMA did not quiesce before its rings are freed. It does not address stale network state across a system restart; that separate condition is handled by #24724.

Testing

The unchanged DSA code was functionally tested on an MT7620N rev 2 eco 6 using a local, intentionally unsubmitted D-Link DWR-921 C1 DT migration:

  • identical-image sysupgrade -n, runtime Ethernet-driver unbind/rebind, and a hard power cycle;
  • VLAN-aware hardware bridging with VLAN 100 untagged on one user port and tagged on another, including hardware FDB learning;
  • 2000-byte and 2026-byte DF traffic; 2001 at MTU 2000 and MTU 2027 were rejected at the expected boundaries;
  • four-stream bidirectional iperf3 at 93.4/93.9 Mbit/s receiver throughput on 100BASE-T;
  • FDB/MDB add/delete, STP states, bridge ageing, unicast/multicast/broadcast flood controls, and hardware MIB accounting;
  • modular DSA driver/tagger build and package contents; the DSA test rootfs contains kmod-dsa-mt7620 and no swconfig;
  • a swconfig-only ZBT-WE826 configuration keeps NET_DSA, NET_DSA_MT7620, NET_DSA_TAG_RALINK, and NET_SWITCHDEV disabled;
  • an independent TP-Link Archer C5 v4 test found no regression with its external RTL8367S DSA switch and RTL8_4t tagger.

The current two-commit series was also applied to namiltd/openwrt#138 and built from a clean tree. Its package manifest and 6,750,503-byte sysupgrade image remained identical; only the initramfs build metadata changed. The integrated-switch module is not selected by that external-switch profile.

The earlier warm-reboot matrix included the reset change now split into #24724. Warm-reboot recovery is therefore not claimed by this DSA PR alone.

Related work

Hardware flow offload/PPE support is intentionally outside this PR.

@openwrt openwrt Bot added core packages pull request/issue for core (in-tree) packages kernel pull request/issue with Linux kernel related changes not following guidelines Pull request does not follow formatting guidelines target/ramips pull request/issue for ramips target labels Jul 30, 2026
@openwrt openwrt Bot removed the not following guidelines Pull request does not follow formatting guidelines label Jul 30, 2026
@namiltd

namiltd commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Many routers disable the built-in switch in the MT7620 and use external switches via RGMII with speeds of 1000 Mbps. These chips, such as the RTL8367S, can be configured in swconfig mode, and after recent updates, in DSA mode. Therefore, your changes require thorough verification to ensure they won't "break" the operation of these routers. Changes made in target/linux/ramips/mt7620/config-6.18 will also apply to these routers. Look at #19397

@dormancygrace

Copy link
Copy Markdown
Contributor Author

Thanks for pointing this out. Unfortunately, none of the MT7620 devices available to me use an external RGMII switch such as the RTL8367S, so I cannot perform hardware testing of that topology.

The MT7620 devices I currently have available are:

  • ZBTlink ZBT-WE826 16M — MT7620A;
  • D-Link DWR-921 C3 — MT7620N;
  • Gaoke LG6000N — MT7620A;
  • Tenda 4G680 — MT7620A.

All of them use the integrated MT7620 switch.

This PR deliberately does not migrate any individual board to DSA. The new DSA path is selected only when the integrated switch node contains an enabled ports child. Existing device trees without it continue through the legacy swconfig path. Enabling NET_DSA and NET_SWITCHDEV in the subtarget configuration should therefore not change their runtime path.

Nevertheless, testing on a device with an external RGMII switch would be valuable. I would be happy to provide test images and investigate any regressions if someone with suitable hardware can help with testing.

@namiltd

namiltd commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

A safer approach would be to make MT7620 DSA support optional (module-based) instead of enabling it target-wide in target/linux/ramips/mt7620/config-6.18.

Suggested direction:

  • Avoid forcing:
    • CONFIG_NET_DSA=y
    • CONFIG_NET_SWITCHDEV=y
    • CONFIG_NET_DSA_TAG_RALINK=y at the whole-target level.
  • Prefer modular/packaging enablement:
    • CONFIG_NET_DSA=m
    • CONFIG_NET_SWITCHDEV=m
    • CONFIG_NET_DSA_TAG_RALINK=m
  • Keep existing non-DSA MT7620 paths unchanged by default, and enable DSA only for migrated boards (via DEVICE_PACKAGES / dedicated kmod dependencies).

Why this helps:

  • It minimizes regression risk for MT7620 devices still on swconfig or external switch setups.
  • It allows board-by-board rollout and validation (e.g. Archer C5 v4 migration PR) without changing baseline behavior for all ramips/mt7620 images.

@openwrt openwrt Bot added the not following guidelines Pull request does not follow formatting guidelines label Jul 30, 2026
@openwrt openwrt Bot removed the not following guidelines Pull request does not follow formatting guidelines label Jul 30, 2026
@dormancygrace

dormancygrace commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 31c7e7b.

  • The MT7620 DSA driver and Ralink tagger are now packaged as the optional kmod-dsa-mt7620.
  • Target-wide NET_DSA, NET_DSA_TAG_RALINK, and NET_SWITCHDEV settings were removed.
  • Migrated boards opt in through DEVICE_PACKAGES; the new kmod conflicts with swconfig, so such profiles must also use -swconfig.
  • Existing swconfig-only MT7620 profiles do not select the new kmod.

NET_SWITCHDEV is a bool rather than a tristate, so it cannot be built as m; it becomes y only in kernel configurations where modular DSA is selected.

I verified the modular kernel build (NET_DSA=m, NET_DSA_MT7620=m, NET_DSA_TAG_RALINK=m), the kmod contents and autoload entries, and a DSA test rootfs containing the three required modules without swconfig. I also generated a swconfig-only ZBT-WE826 configuration and confirmed that DSA, the Ralink tagger, and switchdev all remain disabled.

The D-Link DT/profile migration used for testing remains local and is not included in this PR.

The parent now also keeps its DSA platform child registered until the modular driver loads, allowing normal late module binding without deferring the built-in frame-engine driver. A clean kernel rebuild passed with this load-order fix.

Comment thread target/linux/ramips/modules.mk Resolved
@namiltd

namiltd commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

mt7620_gsw_dsa_init()/mt7620_gsw_dsa_cleanup() currently live in gsw_mt7620.c, which is always compiled when CONFIG_NET_RALINK_GSW_MT7620=y, regardless of whether CONFIG_NET_DSA_MT7620 is enabled. Two issues:

  1. Layering: this glue code sits in the generic switch file instead of
    next to the rest of the DSA implementation in gsw_mt7620_dsa.c.

  2. Runtime failure mode: if a board's DTS has a "ports" node
    (priv->dsa_switch == true) but the image is built without
    kmod-dsa-mt7620, mt7620_gsw_dsa_init() will create the
    "mt7620-dsa" platform_device, no driver will ever bind to it,
    gsw->ds will never be set, and the function keeps returning
    -EPROBE_DEFER indefinitely. fe_probe() ends up stuck in the
    deferred-probe queue with no clear error, and the interface never
    comes up. CONFLICTS:=swconfig in modules.mk only prevents
    installing both opkg packages together, it doesn't tie DTS content
    to kernel config at build time.

Proposed change:

  1. Move mt7620_gsw_dsa_init() and mt7620_gsw_dsa_cleanup() from
    gsw_mt7620.c into gsw_mt7620_dsa.c, alongside the rest of the DSA
    code (mt7620_gsw_dsa_probe, dsa_switch_ops, etc.), instead of the
    generic file that also serves the legacy swconfig path.

  2. In gsw_mt7620.h, guard the declarations and add inline stubs for
    the disabled case:

   #if IS_ENABLED(CONFIG_NET_DSA_MT7620)
   int mt7620_gsw_dsa_init(struct mt7620_gsw *gsw, struct device *parent);
   void mt7620_gsw_dsa_cleanup(struct mt7620_gsw *gsw);
   #else
   static inline int mt7620_gsw_dsa_init(struct mt7620_gsw *gsw,
                                         struct device *parent)
   {
       return -ENODEV;
   }
   static inline void mt7620_gsw_dsa_cleanup(struct mt7620_gsw *gsw) {}
   #endif

This keeps the call site in soc_mt7620.c linking cleanly when CONFIG_NET_DSA_MT7620=n, and also fixes the silent infinite EPROBE_DEFER case for free: a DTS requesting DSA on a kernel without the DSA driver built in will now fail probe with a clear -ENODEV instead of hanging forever.

  1. Since struct mt7620_gsw must stay visible unconditionally, the
    ds/dsa_dev/dsa_irq_claimed fields and the vlans[]/pvid[]/mib_*
    state could optionally be wrapped in
    #if IS_ENABLED(CONFIG_NET_DSA_MT7620) as well, so swconfig-only
    images don't carry that per-device state. Nice-to-have, not a
    blocker.

Summary: move the DSA init/cleanup glue into gsw_mt7620_dsa.c and add -ENODEV inline stubs under
#else CONFIG_NET_DSA_MT7620 in the header. This cleans up the file split and removes the risk of a silent, infinite -EPROBE_DEFER loop when the DTS declares a "ports" node but the DSA module isn't built.

@dormancygrace

dormancygrace commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks. The disabled-configuration part is now addressed in c20e372.

The current implementation no longer checks gsw->ds or returns -EPROBE_DEFER after registering the child. The parent keeps the child registered, and the platform bus binds it when the module is loaded. I also verified this exact ordering on hardware: the built-in GSW initialized at 1.012 s, gsw_mt7620_dsa.ko bound at 18.900 s, and the DSA tree completed setup at 19.041 s.

This revision additionally:

  • guards the registration helpers with IS_ENABLED(CONFIG_NET_DSA_MT7620);
  • returns -ENODEV when a DT requests DSA but support is disabled;
  • omits the DSA-only switch state from swconfig-only builds;
  • renames the helpers to mt7620_gsw_dsa_device_register()/_unregister() to make their lifetime role explicit.

I kept the child-device registration in the built-in GSW core intentionally. With the frame-engine driver built in and NET_DSA_MT7620=m, moving these functions into gsw_mt7620_dsa.ko would leave built-in code referring to a module-only implementation (IS_ENABLED(...=m) is true). Using IS_REACHABLE() instead would disable the required modular late-binding path. The parent therefore owns only the platform-child lifetime, while the module owns the platform driver and all DSA implementation.

Both configurations were rebuilt: the modular DSA build passed, and a ZBT-WE826 swconfig-only build passed with NET_DSA and NET_SWITCHDEV unset.

@namiltd

namiltd commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

One more small thing, purely cosmetic: mt7620_gsw_dsa_device_register()/_unregister() and gsw_interrupt_mt7620_dsa() are now fully wrapped in #if IS_ENABLED(CONFIG_NET_DSA_MT7620), so they're effectively dead code in a plain swconfig build anyway. Might as well move them out of gsw_mt7620.c into gsw_mt7620_dsa.c where the rest of the DSA logic already lives — right now someone reading gsw_mt7620.c to work on the legacy swconfig path has to scroll past DSA-only code that's guarded out for them, which is a bit noisy. The declarations/stubs in gsw_mt7620.h can stay exactly as-is, only the function bodies would move. No functional change, just easier to follow which file owns what.

@dormancygrace

dormancygrace commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Those functions need to stay on the built-in side of the module boundary.

The supported configuration is NET_RALINK_GSW_MT7620=y with NET_DSA_MT7620=m. With that combination, IS_ENABLED(...=m) is true, so moving the function bodies into gsw_mt7620_dsa.ko would make built-in gsw_mt7620.o reference module-only symbols. The final vmlinux link would then fail. gsw_interrupt_mt7620_dsa() has the same issue because it is called by the built-in GSW IRQ path.

The code left in gsw_mt7620.c is intentionally limited to parent-owned platform-device lifetime and the IRQ dispatch needed before/after modular binding. The module still owns the platform driver, probe/remove, DSA switch registration, and all switch operations.

Moving the helpers would therefore require a larger redesign (for example a runtime callback-registration interface), not a cosmetic file move. I would prefer to keep the current split.

@dormancygrace
dormancygrace force-pushed the mt7620-dsa branch 3 times, most recently from 51b6506 to 1306ef7 Compare July 31, 2026 01:54
@openwrt openwrt Bot added target/ipq40xx pull request/issue for ipq40xx target target/qualcommax pull request/issue for qualcommax target target/realtek pull request/issue for realtek target labels Jul 31, 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 all 5 commits (first review of this PR, against 1306ef7). Substantial, well-tested work — most of what follows is about commit-message/diff hygiene rather than the DSA design itself. Inline comments cover the details.

Commit checks

  • b11fe4d "generic: add Ralink DMA metadata DSA tagger" — the subject scopes the change to generic:, but the diff also edits four target patches (target/linux/ipq40xx/patches-6.18/701-*, target/linux/qualcommax/patches-6.18/0950-*, target/linux/realtek/patches-6.18/700-* and 721-*). Those are just hunk-offset refreshes forced by inserting into include/net/dsa.h, but the body doesn't say so, and nothing explains why value 33 was chosen over the next free number. Worth a sentence in the message.
    • FWIW the formality bot's warning about missing From:/Date:/Subject: headers on target/linux/realtek/patches-6.18/721-net-dsa-add-support-for-tag-rtl-otto.patch is pre-existing in that file; this commit only shifted its hunk offsets.
  • 1306ef7 "ramips: mt7620: add DSA support for integrated switch" — the message enumerates the teardown/lifetime fixes carefully but omits three hunks that change existing, non-DSA behaviour: the GSW_REG_MIB_CNT_EN register address and enable-mask change (0x4000/BIT(1) → 0x4800/GENMASK(30, 24)), which affects mt7620_mac_init() on every swconfig MT7620 board; the split of priv->resets into by-name "fe"/"esw" reset controls; and the removal of netif_napi_del() from fe_remove(). The first of those in particular looks like an independent bug fix that would be better as its own commit.

Commits 22bdd16, fdb1075 and a2167b3 match their diffs.


Generated by Claude Code

@dormancygrace

Copy link
Copy Markdown
Contributor Author

Good catch. Addressed in cc89efc.

The MIB worker now uses two polling rates instead of increasing the cost for every port:

  • port 6 (the 1000BASE-T CPU port) is sampled every 20 ms;
  • the complete seven-port set is sampled every fifth tick, i.e. every 100 ms.

This leaves scheduling margin before the CPU port's 16-bit packet counters wrap at minimum-sized gigabit line rate while increasing the steady-state work from 70 to 110 port samples per second, rather than polling all seven ports five times more often. The worker still runs only while at least one user port is enabled, and the final full-port snapshot on stop is preserved.

I also removed the warm-reset discussion and the jumbo/reset PR links from the integrated-switch commit message. The FE-only stop-path reset remains described because that code is part of this diff, but the separate system-restart recovery claim is gone.

Validation on the exact updated head:

  • clean make target/linux/compile -j12 V=s passed, including gsw_mt7620_dsa.ko and tag_ralink.ko;
  • make target/linux/refresh V=s completed without tracked changes;
  • git diff --check is clean.

@namiltd

namiltd commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

For #define MT7620_MIB_PORT_INTERVALS 10 You will only get 80 port samples per second with still a safe margin.

@dormancygrace

Copy link
Copy Markdown
Contributor Author

Agreed, updated in 69c659d.

The CPU port remains at 20 ms, while the complete port set is now sampled every tenth tick (200 ms). That reduces the steady-state cost from 110 to 80 port samples per second and still leaves more than a 2x margin before a 100BASE-T port's 16-bit packet counter wraps at minimum-frame line rate.

The exact updated head passed make target/linux/compile -j12 V=s, including both gsw_mt7620_dsa.ko and tag_ralink.ko.

@namiltd

namiltd commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

In my opinion, the 761-net-dsa-add-ralink-metadata-tagger.patch patch could be placed in target/linux/ramips/patches-6.18 as it only applies to the mt7620 soc, i.e. ramips.

@dormancygrace

dormancygrace commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Agreed. Moved in 9d3cb05d04.

  • The tagger patch is now target/linux/ramips/patches-6.18/761-net-dsa-add-ralink-metadata-tagger.patch.
  • The first commit is now scoped as ramips: mt7620: add Ralink DMA metadata DSA tagger.
  • The ipq40xx, qualcommax, and realtek patch refreshes are no longer needed and were dropped; those four files are byte-identical to main again.
  • The PR description was updated to describe the tagger as ramips-local.

The relocated ramips patch series applies cleanly through target/linux/prepare, checkpatch.pl is clean, and the new CI run is in progress.

@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.

Re-reviewed the delta since my last pass (3c01d63..f6fda3c). The series was restructured from five commits to two: the three MIPS workaround/reset commits moved out to #24723 and #24724, and the tagger moved from target/linux/generic/pending-6.18/761-net-dsa-add-ralink-metadata-tagger.patch into the ramips target, so the commit is now scoped ramips: mt7620: and the ipq40xx/qualcommax/realtek offset refreshes are gone (those four files are byte-identical to main again). On top of that, the MIB worker gained the two-rate CPU/all-ports polling. Three inline comments, all on the relocated patch file; nothing blocking.

Things I checked and found correct, for the record:

  • The relocated patch body is byte-identical to the old generic 761- patch apart from the added MODULE_AUTHOR line and the correspondingly bumped hunk count. Nothing was lost in the move, and no stale generic/pending-6.18 file is left behind.
  • Putting a net/dsa/ patch in a target patches-<ver> directory is established practice — realtek 718-net-dsa-add-support-for-rtl838x-switch.patch / 721-...tag-rtl-otto.patch and ipq40xx 701-net-dsa-add-out-of-band-tagging-protocol.patch do exactly this.
  • The two-rate MIB polling is sound. mt7620_gsw_setup() still seeds every port with MT7620_DSA_ALL_PORTS before mib_initialized flips to true, so the user ports' mib_last is always valid when the every-tenth-tick full sweep runs 200 ms later; MT7620_DSA_ALL_PORTS includes bit 6, so the CPU port never sees a gap longer than one 20 ms tick. mib_port_intervals is touched only from the single delayed work item and from setup(), so the unlocked ++ is not racy, and the partially-filled raw[][] entries are only ever read under the same for_each_set_bit() mask.
  • for_each_set_bit() over int port against an unsigned long mask does not reintroduce a signed-compare issue, and the remaining int/unsigned int comparisons in tag_ralink.c (port < ds->num_ports, port < data->num_ports) only warn under W=3 — scripts/Makefile.extrawarn adds -Wno-sign-compare for everything below that.
  • No tag-protocol value collision in a ramips build: generic 760-08-... claims up to 31, and the two other patches claiming 32 (OOB, RTL_OTTO) live in ipq40xx/qualcommax/realtek and never apply here.

Both commit messages match their diffs — the tagger commit adds only the patch file, and the driver commit's message covers every hunk including the MIB register fix, the by-name FE/ESW resets, the readl_poll_timeout_atomic() conversion and the netif_napi_del() removal — so no commit-checks section this round.

CI on f6fda3c has no failures: all 26 check runs are success or skipped, including Check Kernel patches (ramips, mt7620) and every ramips subtarget kernel build. The single cancelled entry is a superseded build-pr-profile run from the previous push. Nothing CI-grounded.


Generated by Claude Code

@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.

Re-reviewed the delta since my last pass (3c01d63..9d3cb05). The series shrank from five commits to two: the entropy/long-calls/reset commits moved out to #24723 and #24724, so what remains is the tagger plus the integrated-switch driver. The tree delta against my last review is the tagger patch relocation, the split MIB polling rate, and two MODULE_AUTHOR lines. One nit inline, nothing blocking.

Things I checked in the delta and found correct:

  • Tagger relocation is a net improvement over the old generic/pending-6.18 placement. Moving to target/linux/ramips/patches-6.18/761-* lets DSA_TAG_PROTO_RALINK_VALUE drop from 33 to 32, which is exactly what the three existing target-local taggers already do — ipq40xx/patches-6.18/701-* and qualcommax/patches-6.18/0950-* both define DSA_TAG_PROTO_OOB_VALUE 32, and realtek/patches-6.18/721-* defines DSA_TAG_PROTO_RTL_OTTO_VALUE 32. Since only one target's kernel is built at a time, there is no collision, and the enum entry now sits in numeric order at the end of the list, so the patch-header paragraph justifying the out-of-order insertion is correctly gone. The four ipq40xx/qualcommax/realtek patch files are byte-identical to main again, and the Kconfig/Makefile insertions stay alphabetical (between QCA and RTL4_A).
  • Polling the CPU port is not dead work. DSA has no user netdev for port 6, but dsa_conduit_get_ethtool_stats() calls ds->ops->get_ethtool_stats(ds, cpu_dp->index, ...) at conduit.c:89-97, so mib_stats[6][*] really is reachable through ethtool -S on the conduit. The 20 ms rate therefore protects counters a user can actually observe.
  • The partial-port update is safe. mt7620_gsw_mib_update() iterates the same for_each_set_bit(port, &ports, …) in both the read loop and the accumulate loop, so no raw[port][] slot is consumed uninitialised. The single global mib_initialized flag is not a partial-init hazard either, because the only call that flips it from false to true is the MT7620_DSA_ALL_PORTS sweep in mt7620_gsw_setup(), which runs before the worker is ever scheduled. mib_port_intervals is touched only by the single worker plus that same setup path.
  • -Wsign-compare is not a concern for the int port / unsigned int num_ports comparisons in tag_ralink.c: 6.18 only enables it at W=3 (Makefile.extrawarn:201, with -Wno-sign-compare in the default path).

The 200 ms full-port interval versus the 440 ms wrap was raised and settled in the thread (#24493 comments of 2026-08-18), so I'm not re-opening it.

Both commit messages match their diffs — commit 1 is now correctly scoped ramips: mt7620: for a patch that lives under target/linux/ramips/, and commit 2 documents the 20 ms / 200 ms split — so no commit-checks section this round.

CI on 9d3cb05 has no failures: all 25 check runs are success or skipped, including Check Kernel patches (ramips, mt7620) (which is what would have caught a bad relocation), all five ramips subtarget kernel builds, and the three FormalityCheck jobs. Nothing CI-grounded.


Generated by Claude Code

@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.

Re-reviewed the delta since my last pass (3c01d63..3ec27fd). The series was restructured from five commits to two: 333/334 moved to #24723 and 335 to #24724, exactly as agreed in the thread, and the tagger moved from generic/pending-6.18/ into target/linux/ramips/patches-6.18/. Restricted to the twelve files this PR owns, the tree delta is small and I found no new issues; one nit inline.

What I checked in the delta:

  • Tagger relocation and value change. The patch content is unchanged apart from dropping the now-obsolete value-33 placement paragraph, renumbering to 32, and adding MODULE_AUTHOR. The two include/net/dsa.h hunks are now in numeric order after MXL862_8021Q (31) rather than spliced next to NONE, which is only possible because the patch no longer has to keep the end-of-list context free for the ipq40xx/qualcommax/realtek patches. Check Kernel patches (ramips, mt7620) and all five ramips subtarget kernel builds are green on this head, so the new offsets apply cleanly. The four previously-refreshed target patches are byte-identical to main again.
  • Split-out commits are not prerequisites. 334-mt7620-use-long-calls.patch only adds -mlong-calls to drivers/spi/spi.o and net/ipv6/udp.o; neither the DSA driver nor the tagger depends on it, and 335 is the system-restart reset, which the PR body explicitly disclaims. Nothing this diff needs went out with them.
  • Two-rate MIB polling. mib_port_intervals is a u8 reset to 0 in setup() and only touched from the single work item, so no wrap and no locking gap. for_each_set_bit(port, &ports, MT7620_DSA_NUM_PORTS) with MT7620_DSA_ALL_PORTS = GENMASK(6, 0) stays inside raw[GSW_NUM_PORTS=7]. mib_initialized is only ever set from a full sweep (setup() seeds every port before the worker can run), so the CPU-only ticks can never publish a delta against an unseeded mib_last. port_disable() still does the final full sync after cancel_delayed_work_sync(); not resetting mib_port_intervals there only means the first sweep after a re-enable can arrive early, which is harmless.
  • The fast CPU-port poll has a consumer. dsa_conduit_get_ethtool_stats() calls ds->ops->get_ethtool_stats(ds, port, ...) for the CPU port at conduit.c:96-97 (v6.18.44), so port 6's counters are surfaced on the conduit netdev rather than being computed and discarded.
  • The 200 ms full-sweep interval and the ~2x margin against the 100BASE-T wrap were settled in the thread, so not re-raising.

CI on 3ec27fd has no failures — all 25 check runs are success or skipped, including FormalityCheck / Code Patches and the ramips mt7620/mt7621/mt76x8/rt305x/rt3883 kernel builds. Nothing CI-grounded.

Both commit messages match their diffs, so no commit-checks section this round.


Generated by Claude Code

@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.

Re-reviewed the delta since my last pass (3c01d63..d654368). The series was restructured from five commits to two: the entropy-jal, long-calls and warm-restart-reset commits were split into #24723/#24724, leaving just the tagger and the DSA driver here. Reviewed against the PR's own base (f6bc2a3), the net contribution is the same two-commit DSA change, now rebased onto current main. No new issues found; nothing inline.

The tagger moved from a generic:-scoped patch to the ramips-local target/linux/ramips/patches-6.18/761-net-dsa-add-ralink-metadata-tagger.patch, and its protocol value changed 33 → 32. That resolves the whole 32/33 thread cleanly, and I confirmed it:

  • Value 32 is in-order (next free after DSA_TAG_PROTO_MXL862_8021Q_VALUE = 31) and is the only DSA_TAG_PROTO_*_VALUE added under target/linux/ramips/patches-6.18/. Because the patch is now ramips-local rather than generic, it cannot coexist with the ipq40xx/qualcommax OOB or realtek RTL_OTTO patches that also claim 32 — those apply only in their own mutually-exclusive targets — so no collision, unlike the earlier generic form that needed 33 to dodge them.
  • tag_ralink.c follows the standard METADATA_HW_PORT_MUX pattern (per-port metadata_dst, skb_dst_set_noref on xmit); the ralink_tag_connect error path unwinds with while (port--) dst_release(...) correctly, and ralink_tag_rcv returning NULL is safe since dsa_switch_rcv() frees the skb and this path is diagnostic-only.
  • kmod packaging is consistent: kmod-dsa-mt7620 selects CONFIG_NET_DSA_MT7620 + CONFIG_NET_DSA_TAG_RALINK, ships gsw_mt7620_dsa.ko + tag_ralink.ko, and CONFLICTS:=swconfig.

The MIB polling design described in the driver commit message is now realised in code — mib_work samples the CPU port every 20 ms and the full port set every tenth tick (200 ms) via mib_port_intervals. That is correct: the 1000BASE-T CPU port (44 ms wrap) is read at 20 ms and the 100BASE-T user ports (440 ms wrap) at 200 ms, so no counter double-wraps between samples; the worker is single-threaded so the interval counter needs no locking, and setup()/port_disable() still do a full-port sync to keep baselines correct.

Both commit messages match their diffs, so no commit-checks section this round. CI on d654368 has no failures — the ramips/mt7620 build, Check Kernel patches (ramips, mt7620), and all three FormalityCheck jobs are green; everything else is success or skipped. Nothing CI-grounded.


Generated by Claude Code

The MT7620 frame engine selects the egress switch port in TXD4 and
reports the ingress source port in RXD4. Add a DSA tagger which
exchanges the port through METADATA_HW_PORT_MUX instead of modifying
packet data.

This preserves the frame payload and leaves descriptor encoding to the
conduit driver. Keep the kernel patch in the ramips target because the
tagger is specific to the MT7620 frame engine.

Signed-off-by: Gleb Pesin <[email protected]>
Link: openwrt#24493
Signed-off-by: Jonas Jelonek <[email protected]>
Add a DSA driver for the seven-port switch integrated in MT7620. Keep
the existing swconfig path for device trees without a DSA ports node.

Use RXD4 source-port and TXD4 forced-port metadata with the Ralink
DSA tagger. The programming guide places TXD4 FP_BMAP at bits 27:20;
use that layout instead of the stale unused bits 26:19 definition.

Implement bridge isolation and STP, VLAN filtering, FDB and
MDB offload, ageing, flood controls, phylink, MTU limits, and
software-extended hardware MIB counters. Poll the 1000BASE-T CPU
port counters every 20 ms and the remaining ports every 200 ms to
leave scheduling margin before their 16-bit packet counters wrap at
minimum-sized line-rate traffic. DSA invokes port_stp_state_set()
before updating its cached state, so pass the pending callback state
as an override when recalculating port matrices instead of leaving
hardware one transition behind.

Correct the shared switch MIB enable register and enable all seven
port counters. The old address was inside port 0 counter space,
so this also fixes legacy swconfig initialization.

Register DSA through a bound child of the frame-engine device. This
gives the managed conduit device link the correct lifetime across
driver unbind and reprobe while the switch registers remain owned by
the existing GSW platform device.

Package the driver and tagger as kmod-dsa-mt7620 for per-device
opt-in. This keeps DSA and switchdev out of swconfig-only MT7620
images and prevents installing the DSA package together with swconfig.

Also make MDIO and frame-engine teardown safe for deferred probes and
runtime reprobes. Replace the legacy MDIO busy loop and -1 return
with readl_poll_timeout_atomic() and its real error, and reset a
still-busy frame engine before freeing DMA rings. Resolve FE and ESW
resets by name so recovery can reset FE alone, and warn if a switch
node provides neither named reset.

The netdev is devm-managed, so leave NAPI deletion to free_netdev
after unregister instead of deleting NAPI from fe_remove while the
netdev is still registered.

Tested on an MT7620N rev 2 eco 6 with 100BASE-T traffic, VLAN-aware
hardware bridging, 2026-byte MTU, FDB/MDB offload, pending STP state,
and driver unbind/rebind. The modular driver, tagger, package contents,
DSA image composition, and swconfig-only kernel configuration were
also verified.

An independent TP-Link Archer C5 v4 test exercised an external RTL8367S
DSA switch using the RTL8_4t tagger as a regression check on the
shared dsa_tag_protocol enum. It found no collision or external-switch
regression; it does not validate the MT7620 integrated-switch path.

Signed-off-by: Gleb Pesin <[email protected]>
Link: openwrt#24493
Signed-off-by: Jonas Jelonek <[email protected]>
@openwrt-bot
openwrt-bot merged commit d0f9d21 into openwrt:main Aug 20, 2026
5 checks passed
@jonasjelonek

Copy link
Copy Markdown
Member

Thanks! Rebased on top of main and merged!

Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
The MT7620 frame engine selects the egress switch port in TXD4 and
reports the ingress source port in RXD4. Add a DSA tagger which
exchanges the port through METADATA_HW_PORT_MUX instead of modifying
packet data.

This preserves the frame payload and leaves descriptor encoding to the
conduit driver. Keep the kernel patch in the ramips target because the
tagger is specific to the MT7620 frame engine.

Signed-off-by: Gleb Pesin <[email protected]>
Link: openwrt#24493
Signed-off-by: Jonas Jelonek <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
Add a DSA driver for the seven-port switch integrated in MT7620. Keep
the existing swconfig path for device trees without a DSA ports node.

Use RXD4 source-port and TXD4 forced-port metadata with the Ralink
DSA tagger. The programming guide places TXD4 FP_BMAP at bits 27:20;
use that layout instead of the stale unused bits 26:19 definition.

Implement bridge isolation and STP, VLAN filtering, FDB and
MDB offload, ageing, flood controls, phylink, MTU limits, and
software-extended hardware MIB counters. Poll the 1000BASE-T CPU
port counters every 20 ms and the remaining ports every 200 ms to
leave scheduling margin before their 16-bit packet counters wrap at
minimum-sized line-rate traffic. DSA invokes port_stp_state_set()
before updating its cached state, so pass the pending callback state
as an override when recalculating port matrices instead of leaving
hardware one transition behind.

Correct the shared switch MIB enable register and enable all seven
port counters. The old address was inside port 0 counter space,
so this also fixes legacy swconfig initialization.

Register DSA through a bound child of the frame-engine device. This
gives the managed conduit device link the correct lifetime across
driver unbind and reprobe while the switch registers remain owned by
the existing GSW platform device.

Package the driver and tagger as kmod-dsa-mt7620 for per-device
opt-in. This keeps DSA and switchdev out of swconfig-only MT7620
images and prevents installing the DSA package together with swconfig.

Also make MDIO and frame-engine teardown safe for deferred probes and
runtime reprobes. Replace the legacy MDIO busy loop and -1 return
with readl_poll_timeout_atomic() and its real error, and reset a
still-busy frame engine before freeing DMA rings. Resolve FE and ESW
resets by name so recovery can reset FE alone, and warn if a switch
node provides neither named reset.

The netdev is devm-managed, so leave NAPI deletion to free_netdev
after unregister instead of deleting NAPI from fe_remove while the
netdev is still registered.

Tested on an MT7620N rev 2 eco 6 with 100BASE-T traffic, VLAN-aware
hardware bridging, 2026-byte MTU, FDB/MDB offload, pending STP state,
and driver unbind/rebind. The modular driver, tagger, package contents,
DSA image composition, and swconfig-only kernel configuration were
also verified.

An independent TP-Link Archer C5 v4 test exercised an external RTL8367S
DSA switch using the RTL8_4t tagger as a regression check on the
shared dsa_tag_protocol enum. It found no collision or external-switch
regression; it does not validate the MT7620 integrated-switch path.

Signed-off-by: Gleb Pesin <[email protected]>
Link: openwrt#24493
Signed-off-by: Jonas Jelonek <[email protected]>
@Boilerplate4u

Copy link
Copy Markdown

@dormancygrace, @namiltd

I've now got MT7620 DSA working on the DAP-1620 A2 with this PR and I'd appreciate some review before I try to turn this into a proper OpenWrt PR.

Openwrt forum link: DAP-1620 A2 - MT7620 DSA test (#24493): external port 5 and RGMII delays

@Boilerplate4u

Copy link
Copy Markdown

Review and feedback appreciated: ramips: mt7620: add DSA support for RGMII1 that is based on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core packages pull request/issue for core (in-tree) packages kernel pull request/issue with Linux kernel related changes target/ipq40xx pull request/issue for ipq40xx target target/qualcommax pull request/issue for qualcommax target target/ramips pull request/issue for ramips target target/realtek pull request/issue for realtek target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants