Skip to contentSkip to conversation

net: dsa: yt921x: Add support for Motorcomm YT921x

PATCH Superseded David Yang 6 participants 19 messages Sep 22, 2025 – Sep 26, 2025

Subsystems (7)

v11 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

David Yang

author maintainer
#0 lore raw

v11 cover net: dsa: yt921x: Add support for Motorcomm YT921x

Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:

- YT9215S / YT9215RB / YT9215SC: 5 GbE phys
- YT9213NB / YT9214NB: 2 GbE phys
- YT9218N / YT9218MB: 8 GbE phys

and up to 2 serdes interfaces.

This patch adds basic support for a working DSA switch.

v10: https://lore.kernel.org/r/[email protected]
- fix warnings related to PHY_INTERFACE_MODE_REVSGMII
v9: https://lore.kernel.org/r/[email protected]
- add PHY_INTERFACE_MODE_REVSGMII
- remove mdio_verify()
- remove uncessary fdb flush opeartions
- rework mib reading
- set port pvid by port_set_pvid()
v8: https://lore.kernel.org/r/[email protected]
- rework register polling
- rework mib reading
- other suggested code style changes
v7: https://lore.kernel.org/r/[email protected]
- simplify locking scheme
v6: https://lore.kernel.org/r/[email protected]
- handle unforwarded packets in tag driver
- move register and struct definitions to header file
- rework register abstraction and implement a driver lock
- implement *_stats and use a periodic work to fetch MIB
- remove EEPROM dump
- remove sysfs attr and other debug leftovers
- remove ds->user_mii_bus assignment
- run selftests and fix any errors found
v5: https://lore.kernel.org/r/[email protected]
- use enum for reg in dt binding
- fix phylink_mac_ops in the driver
- fix coding style
v4: https://lore.kernel.org/r/[email protected]
- remove switchid from dt binding
- remove hsr from tag driver
- use ratelimited log in tag driver
v3: https://lore.kernel.org/r/[email protected]
- fix words and warnings in dt binding
- remove unnecessary dev_warn_ratelimited and u64_from_u32
- remove lag and mst
- check for mdio results and fix a unlocked write in conduit_state_change
v2: https://lore.kernel.org/r/[email protected]
- fix words in dt binding
- add support for lag and mst
v1: https://lore.kernel.org/r/[email protected]
- fix coding style
- add dt binding
- add support for fdb, vlan and bridge

David Yang (5):
dt-bindings: ethernet-phy: add reverse SGMII phy interface type
net: phy: introduce PHY_INTERFACE_MODE_REVSGMII
dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
net: dsa: yt921x: Add support for Motorcomm YT921x

 .../bindings/net/dsa/motorcomm,yt921x.yaml    |  169 +
 .../bindings/net/ethernet-controller.yaml     |    1 +
 drivers/net/dsa/Kconfig                       |    7 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/yt921x.c                      | 2900 +++++++++++++++++
 drivers/net/dsa/yt921x.h                      |  505 +++
 drivers/net/phy/phy-core.c                    |    1 +
 drivers/net/phy/phy_caps.c                    |    1 +
 drivers/net/phy/phylink.c                     |    1 +
 include/linux/phy.h                           |    4 +
 include/net/dsa.h                             |    2 +
 include/uapi/linux/if_ether.h                 |    1 +
 net/dsa/Kconfig                               |    6 +
 net/dsa/Makefile                              |    1 +
 net/dsa/tag_yt921x.c                          |  141 +
 15 files changed, 3741 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
 create mode 100644 drivers/net/dsa/yt921x.c
 create mode 100644 drivers/net/dsa/yt921x.h
 create mode 100644 net/dsa/tag_yt921x.c
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH v11 1/5 dt-bindings: ethernet-phy: add reverse SGMII phy interface type

The "reverse SGMII" protocol name is a personal invention, derived from "reverse MII" and "reverse RMII", this means: "behave like an SGMII PHY".

---
 Documentation/devicetree/bindings/net/ethernet-controller.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +1 -0
index 2c924d296a8f..8f190fe2208a 100644
@@ -42,6 +42,7 @@ properties:
       - mii-lite
       - gmii
       - sgmii
+      - rev-sgmii
       - psgmii
       - qsgmii
       - qusgmii
Signature · 1 line
2.51.0
maintainer Acked-by on v11 1/5
#2 lore raw

Re: [PATCH net-next v11 1/5] dt-bindings: ethernet-phy: add reverse SGMII phy interface type

Quoted 9 lines · David Yang

The "reverse SGMII" protocol name is a personal invention, derived from "reverse MII" and "reverse RMII", this means: "behave like an SGMII PHY".

---
 Documentation/devicetree/bindings/net/ethernet-controller.yaml | 1 +
 1 file changed, 1 insertion(+)
author maintainer
#3 lore raw

PATCH v11 2/5 net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

In reply to David Yang

The "reverse SGMII" protocol name is a personal invention, derived from "reverse MII" and "reverse RMII", this means: "behave like an SGMII PHY".

---
 drivers/net/phy/phy-core.c | 1 +
 drivers/net/phy/phy_caps.c | 1 +
 drivers/net/phy/phylink.c  | 1 +
 include/linux/phy.h        | 4 ++++
 4 files changed, 7 insertions(+)
drivers/net/phy/phy-core.c +1 -0
index 605ca20ae192..074645840cd5 100644
@@ -132,6 +132,7 @@ int phy_interface_num_ports(phy_interface_t interface)
 	case PHY_INTERFACE_MODE_TRGMII:
 	case PHY_INTERFACE_MODE_USXGMII:
 	case PHY_INTERFACE_MODE_SGMII:
+	case PHY_INTERFACE_MODE_REVSGMII:
 	case PHY_INTERFACE_MODE_SMII:
 	case PHY_INTERFACE_MODE_1000BASEX:
 	case PHY_INTERFACE_MODE_2500BASEX:
drivers/net/phy/phy_caps.c +1 -0
index 2cc9ee97e867..9a9a8afc056f 100644
@@ -299,6 +299,7 @@ unsigned long phy_caps_from_interface(phy_interface_t interface)
 	case PHY_INTERFACE_MODE_PSGMII:
 	case PHY_INTERFACE_MODE_QSGMII:
 	case PHY_INTERFACE_MODE_QUSGMII:
+	case PHY_INTERFACE_MODE_REVSGMII:
 	case PHY_INTERFACE_MODE_SGMII:
 	case PHY_INTERFACE_MODE_GMII:
 		link_caps |= BIT(LINK_CAPA_1000HD) | BIT(LINK_CAPA_1000FD);
drivers/net/phy/phylink.c +1 -0
index 1b06805f1bd7..e8e237fb9d35 100644
@@ -255,6 +255,7 @@ static int phylink_interface_max_speed(phy_interface_t interface)
 	case PHY_INTERFACE_MODE_PSGMII:
 	case PHY_INTERFACE_MODE_QSGMII:
 	case PHY_INTERFACE_MODE_QUSGMII:
+	case PHY_INTERFACE_MODE_REVSGMII:
 	case PHY_INTERFACE_MODE_SGMII:
 	case PHY_INTERFACE_MODE_GMII:
 		return SPEED_1000;
include/linux/phy.h +4 -0
index 7da9e19471c9..42d5c1f4d8ad 100644
@@ -107,6 +107,7 @@ extern const int phy_basic_ports_array[3];
  * @PHY_INTERFACE_MODE_LAUI: 50 Gigabit Attachment Unit Interface
  * @PHY_INTERFACE_MODE_100GBASEP: 100GBase-P - with Clause 134 FEC
  * @PHY_INTERFACE_MODE_MIILITE: MII-Lite - MII without RXER TXER CRS COL
+ * @PHY_INTERFACE_MODE_REVSGMII: Serial gigabit media-independent interface in PHY role
  * @PHY_INTERFACE_MODE_MAX: Book keeping
  *
  * Describes the interface between the MAC and PHY.
@@ -152,6 +153,7 @@ typedef enum {
 	PHY_INTERFACE_MODE_LAUI,
 	PHY_INTERFACE_MODE_100GBASEP,
 	PHY_INTERFACE_MODE_MIILITE,
+	PHY_INTERFACE_MODE_REVSGMII,
 	PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
@@ -281,6 +283,8 @@ static inline const char *phy_modes(phy_interface_t interface)
 		return "100gbase-p";
 	case PHY_INTERFACE_MODE_MIILITE:
 		return "mii-lite";
+	case PHY_INTERFACE_MODE_REVSGMII:
+		return "rev-sgmii";
 	default:
 		return "unknown";
 	}
Signature · 1 line
2.51.0
Reviewed-by on v11 2/5
#4 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 3 lines · David Yang

The "reverse SGMII" protocol name is a personal invention, derived from "reverse MII" and "reverse RMII", this means: "behave like an SGMII PHY".

Wasn't it Russell who suggested that name ? :D

Quoted 1 line

Maxime

#5 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

In reply to David Yang
Quoted 3 lines · David Yang

The "reverse SGMII" protocol name is a personal invention, derived from "reverse MII" and "reverse RMII", this means: "behave like an SGMII PHY".

Sorry to mess you around, but... I've been getting further with stmmac's PCS stuff (I've started again with it) and I've come to realise that the stmmac driver is full of worms here.

I think we need to have a bigger discussion here.

Today, we have:

- PHY_INTERFACE_MODE_REVMII
- PHY_INTERFACE_MODE_REVRMII

which both complement their _MII and _RMII definitions. So, it seems entirely sensible to also introduce REVSGMII to complement SGMII.

However, stmmac hardware supports "reverse" mode for more than just SGMII, also RGMII and SMII. The driver doesn't support SMII, and is actually buggy - despite having the DT configuration knobs (which are used), the hardware is never actually configured to operate in "reverse" mode (it never has the GMAC_CONFIG_TC bit set to allow the core to, in effect, act as a PHY.) That said, the core does have it's SGMII rate adapter switched from using the incoming inband word to using the MAC configuration.

So, while I thought this would be useful for stmmac, given that all the platforms we have today aren't actually using "reverse SGMII" mode, I don't think this will be useful there.

If we go round the route of adding REVSGMII, we are also opening the path to also having REVSMII, and all four REVRGMII* as well. Is this a good idea?

Would it be better to have phy_interface_t + reverse-mode flag and accept REVMII and REVRMII as a pecularity? That's probably going to be a very painful change.

Andrew, any views?

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
maintainer
#6 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 11 lines · Russell King (Oracle)
Quoted 3 lines · David Yang

The "reverse SGMII" protocol name is a personal invention, derived from "reverse MII" and "reverse RMII", this means: "behave like an SGMII PHY".

Sorry to mess you around, but... I've been getting further with stmmac's PCS stuff (I've started again with it) and I've come to realise that the stmmac driver is full of worms here.

I think we need to have a bigger discussion here.

Quoted 7 lines

Today, we have:

- PHY_INTERFACE_MODE_REVMII
- PHY_INTERFACE_MODE_REVRMII

which both complement their _MII and _RMII definitions. So, it seems entirely sensible to also introduce REVSGMII to complement SGMII.

Maybe we need to think about, what does REVfoo actually mean?

Is it simply about, who provides the clock? For MII, the 'PHY' provides the clock to the 'MAC;. So does REVMII simply mean a MAC in REVMII mode provides the clock? Is more needed? As far as i know MII does not have any inband signalling.

For RMII, it appears each side can provide the clock, or consume the clock, or a 3rd party can provide the clock. It is a hardware design choice. So does REVRMII actual mean anything? Again there is no inband signalling.

GMII the transmit clock is provided by the transmitter, the receive clock by the receiver. It is symmetrical. REV has no meaning here?

In theory, {R}GMII does have inband signalling, but it is pretty much never used. REV for GMII could thus indicate what role the device is playing in this in-band signalling?

For any SERDES based links likes like SGMII, 1000Base-X and above, clocking is part of the SERDES, so symmetrical. There clearly is inband signalling, mostly, when it is not broken because of overclocked SGMII. But we have never needed to specify what role each end needs to play.

Quoted 2 lines

However, stmmac hardware supports "reverse" mode for more than just SGMII, also RGMII and SMII.

How does the databook describe reverse SGMII? How does it differ from SGMII?

Andrew

#7 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 3 lines · Andrew Lunn

In theory, {R}GMII does have inband signalling, but it is pretty much never used. REV for GMII could thus indicate what role the device is playing in this in-band signalling?

For RGMII, as you say, the in-band signalling is pretty much never used. The stmmac code as it stands today does have support for using it, but the code has been broken for longer than six years:

1. the longest historical breakage, it's conditional on the hardware reporting that it has a PCS integrated into the design, but a PCS won't be integrated into the design for RGMII-only cases.

2. even if (1) was fixed, that would result in the driver manipulating the netif carrier state from interrupt context, always beating phylink's resolve worker, meaning that mac_link_(down|up) never get called. This results in no traffic flow and a non-functional interface.

So, maybe we should just ignore the RGMII in-band signalling until someone pops up with a hard and fast requirement for it.

Quoted 5 lines

For any SERDES based links likes like SGMII, 1000Base-X and above, clocking is part of the SERDES, so symmetrical. There clearly is inband signalling, mostly, when it is not broken because of overclocked SGMII. But we have never needed to specify what role each end needs to play.

100base-X is intentionally symmetric, and designed for:

	MAC----PCS---- some kind of link ----PCS----MAC

where "some kind of link" is fibre or copper. There is no reverse mode possible there, because "reverse" is just the same as "normal".

For SGMII though, it's a different matter. The PHY-like end transmits the link configuration. The MAC-like end receives the link configuration and configures itself to it - and never sends a link configuration back.

So, the formats of the in-band tx_config_reg[15:0] are different depending on the role each end is in.

In order for a SGMII link with in-band signalling to work, one end has to assume the MAC-like role and the other a PHY-like role.

PHY_INTERFACE_MODE_SGMII generally means that the MAC is acting in a MAC-like role. However, stmmac had the intention (but broken) idea that setting the DT snps,ps-speed property would configure it into a PHY-like role. It almost does... but instead of setting the "transmit configuration" (TC) bit, someone typo'd and instead set the "transmit enable" (TE) bit. So no one has actually had their stmmac-based device operating in a PHY-like role, even if they _thought_ it was!

Quoted 5 lines
Quoted 2 lines

However, stmmac hardware supports "reverse" mode for more than just SGMII, also RGMII and SMII.

How does the databook describe reverse SGMII? How does it differ from SGMII?

It doesn't describe "reverse SGMII". Instead, it describes:

1. The TC bit in the MAC configuration register, which makes the block transmit the speed and duplex from the MAC configuration register over RGMII, SGMII or SMII links (only, not 1000base-X.)

2. The SGMIIRAL bit in the PCS control register, which switches where the SGMII rate adapter layer takes its speed configuration from - either the incoming in-band tx_config_reg[15:0] word, or from the MAC configuration register. It is explicitly stated for this bit that it is for back-to-back MAC links, and as it's specific to SGMII, that means a back-to-back SGMII MAC link.

Set both these bits while the MAC is configured for SGMII mode, and you have a stmmac MAC which immitates a SGMII PHY as far as the in-band tx_config_reg[15:0] word is concerned.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
author maintainer
#8 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 74 lines · Russell King (Oracle)
Quoted 3 lines · Andrew Lunn

In theory, {R}GMII does have inband signalling, but it is pretty much never used. REV for GMII could thus indicate what role the device is playing in this in-band signalling?

For RGMII, as you say, the in-band signalling is pretty much never used. The stmmac code as it stands today does have support for using it, but the code has been broken for longer than six years:

1. the longest historical breakage, it's conditional on the hardware reporting that it has a PCS integrated into the design, but a PCS won't be integrated into the design for RGMII-only cases.

2. even if (1) was fixed, that would result in the driver manipulating the netif carrier state from interrupt context, always beating phylink's resolve worker, meaning that mac_link_(down|up) never get called. This results in no traffic flow and a non-functional interface.

So, maybe we should just ignore the RGMII in-band signalling until someone pops up with a hard and fast requirement for it.

Quoted 5 lines

For any SERDES based links likes like SGMII, 1000Base-X and above, clocking is part of the SERDES, so symmetrical. There clearly is inband signalling, mostly, when it is not broken because of overclocked SGMII. But we have never needed to specify what role each end needs to play.

100base-X is intentionally symmetric, and designed for:

        MAC----PCS---- some kind of link ----PCS----MAC

where "some kind of link" is fibre or copper. There is no reverse mode possible there, because "reverse" is just the same as "normal".

For SGMII though, it's a different matter. The PHY-like end transmits the link configuration. The MAC-like end receives the link configuration and configures itself to it - and never sends a link configuration back.

So, the formats of the in-band tx_config_reg[15:0] are different depending on the role each end is in.

In order for a SGMII link with in-band signalling to work, one end has to assume the MAC-like role and the other a PHY-like role.

PHY_INTERFACE_MODE_SGMII generally means that the MAC is acting in a MAC-like role. However, stmmac had the intention (but broken) idea that setting the DT snps,ps-speed property would configure it into a PHY-like role. It almost does... but instead of setting the "transmit configuration" (TC) bit, someone typo'd and instead set the "transmit enable" (TE) bit. So no one has actually had their stmmac-based device operating in a PHY-like role, even if they _thought_ it was!

Quoted 5 lines
Quoted 2 lines

However, stmmac hardware supports "reverse" mode for more than just SGMII, also RGMII and SMII.

How does the databook describe reverse SGMII? How does it differ from SGMII?

It doesn't describe "reverse SGMII". Instead, it describes:

1. The TC bit in the MAC configuration register, which makes the block transmit the speed and duplex from the MAC configuration register over RGMII, SGMII or SMII links (only, not 1000base-X.)

2. The SGMIIRAL bit in the PCS control register, which switches where the SGMII rate adapter layer takes its speed configuration from - either the incoming in-band tx_config_reg[15:0] word, or from the MAC configuration register. It is explicitly stated for this bit that it is for back-to-back MAC links, and as it's specific to SGMII, that means a back-to-back SGMII MAC link.

Quoted 7 lines

Set both these bits while the MAC is configured for SGMII mode, and you have a stmmac MAC which immitates a SGMII PHY as far as the in-band tx_config_reg[15:0] word is concerned.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

So any conclusion? Should I go on with REV*MII, or wait for (or write it myself) reverse-mode flag?

#9 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 76 lines · Yangfl
Quoted 74 lines · Russell King (Oracle)
Quoted 3 lines · Andrew Lunn

In theory, {R}GMII does have inband signalling, but it is pretty much never used. REV for GMII could thus indicate what role the device is playing in this in-band signalling?

For RGMII, as you say, the in-band signalling is pretty much never used. The stmmac code as it stands today does have support for using it, but the code has been broken for longer than six years:

1. the longest historical breakage, it's conditional on the hardware reporting that it has a PCS integrated into the design, but a PCS won't be integrated into the design for RGMII-only cases.

2. even if (1) was fixed, that would result in the driver manipulating the netif carrier state from interrupt context, always beating phylink's resolve worker, meaning that mac_link_(down|up) never get called. This results in no traffic flow and a non-functional interface.

So, maybe we should just ignore the RGMII in-band signalling until someone pops up with a hard and fast requirement for it.

Quoted 5 lines

For any SERDES based links likes like SGMII, 1000Base-X and above, clocking is part of the SERDES, so symmetrical. There clearly is inband signalling, mostly, when it is not broken because of overclocked SGMII. But we have never needed to specify what role each end needs to play.

100base-X is intentionally symmetric, and designed for:

        MAC----PCS---- some kind of link ----PCS----MAC

where "some kind of link" is fibre or copper. There is no reverse mode possible there, because "reverse" is just the same as "normal".

For SGMII though, it's a different matter. The PHY-like end transmits the link configuration. The MAC-like end receives the link configuration and configures itself to it - and never sends a link configuration back.

So, the formats of the in-band tx_config_reg[15:0] are different depending on the role each end is in.

In order for a SGMII link with in-band signalling to work, one end has to assume the MAC-like role and the other a PHY-like role.

PHY_INTERFACE_MODE_SGMII generally means that the MAC is acting in a MAC-like role. However, stmmac had the intention (but broken) idea that setting the DT snps,ps-speed property would configure it into a PHY-like role. It almost does... but instead of setting the "transmit configuration" (TC) bit, someone typo'd and instead set the "transmit enable" (TE) bit. So no one has actually had their stmmac-based device operating in a PHY-like role, even if they _thought_ it was!

Quoted 5 lines
Quoted 2 lines

However, stmmac hardware supports "reverse" mode for more than just SGMII, also RGMII and SMII.

How does the databook describe reverse SGMII? How does it differ from SGMII?

It doesn't describe "reverse SGMII". Instead, it describes:

1. The TC bit in the MAC configuration register, which makes the block transmit the speed and duplex from the MAC configuration register over RGMII, SGMII or SMII links (only, not 1000base-X.)

2. The SGMIIRAL bit in the PCS control register, which switches where the SGMII rate adapter layer takes its speed configuration from - either the incoming in-band tx_config_reg[15:0] word, or from the MAC configuration register. It is explicitly stated for this bit that it is for back-to-back MAC links, and as it's specific to SGMII, that means a back-to-back SGMII MAC link.

Quoted 6 lines
Quoted 3 lines

Set both these bits while the MAC is configured for SGMII mode, and you have a stmmac MAC which immitates a SGMII PHY as far as the in-band tx_config_reg[15:0] word is concerned.

So any conclusion? Should I go on with REV*MII, or wait for (or write it myself) reverse-mode flag?

Clearly not as there's been no discussion beyond my response to Andrew. I don't know what to suggest, as whatever decision we make here, we will have to live with the consequences of it for a very long time.

I suspect no one really knows the answer, so given the lack of engagement on the issue, my suggestion would be to just press ahead with your current approach.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
maintainer
#10 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

In reply to Yangfl
Quoted 16 lines
Quoted 16 lines
Quoted 2 lines

How does the databook describe reverse SGMII? How does it differ from SGMII?

It doesn't describe "reverse SGMII". Instead, it describes:

1. The TC bit in the MAC configuration register, which makes the block transmit the speed and duplex from the MAC configuration register over RGMII, SGMII or SMII links (only, not 1000base-X.)

2. The SGMIIRAL bit in the PCS control register, which switches where the SGMII rate adapter layer takes its speed configuration from - either the incoming in-band tx_config_reg[15:0] word, or from the MAC configuration register. It is explicitly stated for this bit that it is for back-to-back MAC links, and as it's specific to SGMII, that means a back-to-back SGMII MAC link.

Quoted 6 lines
Quoted 3 lines

Set both these bits while the MAC is configured for SGMII mode, and you have a stmmac MAC which immitates a SGMII PHY as far as the in-band tx_config_reg[15:0] word is concerned.

So any conclusion? Should I go on with REV*MII, or wait for (or write it myself) reverse-mode flag?

Sorry, i'm missing some context here.

Why do you actually need REVSGMII, or at least the concept?

REVMII is used when you connect one MAC to another. You need to indicate one ends needs to play the PHY role. This is generally when you connect a host MAC to an Ethernet switch, and you want the switch to play the PHY role.

Now consider SGMII, when connecting a host MAC to a switch. Why would you even use SGMII, 1000BaseX is the more logical choice. You don't want the link to run at 100Mbps, or 10Mbps. The link between the host and the switch should run as fast as possible. And 1000BaseX is symmetrical, you don't need a REV concept.

Also, in these cases, stmmmac is on the host, not the switch, so it will have the host role, leaving the switch to play 'PHY'. I'm not sure you could even embedded stmmac in a switch, where it might want to play 'PHY', because stmmac is software driven, where as a switch is all hardware.

So the hardware supports reverse SGMII, but it is not clear to me why you would want to use it.

Andrew

author maintainer
#11 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 45 lines · Andrew Lunn
Quoted 17 lines
Quoted 17 lines
Quoted 3 lines

How does the databook describe reverse SGMII? How does it differ from SGMII?

It doesn't describe "reverse SGMII". Instead, it describes:

1. The TC bit in the MAC configuration register, which makes the block transmit the speed and duplex from the MAC configuration register over RGMII, SGMII or SMII links (only, not 1000base-X.)

2. The SGMIIRAL bit in the PCS control register, which switches where the SGMII rate adapter layer takes its speed configuration from - either the incoming in-band tx_config_reg[15:0] word, or from the MAC configuration register. It is explicitly stated for this bit that it is for back-to-back MAC links, and as it's specific to SGMII, that means a back-to-back SGMII MAC link.

Quoted 6 lines
Quoted 3 lines

Set both these bits while the MAC is configured for SGMII mode, and you have a stmmac MAC which immitates a SGMII PHY as far as the in-band tx_config_reg[15:0] word is concerned.

So any conclusion? Should I go on with REV*MII, or wait for (or write it myself) reverse-mode flag?

Sorry, i'm missing some context here.

Why do you actually need REVSGMII, or at least the concept?

REVMII is used when you connect one MAC to another. You need to indicate one ends needs to play the PHY role. This is generally when you connect a host MAC to an Ethernet switch, and you want the switch to play the PHY role.

Now consider SGMII, when connecting a host MAC to a switch. Why would you even use SGMII, 1000BaseX is the more logical choice. You don't want the link to run at 100Mbps, or 10Mbps. The link between the host and the switch should run as fast as possible. And 1000BaseX is symmetrical, you don't need a REV concept.

Also, in these cases, stmmmac is on the host, not the switch, so it will have the host role, leaving the switch to play 'PHY'. I'm not sure you could even embedded stmmac in a switch, where it might want to play 'PHY', because stmmac is software driven, where as a switch is all hardware.

Quoted 5 lines

So the hardware supports reverse SGMII, but it is not clear to me why you would want to use it.

Andrew

Cause I couldn't make 1000BaseX work with qca-ssdk, so I can only confirm and test REVSGMII mode on my device.

#12 lore raw

Re: [PATCH net-next v11 2/5] net: phy: introduce PHY_INTERFACE_MODE_REVSGMII

Quoted 46 lines · Yangfl
Quoted 45 lines · Andrew Lunn
Quoted 17 lines
Quoted 17 lines
Quoted 3 lines

How does the databook describe reverse SGMII? How does it differ from SGMII?

It doesn't describe "reverse SGMII". Instead, it describes:

1. The TC bit in the MAC configuration register, which makes the block transmit the speed and duplex from the MAC configuration register over RGMII, SGMII or SMII links (only, not 1000base-X.)

2. The SGMIIRAL bit in the PCS control register, which switches where the SGMII rate adapter layer takes its speed configuration from - either the incoming in-band tx_config_reg[15:0] word, or from the MAC configuration register. It is explicitly stated for this bit that it is for back-to-back MAC links, and as it's specific to SGMII, that means a back-to-back SGMII MAC link.

Quoted 6 lines
Quoted 3 lines

Set both these bits while the MAC is configured for SGMII mode, and you have a stmmac MAC which immitates a SGMII PHY as far as the in-band tx_config_reg[15:0] word is concerned.

So any conclusion? Should I go on with REV*MII, or wait for (or write it myself) reverse-mode flag?

Sorry, i'm missing some context here.

Why do you actually need REVSGMII, or at least the concept?

REVMII is used when you connect one MAC to another. You need to indicate one ends needs to play the PHY role. This is generally when you connect a host MAC to an Ethernet switch, and you want the switch to play the PHY role.

Now consider SGMII, when connecting a host MAC to a switch. Why would you even use SGMII, 1000BaseX is the more logical choice. You don't want the link to run at 100Mbps, or 10Mbps. The link between the host and the switch should run as fast as possible. And 1000BaseX is symmetrical, you don't need a REV concept.

Also, in these cases, stmmmac is on the host, not the switch, so it will have the host role, leaving the switch to play 'PHY'. I'm not sure you could even embedded stmmac in a switch, where it might want to play 'PHY', because stmmac is software driven, where as a switch is all hardware.

Quoted 8 lines
Quoted 5 lines

So the hardware supports reverse SGMII, but it is not clear to me why you would want to use it.

Andrew

Cause I couldn't make 1000BaseX work with qca-ssdk, so I can only confirm and test REVSGMII mode on my device.

I think it would help if you could show what you tried for 1000base-X in terms of dts fragments for both ends.

Marvell DSA switches support 1000base-X, but it defaults to link-down and without AN, so expecting in-band to work with it doesn't result in a working link, but using fixed-link on both ends does.

Maybe qca-ssdk needs that as well? Is that what you tried?

It could also be a buggy MAC driver that doesn't disable in-band AN for 1000base-X in fixed link mode.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
author maintainer
#13 lore raw

PATCH v11 3/5 dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support

In reply to David Yang

The Motorcomm YT921x series is a family of Ethernet switches with up to 8 internal GbE PHYs and up to 2 GMACs.

---
 .../bindings/net/dsa/motorcomm,yt921x.yaml    | 169 ++++++++++++++++++
 1 file changed, 169 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +169 -0
new file mode 100644
index 000000000000..ff03bff0be4f
@@ -0,0 +1,169 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/dsa/motorcomm,yt921x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorcomm YT921x Ethernet switch family
+
+maintainers:
+  - David Yang <[email protected]>
+
+description: |
+  The Motorcomm YT921x series is a family of Ethernet switches with up to 8
+  internal GbE PHYs and up to 2 GMACs, including:
+
+    - YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs (Port 0-4) + 2 GMACs (Port 8-9)
+    - YT9213NB: 2 GbE PHYs (Port 1/3) + 1 GMAC (Port 9)
+    - YT9214NB: 2 GbE PHYs (Port 1/3) + 2 GMACs (Port 8-9)
+    - YT9218N: 8 GbE PHYs (Port 0-7)
+    - YT9218MB: 8 GbE PHYs (Port 0-7) + 2 GMACs (Port 8-9)
+
+  Any port can be used as the CPU port.
+
+properties:
+  compatible:
+    const: motorcomm,yt9215
+
+  reg:
+    enum: [0x0, 0x1d]
+
+  reset-gpios:
+    maxItems: 1
+
+  mdio:
+    $ref: /schemas/net/mdio.yaml#
+    unevaluatedProperties: false
+    description:
+      Internal MDIO bus for the internal GbE PHYs. PHY 0-7 are used for Port
+      0-7 respectively.
+
+  mdio-external:
+    $ref: /schemas/net/mdio.yaml#
+    unevaluatedProperties: false
+    description:
+      External MDIO bus to access external components. External PHYs for GMACs
+      (Port 8-9) are expected to be connected to the external MDIO bus in
+      vendor's reference design, but that is not a hard limitation from the
+      chip.
+
+required:
+  - compatible
+  - reg
+
+allOf:
+  - $ref: dsa.yaml#/$defs/ethernet-ports
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        switch@1d {
+            compatible = "motorcomm,yt9215";
+            /* default 0x1d, alternate 0x0 */
+            reg = <0x1d>;
+            reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
+
+            mdio {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                sw_phy0: phy@0 {
+                    reg = <0x0>;
+                };
+
+                sw_phy1: phy@1 {
+                    reg = <0x1>;
+                };
+
+                sw_phy2: phy@2 {
+                    reg = <0x2>;
+                };
+
+                sw_phy3: phy@3 {
+                    reg = <0x3>;
+                };
+
+                sw_phy4: phy@4 {
+                    reg = <0x4>;
+                };
+            };
+
+            mdio-external {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                phy1: phy@b {
+                    reg = <0xb>;
+                };
+            };
+
+            ethernet-ports {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                ethernet-port@0 {
+                    reg = <0>;
+                    label = "lan1";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy0>;
+                };
+
+                ethernet-port@1 {
+                    reg = <1>;
+                    label = "lan2";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy1>;
+                };
+
+                ethernet-port@2 {
+                    reg = <2>;
+                    label = "lan3";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy2>;
+                };
+
+                ethernet-port@3 {
+                    reg = <3>;
+                    label = "lan4";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy3>;
+                };
+
+                ethernet-port@4 {
+                    reg = <4>;
+                    label = "lan5";
+                    phy-mode = "internal";
+                    phy-handle = <&sw_phy4>;
+                };
+
+                /* CPU port */
+                ethernet-port@8 {
+                    reg = <8>;
+                    phy-mode = "rev-sgmii";
+                    ethernet = <&eth0>;
+
+                    fixed-link {
+                        speed = <1000>;
+                        full-duplex;
+                        pause;
+                        asym-pause;
+                    };
+                };
+
+                /* if external phy is connected to a MAC */
+                ethernet-port@9 {
+                    reg = <9>;
+                    label = "wan";
+                    phy-mode = "rgmii-id";
+                    phy-handle = <&phy1>;
+                };
+            };
+        };
+    };
Signature · 1 line
2.51.0
author maintainer
#14 lore raw

PATCH v11 4/5 net: dsa: tag_yt921x: add support for Motorcomm YT921x tags

In reply to David Yang

Add support for Motorcomm YT921x tags, which includes a proper configurable ethertype field (default to 0x9988).

---
 include/net/dsa.h             |   2 +
 include/uapi/linux/if_ether.h |   1 +
 net/dsa/Kconfig               |   6 ++
 net/dsa/Makefile              |   1 +
 net/dsa/tag_yt921x.c          | 141 ++++++++++++++++++++++++++++++++++
 5 files changed, 151 insertions(+)
 create mode 100644 net/dsa/tag_yt921x.c
include/net/dsa.h +2 -0
index d73ea0880066..67762fdaf3c7 100644
@@ -55,6 +55,7 @@ struct tc_action;
 #define DSA_TAG_PROTO_LAN937X_VALUE		27
 #define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE	28
 #define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE	29
+#define DSA_TAG_PROTO_YT921X_VALUE		30
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -87,6 +88,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_RZN1_A5PSW	= DSA_TAG_PROTO_RZN1_A5PSW_VALUE,
 	DSA_TAG_PROTO_LAN937X		= DSA_TAG_PROTO_LAN937X_VALUE,
 	DSA_TAG_PROTO_VSC73XX_8021Q	= DSA_TAG_PROTO_VSC73XX_8021Q_VALUE,
+	DSA_TAG_PROTO_YT921X		= DSA_TAG_PROTO_YT921X_VALUE,
 };
 
 struct dsa_switch;
include/uapi/linux/if_ether.h +1 -0
index 69e0457eb200..cfd200c87e5e 100644
@@ -114,6 +114,7 @@
 #define ETH_P_QINQ1	0x9100		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_QINQ2	0x9200		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_QINQ3	0x9300		/* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_YT921X	0x9988		/* Motorcomm YT921x DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_EDSA	0xDADA		/* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_DSA_8021Q	0xDADB		/* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
 #define ETH_P_DSA_A5PSW	0xE001		/* A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] */
net/dsa/Kconfig +6 -0
index 869cbe57162f..6b94028b1fcc 100644
@@ -190,4 +190,10 @@ config NET_DSA_TAG_XRS700X
 	  Say Y or M if you want to enable support for tagging frames for
 	  Arrow SpeedChips XRS700x switches that use a single byte tag trailer.
 
+config NET_DSA_TAG_YT921X
+	tristate "Tag driver for Motorcomm YT921x switches"
+	help
+	  Say Y or M if you want to enable support for tagging frames for
+	  Motorcomm YT921x switches.
+
 endif
net/dsa/Makefile +1 -0
index 555c07cfeb71..4b011a1d5c87 100644
@@ -39,6 +39,7 @@ obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o
 obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
 obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o
 obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o
+obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o
 
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
net/dsa/tag_yt921x.c new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
2.51.0
author maintainer
#15 lore raw

PATCH v11 5/5 net: dsa: yt921x: Add support for Motorcomm YT921x

In reply to David Yang

Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:

- YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs
- YT9213NB / YT9214NB: 2 GbE PHYs
- YT9218N / YT9218MB: 8 GbE PHYs

and up to 2 GMACs.

Driver verified on a stock wireless router with IPQ5018 + YT9215S.

---
 drivers/net/dsa/Kconfig  |    7 +
 drivers/net/dsa/Makefile |    1 +
 drivers/net/dsa/yt921x.c | 2900 ++++++++++++++++++++++++++++++++++++++
 drivers/net/dsa/yt921x.h |  505 +++++++
 4 files changed, 3413 insertions(+)
 create mode 100644 drivers/net/dsa/yt921x.c
 create mode 100644 drivers/net/dsa/yt921x.h
drivers/net/dsa/Kconfig +7 -0
index 4d9af691b989..7eb301fd987d 100644
@@ -154,4 +154,11 @@ config NET_DSA_VITESSE_VSC73XX_PLATFORM
 	  This enables support for the Vitesse VSC7385, VSC7388, VSC7395
 	  and VSC7398 SparX integrated ethernet switches, connected over
 	  a CPU-attached address bus and work in memory-mapped I/O mode.
+
+config NET_DSA_YT921X
+	tristate "Motorcomm YT9215 ethernet switch chip support"
+	select NET_DSA_TAG_YT921X
+	help
+	  This enables support for the Motorcomm YT9215 ethernet switch
+	  chip.
 endmenu
drivers/net/dsa/Makefile +1 -0
index 0f8ff4a1a313..16de4ba3fa38 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o
 obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o
+obj-$(CONFIG_NET_DSA_YT921X) += yt921x.o
 obj-y				+= b53/
 obj-y				+= hirschmann/
 obj-y				+= lantiq/
drivers/net/dsa/yt921x.c new file +2900 -0

2,900 lines not on this page · raw message

drivers/net/dsa/yt921x.h new file +505 -0

82 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.51.0

Part of the diff is not shown here. View the raw message.

maintainer
#16 lore raw

drivers/net/dsa/yt921x.c line 41

Quoted 4 lines · On Mon, 22 Sep 2025 21:11:43 +0800 David Yang wrote:
drivers/net/dsa/yt921x.c new file +4 -0
+	MIB_DESC(1, 0x00, "RxBroadcast", false),	/* rx broadcast pkts */
+	MIB_DESC(1, 0x04, "RxPause", false),		/* rx pause pkts */
+	MIB_DESC(1, 0x08, "RxMulticast", false),	/* rx multicast pkts, excluding pause and OAM */
+	MIB_DESC(1, 0x0c, "RxCrcErr", false),		/* rx crc err pkts, len >= 64B */

Keeping the string names for every stat, and the boolean seems like an overkill when there is grand total of 3 stats that set "true". The comments for IEEE stats can also go, there's no extra information here.

drivers/net/dsa/yt921x.c line 2831

Quoted 7 lines
drivers/net/dsa/yt921x.c new file +6 -0
+static void yt921x_mdio_remove(struct mdio_device *mdiodev)
+{
 
+		cancel_delayed_work_sync(&pp->mib_read);
+	}
+
+	dsa_unregister_switch(&priv->ds);

The work canceling looks racy, the port can come up in between cancel_work and dsa_unregister ? disable_delayed_work.. will likely do the job.

Signature · 1 line
pw-bot: cr
author maintainer
#17 lore raw

On Wed, Sep 24, 2025 at 8:47 AM Jakub Kicinski <[email protected]> wrote:
...

Quoted 4 lines
Quoted 3 lines
drivers/net/dsa/yt921x.c new file +2 -0
+static void yt921x_mdio_remove(struct mdio_device *mdiodev)
+{
Quoted 8 lines

drivers/net/dsa/yt921x.c line 2831

Quoted 4 lines
drivers/net/dsa/yt921x.c new file +4 -0
+             cancel_delayed_work_sync(&pp->mib_read);
+     }
+
+     dsa_unregister_switch(&priv->ds);

The work canceling looks racy, the port can come up in between cancel_work and dsa_unregister ? disable_delayed_work.. will likely do the job.

Are you sure about this? There are many others who use cancel_delayed_work_sync in their teardown methods (for example ar9331_sw_remove). If that is true, they should be fixed too.

maintainer
#18 lore raw
Quoted 6 lines · On Wed, 24 Sep 2025 20:33:57 +0800 Yangfl wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 4 lines
drivers/net/dsa/yt921x.c new file +4 -0
+             cancel_delayed_work_sync(&pp->mib_read);
+     }
+
+     dsa_unregister_switch(&priv->ds);  
Quoted 7 lines
Quoted 3 lines

The work canceling looks racy, the port can come up in between cancel_work and dsa_unregister ? disable_delayed_work.. will likely do the job.

Are you sure about this? There are many others who use cancel_delayed_work_sync in their teardown methods (for example ar9331_sw_remove). If that is true, they should be fixed too.

Not at all! I'll gladly accept an explanation of why the code is correct. "Someone else is doing it too" is not an explanation.