summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2021-09-22 15:23:05 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2024-02-27 15:38:03 +0000
commit211b76abc17e89741de9cfa679c24a93103ac52a (patch)
treeb1418de5411064e1aa17abb37ac987942a65ca5f
parent9c7155aaabd96396caf2c048b2d78752cf819ee2 (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>
-rw-r--r--drivers/net/phy/phylink.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index ed217909b1c8..b885a33c9152 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;
@@ -3364,8 +3365,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);
@@ -3383,7 +3383,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,
@@ -3401,11 +3401,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));
@@ -3414,7 +3414,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;
}
@@ -3499,6 +3499,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);
@@ -3568,7 +3569,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;
/*
@@ -3581,9 +3581,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,
@@ -3593,7 +3591,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 {
@@ -3615,13 +3613,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));
}