From cb1c10f82bdcd5b54b9c9937530b282d3aecf848 Mon Sep 17 00:00:00 2001 From: "Russell King (Oracle)" Date: Thu, 8 Feb 2024 12:53:59 +0000 Subject: net: phylink: switch to use phy_query_inband() for copper SFP modules Use phy_query_inband() with the initial mode when configuring copper SFP modules to determine whether we should use inband or PHY mode. This allows us to remove the BCM84881 specific detection from phylink, and instead rely on the PHY driver giving us this detail. We can use a simple check here - if the PHY reports that the inband information is valid, but sets no other bits, then inband is definitely not supported. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index c1a31f0cea61..066d60f185d5 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3555,21 +3555,12 @@ static void phylink_sfp_link_up(void *upstream) phylink_enable_and_run_resolve(pl, PHYLINK_DISABLE_LINK); } -/* The Broadcom BCM84881 in the Methode DM7052 is unable to provide a SGMII - * or 802.3z control word, so inband will not work. - */ -static bool phylink_phy_no_inband(struct phy_device *phy) -{ - return phy->is_c45 && phy_id_compare(phy->c45_ids.device_ids[1], - 0xae025150, 0xfffffff0); -} - static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) { DECLARE_PHY_INTERFACE_MASK(interfaces); struct phylink *pl = upstream; phy_interface_t interface; - int ret; + int link_inband, ret; /* * This is the new way of dealing with flow control for PHYs, @@ -3610,7 +3601,14 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) phylink_dbg(pl, "copper SFP: chosen %s interface\n", phy_modes(interface)); - if (phylink_phy_no_inband(phy)) + link_inband = phy_query_inband(phy, interface); + phylink_dbg(pl, "copper SFP: PHY link in-band modes 0x%x\n", + link_inband); + + /* If the link inband is valid but the PHY doesn't support + * inband, then we have to use PHY mode. E.g. BCM84881. + */ + if (link_inband == LINK_INBAND_VALID) pl->sfp_link_an_mode = MLO_AN_PHY; if (pl->cur_link_an_mode != pl->sfp_link_an_mode || -- cgit