#include "rte_eth_vhost.h"
-static int vhost_logtype;
+RTE_LOG_REGISTER(vhost_logtype, pmd.net.vhost, NOTICE);
#define VHOST_LOG(level, ...) \
rte_log(RTE_LOG_ ## level, vhost_logtype, __VA_ARGS__)
#define ETH_VHOST_IOMMU_SUPPORT "iommu-support"
#define ETH_VHOST_POSTCOPY_SUPPORT "postcopy-support"
#define ETH_VHOST_VIRTIO_NET_F_HOST_TSO "tso"
+#define ETH_VHOST_LINEAR_BUF "linear-buffer"
+#define ETH_VHOST_EXT_BUF "ext-buffer"
#define VHOST_MAX_PKT_BURST 32
static const char *valid_arguments[] = {
ETH_VHOST_IOMMU_SUPPORT,
ETH_VHOST_POSTCOPY_SUPPORT,
ETH_VHOST_VIRTIO_NET_F_HOST_TSO,
+ ETH_VHOST_LINEAR_BUF,
+ ETH_VHOST_EXT_BUF,
NULL
};
struct rte_mempool *mb_pool;
uint16_t port;
uint16_t virtqueue_id;
+ bool intr_en;
struct vhost_stats stats;
};
rte_vhost_enable_guest_notification(vq->vid, (qid << 1) + 1, 1);
rte_wmb();
+ vq->intr_en = true;
+
return ret;
}
rte_vhost_enable_guest_notification(vq->vid, (qid << 1) + 1, 0);
rte_wmb();
+ vq->intr_en = false;
+
return 0;
}
_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL);
}
+static int
+vring_conf_update(int vid, struct rte_eth_dev *eth_dev, uint16_t vring_id)
+{
+ struct rte_eth_conf *dev_conf = ð_dev->data->dev_conf;
+ struct pmd_internal *internal = eth_dev->data->dev_private;
+ struct rte_vhost_vring vring;
+ struct vhost_queue *vq;
+ int rx_idx = vring_id % 2 ? (vring_id - 1) >> 1 : -1;
+ int ret = 0;
+
+ /*
+ * The vring kickfd may be changed after the new device notification.
+ * Update it when the vring state is updated.
+ */
+ if (rx_idx >= 0 && rx_idx < eth_dev->data->nb_rx_queues &&
+ rte_atomic32_read(&internal->dev_attached) &&
+ rte_atomic32_read(&internal->started) &&
+ dev_conf->intr_conf.rxq) {
+ vq = eth_dev->data->rx_queues[rx_idx];
+ ret = rte_vhost_get_vhost_vring(vid, vring_id, &vring);
+ if (!ret) {
+ if (vring.kickfd !=
+ eth_dev->intr_handle->efds[rx_idx]) {
+ VHOST_LOG(INFO,
+ "kickfd for rxq-%d was changed.\n",
+ rx_idx);
+ eth_dev->intr_handle->efds[rx_idx] =
+ vring.kickfd;
+ }
+
+ rte_vhost_enable_guest_notification(vid, vring_id,
+ vq->intr_en);
+ rte_wmb();
+ }
+ }
+
+ return ret;
+}
+
static int
vring_state_changed(int vid, uint16_t vring, int enable)
{
eth_dev = list->eth_dev;
/* won't be NULL */
state = vring_states[eth_dev->data->port_id];
+
+ if (enable && vring_conf_update(vid, eth_dev, vring))
+ VHOST_LOG(INFO, "Failed to update vring-%d configuration.\n",
+ (int)vring);
+
rte_spinlock_lock(&state->lock);
if (state->cur[vring] == enable) {
rte_spinlock_unlock(&state->lock);
eth_dev_stop(dev);
- rte_vhost_driver_unregister(internal->iface_name);
-
list = find_internal_resource(internal->iface_name);
- if (!list)
- return;
-
- pthread_mutex_lock(&internal_list_lock);
- TAILQ_REMOVE(&internal_list, list, next);
- pthread_mutex_unlock(&internal_list_lock);
- rte_free(list);
+ if (list) {
+ rte_vhost_driver_unregister(internal->iface_name);
+ pthread_mutex_lock(&internal_list_lock);
+ TAILQ_REMOVE(&internal_list, list, next);
+ pthread_mutex_unlock(&internal_list_lock);
+ rte_free(list);
+ }
if (dev->data->rx_queues)
for (i = 0; i < dev->data->nb_rx_queues; i++)
internal->disable_flags = disable_flags;
data->dev_link = pmd_link;
data->dev_flags = RTE_ETH_DEV_INTR_LSC | RTE_ETH_DEV_CLOSE_REMOVE;
+ data->promiscuous = 1;
+ data->all_multicast = 1;
eth_dev->dev_ops = &ops;
int iommu_support = 0;
int postcopy_support = 0;
int tso = 0;
+ int linear_buf = 0;
+ int ext_buf = 0;
struct rte_eth_dev *eth_dev;
const char *name = rte_vdev_device_name(dev);
}
}
+ if (rte_kvargs_count(kvlist, ETH_VHOST_LINEAR_BUF) == 1) {
+ ret = rte_kvargs_process(kvlist,
+ ETH_VHOST_LINEAR_BUF,
+ &open_int, &linear_buf);
+ if (ret < 0)
+ goto out_free;
+
+ if (linear_buf == 1)
+ flags |= RTE_VHOST_USER_LINEARBUF_SUPPORT;
+ }
+
+ if (rte_kvargs_count(kvlist, ETH_VHOST_EXT_BUF) == 1) {
+ ret = rte_kvargs_process(kvlist,
+ ETH_VHOST_EXT_BUF,
+ &open_int, &ext_buf);
+ if (ret < 0)
+ goto out_free;
+
+ if (ext_buf == 1)
+ flags |= RTE_VHOST_USER_EXTBUF_SUPPORT;
+ }
+
if (dev->device.numa_node == SOCKET_ID_ANY)
dev->device.numa_node = rte_socket_id();
"dequeue-zero-copy=<0|1> "
"iommu-support=<0|1> "
"postcopy-support=<0|1> "
- "tso=<0|1>");
-
-RTE_INIT(vhost_init_log)
-{
- vhost_logtype = rte_log_register("pmd.net.vhost");
- if (vhost_logtype >= 0)
- rte_log_set_level(vhost_logtype, RTE_LOG_NOTICE);
-}
+ "tso=<0|1> "
+ "linear-buffer=<0|1> "
+ "ext-buffer=<0|1>");