Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3650569pxk; Tue, 29 Sep 2020 02:37:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWK1zfc7M7dAzk73vnZ7c467UQ4sQH2VnuO7uvYm7YYYOTZq8mKmA9l8fLWAJkfgDvyq/C X-Received: by 2002:a17:907:2115:: with SMTP id qn21mr2900315ejb.278.1601372263762; Tue, 29 Sep 2020 02:37:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601372263; cv=none; d=google.com; s=arc-20160816; b=c7DVl+ODnUcy22+h9UKl1/KfeyXZmhUN1SSPtTeITQX0PF2uYa5xhuXaSoHWMjlc/G NIApS/66v09Q7Q8Pp8o0iJaCebPNWsDIx/rBD7O9ZCPHx8SXIamV+KTzgZim9vSRUyVN zqBmbjwznOfcR1mhmsQ1mLmE3bt/JAmosG3HegmBU0R85ZAl+u8q0LUC6N/AJNsKCykX +zp5f6HhbLzFw9oKdMq0ZwJrWT9BI2+KJGEMWv+0v9PDRO0x3+vLTec/G7LkjFBoyJd9 O32uB8fV27ZG8U94VsKn9t33cPrPxjJQh6Z0ilisJyqaZF+SjJAVjh0ivhs+jrWLY8VY M0qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=93pGS3VROzwEOXv9wXFX11CdlESu7zuU/kYm/XPDavg=; b=iPB1nvknnnVlzDpAcGYYWAlr6UF/5tal1RxBn3IwzU+EPJrNsJWeFXtMc8E7cto5AT b/JuWdSmXYA8sWWjDBFT6UO8FuuUvRtSngHkRULXP/D255yCvoFwo52Mm1XQRmH6f5QX S218bEmRHlW7jUqzUuH4+zPBPx3mAHPlLwpADSG0bAJc2XCSe4lUX7j6Xwu3JNx8ltyx EeEyJXS8K7Rc/zkrbakVZuaKfqt5+uiXOY6SEPcGdfyqj2SYVtX9M07faN66ymHlEgZ4 BGcKjWHDJgFGe3dHvbGf02tsMbJKjK9jfEMRLLvIP97Ok///SbeCAP8DHUtKJyty478c JNoA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si2579592edf.246.2020.09.29.02.37.20; Tue, 29 Sep 2020 02:37:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbgI2Jex (ORCPT + 99 others); Tue, 29 Sep 2020 05:34:53 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:14772 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727814AbgI2Jew (ORCPT ); Tue, 29 Sep 2020 05:34:52 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A15D32C30213399210C3; Tue, 29 Sep 2020 17:34:50 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 29 Sep 2020 17:34:44 +0800 From: Huazhong Tan To: CC: , , , , , , Huazhong Tan Subject: [PATCH net-next 3/7] net: hns3: add UDP segmentation offload support Date: Tue, 29 Sep 2020 17:32:01 +0800 Message-ID: <1601371925-49426-4-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1601371925-49426-1-git-send-email-tanhuazhong@huawei.com> References: <1601371925-49426-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for UDP segmentation offload to the HNS3 driver when the device can do it. Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index df52abb..a362516 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -696,12 +696,19 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen, /* normal or tunnel packet */ l4_offset = l4.hdr - skb->data; - hdr_len = (l4.tcp->doff << 2) + l4_offset; /* remove payload length from inner pseudo checksum when tso */ l4_paylen = skb->len - l4_offset; - csum_replace_by_diff(&l4.tcp->check, - (__force __wsum)htonl(l4_paylen)); + + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { + hdr_len = sizeof(*l4.udp) + l4_offset; + csum_replace_by_diff(&l4.udp->check, + (__force __wsum)htonl(l4_paylen)); + } else { + hdr_len = (l4.tcp->doff << 2) + l4_offset; + csum_replace_by_diff(&l4.tcp->check, + (__force __wsum)htonl(l4_paylen)); + } /* find the txbd field values */ *paylen = skb->len - hdr_len; @@ -2311,6 +2318,13 @@ static void hns3_set_default_feature(struct net_device *netdev) netdev->features |= NETIF_F_NTUPLE; } } + + if (test_bit(HNAE3_DEV_SUPPORT_UDP_GSO_B, ae_dev->caps)) { + netdev->hw_features |= NETIF_F_GSO_UDP_L4; + netdev->features |= NETIF_F_GSO_UDP_L4; + netdev->vlan_features |= NETIF_F_GSO_UDP_L4; + netdev->hw_enc_features |= NETIF_F_GSO_UDP_L4; + } } static int hns3_alloc_buffer(struct hns3_enet_ring *ring, -- 2.7.4