netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] RJ45 to SFP auto-sensing and switching in mux-ed single-mac devices (XOR RJ/SFP)
@ 2023-08-29 15:12 Nicolò Veronese
  2023-08-29 15:38 ` Russell King (Oracle)
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolò Veronese @ 2023-08-29 15:12 UTC (permalink / raw)
  To: netdev
  Cc: simonebortolin, nanomad, Federico Cappon, daniel, lorenzo, ftp21,
	pierto88, hitech95, davem, andrew, edumazet, hkallweit1, kuba,
	pabeni, linux, nbd

Hi,

I and some folks in CC are working to properly port all the
 functions of a Zyxel ex5601-t0 to OpenWrt.

The manufacturer decided to use a single SerDes connected
 to both an SPF cage and an RJ45 phy. A simple GPIO is
 used to control a 2 Channel 2:1 MUX to switch the two SGMII pairs
 between the RJ45 and the SFP.

  ┌─────┐  ┌──────┐   ┌─────────┐
  │     │  │      │   │         │
  │     │  │      ├───┤ SFP     │
  │     │  │      │   └─────────┘
  │     │  │      │
  │ MAC ├──┤ MUX  │   ┌─────────┐
  │     │  │      │   │         │
  │     │  │      │   │ RJ45    │
  │     │  │      ├───┤ 2.5G PHY│
  │     │  │      │   │         │
  └─────┘  └───▲──┘   └─────────┘
               │
  MUX-GPIO ────┘

Other vendors may implement this differently (e.g. Keenetic
 KN-1011 has a similar setup, although the PHY is doing all the work),
 but this seems a common enough approach to produce cheap CPEs
 with multiple interface types for fiber internet.

In this particular case, Zyxel implemented a user-land script[1] that is
 continuously polling GPIO 57 (Moddef0) of the SFP cage.

Once an SFP module is detected the process continues as follows:
- An MDIO command disables the RJ45 PHY
- A GPIO write to GPIO 10 that switches the MUX to the SFP interface
- The MAC is then re-configured by writing directly to the SoC registers
 using a mix of lookup tables and heuristics/try-catch.

This allows Zyxel to configure the MAC with the supposedly correct SFP
 interface speed, bypassing any well-established interface speed
 auto-detection and negotiation logic.

Zyxel also configures the GMAC at boot with a fixed speed of 2500M
 forcing the link status to be always up irrespective of the real
 physical interface status.

On SFP disconnect the process is simply applied in reverse.

We are looking for guidance on how to design changes that could achieve
 the following goals and could be accepted upstream in the future:

 - SFP and RJ45 speed auto-sensing and auto-negotiation working
 - Automatic SFP/RJ45 switching
 - Failsafe logic in case both media are connected.
 - Reduce overall potential power consumption and rate-adaption by not
   having the GMAC always switched to 2500M mode without reason.
 - (optional) default configurable logic for both failsafe and idle status

References:
[1]: https://github.com/pameruoso/zyxel-ex5601t0/blob/V5.70(ACDZ.0)C0/target/linux/mediatek/ex5601t0/base-files/bin/sfp_wan.sh

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-04  6:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-29 15:12 [RFC] RJ45 to SFP auto-sensing and switching in mux-ed single-mac devices (XOR RJ/SFP) Nicolò Veronese
2023-08-29 15:38 ` Russell King (Oracle)
2023-08-29 17:37   ` Daniel Golle
2023-08-29 18:04     ` Russell King (Oracle)
2023-08-31  1:04   ` Jakub Kicinski
2023-09-03 22:51   ` Andrew Lunn
2023-09-04  6:06     ` Maxime Chevallier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).