diff --git a/lib/bdev/virtio/bdev_virtio.c b/lib/bdev/virtio/bdev_virtio.c index b982293cf..1d7e26a5d 100644 --- a/lib/bdev/virtio/bdev_virtio.c +++ b/lib/bdev/virtio/bdev_virtio.c @@ -49,7 +49,6 @@ #include #include -#include #include "bdev_virtio.h" diff --git a/lib/bdev/virtio/rte_virtio/virtio_dev.h b/lib/bdev/virtio/rte_virtio/virtio_dev.h index 9a3ffc9f8..26d1fd7a7 100644 --- a/lib/bdev/virtio/rte_virtio/virtio_dev.h +++ b/lib/bdev/virtio/rte_virtio/virtio_dev.h @@ -438,6 +438,23 @@ void virtio_dev_dump_json_config(struct virtio_dev *vdev, struct spdk_json_write */ int virtio_enumerate_pci(void); +/** + * Connect to a vhost-user device and create corresponding virtio_dev. + * + * \param name name of this virtio device + * \param path path to the Unix domain socket of the vhost-user device + * \param requested_queues maximum number of request queues that this + * device will support + * \param queue_size size of each of the queues + * \param fixed_queue_num number of queues preceeding the first + * request queue. For Virtio-SCSI this is equal to 2, as there are + * additional event and control queues. + * \return virtio device + */ +struct virtio_dev *virtio_user_dev_init(const char *name, const char *path, + uint16_t requested_queues, + uint32_t queue_size, uint16_t fixed_queue_num); + extern const struct virtio_pci_ops virtio_user_ops; #endif /* _VIRTIO_DEV_H_ */ diff --git a/lib/bdev/virtio/rte_virtio/virtio_user.c b/lib/bdev/virtio/rte_virtio/virtio_user.c index 3ecf37ec5..e22391648 100644 --- a/lib/bdev/virtio/rte_virtio/virtio_user.c +++ b/lib/bdev/virtio/rte_virtio/virtio_user.c @@ -42,7 +42,7 @@ #include #include "virtio_dev.h" -#include "virtio_user/virtio_user_dev.h" +#include "virtio_user/vhost.h" #include "spdk/string.h" diff --git a/lib/bdev/virtio/rte_virtio/virtio_user/vhost.h b/lib/bdev/virtio/rte_virtio/virtio_user/vhost.h index c1e941767..df5e8a2fd 100644 --- a/lib/bdev/virtio/rte_virtio/virtio_user/vhost.h +++ b/lib/bdev/virtio/rte_virtio/virtio_user/vhost.h @@ -42,6 +42,8 @@ #include "../virtio_dev.h" +#define VIRTIO_MAX_VIRTQUEUES 0x100 + enum vhost_user_request { VHOST_USER_NONE = 0, VHOST_USER_GET_FEATURES = 1, @@ -67,7 +69,22 @@ enum vhost_user_request { extern const char *const vhost_msg_strings[VHOST_USER_MAX]; -struct virtio_user_dev; +struct virtio_user_backend_ops; + +struct virtio_user_dev { + /* for vhost_user backend */ + int vhostfd; + + /* for both vhost_user and vhost_kernel */ + int callfds[VIRTIO_MAX_VIRTQUEUES]; + int kickfds[VIRTIO_MAX_VIRTQUEUES]; + uint32_t queue_size; + + uint8_t status; + char path[PATH_MAX]; + struct vring vrings[VIRTIO_MAX_VIRTQUEUES]; + struct virtio_user_backend_ops *ops; +}; struct virtio_user_backend_ops { int (*setup)(struct virtio_user_dev *dev); diff --git a/lib/bdev/virtio/rte_virtio/virtio_user/vhost_user.c b/lib/bdev/virtio/rte_virtio/virtio_user/vhost_user.c index e70839cfd..71db656ee 100644 --- a/lib/bdev/virtio/rte_virtio/virtio_user/vhost_user.c +++ b/lib/bdev/virtio/rte_virtio/virtio_user/vhost_user.c @@ -34,7 +34,6 @@ #include "spdk/stdinc.h" #include "vhost.h" -#include "virtio_user_dev.h" #include "spdk/string.h" diff --git a/lib/bdev/virtio/rte_virtio/virtio_user/virtio_user_dev.h b/lib/bdev/virtio/rte_virtio/virtio_user/virtio_user_dev.h deleted file mode 100644 index e115164b7..000000000 --- a/lib/bdev/virtio/rte_virtio/virtio_user/virtio_user_dev.h +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2010-2016 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_USER_DEV_H -#define _VIRTIO_USER_DEV_H - -#include "spdk/stdinc.h" - -#include "vhost.h" - -#include "../virtio_dev.h" - -#define VIRTIO_MAX_VIRTQUEUES 0x100 - -struct virtio_user_dev { - /* for vhost_user backend */ - int vhostfd; - - /* for both vhost_user and vhost_kernel */ - int callfds[VIRTIO_MAX_VIRTQUEUES]; - int kickfds[VIRTIO_MAX_VIRTQUEUES]; - uint32_t queue_size; - - uint8_t status; - char path[PATH_MAX]; - struct vring vrings[VIRTIO_MAX_VIRTQUEUES]; - struct virtio_user_backend_ops *ops; -}; - -/** - * Connect to a vhost-user device and create corresponding virtio_dev. - * - * \param name name of this virtio device - * \param path path to the Unix domain socket of the vhost-user device - * \param requested_queues maximum number of request queues that this - * device will support - * \param queue_size size of each of the queues - * \param fixed_queue_num number of queues preceeding the first - * request queue. For Virtio-SCSI this is equal to 2, as there are - * additional event and control queues. - * \return virtio device - */ -struct virtio_dev *virtio_user_dev_init(const char *name, const char *path, - uint16_t requested_queues, - uint32_t queue_size, uint16_t fixed_queue_num); - -#endif