get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 10266,
    "url": "http://patches.dpdk.org/api/patches/10266/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1454076516-21591-10-git-send-email-david.marchand@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": "<1454076516-21591-10-git-send-email-david.marchand@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1454076516-21591-10-git-send-email-david.marchand@6wind.com",
    "date": "2016-01-29T14:08:36",
    "name": "[dpdk-dev,9/9] eal: relocate hotplug code from ethdev",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "1838171132c64d554a4449fdd1093ac0de6cd04d",
    "submitter": {
        "id": 3,
        "url": "http://patches.dpdk.org/api/people/3/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@6wind.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1454076516-21591-10-git-send-email-david.marchand@6wind.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/10266/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/10266/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 490B4C712;\n\tFri, 29 Jan 2016 15:08:56 +0100 (CET)",
            "from mail-wm0-f50.google.com (mail-wm0-f50.google.com\n\t[74.125.82.50]) by dpdk.org (Postfix) with ESMTP id 9B9DFC6CE\n\tfor <dev@dpdk.org>; Fri, 29 Jan 2016 15:08:51 +0100 (CET)",
            "by mail-wm0-f50.google.com with SMTP id l66so56065950wml.0\n\tfor <dev@dpdk.org>; Fri, 29 Jan 2016 06:08:51 -0800 (PST)",
            "from gloops.dev.6wind.com (144.77.126.78.rev.sfr.net.\n\t[78.126.77.144]) by smtp.gmail.com with ESMTPSA id\n\t67sm7669944wmp.20.2016.01.29.06.08.50\n\t(version=TLSv1/SSLv3 cipher=OTHER);\n\tFri, 29 Jan 2016 06:08:50 -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=uuWuawIr8Dxc/0u8+FLAfMerorHKn6ALUj103Yh7TAY=;\n\tb=TR4K/QqtW8LIs39mgBgeakClNi8CPQiukNGS1jwRnDxdx8G1y/bu4HlJH02jokrfj9\n\tNXfls3P10vHOrtYsJ0KfDngNL5OONBH0ajAmAbLGkelf9Yfl2GD34QDNMKrWXzTvWLmO\n\trVfcf3qEo6E+W2vqTuT7k4iplrc+4PcB3ZZhy/K8rBwRR5w8OQuzTh/jwP870AGiU8Un\n\tDJkpFjr+LmTZS4emzb/PYFKKL5y185Qalg2rXYT+4+SXrmrWhFwWVCkF8Xn4C9yda3gB\n\tzxz91PUVhmWP49CZRK5QHZQXzXAOMfYa4+0+IXYmyqbkkZ4J/TCNxHhFZOFLbGlLqwmJ\n\tqP7Q==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=uuWuawIr8Dxc/0u8+FLAfMerorHKn6ALUj103Yh7TAY=;\n\tb=kP8jTfM32nxOixREfnbiV9fjOtGF8qxXKQh8DmoJaOkFcvRYR7tH6bTFFkwQ5J00cD\n\tPy70mbed0H6MdkN3+VLwW3RQ6QZTE8eLL7EuybTy4uSHDK5PRpSFBWSBr4zu/VOqyr8x\n\t+tJZNorUJ9EMINuA9ZMd30q2nO4D+qexWRz8tb3D0pZbic6VhvXaZNpHICdAARfHPCRg\n\trbazNGNtMkaLWploXHI9eEp4nN/CVcgHCn963o4wi4o6MyvR+ZXlUYpQJcIP0tMajyDS\n\tC6IIo1d0W3ZprL9IdUvH6hIhbIPfbMgoolS+ysnWMgCmS6ZjV5mfSE6ls+0nOisg4oBw\n\tscFQ==",
        "X-Gm-Message-State": "AG10YOTWLQMmo7O88DquVw3VmQ7pHNta2mm96fnXzk/XIO2EO9/Pa0r1J/0JPSVF3GZHLVXq",
        "X-Received": "by 10.28.223.134 with SMTP id w128mr8837677wmg.69.1454076531469; \n\tFri, 29 Jan 2016 06:08:51 -0800 (PST)",
        "From": "David Marchand <david.marchand@6wind.com>",
        "To": "dev@dpdk.org",
        "Date": "Fri, 29 Jan 2016 15:08:36 +0100",
        "Message-Id": "<1454076516-21591-10-git-send-email-david.marchand@6wind.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1454076516-21591-1-git-send-email-david.marchand@6wind.com>",
        "References": "<1454076516-21591-1-git-send-email-david.marchand@6wind.com>",
        "Cc": "viktorin@rehivetech.com",
        "Subject": "[dpdk-dev] [PATCH 9/9] eal: relocate hotplug code from ethdev",
        "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": "hotplug which deals with resources should come from the layer that already\nhandles them, i.e. eal.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   8 +\n lib/librte_eal/common/eal_common_dev.c          |  39 ++++\n lib/librte_eal/common/eal_common_pci.c          |  11 +-\n lib/librte_eal/common/include/rte_dev.h         |  25 +++\n lib/librte_eal/linuxapp/eal/rte_eal_version.map |   8 +\n lib/librte_ether/rte_ethdev.c                   | 258 ++++--------------------\n 6 files changed, 125 insertions(+), 224 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 9d7adf1..9aad048 100644\n--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map\n@@ -135,3 +135,11 @@ DPDK_2.2 {\n \trte_xen_dom0_supported;\n \n } DPDK_2.1;\n+\n+DPDK_2.3 {\n+\tglobal:\n+\n+\trte_eal_dev_attach;\n+\trte_eal_dev_detach;\n+\n+} DPDK_2.2;\ndiff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c\nindex 5137172..ec04b3a 100644\n--- a/lib/librte_eal/common/eal_common_dev.c\n+++ b/lib/librte_eal/common/eal_common_dev.c\n@@ -155,3 +155,42 @@ rte_eal_vdev_uninit(const char *name)\n \tRTE_LOG(ERR, EAL, \"no driver found for %s\\n\", name);\n \treturn -EINVAL;\n }\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+\n+\tif (eal_parse_pci_DomBDF(name, &addr) == 0) {\n+\t\tif (rte_eal_pci_probe_one(&addr) < 0)\n+\t\t\tgoto err;\n+\n+\t} else {\n+\t\tif (rte_eal_vdev_init(name, devargs))\n+\t\t\tgoto err;\n+\t}\n+\n+\treturn 0;\n+\n+err:\n+\tRTE_LOG(ERR, EAL, \"Driver, cannot attach the device\\n\");\n+\treturn ret;\n+}\n+\n+int rte_eal_dev_detach(const char *name)\n+{\n+\tstruct rte_pci_addr addr;\n+\n+\tif (eal_parse_pci_DomBDF(name, &addr) == 0) {\n+\t\tif (rte_eal_pci_detach(&addr) < 0)\n+\t\t\tgoto err;\n+\t} else {\n+\t\tif (rte_eal_vdev_uninit(name))\n+\t\t\tgoto err;\n+\t}\n+\treturn 0;\n+\n+err:\n+\tRTE_LOG(ERR, EAL, \"Driver, cannot detach the device\\n\");\n+\treturn -1;\n+}\ndiff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c\nindex 1e12776..d9aa66b 100644\n--- a/lib/librte_eal/common/eal_common_pci.c\n+++ b/lib/librte_eal/common/eal_common_pci.c\n@@ -332,6 +332,11 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)\n \tif (addr == NULL)\n \t\treturn -1;\n \n+\t/* update current pci device in global list, kernel bindings might have\n+\t * changed since last time we looked at it */\n+\tif (pci_refresh_device(addr) < 0)\n+\t\tgoto err_return;\n+\n \tTAILQ_FOREACH(dev, &pci_device_list, next) {\n \t\tif (rte_eal_compare_pci_addr(&dev->addr, addr))\n \t\t\tcontinue;\n@@ -344,9 +349,9 @@ rte_eal_pci_probe_one(const struct rte_pci_addr *addr)\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);\n+\tRTE_LOG(WARNING, EAL,\n+\t\t\"Requested device \" PCI_PRI_FMT \" cannot be used\\n\",\n+\t\taddr->domain, addr->bus, addr->devid, addr->function);\n \treturn -1;\n }\n \ndiff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h\nindex df69e28..6f026ff 100644\n--- a/lib/librte_eal/common/include/rte_dev.h\n+++ b/lib/librte_eal/common/include/rte_dev.h\n@@ -182,6 +182,31 @@ int rte_eal_vdev_init(const char *name, const char *args);\n  */\n int rte_eal_vdev_uninit(const char *name);\n \n+/**\n+ * Attach a resource to a registered driver.\n+ *\n+ * @param name\n+ *   The resource name, that refers to a pci resource or some private\n+ *   way of designating a resource for vdev drivers. Based on this\n+ *   resource name, eal will identify a driver capable of handling\n+ *   this resource and pass this resource to the driver probing\n+ *   function.\n+ * @param devargs\n+ *   Device arguments to be passed to the driver.\n+ * @return\n+ *   0 on success, negative on error.\n+ */\n+int rte_eal_dev_attach(const char *name, const char *devargs);\n+\n+/**\n+ * Detach a resource from its driver.\n+ *\n+ * @param name\n+ *   Same description as for rte_eal_dev_attach().\n+ *   Here, eal will call the driver detaching function.\n+ */\n+int rte_eal_dev_detach(const char *name);\n+\n #define PMD_REGISTER_DRIVER(d)\\\n void devinitfn_ ##d(void);\\\n void __attribute__((constructor, used)) devinitfn_ ##d(void)\\\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex cbe175f..ba0ff56 100644\n--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n@@ -138,3 +138,11 @@ DPDK_2.2 {\n \trte_xen_dom0_supported;\n \n } DPDK_2.1;\n+\n+DPDK_2.3 {\n+\tglobal:\n+\n+\trte_eal_dev_attach;\n+\trte_eal_dev_detach;\n+\n+} DPDK_2.2;\ndiff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex 5ba7479..5a5d419 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -72,6 +72,7 @@\n static const char *MZ_RTE_ETH_DEV_DATA = \"rte_eth_dev_data\";\n struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];\n static struct rte_eth_dev_data *rte_eth_dev_data;\n+static uint8_t eth_dev_last_created_port;\n static uint8_t nb_ports;\n \n /* spinlock for eth device callbacks */\n@@ -210,6 +211,7 @@ rte_eth_dev_allocate(const char *name, enum rte_eth_dev_type type)\n \teth_dev->data->port_id = port_id;\n \teth_dev->attached = DEV_ATTACHED;\n \teth_dev->dev_type = type;\n+\teth_dev_last_created_port = port_id;\n \tnb_ports++;\n \treturn eth_dev;\n }\n@@ -364,100 +366,6 @@ rte_eth_dev_count(void)\n \treturn nb_ports;\n }\n \n-static enum rte_eth_dev_type\n-rte_eth_dev_get_device_type(uint8_t port_id)\n-{\n-\tif (!rte_eth_dev_is_valid_port(port_id))\n-\t\treturn RTE_ETH_DEV_UNKNOWN;\n-\treturn rte_eth_devices[port_id].dev_type;\n-}\n-\n-static int\n-rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)\n-{\n-\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);\n-\n-\tif (addr == NULL) {\n-\t\tRTE_PMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t*addr = rte_eth_devices[port_id].pci_dev->addr;\n-\treturn 0;\n-}\n-\n-static int\n-rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)\n-{\n-\tchar *tmp;\n-\n-\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);\n-\n-\tif (name == NULL) {\n-\t\tRTE_PMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t/* shouldn't check 'rte_eth_devices[i].data',\n-\t * because it might be overwritten by VDEV PMD */\n-\ttmp = rte_eth_dev_data[port_id].name;\n-\tstrcpy(name, tmp);\n-\treturn 0;\n-}\n-\n-static int\n-rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id)\n-{\n-\tint i;\n-\n-\tif (name == NULL) {\n-\t\tRTE_PMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t*port_id = RTE_MAX_ETHPORTS;\n-\n-\tfor (i = 0; i < RTE_MAX_ETHPORTS; i++) {\n-\n-\t\tif (!strncmp(name,\n-\t\t\trte_eth_dev_data[i].name, strlen(name))) {\n-\n-\t\t\t*port_id = i;\n-\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\treturn -ENODEV;\n-}\n-\n-static int\n-rte_eth_dev_get_port_by_addr(const struct rte_pci_addr *addr, uint8_t *port_id)\n-{\n-\tint i;\n-\tstruct rte_pci_device *pci_dev = NULL;\n-\n-\tif (addr == NULL) {\n-\t\tRTE_PMD_DEBUG_TRACE(\"Null pointer is specified\\n\");\n-\t\treturn -EINVAL;\n-\t}\n-\n-\t*port_id = RTE_MAX_ETHPORTS;\n-\n-\tfor (i = 0; i < RTE_MAX_ETHPORTS; i++) {\n-\n-\t\tpci_dev = rte_eth_devices[i].pci_dev;\n-\n-\t\tif (pci_dev &&\n-\t\t\t!rte_eal_compare_pci_addr(&pci_dev->addr, addr)) {\n-\n-\t\t\t*port_id = i;\n-\n-\t\t\treturn 0;\n-\t\t}\n-\t}\n-\treturn -ENODEV;\n-}\n-\n static int\n rte_eth_dev_is_detachable(uint8_t port_id)\n {\n@@ -482,127 +390,50 @@ rte_eth_dev_is_detachable(uint8_t port_id)\n \treturn !(dev_flags & RTE_ETH_DEV_DETACHABLE);\n }\n \n-/* attach the new physical device, then store port_id of the device */\n-static int\n-rte_eth_dev_attach_pdev(struct rte_pci_addr *addr, uint8_t *port_id)\n-{\n-\t/* re-construct pci_device_list */\n-\tif (rte_eal_pci_scan())\n-\t\tgoto err;\n-\t/* Invoke probe func of the driver can handle the new device. */\n-\tif (rte_eal_pci_probe_one(addr))\n-\t\tgoto err;\n-\n-\tif (rte_eth_dev_get_port_by_addr(addr, port_id))\n-\t\tgoto err;\n-\n-\treturn 0;\n-err:\n-\treturn -1;\n-}\n-\n-/* detach the new physical device, then store pci_addr of the device */\n-static int\n-rte_eth_dev_detach_pdev(uint8_t port_id, struct rte_pci_addr *addr)\n-{\n-\tstruct rte_pci_addr freed_addr;\n-\tstruct rte_pci_addr vp;\n-\n-\t/* get pci address by port id */\n-\tif (rte_eth_dev_get_addr_by_port(port_id, &freed_addr))\n-\t\tgoto err;\n-\n-\t/* Zeroed pci addr means the port comes from virtual device */\n-\tvp.domain = vp.bus = vp.devid = vp.function = 0;\n-\tif (rte_eal_compare_pci_addr(&vp, &freed_addr) == 0)\n-\t\tgoto err;\n-\n-\t/* invoke devuninit func of the pci driver,\n-\t * also remove the device from pci_device_list */\n-\tif (rte_eal_pci_detach(&freed_addr))\n-\t\tgoto err;\n-\n-\t*addr = freed_addr;\n-\treturn 0;\n-err:\n-\treturn -1;\n-}\n-\n-/* attach the new virtual device, then store port_id of the device */\n-static int\n-rte_eth_dev_attach_vdev(const char *vdevargs, uint8_t *port_id)\n-{\n-\tchar *name = NULL, *args = NULL;\n-\tint ret = -1;\n-\n-\t/* parse vdevargs, then retrieve device name and args */\n-\tif (rte_eal_parse_devargs_str(vdevargs, &name, &args))\n-\t\tgoto end;\n-\n-\t/* walk around dev_driver_list to find the driver of the device,\n-\t * then invoke probe function of the driver.\n-\t * rte_eal_vdev_init() updates port_id allocated after\n-\t * initialization.\n-\t */\n-\tif (rte_eal_vdev_init(name, args))\n-\t\tgoto end;\n-\n-\tif (rte_eth_dev_get_port_by_name(name, port_id))\n-\t\tgoto end;\n-\n-\tret = 0;\n-end:\n-\tfree(name);\n-\tfree(args);\n-\n-\treturn ret;\n-}\n-\n-/* detach the new virtual device, then store the name of the device */\n-static int\n-rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)\n-{\n-\tchar name[RTE_ETH_NAME_MAX_LEN];\n-\n-\t/* get device name by port id */\n-\tif (rte_eth_dev_get_name_by_port(port_id, name))\n-\t\tgoto err;\n-\t/* walk around dev_driver_list to find the driver of the device,\n-\t * then invoke uninit function of the driver */\n-\tif (rte_eal_vdev_uninit(name))\n-\t\tgoto err;\n-\n-\tstrncpy(vdevname, name, sizeof(name));\n-\treturn 0;\n-err:\n-\treturn -1;\n-}\n-\n /* attach the new device, then store port_id of the device */\n int\n rte_eth_dev_attach(const char *devargs, uint8_t *port_id)\n {\n-\tstruct rte_pci_addr addr;\n \tint ret = -1;\n+\tint current = eth_dev_last_created_port;\n+\tchar *name = NULL, *args;\n \n \tif ((devargs == NULL) || (port_id == NULL)) {\n \t\tret = -EINVAL;\n \t\tgoto err;\n \t}\n \n-\tif (eal_parse_pci_DomBDF(devargs, &addr) == 0) {\n-\t\tret = rte_eth_dev_attach_pdev(&addr, port_id);\n-\t\tif (ret < 0)\n-\t\t\tgoto err;\n-\t} else {\n-\t\tret = rte_eth_dev_attach_vdev(devargs, port_id);\n-\t\tif (ret < 0)\n-\t\t\tgoto err;\n+\tname = strdup(devargs);\n+\tif (!name)\n+\t\tgoto err;\n+\n+\targs = strchr(name, ',');\n+\tif (args) {\n+\t\targs[0] = '\\0';\n+\t\targs++;\n \t}\n \n+\tret = rte_eal_dev_attach(name, args);\n+\tif (ret < 0)\n+\t\tgoto err;\n+\n+\t/* no point looking at eth_dev_last_created_port if no port exists */\n+\tif (!nb_ports) {\n+\t\tret = -1;\n+\t\tgoto err;\n+\t}\n+\t/* if nothing happened, there is a bug here, since some driver told us\n+\t * it did attach a device, but did not create a port */\n+\tif (current == eth_dev_last_created_port) {\n+\t\tret = -1;\n+\t\tgoto err;\n+\t}\n+\t*port_id = eth_dev_last_created_port;\n+\n+\tfree(name);\n \treturn 0;\n err:\n-\tRTE_LOG(ERR, EAL, \"Driver, cannot attach the device\\n\");\n+\tfree(name);\n \treturn ret;\n }\n \n@@ -610,7 +441,6 @@ err:\n int\n rte_eth_dev_detach(uint8_t port_id, char *name)\n {\n-\tstruct rte_pci_addr addr;\n \tint ret = -1;\n \n \tif (name == NULL) {\n@@ -618,33 +448,19 @@ rte_eth_dev_detach(uint8_t port_id, char *name)\n \t\tgoto err;\n \t}\n \n-\t/* check whether the driver supports detach feature, or not */\n+\t/* FIXME: move this to eal, once device flags are relocated there */\n \tif (rte_eth_dev_is_detachable(port_id))\n \t\tgoto err;\n \n-\tif (rte_eth_dev_get_device_type(port_id) == RTE_ETH_DEV_PCI) {\n-\t\tret = rte_eth_dev_get_addr_by_port(port_id, &addr);\n-\t\tif (ret < 0)\n-\t\t\tgoto err;\n-\n-\t\tret = rte_eth_dev_detach_pdev(port_id, &addr);\n-\t\tif (ret < 0)\n-\t\t\tgoto err;\n-\n-\t\tsnprintf(name, RTE_ETH_NAME_MAX_LEN,\n-\t\t\t\"%04x:%02x:%02x.%d\",\n-\t\t\taddr.domain, addr.bus,\n-\t\t\taddr.devid, addr.function);\n-\t} else {\n-\t\tret = rte_eth_dev_detach_vdev(port_id, name);\n-\t\tif (ret < 0)\n-\t\t\tgoto err;\n-\t}\n+\tsnprintf(name, sizeof(rte_eth_devices[port_id].data->name),\n+\t\t \"%s\", rte_eth_devices[port_id].data->name);\n+\tret = rte_eal_dev_detach(name);\n+\tif (ret < 0)\n+\t\tgoto err;\n \n \treturn 0;\n \n err:\n-\tRTE_LOG(ERR, EAL, \"Driver, cannot detach the device\\n\");\n \treturn ret;\n }\n \n",
    "prefixes": [
        "dpdk-dev",
        "9/9"
    ]
}