Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1872058yba; Thu, 25 Apr 2019 07:06:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqybX4vQ+QKVueuNCoF18A92U8fdDFVhVWiIJHWBuiGBoDU7buj1ulCoFLqGs4oVE+/Gyo2k X-Received: by 2002:a17:902:12f:: with SMTP id 44mr2111953plb.193.1556201172009; Thu, 25 Apr 2019 07:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556201171; cv=none; d=google.com; s=arc-20160816; b=QhzuZ8NeaERaZdGdNNocxUe/EjYggN+3wiXZgKLyK9Z9Ki1V5Wab1st+dp/aB2GgC4 mQTrE6uhdJALmyF/sTeTLg8Z1EnEr3oIOKw4WlGC9gCcM7k5apjn5904IATpRi6avxee RBdr9sUvptW4Wf1FryMoOqp7EiWotdGiX9Gyk8hRvNEgwHbq5rz69UP+HVgrkYJjBk3d XCRDulVAonp0SkZEnqufT0t3fJo43SDx6cMCWwryXdj2G5BDlpBDyKMjbpw0hVmotl6k 5FKHJurm+ImLpi66CAgxu30ZFFZew7Dj610XTpY8rOwNf/NsKc1UGd3KA0SuxqgqL/9m GpTQ== 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=fnL+YmX/XbCiVsUWKe8Jx/Ih6xj+vx1CQQsBHSIi6EE=; b=MU1o/eLavqU+FY3svUCemxyTrCztuEWKa0MjL4fak4ZrahZPsYTjU6S9ZIrOV/YSfR je7o2qnezOga4teKLtueQO6DHyzNdqzzSAkhna6Q2DKCT64EJTB9s88xgh+yiSwVnBoT srg6gH1GU7n12E9bDwsb4He949i9J2/YFSltFvgos+UBLxD19mabY0YjXG7eoY6u3y4L 1Vjs6V2yekGrbuFGn7T2WMemAQawmFz+ZavtlMUt2BaszeYCipOuzRzYuNSSz6gshCZ5 gDW2ymkFoTFkQW9sJpDoGkgXQZ1fTW58ptKueRpqATvKxvexT9eZZxGWdqQcVRKyphhV 18DA== 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 s7si10151844pgr.287.2019.04.25.07.05.55; Thu, 25 Apr 2019 07:06:11 -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 S1731407AbfDYMoQ (ORCPT + 99 others); Thu, 25 Apr 2019 08:44:16 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:40706 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731332AbfDYMoM (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 2A9423DBC008B7D7ADE2; 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 02/11] net: hns3: fix for TX clean num when cleaning TX BD Date: Thu, 25 Apr 2019 20:42:46 +0800 Message-ID: <1556196175-65389-3-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 hns3_desc_unused() returns how many BD have been cleaned, but new buffer has not been attached to them. The register of HNS3_RING_RX_RING_FBDNUM_REG returns how many BD need allocating new buffer to or need to cleaned. So the remaining BD need to be clean is HNS3_RING_RX_RING_FBDNUM_REG - hns3_desc_unused(). Also, new buffer can not attach to the pending BD when the last BD is not handled, because memcpy has not been done on the first pending BD. This patch fixes by subtracting the pending BD num from unused_count after 'HNS3_RING_RX_RING_FBDNUM_REG - unused_count' is used to calculate the BD bum need to be clean. 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 9fdc87e..6695b94 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2874,7 +2874,7 @@ int hns3_clean_rx_ring( { #define RCB_NOF_ALLOC_RX_BUFF_ONCE 16 int recv_pkts, recv_bds, clean_count, err; - int unused_count = hns3_desc_unused(ring) - ring->pending_buf; + int unused_count = hns3_desc_unused(ring); struct sk_buff *skb = ring->skb; int num; @@ -2883,6 +2883,7 @@ int hns3_clean_rx_ring( recv_pkts = 0, recv_bds = 0, clean_count = 0; num -= unused_count; + unused_count -= ring->pending_buf; while (recv_pkts < budget && recv_bds < num) { /* Reuse or realloc buffers */ -- 2.7.4