]> git.droids-corp.org - dpdk.git/commitdiff
net/iavf: fix queue start exception handling
authorQiming Yang <qiming.yang@intel.com>
Thu, 19 May 2022 05:01:56 +0000 (05:01 +0000)
committerQi Zhang <qi.z.zhang@intel.com>
Tue, 24 May 2022 02:53:37 +0000 (04:53 +0200)
If any queue start fail during dev_start, all started queues
should be stopped.

Fixes: 69dd4c3d0898 ("net/avf: enable queue and device")
Cc: stable@dpdk.org
Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/iavf/iavf_ethdev.c

index 198d8299af722730305b4fa6f1f7a9e550fe5262..315ab15aad1d9beffe4c38df859def899ebef81f 100644 (file)
@@ -926,28 +926,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