get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1319,
    "url": "https://patches.dpdk.org/api/patches/1319/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416204438-4327-2-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": "<1416204438-4327-2-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1416204438-4327-2-git-send-email-mukawa@igel.co.jp",
    "date": "2014-11-17T06:07:18",
    "name": "[dpdk-dev,RFC,2/2] lib/librte_vhost: Add device abstraction layer",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "dee6917159284d134f91b7ddcd024cc5be40c297",
    "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/1416204438-4327-2-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1319/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1319/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 68DE07FC0;\n\tMon, 17 Nov 2014 06:57:21 +0100 (CET)",
            "from mail-pa0-f46.google.com (mail-pa0-f46.google.com\n\t[209.85.220.46]) by dpdk.org (Postfix) with ESMTP id A2A737FA1\n\tfor <dev@dpdk.org>; Mon, 17 Nov 2014 06:57:15 +0100 (CET)",
            "by mail-pa0-f46.google.com with SMTP id lf10so21608771pab.33\n\tfor <dev@dpdk.org>; Sun, 16 Nov 2014 22:07:30 -0800 (PST)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\toe10sm33953028pdb.66.2014.11.16.22.07.28 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tSun, 16 Nov 2014 22:07:29 -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=EVtPB80pTQe/yf/aWSmCqvGqgS1Awn4bkQvBpfS61b8=;\n\tb=ZAj4H8KSB3zvUn1WtKNk9H6INDn+sXJ5L5XcRTBxLd2n6I3Kg4ha9DvtAJeuvhEWPJ\n\tsje3Hev0n02ZpLWQB793aMRlw/J1w1G+4eTegb7GAVMhGVcyzqRSYv28014+i40JgJmc\n\tRBvx1emUzxGMrQxD+aT1mfpBitG0MNNpFQzZx87ql/U1vLHP7E1ZH087QhZJ1+9mnP5h\n\t7MDeeIIAYvWuBVm1tK76483na2R0/iUysBfKtt2sOdAtuWIM7WFkpnIr5lmBwF+G5VWZ\n\tPtgTwNXWNFQMQn/nt5fyFGcExw2FVbwUJSE+G2dEJbjb6BSDaPSmC16zourJ7FrH7BPW\n\tFQOg==",
        "X-Gm-Message-State": "ALoCoQmdclsgqd9RGj+kIyTAmLwzPNh8n4ASUbNMBziVsVwuThyGuB/EHv6ExLMCu04LALOip32S",
        "X-Received": "by 10.66.188.200 with SMTP id gc8mr27607838pac.38.1416204450480; \n\tSun, 16 Nov 2014 22:07:30 -0800 (PST)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 17 Nov 2014 15:07:18 +0900",
        "Message-Id": "<1416204438-4327-2-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1416204438-4327-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1416014087-22499-1-git-send-email-huawei.xie@intel.com>\n\t<1416204438-4327-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [RFC PATCH 2/2] lib/librte_vhost: Add device abstraction\n\tlayer",
        "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": "---\n lib/librte_vhost/Makefile                     |   6 +-\n lib/librte_vhost/rte_virtio_net.h             |  22 ++++-\n lib/librte_vhost/vhost-cuse/vhost-net-cdev.c  |   6 +-\n lib/librte_vhost/vhost-cuse/vhost-net-cdev.h  |  40 +++++++++\n lib/librte_vhost/vhost-cuse/virtio-net-cdev.c |   1 +\n lib/librte_vhost/vhost-net.c                  | 101 +++++++++++++++++++++++\n lib/librte_vhost/vhost-net.h                  | 114 ++++++++++++++++++++++++++\n lib/librte_vhost/vhost-user/vhost-net-user.c  |   6 +-\n lib/librte_vhost/vhost-user/vhost-net-user.h  |   3 +\n lib/librte_vhost/vhost-user/virtio-net-user.c |   1 +\n 10 files changed, 290 insertions(+), 10 deletions(-)\n create mode 100644 lib/librte_vhost/vhost-cuse/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 cb4e172..4363a14 100644\n--- a/lib/librte_vhost/Makefile\n+++ b/lib/librte_vhost/Makefile\n@@ -37,11 +37,11 @@ LIB = librte_vhost.a\n CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -I. -I vhost-user -I vhost-cuse -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-cuse/vhost-net-cdev.c vhost-cuse/virtio-net-cdev.c\n+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost-cuse/vhost-net-cdev.c vhost-cuse/virtio-net-cdev.c\n \n-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := vhost-user/fd_man.c vhost-user/vhost-net-user.c vhost-user/virtio-net-user.c\n+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) += vhost-user/fd_man.c vhost-user/vhost-net-user.c vhost-user/virtio-net-user.c\n \n-SRCS-$(CONFIG_RTE_LIBRTE_VHOST) += virtio-net.c vhost_rxtx.c\n+SRCS-$(CONFIG_RTE_LIBRTE_VHOST) += virtio-net.c vhost_rxtx.c vhost-net.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 a09533d..116c7e9 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -140,6 +140,23 @@ gpa_to_vva(struct virtio_net *dev, uint64_t guest_pa)\n }\n \n /**\n+ * Enum for vhost driver types.\n+ */\n+enum rte_vhost_driver_t {\n+       VHOST_DRV_CUSE, /* vhost-cuse driver */\n+       VHOST_DRV_USER, /* vhost-user driver */\n+       VHOST_DRV_NUM   /* the number of vhost driver types */\n+};\n+\n+/**\n+  * Structure contains information relating vhost driver.\n+  */\n+struct rte_vhost_driver {\n+\tenum rte_vhost_driver_t type;\t\t/**< driver type. */\n+\tconst char\t\t*dev_name;\t/**< accessing device name. */\n+};\n+\n+/**\n  * Disable features in feature_mask. Returns 0 on success.\n  */\n int rte_vhost_feature_disable(uint64_t feature_mask);\n@@ -155,12 +172,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 rte_vhost_driver *rte_vhost_driver_register(\n+\t\tconst char *dev_name, enum rte_vhost_driver_t type);\n \n /* Register callbacks. */\n int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * const);\n \n-int rte_vhost_driver_session_start(void);\n+int rte_vhost_driver_session_start(struct rte_vhost_driver *drv);\n \n /**\n  * This function adds buffers to the virtio devices RX virtqueue. Buffers can\ndiff --git a/lib/librte_vhost/vhost-cuse/vhost-net-cdev.c b/lib/librte_vhost/vhost-cuse/vhost-net-cdev.c\nindex 688ec00..6ea54ee 100644\n--- a/lib/librte_vhost/vhost-cuse/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost-cuse/vhost-net-cdev.c\n@@ -47,6 +47,7 @@\n \n #include \"virtio-net-cdev.h\"\n #include \"vhost-net.h\"\n+#include \"vhost-net-cdev.h\"\n #include \"eventfd_link/eventfd_link.h\"\n \n #define FUSE_OPT_DUMMY \"\\0\\0\"\n@@ -373,8 +374,9 @@ static const struct cuse_lowlevel_ops vhost_net_ops = {\n  * vhost_net_device_ops are also passed when the device is registered in app.\n  */\n int\n-rte_vhost_driver_register(const char *dev_name)\n+vhost_cuse_driver_register(struct rte_vhost_driver *drv)\n {\n+\tconst char *dev_name = drv->dev_name;\n \tstruct cuse_info cuse_info;\n \tchar device_name[PATH_MAX] = \"\";\n \tchar char_device_name[PATH_MAX] = \"\";\n@@ -428,7 +430,7 @@ rte_vhost_driver_register(const char *dev_name)\n  * release and ioctl calls.\n  */\n int\n-rte_vhost_driver_session_start(void)\n+vhost_cuse_driver_session_start(void)\n {\n \tfuse_session_loop(session);\n \ndiff --git a/lib/librte_vhost/vhost-cuse/vhost-net-cdev.h b/lib/librte_vhost/vhost-cuse/vhost-net-cdev.h\nnew file mode 100644\nindex 0000000..cb094ee\n--- /dev/null\n+++ b/lib/librte_vhost/vhost-cuse/vhost-net-cdev.h\n@@ -0,0 +1,40 @@\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+#ifndef _VHOST_NET_CDEV_H\n+#define _VHOST_NET_CDEV_H\n+\n+int vhost_cuse_driver_register(struct rte_vhost_driver *drv);\n+int vhost_cuse_driver_session_start(void);\n+\n+#endif\ndiff --git a/lib/librte_vhost/vhost-cuse/virtio-net-cdev.c b/lib/librte_vhost/vhost-cuse/virtio-net-cdev.c\nindex 7381140..42a6b24 100644\n--- a/lib/librte_vhost/vhost-cuse/virtio-net-cdev.c\n+++ b/lib/librte_vhost/vhost-cuse/virtio-net-cdev.c\n@@ -46,6 +46,7 @@\n #include <errno.h>\n \n #include <rte_log.h>\n+#include <rte_virtio_net.h>\n \n #include \"vhost-net.h\"\n #include \"virtio-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..7a4537d\n--- /dev/null\n+++ b/lib/librte_vhost/vhost-net.c\n@@ -0,0 +1,101 @@\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-cuse/vhost-net-cdev.h\"\n+#include \"vhost-user/vhost-net-user.h\"\n+\n+/**\n+ * This function abstracts cuse and vhost-user driver registration.\n+ */\n+struct rte_vhost_driver *\n+rte_vhost_driver_register(const char *dev_name, enum rte_vhost_driver_t type)\n+{\n+\tint ret;\n+\tstruct rte_vhost_driver *drv;\n+\n+\tdrv = rte_zmalloc(dev_name, sizeof(struct rte_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+\tcase VHOST_DRV_USER:\n+\t\tret = vhost_user_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 session is launched allowing the application to\n+ * receive open, release and ioctl calls.\n+ */\n+int\n+rte_vhost_driver_session_start(struct rte_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();\n+\t\tbreak;\n+\tcase VHOST_DRV_USER:\n+\t\tvhost_user_driver_session_start();\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+\n+\treturn 0;\n+}\ndiff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h\nnew file mode 100644\nindex 0000000..881a45f\n--- /dev/null\n+++ b/lib/librte_vhost/vhost-net.h\n@@ -0,0 +1,114 @@\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_H_\n+#define _VHOST_NET_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 VHOST_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 VHOST_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,\n+\t\t\tconst struct virtio_memory_regions *, 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_H_ */\ndiff --git a/lib/librte_vhost/vhost-user/vhost-net-user.c b/lib/librte_vhost/vhost-user/vhost-net-user.c\nindex 0b100ba..837f840 100644\n--- a/lib/librte_vhost/vhost-user/vhost-net-user.c\n+++ b/lib/librte_vhost/vhost-user/vhost-net-user.c\n@@ -371,9 +371,9 @@ vserver_message_handler(int connfd, uint64_t dat)\n  * Creates and initialise the vhost server.\n  */\n int\n-rte_vhost_driver_register(const char *path)\n+vhost_user_driver_register(struct rte_vhost_driver *drv)\n {\n-\n+\tconst char *path = drv->dev_name;\n \tstruct vhost_server *vserver;\n \n \tif (g_vhost_server != NULL)\n@@ -408,7 +408,7 @@ rte_vhost_driver_register(const char *path)\n \n \n int\n-rte_vhost_driver_session_start(void)\n+vhost_user_driver_session_start(void)\n {\n \tfdset_event_dispatch(&g_vhost_server->fdset);\n \treturn 0;\ndiff --git a/lib/librte_vhost/vhost-user/vhost-net-user.h b/lib/librte_vhost/vhost-user/vhost-net-user.h\nindex c9df9fa..d90c147 100644\n--- a/lib/librte_vhost/vhost-user/vhost-net-user.h\n+++ b/lib/librte_vhost/vhost-user/vhost-net-user.h\n@@ -71,4 +71,7 @@ typedef struct VhostUserMsg {\n #define VHOST_USER_VERSION    (0x1)\n \n /*****************************************************************************/\n+int vhost_user_driver_register(struct rte_vhost_driver *drv);\n+int vhost_user_driver_session_start(void);\n+\n #endif\ndiff --git a/lib/librte_vhost/vhost-user/virtio-net-user.c b/lib/librte_vhost/vhost-user/virtio-net-user.c\nindex 4103977..f839219 100644\n--- a/lib/librte_vhost/vhost-user/virtio-net-user.c\n+++ b/lib/librte_vhost/vhost-user/virtio-net-user.c\n@@ -38,6 +38,7 @@\n #include <sys/mman.h>\n \n #include <rte_log.h>\n+#include <rte_virtio_net.h>\n \n #include \"virtio-net-user.h\"\n #include \"vhost-net-user.h\"\n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "2/2"
    ]
}