net: thunderbolt: Various improvements
Subsystems (7)
v3 cover net: thunderbolt: Various improvements
Hi all,
This series improves the Thunderbolt networking driver so that it should work with the bonding driver.
The discussion that started this patch series can be read below:
https://lore.kernel.org/netdev/CAFJzfF9N4Hak23sc-zh0jMobbkjK7rg4odhic1DQ1cC+=MoQoA@mail.gmail.com/
The previous version of the series can be seen here:
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
Changes from v2:
- Drop the patch that allows changing MTU. It is not necessary as we fill in the min/max_mtu already.
- Updated code under drivers/net/phy/ to deal with the new SPEED_80000.
- Updated bond_3ad.c::__get_agg_bandwidth() with the new speed as well.
- Added review tags from Andrew.
Changes from v1:
- Add SPEED_80000
- Add support for SPEED_80000 for ethtool and 3ad bonding driver
- Use SPEED_80000 with the USB4 v2 symmetric link
- Fill blank for supported and advertising.
Ian MacDonald (1):
net: thunderbolt: Allow reading link settings
Mika Westerberg (3):
net: thunderbolt: Allow changing MAC address of the device
net: ethtool: Add support for 80Gbps speed
bonding: 3ad: Add support for SPEED_80000
drivers/net/bonding/bond_3ad.c | 9 ++++++ drivers/net/phy/phy-caps.h | 1 + drivers/net/phy/phy-core.c | 2 ++ drivers/net/phy/phy_caps.c | 2 ++ drivers/net/phy/phylink.c | 1 + drivers/net/thunderbolt/main.c | 53 ++++++++++++++++++++++++++++++++++ include/linux/phylink.h | 7 +++-- include/uapi/linux/ethtool.h | 1 + 8 files changed, 73 insertions(+), 3 deletions(-)
Signature · 1 line
2.50.1
PATCH v3 1/4 net: thunderbolt: Allow changing MAC address of the device
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.
--- drivers/net/thunderbolt/main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/thunderbolt/main.c +4 -0
@@ -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)
Signature · 1 line
2.50.1
PATCH v3 2/4 net: ethtool: Add support for 80Gbps speed
In reply to Mika WesterbergUSB4 v2 link used in peer-to-peer networking is symmetric 80Gbps so in order to support reading this link speed, add support for it to ethtool.
---
I had to update include/linux/phylink.h as well, I hope it's fine to just put it into middle and changing all the following bits accordingly. These does not seem to be user-facing.
drivers/net/phy/phy-caps.h | 1 + drivers/net/phy/phy-core.c | 2 ++ drivers/net/phy/phy_caps.c | 2 ++ drivers/net/phy/phylink.c | 1 + include/linux/phylink.h | 7 ++++--- include/uapi/linux/ethtool.h | 1 + 6 files changed, 11 insertions(+), 3 deletions(-)
drivers/net/phy/phy-caps.h +1 -0
@@ -25,6 +25,7 @@ enum {LINK_CAPA_40000FD ,LINK_CAPA_50000FD ,LINK_CAPA_56000FD , +LINK_CAPA_80000FD ,LINK_CAPA_100000FD ,LINK_CAPA_200000FD , LINK_CAPA_400000FD,
drivers/net/phy/phy-core.c +2 -0
@@ -47,6 +47,8 @@ const char *phy_speed_to_str(int speed)return "50Gbps" ;case SPEED_56000 :return "56Gbps" ; +case SPEED_80000 : +return "80Gbps" ;case SPEED_100000 :return "100Gbps" ;case SPEED_200000 :
drivers/net/phy/phy_caps.c +2 -0
@@ -21,6 +21,7 @@ static struct link_capabilities link_caps[__LINK_CAPA_MAX] __ro_after_init = { { SPEED_40000, DUPLEX_FULL, {0} }, /* LINK_CAPA_40000FD */ { SPEED_50000, DUPLEX_FULL, {0} }, /* LINK_CAPA_50000FD */ { SPEED_56000, DUPLEX_FULL, {0} }, /* LINK_CAPA_56000FD */ + { SPEED_80000, DUPLEX_FULL, {0} }, /* LINK_CAPA_80000FD */ { SPEED_100000, DUPLEX_FULL, {0} }, /* LINK_CAPA_100000FD */ { SPEED_200000, DUPLEX_FULL, {0} }, /* LINK_CAPA_200000FD */ { SPEED_400000, DUPLEX_FULL, {0} }, /* LINK_CAPA_400000FD */
@@ -49,6 +50,7 @@ static int speed_duplex_to_capa(int speed, unsigned int duplex)case SPEED_40000 :return LINK_CAPA_40000FD ;case SPEED_50000 :return LINK_CAPA_50000FD ;case SPEED_56000 :return LINK_CAPA_56000FD ; +case SPEED_80000 :return LINK_CAPA_80000FD ;case SPEED_100000 :return LINK_CAPA_100000FD ;case SPEED_200000 :return LINK_CAPA_200000FD ;case SPEED_400000 :return LINK_CAPA_400000FD ;
drivers/net/phy/phylink.c +1 -0
@@ -311,6 +311,7 @@ static struct { { MAC_400000FD, SPEED_400000, DUPLEX_FULL, BIT(LINK_CAPA_400000FD) }, { MAC_200000FD, SPEED_200000, DUPLEX_FULL, BIT(LINK_CAPA_200000FD) }, { MAC_100000FD, SPEED_100000, DUPLEX_FULL, BIT(LINK_CAPA_100000FD) }, + { MAC_80000FD, SPEED_80000, DUPLEX_FULL, BIT(LINK_CAPA_80000FD) }, { MAC_56000FD, SPEED_56000, DUPLEX_FULL, BIT(LINK_CAPA_56000FD) }, { MAC_50000FD, SPEED_50000, DUPLEX_FULL, BIT(LINK_CAPA_50000FD) }, { MAC_40000FD, SPEED_40000, DUPLEX_FULL, BIT(LINK_CAPA_40000FD) },
include/linux/phylink.h +4 -3
@@ -90,9 +90,10 @@ enum {MAC_40000FD =BIT (13 ),MAC_50000FD =BIT (14 ),MAC_56000FD =BIT (15 ), -MAC_100000FD =BIT (16 ), -MAC_200000FD =BIT (17 ), - MAC_400000FD = BIT(18), +MAC_80000FD =BIT (16 ), +MAC_100000FD =BIT (17 ), +MAC_200000FD =BIT (18 ), + MAC_400000FD = BIT(19), };static inline bool phylink_autoneg_inband (unsigned int mode)
include/uapi/linux/ethtool.h +1 -0
@@ -2190,6 +2190,7 @@ enum ethtool_link_mode_bit_indices {#define SPEED_40000 40000#define SPEED_50000 50000#define SPEED_56000 56000 +#define SPEED_80000 80000#define SPEED_100000 100000#define SPEED_200000 200000#define SPEED_400000 400000
Signature · 1 line
2.50.1
Re: [PATCH net-next v3 2/4] net: ethtool: Add support for 80Gbps speed
Quoted 4 lines · Mika Westerberg
USB4 v2 link used in peer-to-peer networking is symmetric 80Gbps so in order to support reading this link speed, add support for it to ethtool.
Signed-off-by Mika Westerberg <[email protected]>
Andrew
PATCH v3 3/4 bonding: 3ad: Add support for SPEED_80000
In reply to Mika WesterbergAdd support for ethtool SPEED_80000. This is needed to allow Thunderbolt/USB4 networking driver to be used with the bonding driver.
--- drivers/net/bonding/bond_3ad.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/bonding/bond_3ad.c +9 -0
@@ -72,6 +72,7 @@ enum ad_link_speed_type {AD_LINK_SPEED_40000MBPS ,AD_LINK_SPEED_50000MBPS ,AD_LINK_SPEED_56000MBPS , +AD_LINK_SPEED_80000MBPS ,AD_LINK_SPEED_100000MBPS ,AD_LINK_SPEED_200000MBPS , AD_LINK_SPEED_400000MBPS,
@@ -297,6 +298,7 @@ static inline int __check_agg_selection_timer(struct port *port)* %AD_LINK_SPEED_40000MBPS * %AD_LINK_SPEED_50000MBPS * %AD_LINK_SPEED_56000MBPS +* %AD_LINK_SPEED_80000MBPS * %AD_LINK_SPEED_100000MBPS * %AD_LINK_SPEED_200000MBPS * %AD_LINK_SPEED_400000MBPS
@@ -365,6 +367,10 @@ static u16 __get_link_speed(struct port *port) speed =AD_LINK_SPEED_56000MBPS ;break ; +case SPEED_80000 : + speed =AD_LINK_SPEED_80000MBPS ; +break ; +case SPEED_100000 : speed =AD_LINK_SPEED_100000MBPS ;break ;
@@ -816,6 +822,9 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)case AD_LINK_SPEED_56000MBPS : bandwidth = nports *56000 ;break ; +case AD_LINK_SPEED_80000MBPS : + bandwidth = nports *80000 ; +break ;case AD_LINK_SPEED_100000MBPS : bandwidth = nports *100000 ;break ;
Signature · 1 line
2.50.1
Re: [PATCH net-next v3 3/4] bonding: 3ad: Add support for SPEED_80000
Quoted 8 lines · Mika Westerberg
Add support for ethtool
SPEED_80000. This is needed to allow Thunderbolt/USB4 networking driver to be used with the bonding driver.Signed-off-by Mika Westerberg <[email protected]>--- drivers/net/bonding/bond_3ad.c | 9 +++++++++ 1 file changed, 9 insertions(+)
PATCH v3 4/4 net: thunderbolt: Allow reading link settings
In reply to Mika WesterbergFrom: Ian MacDonald <[email protected]>
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.
--- drivers/net/thunderbolt/main.c | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/net/thunderbolt/main.c +49 -0
@@ -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
Signature · 1 line
2.50.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 15 Jan 2026 12:56:42 +0100 you wrote:
Hi all,
This series improves the Thunderbolt networking driver so that it should work with the bonding driver.
The discussion that started this patch series can be read below:
[...]
Here is the summary with links:
- [net-next,v3,1/4] net: thunderbolt: Allow changing MAC address of the device
https://git.kernel.org/netdev/net-next/c/8411d7286bcb - [net-next,v3,2/4] net: ethtool: Add support for 80Gbps speed https://git.kernel.org/netdev/net-next/c/a9927022c449 - [net-next,v3,3/4] bonding: 3ad: Add support for SPEED_80000 https://git.kernel.org/netdev/net-next/c/2e62e5565bd2 - [net-next,v3,4/4] net: thunderbolt: Allow reading link settings https://git.kernel.org/netdev/net-next/c/7a3d3279a566
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html