get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 71293,
    "url": "http://patches.dpdk.org/api/patches/71293/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200611213748.1967029-8-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": "<20200611213748.1967029-8-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200611213748.1967029-8-maxime.coquelin@redhat.com",
    "date": "2020-06-11T21:37:41",
    "name": "[07/14] vhost: replace device ID in applications",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "dc394165844e0c202c14b3851a550418fc6323fc",
    "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/20200611213748.1967029-8-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 10421,
            "url": "http://patches.dpdk.org/api/series/10421/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=10421",
            "date": "2020-06-11T21:37:34",
            "name": "vDPA API and framework rework",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/10421/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/71293/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/71293/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 5F0D7A00BE;\n\tThu, 11 Jun 2020 23:38:59 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D8D8011A4;\n\tThu, 11 Jun 2020 23:38:36 +0200 (CEST)",
            "from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com\n [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 616951023\n for <dev@dpdk.org>; Thu, 11 Jun 2020 23:38:35 +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-138-qbx46W_WNRqbskD8r-kGRA-1; Thu, 11 Jun 2020 17:38:33 -0400",
            "from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com\n [10.5.11.22])\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 96ADD1005512;\n Thu, 11 Jun 2020 21:38:31 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.36.110.37])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 667841001B0B;\n Thu, 11 Jun 2020 21:38:28 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1591911514;\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=lk1eI29bTrKtrIJtv+rkI2NVjn1lin6XFmILXfF/UPk=;\n b=SDi+87rDuOtypUltXmTGdoMqsCPzO0STtvXTV+5l9YaRUDTtODBMMcr/Iq3vfVMcMRFuyy\n 6bJIN0r5PYbEA3HW1CYJkdkMYr2f7cw5vqXr4+ipS5NK2g6vy8bVV/ioybMDmvU7RfczWq\n leWik18TVHEOpRljP+QpESB3rnPq73M=",
        "X-MC-Unique": "qbx46W_WNRqbskD8r-kGRA-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, matan@mellanox.com, xiao.w.wang@intel.com,\n zhihong.wang@intel.com, xiaolong.ye@intel.com, chenbo.xia@intel.com,\n david.marchand@redhat.com, amorenoz@redhat.com, shreyansh.jain@nxp.com,\n viacheslavo@mellanox.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Thu, 11 Jun 2020 23:37:41 +0200",
        "Message-Id": "<20200611213748.1967029-8-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20200611213748.1967029-1-maxime.coquelin@redhat.com>",
        "References": "<20200611213748.1967029-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.84 on 10.5.11.22",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Type": "text/plain; charset=US-ASCII",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH 07/14] vhost: replace device ID in applications",
        "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": "This patch replaces the use of vDPA device ID with\nvDPA device pointer. The goals is to remove the vDPA\ndevice ID to avoid condusion with the Vhost ID.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n examples/vdpa/main.c                   | 79 +++++++++++++-------------\n lib/librte_vhost/rte_vdpa.h            | 21 ++++++-\n lib/librte_vhost/rte_vhost_version.map |  3 +-\n lib/librte_vhost/vdpa.c                | 19 +++++--\n 4 files changed, 75 insertions(+), 47 deletions(-)",
    "diff": "diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c\nindex 8d707c9e2d..4417500d9b 100644\n--- a/examples/vdpa/main.c\n+++ b/examples/vdpa/main.c\n@@ -26,7 +26,7 @@\n \n struct vdpa_port {\n \tchar ifname[MAX_PATH_LEN];\n-\tint did;\n+\tstruct rte_vdpa_device *dev;\n \tint vid;\n \tuint64_t flags;\n };\n@@ -101,16 +101,23 @@ static int\n new_device(int vid)\n {\n \tchar ifname[MAX_PATH_LEN];\n+\tstruct rte_device *dev;\n \tint i;\n \n \trte_vhost_get_ifname(vid, ifname, sizeof(ifname));\n \tfor (i = 0; i < MAX_VDPA_SAMPLE_PORTS; i++) {\n-\t\tif (strncmp(ifname, vports[i].ifname, MAX_PATH_LEN) == 0) {\n-\t\t\tprintf(\"\\nnew port %s, did: %d\\n\",\n-\t\t\t\t\tifname, vports[i].did);\n-\t\t\tvports[i].vid = vid;\n-\t\t\tbreak;\n+\t\tif (strncmp(ifname, vports[i].ifname, MAX_PATH_LEN))\n+\t\t\tcontinue;\n+\n+\t\tdev = rte_vdpa_get_rte_device(vports[i].dev);\n+\t\tif (!dev) {\n+\t\t\tRTE_LOG(ERR, VDPA,\n+\t\t\t\t\"Failed to get generic device for port %d\\n\", i);\n+\t\t\tcontinue;\n \t\t}\n+\t\tprintf(\"\\nnew port %s, device : %s\\n\", ifname, dev->name);\n+\t\tvports[i].vid = vid;\n+\t\tbreak;\n \t}\n \n \tif (i >= MAX_VDPA_SAMPLE_PORTS)\n@@ -122,16 +129,24 @@ new_device(int vid)\n static void\n destroy_device(int vid)\n {\n+\tstruct rte_device *dev;\n \tchar ifname[MAX_PATH_LEN];\n \tint i;\n \n \trte_vhost_get_ifname(vid, ifname, sizeof(ifname));\n \tfor (i = 0; i < MAX_VDPA_SAMPLE_PORTS; i++) {\n-\t\tif (strcmp(ifname, vports[i].ifname) == 0) {\n-\t\t\tprintf(\"\\ndestroy port %s, did: %d\\n\",\n-\t\t\t\t\tifname, vports[i].did);\n-\t\t\tbreak;\n+\t\tif (strncmp(ifname, vports[i].ifname, MAX_PATH_LEN))\n+\t\t\tcontinue;\n+\n+\t\tdev = rte_vdpa_get_rte_device(vports[i].dev);\n+\t\tif (!dev) {\n+\t\t\tRTE_LOG(ERR, VDPA,\n+\t\t\t\t\"Failed to get generic device for port %d\\n\", i);\n+\t\t\tcontinue;\n \t\t}\n+\n+\t\tprintf(\"\\ndestroy port %s, device: %s\\n\", ifname, dev->name);\n+\t\tbreak;\n \t}\n }\n \n@@ -145,8 +160,6 @@ start_vdpa(struct vdpa_port *vport)\n {\n \tint ret;\n \tchar *socket_path = vport->ifname;\n-\tstruct rte_vdpa_device *vdev;\n-\tint did = vport->did;\n \n \tif (client_mode)\n \t\tvport->flags |= RTE_VHOST_USER_CLIENT;\n@@ -170,13 +183,7 @@ start_vdpa(struct vdpa_port *vport)\n \t\t\t\"register driver ops failed: %s\\n\",\n \t\t\tsocket_path);\n \n-\tvdev = rte_vdpa_get_device(did);\n-\tif (!vdev)\n-\t\trte_exit(EXIT_FAILURE,\n-\t\t\t\"vDPA device retrieval failed: %p\\n\",\n-\t\t\tvdev);\n-\n-\tret = rte_vhost_driver_attach_vdpa_device(socket_path, vdev);\n+\tret = rte_vhost_driver_attach_vdpa_device(socket_path, vport->dev);\n \tif (ret != 0)\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"attach vdpa device failed: %s\\n\",\n@@ -274,35 +281,31 @@ static void cmd_list_vdpa_devices_parsed(\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n {\n-\tint did;\n \tuint32_t queue_num;\n \tuint64_t features;\n \tstruct rte_vdpa_device *vdev;\n \tstruct rte_device *dev;\n \tstruct rte_dev_iterator dev_iter;\n \n-\tcmdline_printf(cl, \"device id\\tdevice name\\tqueue num\\tsupported features\\n\");\n+\tcmdline_printf(cl, \"device name\\tqueue num\\tsupported features\\n\");\n \tRTE_DEV_FOREACH(dev, \"class=vdpa\", &dev_iter) {\n-\t\tdid = rte_vdpa_find_device_id_by_name(dev->name);\n-\t\tif (did < 0)\n-\t\t\tcontinue;\n-\t\tvdev = rte_vdpa_get_device(did);\n+\t\tvdev = rte_vdpa_find_device_by_name(dev->name);\n \t\tif (!vdev)\n \t\t\tcontinue;\n \t\tif (vdev->ops->get_queue_num(vdev, &queue_num) < 0) {\n \t\t\tRTE_LOG(ERR, VDPA,\n \t\t\t\t\"failed to get vdpa queue number \"\n-\t\t\t\t\"for device id %d.\\n\", did);\n+\t\t\t\t\"for device %s.\\n\", dev->name);\n \t\t\tcontinue;\n \t\t}\n \t\tif (vdev->ops->get_features(vdev, &features) < 0) {\n \t\t\tRTE_LOG(ERR, VDPA,\n \t\t\t\t\"failed to get vdpa features \"\n-\t\t\t\t\"for device id %d.\\n\", did);\n+\t\t\t\t\"for device %s.\\n\", dev->name);\n \t\t\tcontinue;\n \t\t}\n-\t\tcmdline_printf(cl, \"%d\\t\\t%s\\t\\t%\" PRIu32 \"\\t\\t0x%\" PRIx64 \"\\n\",\n-\t\t\tdid, dev->name, queue_num, features);\n+\t\tcmdline_printf(cl, \"%s\\t\\t%\" PRIu32 \"\\t\\t0x%\" PRIx64 \"\\n\",\n+\t\t\tdev->name, queue_num, features);\n \t}\n }\n \n@@ -330,18 +333,18 @@ static void cmd_create_vdpa_port_parsed(void *parsed_result,\n \t\tstruct cmdline *cl,\n \t\t__rte_unused void *data)\n {\n-\tint did;\n+\tstruct rte_vdpa_device *dev;\n \tstruct cmd_create_result *res = parsed_result;\n \n \trte_strscpy(vports[devcnt].ifname, res->socket_path, MAX_PATH_LEN);\n-\tdid = rte_vdpa_find_device_id_by_name(res->bdf);\n-\tif (did < 0) {\n+\tdev = rte_vdpa_find_device_by_name(res->bdf);\n+\tif (dev == NULL) {\n \t\tcmdline_printf(cl, \"Unable to find vdpa device id for %s.\\n\",\n \t\t\t\tres->bdf);\n \t\treturn;\n \t}\n \n-\tvports[devcnt].did = did;\n+\tvports[devcnt].dev = dev;\n \n \tif (start_vdpa(&vports[devcnt]) == 0)\n \t\tdevcnt++;\n@@ -403,9 +406,9 @@ int\n main(int argc, char *argv[])\n {\n \tchar ch;\n-\tint did;\n \tint ret;\n \tstruct cmdline *cl;\n+\tstruct rte_vdpa_device *vdev;\n \tstruct rte_device *dev;\n \tstruct rte_dev_iterator dev_iter;\n \n@@ -434,12 +437,12 @@ main(int argc, char *argv[])\n \t\tcmdline_stdin_exit(cl);\n \t} else {\n \t\tRTE_DEV_FOREACH(dev, \"class=vdpa\", &dev_iter) {\n-\t\t\tdid = rte_vdpa_find_device_id_by_name(dev->name);\n-\t\t\tif (did < 0) {\n-\t\t\t\trte_panic(\"Failed to find device id for %s\\n\",\n+\t\t\tvdev = rte_vdpa_find_device_by_name(dev->name);\n+\t\t\tif (vdev == NULL) {\n+\t\t\t\trte_panic(\"Failed to find vDPA dev for %s\\n\",\n \t\t\t\t\t\tdev->name);\n \t\t\t}\n-\t\t\tvports[devcnt].did = did;\n+\t\t\tvports[devcnt].dev = vdev;\n \t\t\tsnprintf(vports[devcnt].ifname, MAX_PATH_LEN, \"%s%d\",\n \t\t\t\t\tiface, devcnt);\n \ndiff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h\nindex e7c785102d..6188bf6483 100644\n--- a/lib/librte_vhost/rte_vdpa.h\n+++ b/lib/librte_vhost/rte_vdpa.h\n@@ -113,11 +113,26 @@ rte_vdpa_unregister_device(struct rte_vdpa_device *);\n  * @param name\n  *  the vdpa device name\n  * @return\n- *  device id on success, -1 on failure\n+ *  vDPA device pointer on success, NULL on failure\n  */\n __rte_experimental\n-int\n-rte_vdpa_find_device_id_by_name(const char *name);\n+struct rte_vdpa_device *\n+rte_vdpa_find_device_by_name(const char *name);\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: this API may change without prior notice\n+ *\n+ * Get the generic device from the vdpa device\n+ *\n+ * @param vdpa_dev\n+ *  the vdpa device pointer\n+ * @return\n+ *  generic device pointer on success, NULL on failure\n+ */\n+__rte_experimental\n+struct rte_device *\n+rte_vdpa_get_rte_device(struct rte_vdpa_device *vdpa_dev);\n \n /**\n  * @warning\ndiff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map\nindex 4872bc4f35..43caab7553 100644\n--- a/lib/librte_vhost/rte_vhost_version.map\n+++ b/lib/librte_vhost/rte_vhost_version.map\n@@ -66,5 +66,6 @@ EXPERIMENTAL {\n \trte_vhost_get_vhost_ring_inflight;\n \trte_vhost_get_vring_base_from_inflight;\n \trte_vhost_slave_config_change;\n-\trte_vdpa_find_device_id_by_name;\n+\trte_vdpa_find_device_by_name;\n+\trte_vdpa_get_rte_device;\n };\ndiff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c\nindex 5ad96fe8a6..9ec5677a78 100644\n--- a/lib/librte_vhost/vdpa.c\n+++ b/lib/librte_vhost/vdpa.c\n@@ -40,14 +40,14 @@ rte_vdpa_find_device_id(struct rte_vdpa_device *dev)\n \treturn -1;\n }\n \n-int\n-rte_vdpa_find_device_id_by_name(const char *name)\n+struct rte_vdpa_device *\n+rte_vdpa_find_device_by_name(const char *name)\n {\n \tstruct rte_vdpa_device *dev;\n \tint i;\n \n \tif (name == NULL)\n-\t\treturn -1;\n+\t\treturn NULL;\n \n \tfor (i = 0; i < MAX_VHOST_DEVICE; ++i) {\n \t\tdev = &vdpa_devices[i];\n@@ -55,10 +55,19 @@ rte_vdpa_find_device_id_by_name(const char *name)\n \t\t\tcontinue;\n \n \t\tif (strcmp(dev->device->name, name) == 0)\n-\t\t\treturn i;\n+\t\t\treturn dev;\n \t}\n \n-\treturn -1;\n+\treturn NULL;\n+}\n+\n+struct rte_device *\n+rte_vdpa_get_rte_device(struct rte_vdpa_device *vdpa_dev)\n+{\n+\tif (vdpa_dev == NULL)\n+\t\treturn NULL;\n+\n+\treturn vdpa_dev->device;\n }\n \n struct rte_vdpa_device *\n",
    "prefixes": [
        "07/14"
    ]
}