Show a patch.

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

{
    "id": 42270,
    "url": "http://patches.dpdk.org/api/patches/42270/",
    "web_url": "http://patches.dpdk.org/patch/42270/",
    "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-4-maxime.coquelin@redhat.com>",
    "date": "2018-07-04T21:54:26",
    "name": "[v7,03/15] vhost: vring address setup for packed queues",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "babf4b7b9739b3e37fff93418455ddb0dc52d67a",
    "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/42270/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/42270/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42270/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 6561C1B8BE;\n\tWed,  4 Jul 2018 23:54:52 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 5CCF01B6A1\n\tfor <dev@dpdk.org>; Wed,  4 Jul 2018 23:54:51 +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 065FE401CB89;\n\tWed,  4 Jul 2018 21:54:51 +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 C4E082156880;\n\tWed,  4 Jul 2018 21:54:48 +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-4-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.5]); Wed, 04 Jul 2018 21:54:51 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.5]); \n\tWed, 04 Jul 2018 21:54:51 +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:26 +0200",
        "Cc": "mst@redhat.com, jasowang@redhat.com, wexu@redhat.com,\n\tYuanhan Liu <yuanhan.liu@linux.intel.com>,\n\tJens Freimann <jfreiman@redhat.com>,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v7 03/15] vhost: vring address setup for packed\n\tqueues"
    },
    "content": "From: Yuanhan Liu <yuanhan.liu@linux.intel.com>\n\nAdd code to set up packed queues when enabled.\n\nSigned-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>\nSigned-off-by: Jens Freimann <jfreiman@redhat.com>\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/vhost.c      | 43 ++++++++++++++++++++++++++++++++++++++-----\n lib/librte_vhost/vhost.h      |  7 ++++++-\n lib/librte_vhost/vhost_user.c | 39 +++++++++++++++++++++++++++++++++++----\n 3 files changed, 79 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex 13ce864db..70657b384 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -115,14 +115,11 @@ free_device(struct virtio_net *dev)\n \trte_free(dev);\n }\n \n-int\n-vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+static int\n+vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)\n {\n \tuint64_t req_size, size;\n \n-\tif (!(dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))\n-\t\tgoto out;\n-\n \treq_size = sizeof(struct vring_desc) * vq->size;\n \tsize = req_size;\n \tvq->desc = (struct vring_desc *)(uintptr_t)vhost_iova_to_vva(dev, vq,\n@@ -153,6 +150,40 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \tif (!vq->used || size != req_size)\n \t\treturn -1;\n \n+\treturn 0;\n+}\n+\n+static int\n+vring_translate_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+{\n+\tuint64_t req_size, size;\n+\n+\treq_size = sizeof(struct vring_desc_packed) * vq->size;\n+\tsize = req_size;\n+\tvq->desc_packed =\n+\t\t(struct vring_desc_packed *)(uintptr_t)vhost_iova_to_vva(dev,\n+\t\t\t\t\tvq, vq->ring_addrs.desc_user_addr,\n+\t\t\t\t\t&size, VHOST_ACCESS_RW);\n+\tif (!vq->desc_packed || size != req_size)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+int\n+vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+{\n+\n+\tif (!(dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))\n+\t\tgoto out;\n+\n+\tif (vq_is_packed(dev)) {\n+\t\tif (vring_translate_packed(dev, vq) < 0)\n+\t\t\treturn -1;\n+\t} else {\n+\t\tif (vring_translate_split(dev, vq) < 0)\n+\t\t\treturn -1;\n+\t}\n out:\n \tvq->access_ok = 1;\n \n@@ -234,6 +265,8 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)\n \tdev->virtqueue[vring_idx] = vq;\n \tinit_vring_queue(dev, vring_idx);\n \trte_spinlock_init(&vq->access_lock);\n+\tvq->avail_wrap_counter = 1;\n+\tvq->used_wrap_counter = 1;\n \n \tdev->nr_vring += 1;\n \ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex 7124af001..09f69d0f7 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -84,7 +84,10 @@ struct log_cache_entry {\n  * Structure contains variables relevant to RX/TX virtqueues.\n  */\n struct vhost_virtqueue {\n-\tstruct vring_desc\t*desc;\n+\tunion {\n+\t\tstruct vring_desc\t*desc;\n+\t\tstruct vring_desc_packed   *desc_packed;\n+\t};\n \tstruct vring_avail\t*avail;\n \tstruct vring_used\t*used;\n \tuint32_t\t\tsize;\n@@ -122,6 +125,8 @@ struct vhost_virtqueue {\n \n \tstruct batch_copy_elem\t*batch_copy_elems;\n \tuint16_t\t\tbatch_copy_nb_elems;\n+\tbool\t\t\tused_wrap_counter;\n+\tbool\t\t\tavail_wrap_counter;\n \n \tstruct log_cache_entry log_cache[VHOST_LOG_CACHE_NR];\n \tuint16_t log_cache_nb_elem;\ndiff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex bea6a0428..94890363b 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -467,6 +467,27 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)\n \tstruct vhost_vring_addr *addr = &vq->ring_addrs;\n \tuint64_t len;\n \n+\tif (vq_is_packed(dev)) {\n+\t\tlen = sizeof(struct vring_desc_packed) * vq->size;\n+\t\tvq->desc_packed = (struct vring_desc_packed *) ring_addr_to_vva\n+\t\t\t(dev, vq, addr->desc_user_addr, &len);\n+\t\tvq->log_guest_addr = 0;\n+\t\tif (vq->desc_packed == NULL ||\n+\t\t\t\tlen != sizeof(struct vring_desc_packed) *\n+\t\t\t\tvq->size) {\n+\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n+\t\t\t\t\"(%d) failed to map desc_packed ring.\\n\",\n+\t\t\t\tdev->vid);\n+\t\t\treturn dev;\n+\t\t}\n+\n+\t\tdev = numa_realloc(dev, vq_index);\n+\t\tvq = dev->virtqueue[vq_index];\n+\t\taddr = &vq->ring_addrs;\n+\n+\t\treturn dev;\n+\t}\n+\n \t/* The addresses are converted from QEMU virtual to Vhost virtual. */\n \tif (vq->desc && vq->avail && vq->used)\n \t\treturn dev;\n@@ -875,10 +896,20 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *pmsg)\n \treturn -1;\n }\n \n-static int\n-vq_is_ready(struct vhost_virtqueue *vq)\n+static bool\n+vq_is_ready(struct virtio_net *dev, struct vhost_virtqueue *vq)\n {\n-\treturn vq && vq->desc && vq->avail && vq->used &&\n+\tbool rings_ok;\n+\n+\tif (!vq)\n+\t\treturn false;\n+\n+\tif (vq_is_packed(dev))\n+\t\trings_ok = !!vq->desc_packed;\n+\telse\n+\t\trings_ok = vq->desc && vq->avail && vq->used;\n+\n+\treturn rings_ok &&\n \t       vq->kickfd != VIRTIO_UNINITIALIZED_EVENTFD &&\n \t       vq->callfd != VIRTIO_UNINITIALIZED_EVENTFD;\n }\n@@ -895,7 +926,7 @@ virtio_is_ready(struct virtio_net *dev)\n \tfor (i = 0; i < dev->nr_vring; i++) {\n \t\tvq = dev->virtqueue[i];\n \n-\t\tif (!vq_is_ready(vq))\n+\t\tif (!vq_is_ready(dev, vq))\n \t\t\treturn 0;\n \t}\n \n",
    "prefixes": [
        "v7",
        "03/15"
    ]
}