Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2689172imj; Mon, 11 Feb 2019 07:04:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IaF7/JqwmerzpTtqBdOC07hMX64Ud1t1sLdWvponYJNQsTT2f+8dabSTp+HfmgHEPIAWVWn X-Received: by 2002:a63:cf54:: with SMTP id b20mr19747490pgj.123.1549897446709; Mon, 11 Feb 2019 07:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897446; cv=none; d=google.com; s=arc-20160816; b=SfuUv1/gsZio7EUt4K5/E2TqQZGTTeDq0/Rh+cYGQswcKmevv6AGLN72sZiylWsveO qP6I9A9uwR7Z/cfvjbkvMEKY1VYYWtluUAtk28TwhGkHSb2VBLaGsb7oH/dwnZ8Eo8wd ChtGFau7oYZKOfvGV5Qnaqo1Oofmz57zM1qVtVfCuvrSQW4Vs/nV7pduOE1mCxxOj5JQ YPQ+6RfPEbFTlVaHq05nBoX6inDro+eIdVuGoxmzJxP3jKYqQt6l+DN5+/9xe7mWNaKT uif75NrPGQHSru5lEua25zjyYFDI+bOSqWXF8gfDO2z6a2+10q5xttOEVM55ljyDVJK2 Ah0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MntbVzZ2xEFh9ubJcKRSf+LsEi1Nb0br8ir5LTe3XHg=; b=sdb+kXjJbPU6OHMOHAxJyF5rHfJkJAfCJt0KwGN6rwa8LaiGAJ+dZKskTGSfWsD/DK i641cT7CfSPG+EeSiolyV1T9auxcZOq+KdiuFVYadVqBMsMNlZVxXPCdqUIpcMrVfSl6 NN97tx+au1Q9PX4f0E9l4QJmWFL1O67NtMRb8Q67Qp+b7DJQazBE3O5FDKt75dmt6HHC P5vNKeVihGR46nJBQK5DOtu5KTf3Yu/OYlaPwI/GgkrtoS+oCkYq7+FRWQ1qwsOUQsZf VjiY1MPmozgVWTxwGy2e638lIzO4/aFMy9Zofqh5iCVks1XTWnoc2kZ6odLJ1BP6Ouft UuHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UwGn64vR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si10293193plp.9.2019.02.11.07.03.42; Mon, 11 Feb 2019 07:04:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UwGn64vR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390009AbfBKPCi (ORCPT + 99 others); Mon, 11 Feb 2019 10:02:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:50740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390425AbfBKPCc (ORCPT ); Mon, 11 Feb 2019 10:02:32 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC3EC222A7; Mon, 11 Feb 2019 15:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897351; bh=hfEY1RH1kScw8epRhAsBXY4kzmH6dAv87wYbFk5AcJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UwGn64vRuyIo4hdgcBEt/3jdNecxLo0oK7X2aQw0MRqKZZpEKasAr9ztatWOwnlHl hleCqFlRI6DHMu77mMoL8ooYMdA9ZxhmxVur8VfMBLE8+hx8t8v4wX6Qd3DoM71Hu8 XRKgSXJtTwmD56/aKcI10cmLe6XYcq0Gh0r+234E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Tariq Toukan , Nikola Ciprich , Cong Wang , Saeed Mahameed Subject: [PATCH 4.14 173/205] net/mlx5e: Force CHECKSUM_UNNECESSARY for short ethernet frames Date: Mon, 11 Feb 2019 15:19:31 +0100 Message-Id: <20190211141839.678919090@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit e8c8b53ccaff568fef4c13a6ccaf08bf241aa01a ] When an ethernet frame is padded to meet the minimum ethernet frame size, the padding octets are not covered by the hardware checksum. Fortunately the padding octets are usually zero's, which don't affect checksum. However, we have a switch which pads non-zero octets, this causes kernel hardware checksum fault repeatedly. Prior to: commit '88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE ...")' skb checksum was forced to be CHECKSUM_NONE when padding is detected. After it, we need to keep skb->csum updated, like what we do for RXFCS. However, fixing up CHECKSUM_COMPLETE requires to verify and parse IP headers, it is not worthy the effort as the packets are so small that CHECKSUM_COMPLETE can't save anything. Fixes: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"), Cc: Eric Dumazet Cc: Tariq Toukan Cc: Nikola Ciprich Signed-off-by: Cong Wang Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -646,6 +646,8 @@ static u32 mlx5e_get_fcs(const struct sk return __get_unaligned_cpu32(fcs_bytes); } +#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) + static inline void mlx5e_handle_csum(struct net_device *netdev, struct mlx5_cqe64 *cqe, struct mlx5e_rq *rq, @@ -661,6 +663,17 @@ static inline void mlx5e_handle_csum(str return; } + /* CQE csum doesn't cover padding octets in short ethernet + * frames. And the pad field is appended prior to calculating + * and appending the FCS field. + * + * Detecting these padded frames requires to verify and parse + * IP headers, so we simply force all those small frames to be + * CHECKSUM_UNNECESSARY even if they are not padded. + */ + if (short_frame(skb->len)) + goto csum_unnecessary; + if (is_first_ethertype_ip(skb)) { skb->ip_summed = CHECKSUM_COMPLETE; skb->csum = csum_unfold((__force __sum16)cqe->check_sum); @@ -672,6 +685,7 @@ static inline void mlx5e_handle_csum(str return; } +csum_unnecessary: if (likely((cqe->hds_ip_ext & CQE_L3_OK) && (cqe->hds_ip_ext & CQE_L4_OK))) { skb->ip_summed = CHECKSUM_UNNECESSARY;