Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp809778imm; Fri, 1 Jun 2018 09:55:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLGA2vjSPMsPeUNvsL0nUqai1t1bD96qR5kKqD+RElq8OavpNA3Tw+DhyNqYwGjZemkglg/ X-Received: by 2002:a62:c4dd:: with SMTP id h90-v6mr11830996pfk.86.1527872120421; Fri, 01 Jun 2018 09:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527872120; cv=none; d=google.com; s=arc-20160816; b=SP8Apj0l+dhSktVKlmlPCMGItPHrDuK1/B1+avGEysbRKd3nUHXyX9bgCVnmqOBUyr Y6roBH7iQ+eiws0O7fIPojoTlivLxyJe5Crcd0YF1Wc6nr0Aki0jyJgm4iPD8dd1GV1p puICVKBnK6rhtHG8J8gGqGPhFHgU9ntrrOSVwA20BmGGa4R1kEpAV32BCismTSXW1nJW DRN7q8ssrBHJBFrnTu+mOCinLu1l8JSQTjQsxuxAWrAH4POyp4Gi3aK+reD0OmT2O6v2 9KLXdKiRp9XgelFeohWXlJW+AwByzxfKRo3E7Dl2nYdY2Ftx2slScvAj/4Du2t8d/f6F RwLQ== 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 k16-v6si42082072pli.171.2018.06.01.09.55.06; Fri, 01 Jun 2018 09:55:20 -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 S1753422AbeFAQyS (ORCPT + 99 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 Content-Type: text/plain 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(+) 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, -- 2.7.4