get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 71292,
    "url": "http://patches.dpdk.org/api/patches/71292/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200611213748.1967029-7-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-7-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200611213748.1967029-7-maxime.coquelin@redhat.com",
    "date": "2020-06-11T21:37:40",
    "name": "[06/14] vhost: replace vDPA device ID in Vhost",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "9528f49300ec40171cc064c9d3cc14d71f2b9484",
    "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-7-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/71292/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/71292/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 7AD9BA00BE;\n\tThu, 11 Jun 2020 23:38:50 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6D8932C38;\n\tThu, 11 Jun 2020 23:38:32 +0200 (CEST)",
            "from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com\n [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id C404C2C23\n for <dev@dpdk.org>; Thu, 11 Jun 2020 23:38:31 +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-467-j-UGiUIPPR2cBCoRrdqN-A-1; Thu, 11 Jun 2020 17:38:29 -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 0DEB518A0724;\n Thu, 11 Jun 2020 21:38:28 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.36.110.37])\n by smtp.corp.redhat.com (Postfix) with ESMTP id EC511100238D;\n Thu, 11 Jun 2020 21:38:24 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1591911511;\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=Tv77znRvX3/zv7BY6vpgJ+zyW6Z7JT6r099jNgXkK3I=;\n b=A9BOSWoxiZT1cYr/QfRUvb/5rhxiuPtfvxgyKLgMYjeKL6BFEE2CgS4Lwi0RU3oqKkQl8s\n ChNz/u3QToTym2gQ2LrUuqY0k75sTLzfJ3Bsqh9PjNpYkWJYi0bLouW2XFASdYfJvMv6dB\n 34f3Ho6kYTScArIDrzCHVqeGN+t/z1E=",
        "X-MC-Unique": "j-UGiUIPPR2cBCoRrdqN-A-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:40 +0200",
        "Message-Id": "<20200611213748.1967029-7-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 06/14] vhost: replace vDPA device ID in Vhost",
        "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 removes the notion of device ID in Vhost library\nas a preliminary step to get rid of the vDPA device ID.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n drivers/vdpa/ifc/ifcvf_vdpa.c          | 12 ++++----\n drivers/vdpa/mlx5/mlx5_vdpa.c          | 18 ++++-------\n examples/vdpa/main.c                   |  9 +++++-\n lib/librte_vhost/rte_vhost.h           | 20 ++++++------\n lib/librte_vhost/rte_vhost_version.map |  4 +--\n lib/librte_vhost/socket.c              | 42 ++++++++++----------------\n lib/librte_vhost/vhost.c               | 19 +++++-------\n lib/librte_vhost/vhost.h               |  8 ++---\n lib/librte_vhost/vhost_user.c          | 28 +++++------------\n 9 files changed, 66 insertions(+), 94 deletions(-)",
    "diff": "diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c\nindex a04da16bbe..a8fdedba06 100644\n--- a/drivers/vdpa/ifc/ifcvf_vdpa.c\n+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c\n@@ -880,7 +880,7 @@ ifcvf_dev_config(int vid)\n \tstruct internal_list *list;\n \tstruct ifcvf_internal *internal;\n \n-\tvdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n \tlist = find_internal_resource_by_vdev(vdev);\n \tif (list == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\n@@ -906,7 +906,7 @@ ifcvf_dev_close(int vid)\n \tstruct internal_list *list;\n \tstruct ifcvf_internal *internal;\n \n-\tvdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n \tlist = find_internal_resource_by_vdev(vdev);\n \tif (list == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\n@@ -946,7 +946,7 @@ ifcvf_set_features(int vid)\n \tstruct ifcvf_internal *internal;\n \tuint64_t log_base = 0, log_size = 0;\n \n-\tvdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n \tlist = find_internal_resource_by_vdev(vdev);\n \tif (list == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\n@@ -977,7 +977,7 @@ ifcvf_get_vfio_group_fd(int vid)\n \tstruct rte_vdpa_device *vdev;\n \tstruct internal_list *list;\n \n-\tvdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n \tlist = find_internal_resource_by_vdev(vdev);\n \tif (list == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\n@@ -993,7 +993,7 @@ ifcvf_get_vfio_device_fd(int vid)\n \tstruct rte_vdpa_device *vdev;\n \tstruct internal_list *list;\n \n-\tvdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n \tlist = find_internal_resource_by_vdev(vdev);\n \tif (list == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\n@@ -1012,7 +1012,7 @@ ifcvf_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)\n \tstruct vfio_region_info reg = { .argsz = sizeof(reg) };\n \tint ret;\n \n-\tvdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));\n+\tvdev = rte_vhost_get_vdpa_device(vid);\n \tlist = find_internal_resource_by_vdev(vdev);\n \tif (list == NULL) {\n \t\tDRV_LOG(ERR, \"Invalid vDPA device: %p\", vdev);\ndiff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c\nindex cbf5c94c78..c1b9e68516 100644\n--- a/drivers/vdpa/mlx5/mlx5_vdpa.c\n+++ b/drivers/vdpa/mlx5/mlx5_vdpa.c\n@@ -118,8 +118,7 @@ mlx5_vdpa_get_protocol_features(struct rte_vdpa_device *vdev,\n static int\n mlx5_vdpa_set_vring_state(int vid, int vring, int state)\n {\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(\n-\t\t\trte_vhost_get_vdpa_device_id(vid));\n+\tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n \n@@ -160,8 +159,7 @@ mlx5_vdpa_direct_db_prepare(struct mlx5_vdpa_priv *priv)\n static int\n mlx5_vdpa_features_set(int vid)\n {\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(\n-\t\t\trte_vhost_get_vdpa_device_id(vid));\n+\tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n \tuint64_t log_base, log_size;\n@@ -201,8 +199,7 @@ mlx5_vdpa_features_set(int vid)\n static int\n mlx5_vdpa_dev_close(int vid)\n {\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(\n-\t\t\trte_vhost_get_vdpa_device_id(vid));\n+\tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n \tint ret = 0;\n@@ -227,8 +224,7 @@ mlx5_vdpa_dev_close(int vid)\n static int\n mlx5_vdpa_dev_config(int vid)\n {\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(\n-\t\t\trte_vhost_get_vdpa_device_id(vid));\n+\tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n \n@@ -255,8 +251,7 @@ mlx5_vdpa_dev_config(int vid)\n static int\n mlx5_vdpa_get_device_fd(int vid)\n {\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(\n-\t\t\trte_vhost_get_vdpa_device_id(vid));\n+\tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n \n@@ -270,8 +265,7 @@ mlx5_vdpa_get_device_fd(int vid)\n static int\n mlx5_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)\n {\n-\tstruct rte_vdpa_device *vdev = rte_vdpa_get_device(\n-\t\t\trte_vhost_get_vdpa_device_id(vid));\n+\tstruct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);\n \tstruct mlx5_vdpa_priv *priv =\n \t\tmlx5_vdpa_find_priv_resource_by_vdev(vdev);\n \ndiff --git a/examples/vdpa/main.c b/examples/vdpa/main.c\nindex 6b92c712e8..8d707c9e2d 100644\n--- a/examples/vdpa/main.c\n+++ b/examples/vdpa/main.c\n@@ -145,6 +145,7 @@ 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@@ -169,7 +170,13 @@ start_vdpa(struct vdpa_port *vport)\n \t\t\t\"register driver ops failed: %s\\n\",\n \t\t\tsocket_path);\n \n-\tret = rte_vhost_driver_attach_vdpa_device(socket_path, did);\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 \tif (ret != 0)\n \t\trte_exit(EXIT_FAILURE,\n \t\t\t\"attach vdpa device failed: %s\\n\",\ndiff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h\nindex d43669f2c2..2fbc364643 100644\n--- a/lib/librte_vhost/rte_vhost.h\n+++ b/lib/librte_vhost/rte_vhost.h\n@@ -90,6 +90,7 @@ extern \"C\" {\n #define VHOST_USER_F_PROTOCOL_FEATURES\t30\n #endif\n \n+struct rte_vdpa_device;\n \n /**\n  * Information relating to memory regions including offsets to\n@@ -402,14 +403,15 @@ int rte_vhost_driver_unregister(const char *path);\n  *\n  * @param path\n  *  The vhost-user socket file path\n- * @param did\n- *  Device id\n+ * @param dev\n+ *  vDPA device pointer\n  * @return\n  *  0 on success, -1 on failure\n  */\n __rte_experimental\n int\n-rte_vhost_driver_attach_vdpa_device(const char *path, int did);\n+rte_vhost_driver_attach_vdpa_device(const char *path,\n+\t\tstruct rte_vdpa_device *dev);\n \n /**\n  * Unset the vdpa device id\n@@ -429,11 +431,11 @@ rte_vhost_driver_detach_vdpa_device(const char *path);\n  * @param path\n  *  The vhost-user socket file path\n  * @return\n- *  Device id, -1 on failure\n+ *  vDPA device pointer, NULL on failure\n  */\n __rte_experimental\n-int\n-rte_vhost_driver_get_vdpa_device_id(const char *path);\n+struct rte_vdpa_device *\n+rte_vhost_driver_get_vdpa_device(const char *path);\n \n /**\n  * Set the feature bits the vhost-user driver supports.\n@@ -977,11 +979,11 @@ rte_vhost_extern_callback_register(int vid,\n  * @param vid\n  *  vhost device id\n  * @return\n- *  device id\n+ *  vDPA device pointer on success, NULL on failure\n  */\n __rte_experimental\n-int\n-rte_vhost_get_vdpa_device_id(int vid);\n+struct rte_vdpa_device *\n+rte_vhost_get_vdpa_device(int vid);\n \n /**\n  * Notify the guest that should get virtio configuration space from backend.\ndiff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map\nindex 1abfff8a0c..4872bc4f35 100644\n--- a/lib/librte_vhost/rte_vhost_version.map\n+++ b/lib/librte_vhost/rte_vhost_version.map\n@@ -40,8 +40,8 @@ EXPERIMENTAL {\n \trte_vdpa_get_device_num;\n \trte_vhost_driver_attach_vdpa_device;\n \trte_vhost_driver_detach_vdpa_device;\n-\trte_vhost_driver_get_vdpa_device_id;\n-\trte_vhost_get_vdpa_device_id;\n+\trte_vhost_driver_get_vdpa_device;\n+\trte_vhost_get_vdpa_device;\n \trte_vhost_driver_get_protocol_features;\n \trte_vhost_driver_get_queue_num;\n \trte_vhost_get_log_base;\ndiff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c\nindex da575b608c..49267cebf9 100644\n--- a/lib/librte_vhost/socket.c\n+++ b/lib/librte_vhost/socket.c\n@@ -55,12 +55,7 @@ struct vhost_user_socket {\n \n \tuint64_t protocol_features;\n \n-\t/*\n-\t * Device id to identify a specific backend device.\n-\t * It's set to -1 for the default software implementation.\n-\t * If valid, one socket can have 1 connection only.\n-\t */\n-\tint vdpa_dev_id;\n+\tstruct rte_vdpa_device *vdpa_dev;\n \n \tstruct vhost_device_ops const *notify_ops;\n };\n@@ -230,7 +225,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)\n \n \tvhost_set_builtin_virtio_net(vid, vsocket->use_builtin_virtio_net);\n \n-\tvhost_attach_vdpa_device(vid, vsocket->vdpa_dev_id);\n+\tvhost_attach_vdpa_device(vid, vsocket->vdpa_dev);\n \n \tif (vsocket->dequeue_zero_copy)\n \t\tvhost_enable_dequeue_zero_copy(vid);\n@@ -578,17 +573,18 @@ find_vhost_user_socket(const char *path)\n }\n \n int\n-rte_vhost_driver_attach_vdpa_device(const char *path, int did)\n+rte_vhost_driver_attach_vdpa_device(const char *path,\n+\t\tstruct rte_vdpa_device *dev)\n {\n \tstruct vhost_user_socket *vsocket;\n \n-\tif (rte_vdpa_get_device(did) == NULL || path == NULL)\n+\tif (dev == NULL || path == NULL)\n \t\treturn -1;\n \n \tpthread_mutex_lock(&vhost_user.mutex);\n \tvsocket = find_vhost_user_socket(path);\n \tif (vsocket)\n-\t\tvsocket->vdpa_dev_id = did;\n+\t\tvsocket->vdpa_dev = dev;\n \tpthread_mutex_unlock(&vhost_user.mutex);\n \n \treturn vsocket ? 0 : -1;\n@@ -602,25 +598,25 @@ rte_vhost_driver_detach_vdpa_device(const char *path)\n \tpthread_mutex_lock(&vhost_user.mutex);\n \tvsocket = find_vhost_user_socket(path);\n \tif (vsocket)\n-\t\tvsocket->vdpa_dev_id = -1;\n+\t\tvsocket->vdpa_dev = NULL;\n \tpthread_mutex_unlock(&vhost_user.mutex);\n \n \treturn vsocket ? 0 : -1;\n }\n \n-int\n-rte_vhost_driver_get_vdpa_device_id(const char *path)\n+struct rte_vdpa_device *\n+rte_vhost_driver_get_vdpa_device(const char *path)\n {\n \tstruct vhost_user_socket *vsocket;\n-\tint did = -1;\n+\tstruct rte_vdpa_device *dev = NULL;\n \n \tpthread_mutex_lock(&vhost_user.mutex);\n \tvsocket = find_vhost_user_socket(path);\n \tif (vsocket)\n-\t\tdid = vsocket->vdpa_dev_id;\n+\t\tdev = vsocket->vdpa_dev;\n \tpthread_mutex_unlock(&vhost_user.mutex);\n \n-\treturn did;\n+\treturn dev;\n }\n \n int\n@@ -693,7 +689,6 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)\n \tstruct vhost_user_socket *vsocket;\n \tuint64_t vdpa_features;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \tint ret = 0;\n \n \tpthread_mutex_lock(&vhost_user.mutex);\n@@ -705,8 +700,7 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)\n \t\tgoto unlock_exit;\n \t}\n \n-\tdid = vsocket->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = vsocket->vdpa_dev;\n \tif (!vdpa_dev || !vdpa_dev->ops->get_features) {\n \t\t*features = vsocket->features;\n \t\tgoto unlock_exit;\n@@ -748,7 +742,6 @@ rte_vhost_driver_get_protocol_features(const char *path,\n \tstruct vhost_user_socket *vsocket;\n \tuint64_t vdpa_protocol_features;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \tint ret = 0;\n \n \tpthread_mutex_lock(&vhost_user.mutex);\n@@ -760,8 +753,7 @@ rte_vhost_driver_get_protocol_features(const char *path,\n \t\tgoto unlock_exit;\n \t}\n \n-\tdid = vsocket->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = vsocket->vdpa_dev;\n \tif (!vdpa_dev || !vdpa_dev->ops->get_protocol_features) {\n \t\t*protocol_features = vsocket->protocol_features;\n \t\tgoto unlock_exit;\n@@ -790,7 +782,6 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)\n \tstruct vhost_user_socket *vsocket;\n \tuint32_t vdpa_queue_num;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \tint ret = 0;\n \n \tpthread_mutex_lock(&vhost_user.mutex);\n@@ -802,8 +793,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)\n \t\tgoto unlock_exit;\n \t}\n \n-\tdid = vsocket->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = vsocket->vdpa_dev;\n \tif (!vdpa_dev || !vdpa_dev->ops->get_queue_num) {\n \t\t*queue_num = VHOST_MAX_QUEUE_PAIRS;\n \t\tgoto unlock_exit;\n@@ -878,7 +868,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)\n \t\t\t\"error: failed to init connection mutex\\n\");\n \t\tgoto out_free;\n \t}\n-\tvsocket->vdpa_dev_id = -1;\n+\tvsocket->vdpa_dev = NULL;\n \tvsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;\n \tvsocket->extbuf = flags & RTE_VHOST_USER_EXTBUF_SUPPORT;\n \tvsocket->linearbuf = flags & RTE_VHOST_USER_LINEARBUF_SUPPORT;\ndiff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex 0266318440..0d822d6a3f 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -633,7 +633,6 @@ vhost_new_device(void)\n \tdev->vid = i;\n \tdev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;\n \tdev->slave_req_fd = -1;\n-\tdev->vdpa_dev_id = -1;\n \tdev->postcopy_ufd = -1;\n \trte_spinlock_init(&dev->slave_req_lock);\n \n@@ -644,11 +643,9 @@ void\n vhost_destroy_device_notify(struct virtio_net *dev)\n {\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did;\n \n \tif (dev->flags & VIRTIO_DEV_RUNNING) {\n-\t\tdid = dev->vdpa_dev_id;\n-\t\tvdpa_dev = rte_vdpa_get_device(did);\n+\t\tvdpa_dev = dev->vdpa_dev;\n \t\tif (vdpa_dev && vdpa_dev->ops->dev_close)\n \t\t\tvdpa_dev->ops->dev_close(dev->vid);\n \t\tdev->flags &= ~VIRTIO_DEV_RUNNING;\n@@ -677,17 +674,14 @@ vhost_destroy_device(int vid)\n }\n \n void\n-vhost_attach_vdpa_device(int vid, int did)\n+vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *vdpa_dev)\n {\n \tstruct virtio_net *dev = get_device(vid);\n \n \tif (dev == NULL)\n \t\treturn;\n \n-\tif (rte_vdpa_get_device(did) == NULL)\n-\t\treturn;\n-\n-\tdev->vdpa_dev_id = did;\n+\tdev->vdpa_dev = vdpa_dev;\n }\n \n void\n@@ -1402,14 +1396,15 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid)\n \treturn ret;\n }\n \n-int rte_vhost_get_vdpa_device_id(int vid)\n+struct rte_vdpa_device *\n+rte_vhost_get_vdpa_device(int vid)\n {\n \tstruct virtio_net *dev = get_device(vid);\n \n \tif (dev == NULL)\n-\t\treturn -1;\n+\t\treturn NULL;\n \n-\treturn dev->vdpa_dev_id;\n+\treturn dev->vdpa_dev;\n }\n \n int rte_vhost_get_log_base(int vid, uint64_t *log_base,\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex df98d15de6..819857a65a 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -377,11 +377,7 @@ struct virtio_net {\n \tint\t\t\tpostcopy_ufd;\n \tint\t\t\tpostcopy_listening;\n \n-\t/*\n-\t * Device id to identify a specific backend device.\n-\t * It's set to -1 for the default software implementation.\n-\t */\n-\tint\t\t\tvdpa_dev_id;\n+\tstruct rte_vdpa_device *vdpa_dev;\n \n \t/* context data for the external message handlers */\n \tvoid\t\t\t*extern_data;\n@@ -639,7 +635,7 @@ void free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq);\n \n int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx);\n \n-void vhost_attach_vdpa_device(int vid, int did);\n+void vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *dev);\n \n void vhost_set_ifname(int, const char *if_name, unsigned int if_len);\n void vhost_enable_dequeue_zero_copy(int vid);\ndiff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex 84bebad792..a43f0e9735 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -315,7 +315,6 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \tuint64_t features = msg->payload.u64;\n \tuint64_t vhost_features = 0;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \n \tif (validate_msg_fds(msg, 0) != 0)\n \t\treturn RTE_VHOST_MSG_RESULT_ERR;\n@@ -384,8 +383,7 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \t\t}\n \t}\n \n-\tdid = dev->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = dev->vdpa_dev;\n \tif (vdpa_dev && vdpa_dev->ops->set_features)\n \t\tvdpa_dev->ops->set_features(dev->vid);\n \n@@ -1971,7 +1969,6 @@ vhost_user_set_vring_enable(struct virtio_net **pdev,\n \tint enable = (int)msg->payload.state.num;\n \tint index = (int)msg->payload.state.index;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \n \tif (validate_msg_fds(msg, 0) != 0)\n \t\treturn RTE_VHOST_MSG_RESULT_ERR;\n@@ -1980,8 +1977,7 @@ vhost_user_set_vring_enable(struct virtio_net **pdev,\n \t\t\"set queue enable: %d to qp idx: %d\\n\",\n \t\tenable, index);\n \n-\tdid = dev->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = dev->vdpa_dev;\n \tif (vdpa_dev && vdpa_dev->ops->set_vring_state)\n \t\tvdpa_dev->ops->set_vring_state(dev->vid, index, enable);\n \n@@ -2156,7 +2152,6 @@ vhost_user_send_rarp(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \tstruct virtio_net *dev = *pdev;\n \tuint8_t *mac = (uint8_t *)&msg->payload.u64;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \n \tif (validate_msg_fds(msg, 0) != 0)\n \t\treturn RTE_VHOST_MSG_RESULT_ERR;\n@@ -2174,8 +2169,7 @@ vhost_user_send_rarp(struct virtio_net **pdev, struct VhostUserMsg *msg,\n \t * copied before the flag is set.\n \t */\n \t__atomic_store_n(&dev->broadcast_rarp, 1, __ATOMIC_RELEASE);\n-\tdid = dev->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = dev->vdpa_dev;\n \tif (vdpa_dev && vdpa_dev->ops->migration_done)\n \t\tvdpa_dev->ops->migration_done(dev->vid);\n \n@@ -2622,7 +2616,6 @@ vhost_user_msg_handler(int vid, int fd)\n \tstruct virtio_net *dev;\n \tstruct VhostUserMsg msg;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint did = -1;\n \tint ret;\n \tint unlock_required = 0;\n \tbool handled;\n@@ -2814,8 +2807,7 @@ vhost_user_msg_handler(int vid, int fd)\n \t\t}\n \t}\n \n-\tdid = dev->vdpa_dev_id;\n-\tvdpa_dev = rte_vdpa_get_device(did);\n+\tvdpa_dev = dev->vdpa_dev;\n \tif (vdpa_dev && virtio_is_ready(dev) &&\n \t\t\t!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) &&\n \t\t\tmsg.request.master == VHOST_USER_SET_VRING_CALL) {\n@@ -2964,7 +2956,7 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)\n {\n \tstruct virtio_net *dev;\n \tstruct rte_vdpa_device *vdpa_dev;\n-\tint vfio_device_fd, did, ret = 0;\n+\tint vfio_device_fd, ret = 0;\n \tuint64_t offset, size;\n \tunsigned int i;\n \n@@ -2972,9 +2964,9 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)\n \tif (!dev)\n \t\treturn -ENODEV;\n \n-\tdid = dev->vdpa_dev_id;\n-\tif (did < 0)\n-\t\treturn -EINVAL;\n+\tvdpa_dev = dev->vdpa_dev;\n+\tif (vdpa_dev == NULL)\n+\t\treturn -ENODEV;\n \n \tif (!(dev->features & (1ULL << VIRTIO_F_VERSION_1)) ||\n \t    !(dev->features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) ||\n@@ -2986,10 +2978,6 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)\n \t\t\t(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER)))\n \t\treturn -ENOTSUP;\n \n-\tvdpa_dev = rte_vdpa_get_device(did);\n-\tif (!vdpa_dev)\n-\t\treturn -ENODEV;\n-\n \tRTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_vfio_device_fd, -ENOTSUP);\n \tRTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP);\n \n",
    "prefixes": [
        "06/14"
    ]
}