[v3,6/8] net/hns3: fix HW ring not clear after queue stop
diff mbox series

Message ID 1603975917-28576-7-git-send-email-oulijun@huawei.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • hns3 misc updates
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Lijun Ou Oct. 29, 2020, 12:51 p.m. UTC
From: Chengchang Tang <tangchengchang@huawei.com>

Currently, the rx HW ring is not cleared after queue stop.
When there are packets remaining in the HW rings and the
queues have been stopped, if upper layer user calls the
rx_burst function at this time, an illegal memory access
will occur due to the sw rings has been released.

This patch fix this by reset the sw ring after disable the
queue.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Patch
diff mbox series

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 3386453..2988a4b 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -3805,6 +3805,19 @@  hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	return ret;
 }
 
+static void
+hns3_reset_sw_rxq(struct hns3_rx_queue *rxq)
+{
+	rxq->next_to_use = 0;
+	rxq->rx_rearm_start = 0;
+	rxq->rx_free_hold = 0;
+	rxq->rx_rearm_nb = 0;
+	rxq->pkt_first_seg = NULL;
+	rxq->pkt_last_seg = NULL;
+	memset(&rxq->rx_ring[0], 0, rxq->nb_rx_desc * sizeof(struct hns3_desc));
+	hns3_rxq_vec_setup(rxq);
+}
+
 int
 hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 {
@@ -3815,7 +3828,10 @@  hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 		return -ENOTSUP;
 
 	hns3_enable_rxq(rxq, false);
+
 	hns3_rx_queue_release_mbufs(rxq);
+
+	hns3_reset_sw_rxq(rxq);
 	dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
 
 	return 0;