Skip to contentSkip to conversation

netlink: settings: Enable link modes advertisement according to lanes

PATCH Applied Ido Schimmel 2 participants 2 messages Sep 14, 2022 – Oct 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netlink: settings: Enable link modes advertisement according to lanes

When user space does not pass link modes to advertise (via 'ETHTOOL_A_LINKMODES_OURS'), but enables auto-negotiation (via 'ETHTOOL_A_LINKMODES_AUTONEG'), the kernel will instruct the underlying device driver to advertise link modes according to passed speed (via 'ETHTOOL_A_LINKMODES_SPEED'), duplex (via 'ETHTOOL_A_LINKMODES_DUPLEX') or lanes (via 'ETHTOOL_A_LINKMODES_LANES').

It is not currently possible to have ethtool instruct the kernel to perform advertisement solely based on lanes, as ethtool incorrectly instructs the kernel to simply advertise all the "real" link modes [1]. This is caused by ethtool treating both of these commands as equivalent:

 # ethtool -s swp1 autoneg on
 # ethtool -s swp1 autoneg on lanes 1

Address this by having ethtool recognize that it should not advertise all the "real" link modes when only "lanes" parameter is specified.

Before:

 # ethtool -s swp1 autoneg on lanes 1
 # ethtool swp1
 [...]
        Advertised link modes:  1000baseT/Full
                                10000baseT/Full
                                1000baseKX/Full
                                10000baseKR/Full
                                10000baseR_FEC
                                40000baseKR4/Full
                                40000baseCR4/Full
                                40000baseSR4/Full
                                40000baseLR4/Full
                                25000baseCR/Full
                                25000baseKR/Full
                                25000baseSR/Full
                                50000baseCR2/Full
                                50000baseKR2/Full
                                100000baseKR4/Full
                                100000baseSR4/Full
                                100000baseCR4/Full
                                100000baseLR4_ER4/Full
 [...]

After:

 # ethtool -s swp1 autoneg on lanes 1
 # ethtool swp1
 [...]
        Advertised link modes:  1000baseT/Full
                                10000baseT/Full
                                1000baseKX/Full
                                10000baseKR/Full
                                10000baseR_FEC
                                25000baseCR/Full
                                25000baseKR/Full
                                25000baseSR/Full
                                10000baseCR/Full
                                10000baseSR/Full
                                10000baseLR/Full
                                10000baseER/Full
                                50000baseKR/Full
                                50000baseSR/Full
                                50000baseCR/Full
                                50000baseLR_ER_FR/Full
                                50000baseDR/Full

[1]

 # ethtool --debug 0xff -s swp1 autoneg on lanes 1
 [...]
 sending genetlink packet (96 bytes):
     msg length 96 ethool ETHTOOL_MSG_LINKMODES_SET
     ETHTOOL_MSG_LINKMODES_SET
         ETHTOOL_A_LINKMODES_HEADER
             ETHTOOL_A_HEADER_DEV_NAME = "swp1"
         ETHTOOL_A_LINKMODES_AUTONEG = on
         ETHTOOL_A_LINKMODES_LANES = 1
         ETHTOOL_A_LINKMODES_OURS
             ETHTOOL_A_BITSET_SIZE = 93
             ETHTOOL_A_BITSET_VALUE = 20:10:9a:87 ff:5d:f0:ff e7:03:00:00
             ETHTOOL_A_BITSET_MASK = 20:10:9a:87 ff:5d:f0:ff e7:03:00:00
 [...]

---
Targeting at "ethtool-next" because this is not a regression (never worked), but rather the result of an incomplete implementation in commit 107ee330ec7b ("netlink: settings: Add netlink support for lanes parameter").

---
 netlink/settings.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
netlink/settings.c +5 -3
index 3cf816f06299..dda4ac9bcf35 100644
@@ -1193,8 +1193,9 @@ static int linkmodes_reply_advert_all_cb(const struct nlmsghdr *nlhdr,
 }
 
 /* For compatibility reasons with ioctl-based ethtool, when "autoneg on" is
- * specified without "advertise", "speed" and "duplex", we need to query the
- * supported link modes from the kernel and advertise all the "real" ones.
+ * specified without "advertise", "speed", "duplex" and "lanes", we need to
+ * query the supported link modes from the kernel and advertise all the "real"
+ * ones.
  */
 static int nl_sset_compat_linkmodes(struct nl_context *nlctx,
 				    struct nl_msg_buff *msgbuff)
@@ -1208,7 +1209,8 @@ static int nl_sset_compat_linkmodes(struct nl_context *nlctx,
 	if (ret < 0)
 		return ret;
 	if (!tb[ETHTOOL_A_LINKMODES_AUTONEG] || tb[ETHTOOL_A_LINKMODES_OURS] ||
-	    tb[ETHTOOL_A_LINKMODES_SPEED] || tb[ETHTOOL_A_LINKMODES_DUPLEX])
+	    tb[ETHTOOL_A_LINKMODES_SPEED] || tb[ETHTOOL_A_LINKMODES_DUPLEX] ||
+	    tb[ETHTOOL_A_LINKMODES_LANES])
 		return 0;
 	if (!mnl_attr_get_u8(tb[ETHTOOL_A_LINKMODES_AUTONEG]))
 		return 0;
Signature · 1 line
2.37.1
#1 lore raw
This patch was applied to ethtool/ethtool.git (master) by Michal Kubecek <[email protected]>:

Hello:

This patch was applied to ethtool/ethtool.git (master) by Michal Kubecek <[email protected]>:

Quoted 8 lines · On Wed, 14 Sep 2022 10:25:47 +0300 you wrote:

When user space does not pass link modes to advertise (via 'ETHTOOL_A_LINKMODES_OURS'), but enables auto-negotiation (via 'ETHTOOL_A_LINKMODES_AUTONEG'), the kernel will instruct the underlying device driver to advertise link modes according to passed speed (via 'ETHTOOL_A_LINKMODES_SPEED'), duplex (via 'ETHTOOL_A_LINKMODES_DUPLEX') or lanes (via 'ETHTOOL_A_LINKMODES_LANES').

[...]

Here is the summary with links:
- [ethtool-next] netlink: settings: Enable link modes advertisement according to lanes

    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=174e2b8fc95f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html