Skip to contentSkip to conversation

vhost example based on user space vhost library.

PATCH Superseded Huawei Xie 5 participants 11 messages Aug 5, 2014 – Aug 19, 2014 6 messages not in the archive

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Huawei Xie

author
#0 lore raw

cover vhost example based on user space vhost library.

This vhost example implements a simple vswitch using DPDK user space vhost library(lib/librte_vhost) and VMDQ to demonstrate vhost's performance.
- Each virtio device is bound to a VMDQ pool and each pool is assigned the mac/vlan of the virtio device.
- Packets arriving at a pool after l2 classifier will be moved to the virtio device.
- Packets whose destination is a local virtio device will be delivered either by a)software switching mode b)hardware l2 switch.
- zero copy is supported and could be configured through command line.

Huawei Xie (3):
remove old vhost example
add lib/librte_vhost support in mk/rte.app.mk
add new vhost example

 examples/vhost/Makefile                    |   10 +-
 examples/vhost/eventfd_link/Makefile       |   39 -
 examples/vhost/eventfd_link/eventfd_link.c |  205 -----
 examples/vhost/eventfd_link/eventfd_link.h |   79 --
 examples/vhost/libvirt/qemu-wrap.py        |    5 +-
 examples/vhost/main.c                      | 1101 +++++++++++++-------------
 examples/vhost/main.h                      |   85 +-
 examples/vhost/vhost-net-cdev.c            |  367 ---------
 examples/vhost/vhost-net-cdev.h            |   83 --
 examples/vhost/virtio-net.c                | 1165 ----------------------------
 examples/vhost/virtio-net.h                |  147 ----
 mk/rte.app.mk                              |    5 +
 12 files changed, 585 insertions(+), 2706 deletions(-)
 delete mode 100644 examples/vhost/eventfd_link/Makefile
 delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c
 delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h
 delete mode 100644 examples/vhost/vhost-net-cdev.c
 delete mode 100644 examples/vhost/vhost-net-cdev.h
 delete mode 100644 examples/vhost/virtio-net.c
 delete mode 100644 examples/vhost/virtio-net.h
Signature · 1 line
1.8.1.4
author
#2 lore raw

PATCH 1/3 examples/vhost: remove old vhost example

In reply to a message not in the archive

Old vhost example is refactored into a user space vhost library and a new example.

---
 examples/vhost/Makefile                    |   60 -
 examples/vhost/eventfd_link/Makefile       |   39 -
 examples/vhost/eventfd_link/eventfd_link.c |  205 --
 examples/vhost/eventfd_link/eventfd_link.h |   79 -
 examples/vhost/libvirt/qemu-wrap.py        |  367 ----
 examples/vhost/main.c                      | 3102 ----------------------------
 examples/vhost/main.h                      |   86 -
 examples/vhost/vhost-net-cdev.c            |  367 ----
 examples/vhost/vhost-net-cdev.h            |   83 -
 examples/vhost/virtio-net.c                | 1165 -----------
 examples/vhost/virtio-net.h                |  147 --
 11 files changed, 5700 deletions(-)
 delete mode 100644 examples/vhost/Makefile
 delete mode 100644 examples/vhost/eventfd_link/Makefile
 delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c
 delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h
 delete mode 100755 examples/vhost/libvirt/qemu-wrap.py
 delete mode 100644 examples/vhost/main.c
 delete mode 100644 examples/vhost/main.h
 delete mode 100644 examples/vhost/vhost-net-cdev.c
 delete mode 100644 examples/vhost/vhost-net-cdev.h
 delete mode 100644 examples/vhost/virtio-net.c
 delete mode 100644 examples/vhost/virtio-net.h
examples/vhost/Makefile deleted +0 -60
deleted file mode 100644
index f45f83f..0000000
@@ -1,60 +0,0 @@
-#   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.
-
-ifeq ($(RTE_SDK),)
-$(error "Please define RTE_SDK environment variable")
-endif
-
-# Default target, can be overriden by command line or environment
-RTE_TARGET ?= x86_64-native-linuxapp-gcc
-
-include $(RTE_SDK)/mk/rte.vars.mk
-
-ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
-$(info This application can only operate in a linuxapp environment, \
-please change the definition of the RTE_TARGET environment variable)
-all:
-else
-
-# binary name
-APP = vhost-switch
-
-# all source are stored in SRCS-y
-#SRCS-y := cusedrv.c loopback-userspace.c
-SRCS-y := main.c virtio-net.c vhost-net-cdev.c
-
-CFLAGS += -O2 -I/usr/local/include -D_FILE_OFFSET_BITS=64 -Wno-unused-parameter
-CFLAGS += $(WERROR_FLAGS)
-LDFLAGS += -lfuse
-
-include $(RTE_SDK)/mk/rte.extapp.mk
-
-endif
examples/vhost/eventfd_link/Makefile deleted +0 -39
deleted file mode 100644
index fc3927b..0000000
@@ -1,39 +0,0 @@
-#   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.
-
-obj-m += eventfd_link.o
-
-
-all:
-	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
-
-clean:
-	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
examples/vhost/eventfd_link/eventfd_link.c deleted +0 -205

205 lines not on this page · raw message

examples/vhost/eventfd_link/eventfd_link.h deleted +0 -79

79 lines not on this page · raw message

examples/vhost/libvirt/qemu-wrap.py deleted +0 -367

367 lines not on this page · raw message

examples/vhost/main.c deleted +0 -3102

2,250 lines not on this page · raw message

examples/vhost/main.h deleted +0 -86

86 lines not on this page · raw message

examples/vhost/vhost-net-cdev.c deleted +0 -367

367 lines not on this page · raw message

examples/vhost/vhost-net-cdev.h deleted +0 -83

83 lines not on this page · raw message

examples/vhost/virtio-net.c deleted +0 -1165

1,165 lines not on this page · raw message

examples/vhost/virtio-net.h deleted +0 -147

147 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.1.4

Part of the diff is not shown here. View the raw message.

author
#3 lore raw

PATCH 2/3 lib/librte_vhost: add lib/librte_vhost support in mk/rte.app.mk

In reply to a message not in the archive

Vhost library is turned off by default as it depends on fuse library. User needs to turn on vhost in configure file manually.

---
 mk/rte.app.mk | 5 +++++
 1 file changed, 5 insertions(+)
mk/rte.app.mk +5 -0
index 34dff2a..285b65c 100644
@@ -190,6 +190,11 @@ ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_VHOST), y)
+LDLIBS += -lrte_vhost
+LDLIBS += -lfuse
+endif
+
 ifeq ($(CONFIG_RTE_LIBRTE_I40E_PMD),y)
 LDLIBS += -lrte_pmd_i40e
 endif
Signature · 1 line
1.8.1.4
author
#4 lore raw

PATCH 3/3 examples/vhost: add new vhost example

In reply to a message not in the archive
---
 examples/vhost/Makefile             |   52 +
 examples/vhost/libvirt/qemu-wrap.py |  366 +++++
 examples/vhost/main.c               | 3047 +++++++++++++++++++++++++++++++++++
 examples/vhost/main.h               |  109 ++
 4 files changed, 3574 insertions(+)
 create mode 100644 examples/vhost/Makefile
 create mode 100755 examples/vhost/libvirt/qemu-wrap.py
 create mode 100644 examples/vhost/main.c
 create mode 100644 examples/vhost/main.h
examples/vhost/Makefile new file +52 -0
new file mode 100644
index 0000000..a4d4fb0
@@ -0,0 +1,52 @@
+#   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.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overriden by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = vhost-switch
+
+# all source are stored in SRCS-y
+#SRCS-y := cusedrv.c loopback-userspace.c
+SRCS-y := main.c
+
+CFLAGS += -O2 -I/usr/local/include -D_FILE_OFFSET_BITS=64 -Wno-unused-parameter
+CFLAGS += $(WERROR_FLAGS)
+LDFLAGS += -lfuse
+
+include $(RTE_SDK)/mk/rte.extapp.mk
examples/vhost/libvirt/qemu-wrap.py new file +366 -0

366 lines not on this page · raw message

examples/vhost/main.c new file +3047 -0

2,582 lines not on this page · raw message

examples/vhost/main.h new file +109 -0

109 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.8.1.4

Part of the diff is not shown here. View the raw message.

Tested-by
#9 lore raw
In reply to a message not in the archive

This patch includes 3 files, and has been tested by Intel. Please see information as the following:

Host:
Fedora 19 x86_64, Linux Kernel 3.9.0, GCC 4.8.2 Intel Xeon CPU E5-2680 v2 @ 2.80GHz
NIC: Intel Niantic 82599, Intel i350, Intel 82580 and Intel 82576

Guest:
Fedora 16 x86_64, Linux Kernel 3.4.2, GCC 4.6.3 Qemu emulator 1.4.2

This patch tests with user space vhost driver library patch.
We verified zero copy and one copy test cases for functional and performance.

Total case Passed Failed
8 8 0

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Huawei Xie
Sent: Tuesday, August 05, 2014 11:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

This vhost example implements a simple vswitch using DPDK user space vhost library(lib/librte_vhost) and VMDQ to demonstrate vhost's performance.
- Each virtio device is bound to a VMDQ pool and each pool is assigned the mac/vlan of the virtio device.
- Packets arriving at a pool after l2 classifier will be moved to the virtio device.
- Packets whose destination is a local virtio device will be delivered either by a)software switching mode b)hardware l2 switch.
- zero copy is supported and could be configured through command line.

Huawei Xie (3):
remove old vhost example
add lib/librte_vhost support in mk/rte.app.mk
add new vhost example

 examples/vhost/Makefile                    |   10 +-
 examples/vhost/eventfd_link/Makefile       |   39 -
 examples/vhost/eventfd_link/eventfd_link.c |  205 -----
 examples/vhost/eventfd_link/eventfd_link.h |   79 --
 examples/vhost/libvirt/qemu-wrap.py        |    5 +-
 examples/vhost/main.c                      | 1101 +++++++++++++-------------
 examples/vhost/main.h                      |   85 +-
 examples/vhost/vhost-net-cdev.c            |  367 ---------
 examples/vhost/vhost-net-cdev.h            |   83 --
 examples/vhost/virtio-net.c                | 1165 ----------------------------
 examples/vhost/virtio-net.h                |  147 ----
 mk/rte.app.mk                              |    5 +
 12 files changed, 585 insertions(+), 2706 deletions(-)
 delete mode 100644 examples/vhost/eventfd_link/Makefile
 delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c
 delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h
 delete mode 100644 examples/vhost/vhost-net-cdev.c
 delete mode 100644 examples/vhost/vhost-net-cdev.h
 delete mode 100644 examples/vhost/virtio-net.c
 delete mode 100644 examples/vhost/virtio-net.h
Signature · 1 line
1.8.1.4
#6 lore raw

Re: [PATCH 3/3] examples/vhost: add new vhost example

In reply to a message not in the archive

examples/vhost/main.c line 311

Quoted 12 lines
examples/vhost/main.c new file +11 -0
+static const uint16_t external_pkt_default_vlan_tag = 2000;
+const uint16_t vlan_tags[] = {
+	1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
+	1008, 1009, 1010, 1011,	1012, 1013, 1014, 1015,
+	1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023,
+	1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031,
+	1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039,
+	1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047,
+	1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055,
+	1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063,
+};

Why pre-compute table if it is just: vlan_tag = n + 1000?

examples/vhost/main.c line 372

Quoted 11 lines
examples/vhost/main.c new file +11 -0
+
+/* Per-device statistics struct */
+struct device_statistics {
+	uint64_t tx_total;
+	rte_atomic64_t rx_total_atomic;
+	uint64_t rx_total;
+	uint64_t tx;
+	rte_atomic64_t rx_atomic;
+	uint64_t rx;
+} __rte_cache_aligned;
+struct device_statistics dev_statistics[MAX_DEVICES];

Doing per-core statistics would be faster than using atomic's which have implicit lock.

Quoted 16 lines
examples/vhost/main.c new file +16 -0
+/*
+ * Builds up the correct configuration for VMDQ VLAN pool map
+ * according to the pool & queue limits.
+ */
+static inline int
+get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices)
+{
+	struct rte_eth_vmdq_rx_conf conf;
+	unsigned i;
+
+	memset(&conf, 0, sizeof(conf));
+	conf.nb_queue_pools = (enum rte_eth_nb_pools)num_devices;
+	conf.nb_pool_maps = num_devices;
+	conf.enable_loop_back =
+		vmdq_conf_default.rx_adv_conf.vmdq_rx_conf.enable_loop_back;
+

examples/vhost/main.c line 399

Quoted 10 lines
examples/vhost/main.c new file +10 -0
+	for (i = 0; i < conf.nb_pool_maps; i++) {
+		conf.pool_map[i].vlan_id = vlan_tags[i];
+		conf.pool_map[i].pools = (1UL << i);
+	}
+
+	(void)(rte_memcpy(eth_conf, &vmdq_conf_default, sizeof(*eth_conf)));
+	(void)(rte_memcpy(&eth_conf->rx_adv_conf.vmdq_rx_conf, &conf,
+		   sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf)));
+	return 0;
+}

If function always returns 0 just make it void.
No point in making non-fastpath code inline.
The cast to (void) is unnecessary and just makes things ugly.
Why not use structure assignment rather than memcpy() which is not type safe?

#8 lore raw

Re: [PATCH 3/3] examples/vhost: add new vhost example

In reply to a message not in the archive
Quoted 10 lines

-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Wednesday, August 06, 2014 11:33 AM
To: Xie, Huawei
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH 3/3] examples/vhost: add new vhost example

Quoted 13 lines

examples/vhost/main.c line 311

Quoted 11 lines
examples/vhost/main.c new file +11 -0
+static const uint16_t external_pkt_default_vlan_tag = 2000;
+const uint16_t vlan_tags[] = {
+	1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
+	1008, 1009, 1010, 1011,	1012, 1013, 1014, 1015,
+	1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023,
+	1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031,
+	1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039,
+	1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047,
+	1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055,
+	1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063,
+};

Why pre-compute table if it is just: vlan_tag = n + 1000?

This is inherited from old vhost example. For demonstration purpose, I feel it is ok. Besides, the purpose of this patch is to refactor the example using vhost library, so I prefer subsequent patches to fix those kind of problems.

Quoted 16 lines

examples/vhost/main.c line 372

Quoted 13 lines
examples/vhost/main.c new file +11 -0
+
+/* Per-device statistics struct */
+struct device_statistics {
+	uint64_t tx_total;
+	rte_atomic64_t rx_total_atomic;
+	uint64_t rx_total;
+	uint64_t tx;
+	rte_atomic64_t rx_atomic;
+	uint64_t rx;
+} __rte_cache_aligned;
+struct device_statistics dev_statistics[MAX_DEVICES];

Doing per-core statistics would be faster than using atomic's which have implicit lock.

For software vm2vm mode, there is contention as two cores could enqueue the same virtio ring concurrently.

Quoted 17 lines
Quoted 6 lines
examples/vhost/main.c new file +5 -0
+/*
+ * Builds up the correct configuration for VMDQ VLAN pool map
+ * according to the pool & queue limits.
+ */
+static inline int

examples/vhost/main.c line 389

Quoted 10 lines
examples/vhost/main.c new file +10 -0
+get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices)
+{
+	struct rte_eth_vmdq_rx_conf conf;
+	unsigned i;
+
+	memset(&conf, 0, sizeof(conf));
+	conf.nb_queue_pools = (enum rte_eth_nb_pools)num_devices;
+	conf.nb_pool_maps = num_devices;
+	conf.enable_loop_back =
+
	vmdq_conf_default.rx_adv_conf.vmdq_rx_conf.enable_loop_back;
Quoted 16 lines

examples/vhost/main.c line 399

Quoted 11 lines
examples/vhost/main.c new file +11 -0
+
+	for (i = 0; i < conf.nb_pool_maps; i++) {
+		conf.pool_map[i].vlan_id = vlan_tags[i];
+		conf.pool_map[i].pools = (1UL << i);
+	}
+
+	(void)(rte_memcpy(eth_conf, &vmdq_conf_default, sizeof(*eth_conf)));
+	(void)(rte_memcpy(&eth_conf->rx_adv_conf.vmdq_rx_conf, &conf,
+		   sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf)));
+	return 0;
+}

If function always returns 0 just make it void.
No point in making non-fastpath code inline.
The cast to (void) is unnecessary and just makes things ugly.
Why not use structure assignment rather than memcpy() which is not type safe?

Agree. As stated above, I prefer subsequent patches to fix those issues inherited from old example. How do you think?

Tested-by
#10 lore raw
In reply to a message not in the archive

This patch implements a simple vswitch by user vhost library, and is ready to integrate into DPDK.org.

-----Original Message-----

Quoted 36 lines

From: dev [mailto:[email protected]] On Behalf Of Huawei Xie
Sent: Tuesday, August 5, 2014 11:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

This vhost example implements a simple vswitch using DPDK user space vhost library(lib/librte_vhost) and VMDQ to demonstrate vhost's performance.
- Each virtio device is bound to a VMDQ pool and each pool is assigned the mac/vlan of the virtio device.
- Packets arriving at a pool after l2 classifier will be moved to the virtio device.
- Packets whose destination is a local virtio device will be delivered either by a)software switching mode b)hardware l2 switch.
- zero copy is supported and could be configured through command line.

Huawei Xie (3):
remove old vhost example
add lib/librte_vhost support in mk/rte.app.mk
add new vhost example

examples/vhost/Makefile                    |   10 +-
examples/vhost/eventfd_link/Makefile       |   39 -
examples/vhost/eventfd_link/eventfd_link.c |  205 -----
examples/vhost/eventfd_link/eventfd_link.h |   79 --
examples/vhost/libvirt/qemu-wrap.py        |    5 +-
examples/vhost/main.c                      | 1101 +++++++++++++-------------
examples/vhost/main.h                      |   85 +-
examples/vhost/vhost-net-cdev.c            |  367 ---------
examples/vhost/vhost-net-cdev.h            |   83 --
examples/vhost/virtio-net.c                | 1165 ----------------------------
examples/vhost/virtio-net.h                |  147 ----
mk/rte.app.mk                              |    5 +
12 files changed, 585 insertions(+), 2706 deletions(-)  delete mode 100644 examples/vhost/eventfd_link/Makefile

delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c
delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h
delete mode 100644 examples/vhost/vhost-net-cdev.c delete mode 100644 examples/vhost/vhost-net-cdev.h delete mode 100644 examples/vhost/virtio-net.c delete mode 100644 examples/vhost/virtio-net.h

--
1.8.1.4

Tested-by Waterman Cao
#12 lore raw
In reply to a message not in the archive

Hi
I see the eventfd module is still included... is this to support existing vhost implementations? Is Qemu's vhost-user supported?

Thanks
Maryam

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Cao, Waterman
Sent: Thursday, August 7, 2014 3:29 PM
To: Xie, Huawei; [email protected]
Subject: Re: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

-----Original Message-----

Quoted 37 lines

From: dev [mailto:[email protected]] On Behalf Of Huawei Xie
Sent: Tuesday, August 5, 2014 11:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

This vhost example implements a simple vswitch using DPDK user space vhost library(lib/librte_vhost) and VMDQ to demonstrate vhost's performance.
- Each virtio device is bound to a VMDQ pool and each pool is assigned the mac/vlan of the virtio device.
- Packets arriving at a pool after l2 classifier will be moved to the virtio device.
- Packets whose destination is a local virtio device will be delivered either by a)software switching mode b)hardware l2 switch.
- zero copy is supported and could be configured through command line.

Huawei Xie (3):
remove old vhost example
add lib/librte_vhost support in mk/rte.app.mk
add new vhost example

examples/vhost/Makefile                    |   10 +-
examples/vhost/eventfd_link/Makefile       |   39 -
examples/vhost/eventfd_link/eventfd_link.c |  205 -----
examples/vhost/eventfd_link/eventfd_link.h |   79 --
examples/vhost/libvirt/qemu-wrap.py        |    5 +-
examples/vhost/main.c                      | 1101 +++++++++++++-------------
examples/vhost/main.h                      |   85 +-
examples/vhost/vhost-net-cdev.c            |  367 ---------
examples/vhost/vhost-net-cdev.h            |   83 --
examples/vhost/virtio-net.c                | 1165 ----------------------------
examples/vhost/virtio-net.h                |  147 ----
mk/rte.app.mk                              |    5 +
12 files changed, 585 insertions(+), 2706 deletions(-)  delete mode 

100644 examples/vhost/eventfd_link/Makefile
delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h delete mode 100644 examples/vhost/vhost-net-cdev.c delete mode 100644 examples/vhost/vhost-net-cdev.h delete mode 100644 examples/vhost/virtio-net.c delete mode 100644 examples/vhost/virtio-net.h

Quoted 3 lines

--
1.8.1.4

--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#14 lore raw
In reply to a message not in the archive

Hi Maryam:
This patch removes eventfd kernel module from example.
Qemu user space vhost support is within progress. This is our existing vhost implementation. With the new implementation, there should be no or minor change to the library API.

BR.
-huawei

Quoted 70 lines

-----Original Message-----
From: Tahhan, Maryam
Sent: Tuesday, August 19, 2014 4:51 PM
To: Cao, Waterman; Xie, Huawei; [email protected]
Cc: Long, Thomas
Subject: RE: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

Hi
I see the eventfd module is still included... is this to support existing vhost implementations? Is Qemu's vhost-user supported?

Thanks
Maryam

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Cao, Waterman
Sent: Thursday, August 7, 2014 3:29 PM
To: Xie, Huawei; [email protected]
Subject: Re: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

a simple vswitch by user vhost library, and is ready to integrate into DPDK.org.

-----Original Message-----

Quoted 4 lines

From: dev [mailto:[email protected]] On Behalf Of Huawei Xie
Sent: Tuesday, August 5, 2014 11:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost

library.

Quoted 2 lines

This vhost example implements a simple vswitch using DPDK user space vhost

library(lib/librte_vhost) and VMDQ to demonstrate vhost's performance.

Quoted 1 line

- Each virtio device is bound to a VMDQ pool and each pool is assigned the

mac/vlan of the virtio device.

Quoted 2 lines

- Packets arriving at a pool after l2 classifier will be moved to the virtio device.
- Packets whose destination is a local virtio device will be delivered either by

a)software switching mode b)hardware l2 switch.

Quoted 31 lines

- zero copy is supported and could be configured through command line.

Huawei Xie (3):
remove old vhost example
add lib/librte_vhost support in mk/rte.app.mk
add new vhost example

examples/vhost/Makefile                    |   10 +-
examples/vhost/eventfd_link/Makefile       |   39 -
examples/vhost/eventfd_link/eventfd_link.c |  205 -----
examples/vhost/eventfd_link/eventfd_link.h |   79 --
examples/vhost/libvirt/qemu-wrap.py        |    5 +-
examples/vhost/main.c                      | 1101 +++++++++++++-------------
examples/vhost/main.h                      |   85 +-
examples/vhost/vhost-net-cdev.c            |  367 ---------
examples/vhost/vhost-net-cdev.h            |   83 --
examples/vhost/virtio-net.c                | 1165 ----------------------------
examples/vhost/virtio-net.h                |  147 ----
mk/rte.app.mk                              |    5 +
12 files changed, 585 insertions(+), 2706 deletions(-)  delete mode

100644 examples/vhost/eventfd_link/Makefile
delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h delete mode 100644 examples/vhost/vhost-net-cdev.c delete mode 100644 examples/vhost/vhost-net-cdev.h delete mode 100644 examples/vhost/virtio-net.c delete mode 100644 examples/vhost/virtio-net.h

--
1.8.1.4

#16 lore raw
In reply to a message not in the archive

Thanks
I was looking at the wrong version of the patch :(

-----Original Message-----
From: Xie, Huawei
Sent: Tuesday, August 19, 2014 10:07 AM
To: Tahhan, Maryam; Cao, Waterman; [email protected]
Cc: Long, Thomas
Subject: RE: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

Hi Maryam:
This patch removes eventfd kernel module from example.
Qemu user space vhost support is within progress. This is our existing vhost implementation. With the new implementation, there should be no or minor change to the library API.

BR.
-huawei

Quoted 35 lines

-----Original Message-----
From: Tahhan, Maryam
Sent: Tuesday, August 19, 2014 4:51 PM
To: Cao, Waterman; Xie, Huawei; [email protected]
Cc: Long, Thomas
Subject: RE: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

Hi
I see the eventfd module is still included... is this to support existing vhost implementations? Is Qemu's vhost-user supported?

Thanks
Maryam

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Cao, Waterman
Sent: Thursday, August 7, 2014 3:29 PM
To: Xie, Huawei; [email protected]
Subject: Re: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost library.

implements a simple vswitch by user vhost library, and is ready to integrate into DPDK.org.

-----Original Message-----

Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of Huawei Xie
Sent: Tuesday, August 5, 2014 11:58 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH 0/3] vhost example based on user space vhost

library.

Quoted 3 lines

This vhost example implements a simple vswitch using DPDK user space vhost

Quoted 39 lines

library(lib/librte_vhost) and VMDQ to demonstrate vhost's performance.

Quoted 2 lines

- Each virtio device is bound to a VMDQ pool and each pool is assigned the

mac/vlan of the virtio device.

Quoted 3 lines

- Packets arriving at a pool after l2 classifier will be moved to the virtio device.
- Packets whose destination is a local virtio device will be
delivered either by

a)software switching mode b)hardware l2 switch.

Quoted 31 lines

- zero copy is supported and could be configured through command line.

Huawei Xie (3):
remove old vhost example
add lib/librte_vhost support in mk/rte.app.mk
add new vhost example

examples/vhost/Makefile                    |   10 +-
examples/vhost/eventfd_link/Makefile       |   39 -
examples/vhost/eventfd_link/eventfd_link.c |  205 -----
examples/vhost/eventfd_link/eventfd_link.h |   79 --
examples/vhost/libvirt/qemu-wrap.py        |    5 +-
examples/vhost/main.c                      | 1101 +++++++++++++-------------
examples/vhost/main.h                      |   85 +-
examples/vhost/vhost-net-cdev.c            |  367 ---------
examples/vhost/vhost-net-cdev.h            |   83 --
examples/vhost/virtio-net.c                | 1165 ----------------------------
examples/vhost/virtio-net.h                |  147 ----
mk/rte.app.mk                              |    5 +
12 files changed, 585 insertions(+), 2706 deletions(-)  delete mode

100644 examples/vhost/eventfd_link/Makefile
delete mode 100644 examples/vhost/eventfd_link/eventfd_link.c delete mode 100644 examples/vhost/eventfd_link/eventfd_link.h delete mode 100644 examples/vhost/vhost-net-cdev.c delete mode 100644 examples/vhost/vhost-net-cdev.h delete mode 100644 examples/vhost/virtio-net.c delete mode 100644 examples/vhost/virtio-net.h

--
1.8.1.4

--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.