From patchwork Thu Nov 15 09:29:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 151216 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6766029ljp; Thu, 15 Nov 2018 01:30:58 -0800 (PST) X-Google-Smtp-Source: AJdET5dY9mS3f03KN1TtrweOj+arUICT7PVw6UQgB2FFzNQsRBvDZ5pSNruSjkVXHnnmD+KmvBxr X-Received: by 2002:a62:714a:: with SMTP id m71-v6mr5894169pfc.89.1542274257929; Thu, 15 Nov 2018 01:30:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542274257; cv=none; d=google.com; s=arc-20160816; b=ECW39dScleSi/aeHnhpp0bnkaPgLm+qD9TcGdk4WecHf9wcjP5YIaP7rORB+gLwXOY AHAggzCelPeezNNUSSckIP4QM8YdjL+81PZLp02bcVVdt/v5pYaynqG6+3bz9QVScv54 nthx7yicrqnJTLbOCvMG/VRcPxoOp2mgOzl9nSl7nXxmf6RlCWOqmEqegoLFJyFR8fDJ qNa8IpX/BrO9QVDArKNS57zFgHh++X86NKoyyHnK7LewcKm7NXsOjjNHfHbJgVym1f4g 7l5qKkrVNSTjnvAB4ovowdVX759Q5fJwqhsEUeKxMWXd+0FDHDDDw9MH79M7h1Y7hxR9 EtwQ== 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; bh=X2zsl5gEpQcCZRq0LEhAaOGuuXND4ufHR1N2P7yjsd8=; b=njV2x97f9TJB5NtjPOHLbWLbPdqUrqASdG2JxKtWKWc1JZmNuz7sKG1RYAEdXxyZJQ Y1l4QUxayV2vlH6pFzGKo4ZRETwBeh8r3BRaFobDy7oZ/As07ovrhg1aNNy1xoUzLKyM TBiWeBIUQ8UVjBKAmgxAFo9MGYwYuKTLmP6AOY3btZp7qWrEXTvx9QeLi42cRV1ohjlz bCB9TebIEuhL99L30r2HulxpqGLDnRqyXYZp1sjYdKyMAad+oGC07xhobr+oW4aBGSJn M2iwMOh2maGe+4F7LU3MjOtg1Jgd9ZzW6DjVw2xGpAFZfkIScqQZPX7o6RBnjqZmIPY6 4vSg== 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 b137si27358061pga.394.2018.11.15.01.30.57; Thu, 15 Nov 2018 01:30:57 -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; 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 S2388177AbeKOTh4 (ORCPT + 32 others); Thu, 15 Nov 2018 14:37:56 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:58120 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727265AbeKOTh4 (ORCPT ); Thu, 15 Nov 2018 14:37:56 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 08F917C9B1E06; Thu, 15 Nov 2018 17:30:52 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.47.88.106) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Thu, 15 Nov 2018 17:30:43 +0800 From: Salil Mehta To: CC: , , , , , , , Subject: [PATCH V2 net-next 5/5] net: hns3: Adds GRO params to SKB for the stack Date: Thu, 15 Nov 2018 09:29:25 +0000 Message-ID: <20181115092925.11812-6-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20181115092925.11812-1-salil.mehta@huawei.com> References: <20181115092925.11812-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.88.106] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li When HW GRO enable, protocol stack will not do GRO again, driver should add gro param to the skb for the protocol stack.. Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 43 +++++++++++++++++++ .../net/ethernet/hisilicon/hns3/hns3_enet.h | 9 ++-- 2 files changed, 49 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 7776089b6bc2..22220af92aa9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "hnae3.h" @@ -2318,6 +2319,12 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb, if (!(netdev->features & NETIF_F_RXCSUM)) return; + /* We MUST enable hardware checksum before enabling hardware GRO */ + if (skb_shinfo(skb)->gso_size) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + return; + } + /* check if hardware has done checksum */ if (!hnae3_get_bit(bd_base_info, HNS3_RXD_L3L4P_B)) return; @@ -2511,6 +2518,39 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc, return 0; } +static void hns3_set_gro_param(struct sk_buff *skb, u32 l234info, + u32 bd_base_info) +{ + u16 gro_count; + u32 l3_type; + + gro_count = hnae3_get_field(l234info, HNS3_RXD_GRO_COUNT_M, + HNS3_RXD_GRO_COUNT_S); + /* if there is no HW GRO, do not set gro params */ + if (!gro_count) + return; + + /* tcp_gro_complete() will copy NAPI_GRO_CB(skb)->count + * to skb_shinfo(skb)->gso_segs + */ + NAPI_GRO_CB(skb)->count = gro_count; + + l3_type = hnae3_get_field(l234info, HNS3_RXD_L3ID_M, + HNS3_RXD_L3ID_S); + if (l3_type == HNS3_L3_TYPE_IPV4) + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; + else if (l3_type == HNS3_L3_TYPE_IPV6) + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; + else + return; + + skb_shinfo(skb)->gso_size = hnae3_get_field(bd_base_info, + HNS3_RXD_GRO_SIZE_M, + HNS3_RXD_GRO_SIZE_S); + if (skb_shinfo(skb)->gso_size) + tcp_gro_complete(skb); +} + static void hns3_set_rx_skb_rss_type(struct hns3_enet_ring *ring, struct sk_buff *skb) { @@ -2645,6 +2685,9 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, ring->tqp_vector->rx_group.total_bytes += skb->len; + /* This is needed in order to enable forwarding support */ + hns3_set_gro_param(skb, l234info, bd_base_info); + hns3_rx_checksum(ring, skb, desc); *out_skb = skb; hns3_set_rx_skb_rss_type(ring, skb); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 8e56b7e44978..3365c9596983 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -109,6 +109,10 @@ enum hns3_nic_state { #define HNS3_RXD_DOI_B 21 #define HNS3_RXD_OL3E_B 22 #define HNS3_RXD_OL4E_B 23 +#define HNS3_RXD_GRO_COUNT_S 24 +#define HNS3_RXD_GRO_COUNT_M (0x3f << HNS3_RXD_GRO_COUNT_S) +#define HNS3_RXD_GRO_FIXID_B 30 +#define HNS3_RXD_GRO_ECN_B 31 #define HNS3_RXD_ODMAC_S 0 #define HNS3_RXD_ODMAC_M (0x3 << HNS3_RXD_ODMAC_S) @@ -135,9 +139,8 @@ enum hns3_nic_state { #define HNS3_RXD_TSIND_S 12 #define HNS3_RXD_TSIND_M (0x7 << HNS3_RXD_TSIND_S) #define HNS3_RXD_LKBK_B 15 -#define HNS3_RXD_HDL_S 16 -#define HNS3_RXD_HDL_M (0x7ff << HNS3_RXD_HDL_S) -#define HNS3_RXD_HSIND_B 31 +#define HNS3_RXD_GRO_SIZE_S 16 +#define HNS3_RXD_GRO_SIZE_M (0x3ff << HNS3_RXD_GRO_SIZE_S) #define HNS3_TXD_L3T_S 0 #define HNS3_TXD_L3T_M (0x3 << HNS3_TXD_L3T_S)