]> git.droids-corp.org - dpdk.git/commitdiff
net/hns3: fix mbuf free on Tx done cleanup
authorChengwen Feng <fengchengwen@huawei.com>
Thu, 5 May 2022 12:27:04 +0000 (20:27 +0800)
committerFerruh Yigit <ferruh.yigit@xilinx.com>
Thu, 12 May 2022 08:28:54 +0000 (10:28 +0200)
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 <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
drivers/net/hns3/hns3_rxtx.c

index a28de06dfdf0d436dca183a7cd31bd4206219ee4..0c91e4721ef23dc8642af00c3d47dc65cdd13ac3 100644 (file)
@@ -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