diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2021-09-22 15:23:05 +0100 |
---|---|---|
committer | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2024-04-16 16:51:15 +0100 |
commit | 02a537c4fcc953c144ff4c9d89b1729dfb17bc28 (patch) | |
tree | c8bbd08d0bf33266e574eaebcea71cabb2418900 /drivers | |
parent | 5bb8123b0b784b1457071e10621579403c559436 (diff) |
net: phylink: move the sfp autoneg mode into struct phylink
Move the SFP autoneg mode into struct phylink rather than passing it
into phylink_sfp_config(). This is generally MLO_AN_INBAND except when
we have a copper SFP with a Broadcom 84881 PHY.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/phy/phylink.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 182f2fa95707..b10c6f6f0f88 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -85,6 +85,7 @@ struct phylink { bool sfp_may_have_phy; DECLARE_PHY_INTERFACE_MASK(sfp_interfaces); __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support); + u8 sfp_link_an_mode; u8 sfp_port; struct eee_config eee_cfg; @@ -3433,8 +3434,7 @@ static void phylink_sfp_set_config(struct phylink *pl, u8 mode, phylink_mac_initial_config(pl, false); } -static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, - struct phy_device *phy) +static int phylink_sfp_config_phy(struct phylink *pl, struct phy_device *phy) { __ETHTOOL_DECLARE_LINK_MODE_MASK(support1); __ETHTOOL_DECLARE_LINK_MODE_MASK(support); @@ -3452,7 +3452,7 @@ static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, config.pause = MLO_PAUSE_AN; /* Ignore errors if we're expecting a PHY to attach later */ - ret = phylink_validate(pl, mode, support, &config); + ret = phylink_validate(pl, pl->sfp_link_an_mode, support, &config); if (ret) { phylink_err(pl, "validation with support %*pb failed: %pe\n", __ETHTOOL_LINK_MODE_MASK_NBITS, support, @@ -3470,11 +3470,11 @@ static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, config.interface = iface; linkmode_copy(support1, support); - ret = phylink_validate(pl, mode, support1, &config); + ret = phylink_validate(pl, pl->sfp_link_an_mode, support1, &config); if (ret) { phylink_err(pl, "validation of %s/%s with support %*pb failed: %pe\n", - phylink_an_mode_str(mode), + phylink_an_mode_str(pl->sfp_link_an_mode), phy_modes(config.interface), __ETHTOOL_LINK_MODE_MASK_NBITS, support, ERR_PTR(ret)); @@ -3483,7 +3483,7 @@ static int phylink_sfp_config_phy(struct phylink *pl, u8 mode, pl->link_port = pl->sfp_port; - phylink_sfp_set_config(pl, mode, support, &config); + phylink_sfp_set_config(pl, pl->sfp_link_an_mode, support, &config); return 0; } @@ -3575,6 +3575,7 @@ static int phylink_sfp_module_insert(void *upstream, phy_interface_zero(pl->sfp_interfaces); sfp_parse_support(pl->sfp_bus, id, pl->sfp_support, pl->sfp_interfaces); pl->sfp_port = sfp_parse_port(pl->sfp_bus, id, pl->sfp_support); + pl->sfp_link_an_mode = MLO_AN_INBAND; /* If this module may have a PHY connecting later, defer until later */ pl->sfp_may_have_phy = sfp_may_have_phy(pl->sfp_bus, id); @@ -3644,7 +3645,6 @@ 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; - u8 mode; int ret; /* @@ -3657,9 +3657,7 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) phy_support_asym_pause(phy); if (phylink_phy_no_inband(phy)) - mode = MLO_AN_PHY; - else - mode = MLO_AN_INBAND; + pl->sfp_link_an_mode = MLO_AN_PHY; /* Set the PHY's host supported interfaces */ phy_interface_and(phy->host_interfaces, phylink_sfp_interfaces, @@ -3669,7 +3667,7 @@ static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy) phylink_dbg(pl, "copper SFP: PHY provides empty supported_interfaces\n"); /* Do the initial configuration */ - ret = phylink_sfp_config_phy(pl, mode, phy); + ret = phylink_sfp_config_phy(pl, phy); if (ret < 0) return ret; } else { @@ -3691,13 +3689,13 @@ 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 (pl->cur_link_an_mode != mode || + if (pl->cur_link_an_mode != pl->sfp_link_an_mode || pl->link_config.interface != interface) { pl->link_config.interface = interface; - pl->cur_link_an_mode = mode; + pl->cur_link_an_mode = pl->sfp_link_an_mode; phylink_info(pl, "switched to %s/%s link mode\n", - phylink_an_mode_str(mode), + phylink_an_mode_str(pl->sfp_link_an_mode), phy_modes(interface)); } |