[dpdk-dev] [PATCH 1/2] lib/librte_vhost: vhost library support to facilitate integration with vswitch.

2014-08-08 Thread Xie, Huawei

> -Original Message-
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Friday, August 08, 2014 1:59 AM
> To: Xie, Huawei
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/2] lib/librte_vhost: vhost library support to
> facilitate integration with vswitch.
> 
> On Fri, 18 Jul 2014 13:39:05 +0800
> Huawei Xie  wrote:
> 
> > Signed-off-by: Huawei Xie 
> > Acked-by: Konstantin Ananyev 
> > Acked-by: Thomos Long 
> 
> This looks good, but there are some style convention issues:
> 
> 1. Please don't use really long lines. About 100 or 120 characters is maximum
>reasonable length in an editor
> 
I plan to fix the length issues in subsequent patch. There are plenty of them, 
which are inherited from old vhost code. 
> 2. Don't put space here in function decl.
> 
> ERROR: space prohibited after that '*' (ctx:BxW)
> #1183: FILE: lib/librte_vhost/vhost-net-cdev.h:102:
> + int (* set_vring_kick)(struct vhost_device_ctx, struct vhost_vring_file 
> *);
>^
> 
In this patch, I only run checkpatch.pl against the source file I modified 
rather than the patch itself, so missed these checking.  I had sent the V3 
patch in which those kind of issues are fixed. Please refer to the latest V3 
patch.
> 3. Use BSD and kernel style brace
> Not:
> 
> +void
> +put_files_struct (struct files_struct *files)
> +{
> + if (atomic_dec_and_test (>count))
> + {
> + BUG ();
> + }
> +}
> 
> Instead:
> +void
> +put_files_struct (struct files_struct *files)
> +{
> + if (atomic_dec_and_test (>count)) {
> + BUG ();
> + }
> +}
> 
> 4. All functions that are not used in other files should be marked static.
>For example put_files_struct
> 
> 5. Switch should be indented at same level as case:
> Not:
> + switch (ioctl)
> + {
> + case EVENTFD_COPY:
> + if (copy_from_user (_copy, argp, sizeof (struct
> eventfd_copy)))
> + return -EFAULT;
> +
> 
> Instead:
> + switch (ioctl) {
> + case EVENTFD_COPY:
> + if (copy_from_user (_copy, argp, sizeof (struct
> eventfd_copy)))
> + return -EFAULT

Thanks. As stated above, have fixed all the style issues except 80 length 
warning in v3 patch.


[dpdk-dev] [PATCH 1/2] lib/librte_vhost: vhost library support to facilitate integration with vswitch.

2014-08-07 Thread Stephen Hemminger
On Fri, 18 Jul 2014 13:39:05 +0800
Huawei Xie  wrote:

> Signed-off-by: Huawei Xie 
> Acked-by: Konstantin Ananyev 
> Acked-by: Thomos Long 

This looks good, but there are some style convention issues:

1. Please don't use really long lines. About 100 or 120 characters is maximum
   reasonable length in an editor

2. Don't put space here in function decl.

ERROR: space prohibited after that '*' (ctx:BxW)
#1183: FILE: lib/librte_vhost/vhost-net-cdev.h:102:
+   int (* set_vring_kick)(struct vhost_device_ctx, struct vhost_vring_file 
*);
 ^

3. Use BSD and kernel style brace
Not:

+void
+put_files_struct (struct files_struct *files)
+{
+   if (atomic_dec_and_test (>count))
+   {
+   BUG ();
+   }
+}

Instead:
+void
+put_files_struct (struct files_struct *files)
+{
+   if (atomic_dec_and_test (>count)) {
+   BUG ();
+   }
+}

4. All functions that are not used in other files should be marked static.
   For example put_files_struct

5. Switch should be indented at same level as case:
Not:
+   switch (ioctl)
+   {
+   case EVENTFD_COPY:
+   if (copy_from_user (_copy, argp, sizeof (struct 
eventfd_copy)))
+   return -EFAULT;
+

Instead:
+   switch (ioctl) {
+   case EVENTFD_COPY:
+   if (copy_from_user (_copy, argp, sizeof (struct 
eventfd_copy)))
+   return -EFAULT


[dpdk-dev] [PATCH 1/2] lib/librte_vhost: vhost library support to facilitate integration with vswitch.

2014-07-18 Thread Huawei Xie
Signed-off-by: Huawei Xie 
Acked-by: Konstantin Ananyev 
Acked-by: Thomos Long 
---
 config/common_linuxapp   |6 +
 lib/Makefile |1 +
 lib/librte_vhost/Makefile|   48 ++
 lib/librte_vhost/eventfd_link/Makefile   |   39 +
 lib/librte_vhost/eventfd_link/eventfd_link.c |  205 ++
 lib/librte_vhost/eventfd_link/eventfd_link.h |   79 ++
 lib/librte_vhost/rte_virtio_net.h|  192 +
 lib/librte_vhost/vhost-net-cdev.c|  363 ++
 lib/librte_vhost/vhost-net-cdev.h|  112 +++
 lib/librte_vhost/vhost_rxtx.c|  292 
 lib/librte_vhost/virtio-net.c| 1002 ++
 11 files changed, 2339 insertions(+)
 create mode 100644 lib/librte_vhost/Makefile
 create mode 100644 lib/librte_vhost/eventfd_link/Makefile
 create mode 100644 lib/librte_vhost/eventfd_link/eventfd_link.c
 create mode 100644 lib/librte_vhost/eventfd_link/eventfd_link.h
 create mode 100644 lib/librte_vhost/rte_virtio_net.h
 create mode 100644 lib/librte_vhost/vhost-net-cdev.c
 create mode 100644 lib/librte_vhost/vhost-net-cdev.h
 create mode 100644 lib/librte_vhost/vhost_rxtx.c
 create mode 100644 lib/librte_vhost/virtio-net.c

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 7bf5d80..002ed84 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -390,6 +390,12 @@ CONFIG_RTE_KNI_VHOST_DEBUG_RX=n
 CONFIG_RTE_KNI_VHOST_DEBUG_TX=n

 #
+# Compile vhost library
+#
+CONFIG_RTE_LIBRTE_VHOST=y
+CONFIG_RTE_LIBRTE_VHOST_DEBUG=n
+
+#
 #Compile Xen domain0 support
 #
 CONFIG_RTE_LIBRTE_XEN_DOM0=n
diff --git a/lib/Makefile b/lib/Makefile
index 10c5bb3..007c174 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -60,6 +60,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_METER) += librte_meter
 DIRS-$(CONFIG_RTE_LIBRTE_SCHED) += librte_sched
 DIRS-$(CONFIG_RTE_LIBRTE_KVARGS) += librte_kvargs
 DIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += librte_distributor
+DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += librte_vhost
 DIRS-$(CONFIG_RTE_LIBRTE_PORT) += librte_port
 DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table
 DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline
diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
new file mode 100644
index 000..f79778b
--- /dev/null
+++ b/lib/librte_vhost/Makefile
@@ -0,0 +1,48 @@
+#   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_vhost.a
+
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 -lfuse
+LDFLAGS += -lfuse
+# all source are stored in SRCS-y
+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost-net-cdev.c virtio-net.c vhost_rxtx.c
+
+# install includes
+SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h
+
+# this lib needs eal
+DEPDIRS-$(CONFIG_RTE_LIBRTE_VHOST) += lib/librte_eal lib/librte_mbuf
+
+include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/lib/librte_vhost/eventfd_link/Makefile 
b/lib/librte_vhost/eventfd_link/Makefile
new file mode 100644
index 000..5fe7297
--- /dev/null
+++ b/lib/librte_vhost/eventfd_link/Makefile
@@ -0,0 +1,39 @@
+#   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,