get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 77431,
    "url": "http://patches.dpdk.org/api/patches/77431/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200911150805.79901-4-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": "<20200911150805.79901-4-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200911150805.79901-4-maxime.coquelin@redhat.com",
    "date": "2020-09-11T15:08:01",
    "name": "[3/7] net/virtio: introduce Vhost-vDPA backend type",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "56b3ee268bd05a1fa265e018d57bf1e148453500",
    "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/20200911150805.79901-4-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 12149,
            "url": "http://patches.dpdk.org/api/series/12149/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12149",
            "date": "2020-09-11T15:07:58",
            "name": "virtio-user: introduce vhost-vdpa backend",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12149/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/77431/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/77431/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 97A87A04BB;\n\tFri, 11 Sep 2020 17:08:53 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 155ED1C11C;\n\tFri, 11 Sep 2020 17:08:25 +0200 (CEST)",
            "from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com\n [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 9F1D61C10A\n for <dev@dpdk.org>; Fri, 11 Sep 2020 17:08:21 +0200 (CEST)",
            "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-128-3M4KjLSVPZuDlFIqFIQ_PQ-1; Fri, 11 Sep 2020 11:08:19 -0400",
            "from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com\n [10.5.11.23])\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 62FB1801E53;\n Fri, 11 Sep 2020 15:08:18 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.36.110.16])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 1A39E3C89;\n Fri, 11 Sep 2020 15:08:16 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1599836901;\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=w5qwil9EsbcrtNICJvzjCKjKps/MQm2VHK60/brsOwo=;\n b=GA5by83zXYhFdZYIaz4oLAdNF8d1n7IwiXdpnRX/5uBVQoyWSI4buW+NObZ4Pq+Isv60mW\n spXbvTUAY0j1zG5VrbNSnA0kLLtGRJYsRV63CnfWbzePi9PbpLfzmr4QXbvL2h2OEKNpMb\n xfR4jIlaJLTJBML+RxJTnBn+gq7qUyE=",
        "X-MC-Unique": "3M4KjLSVPZuDlFIqFIQ_PQ-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org,\n\tpatrick.fu@intel.com,\n\tamorenoz@redhat.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Fri, 11 Sep 2020 17:08:01 +0200",
        "Message-Id": "<20200911150805.79901-4-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20200911150805.79901-1-maxime.coquelin@redhat.com>",
        "References": "<20200911150805.79901-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.84 on 10.5.11.23",
        "Authentication-Results": "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com",
        "X-Mimecast-Spam-Score": "0.002",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Type": "text/plain; charset=US-ASCII",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH 3/7] net/virtio: introduce Vhost-vDPA backend type",
        "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://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": "Introduce virtio_user_backend_type function and its enum in\norder to support more than two backends with vDPA backend\naddition.\nBackend type is determined by checking the virtio-user control\nfile information at runtime.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nSigned-off-by: Adrian Moreno <amorenoz@redhat.com>\n---\n .../net/virtio/virtio_user/virtio_user_dev.c  | 86 +++++++++++++++----\n .../net/virtio/virtio_user/virtio_user_dev.h  | 10 ++-\n drivers/net/virtio/virtio_user_ethdev.c       |  3 +-\n 3 files changed, 79 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c\nindex 2a0c861085..93274b2a94 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c\n@@ -12,6 +12,8 @@\n #include <sys/eventfd.h>\n #include <sys/types.h>\n #include <sys/stat.h>\n+#include <sys/sysmacros.h>\n+#include <linux/major.h>\n \n #include <rte_string_fns.h>\n #include <rte_eal_memconfig.h>\n@@ -111,15 +113,55 @@ virtio_user_queue_setup(struct virtio_user_dev *dev,\n \treturn 0;\n }\n \n-int\n-is_vhost_user_by_type(const char *path)\n+static uint32_t\n+vdpa_dynamic_major_num(void)\n+{\n+\tFILE *fp;\n+\tchar *line = NULL;\n+\tsize_t size;\n+\tchar name[11];\n+\tbool found = false;\n+\tuint32_t num;\n+\n+\tfp = fopen(\"/proc/devices\", \"r\");\n+\tif (fp == NULL) {\n+\t\tPMD_INIT_LOG(ERR, \"Cannot open /proc/devices: %s\",\n+\t\t\t     strerror(errno));\n+\t\treturn UNNAMED_MAJOR;\n+\t}\n+\n+\twhile (getline(&line, &size, fp) > 0) {\n+\t\tchar *stripped = line + strspn(line, \" \");\n+\t\tif ((sscanf(stripped, \"%u %10s\", &num, name) == 2) &&\n+\t\t    (strncmp(name, \"vhost-vdpa\", 10) == 0)) {\n+\t\t\tfound = true;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tfclose(fp);\n+\treturn found ? num : UNNAMED_MAJOR;\n+}\n+\n+enum virtio_user_backend_type\n+virtio_user_backend_type(const char *path)\n {\n \tstruct stat sb;\n \n-\tif (stat(path, &sb) == -1)\n-\t\treturn 0;\n+\tif (stat(path, &sb) == -1) {\n+\t\tPMD_INIT_LOG(ERR, \"Stat fails: %s (%s)\\n\", path,\n+\t\t\t     strerror(errno));\n+\t\treturn VIRTIO_USER_BACKEND_UNKNOWN;\n+\t}\n \n-\treturn S_ISSOCK(sb.st_mode);\n+\tif (S_ISSOCK(sb.st_mode)) {\n+\t\treturn VIRTIO_USER_BACKEND_VHOST_USER;\n+\t} else if (S_ISCHR(sb.st_mode)) {\n+\t\tif (major(sb.st_rdev) == MISC_MAJOR)\n+\t\t\treturn VIRTIO_USER_BACKEND_VHOST_KERNEL;\n+\t\tif (major(sb.st_rdev) == vdpa_dynamic_major_num())\n+\t\t\treturn VIRTIO_USER_BACKEND_VHOST_VDPA;\n+\t}\n+\treturn VIRTIO_USER_BACKEND_UNKNOWN;\n }\n \n int\n@@ -144,7 +186,8 @@ virtio_user_start_device(struct virtio_user_dev *dev)\n \trte_mcfg_mem_read_lock();\n \tpthread_mutex_lock(&dev->mutex);\n \n-\tif (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0)\n+\tif (virtio_user_backend_type(dev->path) ==\n+\t\tVIRTIO_USER_BACKEND_VHOST_USER && dev->vhostfd < 0)\n \t\tgoto error;\n \n \t/* Step 0: tell vhost to create queues */\n@@ -359,17 +402,19 @@ virtio_user_dev_setup(struct virtio_user_dev *dev)\n \tdev->vhostfds = NULL;\n \tdev->tapfds = NULL;\n \n+\tdev->backend_type = virtio_user_backend_type(dev->path);\n+\n \tif (dev->is_server) {\n-\t\tif (access(dev->path, F_OK) == 0 &&\n-\t\t    !is_vhost_user_by_type(dev->path)) {\n-\t\t\tPMD_DRV_LOG(ERR, \"Server mode doesn't support vhost-kernel!\");\n+\t\tif (dev->backend_type != VIRTIO_USER_BACKEND_VHOST_USER) {\n+\t\t\tPMD_DRV_LOG(ERR, \"Server mode only supports vhost-user!\");\n \t\t\treturn -1;\n \t\t}\n \t\tdev->ops = &virtio_ops_user;\n \t} else {\n-\t\tif (is_vhost_user_by_type(dev->path)) {\n+\t\tif (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER) {\n \t\t\tdev->ops = &virtio_ops_user;\n-\t\t} else {\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@@ -457,7 +502,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\n \t\treturn -1;\n \t}\n \n-\tif (!is_vhost_user_by_type(dev->path))\n+\tif (virtio_user_backend_type(dev->path) !=\n+\t\t\t\t\tVIRTIO_USER_BACKEND_VHOST_USER)\n \t\tdev->unsupported_features |=\n \t\t\t(1ULL << VHOST_USER_F_PROTOCOL_FEATURES);\n \n@@ -505,8 +551,6 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\n \t\tdev->device_features = VIRTIO_USER_SUPPORTED_FEATURES;\n \t}\n \n-\n-\n \tif (!mrg_rxbuf)\n \t\tdev->unsupported_features |= (1ull << VIRTIO_NET_F_MRG_RXBUF);\n \n@@ -539,7 +583,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\n \t}\n \n \t/* The backend will not report this feature, we add it explicitly */\n-\tif (is_vhost_user_by_type(dev->path))\n+\tif (virtio_user_backend_type(dev->path) ==\n+\t\t\t\t\tVIRTIO_USER_BACKEND_VHOST_USER)\n \t\tdev->frontend_features |= (1ull << VIRTIO_NET_F_STATUS);\n \n \t/*\n@@ -790,9 +835,11 @@ virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t status)\n {\n \tint ret;\n \tuint64_t arg = status;\n+\tenum virtio_user_backend_type backend_type =\n+\t\t\t\tvirtio_user_backend_type(dev->path);\n \n \t/* Vhost-user only for now */\n-\tif (!is_vhost_user_by_type(dev->path))\n+\tif (backend_type != VIRTIO_USER_BACKEND_VHOST_USER)\n \t\treturn 0;\n \n \tif (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_STATUS)))\n@@ -813,9 +860,11 @@ virtio_user_update_status(struct virtio_user_dev *dev)\n {\n \tuint64_t ret;\n \tint err;\n+\tenum virtio_user_backend_type backend_type =\n+\t\t\t\tvirtio_user_backend_type(dev->path);\n \n \t/* Vhost-user only for now */\n-\tif (!is_vhost_user_by_type(dev->path))\n+\tif (backend_type != VIRTIO_USER_BACKEND_VHOST_USER)\n \t\treturn 0;\n \n \tif (!(dev->protocol_features & (1UL << VHOST_USER_PROTOCOL_F_STATUS)))\n@@ -828,7 +877,8 @@ virtio_user_update_status(struct virtio_user_dev *dev)\n \t\treturn -1;\n \t}\n \tif (ret > UINT8_MAX) {\n-\t\tPMD_INIT_LOG(ERR, \"Invalid VHOST_USER_GET_STATUS response 0x%\" PRIx64 \"\\n\", ret);\n+\t\tPMD_INIT_LOG(ERR, \"Invalid VHOST_USER_GET_STATUS \"\n+\t\t\t\t\"response 0x%\" PRIx64 \"\\n\", ret);\n \t\treturn -1;\n \t}\n \ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h\nindex 9377d5ba66..4bb7cdbd26 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h\n@@ -10,6 +10,13 @@\n #include \"../virtio_pci.h\"\n #include \"../virtio_ring.h\"\n \n+enum virtio_user_backend_type {\n+\tVIRTIO_USER_BACKEND_UNKNOWN,\n+\tVIRTIO_USER_BACKEND_VHOST_USER,\n+\tVIRTIO_USER_BACKEND_VHOST_KERNEL,\n+\tVIRTIO_USER_BACKEND_VHOST_VDPA,\n+};\n+\n struct virtio_user_queue {\n \tuint16_t used_idx;\n \tbool avail_wrap_counter;\n@@ -17,6 +24,7 @@ struct virtio_user_queue {\n };\n \n struct virtio_user_dev {\n+\tenum virtio_user_backend_type backend_type;\n \t/* for vhost_user backend */\n \tint\t\tvhostfd;\n \tint\t\tlistenfd;   /* listening fd */\n@@ -60,7 +68,7 @@ struct virtio_user_dev {\n \tbool\t\tstarted;\n };\n \n-int is_vhost_user_by_type(const char *path);\n+enum virtio_user_backend_type virtio_user_backend_type(const char *path);\n int virtio_user_start_device(struct virtio_user_dev *dev);\n int virtio_user_stop_device(struct virtio_user_dev *dev);\n int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,\ndiff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c\nindex 60d17af888..2163d0e30d 100644\n--- a/drivers/net/virtio/virtio_user_ethdev.c\n+++ b/drivers/net/virtio/virtio_user_ethdev.c\n@@ -632,7 +632,8 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)\n \t}\n \n \tif (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_INTERFACE_NAME) == 1) {\n-\t\tif (is_vhost_user_by_type(path)) {\n+\t\tif (virtio_user_backend_type(path) !=\n+\t\t\t\tVIRTIO_USER_BACKEND_VHOST_KERNEL) {\n \t\t\tPMD_INIT_LOG(ERR,\n \t\t\t\t\"arg %s applies only to vhost-kernel backend\",\n \t\t\t\tVIRTIO_USER_ARG_INTERFACE_NAME);\n",
    "prefixes": [
        "3/7"
    ]
}