netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com,
	danieller@nvidia.com, andrew@lunn.ch, f.fainelli@gmail.com,
	mkubecek@suse.cz, mlxsw@nvidia.com,
	Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 2/6] ethtool: Expose the number of lanes in use
Date: Sat, 10 Oct 2020 18:41:15 +0300	[thread overview]
Message-ID: <20201010154119.3537085-3-idosch@idosch.org> (raw)
In-Reply-To: <20201010154119.3537085-1-idosch@idosch.org>

From: Danielle Ratson <danieller@nvidia.com>

Currently, ethtool does not expose how many lanes are used when the
link is up.

After adding a possibility to advertise or force a specific number of
lanes, the lanes in use value can be either the maximum width of the port
or below.

Extend ethtool to expose the number of lanes currently in use for
drivers that support it.

For example:

$ ethtool -s swp1 speed 100000 lanes 4
$ ethtool -s swp2 speed 100000 lanes 4
$ ip link set swp1 up
$ ip link set swp2 up
$ ethtool swp1
Settings for swp1:
        Supported ports: [ FIBRE         Backplane ]
        Supported 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
                                50000baseSR2/Full
                                10000baseCR/Full
                                10000baseSR/Full
                                10000baseLR/Full
                                10000baseER/Full
                                50000baseKR/Full
                                50000baseSR/Full
                                50000baseCR/Full
                                50000baseLR_ER_FR/Full
                                50000baseDR/Full
                                100000baseKR2/Full
                                100000baseSR2/Full
                                100000baseCR2/Full
                                100000baseLR2_ER2_FR2/Full
                                100000baseDR2/Full
                                200000baseKR4/Full
                                200000baseSR4/Full
                                200000baseLR4_ER4_FR4/Full
                                200000baseDR4/Full
				200000baseCR4/Full
	Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  1000baseT/Full
                                10000baseT/Full
                                1000baseKX/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
                                50000baseSR2/Full
                                10000baseCR/Full
                                10000baseSR/Full
                                10000baseLR/Full
                                10000baseER/Full
                                200000baseKR4/Full
                                200000baseSR4/Full
                                200000baseLR4_ER4_FR4/Full
                                200000baseDR4/Full
                                200000baseCR4/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Advertised link modes:  100000baseKR4/Full
                                100000baseSR4/Full
                                100000baseCR4/Full
                                100000baseLR4_ER4/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 100000Mb/s
        Lanes: 4
        Duplex: Full
        Auto-negotiation: on
        Port: Direct Attach Copper
        PHYAD: 0
        Transceiver: internal
        Link detected: yes

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 Documentation/networking/ethtool-netlink.rst | 5 +++--
 net/ethtool/linkmodes.c                      | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst
index 05073482db05..16638ee9d3f9 100644
--- a/Documentation/networking/ethtool-netlink.rst
+++ b/Documentation/networking/ethtool-netlink.rst
@@ -388,8 +388,8 @@ LINKMODES_GET
 =============
 
 Requests link modes (supported, advertised and peer advertised) and related
-information (autonegotiation status, link speed and duplex) as provided by
-``ETHTOOL_GLINKSETTINGS``. The request does not use any attributes.
+information (autonegotiation status, link speed, duplex and lanes) as provided
+by ``ETHTOOL_GLINKSETTINGS``. The request does not use any attributes.
 
 Request contents:
 
@@ -408,6 +408,7 @@ Kernel response contents:
   ``ETHTOOL_A_LINKMODES_DUPLEX``              u8      duplex mode
   ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG``    u8      Master/slave port mode
   ``ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE``  u8      Master/slave port state
+  ``ETHTOOL_A_LINKMODES_LANES``               u32     lanes
   ==========================================  ======  ==========================
 
 For ``ETHTOOL_A_LINKMODES_OURS``, value represents advertised modes and mask
diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c
index a1f02896ed8b..a940cfcd2122 100644
--- a/net/ethtool/linkmodes.c
+++ b/net/ethtool/linkmodes.c
@@ -43,6 +43,9 @@ static int linkmodes_prepare_data(const struct ethnl_req_info *req_base,
 		goto out;
 	}
 
+	if (!(dev->ethtool_ops->capabilities & ETHTOOL_CAP_LINK_LANES_SUPPORTED))
+		data->ksettings.lanes = ETHTOOL_LANES_UNKNOWN;
+
 	data->peer_empty =
 		bitmap_empty(data->ksettings.link_modes.lp_advertising,
 			     __ETHTOOL_LINK_MODE_MASK_NBITS);
@@ -63,6 +66,7 @@ static int linkmodes_reply_size(const struct ethnl_req_info *req_base,
 
 	len = nla_total_size(sizeof(u8)) /* LINKMODES_AUTONEG */
 		+ nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */
+		+ nla_total_size(sizeof(u32)) /* LINKMODES_LANES */
 		+ nla_total_size(sizeof(u8)) /* LINKMODES_DUPLEX */
 		+ 0;
 	ret = ethnl_bitset_size(ksettings->link_modes.advertising,
@@ -120,6 +124,7 @@ static int linkmodes_fill_reply(struct sk_buff *skb,
 	}
 
 	if (nla_put_u32(skb, ETHTOOL_A_LINKMODES_SPEED, lsettings->speed) ||
+	    nla_put_u32(skb, ETHTOOL_A_LINKMODES_LANES, ksettings->lanes) ||
 	    nla_put_u8(skb, ETHTOOL_A_LINKMODES_DUPLEX, lsettings->duplex))
 		return -EMSGSIZE;
 
-- 
2.26.2


  parent reply	other threads:[~2020-10-10 22:54 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-10 15:41 [PATCH net-next 0/6] Support setting lanes via ethtool Ido Schimmel
2020-10-10 15:41 ` [PATCH net-next 1/6] ethtool: Extend link modes settings uAPI with lanes Ido Schimmel
2020-10-11 22:37   ` Jakub Kicinski
2020-10-12 15:33     ` Danielle Ratson
2020-10-12 15:58       ` Jakub Kicinski
2020-10-13 14:29         ` Danielle Ratson
2020-10-13 15:43           ` Jakub Kicinski
2020-10-16 22:15           ` Andrew Lunn
2020-10-19  7:19             ` Danielle Ratson
2020-10-19 11:04               ` Michal Kubecek
2020-10-19 12:26                 ` Jiri Pirko
2020-10-19 13:24                   ` Michal Kubecek
2020-10-20  7:39                     ` Danielle Ratson
2020-10-21  7:08                       ` Michal Kubecek
2020-10-21  7:20                         ` Danielle Ratson
2020-10-21  8:47                           ` Michal Kubecek
2020-10-22  6:15                             ` Danielle Ratson
2020-10-22 16:27                               ` Michal Kubecek
2020-11-23  9:47                                 ` Danielle Ratson
2020-11-24 22:12                                   ` Michal Kubecek
2020-11-25 10:35                                     ` Danielle Ratson
2020-11-26 21:07                                       ` Michal Kubecek
2020-12-01 17:22                                         ` Danielle Ratson
2020-12-02  0:52                                           ` Edwin Peer
2020-12-02  1:17                                           ` Edwin Peer
2020-10-19 12:24             ` Jiri Pirko
2020-10-19 12:38               ` Andrew Lunn
2020-10-12 16:40       ` Michal Kubecek
2020-10-12 19:10     ` Johannes Berg
2020-10-12 20:08       ` Jakub Kicinski
2020-10-12 17:03   ` Michal Kubecek
2020-11-19 20:38   ` Edwin Peer
2020-11-23  9:40     ` Jiri Pirko
2020-11-30 17:01       ` Edwin Peer
2020-11-30 17:14         ` Jiri Pirko
2020-11-30 18:00           ` Edwin Peer
2020-12-01 11:22             ` Jiri Pirko
2020-12-02  0:32               ` Edwin Peer
2020-12-02 10:09                 ` Jiri Pirko
2020-12-02 17:53                   ` Edwin Peer
2020-10-10 15:41 ` Ido Schimmel [this message]
2020-10-10 15:41 ` [PATCH net-next 3/6] mlxsw: ethtool: Remove max lanes filtering Ido Schimmel
2020-10-10 15:41 ` [PATCH net-next 4/6] mlxsw: ethtool: Add support for setting lanes when autoneg is off Ido Schimmel
2020-10-10 15:41 ` [PATCH net-next 5/6] mlxsw: ethtool: Expose the number of lanes in use Ido Schimmel
2020-10-10 15:41 ` [PATCH net-next 6/6] net: selftests: Add lanes setting test Ido Schimmel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201010154119.3537085-3-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=andrew@lunn.ch \
    --cc=danieller@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).