From patchwork Fri Jun 1 16:52:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 137561 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1178351lji; Fri, 1 Jun 2018 09:54:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKT0k02JE8Y45vmNssAEhsxCPp5tVPk3/6qjEpDBi0dSTx1AXeLOxrZ/aA1wvUZem2STdoi X-Received: by 2002:a17:902:7c83:: with SMTP id y3-v6mr11907265pll.51.1527872061590; Fri, 01 Jun 2018 09:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527872061; cv=none; d=google.com; s=arc-20160816; b=QyiIL2otqdW+Wd55b6RcmnOtoTqM6WJyQrfYJ39btpzFAmjRWOIceB/baKeKwQluF9 R1GG7bZbJ4iXXANt4CAGl4usTjrqZ+gYqJJNy1thcg9X0YsmyO/0jLwUlT4HyNPqUqdz qgRCh4ZmRzuZ4XOvVwDNw8xUbuL7qrjdZ4AwQfRpprYSveQnml77CnrJxKRVB28AqZXU rUH+ywhcBboBDCywsPxJ9+UwL2Wk6et5Hj7RFrAo7zs0ykvupnOMTJnER8ohK/b6smrz Ru7vsI9pQ2WHP/GufPGJZqa533iBFLiF2WuxhBFkak285xd+qW5PohAxnzLMbztvvluo b44A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=3jQTyeLuFQvh1nT3XrwIM3U8WgRCA8zVM5HRW/ZVA8U=; b=zbePSGbwgDVKrPa0u2EEcxOYMDCF+pOGmgvqbbyx3/Ok8RFDTElFiV/hhUVejrMGC7 YmDDIMoLchpFV5vOGwnqPfphU5DGlgcrIFJ//z3hoRdsj4qi+xKdLNhiaBTy+LQ+uUlg ppoEscJvsL8bJ/WKGSEMvPVqVw7lSYu15WFVQmhYMsg71Q343wtIrrHyJj4492+H9sjc kpl5+huVZfYOepknd+yVNwBA+O7uwrysNNMOvgdU9Pqf5EjV6J7HZI0vYuYR/XCqDUiI rwyxJQB/qkRSNnHBJjKOZ6axGY0wVL3YT7SCMtR4eGe+7dpUAyQAXuUpf1H5wVXCuJhA vzMQ== ARC-Authentication-Results: i=1; mx.google.com; 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 k28-v6si7243393pfh.50.2018.06.01.09.54.21; Fri, 01 Jun 2018 09:54:21 -0700 (PDT) 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; 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 S1753432AbeFAQyS (ORCPT + 30 others); Fri, 1 Jun 2018 12:54:18 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8683 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753273AbeFAQyO (ORCPT ); Fri, 1 Jun 2018 12:54:14 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 83EAC4118B2A; Sat, 2 Jun 2018 00:53:56 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.382.0; Sat, 2 Jun 2018 00:53:51 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 09/11] net: hns3: Fix for vxlan tx checksum bug Date: Fri, 1 Jun 2018 17:52:09 +0100 Message-ID: <20180601165211.46372-10-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180601165211.46372-1-salil.mehta@huawei.com> References: <20180601165211.46372-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin when skb->encapsulation is 0, skb->ip_summed is CHECKSUM_PARTIAL and it is udp packet, which has a dest port as the IANA assigned. the hardware is expected to do the checksum offload, but the hardware will not do the checksum offload when udp dest port is 4789. This patch fixes it by doing the checksum in software. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 235eea1..e572804 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -655,6 +655,32 @@ static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto, } } +/* when skb->encapsulation is 0, skb->ip_summed is CHECKSUM_PARTIAL + * and it is udp packet, which has a dest port as the IANA assigned. + * the hardware is expected to do the checksum offload, but the + * hardware will not do the checksum offload when udp dest port is + * 4789. + */ +static bool hns3_tunnel_csum_bug(struct sk_buff *skb) +{ +#define IANA_VXLAN_PORT 4789 + union { + struct tcphdr *tcp; + struct udphdr *udp; + struct gre_base_hdr *gre; + unsigned char *hdr; + } l4; + + l4.hdr = skb_transport_header(skb); + + if (!(!skb->encapsulation && l4.udp->dest == htons(IANA_VXLAN_PORT))) + return false; + + skb_checksum_help(skb); + + return true; +} + static int hns3_set_l3l4_type_csum(struct sk_buff *skb, u8 ol4_proto, u8 il4_proto, u32 *type_cs_vlan_tso, u32 *ol_type_vlan_len_msec) @@ -743,6 +769,9 @@ static int hns3_set_l3l4_type_csum(struct sk_buff *skb, u8 ol4_proto, HNS3_L4T_TCP); break; case IPPROTO_UDP: + if (hns3_tunnel_csum_bug(skb)) + break; + hnae_set_field(*type_cs_vlan_tso, HNS3_TXD_L4T_M, HNS3_TXD_L4T_S,