get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 127496,
    "url": "http://patches.dpdk.org/api/patches/127496/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230525162551.70359-28-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": "<20230525162551.70359-28-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230525162551.70359-28-maxime.coquelin@redhat.com",
    "date": "2023-05-25T16:25:50",
    "name": "[v3,27/28] vhost: add multiqueue support to VDUSE",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ced54d4fbe149e325c8cb4bcf67be6d1612ed542",
    "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/20230525162551.70359-28-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 28187,
            "url": "http://patches.dpdk.org/api/series/28187/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=28187",
            "date": "2023-05-25T16:25:23",
            "name": "Add VDUSE support to Vhost library",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/28187/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/127496/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/127496/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 8B2C142B9D;\n\tThu, 25 May 2023 18:28:42 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 333164300F;\n\tThu, 25 May 2023 18:27:37 +0200 (CEST)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by mails.dpdk.org (Postfix) with ESMTP id 9023642D9B\n for <dev@dpdk.org>; Thu, 25 May 2023 18:27:35 +0200 (CEST)",
            "from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com\n [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-529-T8KIR_lrMHi_Hfz3jsbtHA-1; Thu, 25 May 2023 12:27:31 -0400",
            "from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com\n [10.11.54.7])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D84043C14AB4;\n Thu, 25 May 2023 16:27:30 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.39.208.23])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 44BB8140E961;\n Thu, 25 May 2023 16:27:28 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1685032055;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=GB/AU+Vbvek3rhMkceixizYLiCXsskLFM3Hzutrpcc4=;\n b=HdUsq6grWhZCHK2gSazLzuQ4ormZ4wB/6BfEm8snTBHqSBcaM+6N9+7l5Qj0tsFWtNQn5N\n 20i+PdlNLvGFL93yuCb4oEIqmrmft8AazhbO3xVPJUJ/fkMLsMnj1+Qf2dT2y9M9SX9HSf\n bLpnH+Xfkzk5AefpwudfYEwe8to2pNY=",
        "X-MC-Unique": "T8KIR_lrMHi_Hfz3jsbtHA-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com,\n mkp@redhat.com, fbl@redhat.com, jasowang@redhat.com,\n cunming.liang@intel.com, xieyongji@bytedance.com, echaudro@redhat.com,\n eperezma@redhat.com, amorenoz@redhat.com, lulu@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[PATCH v3 27/28] vhost: add multiqueue support to VDUSE",
        "Date": "Thu, 25 May 2023 18:25:50 +0200",
        "Message-Id": "<20230525162551.70359-28-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20230525162551.70359-1-maxime.coquelin@redhat.com>",
        "References": "<20230525162551.70359-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.7",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "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"
    },
    "content": "This patch enables control queue support in order to\nsupport multiqueue.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Chenbo Xia <chenbo.xia@intel.com>\n---\n lib/vhost/vduse.c | 83 +++++++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 76 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c\nindex a10dc24d38..699cfed9e3 100644\n--- a/lib/vhost/vduse.c\n+++ b/lib/vhost/vduse.c\n@@ -21,6 +21,7 @@\n #include \"iotlb.h\"\n #include \"vduse.h\"\n #include \"vhost.h\"\n+#include \"virtio_net_ctrl.h\"\n \n #define VHOST_VDUSE_API_VERSION 0\n #define VDUSE_CTRL_PATH \"/dev/vduse/control\"\n@@ -41,7 +42,9 @@\n \t\t\t\t(1ULL << VIRTIO_NET_F_GUEST_ECN) | \\\n \t\t\t\t(1ULL << VIRTIO_RING_F_INDIRECT_DESC) | \\\n \t\t\t\t(1ULL << VIRTIO_F_IN_ORDER) | \\\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_NET_F_CTRL_VQ) | \\\n+\t\t\t\t(1ULL << VIRTIO_NET_F_MQ))\n \n struct vduse {\n \tstruct fdset fdset;\n@@ -141,6 +144,25 @@ static struct vhost_backend_ops vduse_backend_ops = {\n \t.inject_irq = vduse_inject_irq,\n };\n \n+static void\n+vduse_control_queue_event(int fd, void *arg, int *remove __rte_unused)\n+{\n+\tstruct virtio_net *dev = arg;\n+\tuint64_t buf;\n+\tint ret;\n+\n+\tret = read(fd, &buf, sizeof(buf));\n+\tif (ret < 0) {\n+\t\tVHOST_LOG_CONFIG(dev->ifname, ERR, \"Failed to read control queue event: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\treturn;\n+\t}\n+\n+\tVHOST_LOG_CONFIG(dev->ifname, DEBUG, \"Control queue kicked\\n\");\n+\tif (virtio_net_ctrl_handle(dev))\n+\t\tVHOST_LOG_CONFIG(dev->ifname, ERR, \"Failed to handle ctrl request\\n\");\n+}\n+\n static void\n vduse_vring_setup(struct virtio_net *dev, unsigned int index)\n {\n@@ -212,6 +234,22 @@ vduse_vring_setup(struct virtio_net *dev, unsigned int index)\n \t\tvq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;\n \t\treturn;\n \t}\n+\n+\tif (vq == dev->cvq) {\n+\t\tret = fdset_add(&vduse.fdset, vq->kickfd, vduse_control_queue_event, NULL, dev);\n+\t\tif (ret) {\n+\t\t\tVHOST_LOG_CONFIG(dev->ifname, ERR,\n+\t\t\t\t\t\"Failed to setup kickfd handler for VQ %u: %s\\n\",\n+\t\t\t\t\tindex, strerror(errno));\n+\t\t\tvq_efd.fd = VDUSE_EVENTFD_DEASSIGN;\n+\t\t\tioctl(dev->vduse_dev_fd, VDUSE_VQ_SETUP_KICKFD, &vq_efd);\n+\t\t\tclose(vq->kickfd);\n+\t\t\tvq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;\n+\t\t}\n+\t\tfdset_pipe_notify(&vduse.fdset);\n+\t\tvhost_enable_guest_notification(dev, vq, 1);\n+\t\tVHOST_LOG_CONFIG(dev->ifname, INFO, \"Ctrl queue event handler installed\\n\");\n+\t}\n }\n \n static void\n@@ -258,6 +296,9 @@ vduse_device_start(struct virtio_net *dev)\n \tfor (i = 0; i < dev->nr_vring; i++) {\n \t\tstruct vhost_virtqueue *vq = dev->virtqueue[i];\n \n+\t\tif (vq == dev->cvq)\n+\t\t\tcontinue;\n+\n \t\tif (dev->notify_ops->vring_state_changed)\n \t\t\tdev->notify_ops->vring_state_changed(dev->vid, i, vq->enabled);\n \t}\n@@ -334,9 +375,11 @@ vduse_device_create(const char *path)\n {\n \tint control_fd, dev_fd, vid, ret;\n \tpthread_t fdset_tid;\n-\tuint32_t i;\n+\tuint32_t i, max_queue_pairs, total_queues;\n \tstruct virtio_net *dev;\n+\tstruct virtio_net_config vnet_config = { 0 };\n \tuint64_t ver = VHOST_VDUSE_API_VERSION;\n+\tuint64_t features = VDUSE_NET_SUPPORTED_FEATURES;\n \tstruct vduse_dev_config *dev_config = NULL;\n \tconst char *name = path + strlen(\"/dev/vduse/\");\n \n@@ -376,22 +419,39 @@ vduse_device_create(const char *path)\n \t\tgoto out_ctrl_close;\n \t}\n \n-\tdev_config = malloc(offsetof(struct vduse_dev_config, config));\n+\tdev_config = malloc(offsetof(struct vduse_dev_config, config) +\n+\t\t\tsizeof(vnet_config));\n \tif (!dev_config) {\n \t\tVHOST_LOG_CONFIG(name, ERR, \"Failed to allocate VDUSE config\\n\");\n \t\tret = -1;\n \t\tgoto out_ctrl_close;\n \t}\n \n+\tret = rte_vhost_driver_get_queue_num(path, &max_queue_pairs);\n+\tif (ret < 0) {\n+\t\tVHOST_LOG_CONFIG(name, ERR, \"Failed to get max queue pairs\\n\");\n+\t\tgoto out_free;\n+\t}\n+\n+\tVHOST_LOG_CONFIG(path, INFO, \"VDUSE max queue pairs: %u\\n\", max_queue_pairs);\n+\ttotal_queues = max_queue_pairs * 2;\n+\n+\tif (max_queue_pairs == 1)\n+\t\tfeatures &= ~(RTE_BIT64(VIRTIO_NET_F_CTRL_VQ) | RTE_BIT64(VIRTIO_NET_F_MQ));\n+\telse\n+\t\ttotal_queues += 1; /* Includes ctrl queue */\n+\n+\tvnet_config.max_virtqueue_pairs = max_queue_pairs;\n \tmemset(dev_config, 0, sizeof(struct vduse_dev_config));\n \n \tstrncpy(dev_config->name, name, VDUSE_NAME_MAX - 1);\n \tdev_config->device_id = VIRTIO_ID_NET;\n \tdev_config->vendor_id = 0;\n-\tdev_config->features = VDUSE_NET_SUPPORTED_FEATURES;\n-\tdev_config->vq_num = 2;\n+\tdev_config->features = features;\n+\tdev_config->vq_num = total_queues;\n \tdev_config->vq_align = sysconf(_SC_PAGE_SIZE);\n-\tdev_config->config_size = 0;\n+\tdev_config->config_size = sizeof(struct virtio_net_config);\n+\tmemcpy(dev_config->config, &vnet_config, sizeof(vnet_config));\n \n \tret = ioctl(control_fd, VDUSE_CREATE_DEV, dev_config);\n \tif (ret < 0) {\n@@ -433,7 +493,7 @@ vduse_device_create(const char *path)\n \tdev->vduse_dev_fd = dev_fd;\n \tvhost_setup_virtio_net(dev->vid, true, true, true, true);\n \n-\tfor (i = 0; i < 2; i++) {\n+\tfor (i = 0; i < total_queues; i++) {\n \t\tstruct vduse_vq_config vq_cfg = { 0 };\n \n \t\tret = alloc_vring_queue(dev, i);\n@@ -452,6 +512,8 @@ vduse_device_create(const char *path)\n \t\t}\n \t}\n \n+\tdev->cvq = dev->virtqueue[max_queue_pairs * 2];\n+\n \tret = fdset_add(&vduse.fdset, dev->vduse_dev_fd, vduse_events_handler, NULL, dev);\n \tif (ret) {\n \t\tVHOST_LOG_CONFIG(name, ERR, \"Failed to add fd %d to vduse fdset\\n\",\n@@ -498,6 +560,13 @@ vduse_device_destroy(const char *path)\n \tif (vid == RTE_MAX_VHOST_DEVICE)\n \t\treturn -1;\n \n+\tif (dev->cvq && dev->cvq->kickfd >= 0) {\n+\t\tfdset_del(&vduse.fdset, dev->cvq->kickfd);\n+\t\tfdset_pipe_notify(&vduse.fdset);\n+\t\tclose(dev->cvq->kickfd);\n+\t\tdev->cvq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;\n+\t}\n+\n \tfdset_del(&vduse.fdset, dev->vduse_dev_fd);\n \tfdset_pipe_notify(&vduse.fdset);\n \n",
    "prefixes": [
        "v3",
        "27/28"
    ]
}