Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/72249/?format=api
http://patches.dpdk.org/api/patches/72249/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200626140441.1441763-4-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-4-maxime.coquelin@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200626140441.1441763-4-maxime.coquelin@redhat.com", "date": "2020-06-26T14:04:30", "name": "[v3,03/14] vhost: introduce vDPA devices class", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "de7567fd45f1226eea4807a02cbe5b9c8eef8132", "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-4-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/72249/comments/", "check": "fail", "checks": "http://patches.dpdk.org/api/patches/72249/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 00DBCA051C;\n\tFri, 26 Jun 2020 16:05:31 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5DF6D1C029;\n\tFri, 26 Jun 2020 16:05:13 +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 11E011BFFF\n for <dev@dpdk.org>; Fri, 26 Jun 2020 16:05:08 +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-332-oOl5XxcvOYKvqe04LI7PfQ-1; Fri, 26 Jun 2020 10:05:06 -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 01223800D5C;\n Fri, 26 Jun 2020 14:05:05 +0000 (UTC)", "from localhost.localdomain (unknown [10.36.110.7])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 289D580882;\n Fri, 26 Jun 2020 14:04:58 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1593180308;\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=a11ps+nTW+xpyUwaJvAVwALxg76U10DOIwPcCvQkmK4=;\n b=XXbe46Aiv9kOCoTdD1lvYYOKxfSxLPzhuE7LsDSNmaEg/NU392RW0c4Av/F4wdwycYzYeH\n p/Zh7aFnSUyl59YsvD/DmZdeBG8E+TdY96zzAFeNF2AsmeGibHWHpiDJPeKRRfzTCqvGKl\n gzZ3R/YCb883ZjWaCGNOP1XvaYX7z6k=", "X-MC-Unique": "oOl5XxcvOYKvqe04LI7PfQ-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:30 +0200", "Message-Id": "<20200626140441.1441763-4-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=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v3 03/14] vhost: introduce vDPA devices class", "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 introduces vDPA device class. It will enable\napplication to iterate over the vDPA devices.\n\nAcked-by: Adrián Moreno <amorenoz@redhat.com>\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/librte_vhost/vdpa.c | 115 +++++++++++++++++++++++++++++++++-------\n 1 file changed, 97 insertions(+), 18 deletions(-)", "diff": "diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c\nindex 1f5cdcd64b..a429841691 100644\n--- a/lib/librte_vhost/vdpa.c\n+++ b/lib/librte_vhost/vdpa.c\n@@ -10,11 +10,12 @@\n \n #include <stdbool.h>\n \n+#include <rte_class.h>\n #include <rte_malloc.h>\n #include \"rte_vdpa.h\"\n #include \"vhost.h\"\n \n-static struct rte_vdpa_device *vdpa_devices[MAX_VHOST_DEVICE];\n+static struct rte_vdpa_device vdpa_devices[MAX_VHOST_DEVICE];\n static uint32_t vdpa_device_num;\n \n static bool\n@@ -46,35 +47,28 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,\n \t\tstruct rte_vdpa_dev_ops *ops)\n {\n \tstruct rte_vdpa_device *dev;\n-\tchar device_name[MAX_VDPA_NAME_LEN];\n \tint i;\n \n \tif (vdpa_device_num >= MAX_VHOST_DEVICE || addr == NULL || ops == NULL)\n \t\treturn -1;\n \n \tfor (i = 0; i < MAX_VHOST_DEVICE; i++) {\n-\t\tdev = vdpa_devices[i];\n-\t\tif (dev && is_same_vdpa_device(&dev->addr, addr))\n+\t\tdev = &vdpa_devices[i];\n+\t\tif (dev->ops && is_same_vdpa_device(&dev->addr, addr))\n \t\t\treturn -1;\n \t}\n \n \tfor (i = 0; i < MAX_VHOST_DEVICE; i++) {\n-\t\tif (vdpa_devices[i] == NULL)\n+\t\tif (vdpa_devices[i].ops == NULL)\n \t\t\tbreak;\n \t}\n \n \tif (i == MAX_VHOST_DEVICE)\n \t\treturn -1;\n \n-\tsnprintf(device_name, sizeof(device_name), \"vdpa-dev-%d\", i);\n-\tdev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device),\n-\t\t\tRTE_CACHE_LINE_SIZE);\n-\tif (!dev)\n-\t\treturn -1;\n-\n+\tdev = &vdpa_devices[i];\n \tmemcpy(&dev->addr, addr, sizeof(struct rte_vdpa_dev_addr));\n \tdev->ops = ops;\n-\tvdpa_devices[i] = dev;\n \tvdpa_device_num++;\n \n \treturn i;\n@@ -83,11 +77,10 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,\n int\n rte_vdpa_unregister_device(int did)\n {\n-\tif (did < 0 || did >= MAX_VHOST_DEVICE || vdpa_devices[did] == NULL)\n+\tif (did < 0 || did >= MAX_VHOST_DEVICE || vdpa_devices[did].ops == NULL)\n \t\treturn -1;\n \n-\trte_free(vdpa_devices[did]);\n-\tvdpa_devices[did] = NULL;\n+\tmemset(&vdpa_devices[did], 0, sizeof(struct rte_vdpa_device));\n \tvdpa_device_num--;\n \n \treturn did;\n@@ -103,8 +96,11 @@ rte_vdpa_find_device_id(struct rte_vdpa_dev_addr *addr)\n \t\treturn -1;\n \n \tfor (i = 0; i < MAX_VHOST_DEVICE; ++i) {\n-\t\tdev = vdpa_devices[i];\n-\t\tif (dev && is_same_vdpa_device(&dev->addr, addr))\n+\t\tdev = &vdpa_devices[i];\n+\t\tif (dev->ops == NULL)\n+\t\t\tcontinue;\n+\n+\t\tif (is_same_vdpa_device(&dev->addr, addr))\n \t\t\treturn i;\n \t}\n \n@@ -117,7 +113,7 @@ rte_vdpa_get_device(int did)\n \tif (did < 0 || did >= MAX_VHOST_DEVICE)\n \t\treturn NULL;\n \n-\treturn vdpa_devices[did];\n+\treturn &vdpa_devices[did];\n }\n \n int\n@@ -274,3 +270,86 @@ rte_vdpa_reset_stats(int did, uint16_t qid)\n \n \treturn vdpa_dev->ops->reset_stats(did, 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+{\n+\tstruct rte_vdpa_dev_addr addr;\n+\n+\t/* Only PCI bus supported for now */\n+\tif (strcmp(rte_dev->bus->name, \"pci\") != 0)\n+\t\treturn -1;\n+\n+\taddr.type = VDPA_ADDR_PCI;\n+\n+\tif (rte_pci_addr_parse(rte_dev->name, &addr.pci_addr) != 0)\n+\t\treturn -1;\n+\n+\tif (!is_same_vdpa_device(&dev->addr, &addr))\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/* Generic rte_vdpa_dev comparison function. */\n+typedef int (*rte_vdpa_cmp_t)(struct rte_vdpa_device *,\n+\t\tconst struct rte_device *rte_dev);\n+\n+static struct rte_vdpa_device *\n+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+\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\tif (cmp(dev, rte_dev) == 0)\n+\t\t\treturn dev;\n+\t}\n+\treturn NULL;\n+}\n+\n+static void *\n+vdpa_dev_iterate(const void *start,\n+\t\tconst char *str,\n+\t\tconst struct rte_dev_iterator *it)\n+{\n+\tstruct rte_vdpa_device *vdpa_dev = NULL;\n+\n+\tRTE_SET_USED(str);\n+\n+\tvdpa_dev = vdpa_find_device(start, vdpa_dev_match, it->device);\n+\n+\treturn vdpa_dev;\n+}\n+\n+static struct rte_class rte_class_vdpa = {\n+\t.dev_iterate = vdpa_dev_iterate,\n+};\n+\n+RTE_REGISTER_CLASS(vdpa, rte_class_vdpa);\n", "prefixes": [ "v3", "03/14" ] }{ "id": 72249, "url": "