[ovs-dev] [PATCH RFC v2 2/6] dpif-netdev: Allow configuration of number of tx queues.

Ilya Maximets i.maximets at samsung.com
Tue May 24 13:34:05 UTC 2016


Currently number of tx queues is not configurable.
Fix that by introducing of new option for PMD interfaces: 'n_txq',
which specifies the maximum number of tx queues to be created for
this interface.

Example:
	ovs-vsctl set Interface dpdk0 options:n_txq=64

Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
---
 INSTALL.DPDK.md       | 11 ++++++++---
 lib/netdev-dpdk.c     | 26 +++++++++++++++++++-------
 lib/netdev-provider.h |  2 +-
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/INSTALL.DPDK.md b/INSTALL.DPDK.md
index 93f92e4..630c68d 100644
--- a/INSTALL.DPDK.md
+++ b/INSTALL.DPDK.md
@@ -355,11 +355,14 @@ Performance Tuning:
 	ovs-appctl dpif-netdev/pmd-stats-show
 	```
 
-  3. DPDK port Rx Queues
+  3. DPDK port Queues
 
-	`ovs-vsctl set Interface <DPDK interface> options:n_rxq=<integer>`
+	```
+	ovs-vsctl set Interface <DPDK interface> options:n_rxq=<integer>
+	ovs-vsctl set Interface <DPDK interface> options:n_txq=<integer>
+	```
 
-	The command above sets the number of rx queues for DPDK interface.
+	The commands above sets the number of rx and tx queues for DPDK interface.
 	The rx queues are assigned to pmd threads on the same NUMA node in a
 	round-robin fashion.  For more information, please refer to the
 	Open_vSwitch TABLE section in
@@ -638,7 +641,9 @@ Follow the steps below to attach vhost-user port(s) to a VM.
 
    ```
    ovs-vsctl set Interface vhost-user-2 options:n_rxq=<requested queues>
+   ovs-vsctl set Interface vhost-user-2 options:n_txq=<requested queues>
    ```
+   Note: `n_rxq` should be equal to `n_txq`.
 
    QEMU needs to be configured as well.
    The $q below should match the queues requested in OVS (if $q is more,
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 66e33df..e015f6f 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -345,8 +345,9 @@ struct netdev_dpdk {
     struct rte_eth_link link;
     int link_reset_cnt;
 
-    /* The user might request more txqs than the NIC has.  We remap those
-     * ('up.n_txq') on these ('real_n_txq').
+    /* dpif-netdev might request more txqs than the NIC has, also, number of tx
+     * queues may be changed via database ('options:n_txq').
+     * We remap requested by dpif-netdev number on 'real_n_txq'.
      * If the numbers match, 'txq_needs_locking' is false, otherwise it is
      * true and we will take a spinlock on transmission */
     int real_n_txq;
@@ -954,14 +955,27 @@ static int
 netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args)
 {
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
-    int new_n_rxq;
+    int new_n_rxq, new_n_txq;
+    bool reconfigure_needed = false;
 
     ovs_mutex_lock(&dev->mutex);
+
     new_n_rxq = MAX(smap_get_int(args, "n_rxq", dev->requested_n_rxq), 1);
     if (new_n_rxq != dev->requested_n_rxq) {
         dev->requested_n_rxq = new_n_rxq;
+        reconfigure_needed = true;
+    }
+
+    new_n_txq = MAX(smap_get_int(args, "n_txq", dev->requested_n_txq), 1);
+    if (new_n_txq != dev->requested_n_txq) {
+        dev->requested_n_txq = new_n_txq;
+        reconfigure_needed = true;
+    }
+
+    if (reconfigure_needed) {
         netdev_request_reconfigure(netdev);
     }
+
     ovs_mutex_unlock(&dev->mutex);
 
     return 0;
@@ -2670,12 +2684,10 @@ netdev_dpdk_reconfigure(struct netdev *netdev)
 
     rte_free(dev->tx_q);
     err = dpdk_eth_dev_init(dev);
+    dev->txq_needs_locking = dev->real_n_txq < ovs_numa_get_n_cores() + 1;
     netdev_dpdk_alloc_txq(dev, dev->real_n_txq);
 
-    dev->txq_needs_locking = dev->real_n_txq != netdev->n_txq;
-
 out:
-
     ovs_mutex_unlock(&dev->mutex);
     ovs_mutex_unlock(&dpdk_mutex);
 
@@ -2710,7 +2722,7 @@ netdev_dpdk_vhost_cuse_reconfigure(struct netdev *netdev)
     netdev->n_txq = dev->requested_n_txq;
     dev->real_n_txq = 1;
     netdev->n_rxq = 1;
-    dev->txq_needs_locking = dev->real_n_txq != netdev->n_txq;
+    dev->txq_needs_locking = true;
 
     ovs_mutex_unlock(&dev->mutex);
     ovs_mutex_unlock(&dpdk_mutex);
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 5da377f..cbc1410 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -54,7 +54,7 @@ struct netdev {
     uint64_t change_seq;
 
     /* A netdev provider might be unable to change some of the device's
-     * parameter (n_rxq, mtu) when the device is in use.  In this case
+     * parameter (n_rxq, n_txq,  mtu) when the device is in use.  In this case
      * the provider can notify the upper layer by calling
      * netdev_request_reconfigure().  The upper layer will react by stopping
      * the operations on the device and calling netdev_reconfigure() to allow
-- 
2.5.0




More information about the dev mailing list