From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 2EF24695D for ; Thu, 23 Mar 2017 08:13:24 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 23 Mar 2017 00:13:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,208,1486454400"; d="scan'208";a="837675427" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by FMSMGA003.fm.intel.com with ESMTP; 23 Mar 2017 00:13:22 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: Maxime Coquelin , Harris James R , Liu Changpeng , Yuanhan Liu Date: Thu, 23 Mar 2017 15:10:56 +0800 Message-Id: <1490253059-28112-20-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1490253059-28112-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1488534682-3494-1-git-send-email-yuanhan.liu@linux.intel.com> <1490253059-28112-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH v2 19/22] vhost: rename header file X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Mar 2017 07:13:25 -0000 Rename "rte_virtio_net.h" to "rte_vhost.h", to not let it be virtio net specific. Signed-off-by: Yuanhan Liu Reviewed-by: Maxime Coquelin --- doc/guides/rel_notes/deprecation.rst | 9 - doc/guides/rel_notes/release_17_05.rst | 3 + drivers/net/vhost/rte_eth_vhost.c | 2 +- drivers/net/vhost/rte_eth_vhost.h | 2 +- examples/tep_termination/main.c | 2 +- examples/tep_termination/vxlan_setup.c | 2 +- examples/vhost/main.c | 2 +- lib/librte_vhost/Makefile | 2 +- lib/librte_vhost/rte_vhost.h | 421 +++++++++++++++++++++++++++++++++ lib/librte_vhost/rte_virtio_net.h | 421 --------------------------------- lib/librte_vhost/vhost.c | 2 +- lib/librte_vhost/vhost.h | 2 +- lib/librte_vhost/vhost_user.h | 2 +- lib/librte_vhost/virtio_net.c | 2 +- 14 files changed, 434 insertions(+), 440 deletions(-) create mode 100644 lib/librte_vhost/rte_vhost.h delete mode 100644 lib/librte_vhost/rte_virtio_net.h diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index d6544ed..9708b39 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -95,15 +95,6 @@ Deprecation Notices Target release for removal of the legacy API will be defined once most PMDs have switched to rte_flow. -* vhost: API/ABI changes are planned for 17.05, for making DPDK vhost library - generic enough so that applications can build different vhost-user drivers - (instead of vhost-user net only) on top of that. - Specifically, ``virtio_net_device_ops`` will be renamed to ``vhost_device_ops``. - Correspondingly, some API's parameter need be changed. Few more functions also - need be reworked to let it be device aware. For example, different virtio device - has different feature set, meaning functions like ``rte_vhost_feature_disable`` - need be changed. Last, file rte_virtio_net.h will be renamed to rte_vhost.h. - * ABI changes are planned for 17.05 in the ``rte_cryptodev_ops`` structure. A pointer to a rte_cryptodev_config structure will be added to the function prototype ``cryptodev_configure_t``, as a new parameter. diff --git a/doc/guides/rel_notes/release_17_05.rst b/doc/guides/rel_notes/release_17_05.rst index 8f06fc4..c053fff 100644 --- a/doc/guides/rel_notes/release_17_05.rst +++ b/doc/guides/rel_notes/release_17_05.rst @@ -165,6 +165,9 @@ API Changes * The vhost API ``rte_vhost_driver_session_start`` is removed. Instead, ``rte_vhost_driver_start`` should be used. + * The vhost public header file ``rte_virtio_net.h`` is renamed to + ``rte_vhost.h`` + ABI Changes ----------- diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index e6c0758..32e774b 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include "rte_eth_vhost.h" diff --git a/drivers/net/vhost/rte_eth_vhost.h b/drivers/net/vhost/rte_eth_vhost.h index ea4bce4..39ca771 100644 --- a/drivers/net/vhost/rte_eth_vhost.h +++ b/drivers/net/vhost/rte_eth_vhost.h @@ -41,7 +41,7 @@ #include #include -#include +#include /* * Event description. diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c index 24c62cd..cd6e3f1 100644 --- a/examples/tep_termination/main.c +++ b/examples/tep_termination/main.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include "main.h" #include "vxlan.h" diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c index 8f1f15b..87de74d 100644 --- a/examples/tep_termination/vxlan_setup.c +++ b/examples/tep_termination/vxlan_setup.c @@ -49,7 +49,7 @@ #include #include "main.h" -#include "rte_virtio_net.h" +#include "rte_vhost.h" #include "vxlan.h" #include "vxlan_setup.h" diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 64b3eea..08b82f6 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile index 5cf4e93..4847069 100644 --- a/lib/librte_vhost/Makefile +++ b/lib/librte_vhost/Makefile @@ -51,7 +51,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := fd_man.c socket.c vhost.c vhost_user.c \ virtio_net.c # install includes -SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_vhost.h # dependencies DEPDIRS-$(CONFIG_RTE_LIBRTE_VHOST) += lib/librte_eal diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h new file mode 100644 index 0000000..d4ee210 --- /dev/null +++ b/lib/librte_vhost/rte_vhost.h @@ -0,0 +1,421 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2017 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. + */ + +#ifndef _RTE_VHOST_H_ +#define _RTE_VHOST_H_ + +/** + * @file + * Interface to vhost-user + */ + +#include +#include +#include +#include + +#include +#include + +#define RTE_VHOST_USER_CLIENT (1ULL << 0) +#define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1) +#define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2) + +/** + * Information relating to memory regions including offsets to + * addresses in QEMUs memory file. + */ +struct rte_vhost_mem_region { + uint64_t guest_phys_addr; + uint64_t guest_user_addr; + uint64_t host_user_addr; + uint64_t size; + void *mmap_addr; + uint64_t mmap_size; + int fd; +}; + +/** + * Memory structure includes region and mapping information. + */ +struct rte_vhost_memory { + uint32_t nregions; + struct rte_vhost_mem_region regions[0]; +}; + +struct rte_vhost_vring { + struct vring_desc *desc; + struct vring_avail *avail; + struct vring_used *used; + uint64_t log_guest_addr; + + int callfd; + int kickfd; + uint16_t size; +}; + +/** + * Device and vring operations. + */ +struct vhost_device_ops { + int (*new_device)(int vid); /**< Add device. */ + void (*destroy_device)(int vid); /**< Remove device. */ + + int (*vring_state_changed)(int vid, uint16_t queue_id, int enable); /**< triggered when a vring is enabled or disabled */ + + /** + * Features could be changed after the feature negotiation. + * For example, VHOST_F_LOG_ALL will be set/cleared at the + * start/end of live migration, respectively. This callback + * is used to inform the application on such change. + */ + int (*features_changed)(int vid, uint64_t features); + + void *reserved[4]; /**< Reserved for future extension */ +}; + +/** + * Convert guest physical address to host virtual address + * + * @param mem + * the guest memory regions + * @param gpa + * the guest physical address for querying + * @return + * the host virtual address on success, 0 on failure + */ +static inline uint64_t __attribute__((always_inline)) +rte_vhost_gpa_to_vva(struct rte_vhost_memory *mem, uint64_t gpa) +{ + struct rte_vhost_mem_region *reg; + uint32_t i; + + for (i = 0; i < mem->nregions; i++) { + reg = &mem->regions[i]; + if (gpa >= reg->guest_phys_addr && + gpa < reg->guest_phys_addr + reg->size) { + return gpa - reg->guest_phys_addr + + reg->host_user_addr; + } + } + + return 0; +} + +#define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL)) + +/** + * Log the memory write start with given address. + * + * This function only need be invoked when the live migration starts. + * Therefore, we won't need call it at all in the most of time. For + * making the performance impact be minimum, it's suggested to do a + * check before calling it: + * + * if (unlikely(RTE_VHOST_NEED_LOG(features))) + * rte_vhost_log_write(vid, addr, len); + * + * @param vid + * vhost device ID + * @param addr + * the starting address for write + * @param len + * the length to write + */ +void rte_vhost_log_write(int vid, uint64_t addr, uint64_t len); + +/** + * Log the used ring update start at given offset. + * + * Same as rte_vhost_log_write, it's suggested to do a check before + * calling it: + * + * if (unlikely(RTE_VHOST_NEED_LOG(features))) + * rte_vhost_log_used_vring(vid, vring_idx, offset, len); + * + * @param vid + * vhost device ID + * @param vring_idx + * the vring index + * @param offset + * the offset inside the used ring + * @param len + * the length to write + */ +void rte_vhost_log_used_vring(int vid, uint16_t vring_idx, + uint64_t offset, uint64_t len); + +int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable); + +/** + * Register vhost driver. path could be different for multiple + * instance support. + */ +int rte_vhost_driver_register(const char *path, uint64_t flags); + +/* Unregister vhost driver. This is only meaningful to vhost user. */ +int rte_vhost_driver_unregister(const char *path); + +/** + * Set the feature bits the vhost-user driver supports. + * + * @param path + * The vhost-user socket file path + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_driver_set_features(const char *path, uint64_t features); + +/** + * Enable vhost-user driver features. + * + * Note that + * - the param @features should be a subset of the feature bits provided + * by rte_vhost_driver_set_features(). + * - it must be invoked before vhost-user negotiation starts. + * + * @param path + * The vhost-user socket file path + * @param features + * Features to enable + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_driver_enable_features(const char *path, uint64_t features); + +/** + * Disable vhost-user driver features. + * + * The two notes at rte_vhost_driver_enable_features() also apply here. + * + * @param path + * The vhost-user socket file path + * @param features + * Features to disable + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_driver_disable_features(const char *path, uint64_t features); + +/** + * Get the final feature bits for feature negotiation. + * + * @param path + * The vhost-user socket file path + * @return + * Feature bits on success, 0 on failure + */ +uint64_t rte_vhost_driver_get_features(const char *path); + +/** + * Get the feature bits after negotiation + * + * @param vid + * Vhost device ID + * @return + * Negotiated feature bits on success, 0 on failure + */ +uint64_t rte_vhost_get_negotiated_features(int vid); + +/* Register callbacks. */ +int rte_vhost_driver_callback_register(const char *path, + struct vhost_device_ops const * const ops); + +/** + * + * Start the vhost-user driver. + * + * This function triggers the vhost-user negotiation. + * + * @param path + * The vhost-user socket file path + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_driver_start(const char *path); + +/** + * Get the MTU value of the device if set in QEMU. + * + * @param vid + * virtio-net device ID + * @param mtu + * The variable to store the MTU value + * + * @return + * 0: success + * -EAGAIN: device not yet started + * -ENOTSUP: device does not support MTU feature + */ +int rte_vhost_get_mtu(int vid, uint16_t *mtu); + +/** + * Get the numa node from which the virtio net device's memory + * is allocated. + * + * @param vid + * vhost device ID + * + * @return + * The numa node, -1 on failure + */ +int rte_vhost_get_numa_node(int vid); + +/** + * @deprecated + * Get the number of queues the device supports. + * + * Note this function is deprecated, as it returns a queue pair number, + * which is vhost specific. Instead, rte_vhost_get_vring_num should + * be used. + * + * @param vid + * vhost device ID + * + * @return + * The number of queues, 0 on failure + */ +__rte_deprecated +uint32_t rte_vhost_get_queue_num(int vid); + +/** + * Get the number of vrings the device supports. + * + * @param vid + * vhost device ID + * + * @return + * The number of vrings, 0 on failure + */ +uint16_t rte_vhost_get_vring_num(int vid); + +/** + * Get the virtio net device's ifname, which is the vhost-user socket + * file path. + * + * @param vid + * vhost device ID + * @param buf + * The buffer to stored the queried ifname + * @param len + * The length of buf + * + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_get_ifname(int vid, char *buf, size_t len); + +/** + * Get how many avail entries are left in the queue + * + * @param vid + * vhost device ID + * @param queue_id + * virtio queue index + * + * @return + * num of avail entires left + */ +uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id); + +/** + * This function adds buffers to the virtio devices RX virtqueue. Buffers can + * be received from the physical port or from another virtual device. A packet + * count is returned to indicate the number of packets that were succesfully + * added to the RX queue. + * @param vid + * vhost device ID + * @param queue_id + * virtio queue index in mq case + * @param pkts + * array to contain packets to be enqueued + * @param count + * packets num to be enqueued + * @return + * num of packets enqueued + */ +uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id, + struct rte_mbuf **pkts, uint16_t count); + +/** + * This function gets guest buffers from the virtio device TX virtqueue, + * construct host mbufs, copies guest buffer content to host mbufs and + * store them in pkts to be processed. + * @param vid + * vhost device ID + * @param queue_id + * virtio queue index in mq case + * @param mbuf_pool + * mbuf_pool where host mbuf is allocated. + * @param pkts + * array to contain packets to be dequeued + * @param count + * packets num to be dequeued + * @return + * num of packets dequeued + */ +uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id, + struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count); + +/** + * Get guest mem table: a list of memory regions. + * + * An rte_vhost_vhost_memory object will be allocated internaly, to hold the + * guest memory regions. Application should free it at destroy_device() + * callback. + * + * @param vid + * vhost device ID + * @param mem + * To store the returned mem regions + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem); + +/** + * Get guest vring info, including the vring address, vring size, etc. + * + * @param vid + * vhost device ID + * @param vring_idx + * vring index + * @param vring + * the structure to hold the requested vring info + * @return + * 0 on success, -1 on failure + */ +int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, + struct rte_vhost_vring *vring); + +#endif /* _RTE_VHOST_H_ */ diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h deleted file mode 100644 index 627708d..0000000 --- a/lib/librte_vhost/rte_virtio_net.h +++ /dev/null @@ -1,421 +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. - */ - -#ifndef _VIRTIO_NET_H_ -#define _VIRTIO_NET_H_ - -/** - * @file - * Interface to vhost net - */ - -#include -#include -#include -#include - -#include -#include - -#define RTE_VHOST_USER_CLIENT (1ULL << 0) -#define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1) -#define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2) - -/** - * Information relating to memory regions including offsets to - * addresses in QEMUs memory file. - */ -struct rte_vhost_mem_region { - uint64_t guest_phys_addr; - uint64_t guest_user_addr; - uint64_t host_user_addr; - uint64_t size; - void *mmap_addr; - uint64_t mmap_size; - int fd; -}; - -/** - * Memory structure includes region and mapping information. - */ -struct rte_vhost_memory { - uint32_t nregions; - struct rte_vhost_mem_region regions[0]; -}; - -struct rte_vhost_vring { - struct vring_desc *desc; - struct vring_avail *avail; - struct vring_used *used; - uint64_t log_guest_addr; - - int callfd; - int kickfd; - uint16_t size; -}; - -/** - * Device and vring operations. - */ -struct vhost_device_ops { - int (*new_device)(int vid); /**< Add device. */ - void (*destroy_device)(int vid); /**< Remove device. */ - - int (*vring_state_changed)(int vid, uint16_t queue_id, int enable); /**< triggered when a vring is enabled or disabled */ - - /** - * Features could be changed after the feature negotiation. - * For example, VHOST_F_LOG_ALL will be set/cleared at the - * start/end of live migration, respectively. This callback - * is used to inform the application on such change. - */ - int (*features_changed)(int vid, uint64_t features); - - void *reserved[4]; /**< Reserved for future extension */ -}; - -/** - * Convert guest physical address to host virtual address - * - * @param mem - * the guest memory regions - * @param gpa - * the guest physical address for querying - * @return - * the host virtual address on success, 0 on failure - */ -static inline uint64_t __attribute__((always_inline)) -rte_vhost_gpa_to_vva(struct rte_vhost_memory *mem, uint64_t gpa) -{ - struct rte_vhost_mem_region *reg; - uint32_t i; - - for (i = 0; i < mem->nregions; i++) { - reg = &mem->regions[i]; - if (gpa >= reg->guest_phys_addr && - gpa < reg->guest_phys_addr + reg->size) { - return gpa - reg->guest_phys_addr + - reg->host_user_addr; - } - } - - return 0; -} - -#define RTE_VHOST_NEED_LOG(features) ((features) & (1ULL << VHOST_F_LOG_ALL)) - -/** - * Log the memory write start with given address. - * - * This function only need be invoked when the live migration starts. - * Therefore, we won't need call it at all in the most of time. For - * making the performance impact be minimum, it's suggested to do a - * check before calling it: - * - * if (unlikely(RTE_VHOST_NEED_LOG(features))) - * rte_vhost_log_write(vid, addr, len); - * - * @param vid - * vhost device ID - * @param addr - * the starting address for write - * @param len - * the length to write - */ -void rte_vhost_log_write(int vid, uint64_t addr, uint64_t len); - -/** - * Log the used ring update start at given offset. - * - * Same as rte_vhost_log_write, it's suggested to do a check before - * calling it: - * - * if (unlikely(RTE_VHOST_NEED_LOG(features))) - * rte_vhost_log_used_vring(vid, vring_idx, offset, len); - * - * @param vid - * vhost device ID - * @param vring_idx - * the vring index - * @param offset - * the offset inside the used ring - * @param len - * the length to write - */ -void rte_vhost_log_used_vring(int vid, uint16_t vring_idx, - uint64_t offset, uint64_t len); - -int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable); - -/** - * Register vhost driver. path could be different for multiple - * instance support. - */ -int rte_vhost_driver_register(const char *path, uint64_t flags); - -/* Unregister vhost driver. This is only meaningful to vhost user. */ -int rte_vhost_driver_unregister(const char *path); - -/** - * Set the feature bits the vhost-user driver supports. - * - * @param path - * The vhost-user socket file path - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_driver_set_features(const char *path, uint64_t features); - -/** - * Enable vhost-user driver features. - * - * Note that - * - the param @features should be a subset of the feature bits provided - * by rte_vhost_driver_set_features(). - * - it must be invoked before vhost-user negotiation starts. - * - * @param path - * The vhost-user socket file path - * @param features - * Features to enable - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_driver_enable_features(const char *path, uint64_t features); - -/** - * Disable vhost-user driver features. - * - * The two notes at rte_vhost_driver_enable_features() also apply here. - * - * @param path - * The vhost-user socket file path - * @param features - * Features to disable - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_driver_disable_features(const char *path, uint64_t features); - -/** - * Get the final feature bits for feature negotiation. - * - * @param path - * The vhost-user socket file path - * @return - * Feature bits on success, 0 on failure - */ -uint64_t rte_vhost_driver_get_features(const char *path); - -/** - * Get the feature bits after negotiation - * - * @param vid - * Vhost device ID - * @return - * Negotiated feature bits on success, 0 on failure - */ -uint64_t rte_vhost_get_negotiated_features(int vid); - -/* Register callbacks. */ -int rte_vhost_driver_callback_register(const char *path, - struct vhost_device_ops const * const ops); - -/** - * - * Start the vhost-user driver. - * - * This function triggers the vhost-user negotiation. - * - * @param path - * The vhost-user socket file path - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_driver_start(const char *path); - -/** - * Get the MTU value of the device if set in QEMU. - * - * @param vid - * virtio-net device ID - * @param mtu - * The variable to store the MTU value - * - * @return - * 0: success - * -EAGAIN: device not yet started - * -ENOTSUP: device does not support MTU feature - */ -int rte_vhost_get_mtu(int vid, uint16_t *mtu); - -/** - * Get the numa node from which the virtio net device's memory - * is allocated. - * - * @param vid - * vhost device ID - * - * @return - * The numa node, -1 on failure - */ -int rte_vhost_get_numa_node(int vid); - -/** - * @deprecated - * Get the number of queues the device supports. - * - * Note this function is deprecated, as it returns a queue pair number, - * which is vhost specific. Instead, rte_vhost_get_vring_num should - * be used. - * - * @param vid - * vhost device ID - * - * @return - * The number of queues, 0 on failure - */ -__rte_deprecated -uint32_t rte_vhost_get_queue_num(int vid); - -/** - * Get the number of vrings the device supports. - * - * @param vid - * vhost device ID - * - * @return - * The number of vrings, 0 on failure - */ -uint16_t rte_vhost_get_vring_num(int vid); - -/** - * Get the virtio net device's ifname, which is the vhost-user socket - * file path. - * - * @param vid - * vhost device ID - * @param buf - * The buffer to stored the queried ifname - * @param len - * The length of buf - * - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_get_ifname(int vid, char *buf, size_t len); - -/** - * Get how many avail entries are left in the queue - * - * @param vid - * vhost device ID - * @param queue_id - * virtio queue index - * - * @return - * num of avail entires left - */ -uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id); - -/** - * This function adds buffers to the virtio devices RX virtqueue. Buffers can - * be received from the physical port or from another virtual device. A packet - * count is returned to indicate the number of packets that were succesfully - * added to the RX queue. - * @param vid - * vhost device ID - * @param queue_id - * virtio queue index in mq case - * @param pkts - * array to contain packets to be enqueued - * @param count - * packets num to be enqueued - * @return - * num of packets enqueued - */ -uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id, - struct rte_mbuf **pkts, uint16_t count); - -/** - * This function gets guest buffers from the virtio device TX virtqueue, - * construct host mbufs, copies guest buffer content to host mbufs and - * store them in pkts to be processed. - * @param vid - * vhost device ID - * @param queue_id - * virtio queue index in mq case - * @param mbuf_pool - * mbuf_pool where host mbuf is allocated. - * @param pkts - * array to contain packets to be dequeued - * @param count - * packets num to be dequeued - * @return - * num of packets dequeued - */ -uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id, - struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count); - -/** - * Get guest mem table: a list of memory regions. - * - * An rte_vhost_vhost_memory object will be allocated internaly, to hold the - * guest memory regions. Application should free it at destroy_device() - * callback. - * - * @param vid - * vhost device ID - * @param mem - * To store the returned mem regions - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem); - -/** - * Get guest vring info, including the vring address, vring size, etc. - * - * @param vid - * vhost device ID - * @param vring_idx - * vring index - * @param vring - * the structure to hold the requested vring info - * @return - * 0 on success, -1 on failure - */ -int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, - struct rte_vhost_vring *vring); - -#endif /* _VIRTIO_NET_H_ */ diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 8be5b6a..3105a47 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "vhost.h" diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index a199ee6..ddd8a9c 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -46,7 +46,7 @@ #include #include -#include "rte_virtio_net.h" +#include "rte_vhost.h" /* Used to indicate that the device is running on a data core */ #define VIRTIO_DEV_RUNNING 1 diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h index 838dec8..2ba22db 100644 --- a/lib/librte_vhost/vhost_user.h +++ b/lib/librte_vhost/vhost_user.h @@ -37,7 +37,7 @@ #include #include -#include "rte_virtio_net.h" +#include "rte_vhost.h" /* refer to hw/virtio/vhost-user.c */ diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 7ae7904..1004ae6 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include -- 1.9.0