get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 96232,
    "url": "http://patchwork.dpdk.org/api/patches/96232/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210723080937.20256-5-cheng1.jiang@intel.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": "<20210723080937.20256-5-cheng1.jiang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210723080937.20256-5-cheng1.jiang@intel.com",
    "date": "2021-07-23T08:09:37",
    "name": "[v8,4/4] examples/vhost: handle memory hotplug for async vhost",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "40db133f80bfcd72ac80c3fb60cebaf4474e634b",
    "submitter": {
        "id": 1530,
        "url": "http://patchwork.dpdk.org/api/people/1530/?format=api",
        "name": "Jiang, Cheng1",
        "email": "Cheng1.jiang@intel.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/20210723080937.20256-5-cheng1.jiang@intel.com/mbox/",
    "series": [
        {
            "id": 17963,
            "url": "http://patchwork.dpdk.org/api/series/17963/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=17963",
            "date": "2021-07-23T08:09:33",
            "name": "vhost: handle memory hotplug for async vhost",
            "version": 8,
            "mbox": "http://patchwork.dpdk.org/series/17963/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/96232/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/96232/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 95C3BA0C46;\n\tFri, 23 Jul 2021 10:27:27 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 5BD0B410F5;\n\tFri, 23 Jul 2021 10:27:12 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by mails.dpdk.org (Postfix) with ESMTP id D1381410F5\n for <dev@dpdk.org>; Fri, 23 Jul 2021 10:27:10 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 23 Jul 2021 01:27:10 -0700",
            "from dpdk_jiangcheng.sh.intel.com ([10.67.119.149])\n by FMSMGA003.fm.intel.com with ESMTP; 23 Jul 2021 01:27:08 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10053\"; a=\"199042822\"",
            "E=Sophos;i=\"5.84,263,1620716400\"; d=\"scan'208\";a=\"199042822\"",
            "E=Sophos;i=\"5.84,263,1620716400\"; d=\"scan'208\";a=\"502430136\""
        ],
        "X-ExtLoop1": "1",
        "From": "Cheng Jiang <cheng1.jiang@intel.com>",
        "To": "maxime.coquelin@redhat.com,\n\tChenbo.Xia@intel.com",
        "Cc": "dev@dpdk.org, jiayu.hu@intel.com, yvonnex.yang@intel.com,\n Cheng Jiang <cheng1.jiang@intel.com>",
        "Date": "Fri, 23 Jul 2021 08:09:37 +0000",
        "Message-Id": "<20210723080937.20256-5-cheng1.jiang@intel.com>",
        "X-Mailer": "git-send-email 2.29.2",
        "In-Reply-To": "<20210723080937.20256-1-cheng1.jiang@intel.com>",
        "References": "<20210602042802.31943-1-cheng1.jiang@intel.com>\n <20210723080937.20256-1-cheng1.jiang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v8 4/4] examples/vhost: handle memory hotplug for\n async vhost",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "When the guest memory is hotplugged, the vhost application which\nenables DMA acceleration must stop DMA transfers before the vhost\nre-maps the guest memory.\n\nTo accomplish that, we need to do these changes in the vhost sample:\n1. add inflight packets count.\n2. add vring_state_changed() callback.\n3. add inflight packets clear process in destroy_device() and\nvring_state_changed().\n\nSigned-off-by: Cheng Jiang <cheng1.jiang@intel.com>\nReviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n examples/vhost/main.c | 55 +++++++++++++++++++++++++++++++++++++++++--\n examples/vhost/main.h |  1 +\n 2 files changed, 54 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/examples/vhost/main.c b/examples/vhost/main.c\nindex 9cd855a696..bc3d71c898 100644\n--- a/examples/vhost/main.c\n+++ b/examples/vhost/main.c\n@@ -851,8 +851,11 @@ complete_async_pkts(struct vhost_dev *vdev)\n \n \tcomplete_count = rte_vhost_poll_enqueue_completed(vdev->vid,\n \t\t\t\t\tVIRTIO_RXQ, p_cpl, MAX_PKT_BURST);\n-\tif (complete_count)\n+\tif (complete_count) {\n \t\tfree_pkts(p_cpl, complete_count);\n+\t\t__atomic_sub_fetch(&vdev->pkts_inflight, complete_count, __ATOMIC_SEQ_CST);\n+\t}\n+\n }\n \n static __rte_always_inline void\n@@ -895,6 +898,7 @@ drain_vhost(struct vhost_dev *vdev)\n \t\tcomplete_async_pkts(vdev);\n \t\tret = rte_vhost_submit_enqueue_burst(vdev->vid, VIRTIO_RXQ,\n \t\t\t\t\tm, nr_xmit, m_cpu_cpl, &cpu_cpl_nr);\n+\t\t__atomic_add_fetch(&vdev->pkts_inflight, ret - cpu_cpl_nr, __ATOMIC_SEQ_CST);\n \n \t\tif (cpu_cpl_nr)\n \t\t\tfree_pkts(m_cpu_cpl, cpu_cpl_nr);\n@@ -1226,6 +1230,9 @@ drain_eth_rx(struct vhost_dev *vdev)\n \t\tenqueue_count = rte_vhost_submit_enqueue_burst(vdev->vid,\n \t\t\t\t\tVIRTIO_RXQ, pkts, rx_count,\n \t\t\t\t\tm_cpu_cpl, &cpu_cpl_nr);\n+\t\t__atomic_add_fetch(&vdev->pkts_inflight, enqueue_count - cpu_cpl_nr,\n+\t\t\t\t\t__ATOMIC_SEQ_CST);\n+\n \t\tif (cpu_cpl_nr)\n \t\t\tfree_pkts(m_cpu_cpl, cpu_cpl_nr);\n \n@@ -1397,8 +1404,19 @@ destroy_device(int vid)\n \t\t\"(%d) device has been removed from data core\\n\",\n \t\tvdev->vid);\n \n-\tif (async_vhost_driver)\n+\tif (async_vhost_driver) {\n+\t\tuint16_t n_pkt = 0;\n+\t\tstruct rte_mbuf *m_cpl[vdev->pkts_inflight];\n+\n+\t\twhile (vdev->pkts_inflight) {\n+\t\t\tn_pkt = rte_vhost_clear_queue_thread_unsafe(vid, VIRTIO_RXQ,\n+\t\t\t\t\t\tm_cpl, vdev->pkts_inflight);\n+\t\t\tfree_pkts(m_cpl, n_pkt);\n+\t\t\t__atomic_sub_fetch(&vdev->pkts_inflight, n_pkt, __ATOMIC_SEQ_CST);\n+\t\t}\n+\n \t\trte_vhost_async_channel_unregister(vid, VIRTIO_RXQ);\n+\t}\n \n \trte_free(vdev);\n }\n@@ -1487,6 +1505,38 @@ new_device(int vid)\n \treturn 0;\n }\n \n+static int\n+vring_state_changed(int vid, uint16_t queue_id, int enable)\n+{\n+\tstruct vhost_dev *vdev = NULL;\n+\n+\tTAILQ_FOREACH(vdev, &vhost_dev_list, global_vdev_entry) {\n+\t\tif (vdev->vid == vid)\n+\t\t\tbreak;\n+\t}\n+\tif (!vdev)\n+\t\treturn -1;\n+\n+\tif (queue_id != VIRTIO_RXQ)\n+\t\treturn 0;\n+\n+\tif (async_vhost_driver) {\n+\t\tif (!enable) {\n+\t\t\tuint16_t n_pkt = 0;\n+\t\t\tstruct rte_mbuf *m_cpl[vdev->pkts_inflight];\n+\n+\t\t\twhile (vdev->pkts_inflight) {\n+\t\t\t\tn_pkt = rte_vhost_clear_queue_thread_unsafe(vid, queue_id,\n+\t\t\t\t\t\t\tm_cpl, vdev->pkts_inflight);\n+\t\t\t\tfree_pkts(m_cpl, n_pkt);\n+\t\t\t\t__atomic_sub_fetch(&vdev->pkts_inflight, n_pkt, __ATOMIC_SEQ_CST);\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n /*\n  * These callback allow devices to be added to the data core when configuration\n  * has been fully complete.\n@@ -1495,6 +1545,7 @@ static const struct vhost_device_ops virtio_net_device_ops =\n {\n \t.new_device =  new_device,\n \t.destroy_device = destroy_device,\n+\t.vring_state_changed = vring_state_changed,\n };\n \n /*\ndiff --git a/examples/vhost/main.h b/examples/vhost/main.h\nindex 0ccdce4b4a..e7b1ac60a6 100644\n--- a/examples/vhost/main.h\n+++ b/examples/vhost/main.h\n@@ -51,6 +51,7 @@ struct vhost_dev {\n \tuint64_t features;\n \tsize_t hdr_len;\n \tuint16_t nr_vrings;\n+\tuint16_t pkts_inflight;\n \tstruct rte_vhost_memory *mem;\n \tstruct device_statistics stats;\n \tTAILQ_ENTRY(vhost_dev) global_vdev_entry;\n",
    "prefixes": [
        "v8",
        "4/4"
    ]
}