Skip to contentSkip to conversation

net/mlx5e: SHAMPO: Do not merge PSP packets

PATCH Applied Tariq Toukan 5 participants 6 messages Oct 21 – Oct 23

Subsystems (6)
lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

PATCH v2 1/1 net/mlx5e: SHAMPO: Do not merge PSP packets

From: Cosmin Ratiu <[email protected]>

PSP packets are UDP-encapsulated, and enabling HW GRO (SHAMPO in mlx5) makes it possible to merge those packets in a silly way:
IP|UDP|PSP1|payload1|PSP2|payload2|...

That happens because the HW GRO machinery doesn't know about PSP and considers it part of the UDP payload.

Reject merging when the incoming CQE has PSP marker or the pending skb has the PSP extension.

Fixes 29d7f433fcec ("net/mlx5e: Add Rx data path offload")
---
 .../ethernet/mellanox/mlx5/core/en_accel/en_accel.h |  6 ++++++
 .../ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.h | 13 +++++++++++++
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c     |  6 ++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

V2:
- Separated from the patchset.
- Moved the PSP merge check into a helper in psp_rxtx.h, with a stub returning true when CONFIG_MLX5_EN_PSP is off, and an en_accel.h wrapper, replacing the #ifdef in en_rx.c.
- Also reject merging when the pending skb already has the PSP extension, not only when the incoming CQE has the PSP marker.
- Fixed the commit message diagram and capitalized SHAMPO in the subject.

V1:
https://lore.kernel.org/all/[email protected]/

drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +6 -0
index 3f212e46fc2f..5a340f1435e6 100644
@@ -218,6 +218,12 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq,
 #endif
 }
 
+static inline bool
+mlx5e_accel_shampo_can_merge(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
+{
+	return mlx5e_psp_shampo_can_merge(rq->hw_gro_data->skb, cqe);
+}
+
 static inline int mlx5e_accel_init_rx(struct mlx5e_priv *priv)
 {
 	return mlx5e_ktls_init_rx(priv);
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.h +13 -0
index 2b080c39cc37..9fd1ee789de0 100644
@@ -85,6 +85,13 @@ static inline bool mlx5e_psp_is_rx_flow(struct mlx5_cqe64 *cqe)
 	return MLX5_PSP_METADATA_MARKER(be32_to_cpu(cqe->ft_metadata));
 }
 
+static inline bool
+mlx5e_psp_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+	/* PSP packets cannot be merged. */
+	return !skb_ext_exist(skb, SKB_EXT_PSP) && !mlx5e_psp_is_rx_flow(cqe);
+}
+
 bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
 				     struct mlx5_cqe64 *cqe);
 #else
@@ -110,6 +117,12 @@ static inline bool mlx5e_psp_is_rx_flow(struct mlx5_cqe64 *cqe)
 	return false;
 }
 
+static inline bool
+mlx5e_psp_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+	return true;
+}
+
 static inline bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev,
 						   struct sk_buff *skb,
 						   struct mlx5_cqe64 *cqe)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +4 -2
index 903af3b3e779..d49f26323b1e 100644
@@ -49,6 +49,7 @@
 #include "en_rep.h"
 #include "en/rep/tc.h"
 #include "ipoib/ipoib.h"
+#include "en_accel/en_accel.h"
 #include "en_accel/ipsec.h"
 #include "en_accel/macsec.h"
 #include "en_accel/psp_rxtx.h"
@@ -2268,8 +2269,9 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
 	}
 
 	if (*skb &&
-	    !(match && mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt,
-							 page_size))) {
+	    !(match &&
+	      mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, page_size) &&
+	      mlx5e_accel_shampo_can_merge(rq, cqe))) {
 		match = false;
 		mlx5e_shampo_flush_skb(rq, cqe, match);
 	}

base-commit: b6ef0d965fe8ce0ee4b4dcb58b3511f83003e42d

Signature · 1 line
2.44.0
#1 lore raw
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.

The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.

#2 lore raw
In reply to Tariq Toukan
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

From: Cosmin Ratiu <[email protected]>

PSP packets are UDP-encapsulated, and enabling HW GRO (SHAMPO in mlx5) makes it possible to merge those packets in a silly way:
IP|UDP|PSP1|payload1|PSP2|payload2|...

That happens because the HW GRO machinery doesn't know about PSP and considers it part of the UDP payload.

Quoted 7 lines

Reject merging when the incoming CQE has PSP marker or the pending skb has the PSP extension.

Fixes 29d7f433fcec ("net/mlx5e: Add Rx data path offload")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v2 1/1
#3 lore raw
In reply to Tariq Toukan
Quoted 96 lines · Tariq Toukan

From: Cosmin Ratiu <[email protected]>

PSP packets are UDP-encapsulated, and enabling HW GRO (SHAMPO in mlx5) makes it possible to merge those packets in a silly way:
IP|UDP|PSP1|payload1|PSP2|payload2|...

That happens because the HW GRO machinery doesn't know about PSP and considers it part of the UDP payload.

Reject merging when the incoming CQE has PSP marker or the pending skb has the PSP extension.

Fixes 29d7f433fcec ("net/mlx5e: Add Rx data path offload")
---
 .../ethernet/mellanox/mlx5/core/en_accel/en_accel.h |  6 ++++++
 .../ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.h | 13 +++++++++++++
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c     |  6 ++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

V2:
- Separated from the patchset.
- Moved the PSP merge check into a helper in psp_rxtx.h, with a stub returning true when CONFIG_MLX5_EN_PSP is off, and an en_accel.h wrapper, replacing the #ifdef in en_rx.c.
- Also reject merging when the pending skb already has the PSP extension, not only when the incoming CQE has the PSP marker.
- Fixed the commit message diagram and capitalized SHAMPO in the subject.

V1:
https://lore.kernel.org/all/[email protected]/

drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +6 -0
index 3f212e46fc2f..5a340f1435e6 100644
@@ -218,6 +218,12 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq,
 #endif
 }
 
+static inline bool
+mlx5e_accel_shampo_can_merge(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
+{
+	return mlx5e_psp_shampo_can_merge(rq->hw_gro_data->skb, cqe);
+}
+
 static inline int mlx5e_accel_init_rx(struct mlx5e_priv *priv)
 {
 	return mlx5e_ktls_init_rx(priv);
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.h +13 -0
index 2b080c39cc37..9fd1ee789de0 100644
@@ -85,6 +85,13 @@ static inline bool mlx5e_psp_is_rx_flow(struct mlx5_cqe64 *cqe)
 	return MLX5_PSP_METADATA_MARKER(be32_to_cpu(cqe->ft_metadata));
 }
 
+static inline bool
+mlx5e_psp_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+	/* PSP packets cannot be merged. */
+	return !skb_ext_exist(skb, SKB_EXT_PSP) && !mlx5e_psp_is_rx_flow(cqe);
+}
+
 bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
 				     struct mlx5_cqe64 *cqe);
 #else
@@ -110,6 +117,12 @@ static inline bool mlx5e_psp_is_rx_flow(struct mlx5_cqe64 *cqe)
 	return false;
 }
 
+static inline bool
+mlx5e_psp_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+	return true;
+}
+
 static inline bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev,
 						   struct sk_buff *skb,
 						   struct mlx5_cqe64 *cqe)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -0
index 903af3b3e779..d49f26323b1e 100644
@@ -49,6 +49,7 @@
 #include "en_rep.h"
 #include "en/rep/tc.h"
 #include "ipoib/ipoib.h"
+#include "en_accel/en_accel.h"
 #include "en_accel/ipsec.h"
 #include "en_accel/macsec.h"
 #include "en_accel/psp_rxtx.h"

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq · line 2274

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +3 -2
@@ -2268,8 +2269,9 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
 	}
 
 	if (*skb &&
-	    !(match && mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt,
-							 page_size))) {
+	    !(match &&
+	      mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, page_size) &&
+	      mlx5e_accel_shampo_can_merge(rq, cqe))) {

nit: we already have the skb from the line above, why go back to the rq just to find the same skb again?

Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +0 -0
 		match = false;
 		mlx5e_shampo_flush_skb(rq, cqe, match);
 	}

base-commit: b6ef0d965fe8ce0ee4b4dcb58b3511f83003e42d

Makes sense to me:

author maintainer
#4 lore raw
Quoted 99 lines · Daniel Zahka
Quoted 98 lines · Tariq Toukan

From: Cosmin Ratiu <[email protected]>

PSP packets are UDP-encapsulated, and enabling HW GRO (SHAMPO in mlx5) makes it possible to merge those packets in a silly way:
IP|UDP|PSP1|payload1|PSP2|payload2|...

That happens because the HW GRO machinery doesn't know about PSP and considers it part of the UDP payload.

Reject merging when the incoming CQE has PSP marker or the pending skb has the PSP extension.

Fixes 29d7f433fcec ("net/mlx5e: Add Rx data path offload")
---
  .../ethernet/mellanox/mlx5/core/en_accel/en_accel.h |  6 ++++++
  .../ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.h | 13 +++++++++++++
  drivers/net/ethernet/mellanox/mlx5/core/en_rx.c     |  6 ++++--
  3 files changed, 23 insertions(+), 2 deletions(-)

V2:
- Separated from the patchset.
- Moved the PSP merge check into a helper in psp_rxtx.h, with a stub returning true when CONFIG_MLX5_EN_PSP is off, and an en_accel.h wrapper, replacing the #ifdef in en_rx.c.
- Also reject merging when the pending skb already has the PSP extension, not only when the incoming CQE has the PSP marker.
- Fixed the commit message diagram and capitalized SHAMPO in the subject.

V1:
https://lore.kernel.org/all/[email protected]/

drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +6 -0
index 3f212e46fc2f..5a340f1435e6 100644
@@ -218,6 +218,12 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq,
  #endif
  }
 
+static inline bool
+mlx5e_accel_shampo_can_merge(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
+{
+	return mlx5e_psp_shampo_can_merge(rq->hw_gro_data->skb, cqe);
+}
+
  static inline int mlx5e_accel_init_rx(struct mlx5e_priv *priv)
  {
  	return mlx5e_ktls_init_rx(priv);
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.h +13 -0
index 2b080c39cc37..9fd1ee789de0 100644
@@ -85,6 +85,13 @@ static inline bool mlx5e_psp_is_rx_flow(struct mlx5_cqe64 *cqe)
  	return MLX5_PSP_METADATA_MARKER(be32_to_cpu(cqe->ft_metadata));
  }
 
+static inline bool
+mlx5e_psp_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+	/* PSP packets cannot be merged. */
+	return !skb_ext_exist(skb, SKB_EXT_PSP) && !mlx5e_psp_is_rx_flow(cqe);
+}
+
  bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
  				     struct mlx5_cqe64 *cqe);
  #else
@@ -110,6 +117,12 @@ static inline bool mlx5e_psp_is_rx_flow(struct mlx5_cqe64 *cqe)
  	return false;
  }
 
+static inline bool
+mlx5e_psp_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+	return true;
+}
+
  static inline bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev,
  						   struct sk_buff *skb,
  						   struct mlx5_cqe64 *cqe)
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -0
index 903af3b3e779..d49f26323b1e 100644
@@ -49,6 +49,7 @@
  #include "en_rep.h"
  #include "en/rep/tc.h"
  #include "ipoib/ipoib.h"
+#include "en_accel/en_accel.h"
  #include "en_accel/ipsec.h"
  #include "en_accel/macsec.h"
  #include "en_accel/psp_rxtx.h"
@@ -2268,8 +2269,9 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
  	}
 
Quoted 10 lines

drivers/net/ethernet/mellanox/mlx5/core/en_rx.c static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq · line 2274

Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +3 -2
  	if (*skb &&
-	    !(match && mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt,
-							 page_size))) {
+	    !(match &&
+	      mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, page_size) &&
+	      mlx5e_accel_shampo_can_merge(rq, cqe))) {

nit: we already have the skb from the line above, why go back to the rq just to find the same skb again?

Because we have a followup patch to be submitted soon, that adds a check for TLS. It needs the RQ, not the SKB.

Quoted 9 lines
Quoted 5 lines
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +0 -0
  		match = false;
  		mlx5e_shampo_flush_skb(rq, cqe, match);
  	}

base-commit: b6ef0d965fe8ce0ee4b4dcb58b3511f83003e42d

Makes sense to me:

Thanks for the review.

#5 lore raw
In reply to Tariq Toukan
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 21 Oct 2026 09:28:05 +0300 you wrote:

From: Cosmin Ratiu <[email protected]>

PSP packets are UDP-encapsulated, and enabling HW GRO (SHAMPO in mlx5) makes it possible to merge those packets in a silly way:
IP|UDP|PSP1|payload1|PSP2|payload2|...

That happens because the HW GRO machinery doesn't know about PSP and considers it part of the UDP payload.

[...]

Here is the summary with links:
- [net,V2] net/mlx5e: SHAMPO: Do not merge PSP packets

    https://git.kernel.org/netdev/net/c/46bd2bf65b93

You are awesome, thank you!

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