get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42471,
    "url": "http://patches.dpdk.org/api/patches/42471/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180706070722.2043-10-maxime.coquelin@redhat.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": "<20180706070722.2043-10-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180706070722.2043-10-maxime.coquelin@redhat.com",
    "date": "2018-07-06T07:07:16",
    "name": "[v9,09/15] vhost: add shadow used ring support for packed rings",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "08ec6483902acebce231f751ab954d153e4c53c8",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180706070722.2043-10-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 450,
            "url": "http://patches.dpdk.org/api/series/450/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=450",
            "date": "2018-07-06T07:07:07",
            "name": "Vhost: add support to packed ring layout",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/450/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42471/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42471/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 2F2AE1BFD2;\n\tFri,  6 Jul 2018 09:07:46 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 0BEDA1BFD2\n\tfor <dev@dpdk.org>; Fri,  6 Jul 2018 09:07:45 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id ABDBAE9002;\n\tFri,  6 Jul 2018 07:07:44 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.36.112.10])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id E0EF42026D68;\n\tFri,  6 Jul 2018 07:07:42 +0000 (UTC)"
        ],
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com,\n\tdev@dpdk.org",
        "Cc": "mst@redhat.com, jasowang@redhat.com, wexu@redhat.com,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Fri,  6 Jul 2018 09:07:16 +0200",
        "Message-Id": "<20180706070722.2043-10-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20180706070722.2043-1-maxime.coquelin@redhat.com>",
        "References": "<20180706070722.2043-1-maxime.coquelin@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.4",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.1]); Fri, 06 Jul 2018 07:07:44 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.1]); \n\tFri, 06 Jul 2018 07:07:44 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "Subject": "[dpdk-dev] [PATCH v9 09/15] vhost: add shadow used ring support for\n\tpacked rings",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/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: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/vhost.c      |  9 ++++--\n lib/librte_vhost/vhost.h      | 13 ++++++--\n lib/librte_vhost/vhost_user.c | 64 ++++++++++++++++++++++++++++----------\n lib/librte_vhost/virtio_net.c | 71 +++++++++++++++++++++++++++++++++++++++++--\n 4 files changed, 133 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex 0bf2cc14a..534f30cf6 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -93,9 +93,12 @@ cleanup_device(struct virtio_net *dev, int destroy)\n }\n \n void\n-free_vq(struct vhost_virtqueue *vq)\n+free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq)\n {\n-\trte_free(vq->shadow_used_ring);\n+\tif (vq_is_packed(dev))\n+\t\trte_free(vq->shadow_used_packed);\n+\telse\n+\t\trte_free(vq->shadow_used_split);\n \trte_free(vq->batch_copy_elems);\n \trte_mempool_free(vq->iotlb_pool);\n \trte_free(vq);\n@@ -110,7 +113,7 @@ free_device(struct virtio_net *dev)\n \tuint32_t i;\n \n \tfor (i = 0; i < dev->nr_vring; i++)\n-\t\tfree_vq(dev->virtqueue[i]);\n+\t\tfree_vq(dev, dev->virtqueue[i]);\n \n \trte_free(dev);\n }\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex b486682c5..70f0eebcf 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -80,6 +80,12 @@ struct log_cache_entry {\n \tunsigned long val;\n };\n \n+struct vring_used_elem_packed {\n+\tuint16_t id;\n+\tuint32_t len;\n+\tuint32_t count;\n+};\n+\n /**\n  * Structure contains variables relevant to RX/TX virtqueues.\n  */\n@@ -119,7 +125,10 @@ struct vhost_virtqueue {\n \tstruct zcopy_mbuf\t*zmbufs;\n \tstruct zcopy_mbuf_list\tzmbuf_list;\n \n-\tstruct vring_used_elem  *shadow_used_ring;\n+\tunion {\n+\t\tstruct vring_used_elem  *shadow_used_split;\n+\t\tstruct vring_used_elem_packed *shadow_used_packed;\n+\t};\n \tuint16_t                shadow_used_idx;\n \tstruct vhost_vring_addr ring_addrs;\n \n@@ -587,7 +596,7 @@ void vhost_destroy_device(int);\n void vhost_destroy_device_notify(struct virtio_net *dev);\n \n void cleanup_vq(struct vhost_virtqueue *vq, int destroy);\n-void free_vq(struct vhost_virtqueue *vq);\n+void free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq);\n \n int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx);\n \ndiff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex dca43ff00..71d1fe0ac 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -233,7 +233,7 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features)\n \n \t\t\tdev->virtqueue[dev->nr_vring] = NULL;\n \t\t\tcleanup_vq(vq, 1);\n-\t\t\tfree_vq(vq);\n+\t\t\tfree_vq(dev, vq);\n \t\t}\n \t}\n \n@@ -282,13 +282,26 @@ vhost_user_set_vring_num(struct virtio_net *dev,\n \t\tTAILQ_INIT(&vq->zmbuf_list);\n \t}\n \n-\tvq->shadow_used_ring = rte_malloc(NULL,\n+\tif (vq_is_packed(dev)) {\n+\t\tvq->shadow_used_packed = rte_malloc(NULL,\n+\t\t\t\tvq->size *\n+\t\t\t\tsizeof(struct vring_used_elem_packed),\n+\t\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (!vq->shadow_used_packed) {\n+\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t} else {\n+\t\tvq->shadow_used_split = rte_malloc(NULL,\n \t\t\t\tvq->size * sizeof(struct vring_used_elem),\n \t\t\t\tRTE_CACHE_LINE_SIZE);\n-\tif (!vq->shadow_used_ring) {\n-\t\tRTE_LOG(ERR, VHOST_CONFIG,\n-\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n-\t\treturn -1;\n+\t\tif (!vq->shadow_used_split) {\n+\t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n+\t\t\treturn -1;\n+\t\t}\n \t}\n \n \tvq->batch_copy_elems = rte_malloc(NULL,\n@@ -315,7 +328,8 @@ numa_realloc(struct virtio_net *dev, int index)\n \tstruct virtio_net *old_dev;\n \tstruct vhost_virtqueue *old_vq, *vq;\n \tstruct zcopy_mbuf *new_zmbuf;\n-\tstruct vring_used_elem *new_shadow_used_ring;\n+\tstruct vring_used_elem *new_shadow_used_split;\n+\tstruct vring_used_elem_packed *new_shadow_used_packed;\n \tstruct batch_copy_elem *new_batch_copy_elems;\n \tint ret;\n \n@@ -350,13 +364,26 @@ numa_realloc(struct virtio_net *dev, int index)\n \t\t\tvq->zmbufs = new_zmbuf;\n \t\t}\n \n-\t\tnew_shadow_used_ring = rte_malloc_socket(NULL,\n-\t\t\tvq->size * sizeof(struct vring_used_elem),\n-\t\t\tRTE_CACHE_LINE_SIZE,\n-\t\t\tnewnode);\n-\t\tif (new_shadow_used_ring) {\n-\t\t\trte_free(vq->shadow_used_ring);\n-\t\t\tvq->shadow_used_ring = new_shadow_used_ring;\n+\t\tif (vq_is_packed(dev)) {\n+\t\t\tnew_shadow_used_packed = rte_malloc_socket(NULL,\n+\t\t\t\t\tvq->size *\n+\t\t\t\t\tsizeof(struct vring_used_elem_packed),\n+\t\t\t\t\tRTE_CACHE_LINE_SIZE,\n+\t\t\t\t\tnewnode);\n+\t\t\tif (new_shadow_used_packed) {\n+\t\t\t\trte_free(vq->shadow_used_packed);\n+\t\t\t\tvq->shadow_used_packed = new_shadow_used_packed;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tnew_shadow_used_split = rte_malloc_socket(NULL,\n+\t\t\t\t\tvq->size *\n+\t\t\t\t\tsizeof(struct vring_used_elem),\n+\t\t\t\t\tRTE_CACHE_LINE_SIZE,\n+\t\t\t\t\tnewnode);\n+\t\t\tif (new_shadow_used_split) {\n+\t\t\t\trte_free(vq->shadow_used_split);\n+\t\t\t\tvq->shadow_used_split = new_shadow_used_split;\n+\t\t\t}\n \t\t}\n \n \t\tnew_batch_copy_elems = rte_malloc_socket(NULL,\n@@ -1047,8 +1074,13 @@ vhost_user_get_vring_base(struct virtio_net *dev,\n \n \tif (dev->dequeue_zero_copy)\n \t\tfree_zmbufs(vq);\n-\trte_free(vq->shadow_used_ring);\n-\tvq->shadow_used_ring = NULL;\n+\tif (vq_is_packed(dev)) {\n+\t\trte_free(vq->shadow_used_packed);\n+\t\tvq->shadow_used_packed = NULL;\n+\t} else {\n+\t\trte_free(vq->shadow_used_split);\n+\t\tvq->shadow_used_split = NULL;\n+\t}\n \n \trte_free(vq->batch_copy_elems);\n \tvq->batch_copy_elems = NULL;\ndiff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex ae256e062..44b9daf4a 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -82,7 +82,7 @@ do_flush_shadow_used_ring_split(struct virtio_net *dev,\n \t\t\tuint16_t to, uint16_t from, uint16_t size)\n {\n \trte_memcpy(&vq->used->ring[to],\n-\t\t\t&vq->shadow_used_ring[from],\n+\t\t\t&vq->shadow_used_split[from],\n \t\t\tsize * sizeof(struct vring_used_elem));\n \tvhost_log_cache_used_vring(dev, vq,\n \t\t\toffsetof(struct vring_used, ring[to]),\n@@ -126,8 +126,73 @@ update_shadow_used_ring_split(struct vhost_virtqueue *vq,\n {\n \tuint16_t i = vq->shadow_used_idx++;\n \n-\tvq->shadow_used_ring[i].id  = desc_idx;\n-\tvq->shadow_used_ring[i].len = len;\n+\tvq->shadow_used_split[i].id  = desc_idx;\n+\tvq->shadow_used_split[i].len = len;\n+}\n+\n+static __rte_unused __rte_always_inline void\n+flush_shadow_used_ring_packed(struct virtio_net *dev,\n+\t\t\tstruct vhost_virtqueue *vq)\n+{\n+\tint i;\n+\tuint16_t used_idx = vq->last_used_idx;\n+\n+\t/* Split loop in two to save memory barriers */\n+\tfor (i = 0; i < vq->shadow_used_idx; i++) {\n+\t\tvq->desc_packed[used_idx].id = vq->shadow_used_packed[i].id;\n+\t\tvq->desc_packed[used_idx].len = vq->shadow_used_packed[i].len;\n+\n+\t\tused_idx += vq->shadow_used_packed[i].count;\n+\t\tif (used_idx >= vq->size)\n+\t\t\tused_idx -= vq->size;\n+\t}\n+\n+\trte_smp_wmb();\n+\n+\tfor (i = 0; i < vq->shadow_used_idx; i++) {\n+\t\tuint16_t flags;\n+\n+\t\tif (vq->shadow_used_packed[i].len)\n+\t\t\tflags = VRING_DESC_F_WRITE;\n+\t\telse\n+\t\t\tflags = 0;\n+\n+\t\tif (vq->used_wrap_counter) {\n+\t\t\tflags |= VRING_DESC_F_USED;\n+\t\t\tflags |= VRING_DESC_F_AVAIL;\n+\t\t} else {\n+\t\t\tflags &= ~VRING_DESC_F_USED;\n+\t\t\tflags &= ~VRING_DESC_F_AVAIL;\n+\t\t}\n+\n+\t\tvq->desc_packed[vq->last_used_idx].flags = flags;\n+\n+\t\tvhost_log_cache_used_vring(dev, vq,\n+\t\t\t\t\tvq->last_used_idx *\n+\t\t\t\t\tsizeof(struct vring_packed_desc),\n+\t\t\t\t\tsizeof(struct vring_packed_desc));\n+\n+\t\tvq->last_used_idx += vq->shadow_used_packed[i].count;\n+\t\tif (vq->last_used_idx >= vq->size) {\n+\t\t\tvq->used_wrap_counter ^= 1;\n+\t\t\tvq->last_used_idx -= vq->size;\n+\t\t}\n+\t}\n+\n+\trte_smp_wmb();\n+\tvq->shadow_used_idx = 0;\n+\tvhost_log_cache_sync(dev, vq);\n+}\n+\n+static __rte_unused __rte_always_inline void\n+update_shadow_used_ring_packed(struct vhost_virtqueue *vq,\n+\t\t\t uint16_t desc_idx, uint16_t len, uint16_t count)\n+{\n+\tuint16_t i = vq->shadow_used_idx++;\n+\n+\tvq->shadow_used_packed[i].id  = desc_idx;\n+\tvq->shadow_used_packed[i].len = len;\n+\tvq->shadow_used_packed[i].count = count;\n }\n \n static inline void\n",
    "prefixes": [
        "v9",
        "09/15"
    ]
}