Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp720599pxb; Mon, 25 Oct 2021 17:24:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrxMTKjoJp8E3kJp2xtJw1lMCsOekUKskgOq/FSlr9TTHCZZrQzyErGBF2O5yJoEY7oM+0 X-Received: by 2002:a63:18b:: with SMTP id 133mr15870017pgb.156.1635207881253; Mon, 25 Oct 2021 17:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635207881; cv=none; d=google.com; s=arc-20160816; b=CM3lRHCI/yxgacObZq/58BfhGpyQxWAqmfaoWGzy3cOrHoa7z1oQNRhNY3J8NnXxFx +8f6HeyS5/dngMOXsW8ojPQ3uX5JF1dLWGwMT1YEdG2SFxIjiU2I8/CZGUFQ32gQ0k3P yPwnkBygINaTBq6HLWVfk/go4KhCOPQu9daGXYSWvbWYXzM2lcWoF1Eg82MrngQuZa9S oSDx2HWWMa0q/qfRgSvW6PNjSIiB0s5yut3TnUWZzE7ze0KmlEgOLJ10ijAr6NOBEgW/ piBGcI29P5o3YyX2mSnNoLWn8TOikeKMMDmQblcxdW4CCDO8lkXMN7ube43C7RMb3F1Y gEOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7vU0rOGX6d7h7ORghKZoNr+d5Gu1AXdZ07wdWeMvwQM=; b=sLW0rWZ3EiMfZWFFhZ7sU1N0Lh7LO4m2MGF7EYXLpr7Q7SYbeSYZ9LDcdTYOsAHAgT 05hv+OE1QYp2HlEzWFzSbT3FXro6JryNQvUTmhb8i8zxs3syXMTtCNt0FL5trFSJh5Tx Av90ohuIzBSDR+Bx3vithB1VSVmEnf5dZrrM+v2GjOuUo7coLdIXobzEaqSHIj3yaOI2 zkHi1ynlQ2jHKzbPOc+E3/K+haeQL+A+bHOrq9c8FHY4upyn8gxowckFzm4bzstdX2Jq iVnb0F/ZGej4VRxSpHWj1DXt5UH2mDxgmztUhsL00BJJtBTxnHHsL1GRY21E/rxVEHdi aicA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="RsuSxG/x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si28870111pgw.185.2021.10.25.17.24.28; Mon, 25 Oct 2021 17:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="RsuSxG/x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236763AbhJYTug (ORCPT + 99 others); Mon, 25 Oct 2021 15:50:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:60708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236612AbhJYTo5 (ORCPT ); Mon, 25 Oct 2021 15:44:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 69F4360187; Mon, 25 Oct 2021 19:38:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635190723; bh=Kw2pnTLaMolyqnbKdYQUDurXX5IzbfZt67LnOkHyEz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RsuSxG/xf8wk3eKsgwwo+3c2h6Brc4ivL+zYeBBORy9K2RifmKBifSb+bMwMvPGOp F+o/8ooG/z9LPDyusSMtQIOgP7ktL95x/GzJSZ9YfLd5sl/Z3v+lAaOXZY+p4YOaa7 mIuNJBK+KL2HT0wg0492/dumBxhxb1S7e7oXBS7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emeel Hakim , Raed Salem , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.14 055/169] net/mlx5e: IPsec: Fix a misuse of the software parsers fields Date: Mon, 25 Oct 2021 21:13:56 +0200 Message-Id: <20211025191024.592815653@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025191017.756020307@linuxfoundation.org> References: <20211025191017.756020307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Emeel Hakim [ 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 Reviewed-by: Raed Salem Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) 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, -- 2.33.0