Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1807798ybg; Sat, 19 Oct 2019 02:57:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlpulC4RgObwD5d16zFMEdt6fL0TUpUwcMhCqK+TZV6FA9AAUAC2d8fTyUB9qzDlACx3MN X-Received: by 2002:a50:eb42:: with SMTP id z2mr14198482edp.291.1571479046663; Sat, 19 Oct 2019 02:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571479046; cv=none; d=google.com; s=arc-20160816; b=BkriSGMOe4vNt1meHD6Jn+7fN3BP4MbRDqwZ9ofXNlIkBY52JHxJF4iLiOmpjPFR52 QcTlXGs7GJ8FsRM09P1HfC1rQeHFlxMxqaG1mZPvvKIGKyCQCes5kndNuTB9Oqsrz4u7 ESVt3x8x2iwWj+gphphi4dZ77DnXYwPq50qxokcBU6VIVq/S+PqucLQJh8W6Rv0BpA7J WBuovYksxXD4y4RuBAFJtgYKvtWyja7plNeXX7Vb4J2PNMmzHVkSVPqOuIh+y84Wzq3p KYgrNyhjmkNZNDHC976ys+1CR8qF2lkEpS71tW4Uea7ljpbOZspItn/78KQXGne/HgSX H46A== 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=37J90+SfXhszflX+dwN4yJACZRJIkItAMNEHDPH+sdc=; b=CJjTqQwsgsIilzvYycVe/+MFg9fuoZpexEONnpIJfAFpeMFFta1LQNHlXzpkDJ/6MR 1Qa8sIQ0D4b0PRArI7JTZDt50JjeB+YnmkgeaRW3AjC9rrL4AhkEub+eVOijBacb9V0S wDFEMFI9xSqaLvOUF5oM+lTVJA8zeFIS8hLFgS284JVTruX9gLy6JNwIwRJO9bPiWQs2 qfBjuAou/gEKWj9KJ0ovrxutkml5sQzO1cXY563xNf1Rq5jBPNZgb/Jz+rI2B/Ik4MVF juAG5IrSEMq/cC5rkZBv5epuLnUyZGwTEj3Ejf54Yp7/pnR0ME2r65B+p7VaXgVevBQr z9pA== 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 s21si895011edm.311.2019.10.19.02.57.03; Sat, 19 Oct 2019 02:57:26 -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 S1728176AbfJSIDw (ORCPT + 99 others); Sat, 19 Oct 2019 04:03:52 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33886 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726139AbfJSID3 (ORCPT ); Sat, 19 Oct 2019 04:03:29 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DD60844CB455F6392F66; Sat, 19 Oct 2019 16:03:25 +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.439.0; Sat, 19 Oct 2019 16:03:16 +0800 From: Huazhong Tan To: CC: , , , , , , Yunsheng Lin , Huazhong Tan Subject: [PATCH net-next 6/8] net: hns3: minor cleanup for hns3_handle_rx_bd() Date: Sat, 19 Oct 2019 16:03:54 +0800 Message-ID: <1571472236-17401-7-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571472236-17401-1-git-send-email-tanhuazhong@huawei.com> References: <1571472236-17401-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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin Since commit e55970950556 ("net: hns3: Add handling of GRO Pkts not fully RX'ed in NAPI poll"), ring->skb is used to record the current SKB when processing the RX BD in hns3_handle_rx_bd(), so the parameter out_skb is unnecessary. This patch also adjusts the err checking to reduce duplication in hns3_handle_rx_bd(), and "err == -ENXIO" is rare case, so put it in the unlikely annotation. Signed-off-by: Yunsheng Lin Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 38 +++++++++---------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 422fa4d..1c5e0d2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2831,10 +2831,10 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, unsigned int length, } static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc, - struct sk_buff **out_skb, bool pending) + bool pending) { - struct sk_buff *skb = *out_skb; - struct sk_buff *head_skb = *out_skb; + struct sk_buff *skb = ring->skb; + struct sk_buff *head_skb = skb; struct sk_buff *new_skb; struct hns3_desc_cb *desc_cb; struct hns3_desc *pre_desc; @@ -3017,8 +3017,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb) return 0; } -static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, - struct sk_buff **out_skb) +static int hns3_handle_rx_bd(struct hns3_enet_ring *ring) { struct sk_buff *skb = ring->skb; struct hns3_desc_cb *desc_cb; @@ -3056,12 +3055,12 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, if (!skb) { ret = hns3_alloc_skb(ring, length, ring->va); - *out_skb = skb = ring->skb; + skb = ring->skb; if (ret < 0) /* alloc buffer fail */ return ret; if (ret > 0) { /* need add frag */ - ret = hns3_add_frag(ring, desc, &skb, false); + ret = hns3_add_frag(ring, desc, false); if (ret) return ret; @@ -3072,7 +3071,7 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, ALIGN(ring->pull_len, sizeof(long))); } } else { - ret = hns3_add_frag(ring, desc, &skb, true); + ret = hns3_add_frag(ring, desc, true); if (ret) return ret; @@ -3090,8 +3089,6 @@ static int hns3_handle_rx_bd(struct hns3_enet_ring *ring, } skb_record_rx_queue(skb, ring->tqp->tqp_index); - *out_skb = skb; - return 0; } @@ -3100,7 +3097,6 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, { #define RCB_NOF_ALLOC_RX_BUFF_ONCE 16 int unused_count = hns3_desc_unused(ring); - struct sk_buff *skb = ring->skb; int recv_pkts = 0; int recv_bds = 0; int err, num; @@ -3123,27 +3119,19 @@ int hns3_clean_rx_ring(struct hns3_enet_ring *ring, int budget, } /* Poll one pkt */ - err = hns3_handle_rx_bd(ring, &skb); - if (unlikely(!skb)) /* This fault cannot be repaired */ + err = hns3_handle_rx_bd(ring); + /* Do not get FE for the packet or failed to alloc skb */ + if (unlikely(!ring->skb || err == -ENXIO)) { goto out; - - if (err == -ENXIO) { /* Do not get FE for the packet */ - goto out; - } else if (unlikely(err)) { /* Do jump the err */ - recv_bds += ring->pending_buf; - unused_count += ring->pending_buf; - ring->skb = NULL; - ring->pending_buf = 0; - continue; + } else if (likely(!err)) { + rx_fn(ring, ring->skb); + recv_pkts++; } - rx_fn(ring, skb); recv_bds += ring->pending_buf; unused_count += ring->pending_buf; ring->skb = NULL; ring->pending_buf = 0; - - recv_pkts++; } out: -- 2.7.4