get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 17196,
    "url": "https://patches.dpdk.org/api/patches/17196/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1479929804-19614-8-git-send-email-benjamin.walker@intel.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<1479929804-19614-8-git-send-email-benjamin.walker@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1479929804-19614-8-git-send-email-benjamin.walker@intel.com",
    "date": "2016-11-23T19:36:44",
    "name": "[dpdk-dev,7/7] pci: Clarify interfaces for dynamic attach/detach of drivers",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f539d9682289c7f4f36a1890c851ac6d7d0f6679",
    "submitter": {
        "id": 487,
        "url": "https://patches.dpdk.org/api/people/487/?format=api",
        "name": "Walker, Benjamin",
        "email": "benjamin.walker@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1479929804-19614-8-git-send-email-benjamin.walker@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/17196/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/17196/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 A0FF668F5;\n\tWed, 23 Nov 2016 20:37:28 +0100 (CET)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby dpdk.org (Postfix) with ESMTP id 6ECCF5598\n\tfor <dev@dpdk.org>; Wed, 23 Nov 2016 20:36:50 +0100 (CET)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga101.fm.intel.com with ESMTP; 23 Nov 2016 11:36:47 -0800",
            "from bwalker-desk.ch.intel.com ([143.182.137.60])\n\tby fmsmga001.fm.intel.com with ESMTP; 23 Nov 2016 11:36:47 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.31,539,1473145200\"; d=\"scan'208\";\n\ta=\"1072691993\"",
        "From": "Ben Walker <benjamin.walker@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Ben Walker <benjamin.walker@intel.com>",
        "Date": "Wed, 23 Nov 2016 12:36:44 -0700",
        "Message-Id": "<1479929804-19614-8-git-send-email-benjamin.walker@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1479929804-19614-1-git-send-email-benjamin.walker@intel.com>",
        "References": "<1479929804-19614-1-git-send-email-benjamin.walker@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 7/7] pci: Clarify interfaces for dynamic\n\tattach/detach of drivers",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <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": "There are now two functions - rte_eal_pci_attach_driver and\nrte_eal_pci_detach_driver - that dynamically attempt to attach\nand detach drivers from PCI devices. These only control\nwhether a registered PCI driver is loaded or not - they are\nindependent of whether the PCI device exists on the system.\n\nSigned-off-by: Ben Walker <benjamin.walker@intel.com>\n---\n lib/librte_eal/common/eal_common_dev.c  |   4 +-\n lib/librte_eal/common/eal_common_pci.c  | 111 +++++++++-----------------------\n lib/librte_eal/common/include/rte_pci.h |  22 ++++---\n 3 files changed, 45 insertions(+), 92 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c\nindex 4f3b493..1c6834e 100644\n--- a/lib/librte_eal/common/eal_common_dev.c\n+++ b/lib/librte_eal/common/eal_common_dev.c\n@@ -114,7 +114,7 @@ int rte_eal_dev_attach(const char *name, const char *devargs)\n \t}\n \n \tif (eal_parse_pci_DomBDF(name, &addr) == 0) {\n-\t\tif (rte_eal_pci_probe_one(&addr) < 0)\n+\t\tif (rte_eal_pci_attach_driver(&addr) < 0)\n \t\t\tgoto err;\n \n \t} else {\n@@ -139,7 +139,7 @@ int rte_eal_dev_detach(const char *name)\n \t}\n \n \tif (eal_parse_pci_DomBDF(name, &addr) == 0) {\n-\t\tif (rte_eal_pci_detach(&addr) < 0)\n+\t\tif (rte_eal_pci_detach_driver(&addr) < 0)\n \t\t\tgoto err;\n \t} else {\n \t\tif (rte_eal_vdev_uninit(name))\ndiff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c\nindex 62b996d..f2879af 100644\n--- a/lib/librte_eal/common/eal_common_pci.c\n+++ b/lib/librte_eal/common/eal_common_pci.c\n@@ -228,59 +228,37 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d\n \treturn 1;\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+rte_eal_pci_remove_driver(struct rte_pci_device *dev)\n {\n-\tconst struct rte_pci_id *id_table;\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-\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+\tstruct rte_pci_driver *driver;\n+\tstruct rte_pci_addr *loc;\n \n-\t\tstruct rte_pci_addr *loc = &dev->addr;\n+\tloc = &dev->addr;\n+\tdriver = dev->driver;\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+\tif (driver == NULL) {\n+\t\treturn 0;\n+\t}\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+\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-\t\tif (dr->remove && (dr->remove(dev) < 0))\n-\t\t\treturn -1;\t/* negative value is an error */\n+\tRTE_LOG(DEBUG, EAL, \"  remove driver: %x:%x %s\\n\", dev->id.vendor_id,\n+\t\t\tdev->id.device_id, driver->driver.name);\n \n-\t\t/* clear driver structure */\n-\t\tdev->driver = NULL;\n+\tif (driver->remove && (driver->remove(dev) < 0))\n+\t\treturn -1;\t/* negative value is an error */\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/* clear driver structure */\n+\tdev->driver = NULL;\n \n-\t\treturn 0;\n-\t}\n+\tif (driver->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-\t/* return positive value if driver doesn't support this device */\n-\treturn 1;\n+\treturn 0;\n }\n \n /*\n@@ -315,38 +293,11 @@ pci_probe_all_drivers(struct rte_pci_device *dev)\n }\n \n /*\n- * If vendor/device ID match, call the remove() function of all\n- * registered driver for the given device. Return -1 if initialization\n- * failed, return 1 if no driver is found for this device.\n- */\n-static int\n-pci_detach_all_drivers(struct rte_pci_device *dev)\n-{\n-\tstruct rte_pci_driver *dr = NULL;\n-\tint rc = 0;\n-\n-\tif (dev == NULL)\n-\t\treturn -1;\n-\n-\tTAILQ_FOREACH(dr, &pci_driver_list, next) {\n-\t\trc = rte_eal_pci_detach_dev(dr, dev);\n-\t\tif (rc < 0)\n-\t\t\t/* negative value is an error */\n-\t\t\treturn -1;\n-\t\tif (rc > 0)\n-\t\t\t/* positive value means driver doesn't support it */\n-\t\t\tcontinue;\n-\t\treturn 0;\n-\t}\n-\treturn 1;\n-}\n-\n-/*\n  * Find the pci device specified by pci address, then invoke probe function of\n  * the driver of the devive.\n  */\n int\n-rte_eal_pci_probe_one(const struct rte_pci_addr *addr)\n+rte_eal_pci_attach_driver(const struct rte_pci_addr *addr)\n {\n \tstruct rte_pci_device *dev = NULL;\n \tint ret = 0;\n@@ -382,10 +333,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)\n  * Detach device specified by its pci address.\n  */\n int\n-rte_eal_pci_detach(const struct rte_pci_addr *addr)\n+rte_eal_pci_detach_driver(const struct rte_pci_addr *addr)\n {\n \tstruct rte_pci_device *dev = NULL;\n-\tint ret = 0;\n \n \tif (addr == NULL)\n \t\treturn -1;\n@@ -394,17 +344,18 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr)\n \t\tif (rte_eal_compare_pci_addr(&dev->addr, addr))\n \t\t\tcontinue;\n \n-\t\tret = pci_detach_all_drivers(dev);\n-\t\tif (ret < 0)\n-\t\t\tgoto err_return;\n+\t\tif (dev->driver == NULL) {\n+\t\t\t/* The device at that address does not have a driver loaded */\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\tif (rte_eal_pci_remove_driver(dev) < 0) {\n+\t\t\treturn -1;\n+\t\t}\n \n-\t\tTAILQ_REMOVE(&pci_device_list, dev, next);\n-\t\tfree(dev);\n \t\treturn 0;\n \t}\n-\treturn -1;\n \n-err_return:\n \tRTE_LOG(WARNING, EAL, \"Requested device \" PCI_PRI_FMT\n \t\t\t\" cannot be used\\n\", dev->addr.domain, dev->addr.bus,\n \t\t\tdev->addr.devid, dev->addr.function);\ndiff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex 2154a54..e304853 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -459,11 +459,14 @@ void *pci_map_resource(void *requested_addr, int fd, off_t offset,\n void pci_unmap_resource(void *requested_addr, size_t size);\n \n /**\n- * Probe the single PCI device.\n+ * Attempt to load the registered driver for the PCI device at addr.\n  *\n- * Scan the content of the PCI bus, and find the pci device specified by pci\n- * address, then call the probe() function for registered driver that has a\n- * matching entry in its id_table for discovered device.\n+ * Find the pci device specified by addr, then call the probe() function\n+ * for each registered driver that has a matching entry in its id_table until\n+ * the correct driver is found.\n+ *\n+ * If the PCI address is known, this is considerably more efficient than\n+ * calling rte_eal_pci_probe.\n  *\n  * @param addr\n  *\tThe PCI Bus-Device-Function address to probe.\n@@ -471,14 +474,13 @@ void pci_unmap_resource(void *requested_addr, size_t size);\n  *   - 0 on success.\n  *   - Negative on error.\n  */\n-int rte_eal_pci_probe_one(const struct rte_pci_addr *addr);\n+int rte_eal_pci_attach_driver(const struct rte_pci_addr *addr);\n \n /**\n- * Close the single PCI device.\n+ * Unload the driver for the PCI device at addr.\n  *\n- * Scan the content of the PCI bus, and find the pci device specified by pci\n- * address, then call the remove() function for registered driver that has a\n- * matching entry in its id_table for discovered device.\n+ * Find the pci device specified by addr, then call the remove() function\n+ * for the currently loaded driver.\n  *\n  * @param addr\n  *\tThe PCI Bus-Device-Function address to close.\n@@ -486,7 +488,7 @@ int rte_eal_pci_probe_one(const struct rte_pci_addr *addr);\n  *   - 0 on success.\n  *   - Negative on error.\n  */\n-int rte_eal_pci_detach(const struct rte_pci_addr *addr);\n+int rte_eal_pci_detach_driver(const struct rte_pci_addr *addr);\n \n /**\n  * Dump the content of the PCI bus.\n",
    "prefixes": [
        "dpdk-dev",
        "7/7"
    ]
}