get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1152/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1152,
    "url": "https://patches.dpdk.org/api/patches/1152/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1415272471-3299-3-git-send-email-mukawa@igel.co.jp/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1415272471-3299-3-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1415272471-3299-3-git-send-email-mukawa@igel.co.jp",
    "date": "2014-11-06T11:14:26",
    "name": "[dpdk-dev,RFC,2/7] lib/librte_vhost: Add an abstraction layer for vhost backends",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "0404a3df41f6bf2d4fd5548da0ed3d6af5cfe22f",
    "submitter": {
        "id": 64,
        "url": "https://patches.dpdk.org/api/people/64/?format=api",
        "name": "Tetsuya Mukawa",
        "email": "mukawa@igel.co.jp"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1415272471-3299-3-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1152/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1152/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 3BD927F39;\n\tThu,  6 Nov 2014 12:05:44 +0100 (CET)",
            "from mail-pa0-f51.google.com (mail-pa0-f51.google.com\n\t[209.85.220.51]) by dpdk.org (Postfix) with ESMTP id 000F07E80\n\tfor <dev@dpdk.org>; Thu,  6 Nov 2014 12:05:32 +0100 (CET)",
            "by mail-pa0-f51.google.com with SMTP id kq14so1053931pab.24\n\tfor <dev@dpdk.org>; Thu, 06 Nov 2014 03:14:59 -0800 (PST)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\tjc3sm5652315pbb.49.2014.11.06.03.14.57 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 06 Nov 2014 03:14:58 -0800 (PST)"
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=PzXWFZQo0PHaf2C9egQIenSVCJdYyW6gW1YReq2LaEk=;\n\tb=eiF7o63GjYwHYUq5xLDbjFcTH3YOWiP+nFBwQtqRyZjegrbWsgy181I+T8U61UjR4H\n\tyg/x6F3Lz6XEXyIHnhFlMTvPaiHZAWGNJdEXjRl4vvb4NIiK/aVw30azPoozUjkQ4xU8\n\tU2vAknckT4B4FG/3HQ3GUgik2zTx4APqlWxrAuhn5q7e2bIO8p032JrUPsOyC6nsKyDN\n\tkLIezmGG2MHlwaGvJH7fv+avpv5iIbVx7CMt+vG2+k1+m//pBfHK9rjvba7jyWbYNVBQ\n\tAQ585PYy1TACP2jpT7czAljzIJdHu7T+UkACNYWEyCvXdKnvYYZbOTmiADZqIL9dZ1P8\n\t2sYQ==",
        "X-Gm-Message-State": "ALoCoQks4Yy+YoyPcIgi9BwRwVnB/VFm1+z8yDq5Zf5w80QgE2PAP6N7kYjU1iKwLrFAcBx8tuyU",
        "X-Received": "by 10.68.201.130 with SMTP id ka2mr3685082pbc.112.1415272499376; \n\tThu, 06 Nov 2014 03:14:59 -0800 (PST)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Thu,  6 Nov 2014 20:14:26 +0900",
        "Message-Id": "<1415272471-3299-3-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1415272471-3299-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1415272471-3299-1-git-send-email-mukawa@igel.co.jp>",
        "Cc": "nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp",
        "Subject": "[dpdk-dev] [RFC PATCH 2/7] lib/librte_vhost: Add an abstraction\n\tlayer for vhost backends",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The patch adds an abstraction layer for vhost backends.\nSo far CUSE is the only one vhost backend. But QEMU-2.1 can have one\nmore backend called vhost-user. To handle both backends, this kind of\nlayer is needed.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_vhost/Makefile         |   2 +-\n lib/librte_vhost/rte_virtio_net.h |  30 ++++++++--\n lib/librte_vhost/vhost-net-cdev.c |  24 ++++----\n lib/librte_vhost/vhost-net-cdev.h | 113 --------------------------------------\n lib/librte_vhost/vhost-net.c      |  97 ++++++++++++++++++++++++++++++++\n lib/librte_vhost/vhost-net.h      | 113 ++++++++++++++++++++++++++++++++++++++\n lib/librte_vhost/vhost_rxtx.c     |   2 +-\n lib/librte_vhost/virtio-net.c     |   2 +-\n 8 files changed, 252 insertions(+), 131 deletions(-)\n delete mode 100644 lib/librte_vhost/vhost-net-cdev.h\n create mode 100644 lib/librte_vhost/vhost-net.c\n create mode 100644 lib/librte_vhost/vhost-net.h",
    "diff": "diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile\nindex c008d64..0d4aa98 100644\n--- a/lib/librte_vhost/Makefile\n+++ b/lib/librte_vhost/Makefile\n@@ -37,7 +37,7 @@ LIB = librte_vhost.a\n CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64 -lfuse\n LDFLAGS += -lfuse\n # all source are stored in SRCS-y\n-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost-net-cdev.c virtio-net.c vhost_rxtx.c\n+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost-net.c virtio-net.c vhost_rxtx.c\n \n # install includes\n SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_virtio_net.h\ndiff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h\nindex b6548a1..a36c0e3 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -31,8 +31,8 @@\n  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n  */\n \n-#ifndef _VIRTIO_NET_H_\n-#define _VIRTIO_NET_H_\n+#ifndef _RTE_VIRTIO_NET_H_\n+#define _RTE_VIRTIO_NET_H_\n \n /**\n  * @file\n@@ -71,6 +71,25 @@ struct buf_vector {\n };\n \n /**\n+ * Enum for vhost driver types.\n+ */\n+typedef enum {\n+\tVHOST_DRV_CUSE, /* cuse driver */\n+\tVHOST_DRV_NUM\t/* the number of vhost driver types */\n+} vhost_driver_type_t;\n+\n+/**\n+ * Structure contains information relating vhost driver.\n+ */\n+struct vhost_driver {\n+\tvhost_driver_type_t\ttype;\t\t/**< driver type. */\n+\tconst char\t\t*dev_name;\t/**< accessing device name. */\n+\tunion {\n+\t\tstruct fuse_session *session;\t/**< fuse session. */\n+\t};\n+};\n+\n+/**\n  * Structure contains variables relevant to RX/TX virtqueues.\n  */\n struct vhost_virtqueue {\n@@ -176,12 +195,13 @@ uint64_t rte_vhost_feature_get(void);\n int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable);\n \n /* Register vhost driver. dev_name could be different for multiple instance support. */\n-int rte_vhost_driver_register(const char *dev_name);\n+struct vhost_driver *rte_vhost_driver_register(\n+\t\tconst char *dev_name, vhost_driver_type_t type);\n \n /* Register callbacks. */\n int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * const);\n /* Start vhost driver session blocking loop. */\n-int rte_vhost_driver_session_start(void);\n+int rte_vhost_driver_session_start(struct vhost_driver *drv);\n \n /**\n  * This function adds buffers to the virtio devices RX virtqueue. Buffers can\n@@ -210,4 +230,4 @@ uint16_t rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id,\n uint16_t rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \tstruct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count);\n \n-#endif /* _VIRTIO_NET_H_ */\n+#endif /* _RTE_VIRTIO_NET_H_ */\ndiff --git a/lib/librte_vhost/vhost-net-cdev.c b/lib/librte_vhost/vhost-net-cdev.c\nindex 91ff0d8..83e1d14 100644\n--- a/lib/librte_vhost/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost-net-cdev.c\n@@ -2,7 +2,6 @@\n  *   BSD LICENSE\n  *\n  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n- *   All rights reserved.\n  *\n  *   Redistribution and use in source and binary forms, with or without\n  *   modification, are permitted provided that the following conditions\n@@ -44,7 +43,7 @@\n #include <rte_string_fns.h>\n #include <rte_virtio_net.h>\n \n-#include \"vhost-net-cdev.h\"\n+#include \"vhost-net.h\"\n \n #define FUSE_OPT_DUMMY\t\t\"\\0\\0\"\n #define FUSE_OPT_FORE\t\t\"-f\\0\\0\"\n@@ -55,7 +54,6 @@ static const uint32_t\tdefault_minor = 1;\n static const char\tcuse_device_name[]\t= \"/dev/cuse\";\n static const char\tdefault_cdev[] = \"vhost-net\";\n \n-static struct fuse_session\t\t\t*session;\n static struct vhost_net_device_ops\tconst *ops;\n \n /*\n@@ -300,9 +298,10 @@ static const struct cuse_lowlevel_ops vhost_net_ops = {\n  * cuse_info is populated and used to register the cuse device. vhost_net_device_ops are\n  * also passed when the device is registered in main.c.\n  */\n-int\n-rte_vhost_driver_register(const char *dev_name)\n+static int\n+vhost_cuse_driver_register(struct vhost_driver *drv)\n {\n+\tconst char *dev_name;\n \tstruct cuse_info cuse_info;\n \tchar device_name[PATH_MAX] = \"\";\n \tchar char_device_name[PATH_MAX] = \"\";\n@@ -318,6 +317,11 @@ rte_vhost_driver_register(const char *dev_name)\n \t\treturn -1;\n \t}\n \n+\tif (drv == NULL)\n+\t\treturn -1;\n+\n+\tdev_name = drv->dev_name;\n+\n \t/*\n \t * The device name is created. This is passed to QEMU so that it can register\n \t * the device with our application.\n@@ -340,9 +344,9 @@ rte_vhost_driver_register(const char *dev_name)\n \n \tops = get_virtio_net_callbacks();\n \n-\tsession = cuse_lowlevel_setup(3, fuse_argv,\n+\tdrv->session = cuse_lowlevel_setup(3, fuse_argv,\n \t\t\t\t&cuse_info, &vhost_net_ops, 0, NULL);\n-\tif (session == NULL)\n+\tif (drv->session == NULL)\n \t\treturn -1;\n \n \treturn 0;\n@@ -351,10 +355,10 @@ rte_vhost_driver_register(const char *dev_name)\n /**\n  * The CUSE session is launched allowing the application to receive open, release and ioctl calls.\n  */\n-int\n-rte_vhost_driver_session_start(void)\n+static int\n+vhost_cuse_driver_session_start(struct vhost_driver *drv)\n {\n-\tfuse_session_loop(session);\n+\tfuse_session_loop(drv->session);\n \n \treturn 0;\n }\ndiff --git a/lib/librte_vhost/vhost-net-cdev.h b/lib/librte_vhost/vhost-net-cdev.h\ndeleted file mode 100644\nindex 03a5c57..0000000\n--- a/lib/librte_vhost/vhost-net-cdev.h\n+++ /dev/null\n@@ -1,113 +0,0 @@\n-/*-\n- *   BSD LICENSE\n- *\n- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n- *   All rights reserved.\n- *\n- *   Redistribution and use in source and binary forms, with or without\n- *   modification, are permitted provided that the following conditions\n- *   are met:\n- *\n- *     * Redistributions of source code must retain the above copyright\n- *       notice, this list of conditions and the following disclaimer.\n- *     * Redistributions in binary form must reproduce the above copyright\n- *       notice, this list of conditions and the following disclaimer in\n- *       the documentation and/or other materials provided with the\n- *       distribution.\n- *     * Neither the name of Intel Corporation nor the names of its\n- *       contributors may be used to endorse or promote products derived\n- *       from this software without specific prior written permission.\n- *\n- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n- *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n- */\n-\n-#ifndef _VHOST_NET_CDEV_H_\n-#define _VHOST_NET_CDEV_H_\n-#include <stdint.h>\n-#include <stdio.h>\n-#include <sys/types.h>\n-#include <unistd.h>\n-#include <linux/vhost.h>\n-\n-#include <rte_log.h>\n-\n-/* Macros for printing using RTE_LOG */\n-#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1\n-#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1\n-\n-#ifdef RTE_LIBRTE_VHOST_DEBUG\n-#define VHOST_MAX_PRINT_BUFF 6072\n-#define LOG_LEVEL RTE_LOG_DEBUG\n-#define LOG_DEBUG(log_type, fmt, args...) RTE_LOG(DEBUG, log_type, fmt, ##args)\n-#define PRINT_PACKET(device, addr, size, header) do { \\\n-\tchar *pkt_addr = (char *)(addr); \\\n-\tunsigned int index; \\\n-\tchar packet[VHOST_MAX_PRINT_BUFF]; \\\n-\t\\\n-\tif ((header)) \\\n-\t\tsnprintf(packet, VHOST_MAX_PRINT_BUFF, \"(%\"PRIu64\") Header size %d: \", (device->device_fh), (size)); \\\n-\telse \\\n-\t\tsnprintf(packet, VHOST_MAX_PRINT_BUFF, \"(%\"PRIu64\") Packet size %d: \", (device->device_fh), (size)); \\\n-\tfor (index = 0; index < (size); index++) { \\\n-\t\tsnprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \\\n-\t\t\t\"%02hhx \", pkt_addr[index]); \\\n-\t} \\\n-\tsnprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \"\\n\"); \\\n-\t\\\n-\tLOG_DEBUG(VHOST_DATA, \"%s\", packet); \\\n-} while (0)\n-#else\n-#define LOG_LEVEL RTE_LOG_INFO\n-#define LOG_DEBUG(log_type, fmt, args...) do {} while (0)\n-#define PRINT_PACKET(device, addr, size, header) do {} while (0)\n-#endif\n-\n-\n-/*\n- * Structure used to identify device context.\n- */\n-struct vhost_device_ctx {\n-\tpid_t\t\tpid;\t/* PID of process calling the IOCTL. */\n-\tuint64_t\tfh;\t/* Populated with fi->fh to track the device index. */\n-};\n-\n-/*\n- * Structure contains function pointers to be defined in virtio-net.c. These\n- * functions are called in CUSE context and are used to configure devices.\n- */\n-struct vhost_net_device_ops {\n-\tint (*new_device)(struct vhost_device_ctx);\n-\tvoid (*destroy_device)(struct vhost_device_ctx);\n-\n-\tint (*get_features)(struct vhost_device_ctx, uint64_t *);\n-\tint (*set_features)(struct vhost_device_ctx, uint64_t *);\n-\n-\tint (*set_mem_table)(struct vhost_device_ctx, const void *, uint32_t);\n-\n-\tint (*set_vring_num)(struct vhost_device_ctx, struct vhost_vring_state *);\n-\tint (*set_vring_addr)(struct vhost_device_ctx, struct vhost_vring_addr *);\n-\tint (*set_vring_base)(struct vhost_device_ctx, struct vhost_vring_state *);\n-\tint (*get_vring_base)(struct vhost_device_ctx, uint32_t, struct vhost_vring_state *);\n-\n-\tint (*set_vring_kick)(struct vhost_device_ctx, struct vhost_vring_file *);\n-\tint (*set_vring_call)(struct vhost_device_ctx, struct vhost_vring_file *);\n-\n-\tint (*set_backend)(struct vhost_device_ctx, struct vhost_vring_file *);\n-\n-\tint (*set_owner)(struct vhost_device_ctx);\n-\tint (*reset_owner)(struct vhost_device_ctx);\n-};\n-\n-\n-struct vhost_net_device_ops const *get_virtio_net_callbacks(void);\n-#endif /* _VHOST_NET_CDEV_H_ */\ndiff --git a/lib/librte_vhost/vhost-net.c b/lib/librte_vhost/vhost-net.c\nnew file mode 100644\nindex 0000000..b0de5fd\n--- /dev/null\n+++ b/lib/librte_vhost/vhost-net.c\n@@ -0,0 +1,97 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2014 IGEL Co.,Ltd. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of IGEL nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <errno.h>\n+#include <rte_malloc.h>\n+#include <rte_virtio_net.h>\n+\n+#include \"vhost-net.h\"\n+\n+/**\n+ * Include cuse depend functions and definitions\n+ */\n+#include \"vhost-net-cdev.c\"\n+\n+/**\n+ * This function abstracts cuse and vhost-user driver registration.\n+ */\n+struct vhost_driver *\n+rte_vhost_driver_register(const char *dev_name, vhost_driver_type_t type)\n+{\n+\tint ret;\n+\tstruct vhost_driver *drv;\n+\n+\tdrv = rte_zmalloc(dev_name, sizeof(struct vhost_driver),\n+\t\t\tCACHE_LINE_SIZE);\n+\tif (drv == NULL)\n+\t\treturn NULL;\n+\n+\tdrv->dev_name = dev_name;\n+\tdrv->type = type;\n+\n+\tswitch (type) {\n+\tcase VHOST_DRV_CUSE:\n+\t\tret = vhost_cuse_driver_register(drv);\n+\t\tif (ret != 0)\n+\t\t\tgoto err;\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\treturn drv;\n+err:\n+\tfree(drv);\n+\treturn NULL;\n+}\n+\n+/**\n+ * The CUSE session is launched allowing the application to receive open, release and ioctl calls.\n+ */\n+int\n+rte_vhost_driver_session_start(struct vhost_driver *drv)\n+{\n+\tif (drv == NULL)\n+\t\treturn -ENODEV;\n+\n+\tswitch (drv->type) {\n+\tcase VHOST_DRV_CUSE:\n+\t\tvhost_cuse_driver_session_start(drv);\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\treturn 0;\n+}\n+\ndiff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h\nnew file mode 100644\nindex 0000000..03a5c57\n--- /dev/null\n+++ b/lib/librte_vhost/vhost-net.h\n@@ -0,0 +1,113 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _VHOST_NET_CDEV_H_\n+#define _VHOST_NET_CDEV_H_\n+#include <stdint.h>\n+#include <stdio.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+#include <linux/vhost.h>\n+\n+#include <rte_log.h>\n+\n+/* Macros for printing using RTE_LOG */\n+#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1\n+#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1\n+\n+#ifdef RTE_LIBRTE_VHOST_DEBUG\n+#define VHOST_MAX_PRINT_BUFF 6072\n+#define LOG_LEVEL RTE_LOG_DEBUG\n+#define LOG_DEBUG(log_type, fmt, args...) RTE_LOG(DEBUG, log_type, fmt, ##args)\n+#define PRINT_PACKET(device, addr, size, header) do { \\\n+\tchar *pkt_addr = (char *)(addr); \\\n+\tunsigned int index; \\\n+\tchar packet[VHOST_MAX_PRINT_BUFF]; \\\n+\t\\\n+\tif ((header)) \\\n+\t\tsnprintf(packet, VHOST_MAX_PRINT_BUFF, \"(%\"PRIu64\") Header size %d: \", (device->device_fh), (size)); \\\n+\telse \\\n+\t\tsnprintf(packet, VHOST_MAX_PRINT_BUFF, \"(%\"PRIu64\") Packet size %d: \", (device->device_fh), (size)); \\\n+\tfor (index = 0; index < (size); index++) { \\\n+\t\tsnprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \\\n+\t\t\t\"%02hhx \", pkt_addr[index]); \\\n+\t} \\\n+\tsnprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \"\\n\"); \\\n+\t\\\n+\tLOG_DEBUG(VHOST_DATA, \"%s\", packet); \\\n+} while (0)\n+#else\n+#define LOG_LEVEL RTE_LOG_INFO\n+#define LOG_DEBUG(log_type, fmt, args...) do {} while (0)\n+#define PRINT_PACKET(device, addr, size, header) do {} while (0)\n+#endif\n+\n+\n+/*\n+ * Structure used to identify device context.\n+ */\n+struct vhost_device_ctx {\n+\tpid_t\t\tpid;\t/* PID of process calling the IOCTL. */\n+\tuint64_t\tfh;\t/* Populated with fi->fh to track the device index. */\n+};\n+\n+/*\n+ * Structure contains function pointers to be defined in virtio-net.c. These\n+ * functions are called in CUSE context and are used to configure devices.\n+ */\n+struct vhost_net_device_ops {\n+\tint (*new_device)(struct vhost_device_ctx);\n+\tvoid (*destroy_device)(struct vhost_device_ctx);\n+\n+\tint (*get_features)(struct vhost_device_ctx, uint64_t *);\n+\tint (*set_features)(struct vhost_device_ctx, uint64_t *);\n+\n+\tint (*set_mem_table)(struct vhost_device_ctx, const void *, uint32_t);\n+\n+\tint (*set_vring_num)(struct vhost_device_ctx, struct vhost_vring_state *);\n+\tint (*set_vring_addr)(struct vhost_device_ctx, struct vhost_vring_addr *);\n+\tint (*set_vring_base)(struct vhost_device_ctx, struct vhost_vring_state *);\n+\tint (*get_vring_base)(struct vhost_device_ctx, uint32_t, struct vhost_vring_state *);\n+\n+\tint (*set_vring_kick)(struct vhost_device_ctx, struct vhost_vring_file *);\n+\tint (*set_vring_call)(struct vhost_device_ctx, struct vhost_vring_file *);\n+\n+\tint (*set_backend)(struct vhost_device_ctx, struct vhost_vring_file *);\n+\n+\tint (*set_owner)(struct vhost_device_ctx);\n+\tint (*reset_owner)(struct vhost_device_ctx);\n+};\n+\n+\n+struct vhost_net_device_ops const *get_virtio_net_callbacks(void);\n+#endif /* _VHOST_NET_CDEV_H_ */\ndiff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex 84ec0e8..dad9db9 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -38,7 +38,7 @@\n #include <rte_memcpy.h>\n #include <rte_virtio_net.h>\n \n-#include \"vhost-net-cdev.h\"\n+#include \"vhost-net.h\"\n \n #define MAX_PKT_BURST 32\n \ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex 9155a68..1dee1d8 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -49,7 +49,7 @@\n #include <rte_memory.h>\n #include <rte_virtio_net.h>\n \n-#include \"vhost-net-cdev.h\"\n+#include \"vhost-net.h\"\n #include \"eventfd_link/eventfd_link.h\"\n \n /**\n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "2/7"
    ]
}