[dpdk-dev] [PATCH 2/3] lib/librte_vhost: vhost library support to facilitate integration with DPDK accelerated vswitch
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen Hemminger > Sent: Wednesday, September 03, 2014 7:02 AM > To: Xie, Huawei > Cc: dev at dpdk.org > Subject: Re: [dpdk-dev] [PATCH 2/3] lib/librte_vhost: vhost library support > to facilitate integration with DPDK accelerated vswitch > > On Wed, 3 Sep 2014 05:39:24 + > "Xie, Huawei" wrote: > > > Thanks Tetsuya: > > Some of them are due to 80 character limitation. Is it ok to break the > > limitation for better indentation? > > Many of these comments could just be removed or shortened. > Often removing comments makes code clearer and less buggy, because > there is no risk that comment does not match code. If comment string is longer than 80 characters, why just not split comment string into multiline?
[dpdk-dev] [PATCH 2/3] lib/librte_vhost: vhost library support to facilitate integration with DPDK accelerated vswitch
Thanks Tetsuya: Some of them are due to 80 character limitation. Is it ok to break the limitation for better indentation? > -Original Message- > From: Tetsuya.Mukawa [mailto:mukawa at igel.co.jp] > Sent: Wednesday, September 03, 2014 11:39 AM > To: Xie, Huawei; dev at dpdk.org > Subject: Re: [dpdk-dev] [PATCH 2/3] lib/librte_vhost: vhost library support to > facilitate integration with DPDK accelerated vswitch > > Hi Huawei, > > I added few comments. Mainly those comments are about source code indent. > > (2014/09/02 17:55), Huawei Xie wrote: > > + > > +/** > > + * Structure contains variables relevant to RX/TX virtqueues. > > + */ > > +struct vhost_virtqueue { > > + /**< descriptor ring. */ > > + struct vring_desc*desc; > > + /**< available ring. */ > > + struct vring_avail *avail; > > + /**< used ring. */ > > + struct vring_used*used; > > + /**< Size of descriptor ring. */ > > + uint32_t size; > > + /**< Backend value to determine if device should be started/stopped. */ > > + uint32_t backend; > > + /**< Vhost header length (varies depending on RX merge buffers. */ > > + uint16_t vhost_hlen; > > + /**< Last index used on the available ring. */ > > + volatile uint16_tlast_used_idx; > > + /**< Used for multiple devices reserving buffers. */ > > + volatile uint16_tlast_used_idx_res; > > + /**< Currently unused as polling mode is enabled. */ > > + eventfd_tcallfd; > > + /**< Used to notify the guest (trigger interrupt). */ > > + eventfd_tkickfd; > > +} __rte_cache_aligned; > > + > > +/** > > + * Information relating to memory regions including offsets to > > + * addresses in QEMUs memory file. > > + */ > > +struct virtio_memory_regions { > > + /**< Base guest physical address of region. */ > > + uint64_tguest_phys_address; > > + /**< End guest physical address of region. */ > > + uint64_tguest_phys_address_end; > > + /**< Size of region. */ > > + uint64_tmemory_size; > > + /**< Base userspace address of region. */ > > + uint64_tuserspace_address; > > + /**< Offset of region for address translation. */ > > + uint64_taddress_offset; > > +}; > > + > > + > > +/** > > + * Memory structure includes region and mapping information. > > + */ > > +struct virtio_memory { > > + /**< Base QEMU userspace address of the memory file. */ > > + uint64_tbase_address; > > + /**< Mapped address of memory file in this process's memory space. */ > > + uint64_tmapped_address; > > + /**< Total size of memory file. */ > > + uint64_tmapped_size; > > + /**< Number of memory regions. */ > > + uint32_tnregions; > > + /**< Memory region information. */ > > + struct virtio_memory_regions regions[0]; > > +}; > > + > > +/** > > + * Device structure contains all configuration information relating to the > device. > > + */ > > +struct virtio_net { > > + /**< Contains all virtqueue information. */ > > + struct vhost_virtqueue *virtqueue[VIRTIO_QNUM]; > > + /**< QEMU memory and memory region information. */ > > + struct virtio_memory*mem; > > + /**< Negotiated feature set. */ > > + uint64_t features; > > + /**< Device identifier. */ > > + uint64_t device_fh; > > + /**< Device flags, used to check if device is running on data core. */ > > + uint32_t flags; > > + void *priv; > > +} __rte_cache_aligned; > > + > Above comments of 'vhost_virtqueue', 'struct virtio_memory_regions', > 'struct virtio-memory' > and 'struct virtio-net' will break API documentation created by Doxygen. > Not to break, I guess those comment need to be placed after variable. Thanks. I will check doxgen rule. Moved the comment above to avoid 80 character limitation warning. > > > +/** > > + * cuse_info is populated and used to register the cuse device. > > + * vhost_net_device_ops is passed when the device is registered in main.c. > > + */ > > +int > > +rte_vhost_driver_register(const char *dev_name) > > +{ > > + struct cuse_info cuse_info; > > + char device_name[PATH_MAX] = ""; > > + char char_device_name[PATH_MAX] = ""; > > + const char *device_argv[] = { device_name }; > > + > > + char fuse_opt_dummy[] = FUSE_OPT
[dpdk-dev] [PATCH 2/3] lib/librte_vhost: vhost library support to facilitate integration with DPDK accelerated vswitch
This library is turned off by default so that it doesn't break build on default system. Install fuse development library and turn it on. Signed-off-by: Huawei Xie Acked-by: Konstantin Ananyev Acked-by: Thomos Long --- config/common_linuxapp |7 + lib/Makefile |1 + lib/librte_vhost/Makefile| 48 ++ lib/librte_vhost/eventfd_link/Makefile | 39 + lib/librte_vhost/eventfd_link/eventfd_link.c | 196 + lib/librte_vhost/eventfd_link/eventfd_link.h | 40 + lib/librte_vhost/rte_virtio_net.h| 222 + lib/librte_vhost/vhost-net-cdev.c| 394 + lib/librte_vhost/vhost-net-cdev.h| 119 +++ lib/librte_vhost/vhost_rxtx.c| 316 lib/librte_vhost/virtio-net.c| 1113 ++ mk/rte.app.mk|5 + 12 files changed, 2500 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 9047975..c7c1c83 100644 --- a/config/common_linuxapp +++ b/config/common_linuxapp @@ -390,6 +390,13 @@ CONFIG_RTE_KNI_VHOST_DEBUG_RX=n CONFIG_RTE_KNI_VHOST_DEBUG_TX=n # +# Compile vhost library +# fuse, fuse-devel, kernel-modules-extra packages are needed +# +CONFIG_RTE_LIBRTE_VHOST=n +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..6ad706d --- /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..fc3927b --- /dev/null +++