get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1134,
    "url": "https://patches.dpdk.org/api/patches/1134/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1415162572-25941-1-git-send-email-huawei.xie@intel.com/",
    "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": "<1415162572-25941-1-git-send-email-huawei.xie@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1415162572-25941-1-git-send-email-huawei.xie@intel.com",
    "date": "2014-11-05T04:42:52",
    "name": "[dpdk-dev] lib/librte_vhost: code style fixes",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": true,
    "hash": "9e72f07946170d680048b636bd7c0f84718470a3",
    "submitter": {
        "id": 16,
        "url": "https://patches.dpdk.org/api/people/16/?format=api",
        "name": "Huawei Xie",
        "email": "huawei.xie@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1415162572-25941-1-git-send-email-huawei.xie@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1134/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1134/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 0706A5944;\n\tWed,  5 Nov 2014 05:33:41 +0100 (CET)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 6A20A2E89\n\tfor <dev@dpdk.org>; Wed,  5 Nov 2014 05:33:38 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga102.fm.intel.com with ESMTP; 04 Nov 2014 20:42:58 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga001.fm.intel.com with ESMTP; 04 Nov 2014 20:42:55 -0800",
            "from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com\n\t[10.239.29.90])\n\tby shvmail01.sh.intel.com with ESMTP id sA54gtfx024036\n\tfor <dev@dpdk.org>; Wed, 5 Nov 2014 12:42:55 +0800",
            "from shecgisg003.sh.intel.com (localhost [127.0.0.1])\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP\n\tid\n\tsA54grJd025976 for <dev@dpdk.org>; Wed, 5 Nov 2014 12:42:55 +0800",
            "(from hxie5@localhost)\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id sA54gq88025972\n\tfor dev@dpdk.org; Wed, 5 Nov 2014 12:42:52 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.07,317,1413270000\"; d=\"scan'208\";a=\"617319798\"",
        "From": "Huawei Xie <huawei.xie@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Wed,  5 Nov 2014 12:42:52 +0800",
        "Message-Id": "<1415162572-25941-1-git-send-email-huawei.xie@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "Subject": "[dpdk-dev] [PATCH] lib/librte_vhost: code style fixes",
        "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": "This patch fixes code style issues and refines some comments in vhost library.\n\n\n---\n lib/librte_vhost/eventfd_link/eventfd_link.c | 244 ++++++++++-----------\n lib/librte_vhost/eventfd_link/eventfd_link.h | 127 ++++++-----\n lib/librte_vhost/rte_virtio_net.h            |   3 +-\n lib/librte_vhost/vhost-net-cdev.c            | 187 +++++++++-------\n lib/librte_vhost/vhost_rxtx.c                |  13 +-\n lib/librte_vhost/virtio-net.c                | 317 +++++++++++++++++----------\n 6 files changed, 494 insertions(+), 397 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/eventfd_link/eventfd_link.c b/lib/librte_vhost/eventfd_link/eventfd_link.c\nindex fc0653a..542ec2c 100644\n--- a/lib/librte_vhost/eventfd_link/eventfd_link.c\n+++ b/lib/librte_vhost/eventfd_link/eventfd_link.c\n@@ -1,26 +1,26 @@\n /*-\n- *  * GPL LICENSE SUMMARY\n- *  *\n- *  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n- *  *\n- *  *   This program is free software; you can redistribute it and/or modify\n- *  *   it under the terms of version 2 of the GNU General Public License as\n- *  *   published by the Free Software Foundation.\n- *  *\n- *  *   This program is distributed in the hope that it will be useful, but\n- *  *   WITHOUT ANY WARRANTY; without even the implied warranty of\n- *  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n- *  *   General Public License for more details.\n- *  *\n- *  *   You should have received a copy of the GNU General Public License\n- *  *   along with this program; if not, write to the Free Software\n- *  *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.\n- *  *   The full GNU General Public License is included in this distribution\n- *  *   in the file called LICENSE.GPL.\n- *  *\n- *  *   Contact Information:\n- *  *   Intel Corporation\n- *   */\n+ * GPL LICENSE SUMMARY\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *\n+ *   This program is free software; you can redistribute it and/or modify\n+ *   it under the terms of version 2 of the GNU General Public License as\n+ *   published by the Free Software Foundation.\n+ *\n+ *   This program is distributed in the hope that it will be useful, but\n+ *   WITHOUT ANY WARRANTY; without even the implied warranty of\n+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ *   General Public License for more details.\n+ *\n+ *   You should have received a copy of the GNU General Public License\n+ *   along with this program; if not, write to the Free Software\n+ *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.\n+ *   The full GNU General Public License is included in this distribution\n+ *   in the file called LICENSE.GPL.\n+ *\n+ *   Contact Information:\n+ *   Intel Corporation\n+ */\n \n #include <linux/eventfd.h>\n #include <linux/miscdevice.h>\n@@ -42,15 +42,15 @@\n  * get_files_struct is copied from fs/file.c\n  */\n struct files_struct *\n-get_files_struct (struct task_struct *task)\n+get_files_struct(struct task_struct *task)\n {\n \tstruct files_struct *files;\n \n-\ttask_lock (task);\n+\ttask_lock(task);\n \tfiles = task->files;\n \tif (files)\n-\t\tatomic_inc (&files->count);\n-\ttask_unlock (task);\n+\t\tatomic_inc(&files->count);\n+\ttask_unlock(task);\n \n \treturn files;\n }\n@@ -59,17 +59,15 @@ get_files_struct (struct task_struct *task)\n  * put_files_struct is extracted from fs/file.c\n  */\n void\n-put_files_struct (struct files_struct *files)\n+put_files_struct(struct files_struct *files)\n {\n-\tif (atomic_dec_and_test (&files->count))\n-\t{\n-\t\tBUG ();\n-\t}\n+\tif (atomic_dec_and_test(&files->count))\n+\t\tBUG();\n }\n \n \n static long\n-eventfd_link_ioctl (struct file *f, unsigned int ioctl, unsigned long arg)\n+eventfd_link_ioctl(struct file *f, unsigned int ioctl, unsigned long arg)\n {\n \tvoid __user *argp = (void __user *) arg;\n \tstruct task_struct *task_target = NULL;\n@@ -78,96 +76,88 @@ eventfd_link_ioctl (struct file *f, unsigned int ioctl, unsigned long arg)\n \tstruct fdtable *fdt;\n \tstruct eventfd_copy eventfd_copy;\n \n-\tswitch (ioctl)\n-\t{\n-\t\tcase EVENTFD_COPY:\n-\t\t\tif (copy_from_user (&eventfd_copy, argp, sizeof (struct eventfd_copy)))\n-\t\t\t\treturn -EFAULT;\n-\n-\t\t\t/*\n-\t\t\t * Find the task struct for the target pid\n-\t\t\t */\n-\t\t\ttask_target =\n-\t\t\t\tpid_task (find_vpid (eventfd_copy.target_pid), PIDTYPE_PID);\n-\t\t\tif (task_target == NULL)\n-\t\t\t{\n-\t\t\t\tprintk (KERN_DEBUG \"Failed to get mem ctx for target pid\\n\");\n-\t\t\t\treturn -EFAULT;\n-\t\t\t}\n-\n-\t\t\tfiles = get_files_struct (current);\n-\t\t\tif (files == NULL)\n-\t\t\t{\n-\t\t\t\tprintk (KERN_DEBUG \"Failed to get files struct\\n\");\n-\t\t\t\treturn -EFAULT;\n-\t\t\t}\n-\n-\t\t\trcu_read_lock ();\n-\t\t\tfile = fcheck_files (files, eventfd_copy.source_fd);\n-\t\t\tif (file)\n-\t\t\t{\n-\t\t\t\tif (file->f_mode & FMODE_PATH\n-\t\t\t\t\t\t|| !atomic_long_inc_not_zero (&file->f_count))\n-\t\t\t\t\tfile = NULL;\n-\t\t\t}\n-\t\t\trcu_read_unlock ();\n-\t\t\tput_files_struct (files);\n-\n-\t\t\tif (file == NULL)\n-\t\t\t{\n-\t\t\t\tprintk (KERN_DEBUG \"Failed to get file from source pid\\n\");\n-\t\t\t\treturn 0;\n-\t\t\t}\n-\n-\t\t\t/*\n-\t\t\t * Release the existing eventfd in the source process\n-\t\t\t */\n-\t\t\tspin_lock (&files->file_lock);\n-\t\t\tfilp_close (file, files);\n-\t\t\tfdt = files_fdtable (files);\n-\t\t\tfdt->fd[eventfd_copy.source_fd] = NULL;\n-\t\t\tspin_unlock (&files->file_lock);\n-\n-\t\t\t/*\n-\t\t\t * Find the file struct associated with the target fd.\n-\t\t\t */\n-\n-\t\t\tfiles = get_files_struct (task_target);\n-\t\t\tif (files == NULL)\n-\t\t\t{\n-\t\t\t\tprintk (KERN_DEBUG \"Failed to get files struct\\n\");\n-\t\t\t\treturn -EFAULT;\n-\t\t\t}\n-\n-\t\t\trcu_read_lock ();\n-\t\t\tfile = fcheck_files (files, eventfd_copy.target_fd);\n-\t\t\tif (file)\n-\t\t\t{\n-\t\t\t\tif (file->f_mode & FMODE_PATH\n-\t\t\t\t\t\t|| !atomic_long_inc_not_zero (&file->f_count))\n+\tswitch (ioctl) {\n+\tcase EVENTFD_COPY:\n+\t\tif (copy_from_user(&eventfd_copy, argp,\n+\t\t\tsizeof(struct eventfd_copy)))\n+\t\t\treturn -EFAULT;\n+\n+\t\t/*\n+\t\t * Find the task struct for the target pid\n+\t\t */\n+\t\ttask_target =\n+\t\t\tpid_task(find_vpid(eventfd_copy.target_pid), PIDTYPE_PID);\n+\t\tif (task_target == NULL) {\n+\t\t\tprintk(KERN_DEBUG \"Failed to get mem ctx for target pid\\n\");\n+\t\t\treturn -EFAULT;\n+\t\t}\n+\n+\t\tfiles = get_files_struct(current);\n+\t\tif (files == NULL) {\n+\t\t\tprintk(KERN_DEBUG \"Failed to get files struct\\n\");\n+\t\t\treturn -EFAULT;\n+\t\t}\n+\n+\t\trcu_read_lock();\n+\t\tfile = fcheck_files(files, eventfd_copy.source_fd);\n+\t\tif (file) {\n+\t\t\tif (file->f_mode & FMODE_PATH ||\n+\t\t\t\t!atomic_long_inc_not_zero(&file->f_count))\n+\t\t\t\tfile = NULL;\n+\t\t}\n+\t\trcu_read_unlock();\n+\t\tput_files_struct(files);\n+\n+\t\tif (file == NULL) {\n+\t\t\tprintk(KERN_DEBUG \"Failed to get file from source pid\\n\");\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Release the existing eventfd in the source process\n+\t\t */\n+\t\tspin_lock(&files->file_lock);\n+\t\tfilp_close(file, files);\n+\t\tfdt = files_fdtable(files);\n+\t\tfdt->fd[eventfd_copy.source_fd] = NULL;\n+\t\tspin_unlock(&files->file_lock);\n+\n+\t\t/*\n+\t\t * Find the file struct associated with the target fd.\n+\t\t */\n+\n+\t\tfiles = get_files_struct(task_target);\n+\t\tif (files == NULL) {\n+\t\t\tprintk(KERN_DEBUG \"Failed to get files struct\\n\");\n+\t\t\treturn -EFAULT;\n+\t\t}\n+\n+\t\trcu_read_lock();\n+\t\tfile = fcheck_files(files, eventfd_copy.target_fd);\n+\t\tif (file) {\n+\t\t\tif (file->f_mode & FMODE_PATH ||\n+\t\t\t\t!atomic_long_inc_not_zero(&file->f_count))\n \t\t\t\t\tfile = NULL;\n-\t\t\t}\n-\t\t\trcu_read_unlock ();\n-\t\t\tput_files_struct (files);\n-\n-\t\t\tif (file == NULL)\n-\t\t\t{\n-\t\t\t\tprintk (KERN_DEBUG \"Failed to get file from target pid\\n\");\n-\t\t\t\treturn 0;\n-\t\t\t}\n+\t\t}\n+\t\trcu_read_unlock();\n+\t\tput_files_struct(files);\n \n+\t\tif (file == NULL) {\n+\t\t\tprintk(KERN_DEBUG \"Failed to get file from target pid\\n\");\n+\t\t\treturn 0;\n+\t\t}\n \n-\t\t\t/*\n-\t\t\t * Install the file struct from the target process into the\n-\t\t\t * file desciptor of the source process,\n-\t\t\t */\n+\t\t/*\n+\t\t * Install the file struct from the target process into the\n+\t\t * file desciptor of the source process,\n+\t\t */\n \n-\t\t\tfd_install (eventfd_copy.source_fd, file);\n+\t\tfd_install(eventfd_copy.source_fd, file);\n \n-\t\t\treturn 0;\n+\t\treturn 0;\n \n-\t\tdefault:\n-\t\t\treturn -ENOIOCTLCMD;\n+\tdefault:\n+\t\treturn -ENOIOCTLCMD;\n \t}\n }\n \n@@ -183,23 +173,23 @@ static struct miscdevice eventfd_link_misc = {\n };\n \n static int __init\n-eventfd_link_init (void)\n+eventfd_link_init(void)\n {\n-\treturn misc_register (&eventfd_link_misc);\n+\treturn misc_register(&eventfd_link_misc);\n }\n \n-module_init (eventfd_link_init);\n+module_init(eventfd_link_init);\n \n static void __exit\n-eventfd_link_exit (void)\n+eventfd_link_exit(void)\n {\n-\tmisc_deregister (&eventfd_link_misc);\n+\tmisc_deregister(&eventfd_link_misc);\n }\n \n-module_exit (eventfd_link_exit);\n+module_exit(eventfd_link_exit);\n \n-MODULE_VERSION (\"0.0.1\");\n-MODULE_LICENSE (\"GPL v2\");\n-MODULE_AUTHOR (\"Anthony Fee\");\n-MODULE_DESCRIPTION (\"Link eventfd\");\n-MODULE_ALIAS (\"devname:eventfd-link\");\n+MODULE_VERSION(\"0.0.1\");\n+MODULE_LICENSE(\"GPL v2\");\n+MODULE_AUTHOR(\"Anthony Fee\");\n+MODULE_DESCRIPTION(\"Link eventfd\");\n+MODULE_ALIAS(\"devname:eventfd-link\");\ndiff --git a/lib/librte_vhost/eventfd_link/eventfd_link.h b/lib/librte_vhost/eventfd_link/eventfd_link.h\nindex a32a8dd..ea619ec 100644\n--- a/lib/librte_vhost/eventfd_link/eventfd_link.h\n+++ b/lib/librte_vhost/eventfd_link/eventfd_link.h\n@@ -1,79 +1,76 @@\n /*-\n- *  * This file is provided under a dual BSD/GPLv2 license.  When using or\n- *  *   redistributing this file, you may do so under either license.\n- *  *\n- *  *   GPL LICENSE SUMMARY\n- *  *\n- *  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n- *  *\n- *  *   This program is free software; you can redistribute it and/or modify\n- *  *   it under the terms of version 2 of the GNU General Public License as\n- *  *   published by the Free Software Foundation.\n- *  *\n- *  *   This program is distributed in the hope that it will be useful, but\n- *  *   WITHOUT ANY WARRANTY; without even the implied warranty of\n- *  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n- *  *   General Public License for more details.\n- *  *\n- *  *   You should have received a copy of the GNU General Public License\n- *  *   along with this program; if not, write to the Free Software\n- *  *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.\n- *  *   The full GNU General Public License is included in this distribution\n- *  *   in the file called LICENSE.GPL.\n- *  *\n- *  *   Contact Information:\n- *  *   Intel Corporation\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+ *  This file is provided under a dual BSD/GPLv2 license.  When using or\n+ *  redistributing this file, you may do so under either license.\n+ *\n+ * GPL LICENSE SUMMARY\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *\n+ *   This program is free software; you can redistribute it and/or modify\n+ *   it under the terms of version 2 of the GNU General Public License as\n+ *   published by the Free Software Foundation.\n+ *\n+ *   This program is distributed in the hope that it will be useful, but\n+ *   WITHOUT ANY WARRANTY; without even the implied warranty of\n+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ *   General Public License for more details.\n+ *\n+ *   You should have received a copy of the GNU General Public License\n+ *   along with this program; if not, write to the Free Software\n+ *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.\n+ *   The full GNU General Public License is included in this distribution\n+ *   in the file called LICENSE.GPL.\n+ *\n+ *   Contact Information:\n+ *   Intel Corporation\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 \n #ifndef _EVENTFD_LINK_H_\n #define _EVENTFD_LINK_H_\n \n /*\n- *\tioctl to copy an fd entry in calling process to an fd in a target process\n+ * ioctl to copy an fd entry in calling process to an fd in a target process\n  */\n #define EVENTFD_COPY 1\n \n /*\n- *\targuements for the EVENTFD_COPY ioctl\n+ * arguements for the EVENTFD_COPY ioctl\n  */\n struct eventfd_copy {\n-\t// fd in the target pid\n-    unsigned target_fd;\n-\t// fd in the calling pid\n-    unsigned source_fd;\n-\t// pid of the target pid\n-    pid_t target_pid;\n+\tunsigned target_fd; /* fd in the target pid */\n+\tunsigned source_fd; /* fd in the calling pid */\n+\tpid_t target_pid; /* pid of the target pid */\n };\n #endif /* _EVENTFD_LINK_H_ */\ndiff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h\nindex b6548a1..00b1328 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -90,8 +90,7 @@ struct vhost_virtqueue {\n /**\n  * Device structure contains all configuration information relating to the device.\n  */\n-struct virtio_net\n-{\n+struct virtio_net {\n \tstruct vhost_virtqueue\t*virtqueue[VIRTIO_QNUM];\t/**< Contains all virtqueue information. */\n \tstruct virtio_memory\t*mem;\t\t/**< QEMU memory and memory region information. */\n \tuint64_t\t\tfeatures;\t/**< Negotiated feature set. */\ndiff --git a/lib/librte_vhost/vhost-net-cdev.c b/lib/librte_vhost/vhost-net-cdev.c\nindex 91ff0d8..57c76cb 100644\n--- a/lib/librte_vhost/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost-net-cdev.c\n@@ -46,21 +46,21 @@\n \n #include \"vhost-net-cdev.h\"\n \n-#define FUSE_OPT_DUMMY\t\t\"\\0\\0\"\n-#define FUSE_OPT_FORE\t\t\"-f\\0\\0\"\n-#define FUSE_OPT_NOMULTI\t\"-s\\0\\0\"\n+#define FUSE_OPT_DUMMY \"\\0\\0\"\n+#define FUSE_OPT_FORE  \"-f\\0\\0\"\n+#define FUSE_OPT_NOMULTI \"-s\\0\\0\"\n \n-static const uint32_t\tdefault_major = 231;\n-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+static const uint32_t default_major = 231;\n+static const uint32_t default_minor = 1;\n+static const char cuse_device_name[] = \"/dev/cuse\";\n+static const char default_cdev[] = \"vhost-net\";\n \n-static struct fuse_session\t\t\t*session;\n-static struct vhost_net_device_ops\tconst *ops;\n+static struct fuse_session *session;\n+static struct vhost_net_device_ops const *ops;\n \n /*\n- * Returns vhost_device_ctx from given fuse_req_t. The index is populated later when\n- * the device is added to the device linked list.\n+ * Returns vhost_device_ctx from given fuse_req_t. The index is populated later\n+ * when the device is added to the device linked list.\n  */\n static struct vhost_device_ctx\n fuse_req_to_vhost_ctx(fuse_req_t req, struct fuse_file_info *fi)\n@@ -75,7 +75,8 @@ fuse_req_to_vhost_ctx(fuse_req_t req, struct fuse_file_info *fi)\n }\n \n /*\n- * When the device is created in QEMU it gets initialised here and added to the device linked list.\n+ * When the device is created in QEMU it gets initialised here and\n+ * added to the device linked list.\n  */\n static void\n vhost_net_open(fuse_req_t req, struct fuse_file_info *fi)\n@@ -91,7 +92,8 @@ vhost_net_open(fuse_req_t req, struct fuse_file_info *fi)\n \n \tfi->fh = err;\n \n-\tRTE_LOG(INFO, VHOST_CONFIG, \"(%\"PRIu64\") Device configuration started\\n\", fi->fh);\n+\tRTE_LOG(INFO, VHOST_CONFIG,\n+\t\t\"(%\"PRIu64\") Device configuration started\\n\", fi->fh);\n \tfuse_reply_open(req, fi);\n }\n \n@@ -113,8 +115,8 @@ vhost_net_release(fuse_req_t req, struct fuse_file_info *fi)\n  * Boilerplate code for CUSE IOCTL\n  * Implicit arguments: ctx, req, result.\n  */\n-#define VHOST_IOCTL(func) do {\t\t\t\\\n-\tresult = (func)(ctx);\t\t\t\\\n+#define VHOST_IOCTL(func) do {\t\\\n+\tresult = (func)(ctx);\t\\\n \tfuse_reply_ioctl(req, result, NULL, 0);\t\\\n } while (0)\n \n@@ -122,57 +124,58 @@ vhost_net_release(fuse_req_t req, struct fuse_file_info *fi)\n  * Boilerplate IOCTL RETRY\n  * Implicit arguments: req.\n  */\n-#define VHOST_IOCTL_RETRY(size_r, size_w) do {\t\t\\\n-\tstruct iovec iov_r = { arg, (size_r) };\t\t\\\n-\tstruct iovec iov_w = { arg, (size_w) };\t\t\\\n-\tfuse_reply_ioctl_retry(req, &iov_r, (size_r)?1:0, &iov_w, (size_w)?1:0);\t\\\n+#define VHOST_IOCTL_RETRY(size_r, size_w) do {\t\\\n+\tstruct iovec iov_r = { arg, (size_r) };\t\\\n+\tstruct iovec iov_w = { arg, (size_w) };\t\\\n+\tfuse_reply_ioctl_retry(req, &iov_r,\t\\\n+\t\t(size_r) ? 1 : 0, &iov_w, (size_w) ? 1 : 0);\\\n } while (0)\n \n /*\n  * Boilerplate code for CUSE Read IOCTL\n  * Implicit arguments: ctx, req, result, in_bufsz, in_buf.\n  */\n-#define VHOST_IOCTL_R(type, var, func) do {\t\t\\\n-\tif (!in_bufsz) {\t\t\t\t\\\n-\t\tVHOST_IOCTL_RETRY(sizeof(type), 0);\t\\\n-\t} else {\t\t\t\t\t\\\n-\t\t(var) = *(const type*) in_buf;\t\t\\\n-\t\tresult = func(ctx, &(var));\t\t\\\n-\t\tfuse_reply_ioctl(req, result, NULL, 0);\t\\\n-\t}\t\t\t\t\t\t\\\n+#define VHOST_IOCTL_R(type, var, func) do {\t\\\n+\tif (!in_bufsz) {\t\\\n+\t\tVHOST_IOCTL_RETRY(sizeof(type), 0);\\\n+\t} else {\t\\\n+\t\t(var) = *(const type*)in_buf;\t\\\n+\t\tresult = func(ctx, &(var));\t\\\n+\t\tfuse_reply_ioctl(req, result, NULL, 0);\\\n+\t}\t\\\n } while (0)\n \n /*\n- *\tBoilerplate code for CUSE Write IOCTL\n+ * Boilerplate code for CUSE Write IOCTL\n  * Implicit arguments: ctx, req, result, out_bufsz.\n  */\n-#define\tVHOST_IOCTL_W(type, var, func) do {\t\t\\\n-\tif (!out_bufsz) {\t\t\t\t\\\n-\t\tVHOST_IOCTL_RETRY(0, sizeof(type));\t\\\n-\t} else {\t\t\t\t\t\\\n-\t\tresult = (func)(ctx, &(var));\t\t\\\n-\t\tfuse_reply_ioctl(req, result, &(var), sizeof(type));\t\\\n-\t}\t\t\t\t\t\t\t\t\\\n+#define VHOST_IOCTL_W(type, var, func) do {\t\\\n+\tif (!out_bufsz) {\t\\\n+\t\tVHOST_IOCTL_RETRY(0, sizeof(type));\\\n+\t} else {\t\\\n+\t\tresult = (func)(ctx, &(var));\\\n+\t\tfuse_reply_ioctl(req, result, &(var), sizeof(type));\\\n+\t} \\\n } while (0)\n \n /*\n  * Boilerplate code for CUSE Read/Write IOCTL\n  * Implicit arguments: ctx, req, result, in_bufsz, in_buf.\n  */\n-#define VHOST_IOCTL_RW(type1, var1, type2, var2, func) do {\t\t\\\n-\tif (!in_bufsz) {\t\t\t\t\t\t\\\n-\t\tVHOST_IOCTL_RETRY(sizeof(type1), sizeof(type2));\t\\\n-\t} else {\t\t\t\t\t\t\t\\\n-\t\t(var1) = *(const type1*) (in_buf);\t\t\t\\\n-\t\tresult = (func)(ctx, (var1), &(var2));\t\t\t\\\n-\t\tfuse_reply_ioctl(req, result, &(var2), sizeof(type2));\t\\\n-\t}\t\t\t\t\t\t\t\t\\\n+#define VHOST_IOCTL_RW(type1, var1, type2, var2, func) do {\t\\\n+\tif (!in_bufsz) {\t\\\n+\t\tVHOST_IOCTL_RETRY(sizeof(type1), sizeof(type2));\\\n+\t} else {\t\\\n+\t\t(var1) = *(const type1*) (in_buf);\t\\\n+\t\tresult = (func)(ctx, (var1), &(var2));\t\\\n+\t\tfuse_reply_ioctl(req, result, &(var2), sizeof(type2));\\\n+\t}\t\\\n } while (0)\n \n /*\n- * The IOCTLs are handled using CUSE/FUSE in userspace. Depending on\n- * the type of IOCTL a buffer is requested to read or to write. This\n- * request is handled by FUSE and the buffer is then given to CUSE.\n+ * The IOCTLs are handled using CUSE/FUSE in userspace. Depending on the type\n+ * of IOCTL a buffer is requested to read or to write. This request is handled\n+ * by FUSE and the buffer is then given to CUSE.\n  */\n static void\n vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n@@ -189,33 +192,39 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n \n \tswitch (cmd) {\n \tcase VHOST_NET_SET_BACKEND:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_NET_SET_BACKEND\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_NET_SET_BACKEND\\n\", ctx.fh);\n \t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_backend);\n \t\tbreak;\n \n \tcase VHOST_GET_FEATURES:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_GET_FEATURES\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_GET_FEATURES\\n\", ctx.fh);\n \t\tVHOST_IOCTL_W(uint64_t, features, ops->get_features);\n \t\tbreak;\n \n \tcase VHOST_SET_FEATURES:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_FEATURES\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_FEATURES\\n\", ctx.fh);\n \t\tVHOST_IOCTL_R(uint64_t, features, ops->set_features);\n \t\tbreak;\n \n \tcase VHOST_RESET_OWNER:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_RESET_OWNER\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_RESET_OWNER\\n\", ctx.fh);\n \t\tVHOST_IOCTL(ops->reset_owner);\n \t\tbreak;\n \n \tcase VHOST_SET_OWNER:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_OWNER\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_OWNER\\n\", ctx.fh);\n \t\tVHOST_IOCTL(ops->set_owner);\n \t\tbreak;\n \n \tcase VHOST_SET_MEM_TABLE:\n \t\t/*TODO fix race condition.*/\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_MEM_TABLE\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_MEM_TABLE\\n\", ctx.fh);\n \t\tstatic struct vhost_memory mem_temp;\n \n \t\tswitch (in_bufsz) {\n@@ -227,7 +236,9 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n \t\t\tmem_temp = *(const struct vhost_memory *) in_buf;\n \n \t\t\tif (mem_temp.nregions > 0) {\n-\t\t\t\tVHOST_IOCTL_RETRY(sizeof(struct vhost_memory) + (sizeof(struct vhost_memory_region) * mem_temp.nregions), 0);\n+\t\t\t\tVHOST_IOCTL_RETRY(sizeof(struct vhost_memory) +\n+\t\t\t\t\t(sizeof(struct vhost_memory_region) *\n+\t\t\t\t\t\tmem_temp.nregions), 0);\n \t\t\t} else {\n \t\t\t\tresult = -1;\n \t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n@@ -235,56 +246,70 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\tresult = ops->set_mem_table(ctx, in_buf, mem_temp.nregions);\n+\t\t\tresult = ops->set_mem_table(ctx,\n+\t\t\t\t\tin_buf, mem_temp.nregions);\n \t\t\tif (result)\n \t\t\t\tfuse_reply_err(req, EINVAL);\n \t\t\telse\n \t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n-\n \t\t}\n-\n \t\tbreak;\n \n \tcase VHOST_SET_VRING_NUM:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_NUM\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_R(struct vhost_vring_state, state, ops->set_vring_num);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_NUM\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_R(struct vhost_vring_state, state,\n+\t\t\tops->set_vring_num);\n \t\tbreak;\n \n \tcase VHOST_SET_VRING_BASE:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_BASE\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_R(struct vhost_vring_state, state, ops->set_vring_base);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_BASE\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_R(struct vhost_vring_state, state,\n+\t\t\tops->set_vring_base);\n \t\tbreak;\n \n \tcase VHOST_GET_VRING_BASE:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_GET_VRING_BASE\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_RW(uint32_t, index, struct vhost_vring_state, state, ops->get_vring_base);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_GET_VRING_BASE\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_RW(uint32_t, index,\n+\t\t\tstruct vhost_vring_state, state, ops->get_vring_base);\n \t\tbreak;\n \n \tcase VHOST_SET_VRING_ADDR:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_ADDR\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_R(struct vhost_vring_addr, addr, ops->set_vring_addr);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_ADDR\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_R(struct vhost_vring_addr, addr,\n+\t\t\tops->set_vring_addr);\n \t\tbreak;\n \n \tcase VHOST_SET_VRING_KICK:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_KICK\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_vring_kick);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_KICK\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_R(struct vhost_vring_file, file,\n+\t\t\tops->set_vring_kick);\n \t\tbreak;\n \n \tcase VHOST_SET_VRING_CALL:\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_CALL\\n\", ctx.fh);\n-\t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_vring_call);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_CALL\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_R(struct vhost_vring_file, file,\n+\t\t\tops->set_vring_call);\n \t\tbreak;\n \n \tdefault:\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: DOESN NOT EXIST\\n\", ctx.fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: DOESN NOT EXIST\\n\", ctx.fh);\n \t\tresult = -1;\n \t\tfuse_reply_ioctl(req, result, NULL, 0);\n \t}\n \n \tif (result < 0)\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: FAIL\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: FAIL\\n\", ctx.fh);\n \telse\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: SUCCESS\\n\", ctx.fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") IOCTL: SUCCESS\\n\", ctx.fh);\n }\n \n /*\n@@ -297,8 +322,8 @@ static const struct cuse_lowlevel_ops vhost_net_ops = {\n };\n \n /*\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+ * cuse_info is populated and used to register the cuse device.\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@@ -314,20 +339,23 @@ rte_vhost_driver_register(const char *dev_name)\n \tchar *fuse_argv[] = {fuse_opt_dummy, fuse_opt_fore, fuse_opt_nomulti};\n \n \tif (access(cuse_device_name, R_OK | W_OK) < 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"Character device %s can't be accessed, maybe not exist\\n\", cuse_device_name);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"char device %s can't be accessed, maybe not exist\\n\",\n+\t\t\tcuse_device_name);\n \t\treturn -1;\n \t}\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+\t * The device name is created. This is passed to QEMU so that it can\n+\t * register the device with our application.\n \t */\n \tsnprintf(device_name, PATH_MAX, \"DEVNAME=%s\", dev_name);\n \tsnprintf(char_device_name, PATH_MAX, \"/dev/%s\", dev_name);\n \n \t/* Check if device already exists. */\n \tif (access(char_device_name, F_OK) != -1) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"Character device %s already exists\\n\", char_device_name);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"char device %s already exists\\n\", char_device_name);\n \t\treturn -1;\n \t}\n \n@@ -341,7 +369,7 @@ rte_vhost_driver_register(const char *dev_name)\n \tops = get_virtio_net_callbacks();\n \n \tsession = cuse_lowlevel_setup(3, fuse_argv,\n-\t\t\t\t&cuse_info, &vhost_net_ops, 0, NULL);\n+\t\t\t&cuse_info, &vhost_net_ops, 0, NULL);\n \tif (session == NULL)\n \t\treturn -1;\n \n@@ -349,7 +377,8 @@ rte_vhost_driver_register(const char *dev_name)\n }\n \n /**\n- * The CUSE session is launched allowing the application to receive open, release and ioctl calls.\n+ * The CUSE session is launched allowing the application to receive open,\n+ * release and ioctl calls.\n  */\n int\n rte_vhost_driver_session_start(void)\ndiff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex 84ec0e8..ccfd82f 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -45,7 +45,7 @@\n /**\n  * This function adds buffers to the virtio devices RX virtqueue. Buffers can\n  * be received from the physical port or from another virtio device. A packet\n- * count is returned to indicate the number of packets that were succesfully\n+ * count is returned to indicate the number of packets that are succesfully\n  * added to the RX queue. This function works when mergeable is disabled.\n  */\n static inline uint32_t __attribute__((always_inline))\n@@ -76,7 +76,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \tcount = (count > MAX_PKT_BURST) ? MAX_PKT_BURST : count;\n \n \t/*\n-\t * As many data cores may want access to available buffers, \n+\t * As many data cores may want access to available buffers,\n \t * they need to be reserved.\n \t */\n \tdo {\n@@ -143,7 +143,8 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \t\t}\n \n \t\t/* Update used ring with desc information */\n-\t\tvq->used->ring[res_cur_idx & (vq->size - 1)].id = head[packet_success];\n+\t\tvq->used->ring[res_cur_idx & (vq->size - 1)].id =\n+\t\t\t\t\t\t\thead[packet_success];\n \t\tvq->used->ring[res_cur_idx & (vq->size - 1)].len = packet_len;\n \n \t\t/* Copy mbuf data to buffer */\n@@ -389,10 +390,7 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t res_base_idx,\n }\n \n /*\n- * This function adds buffers to the virtio devices RX virtqueue. Buffers can\n- * be received from the physical port or from another virtio device. A packet\n- * count is returned to indicate the number of packets that were succesfully\n- * added to the RX queue. This function works for mergeable RX.\n+ * This function works for mergeable RX.\n  */\n static inline uint32_t __attribute__((always_inline))\n virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,\n@@ -729,5 +727,4 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n \tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))\n \t\teventfd_write((int)vq->kickfd, 1);\n \treturn entry_success;\n-\n }\ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex 8015dd8..c07a11e 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -52,27 +52,27 @@\n #include \"vhost-net-cdev.h\"\n #include \"eventfd_link/eventfd_link.h\"\n \n-/**\n+/*\n  * Device linked list structure for configuration.\n  */\n struct virtio_net_config_ll {\n-\tstruct virtio_net\t\tdev;\t/* Virtio device.*/\n-\tstruct virtio_net_config_ll\t*next;\t/* Next entry on linked list.*/\n+\tstruct virtio_net dev;\t\t\t/* Virtio device.*/\n+\tstruct virtio_net_config_ll *next;\t/* Next dev on linked list.*/\n };\n \n const char eventfd_cdev[] = \"/dev/eventfd-link\";\n \n-/* device ops to add/remove device to data core. */\n+/* device ops to add/remove device to/from data core. */\n static struct virtio_net_device_ops const *notify_ops;\n-/* Root address of the linked list in the configuration core. */\n-static struct virtio_net_config_ll\t*ll_root;\n+/* root address of the linked list of managed virtio devices */\n+static struct virtio_net_config_ll *ll_root;\n \n-/* Features supported by this application. RX merge buffers are enabled by default. */\n+/* Features supported by this lib. */\n #define VHOST_SUPPORTED_FEATURES (1ULL << VIRTIO_NET_F_MRG_RXBUF)\n static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;\n \n /* Line size for reading maps file. */\n-const uint32_t BUFSIZE = PATH_MAX;\n+static const uint32_t BUFSIZE = PATH_MAX;\n \n /* Size of prot char array in procmap. */\n #define PROT_SZ 5\n@@ -82,19 +82,19 @@ const uint32_t BUFSIZE = PATH_MAX;\n \n /* Structure containing information gathered from maps file. */\n struct procmap {\n-\tuint64_t\tva_start;\t/* Start virtual address in file. */\n-\tuint64_t\tlen;\t\t/* Size of file. */\n-\tuint64_t\tpgoff;\t\t/* Not used. */\n-\tuint32_t\tmaj;\t\t/* Not used. */\n-\tuint32_t\tmin;\t\t/* Not used. */\n-\tuint32_t\tino;\t\t/* Not used. */\n-\tchar\t\tprot[PROT_SZ];\t/* Not used. */\n-\tchar\t\tfname[PATH_MAX];/* File name. */\n+\tuint64_t va_start;\t/* Start virtual address in file. */\n+\tuint64_t len;\t\t/* Size of file. */\n+\tuint64_t pgoff;\t\t/* Not used. */\n+\tuint32_t maj;\t\t/* Not used. */\n+\tuint32_t min;\t\t/* Not used. */\n+\tuint32_t ino;\t\t/* Not used. */\n+\tchar prot[PROT_SZ];\t/* Not used. */\n+\tchar fname[PATH_MAX];\t/* File name. */\n };\n \n /*\n- * Converts QEMU virtual address to Vhost virtual address. This function is used\n- * to convert the ring addresses to our address space.\n+ * Converts QEMU virtual address to Vhost virtual address. This function is\n+ * used to convert the ring addresses to our address space.\n  */\n static uint64_t\n qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)\n@@ -107,8 +107,8 @@ qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)\n \tfor (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) {\n \t\tregion = &dev->mem->regions[regionidx];\n \t\tif ((qemu_va >= region->userspace_address) &&\n-\t\t\t\t(qemu_va <= region->userspace_address +\n-\t\t\t\tregion->memory_size)) {\n+\t\t\t(qemu_va <= region->userspace_address +\n+\t\t\tregion->memory_size)) {\n \t\t\tvhost_va = dev->mem->mapped_address + qemu_va -\n \t\t\t\t\tdev->mem->base_address;\n \t\t\tbreak;\n@@ -118,7 +118,8 @@ qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)\n }\n \n /*\n- * Locate the file containing QEMU's memory space and map it to our address space.\n+ * Locate the file containing QEMU's memory space and\n+ * map it to our address space.\n  */\n static int\n host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n@@ -134,10 +135,10 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n \tchar procdir[PATH_MAX];\n \tchar resolved_path[PATH_MAX];\n \tchar *path = NULL;\n-\tFILE\t\t*fmap;\n-\tvoid\t\t*map;\n-\tuint8_t\t\tfound = 0;\n-\tchar\t\tline[BUFSIZE];\n+\tFILE *fmap;\n+\tvoid *map;\n+\tuint8_t found = 0;\n+\tchar line[BUFSIZE];\n \tchar dlm[] = \"-   :   \";\n \tchar *str, *sp, *in[PROCMAP_SZ];\n \tchar *end = NULL;\n@@ -159,7 +160,7 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n \twhile (fgets(line, BUFSIZE, fmap) != 0) {\n \t\tstr = line;\n \t\terrno = 0;\n-\t\t/* Split line in to fields. */\n+\t\t/* Split line into fields. */\n \t\tfor (i = 0; i < PROCMAP_SZ; i++) {\n \t\t\tin[i] = strtok_r(str, &dlm[i], &sp);\n \t\t\tif ((in[i] == NULL) || (errno != 0)) {\n@@ -171,37 +172,43 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n \n \t\t/* Convert/Copy each field as needed. */\n \t\tprocmap.va_start = strtoull(in[0], &end, 16);\n-\t\tif ((in[0] == '\\0') || (end == NULL) || (*end != '\\0') || (errno != 0)) {\n+\t\tif ((in[0] == '\\0') || (end == NULL) || (*end != '\\0') ||\n+\t\t\t(errno != 0)) {\n \t\t\tfclose(fmap);\n \t\t\treturn -1;\n \t\t}\n \n \t\tprocmap.len = strtoull(in[1], &end, 16);\n-\t\tif ((in[1] == '\\0') || (end == NULL) || (*end != '\\0') || (errno != 0)) {\n+\t\tif ((in[1] == '\\0') || (end == NULL) || (*end != '\\0') ||\n+\t\t\t(errno != 0)) {\n \t\t\tfclose(fmap);\n \t\t\treturn -1;\n \t\t}\n \n \t\tprocmap.pgoff = strtoull(in[3], &end, 16);\n-\t\tif ((in[3] == '\\0') || (end == NULL) || (*end != '\\0') || (errno != 0)) {\n+\t\tif ((in[3] == '\\0') || (end == NULL) || (*end != '\\0') ||\n+\t\t\t(errno != 0)) {\n \t\t\tfclose(fmap);\n \t\t\treturn -1;\n \t\t}\n \n \t\tprocmap.maj = strtoul(in[4], &end, 16);\n-\t\tif ((in[4] == '\\0') || (end == NULL) || (*end != '\\0') || (errno != 0)) {\n+\t\tif ((in[4] == '\\0') || (end == NULL) || (*end != '\\0') ||\n+\t\t\t(errno != 0)) {\n \t\t\tfclose(fmap);\n \t\t\treturn -1;\n \t\t}\n \n \t\tprocmap.min = strtoul(in[5], &end, 16);\n-\t\tif ((in[5] == '\\0') || (end == NULL) || (*end != '\\0') || (errno != 0)) {\n+\t\tif ((in[5] == '\\0') || (end == NULL) || (*end != '\\0') ||\n+\t\t\t(errno != 0)) {\n \t\t\tfclose(fmap);\n \t\t\treturn -1;\n \t\t}\n \n \t\tprocmap.ino = strtoul(in[6], &end, 16);\n-\t\tif ((in[6] == '\\0') || (end == NULL) || (*end != '\\0') || (errno != 0)) {\n+\t\tif ((in[6] == '\\0') || (end == NULL) || (*end != '\\0') ||\n+\t\t\t(errno != 0)) {\n \t\t\tfclose(fmap);\n \t\t\treturn -1;\n \t\t}\n@@ -218,16 +225,19 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n \tfclose(fmap);\n \n \tif (!found) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to find memory file in pid %d maps file\\n\", dev->device_fh, pid);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to find memory file in pid %d maps file\\n\",\n+\t\t\tdev->device_fh, pid);\n \t\treturn -1;\n \t}\n \n \t/* Find the guest memory file among the process fds. */\n \tdp = opendir(procdir);\n \tif (dp == NULL) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Cannot open pid %d process directory\\n\", dev->device_fh, pid);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Cannot open pid %d process directory\\n\",\n+\t\t\tdev->device_fh, pid);\n \t\treturn -1;\n-\n \t}\n \n \tfound = 0;\n@@ -254,23 +264,29 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n \tclosedir(dp);\n \n \tif (found == 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to find memory file for pid %d\\n\", dev->device_fh, pid);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to find memory file for pid %d\\n\",\n+\t\t\tdev->device_fh, pid);\n \t\treturn -1;\n \t}\n \t/* Open the shared memory file and map the memory into this process. */\n \tfd = open(memfile, O_RDWR);\n \n \tif (fd == -1) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to open %s for pid %d\\n\", dev->device_fh, memfile, pid);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to open %s for pid %d\\n\",\n+\t\t\tdev->device_fh, memfile, pid);\n \t\treturn -1;\n \t}\n \n-\tmap = mmap(0, (size_t)procmap.len, PROT_READ|PROT_WRITE ,\n-\t\t\tMAP_POPULATE|MAP_SHARED, fd, 0);\n+\tmap = mmap(0, (size_t)procmap.len, PROT_READ|PROT_WRITE,\n+\t\tMAP_POPULATE|MAP_SHARED, fd, 0);\n \tclose(fd);\n \n \tif (map == MAP_FAILED) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Error mapping the file %s for pid %d\\n\",  dev->device_fh, memfile, pid);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Error mapping the file %s for pid %d\\n\",\n+\t\t\tdev->device_fh, memfile, pid);\n \t\treturn -1;\n \t}\n \n@@ -278,8 +294,11 @@ host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n \tmem->mapped_address = (uint64_t)(uintptr_t)map;\n \tmem->mapped_size = procmap.len;\n \n-\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") Mem File: %s->%s - Size: %llu - VA: %p\\n\", dev->device_fh,\n-\t\tmemfile, resolved_path, (long long unsigned)mem->mapped_size, map);\n+\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\"(%\"PRIu64\") Mem File: %s->%s - Size: %llu - VA: %p\\n\",\n+\t\tdev->device_fh,\n+\t\tmemfile, resolved_path,\n+\t\t(long long unsigned)mem->mapped_size, map);\n \n \treturn 0;\n }\n@@ -303,7 +322,8 @@ get_config_ll_entry(struct vhost_device_ctx ctx)\n }\n \n /*\n- * Searches the configuration core linked list and retrieves the device if it exists.\n+ * Searches the configuration core linked list and\n+ * retrieves the device if it exists.\n  */\n static struct virtio_net *\n get_device(struct vhost_device_ctx ctx)\n@@ -312,11 +332,11 @@ get_device(struct vhost_device_ctx ctx)\n \n \tll_dev = get_config_ll_entry(ctx);\n \n-\t/* If a matching entry is found in the linked list, return the device in that entry. */\n \tif (ll_dev)\n \t\treturn &ll_dev->dev;\n \n-\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Device not found in linked list.\\n\", ctx.fh);\n+\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\"(%\"PRIu64\") Device not found in linked list.\\n\", ctx.fh);\n \treturn NULL;\n }\n \n@@ -331,13 +351,18 @@ add_config_ll_entry(struct virtio_net_config_ll *new_ll_dev)\n \t/* If ll_dev == NULL then this is the first device so go to else */\n \tif (ll_dev) {\n \t\t/* If the 1st device_fh != 0 then we insert our device here. */\n-\t\tif (ll_dev->dev.device_fh != 0)\t{\n+\t\tif (ll_dev->dev.device_fh != 0) {\n \t\t\tnew_ll_dev->dev.device_fh = 0;\n \t\t\tnew_ll_dev->next = ll_dev;\n \t\t\tll_root = new_ll_dev;\n \t\t} else {\n-\t\t\t/* Increment through the ll until we find un unused device_fh. Insert the device at that entry*/\n-\t\t\twhile ((ll_dev->next != NULL) && (ll_dev->dev.device_fh == (ll_dev->next->dev.device_fh - 1)))\n+\t\t\t/*\n+\t\t\t * Increment through the ll until we find un unused\n+\t\t\t * device_fh. Insert the device at that entry.\n+\t\t\t */\n+\t\t\twhile ((ll_dev->next != NULL) &&\n+\t\t\t\t(ll_dev->dev.device_fh ==\n+\t\t\t\t\t(ll_dev->next->dev.device_fh - 1)))\n \t\t\t\tll_dev = ll_dev->next;\n \n \t\t\tnew_ll_dev->dev.device_fh = ll_dev->dev.device_fh + 1;\n@@ -352,7 +377,8 @@ add_config_ll_entry(struct virtio_net_config_ll *new_ll_dev)\n }\n \n /*\n- * Unmap any memory, close any file descriptors and free any memory owned by a device.\n+ * Unmap any memory, close any file descriptors and\n+ * free any memory owned by a device.\n  */\n static void\n cleanup_device(struct virtio_net *dev)\n@@ -386,6 +412,7 @@ free_device(struct virtio_net_config_ll *ll_dev)\n \tfree(ll_dev->dev.virtqueue[VIRTIO_TXQ]);\n \tfree(ll_dev);\n }\n+\n /*\n  * Remove an entry from the device configuration linked list.\n  */\n@@ -423,7 +450,10 @@ init_device(struct virtio_net *dev)\n {\n \tuint64_t vq_offset;\n \n-\t/* Virtqueues have already been malloced so we don't want to set them to NULL. */\n+\t/*\n+\t * Virtqueues have already been malloced so\n+\t * we don't want to set them to NULL.\n+\t */\n \tvq_offset = offsetof(struct virtio_net, mem);\n \n \t/* Set everything to 0. */\n@@ -491,8 +521,8 @@ new_device(struct vhost_device_ctx ctx)\n }\n \n /*\n- * Function is called from the CUSE release function. This function will cleanup\n- * the device and remove it from device configuration linked list.\n+ * Function is called from the CUSE release function. This function will\n+ * cleanup the device and remove it from device configuration linked list.\n  */\n static void\n destroy_device(struct vhost_device_ctx ctx)\n@@ -503,15 +533,19 @@ destroy_device(struct vhost_device_ctx ctx)\n \t/* Find the linked list entry for the device to be removed. */\n \tll_dev_cur_ctx = get_config_ll_entry(ctx);\n \twhile (ll_dev_cur != NULL) {\n-\t\t/* If the device is found or a device that doesn't exist is found then it is removed. */\n+\t\t/*\n+\t\t * If the device is found or\n+\t\t * a device that doesn't exist is found then it is removed.\n+\t\t */\n \t\tif (ll_dev_cur == ll_dev_cur_ctx) {\n \t\t\t/*\n-\t\t\t * If the device is running on a data core then call the function to remove it from\n-\t\t\t * the data core.\n+\t\t\t * If the device is running on a data core then call\n+\t\t\t * the function to remove it from the data core.\n \t\t\t */\n \t\t\tif ((ll_dev_cur->dev.flags & VIRTIO_DEV_RUNNING))\n \t\t\t\tnotify_ops->destroy_device(&(ll_dev_cur->dev));\n-\t\t\tll_dev_cur = rm_config_ll_entry(ll_dev_cur, ll_dev_last);\n+\t\t\tll_dev_cur = rm_config_ll_entry(ll_dev_cur,\n+\t\t\t\t\tll_dev_last);\n \t\t} else {\n \t\t\tll_dev_last = ll_dev_cur;\n \t\t\tll_dev_cur = ll_dev_cur->next;\n@@ -521,7 +555,8 @@ destroy_device(struct vhost_device_ctx ctx)\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_OWNER\n- * This function just returns success at the moment unless the device hasn't been initialised.\n+ * This function just returns success at the moment unless\n+ * the device hasn't been initialised.\n  */\n static int\n set_owner(struct vhost_device_ctx ctx)\n@@ -571,7 +606,7 @@ get_features(struct vhost_device_ctx ctx, uint64_t *pu)\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_FEATURES\n- * We receive the negotiated set of features supported by us and the virtio device.\n+ * We receive the negotiated features supported by us and the virtio device.\n  */\n static int\n set_features(struct vhost_device_ctx ctx, uint64_t *pu)\n@@ -589,13 +624,17 @@ set_features(struct vhost_device_ctx ctx, uint64_t *pu)\n \n \t/* Set the vhost_hlen depending on if VIRTIO_NET_F_MRG_RXBUF is set. */\n \tif (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") Mergeable RX buffers enabled\\n\", dev->device_fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Mergeable RX buffers enabled\\n\",\n+\t\t\tdev->device_fh);\n \t\tdev->virtqueue[VIRTIO_RXQ]->vhost_hlen =\n \t\t\tsizeof(struct virtio_net_hdr_mrg_rxbuf);\n \t\tdev->virtqueue[VIRTIO_TXQ]->vhost_hlen =\n \t\t\tsizeof(struct virtio_net_hdr_mrg_rxbuf);\n \t} else {\n-\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") Mergeable RX buffers disabled\\n\", dev->device_fh);\n+\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Mergeable RX buffers disabled\\n\",\n+\t\t\tdev->device_fh);\n \t\tdev->virtqueue[VIRTIO_RXQ]->vhost_hlen =\n \t\t\tsizeof(struct virtio_net_hdr);\n \t\tdev->virtqueue[VIRTIO_TXQ]->vhost_hlen =\n@@ -607,8 +646,8 @@ set_features(struct vhost_device_ctx ctx, uint64_t *pu)\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_MEM_TABLE\n- * This function creates and populates the memory structure for the device. This includes\n- * storing offsets used to translate buffer addresses.\n+ * This function creates and populates the memory structure for the device.\n+ * This includes storing offsets used to translate buffer addresses.\n  */\n static int\n set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,\n@@ -634,7 +673,9 @@ set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,\n \tmem = calloc(1, sizeof(struct virtio_memory) +\n \t\t(sizeof(struct virtio_memory_regions) * nregions));\n \tif (mem == NULL) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to allocate memory for dev->mem.\\n\", dev->device_fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to allocate memory for dev->mem.\\n\",\n+\t\t\tdev->device_fh);\n \t\treturn -1;\n \t}\n \n@@ -656,15 +697,18 @@ set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,\n \t\t\tmem_regions[regionidx].userspace_addr;\n \n \t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") REGION: %u - GPA: %p - QEMU VA: %p - SIZE (%\"PRIu64\")\\n\", dev->device_fh,\n-\t\t\t\tregionidx, (void *)(uintptr_t)mem->regions[regionidx].guest_phys_address,\n-\t\t\t\t(void *)(uintptr_t)mem->regions[regionidx].userspace_address,\n-\t\t\t\tmem->regions[regionidx].memory_size);\n+\t\t\tregionidx,\n+\t\t\t(void *)(uintptr_t)mem->regions[regionidx].guest_phys_address,\n+\t\t\t(void *)(uintptr_t)mem->regions[regionidx].userspace_address,\n+\t\t\tmem->regions[regionidx].memory_size);\n \n \t\t/*set the base address mapping*/\n \t\tif (mem->regions[regionidx].guest_phys_address == 0x0) {\n-\t\t\tmem->base_address = mem->regions[regionidx].userspace_address;\n+\t\t\tmem->base_address =\n+\t\t\t\tmem->regions[regionidx].userspace_address;\n \t\t\t/* Map VM memory file */\n-\t\t\tif (host_memory_map(dev, mem, ctx.pid, mem->base_address) != 0) {\n+\t\t\tif (host_memory_map(dev, mem, ctx.pid,\n+\t\t\t\tmem->base_address) != 0) {\n \t\t\t\tfree(mem);\n \t\t\t\treturn -1;\n \t\t\t}\n@@ -678,27 +722,42 @@ set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,\n \t\treturn -1;\n \t}\n \n-\t/* Check if all of our regions have valid mappings. Usually one does not exist in the QEMU memory file. */\n+\t/*\n+\t * Check if all of our regions have valid mappings.\n+\t * Usually one does not exist in the QEMU memory file.\n+\t */\n \tvalid_regions = mem->nregions;\n \tfor (regionidx = 0; regionidx < mem->nregions; regionidx++) {\n-\t\tif ((mem->regions[regionidx].userspace_address < mem->base_address) ||\n-\t\t\t(mem->regions[regionidx].userspace_address > (mem->base_address + mem->mapped_size)))\n+\t\tif ((mem->regions[regionidx].userspace_address <\n+\t\t\tmem->base_address) ||\n+\t\t\t(mem->regions[regionidx].userspace_address >\n+\t\t\t(mem->base_address + mem->mapped_size)))\n \t\t\t\tvalid_regions--;\n \t}\n \n-\t/* If a region does not have a valid mapping we rebuild our memory struct to contain only valid entries. */\n+\t/*\n+\t * If a region does not have a valid mapping,\n+\t * we rebuild our memory struct to contain only valid entries.\n+\t */\n \tif (valid_regions != mem->nregions) {\n \t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") Not all memory regions exist in the QEMU mem file. Re-populating mem structure\\n\",\n \t\t\tdev->device_fh);\n \n-\t\t/* Re-populate the memory structure with only valid regions. Invalid regions are over-written with memmove. */\n+\t\t/*\n+\t\t * Re-populate the memory structure with only valid regions.\n+\t\t * Invalid regions are over-written with memmove.\n+\t\t */\n \t\tvalid_regions = 0;\n \n \t\tfor (regionidx = mem->nregions; 0 != regionidx--;) {\n-\t\t\tif ((mem->regions[regionidx].userspace_address < mem->base_address) ||\n-\t\t\t\t\t(mem->regions[regionidx].userspace_address > (mem->base_address + mem->mapped_size))) {\n-\t\t\t\tmemmove(&mem->regions[regionidx], &mem->regions[regionidx + 1],\n-\t\t\t\t\tsizeof(struct virtio_memory_regions) * valid_regions);\n+\t\t\tif ((mem->regions[regionidx].userspace_address <\n+\t\t\t\tmem->base_address) ||\n+\t\t\t\t(mem->regions[regionidx].userspace_address >\n+\t\t\t\t(mem->base_address + mem->mapped_size))) {\n+\t\t\t\tmemmove(&mem->regions[regionidx],\n+\t\t\t\t\t&mem->regions[regionidx + 1],\n+\t\t\t\t\tsizeof(struct virtio_memory_regions) *\n+\t\t\t\t\t\tvalid_regions);\n \t\t\t} else {\n \t\t\t\tvalid_regions++;\n \t\t\t}\n@@ -708,12 +767,16 @@ set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,\n \tdev->mem = mem;\n \n \t/*\n-\t * Calculate the address offset for each region. This offset is used to identify the vhost virtual address\n+\t * Calculate the address offset for each region.\n+\t * This offset is used to identify the vhost virtual address\n \t * corresponding to a QEMU guest physical address.\n \t */\n \tfor (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) {\n-\t\tdev->mem->regions[regionidx].address_offset = dev->mem->regions[regionidx].userspace_address - dev->mem->base_address\n-\t\t\t+ dev->mem->mapped_address - dev->mem->regions[regionidx].guest_phys_address;\n+\t\tdev->mem->regions[regionidx].address_offset =\n+\t\t\tdev->mem->regions[regionidx].userspace_address -\n+\t\t\t\tdev->mem->base_address +\n+\t\t\t\tdev->mem->mapped_address -\n+\t\t\t\tdev->mem->regions[regionidx].guest_phys_address;\n \n \t}\n \treturn 0;\n@@ -732,7 +795,7 @@ set_vring_num(struct vhost_device_ctx ctx, struct vhost_vring_state *state)\n \tif (dev == NULL)\n \t\treturn -1;\n \n-\t/* State->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* State->index refers to the queue index. The txq is 1, rxq is 0. */\n \tdev->virtqueue[state->index]->size = state->num;\n \n \treturn 0;\n@@ -740,8 +803,8 @@ set_vring_num(struct vhost_device_ctx ctx, struct vhost_vring_state *state)\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_VRING_ADDR\n- * The virtio device sends us the desc, used and avail ring addresses. This function\n- * then converts these to our address space.\n+ * The virtio device sends us the desc, used and avail ring addresses.\n+ * This function then converts these to our address space.\n  */\n static int\n set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)\n@@ -753,31 +816,43 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)\n \tif (dev == NULL)\n \t\treturn -1;\n \n-\t/* addr->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* addr->index refers to the queue index. The txq 1, rxq is 0. */\n \tvq = dev->virtqueue[addr->index];\n \n \t/* The addresses are converted from QEMU virtual to Vhost virtual. */\n-\tvq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev, addr->desc_user_addr);\n+\tvq->desc = (struct vring_desc *)(uintptr_t)qva_to_vva(dev,\n+\t\t\taddr->desc_user_addr);\n \tif (vq->desc == 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to find descriptor ring address.\\n\", dev->device_fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to find desc ring address.\\n\",\n+\t\t\tdev->device_fh);\n \t\treturn -1;\n \t}\n \n-\tvq->avail = (struct vring_avail *)(uintptr_t)qva_to_vva(dev, addr->avail_user_addr);\n+\tvq->avail = (struct vring_avail *)(uintptr_t)qva_to_vva(dev,\n+\t\t\taddr->avail_user_addr);\n \tif (vq->avail == 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to find available ring address.\\n\", dev->device_fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to find avail ring address.\\n\",\n+\t\t\tdev->device_fh);\n \t\treturn -1;\n \t}\n \n-\tvq->used = (struct vring_used *)(uintptr_t)qva_to_vva(dev, addr->used_user_addr);\n+\tvq->used = (struct vring_used *)(uintptr_t)qva_to_vva(dev,\n+\t\t\taddr->used_user_addr);\n \tif (vq->used == 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to find used ring address.\\n\", dev->device_fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to find used ring address.\\n\",\n+\t\t\tdev->device_fh);\n \t\treturn -1;\n \t}\n \n-\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address desc: %p\\n\", dev->device_fh, vq->desc);\n-\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address avail: %p\\n\", dev->device_fh, vq->avail);\n-\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address used: %p\\n\", dev->device_fh, vq->used);\n+\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address desc: %p\\n\",\n+\t\t\tdev->device_fh, vq->desc);\n+\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address avail: %p\\n\",\n+\t\t\tdev->device_fh, vq->avail);\n+\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") mapped address used: %p\\n\",\n+\t\t\tdev->device_fh, vq->used);\n \n \treturn 0;\n }\n@@ -795,7 +870,7 @@ set_vring_base(struct vhost_device_ctx ctx, struct vhost_vring_state *state)\n \tif (dev == NULL)\n \t\treturn -1;\n \n-\t/* State->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* State->index refers to the queue index. The txq is 1, rxq is 0. */\n \tdev->virtqueue[state->index]->last_used_idx = state->num;\n \tdev->virtqueue[state->index]->last_used_idx_res = state->num;\n \n@@ -817,15 +892,15 @@ get_vring_base(struct vhost_device_ctx ctx, uint32_t index,\n \t\treturn -1;\n \n \tstate->index = index;\n-\t/* State->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* State->index refers to the queue index. The txq is 1, rxq is 0. */\n \tstate->num = dev->virtqueue[state->index]->last_used_idx;\n \n \treturn 0;\n }\n \n /*\n- * This function uses the eventfd_link kernel module to copy an eventfd file descriptor\n- * provided by QEMU in to our process space.\n+ * This function uses the eventfd_link kernel module to copy an eventfd file\n+ * descriptor provided by QEMU in to our process space.\n  */\n static int\n eventfd_copy(struct virtio_net *dev, struct eventfd_copy *eventfd_copy)\n@@ -835,7 +910,9 @@ eventfd_copy(struct virtio_net *dev, struct eventfd_copy *eventfd_copy)\n \t/* Open the character device to the kernel module. */\n \teventfd_link = open(eventfd_cdev, O_RDWR);\n \tif (eventfd_link < 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") eventfd_link module is not loaded\\n\",  dev->device_fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") eventfd_link module is not loaded\\n\",\n+\t\t\tdev->device_fh);\n \t\treturn -1;\n \t}\n \n@@ -844,18 +921,19 @@ eventfd_copy(struct virtio_net *dev, struct eventfd_copy *eventfd_copy)\n \tclose(eventfd_link);\n \n \tif (ret < 0) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") EVENTFD_COPY ioctl failed\\n\",  dev->device_fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") EVENTFD_COPY ioctl failed\\n\",\n+\t\t\tdev->device_fh);\n \t\treturn -1;\n \t}\n \n-\n \treturn 0;\n }\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_VRING_CALL\n- * The virtio device sends an eventfd to interrupt the guest. This fd gets copied in\n- * to our process space.\n+ * The virtio device sends an eventfd to interrupt the guest. This fd gets\n+ * copied into our process space.\n  */\n static int\n set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n@@ -868,7 +946,7 @@ set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \tif (dev == NULL)\n \t\treturn -1;\n \n-\t/* file->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* file->index refers to the queue index. The txq is 1, rxq is 0. */\n \tvq = dev->virtqueue[file->index];\n \n \tif (vq->kickfd)\n@@ -888,8 +966,8 @@ set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_VRING_KICK\n- * The virtio device sends an eventfd that it can use to notify us. This fd gets copied in\n- * to our process space.\n+ * The virtio device sends an eventfd that it can use to notify us.\n+ * This fd gets copied into our process space.\n  */\n static int\n set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n@@ -902,7 +980,7 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \tif (dev == NULL)\n \t\treturn -1;\n \n-\t/* file->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* file->index refers to the queue index. The txq is 1, rxq is 0. */\n \tvq = dev->virtqueue[file->index];\n \n \tif (vq->callfd)\n@@ -922,10 +1000,12 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \n /*\n  * Called from CUSE IOCTL: VHOST_NET_SET_BACKEND\n- * To complete device initialisation when the virtio driver is loaded we are provided with a\n- * valid fd for a tap device (not used by us). If this happens then we can add the device to a\n- * data core. When the virtio driver is removed we get fd=-1. At that point we remove the device\n- * from the data core. The device will still exist in the device configuration linked list.\n+ * To complete device initialisation when the virtio driver is loaded,\n+ * we are provided with a valid fd for a tap device (not used by us).\n+ * If this happens then we can add the device to a data core.\n+ * When the virtio driver is removed we get fd=-1.\n+ * At that point we remove the device from the data core.\n+ * The device will still exist in the device configuration linked list.\n  */\n static int\n set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n@@ -936,10 +1016,13 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \tif (dev == NULL)\n \t\treturn -1;\n \n-\t/* file->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n+\t/* file->index refers to the queue index. The txq is 1, rxq is 0. */\n \tdev->virtqueue[file->index]->backend = file->fd;\n \n-\t/* If the device isn't already running and both backend fds are set we add the device. */\n+\t/*\n+\t * If the device isn't already running and both backend fds are set,\n+\t * we add the device.\n+\t */\n \tif (!(dev->flags & VIRTIO_DEV_RUNNING)) {\n \t\tif (((int)dev->virtqueue[VIRTIO_TXQ]->backend != VIRTIO_DEV_STOPPED) &&\n \t\t\t((int)dev->virtqueue[VIRTIO_RXQ]->backend != VIRTIO_DEV_STOPPED))\n@@ -952,8 +1035,8 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n }\n \n /*\n- * Function pointers are set for the device operations to allow CUSE to call functions\n- * when an IOCTL, device_add or device_release is received.\n+ * Function pointers are set for the device operations to allow CUSE to call\n+ * functions when an IOCTL, device_add or device_release is received.\n  */\n static const struct vhost_net_device_ops vhost_device_ops = {\n \t.new_device = new_device,\n@@ -991,11 +1074,13 @@ int rte_vhost_enable_guest_notification(struct virtio_net *dev,\n \tuint16_t queue_id, int enable)\n {\n \tif (enable) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"guest notification isn't supported.\\n\");\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"guest notification isn't supported.\\n\");\n \t\treturn -1;\n \t}\n \n-\tdev->virtqueue[queue_id]->used->flags = enable ? 0 : VRING_USED_F_NO_NOTIFY;\n+\tdev->virtqueue[queue_id]->used->flags =\n+\t\tenable ? 0 : VRING_USED_F_NO_NOTIFY;\n \treturn 0;\n }\n \n",
    "prefixes": [
        "dpdk-dev"
    ]
}