net/mlx5e: misc changes 2025-07-22
Subsystems (5)
Tariq Toukan
maintainerv2 cover net/mlx5e: misc changes 2025-07-22
Hi,
This series contains misc enhancements to the mlx5e driver. This is V2. Previous one was deferred, find it here:
https://lore.kernel.org/all/[email protected]/
Regards,
Tariq
V2:
- Fixed RCT issue in patch #1.
- Dropped patch #2, the same as
https://patchwork.kernel.org/project/linux-rdma/patch/[email protected]/
Alexandre Cassen (1):
net/mlx5e: Support routed networks during IPsec MACs initialization
Feng Liu (1):
net/mlx5e: Expose TIS via devlink tx reporter diagnose
.../mellanox/mlx5/core/en/reporter_tx.c | 25 ++++++ .../mellanox/mlx5/core/en_accel/ipsec.c | 82 ++++++++++++++++++- 2 files changed, 105 insertions(+), 2 deletions(-)
base-commit: 3fc894728fb3a0d9282e81247b68c07468fe2985
Signature · 1 line
2.31.1
Tariq Toukan
maintainerPATCH v2 1/2 net/mlx5e: Support routed networks during IPsec MACs initialization
From: Alexandre Cassen <[email protected]>
Remote IPsec tunnel endpoint may refer to a network segment that is not directly connected to the host. In such a case, IPsec tunnel endpoints are connected to a router and reachable via a routing path. In IPsec packet offload mode, HW is initialized with the MAC address of both IPsec tunnel endpoints.
Extend the current IPsec init MACs procedure to resolve nexthop for routed networks. Direct neighbour lookup and probe is still used for directly connected networks and as a fallback mechanism if fib lookup fails.
--- .../mellanox/mlx5/core/en_accel/ipsec.c | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +80 -2
@@ -36,6 +36,7 @@#include <linux/inetdevice.h> #include <linux/netdevice.h> #include <net/netevent.h> +#include <net/ipv6_stubs.h> #include "en.h" #include "eswitch.h"
@@ -259,9 +260,15 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, struct mlx5_accel_esp_xfrm_attrs *attrs) {struct mlx5_core_dev *mdev =mlx5e_ipsec_sa2dev (sa_entry); +struct mlx5e_ipsec_addr *addrs = &attrs->addrs;struct net_device *netdev = sa_entry->dev; +struct xfrm_state *x = sa_entry->x; +struct dst_entry *rt_dst_entry; +struct flowi4 fl4 = {}; +struct flowi6 fl6 = {};struct neighbour *n;u8 addr[ETH_ALEN ]; +struct rtable *rt;const void *pkey;u8 *dst, *src;
@@ -274,18 +281,89 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry,case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac; dst = attrs->smac; - pkey = &attrs->addrs.saddr.a4; + +switch (addrs->family) { +case AF_INET : + fl4.flowi4_proto = x->sel.proto; + fl4.daddr = addrs->saddr.a4; + fl4.saddr = addrs->daddr.a4; + pkey = &addrs->saddr.a4; +break ; +case AF_INET6 : + fl6.flowi6_proto = x->sel.proto; +memcpy (fl6.daddr.s6_addr32, addrs->saddr.a6,16 ); +memcpy (fl6.saddr.s6_addr32, addrs->daddr.a6,16 ); + pkey = &addrs->saddr.a6; +break ; +default : +return ; + }break ;case XFRM_DEV_OFFLOAD_OUT : src = attrs->smac; dst = attrs->dmac; - pkey = &attrs->addrs.daddr.a4; +switch (addrs->family) { +case AF_INET : + fl4.flowi4_proto = x->sel.proto; + fl4.daddr = addrs->daddr.a4; + fl4.saddr = addrs->saddr.a4; + pkey = &addrs->daddr.a4; +break ; +case AF_INET6 : + fl6.flowi6_proto = x->sel.proto; +memcpy (fl6.daddr.s6_addr32, addrs->daddr.a6,16 ); +memcpy (fl6.saddr.s6_addr32, addrs->saddr.a6,16 ); + pkey = &addrs->daddr.a6; +break ; +default : +return ; + }break ;default :return ; }ether_addr_copy (src, addr); + +/* Destination can refer to a routed network, so perform FIB lookup +* to resolve nexthop and get its MAC. Neighbour resolution is used as +* fallback. +*/ +switch (addrs->family) { +case AF_INET : + rt =ip_route_output_key (dev_net (netdev), &fl4); +if (IS_ERR (rt)) + goto neigh; + +if (rt->rt_type !=RTN_UNICAST ) { +ip_rt_put (rt); + goto neigh; + } + rt_dst_entry = &rt->dst; +break ; +case AF_INET6 : + rt_dst_entry = ipv6_stub->ipv6_dst_lookup_flow ( +dev_net (netdev),NULL , &fl6,NULL ); +if (IS_ERR (rt_dst_entry)) + goto neigh; +break ; +default : +return ; + } + + n =dst_neigh_lookup (rt_dst_entry, pkey); +if (!n) { +dst_release (rt_dst_entry); + goto neigh; + } + +neigh_ha_snapshot (addr, n, netdev); +ether_addr_copy (dst, addr); +dst_release (rt_dst_entry); +neigh_release (n); +return ; + +neigh: n =neigh_lookup (&arp_tbl, pkey, netdev);if (!n) { n =neigh_create (&arp_tbl, pkey, netdev);
Signature · 1 line
2.31.1
Re: [PATCH net-next V2 1/2] net/mlx5e: Support routed networks during IPsec MACs initialization
Quoted 66 lines · Tariq Toukan
From: Alexandre Cassen <[email protected]>
Remote IPsec tunnel endpoint may refer to a network segment that is not directly connected to the host. In such a case, IPsec tunnel endpoints are connected to a router and reachable via a routing path. In IPsec packet offload mode, HW is initialized with the MAC address of both IPsec tunnel endpoints.
Extend the current IPsec init MACs procedure to resolve nexthop for routed networks. Direct neighbour lookup and probe is still used for directly connected networks and as a fallback mechanism if fib lookup fails.
Signed-off-by Alexandre Cassen <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Cosmin Ratiu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- .../mellanox/mlx5/core/en_accel/ipsec.c | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +19
-1@@ -36,6 +36,7 @@#include <linux/inetdevice.h> #include <linux/netdevice.h> #include <net/netevent.h> +#include <net/ipv6_stubs.h> #include "en.h" #include "eswitch.h" @@ -259,9 +260,15 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, struct mlx5_accel_esp_xfrm_attrs *attrs) {struct mlx5_core_dev *mdev =mlx5e_ipsec_sa2dev (sa_entry); +struct mlx5e_ipsec_addr *addrs = &attrs->addrs;struct net_device *netdev = sa_entry->dev; +struct xfrm_state *x = sa_entry->x; +struct dst_entry *rt_dst_entry; +struct flowi4 fl4 = {}; +struct flowi6 fl6 = {};struct neighbour *n;u8 addr[ETH_ALEN ]; +struct rtable *rt;const void *pkey;u8 *dst, *src;@@ -274,18 +281,89 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry,case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac; dst = attrs->smac; - pkey = &attrs->addrs.saddr.a4; + +switch (addrs->family) { +case AF_INET : + fl4.flowi4_proto = x->sel.proto; + fl4.daddr = addrs->saddr.a4; + fl4.saddr = addrs->daddr.a4; + pkey = &addrs->saddr.a4; +break ; +case AF_INET6 : + fl6.flowi6_proto = x->sel.proto; +memcpy (fl6.daddr.s6_addr32, addrs->saddr.a6,16 ); +memcpy (fl6.saddr.s6_addr32, addrs->daddr.a6,16 );
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, · line 282
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +5
-1+ pkey = &addrs->saddr.a6; +break ; +default : +return ; + }break ;case XFRM_DEV_OFFLOAD_OUT : src = attrs->smac; dst = attrs->dmac; - pkey = &attrs->addrs.daddr.a4;
Isn't it worth to move getting pkey to separate function? The switch is the same with OFFLOAD_IN and OFFLOAD_OUT.
Quoted 55 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +49
-0+switch (addrs->family) { +case AF_INET : + fl4.flowi4_proto = x->sel.proto; + fl4.daddr = addrs->daddr.a4; + fl4.saddr = addrs->saddr.a4; + pkey = &addrs->daddr.a4; +break ; +case AF_INET6 : + fl6.flowi6_proto = x->sel.proto; +memcpy (fl6.daddr.s6_addr32, addrs->daddr.a6,16 ); +memcpy (fl6.saddr.s6_addr32, addrs->saddr.a6,16 ); + pkey = &addrs->daddr.a6; +break ; +default : +return ; + }break ;default :return ; }ether_addr_copy (src, addr); + +/* Destination can refer to a routed network, so perform FIB lookup +* to resolve nexthop and get its MAC. Neighbour resolution is used as +* fallback. +*/ +switch (addrs->family) { +case AF_INET : + rt =ip_route_output_key (dev_net (netdev), &fl4); +if (IS_ERR (rt)) + goto neigh; + +if (rt->rt_type !=RTN_UNICAST ) { +ip_rt_put (rt); + goto neigh; + } + rt_dst_entry = &rt->dst; +break ; +case AF_INET6 : + rt_dst_entry = ipv6_stub->ipv6_dst_lookup_flow ( +dev_net (netdev),NULL , &fl6,NULL ); +if (IS_ERR (rt_dst_entry)) + goto neigh; +break ; +default : +return ; + } + + n =dst_neigh_lookup (rt_dst_entry, pkey); +if (!n) { +dst_release (rt_dst_entry); + goto neigh; + } +
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, · line 369
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +7
-0+neigh_ha_snapshot (addr, n, netdev); +ether_addr_copy (dst, addr); +dst_release (rt_dst_entry); +neigh_release (n); +return ; + +neigh: n =neigh_lookup (&arp_tbl, pkey, netdev);if (!n) { n =neigh_create (&arp_tbl, pkey, netdev);
Code looks fine,
Quoted 2 lines
Signature · 1 line
2.31.1
Re: [PATCH net-next V2 1/2] net/mlx5e: Support routed networks during IPsec MACs initialization
Quoted 21 lines · Michal Swiatkowski
Quoted 20 lines · Tariq Toukan
From: Alexandre Cassen <[email protected]>
Remote IPsec tunnel endpoint may refer to a network segment that is not directly connected to the host. In such a case, IPsec tunnel endpoints are connected to a router and reachable via a routing path. In IPsec packet offload mode, HW is initialized with the MAC address of both IPsec tunnel endpoints.
Extend the current IPsec init MACs procedure to resolve nexthop for routed networks. Direct neighbour lookup and probe is still used for directly connected networks and as a fallback mechanism if fib lookup fails.
Signed-off-by Alexandre Cassen <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>Reviewed-by Cosmin Ratiu <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- .../mellanox/mlx5/core/en_accel/ipsec.c | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-)
<...>
Quoted 22 lines
Quoted 22 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +17
-1@@ -274,18 +281,89 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry,case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac; dst = attrs->smac; - pkey = &attrs->addrs.saddr.a4; + +switch (addrs->family) { +case AF_INET : + fl4.flowi4_proto = x->sel.proto; + fl4.daddr = addrs->saddr.a4; + fl4.saddr = addrs->daddr.a4; + pkey = &addrs->saddr.a4; +break ; +case AF_INET6 : + fl6.flowi6_proto = x->sel.proto; +memcpy (fl6.daddr.s6_addr32, addrs->saddr.a6,16 ); +memcpy (fl6.saddr.s6_addr32, addrs->daddr.a6,16 ); + pkey = &addrs->saddr.a6; +break ; +default : +return ; + }
Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, · line 282
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +0
-1break ;case XFRM_DEV_OFFLOAD_OUT : src = attrs->smac; dst = attrs->dmac; - pkey = &attrs->addrs.daddr.a4;Isn't it worth to move getting pkey to separate function? The switch is the same with
OFFLOAD_INandOFFLOAD_OUT.
The content of the switch is completely opposite, as an example for pkey:
In OFFLOAD_IN:
pkey = &addrs->...S...addr.a4;
pkey = &addrs->...S...addr.a6;
In OFFLOAD_OUT:
pkey = &addrs->...D...addr.a4;
pkey = &addrs->...D...addr.a6;
There is only one line which is common: "... = x->sel.proto;"
Quoted 16 lines
Quoted 16 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +15
-0+switch (addrs->family) { +case AF_INET : + fl4.flowi4_proto = x->sel.proto; + fl4.daddr = addrs->daddr.a4; + fl4.saddr = addrs->saddr.a4; + pkey = &addrs->daddr.a4; +break ; +case AF_INET6 : + fl6.flowi6_proto = x->sel.proto; +memcpy (fl6.daddr.s6_addr32, addrs->daddr.a6,16 ); +memcpy (fl6.saddr.s6_addr32, addrs->saddr.a6,16 ); + pkey = &addrs->daddr.a6; +break ; +default : +return ;
<...>
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, · line 369
Quoted 3 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +0
-0n =neigh_lookup (&arp_tbl, pkey, netdev);if (!n) { n =neigh_create (&arp_tbl, pkey, netdev);Code looks fine,
Reviewed-by Michal Swiatkowski <[email protected]>
Thanks
Quoted 4 lines
Quoted 3 lines
Signature · 2 lines
-- 2.31.1
Tariq Toukan
maintainerPATCH v2 2/2 net/mlx5e: Expose TIS via devlink tx reporter diagnose
In reply to Tariq ToukanFrom: Feng Liu <[email protected]>
Underneath "TIS Config" tag expose TIS diagnostic information. Expose the tisn of each TC under each lag port.
$ sudo devlink health diagnose auxiliary/mlx5_core.eth.2/131072 reporter tx
......
TIS Config:
lag port: 0 tc: 0 tisn: 0
lag port: 1 tc: 0 tisn: 8
......--- .../mellanox/mlx5/core/en/reporter_tx.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +25 -0
@@ -311,6 +311,30 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reportemlx5e_health_fmsg_named_obj_nest_end (fmsg); } +static void +mlx5e_tx_reporter_diagnose_tis_config (struct devlink_health_reporter *reporter, +struct devlink_fmsg *fmsg) +{ +struct mlx5e_priv *priv =devlink_health_reporter_priv (reporter); +u8 num_tc =mlx5e_get_dcb_num_tc (&priv->channels.params); +u32 tc, i, tisn; + +devlink_fmsg_arr_pair_nest_start (fmsg,"TIS Config" ); +for (i =0 ; i <mlx5e_get_num_lag_ports (priv->mdev); i++) { +for (tc =0 ; tc < num_tc; tc++) { + tisn =mlx5e_profile_get_tisn (priv->mdev, priv, + priv->profile, i, tc); + +devlink_fmsg_obj_nest_start (fmsg); +devlink_fmsg_u32_pair_put (fmsg,"lag port" , i); +devlink_fmsg_u32_pair_put (fmsg,"tc" , tc); +devlink_fmsg_u32_pair_put (fmsg,"tisn" , tisn); +devlink_fmsg_obj_nest_end (fmsg); + } + } +devlink_fmsg_arr_pair_nest_end (fmsg); +} +static int mlx5e_tx_reporter_diagnose (struct devlink_health_reporter *reporter,struct devlink_fmsg *fmsg,struct netlink_ext_ack *extack)
@@ -326,6 +350,7 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, goto unlock;mlx5e_tx_reporter_diagnose_common_config (reporter, fmsg); +mlx5e_tx_reporter_diagnose_tis_config (reporter, fmsg);devlink_fmsg_arr_pair_nest_start (fmsg,"SQs" );for (i =0 ; i < priv->channels.num; i++) {
Signature · 1 line
2.31.1
Re: [PATCH net-next V2 2/2] net/mlx5e: Expose TIS via devlink tx reporter diagnose
Quoted 28 lines · Tariq Toukan
From: Feng Liu <[email protected]>
Underneath "TIS Config" tag expose TIS diagnostic information. Expose the tisn of each TC under each lag port.
$ sudo devlink health diagnose auxiliary/mlx5_core.eth.2/131072 reporter tx ...... TIS Config: lag port: 0 tc: 0 tisn: 0 lag port: 1 tc: 0 tisn: 8 ......Signed-off-by Feng Liu <[email protected]>Reviewed-by Aya Levin <[email protected]>Signed-off-by Tariq Toukan <[email protected]>--- .../mellanox/mlx5/core/en/reporter_tx.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +1
-0@@ -311,6 +311,30 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reportemlx5e_health_fmsg_named_obj_nest_end (fmsg); } +static void
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte · line 324
Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +10
-0+mlx5e_tx_reporter_diagnose_tis_config(struct devlink_health_reporter *reporter, + struct devlink_fmsg *fmsg) +{ + struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter); +u8 num_tc =mlx5e_get_dcb_num_tc (&priv->channels.params); +u32 tc, i, tisn; + +devlink_fmsg_arr_pair_nest_start (fmsg,"TIS Config" ); +for (i =0 ; i <mlx5e_get_num_lag_ports (priv->mdev); i++) { +for (tc =0 ; tc < num_tc; tc++) {
nit: tisn can be defined in this for, not outside.
Quoted 17 lines
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +13
-0+ tisn =mlx5e_profile_get_tisn (priv->mdev, priv, + priv->profile, i, tc); + +devlink_fmsg_obj_nest_start (fmsg); +devlink_fmsg_u32_pair_put (fmsg,"lag port" , i); +devlink_fmsg_u32_pair_put (fmsg,"tc" , tc); +devlink_fmsg_u32_pair_put (fmsg,"tisn" , tisn); +devlink_fmsg_obj_nest_end (fmsg); + } + } +devlink_fmsg_arr_pair_nest_end (fmsg); +} +static int mlx5e_tx_reporter_diagnose (struct devlink_health_reporter *reporter,struct devlink_fmsg *fmsg,struct netlink_ext_ack *extack)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, · line 355
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +1
-0@@ -326,6 +350,7 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, goto unlock;mlx5e_tx_reporter_diagnose_common_config (reporter, fmsg); +mlx5e_tx_reporter_diagnose_tis_config (reporter, fmsg);devlink_fmsg_arr_pair_nest_start (fmsg,"SQs" );for (i =0 ; i < priv->channels.num; i++) {
Quoted 2 lines
Signature · 1 line
2.31.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 10 lines · On Tue, 22 Jul 2025 17:23:46 +0300 you wrote:
Hi,
This series contains misc enhancements to the mlx5e driver. This is V2. Previous one was deferred, find it here:
https://lore.kernel.org/all/[email protected]/Regards,
Tariq[...]
Here is the summary with links:
- [net-next,V2,1/2] net/mlx5e: Support routed networks during IPsec MACs initialization
https://git.kernel.org/netdev/net-next/c/71670f766b8f - [net-next,V2,2/2] net/mlx5e: Expose TIS via devlink tx reporter diagnose https://git.kernel.org/netdev/net-next/c/5474ca211819
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html