get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 31697,
    "url": "http://patches.dpdk.org/api/patches/31697/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20171128094826.179454-1-junjie.j.chen@intel.com/",
    "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20171128094826.179454-1-junjie.j.chen@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20171128094826.179454-1-junjie.j.chen@intel.com",
    "date": "2017-11-28T09:48:26",
    "name": "[dpdk-dev,v2] vhost: support virtqueue interrupt/notification suppression",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "4779877bd3264493191d6c38a1d9ea43b6b1f0b6",
    "submitter": {
        "id": 903,
        "url": "http://patches.dpdk.org/api/people/903/?format=api",
        "name": null,
        "email": "junjie.j.chen@intel.com"
    },
    "delegate": {
        "id": 355,
        "url": "http://patches.dpdk.org/api/users/355/?format=api",
        "username": "yliu",
        "first_name": "Yuanhan",
        "last_name": "Liu",
        "email": "yuanhan.liu@linux.intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20171128094826.179454-1-junjie.j.chen@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/31697/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/31697/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 9F27B2B99;\n\tTue, 28 Nov 2017 03:06:57 +0100 (CET)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby dpdk.org (Postfix) with ESMTP id DD689271\n\tfor <dev@dpdk.org>; Tue, 28 Nov 2017 03:06:55 +0100 (CET)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t27 Nov 2017 18:06:54 -0800",
            "from pppoe-test.sh.intel.com ([10.67.111.147])\n\tby FMSMGA003.fm.intel.com with ESMTP; 27 Nov 2017 18:06:52 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.44,466,1505804400\"; d=\"scan'208\";a=\"6646603\"",
        "From": "junjie.j.chen@intel.com",
        "To": "yliu@fridaylinux.org, maxime.coquelin@redhat.com, tiwei.bie@intel.com,\n\tjianfeng.tan@intel.com, dev@dpdk.org",
        "Cc": "Junjie Chen <junjie.j.chen@intel.com>",
        "Date": "Tue, 28 Nov 2017 04:48:26 -0500",
        "Message-Id": "<20171128094826.179454-1-junjie.j.chen@intel.com>",
        "X-Mailer": "git-send-email 2.15.0",
        "Subject": "[dpdk-dev] [PATCH v2] vhost: support virtqueue\n\tinterrupt/notification suppression",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Junjie Chen <junjie.j.chen@intel.com>\n\nThe driver can suppress interrupt when VIRTIO_F_EVENT_IDX feature bit is\nnegotiated. The driver set vring flags to 0, and MAY use used_event in\navailable ring to advise device interrupt util reach an index specified\nby used_event. The device ignore the lower bit of vring flags, and send\nan interrupt when index reach used_event.\n\nThe device can suppress notification in a manner analogous to the ways\ndriver suppress interrupt. The device manipulates flags or avail_event in\nthe used ringin the same way the driver manipulates flags or used_event in\navailable ring.\n\nThis patch is to enable this feature in vhost.\n\nSigned-off-by: Junjie Chen <junjie.j.chen@intel.com>\n---\n lib/librte_vhost/Makefile     |  1 +\n lib/librte_vhost/vhost.h      |  9 ++++++-\n lib/librte_vhost/virtio_net.c | 56 +++++++++++++++++++++++++++++++------------\n 3 files changed, 50 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile\nindex be182798a..85695d443 100644\n--- a/lib/librte_vhost/Makefile\n+++ b/lib/librte_vhost/Makefile\n@@ -40,6 +40,7 @@ LIBABIVER := 4\n \n CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 -D_FILE_OFFSET_BITS=64\n CFLAGS += -I vhost_user\n+CFLAGS += -fno-strict-aliasing\n LDLIBS += -lpthread\n \n ifeq ($(CONFIG_RTE_LIBRTE_VHOST_NUMA),y)\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex 1cc81c17c..b0a955f64 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -103,6 +103,8 @@ struct vhost_virtqueue {\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 #define VIRTIO_INVALID_EVENTFD\t\t(-1)\n #define VIRTIO_UNINITIALIZED_EVENTFD\t(-2)\n \n@@ -195,6 +197,10 @@ struct vhost_msg {\n \n #define VHOST_USER_F_PROTOCOL_FEATURES\t30\n \n+#ifndef VIRTIO_F_EVENT_IDX\n+ #define VIRTIO_F_EVENT_IDX 29\n+#endif\n+\n /* Features supported by this builtin vhost-user net driver. */\n #define VIRTIO_NET_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \\\n \t\t\t\t(1ULL << VIRTIO_NET_F_CTRL_VQ) | \\\n@@ -212,7 +218,8 @@ struct vhost_msg {\n \t\t\t\t(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \\\n \t\t\t\t(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \\\n \t\t\t\t(1ULL << VIRTIO_NET_F_MTU) | \\\n-\t\t\t\t(1ULL << VIRTIO_F_IOMMU_PLATFORM))\n+\t\t\t\t(1ULL << VIRTIO_F_IOMMU_PLATFORM) | \\\n+\t\t\t\t(1ULL << VIRTIO_F_EVENT_IDX))\n \n \n struct guest_page {\ndiff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex 6fee16e55..0c1d66d7c 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -52,6 +52,35 @@\n \n #define MAX_BATCH_LEN 256\n \n+#define vhost_used_event(vr)  ((vr)->avail->ring[(vr)->size])\n+#define vhost_avail_event(vr) \\\n+\t(*(volatile uint16_t *)&(vr)->used->ring[(vr)->size])\n+\n+static __rte_always_inline void\n+vhost_notify(struct virtio_net *dev,  struct vhost_virtqueue *vq)\n+{\n+\t/* Don't notify guest if we don't reach index specified by guest. */\n+\tif (dev->features & (1ULL << VIRTIO_F_EVENT_IDX)) {\n+\t\tuint16_t old = vq->signalled_used;\n+\t\tuint16_t new = vq->last_used_idx;\n+\n+\t\tLOG_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\tif (vring_need_event(vhost_used_event(vq), new, old)\n+\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+\t} else {\n+\t\t/* Kick the guest if necessary. */\n+\t\tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)\n+\t\t\t&& (vq->callfd >= 0))\n+\t\t\teventfd_write(vq->callfd, (eventfd_t)1);\n+\t}\n+}\n+\n static bool\n is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring)\n {\n@@ -410,11 +439,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,\n \n \t/* flush used->idx update before we read avail->flags. */\n \trte_mb();\n-\n-\t/* Kick the guest if necessary. */\n-\tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)\n-\t\t\t&& (vq->callfd >= 0))\n-\t\teventfd_write(vq->callfd, (eventfd_t)1);\n+\tvhost_notify(dev, vq);\n out:\n \tif (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))\n \t\tvhost_user_iotlb_rd_unlock(vq);\n@@ -704,11 +729,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,\n \n \t\t/* flush used->idx update before we read avail->flags. */\n \t\trte_mb();\n-\n-\t\t/* Kick the guest if necessary. */\n-\t\tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)\n-\t\t\t\t&& (vq->callfd >= 0))\n-\t\t\teventfd_write(vq->callfd, (eventfd_t)1);\n+\t\tvhost_notify(dev, vq);\n \t}\n \n out:\n@@ -1106,11 +1127,7 @@ update_used_idx(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \tvq->used->idx += count;\n \tvhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx),\n \t\t\tsizeof(vq->used->idx));\n-\n-\t/* Kick guest if required. */\n-\tif (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)\n-\t\t\t&& (vq->callfd >= 0))\n-\t\teventfd_write(vq->callfd, (eventfd_t)1);\n+\tvhost_notify(dev, vq);\n }\n \n static __rte_always_inline struct zcopy_mbuf *\n@@ -1352,6 +1369,15 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,\n \t\tupdate_used_idx(dev, vq, i);\n \t}\n \n+\t/*\n+\t * Update avail event index to last_avail_idx to expect\n+\t * front end notify us after next buffer available.\n+\t */\n+\tif (dev->features & (1ULL << VIRTIO_F_EVENT_IDX)) {\n+\t\tvhost_avail_event(vq) = vq->last_avail_idx;\n+\t\trte_mb();\n+\t}\n+\n out:\n \tif (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))\n \t\tvhost_user_iotlb_rd_unlock(vq);\n",
    "prefixes": [
        "dpdk-dev",
        "v2"
    ]
}