Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/72255/?format=api
http://patches.dpdk.org/api/patches/72255/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200626140441.1441763-10-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-10-maxime.coquelin@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200626140441.1441763-10-maxime.coquelin@redhat.com", "date": "2020-06-26T14:04:36", "name": "[v3,09/14] vhost: use linked-list for vDPA devices", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "fbe981275b5184d2603771a2fadc84fcefb237ce", "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-10-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/72255/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/72255/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 CE28BA051C;\n\tFri, 26 Jun 2020 16:07:06 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 476281C0C6;\n\tFri, 26 Jun 2020 16:06:03 +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 2C29D1BFC8\n for <dev@dpdk.org>; Fri, 26 Jun 2020 16:06:01 +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-486-dMquNgsvMV29ce5j6-Hc0A-1; Fri, 26 Jun 2020 10:05:59 -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 A53F71883625;\n Fri, 26 Jun 2020 14:05:57 +0000 (UTC)", "from localhost.localdomain (unknown [10.36.110.7])\n by smtp.corp.redhat.com (Postfix) with ESMTP id EF5E35BAE1;\n Fri, 26 Jun 2020 14:05:46 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1593180360;\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=gcTclqgfzyl1twdC/7nu7+BqHHV77Ij8XRkKTfyuyfA=;\n b=Of6Nv3G77lwBM69fqvW06b2o7piQKvX3f3wqtUEWbihVBnI/l0bNdH3z2AyRChShAa5XU3\n Wn2AmFx98YBUMRlVv0CLBGra5I+X2q6Ir5UVf6I7RAwbpZHLeILigXI6rZWpPPsPuxIw+E\n G1EbOnW/cDRd3Lqzw+dYRHWWDvR4IOM=", "X-MC-Unique": "dMquNgsvMV29ce5j6-Hc0A-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:36 +0200", "Message-Id": "<20200626140441.1441763-10-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", "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 v3 09/14] vhost: use linked-list for vDPA devices", "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": "There is no more notion of device ID outside of vdpa.c.\nWe can now move from array to linked-list model for keeping\ntrack of the vDPA devices.\n\nThere is no point in using array here, as all vDPA API are\nused from the control path, so no performance concerns.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/rte_vdpa.h | 1 +\n lib/librte_vhost/vdpa.c | 134 +++++++++++++++++++-----------------\n 2 files changed, 70 insertions(+), 65 deletions(-)", "diff": "diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h\nindex da8ee33ab1..dbdc273702 100644\n--- a/lib/librte_vhost/rte_vdpa.h\n+++ b/lib/librte_vhost/rte_vdpa.h\n@@ -105,6 +105,7 @@ struct rte_vdpa_dev_ops {\n * vdpa device structure includes device address and device operations.\n */\n struct rte_vdpa_device {\n+\tTAILQ_ENTRY(rte_vdpa_device) next;\n \t/** Generic device information */\n \tstruct rte_device *device;\n \t/** vdpa device operations */\ndiff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c\nindex bed20a3103..72561552c3 100644\n--- a/lib/librte_vhost/vdpa.c\n+++ b/lib/librte_vhost/vdpa.c\n@@ -9,35 +9,54 @@\n */\n \n #include <stdbool.h>\n+#include <sys/queue.h>\n \n #include <rte_class.h>\n #include <rte_malloc.h>\n+#include <rte_spinlock.h>\n+#include <rte_tailq.h>\n+\n #include \"rte_vdpa.h\"\n #include \"vhost.h\"\n \n-static struct rte_vdpa_device vdpa_devices[MAX_VHOST_DEVICE];\n+/** Double linked list of vDPA devices. */\n+TAILQ_HEAD(vdpa_device_list, rte_vdpa_device);\n+\n+static struct vdpa_device_list vdpa_device_list =\n+\t\tTAILQ_HEAD_INITIALIZER(vdpa_device_list);\n+static rte_spinlock_t vdpa_device_list_lock = RTE_SPINLOCK_INITIALIZER;\n static uint32_t vdpa_device_num;\n \n \n-struct rte_vdpa_device *\n-rte_vdpa_find_device_by_name(const char *name)\n+/* Unsafe, needs to be called with vdpa_device_list_lock held */\n+static struct rte_vdpa_device *\n+__vdpa_find_device_by_name(const char *name)\n {\n-\tstruct rte_vdpa_device *dev;\n-\tint i;\n+\tstruct rte_vdpa_device *dev, *ret = NULL;\n \n \tif (name == NULL)\n \t\treturn NULL;\n \n-\tfor (i = 0; i < MAX_VHOST_DEVICE; ++i) {\n-\t\tdev = &vdpa_devices[i];\n-\t\tif (dev->ops == NULL)\n-\t\t\tcontinue;\n-\n-\t\tif (strncmp(dev->device->name, name, RTE_DEV_NAME_MAX_LEN) == 0)\n-\t\t\treturn dev;\n+\tTAILQ_FOREACH(dev, &vdpa_device_list, next) {\n+\t\tif (!strncmp(dev->device->name, name, RTE_DEV_NAME_MAX_LEN)) {\n+\t\t\tret = dev;\n+\t\t\tbreak;\n+\t\t}\n \t}\n \n-\treturn NULL;\n+\treturn ret;\n+}\n+\n+struct rte_vdpa_device *\n+rte_vdpa_find_device_by_name(const char *name)\n+{\n+\tstruct rte_vdpa_device *dev;\n+\n+\trte_spinlock_lock(&vdpa_device_list_lock);\n+\tdev = __vdpa_find_device_by_name(name);\n+\trte_spinlock_unlock(&vdpa_device_list_lock);\n+\n+\treturn dev;\n }\n \n struct rte_device *\n@@ -54,52 +73,52 @@ rte_vdpa_register_device(struct rte_device *rte_dev,\n \t\tstruct rte_vdpa_dev_ops *ops)\n {\n \tstruct rte_vdpa_device *dev;\n-\tint i;\n \n-\tif (vdpa_device_num >= MAX_VHOST_DEVICE || ops == NULL)\n+\tif (ops == NULL)\n \t\treturn NULL;\n \n-\tfor (i = 0; i < MAX_VHOST_DEVICE; i++) {\n-\t\tdev = &vdpa_devices[i];\n-\t\tif (dev->ops == NULL)\n-\t\t\tcontinue;\n-\n-\t\tif (dev->device == rte_dev)\n-\t\t\treturn NULL;\n-\t}\n-\n-\tfor (i = 0; i < MAX_VHOST_DEVICE; i++) {\n-\t\tif (vdpa_devices[i].ops == NULL)\n-\t\t\tbreak;\n+\trte_spinlock_lock(&vdpa_device_list_lock);\n+\t/* Check the device hasn't been register already */\n+\tdev = __vdpa_find_device_by_name(rte_dev->name);\n+\tif (dev) {\n+\t\tdev = NULL;\n+\t\tgoto out_unlock;\n \t}\n \n-\tif (i == MAX_VHOST_DEVICE)\n-\t\treturn NULL;\n+\tdev = rte_zmalloc(NULL, sizeof(*dev), 0);\n+\tif (!dev)\n+\t\tgoto out_unlock;\n \n-\tdev = &vdpa_devices[i];\n \tdev->device = rte_dev;\n \tdev->ops = ops;\n+\tTAILQ_INSERT_TAIL(&vdpa_device_list, dev, next);\n \tvdpa_device_num++;\n+out_unlock:\n+\trte_spinlock_unlock(&vdpa_device_list_lock);\n \n \treturn dev;\n }\n \n int\n-rte_vdpa_unregister_device(struct rte_vdpa_device *vdev)\n+rte_vdpa_unregister_device(struct rte_vdpa_device *dev)\n {\n-\tint i;\n+\tstruct rte_vdpa_device *cur_dev, *tmp_dev;\n+\tint ret = -1;\n \n-\tfor (i = 0; i < MAX_VHOST_DEVICE; i++) {\n-\t\tif (vdev != &vdpa_devices[i])\n+\trte_spinlock_lock(&vdpa_device_list_lock);\n+\tTAILQ_FOREACH_SAFE(cur_dev, &vdpa_device_list, next, tmp_dev) {\n+\t\tif (dev != cur_dev)\n \t\t\tcontinue;\n \n-\t\tmemset(vdev, 0, sizeof(struct rte_vdpa_device));\n+\t\tTAILQ_REMOVE(&vdpa_device_list, dev, next);\n+\t\trte_free(dev);\n \t\tvdpa_device_num--;\n-\n-\t\treturn 0;\n+\t\tret = 0;\n+\t\tbreak;\n \t}\n+\trte_spinlock_unlock(&vdpa_device_list_lock);\n \n-\treturn -1;\n+\treturn ret;\n }\n \n int\n@@ -246,19 +265,6 @@ rte_vdpa_reset_stats(struct rte_vdpa_device *dev, uint16_t qid)\n \treturn dev->ops->reset_stats(dev, qid);\n }\n \n-static uint16_t\n-vdpa_dev_to_id(const struct rte_vdpa_device *dev)\n-{\n-\tif (dev == NULL)\n-\t\treturn MAX_VHOST_DEVICE;\n-\n-\tif (dev < &vdpa_devices[0] ||\n-\t\t\tdev >= &vdpa_devices[MAX_VHOST_DEVICE])\n-\t\treturn MAX_VHOST_DEVICE;\n-\n-\treturn (uint16_t)(dev - vdpa_devices);\n-}\n-\n static int\n vdpa_dev_match(struct rte_vdpa_device *dev,\n \t const struct rte_device *rte_dev)\n@@ -278,24 +284,22 @@ vdpa_find_device(const struct rte_vdpa_device *start, rte_vdpa_cmp_t cmp,\n \t\tstruct rte_device *rte_dev)\n {\n \tstruct rte_vdpa_device *dev;\n-\tuint16_t idx;\n \n-\tif (start != NULL)\n-\t\tidx = vdpa_dev_to_id(start) + 1;\n+\trte_spinlock_lock(&vdpa_device_list_lock);\n+\tif (start == NULL)\n+\t\tdev = TAILQ_FIRST(&vdpa_device_list);\n \telse\n-\t\tidx = 0;\n-\tfor (; idx < MAX_VHOST_DEVICE; idx++) {\n-\t\tdev = &vdpa_devices[idx];\n-\t\t/*\n-\t\t * ToDo: Certainly better to introduce a state field,\n-\t\t * but rely on ops being set for now.\n-\t\t */\n-\t\tif (dev->ops == NULL)\n-\t\t\tcontinue;\n+\t\tdev = TAILQ_NEXT(start, next);\n+\n+\twhile (dev != NULL) {\n \t\tif (cmp(dev, rte_dev) == 0)\n-\t\t\treturn dev;\n+\t\t\tbreak;\n+\n+\t\tdev = TAILQ_NEXT(dev, next);\n \t}\n-\treturn NULL;\n+\trte_spinlock_unlock(&vdpa_device_list_lock);\n+\n+\treturn dev;\n }\n \n static void *\n", "prefixes": [ "v3", "09/14" ] }{ "id": 72255, "url": "