Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/85564/?format=api
http://patches.dpdk.org/api/patches/85564/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20201220211405.313012-41-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": "<20201220211405.313012-41-maxime.coquelin@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20201220211405.313012-41-maxime.coquelin@redhat.com", "date": "2020-12-20T21:14:05", "name": "[40/40] net/virtio: move Vhost-vDPA data to its backend", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "59f4a65dc7cd07ddbb5fd0682fbf9e992b3bc1a8", "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/20201220211405.313012-41-maxime.coquelin@redhat.com/mbox/", "series": [ { "id": 14390, "url": "http://patches.dpdk.org/api/series/14390/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=14390", "date": "2020-12-20T21:13:25", "name": "net/virtio: Virtio PMD rework", "version": 1, "mbox": "http://patches.dpdk.org/series/14390/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/85564/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/85564/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 6C7E3A09FD;\n\tSun, 20 Dec 2020 22:26:43 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6E873CF35;\n\tSun, 20 Dec 2020 22:16:57 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [63.128.21.124])\n by dpdk.org (Postfix) with ESMTP id 32BC2CBD5\n for <dev@dpdk.org>; Sun, 20 Dec 2020 22:16:55 +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-266-xWEizeeFOgO_h7GgV4BfUA-1; Sun, 20 Dec 2020 16:16:51 -0500", "from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com\n [10.5.11.12])\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 CADFE107ACE4;\n Sun, 20 Dec 2020 21:16:50 +0000 (UTC)", "from max-t490s.redhat.com (unknown [10.36.110.43])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 2F4D760C43;\n Sun, 20 Dec 2020 21:16:49 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1608499013;\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=Du6jgHnLunRZTqxTD+BLL6HlxAimplNRvn1H5akPA0I=;\n b=JWj4NnYeZdlr25lLNaW0T83gdmpMJU09/Skrsdn0qZRQGzjNLizkT8MgxFg0jBJzkl7WlX\n A+wU/B0A7wlr+UbQ2zTs66UB06lnZf+90FwcHOETaqogU/skOTcdifOvKtLaRC5IOtELc8\n JSN1NBOObR0v0hqz1IZ7xqP01DYhxbo=", "X-MC-Unique": "xWEizeeFOgO_h7GgV4BfUA-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": "Sun, 20 Dec 2020 22:14:05 +0100", "Message-Id": "<20201220211405.313012-41-maxime.coquelin@redhat.com>", "In-Reply-To": "<20201220211405.313012-1-maxime.coquelin@redhat.com>", "References": "<20201220211405.313012-1-maxime.coquelin@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.12", "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 40/40] net/virtio: move Vhost-vDPA data to its\n\tbackend", "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": "As done earlier for Vhost-user and Vhost-kernel, this\npatch moves the Vhost-vDPA specific data to its backend\nfile.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n drivers/net/virtio/virtio_user/vhost_vdpa.c | 77 ++++++++++++++-----\n .../net/virtio/virtio_user/virtio_user_dev.h | 3 -\n 2 files changed, 58 insertions(+), 22 deletions(-)", "diff": "diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c b/drivers/net/virtio/virtio_user/vhost_vdpa.c\nindex 0f422ae84a..c9738b462a 100644\n--- a/drivers/net/virtio/virtio_user/vhost_vdpa.c\n+++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c\n@@ -13,6 +13,10 @@\n #include \"vhost.h\"\n #include \"virtio_user_dev.h\"\n \n+struct vhost_vdpa_data {\n+\tint vhostfd;\n+};\n+\n /* vhost kernel & vdpa ioctls */\n #define VHOST_VIRTIO 0xAF\n #define VHOST_GET_FEATURES _IOR(VHOST_VIRTIO, 0x00, __u64)\n@@ -80,15 +84,18 @@ vhost_vdpa_ioctl(int fd, uint64_t request, void *arg)\n static int\n vhost_vdpa_set_owner(struct virtio_user_dev *dev)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_OWNER, NULL);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_OWNER, NULL);\n }\n \n static int\n vhost_vdpa_get_features(struct virtio_user_dev *dev, uint64_t *features)\n {\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n \tint ret;\n \n-\tret = vhost_vdpa_ioctl(dev->vhostfd, VHOST_GET_FEATURES, features);\n+\tret = vhost_vdpa_ioctl(data->vhostfd, VHOST_GET_FEATURES, features);\n \tif (ret) {\n \t\tPMD_DRV_LOG(ERR, \"Failed to get features\");\n \t\treturn -1;\n@@ -103,16 +110,19 @@ vhost_vdpa_get_features(struct virtio_user_dev *dev, uint64_t *features)\n static int\n vhost_vdpa_set_features(struct virtio_user_dev *dev, uint64_t features)\n {\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n \t/* WORKAROUND */\n \tfeatures |= 1ULL << VIRTIO_F_IOMMU_PLATFORM;\n \n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_FEATURES, &features);\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_FEATURES, &features);\n }\n \n static int\n vhost_vdpa_dma_map(struct virtio_user_dev *dev, void *addr,\n \t\t\t\t uint64_t iova, size_t len)\n {\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n \tstruct vhost_msg msg = {};\n \n \tmsg.type = VHOST_IOTLB_MSG_V2;\n@@ -122,7 +132,7 @@ vhost_vdpa_dma_map(struct virtio_user_dev *dev, void *addr,\n \tmsg.iotlb.size = len;\n \tmsg.iotlb.perm = VHOST_ACCESS_RW;\n \n-\tif (write(dev->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {\n+\tif (write(data->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {\n \t\tPMD_DRV_LOG(ERR, \"Failed to send IOTLB update (%s)\",\n \t\t\t\tstrerror(errno));\n \t\treturn -1;\n@@ -135,6 +145,7 @@ static int\n vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, __rte_unused void *addr,\n \t\t\t\t uint64_t iova, size_t len)\n {\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n \tstruct vhost_msg msg = {};\n \n \tmsg.type = VHOST_IOTLB_MSG_V2;\n@@ -142,7 +153,7 @@ vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, __rte_unused void *addr,\n \tmsg.iotlb.iova = iova;\n \tmsg.iotlb.size = len;\n \n-\tif (write(dev->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {\n+\tif (write(data->vhostfd, &msg, sizeof(msg)) != sizeof(msg)) {\n \t\tPMD_DRV_LOG(ERR, \"Failed to send IOTLB invalidate (%s)\",\n \t\t\t\tstrerror(errno));\n \t\treturn -1;\n@@ -208,55 +219,73 @@ vhost_vdpa_set_memory_table(struct virtio_user_dev *dev)\n static int\n vhost_vdpa_set_vring_enable(struct virtio_user_dev *dev, struct vhost_vring_state *state)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_VDPA_SET_VRING_ENABLE, state);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_VDPA_SET_VRING_ENABLE, state);\n }\n \n static int\n vhost_vdpa_set_vring_num(struct virtio_user_dev *dev, struct vhost_vring_state *state)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_VRING_NUM, state);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_VRING_NUM, state);\n }\n \n static int\n vhost_vdpa_set_vring_base(struct virtio_user_dev *dev, struct vhost_vring_state *state)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_VRING_BASE, state);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_VRING_BASE, state);\n }\n \n static int\n vhost_vdpa_get_vring_base(struct virtio_user_dev *dev, struct vhost_vring_state *state)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_GET_VRING_BASE, state);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_GET_VRING_BASE, state);\n }\n \n static int\n vhost_vdpa_set_vring_call(struct virtio_user_dev *dev, struct vhost_vring_file *file)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_VRING_CALL, file);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_VRING_CALL, file);\n }\n \n static int\n vhost_vdpa_set_vring_kick(struct virtio_user_dev *dev, struct vhost_vring_file *file)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_VRING_KICK, file);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_VRING_KICK, file);\n }\n \n static int\n vhost_vdpa_set_vring_addr(struct virtio_user_dev *dev, struct vhost_vring_addr *addr)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_SET_VRING_ADDR, addr);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_SET_VRING_ADDR, addr);\n }\n \n static int\n vhost_vdpa_get_status(struct virtio_user_dev *dev, uint8_t *status)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_VDPA_GET_STATUS, status);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_VDPA_GET_STATUS, status);\n }\n \n static int\n vhost_vdpa_set_status(struct virtio_user_dev *dev, uint8_t status)\n {\n-\treturn vhost_vdpa_ioctl(dev->vhostfd, VHOST_VDPA_SET_STATUS, &status);\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\treturn vhost_vdpa_ioctl(data->vhostfd, VHOST_VDPA_SET_STATUS, &status);\n }\n \n /**\n@@ -269,16 +298,23 @@ vhost_vdpa_set_status(struct virtio_user_dev *dev, uint8_t status)\n static int\n vhost_vdpa_setup(struct virtio_user_dev *dev)\n {\n+\tstruct vhost_vdpa_data *data;\n \tuint32_t did = (uint32_t)-1;\n \n-\tdev->vhostfd = open(dev->path, O_RDWR);\n-\tif (dev->vhostfd < 0) {\n+\tdata = malloc(sizeof(*data));\n+\tif (!data) {\n+\t\tPMD_DRV_LOG(ERR, \"(%s) Faidle to allocate backend data\", dev->path);\n+\t\treturn -1;\n+\t}\n+\n+\tdata->vhostfd = open(dev->path, O_RDWR);\n+\tif (data->vhostfd < 0) {\n \t\tPMD_DRV_LOG(ERR, \"Failed to open %s: %s\\n\",\n \t\t\t\tdev->path, strerror(errno));\n \t\treturn -1;\n \t}\n \n-\tif (ioctl(dev->vhostfd, VHOST_VDPA_GET_DEVICE_ID, &did) < 0 ||\n+\tif (ioctl(data->vhostfd, VHOST_VDPA_GET_DEVICE_ID, &did) < 0 ||\n \t\t\tdid != VIRTIO_ID_NETWORK) {\n \t\tPMD_DRV_LOG(ERR, \"Invalid vdpa device ID: %u\\n\", did);\n \t\treturn -1;\n@@ -288,9 +324,12 @@ vhost_vdpa_setup(struct virtio_user_dev *dev)\n }\n \n static int\n-vhost_vdpa_destroy(struct virtio_user_dev *dev __rte_unused)\n+vhost_vdpa_destroy(struct virtio_user_dev *dev )\n {\n-\treturn;\n+\tstruct vhost_vdpa_data *data = dev->backend_data;\n+\n+\tclose(data->vhostfd);\n+\n \treturn 0;\n }\n \ndiff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h\nindex 5a2c9d38dd..2e0d6504f6 100644\n--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h\n+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h\n@@ -28,9 +28,6 @@ struct virtio_user_dev {\n \tenum virtio_user_backend_type backend_type;\n \tbool\t\tis_server; /* server or client mode */\n \n-\t/* for vhost_vdpa backend */\n-\tint\t\tvhostfd;\n-\n \t/* for both vhost_user and vhost_kernel */\n \tint\t\tcallfds[VIRTIO_MAX_VIRTQUEUES];\n \tint\t\tkickfds[VIRTIO_MAX_VIRTQUEUES];\n", "prefixes": [ "40/40" ] }{ "id": 85564, "url": "