Skip to contentSkip to conversation

mlx5 fixes 24-05-22

PATCH Applied Tariq Toukan 3 participants 18 messages May 22, 2024 – May 24, 2024

Subsystems (6)
lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

cover mlx5 fixes 24-05-22

Hi,

This patchset provides bug fixes to mlx5 core and Eth drivers.

Series generated against:
commit 9c91c7fadb17 ("net: mana: Fix the extra HZ in mana_hwc_send_request")

Thanks,
Tariq.

Carolina Jubran (1):
net/mlx5e: Use rx_missed_errors instead of rx_dropped for reporting
buffer exhaustion

Gal Pressman (2):
net/mlx5: Fix MTMP register capability offset in MCAM register net/mlx5e: Fix UDP GSO for encapsulated packets

Maher Sanalla (1):
net/mlx5: Lag, do bond only if slaves agree on roce state

Rahul Rameshbabu (3):
net/mlx5: Use mlx5_ipsec_rx_status_destroy to correctly delete status
rules
net/mlx5e: Fix IPsec tunnel mode offload feature check net/mlx5e: Do not use ptp structure for tx ts stats when not
initialized

Tariq Toukan (1):
net/mlx5: Do not query MPIR on embedded CPU function

 .../mellanox/mlx5/core/en_accel/en_accel.h      |  8 +++++++-
 .../mellanox/mlx5/core/en_accel/ipsec_fs.c      |  3 +--
 .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h    | 17 +++++------------
 .../net/ethernet/mellanox/mlx5/core/en_main.c   |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_stats.c  |  4 ++++
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c |  6 +++++-
 .../net/ethernet/mellanox/mlx5/core/lag/lag.c   | 12 ++++++++++--
 .../net/ethernet/mellanox/mlx5/core/lib/sd.c    | 12 ++++++++----
 include/linux/mlx5/mlx5_ifc.h                   |  4 ++--
 9 files changed, 43 insertions(+), 25 deletions(-)
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 1/8 net/mlx5: Lag, do bond only if slaves agree on roce state

From: Maher Sanalla <[email protected]>

Currently, the driver does not enforce that lag bond slaves must have matching roce capabilities. Yet, in mlx5_do_bond(), the driver attempts to enable roce on all vports of the bond slaves, causing the following syndrome when one slave has no roce fw support:

mlx5_cmd_out_err:809:(pid 25427): MODIFY_NIC_VPORT_CONTEXT(0×755) op_mod(0×0) failed, status bad parameter(0×3), syndrome (0xc1f678), err(-22)

Thus, create HW lag only if bond's slaves agree on roce state, either all slaves have roce support resulting in a roce lag bond, or none do, resulting in a raw eth bond.

Fixes 7907f23adc18 ("net/mlx5: Implement RoCE LAG feature")
---
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +10 -2
index f7f0476a4a58..d0871c46b8c5 100644
@@ -719,6 +719,7 @@ bool mlx5_lag_check_prereq(struct mlx5_lag *ldev)
 	struct mlx5_core_dev *dev;
 	u8 mode;
 #endif
+	bool roce_support;
 	int i;
 
 	for (i = 0; i < ldev->ports; i++)
@@ -743,6 +744,11 @@ bool mlx5_lag_check_prereq(struct mlx5_lag *ldev)
 		if (mlx5_sriov_is_enabled(ldev->pf[i].dev))
 			return false;
 #endif
+	roce_support = mlx5_get_roce_state(ldev->pf[MLX5_LAG_P1].dev);
+	for (i = 1; i < ldev->ports; i++)
+		if (mlx5_get_roce_state(ldev->pf[i].dev) != roce_support)
+			return false;
+
 	return true;
 }
 
@@ -910,8 +916,10 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)
 		} else if (roce_lag) {
 			dev0->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
 			mlx5_rescan_drivers_locked(dev0);
-			for (i = 1; i < ldev->ports; i++)
-				mlx5_nic_vport_enable_roce(ldev->pf[i].dev);
+			for (i = 1; i < ldev->ports; i++) {
+				if (mlx5_get_roce_state(ldev->pf[i].dev))
+					mlx5_nic_vport_enable_roce(ldev->pf[i].dev);
+			}
 		} else if (shared_fdb) {
 			int i;
 
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH net 1/8] net/mlx5: Lag, do bond only if slaves agree on roce state

Quoted 10 lines · Tariq Toukan

From: Maher Sanalla <[email protected]>

Currently, the driver does not enforce that lag bond slaves must have matching roce capabilities. Yet, in mlx5_do_bond(), the driver attempts to enable roce on all vports of the bond slaves, causing the following syndrome when one slave has no roce fw support:

mlx5_cmd_out_err:809:(pid 25427): MODIFY_NIC_VPORT_CONTEXT(0×755) op_mod(0×0) failed, status bad parameter(0×3), syndrome (0xc1f678), err(-22)

Quoted 7 lines

Thus, create HW lag only if bond's slaves agree on roce state, either all slaves have roce support resulting in a roce lag bond, or none do, resulting in a raw eth bond.

Fixes 7907f23adc18 ("net/mlx5: Implement RoCE LAG feature")
author maintainer
#3 lore raw

PATCH 2/8 net/mlx5: Do not query MPIR on embedded CPU function

In reply to Tariq Toukan

A proper query to MPIR needs to set the correct value in the depth field. On embedded CPU this value is not necessarily zero. As there is no real use case for multi-PF netdev on the embedded CPU of the smart NIC, block this option.

This fixes the following failure:
ACCESS_REG(0x805) op_mod(0x1) failed, status bad system state(0x4), syndrome (0x685f19), err(-5)

Fixes 678eb448055a ("net/mlx5: SD, Implement basic query and instantiation")
---
 drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c +8 -4
index dd5d186dc614..f6deb5a3f820 100644
@@ -100,10 +100,6 @@ static bool ft_create_alias_supported(struct mlx5_core_dev *dev)
 
 static bool mlx5_sd_is_supported(struct mlx5_core_dev *dev, u8 host_buses)
 {
-	/* Feature is currently implemented for PFs only */
-	if (!mlx5_core_is_pf(dev))
-		return false;
-
 	/* Honor the SW implementation limit */
 	if (host_buses > MLX5_SD_MAX_GROUP_SZ)
 		return false;
@@ -162,6 +158,14 @@ static int sd_init(struct mlx5_core_dev *dev)
 	bool sdm;
 	int err;
 
+	/* Feature is currently implemented for PFs only */
+	if (!mlx5_core_is_pf(dev))
+		return 0;
+
+	/* Block on embedded CPU PFs */
+	if (mlx5_core_is_ecpf(dev))
+		return 0;
+
 	if (!MLX5_CAP_MCAM_REG(dev, mpir))
 		return 0;
 
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 2/8
#4 lore raw

Re: [PATCH net 2/8] net/mlx5: Do not query MPIR on embedded CPU function

Quoted 10 lines · Tariq Toukan

A proper query to MPIR needs to set the correct value in the depth field. On embedded CPU this value is not necessarily zero. As there is no real use case for multi-PF netdev on the embedded CPU of the smart NIC, block this option.

This fixes the following failure:
ACCESS_REG(0x805) op_mod(0x1) failed, status bad system state(0x4), syndrome (0x685f19), err(-5)

Fixes 678eb448055a ("net/mlx5: SD, Implement basic query and instantiation")
author maintainer
#5 lore raw

PATCH 3/8 net/mlx5: Fix MTMP register capability offset in MCAM register

In reply to Tariq Toukan

From: Gal Pressman <[email protected]>

The MTMP register (0x900a) capability offset is off-by-one, move it to the right place.

Fixes 1f507e80c700 ("net/mlx5: Expose NIC temperature via hardware monitoring kernel API")
---
 include/linux/mlx5/mlx5_ifc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mlx5/mlx5_ifc.h +2 -2
index f468763478ae..5df52e15f7d6 100644
@@ -10308,9 +10308,9 @@ struct mlx5_ifc_mcam_access_reg_bits {
 	u8         mfrl[0x1];
 	u8         regs_39_to_32[0x8];
 
-	u8         regs_31_to_10[0x16];
+	u8         regs_31_to_11[0x15];
 	u8         mtmp[0x1];
-	u8         regs_8_to_0[0x9];
+	u8         regs_9_to_0[0xa];
 };
 
 struct mlx5_ifc_mcam_access_reg_bits1 {
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 3/8
#6 lore raw

Re: [PATCH net 3/8] net/mlx5: Fix MTMP register capability offset in MCAM register

Quoted 9 lines · Tariq Toukan

From: Gal Pressman <[email protected]>

The MTMP register (0x900a) capability offset is off-by-one, move it to the right place.

Fixes 1f507e80c700 ("net/mlx5: Expose NIC temperature via hardware monitoring kernel API")
author maintainer
#7 lore raw

PATCH 4/8 net/mlx5: Use mlx5_ipsec_rx_status_destroy to correctly delete status rules

In reply to Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

rx_create no longer allocates a modify_hdr instance that needs to be cleaned up. The mlx5_modify_header_dealloc call will lead to a NULL pointer dereference. A leak in the rules also previously occurred since there are now two rules populated related to status.

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not-present page
  PGD 109907067 P4D 109907067 PUD 116890067 PMD 0
  Oops: 0000 [#1] SMP
  CPU: 1 PID: 484 Comm: ip Not tainted 6.9.0-rc2-rrameshbabu+ #254
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Arch Linux 1.16.3-1-1 04/01/2014
  RIP: 0010:mlx5_modify_header_dealloc+0xd/0x70
  <snip>
  Call Trace:
   <TASK>
   ? show_regs+0x60/0x70
   ? __die+0x24/0x70
   ? page_fault_oops+0x15f/0x430
   ? free_to_partial_list.constprop.0+0x79/0x150
   ? do_user_addr_fault+0x2c9/0x5c0
   ? exc_page_fault+0x63/0x110
   ? asm_exc_page_fault+0x27/0x30
   ? mlx5_modify_header_dealloc+0xd/0x70
   rx_create+0x374/0x590
   rx_add_rule+0x3ad/0x500
   ? rx_add_rule+0x3ad/0x500
   ? mlx5_cmd_exec+0x2c/0x40
   ? mlx5_create_ipsec_obj+0xd6/0x200
   mlx5e_accel_ipsec_fs_add_rule+0x31/0xf0
   mlx5e_xfrm_add_state+0x426/0xc00
  <snip>
Fixes 94af50c0a9bb ("net/mlx5e: Unify esw and normal IPsec status table creation/destruction")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +1 -2
index 41a2543a52cd..e51b03d4c717 100644
@@ -750,8 +750,7 @@ static int rx_create(struct mlx5_core_dev *mdev, struct mlx5e_ipsec *ipsec,
 err_fs_ft:
 	if (rx->allow_tunnel_mode)
 		mlx5_eswitch_unblock_encap(mdev);
-	mlx5_del_flow_rules(rx->status.rule);
-	mlx5_modify_header_dealloc(mdev, rx->status.modify_hdr);
+	mlx5_ipsec_rx_status_destroy(ipsec, rx);
 err_add:
 	mlx5_destroy_flow_table(rx->ft.status);
 err_fs_ft_status:
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 4/8
#8 lore raw

Re: [PATCH net 4/8] net/mlx5: Use mlx5_ipsec_rx_status_destroy to correctly delete status rules

Quoted 35 lines · Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

rx_create no longer allocates a modify_hdr instance that needs to be cleaned up. The mlx5_modify_header_dealloc call will lead to a NULL pointer dereference. A leak in the rules also previously occurred since there are now two rules populated related to status.

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not-present page
  PGD 109907067 P4D 109907067 PUD 116890067 PMD 0
  Oops: 0000 [#1] SMP
  CPU: 1 PID: 484 Comm: ip Not tainted 6.9.0-rc2-rrameshbabu+ #254
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Arch Linux 1.16.3-1-1 04/01/2014
  RIP: 0010:mlx5_modify_header_dealloc+0xd/0x70
  <snip>
  Call Trace:
   <TASK>
   ? show_regs+0x60/0x70
   ? __die+0x24/0x70
   ? page_fault_oops+0x15f/0x430
   ? free_to_partial_list.constprop.0+0x79/0x150
   ? do_user_addr_fault+0x2c9/0x5c0
   ? exc_page_fault+0x63/0x110
   ? asm_exc_page_fault+0x27/0x30
   ? mlx5_modify_header_dealloc+0xd/0x70
   rx_create+0x374/0x590
   rx_add_rule+0x3ad/0x500
   ? rx_add_rule+0x3ad/0x500
   ? mlx5_cmd_exec+0x2c/0x40
   ? mlx5_create_ipsec_obj+0xd6/0x200
   mlx5e_accel_ipsec_fs_add_rule+0x31/0xf0
   mlx5e_xfrm_add_state+0x426/0xc00
  <snip>
Quoted 3 lines
Fixes 94af50c0a9bb ("net/mlx5e: Unify esw and normal IPsec status table creation/destruction")
author maintainer
#9 lore raw

PATCH 5/8 net/mlx5e: Fix IPsec tunnel mode offload feature check

In reply to Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

Remove faulty check disabling checksum offload and GSO for offload of simple IPsec tunnel L4 traffic. Comment previously describing the deleted code incorrectly claimed the check prevented double tunnel (or three layers of ip headers).

Fixes f1267798c980 ("net/mlx5: Fix checksum issue of VXLAN and IPsec crypto offload")
---
 .../mellanox/mlx5/core/en_accel/ipsec_rxtx.h    | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.h +5 -12
index 82064614846f..359050f0b54d 100644
@@ -97,18 +97,11 @@ mlx5e_ipsec_feature_check(struct sk_buff *skb, netdev_features_t features)
 		if (!x || !x->xso.offload_handle)
 			goto out_disable;
 
-		if (xo->inner_ipproto) {
-			/* Cannot support tunnel packet over IPsec tunnel mode
-			 * because we cannot offload three IP header csum
-			 */
-			if (x->props.mode == XFRM_MODE_TUNNEL)
-				goto out_disable;
-
-			/* Only support UDP or TCP L4 checksum */
-			if (xo->inner_ipproto != IPPROTO_UDP &&
-			    xo->inner_ipproto != IPPROTO_TCP)
-				goto out_disable;
-		}
+		/* Only support UDP or TCP L4 checksum */
+		if (xo->inner_ipproto &&
+		    xo->inner_ipproto != IPPROTO_UDP &&
+		    xo->inner_ipproto != IPPROTO_TCP)
+			goto out_disable;
 
 		return features;
 
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 5/8
#10 lore raw

Re: [PATCH net 5/8] net/mlx5e: Fix IPsec tunnel mode offload feature check

Quoted 10 lines · Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

Remove faulty check disabling checksum offload and GSO for offload of simple IPsec tunnel L4 traffic. Comment previously describing the deleted code incorrectly claimed the check prevented double tunnel (or three layers of ip headers).

Fixes f1267798c980 ("net/mlx5: Fix checksum issue of VXLAN and IPsec crypto offload")
author maintainer
#11 lore raw

PATCH 6/8 net/mlx5e: Do not use ptp structure for tx ts stats when not initialized

In reply to Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

The ptp channel instance is only initialized when ptp traffic is first processed by the driver. This means that there is a window in between when port timestamping is enabled and ptp traffic is sent where the ptp channel instance is not initialized. Accessing statistics during this window will lead to an access violation (NULL + member offset). Check the validity of the instance before attempting to query statistics.

  BUG: unable to handle page fault for address: 0000000000003524
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not-present page
  PGD 109dfc067 P4D 109dfc067 PUD 1064ef067 PMD 0
  Oops: 0000 [#1] SMP
  CPU: 0 PID: 420 Comm: ethtool Not tainted 6.9.0-rc2-rrameshbabu+ #245
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Arch Linux 1.16.3-1-1 04/01/204
  RIP: 0010:mlx5e_stats_ts_get+0x4c/0x130
  <snip>
  Call Trace:
   <TASK>
   ? show_regs+0x60/0x70
   ? __die+0x24/0x70
   ? page_fault_oops+0x15f/0x430
   ? do_user_addr_fault+0x2c9/0x5c0
   ? exc_page_fault+0x63/0x110
   ? asm_exc_page_fault+0x27/0x30
   ? mlx5e_stats_ts_get+0x4c/0x130
   ? mlx5e_stats_ts_get+0x20/0x130
   mlx5e_get_ts_stats+0x15/0x20
  <snip>
Fixes 3579032c08c1 ("net/mlx5e: Implement ethtool hardware timestamping statistics")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +4 -0
index e211c41cec06..e1ed214e8651 100644
@@ -1186,6 +1186,9 @@ void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
 		ts_stats->err = 0;
 		ts_stats->lost = 0;
 
+		if (!ptp)
+			goto out;
+
 		/* Aggregate stats across all TCs */
 		for (i = 0; i < ptp->num_tc; i++) {
 			struct mlx5e_ptp_cq_stats *stats =
@@ -1214,6 +1217,7 @@ void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
 		}
 	}
 
+out:
 	mutex_unlock(&priv->state_lock);
 }
 
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 6/8
#12 lore raw

Re: [PATCH net 6/8] net/mlx5e: Do not use ptp structure for tx ts stats when not initialized

Quoted 31 lines · Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

The ptp channel instance is only initialized when ptp traffic is first processed by the driver. This means that there is a window in between when port timestamping is enabled and ptp traffic is sent where the ptp channel instance is not initialized. Accessing statistics during this window will lead to an access violation (NULL + member offset). Check the validity of the instance before attempting to query statistics.

  BUG: unable to handle page fault for address: 0000000000003524
  #PF: supervisor read access in kernel mode
  #PF: error_code(0x0000) - not-present page
  PGD 109dfc067 P4D 109dfc067 PUD 1064ef067 PMD 0
  Oops: 0000 [#1] SMP
  CPU: 0 PID: 420 Comm: ethtool Not tainted 6.9.0-rc2-rrameshbabu+ #245
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Arch Linux 1.16.3-1-1 04/01/204
  RIP: 0010:mlx5e_stats_ts_get+0x4c/0x130
  <snip>
  Call Trace:
   <TASK>
   ? show_regs+0x60/0x70
   ? __die+0x24/0x70
   ? page_fault_oops+0x15f/0x430
   ? do_user_addr_fault+0x2c9/0x5c0
   ? exc_page_fault+0x63/0x110
   ? asm_exc_page_fault+0x27/0x30
   ? mlx5e_stats_ts_get+0x4c/0x130
   ? mlx5e_stats_ts_get+0x20/0x130
   mlx5e_get_ts_stats+0x15/0x20
  <snip>
Quoted 3 lines
Fixes 3579032c08c1 ("net/mlx5e: Implement ethtool hardware timestamping statistics")
author maintainer
#13 lore raw

PATCH 7/8 net/mlx5e: Use rx_missed_errors instead of rx_dropped for reporting buffer exhaustion

In reply to Tariq Toukan

From: Carolina Jubran <[email protected]>

Previously, the driver incorrectly used rx_dropped to report device buffer exhaustion.

According to the documentation, rx_dropped should not be used to count packets dropped due to buffer exhaustion, which is the purpose of rx_missed_errors.

Use rx_missed_errors as intended for counting packets dropped due to buffer exhaustion.

Fixes 269e6b3af3bf ("net/mlx5e: Report additional error statistics in get stats ndo")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +1 -1
index b758bc72ac36..c53c99dde558 100644
@@ -3886,7 +3886,7 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
 		mlx5e_fold_sw_stats64(priv, stats);
 	}
 
-	stats->rx_dropped = priv->stats.qcnt.rx_out_of_buffer;
+	stats->rx_missed_errors = priv->stats.qcnt.rx_out_of_buffer;
 
 	stats->rx_length_errors =
 		PPORT_802_3_GET(pstats, a_in_range_length_errors) +
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 7/8
#14 lore raw

Re: [PATCH net 7/8] net/mlx5e: Use rx_missed_errors instead of rx_dropped for reporting buffer exhaustion

Quoted 9 lines · Tariq Toukan

From: Carolina Jubran <[email protected]>

Previously, the driver incorrectly used rx_dropped to report device buffer exhaustion.

According to the documentation, rx_dropped should not be used to count packets dropped due to buffer exhaustion, which is the purpose of rx_missed_errors.

Quoted 6 lines

Use rx_missed_errors as intended for counting packets dropped due to buffer exhaustion.

Fixes 269e6b3af3bf ("net/mlx5e: Report additional error statistics in get stats ndo")
author maintainer
#15 lore raw

PATCH 8/8 net/mlx5e: Fix UDP GSO for encapsulated packets

In reply to Tariq Toukan

From: Gal Pressman <[email protected]>

When the skb is encapsulated, adjust the inner UDP header instead of the outer one, and account for UDP header (instead of TCP) in the inline header size calculation.

---
 .../net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h   | 8 +++++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c           | 6 +++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +7 -1
index caa34b9c161e..33e32584b07f 100644
@@ -102,8 +102,14 @@ static inline void
 mlx5e_udp_gso_handle_tx_skb(struct sk_buff *skb)
 {
 	int payload_len = skb_shinfo(skb)->gso_size + sizeof(struct udphdr);
+	struct udphdr *udphdr;
 
-	udp_hdr(skb)->len = htons(payload_len);
+	if (skb->encapsulation)
+		udphdr = (struct udphdr *)skb_inner_transport_header(skb);
+	else
+		udphdr = udp_hdr(skb);
+
+	udphdr->len = htons(payload_len);
 }
 
 struct mlx5e_accel_tx_state {
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +5 -1
index 099bf1078889..b09e9abd39f3 100644
@@ -153,7 +153,11 @@ mlx5e_tx_get_gso_ihs(struct mlx5e_txqsq *sq, struct sk_buff *skb, int *hopbyhop)
 
 	*hopbyhop = 0;
 	if (skb->encapsulation) {
-		ihs = skb_inner_tcp_all_headers(skb);
+		if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
+			ihs = skb_inner_transport_offset(skb) +
+			      sizeof(struct udphdr);
+		else
+			ihs = skb_inner_tcp_all_headers(skb);
 		stats->tso_inner_packets++;
 		stats->tso_inner_bytes += skb->len - ihs;
 	} else {
Signature · 1 line
2.44.0
reviewer Reviewed-by on v1 8/8
#16 lore raw

Re: [PATCH net 8/8] net/mlx5e: Fix UDP GSO for encapsulated packets

Quoted 6 lines · Tariq Toukan

From: Gal Pressman <[email protected]>

When the skb is encapsulated, adjust the inner UDP header instead of the outer one, and account for UDP header (instead of TCP) in the inline header size calculation.

Quoted 7 lines

Thanks,

This patch looks good to me.

While looking over this patch, I noticed that it seems that a similar pattern to the mlx5e_tx_get_gso_ihs() code modified here appears in at least the MANA and NFP drivers. So perhaps we could consider a helper in future.

#17 lore raw
In reply to Tariq Toukan
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Wed, 22 May 2024 22:26:51 +0300 you wrote:

Hi,

This patchset provides bug fixes to mlx5 core and Eth drivers.

Series generated against:
commit 9c91c7fadb17 ("net: mana: Fix the extra HZ in mana_hwc_send_request")

[...]

Here is the summary with links:
- [net,1/8] net/mlx5: Lag, do bond only if slaves agree on roce state

    https://git.kernel.org/netdev/net/c/51ef9305b8f4
  - [net,2/8] net/mlx5: Do not query MPIR on embedded CPU function
    https://git.kernel.org/netdev/net/c/fca3b4791850
  - [net,3/8] net/mlx5: Fix MTMP register capability offset in MCAM register
    https://git.kernel.org/netdev/net/c/1b9f86c6d532
  - [net,4/8] net/mlx5: Use mlx5_ipsec_rx_status_destroy to correctly delete status rules
    https://git.kernel.org/netdev/net/c/16d66a4fa81d
  - [net,5/8] net/mlx5e: Fix IPsec tunnel mode offload feature check
    https://git.kernel.org/netdev/net/c/9a52f6d44f45
  - [net,6/8] net/mlx5e: Do not use ptp structure for tx ts stats when not initialized
    https://git.kernel.org/netdev/net/c/f55cd31287e5
  - [net,7/8] net/mlx5e: Use rx_missed_errors instead of rx_dropped for reporting buffer exhaustion
    https://git.kernel.org/netdev/net/c/5c74195d5dd9
  - [net,8/8] net/mlx5e: Fix UDP GSO for encapsulated packets
    https://git.kernel.org/netdev/net/c/83fea49f2711

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html