#define NIC_PORT_TX_Q_SIZE 2048 /* Size of Physical NIC TX Queue, Max (n+32<=4096)*/
#define OVS_VHOST_MAX_QUEUE_NUM 1024 /* Maximum number of vHost TX queues. */
+#define OVS_VHOST_QUEUE_MAP_UNKNOWN (-1) /* Mapping not initialized. */
+#define OVS_VHOST_QUEUE_DISABLED (-2) /* Queue was disabled by guest and not
+ * yet mapped to another queue. */
static char *cuse_dev_name = NULL; /* Character device cuse_dev_name. */
static char *vhost_sock_dir = NULL; /* Location of vhost-user sockets */
}
/* Initialize map for vhost devices. */
- netdev->tx_q[i].map = -1;
+ netdev->tx_q[i].map = OVS_VHOST_QUEUE_MAP_UNKNOWN;
rte_spinlock_init(&netdev->tx_q[i].tx_lock);
}
}
qid = vhost_dev->tx_q[qid % vhost_dev->real_n_txq].map;
- if (OVS_UNLIKELY(!is_vhost_running(virtio_dev) || qid == -1)) {
+ if (OVS_UNLIKELY(!is_vhost_running(virtio_dev) || qid < 0)) {
rte_spinlock_lock(&vhost_dev->stats_lock);
vhost_dev->stats.tx_dropped+= cnt;
rte_spinlock_unlock(&vhost_dev->stats_lock);
}
if (n_enabled == 0 && total_txqs != 0) {
- enabled_queues[0] = -1;
+ enabled_queues[0] = OVS_VHOST_QUEUE_DISABLED;
n_enabled = 1;
}
netdev->real_n_rxq = qp_num;
netdev->real_n_txq = qp_num;
netdev->txq_needs_locking = true;
+ /* Enable TX queue 0 by default if it wasn't disabled. */
+ if (netdev->tx_q[0].map == OVS_VHOST_QUEUE_MAP_UNKNOWN) {
+ netdev->tx_q[0].map = 0;
+ }
netdev_dpdk_remap_txqs(netdev);
return 0;
}
+/* Clears mapping for all available queues of vhost interface. */
+static void
+netdev_dpdk_txq_map_clear(struct netdev_dpdk *dev)
+ OVS_REQUIRES(dev->mutex)
+{
+ int i;
+
+ for (i = 0; i < dev->real_n_txq; i++) {
+ dev->tx_q[i].map = OVS_VHOST_QUEUE_MAP_UNKNOWN;
+ }
+}
+
/*
* Remove a virtio-net device from the specific vhost port. Use dev->remove
* flag to stop any more packets from being sent or received to/from a VM and
ovs_mutex_lock(&vhost_dev->mutex);
dev->flags &= ~VIRTIO_DEV_RUNNING;
ovsrcu_set(&vhost_dev->virtio_dev, NULL);
+ netdev_dpdk_txq_map_clear(vhost_dev);
exists = true;
ovs_mutex_unlock(&vhost_dev->mutex);
break;
if (enable) {
vhost_dev->tx_q[qid].map = qid;
} else {
- vhost_dev->tx_q[qid].map = -1;
+ vhost_dev->tx_q[qid].map = OVS_VHOST_QUEUE_DISABLED;
}
netdev_dpdk_remap_txqs(vhost_dev);
exists = true;