Skip to content

Commit e847c76

Browse files
aroulinkuba-moo
authored andcommitted
ethtool: reset #lanes when lanes is omitted
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. The consequence is that the same ethtool operation will produce different results based on the initial state. If the initial state is: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: on then executing 'ethtool -s swp1 speed 50000 autoneg off' will yield: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: off While if the initial state is: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 1 Duplex: Full Auto-negotiation: off executing the same 'ethtool -s swp1 speed 50000 autoneg off' results in: $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 1 Duplex: Full Auto-negotiation: off This patch fixes this behavior. Omitting lanes will always results in the driver choosing the default lane width for the chosen speed. In this scenario, regardless of the initial state, the end state will be, e.g., $ ethtool swp1 | grep -A 3 'Speed: ' Speed: 500000Mb/s Lanes: 2 Duplex: Full Auto-negotiation: off Fixes: 012ce4d ("ethtool: Extend link modes settings uAPI with lanes") Signed-off-by: Andy Roulin <[email protected]> Reviewed-by: Danielle Ratson <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 95fac54 commit e847c76

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ethtool/linkmodes.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,12 @@ static int ethnl_update_linkmodes(struct genl_info *info, struct nlattr **tb,
270270
"lanes configuration not supported by device");
271271
return -EOPNOTSUPP;
272272
}
273-
} else if (!lsettings->autoneg) {
274-
/* If autoneg is off and lanes parameter is not passed from user,
275-
* set the lanes parameter to 0.
273+
} else if (!lsettings->autoneg && ksettings->lanes) {
274+
/* If autoneg is off and lanes parameter is not passed from user but
275+
* it was defined previously then set the lanes parameter to 0.
276276
*/
277277
ksettings->lanes = 0;
278+
*mod = true;
278279
}
279280

280281
ret = ethnl_update_bitset(ksettings->link_modes.advertising,

0 commit comments

Comments
 (0)