get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 72253,
    "url": "http://patches.dpdk.org/api/patches/72253/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200626140441.1441763-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": "<20200626140441.1441763-8-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200626140441.1441763-8-maxime.coquelin@redhat.com",
    "date": "2020-06-26T14:04:34",
    "name": "[v3,07/14] vhost: replace device ID in applications",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "694b893ad9d8cf32d12396cacf55ae47bc2d5387",
    "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/20200626140441.1441763-8-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 10634,
            "url": "http://patches.dpdk.org/api/series/10634/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=10634",
            "date": "2020-06-26T14:04:28",
            "name": "vDPA API and framework rework",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/10634/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/72253/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/72253/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 40395A051C;\n\tFri, 26 Jun 2020 16:06:40 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 3BB4E1C0B1;\n\tFri, 26 Jun 2020 16:05:42 +0200 (CEST)",
            "from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com\n [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 5B3141C037\n for <dev@dpdk.org>; Fri, 26 Jun 2020 16:05:40 +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-72-ZgryD-d5OjiFkyQhcc4Fwg-1; Fri, 26 Jun 2020 10:05:38 -0400",
            "from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com\n [10.5.11.15])\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 A9B7F8064B4;\n Fri, 26 Jun 2020 14:05:36 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.36.110.7])\n by smtp.corp.redhat.com (Postfix) with ESMTP id D8D165BAE1;\n Fri, 26 Jun 2020 14:05:33 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1593180339;\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=EoLSLw8Uy2YifsLR+6MZOT/F84WTwiMFvINty31VZPk=;\n b=P+SrrNtGG4FLfMHYic2atkP/Hekpp20ANQe/vtFKIpBWotQ3pHgzYZWlXYC4ulx6ZZzLXo\n C+IzhefXhAQPt4NFi+n6CC0aGkRU6EtUI3oEMmY0F7eHLRDJPi/XB69Zqlphx+z0pQCuyJ\n g6gkgQeSpAbSbUhvRii7ZV5F6MlWgxY=",
        "X-MC-Unique": "ZgryD-d5OjiFkyQhcc4Fwg-1",
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "matan@mellanox.com, xiao.w.wang@intel.com, zhihong.wang@intel.com,\n chenbo.xia@intel.com, david.marchand@redhat.com, amorenoz@redhat.com,\n viacheslavo@mellanox.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com,\n grive@u256.net, dev@dpdk.org",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Fri, 26 Jun 2020 16:04:34 +0200",
        "Message-Id": "<20200626140441.1441763-8-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20200626140441.1441763-1-maxime.coquelin@redhat.com>",
        "References": "<20200626140441.1441763-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15",
        "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-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v3 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\nAcked-by: Adrián Moreno <amorenoz@redhat.com>\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n examples/vdpa/main.c                   | 118 +++++++++++++------------\n lib/librte_vhost/rte_vdpa.h            |  44 ++++++---\n lib/librte_vhost/rte_vhost_version.map |   3 +-\n lib/librte_vhost/vdpa.c                |  64 +++++++-------\n 4 files changed, 123 insertions(+), 106 deletions(-)",
    "diff": "diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c\nindex 6a719e32d8..54f4940b31 100644\n--- a/examples/vdpa/main.c\n+++ b/examples/vdpa/main.c\n@@ -27,7 +27,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 \tint stats_n;\n@@ -105,16 +105,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@@ -126,16 +133,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@@ -149,8 +164,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@@ -174,13 +187,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@@ -283,35 +290,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@@ -339,18 +342,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@@ -378,7 +381,7 @@ cmdline_parse_inst_t cmd_create_vdpa_port = {\n /* *** STATS *** */\n struct cmd_stats_result {\n \tcmdline_fixed_string_t stats;\n-\tuint16_t did;\n+\tcmdline_fixed_string_t bdf;\n \tuint16_t qid;\n };\n \n@@ -386,25 +389,24 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n \t\t\t\t    __rte_unused void *data)\n {\n \tstruct cmd_stats_result *res = parsed_result;\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(res->did);\n+\tstruct rte_vdpa_device *vdev = rte_vdpa_find_device_by_name(res->bdf);\n \tstruct vdpa_port *vport = NULL;\n \tuint32_t first, last;\n \tint i;\n \n \tif (!vdev) {\n-\t\tRTE_LOG(ERR, VDPA, \"Invalid device id %\" PRIu16 \".\\n\",\n-\t\t\tres->did);\n+\t\tRTE_LOG(ERR, VDPA, \"Invalid device: %s.\\n\",\n+\t\t\tres->bdf);\n \t\treturn;\n \t}\n \tfor (i = 0; i < RTE_MIN(MAX_VDPA_SAMPLE_PORTS, dev_total); i++) {\n-\t\tif (vports[i].did == res->did) {\n+\t\tif (vports[i].dev == vdev) {\n \t\t\tvport = &vports[i];\n \t\t\tbreak;\n \t\t}\n \t}\n \tif (!vport) {\n-\t\tRTE_LOG(ERR, VDPA, \"Device id %\" PRIu16 \" was not created.\\n\",\n-\t\t\tres->did);\n+\t\tRTE_LOG(ERR, VDPA, \"Device %s was not created.\\n\", res->bdf);\n \t\treturn;\n \t}\n \tif (res->qid == 0xFFFF) {\n@@ -412,7 +414,7 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n \t\tlast = rte_vhost_get_vring_num(vport->vid);\n \t\tif (last == 0) {\n \t\t\tRTE_LOG(ERR, VDPA, \"Failed to get num of actual virtqs\"\n-\t\t\t\t\" for device id %d.\\n\", (int)res->did);\n+\t\t\t\t\" for device %s.\\n\", res->bdf);\n \t\t\treturn;\n \t\t}\n \t\tlast--;\n@@ -421,10 +423,10 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n \t\tlast = res->qid;\n \t}\n \tif (!vport->stats_names) {\n-\t\tvport->stats_n = rte_vdpa_get_stats_names(vport->did, NULL, 0);\n+\t\tvport->stats_n = rte_vdpa_get_stats_names(vport->dev, NULL, 0);\n \t\tif (vport->stats_n <= 0) {\n \t\t\tRTE_LOG(ERR, VDPA, \"Failed to get names number of \"\n-\t\t\t\t\"device %d stats.\\n\", (int)res->did);\n+\t\t\t\t\"device %s stats.\\n\", res->bdf);\n \t\t\treturn;\n \t\t}\n \t\tvport->stats_names = rte_zmalloc(NULL,\n@@ -432,26 +434,26 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n \t\t\t\t\t\t\tvport->stats_n, 0);\n \t\tif (!vport->stats_names) {\n \t\t\tRTE_LOG(ERR, VDPA, \"Failed to allocate memory for stat\"\n-\t\t\t\t\" names of device %d.\\n\", (int)res->did);\n+\t\t\t\t\" names of device %s.\\n\", res->bdf);\n \t\t\treturn;\n \t\t}\n-\t\ti = rte_vdpa_get_stats_names(vport->did, vport->stats_names,\n+\t\ti = rte_vdpa_get_stats_names(vport->dev, vport->stats_names,\n \t\t\t\t\t\tvport->stats_n);\n \t\tif (vport->stats_n != i) {\n-\t\t\tRTE_LOG(ERR, VDPA, \"Failed to get names of device %d \"\n-\t\t\t\t\"stats.\\n\", (int)res->did);\n+\t\t\tRTE_LOG(ERR, VDPA, \"Failed to get names of device %s \"\n+\t\t\t\t\"stats.\\n\", res->bdf);\n \t\t\treturn;\n \t\t}\n \t\tvport->stats = (struct rte_vdpa_stat *)\n \t\t\t\t\t(vport->stats_names + vport->stats_n);\n \t}\n-\tcmdline_printf(cl, \"\\nDevice %d:\\n\", (int)res->did);\n+\tcmdline_printf(cl, \"\\nDevice %s:\\n\", res->bdf);\n \tfor (; first <= last; first++) {\n \t\tmemset(vport->stats, 0, sizeof(*vport->stats) * vport->stats_n);\n-\t\tif (rte_vdpa_get_stats(vport->did, (int)first, vport->stats,\n+\t\tif (rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,\n \t\t\t\t\tvport->stats_n) <= 0) {\n \t\t\tRTE_LOG(ERR, VDPA, \"Failed to get vdpa queue statistics\"\n-\t\t\t\t\" for device id %d qid %d.\\n\", (int)res->did,\n+\t\t\t\t\" for device %s qid %d.\\n\", res->bdf,\n \t\t\t\t(int)first);\n \t\t\treturn;\n \t\t}\n@@ -467,8 +469,8 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,\n \n cmdline_parse_token_string_t cmd_device_stats_ =\n \tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, stats, \"stats\");\n-cmdline_parse_token_num_t cmd_device_id =\n-\tTOKEN_NUM_INITIALIZER(struct cmd_stats_result, did, UINT32);\n+cmdline_parse_token_string_t cmd_device_bdf =\n+\tTOKEN_STRING_INITIALIZER(struct cmd_stats_result, bdf, NULL);\n cmdline_parse_token_num_t cmd_queue_id =\n \tTOKEN_NUM_INITIALIZER(struct cmd_stats_result, qid, UINT32);\n \n@@ -478,7 +480,7 @@ cmdline_parse_inst_t cmd_device_stats = {\n \t.help_str = \"stats: show device statistics\",\n \t.tokens = {\n \t\t(void *)&cmd_device_stats_,\n-\t\t(void *)&cmd_device_id,\n+\t\t(void *)&cmd_device_bdf,\n \t\t(void *)&cmd_queue_id,\n \t\tNULL,\n \t},\n@@ -522,9 +524,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@@ -553,12 +555,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 109cf83b8f..549b0a2cb0 100644\n--- a/lib/librte_vhost/rte_vdpa.h\n+++ b/lib/librte_vhost/rte_vdpa.h\n@@ -153,11 +153,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\n@@ -252,8 +267,8 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);\n  * And the array index is same with id field of 'struct rte_vdpa_stat':\n  * stats[i].id == i\n  *\n- * @param did\n- *  device id\n+ * @param dev\n+ *  vDPA device pointer\n  * @param stats_names\n  *   array of at least size elements to be filled.\n  *   If set to NULL, the function returns the required number of elements.\n@@ -265,8 +280,9 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m);\n  */\n __rte_experimental\n int\n-rte_vdpa_get_stats_names(int did, struct rte_vdpa_stat_name *stats_names,\n-\t\t\t unsigned int size);\n+rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,\n+\t\tstruct rte_vdpa_stat_name *stats_names,\n+\t\tunsigned int size);\n \n /**\n  * @warning\n@@ -280,8 +296,8 @@ rte_vdpa_get_stats_names(int did, struct rte_vdpa_stat_name *stats_names,\n  * And the array index is same with id field of 'struct rte_vdpa_stat':\n  * stats[i].id == i\n  *\n- * @param did\n- *  device id\n+ * @param dev\n+ *  vDPA device pointer\n  * @param qid\n  *  queue id\n  * @param stats\n@@ -295,16 +311,16 @@ rte_vdpa_get_stats_names(int did, struct rte_vdpa_stat_name *stats_names,\n  */\n __rte_experimental\n int\n-rte_vdpa_get_stats(int did, uint16_t qid, struct rte_vdpa_stat *stats,\n-\t\t   unsigned int n);\n+rte_vdpa_get_stats(struct rte_vdpa_device *dev, uint16_t qid,\n+\t\tstruct rte_vdpa_stat *stats, unsigned int n);\n /**\n  * @warning\n  * @b EXPERIMENTAL: this API may change without prior notice\n  *\n  * Reset statistics of a vDPA device.\n  *\n- * @param did\n- *  device id\n+ * @param dev\n+ *  vDPA device pointer\n  * @param qid\n  *  queue id\n  * @return\n@@ -312,5 +328,5 @@ rte_vdpa_get_stats(int did, uint16_t qid, struct rte_vdpa_stat *stats,\n  */\n __rte_experimental\n int\n-rte_vdpa_reset_stats(int did, uint16_t qid);\n+rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid);\n #endif /* _RTE_VDPA_H_ */\ndiff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map\nindex 60d67445d7..ba55f6f421 100644\n--- a/lib/librte_vhost/rte_vhost_version.map\n+++ b/lib/librte_vhost/rte_vhost_version.map\n@@ -69,5 +69,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 49ada00277..cececc3098 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 (strncmp(dev->device->name, name, RTE_DEV_NAME_MAX_LEN) == 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@@ -228,50 +237,39 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)\n }\n \n int\n-rte_vdpa_get_stats_names(int did, struct rte_vdpa_stat_name *stats_names,\n-\t\t\t unsigned int size)\n+rte_vdpa_get_stats_names(struct rte_vdpa_device *dev,\n+\t\tstruct rte_vdpa_stat_name *stats_names,\n+\t\tunsigned int size)\n {\n-\tstruct rte_vdpa_device *vdpa_dev;\n-\n-\tvdpa_dev = rte_vdpa_get_device(did);\n-\tif (!vdpa_dev)\n-\t\treturn -ENODEV;\n+\tif (!dev)\n+\t\treturn -EINVAL;\n \n-\tRTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_stats_names, -ENOTSUP);\n+\tRTE_FUNC_PTR_OR_ERR_RET(dev->ops->get_stats_names, -ENOTSUP);\n \n-\treturn vdpa_dev->ops->get_stats_names(vdpa_dev, stats_names, size);\n+\treturn dev->ops->get_stats_names(dev, stats_names, size);\n }\n \n int\n-rte_vdpa_get_stats(int did, uint16_t qid, struct rte_vdpa_stat *stats,\n-\t\t   unsigned int n)\n+rte_vdpa_get_stats(struct rte_vdpa_device *dev, uint16_t qid,\n+\t\tstruct rte_vdpa_stat *stats, unsigned int n)\n {\n-\tstruct rte_vdpa_device *vdpa_dev;\n-\n-\tvdpa_dev = rte_vdpa_get_device(did);\n-\tif (!vdpa_dev)\n-\t\treturn -ENODEV;\n-\n-\tif (!stats || !n)\n+\tif (!dev || !stats || !n)\n \t\treturn -EINVAL;\n \n-\tRTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_stats, -ENOTSUP);\n+\tRTE_FUNC_PTR_OR_ERR_RET(dev->ops->get_stats, -ENOTSUP);\n \n-\treturn vdpa_dev->ops->get_stats(vdpa_dev, qid, stats, n);\n+\treturn dev->ops->get_stats(dev, qid, stats, n);\n }\n \n int\n-rte_vdpa_reset_stats(int did, uint16_t qid)\n+rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid)\n {\n-\tstruct rte_vdpa_device *vdpa_dev;\n-\n-\tvdpa_dev = rte_vdpa_get_device(did);\n-\tif (!vdpa_dev)\n-\t\treturn -ENODEV;\n+\tif (!dev)\n+\t\treturn -EINVAL;\n \n-\tRTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->reset_stats, -ENOTSUP);\n+\tRTE_FUNC_PTR_OR_ERR_RET(dev->ops->reset_stats, -ENOTSUP);\n \n-\treturn vdpa_dev->ops->reset_stats(vdpa_dev, qid);\n+\treturn dev->ops->reset_stats(dev, qid);\n }\n \n static uint16_t\n",
    "prefixes": [
        "v3",
        "07/14"
    ]
}