From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: netdev@vger.kernel.org
Cc: Ian MacDonald <ian@netstatz.com>, Jay Vosburgh <jv@jvosburgh.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Yehezkel Bernat <YehezkelShB@gmail.com>,
Simon Horman <horms@kernel.org>,
Salvatore Bonaccorso <carnil@debian.org>,
Nikolay Aleksandrov <razor@blackwall.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH net-next v3 4/4] net: thunderbolt: Allow reading link settings
Date: Thu, 15 Jan 2026 12:56:46 +0100 [thread overview]
Message-ID: <20260115115646.328898-5-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20260115115646.328898-1-mika.westerberg@linux.intel.com>
From: Ian MacDonald <ian@netstatz.com>
In order to use Thunderbolt networking as part of bonding device it
needs to support ->get_link_ksettings() ethtool operation, so that the
bonding driver can read the link speed and the related attributes. Add
support for this to the driver.
Signed-off-by: Ian MacDonald <ian@netstatz.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/net/thunderbolt/main.c | 49 ++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c
index 57b226afeb84..7aae5d915a1e 100644
--- a/drivers/net/thunderbolt/main.c
+++ b/drivers/net/thunderbolt/main.c
@@ -10,6 +10,7 @@
*/
#include <linux/atomic.h>
+#include <linux/ethtool.h>
#include <linux/highmem.h>
#include <linux/if_vlan.h>
#include <linux/jhash.h>
@@ -1265,6 +1266,53 @@ static const struct net_device_ops tbnet_netdev_ops = {
.ndo_get_stats64 = tbnet_get_stats64,
};
+static int tbnet_get_link_ksettings(struct net_device *dev,
+ struct ethtool_link_ksettings *cmd)
+{
+ const struct tbnet *net = netdev_priv(dev);
+ const struct tb_xdomain *xd = net->xd;
+ int speed;
+
+ ethtool_link_ksettings_zero_link_mode(cmd, supported);
+ ethtool_link_ksettings_zero_link_mode(cmd, advertising);
+
+ /* Figure out the current link speed and width */
+ switch (xd->link_speed) {
+ case 40:
+ speed = SPEED_80000;
+ break;
+
+ case 20:
+ if (xd->link_width == 2)
+ speed = SPEED_40000;
+ else
+ speed = SPEED_20000;
+ break;
+
+ case 10:
+ if (xd->link_width == 2) {
+ speed = SPEED_20000;
+ break;
+ }
+ fallthrough;
+
+ default:
+ speed = SPEED_10000;
+ break;
+ }
+
+ cmd->base.speed = speed;
+ cmd->base.duplex = DUPLEX_FULL;
+ cmd->base.autoneg = AUTONEG_DISABLE;
+ cmd->base.port = PORT_OTHER;
+
+ return 0;
+}
+
+static const struct ethtool_ops tbnet_ethtool_ops = {
+ .get_link_ksettings = tbnet_get_link_ksettings,
+};
+
static void tbnet_generate_mac(struct net_device *dev)
{
const struct tbnet *net = netdev_priv(dev);
@@ -1315,6 +1363,7 @@ static int tbnet_probe(struct tb_service *svc, const struct tb_service_id *id)
strcpy(dev->name, "thunderbolt%d");
dev->netdev_ops = &tbnet_netdev_ops;
+ dev->ethtool_ops = &tbnet_ethtool_ops;
/* ThunderboltIP takes advantage of TSO packets but instead of
* segmenting them we just split the packet into Thunderbolt
--
2.50.1
next prev parent reply other threads:[~2026-01-15 11:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 11:56 [PATCH net-next v3 0/4] net: thunderbolt: Various improvements Mika Westerberg
2026-01-15 11:56 ` [PATCH net-next v3 1/4] net: thunderbolt: Allow changing MAC address of the device Mika Westerberg
2026-01-15 11:56 ` [PATCH net-next v3 2/4] net: ethtool: Add support for 80Gbps speed Mika Westerberg
2026-01-15 17:44 ` Andrew Lunn
2026-01-15 11:56 ` [PATCH net-next v3 3/4] bonding: 3ad: Add support for SPEED_80000 Mika Westerberg
2026-01-15 17:09 ` Nikolay Aleksandrov
2026-01-15 11:56 ` Mika Westerberg [this message]
2026-01-19 20:30 ` [PATCH net-next v3 0/4] net: thunderbolt: Various improvements patchwork-bot+netdevbpf
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=20260115115646.328898-5-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=carnil@debian.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=ian@netstatz.com \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.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