get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 588,
    "url": "https://patches.dpdk.org/api/patches/588/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1411724758-27488-7-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": "<1411724758-27488-7-git-send-email-huawei.xie@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1411724758-27488-7-git-send-email-huawei.xie@intel.com",
    "date": "2014-09-26T09:45:53",
    "name": "[dpdk-dev,v5,06/11] lib/librte_vhost: fixes serious coding style issues",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "de31b7095fb53de4a71049dcac728900aced0633",
    "submitter": {
        "id": 16,
        "url": "https://patches.dpdk.org/api/people/16/?format=api",
        "name": "Huawei Xie",
        "email": "huawei.xie@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1411724758-27488-7-git-send-email-huawei.xie@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/588/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/588/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 7334B7E4F;\n\tFri, 26 Sep 2014 11:40:33 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id 3E5727E40\n\tfor <dev@dpdk.org>; Fri, 26 Sep 2014 11:40:28 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga102.fm.intel.com with ESMTP; 26 Sep 2014 02:46:49 -0700",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga002.fm.intel.com with ESMTP; 26 Sep 2014 02:46:47 -0700",
            "from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com\n\t[10.239.29.90])\n\tby shvmail01.sh.intel.com with ESMTP id s8Q9kjjT007085;\n\tFri, 26 Sep 2014 17:46:45 +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 s8Q9khXx027565; Fri, 26 Sep 2014 17:46:45 +0800",
            "(from hxie5@localhost)\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s8Q9khGI027561; \n\tFri, 26 Sep 2014 17:46:43 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.04,603,1406617200\"; d=\"scan'208\";a=\"605743417\"",
        "From": "Huawei Xie <huawei.xie@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Fri, 26 Sep 2014 17:45:53 +0800",
        "Message-Id": "<1411724758-27488-7-git-send-email-huawei.xie@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1411724758-27488-1-git-send-email-huawei.xie@intel.com>",
        "References": "<1411724758-27488-1-git-send-email-huawei.xie@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5 06/11] lib/librte_vhost: fixes serious coding\n\tstyle issues",
        "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": "fixes checkpatch reported issues.\n\nSigned-off-by: Huawei Xie <huawei.xie@intel.com>\n---\n lib/librte_vhost/rte_virtio_net.h |  55 +++++----\n lib/librte_vhost/vhost-net-cdev.c | 236 +++++++++++++++++++-------------------\n lib/librte_vhost/vhost-net-cdev.h |  33 +++---\n lib/librte_vhost/vhost_rxtx.c     |  57 +++++----\n lib/librte_vhost/virtio-net.c     | 149 ++++++++++++++----------\n 5 files changed, 281 insertions(+), 249 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h\nindex 99ddfc1..06cbdf7 100644\n--- a/lib/librte_vhost/rte_virtio_net.h\n+++ b/lib/librte_vhost/rte_virtio_net.h\n@@ -66,19 +66,18 @@ struct buf_vector {\n /**\n  * Structure contains variables relevant to RX/TX virtqueues.\n  */\n-struct vhost_virtqueue\n-{\n-\tstruct vring_desc\t*desc;\t\t\t\t/* Virtqueue descriptor ring. */\n-\tstruct vring_avail\t*avail;\t\t\t\t/* Virtqueue available ring. */\n-\tstruct vring_used\t*used;\t\t\t\t/* Virtqueue used ring. */\n-\tuint32_t\t\t\tsize;\t\t\t\t/* Size of descriptor ring. */\n-\tuint32_t\t\t\tbackend;\t\t\t/* Backend value to determine if device should started/stopped. */\n-\tuint16_t\t\t\tvhost_hlen;\t\t\t/* Vhost header length (varies depending on RX merge buffers. */\n+struct vhost_virtqueue {\n+\tstruct vring_desc\t*desc;\t\t\t/* Virtqueue descriptor ring. */\n+\tstruct vring_avail\t*avail;\t\t\t/* Virtqueue available ring. */\n+\tstruct vring_used\t*used;\t\t\t/* Virtqueue used ring. */\n+\tuint32_t\t\tsize;\t\t\t/* Size of descriptor ring. */\n+\tuint32_t\t\tbackend;\t\t/* Backend value to determine if device should started/stopped. */\n+\tuint16_t\t\tvhost_hlen;\t\t/* Vhost header length (varies depending on RX merge buffers. */\n \tvolatile uint16_t\tlast_used_idx;\t\t/* Last index used on the available ring */\n \tvolatile uint16_t\tlast_used_idx_res;\t/* Used for multiple devices reserving buffers. */\n-\teventfd_t\t\t\tcallfd;\t\t\t\t/* Currently unused as polling mode is enabled. */\n-\teventfd_t\t\t\tkickfd;\t\t\t\t/* Used to notify the guest (trigger interrupt). */\n-\tstruct buf_vector    buf_vec[BUF_VECTOR_MAX]; /**< for scatter RX. */\n+\teventfd_t\t\tcallfd;\t\t\t/* Currently unused as polling mode is enabled. */\n+\teventfd_t\t\tkickfd;\t\t\t/* Used to notify the guest (trigger interrupt). */\n+\tstruct buf_vector\tbuf_vec[BUF_VECTOR_MAX]; /**< for scatter RX. */\n } __rte_cache_aligned;\n \n \n@@ -86,11 +85,11 @@ struct vhost_virtqueue\n  * Information relating to memory regions including offsets to addresses in QEMUs memory file.\n  */\n struct virtio_memory_regions {\n-\tuint64_t\tguest_phys_address;\t\t/* Base guest physical address of region. */\n+\tuint64_t\tguest_phys_address;\t/* Base guest physical address of region. */\n \tuint64_t\tguest_phys_address_end;\t/* End guest physical address of region. */\n-\tuint64_t\tmemory_size;\t\t\t/* Size of region. */\n-\tuint64_t\tuserspace_address;\t\t/* Base userspace address of region. */\n-\tuint64_t\taddress_offset;\t\t\t/* Offset of region for address translation. */\n+\tuint64_t\tmemory_size;\t\t/* Size of region. */\n+\tuint64_t\tuserspace_address;\t/* Base userspace address of region. */\n+\tuint64_t\taddress_offset;\t\t/* Offset of region for address translation. */\n };\n \n \n@@ -98,31 +97,31 @@ struct virtio_memory_regions {\n  * Memory structure includes region and mapping information.\n  */\n struct virtio_memory {\n-\tuint64_t    base_address;    /**< Base QEMU userspace address of the memory file. */\n-\tuint64_t    mapped_address;  /**< Mapped address of memory file base in our applications memory space. */\n-\tuint64_t    mapped_size;     /**< Total size of memory file. */\n-\tuint32_t    nregions;        /**< Number of memory regions. */\n-\tstruct virtio_memory_regions      regions[0]; /**< Memory region information. */\n+\tuint64_t\tbase_address;\t/**< Base QEMU userspace address of the memory file. */\n+\tuint64_t\tmapped_address;\t/**< Mapped address of memory file base in our applications memory space. */\n+\tuint64_t\tmapped_size;\t/**< Total size of memory file. */\n+\tuint32_t\tnregions;\t/**< Number of memory regions. */\n+\tstruct\t\tvirtio_memory_regions      regions[0];\t/**< Memory region information. */\n };\n \n /**\n  * Device structure contains all configuration information relating to the device.\n  */\n struct virtio_net {\n-\tstruct vhost_virtqueue  *virtqueue[VIRTIO_QNUM]; /**< Contains all virtqueue information. */\n-\tstruct virtio_memory    *mem;                    /**< QEMU memory and memory region information. */\n-\tuint64_t features;    /**< Negotiated feature set. */\n-\tuint64_t device_fh;   /**< Device identifier. */\n-\tuint32_t flags;       /**< Device flags. Only used to check if device is running on data core. */\n-\tvoid     *priv;\n+\tstruct vhost_virtqueue\t*virtqueue[VIRTIO_QNUM];\t/**< Contains all virtqueue information. */\n+\tstruct virtio_memory\t*mem;\t\t\t\t/**< QEMU memory and memory region information. */\n+\tuint64_t features;\t/**< Negotiated feature set. */\n+\tuint64_t device_fh;\t/**< Device identifier. */\n+\tuint32_t flags;\t\t/**< Device flags. Only used to check if device is running on data core. */\n+\tvoid     *priv;\t\t/**< User context. */\n } __rte_cache_aligned;\n \n /**\n  * Device operations to add/remove device.\n  */\n struct virtio_net_device_ops {\n-\tint (*new_device)(struct virtio_net *); /**< Add device. */\n-\tvoid (*destroy_device)(struct virtio_net *); /**< Remove device. */\n+\tint (*new_device)(struct virtio_net *);\t\t/**< Add device. */\n+\tvoid (*destroy_device)(struct virtio_net *);\t/**< Remove device. */\n };\n \n \ndiff --git a/lib/librte_vhost/vhost-net-cdev.c b/lib/librte_vhost/vhost-net-cdev.c\nindex e73bf23..499e9b3 100644\n--- a/lib/librte_vhost/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost-net-cdev.c\n@@ -46,9 +46,9 @@\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\t\t\"\\0\\0\"\n+#define FUSE_OPT_FORE\t\t\"-f\\0\\0\"\n+#define FUSE_OPT_NOMULTI\t\"-s\\0\\0\"\n \n static const uint32_t\tdefault_major = 231;\n static const uint32_t\tdefault_minor = 1;\n@@ -113,61 +113,61 @@ 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\t\t\t\t\t\\\n-\tresult = (func)(ctx);\t\t\t\t\t\t\t\t\t\\\n-\tfuse_reply_ioctl(req, result, NULL, 0);\t\t\t\t\t\\\n-} while(0)\t\t\t\t\t\t\t\t\t\t\t\t\t\n+#define VHOST_IOCTL(func) do {\t\t\t\\\n+\tresult = (func)(ctx);\t\t\t\\\n+\tfuse_reply_ioctl(req, result, NULL, 0);\t\\\n+} while (0)\n \n /*\n  * Boilerplate IOCTL RETRY\n  * Implicit arguments: req.\n  */\n-#define VHOST_IOCTL_RETRY(size_r, size_w) do {\t\t\t\t\t\t\t\t\t\\\n-\tstruct iovec iov_r = { arg, (size_r) };\t\t\t\t\t\t\t\t\t\t\\\n-\tstruct iovec iov_w = { arg, (size_w) };\t\t\t\t\t\t\t\t\t\t\\\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-} while(0)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\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\t\t\\\n-\tif (!in_bufsz) {\t\t\t\t\t\t\t\t\t\\\n-\t\tVHOST_IOCTL_RETRY(sizeof(type), 0);\t\t\t\t\\\n-\t} else {\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\t(var) = *(const type * ) in_buf;\t\t\t\t\\\n-\t\tresult = func(ctx, &(var));\t\t\t\t\t\t\\\n-\t\tfuse_reply_ioctl(req, result, NULL, 0);\t\t\t\\\n-\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n-} while(0)\t\t\t\t\t\t\t\t\t\t\t\t\\\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\\\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+} while (0)\n \n /*\n  *\tBoilerplate 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\t\t\t\t\\\n-\tif (!out_bufsz) {\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\tVHOST_IOCTL_RETRY(0, sizeof(type));\t\t\t\t\t\t\\\n-\t} else {\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\tresult = (func)(ctx, &(var));\t\t\t\t\t\t\t\\\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\t\t\t\t\t\t\t\\\n-} while(0)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n+\t}\t\t\t\t\t\t\t\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\t\\\n-\tif (!in_bufsz) {\t\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\tVHOST_IOCTL_RETRY(sizeof(type1), sizeof(type2));\t\t\t\\\n-\t} else {\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n-\t\t(var1) = *(const type1* ) (in_buf);\t\t\t\t\t\t\t\\\n-\t\tresult = (func)(ctx, (var1), &(var2));\t\t\t\t\t\t\\\n-\t\tfuse_reply_ioctl(req, result, &(var2), sizeof(type2));\t\t\\\n-\t}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n-} while(0)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\\\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+} while (0)\n \n /*\n  * The IOCTLs are handled using CUSE/FUSE in userspace. Depending on\n@@ -187,106 +187,104 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n \tuint32_t index;\n \tint result = 0;\n \n-\tswitch(cmd)\n-\t{\n-\t\tcase VHOST_NET_SET_BACKEND:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_NET_SET_BACKEND\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_backend);\n-\t\t\tbreak;\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\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_backend);\n+\t\tbreak;\n \n-\t\tcase VHOST_GET_FEATURES:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_GET_FEATURES\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_W(uint64_t, features, ops->get_features);\n-\t\t\tbreak;\n+\tcase VHOST_GET_FEATURES:\n+\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_GET_FEATURES\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_W(uint64_t, features, ops->get_features);\n+\t\tbreak;\n \n-\t\tcase VHOST_SET_FEATURES:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_FEATURES\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(uint64_t, features, ops->set_features);\n+\tcase VHOST_SET_FEATURES:\n+\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_FEATURES\\n\", ctx.fh);\n+\t\tVHOST_IOCTL_R(uint64_t, features, ops->set_features);\n \t\t\tbreak;\n \n-\t\tcase VHOST_RESET_OWNER:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_RESET_OWNER\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL(ops->reset_owner);\n-\t\t\tbreak;\n+\tcase VHOST_RESET_OWNER:\n+\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_RESET_OWNER\\n\", ctx.fh);\n+\t\tVHOST_IOCTL(ops->reset_owner);\n+\t\tbreak;\n \n-\t\tcase VHOST_SET_OWNER:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_OWNER\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL(ops->set_owner);\n-\t\t\tbreak;\n+\tcase VHOST_SET_OWNER:\n+\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_OWNER\\n\", ctx.fh);\n+\t\tVHOST_IOCTL(ops->set_owner);\n+\t\tbreak;\n \n-\t\tcase VHOST_SET_MEM_TABLE:\n-\t\t\t/*TODO fix race condition.*/\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_MEM_TABLE\\n\", ctx.fh);\n-\t\t\tstatic struct vhost_memory mem_temp;\n-\n-\t\t\tswitch(in_bufsz){\n-\t\t\t\tcase 0:\n-\t\t\t\t\tVHOST_IOCTL_RETRY(sizeof(struct vhost_memory), 0);\n-\t\t\t\t\tbreak;\n-\n-\t\t\t\tcase sizeof(struct vhost_memory):\n-\t\t\t\t\tmem_temp = *(const struct vhost_memory *) in_buf;\n-\n-\t\t\t\t\tif (mem_temp.nregions > 0) {\n-\t\t\t\t\t\tVHOST_IOCTL_RETRY(sizeof(struct vhost_memory) + (sizeof(struct vhost_memory_region) * mem_temp.nregions), 0);\n-\t\t\t\t\t} else {\n-\t\t\t\t\t\tresult = -1;\n-\t\t\t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n-\t\t\t\t\t}\n-\t\t\t\t\tbreak;\n-\n-\t\t\t\tdefault:\n-\t\t\t\t\tresult = ops->set_mem_table(ctx, in_buf, mem_temp.nregions);\n-\t\t\t\t\tif (result)\n-\t\t\t\t\t\tfuse_reply_err(req, EINVAL);\n-\t\t\t\t\telse\n-\t\t\t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\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\tstatic struct vhost_memory mem_temp;\n \n-\t\t\t}\n-\n-\t\t\tbreak;\n-\n-\t\tcase VHOST_SET_VRING_NUM:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_NUM\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(struct vhost_vring_state, state, ops->set_vring_num);\n+\t\tswitch (in_bufsz) {\n+\t\tcase 0:\n+\t\t\tVHOST_IOCTL_RETRY(sizeof(struct vhost_memory), 0);\n \t\t\tbreak;\n \n-\t\tcase VHOST_SET_VRING_BASE:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_BASE\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(struct vhost_vring_state, state, ops->set_vring_base);\n-\t\t\tbreak;\n+\t\tcase sizeof(struct vhost_memory):\n+\t\t\tmem_temp = *(const struct vhost_memory *) in_buf;\n \n-\t\tcase VHOST_GET_VRING_BASE:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_GET_VRING_BASE\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_RW(uint32_t, index, struct vhost_vring_state, state, ops->get_vring_base);\n-\t\t\tbreak;\n-\n-\t\tcase VHOST_SET_VRING_ADDR:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_ADDR\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(struct vhost_vring_addr, addr, ops->set_vring_addr);\n-\t\t\tbreak;\n-\n-\t\tcase VHOST_SET_VRING_KICK:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_KICK\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_vring_kick);\n-\t\t\tbreak;\n-\n-\t\tcase VHOST_SET_VRING_CALL:\n-\t\t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_CALL\\n\", ctx.fh);\n-\t\t\tVHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_vring_call);\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} else {\n+\t\t\t\tresult = -1;\n+\t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n+\t\t\t}\n \t\t\tbreak;\n \n \t\tdefault:\n-\t\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: DOESN NOT EXIST\\n\", ctx.fh);\n-\t\t\tresult = -1;\n-\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n+\t\t\tresult = ops->set_mem_table(ctx, in_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\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\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\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\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\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\tbreak;\n+\n+\tdefault:\n+\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"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+\tif (result < 0)\n \t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: FAIL\\n\", ctx.fh);\n-\t} else {\n+\telse\n \t\tLOG_DEBUG(VHOST_CONFIG, \"(%\"PRIu64\") IOCTL: SUCCESS\\n\", ctx.fh);\n-\t}\n }\n \n /*\ndiff --git a/lib/librte_vhost/vhost-net-cdev.h b/lib/librte_vhost/vhost-net-cdev.h\nindex d9a5a9a..f685f2b 100644\n--- a/lib/librte_vhost/vhost-net-cdev.h\n+++ b/lib/librte_vhost/vhost-net-cdev.h\n@@ -76,10 +76,9 @@\n /*\n  * Structure used to identify device context.\n  */\n-struct vhost_device_ctx\n-{\n+struct vhost_device_ctx {\n \tpid_t\t\tpid;\t/* PID of process calling the IOCTL. */\n-\tuint64_t \tfh;\t\t/* Populated with fi->fh to track the device index. */\n+\tuint64_t\tfh;\t/* Populated with fi->fh to track the device index. */\n };\n \n /*\n@@ -87,26 +86,26 @@ struct vhost_device_ctx\n  * functions are called in CUSE context and are used to configure devices.\n  */\n struct vhost_net_device_ops {\n-\tint (* new_device) \t\t(struct vhost_device_ctx);\n-\tvoid (* destroy_device) (struct vhost_device_ctx);\n+\tint (*new_device)(struct vhost_device_ctx);\n+\tvoid (*destroy_device)(struct vhost_device_ctx);\n \n-\tint (* get_features) \t(struct vhost_device_ctx, uint64_t *);\n-\tint (* set_features) \t(struct vhost_device_ctx, uint64_t *);\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) \t(struct vhost_device_ctx, const void *, uint32_t);\n+\tint (*set_mem_table)(struct vhost_device_ctx, const void *, uint32_t);\n \n-\tint (* set_vring_num) \t(struct vhost_device_ctx, struct vhost_vring_state *);\n-\tint (* set_vring_addr) \t(struct vhost_device_ctx, struct vhost_vring_addr *);\n-\tint (* set_vring_base) \t(struct vhost_device_ctx, struct vhost_vring_state *);\n-\tint (* get_vring_base) \t(struct vhost_device_ctx, uint32_t, struct vhost_vring_state *);\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) \t(struct vhost_device_ctx, struct vhost_vring_file *);\n-\tint (* set_vring_call) \t(struct vhost_device_ctx, struct vhost_vring_file *);\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) \t(struct vhost_device_ctx, struct vhost_vring_file *);\n+\tint (*set_backend)(struct vhost_device_ctx, struct vhost_vring_file *);\n \n-\tint (* set_owner) \t\t(struct vhost_device_ctx);\n-\tint (* reset_owner) \t(struct vhost_device_ctx);\n+\tint (*set_owner)(struct vhost_device_ctx);\n+\tint (*reset_owner)(struct vhost_device_ctx);\n };\n \n \ndiff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c\nindex 688e661..7c2c47a 100644\n--- a/lib/librte_vhost/vhost_rxtx.c\n+++ b/lib/librte_vhost/vhost_rxtx.c\n@@ -50,13 +50,14 @@\n  * added to the RX queue. This function works when mergeable is disabled.\n  */\n static inline uint32_t __attribute__((always_inline))\n-virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts, uint32_t count)\n+virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n+\tstruct rte_mbuf **pkts, uint32_t count)\n {\n \tstruct vhost_virtqueue *vq;\n \tstruct vring_desc *desc;\n \tstruct rte_mbuf *buff;\n \t/* The virtio_hdr is initialised to 0. */\n-\tstruct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0,0,0,0,0,0},0};\n+\tstruct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, 0, 0, 0, 0, 0}, 0};\n \tuint64_t buff_addr = 0;\n \tuint64_t buff_hdr_addr = 0;\n \tuint32_t head[VHOST_MAX_PKT_BURST], packet_len = 0;\n@@ -74,7 +75,10 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts,\n \n \tvq = dev->virtqueue[VIRTIO_RXQ];\n \tcount = (count > VHOST_MAX_PKT_BURST) ? VHOST_MAX_PKT_BURST : count;\n-\t/* As many data cores may want access to available buffers, they need to be reserved. */\n+\t/*\n+\t * As many data cores may want access to available buffers,\n+\t * they need to be reserved.\n+\t */\n \tdo {\n \t\tres_base_idx = vq->last_used_idx_res;\n \t\tavail_idx = *((volatile uint16_t *)&vq->avail->idx);\n@@ -89,20 +93,22 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts,\n \n \t\tres_end_idx = res_base_idx + count;\n \t\t/* vq->last_used_idx_res is atomically updated. */\n-\t\t/* TODO: Allow to disable cmpset if no concurrency in application */\n+\t\t/* TODO: Allow to disable cmpset if no concurrency in application. */\n \t\tsuccess = rte_atomic16_cmpset(&vq->last_used_idx_res,\n \t\t\t\tres_base_idx, res_end_idx);\n \t\t/* If there is contention here and failed, try again. */\n \t} while (unlikely(success == 0));\n \tres_cur_idx = res_base_idx;\n-\tLOG_DEBUG(VHOST_DATA, \"(%\"PRIu64\") Current Index %d| End Index %d\\n\", dev->device_fh, res_cur_idx, res_end_idx);\n+\tLOG_DEBUG(VHOST_DATA, \"(%\"PRIu64\") Current Index %d| End Index %d\\n\",\n+\t\t\tdev->device_fh, res_cur_idx, res_end_idx);\n \n \t/* Prefetch available ring to retrieve indexes. */\n \trte_prefetch0(&vq->avail->ring[res_cur_idx & (vq->size - 1)]);\n \n \t/* Retrieve all of the head indexes first to avoid caching issues. */\n \tfor (head_idx = 0; head_idx < count; head_idx++)\n-\t\thead[head_idx] = vq->avail->ring[(res_cur_idx + head_idx) & (vq->size - 1)];\n+\t\thead[head_idx] = vq->avail->ring[(res_cur_idx + head_idx) &\n+\t\t\t\t\t(vq->size - 1)];\n \n \t/*Prefetch descriptor index. */\n \trte_prefetch0(&vq->desc[head[packet_success]]);\n@@ -113,18 +119,18 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts,\n \n \t\tbuff = pkts[packet_success];\n \n-\t\t/* Convert from gpa to vva (guest physical addr -> vhost virtual addr) */\n+\t\t/* gpa to vva (guest physical addr -> vhost virtual addr) */\n \t\tbuff_addr = gpa_to_vva(dev, desc->addr);\n \t\t/* Prefetch buffer address. */\n-\t\trte_prefetch0((void*)(uintptr_t)buff_addr);\n+\t\trte_prefetch0((void *)(uintptr_t)buff_addr);\n \n \t\t/* Copy virtio_hdr to packet and increment buffer address */\n \t\tbuff_hdr_addr = buff_addr;\n \t\tpacket_len = rte_pktmbuf_data_len(buff) + vq->vhost_hlen;\n \n \t\t/*\n-\t\t * If the descriptors are chained the header and data are placed in\n-\t\t * separate buffers.\n+\t\t * If the descriptors are chained the header and data are\n+\t\t * placed in separate buffers.\n \t\t */\n \t\tif (desc->flags & VRING_DESC_F_NEXT) {\n \t\t\tdesc->len = vq->vhost_hlen;\n@@ -143,7 +149,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts,\n \t\tvq->used->ring[res_cur_idx & (vq->size - 1)].len = packet_len;\n \n \t\t/* Copy mbuf data to buffer */\n-\t\t/* TODO fixme for sg mbuf and the case that desc couldn't hold the mbuf data */\n+\t\t/* FIXME for sg mbuf and the case that desc couldn't hold the mbuf data */\n \t\trte_memcpy((void *)(uintptr_t)buff_addr,\n \t\t\trte_pktmbuf_mtod(buff, const void *),\n \t\t\trte_pktmbuf_data_len(buff));\n@@ -152,10 +158,11 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts,\n \n \t\tres_cur_idx++;\n \t\tpacket_success++;\n-\t\n-\t\trte_memcpy((void *)(uintptr_t)buff_hdr_addr, (const void *)&virtio_hdr,\n-\t\t\t\tvq->vhost_hlen);\n-\t\tVHOST_PRINT_PACKET(dev, (uintptr_t)buff_hdr_addr, vq->vhost_hlen, 1);\n+\n+\t\trte_memcpy((void *)(uintptr_t)buff_hdr_addr,\n+\t\t\t(const void *)&virtio_hdr, vq->vhost_hlen);\n+\t\tVHOST_PRINT_PACKET(dev, (uintptr_t)buff_hdr_addr,\n+\t\t\t\tvq->vhost_hlen, 1);\n \t\tif (res_cur_idx < res_end_idx) {\n \t\t\t/* Prefetch descriptor index. */\n \t\t\trte_prefetch0(&vq->desc[head[packet_success]]);\n@@ -386,8 +393,8 @@ copy_from_mbuf_to_vring(struct virtio_net *dev, uint16_t res_base_idx,\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, struct rte_mbuf **pkts,\n-\tuint32_t count)\n+virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,\n+\tstruct rte_mbuf **pkts, uint32_t count)\n {\n \tstruct vhost_virtqueue *vq;\n \tuint32_t pkt_idx = 0, entry_success = 0;\n@@ -507,7 +514,8 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf *\n }\n \n uint32_t\n-rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_mbuf **pkts, uint32_t count)\n+rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id,\n+\tstruct rte_mbuf **pkts, uint32_t count)\n {\n \tif (unlikely(dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)))\n \t\treturn virtio_dev_merge_rx(dev, queue_id, pkts, count);\n@@ -518,7 +526,8 @@ rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_mb\n \n \n uint32_t\n-rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint32_t count)\n+rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,\n+\tstruct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint32_t count)\n {\n \tstruct rte_mbuf *m, *prev;\n \tstruct vhost_virtqueue *vq;\n@@ -555,7 +564,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_me\n \t/* Limit to MAX_PKT_BURST. */\n \tfree_entries = RTE_MIN(free_entries, VHOST_MAX_PKT_BURST);\n \n-\tLOG_DEBUG(VHOST_DATA, \"(%\"PRIu64\") Buffers available %d\\n\", dev->device_fh, free_entries);\n+\tLOG_DEBUG(VHOST_DATA, \"(%\"PRIu64\") Buffers available %d\\n\",\n+\t\t\tdev->device_fh, free_entries);\n \t/* Retrieve all of the head indexes first to avoid caching issues. */\n \tfor (i = 0; i < free_entries; i++)\n \t\thead[i] = vq->avail->ring[(vq->last_used_idx + i) & (vq->size - 1)];\n@@ -596,7 +606,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_me\n \n \t\tvb_offset = 0;\n \t\tvb_avail = desc->len;\n-\t\t\n+\n \t\tseg_avail = 0;\n \t\t/* Allocate an mbuf and populate the structure. */\n \t\tm = rte_pktmbuf_alloc(mbuf_pool);\n@@ -611,7 +621,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_me\n \n \t\tVHOST_PRINT_PACKET(dev, (uintptr_t)vb_addr, desc->len, 0);\n \n-\t\t\n+\n \t\tseg_num++;\n \t\tcur = m;\n \t\tprev = m;\n@@ -681,7 +691,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id, struct rte_me\n \t\t\t\t\t\tprev->next = cur;\n \t\t\t\t\t\tprev = cur;\n \t\t\t\t\t\tseg_offset = 0;\n-\t\t\t\t\t\tseg_avail = cur->buf_len - RTE_PKTMBUF_HEADROOM;\n+\t\t\t\t\t\tseg_avail = cur->buf_len -\n+\t\t\t\t\t\t\tRTE_PKTMBUF_HEADROOM;\n \t\t\t\t\t}\n \n \t\t\t\t\tdesc = &vq->desc[desc->next];\ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex 9852961..616af5f 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -56,16 +56,16 @@\n  * Device linked list structure for configuration.\n  */\n struct virtio_net_config_ll {\n-\tstruct virtio_net             dev;    /* Virtio device. */\n-\tstruct virtio_net_config_ll   *next;  /* Next entry on linked list. */\n+\tstruct virtio_net\t\tdev;\t/* Virtio device.*/\n+\tstruct virtio_net_config_ll\t*next;\t/* Next entry on linked list.*/\n };\n \n static const char eventfd_cdev[] = \"/dev/eventfd-link\";\n \n /* device ops to add/remove device to data core. */\n-static struct virtio_net_device_ops const * notify_ops;\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\t\t*ll_root = NULL;\n+static struct virtio_net_config_ll\t*ll_root;\n \n /* Features supported by this library. */\n #define VHOST_SUPPORTED_FEATURES (1ULL << VIRTIO_NET_F_MRG_RXBUF)\n@@ -81,16 +81,15 @@ static const uint32_t BUFSIZE = PATH_MAX;\n #define PROCMAP_SZ 8\n \n /* Structure containing information gathered from maps file. */\n-struct procmap\n-{\n-\tuint64_t\tva_start;\t\t\t/* Start virtual address in file. */\n-\tuint64_t\tlen;\t\t\t\t/* Size of file. */\n-\tuint64_t\tpgoff;\t\t\t\t/* Not used. */\n-\tuint32_t\tmaj;\t\t\t\t/* Not used. */\n-\tuint32_t\tmin;\t\t\t\t/* Not used. */\n-\tuint32_t\tino;\t\t\t\t/* Not used. */\n-\tchar\t\tprot[PROT_SZ];\t\t/* Not used. */\n-\tchar\t\tfname[PATH_MAX];\t/* File name. */\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 };\n \n /*\n@@ -109,8 +108,9 @@ qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)\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\tvhost_va = dev->mem->mapped_address + qemu_va - dev->mem->base_address;\n+\t\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 \t\t}\n \t}\n@@ -121,7 +121,8 @@ qva_to_vva(struct virtio_net *dev, uint64_t qemu_va)\n  * Locate the file containing QEMU's memory space and map it to our address space.\n  */\n static int\n-host_memory_map (struct virtio_net *dev, struct virtio_memory *mem, pid_t pid, uint64_t addr)\n+host_memory_map(struct virtio_net *dev, struct virtio_memory *mem,\n+\tpid_t pid, uint64_t addr)\n {\n \tstruct dirent *dptr = NULL;\n \tstruct procmap procmap;\n@@ -134,20 +135,22 @@ host_memory_map (struct virtio_net *dev, struct virtio_memory *mem, pid_t pid, u\n \tchar resolved_path[PATH_MAX];\n \tFILE\t\t*fmap;\n \tvoid\t\t*map;\n-\tuint8_t \tfound = 0;\n-\tchar \t\tline[BUFSIZE];\n+\tuint8_t\t\tfound = 0;\n+\tchar\t\tline[BUFSIZE];\n \tchar dlm[] = \"-   :   \";\n \tchar *str, *sp, *in[PROCMAP_SZ];\n \tchar *end = NULL;\n \n \t/* Path where mem files are located. */\n-\tsnprintf (procdir, PATH_MAX, \"/proc/%u/fd/\", pid);\n+\tsnprintf(procdir, PATH_MAX, \"/proc/%u/fd/\", pid);\n \t/* Maps file used to locate mem file. */\n-\tsnprintf (mapfile, PATH_MAX, \"/proc/%u/maps\", pid);\n+\tsnprintf(mapfile, PATH_MAX, \"/proc/%u/maps\", pid);\n \n \tfmap = fopen(mapfile, \"r\");\n \tif (fmap == NULL) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to open maps file for pid %d\\n\", dev->device_fh, pid);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to open maps file for pid %d\\n\",\n+\t\t\tdev->device_fh, pid);\n \t\treturn -1;\n \t}\n \n@@ -157,7 +160,8 @@ host_memory_map (struct virtio_net *dev, struct virtio_memory *mem, pid_t pid, u\n \t\terrno = 0;\n \t\t/* Split line in to fields. */\n \t\tfor (i = 0; i < PROCMAP_SZ; i++) {\n-\t\t\tif (((in[i] = strtok_r(str, &dlm[i], &sp)) == NULL) || (errno != 0)) {\n+\t\t\tin[i] = strtok_r(str, &dlm[i], &sp);\n+\t\t\tif ((in[i] == NULL) || (errno != 0)) {\n \t\t\t\tfclose(fmap);\n \t\t\t\treturn -1;\n \t\t\t}\n@@ -220,7 +224,7 @@ host_memory_map (struct virtio_net *dev, struct virtio_memory *mem, pid_t pid, u\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, \"(%\"PRIu64\") Cannot open pid %d process directory\\n\", dev->device_fh, pid);\n \t\treturn -1;\n \n \t}\n@@ -229,7 +233,8 @@ host_memory_map (struct virtio_net *dev, struct virtio_memory *mem, pid_t pid, u\n \n \t/* Read the fd directory contents. */\n \twhile (NULL != (dptr = readdir(dp))) {\n-\t\tsnprintf (memfile, PATH_MAX, \"/proc/%u/fd/%s\", pid, dptr->d_name);\n+\t\tsnprintf(memfile, PATH_MAX, \"/proc/%u/fd/%s\",\n+\t\t\t\tpid, dptr->d_name);\n \t    realpath(memfile, resolved_path);\n \t\tif (resolved_path == NULL) {\n \t\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to resolve fd directory\\n\", dev->device_fh);\n@@ -257,8 +262,9 @@ host_memory_map (struct virtio_net *dev, struct virtio_memory *mem, pid_t pid, u\n \t\treturn -1;\n \t}\n \n-\tmap = mmap(0, (size_t)procmap.len, PROT_READ|PROT_WRITE , MAP_POPULATE|MAP_SHARED, fd, 0);\n-\tclose (fd);\n+\tmap = mmap(0, (size_t)procmap.len, PROT_READ|PROT_WRITE ,\n+\t\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@@ -304,9 +310,8 @@ get_device(struct vhost_device_ctx ctx)\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+\tif (ll_dev)\n \t\treturn &ll_dev->dev;\n-\t}\n \n \tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Device not found in linked list.\\n\", ctx.fh);\n \treturn NULL;\n@@ -351,7 +356,8 @@ cleanup_device(struct virtio_net *dev)\n {\n \t/* Unmap QEMU memory file if mapped. */\n \tif (dev->mem) {\n-\t\tmunmap((void*)(uintptr_t)dev->mem->mapped_address, (size_t)dev->mem->mapped_size);\n+\t\tmunmap((void *)(uintptr_t)dev->mem->mapped_address,\n+\t\t\t(size_t)dev->mem->mapped_size);\n \t\tfree(dev->mem);\n \t}\n \n@@ -381,7 +387,8 @@ free_device(struct virtio_net_config_ll *ll_dev)\n  * Remove an entry from the device configuration linked list.\n  */\n static struct virtio_net_config_ll *\n-rm_config_ll_entry(struct virtio_net_config_ll *ll_dev, struct virtio_net_config_ll *ll_dev_last)\n+rm_config_ll_entry(struct virtio_net_config_ll *ll_dev,\n+\tstruct virtio_net_config_ll *ll_dev_last)\n {\n \t/* First remove the device and then clean it up. */\n \tif (ll_dev == ll_root) {\n@@ -398,7 +405,8 @@ rm_config_ll_entry(struct virtio_net_config_ll *ll_dev, struct virtio_net_config\n \t\t} else {\n \t\t\tcleanup_device(&ll_dev->dev);\n \t\t\tfree_device(ll_dev);\n-\t\t\tRTE_LOG(ERR, VHOST_CONFIG, \"Remove entry from config_ll failed\\n\");\n+\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\t\"Remove entry from config_ll failed\\n\");\n \t\t\treturn NULL;\n \t\t}\n \t}\n@@ -416,7 +424,7 @@ init_device(struct virtio_net *dev)\n \tvq_offset = offsetof(struct virtio_net, mem);\n \n \t/* Set everything to 0. */\n-\tmemset((void*)(uintptr_t)((uint64_t)(uintptr_t)dev + vq_offset), 0,\n+\tmemset((void *)(uintptr_t)((uint64_t)(uintptr_t)dev + vq_offset), 0,\n \t\t(sizeof(struct virtio_net) - (size_t)vq_offset));\n \tmemset(dev->virtqueue[VIRTIO_RXQ], 0, sizeof(struct vhost_virtqueue));\n \tmemset(dev->virtqueue[VIRTIO_TXQ], 0, sizeof(struct vhost_virtqueue));\n@@ -440,14 +448,18 @@ new_device(struct vhost_device_ctx ctx)\n \t/* Setup device and virtqueues. */\n \tnew_ll_dev = malloc(sizeof(struct virtio_net_config_ll));\n \tif (new_ll_dev == NULL) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to allocate memory for dev.\\n\", ctx.fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to allocate memory for dev.\\n\",\n+\t\t\tctx.fh);\n \t\treturn -1;\n \t}\n \n \tvirtqueue_rx = malloc(sizeof(struct vhost_virtqueue));\n \tif (virtqueue_rx == NULL) {\n \t\tfree(new_ll_dev);\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to allocate memory for virtqueue_rx.\\n\", ctx.fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to allocate memory for rxq.\\n\",\n+\t\t\tctx.fh);\n \t\treturn -1;\n \t}\n \n@@ -455,7 +467,9 @@ new_device(struct vhost_device_ctx ctx)\n \tif (virtqueue_tx == NULL) {\n \t\tfree(virtqueue_rx);\n \t\tfree(new_ll_dev);\n-\t\tRTE_LOG(ERR, VHOST_CONFIG, \"(%\"PRIu64\") Failed to allocate memory for virtqueue_tx.\\n\", ctx.fh);\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"(%\"PRIu64\") Failed to allocate memory for txq.\\n\",\n+\t\t\tctx.fh);\n \t\treturn -1;\n \t}\n \n@@ -573,12 +587,16 @@ set_features(struct vhost_device_ctx ctx, uint64_t *pu)\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\tdev->virtqueue[VIRTIO_RXQ]->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf);\n-\t\tdev->virtqueue[VIRTIO_TXQ]->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf);\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\tdev->virtqueue[VIRTIO_RXQ]->vhost_hlen = sizeof(struct virtio_net_hdr);\n-\t\tdev->virtqueue[VIRTIO_TXQ]->vhost_hlen = sizeof(struct virtio_net_hdr);\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+\t\t\tsizeof(struct virtio_net_hdr);\n \t}\n \treturn 0;\n }\n@@ -590,7 +608,8 @@ set_features(struct vhost_device_ctx ctx, uint64_t *pu)\n  * 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, uint32_t nregions)\n+set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr,\n+\tuint32_t nregions)\n {\n \tstruct virtio_net *dev;\n \tstruct vhost_memory_region *mem_regions;\n@@ -603,12 +622,14 @@ set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr, uint32_\n \t\treturn -1;\n \n \tif (dev->mem) {\n-\t\tmunmap((void*)(uintptr_t)dev->mem->mapped_address, (size_t)dev->mem->mapped_size);\n+\t\tmunmap((void *)(uintptr_t)dev->mem->mapped_address,\n+\t\t\t(size_t)dev->mem->mapped_size);\n \t\tfree(dev->mem);\n \t}\n \n \t/* Malloc the memory structure depending on the number of regions. */\n-\tmem = calloc(1, sizeof(struct virtio_memory) + (sizeof(struct virtio_memory_regions) * nregions));\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\treturn -1;\n@@ -616,19 +637,24 @@ set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr, uint32_\n \n \tmem->nregions = nregions;\n \n-\tmem_regions = (void*)(uintptr_t)((uint64_t)(uintptr_t)mem_regions_addr + size);\n+\tmem_regions = (void *)(uintptr_t)\n+\t\t\t((uint64_t)(uintptr_t)mem_regions_addr + size);\n \n \tfor (regionidx = 0; regionidx < mem->nregions; regionidx++) {\n \t\t/* Populate the region structure for each region. */\n-\t\tmem->regions[regionidx].guest_phys_address = mem_regions[regionidx].guest_phys_addr;\n-\t\tmem->regions[regionidx].guest_phys_address_end = mem->regions[regionidx].guest_phys_address +\n+\t\tmem->regions[regionidx].guest_phys_address =\n+\t\t\tmem_regions[regionidx].guest_phys_addr;\n+\t\tmem->regions[regionidx].guest_phys_address_end =\n+\t\t\tmem->regions[regionidx].guest_phys_address +\n \t\t\tmem_regions[regionidx].memory_size;\n-\t\tmem->regions[regionidx].memory_size = mem_regions[regionidx].memory_size;\n-\t\tmem->regions[regionidx].userspace_address = mem_regions[regionidx].userspace_addr;\n+\t\tmem->regions[regionidx].memory_size =\n+\t\t\tmem_regions[regionidx].memory_size;\n+\t\tmem->regions[regionidx].userspace_address =\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\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 \n \t\t/*set the base address mapping*/\n@@ -728,19 +754,19 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)\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, addr->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\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, addr->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\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, addr->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\treturn -1;\n@@ -778,7 +804,8 @@ set_vring_base(struct vhost_device_ctx ctx, struct vhost_vring_state *state)\n  * We send the virtio device our available ring last used index.\n  */\n static int\n-get_vring_base(struct vhost_device_ctx ctx, uint32_t index, struct vhost_vring_state *state)\n+get_vring_base(struct vhost_device_ctx ctx, uint32_t index,\n+\tstruct vhost_vring_state *state)\n {\n \tstruct virtio_net *dev;\n \n@@ -885,7 +912,7 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \teventfd_call.target_pid = ctx.pid;\n \n \tif (eventfd_copy(dev, &eventfd_call))\n-        return -1;\n+\t\treturn -1;\n \n \treturn 0;\n }\n@@ -903,9 +930,8 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \tstruct virtio_net *dev;\n \n \tdev = get_device(ctx);\n-\tif (dev == NULL) {\n+\tif (dev == NULL)\n \t\treturn -1;\n-\t}\n \n \t/* file->index refers to the queue index. The TX queue is 1, RX queue is 0. */\n \tdev->virtqueue[file->index]->backend = file->fd;\n@@ -917,9 +943,8 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \t\t\treturn notify_ops->new_device(dev);\n \t/* Otherwise we remove it. */\n \t} else\n-\t\tif (file->fd == VIRTIO_DEV_STOPPED) {\n+\t\tif (file->fd == VIRTIO_DEV_STOPPED)\n \t\t\tnotify_ops->destroy_device(dev);\n-\t\t}\n \treturn 0;\n }\n \n@@ -927,8 +952,7 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\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  */\n-static const struct vhost_net_device_ops vhost_device_ops =\n-{\n+static const struct vhost_net_device_ops vhost_device_ops = {\n \t.new_device = new_device,\n \t.destroy_device = destroy_device,\n \n@@ -960,7 +984,8 @@ get_virtio_net_callbacks(void)\n \treturn &vhost_device_ops;\n }\n \n-int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable)\n+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",
    "prefixes": [
        "dpdk-dev",
        "v5",
        "06/11"
    ]
}