get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41413,
    "url": "http://patchwork.dpdk.org/api/patches/41413/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20180622134327.18973-15-maxime.coquelin@redhat.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20180622134327.18973-15-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180622134327.18973-15-maxime.coquelin@redhat.com",
    "date": "2018-06-22T13:43:26",
    "name": "[v5,14/15] vhost: add notification for packed ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3ed47b1f71b883e0dbdab970a57e25106fc9f36f",
    "submitter": {
        "id": 512,
        "url": "http://patchwork.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patchwork.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20180622134327.18973-15-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 210,
            "url": "http://patchwork.dpdk.org/api/series/210/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=210",
            "date": "2018-06-22T13:43:12",
            "name": "Vhost: add support to packed ring layout",
            "version": 5,
            "mbox": "http://patchwork.dpdk.org/series/210/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/41413/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/41413/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 B7B1C1BDF8;\n\tFri, 22 Jun 2018 15:44:14 +0200 (CEST)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 643FA1BDE1\n\tfor <dev@dpdk.org>; Fri, 22 Jun 2018 15:44:10 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4])\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 DC31281A4EBE;\n\tFri, 22 Jun 2018 13:44:09 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-42.ams2.redhat.com\n\t[10.36.112.42])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 33D4B2026D6B;\n\tFri, 22 Jun 2018 13:44:08 +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": "Fri, 22 Jun 2018 15:43:26 +0200",
        "Message-Id": "<20180622134327.18973-15-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20180622134327.18973-1-maxime.coquelin@redhat.com>",
        "References": "<20180622134327.18973-1-maxime.coquelin@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.4",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.8]); Fri, 22 Jun 2018 13:44:09 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.8]); \n\tFri, 22 Jun 2018 13:44:09 +0000 (UTC) for IP:'10.11.54.4'\n\tDOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "Subject": "[dpdk-dev] [PATCH v5 14/15] vhost: add notification for packed ring",
        "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         | 55 +++++++++++++++++++++++++++----\n lib/librte_vhost/vhost.h         | 71 ++++++++++++++++++++++++++++++++++++----\n lib/librte_vhost/vhost_user.c    | 29 +++++++++++++---\n lib/librte_vhost/virtio-packed.h | 11 +++++++\n lib/librte_vhost/virtio_net.c    | 12 +++----\n 5 files changed, 154 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex 7cbf1eded..c26162542 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -595,7 +595,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@@ -616,20 +620,59 @@ 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 int\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+\treturn 0;\n+}\n+\n+static inline int\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 = RING_EVENT_FLAGS_DISABLE;\n+\t\treturn 0;\n+\t}\n+\n+\tflags = RING_EVENT_FLAGS_DISABLE;\n+\tif (dev->features & (1ULL << VIRTIO_RING_F_EVENT_IDX)) {\n+\t\tflags = RING_EVENT_FLAGS_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+\trte_smp_wmb();\n+\n+\treturn 0;\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\treturn vhost_enable_notify_packed(dev, vq, enable);\n \telse\n-\t\tdev->virtqueue[queue_id]->used->flags |= VRING_USED_F_NO_NOTIFY;\n-\treturn 0;\n+\t\treturn vhost_enable_notify_split(vq, enable);\n }\n \n void\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex 5dcb61c71..99db688a8 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -21,6 +21,7 @@\n \n #include \"rte_vhost.h\"\n #include \"rte_vdpa.h\"\n+#include \"virtio-packed.h\"\n \n /* Used to indicate that the device is running on a data core */\n #define VIRTIO_DEV_RUNNING 1\n@@ -95,8 +96,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@@ -614,7 +621,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_mb();\n@@ -625,11 +632,11 @@ vhost_vring_call(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \t\tuint16_t new = vq->last_used_idx;\n \n \t\tVHOST_LOG_DEBUG(VHOST_DATA, \"%s: used_event_idx=%d, old=%d, new=%d\\n\",\n-\t\t\t__func__,\n-\t\t\tvhost_used_event(vq),\n-\t\t\told, new);\n+\t\t\t\t__func__,\n+\t\t\t\tvhost_used_event(vq),\n+\t\t\t\told, new);\n \t\tif (vhost_need_event(vhost_used_event(vq), new, old)\n-\t\t\t&& (vq->callfd >= 0)) {\n+\t\t\t\t&& (vq->callfd >= 0)) {\n \t\t\tvq->signalled_used = vq->last_used_idx;\n \t\t\teventfd_write(vq->callfd, (eventfd_t) 1);\n \t\t}\n@@ -641,4 +648,54 @@ 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, wrap;\n+\tbool kick = false;\n+\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\tRING_EVENT_FLAGS_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 != RING_EVENT_FLAGS_DESC) {\n+\t\tif (vq->driver_event->desc_event_flags !=\n+\t\t\t\tRING_EVENT_FLAGS_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+\twrap = vq->used_wrap_counter;\n+\n+\tif (new < old) {\n+\t\tnew += vq->size;\n+\t\twrap ^= 1;\n+\t}\n+\n+\tif (wrap != off_wrap >> 15)\n+\t\toff += vq->size;\n+\n+\tif (vhost_need_event(off, new, old))\n+\t\tkick = true;\n+\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 a08d99314..c74924564 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -509,9 +509,6 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)\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->desc = NULL;\n-\t\tvq->avail = NULL;\n-\t\tvq->used = NULL;\n \t\tvq->log_guest_addr = 0;\n \t\tif (vq->desc_packed == 0 ||\n \t\t\t\tlen != sizeof(struct vring_desc_packed) *\n@@ -526,6 +523,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 == 0 ||\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 == 0 ||\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 \n@@ -542,8 +563,6 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)\n \t\t\tdev->vid);\n \t\treturn dev;\n \t}\n-\tvq->desc_packed = NULL;\n-\n \tdev = numa_realloc(dev, vq_index);\n \tvq = dev->virtqueue[vq_index];\n \taddr = &vq->ring_addrs;\ndiff --git a/lib/librte_vhost/virtio-packed.h b/lib/librte_vhost/virtio-packed.h\nindex 21fe5045b..f271249d8 100644\n--- a/lib/librte_vhost/virtio-packed.h\n+++ b/lib/librte_vhost/virtio-packed.h\n@@ -19,6 +19,17 @@ struct vring_desc_packed {\n \tuint16_t flags;\n };\n \n+#define RING_EVENT_FLAGS_ENABLE 0x0\n+#define RING_EVENT_FLAGS_DISABLE 0x1\n+#define RING_EVENT_FLAGS_DESC 0x2\n+#define RING_EVENT_FLAGS_MASK 0xFFFC\n+#define RING_EVENT_WRAP_MASK 0x8000\n+#define RING_EVENT_OFF_MASK 0x7FFF\n+\n+struct vring_packed_desc_event {\n+\tuint16_t desc_event_off_wrap;\n+\tuint16_t desc_event_flags;\n+};\n \n static inline int\n desc_is_avail(struct vring_desc_packed *desc, uint16_t wrap_counter)\ndiff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex b9f49175c..9e8c9969b 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -822,7 +822,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@@ -875,7 +875,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@@ -1358,7 +1358,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@@ -1437,7 +1437,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@@ -1475,7 +1475,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@@ -1553,7 +1553,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": [
        "v5",
        "14/15"
    ]
}