Show a patch.

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

{
    "id": 42442,
    "url": "http://patches.dpdk.org/api/patches/42442/?format=api",
    "web_url": "http://patches.dpdk.org/patch/42442/",
    "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"
    },
    "msgid": "<20180705210741.17974-15-maxime.coquelin@redhat.com>",
    "date": "2018-07-05T21:07:40",
    "name": "[v8,14/15] vhost: add notification for packed ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d48211e4816163b0542f4a128ff4319b7175fa98",
    "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/patch/42442/mbox/",
    "series": [
        {
            "id": 443,
            "url": "http://patches.dpdk.org/api/series/443/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=443",
            "date": "2018-07-05T21:07:26",
            "name": "Vhost: add support to packed ring layout",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/443/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42442/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42442/checks/",
    "tags": {},
    "headers": {
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Date": "Thu,  5 Jul 2018 23:07:40 +0200",
        "X-Mailman-Version": "2.1.15",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Cc": "mst@redhat.com, jasowang@redhat.com, wexu@redhat.com,\n\tMaxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "tiwei.bie@intel.com, zhihong.wang@intel.com, jfreimann@redhat.com,\n\tdev@dpdk.org",
        "Errors-To": "dev-bounces@dpdk.org",
        "References": "<20180705210741.17974-1-maxime.coquelin@redhat.com>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-BeenThere": "dev@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6DC851BF9A;\n\tThu,  5 Jul 2018 23:08:15 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 83A9D1BF92\n\tfor <dev@dpdk.org>; Thu,  5 Jul 2018 23:08:13 +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 23D0C212D4;\n\tThu,  5 Jul 2018 21:08:13 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-37.ams2.redhat.com\n\t[10.36.112.37])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 6404B2156899;\n\tThu,  5 Jul 2018 21:08:11 +0000 (UTC)"
        ],
        "X-Original-To": "patchwork@dpdk.org",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.6",
        "Subject": "[dpdk-dev] [PATCH v8 14/15] vhost: add notification for packed ring",
        "In-Reply-To": "<20180705210741.17974-1-maxime.coquelin@redhat.com>",
        "Message-Id": "<20180705210741.17974-15-maxime.coquelin@redhat.com>",
        "Precedence": "list",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.2]); Thu, 05 Jul 2018 21:08:13 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.2]); \n\tThu, 05 Jul 2018 21:08:13 +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:''"
        ]
    },
    "content": "Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/vhost.c      | 71 +++++++++++++++++++++++++++++++++++------\n lib/librte_vhost/vhost.h      | 73 +++++++++++++++++++++++++++++++++++++++++--\n lib/librte_vhost/vhost_user.c | 24 ++++++++++++++\n lib/librte_vhost/virtio_net.c | 12 +++----\n 4 files changed, 162 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex b5c649281..eb32e91c7 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -163,13 +163,28 @@ vring_translate_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)\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+\tvq->desc_packed = (struct vring_desc_packed *)(uintptr_t)\n+\t\tvhost_iova_to_vva(dev, vq, vq->ring_addrs.desc_user_addr,\n+\t\t\t\t&size, VHOST_ACCESS_RW);\n \tif (!vq->desc_packed || size != req_size)\n \t\treturn -1;\n \n+\treq_size = sizeof(struct vring_packed_desc_event);\n+\tsize = req_size;\n+\tvq->driver_event = (struct vring_packed_desc_event *)(uintptr_t)\n+\t\tvhost_iova_to_vva(dev, vq, vq->ring_addrs.avail_user_addr,\n+\t\t\t\t&size, VHOST_ACCESS_RW);\n+\tif (!vq->driver_event || size != req_size)\n+\t\treturn -1;\n+\n+\treq_size = sizeof(struct vring_packed_desc_event);\n+\tsize = req_size;\n+\tvq->device_event = (struct vring_packed_desc_event *)(uintptr_t)\n+\t\tvhost_iova_to_vva(dev, vq, vq->ring_addrs.used_user_addr,\n+\t\t\t\t&size, VHOST_ACCESS_RW);\n+\tif (!vq->device_event || size != req_size)\n+\t\treturn -1;\n+\n \treturn 0;\n }\n \n@@ -270,6 +285,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)\n \trte_spinlock_init(&vq->access_lock);\n \tvq->avail_wrap_counter = 1;\n \tvq->used_wrap_counter = 1;\n+\tvq->signalled_used_valid = false;\n \n \tdev->nr_vring += 1;\n \n@@ -604,7 +620,11 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)\n \tif (!vq)\n \t\treturn -1;\n \n-\tvhost_vring_call(dev, vq);\n+\tif (vq_is_packed(dev))\n+\t\tvhost_vring_call_packed(dev, vq);\n+\telse\n+\t\tvhost_vring_call_split(dev, vq);\n+\n \treturn 0;\n }\n \n@@ -625,19 +645,52 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id)\n \treturn *(volatile uint16_t *)&vq->avail->idx - vq->last_used_idx;\n }\n \n+static inline void\n+vhost_enable_notify_split(struct vhost_virtqueue *vq, int enable)\n+{\n+\tif (enable)\n+\t\tvq->used->flags &= ~VRING_USED_F_NO_NOTIFY;\n+\telse\n+\t\tvq->used->flags |= VRING_USED_F_NO_NOTIFY;\n+}\n+\n+static inline void\n+vhost_enable_notify_packed(struct virtio_net *dev,\n+\t\tstruct vhost_virtqueue *vq, int enable)\n+{\n+\tuint16_t flags;\n+\n+\tif (!enable)\n+\t\tvq->device_event->flags = VRING_EVENT_F_DISABLE;\n+\n+\tflags = VRING_EVENT_F_ENABLE;\n+\tif (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) {\n+\t\tflags = VRING_EVENT_F_DESC;\n+\t\tvq->device_event->off_wrap = vq->last_avail_idx |\n+\t\t\tvq->avail_wrap_counter << 15;\n+\t}\n+\n+\trte_smp_wmb();\n+\n+\tvq->device_event->flags = flags;\n+}\n+\n int\n rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable)\n {\n \tstruct virtio_net *dev = get_device(vid);\n+\tstruct vhost_virtqueue *vq;\n \n \tif (!dev)\n \t\treturn -1;\n \n-\tif (enable)\n-\t\tdev->virtqueue[queue_id]->used->flags &=\n-\t\t\t~VRING_USED_F_NO_NOTIFY;\n+\tvq = dev->virtqueue[queue_id];\n+\n+\tif (vq_is_packed(dev))\n+\t\tvhost_enable_notify_packed(dev, vq, enable);\n \telse\n-\t\tdev->virtqueue[queue_id]->used->flags |= VRING_USED_F_NO_NOTIFY;\n+\t\tvhost_enable_notify_split(vq, enable);\n+\n \treturn 0;\n }\n \ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex a18c63cad..3daa6e7d0 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -95,14 +95,21 @@ struct vhost_virtqueue {\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+\tunion {\n+\t\tstruct vring_avail\t*avail;\n+\t\tstruct vring_packed_desc_event *driver_event;\n+\t};\n+\tunion {\n+\t\tstruct vring_used\t*used;\n+\t\tstruct vring_packed_desc_event *device_event;\n+\t};\n \tuint32_t\t\tsize;\n \n \tuint16_t\t\tlast_avail_idx;\n \tuint16_t\t\tlast_used_idx;\n \t/* Last used index we notify to front end. */\n \tuint16_t\t\tsignalled_used;\n+\tbool\t\t\tsignalled_used_valid;\n #define VIRTIO_INVALID_EVENTFD\t\t(-1)\n #define VIRTIO_UNINITIALIZED_EVENTFD\t(-2)\n \n@@ -225,6 +232,15 @@ struct vring_desc_packed {\n \tuint16_t id;\n \tuint16_t flags;\n };\n+\n+#define VRING_EVENT_F_ENABLE 0x0\n+#define VRING_EVENT_F_DISABLE 0x1\n+#define VRING_EVENT_F_DESC 0x2\n+\n+struct vring_packed_desc_event {\n+\tuint16_t off_wrap;\n+\tuint16_t flags;\n+};\n #endif\n \n /*\n@@ -648,7 +664,7 @@ vhost_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)\n }\n \n static __rte_always_inline void\n-vhost_vring_call(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)\n {\n \t/* Flush used->idx update before we read avail->flags. */\n \trte_smp_mb();\n@@ -675,4 +691,55 @@ vhost_vring_call(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \t}\n }\n \n+static __rte_always_inline void\n+vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)\n+{\n+\tuint16_t old, new, off, off_wrap;\n+\tbool signalled_used_valid, kick = false;\n+\n+\t/* Flush used desc update. */\n+\trte_smp_mb();\n+\n+\tif (!(dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX))) {\n+\t\tif (vq->driver_event->flags !=\n+\t\t\t\tVRING_EVENT_F_DISABLE)\n+\t\t\tkick = true;\n+\t\tgoto kick;\n+\t}\n+\n+\told = vq->signalled_used;\n+\tnew = vq->last_used_idx;\n+\tvq->signalled_used = new;\n+\tsignalled_used_valid = vq->signalled_used_valid;\n+\tvq->signalled_used_valid = true;\n+\n+\tif (vq->driver_event->flags != VRING_EVENT_F_DESC) {\n+\t\tif (vq->driver_event->flags != VRING_EVENT_F_DISABLE)\n+\t\t\tkick = true;\n+\t\tgoto kick;\n+\t}\n+\n+\tif (unlikely(!signalled_used_valid)) {\n+\t\tkick = true;\n+\t\tgoto kick;\n+\t}\n+\n+\trte_smp_rmb();\n+\n+\toff_wrap = vq->driver_event->off_wrap;\n+\toff = off_wrap & ~(1 << 15);\n+\n+\tif (new <= old)\n+\t\told -= vq->size;\n+\n+\tif (vq->used_wrap_counter != off_wrap >> 15)\n+\t\toff -= vq->size;\n+\n+\tif (vhost_need_event(off, new, old))\n+\t\tkick = true;\n+kick:\n+\tif (kick)\n+\t\teventfd_write(vq->callfd, (eventfd_t)1);\n+}\n+\n #endif /* _VHOST_NET_CDEV_H_ */\ndiff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex 4ad7c3e55..4fa8dbad3 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -512,6 +512,30 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)\n \t\tvq = dev->virtqueue[vq_index];\n \t\taddr = &vq->ring_addrs;\n \n+\t\tlen = sizeof(struct vring_packed_desc_event);\n+\t\tvq->driver_event = (struct vring_packed_desc_event *)\n+\t\t\t\t\t(uintptr_t)ring_addr_to_vva(dev,\n+\t\t\t\t\tvq, addr->avail_user_addr, &len);\n+\t\tif (vq->driver_event == NULL ||\n+\t\t\t\tlen != sizeof(struct vring_packed_desc_event)) {\n+\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n+\t\t\t\t\"(%d) failed to find driver area address.\\n\",\n+\t\t\t\tdev->vid);\n+\t\t\treturn dev;\n+\t\t}\n+\n+\t\tlen = sizeof(struct vring_packed_desc_event);\n+\t\tvq->device_event = (struct vring_packed_desc_event *)\n+\t\t\t\t\t(uintptr_t)ring_addr_to_vva(dev,\n+\t\t\t\t\tvq, addr->used_user_addr, &len);\n+\t\tif (vq->device_event == NULL ||\n+\t\t\t\tlen != sizeof(struct vring_packed_desc_event)) {\n+\t\t\tRTE_LOG(DEBUG, VHOST_CONFIG,\n+\t\t\t\t\"(%d) failed to find device area address.\\n\",\n+\t\t\t\tdev->vid);\n+\t\t\treturn dev;\n+\t\t}\n+\n \t\treturn dev;\n \t}\n \ndiff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex e79a82f45..ccdf73cf4 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -826,7 +826,7 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \n \tif (likely(vq->shadow_used_idx)) {\n \t\tflush_shadow_used_ring_split(dev, vq);\n-\t\tvhost_vring_call(dev, vq);\n+\t\tvhost_vring_call_split(dev, vq);\n \t}\n \n \treturn pkt_idx;\n@@ -879,7 +879,7 @@ virtio_dev_rx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \n \tif (likely(vq->shadow_used_idx)) {\n \t\tflush_shadow_used_ring_packed(dev, vq);\n-\t\tvhost_vring_call(dev, vq);\n+\t\tvhost_vring_call_packed(dev, vq);\n \t}\n \n \treturn pkt_idx;\n@@ -1362,7 +1362,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t}\n \n \t\tflush_shadow_used_ring_split(dev, vq);\n-\t\tvhost_vring_call(dev, vq);\n+\t\tvhost_vring_call_split(dev, vq);\n \t}\n \n \trte_prefetch0(&vq->avail->ring[vq->last_avail_idx & (vq->size - 1)]);\n@@ -1441,7 +1441,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tif (unlikely(i < count))\n \t\t\tvq->shadow_used_idx = i;\n \t\tflush_shadow_used_ring_split(dev, vq);\n-\t\tvhost_vring_call(dev, vq);\n+\t\tvhost_vring_call_split(dev, vq);\n \t}\n \n \treturn i;\n@@ -1477,7 +1477,7 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t}\n \n \t\tflush_shadow_used_ring_packed(dev, vq);\n-\t\tvhost_vring_call(dev, vq);\n+\t\tvhost_vring_call_packed(dev, vq);\n \t}\n \n \tVHOST_LOG_DEBUG(VHOST_DATA, \"(%d) %s\\n\", dev->vid, __func__);\n@@ -1555,7 +1555,7 @@ virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\tif (unlikely(i < count))\n \t\t\tvq->shadow_used_idx = i;\n \t\tflush_shadow_used_ring_packed(dev, vq);\n-\t\tvhost_vring_call(dev, vq);\n+\t\tvhost_vring_call_packed(dev, vq);\n \t}\n \n \treturn i;\n",
    "prefixes": [
        "v8",
        "14/15"
    ]
}