Patch "net/mlx5e: IPsec: Fix a misuse of the software parser's fields" has been added to the 5.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net/mlx5e: IPsec: Fix a misuse of the software parser's fields

to the 5.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-mlx5e-ipsec-fix-a-misuse-of-the-software-parser-.patch
and it can be found in the queue-5.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 64285acf61e5acabc560d9ec20ce904c4358100e
Author: Emeel Hakim <ehakim@xxxxxxxxxx>
Date:   Mon Oct 18 15:30:09 2021 +0300

    net/mlx5e: IPsec: Fix a misuse of the software parser's fields
    
    [ Upstream commit d10457f85d4ae4d32c0df0cd65358a78c577fbe6 ]
    
    IPsec crypto offload current Software Parser (SWP) fields settings in
    the ethernet segment (eseg) are not aligned with PRM/HW expectations.
    Among others in case of IP|ESP|TCP packet, current driver sets the
    offsets for inner_l3 and inner_l4 although there is no inner l3/l4
    headers relative to ESP header in such packets.
    
    SWP provides the offsets for HW ,so it can be used to find csum fields
    to offload the checksum, however these are not necessarily used by HW
    and are used as fallback in case HW fails to parse the packet, e.g
    when performing IPSec Transport Aware (IP | ESP | TCP) there is no
    need to add SW parse on inner packet. So in some cases packets csum
    was calculated correctly , whereas in other cases it failed. The later
    faced csum errors (caused by wrong packet length calculations) which
    led to lots of packet drops hence the low throughput.
    
    Fix by setting the SWP fields as expected in a IP|ESP|TCP packet.
    
    the following describe the expected SWP offsets:
    * Tunnel Mode:
    * SWP:      OutL3       InL3  InL4
    * Pkt: MAC  IP     ESP  IP    L4
    *
    * Transport Mode:
    * SWP:      OutL3       OutL4
    * Pkt: MAC  IP     ESP  L4
    *
    * Tunnel(VXLAN TCP/UDP) over Transport Mode
    * SWP:      OutL3                   InL3  InL4
    * Pkt: MAC  IP     ESP  UDP  VXLAN  IP    L4
    
    Fixes: f1267798c980 ("net/mlx5: Fix checksum issue of VXLAN and IPsec crypto offload")
    Signed-off-by: Emeel Hakim <ehakim@xxxxxxxxxx>
    Reviewed-by: Raed Salem <raeds@xxxxxxxxxx>
    Signed-off-by: Saeed Mahameed <saeedm@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
index 33de8f0092a6..fb5397324aa4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c
@@ -141,8 +141,7 @@ static void mlx5e_ipsec_set_swp(struct sk_buff *skb,
 	 * Pkt: MAC  IP     ESP  IP    L4
 	 *
 	 * Transport Mode:
-	 * SWP:      OutL3       InL4
-	 *           InL3
+	 * SWP:      OutL3       OutL4
 	 * Pkt: MAC  IP     ESP  L4
 	 *
 	 * Tunnel(VXLAN TCP/UDP) over Transport Mode
@@ -171,31 +170,35 @@ static void mlx5e_ipsec_set_swp(struct sk_buff *skb,
 		return;
 
 	if (!xo->inner_ipproto) {
-		eseg->swp_inner_l3_offset = skb_network_offset(skb) / 2;
-		eseg->swp_inner_l4_offset = skb_inner_transport_offset(skb) / 2;
-		if (skb->protocol == htons(ETH_P_IPV6))
-			eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L3_IPV6;
-		if (xo->proto == IPPROTO_UDP)
+		switch (xo->proto) {
+		case IPPROTO_UDP:
+			eseg->swp_flags |= MLX5_ETH_WQE_SWP_OUTER_L4_UDP;
+			fallthrough;
+		case IPPROTO_TCP:
+			/* IP | ESP | TCP */
+			eseg->swp_outer_l4_offset = skb_inner_transport_offset(skb) / 2;
+			break;
+		default:
+			break;
+		}
+	} else {
+		/* Tunnel(VXLAN TCP/UDP) over Transport Mode */
+		switch (xo->inner_ipproto) {
+		case IPPROTO_UDP:
 			eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L4_UDP;
-		return;
-	}
-
-	/* Tunnel(VXLAN TCP/UDP) over Transport Mode */
-	switch (xo->inner_ipproto) {
-	case IPPROTO_UDP:
-		eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L4_UDP;
-		fallthrough;
-	case IPPROTO_TCP:
-		eseg->swp_inner_l3_offset = skb_inner_network_offset(skb) / 2;
-		eseg->swp_inner_l4_offset = (skb->csum_start + skb->head - skb->data) / 2;
-		if (skb->protocol == htons(ETH_P_IPV6))
-			eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L3_IPV6;
-		break;
-	default:
-		break;
+			fallthrough;
+		case IPPROTO_TCP:
+			eseg->swp_inner_l3_offset = skb_inner_network_offset(skb) / 2;
+			eseg->swp_inner_l4_offset =
+				(skb->csum_start + skb->head - skb->data) / 2;
+			if (skb->protocol == htons(ETH_P_IPV6))
+				eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L3_IPV6;
+			break;
+		default:
+			break;
+		}
 	}
 
-	return;
 }
 
 void mlx5e_ipsec_set_iv_esn(struct sk_buff *skb, struct xfrm_state *x,



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux