summaryrefslogtreecommitdiffstats
path: root/vnet/vnet/devices/dpdk/vhost_user.c
diff options
context:
space:
mode:
authorShesha Sreenivasamurthy <shesha@cisco.com>2016-02-19 13:36:53 -0800
committerGerrit Code Review <gerrit@fd.io>2016-02-24 12:05:20 +0000
commit9ad5adcf08f30da0140cce21fae64df3087d8207 (patch)
tree0e1957b852c7cb395141478329b6063d9040ca07 /vnet/vnet/devices/dpdk/vhost_user.c
parenteef4d99bcd0ad868145af76ca1ad2595ecc3ad19 (diff)
Handle dynamic enable/disable VHOST_USER interface
If number of Qs enabled by the guest is less than number of Qs exported to guest, then all threads route packet to Q0 with the assumption that guest is not interested in performance. If all Qs are enabled, each thread queues packet in their own TX-Q of the VHOST_USER interface, boosting performance. Change-Id: Ic24bb8c0505b11c7513aeecd21c9ec5da5f90138 Signed-off-by: Shesha Sreenivasamurthy <shesha@cisco.com>
Diffstat (limited to 'vnet/vnet/devices/dpdk/vhost_user.c')
-rw-r--r--vnet/vnet/devices/dpdk/vhost_user.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/vnet/vnet/devices/dpdk/vhost_user.c b/vnet/vnet/devices/dpdk/vhost_user.c
index 0efbbef3259..b6b31bafb85 100644
--- a/vnet/vnet/devices/dpdk/vhost_user.c
+++ b/vnet/vnet/devices/dpdk/vhost_user.c
@@ -198,7 +198,7 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 *hwaddr)
int num_qpairs = 1;
#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
- num_qpairs = dm->use_rss < 1 ? 1 : dm->use_rss;
+ num_qpairs = dm->use_rss < 1 ? 1 : tm->n_vlib_mains;
#endif
dpdk_device_t * xd = NULL;
@@ -242,9 +242,7 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 *hwaddr)
// reset lockp
dpdk_device_lock_free(xd);
-
- if (xd->tx_q_used < tm->n_vlib_mains)
- dpdk_device_lock_init(xd);
+ dpdk_device_lock_init(xd);
// reset tx vectors
for (j = 0; j < tm->n_vlib_mains; j++)
@@ -301,8 +299,7 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 *hwaddr)
xd->vu_vhost_dev.virtqueue[j]->backend = -1;
}
- if (xd->tx_q_used < dm->input_cpu_count)
- dpdk_device_lock_init(xd);
+ dpdk_device_lock_init(xd);
DBG_SOCK("tm->n_vlib_mains: %d. TX %d, RX: %d, num_qpairs: %d, Lock: %p",
tm->n_vlib_mains, xd->tx_q_used, xd->rx_q_used, num_qpairs, xd->lockp);
@@ -706,6 +703,17 @@ int dpdk_vhost_user_set_vring_enable(u32 hw_if_index, u8 idx, int enable)
*/
vui->vrings[idx].enabled = enable; /* Save local copy */
+ int numqs = xd->vu_vhost_dev.virt_qp_nb * VIRTIO_QNUM;
+ while (numqs--) {
+ if (! vui->vrings[numqs].enabled)
+ break;
+ }
+
+ if (numqs == -1) /* All Qs are enabled */
+ xd->need_txlock = 0;
+ else
+ xd->need_txlock = 1;
+
vq = xd->vu_vhost_dev.virtqueue[idx];
if (vq->desc && vq->avail && vq->used)
xd->vu_vhost_dev.virtqueue[idx]->enabled = enable;