Skip to contentSkip to conversation

net: dsa: mt7628 embedded switch initial support

PATCH Applied Joris Vaisvila 3 participants 8 messages Aug 13 – Aug 18

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v7 cover net: dsa: mt7628 embedded switch initial support

This patch series adds initial support for the MediaTek MT7628 Embedded Switch.

The driver implements the basic functionality required to operate the switch using DSA. The hardware provides five internal Fast Ethernet user ports and one Gigabit port connected internally to the CPU MAC.

Bridge offloading is not yet supported, but due to the CPU to switch link being Gigabit and all the user ports being Fast Ethernet, software bridging is a practical solution for the initial driver.

Tested on an MT7628NN-based board.

Changes since v6:
- added depends on HAS_IOMEM && (SOC_MT7620 || COMPILE_TEST) and select REGMAP_MMIO to NET_DSA_MT7628 kconfig entry
- added comment about all ports being disabled by reset in port_enable function
- added depends on SOC_MT7620 || COMPILE_TEST to MEDIATEK_FE_SOC_PHY kconfig entry
- added genphy suspend and resume features to mtk-fe-soc driver
- rebased on net-next

Changes since v5:
- updated tag_mt7628 to kfree_skb() on error in receive path
- removed Reviewed-by tags from tag_mt7628
- removed mmio base pointer from mt7628_esw since it's only used to initialize the regmap
- rebased on net-next

Changes since v4:
mt7628 dsa driver:
- updated mdiobus allocation to use ds->dev instead of esw->dev, matching other DSA drivers (no functional change)
mt7628 phy driver:
- replaced phy_write() with phy_modify() when setting PHY init bit (no functional change)
mt7628 dt binding:
- moved unevaluatedProperties after required block
- removed blank line between compatible and reg in example

Changes since v3:
- rebased on latest net-next
mt7628 dsa driver:
- simplified vlan_add hardware vlan slot search
- fixed vlan_del not removing vid from port pvid
- separated mii_read/mii_write error handling from return value parsing. Updated RD_DONE/WT_DONE bit checking with clearer logic and a comment.
- moved NET_DSA_MT7628 after NET_DSA_MT7530 in Kconfig
- added missing reset return value checks in probe
- fixed mt7628_switch_ops missing const specifier
- removed mdio node parsing from of, as there is nothing to configure
mt7628 dt binding:
- updated description to be more clear about port count
- dropped optional mdio subnode. the switch does not expose an external MDIO bus and all integrated PHY access is handled by the driver.
- removed unused switch0 label in example

Changes since v2:
- fix binding issues found in review
- fix ignored dsa_tag_8021q_register return value
- add switch teardown to clean up tag_8021q
- fix ordering issue where mdio probe fail would leak tag_8021q

Changes since v1:
- changed port 6 phy-mode to internal
- cleaned up tag_mt7628 rcv function and mask defines
- fixed sorting error in drivers/net/dsa/ Kconfig and Makefile
- fixed sorting error in net/dsa/ Kconfig and Makefile
- fixed mt7628_mii_read/write return values on error

Thanks,
Joris

Joris Vaisvila (4):
dt-bindings: net: dsa: add MT7628 ESW
net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet
PHYs
net: dsa: initial MT7628 tagging driver
net: dsa: initial support for MT7628 embedded switch

 .../bindings/net/dsa/mediatek,mt7628-esw.yaml |  96 +++
 drivers/net/dsa/Kconfig                       |  10 +
 drivers/net/dsa/Makefile                      |   1 +
 drivers/net/dsa/mt7628.c                      | 652 ++++++++++++++++++
 drivers/net/phy/mediatek/Kconfig              |  11 +-
 drivers/net/phy/mediatek/Makefile             |   1 +
 drivers/net/phy/mediatek/mtk-fe-soc.c         |  52 ++
 include/net/dsa.h                             |   2 +
 net/dsa/Kconfig                               |   6 +
 net/dsa/Makefile                              |   1 +
 net/dsa/tag_mt7628.c                          |  93 +++
 11 files changed, 924 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml
 create mode 100644 drivers/net/dsa/mt7628.c
 create mode 100644 drivers/net/phy/mediatek/mtk-fe-soc.c
 create mode 100644 net/dsa/tag_mt7628.c
Signature · 1 line
2.55.0
#1 lore raw

PATCH v7 1/4 dt-bindings: net: dsa: add MT7628 ESW

Add device tree bindings for the MediaTek MT7628 embedded Ethernet Switch.

The Switch provides 5 external user ports and 1 internal CPU port, with integrated 10/100 PHYs and fixed port to PHY mapping.

The CPU port is internally connected and uses port index 6.

---
 .../bindings/net/dsa/mediatek,mt7628-esw.yaml | 96 +++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml
Documentation/devicetree/bindings/net/dsa/mediatek,mt7628-esw.yaml new file +96 -0
new file mode 100644
index 000000000000..e0e7ffef6648
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/dsa/mediatek,mt7628-esw.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT7628 Embedded Ethernet Switch
+
+maintainers:
+  - Joris Vaisvila <[email protected]>
+
+description:
+  The MT7628 SoC's built-in Ethernet Switch has five user ports and one
+  internally connected CPU port. The user ports are all connected to the SoC's
+  integrated Fast Ethernet PHYs. The switch registers are directly mapped in
+  the SoC's memory.
+
+allOf:
+  - $ref: dsa.yaml#/$defs/ethernet-ports
+
+properties:
+  compatible:
+    const: mediatek,mt7628-esw
+
+  reg:
+    maxItems: 1
+
+  resets:
+    items:
+      - description: internal switch block reset
+      - description: internal phy package reset
+
+  reset-names:
+    items:
+      - const: esw
+      - const: ephy
+
+required:
+  - compatible
+  - reg
+  - resets
+  - reset-names
+  - ethernet-ports
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    switch@10110000 {
+        compatible = "mediatek,mt7628-esw";
+        reg = <0x10110000 0x8000>;
+
+        resets = <&sysc 23>, <&sysc 24>;
+        reset-names = "esw", "ephy";
+
+        ethernet-ports {
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            ethernet-port@0 {
+                reg = <0>;
+                phy-mode = "internal";
+            };
+
+            ethernet-port@1 {
+                reg = <1>;
+                phy-mode = "internal";
+            };
+
+            ethernet-port@2 {
+                reg = <2>;
+                phy-mode = "internal";
+            };
+
+            ethernet-port@3 {
+                reg = <3>;
+                phy-mode = "internal";
+            };
+
+            ethernet-port@4 {
+                reg = <4>;
+                phy-mode = "internal";
+            };
+
+            ethernet-port@6 {
+                reg = <6>;
+                phy-mode = "internal";
+                ethernet = <&ethernet>;
+
+                fixed-link {
+                    speed = <1000>;
+                    full-duplex;
+                };
+            };
+        };
+    };
Signature · 1 line
2.55.0
#2 lore raw

PATCH v7 2/4 net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs

In reply to Joris Vaisvila

The Fast Ethernet PHYs present in the MT7628 SoCs require an undocumented bit to be set before they can establish 100mbps links.

This commit adds the Kconfig option MEDIATEK_FE_SOC_PHY and the corresponding driver mtk-fe-soc.c.

---
 drivers/net/phy/mediatek/Kconfig      | 11 +++++-
 drivers/net/phy/mediatek/Makefile     |  1 +
 drivers/net/phy/mediatek/mtk-fe-soc.c | 52 +++++++++++++++++++++++++++
 3 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/phy/mediatek/mtk-fe-soc.c
drivers/net/phy/mediatek/Kconfig +10 -1
index b6d41bbbbc27..3b9cf82c0cb2 100644
@@ -21,8 +21,17 @@ config MEDIATEK_GE_PHY
 	  common operations with MediaTek SoC built-in Gigabit
 	  Ethernet PHYs.
 
+config MEDIATEK_FE_SOC_PHY
+	tristate "MediaTek SoC Fast Ethernet PHYs"
+	depends on SOC_MT7620 || COMPILE_TEST
+	help
+	  Support for MediaTek MT7628 built-in Fast Ethernet PHYs.
+	  This driver only sets an initialization bit required for the PHY
+	  to establish 100 Mbps links. All other PHY operations are handled
+	  by the kernel's generic PHY code.
+
 config MEDIATEK_GE_SOC_PHY
-	tristate "MediaTek SoC Ethernet PHYs"
+	tristate "MediaTek SoC Gigabit Ethernet PHYs"
 	depends on ARM64 || ECONET || COMPILE_TEST
 	depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \
 		   ECONET || COMPILE_TEST
drivers/net/phy/mediatek/Makefile +1 -0
index ac57ecc799fc..6f9cacf7f906 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_MEDIATEK_2P5GE_PHY)	+= mtk-2p5ge.o
+obj-$(CONFIG_MEDIATEK_FE_SOC_PHY)	+= mtk-fe-soc.o
 obj-$(CONFIG_MEDIATEK_GE_PHY)		+= mtk-ge.o
 obj-$(CONFIG_MEDIATEK_GE_SOC_PHY)	+= mtk-ge-soc.o
 obj-$(CONFIG_MTK_NET_PHYLIB)		+= mtk-phy-lib.o
drivers/net/phy/mediatek/mtk-fe-soc.c new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.55.0
#4 lore raw

PATCH v7 4/4 net: dsa: initial support for MT7628 embedded switch

In reply to Joris Vaisvila

Add support for the MT7628 embedded switch.

The switch has 5 built-in 100Mbps user ports (ports 0-4) and one 1Gbps port that is internally attached to the SoCs CPU MAC and serves as the CPU port.

The switch hardware has a very limited 16 entry VLAN table. Configuring VLANs is the only way to control switch forwarding. Currently 6 entries are used by tag_8021q to isolate the ports. Double tag feature is enabled to force the switch to append the VLAN tag even if the incoming packet is already tagged, this simulates VLAN-unaware functionality and simplifies the tagger implementation.

---
 drivers/net/dsa/Kconfig  |  10 +
 drivers/net/dsa/Makefile |   1 +
 drivers/net/dsa/mt7628.c | 652 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 663 insertions(+)
 create mode 100644 drivers/net/dsa/mt7628.c
drivers/net/dsa/Kconfig +10 -0
index 4ab567c5bbaf..676fb7dffe14 100644
@@ -63,6 +63,16 @@ config NET_DSA_MT7530_MMIO
 	  are directly mapped into the SoCs register space rather than being
 	  accessible via MDIO.
 
+config NET_DSA_MT7628
+	tristate "MediaTek MT7628 Embedded Ethernet switch support"
+	depends on HAS_IOMEM && (SOC_MT7620 || COMPILE_TEST)
+	select NET_DSA_TAG_MT7628
+	select MEDIATEK_FE_SOC_PHY
+	select REGMAP_MMIO
+	help
+	  This enables support for the built-in Ethernet switch found
+	  in the MT7628 SoC.
+
 config NET_DSA_MV88E6060
 	tristate "Marvell 88E6060 ethernet switch chip support"
 	select NET_DSA_TAG_TRAILER
drivers/net/dsa/Makefile +1 -0
index d2975badffc0..6ceb78a755d7 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_NET_DSA_KS8995) 	+= ks8995.o
 obj-$(CONFIG_NET_DSA_MT7530)	+= mt7530.o
 obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o
 obj-$(CONFIG_NET_DSA_MT7530_MMIO) += mt7530-mmio.o
+obj-$(CONFIG_NET_DSA_MT7628) += mt7628.o
 obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
 obj-$(CONFIG_NET_DSA_RZN1_A5PSW) += rzn1_a5psw.o
 obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
drivers/net/dsa/mt7628.c new file +652 -0

652 lines not on this page · raw message

Signature · 1 line
2.55.0
#3 lore raw

PATCH v7 3/4 net: dsa: initial MT7628 tagging driver

In reply to Joris Vaisvila

Add support for the MT7628 embedded switch's tag.

The MT7628 tag is merged with the VLAN TPID field when a VLAN is appended by the switch hardware. It is not installed if the VLAN tag is already there on ingress. Due to this hardware quirk the tag cannot be trusted for port 0 if we don't know that the VLAN was added by the hardware. As a workaround for this the switch is configured to always append the port PVID tag even if the incoming packet is already tagged. The tagging driver can then trust that the tag is always accurate and the whole VLAN tag can be removed on ingress as it's only metadata for the tagger.

On egress the MT7628 tag allows precise TX, but the correct VLAN tag from tag_8021q is still appended or the switch will not forward the packet.

---
 include/net/dsa.h    |  2 +
 net/dsa/Kconfig      |  6 +++
 net/dsa/Makefile     |  1 +
 net/dsa/tag_mt7628.c | 93 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 102 insertions(+)
 create mode 100644 net/dsa/tag_mt7628.c
include/net/dsa.h +2 -0
index 6f7f5c17b532..7507d632e7c6 100644
@@ -60,6 +60,7 @@ struct tc_action;
 #define DSA_TAG_PROTO_MXL862_VALUE		32
 #define DSA_TAG_PROTO_NETC_VALUE		33
 #define DSA_TAG_PROTO_KSZ8463_VALUE		34
+#define DSA_TAG_PROTO_MT7628_VALUE		35
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -97,6 +98,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_MXL862		= DSA_TAG_PROTO_MXL862_VALUE,
 	DSA_TAG_PROTO_NETC		= DSA_TAG_PROTO_NETC_VALUE,
 	DSA_TAG_PROTO_KSZ8463		= DSA_TAG_PROTO_KSZ8463_VALUE,
+	DSA_TAG_PROTO_MT7628		= DSA_TAG_PROTO_MT7628_VALUE,
 };
 
 struct dsa_switch;
net/dsa/Kconfig +6 -0
index d5e725b90d78..23b4b74004ed 100644
@@ -98,6 +98,12 @@ config NET_DSA_TAG_EDSA
 	  Say Y or M if you want to enable support for tagging frames for the
 	  Marvell switches which use EtherType DSA headers.
 
+config NET_DSA_TAG_MT7628
+	tristate "Tag driver for the MT7628 embedded switch"
+	help
+	  Say Y or M if you want to enable support for tagging frames for the
+	  switch embedded in the MT7628 SoC.
+
 config NET_DSA_TAG_MTK
 	tristate "Tag driver for Mediatek switches"
 	help
net/dsa/Makefile +1 -0
index b8c2667cd14a..d15bcf5c68f0 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o
 obj-$(CONFIG_NET_DSA_TAG_HELLCREEK) += tag_hellcreek.o
 obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o
 obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o
+obj-$(CONFIG_NET_DSA_TAG_MT7628) += tag_mt7628.o
 obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o
 obj-$(CONFIG_NET_DSA_TAG_MXL_862XX) += tag_mxl862xx.o
 obj-$(CONFIG_NET_DSA_TAG_MXL_GSW1XX) += tag_mxl-gsw1xx.o
net/dsa/tag_mt7628.c new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
2.55.0
#5 lore raw

Re: [PATCH net-next v7 4/4] net: dsa: initial support for MT7628 embedded switch

In reply to Joris Vaisvila
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Using `devm_mdiobus_alloc()` and `devm_mdiobus_register()` in the DSA `.setup()` callback leads to…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Using devm_mdiobus_alloc() and devm_mdiobus_register() in the DSA .setup() callback leads to resource leaks and sysfs collisions on re-bind.
- [High] The VLAN Untag Bitmap (VUB) register stride is incorrectly set to 7 instead of 8, which will write to the wrong hardware bits for VLANs 1, 2, and 3 within a register block. --

--- Patch [4]: [PATCH net-next v7 4/4] net: dsa: initial support for MT7628 embedded switch --- commit 94f2355ae398ce31cce3f01105a3f2af1b3c61d6
Author: Joris Vaisvila <[email protected]>

net: dsa: initial support for MT7628 embedded switch

Add support for the MT7628 embedded switch.

The switch has 5 built-in 100Mbps user ports (ports 0-4) and one 1Gbps port that is internally attached to the SoCs CPU MAC and serves as the CPU port.

Quoted 5 lines
drivers/net/dsa/mt7628.c new file +0 -0
new file mode 100644
index 0000000000000..fb63f6f644b9e

[ ... ]

drivers/net/dsa/mt7628.c line 83

Quoted 8 lines
drivers/net/dsa/mt7628.c new file +8 -0
+#define MT7628_ESW_VMSC_PREP(vlan, vmsc) \
+	(((vmsc) & MT7628_ESW_VMSC_M) << MT7628_ESW_VMSC_SHIFT(vlan))
+
+#define MT7628_ESW_VUB_S 7
+#define MT7628_ESW_VUB_M GENMASK(6, 0)
+#define MT7628_ESW_VUB_SHIFT(vlan) \
+	(MT7628_ESW_VUB_S * ((vlan) % 4))
+#define MT7628_ESW_VUB_MASK(vlan) \

[Severity: High]
Is the register stride for the VLAN Untag Bitmap (VUB) incorrectly set to 7 instead of 8?

The MT7628 switch packs 4 VLAN configurations per 32-bit register. Using a 7-bit stride means the shift offsets will be 7, 14, and 21 for the upper VLANs in the register block, rather than the standard byte-aligned 8, 16, and 24.

Could this write the untagged port mask into the wrong hardware bits and corrupt the VLAN configuration?

[ ... ]

drivers/net/dsa/mt7628.c line 248

Quoted 7 lines
drivers/net/dsa/mt7628.c new file +7 -0
+static int mt7628_setup_internal_mdio(struct dsa_switch *ds)
+{
+	struct mt7628_esw *esw = ds->priv;
+	struct device *dev = ds->dev;
+	struct mii_bus *bus;
+
+	bus = devm_mdiobus_alloc(dev);

[Severity: High]
Does allocating a devm-managed MDIO bus inside a DSA setup callback cause resource leaks or sysfs collisions on re-bind?

The mt7628_setup_internal_mdio() function is called from the main mt7628_setup() callback. This setup callback runs every time the master conduit device binds. If the conduit interface is unbound and bound again, the setup callback is invoked a second time.

Because the bus lifecycle is tied to the switch platform device via devm_, the old bus is not freed when the conduit unbinds. Will the second devm_mdiobus_register() attempt fail with a sysfs name collision (-EEXIST), preventing the switch from initializing?

Quoted 4 lines
drivers/net/dsa/mt7628.c new file +4 -0
+	if (!bus)
+		return -ENOMEM;
+
+	bus->name = "MT7628 internal MDIO bus";
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#6 lore raw

Re: [PATCH net-next v7 4/4] net: dsa: initial support for MT7628 embedded switch

Hi, thank you for the review

Quoted 43 lines · On Fri, Aug 14, 2026 at 07:04:32PM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Using devm_mdiobus_alloc() and devm_mdiobus_register() in the DSA .setup() callback leads to resource leaks and sysfs collisions on re-bind.
- [High] The VLAN Untag Bitmap (VUB) register stride is incorrectly set to 7 instead of 8, which will write to the wrong hardware bits for VLANs 1, 2, and 3 within a register block. --

--- Patch [4]: [PATCH net-next v7 4/4] net: dsa: initial support for MT7628 embedded switch --- commit 94f2355ae398ce31cce3f01105a3f2af1b3c61d6
Author: Joris Vaisvila <[email protected]>

net: dsa: initial support for MT7628 embedded switch

Add support for the MT7628 embedded switch.

The switch has 5 built-in 100Mbps user ports (ports 0-4) and one 1Gbps port that is internally attached to the SoCs CPU MAC and serves as the CPU port.

Quoted 5 lines
drivers/net/dsa/mt7628.c new file +0 -0
new file mode 100644
index 0000000000000..fb63f6f644b9e

[ ... ]

drivers/net/dsa/mt7628.c line 83

Quoted 8 lines
drivers/net/dsa/mt7628.c new file +8 -0
+#define MT7628_ESW_VMSC_PREP(vlan, vmsc) \
+	(((vmsc) & MT7628_ESW_VMSC_M) << MT7628_ESW_VMSC_SHIFT(vlan))
+
+#define MT7628_ESW_VUB_S 7
+#define MT7628_ESW_VUB_M GENMASK(6, 0)
+#define MT7628_ESW_VUB_SHIFT(vlan) \
+	(MT7628_ESW_VUB_S * ((vlan) % 4))
+#define MT7628_ESW_VUB_MASK(vlan) \

[Severity: High]
Is the register stride for the VLAN Untag Bitmap (VUB) incorrectly set to 7 instead of 8?

The MT7628 switch packs 4 VLAN configurations per 32-bit register. Using a 7-bit stride means the shift offsets will be 7, 14, and 21 for the upper VLANs in the register block, rather than the standard byte-aligned 8, 16, and 24.

Quoted 5 lines

Could this write the untagged port mask into the wrong hardware bits and corrupt the VLAN configuration?

[ ... ]

This matches the datasheet and has been tested to work correctly on real hardware.

As per the datasheet, VLAN_0_UNTAG_EN is bits 6-0, VLAN_1_UNTAG_EN is bits 13-7, VLAN_2_UNTAG_EN is bits 20-14, VLAN_3_UNTAG_EN 27-21 and bits 31-28 are unused. The layout is the same for all of the VUB registers.

Quoted 17 lines

drivers/net/dsa/mt7628.c line 248

Quoted 7 lines
drivers/net/dsa/mt7628.c new file +7 -0
+static int mt7628_setup_internal_mdio(struct dsa_switch *ds)
+{
+	struct mt7628_esw *esw = ds->priv;
+	struct device *dev = ds->dev;
+	struct mii_bus *bus;
+
+	bus = devm_mdiobus_alloc(dev);

[Severity: High]
Does allocating a devm-managed MDIO bus inside a DSA setup callback cause resource leaks or sysfs collisions on re-bind?

The mt7628_setup_internal_mdio() function is called from the main mt7628_setup() callback. This setup callback runs every time the master conduit device binds. If the conduit interface is unbound and bound again, the setup callback is invoked a second time.

Quoted 5 lines

Because the bus lifecycle is tied to the switch platform device via devm_, the old bus is not freed when the conduit unbinds. Will the second devm_mdiobus_register() attempt fail with a sysfs name collision (-EEXIST), preventing the switch from initializing?

This can't happen. The switch device is unbound when the conduit device is unbound. Switch setup is only called through probe, so it can only be called once per device lifetime.

In net/dsa/conduit.c:428 a device link is set up for the switch to depend on the conduit device:

```
	/* The DSA conduit must use SET_NETDEV_DEV for this to work. */
	if (!netif_is_lag_master(dev)) {
		consumer_link = device_link_add(ds->dev, dev->dev.parent,
						DL_FLAG_AUTOREMOVE_CONSUMER);
		if (!consumer_link)
			netdev_err(dev,
				   "Failed to create a device link to DSA switch %s\n",
				   dev_name(ds->dev));
	}
```

MT7628 does not support lag, so the device link is set up for this device. This pattern is also used in other drivers, a few examples:
- in NXP NETC priv->dev is set to the &pci_dev->dev, which is used in devm_mdiobus_alloc_size().
- in mt7530-mmio priv->dev is set to the &platform_device->dev, which is then used in devm_mdiobus_alloc().

Quoted 7 lines
Quoted 4 lines
drivers/net/dsa/mt7628.c new file +4 -0
+	if (!bus)
+		return -ENOMEM;
+
+	bus->name = "MT7628 internal MDIO bus";
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4

Thanks,
Joris

#7 lore raw
In reply to Joris Vaisvila
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Thu, 13 Aug 2026 22:02:37 +0300 you wrote:

This patch series adds initial support for the MediaTek MT7628 Embedded Switch.

The driver implements the basic functionality required to operate the switch using DSA. The hardware provides five internal Fast Ethernet user ports and one Gigabit port connected internally to the CPU MAC.

[...]

Here is the summary with links:
- [net-next,v7,1/4] dt-bindings: net: dsa: add MT7628 ESW

    https://git.kernel.org/netdev/net-next/c/2873d364f408
  - [net-next,v7,2/4] net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs
    https://git.kernel.org/netdev/net-next/c/c9c235775bc4
  - [net-next,v7,3/4] net: dsa: initial MT7628 tagging driver
    https://git.kernel.org/netdev/net-next/c/44204fd425af
  - [net-next,v7,4/4] net: dsa: initial support for MT7628 embedded switch
    https://git.kernel.org/netdev/net-next/c/15062bb05e16

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html