Message ID | 659c7c1d-6aa9-0d90-00e4-7a6025ae40b5@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] ethtool: reset #lanes when lanes is omitted | expand |
On Thu, Mar 30, 2023 at 11:38:26AM -0700, Andy Roulin wrote: > If the number of lanes was forced and then subsequently the user > omits this parameter, the ksettings->lanes is reset. The driver > should then reset the number of lanes to the device's default > for the specified speed. > > However, although the ksettings->lanes is set to 0, the mod variable > is not set to true to indicate the driver and userspace should be > notified of the changes. Code looks fine, but I suggest including before and after examples in the commit message. Currently, the same operation produces different results based on the state of the system. For example, if the starting state is: # ethtool swp1 | grep -A 3 'Speed: ' Speed: 400000Mb/s Lanes: 8 Duplex: Full Auto-negotiation: on And I do: # ethtool -s swp1 speed 100000 autoneg off I get: # ethtool swp1 | grep -A 3 'Speed: ' Speed: 100000Mb/s Lanes: 4 Duplex: Full Auto-negotiation: off But if the current state is: # ethtool swp1 | grep -A 3 'Speed: ' Speed: 100000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: off And I do: # ethtool -s swp1 speed 100000 autoneg off Nothing changes: # ethtool swp1 | grep -A 3 'Speed: ' Speed: 100000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: off I expect that after this patch I will get the same result regardless of the current state.
diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c index fab66c169b9f..20165e07ef90 100644 --- a/net/ethtool/linkmodes.c +++ b/net/ethtool/linkmodes.c @@ -270,11 +270,12 @@ static int ethnl_update_linkmodes(struct genl_info *info, struct nlattr **tb, "lanes configuration not supported by device"); return -EOPNOTSUPP; } - } else if (!lsettings->autoneg) { - /* If autoneg is off and lanes parameter is not passed from user, - * set the lanes parameter to 0. + } else if (!lsettings->autoneg && ksettings->lanes) { + /* If autoneg is off and lanes parameter is not passed from user but + * it was defined previously then set the lanes parameter to 0. */ ksettings->lanes = 0; + *mod = true; } ret = ethnl_update_bitset(ksettings->link_modes.advertising,