get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 120379,
    "url": "https://patches.dpdk.org/api/patches/120379/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20221130155639.150553-22-maxime.coquelin@redhat.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20221130155639.150553-22-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221130155639.150553-22-maxime.coquelin@redhat.com",
    "date": "2022-11-30T15:56:39",
    "name": "[v1,21/21] net/virtio-user: remove max queues limitation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f94655ce5b7046cb1bec7a66cd0a064ea5f8dbe0",
    "submitter": {
        "id": 512,
        "url": "https://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "https://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20221130155639.150553-22-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 25958,
            "url": "https://patches.dpdk.org/api/series/25958/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=25958",
            "date": "2022-11-30T15:56:18",
            "name": "Add control queue & MQ support to Virtio-user vDPA",
            "version": 1,
            "mbox": "https://patches.dpdk.org/series/25958/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/120379/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/120379/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 79625A00C2;\n\tWed, 30 Nov 2022 16:59:12 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 780F240693;\n\tWed, 30 Nov 2022 16:57:24 +0100 (CET)",
            "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 93FED42D78\n for <dev@dpdk.org>; Wed, 30 Nov 2022 16:57:21 +0100 (CET)",
            "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-571-zrWpunDGMoKm-Sdfh9Si2w-1; Wed, 30 Nov 2022 10:57:19 -0500",
            "from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com\n [10.11.54.1])\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 0A7873C0E45D;\n Wed, 30 Nov 2022 15:57:19 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.39.208.22])\n by smtp.corp.redhat.com (Postfix) with ESMTP id DC74D40C83D9;\n Wed, 30 Nov 2022 15:57:17 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1669823841;\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=ilBgn6WyLwEOyvbF6J5Zef5rZG8UwOvFDR575inuDfA=;\n b=KZnKnJHOzJmuF8A3bE0OYELk94USeDbpLqD8mz2GIri6i37fxdmok2kS50GZwFTmKO0Osw\n 1R4XuJReosidSnvL6DWuQiL1LHatup04e9fHtHH8mp8/XVoLMP8BJzI7cqj+zR9zbyLYfQ\n GZla62SCm+ZVGNizb6FINHQ6bwyChG4=",
        "X-MC-Unique": "zrWpunDGMoKm-Sdfh9Si2w-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com,\n eperezma@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Subject": "[PATCH v1 21/21] net/virtio-user: remove max queues limitation",
        "Date": "Wed, 30 Nov 2022 16:56:39 +0100",
        "Message-Id": "<20221130155639.150553-22-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20221130155639.150553-1-maxime.coquelin@redhat.com>",
        "References": "<20221130155639.150553-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.1 on 10.11.54.1",
        "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 removes the limitation of 8 queue pairs by\ndynamically allocating vring metadata once we know the\nmaximum number of queue pairs supported by the backend.\n\nThis is especially useful for Vhost-vDPA with physical\ndevices, where the maximum queues supported may be much\nmore than 8 pairs.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n drivers/net/virtio/virtio.h                   |   6 -\n .../net/virtio/virtio_user/virtio_user_dev.c  | 118 ++++++++++++++----\n .../net/virtio/virtio_user/virtio_user_dev.h  |  16 +--\n drivers/net/virtio/virtio_user_ethdev.c       |  17 +--\n 4 files changed, 109 insertions(+), 48 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h\nindex 5c8f71a44d..04a897bf51 100644\n--- a/drivers/net/virtio/virtio.h\n+++ b/drivers/net/virtio/virtio.h\n@@ -124,12 +124,6 @@\n \tVIRTIO_NET_HASH_TYPE_UDP_EX)\n \n \n-/*\n- * Maximum number of virtqueues per device.\n- */\n-#define VIRTIO_MAX_VIRTQUEUE_PAIRS 8\n-#define VIRTIO_MAX_VIRTQUEUES (VIRTIO_MAX_VIRTQUEUE_PAIRS * 2 + 1)\n-\n /* VirtIO device IDs. */\n #define VIRTIO_ID_NETWORK  0x01\n #define VIRTIO_ID_BLOCK    0x02\ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c\nindex 7c48c9bb29..aa24fdea70 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c\n@@ -17,6 +17,7 @@\n #include <rte_alarm.h>\n #include <rte_string_fns.h>\n #include <rte_eal_memconfig.h>\n+#include <rte_malloc.h>\n \n #include \"vhost.h\"\n #include \"virtio_user_dev.h\"\n@@ -58,8 +59,8 @@ virtio_user_kick_queue(struct virtio_user_dev *dev, uint32_t queue_sel)\n \tint ret;\n \tstruct vhost_vring_file file;\n \tstruct vhost_vring_state state;\n-\tstruct vring *vring = &dev->vrings[queue_sel];\n-\tstruct vring_packed *pq_vring = &dev->packed_vrings[queue_sel];\n+\tstruct vring *vring = &dev->vrings.split[queue_sel];\n+\tstruct vring_packed *pq_vring = &dev->vrings.packed[queue_sel];\n \tstruct vhost_vring_addr addr = {\n \t\t.index = queue_sel,\n \t\t.log_guest_addr = 0,\n@@ -299,18 +300,6 @@ virtio_user_dev_init_max_queue_pairs(struct virtio_user_dev *dev, uint32_t user_\n \t\treturn ret;\n \t}\n \n-\tif (dev->max_queue_pairs > VIRTIO_MAX_VIRTQUEUE_PAIRS) {\n-\t\t/*\n-\t\t * If the device supports control queue, the control queue\n-\t\t * index is max_virtqueue_pairs * 2. Disable MQ if it happens.\n-\t\t */\n-\t\tPMD_DRV_LOG(ERR, \"(%s) Device advertises too many queues (%u, max supported %u)\",\n-\t\t\t\tdev->path, dev->max_queue_pairs, VIRTIO_MAX_VIRTQUEUE_PAIRS);\n-\t\tdev->max_queue_pairs = 1;\n-\n-\t\treturn -1;\n-\t}\n-\n \treturn 0;\n }\n \n@@ -579,6 +568,86 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)\n \treturn 0;\n }\n \n+static int\n+virtio_user_alloc_vrings(struct virtio_user_dev *dev)\n+{\n+\tint i, size, nr_vrings;\n+\n+\tnr_vrings = dev->max_queue_pairs * 2;\n+\tif (dev->hw_cvq)\n+\t\tnr_vrings++;\n+\n+\tdev->callfds = rte_zmalloc(\"virtio_user_dev\", nr_vrings * sizeof(*dev->callfds), 0);\n+\tif (!dev->callfds) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to alloc callfds\", dev->path);\n+\t\treturn -1;\n+\t}\n+\n+\tdev->kickfds = rte_zmalloc(\"virtio_user_dev\", nr_vrings * sizeof(*dev->kickfds), 0);\n+\tif (!dev->kickfds) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to alloc kickfds\", dev->path);\n+\t\tgoto free_callfds;\n+\t}\n+\n+\tfor (i = 0; i < nr_vrings; i++) {\n+\t\tdev->callfds[i] = -1;\n+\t\tdev->kickfds[i] = -1;\n+\t}\n+\n+\tsize = RTE_MAX(sizeof(*dev->vrings.split), sizeof(*dev->vrings.packed));\n+\tdev->vrings.ptr = rte_zmalloc(\"virtio_user_dev\", nr_vrings * size, 0);\n+\tif (!dev->vrings.ptr) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to alloc vrings metadata\", dev->path);\n+\t\tgoto free_kickfds;\n+\t}\n+\n+\tdev->packed_queues = rte_zmalloc(\"virtio_user_dev\",\n+\t\t\tnr_vrings * sizeof(*dev->packed_queues), 0);\n+\tif (!dev->packed_queues) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to alloc packed queues metadata\", dev->path);\n+\t\tgoto free_vrings;\n+\t}\n+\n+\tdev->qp_enabled = rte_zmalloc(\"virtio_user_dev\",\n+\t\t\tdev->max_queue_pairs * sizeof(*dev->qp_enabled), 0);\n+\tif (!dev->qp_enabled) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to alloc QP enable states\", dev->path);\n+\t\tgoto free_packed_queues;\n+\t}\n+\n+\treturn 0;\n+\n+free_packed_queues:\n+\trte_free(dev->packed_queues);\n+\tdev->packed_queues = NULL;\n+free_vrings:\n+\trte_free(dev->vrings.ptr);\n+\tdev->vrings.ptr = NULL;\n+free_kickfds:\n+\trte_free(dev->kickfds);\n+\tdev->kickfds = NULL;\n+free_callfds:\n+\trte_free(dev->callfds);\n+\tdev->callfds = NULL;\n+\n+\treturn -1;\n+}\n+\n+static void\n+virtio_user_free_vrings(struct virtio_user_dev *dev)\n+{\n+\trte_free(dev->qp_enabled);\n+\tdev->qp_enabled = NULL;\n+\trte_free(dev->packed_queues);\n+\tdev->packed_queues = NULL;\n+\trte_free(dev->vrings.ptr);\n+\tdev->vrings.ptr = NULL;\n+\trte_free(dev->kickfds);\n+\tdev->kickfds = NULL;\n+\trte_free(dev->callfds);\n+\tdev->callfds = NULL;\n+}\n+\n /* Use below macro to filter features from vhost backend */\n #define VIRTIO_USER_SUPPORTED_FEATURES\t\t\t\\\n \t(1ULL << VIRTIO_NET_F_MAC\t\t|\t\\\n@@ -607,16 +676,10 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,\n \t\t     enum virtio_user_backend_type backend_type)\n {\n \tuint64_t backend_features;\n-\tint i;\n \n \tpthread_mutex_init(&dev->mutex, NULL);\n \tstrlcpy(dev->path, path, PATH_MAX);\n \n-\tfor (i = 0; i < VIRTIO_MAX_VIRTQUEUES; i++) {\n-\t\tdev->kickfds[i] = -1;\n-\t\tdev->callfds[i] = -1;\n-\t}\n-\n \tdev->started = 0;\n \tdev->queue_pairs = 1; /* mq disabled by default */\n \tdev->queue_size = queue_size;\n@@ -661,9 +724,14 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,\n \tif (dev->max_queue_pairs > 1)\n \t\tcq = 1;\n \n+\tif (virtio_user_alloc_vrings(dev) < 0) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to allocate vring metadata\", dev->path);\n+\t\tgoto destroy;\n+\t}\n+\n \tif (virtio_user_dev_init_notify(dev) < 0) {\n \t\tPMD_INIT_LOG(ERR, \"(%s) Failed to init notifiers\", dev->path);\n-\t\tgoto destroy;\n+\t\tgoto free_vrings;\n \t}\n \n \tif (virtio_user_fill_intr_handle(dev) < 0) {\n@@ -722,6 +790,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,\n \n notify_uninit:\n \tvirtio_user_dev_uninit_notify(dev);\n+free_vrings:\n+\tvirtio_user_free_vrings(dev);\n destroy:\n \tdev->ops->destroy(dev);\n \n@@ -742,6 +812,8 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)\n \n \tvirtio_user_dev_uninit_notify(dev);\n \n+\tvirtio_user_free_vrings(dev);\n+\n \tfree(dev->ifname);\n \n \tif (dev->is_server)\n@@ -897,7 +969,7 @@ static void\n virtio_user_handle_cq_packed(struct virtio_user_dev *dev, uint16_t queue_idx)\n {\n \tstruct virtio_user_queue *vq = &dev->packed_queues[queue_idx];\n-\tstruct vring_packed *vring = &dev->packed_vrings[queue_idx];\n+\tstruct vring_packed *vring = &dev->vrings.packed[queue_idx];\n \tuint16_t n_descs, flags;\n \n \t/* Perform a load-acquire barrier in desc_is_avail to\n@@ -931,7 +1003,7 @@ virtio_user_handle_cq_split(struct virtio_user_dev *dev, uint16_t queue_idx)\n \tuint16_t avail_idx, desc_idx;\n \tstruct vring_used_elem *uep;\n \tuint32_t n_descs;\n-\tstruct vring *vring = &dev->vrings[queue_idx];\n+\tstruct vring *vring = &dev->vrings.split[queue_idx];\n \n \t/* Consume avail ring, using used ring idx as first one */\n \twhile (__atomic_load_n(&vring->used->idx, __ATOMIC_RELAXED)\ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h\nindex e8753f6019..7323d88302 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h\n@@ -29,8 +29,8 @@ struct virtio_user_dev {\n \tenum virtio_user_backend_type backend_type;\n \tbool\t\tis_server;  /* server or client mode */\n \n-\tint\t\tcallfds[VIRTIO_MAX_VIRTQUEUES];\n-\tint\t\tkickfds[VIRTIO_MAX_VIRTQUEUES];\n+\tint\t\t*callfds;\n+\tint\t\t*kickfds;\n \tint\t\tmac_specified;\n \tuint16_t\tmax_queue_pairs;\n \tuint16_t\tqueue_pairs;\n@@ -48,11 +48,13 @@ struct virtio_user_dev {\n \tchar\t\t*ifname;\n \n \tunion {\n-\t\tstruct vring\t\tvrings[VIRTIO_MAX_VIRTQUEUES];\n-\t\tstruct vring_packed\tpacked_vrings[VIRTIO_MAX_VIRTQUEUES];\n-\t};\n-\tstruct virtio_user_queue packed_queues[VIRTIO_MAX_VIRTQUEUES];\n-\tbool\t\tqp_enabled[VIRTIO_MAX_VIRTQUEUE_PAIRS];\n+\t\tvoid\t\t\t*ptr;\n+\t\tstruct vring\t\t*split;\n+\t\tstruct vring_packed\t*packed;\n+\t} vrings;\n+\n+\tstruct virtio_user_queue *packed_queues;\n+\tbool\t\t*qp_enabled;\n \n \tstruct virtio_user_backend_ops *ops;\n \tpthread_mutex_t\tmutex;\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex d23959e836..b1fc4d5d30 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -186,7 +186,7 @@ virtio_user_setup_queue_packed(struct virtqueue *vq,\n \tuint64_t used_addr;\n \tuint16_t i;\n \n-\tvring  = &dev->packed_vrings[queue_idx];\n+\tvring  = &dev->vrings.packed[queue_idx];\n \tdesc_addr = (uintptr_t)vq->vq_ring_virt_mem;\n \tavail_addr = desc_addr + vq->vq_nentries *\n \t\tsizeof(struct vring_packed_desc);\n@@ -216,10 +216,10 @@ virtio_user_setup_queue_split(struct virtqueue *vq, struct virtio_user_dev *dev)\n \t\t\t\t\t\t\t ring[vq->vq_nentries]),\n \t\t\t\t   VIRTIO_VRING_ALIGN);\n \n-\tdev->vrings[queue_idx].num = vq->vq_nentries;\n-\tdev->vrings[queue_idx].desc = (void *)(uintptr_t)desc_addr;\n-\tdev->vrings[queue_idx].avail = (void *)(uintptr_t)avail_addr;\n-\tdev->vrings[queue_idx].used = (void *)(uintptr_t)used_addr;\n+\tdev->vrings.split[queue_idx].num = vq->vq_nentries;\n+\tdev->vrings.split[queue_idx].desc = (void *)(uintptr_t)desc_addr;\n+\tdev->vrings.split[queue_idx].avail = (void *)(uintptr_t)avail_addr;\n+\tdev->vrings.split[queue_idx].used = (void *)(uintptr_t)used_addr;\n }\n \n static int\n@@ -619,13 +619,6 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev)\n \t\t}\n \t}\n \n-\tif (queues > VIRTIO_MAX_VIRTQUEUE_PAIRS) {\n-\t\tPMD_INIT_LOG(ERR, \"arg %s %\" PRIu64 \" exceeds the limit %u\",\n-\t\t\tVIRTIO_USER_ARG_QUEUES_NUM, queues,\n-\t\t\tVIRTIO_MAX_VIRTQUEUE_PAIRS);\n-\t\tgoto end;\n-\t}\n-\n \tif (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_MRG_RXBUF) == 1) {\n \t\tif (rte_kvargs_process(kvlist, VIRTIO_USER_ARG_MRG_RXBUF,\n \t\t\t\t       &get_integer_arg, &mrg_rxbuf) < 0) {\n",
    "prefixes": [
        "v1",
        "21/21"
    ]
}