* This device only supports one TX queue,
* and we're running multi-threaded...
*/
- if (PREDICT_FALSE(xd->lockp != 0))
+ if (PREDICT_FALSE(xd->dev_type != VNET_DPDK_DEV_VHOST_USER &&
+ xd->lockp != 0))
{
queue_id = queue_id % xd->tx_q_used;
while (__sync_lock_test_and_set (xd->lockp[queue_id], 1))
else if (xd->dev_type == VNET_DPDK_DEV_VHOST_USER)
{
u32 offset = 0;
+ if (xd->need_txlock) {
+ queue_id = 0;
+ while (__sync_lock_test_and_set (xd->lockp[queue_id], 1));
+ }
#if RTE_VERSION >= RTE_VERSION_NUM(2, 2, 0, 0)
- if (PREDICT_TRUE(xd->lockp == NULL)) {
+ else {
dpdk_device_and_queue_t * dq;
vec_foreach (dq, dm->devices_by_cpu[vm->cpu_index])
{
}
assert (dq);
offset = dq->queue_id * VIRTIO_QNUM;
- } else {
- offset = queue_id * VIRTIO_QNUM;
}
#endif
if (PREDICT_TRUE(tx_head > tx_tail))
n_retry = (rv == DPDK_TX_RING_SIZE - tx_tail) ? 1 : 0;
}
+
+ if (xd->need_txlock)
+ *xd->lockp[queue_id] = 0;
}
#if RTE_LIBRTE_KNI
else if (xd->dev_type == VNET_DPDK_DEV_KNI)
rv = 0;
}
- if (PREDICT_FALSE(xd->lockp != 0))
+ if (PREDICT_FALSE(xd->dev_type != VNET_DPDK_DEV_VHOST_USER &&
+ xd->lockp != 0))
*xd->lockp[queue_id] = 0;
if (PREDICT_FALSE(rv < 0))
dpdk_port_type_t port_type;
dpdk_efd_agent_t efd_agent;
+ u8 need_txlock; /* Used by VNET_DPDK_DEV_VHOST_USER */
} dpdk_device_t;
#define MAX_NELTS 32
CLIB_CACHE_LINE_BYTES);
memset ((void *) xd->lockp[q], 0, CLIB_CACHE_LINE_BYTES);
}
+ xd->need_txlock = 1;
}
void
clib_mem_free((void *) xd->lockp[q]);
vec_free(xd->lockp);
xd->lockp = 0;
+ xd->need_txlock = 0;
}
static clib_error_t *
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;
// 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++)
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);
*/
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;