Show a patch.

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

{
    "id": 42281,
    "url": "http://patches.dpdk.org/api/patches/42281/",
    "web_url": "http://patches.dpdk.org/patch/42281/",
    "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-15-maxime.coquelin@redhat.com>",
    "date": "2018-07-04T21:54:37",
    "name": "[v7,14/15] vhost: add notification for packed ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e1f4bd5423bdb7c54b78a64e8301d7af433e55a9",
    "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/42281/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/42281/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42281/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 3EA911BF92;\n\tWed,  4 Jul 2018 23:55:18 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 001BB1B5C3\n\tfor <dev@dpdk.org>; Wed,  4 Jul 2018 23:55:16 +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 9CAF44075384;\n\tWed,  4 Jul 2018 21:55:16 +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 B20142156880;\n\tWed,  4 Jul 2018 21:55:14 +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-15-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.7]); Wed, 04 Jul 2018 21:55:16 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.7]); \n\tWed, 04 Jul 2018 21:55:16 +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:37 +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 14/15] vhost: add notification for packed ring"
    },
    "content": "Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/vhost.c      | 70 +++++++++++++++++++++++++++++++++++++------\n lib/librte_vhost/vhost.h      | 63 ++++++++++++++++++++++++++++++++++++--\n lib/librte_vhost/vhost_user.c | 24 +++++++++++++++\n lib/librte_vhost/virtio_net.c | 12 ++++----\n 4 files changed, 151 insertions(+), 18 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex b5c649281..13e37825b 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@@ -604,7 +619,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 +644,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->desc_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->desc_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->desc_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 92a87712e..5c7effabe 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -95,8 +95,14 @@ 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@@ -225,6 +231,15 @@ struct vring_desc_packed {\n \tuint16_t index;\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 desc_event_off_wrap;\n+\tuint16_t desc_event_flags;\n+};\n #endif\n \n /*\n@@ -648,7 +663,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 +690,46 @@ 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 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->desc_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+\n+\tif (vq->driver_event->desc_event_flags != VRING_EVENT_F_DESC) {\n+\t\tif (vq->driver_event->desc_event_flags !=\n+\t\t\t\tVRING_EVENT_F_DISABLE)\n+\t\t\tkick = true;\n+\t\tgoto kick;\n+\t}\n+\n+\trte_smp_rmb();\n+\n+\toff_wrap = vq->driver_event->desc_event_off_wrap;\n+\toff = off_wrap & ~(1 << 15);\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 7210cb241..e7dff36fa 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": [
        "v7",
        "14/15"
    ]
}