[dpdk-dev] [TEST] lib/librte_pmd_vhost: Add vhost pmd

Tetsuya Mukawa mukawa at igel.co.jp
Thu Nov 6 12:29:25 CET 2014


The vhost pmd is a poll mode driver using librte_vhost library. It is
almost similar to a relation between librte_ring and ring pmd.

Here is a command example of QEMU(above 2.1) to communicate with the vhost pmd.
qemu-system-x86_64 -M pc-1.0 -cpu host -m 4096 \
	-object memory-backend-file,id=mem,size=4096M,mem-path=/mnt/huge,share=on
	-numa node,memdev=mem \
	-chardev socket,id=chr0,path=/tmp/virtq0,server \
	-netdev vhost-user,id=net0,chardev=chr0 \
	-device virtio-net-pci,netdev=net0

Also testpmd example is here.
testpmd -c f -n 1 -m 1024 --vdev 'eth_vhost0,iface=/tmp/virtq0' -- -i

You can invoke QEMU and testpmd with any order. But if you invoke QEMU
after testpmd, please set '-m' option for qemu not to use all hugepage
memory.

Signed-off-by: Tetsuya Mukawa <mukawa at igel.co.jp>
---
 config/common_linuxapp               |   5 +
 lib/Makefile                         |   1 +
 lib/librte_pmd_vhost/Makefile        |  57 ++++
 lib/librte_pmd_vhost/rte_eth_vhost.c | 487 +++++++++++++++++++++++++++++++++++
 lib/librte_pmd_vhost/rte_eth_vhost.h |  55 ++++
 mk/rte.app.mk                        |   4 +
 6 files changed, 609 insertions(+)
 create mode 100644 lib/librte_pmd_vhost/Makefile
 create mode 100644 lib/librte_pmd_vhost/rte_eth_vhost.c
 create mode 100644 lib/librte_pmd_vhost/rte_eth_vhost.h

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 8be79c3..71a54fc 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -243,6 +243,11 @@ CONFIG_RTE_PMD_RING_MAX_TX_RINGS=16
 CONFIG_RTE_LIBRTE_PMD_PCAP=n
 
 #
+# Compile burst-oriented VHOST PMD driver
+#
+CONFIG_RTE_LIBRTE_PMD_VHOST=n
+
+#
 # Compile link bonding PMD library
 #
 CONFIG_RTE_LIBRTE_PMD_BOND=y
diff --git a/lib/Makefile b/lib/Makefile
index e3237ff..4f314a7 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += librte_pmd_pcap
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += librte_pmd_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += librte_pmd_virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += librte_pmd_vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += librte_pmd_xenvirt
diff --git a/lib/librte_pmd_vhost/Makefile b/lib/librte_pmd_vhost/Makefile
new file mode 100644
index 0000000..6c85d55
--- /dev/null
+++ b/lib/librte_pmd_vhost/Makefile
@@ -0,0 +1,57 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_vhost.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += rte_eth_vhost.c
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_eth_vhost.h
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += lib/librte_eal lib/librte_vhost
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += lib/librte_mbuf lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += lib/librte_kvargs
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_pmd_vhost/rte_eth_vhost.c b/lib/librte_pmd_vhost/rte_eth_vhost.c
new file mode 100644
index 0000000..9e5f622
--- /dev/null
+++ b/lib/librte_pmd_vhost/rte_eth_vhost.c
@@ -0,0 +1,487 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.
+ *
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+
+#include <rte_virtio_net.h>
+#include <rte_mbuf.h>
+#include <rte_ethdev.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_dev.h>
+#include <rte_kvargs.h>
+
+#include "rte_eth_vhost.h"
+
+#define VHOST_PORT_START_TIMEOUT	10
+
+struct vhost_queue {
+	struct virtio_net *device;
+	struct rte_mempool *mb_pool;
+	rte_atomic64_t rx_pkts;
+	rte_atomic64_t tx_pkts;
+	rte_atomic64_t err_pkts;
+};
+
+struct pmd_internals {
+	struct vhost_driver *driver;
+	unsigned nb_rx_queues;
+	unsigned nb_tx_queues;
+
+	struct vhost_queue rx_vhost_queues[RTE_PMD_RING_MAX_RX_RINGS];
+	struct vhost_queue tx_vhost_queues[RTE_PMD_RING_MAX_TX_RINGS];
+};
+
+static struct ether_addr eth_addr = {
+	.addr_bytes ={
+		0x56 /* V */,
+		0x48 /* H */,
+		0x4F /* O */,
+		0x53 /* S */,
+		0x54 /* T */,
+		0x00
+	}
+};
+static const char *drivername = "VHOST PMD";
+static struct rte_eth_link pmd_link = {
+		.link_speed = 10000,
+		.link_duplex = ETH_LINK_FULL_DUPLEX,
+		.link_status = 0
+};
+
+#define ETH_VHOST_IFACE_ARG    "iface"
+
+static const char *valid_arguments[] = {
+	ETH_VHOST_IFACE_ARG,
+	NULL
+};
+
+static uint16_t
+eth_vhost_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+	struct vhost_queue *r = q;
+	uint16_t nb_rx;
+
+	/* connection not established yet */
+	if (r->device == NULL)
+		return 0;
+
+	nb_rx = (uint16_t)rte_vhost_dequeue_burst(r->device,
+			VIRTIO_TXQ, r->mb_pool, bufs, nb_bufs);
+
+	rte_atomic64_add(&(r->rx_pkts), nb_rx);
+
+	return nb_rx;
+}
+
+static uint16_t
+eth_vhost_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
+{
+	struct vhost_queue *r = q;
+	uint16_t i, nb_tx;
+
+	/* connection not established yet */
+	if (r->device == NULL)
+		return 0;
+
+	nb_tx = (uint16_t)rte_vhost_enqueue_burst(r->device,
+			VIRTIO_RXQ, bufs, nb_bufs);
+
+	rte_atomic64_add(&(r->tx_pkts), nb_tx);
+	rte_atomic64_add(&(r->err_pkts), nb_bufs - nb_tx);
+
+	for (i = 0; likely(i < nb_tx); i++)
+		rte_pktmbuf_free(bufs[i]);
+
+	return nb_tx;
+}
+
+static int
+eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { return 0; }
+
+static int
+eth_dev_start(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *internal = dev->data->dev_private;
+
+	if (rte_vhost_driver_session_start(internal->driver) < 0)
+		return -1;
+
+	return 0;
+}
+
+static void
+eth_dev_stop(struct rte_eth_dev *dev)
+{
+	struct pmd_internals *internal = dev->data->dev_private;
+
+	/* stop event thread and wait until connection is closed */
+	rte_vhost_driver_session_stop(internal->driver);
+
+	return;
+}
+
+static int
+eth_rx_queue_setup(struct rte_eth_dev *dev,uint16_t rx_queue_id,
+				    uint16_t nb_rx_desc __rte_unused,
+				    unsigned int socket_id __rte_unused,
+				    const struct rte_eth_rxconf *rx_conf __rte_unused,
+				    struct rte_mempool *mb_pool)
+{
+	struct pmd_internals *internals = dev->data->dev_private;
+	internals->rx_vhost_queues[rx_queue_id].mb_pool = mb_pool;
+	dev->data->rx_queues[rx_queue_id] = &internals->rx_vhost_queues[rx_queue_id];
+	return 0;
+}
+
+static int
+eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
+				    uint16_t nb_tx_desc __rte_unused,
+				    unsigned int socket_id __rte_unused,
+				    const struct rte_eth_txconf *tx_conf __rte_unused)
+{
+	struct pmd_internals *internals = dev->data->dev_private;
+	dev->data->tx_queues[tx_queue_id] = &internals->tx_vhost_queues[tx_queue_id];
+	return 0;
+}
+
+
+static void
+eth_dev_info(struct rte_eth_dev *dev,
+		struct rte_eth_dev_info *dev_info)
+{
+	struct pmd_internals *internals = dev->data->dev_private;
+	dev_info->driver_name = drivername;
+	dev_info->max_mac_addrs = 1;
+	dev_info->max_rx_pktlen = (uint32_t)-1;
+	dev_info->max_rx_queues = (uint16_t)internals->nb_rx_queues;
+	dev_info->max_tx_queues = (uint16_t)internals->nb_tx_queues;
+	dev_info->min_rx_bufsize = 0;
+	dev_info->pci_dev = NULL;
+}
+
+static void
+eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
+{
+	unsigned i;
+	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
+	const struct pmd_internals *internal = dev->data->dev_private;
+
+	memset(igb_stats, 0, sizeof(*igb_stats));
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+			i < internal->nb_rx_queues; i++) {
+		igb_stats->q_ipackets[i] = internal->rx_vhost_queues[i].rx_pkts.cnt;
+		rx_total += igb_stats->q_ipackets[i];
+	}
+
+	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
+			i < internal->nb_tx_queues; i++) {
+		igb_stats->q_opackets[i] = internal->tx_vhost_queues[i].tx_pkts.cnt;
+		igb_stats->q_errors[i] = internal->tx_vhost_queues[i].err_pkts.cnt;
+		tx_total += igb_stats->q_opackets[i];
+		tx_err_total += igb_stats->q_errors[i];
+	}
+
+	igb_stats->ipackets = rx_total;
+	igb_stats->opackets = tx_total;
+	igb_stats->oerrors = tx_err_total;
+}
+
+static void
+eth_stats_reset(struct rte_eth_dev *dev)
+{
+	unsigned i;
+	struct pmd_internals *internal = dev->data->dev_private;
+	for (i = 0; i < internal->nb_rx_queues; i++)
+		internal->rx_vhost_queues[i].rx_pkts.cnt = 0;
+	for (i = 0; i < internal->nb_tx_queues; i++) {
+		internal->tx_vhost_queues[i].tx_pkts.cnt = 0;
+		internal->tx_vhost_queues[i].err_pkts.cnt = 0;
+	}
+}
+
+static void
+eth_queue_release(void *q __rte_unused) { ; }
+static int
+eth_link_update(struct rte_eth_dev *dev __rte_unused,
+		int wait_to_complete __rte_unused)
+{
+#if 0
+	struct pmd_internals *internal = dev->data->dev_private;
+	unsigned i;
+
+	for (i = 0; i < internal->nb_rx_queues; i++)
+		if (internal->rx_vhost_queues[i].device == NULL)
+			goto not_yet;
+
+	for (i = 0; i < internal->nb_tx_queues; i++)
+		if (internal->tx_vhost_queues[i].device == NULL)
+			goto not_yet;
+
+	//dev->data->dev_link.link_status = 1;
+	return 0;
+
+not_yet:
+	//dev->data->dev_link.link_status = 0;
+#endif
+	return 0;
+}
+
+static struct eth_dev_ops ops = {
+		.dev_start = eth_dev_start,
+		.dev_stop = eth_dev_stop,
+		.dev_configure = eth_dev_configure,
+		.dev_infos_get = eth_dev_info,
+		.rx_queue_setup = eth_rx_queue_setup,
+		.tx_queue_setup = eth_tx_queue_setup,
+		.rx_queue_release = eth_queue_release,
+		.tx_queue_release = eth_queue_release,
+		.link_update = eth_link_update,
+		.stats_get = eth_stats_get,
+		.stats_reset = eth_stats_reset,
+};
+
+static int
+new_device(struct virtio_net *dev)
+{
+	struct rte_eth_dev *eth_dev = dev->priv;
+	struct pmd_internals *internal;
+	unsigned i;
+
+	if ((eth_dev == NULL) || (eth_dev->data->dev_private == NULL)) {
+		RTE_LOG(INFO, PMD, "failuer to establish a new connection\n");
+		return -1;
+	}
+
+	internal = eth_dev->data->dev_private;
+
+	RTE_LOG(INFO, PMD, "New connection '%s' established\n",
+			internal->driver->dev_name);
+
+	for (i = 0; i < internal->nb_rx_queues; i++)
+		internal->rx_vhost_queues[i].device = dev;
+	for (i = 0; i < internal->nb_tx_queues; i++)
+		internal->tx_vhost_queues[i].device = dev;
+
+	dev->flags |= VIRTIO_DEV_RUNNING;
+
+	eth_dev->data->dev_link.link_status = 1;
+
+	return 0;
+}
+
+static void
+destroy_device(volatile struct virtio_net *dev)
+{
+	struct rte_eth_dev *eth_dev = dev->priv;
+	struct pmd_internals *internal;
+	unsigned i;
+
+	if ((dev == NULL) || (eth_dev->data->dev_private == NULL)) {
+		RTE_LOG(INFO, PMD, "failuer to close a connection\n");
+		return;
+	}
+
+	internal = eth_dev->data->dev_private;
+
+	RTE_LOG(INFO, PMD, "Connection '%s' closed\n",
+			internal->driver->dev_name);
+
+	for (i = 0; i < internal->nb_rx_queues; i++)
+		internal->rx_vhost_queues[i].device = NULL;
+	for (i = 0; i < internal->nb_tx_queues; i++)
+		internal->rx_vhost_queues[i].device = NULL;
+
+	dev->flags &= ~VIRTIO_DEV_RUNNING;
+
+	eth_dev->data->dev_link.link_status = 0;
+
+	return;
+}
+
+static int
+rte_eth_from_vhosts(const char *name, const unsigned numa_node)
+{
+	struct rte_eth_dev_data *data = NULL;
+	struct rte_pci_device *pci_dev = NULL;
+	struct pmd_internals *internals = NULL;
+	struct rte_eth_dev *eth_dev = NULL;
+	struct vhost_driver *drv = NULL;
+	static struct virtio_net_device_ops *vhost_ops = NULL;;
+
+	uint16_t nb_rx_queues = 1;
+	uint16_t nb_tx_queues = 1;
+
+	/* now do all data allocation - for eth_dev structure, dummy pci driver
+	 * and internal (private) data
+	 */
+	data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node);
+	if (data == NULL)
+		goto error;
+
+	pci_dev = rte_zmalloc_socket(name, sizeof(*pci_dev), 0, numa_node);
+	if (pci_dev == NULL)
+		goto error;
+
+	internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node);
+	if (internals == NULL)
+		goto error;
+
+	vhost_ops = rte_zmalloc_socket(name, sizeof(*vhost_ops), 0, numa_node);
+	if (vhost_ops == NULL)
+		goto error;
+
+	drv = rte_vhost_driver_register(name, VHOST_DRV_USER);
+	if (internals == NULL)
+		goto error;
+
+	/* reserve an ethdev entry */
+	eth_dev = rte_eth_dev_allocate(name);
+	if (eth_dev == NULL)
+		goto error;
+
+	/* set vhost arguments */
+	vhost_ops->new_device = new_device;
+	vhost_ops->destroy_device = destroy_device;
+	if (rte_vhost_driver_callback_register(drv, vhost_ops, eth_dev) < 0)
+		goto error;
+
+	/* now put it all together
+	 * - store numa_node info in pci_driver
+	 * - point eth_dev_data to internals and pci_driver
+	 * - and point eth_dev structure to new eth_dev_data structure
+	 */
+	/* NOTE: we'll replace the data element, of originally allocated eth_dev
+	 * so the vhosts are local per-process */
+
+	internals->driver = drv;
+	internals->nb_rx_queues = nb_rx_queues;
+	internals->nb_tx_queues = nb_tx_queues;
+
+	pci_dev->numa_node = numa_node;
+
+	data->dev_private = internals;
+	data->port_id = eth_dev->data->port_id;
+	data->nb_rx_queues = (uint16_t)nb_rx_queues;
+	data->nb_tx_queues = (uint16_t)nb_tx_queues;
+	data->dev_link = pmd_link;
+	data->mac_addrs = &eth_addr;
+
+	eth_dev->data = data;
+	eth_dev->dev_ops = &ops;
+	eth_dev->pci_dev = pci_dev;
+
+	/* finally assign rx and tx ops */
+	eth_dev->rx_pkt_burst = eth_vhost_rx;
+	eth_dev->tx_pkt_burst = eth_vhost_tx;
+
+	return 0;
+
+error:
+	if (data)
+		rte_free(data);
+	if (pci_dev)
+		rte_free(pci_dev);
+	if (internals)
+		rte_free(internals);
+	if (vhost_ops)
+		rte_free(internals);
+	//if (drv)
+	//	rte_vhost_driver_unregister(drv);
+	return -1;
+}
+
+static int
+eth_dev_vhost_create(const char *name, const unsigned numa_node)
+{
+
+	if (rte_eth_from_vhosts(name, numa_node))
+		return -1;
+
+	return 0;
+}
+
+/*
+ * Opens an interface for reading and writing
+ */
+static inline int
+open_iface(const char *key __rte_unused, const char *value, void *extra_args)
+{
+	const char **iface_name = extra_args;
+
+	if(value == NULL)
+		return -1;
+
+	*iface_name = value;
+
+	return 0;
+}
+
+int
+rte_pmd_vhost_devinit(const char *name, const char *params)
+{
+	const char *iface_name;
+	struct rte_kvargs *kvlist;
+	int ret;
+
+	RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name);
+
+	kvlist = rte_kvargs_parse(params, valid_arguments);
+	if (kvlist == NULL)
+		return -1;
+
+	/*
+	 * If iface argument is passed we open the NICs and use them for
+	 * reading / writing
+	 */
+	if (rte_kvargs_count(kvlist, ETH_VHOST_IFACE_ARG) == 1) {
+
+		ret = rte_kvargs_process(kvlist, ETH_VHOST_IFACE_ARG,
+				&open_iface, &iface_name);
+		if (ret < 0)
+			return -1;
+	}
+
+	eth_dev_vhost_create(iface_name, rte_socket_id());
+
+	return 0;
+}
+
+static struct rte_driver pmd_vhost_drv = {
+	.name = "eth_vhost",
+	.type = PMD_VDEV,
+	.init = rte_pmd_vhost_devinit,
+};
+
+PMD_REGISTER_DRIVER(pmd_vhost_drv);
diff --git a/lib/librte_pmd_vhost/rte_eth_vhost.h b/lib/librte_pmd_vhost/rte_eth_vhost.h
new file mode 100644
index 0000000..6b039f2
--- /dev/null
+++ b/lib/librte_pmd_vhost/rte_eth_vhost.h
@@ -0,0 +1,55 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright (C) 2014 Nippon Telegraph and Telephone Corporation.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_ETH_VHOST_H_
+#define _RTE_ETH_VHOST_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_virtio_net.h>
+
+int rte_eth_register_vhost(const char *name);
+
+/**
+ * For use by test apps only. Called as part of EAL init to set up any dummy NICs
+ * configured on command line.
+ */
+int rte_pmd_vhost_devinit(const char *name, const char *params);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/mk/rte.app.mk b/mk/rte.app.mk
index 285b65c..a2227dc 100644
--- a/mk/rte.app.mk
+++ b/mk/rte.app.mk
@@ -215,6 +215,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y)
 LDLIBS += -lrte_pmd_pcap -lpcap
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_VHOST),y)
+LDLIBS += -lrte_pmd_vhost
+endif
+
 endif # plugins
 
 LDLIBS += $(EXECENV_LDLIBS)
-- 
1.9.1



More information about the dev mailing list