Skip to contentSkip to conversation

net: phylink: check for SFP bus presence in phylink_expects_phy

PATCH In review Maxime Chevallier 2 participants 3 messages Apr 12, 2023

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

PATCH 1/1 net: phylink: check for SFP bus presence in phylink_expects_phy

When an SFP bus is present, we don't expect a PHY to be attached directly from the MAC driver, it will be handled by phylink at SFP attach time.

Fixes 653a180957a8 ("net: phylink: add phylink_expects_phy() method")

---
This was tested on dwmac_socfpga, following discussion here [1]

[1] : https://lore.kernel.org/netdev/PH0PR11MB758766370DD16A5107B1FAB69D9B9@PH0PR11MB7587.namprd11.prod.outlook.com/

 drivers/net/phy/phylink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/phy/phylink.c +2 -1
index a4111f1be375..334018f1028d 100644
@@ -1594,7 +1594,8 @@ EXPORT_SYMBOL_GPL(phylink_destroy);
  */
 bool phylink_expects_phy(struct phylink *pl)
 {
-	if (pl->cfg_link_an_mode == MLO_AN_FIXED ||
+	if (pl->sfp_bus ||
+	    pl->cfg_link_an_mode == MLO_AN_FIXED ||
 	    (pl->cfg_link_an_mode == MLO_AN_INBAND &&
 	     phy_interface_mode_is_8023z(pl->link_config.interface)))
 		return false;
Signature · 1 line
2.39.2
#1 lore raw
Quoted 3 lines · Maxime Chevallier

When an SFP bus is present, we don't expect a PHY to be attached directly from the MAC driver, it will be handled by phylink at SFP attach time.

If we have a SFP, then phylink should be configured for in-band mode. Maybe fix the firmware description instead?

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!
#2 lore raw

Hello Russell,

Quoted 8 lines · On Wed, 12 Apr 2023 08:51:21 +0100 "Russell King (Oracle)"…
Quoted 3 lines · Maxime Chevallier

When an SFP bus is present, we don't expect a PHY to be attached directly from the MAC driver, it will be handled by phylink at SFP attach time.

If we have a SFP, then phylink should be configured for in-band mode. Maybe fix the firmware description instead?

The DT used on that platform has the following configuration :

[...]
&gmac1 {
status = "okay";
phy-mode = "sgmii";
managed = "in-band-status";
sfp = <&sfp>;
[...]
}

Here phylink_expects_phy() returns true because although we use in-band management, the link mode is set to sgmii, and phylink_expects_phy() checks if we are in in-band mode AND 802.3z.

As we have an SFP and the link mode will be changed according to the module we plug-in, there should be no problem switching phy-mode to "1000BaseX", so I'm perfectly fine with this solution.

However, is it semantically correct to use sgmii here ? If so, it may be a bit counter-intuitive to have to set the mode to 1000BaseX just so that the phylink_expects_phy() check passes ?

Thanks for the quick reply,

Maxime