get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 19763,
    "url": "http://patches.dpdk.org/api/patches/19763/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1484801117-779-8-git-send-email-thomas.monjalon@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": "<1484801117-779-8-git-send-email-thomas.monjalon@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1484801117-779-8-git-send-email-thomas.monjalon@6wind.com",
    "date": "2017-01-19T04:45:11",
    "name": "[dpdk-dev,v11,07/13] pci: split match and probe",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1af6e86f8d34158502560ad0ce2e776dfba81792",
    "submitter": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/people/1/?format=api",
        "name": "Thomas Monjalon",
        "email": "thomas.monjalon@6wind.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1484801117-779-8-git-send-email-thomas.monjalon@6wind.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/19763/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/19763/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 96A2FFB51;\n\tThu, 19 Jan 2017 05:45:48 +0100 (CET)",
            "from mail-wm0-f45.google.com (mail-wm0-f45.google.com\n\t[74.125.82.45]) by dpdk.org (Postfix) with ESMTP id 8544CFB28\n\tfor <dev@dpdk.org>; Thu, 19 Jan 2017 05:45:29 +0100 (CET)",
            "by mail-wm0-f45.google.com with SMTP id c206so58681156wme.0\n\tfor <dev@dpdk.org>; Wed, 18 Jan 2017 20:45:29 -0800 (PST)",
            "from XPS13.localdomain (184.203.134.77.rev.sfr.net.\n\t[77.134.203.184]) by smtp.gmail.com with ESMTPSA id\n\tt194sm2568586wmd.1.2017.01.18.20.45.28\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 18 Jan 2017 20:45:28 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=6vAaKTJP0szH1XQ9JU1EPv0ERYRwLtyfJ/F5RbRuSDg=;\n\tb=pV7VrxSIdeCzcDgT2lZGWxkv99hZv8fVCcbIDH0JUj7npZArIyAc6rLT21ULmnqvz0\n\tTEbkZsc8kBSokkmo+R95d8S6ZAYTUBi3MO1HkLldv3ca1rqj+ctHd9rv7fGa+O28ByG9\n\tM6932CbXtVstusKYzfprpE0l6vXfkLDxPkvS/q/vk1sRW8scdUIrlppcxITbdLvQxlrb\n\tXyNezB5SlvrREWrU7UqMSd8rkYPIGS1bmGLwBUTMx20dAlUgUAwpQ2Yyfam/O4BXUX/y\n\tUxEoURQEBbLR/vOTANyBIgJZKEax7e0cFD/1EkgWsClpgMGAN15NTadcoRCeY+SPuxay\n\tSqnw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=6vAaKTJP0szH1XQ9JU1EPv0ERYRwLtyfJ/F5RbRuSDg=;\n\tb=Tznlf9YnYWzwG+r5KAYXwI+VvWXaWy17I6r7T4YNfTGTZRcgX3LmfjBMMfBhfK+AS3\n\tPWzvfy46pkn+D3bd7uXGVoICKDeahaUsWchbIO1g0eTBkXJbT7mVI4NwVsPMYh72bgIs\n\tEtVfZpkW0Mp3loDNjK14N6GrBY2yfwJnxK6nRNel/UW4dXFgWddBYzffN4Qm0cXJWjNW\n\tSANRQgrN8BUwQIre4XK+/P6rgOXrXa9E26063iQlvZQAPghH9w64lgbkiQYwdXUR6Gzs\n\tyqUmoQVYIAUJXSCPOYh2e4Ul1CtnnaQasyCsMy8ZzEpZImSXIusZ5kGgwPC+dxU9SFE5\n\tvitw==",
        "X-Gm-Message-State": "AIkVDXJ3XE42lKmnycTAGceZBpr29HXseTYCk/Do3/nzP9KYgcgokW0TqtbNWNlkQZvmf0lO",
        "X-Received": "by 10.223.129.4 with SMTP id 4mr6428673wrm.92.1484801129180;\n\tWed, 18 Jan 2017 20:45:29 -0800 (PST)",
        "From": "Thomas Monjalon <thomas.monjalon@6wind.com>",
        "To": "Shreyansh Jain <shreyansh.jain@nxp.com>",
        "Cc": "dev@dpdk.org",
        "Date": "Thu, 19 Jan 2017 05:45:11 +0100",
        "Message-Id": "<1484801117-779-8-git-send-email-thomas.monjalon@6wind.com>",
        "X-Mailer": "git-send-email 2.7.0",
        "In-Reply-To": "<1484801117-779-1-git-send-email-thomas.monjalon@6wind.com>",
        "References": "<1484748329-5418-1-git-send-email-shreyansh.jain@nxp.com>\n\t<1484801117-779-1-git-send-email-thomas.monjalon@6wind.com>",
        "Subject": "[dpdk-dev] [PATCH v11 07/13] pci: split match and probe",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Shreyansh Jain <shreyansh.jain@nxp.com>\n\nMatching of PCI device address and driver ID table is being done at two\ndiscreet locations duplicating the code. (rte_eal_pci_probe_one_driver\nand rte_eal_pci_detach_dev).\n\nSplitting the matching function into a public fn rte_pci_match.\n\nSigned-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>\nReviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>\n---\n lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +\n lib/librte_eal/common/eal_common_pci.c          | 189 +++++++++++++-----------\n lib/librte_eal/common/include/rte_pci.h         |  15 ++\n lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +\n 4 files changed, 121 insertions(+), 85 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\nindex a3d9fac..afa1643 100644\n--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n@@ -184,5 +184,6 @@ DPDK_17.02 {\n \trte_bus_register;\n \trte_bus_scan;\n \trte_bus_unregister;\n+\trte_pci_match;\n \n } DPDK_16.11;\ndiff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c\nindex 72547bd..4f155c6 100644\n--- a/lib/librte_eal/common/eal_common_pci.c\n+++ b/lib/librte_eal/common/eal_common_pci.c\n@@ -152,129 +152,148 @@ pci_unmap_resource(void *requested_addr, size_t size)\n \t\t\t\trequested_addr);\n }\n \n-/*\n- * If vendor/device ID match, call the probe() function of the\n- * driver.\n- */\n-static int\n-rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev)\n+int\n+rte_pci_match(const struct rte_pci_driver *pci_drv,\n+\t      const struct rte_pci_device *pci_dev)\n {\n-\tint ret;\n+\tint match = 1;\n \tconst struct rte_pci_id *id_table;\n \n-\tfor (id_table = dr->id_table; id_table->vendor_id != 0; id_table++) {\n+\tif (!pci_drv || !pci_dev || !pci_drv->id_table) {\n+\t\tRTE_LOG(DEBUG, EAL, \"Invalid PCI Driver object\\n\");\n+\t\treturn -1;\n+\t}\n \n+\tfor (id_table = pci_drv->id_table; id_table->vendor_id != 0;\n+\t     id_table++) {\n \t\t/* check if device's identifiers match the driver's ones */\n-\t\tif (id_table->vendor_id != dev->id.vendor_id &&\n+\t\tif (id_table->vendor_id != pci_dev->id.vendor_id &&\n \t\t\t\tid_table->vendor_id != PCI_ANY_ID)\n \t\t\tcontinue;\n-\t\tif (id_table->device_id != dev->id.device_id &&\n+\t\tif (id_table->device_id != pci_dev->id.device_id &&\n \t\t\t\tid_table->device_id != PCI_ANY_ID)\n \t\t\tcontinue;\n-\t\tif (id_table->subsystem_vendor_id != dev->id.subsystem_vendor_id &&\n-\t\t\t\tid_table->subsystem_vendor_id != PCI_ANY_ID)\n+\t\tif (id_table->subsystem_vendor_id !=\n+\t\t    pci_dev->id.subsystem_vendor_id &&\n+\t\t    id_table->subsystem_vendor_id != PCI_ANY_ID)\n \t\t\tcontinue;\n-\t\tif (id_table->subsystem_device_id != dev->id.subsystem_device_id &&\n-\t\t\t\tid_table->subsystem_device_id != PCI_ANY_ID)\n+\t\tif (id_table->subsystem_device_id !=\n+\t\t    pci_dev->id.subsystem_device_id &&\n+\t\t    id_table->subsystem_device_id != PCI_ANY_ID)\n \t\t\tcontinue;\n-\t\tif (id_table->class_id != dev->id.class_id &&\n+\t\tif (id_table->class_id != pci_dev->id.class_id &&\n \t\t\t\tid_table->class_id != RTE_CLASS_ANY_ID)\n \t\t\tcontinue;\n \n-\t\tstruct rte_pci_addr *loc = &dev->addr;\n-\n-\t\tRTE_LOG(INFO, EAL, \"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n-\t\t\t\tloc->domain, loc->bus, loc->devid, loc->function,\n-\t\t\t\tdev->device.numa_node);\n-\n-\t\t/* no initialization when blacklisted, return without error */\n-\t\tif (dev->device.devargs != NULL &&\n-\t\t\tdev->device.devargs->type ==\n-\t\t\t\tRTE_DEVTYPE_BLACKLISTED_PCI) {\n-\t\t\tRTE_LOG(INFO, EAL, \"  Device is blacklisted, not initializing\\n\");\n-\t\t\treturn 1;\n-\t\t}\n-\n-\t\tRTE_LOG(INFO, EAL, \"  probe driver: %x:%x %s\\n\", dev->id.vendor_id,\n-\t\t\t\tdev->id.device_id, dr->driver.name);\n-\n-\t\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {\n-\t\t\t/* map resources for devices that use igb_uio */\n-\t\t\tret = rte_eal_pci_map_device(dev);\n-\t\t\tif (ret != 0)\n-\t\t\t\treturn ret;\n-\t\t}\n-\n-\t\t/* reference driver structure */\n-\t\tdev->driver = dr;\n-\n-\t\t/* call the driver probe() function */\n-\t\tret = dr->probe(dr, dev);\n-\t\tif (ret) {\n-\t\t\tdev->driver = NULL;\n-\t\t\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)\n-\t\t\t\trte_eal_pci_unmap_device(dev);\n-\t\t}\n-\n-\t\treturn ret;\n+\t\tmatch = 0;\n+\t\tbreak;\n \t}\n-\t/* return positive value if driver doesn't support this device */\n-\treturn 1;\n+\n+\treturn match;\n }\n \n /*\n- * If vendor/device ID match, call the remove() function of the\n+ * If vendor/device ID match, call the probe() function of the\n  * driver.\n  */\n static int\n-rte_eal_pci_detach_dev(struct rte_pci_driver *dr,\n-\t\tstruct rte_pci_device *dev)\n+rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr,\n+\t\t\t     struct rte_pci_device *dev)\n {\n-\tconst struct rte_pci_id *id_table;\n+\tint ret;\n+\tstruct rte_pci_addr *loc;\n \n \tif ((dr == NULL) || (dev == NULL))\n \t\treturn -EINVAL;\n \n-\tfor (id_table = dr->id_table; id_table->vendor_id != 0; id_table++) {\n+\tloc = &dev->addr;\n \n-\t\t/* check if device's identifiers match the driver's ones */\n-\t\tif (id_table->vendor_id != dev->id.vendor_id &&\n-\t\t\t\tid_table->vendor_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->device_id != dev->id.device_id &&\n-\t\t\t\tid_table->device_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->subsystem_vendor_id != dev->id.subsystem_vendor_id &&\n-\t\t\t\tid_table->subsystem_vendor_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n-\t\tif (id_table->subsystem_device_id != dev->id.subsystem_device_id &&\n-\t\t\t\tid_table->subsystem_device_id != PCI_ANY_ID)\n-\t\t\tcontinue;\n+\t/* The device is not blacklisted; Check if driver supports it */\n+\tret = rte_pci_match(dr, dev);\n+\tif (ret) {\n+\t\t/* Match of device and driver failed */\n+\t\tRTE_LOG(DEBUG, EAL, \"Driver (%s) doesn't match the device\\n\",\n+\t\t\tdr->driver.name);\n+\t\treturn 1;\n+\t}\n \n-\t\tstruct rte_pci_addr *loc = &dev->addr;\n+\tRTE_LOG(INFO, EAL, \"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n+\t\t\tloc->domain, loc->bus, loc->devid, loc->function,\n+\t\t\tdev->device.numa_node);\n+\n+\t/* no initialization when blacklisted, return without error */\n+\tif (dev->device.devargs != NULL &&\n+\t\tdev->device.devargs->type ==\n+\t\t\tRTE_DEVTYPE_BLACKLISTED_PCI) {\n+\t\tRTE_LOG(INFO, EAL, \"  Device is blacklisted, not\"\n+\t\t\t\" initializing\\n\");\n+\t\treturn 1;\n+\t}\n \n-\t\tRTE_LOG(DEBUG, EAL, \"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n-\t\t\t\tloc->domain, loc->bus, loc->devid,\n-\t\t\t\tloc->function, dev->device.numa_node);\n+\tRTE_LOG(INFO, EAL, \"  probe driver: %x:%x %s\\n\", dev->id.vendor_id,\n+\t\tdev->id.device_id, dr->driver.name);\n \n-\t\tRTE_LOG(DEBUG, EAL, \"  remove driver: %x:%x %s\\n\", dev->id.vendor_id,\n-\t\t\t\tdev->id.device_id, dr->driver.name);\n+\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {\n+\t\t/* map resources for devices that use igb_uio */\n+\t\tret = rte_eal_pci_map_device(dev);\n+\t\tif (ret != 0)\n+\t\t\treturn ret;\n+\t}\n \n-\t\tif (dr->remove && (dr->remove(dev) < 0))\n-\t\t\treturn -1;\t/* negative value is an error */\n+\t/* reference driver structure */\n+\tdev->driver = dr;\n \n-\t\t/* clear driver structure */\n+\t/* call the driver probe() function */\n+\tret = dr->probe(dr, dev);\n+\tif (ret) {\n \t\tdev->driver = NULL;\n-\n \t\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)\n-\t\t\t/* unmap resources for devices that use igb_uio */\n \t\t\trte_eal_pci_unmap_device(dev);\n+\t}\n \n-\t\treturn 0;\n+\treturn ret;\n+}\n+\n+/*\n+ * If vendor/device ID match, call the remove() function of the\n+ * driver.\n+ */\n+static int\n+rte_eal_pci_detach_dev(struct rte_pci_driver *dr,\n+\t\tstruct rte_pci_device *dev)\n+{\n+\tint ret;\n+\tstruct rte_pci_addr *loc;\n+\n+\tif ((dr == NULL) || (dev == NULL))\n+\t\treturn -EINVAL;\n+\n+\tret = rte_pci_match(dr, dev);\n+\tif (ret) {\n+\t\t/* Device and driver don't match */\n+\t\treturn 1;\n \t}\n \n-\t/* return positive value if driver doesn't support this device */\n-\treturn 1;\n+\tloc = &dev->addr;\n+\n+\tRTE_LOG(DEBUG, EAL, \"PCI device \"PCI_PRI_FMT\" on NUMA socket %i\\n\",\n+\t\t\tloc->domain, loc->bus, loc->devid,\n+\t\t\tloc->function, dev->device.numa_node);\n+\n+\tRTE_LOG(DEBUG, EAL, \"  remove driver: %x:%x %s\\n\", dev->id.vendor_id,\n+\t\t\tdev->id.device_id, dr->driver.name);\n+\n+\tif (dr->remove && (dr->remove(dev) < 0))\n+\t\treturn -1;\t/* negative value is an error */\n+\n+\t/* clear driver structure */\n+\tdev->driver = NULL;\n+\n+\tif (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)\n+\t\t/* unmap resources for devices that use igb_uio */\n+\t\trte_eal_pci_unmap_device(dev);\n+\n+\treturn 0;\n }\n \n /*\ndiff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex 8557e47..adc20b9 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -371,6 +371,21 @@ rte_eal_compare_pci_addr(const struct rte_pci_addr *addr,\n int rte_eal_pci_scan(void);\n \n /**\n+ * Match the PCI Driver and Device using the ID Table\n+ *\n+ * @param pci_drv\n+ *\tPCI driver from which ID table would be extracted\n+ * @param pci_dev\n+ *\tPCI device to match against the driver\n+ * @return\n+ *\t0 for successful match\n+ *\t!0 for unsuccessful match\n+ */\n+int\n+rte_pci_match(const struct rte_pci_driver *pci_drv,\n+\t      const struct rte_pci_device *pci_dev);\n+\n+/**\n  * Probe the PCI bus for registered drivers.\n  *\n  * Scan the content of the PCI bus, and call the probe() function for\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 69e0e7b..b557e7c 100644\n--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n@@ -188,5 +188,6 @@ DPDK_17.02 {\n \trte_bus_register;\n \trte_bus_scan;\n \trte_bus_unregister;\n+\trte_pci_match;\n \n } DPDK_16.11;\n",
    "prefixes": [
        "dpdk-dev",
        "v11",
        "07/13"
    ]
}