get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 42259,
    "url": "http://patches.dpdk.org/api/patches/42259/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20180704172322.22571-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": "<20180704172322.22571-5-adrien.mazarguil@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180704172322.22571-5-adrien.mazarguil@6wind.com",
    "date": "2018-07-04T17:27:40",
    "name": "[v3,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/20180704172322.22571-5-adrien.mazarguil@6wind.com/mbox/",
    "series": [
        {
            "id": 402,
            "url": "http://patches.dpdk.org/api/series/402/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=402",
            "date": "2018-07-04T17:27:32",
            "name": "net/mlx5: add port representor support",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/402/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/42259/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/42259/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 51BB61BF59;\n\tWed,  4 Jul 2018 19:27:59 +0200 (CEST)",
            "from mail-wm0-f66.google.com (mail-wm0-f66.google.com\n\t[74.125.82.66]) by dpdk.org (Postfix) with ESMTP id A75D01BF23\n\tfor <dev@dpdk.org>; Wed,  4 Jul 2018 19:27:57 +0200 (CEST)",
            "by mail-wm0-f66.google.com with SMTP id v25-v6so7147830wmc.0\n\tfor <dev@dpdk.org>; Wed, 04 Jul 2018 10:27:57 -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\tv15-v6sm3008635wmc.16.2018.07.04.10.27.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tWed, 04 Jul 2018 10:27:56 -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=fT1UOIK/XCbuOKTx0zT7+xbKpOhTb8rdQQ55imjh3+B6D6OvOSQJEwmFxzCcDBmRNQ\n\tV5b1w9W8hcRUvktSGaKhAdUGBjPy9+0dmdPozZ7LAB/Ovvz6sKkQA8GG0wRkK24x0tdn\n\t0B7eeGia4LbQmSVgfwh7ag9cXpfcv1iMYnMFmrnvn0T7wgDDzKeN6JCW3WNRBEJnFPhe\n\tuziq6p1IkkVh8/kKqKEV/HdIdgRSUHYs82pHyV9R/xPiQ6oUPVekeHo8Mn76pShRfdgs\n\tS1E/OaGc+xiP0DDDPsOtSV1YbB3m+pkgcqYtKvFmEVZ8TtgvAwuZXUr9sNKYKaG6eMC7\n\tkzBA==",
        "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=eN+Fwl7rc+aSjpOFSwoBCOOzDvIFZ1jp7rOPo+ptSYWT3tdPUizoID6TQvqoeZMNLP\n\t3PvWDZWi8MnBahujyQR0Z5AAZCIfOKtD9zoEUlmnPVPcb1GGFYHVv8WJAJLvFofAf4dw\n\tPihvvk4DD2QcdVMQLNirncfRuuQeIeNHCd61QWL+e7ehtwpu+tZ+iIPN1j7FqChLov30\n\tzmnGrnGXQCwP36at58c+LGiXyX0QbuIVYl/I10N3rDJMes4zn9VrW6zsHSUOUpSnio5r\n\txCaO8qGmbq2NcR04bB9BLp35FRwdIixO8SaL6+DrrgTwv3qsLOfviFX6a59zmfiWyE6z\n\tO3RA==",
        "X-Gm-Message-State": "APt69E3rFH9SacD9VL05YwPWiXrbD3Y6crCKD2S/SZpxTVNcfMs95+2l\n\t5L0T9V+9/aVTto+Hu7ivolKO2q2M",
        "X-Google-Smtp-Source": "AAOMgpfJxWMqh29FOP/w51VTzEAHsdcOY7S69KLmGccmKMnFp2QhYF4SIivMTGL5flgp1GtoHCZkUg==",
        "X-Received": "by 2002:a1c:8893:: with SMTP id\n\tk141-v6mr2203134wmd.36.1530725277297; \n\tWed, 04 Jul 2018 10:27:57 -0700 (PDT)",
        "Date": "Wed, 4 Jul 2018 19:27:40 +0200",
        "From": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "To": "Shahaf Shuler <shahafs@mellanox.com>",
        "Cc": "dev@dpdk.org",
        "Message-ID": "<20180704172322.22571-5-adrien.mazarguil@6wind.com>",
        "References": "<20180614083047.10812-1-adrien.mazarguil@6wind.com>\n\t<20180704172322.22571-1-adrien.mazarguil@6wind.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=us-ascii",
        "Content-Disposition": "inline",
        "In-Reply-To": "<20180704172322.22571-1-adrien.mazarguil@6wind.com>",
        "X-Mailer": "git-send-email 2.11.0",
        "Subject": "[dpdk-dev] [PATCH v3 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": [
        "v3",
        "04/10"
    ]
}