summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2020-03-03 12:12:43 +0000
committerRussell King <rmk+kernel@armlinux.org.uk>2021-02-15 13:22:23 +0000
commit22773927d721efab159f7d4cb9177d7996f456c6 (patch)
tree16eb931231291c3f02efd17c864f50e82654ef32
parent01a3e44cc105ca606d7e1cc70bab52479c317da1 (diff)
net: phylink: use phy interface mode bitmaps
Use the phy interface mode bitmaps for SFP modules and PHYs to select the operating interface for SFPs and PHYs with SFPs. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/phy/phylink.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index b0316bfaec24..bd6833148499 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2247,19 +2247,54 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces,
pl->config->supported_interfaces);
- /* Do the initial configuration */
- ret = phylink_sfp_config(pl, mode, phy->supported, phy->advertising);
- if (ret < 0)
- return ret;
+ if (!phy_interface_empty(phy->supported_interfaces) &&
+ !phy_interface_empty(pl->config->supported_interfaces)) {
+ interface = phylink_select_interface(pl,
+ phy->supported_interfaces,
+ "phy");
+ if (interface == PHY_INTERFACE_MODE_NA) {
+ phylink_err(pl,
+ "selection of interface for PHY failed\n");
+ return -EINVAL;
+ }
- interface = pl->link_config.interface;
- ret = phylink_attach_phy(pl, phy, interface);
- if (ret < 0)
- return ret;
+ if (pl->cur_link_an_mode != mode ||
+ pl->link_config.interface != interface) {
+ pl->link_config.interface = interface;
+ pl->cur_link_an_mode = mode;
- ret = phylink_bringup_phy(pl, phy, interface);
- if (ret)
- phy_detach(phy);
+ phylink_info(pl, "switched to %s/%s link mode\n",
+ phylink_an_mode_str(mode),
+ phy_modes(interface));
+ }
+
+ ret = phylink_attach_phy(pl, phy, interface);
+ if (ret < 0)
+ return ret;
+
+ ret = phylink_bringup_phy(pl, phy, interface);
+ if (ret)
+ phy_detach(phy);
+
+ if (!test_bit(PHYLINK_DISABLE_STOPPED,
+ &pl->phylink_disable_state))
+ phylink_mac_initial_config(pl, false);
+ } else {
+ /* Do the initial configuration */
+ ret = phylink_sfp_config(pl, mode, phy->supported,
+ phy->advertising);
+ if (ret < 0)
+ return ret;
+
+ interface = pl->link_config.interface;
+ ret = phylink_attach_phy(pl, phy, interface);
+ if (ret < 0)
+ return ret;
+
+ ret = phylink_bringup_phy(pl, phy, interface);
+ if (ret)
+ phy_detach(phy);
+ }
return ret;
}