Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/42305/?format=api
http://patches.dpdk.org/api/patches/42305/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180705083934.5535-5-adrien.mazarguil@6wind.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": "<20180705083934.5535-5-adrien.mazarguil@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20180705083934.5535-5-adrien.mazarguil@6wind.com", "date": "2018-07-05T08:45:31", "name": "[v4,04/10] net/mlx5: split PCI from generic probing code", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "1ba2c0d296b9d1df8d09bb4fb33b5970fc074766", "submitter": { "id": 165, "url": "http://patches.dpdk.org/api/people/165/?format=api", "name": "Adrien Mazarguil", "email": "adrien.mazarguil@6wind.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20180705083934.5535-5-adrien.mazarguil@6wind.com/mbox/", "series": [ { "id": 413, "url": "http://patches.dpdk.org/api/series/413/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=413", "date": "2018-07-05T08:45:22", "name": "net/mlx5: add port representor support", "version": 4, "mbox": "http://patches.dpdk.org/series/413/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/42305/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/42305/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 501091C38A;\n\tThu, 5 Jul 2018 10:45:50 +0200 (CEST)", "from mail-wm0-f65.google.com (mail-wm0-f65.google.com\n\t[74.125.82.65]) by dpdk.org (Postfix) with ESMTP id B63AF1C382\n\tfor <dev@dpdk.org>; Thu, 5 Jul 2018 10:45:48 +0200 (CEST)", "by mail-wm0-f65.google.com with SMTP id s12-v6so9716208wmc.1\n\tfor <dev@dpdk.org>; Thu, 05 Jul 2018 01:45:48 -0700 (PDT)", "from 6wind.com (host.78.145.23.62.rev.coltfrance.com.\n\t[62.23.145.78]) by smtp.gmail.com with ESMTPSA id\n\ts10-v6sm10165442wmb.12.2018.07.05.01.45.47\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 05 Jul 2018 01:45:47 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to;\n\tbh=WeDqRqvmdzsXRg7MOVj4HafcpqYPtVEfIa/BL915r50=;\n\tb=U+2tgo9qEAMbh5Y43XjgWFJ2nazL87NKgcslsyD/Uk8HEEnPowzLQSf5euQPC2L8vj\n\tw5ssEZbWSGKyHmZAPHe7AtMCUHug+aEeCC5gN2MFZvQUSeXD2EH7qmdQm950cAoEuyJb\n\tXcHdnp/KlIBVD77GPNfz2aNrVH2NOcq5mwvXg47zRKtL3YorrYtlakgGg6gIco8OQLrm\n\tpXQ13j6Ma+KOKdzdEBDnj8Bv6T7tESm4HPLvALSsQ5RoHN4OOn1VTu95c9B9Cv18et4I\n\tSRseEKWk5SRiObnQP9F2P4Qnv4DMnmtCV/ekVuFa4TF3OH0UMF5Y2D45BZllpXTiEqHQ\n\tBgbA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to;\n\tbh=WeDqRqvmdzsXRg7MOVj4HafcpqYPtVEfIa/BL915r50=;\n\tb=jlKl9rx2oGEAUZAYQ6Q9X3ipg+/OJkklDEDv27QKqwtM4aXP4a/UtqAcJkoi8fRvqI\n\tI/YhEqwZuSee6ObBcijxt54aEOixvvhnpBT05jMemDX0Ei0oK8Ql+WZmwIRVjHzqNFFh\n\tHCvgGl/QDH0NIZ0lII+vWCABK5Fejo2awfXoxYoFzSeFewfTBOLrD4wUUdpFu/6Uoh60\n\t8a8sUYrcXAzGZvZGquway5axekTWBz+lwYhbkpwcngicoynzlzuBuH/vccGhw8YqKrLr\n\ta4u3qONtzG+gX9hE+e1wDkUqhHWSgz+CJwsYaQowL5rRkHe2DLho9n5oz4M+w4cKixdB\n\tNeEg==", "X-Gm-Message-State": "APt69E2kQgXfY0FrhlngNhmByFlN73weYy5hlN7pjbObaFzp20fx13e2\n\t2LU7W1einEZO4Aa7/9+2hcgaqA==", "X-Google-Smtp-Source": "AAOMgpfrwWVB0gXB8r6jvpI34rDFM3vow5gpJ4KG8VQEjbf9s9mSDK08j9K+6+l1aVjOnUwx6FPg4g==", "X-Received": "by 2002:a1c:7409:: with SMTP id\n\tp9-v6mr3276156wmc.43.1530780348359; \n\tThu, 05 Jul 2018 01:45:48 -0700 (PDT)", "Date": "Thu, 5 Jul 2018 10:45:31 +0200", "From": "Adrien Mazarguil <adrien.mazarguil@6wind.com>", "To": "Shahaf Shuler <shahafs@mellanox.com>", "Cc": "dev@dpdk.org", "Message-ID": "<20180705083934.5535-5-adrien.mazarguil@6wind.com>", "References": "<20180704172322.22571-1-adrien.mazarguil@6wind.com>\n\t<20180705083934.5535-1-adrien.mazarguil@6wind.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=us-ascii", "Content-Disposition": "inline", "In-Reply-To": "<20180705083934.5535-1-adrien.mazarguil@6wind.com>", "X-Mailer": "git-send-email 2.11.0", "Subject": "[dpdk-dev] [PATCH v4 04/10] net/mlx5: split PCI from generic\n\tprobing code", "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "All the generic probing code needs is an IB device. While this device is\ncurrently supplied by a PCI lookup, other methods will be added soon.\n\nThis patch divides the original function, which has become huge over time,\nas follows:\n\n1. PCI-specific (mlx5_pci_probe()).\n2. Verbs device (mlx5_dev_spawn()).\n\n(Patch based on prior work from Yuanhan Liu)\n\nSigned-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>\nReviewed-by: Xueming Li <xuemingl@mellanox.com>\nCc: Shahaf Shuler <shahafs@mellanox.com>\n--\nv3 changes:\n\n- Moved VF device check within mlx5_pci_probe() after identifying the\n device instead of before that.\n- Merged mlx5_dev_spawn_one() with mlx5_dev_spawn() since there is no need\n anymore for an intermediate function to iterate over Verbs ports.\n\nv2 changes:\n\n- Fixed device naming. A port suffix is now appended only if several IB\n ports happen to be detected.\n- Added separate message to distinguish missing kernel drivers from other\n initialization errors, as it was confusing.\n---\n drivers/net/mlx5/mlx5.c | 195 ++++++++++++++++++++++++-------------------\n 1 file changed, 109 insertions(+), 86 deletions(-)", "diff": "diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 717d8b268..8916d4684 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -36,6 +36,7 @@\n #include <rte_kvargs.h>\n #include <rte_rwlock.h>\n #include <rte_spinlock.h>\n+#include <rte_string_fns.h>\n \n #include \"mlx5.h\"\n #include \"mlx5_utils.h\"\n@@ -635,32 +636,31 @@ mlx5_uar_init_secondary(struct rte_eth_dev *dev)\n }\n \n /**\n- * DPDK callback to register a PCI device.\n- *\n- * This function creates an Ethernet device for each port of a given\n- * PCI device.\n+ * Spawn an Ethernet device from Verbs information.\n *\n- * @param[in] pci_drv\n- * PCI driver structure (mlx5_driver).\n- * @param[in] pci_dev\n- * PCI device information.\n+ * @param dpdk_dev\n+ * Backing DPDK device.\n+ * @param ibv_dev\n+ * Verbs device.\n+ * @param vf\n+ * If nonzero, enable VF-specific features.\n *\n * @return\n- * 0 on success, a negative errno value otherwise and rte_errno is set.\n+ * A valid Ethernet device object on success, NULL otherwise and rte_errno\n+ * is set.\n */\n-static int\n-mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n-\t struct rte_pci_device *pci_dev)\n+static struct rte_eth_dev *\n+mlx5_dev_spawn(struct rte_device *dpdk_dev,\n+\t struct ibv_device *ibv_dev,\n+\t int vf)\n {\n-\tstruct ibv_device **list;\n-\tstruct ibv_context *ctx = NULL;\n+\tstruct ibv_context *ctx;\n \tstruct ibv_device_attr_ex attr;\n \tstruct ibv_pd *pd = NULL;\n \tstruct mlx5dv_context dv_attr = { .comp_mask = 0 };\n \tstruct rte_eth_dev *eth_dev = NULL;\n \tstruct priv *priv = NULL;\n \tint err = 0;\n-\tunsigned int vf = 0;\n \tunsigned int mps;\n \tunsigned int cqe_comp;\n \tunsigned int tunnel_en = 0;\n@@ -672,71 +672,18 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \tunsigned int mprq_max_stride_size_n = 0;\n \tunsigned int mprq_min_stride_num_n = 0;\n \tunsigned int mprq_max_stride_num_n = 0;\n-\tint i;\n #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT\n \tstruct ibv_counter_set_description cs_desc = { .counter_type = 0 };\n #endif\n \n \t/* Prepare shared data between primary and secondary process. */\n \tmlx5_prepare_shared_data();\n-\tassert(pci_drv == &mlx5_driver);\n-\tlist = mlx5_glue->get_device_list(&i);\n-\tif (list == NULL) {\n-\t\tassert(errno);\n-\t\terr = errno;\n-\t\tif (errno == ENOSYS)\n-\t\t\tDRV_LOG(ERR,\n-\t\t\t\t\"cannot list devices, is ib_uverbs loaded?\");\n-\t\tgoto error;\n-\t}\n-\tassert(i >= 0);\n-\t/*\n-\t * For each listed device, check related sysfs entry against\n-\t * the provided PCI ID.\n-\t */\n-\twhile (i != 0) {\n-\t\tstruct rte_pci_addr pci_addr;\n-\n-\t\t--i;\n-\t\tDRV_LOG(DEBUG, \"checking device \\\"%s\\\"\", list[i]->name);\n-\t\tif (mlx5_ibv_device_to_pci_addr(list[i], &pci_addr))\n-\t\t\tcontinue;\n-\t\tif ((pci_dev->addr.domain != pci_addr.domain) ||\n-\t\t (pci_dev->addr.bus != pci_addr.bus) ||\n-\t\t (pci_dev->addr.devid != pci_addr.devid) ||\n-\t\t (pci_dev->addr.function != pci_addr.function))\n-\t\t\tcontinue;\n-\t\tDRV_LOG(INFO, \"PCI information matches, using device \\\"%s\\\"\",\n-\t\t\tlist[i]->name);\n-\t\tvf = ((pci_dev->id.device_id ==\n-\t\t PCI_DEVICE_ID_MELLANOX_CONNECTX4VF) ||\n-\t\t (pci_dev->id.device_id ==\n-\t\t PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF) ||\n-\t\t (pci_dev->id.device_id ==\n-\t\t PCI_DEVICE_ID_MELLANOX_CONNECTX5VF) ||\n-\t\t (pci_dev->id.device_id ==\n-\t\t PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF));\n-\t\tctx = mlx5_glue->open_device(list[i]);\n-\t\trte_errno = errno;\n-\t\terr = rte_errno;\n-\t\tbreak;\n-\t}\n-\tmlx5_glue->free_device_list(list);\n-\tif (ctx == NULL) {\n-\t\tswitch (err) {\n-\t\tcase 0:\n-\t\t\tDRV_LOG(ERR,\n-\t\t\t\t\"cannot access device, is mlx5_ib loaded?\");\n-\t\t\terr = ENODEV;\n-\t\t\tbreak;\n-\t\tcase EINVAL:\n-\t\t\tDRV_LOG(ERR,\n-\t\t\t\t\"cannot use device, are drivers up to date?\");\n-\t\t\tbreak;\n-\t\t}\n-\t\tgoto error;\n+\terrno = 0;\n+\tctx = mlx5_glue->open_device(ibv_dev);\n+\tif (!ctx) {\n+\t\trte_errno = errno ? errno : ENODEV;\n+\t\treturn NULL;\n \t}\n-\tDRV_LOG(DEBUG, \"device opened\");\n #ifdef HAVE_IBV_MLX5_MOD_SWP\n \tdv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;\n #endif\n@@ -855,9 +802,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\t\t},\n \t\t};\n \n-\t\tsnprintf(name, sizeof(name), PCI_PRI_FMT,\n-\t\t\t pci_dev->addr.domain, pci_dev->addr.bus,\n-\t\t\t pci_dev->addr.devid, pci_dev->addr.function);\n+\t\trte_strlcpy(name, dpdk_dev->name, sizeof(name));\n \t\tif (rte_eal_process_type() == RTE_PROC_SECONDARY) {\n \t\t\teth_dev = rte_eth_dev_attach_secondary(name);\n \t\t\tif (eth_dev == NULL) {\n@@ -866,7 +811,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\t\t\terr = rte_errno;\n \t\t\t\tgoto error;\n \t\t\t}\n-\t\t\teth_dev->device = &pci_dev->device;\n+\t\t\teth_dev->device = dpdk_dev;\n \t\t\teth_dev->dev_ops = &mlx5_dev_sec_ops;\n \t\t\terr = mlx5_uar_init_secondary(eth_dev);\n \t\t\tif (err) {\n@@ -894,9 +839,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\t\t\tmlx5_select_rx_function(eth_dev);\n \t\t\teth_dev->tx_pkt_burst =\n \t\t\t\tmlx5_select_tx_function(eth_dev);\n-\t\t\trte_eth_dev_probing_finish(eth_dev);\n \t\t\tclaim_zero(mlx5_glue->close_device(ctx));\n-\t\t\treturn 0;\n+\t\t\treturn eth_dev;\n \t\t}\n \t\t/* Check port status. */\n \t\terr = mlx5_glue->query_port(ctx, 1, &port_attr);\n@@ -935,7 +879,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\tpriv->device_attr = attr;\n \t\tpriv->pd = pd;\n \t\tpriv->mtu = ETHER_MTU;\n-\t\terr = mlx5_args(&config, pci_dev->device.devargs);\n+\t\terr = mlx5_args(&config, dpdk_dev->devargs);\n \t\tif (err) {\n \t\t\terr = rte_errno;\n \t\t\tDRV_LOG(ERR, \"failed to process device arguments: %s\",\n@@ -1027,8 +971,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\teth_dev->data->dev_private = priv;\n \t\tpriv->dev_data = eth_dev->data;\n \t\teth_dev->data->mac_addrs = priv->mac;\n-\t\teth_dev->device = &pci_dev->device;\n-\t\trte_eth_copy_pci_info(eth_dev, pci_dev);\n+\t\teth_dev->device = dpdk_dev;\n \t\teth_dev->device->driver = &mlx5_driver.driver;\n \t\terr = mlx5_uar_init_primary(eth_dev);\n \t\tif (err) {\n@@ -1146,7 +1089,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\t\t\t priv, mem_event_cb);\n \t\trte_rwlock_write_unlock(&mlx5_shared_data->mem_event_rwlock);\n \t\trte_eth_dev_probing_finish(eth_dev);\n-\t\treturn 0;\n+\t\treturn eth_dev;\n \t}\n error:\n \tif (priv)\n@@ -1157,11 +1100,91 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\trte_eth_dev_release_port(eth_dev);\n \tif (ctx)\n \t\tclaim_zero(mlx5_glue->close_device(ctx));\n-\tif (err) {\n-\t\trte_errno = err;\n+\tassert(err > 0);\n+\trte_errno = err;\n+\treturn NULL;\n+}\n+\n+/**\n+ * DPDK callback to register a PCI device.\n+ *\n+ * This function spawns an Ethernet device out of a given PCI device.\n+ *\n+ * @param[in] pci_drv\n+ * PCI driver structure (mlx5_driver).\n+ * @param[in] pci_dev\n+ * PCI device information.\n+ *\n+ * @return\n+ * 0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+static int\n+mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n+\t struct rte_pci_device *pci_dev)\n+{\n+\tstruct ibv_device **ibv_list;\n+\tstruct rte_eth_dev *eth_dev = NULL;\n+\tint vf;\n+\tint ret;\n+\n+\tassert(pci_drv == &mlx5_driver);\n+\terrno = 0;\n+\tibv_list = mlx5_glue->get_device_list(&ret);\n+\tif (!ibv_list) {\n+\t\trte_errno = errno ? errno : ENOSYS;\n+\t\tDRV_LOG(ERR, \"cannot list devices, is ib_uverbs loaded?\");\n \t\treturn -rte_errno;\n \t}\n-\treturn 0;\n+\twhile (ret-- > 0) {\n+\t\tstruct rte_pci_addr pci_addr;\n+\n+\t\tDRV_LOG(DEBUG, \"checking device \\\"%s\\\"\", ibv_list[ret]->name);\n+\t\tif (mlx5_ibv_device_to_pci_addr(ibv_list[ret], &pci_addr))\n+\t\t\tcontinue;\n+\t\tif (pci_dev->addr.domain != pci_addr.domain ||\n+\t\t pci_dev->addr.bus != pci_addr.bus ||\n+\t\t pci_dev->addr.devid != pci_addr.devid ||\n+\t\t pci_dev->addr.function != pci_addr.function)\n+\t\t\tcontinue;\n+\t\tDRV_LOG(INFO, \"PCI information matches, using device \\\"%s\\\"\",\n+\t\t\tibv_list[ret]->name);\n+\t\tbreak;\n+\t}\n+\tswitch (pci_dev->id.device_id) {\n+\tcase PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:\n+\tcase PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF:\n+\tcase PCI_DEVICE_ID_MELLANOX_CONNECTX5VF:\n+\tcase PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF:\n+\t\tvf = 1;\n+\t\tbreak;\n+\tdefault:\n+\t\tvf = 0;\n+\t}\n+\tif (ret >= 0)\n+\t\teth_dev = mlx5_dev_spawn(&pci_dev->device, ibv_list[ret], vf);\n+\tmlx5_glue->free_device_list(ibv_list);\n+\tif (!ret) {\n+\t\tDRV_LOG(WARNING,\n+\t\t\t\"no Verbs device matches PCI device \" PCI_PRI_FMT \",\"\n+\t\t\t\" are kernel drivers loaded?\",\n+\t\t\tpci_dev->addr.domain, pci_dev->addr.bus,\n+\t\t\tpci_dev->addr.devid, pci_dev->addr.function);\n+\t\trte_errno = ENOENT;\n+\t\tret = -rte_errno;\n+\t} else if (!eth_dev) {\n+\t\tDRV_LOG(ERR,\n+\t\t\t\"probe of PCI device \" PCI_PRI_FMT \" aborted after\"\n+\t\t\t\" encountering an error: %s\",\n+\t\t\tpci_dev->addr.domain, pci_dev->addr.bus,\n+\t\t\tpci_dev->addr.devid, pci_dev->addr.function,\n+\t\t\tstrerror(rte_errno));\n+\t\tret = -rte_errno;\n+\t} else {\n+\t\trte_eth_copy_pci_info(eth_dev, pci_dev);\n+\t\trte_eth_dev_probing_finish(eth_dev);\n+\t\tret = 0;\n+\t}\n+\treturn ret;\n }\n \n static const struct rte_pci_id mlx5_pci_id_map[] = {\n", "prefixes": [ "v4", "04/10" ] }{ "id": 42305, "url": "