From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0263A0509; Wed, 6 Apr 2022 11:23:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7541F4285C; Wed, 6 Apr 2022 11:23:21 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id F36AB427EC for ; Wed, 6 Apr 2022 11:23:18 +0200 (CEST) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KYJqG6G4bzBs1w; Wed, 6 Apr 2022 17:19:06 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 6 Apr 2022 17:23:17 +0800 From: "Min Hu (Connor)" To: CC: , Subject: [PATCH 4/7] net/hns3: fix more mbufs are freed when Tx done cleanup Date: Wed, 6 Apr 2022 17:22:37 +0800 Message-ID: <20220406092240.52900-5-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220406092240.52900-1-humin29@huawei.com> References: <20220406092240.52900-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Chengwen Feng Currently, the hns3 PMD may free more mbufs than free_cnt parameter, this is an incorrect implementation. This patch fixes it. Fixes: 0b77e8f3d364 ("net/hns3: optimize Tx performance") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_rxtx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index a28de06dfd..0c91e4721e 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -4595,7 +4595,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) static int hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) { - uint16_t round_free_cnt; + uint16_t round_cnt; uint32_t idx; if (free_cnt == 0 || free_cnt > txq->nb_tx_desc) @@ -4604,13 +4604,13 @@ hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) if (txq->tx_rs_thresh == 0) return 0; - round_free_cnt = roundup(free_cnt, txq->tx_rs_thresh); - for (idx = 0; idx < round_free_cnt; idx += txq->tx_rs_thresh) { + round_cnt = rounddown(free_cnt, txq->tx_rs_thresh); + for (idx = 0; idx < round_cnt; idx += txq->tx_rs_thresh) { if (hns3_tx_free_useless_buffer(txq) != 0) break; } - return RTE_MIN(idx, free_cnt); + return idx; } int -- 2.33.0