diff mbox series

[net] net: phylink: check for SFP bus presence in phylink_expects_phy

Message ID 20230412074850.41260-1-maxime.chevallier@bootlin.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: phylink: check for SFP bus presence in phylink_expects_phy | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Maxime Chevallier April 12, 2023, 7:48 a.m. UTC
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")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
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(-)

Comments

Russell King (Oracle) April 12, 2023, 7:51 a.m. UTC | #1
On Wed, Apr 12, 2023 at 09:48:50AM +0200, Maxime Chevallier wrote:
> 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?
Maxime Chevallier April 12, 2023, 8:06 a.m. UTC | #2
Hello Russell,

On Wed, 12 Apr 2023 08:51:21 +0100
"Russell King (Oracle)" <linux@armlinux.org.uk> wrote:

> On Wed, Apr 12, 2023 at 09:48:50AM +0200, Maxime Chevallier wrote:
> > 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
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index a4111f1be375..334018f1028d 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -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;