summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2020-06-27 10:32:01 +0100
committerRussell King <rmk+kernel@armlinux.org.uk>2020-06-28 13:52:13 +0100
commit776b70d2b1e941b766bede3a0647941b3d520930 (patch)
tree34fb23ac13377e42bada9f609efd3e79175d105b
parentc7fcd190859030512a3e3eb448a9c673ae848ff2 (diff)
net: phylink: simplify fixed-link case for ksettings_set method
For fixed links, we only allow the current settings, so this should be a matter of merely rejecting an attempt to change the settings. If the settings agree, then there is nothing more we need to do. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--drivers/net/phy/phylink.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 46372854f88b..dae2307ddb08 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1361,22 +1361,31 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
if (!s)
return -EINVAL;
- /* If we have a fixed link (as specified by firmware), refuse
- * to change link parameters.
+ /* If we have a fixed link, refuse to change link parameters.
+ * If the link parameters match, accept them but do nothing.
*/
- if (pl->cur_link_an_mode == MLO_AN_FIXED &&
- (s->speed != pl->link_config.speed ||
- s->duplex != pl->link_config.duplex))
- return -EINVAL;
+ if (pl->cur_link_an_mode == MLO_AN_FIXED) {
+ if (s->speed != pl->link_config.speed ||
+ s->duplex != pl->link_config.duplex)
+ return -EINVAL;
+ return 0;
+ }
config.speed = s->speed;
config.duplex = s->duplex;
break;
case AUTONEG_ENABLE:
- /* If we have a fixed link, refuse to enable autonegotiation */
- if (pl->cur_link_an_mode == MLO_AN_FIXED)
- return -EINVAL;
+ /* If we have a fixed link, allow autonegotiation (since that
+ * is our default case) but do not allow the advertisement to
+ * be changed. If the advertisement matches, simply return.
+ */
+ if (pl->cur_link_an_mode == MLO_AN_FIXED) {
+ if (!linkmode_equal(config.advertising,
+ pl->link_config.advertising))
+ return -EINVAL;
+ return 0;
+ }
config.speed = SPEED_UNKNOWN;
config.duplex = DUPLEX_UNKNOWN;
@@ -1386,8 +1395,8 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
return -EINVAL;
}
- /* For a fixed link, this isn't able to change any parameters,
- * which just leaves inband mode.
+ /* We have ruled out the case with a PHY attached, and the
+ * fixed-link cases. All that is left are in-band links.
*/
if (phylink_validate(pl, support, &config))
return -EINVAL;