netdev-dpdk: Restore txq/rxq number if initialization fails.
authorDaniele Di Proietto <diproiettod@vmware.com>
Thu, 16 Jul 2015 18:48:23 +0000 (19:48 +0100)
committerEthan Jackson <ethan@nicira.com>
Tue, 21 Jul 2015 19:01:37 +0000 (12:01 -0700)
netdev_dpdk_set_multiq() should not set the number of configured rxq
and txq if the driver initialization fails (meaning that the driver
failed to setup the queues).  Otherwise, on a subsequent call to
netdev_dpdk_set_multiq(), the code may believe that the queues have
already been setup and there's no work to be done.

This commit fixes the problem by restoring the old values if
dpdk_eth_dev_init() fails.

Reported-by: Ian Stokes <ian.stokes@intel.com>
Tested-by: Ian Stokes <ian.stokes@intel.com>
Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
lib/netdev-dpdk.c

index 8b843db..5ae805e 100644 (file)
@@ -743,6 +743,7 @@ netdev_dpdk_set_multiq(struct netdev *netdev_, unsigned int n_txq,
 {
     struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
     int err = 0;
+    int old_rxq, old_txq;
 
     if (netdev->up.n_txq == n_txq && netdev->up.n_rxq == n_rxq) {
         return err;
@@ -753,12 +754,20 @@ netdev_dpdk_set_multiq(struct netdev *netdev_, unsigned int n_txq,
 
     rte_eth_dev_stop(netdev->port_id);
 
+    old_txq = netdev->up.n_txq;
+    old_rxq = netdev->up.n_rxq;
     netdev->up.n_txq = n_txq;
     netdev->up.n_rxq = n_rxq;
 
     rte_free(netdev->tx_q);
     err = dpdk_eth_dev_init(netdev);
     netdev_dpdk_alloc_txq(netdev, netdev->real_n_txq);
+    if (err) {
+        /* If there has been an error, it means that the requested queues
+         * have not been created.  Restore the old numbers. */
+        netdev->up.n_txq = old_txq;
+        netdev->up.n_rxq = old_rxq;
+    }
 
     netdev->txq_needs_locking = netdev->real_n_txq != netdev->up.n_txq;