get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 35359,
    "url": "http://patches.dpdk.org/api/patches/35359/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180222181910.23134-3-maxime.coquelin@redhat.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": "<20180222181910.23134-3-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180222181910.23134-3-maxime.coquelin@redhat.com",
    "date": "2018-02-22T18:19:09",
    "name": "[dpdk-dev,RFC,2/3] vhost: add SET_VIRTIO_STATUS support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f2aa01391f7f20b647198b1eea6e53e65d3ecd9e",
    "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/project/dpdk/patch/20180222181910.23134-3-maxime.coquelin@redhat.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/35359/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/35359/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 D5E351B1A5;\n\tThu, 22 Feb 2018 19:19:36 +0100 (CET)",
            "from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73])\n\tby dpdk.org (Postfix) with ESMTP id 3DB181B19B\n\tfor <dev@dpdk.org>; Thu, 22 Feb 2018 19:19:34 +0100 (CET)",
            "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3])\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 D7A20EAE98;\n\tThu, 22 Feb 2018 18:19:33 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-33.ams2.redhat.com\n\t[10.36.112.33])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 7E2BA1049460;\n\tThu, 22 Feb 2018 18:19:32 +0000 (UTC)"
        ],
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "jianfeng.tan@intel.com, stefanha@redhat.com, tiwei.bie@intel.com,\n\tjfreimann@redhat.com, dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Thu, 22 Feb 2018 19:19:09 +0100",
        "Message-Id": "<20180222181910.23134-3-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20180222181910.23134-1-maxime.coquelin@redhat.com>",
        "References": "<20180222181910.23134-1-maxime.coquelin@redhat.com>",
        "X-Scanned-By": "MIMEDefang 2.78 on 10.11.54.3",
        "X-Greylist": [
            "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.11.55.1]); Thu, 22 Feb 2018 18:19:33 +0000 (UTC)",
            "inspected by milter-greylist-4.5.16 (mx1.redhat.com\n\t[10.11.55.1]); \n\tThu, 22 Feb 2018 18:19:33 +0000 (UTC) for IP:'10.11.54.3'\n\tDOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com'\n\tHELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:''"
        ],
        "Subject": "[dpdk-dev] [RFC 2/3] vhost: add SET_VIRTIO_STATUS support",
        "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://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": "<https://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": "This patch implements support for the new SET_VIRTIO_STATUS\nvhost-user request.\n\nThe main use for this new request is for the backend to know\nwhen the driver sets the DRIVER_OK status bit. Starting Virtio\n1.0, we know that once the the bit is set, no more queues will\nbe initialized.\nWhen it happens, this patch removes all queues starting from\nthe first uninitialized one, so that the port starts even if\nthe guest driver does not use all the queues provided by QEMU.\nThis is for example the case with Windows driver, which only\ninitializes as much queue pairs as vCPUs.\n\nThe second use for this request is when the status changes to\nreset or failed state, the vhost port is stopped and virtqueues\ncleaned and freed.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/vhost_user.c | 98 +++++++++++++++++++++++++++++++++++++++++++\n lib/librte_vhost/vhost_user.h |  5 ++-\n 2 files changed, 102 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex c256ebb06..7ab02c44b 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -67,6 +67,7 @@ static const char *vhost_message_str[VHOST_USER_MAX] = {\n \t[VHOST_USER_NET_SET_MTU]  = \"VHOST_USER_NET_SET_MTU\",\n \t[VHOST_USER_SET_SLAVE_REQ_FD]  = \"VHOST_USER_SET_SLAVE_REQ_FD\",\n \t[VHOST_USER_IOTLB_MSG]  = \"VHOST_USER_IOTLB_MSG\",\n+\t[VHOST_USER_SET_VIRTIO_STATUS]  = \"VHOST_USER_SET_VIRTIO_STATUS\",\n };\n \n static uint64_t\n@@ -1244,6 +1245,100 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg)\n \treturn 0;\n }\n \n+static int\n+vhost_user_set_virtio_status(struct virtio_net *dev, struct VhostUserMsg *msg)\n+{\n+\tuint8_t old_status, new_status;\n+\tuint32_t i;\n+\n+\t/* As per Virtio spec, the Virtio device status is 8 bits wide */\n+\tif (msg->payload.u64 != (uint8_t)msg->payload.u64) {\n+\t\tRTE_LOG(ERR, VHOST_CONFIG,\n+\t\t\t\t\"Invalid Virtio dev status value (%lx)\\n\",\n+\t\t\t\tmsg->payload.u64);\n+\t\treturn -1;\n+\t}\n+\n+\tnew_status = msg->payload.u64;\n+\told_status = dev->virtio_status;\n+\n+\tif (new_status == old_status)\n+\t\treturn 0;\n+\n+\tRTE_LOG(DEBUG, VHOST_CONFIG,\n+\t\t\t\"New Virtio device status %x (was %x)\\n\",\n+\t\t\tnew_status, old_status);\n+\n+\tdev->virtio_status = new_status;\n+\n+\tif (new_status == 0 || new_status & VIRTIO_CONFIG_S_FAILED) {\n+\t\t/*\n+\t\t * The device moved to reset  or failed state,\n+\t\t * stop processing the virtqueues\n+\t\t */\n+\t\tif (dev->flags & VIRTIO_DEV_RUNNING) {\n+\t\t\tdev->flags &= ~VIRTIO_DEV_RUNNING;\n+\t\t\tdev->notify_ops->destroy_device(dev->vid);\n+\t\t}\n+\n+\t\twhile (dev->nr_vring > 0) {\n+\t\t\tstruct vhost_virtqueue *vq;\n+\n+\t\t\tvq = dev->virtqueue[--dev->nr_vring];\n+\t\t\tif (!vq)\n+\t\t\t\tcontinue;\n+\n+\t\t\tdev->virtqueue[dev->nr_vring] = NULL;\n+\t\t\tcleanup_vq(dev, vq, 1);\n+\t\t\tfree_vq(vq);\n+\t\t}\n+\n+\t\treturn 0;\n+\t}\n+\n+\tif ((dev->features & (1ULL << VIRTIO_F_VERSION_1)) &&\n+\t\t\t(new_status & VIRTIO_CONFIG_S_DRIVER_OK) &&\n+\t\t\t!virtio_is_ready(dev)) {\n+\t\t/*\n+\t\t * Since Virtio 1.0, we know that no more queues will be\n+\t\t * setup after guest sets DRIVER_OK. So let's remove\n+\t\t * uinitialized queues.\n+\t\t */\n+\t\tRTE_LOG(INFO, VHOST_CONFIG,\n+\t\t\t\t\"Driver is ready, but some queues aren't initialized\\n\");\n+\n+\t\t/*\n+\t\t * Find the first uninitialized queue.\n+\t\t *\n+\t\t * Note: Ideally the backend implementation should\n+\t\t * support sparsed virtqueues, but as long as it is\n+\t\t * not the case, let's remove all queues after the\n+\t\t * first uninitialized one.\n+\t\t */\n+\t\tfor (i = 0; i < dev->nr_vring; i++) {\n+\t\t\tif (!vq_is_ready(dev->virtqueue[i]))\n+\t\t\t\tbreak;\n+\t\t}\n+\n+\t\twhile (dev->nr_vring >= i) {\n+\t\t\tstruct vhost_virtqueue *vq;\n+\n+\t\t\tvq = dev->virtqueue[--dev->nr_vring];\n+\t\t\tif (!vq)\n+\t\t\t\tcontinue;\n+\n+\t\t\tRTE_LOG(INFO, VHOST_CONFIG,\n+\t\t\t\t\t\"Removing uninitialized queue %d\\n\",\n+\t\t\t\t\tdev->nr_vring);\n+\n+\t\t\tdev->virtqueue[dev->nr_vring] = NULL;\n+\t\t\tcleanup_vq(dev, vq, 1);\n+\t\t\tfree_vq(vq);\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n /* return bytes# of read on success or negative val on failure. */\n static int\n read_vhost_message(int sockfd, struct VhostUserMsg *msg)\n@@ -1550,6 +1645,9 @@ vhost_user_msg_handler(int vid, int fd)\n \tcase VHOST_USER_IOTLB_MSG:\n \t\tret = vhost_user_iotlb_msg(&dev, &msg);\n \t\tbreak;\n+\tcase VHOST_USER_SET_VIRTIO_STATUS:\n+\t\tret = vhost_user_set_virtio_status(dev, &msg);\n+\t\tbreak;\n \n \tdefault:\n \t\tret = -1;\ndiff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h\nindex 0fafbe6e0..b4e23e0e9 100644\n--- a/lib/librte_vhost/vhost_user.h\n+++ b/lib/librte_vhost/vhost_user.h\n@@ -20,13 +20,15 @@\n #define VHOST_USER_PROTOCOL_F_REPLY_ACK\t3\n #define VHOST_USER_PROTOCOL_F_NET_MTU 4\n #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5\n+#define VHOST_USER_PROTOCOL_F_VIRTIO_STATUS 7\n \n #define VHOST_USER_PROTOCOL_FEATURES\t((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \\\n \t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) |\\\n \t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_RARP) | \\\n \t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK) | \\\n \t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU) | \\\n-\t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ))\n+\t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \\\n+\t\t\t\t\t (1ULL << VHOST_USER_PROTOCOL_F_VIRTIO_STATUS))\n \n typedef enum VhostUserRequest {\n \tVHOST_USER_NONE = 0,\n@@ -52,6 +54,7 @@ typedef enum VhostUserRequest {\n \tVHOST_USER_NET_SET_MTU = 20,\n \tVHOST_USER_SET_SLAVE_REQ_FD = 21,\n \tVHOST_USER_IOTLB_MSG = 22,\n+\tVHOST_USER_SET_VIRTIO_STATUS = 26,\n \tVHOST_USER_MAX\n } VhostUserRequest;\n \n",
    "prefixes": [
        "dpdk-dev",
        "RFC",
        "2/3"
    ]
}