get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 21044,
    "url": "http://patches.dpdk.org/api/patches/21044/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1488435367-22170-1-git-send-email-yuanhan.liu@linux.intel.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<1488435367-22170-1-git-send-email-yuanhan.liu@linux.intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1488435367-22170-1-git-send-email-yuanhan.liu@linux.intel.com",
    "date": "2017-03-02T06:16:07",
    "name": "[dpdk-dev] vhost: remove a hack on queue allocation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "9447efd64f168b64730f5d4c0e5c0e6e0e4f78d2",
    "submitter": {
        "id": 307,
        "url": "http://patches.dpdk.org/api/people/307/?format=api",
        "name": "Yuanhan Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "delegate": {
        "id": 355,
        "url": "http://patches.dpdk.org/api/users/355/?format=api",
        "username": "yliu",
        "first_name": "Yuanhan",
        "last_name": "Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1488435367-22170-1-git-send-email-yuanhan.liu@linux.intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/21044/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/21044/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 8AFA52B94;\n\tThu,  2 Mar 2017 07:17:20 +0100 (CET)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id 1B72D2A5E\n\tfor <dev@dpdk.org>; Thu,  2 Mar 2017 07:17:17 +0100 (CET)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga104.jf.intel.com with ESMTP; 01 Mar 2017 22:17:16 -0800",
            "from yliu-dev.sh.intel.com ([10.239.67.162])\n\tby FMSMGA003.fm.intel.com with ESMTP; 01 Mar 2017 22:17:15 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.35,228,1484035200\"; d=\"scan'208\";a=\"830018965\"",
        "From": "Yuanhan Liu <yuanhan.liu@linux.intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>,\n\tYuanhan Liu <yuanhan.liu@linux.intel.com>",
        "Date": "Thu,  2 Mar 2017 14:16:07 +0800",
        "Message-Id": "<1488435367-22170-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "X-Mailer": "git-send-email 1.9.0",
        "In-Reply-To": "<1488434385-7605-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "References": "<1488434385-7605-1-git-send-email-yuanhan.liu@linux.intel.com>",
        "Subject": "[dpdk-dev] [PATCH] vhost: remove a hack on queue allocation",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <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": "We used to allocate queues based on the index from SET_VRING_CALL\nrequest: if corresponding queue hasn't been allocated, allocate it.\n\nThough it's pratically right (it's the first per-vring request we\nwill get from QEMU for vhost-user negotiation), but it's not technically\nright: it's not documented in the vhost-user spec that it will always\nbe the first per-vring request. For example, SET_VRING_ADDR could also\nbe the first per-vring request.\n\nThus, we should not depend the SET_VRING_CALL on queue allocation.\nInstead, we could catch all the per-vring messages at the entrance of\nrequest handler, and allocate one if it hasn't been allocated before.\n\nBy that, we could remove a hack.\n\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\n---\n\nv2: add missing break\n---\n lib/librte_vhost/vhost_user.c | 61 ++++++++++++++++++++++++++++++++++---------\n 1 file changed, 48 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex cb2156a..8433a54 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -635,7 +635,6 @@ vhost_user_set_vring_call(struct virtio_net *dev, struct VhostUserMsg *pmsg)\n {\n \tstruct vhost_vring_file file;\n \tstruct vhost_virtqueue *vq;\n-\tuint32_t cur_qp_idx;\n \n \tfile.index = pmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK;\n \tif (pmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)\n@@ -645,19 +644,7 @@ vhost_user_set_vring_call(struct virtio_net *dev, struct VhostUserMsg *pmsg)\n \tRTE_LOG(INFO, VHOST_CONFIG,\n \t\t\"vring call idx:%d file:%d\\n\", file.index, file.fd);\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@@ -914,6 +901,46 @@ send_vhost_message(int sockfd, struct VhostUserMsg *msg)\n \treturn ret;\n }\n \n+/*\n+ * Allocate a queue pair if it hasn't been allocated yet\n+ */\n+static int\n+vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev, VhostUserMsg *msg)\n+{\n+\tuint16_t vring_idx;\n+\tuint16_t qp_idx;\n+\n+\tswitch (msg->request) {\n+\tcase VHOST_USER_SET_VRING_KICK:\n+\tcase VHOST_USER_SET_VRING_CALL:\n+\tcase VHOST_USER_SET_VRING_ERR:\n+\t\tvring_idx = msg->payload.u64 & VHOST_USER_VRING_IDX_MASK;\n+\t\tbreak;\n+\tcase VHOST_USER_SET_VRING_NUM:\n+\tcase VHOST_USER_SET_VRING_BASE:\n+\tcase VHOST_USER_SET_VRING_ENABLE:\n+\t\tvring_idx = msg->payload.state.index;\n+\t\tbreak;\n+\tcase VHOST_USER_SET_VRING_ADDR:\n+\t\tvring_idx = msg->payload.addr.index;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn 0;\n+\t}\n+\n+\tqp_idx = vring_idx / VIRTIO_QNUM;\n+\tif (qp_idx >= VHOST_MAX_QUEUE_PAIRS) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"invalid vring index: %u\\n\", vring_idx);\n+\t\treturn -1;\n+\t}\n+\n+\tif (dev->virtqueue[qp_idx])\n+\t\treturn 0;\n+\n+\treturn alloc_vring_queue_pair(dev, qp_idx);\n+}\n+\n int\n vhost_user_msg_handler(int vid, int fd)\n {\n@@ -943,6 +970,14 @@ vhost_user_msg_handler(int vid, int fd)\n \tret = 0;\n \tRTE_LOG(INFO, VHOST_CONFIG, \"read message %s\\n\",\n \t\tvhost_message_str[msg.request]);\n+\n+\tret = vhost_user_check_and_alloc_queue_pair(dev, &msg);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\"failed to alloc queue\\n\");\n+\t\treturn -1;\n+\t}\n+\n \tswitch (msg.request) {\n \tcase VHOST_USER_GET_FEATURES:\n \t\tmsg.payload.u64 = vhost_user_get_features();\n",
    "prefixes": [
        "dpdk-dev"
    ]
}