Show a patch.

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

{
    "id": 42276,
    "url": "http://patches.dpdk.org/api/patches/42276/",
    "web_url": "http://patches.dpdk.org/patch/42276/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<20180704215438.5579-10-maxime.coquelin@redhat.com>",
    "date": "2018-07-04T21:54:32",
    "name": "[v7,09/15] vhost: add shadow used ring support for packed rings",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "fe57cbb7e40bc05a0f11eb93e76f0527c6f26d16",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/patch/42276/mbox/",
    "series": [
        {
            "id": 404,
            "url": "http://patches.dpdk.org/api/series/404/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=404",
            "date": "2018-07-04T21:54:23",
            "name": "Vhost: add support to packed ring layout",
            "version": 7,
            "mbox": "http://patches.dpdk.org/series/404/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42276/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42276/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "In-Reply-To": "<20180704215438.5579-1-maxime.coquelin@redhat.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 592441BF6A;\n\tWed,  4 Jul 2018 23:55:07 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id CFF561BF68\n\tfor <dev@dpdk.org>; Wed,  4 Jul 2018 23:55:05 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6])\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 6EED8C31E;\n\tWed,  4 Jul 2018 21:55:05 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-34.ams2.redhat.com\n\t[10.36.112.34])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 0E1DF2156880;\n\tWed,  4 Jul 2018 21:55:01 +0000 (UTC)"
        ],
        "References": "<20180704215438.5579-1-maxime.coquelin@redhat.com>",
        "Delivered-To": "patchwork@dpdk.org",
        "X-BeenThere": "dev@dpdk.org",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.6",
        "Message-Id": "<20180704215438.5579-10-maxime.coquelin@redhat.com>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Precedence": "list",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.1]); Wed, 04 Jul 2018 21:55:05 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.1]); \n\tWed, 04 Jul 2018 21:55:05 +0000 (UTC) for IP:'10.11.54.6'\n\tDOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "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>",
        "To": "tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com,\n\tdev@dpdk.org",
        "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>",
        "Date": "Wed,  4 Jul 2018 23:54:32 +0200",
        "Cc": "mst@redhat.com, jasowang@redhat.com, wexu@redhat.com,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v7 09/15] vhost: add shadow used ring support for\n\tpacked rings"
    },
    "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 70657b384..b5c649281 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 09f69d0f7..993f10ef9 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 94890363b..4ad7c3e55 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 7db3877d4..da5a13aad 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_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": [
        "v7",
        "09/15"
    ]
}