get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2505,
    "url": "https://patches.dpdk.org/api/patches/2505/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1422242440-28948-6-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": "<1422242440-28948-6-git-send-email-huawei.xie@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1422242440-28948-6-git-send-email-huawei.xie@intel.com",
    "date": "2015-01-26T03:20:31",
    "name": "[dpdk-dev,RFC,v2,05/14] implement eventfd copying(from fd in qemu process to fd in vhost process) in vhost-net-cdev.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5f23f1d6b644517a98ea94be34e401bbb002fbb6",
    "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/1422242440-28948-6-git-send-email-huawei.xie@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/2505/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/2505/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 E86E65A7D;\n\tMon, 26 Jan 2015 04:21:31 +0100 (CET)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id E17F05A9E\n\tfor <dev@dpdk.org>; Mon, 26 Jan 2015 04:21:08 +0100 (CET)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga103.fm.intel.com with ESMTP; 25 Jan 2015 19:15:06 -0800",
            "from shvmail01.sh.intel.com ([10.239.29.42])\n\tby fmsmga002.fm.intel.com with ESMTP; 25 Jan 2015 19:21:06 -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 t0Q3L3cF013359;\n\tMon, 26 Jan 2015 11:21:03 +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 t0Q3L1Oe029018; Mon, 26 Jan 2015 11:21:03 +0800",
            "(from hxie5@localhost)\n\tby shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t0Q3L1Aq029014; \n\tMon, 26 Jan 2015 11:21:01 +0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.09,466,1418112000\"; d=\"scan'208\";a=\"667415709\"",
        "From": "Huawei Xie <huawei.xie@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Mon, 26 Jan 2015 11:20:31 +0800",
        "Message-Id": "<1422242440-28948-6-git-send-email-huawei.xie@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1422242440-28948-1-git-send-email-huawei.xie@intel.com>",
        "References": "<1422242440-28948-1-git-send-email-huawei.xie@intel.com>",
        "Subject": "[dpdk-dev] [RFC PATCH v2 05/14] implement eventfd copying(from fd\n\tin qemu process to fd in vhost process) in vhost-net-cdev.c",
        "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": "Signed-off-by: Huawei Xie <huawei.xie@intel.com>\n---\n lib/librte_vhost/vhost_cuse/vhost-net-cdev.c | 85 ++++++++++++++++++++++++----\n lib/librte_vhost/virtio-net.c                | 57 +------------------\n 2 files changed, 77 insertions(+), 65 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\nindex 2bb07af..802c7dc 100644\n--- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\n+++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c\n@@ -38,6 +38,8 @@\n #include <stdint.h>\n #include <string.h>\n #include <unistd.h>\n+#include <sys/eventfd.h>\n+#include <sys/ioctl.h>\n \n #include <rte_ethdev.h>\n #include <rte_log.h>\n@@ -45,6 +47,7 @@\n #include <rte_virtio_net.h>\n \n #include \"vhost-net.h\"\n+#include \"eventfd_link/eventfd_link.h\"\n \n #define FUSE_OPT_DUMMY \"\\0\\0\"\n #define FUSE_OPT_FORE  \"-f\\0\\0\"\n@@ -54,6 +57,7 @@ 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+static const char eventfd_cdev[] = \"/dev/eventfd-link\";\n \n static struct fuse_session *session;\n static struct vhost_net_device_ops const *ops;\n@@ -173,6 +177,47 @@ vhost_net_release(fuse_req_t req, struct fuse_file_info *fi)\n } while (0)\n \n /*\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(int target_fd, int target_pid)\n+{\n+\tint eventfd_link, ret;\n+\tstruct eventfd_copy eventfd_copy;\n+\tint fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n+\n+\tif (fd == -1)\n+\t\treturn -1;\n+\n+\t/* Open the character device to the kernel module. */\n+\t/* TODO: check this earlier rather than fail until VM boots! */\n+\teventfd_link = open(eventfd_cdev, O_RDWR);\n+\tif (eventfd_link < 0) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"eventfd_link module is not loaded\\n\");\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\teventfd_copy.source_fd = fd;\n+\teventfd_copy.target_fd = target_fd;\n+\teventfd_copy.target_pid = target_pid;\n+\t/* Call the IOCTL to copy the eventfd. */\n+\tret = ioctl(eventfd_link, EVENTFD_COPY, &eventfd_copy);\n+\tclose(eventfd_link);\n+\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"EVENTFD_COPY ioctl failed\\n\");\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\treturn fd;\n+}\n+\n+/*\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@@ -284,17 +329,37 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,\n \t\tbreak;\n \n \tcase VHOST_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,\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\tif (cmd == VHOST_SET_VRING_KICK)\n+\t\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_KICK\\n\",\n+\t\t\tctx.fh);\n+\t\telse\n+\t\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\t\"(%\"PRIu64\") IOCTL: VHOST_SET_VRING_CALL\\n\",\n+\t\t\tctx.fh);\n+\t\tif (!in_buf)\n+\t\t\tVHOST_IOCTL_RETRY(sizeof(struct vhost_vring_file), 0);\n+\t\telse {\n+\t\t\tint fd;\n+\t\t\tfile = *(const struct vhost_vring_file *)in_buf;\n+\t\t\tLOG_DEBUG(VHOST_CONFIG,\n+\t\t\t\t\"idx:%d fd:%d\\n\", file.index, file.fd);\n+\t\t\tfd = eventfd_copy(file.fd, ctx.pid);\n+\t\t\tif (fd < 0) {\n+\t\t\t\tfuse_reply_ioctl(req, -1, NULL, 0);\n+\t\t\t\tresult = -1;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\tfile.fd = fd;\n+\t\t\tif (cmd == VHOST_SET_VRING_KICK) {\n+\t\t\t\tresult = ops->set_vring_kick(ctx, &file);\n+\t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n+\t\t\t} else {\n+\t\t\t\tresult = ops->set_vring_call(ctx, &file);\n+\t\t\t\tfuse_reply_ioctl(req, result, NULL, 0);\n+\t\t\t}\n+\t\t}\n \t\tbreak;\n \n \tdefault:\ndiff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c\nindex 6bc9d51..da9e3a6 100644\n--- a/lib/librte_vhost/virtio-net.c\n+++ b/lib/librte_vhost/virtio-net.c\n@@ -38,8 +38,6 @@\n #include <stddef.h>\n #include <stdint.h>\n #include <stdlib.h>\n-#include <sys/eventfd.h>\n-#include <sys/ioctl.h>\n #include <sys/mman.h>\n #include <unistd.h>\n \n@@ -54,7 +52,6 @@\n #include <rte_virtio_net.h>\n \n #include \"vhost-net.h\"\n-#include \"eventfd_link/eventfd_link.h\"\n \n /*\n  * Device linked list structure for configuration.\n@@ -64,8 +61,6 @@ struct virtio_net_config_ll {\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/from data core. */\n static struct virtio_net_device_ops const *notify_ops;\n /* root address of the linked list of managed virtio devices */\n@@ -904,37 +899,6 @@ get_vring_base(struct vhost_device_ctx ctx, uint32_t index,\n \treturn 0;\n }\n \n-/*\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-{\n-\tint eventfd_link, ret;\n-\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,\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-\t/* Call the IOCTL to copy the eventfd. */\n-\tret = ioctl(eventfd_link, EVENTFD_COPY, eventfd_copy);\n-\tclose(eventfd_link);\n-\n-\tif (ret < 0) {\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-\treturn 0;\n-}\n \n /*\n  * Called from CUSE IOCTL: VHOST_SET_VRING_CALL\n@@ -945,7 +909,6 @@ static int\n set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n {\n \tstruct virtio_net *dev;\n-\tstruct eventfd_copy\teventfd_kick;\n \tstruct vhost_virtqueue *vq;\n \n \tdev = get_device(ctx);\n@@ -958,14 +921,7 @@ set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \tif (vq->kickfd)\n \t\tclose((int)vq->kickfd);\n \n-\t/* Populate the eventfd_copy structure and call eventfd_copy. */\n-\tvq->kickfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n-\teventfd_kick.source_fd = vq->kickfd;\n-\teventfd_kick.target_fd = file->fd;\n-\teventfd_kick.target_pid = ctx.pid;\n-\n-\tif (eventfd_copy(dev, &eventfd_kick))\n-\t\treturn -1;\n+\tvq->kickfd = file->fd;\n \n \treturn 0;\n }\n@@ -979,7 +935,6 @@ static int\n set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n {\n \tstruct virtio_net *dev;\n-\tstruct eventfd_copy eventfd_call;\n \tstruct vhost_virtqueue *vq;\n \n \tdev = get_device(ctx);\n@@ -991,15 +946,7 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)\n \n \tif (vq->callfd)\n \t\tclose((int)vq->callfd);\n-\n-\t/* Populate the eventfd_copy structure and call eventfd_copy. */\n-\tvq->callfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);\n-\teventfd_call.source_fd = vq->callfd;\n-\teventfd_call.target_fd = file->fd;\n-\teventfd_call.target_pid = ctx.pid;\n-\n-\tif (eventfd_copy(dev, &eventfd_call))\n-\t\treturn -1;\n+\tvq->callfd = file->fd;\n \n \treturn 0;\n }\n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "v2",
        "05/14"
    ]
}