get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 86933,
    "url": "https://patches.dpdk.org/api/patches/86933/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210119212507.1043636-38-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": "<20210119212507.1043636-38-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210119212507.1043636-38-maxime.coquelin@redhat.com",
    "date": "2021-01-19T21:25:00",
    "name": "[v2,37/44] net/virtio: make server mode blocking",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "840cef5d65f3638825eb0a34d206e4de7da4209b",
    "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/20210119212507.1043636-38-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 14852,
            "url": "https://patches.dpdk.org/api/series/14852/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=14852",
            "date": "2021-01-19T21:24:23",
            "name": "net/virtio: Virtio PMD rework",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/14852/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/86933/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/86933/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 15F18A0A06;\n\tTue, 19 Jan 2021 22:30:53 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 50FFE140FCB;\n\tTue, 19 Jan 2021 22:28:21 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [216.205.24.124])\n by mails.dpdk.org (Postfix) with ESMTP id E7E56140FB7\n for <dev@dpdk.org>; Tue, 19 Jan 2021 22:28:19 +0100 (CET)",
            "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-469-Zc3SyFXCObub7qkkXZ2zqA-1; Tue, 19 Jan 2021 16:28:17 -0500",
            "from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com\n [10.5.11.14])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49C81A0CA2;\n Tue, 19 Jan 2021 21:28:16 +0000 (UTC)",
            "from max-t490s.redhat.com (unknown [10.36.110.29])\n by smtp.corp.redhat.com (Postfix) with ESMTP id D6B9A5D9E2;\n Tue, 19 Jan 2021 21:28:14 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1611091699;\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=SwJb0dn65bpwiqbAO+NK0iwk2oDCRnp5wWXpRVdOP20=;\n b=aS2NnB7U+X700ywo4OwoKQKr2bKkryXHGnFfZ49DMrlVdOcEOPnQ4JGP5vABluHc6mJ/oT\n i2R6NOc/u5dB/6Ls2WzhZKZOgxtKfWbkmsmtWXTVn8OtDfDDWWMxZnu+avuhs9ZTj8w1KD\n 8ynqIleXrO3dzveZ1I3/x4eIligLbsA=",
        "X-MC-Unique": "Zc3SyFXCObub7qkkXZ2zqA-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com,\n amorenoz@redhat.com, david.marchand@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Tue, 19 Jan 2021 22:25:00 +0100",
        "Message-Id": "<20210119212507.1043636-38-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20210119212507.1043636-1-maxime.coquelin@redhat.com>",
        "References": "<20210119212507.1043636-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.14",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"",
        "Subject": "[dpdk-dev] [PATCH v2 37/44] net/virtio: make server mode blocking",
        "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": "This patch makes the Vhost-user backend server mode\nblocking at init, waiting for the client connection.\n\nThe goal is to make the driver more reliable, as without\nwaiting for client connection, the Virtio driver has to\nassume the Vhost-user backend will support all the\nfeatures it has advertized, which could lead to undefined\nbehaviour.\n\nFor example, without this patch, if the user enables packed\nring Virtio feature but the backend does not support it,\nthe ring initialized by the driver will not be compatible\nwith the backend.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n drivers/net/virtio/virtio_user/vhost_user.c   |   9 +-\n .../net/virtio/virtio_user/virtio_user_dev.c  | 121 +++++++-----------\n drivers/net/virtio/virtio_user_ethdev.c       |   5 -\n 3 files changed, 55 insertions(+), 80 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c\nindex fb6fcc82c9..a48fadd8c9 100644\n--- a/drivers/net/virtio/virtio_user/vhost_user.c\n+++ b/drivers/net/virtio/virtio_user/vhost_user.c\n@@ -692,6 +692,14 @@ virtio_user_start_server(struct virtio_user_dev *dev, struct sockaddr_un *un)\n \tif (ret < 0)\n \t\treturn -1;\n \n+\tPMD_DRV_LOG(NOTICE, \"(%s) waiting for client connection...\", dev->path);\n+\tdev->vhostfd = accept(fd, NULL, NULL);\n+\tif (dev->vhostfd < 0) {\n+\t\tPMD_DRV_LOG(ERR, \"Failed to accept initial client connection (%s)\",\n+\t\t\t\tstrerror(errno));\n+\t\treturn -1;\n+\t}\n+\n \tflag = fcntl(fd, F_GETFL);\n \tif (fcntl(fd, F_SETFL, flag | O_NONBLOCK) < 0) {\n \t\tPMD_DRV_LOG(ERR, \"fcntl failed, %s\", strerror(errno));\n@@ -736,7 +744,6 @@ vhost_user_setup(struct virtio_user_dev *dev)\n \t\t\tclose(fd);\n \t\t\treturn -1;\n \t\t}\n-\t\tdev->vhostfd = -1;\n \t} else {\n \t\tif (connect(fd, (struct sockaddr *)&un, sizeof(un)) < 0) {\n \t\t\tPMD_DRV_LOG(ERR, \"connect error, %s\", strerror(errno));\ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c\nindex 95204ea955..c2a41fe3a0 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c\n@@ -144,10 +144,6 @@ virtio_user_dev_set_features(struct virtio_user_dev *dev)\n \n \tpthread_mutex_lock(&dev->mutex);\n \n-\tif (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER &&\n-\t\t\tdev->vhostfd < 0)\n-\t\tgoto error;\n-\n \t/* Step 0: tell vhost to create queues */\n \tif (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)\n \t\tgoto error;\n@@ -190,11 +186,6 @@ virtio_user_start_device(struct virtio_user_dev *dev)\n \trte_mcfg_mem_read_lock();\n \tpthread_mutex_lock(&dev->mutex);\n \n-\t/* Vhost-user client not connected yet, will start later */\n-\tif (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER &&\n-\t\t\tdev->vhostfd < 0)\n-\t\tgoto out;\n-\n \t/* Step 2: share memory regions */\n \tret = dev->ops->set_memory_table(dev);\n \tif (ret < 0)\n@@ -213,7 +204,7 @@ virtio_user_start_device(struct virtio_user_dev *dev)\n \t\tgoto error;\n \n \tdev->started = true;\n-out:\n+\n \tpthread_mutex_unlock(&dev->mutex);\n \trte_mcfg_mem_read_unlock();\n \n@@ -422,36 +413,36 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)\n \t\t\tPMD_DRV_LOG(ERR, \"Server mode only supports vhost-user!\");\n \t\t\treturn -1;\n \t\t}\n+\t}\n+\n+\tif (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) {\n \t\tdev->ops = &virtio_ops_user;\n-\t} else {\n-\t\tif (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) {\n-\t\t\tdev->ops = &virtio_ops_user;\n-\t\t} else if (dev->backend_type ==\n-\t\t\t\t\tVIRTIO_USER_BACKEND_VHOST_KERNEL) {\n-\t\t\tdev->ops = &virtio_ops_kernel;\n-\n-\t\t\tdev->vhostfds = malloc(dev->max_queue_pairs *\n-\t\t\t\t\t       sizeof(int));\n-\t\t\tdev->tapfds = malloc(dev->max_queue_pairs *\n-\t\t\t\t\t     sizeof(int));\n-\t\t\tif (!dev->vhostfds || !dev->tapfds) {\n-\t\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to allocate FDs\", dev->path);\n-\t\t\t\treturn -1;\n-\t\t\t}\n-\n-\t\t\tfor (q = 0; q < dev->max_queue_pairs; ++q) {\n-\t\t\t\tdev->vhostfds[q] = -1;\n-\t\t\t\tdev->tapfds[q] = -1;\n-\t\t\t}\n-\t\t} else if (dev->backend_type ==\n-\t\t\t\tVIRTIO_USER_BACKEND_VHOST_VDPA) {\n-\t\t\tdev->ops = &virtio_ops_vdpa;\n-\t\t} else {\n-\t\t\tPMD_DRV_LOG(ERR, \"(%s) Unknown backend type\", dev->path);\n+\t} else if (dev->backend_type ==\n+\t\t\tVIRTIO_USER_BACKEND_VHOST_KERNEL) {\n+\t\tdev->ops = &virtio_ops_kernel;\n+\n+\t\tdev->vhostfds = malloc(dev->max_queue_pairs *\n+\t\t\t\tsizeof(int));\n+\t\tdev->tapfds = malloc(dev->max_queue_pairs *\n+\t\t\t\tsizeof(int));\n+\t\tif (!dev->vhostfds || !dev->tapfds) {\n+\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to allocate FDs\", dev->path);\n \t\t\treturn -1;\n \t\t}\n+\n+\t\tfor (q = 0; q < dev->max_queue_pairs; ++q) {\n+\t\t\tdev->vhostfds[q] = -1;\n+\t\t\tdev->tapfds[q] = -1;\n+\t\t}\n+\t} else if (dev->backend_type ==\n+\t\t\tVIRTIO_USER_BACKEND_VHOST_VDPA) {\n+\t\tdev->ops = &virtio_ops_vdpa;\n+\t} else {\n+\t\tPMD_DRV_LOG(ERR, \"(%s) Unknown backend type\", dev->path);\n+\t\treturn -1;\n \t}\n \n+\n \tif (dev->ops->setup(dev) < 0) {\n \t\tPMD_INIT_LOG(ERR, \"(%s) Failed to setup backend\\n\", dev->path);\n \t\treturn -1;\n@@ -541,54 +532,36 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\n \t\tdev->unsupported_features |=\n \t\t\t(1ULL << VHOST_USER_F_PROTOCOL_FEATURES);\n \n-\tif (!dev->is_server) {\n-\t\tif (dev->ops->set_owner(dev) < 0) {\n-\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to set backend owner\", dev->path);\n-\t\t\treturn -1;\n-\t\t}\n+\tif (dev->ops->set_owner(dev) < 0) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to set backend owner\", dev->path);\n+\t\treturn -1;\n+\t}\n+\n+\tif (dev->ops->get_features(dev, &dev->device_features) < 0) {\n+\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to get backend features\", dev->path);\n+\t\treturn -1;\n+\t}\n \n-\t\tif (dev->ops->get_features(dev, &dev->device_features) < 0) {\n-\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to get backend features\", dev->path);\n+\tif ((dev->device_features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) ||\n+\t\t\tdev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA) {\n+\t\tif (dev->ops->get_protocol_features(dev, &protocol_features)) {\n+\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to get backend protocol features\",\n+\t\t\t\t\tdev->path);\n \t\t\treturn -1;\n \t\t}\n \n+\t\tdev->protocol_features &= protocol_features;\n \n-\t\tif ((dev->device_features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) ||\n-\t\t\t\t(dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)) {\n-\t\t\tif (dev->ops->get_protocol_features(dev, &protocol_features)) {\n-\t\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to get backend protocol features\",\n-\t\t\t\t\t\tdev->path);\n-\t\t\t\treturn -1;\n-\t\t\t}\n-\n-\t\t\tdev->protocol_features &= protocol_features;\n-\n-\t\t\tif (dev->ops->set_protocol_features(dev, dev->protocol_features)) {\n-\t\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to set backend protocol features\",\n-\t\t\t\t\t\tdev->path);\n-\t\t\t\treturn -1;\n-\t\t\t}\n-\n-\t\t\tif (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)))\n-\t\t\t\tdev->unsupported_features |= (1ull << VIRTIO_NET_F_MQ);\n+\t\tif (dev->ops->set_protocol_features(dev, dev->protocol_features)) {\n+\t\t\tPMD_INIT_LOG(ERR, \"(%s) Failed to set backend protocol features\",\n+\t\t\t\t\tdev->path);\n+\t\t\treturn -1;\n \t\t}\n-\t} else {\n-\t\t/* We just pretend vhost-user can support all these features.\n-\t\t * Note that this could be problematic that if some feature is\n-\t\t * negotiated but not supported by the vhost-user which comes\n-\t\t * later.\n-\t\t */\n-\t\tdev->device_features = VIRTIO_USER_SUPPORTED_FEATURES;\n \n-\t\t/* We cannot assume VHOST_USER_PROTOCOL_F_STATUS is supported\n-\t\t * until it's negotiated\n-\t\t */\n-\t\tdev->protocol_features &=\n-\t\t\t~(1ULL << VHOST_USER_PROTOCOL_F_STATUS);\n+\t\tif (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)))\n+\t\t\tdev->unsupported_features |= (1ull << VIRTIO_NET_F_MQ);\n \t}\n \n-\n-\n \tif (!mrg_rxbuf)\n \t\tdev->unsupported_features |= (1ull << VIRTIO_NET_F_MRG_RXBUF);\n \ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex 5e256f4e6d..e822d93690 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -174,11 +174,6 @@ virtio_user_delayed_handler(void *param)\n \t\tif (dev->vhostfd >= 0) {\n \t\t\tclose(dev->vhostfd);\n \t\t\tdev->vhostfd = -1;\n-\t\t\t/* Until the featuers are negotiated again, don't assume\n-\t\t\t * the backend supports VHOST_USER_PROTOCOL_F_STATUS\n-\t\t\t */\n-\t\t\tdev->protocol_features &=\n-\t\t\t\t~(1ULL << VHOST_USER_PROTOCOL_F_STATUS);\n \t\t}\n \t\teth_dev->intr_handle->fd = dev->listenfd;\n \t\trte_intr_callback_register(eth_dev->intr_handle,\n",
    "prefixes": [
        "v2",
        "37/44"
    ]
}