Skip to contentSkip to conversation

net/iavf: fix queue start exception handle

PATCH Applied Qiming Yang 2 participants 2 messages May 19, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/iavf: fix queue start exception handle

When queue start fail, started queues should be cleared.

Fixes 69dd4c3d0898 ("net/avf: enable queue and device")
---
 drivers/net/iavf/iavf_ethdev.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/net/iavf/iavf_ethdev.c +20 -10
index 79397f15e5..69472869e3 100644
@@ -896,28 +896,38 @@ iavf_start_queues(struct rte_eth_dev *dev)
 	struct iavf_rx_queue *rxq;
 	struct iavf_tx_queue *txq;
 	int i;
+	uint16_t nb_txq, nb_rxq;
 
-	for (i = 0; i < dev->data->nb_tx_queues; i++) {
-		txq = dev->data->tx_queues[i];
+	for (nb_txq = 0; nb_txq < dev->data->nb_tx_queues; nb_txq++) {
+		txq = dev->data->tx_queues[nb_txq];
 		if (txq->tx_deferred_start)
 			continue;
-		if (iavf_dev_tx_queue_start(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
-			return -1;
+		if (iavf_dev_tx_queue_start(dev, nb_txq) != 0) {
+			PMD_DRV_LOG(ERR, "Fail to start tx queue %u", nb_txq);
+			goto tx_err;
 		}
 	}
 
-	for (i = 0; i < dev->data->nb_rx_queues; i++) {
-		rxq = dev->data->rx_queues[i];
+	for (nb_rxq = 0; nb_rxq < dev->data->nb_rx_queues; nb_rxq++) {
+		rxq = dev->data->rx_queues[nb_rxq];
 		if (rxq->rx_deferred_start)
 			continue;
-		if (iavf_dev_rx_queue_start(dev, i) != 0) {
-			PMD_DRV_LOG(ERR, "Fail to start queue %u", i);
-			return -1;
+		if (iavf_dev_rx_queue_start(dev, nb_rxq) != 0) {
+			PMD_DRV_LOG(ERR, "Fail to start rx queue %u", nb_rxq);
+			goto rx_err;
 		}
 	}
 
 	return 0;
+
+rx_err:
+	for (i = 0; i < nb_rxq; i++)
+		iavf_dev_rx_queue_stop(dev, i);
+tx_err:
+	for (i = 0; i < nb_txq; i++)
+		iavf_dev_tx_queue_stop(dev, i);
+
+	return -1;
 }
 
 static int
Signature · 1 line
2.25.1
Acked-by on v1 1/1 Applied
#1 lore raw
Quoted 8 lines

-----Original Message-----
From: Qiming Yang <[email protected]>
Sent: Thursday, May 19, 2022 1:02 PM
To: [email protected]; Xing, Beilei <[email protected]>
Cc: Yang, Qiming <[email protected]>; [email protected]
Subject: [PATCH] net/iavf: fix queue start exception handle

exception handling

Quoted 2 lines

When queue start fail, started queues should be cleared.

To avoid confuse, better mention this is at a dev_start scenario,
because in a queue_start scenario, if failed we don't need to stop already started queues.

So slightly reword to below:

If any queue start fail during dev_start, all started queues should be stopped.

Quoted 5 lines
Fixes 69dd4c3d0898 ("net/avf: enable queue and device")

Applied to dpdk-next-net-intel.

Thanks
Qi