summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2021-11-21 12:52:30 +0000
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2022-01-18 10:17:25 +0000
commit6602ca96d3a615bb7ee31d14f8d12c723e26f2b1 (patch)
treea20b5c7bb99d2722962ecc497bf7213f7a5d2080
parent471fbe635ee0c3fd7034c17ed1e10f8699f5b6b9 (diff)
net: phylink: pass mode into phylink_validate()
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/phy/phylink.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 0dbe437d2872..6349f6558828 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -414,7 +414,7 @@ void phylink_generic_validate(struct phylink_config *config,
}
EXPORT_SYMBOL_GPL(phylink_generic_validate);
-static int phylink_validate_mac_and_pcs(struct phylink *pl,
+static int phylink_validate_mac_and_pcs(struct phylink *pl, unsigned int mode,
unsigned long *supported,
struct phylink_link_state *state)
{
@@ -465,7 +465,8 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
}
-static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
+static int phylink_validate_mask(struct phylink *pl, unsigned int mode,
+ unsigned long *supported,
struct phylink_link_state *state,
const unsigned long *interfaces)
{
@@ -481,7 +482,7 @@ static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
t = *state;
t.interface = intf;
- if (!phylink_validate_mac_and_pcs(pl, s, &t)) {
+ if (!phylink_validate_mac_and_pcs(pl, mode, s, &t)) {
linkmode_or(all_s, all_s, s);
linkmode_or(all_adv, all_adv, t.advertising);
}
@@ -494,21 +495,22 @@ static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
}
-static int phylink_validate(struct phylink *pl, unsigned long *supported,
+static int phylink_validate(struct phylink *pl, unsigned int mode,
+ unsigned long *supported,
struct phylink_link_state *state)
{
const unsigned long *interfaces = pl->config->supported_interfaces;
if (!phy_interface_empty(interfaces)) {
if (state->interface == PHY_INTERFACE_MODE_NA)
- return phylink_validate_mask(pl, supported, state,
+ return phylink_validate_mask(pl, mode, supported, state,
interfaces);
if (!test_bit(state->interface, interfaces))
return -EINVAL;
}
- return phylink_validate_mac_and_pcs(pl, supported, state);
+ return phylink_validate_mac_and_pcs(pl, mode, supported, state);
}
static int phylink_parse_fixedlink(struct phylink *pl,
@@ -585,7 +587,7 @@ static int phylink_parse_fixedlink(struct phylink *pl,
bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
linkmode_copy(pl->link_config.advertising, pl->supported);
- phylink_validate(pl, pl->supported, &pl->link_config);
+ phylink_validate(pl, MLO_AN_FIXED, pl->supported, &pl->link_config);
s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex,
pl->supported, true);
@@ -727,7 +729,8 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
linkmode_copy(pl->link_config.advertising, pl->supported);
- if (phylink_validate(pl, pl->supported, &pl->link_config)) {
+ if (phylink_validate(pl, pl->cfg_link_an_mode, pl->supported,
+ &pl->link_config)) {
phylink_err(pl,
"failed to validate link configuration for in-band status\n");
return -EINVAL;
@@ -1304,7 +1307,7 @@ struct phylink *phylink_create(struct phylink_config *config,
bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
linkmode_copy(pl->link_config.advertising, pl->supported);
- phylink_validate(pl, pl->supported, &pl->link_config);
+ phylink_validate(pl, MLO_AN_FIXED, pl->supported, &pl->link_config);
ret = phylink_parse_mode(pl, fwnode);
if (ret < 0) {
@@ -1427,10 +1430,13 @@ static int phylink_validate_phy(struct phylink *pl, struct phy_device *phy,
struct phylink_link_state *state)
{
DECLARE_PHY_INTERFACE_MASK(interfaces);
+ unsigned int mode;
+
+ mode = pl->cfg_link_an_mode;
/* If this is a clause 22 PHY, it only operates in a single mode. */
if (!phy->is_c45)
- return phylink_validate(pl, supported, state);
+ return phylink_validate(pl, mode, supported, state);
/* Clause 45 PHYs switch their Serdes lane between several different
* modes according to the negotiated media speed. For example, the
@@ -1448,7 +1454,7 @@ static int phylink_validate_phy(struct phylink *pl, struct phy_device *phy,
state->interface != PHY_INTERFACE_MODE_XAUI &&
state->interface != PHY_INTERFACE_MODE_USXGMII) {
state->interface = PHY_INTERFACE_MODE_NA;
- return phylink_validate(pl, supported, state);
+ return phylink_validate(pl, mode, supported, state);
}
/* Calculate the union of the interfaces the PHY supports in
@@ -1458,7 +1464,7 @@ static int phylink_validate_phy(struct phylink *pl, struct phy_device *phy,
phy_interface_and(interfaces, phy->possible_interfaces,
pl->config->supported_interfaces);
- return phylink_validate_mask(pl, supported, state, interfaces);
+ return phylink_validate_mask(pl, mode, supported, state, interfaces);
}
static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
@@ -2124,7 +2130,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
/* Revalidate with the selected interface */
linkmode_copy(support, pl->supported);
- if (phylink_validate(pl, support, &config)) {
+ if (phylink_validate(pl, pl->cur_link_an_mode, support,
+ &config)) {
phylink_err(pl, "validation of %s/%s with support %*pb failed\n",
phylink_an_mode_str(pl->cur_link_an_mode),
phy_modes(config.interface),
@@ -2134,7 +2141,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
} else {
/* Validate without changing the current supported mask. */
linkmode_copy(support, pl->supported);
- if (phylink_validate(pl, support, &config))
+ if (phylink_validate(pl, pl->cur_link_an_mode, support,
+ &config))
return -EINVAL;
}
@@ -2723,7 +2731,7 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode,
config.an_enabled = pl->link_config.an_enabled;
/* Ignore errors if we're expecting a PHY to attach later */
- ret = phylink_validate(pl, support, &config);
+ ret = phylink_validate(pl, mode, support, &config);
if (ret) {
phylink_err(pl, "validation with support %*pb failed: %d\n",
__ETHTOOL_LINK_MODE_MASK_NBITS, support, ret);
@@ -2740,7 +2748,7 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode,
config.interface = iface;
linkmode_copy(support1, support);
- ret = phylink_validate(pl, support1, &config);
+ ret = phylink_validate(pl, mode, support1, &config);
if (ret) {
phylink_err(pl, "validation of %s/%s with support %*pb failed: %d\n",
phylink_an_mode_str(mode),
@@ -2806,7 +2814,7 @@ static int phylink_sfp_config_nophy(struct phylink *pl)
config.an_enabled = true;
/* Get the full range of supported link modes */
- ret = phylink_validate(pl, pl->sfp_support, &config);
+ ret = phylink_validate(pl, MLO_AN_INBAND, pl->sfp_support, &config);
if (ret) {
phylink_err(pl,
"initial validation with support %*pb failed: %d\n",
@@ -2822,7 +2830,7 @@ static int phylink_sfp_config_nophy(struct phylink *pl)
config.interface = interface;
/* Ignore errors if we're expecting a PHY to attach later */
- ret = phylink_validate(pl, support, &config);
+ ret = phylink_validate(pl, MLO_AN_INBAND, support, &config);
if (ret) {
phylink_err(pl, "validation with support %*pb failed: %d\n",
__ETHTOOL_LINK_MODE_MASK_NBITS, support, ret);