* [PATCH net-next 0/3] net: thunderbolt: Various improvements
@ 2025-11-27 13:15 Mika Westerberg
2025-11-27 13:15 ` [PATCH net-next 1/3] net: thunderbolt: Allow changing MAC address of the device Mika Westerberg
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Mika Westerberg @ 2025-11-27 13:15 UTC (permalink / raw)
To: netdev
Cc: Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Mika Westerberg
Hi all,
This series improves the Thunderbolt networking driver so that it should
work with the bonding driver. I added also possibility of channing MTU
which is sometimes needed, and was part of the original driver.
The discussion that started this patch series can be read below:
https://lore.kernel.org/netdev/CAFJzfF9N4Hak23sc-zh0jMobbkjK7rg4odhic1DQ1cC+=MoQoA@mail.gmail.com/
@Ian, please check if this still works for you? I changed your patch
slightly to cope with the various speeds the USB4 link can train.
Ian MacDonald (1):
net: thunderbolt: Allow reading link settings
Mika Westerberg (2):
net: thunderbolt: Allow changing MAC address of the device
net: thunderbolt: Allow changing MTU of the device
drivers/net/thunderbolt/main.c | 88 ++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
--
2.50.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net-next 1/3] net: thunderbolt: Allow changing MAC address of the device 2025-11-27 13:15 [PATCH net-next 0/3] net: thunderbolt: Various improvements Mika Westerberg @ 2025-11-27 13:15 ` Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 2/3] net: thunderbolt: Allow changing MTU " Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings Mika Westerberg 2 siblings, 0 replies; 8+ messages in thread From: Mika Westerberg @ 2025-11-27 13:15 UTC (permalink / raw) To: netdev Cc: Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Mika Westerberg The MAC address we use is based on a suggestion in the USB4 Inter-domain spec but it is not really used in the USB4NET protocol. It is more targeted for the upper layers of the network stack. There is no reason why it should not be changed by the userspace for example if needed for bonding. Reported-by: Ian MacDonald <ian@netstatz.com> Closes: https://lore.kernel.org/netdev/CAFJzfF9N4Hak23sc-zh0jMobbkjK7rg4odhic1DQ1cC+=MoQoA@mail.gmail.com/ Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> --- drivers/net/thunderbolt/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c index dcaa62377808..57b226afeb84 100644 --- a/drivers/net/thunderbolt/main.c +++ b/drivers/net/thunderbolt/main.c @@ -1261,6 +1261,7 @@ static const struct net_device_ops tbnet_netdev_ops = { .ndo_open = tbnet_open, .ndo_stop = tbnet_stop, .ndo_start_xmit = tbnet_start_xmit, + .ndo_set_mac_address = eth_mac_addr, .ndo_get_stats64 = tbnet_get_stats64, }; @@ -1281,6 +1282,9 @@ static void tbnet_generate_mac(struct net_device *dev) hash = jhash2((u32 *)xd->local_uuid, 4, hash); addr[5] = hash & 0xff; eth_hw_addr_set(dev, addr); + + /* Allow changing it if needed */ + dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; } static int tbnet_probe(struct tb_service *svc, const struct tb_service_id *id) -- 2.50.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 2/3] net: thunderbolt: Allow changing MTU of the device 2025-11-27 13:15 [PATCH net-next 0/3] net: thunderbolt: Various improvements Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 1/3] net: thunderbolt: Allow changing MAC address of the device Mika Westerberg @ 2025-11-27 13:15 ` Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings Mika Westerberg 2 siblings, 0 replies; 8+ messages in thread From: Mika Westerberg @ 2025-11-27 13:15 UTC (permalink / raw) To: netdev Cc: Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Mika Westerberg In some cases it is useful to be able to use different MTU than the default one. Especially when dealing against non-Linux networking stack. For this reason add possibility to change the MTU of the device. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> --- drivers/net/thunderbolt/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c index 57b226afeb84..20bac55a3e20 100644 --- a/drivers/net/thunderbolt/main.c +++ b/drivers/net/thunderbolt/main.c @@ -1257,12 +1257,23 @@ static void tbnet_get_stats64(struct net_device *dev, stats->rx_missed_errors = net->stats.rx_missed_errors; } +static int tbnet_change_mtu(struct net_device *dev, int new_mtu) +{ + /* Keep the MTU within supported range */ + if (new_mtu < 68 || new_mtu > (TBNET_MAX_MTU - ETH_HLEN)) + return -EINVAL; + + dev->mtu = new_mtu; + return 0; +} + static const struct net_device_ops tbnet_netdev_ops = { .ndo_open = tbnet_open, .ndo_stop = tbnet_stop, .ndo_start_xmit = tbnet_start_xmit, .ndo_set_mac_address = eth_mac_addr, .ndo_get_stats64 = tbnet_get_stats64, + .ndo_change_mtu = tbnet_change_mtu, }; static void tbnet_generate_mac(struct net_device *dev) -- 2.50.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings 2025-11-27 13:15 [PATCH net-next 0/3] net: thunderbolt: Various improvements Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 1/3] net: thunderbolt: Allow changing MAC address of the device Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 2/3] net: thunderbolt: Allow changing MTU " Mika Westerberg @ 2025-11-27 13:15 ` Mika Westerberg 2025-11-27 19:20 ` Andrew Lunn 2 siblings, 1 reply; 8+ messages in thread From: Mika Westerberg @ 2025-11-27 13:15 UTC (permalink / raw) To: netdev Cc: Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Mika Westerberg 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> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> --- drivers/net/thunderbolt/main.c | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c index 20bac55a3e20..b056c22ad129 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> @@ -1276,6 +1277,77 @@ static const struct net_device_ops tbnet_netdev_ops = { .ndo_change_mtu = tbnet_change_mtu, }; +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: + /* For Gen 4 80G symmetric link the closest one + * available is 56G so we report that. + */ + ethtool_link_ksettings_add_link_mode(cmd, supported, + 56000baseKR4_Full); + ethtool_link_ksettings_add_link_mode(cmd, advertising, + 56000baseKR4_Full); + speed = SPEED_56000; + break; + + case 20: + if (xd->link_width == 2) { + ethtool_link_ksettings_add_link_mode(cmd, supported, + 40000baseKR4_Full); + ethtool_link_ksettings_add_link_mode(cmd, advertising, + 40000baseKR4_Full); + speed = SPEED_40000; + } else { + ethtool_link_ksettings_add_link_mode(cmd, supported, + 20000baseKR2_Full); + ethtool_link_ksettings_add_link_mode(cmd, advertising, + 20000baseKR2_Full); + speed = SPEED_20000; + } + break; + + case 10: + if (xd->link_width == 2) { + ethtool_link_ksettings_add_link_mode(cmd, supported, + 20000baseKR2_Full); + ethtool_link_ksettings_add_link_mode(cmd, advertising, + 20000baseKR2_Full); + speed = SPEED_20000; + break; + } + fallthrough; + + default: + ethtool_link_ksettings_add_link_mode(cmd, supported, + 10000baseT_Full); + ethtool_link_ksettings_add_link_mode(cmd, advertising, + 10000baseT_Full); + 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); @@ -1326,6 +1398,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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings 2025-11-27 13:15 ` [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings Mika Westerberg @ 2025-11-27 19:20 ` Andrew Lunn 2025-11-28 7:23 ` Mika Westerberg 0 siblings, 1 reply; 8+ messages in thread From: Andrew Lunn @ 2025-11-27 19:20 UTC (permalink / raw) To: Mika Westerberg Cc: netdev, Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni > +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: > + /* For Gen 4 80G symmetric link the closest one > + * available is 56G so we report that. > + */ > + ethtool_link_ksettings_add_link_mode(cmd, supported, > + 56000baseKR4_Full); > + ethtool_link_ksettings_add_link_mode(cmd, advertising, > + 56000baseKR4_Full); > + speed = SPEED_56000; Please add SPEED_80000. I commented on the previous version. Is supported and advertising actually needed? If not, please leave them blank. Andrew ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings 2025-11-27 19:20 ` Andrew Lunn @ 2025-11-28 7:23 ` Mika Westerberg 2025-11-28 14:57 ` Andrew Lunn 0 siblings, 1 reply; 8+ messages in thread From: Mika Westerberg @ 2025-11-28 7:23 UTC (permalink / raw) To: Andrew Lunn Cc: netdev, Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni On Thu, Nov 27, 2025 at 08:20:53PM +0100, Andrew Lunn wrote: > > +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: > > + /* For Gen 4 80G symmetric link the closest one > > + * available is 56G so we report that. > > + */ > > + ethtool_link_ksettings_add_link_mode(cmd, supported, > > + 56000baseKR4_Full); > > + ethtool_link_ksettings_add_link_mode(cmd, advertising, > > + 56000baseKR4_Full); > > + speed = SPEED_56000; > > Please add SPEED_80000. Sure. One additional question though. Comment on top of SPEED_ definitions suggest changing __get_link_speed() of the bonding driver accordingly but it basically converts from SPEED_ to AD_LINK_SPEED_ which I think we need to add too. However, these are user-facing values so should I add the AD_LINK_SPEED_80000 entry to the end of that enum to avoid any possible breakage? > I commented on the previous version. Is supported and advertising > actually needed? If not, please leave them blank. I don't think they are needed (but I'll double check). ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings 2025-11-28 7:23 ` Mika Westerberg @ 2025-11-28 14:57 ` Andrew Lunn 2025-12-01 6:19 ` Mika Westerberg 0 siblings, 1 reply; 8+ messages in thread From: Andrew Lunn @ 2025-11-28 14:57 UTC (permalink / raw) To: Mika Westerberg Cc: netdev, Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni On Fri, Nov 28, 2025 at 08:23:51AM +0100, Mika Westerberg wrote: > On Thu, Nov 27, 2025 at 08:20:53PM +0100, Andrew Lunn wrote: > > > +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: > > > + /* For Gen 4 80G symmetric link the closest one > > > + * available is 56G so we report that. > > > + */ > > > + ethtool_link_ksettings_add_link_mode(cmd, supported, > > > + 56000baseKR4_Full); > > > + ethtool_link_ksettings_add_link_mode(cmd, advertising, > > > + 56000baseKR4_Full); > > > + speed = SPEED_56000; > > > > Please add SPEED_80000. > > Sure. One additional question though. Comment on top of SPEED_ definitions > suggest changing __get_link_speed() of the bonding driver accordingly but > it basically converts from SPEED_ to AD_LINK_SPEED_ which I think we need > to add too. However, these are user-facing values so should I add the > AD_LINK_SPEED_80000 entry to the end of that enum to avoid any possible > breakage? Are they user facing? They should be define in include/uapi if they were. I would keep the list sorted, and Cc: the bonding driver Maintainer, Jay Vosburgh <jv@jvosburgh.net> (maintainer:BONDING DRIVER). Also: cb8dda90c28e2 (Jianhua Xie 2014-11-19 16:48:58 +0800 61) enum ad_link_speed_type { cb8dda90c28e2 (Jianhua Xie 2014-11-19 16:48:58 +0800 62) AD_LINK_SPEED_1MBPS = 1, cb8dda90c28e2 (Jianhua Xie 2014-11-19 16:48:58 +0800 63) AD_LINK_SPEED_10MBPS, cb8dda90c28e2 (Jianhua Xie 2014-11-19 16:48:58 +0800 64) AD_LINK_SPEED_100MBPS, cb8dda90c28e2 (Jianhua Xie 2014-11-19 16:48:58 +0800 65) AD_LINK_SPEED_1000MBPS, 424c3232b04ac (Jianhua Xie 2014-11-19 16:48:59 +0800 66) AD_LINK_SPEED_2500MBPS, c7c550670afda (Thibaut Collet 2017-06-08 11:18:11 +0200 67) AD_LINK_SPEED_5000MBPS, 424c3232b04ac (Jianhua Xie 2014-11-19 16:48:59 +0800 68) AD_LINK_SPEED_10000MBPS, 3fcd64cfa0e9c (Nicolas Dichtel 2017-06-08 11:18:12 +0200 69) AD_LINK_SPEED_14000MBPS, 424c3232b04ac (Jianhua Xie 2014-11-19 16:48:59 +0800 70) AD_LINK_SPEED_20000MBPS, 19ddde1eeca1e (Jarod Wilson 2017-03-14 11:48:32 -0400 71) AD_LINK_SPEED_25000MBPS, 424c3232b04ac (Jianhua Xie 2014-11-19 16:48:59 +0800 72) AD_LINK_SPEED_40000MBPS, c7c550670afda (Thibaut Collet 2017-06-08 11:18:11 +0200 73) AD_LINK_SPEED_50000MBPS, 3952af4d50343 (Jiri Pirko 2015-12-03 12:12:05 +0100 74) AD_LINK_SPEED_56000MBPS, 3952af4d50343 (Jiri Pirko 2015-12-03 12:12:05 +0100 75) AD_LINK_SPEED_100000MBPS, ab73447c38e4f (Nikolay Aleksandrov 2021-02-10 22:43:31 +0200 76) AD_LINK_SPEED_200000MBPS, 138e3b3cc0bbb (Nikolay Aleksandrov 2021-02-10 22:43:32 +0200 77) AD_LINK_SPEED_400000MBPS, 41305d3781d70 (Amit Cohen 2022-10-20 17:20:05 +0200 78) AD_LINK_SPEED_800000MBPS, cb8dda90c28e2 (Jianhua Xie 2014-11-19 16:48:58 +0800 79) }; suggests you can insert in the middle: commit c7c550670afda2e16f9e2d06a1473885312eb6b5 Author: Thibaut Collet <thibaut.collet@6wind.com> Date: Thu Jun 8 11:18:11 2017 +0200 bonding: fix 802.3ad support for 5G and 50G speeds This patch adds [5|50] Gbps enum definition, and fixes aggregated bandwidth calculation based on above slave links. Fixes: c9a70d43461d ("net-next: ethtool: Added port speed macros.") Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: David S. Miller <davem@davemloft.net> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index b44a6aeb346d..d1b09be63ba4 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -90,10 +90,12 @@ enum ad_link_speed_type { AD_LINK_SPEED_100MBPS, AD_LINK_SPEED_1000MBPS, AD_LINK_SPEED_2500MBPS, + AD_LINK_SPEED_5000MBPS, AD_LINK_SPEED_10000MBPS, AD_LINK_SPEED_20000MBPS, AD_LINK_SPEED_25000MBPS, AD_LINK_SPEED_40000MBPS, + AD_LINK_SPEED_50000MBPS, AD_LINK_SPEED_56000MBPS, AD_LINK_SPEED_100000MBPS, Andrew ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings 2025-11-28 14:57 ` Andrew Lunn @ 2025-12-01 6:19 ` Mika Westerberg 0 siblings, 0 replies; 8+ messages in thread From: Mika Westerberg @ 2025-12-01 6:19 UTC (permalink / raw) To: Andrew Lunn Cc: netdev, Yehezkel Bernat, Ian MacDonald, Salvatore Bonaccorso, Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni On Fri, Nov 28, 2025 at 03:57:07PM +0100, Andrew Lunn wrote: > > > Please add SPEED_80000. > > > > Sure. One additional question though. Comment on top of SPEED_ definitions > > suggest changing __get_link_speed() of the bonding driver accordingly but > > it basically converts from SPEED_ to AD_LINK_SPEED_ which I think we need > > to add too. However, these are user-facing values so should I add the > > AD_LINK_SPEED_80000 entry to the end of that enum to avoid any possible > > breakage? > > Are they user facing? They should be define in include/uapi if they > were. I would keep the list sorted, and Cc: the bonding driver > Maintainer, Jay Vosburgh <jv@jvosburgh.net> (maintainer:BONDING DRIVER). Indeed, they look like they are not. As you pointed out these are internals of the drivers/net/bonding/bond_3ad.c and not exposed as is to the userspace. I'll add the 80G there for both of these in v2 and Cd Jay just in case. Since merge window is open I'll send v2 after v6.19-rc1 is released. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-12-01 6:19 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-11-27 13:15 [PATCH net-next 0/3] net: thunderbolt: Various improvements Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 1/3] net: thunderbolt: Allow changing MAC address of the device Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 2/3] net: thunderbolt: Allow changing MTU " Mika Westerberg 2025-11-27 13:15 ` [PATCH net-next 3/3] net: thunderbolt: Allow reading link settings Mika Westerberg 2025-11-27 19:20 ` Andrew Lunn 2025-11-28 7:23 ` Mika Westerberg 2025-11-28 14:57 ` Andrew Lunn 2025-12-01 6:19 ` Mika Westerberg
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).