get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 19768,
    "url": "http://patches.dpdk.org/api/patches/19768/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1484801117-779-13-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-13-git-send-email-thomas.monjalon@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1484801117-779-13-git-send-email-thomas.monjalon@6wind.com",
    "date": "2017-01-19T04:45:16",
    "name": "[dpdk-dev,v11,12/13] pci: use bus driver for attach/detach",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7e3e3993a529839ae9a8ecfcbbbab2c20f2f92fe",
    "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-13-git-send-email-thomas.monjalon@6wind.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/19768/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/19768/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 919A9FB72;\n\tThu, 19 Jan 2017 05:46:02 +0100 (CET)",
            "from mail-wm0-f54.google.com (mail-wm0-f54.google.com\n\t[74.125.82.54]) by dpdk.org (Postfix) with ESMTP id 37CE0FB35\n\tfor <dev@dpdk.org>; Thu, 19 Jan 2017 05:45:35 +0100 (CET)",
            "by mail-wm0-f54.google.com with SMTP id c206so58683588wme.0\n\tfor <dev@dpdk.org>; Wed, 18 Jan 2017 20:45:35 -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.34\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 18 Jan 2017 20:45:34 -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=DYtU0Y5QKg2nS6FZL4PZA5FvEHqIpZuDEHPVspxtZUI=;\n\tb=IHiGpytltqEU7EwevhLKS5qJJd3ymF9SB8aIrlCEJqigpMZkV/GH/dRQdXUHZeWLyn\n\t4544r9LB+t9c+9GSmQEska5m1fQEr+z32vkZpO5ICrLPOmAPC5jBdBzSDDg2kKuRTwGV\n\tBbD9TVeV6rD0w9xXlebdUVnmsj8RIFScSw9JJYCjZtCUYjJJMKQFxOorBcBgfFWZS/pS\n\takbYJ9kgdHKf3G7x88S4CyDReeEdUtTpijrLaNzpOBGpzOCV9NtnRJahc2SRjgFwMoAv\n\tNkyT1HWeNhmYJHreOZCYsG3xtigpzLqWx02AFC8Xa9/Ja6AEiAhi43mP254Jrhp3y9J4\n\tkupg==",
        "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=DYtU0Y5QKg2nS6FZL4PZA5FvEHqIpZuDEHPVspxtZUI=;\n\tb=tvRSW6OtrdsKZ99X+2sI9hLqpqZN5ip0i2A1h70qBcLc7eqmBFvxLjuIOHetKqRjjV\n\t88vUp+7M2ujEuMHO+ckd0/dit2Y+DHn8hjcMwzg7ptuKYqK+uhtKZtI364atWX73E9C5\n\tm4Y903VhI46oLYCRO0SX9SpIDQ2AspvTOnW5FqBVNSkgx0u419WD6h9NagArjIUm4BGp\n\tQLGpT9nlVrzvJmc91SNlWgtT1rhI3eHgrTYczuWen1ueni50lh37/g4WAGhEldsV6FDl\n\tb/3UJgJZFm4jPYI0/rWue6Wt65RbfzEg9FdkcPg9eU2c/+6wAtbnAs3vkwVMXAM6+yrT\n\tN3AA==",
        "X-Gm-Message-State": "AIkVDXKOOXNlab4rmXqmD6R2Ld7nrJas0bdMx1W0QpI+cGXWQ7aw/VJMl18OQqIhId4GTkxA",
        "X-Received": "by 10.223.181.17 with SMTP id a17mr6320131wrd.111.1484801134836; \n\tWed, 18 Jan 2017 20:45:34 -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:16 +0100",
        "Message-Id": "<1484801117-779-13-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 12/13] pci: use bus driver for attach/detach",
        "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\nGiven a bus, attach and detach callbacks allow the implementation to\nhandles calls from EAL for attaching or detaching a named device.\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/eal_pci.c     |  2 +\n lib/librte_eal/common/eal_common_dev.c  | 56 ++++++++++++++++-----\n lib/librte_eal/common/eal_common_pci.c  | 89 +++++++++++++++++++++++++++++++--\n lib/librte_eal/common/include/rte_bus.h | 31 ++++++++++++\n lib/librte_eal/common/include/rte_pci.h | 45 +++++++++++------\n lib/librte_eal/linuxapp/eal/eal_pci.c   |  2 +\n 6 files changed, 193 insertions(+), 32 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c\nindex 103ad70..38a75af 100644\n--- a/lib/librte_eal/bsdapp/eal/eal_pci.c\n+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c\n@@ -670,6 +670,8 @@ struct rte_pci_bus rte_pci_bus = {\n \t.bus = {\n \t\t.scan = rte_eal_pci_scan,\n \t\t.probe = rte_eal_pci_probe,\n+\t\t.attach = rte_eal_pci_attach,\n+\t\t.detach = rte_eal_pci_detach,\n \t},\n \t.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),\n \t.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),\ndiff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c\nindex 4f3b493..97d0cf5 100644\n--- a/lib/librte_eal/common/eal_common_dev.c\n+++ b/lib/librte_eal/common/eal_common_dev.c\n@@ -38,6 +38,7 @@\n #include <sys/queue.h>\n \n #include <rte_dev.h>\n+#include <rte_bus.h>\n #include <rte_devargs.h>\n #include <rte_debug.h>\n #include <rte_devargs.h>\n@@ -106,23 +107,37 @@ rte_eal_dev_init(void)\n \n int rte_eal_dev_attach(const char *name, const char *devargs)\n {\n-\tstruct rte_pci_addr addr;\n+\tint ret = 1;\n+\tstruct rte_bus *bus;\n \n \tif (name == NULL || devargs == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"Invalid device or arguments provided\\n\");\n \t\treturn -EINVAL;\n \t}\n \n-\tif (eal_parse_pci_DomBDF(name, &addr) == 0) {\n-\t\tif (rte_eal_pci_probe_one(&addr) < 0)\n+\tFOREACH_BUS(bus) {\n+\t\tif (!bus->attach) {\n+\t\t\tRTE_LOG(DEBUG, EAL, \"Bus (%s) doesn't implement\"\n+\t\t\t\t\" attach.\\n\", bus->name);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tret = bus->attach(name);\n+\t\tif (!ret) /* device successfully attached */\n+\t\t\treturn ret;\n+\t\tif (ret > 0) /* device not found on bus */\n+\t\t\tcontinue;\n+\t\telse\n \t\t\tgoto err;\n+\t}\n \n-\t} else {\n-\t\tif (rte_eal_vdev_init(name, devargs))\n+\tif (ret > 0) {\n+\t\t/* In case the device was not found on any bus, search VDEV */\n+\t\tret = rte_eal_vdev_init(name, devargs);\n+\t\tif (ret)\n \t\t\tgoto err;\n \t}\n \n-\treturn 0;\n+\treturn ret;\n \n err:\n \tRTE_LOG(ERR, EAL, \"Driver cannot attach the device (%s)\\n\", name);\n@@ -131,21 +146,38 @@ int rte_eal_dev_attach(const char *name, const char *devargs)\n \n int rte_eal_dev_detach(const char *name)\n {\n-\tstruct rte_pci_addr addr;\n+\tint ret = 1;\n+\tstruct rte_bus *bus;\n \n \tif (name == NULL) {\n \t\tRTE_LOG(ERR, EAL, \"Invalid device provided.\\n\");\n \t\treturn -EINVAL;\n \t}\n \n-\tif (eal_parse_pci_DomBDF(name, &addr) == 0) {\n-\t\tif (rte_eal_pci_detach(&addr) < 0)\n+\tFOREACH_BUS(bus) {\n+\t\tif (!bus->detach) {\n+\t\t\tRTE_LOG(DEBUG, EAL, \"Bus (%s) doesn't implement\"\n+\t\t\t\t\" detach.\\n\", bus->name);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tret = bus->detach(name);\n+\t\tif (!ret) /* device successfully detached */\n+\t\t\treturn ret;\n+\t\tif (ret > 0) /* device not found on the bus */\n+\t\t\tcontinue;\n+\t\telse\n \t\t\tgoto err;\n-\t} else {\n-\t\tif (rte_eal_vdev_uninit(name))\n+\t}\n+\n+\tif (ret > 0) {\n+\t\t/* In case the device was not found on any bus, search VDEV */\n+\t\tret = rte_eal_vdev_uninit(name);\n+\t\tif (ret)\n \t\t\tgoto err;\n \t}\n-\treturn 0;\n+\n+\treturn ret;\n \n err:\n \tRTE_LOG(ERR, EAL, \"Driver cannot detach the device (%s)\\n\", name);\ndiff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c\nindex 5149e6e..6866b04 100644\n--- a/lib/librte_eal/common/eal_common_pci.c\n+++ b/lib/librte_eal/common/eal_common_pci.c\n@@ -358,19 +358,98 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)\n }\n \n /*\n+ * Attach device specific by its name\n+ */\n+int\n+rte_eal_pci_attach(const char *device_name)\n+{\n+\tstruct rte_pci_device *dev = NULL;\n+\tstruct rte_pci_driver *drv = NULL;\n+\tstruct rte_pci_addr addr;\n+\tint ret;\n+\n+\tif (!device_name)\n+\t\treturn -1;\n+\n+\tmemset(&addr, 0, sizeof(addr));\n+\tif (eal_parse_pci_DomBDF(device_name, &addr)) {\n+\t\t/* Device doesn't match PCI BDF naming format */\n+\t\treturn 1;\n+\t}\n+\n+\tif (pci_update_device(&addr) < 0)\n+\t\tgoto err_return;\n+\n+\tFOREACH_DEVICE_ON_PCIBUS(dev) {\n+\t\tif (rte_eal_compare_pci_addr(&dev->addr, &addr))\n+\t\t\tcontinue;\n+\n+\t\tFOREACH_DRIVER_ON_PCIBUS(drv) {\n+\t\t\tret = rte_pci_match(drv, dev);\n+\t\t\tif (ret) {\n+\t\t\t\t/* Match of device and driver failed */\n+\t\t\t\tRTE_LOG(DEBUG, EAL, \"Driver (%s) doesn't match\"\n+\t\t\t\t\t\" the device (%s)\\n\", drv->driver.name,\n+\t\t\t\t\tdevice_name);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tRTE_LOG(INFO, EAL, \"  probe driver: %x:%x %s\\n\",\n+\t\t\t\tdev->id.vendor_id, dev->id.device_id,\n+\t\t\t\tdrv->driver.name);\n+\n+\t\t\tif (drv->drv_flags & RTE_PCI_DRV_NEED_MAPPING) {\n+\t\t\t\t/* map resources for devices that use\n+\t\t\t\t * igb_uio\n+\t\t\t\t */\n+\t\t\t\tret = rte_eal_pci_map_device(dev);\n+\t\t\t\tif (ret != 0)\n+\t\t\t\t\tgoto err_return;\n+\t\t\t}\n+\n+\t\t\t/* reference driver structure */\n+\t\t\tdev->driver = drv;\n+\n+\t\t\t/* call the driver probe() function */\n+\t\t\tret = drv->probe(drv, dev);\n+\t\t\tif (ret) {\n+\t\t\t\tdev->driver = NULL;\n+\t\t\t\tif (drv->drv_flags & RTE_PCI_DRV_NEED_MAPPING)\n+\t\t\t\t\trte_eal_pci_unmap_device(dev);\n+\t\t\t}\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\treturn 1;\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);\n+\treturn -1;\n+}\n+\n+/*\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(const char *device_name)\n {\n \tstruct rte_pci_device *dev = NULL;\n-\tint ret = 0;\n+\tstruct rte_pci_addr addr;\n+\tint ret = 1;\n \n-\tif (addr == NULL)\n+\tif (!device_name)\n \t\treturn -1;\n \n+\tmemset(&addr, 0, sizeof(addr));\n+\tif (eal_parse_pci_DomBDF(device_name, &addr)) {\n+\t\t/* Device doesn't match PCI BDF naming format */\n+\t\treturn 1;\n+\t}\n+\n \tFOREACH_DEVICE_ON_PCIBUS(dev) {\n-\t\tif (rte_eal_compare_pci_addr(&dev->addr, addr))\n+\t\tif (rte_eal_compare_pci_addr(&dev->addr, &addr))\n \t\t\tcontinue;\n \n \t\tret = rte_eal_pci_detach_dev(dev);\n@@ -385,8 +464,8 @@ rte_eal_pci_detach(const struct rte_pci_addr *addr)\n \t\tfree(dev);\n \t\treturn 0;\n \t}\n-\treturn -1;\n \n+\treturn ret;\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,\ndiff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h\nindex 19954f4..9a096ec 100644\n--- a/lib/librte_eal/common/include/rte_bus.h\n+++ b/lib/librte_eal/common/include/rte_bus.h\n@@ -59,6 +59,8 @@ TAILQ_HEAD(rte_bus_list, rte_bus);\n /* Bus list exposed */\n extern struct rte_bus_list rte_bus_list;\n \n+#define FOREACH_BUS(bus_p)\tTAILQ_FOREACH(bus_p, &rte_bus_list, next)\n+\n /**\n  * Bus specific scan for devices attached on the bus.\n  * For each bus object, the scan would be reponsible for finding devices and\n@@ -85,6 +87,33 @@ typedef int (*rte_bus_scan_t)(void);\n typedef int (*rte_bus_probe_t)(void);\n \n /**\n+ * Attach a device to a bus, assuming it is 'connected' to the bus.\n+ * A bus is responsible for scanning for devices. Attaching a new device is\n+ * for reenabling the device after being detached/removed.\n+ *\n+ * @param device_name\n+ *\tName of the device to attach.\n+ *\n+ * @return\n+ *\t0 for successful attach\n+ *\t!0 for unsuccessful attach (or incorrect device name)\n+ */\n+typedef int (*rte_bus_attach_t)(const char *device_name);\n+\n+/**\n+ * Detach a named device from a bus. Implementation would check the existence\n+ * of device on the bus and detach it.\n+ *\n+ * @param device_name\n+ *\tName of the device to detach\n+ *\n+ * @return\n+ *\t0 for successful detaching\n+ *\t!0 if device not found or can't detach\n+ */\n+typedef int (*rte_bus_detach_t)(const char *device_name);\n+\n+/**\n  * A structure describing a generic bus.\n  */\n struct rte_bus {\n@@ -92,6 +121,8 @@ struct rte_bus {\n \tconst char *name;            /**< Name of the bus */\n \trte_bus_scan_t scan;         /**< Scan for devices attached to bus */\n \trte_bus_probe_t probe;       /**< Probe devices on bus */\n+\trte_bus_attach_t attach;     /**< Attach a named device */\n+\trte_bus_detach_t detach;     /**< Detach a named device */\n };\n \n /**\ndiff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex bab8df4..215d732 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -418,6 +418,36 @@ int\n rte_eal_pci_probe(void);\n \n /**\n+ * Search and attach a PCI device to PCI Bus\n+ * Implements rte_bus->attach\n+ *\n+ * @param device_name\n+ *\tName of the device to search and attach\n+ *\n+ * @return\n+ *\t0 for successful removal of device\n+ *\t>0 if device not found on bus\n+ *\t<0 in case of error in removal.\n+ */\n+int\n+rte_eal_pci_attach(const char *device_name);\n+\n+/**\n+ * Search and detach a PCI device from PCI Bus\n+ * Implements rte_bus->detach\n+ *\n+ * @param device_name\n+ *\tName of the device to search and detach\n+ *\n+ * @return\n+ *\t0 for successful detaching of device\n+ *\t>0 if device not found on bus\n+ *\t<0 in case of error in removal.\n+ */\n+int\n+rte_eal_pci_detach(const char *device_name);\n+\n+/**\n  * Map the PCI device resources in user space virtual memory address\n  *\n  * Note that driver should not call this function when flag\n@@ -491,21 +521,6 @@ void pci_unmap_resource(void *requested_addr, size_t size);\n int rte_eal_pci_probe_one(const struct rte_pci_addr *addr);\n \n /**\n- * Close the single PCI device.\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- *\n- * @param addr\n- *\tThe PCI Bus-Device-Function address to close.\n- * @return\n- *   - 0 on success.\n- *   - Negative on error.\n- */\n-int rte_eal_pci_detach(const struct rte_pci_addr *addr);\n-\n-/**\n  * Dump the content of the PCI bus.\n  *\n  * @param f\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c\nindex d6f9855..01f0c9a 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c\n@@ -719,6 +719,8 @@ struct rte_pci_bus rte_pci_bus = {\n \t.bus = {\n \t\t.scan = rte_eal_pci_scan,\n \t\t.probe = rte_eal_pci_probe,\n+\t\t.attach = rte_eal_pci_attach,\n+\t\t.detach = rte_eal_pci_detach,\n \t},\n \t.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),\n \t.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),\n",
    "prefixes": [
        "dpdk-dev",
        "v11",
        "12/13"
    ]
}