Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1873176yba; Thu, 25 Apr 2019 07:07:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwV5OA7VFuHfkF0Q33KxxajjoIrWEv6DggGEuyJwDNmRTZlpx6zrjT21ACs3JIAI40aETo5 X-Received: by 2002:a63:120d:: with SMTP id h13mr6247609pgl.93.1556201226051; Thu, 25 Apr 2019 07:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556201226; cv=none; d=google.com; s=arc-20160816; b=BnsmUzsaOK3X4Kx4XKOeDC7Px9k+dsI+CiXWeyvVooTMhYyxkPqqGhfaRD2Boh5ko3 h+cejrM8+9Wh5RmygnlwdB9Sk+wk/OGq5+COqGzQt+QWS3woNZzV9MKCoNvHqwEalxnR eYAQod4QhNyzHaOT51wBiRj+QtZThLPwhonKD9N5c8EmeN2JyNbU3Z8Q711vPcc7MEWK OhNOKGyPnV+PPofLMVN0PCugVOQhv8CWT6HmSgIHtDtLR6iPr/tb/K4MSPa62YEHGHX+ YM+5U6PTUY5gUgU/PkfX1C/kPNxAiPR0qThIzLSRICHLFiseilBPe8ANsLLARlFVUJGh TbrQ== 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=y0HcUaugvr7kTY7CXyle+rQvMGinL39hQ1V38C4/6l0=; b=oxQK/BgNCJAkRzwxgDNmUo9ExHQaKXqCyMVC5MxpjYKkmI2ERambIe56KTL91R6XkO smvU4hlro0WJVPbD2hXkmMI+EPLp0jPFaGcxl76kqa0VM41XMFx5PBDpPInwkkrQuN+i mL0FkzQ0U9snaQWX36z7HrQY7uFsfXMZZFowUiN9bO6iHIBo7QyeAHD48ORqZgGB+hhh Rxo0TG7TUi7RgrumDEvQjpPwqOxDh+vBxxsvbUPoB8O8kiyMel7cbNAeMyVbultN9BwJ aWxGIVz1UxaVDx9Yo7dakfryHvHlxvdOeAN/edTmc0z6vkEJgwYHGBeVOnvGpiBDHlgW HzgQ== 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 z2si22180516plo.368.2019.04.25.07.06.49; Thu, 25 Apr 2019 07:07:06 -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 S1731432AbfDYMoS (ORCPT + 99 others); Thu, 25 Apr 2019 08:44:18 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:40710 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731333AbfDYMoM (ORCPT ); Thu, 25 Apr 2019 08:44:12 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 332819160BDD7E537280; Thu, 25 Apr 2019 20:44:09 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Thu, 25 Apr 2019 20:44:03 +0800 From: Huazhong Tan To: CC: , , , , , , Yunsheng Lin , Peng Li , Huazhong Tan Subject: [PATCH V3 net-next 03/11] net: hns3: handle the BD info on the last BD of the packet Date: Thu, 25 Apr 2019 20:42:47 +0800 Message-ID: <1556196175-65389-4-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556196175-65389-1-git-send-email-tanhuazhong@huawei.com> References: <1556196175-65389-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] 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 The bdinfo handled in hns3_handle_bdinfo is only valid on the last BD of the current packet, currently the bd info may be handled based on the first BD if the packet has more than two BDs, which may cause rx error. This patch fixes it by using the last BD of the current packet in hns3_handle_bdinfo. Also, hns3_set_rx_skb_rss_type has used RSS hash value from the last BD of the current packet, so remove the same last BD calculation in hns3_set_rx_skb_rss_type and call it from hns3_handle_bdinfo. Fixes: e55970950556 ("net: hns3: Add handling of GRO Pkts not fully RX'ed in NAPI poll") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 38 +++++++++++++------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 6695b94..7dc281c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2697,36 +2697,37 @@ static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring, } static void hns3_set_rx_skb_rss_type(struct hns3_enet_ring *ring, - struct sk_buff *skb) + struct sk_buff *skb, u32 rss_hash) { struct hnae3_handle *handle = ring->tqp->handle; enum pkt_hash_types rss_type; - struct hns3_desc *desc; - int last_bd; - - /* When driver handle the rss type, ring->next_to_clean indicates the - * first descriptor of next packet, need -1 here. - */ - last_bd = (ring->next_to_clean - 1 + ring->desc_num) % ring->desc_num; - desc = &ring->desc[last_bd]; - if (le32_to_cpu(desc->rx.rss_hash)) + if (rss_hash) rss_type = handle->kinfo.rss_type; else rss_type = PKT_HASH_TYPE_NONE; - skb_set_hash(skb, le32_to_cpu(desc->rx.rss_hash), rss_type); + skb_set_hash(skb, rss_hash, rss_type); } -static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb, - struct hns3_desc *desc) +static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb) { struct net_device *netdev = ring->tqp->handle->kinfo.netdev; - u32 bd_base_info = le32_to_cpu(desc->rx.bd_base_info); - u32 l234info = le32_to_cpu(desc->rx.l234_info); enum hns3_pkt_l2t_type l2_frame_type; + u32 bd_base_info, l234info; + struct hns3_desc *desc; unsigned int len; - int ret; + int pre_ntc, ret; + + /* bdinfo handled below is only valid on the last BD of the + * current packet, and ring->next_to_clean indicates the first + * descriptor of next packet, so need - 1 below. + */ + pre_ntc = ring->next_to_clean ? (ring->next_to_clean - 1) : + (ring->desc_num - 1); + desc = &ring->desc[pre_ntc]; + bd_base_info = le32_to_cpu(desc->rx.bd_base_info); + l234info = le32_to_cpu(desc->rx.l234_info); /* Based on hw strategy, the tag offloaded will be stored at * ot_vlan_tag in two layer tag case, and stored at vlan_tag @@ -2787,6 +2788,8 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb, u64_stats_update_end(&ring->syncp); ring->tqp_vector->rx_group.total_bytes += len; + + hns3_set_rx_skb_rss_type(ring, skb, le32_to_cpu(desc->rx.rss_hash)); return 0; } @@ -2856,14 +2859,13 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, ALIGN(ring->pull_len, sizeof(long))); } - ret = hns3_handle_bdinfo(ring, skb, desc); + ret = hns3_handle_bdinfo(ring, skb); if (unlikely(ret)) { dev_kfree_skb_any(skb); return ret; } *out_skb = skb; - hns3_set_rx_skb_rss_type(ring, skb); return 0; } -- 2.7.4