get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 15220,
    "url": "https://patches.dpdk.org/api/patches/15220/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1471510123-4984-5-git-send-email-yuanhan.liu@linux.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": "<1471510123-4984-5-git-send-email-yuanhan.liu@linux.intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1471510123-4984-5-git-send-email-yuanhan.liu@linux.intel.com",
    "date": "2016-08-18T08:48:40",
    "name": "[dpdk-dev,4/7] vhost: fold common message handlers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "ca1e7fcfbbbc8f5c8cca86864fc4e92c5cda82ab",
    "submitter": {
        "id": 307,
        "url": "https://patches.dpdk.org/api/people/307/?format=api",
        "name": "Yuanhan Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "delegate": {
        "id": 355,
        "url": "https://patches.dpdk.org/api/users/355/?format=api",
        "username": "yliu",
        "first_name": "Yuanhan",
        "last_name": "Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1471510123-4984-5-git-send-email-yuanhan.liu@linux.intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/15220/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/15220/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 5500F5A5A;\n\tThu, 18 Aug 2016 10:40:23 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 634705A35\n\tfor <dev@dpdk.org>; Thu, 18 Aug 2016 10:40:19 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP; 18 Aug 2016 01:39:54 -0700",
            "from yliu-dev.sh.intel.com ([10.239.67.162])\n\tby fmsmga002.fm.intel.com with ESMTP; 18 Aug 2016 01:39:53 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.28,538,1464678000\"; d=\"scan'208\";\n\ta=\"1043336169\"",
        "From": "Yuanhan Liu <yuanhan.liu@linux.intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Yuanhan Liu <yuanhan.liu@linux.intel.com>",
        "Date": "Thu, 18 Aug 2016 16:48:40 +0800",
        "Message-Id": "<1471510123-4984-5-git-send-email-yuanhan.liu@linux.intel.com>",
        "X-Mailer": "git-send-email 1.9.0",
        "In-Reply-To": "<1471510123-4984-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "References": "<1471510123-4984-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "Subject": "[dpdk-dev] [PATCH 4/7] vhost: fold common message handlers",
        "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": "Due to history reason (that we have 2 vhost implementations), some\nmessages are handled in two calls: vhost specific implementation\nhandles it first and then invoke the common one to do another handling.\n\nWe have one implementation only now, we could write one method for\neach message. Here fold those common handles to corresponding vhost\nuser handler.\n\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\n---\n lib/librte_vhost/vhost_user.c | 115 ++++++++++++------------------------------\n 1 file changed, 31 insertions(+), 84 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex c4714b7..ada0a63 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -426,87 +426,6 @@ vhost_set_vring_base(int vid, struct vhost_vring_state *state)\n \treturn 0;\n }\n \n-/*\n- * We send the virtio device our available ring last used index.\n- */\n-static int\n-vhost_get_vring_base(int vid, uint32_t index,\n-\tstruct vhost_vring_state *state)\n-{\n-\tstruct virtio_net *dev;\n-\n-\tdev = get_device(vid);\n-\tif (dev == NULL)\n-\t\treturn -1;\n-\n-\tstate->index = index;\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- * The virtio device sends an eventfd to interrupt the guest. This fd gets\n- * copied into our process space.\n- */\n-static int\n-vhost_set_vring_call(int vid, struct vhost_vring_file *file)\n-{\n-\tstruct virtio_net *dev;\n-\tstruct vhost_virtqueue *vq;\n-\tuint32_t cur_qp_idx = file->index / VIRTIO_QNUM;\n-\n-\tdev = get_device(vid);\n-\tif (dev == NULL)\n-\t\treturn -1;\n-\n-\t/*\n-\t * FIXME: VHOST_SET_VRING_CALL is the first per-vring message\n-\t * we get, so we do vring queue pair allocation here.\n-\t */\n-\tif (cur_qp_idx + 1 > dev->virt_qp_nb) {\n-\t\tif (alloc_vring_queue_pair(dev, cur_qp_idx) < 0)\n-\t\t\treturn -1;\n-\t}\n-\n-\t/* file->index refers to the queue index. The txq is 1, rxq is 0. */\n-\tvq = dev->virtqueue[file->index];\n-\tassert(vq != NULL);\n-\n-\tif (vq->callfd >= 0)\n-\t\tclose(vq->callfd);\n-\n-\tvq->callfd = file->fd;\n-\n-\treturn 0;\n-}\n-\n-/*\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-vhost_set_vring_kick(int vid, struct vhost_vring_file *file)\n-{\n-\tstruct virtio_net *dev;\n-\tstruct vhost_virtqueue *vq;\n-\n-\tdev = get_device(vid);\n-\tif (dev == NULL)\n-\t\treturn -1;\n-\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 >= 0)\n-\t\tclose(vq->kickfd);\n-\n-\tvq->kickfd = file->fd;\n-\n-\treturn 0;\n-}\n-\n static int\n user_set_mem_table(int vid, struct VhostUserMsg *pmsg)\n {\n@@ -671,6 +590,12 @@ static void\n user_set_vring_call(int vid, struct VhostUserMsg *pmsg)\n {\n \tstruct vhost_vring_file file;\n+\tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n+\tuint32_t cur_qp_idx;\n+\n+\tif (!dev)\n+\t\treturn;\n \n \tfile.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;\n \tif (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)\n@@ -679,7 +604,24 @@ user_set_vring_call(int vid, struct VhostUserMsg *pmsg)\n \t\tfile.fd = pmsg->fds[0];\n \tRTE_LOG(INFO, VHOST_CONFIG,\n \t\t\"vring call idx:%d file:%d\\n\", file.index, file.fd);\n-\tvhost_set_vring_call(vid, &file);\n+\n+\t/*\n+\t * FIXME: VHOST_SET_VRING_CALL is the first per-vring message\n+\t * we get, so we do vring queue pair allocation here.\n+\t */\n+\tcur_qp_idx = file.index / VIRTIO_QNUM;\n+\tif (cur_qp_idx + 1 > dev->virt_qp_nb) {\n+\t\tif (alloc_vring_queue_pair(dev, cur_qp_idx) < 0)\n+\t\t\treturn;\n+\t}\n+\n+\tvq = dev->virtqueue[file.index];\n+\tassert(vq != NULL);\n+\n+\tif (vq->callfd >= 0)\n+\t\tclose(vq->callfd);\n+\n+\tvq->callfd = file.fd;\n }\n \n /*\n@@ -691,6 +633,7 @@ user_set_vring_kick(int vid, struct VhostUserMsg *pmsg)\n {\n \tstruct vhost_vring_file file;\n \tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n \n \tif (!dev)\n \t\treturn;\n@@ -702,7 +645,11 @@ user_set_vring_kick(int vid, struct VhostUserMsg *pmsg)\n \t\tfile.fd = pmsg->fds[0];\n \tRTE_LOG(INFO, VHOST_CONFIG,\n \t\t\"vring kick idx:%d file:%d\\n\", file.index, file.fd);\n-\tvhost_set_vring_kick(vid, &file);\n+\n+\tvq = dev->virtqueue[file.index];\n+\tif (vq->kickfd >= 0)\n+\t\tclose(vq->kickfd);\n+\tvq->kickfd = file.fd;\n \n \tif (virtio_is_ready(dev) && !(dev->flags & VIRTIO_DEV_RUNNING)) {\n \t\tif (notify_ops->new_device(vid) == 0)\n@@ -727,7 +674,7 @@ user_get_vring_base(int vid, struct vhost_vring_state *state)\n \t}\n \n \t/* Here we are safe to get the last used index */\n-\tvhost_get_vring_base(vid, state->index, state);\n+\tstate->num = dev->virtqueue[state->index]->last_used_idx;\n \n \tRTE_LOG(INFO, VHOST_CONFIG,\n \t\t\"vring base idx:%d file:%d\\n\", state->index, state->num);\n",
    "prefixes": [
        "dpdk-dev",
        "4/7"
    ]
}