get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42075,
    "url": "http://patches.dpdk.org/api/patches/42075/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180702081629.29258-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": "<20180702081629.29258-10-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180702081629.29258-10-maxime.coquelin@redhat.com",
    "date": "2018-07-02T08:16:23",
    "name": "[v6,09/15] vhost: add shadow used ring support for packed rings",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d89d6001c1a77740649d8c5b904e3a2f2f5253cf",
    "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/20180702081629.29258-10-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 348,
            "url": "http://patches.dpdk.org/api/series/348/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=348",
            "date": "2018-07-02T08:16:14",
            "name": "Vhost: add support to packed ring layout",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/348/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42075/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42075/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 6E137683E;\n\tMon,  2 Jul 2018 10:17:13 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 9D947683E\n\tfor <dev@dpdk.org>; Mon,  2 Jul 2018 10:17:11 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5])\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 47C58401EF02;\n\tMon,  2 Jul 2018 08:17:11 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-41.ams2.redhat.com\n\t[10.36.112.41])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 838491C589;\n\tMon,  2 Jul 2018 08:17:09 +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": "Mon,  2 Jul 2018 10:16:23 +0200",
        "Message-Id": "<20180702081629.29258-10-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20180702081629.29258-1-maxime.coquelin@redhat.com>",
        "References": "<20180702081629.29258-1-maxime.coquelin@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.11.54.5",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.5]); Mon, 02 Jul 2018 08:17:11 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.5]); \n\tMon, 02 Jul 2018 08:17:11 +0000 (UTC) for IP:'10.11.54.5'\n\tDOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "Subject": "[dpdk-dev] [PATCH v6 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 | 72 +++++++++++++++++++++++++++++++++++++++++--\n 4 files changed, 134 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex 05d2bb182..8538302c9 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -94,9 +94,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@@ -111,7 +114,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 35beff699..a7320469a 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@@ -552,7 +561,7 @@ void reset_device(struct virtio_net *dev);\n void vhost_destroy_device(int);\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 ae03ec29b..b2b57de57 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -244,7 +244,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@@ -293,13 +293,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@@ -326,7 +339,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@@ -361,13 +375,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@@ -1067,8 +1094,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 35f8cf90a..f0e2e6a1f 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -20,6 +20,7 @@\n \n #include \"iotlb.h\"\n #include \"vhost.h\"\n+#include \"virtio-packed.h\"\n \n #define MAX_PKT_BURST 32\n \n@@ -82,7 +83,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 +127,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_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].index = 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_desc_packed),\n+\t\t\t\t\tsizeof(struct vring_desc_packed));\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_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": [
        "v6",
        "09/15"
    ]
}