get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 3726,
    "url": "http://patches.dpdk.org/api/patches/3726/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1424892749-31862-13-git-send-email-mukawa@igel.co.jp/",
    "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": "<1424892749-31862-13-git-send-email-mukawa@igel.co.jp>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1424892749-31862-13-git-send-email-mukawa@igel.co.jp",
    "date": "2015-02-25T19:32:26",
    "name": "[dpdk-dev,v15,12/13] ethdev: Add rte_eth_dev_attach/detach() functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "88d32dcb9252dc7b79ec2a87f1a4b08c38f67c21",
    "submitter": {
        "id": 64,
        "url": "http://patches.dpdk.org/api/people/64/?format=api",
        "name": "Tetsuya Mukawa",
        "email": "mukawa@igel.co.jp"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1424892749-31862-13-git-send-email-mukawa@igel.co.jp/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/3726/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/3726/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 3E5399A92;\n\tWed, 25 Feb 2015 20:33:57 +0100 (CET)",
            "from mail-pa0-f47.google.com (mail-pa0-f47.google.com\n\t[209.85.220.47]) by dpdk.org (Postfix) with ESMTP id 788AB7E6A\n\tfor <dev@dpdk.org>; Wed, 25 Feb 2015 20:33:12 +0100 (CET)",
            "by pablj1 with SMTP id lj1so5173389pab.9\n\tfor <dev@dpdk.org>; Wed, 25 Feb 2015 11:33:11 -0800 (PST)",
            "from localhost.localdomain (napt.igel.co.jp. [219.106.231.132])\n\tby mx.google.com with ESMTPSA id\n\tux7sm39997444pab.19.2015.02.25.11.33.09\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 25 Feb 2015 11:33:11 -0800 (PST)"
        ],
        "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=WFRvGobCeWzSZRr+Qz1OVTcBf00WHcFvalFaE1e8SFo=;\n\tb=kZr1/+pd+aScJlNnvp54UukwqIoiVs0n2z5M4M61KvXFAtdbXGEF2f/Yd8IMtAgZN6\n\tX9B/BNyf+EldtmZatE/izGGqG4CCngAxlCaJI2WUHKZKJEkDd7CMGkincEYDXnHrFgjF\n\tRJk+9T/fIRiw/8WzPw6Hov1XhTkGpzcBwXQXAExF75VpjAjcKy30pdXOyqHATEq3fWfc\n\tjiNvqrjBTkQ+RPM2tS9LCvYI/rUeDNIPoxhiE9Ql+pvvdkFP1QG2l7Unz7C9wLKLctPG\n\tIXIK8CCmwFzD9A9XZznusPEVsM1mXXAIPkivzeI/VSitNohmNuwEpYAMUF1Y7/nPckI9\n\t0RuA==",
        "X-Gm-Message-State": "ALoCoQnhxcd7JAUP5pO10yzLSTE6aV0fIO8Ik+YzJrWG/EbzKFmxZ8iBfEuEvEpHD9tD8jgzgtjL",
        "X-Received": "by 10.66.147.169 with SMTP id tl9mr8023705pab.63.1424892791887; \n\tWed, 25 Feb 2015 11:33:11 -0800 (PST)",
        "From": "Tetsuya Mukawa <mukawa@igel.co.jp>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 26 Feb 2015 04:32:26 +0900",
        "Message-Id": "<1424892749-31862-13-git-send-email-mukawa@igel.co.jp>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1424892749-31862-1-git-send-email-mukawa@igel.co.jp>",
        "References": "<1424837093-5661-13-git-send-email-mukawa@igel.co.jp>\n\t<1424892749-31862-1-git-send-email-mukawa@igel.co.jp>",
        "Subject": "[dpdk-dev] [PATCH v15 12/13] ethdev: Add\n\trte_eth_dev_attach/detach() functions",
        "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": "These functions are used for attaching or detaching a port.\nWhen rte_eth_dev_attach() is called, the function tries to realize the\ndevice name as pci address. If this is done successfully,\nrte_eth_dev_attach() will attach physical device port. If not, attaches\nvirtual devive port.\nWhen rte_eth_dev_detach() is called, the function gets the device type\nof this port to know whether the port is come from physical or virtual.\nAnd then specific detaching function will be called.\n\nv15:\n- Fix issue that eal calls ethedv library APIs.\n - Remove rte_eal_dev_attach(), and add rte_eth_dev_attach().\n - Remove rte_eal_dev_detach(), and add rte_eth_dev_detach().\n - Call rte_eal_vdev_init/uninit from ethdev library.\n  (Thanks to Thomas Monjalon)\n- Fix version.map\n- Squash below patch to compile.\n - ethdev: Add functions that will be used by port hotplug functions\n\nv14:\n- Remove needless if statement.\n  (Thanks to Maxime Leroy)\nv13:\n- Change log level when error occurs in rte_eal_vdev_init() and\n  rte_eal_dev_init().\n- Return value of driver init and uninit functions.\n- Replace rte_panic by RTE_LOG in rte_eal_dev_init()\n- Fix return value of rte_eal_vdev_uninit().\n- Fix rte_eal_dev_attach_vdev to set port_id correctly.\n  (Thanks to Maxime Leroy)\nv11:\n- Remove needless devargs handling codes.\n- Replace get_vdev_name() by rte_eal_parse_devargs_str().\n- Replace rte_eal_vdev_find_and_init by rte_eal_vdev_init()\n- Replace rte_eal_vdev_find_and_uninit by rte_eal_vdev_uninit()\n- Fix rte_eal_dev_init() to use rte_eal_vdev_init().\n  (Thanks to Maxime Leroy)\nv10:\n- Add comments.\n- Change order of version.map.\n  (Thanks to Thomas Monjalon)\nv9:\n- Fix comments.\n- Use strcmp() instead of strncmp().\n- Remove RTE_EAL_INVOKE_TYPE_PROBE/CLOSE.\n- Change definition of rte_dev_uninit_t.\n  (Thanks to Thomas Monjalon and Maxime Leroy)\nv8:\n- Add missing symbol in version map.\n  (Thanks to Qiu, Michael and Iremonger, Bernard)\nv7:\n- Fix typo of warning messages.\n  (Thanks to Qiu, Michael)\nv5:\n- Change function names like below.\n  rte_eal_dev_find_and_invoke() to rte_eal_vdev_find_and_invoke().\n  rte_eal_dev_invoke() to rte_eal_vdev_invoke().\n- Add code to handle a return value of rte_eal_devargs_remove().\n- Fix pci address format in rte_eal_dev_detach().\nv4:\n- Fix comment.\n- Add error checking.\n- Fix indent of 'if' statement.\n- Change function name.\n\nSigned-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>\n---\n lib/librte_eal/common/include/rte_pci.h         |   9 +\n lib/librte_eal/linuxapp/eal/eal_pci.c           |   6 +-\n lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +\n lib/librte_ether/rte_ethdev.c                   | 303 +++++++++++++++++++++++-\n lib/librte_ether/rte_ethdev.h                   |  38 +++\n lib/librte_ether/rte_ether_version.map          |   3 +\n 6 files changed, 355 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h\nindex ac30925..b9cdf8b 100644\n--- a/lib/librte_eal/common/include/rte_pci.h\n+++ b/lib/librte_eal/common/include/rte_pci.h\n@@ -313,6 +313,15 @@ rte_eal_compare_pci_addr(struct rte_pci_addr *addr, struct rte_pci_addr *addr2)\n }\n \n /**\n+ * Scan the content of the PCI bus, and the devices in the devices\n+ * list\n+ *\n+ * @return\n+ *  0 on success, negative on error\n+ */\n+int rte_eal_pci_scan(void);\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/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c\nindex f880f90..6d4932d 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c\n@@ -440,8 +440,8 @@ error:\n  * Scan the content of the PCI bus, and the devices in the devices\n  * list\n  */\n-static int\n-pci_scan(void)\n+int\n+rte_eal_pci_scan(void)\n {\n \tstruct dirent *e;\n \tDIR *dir;\n@@ -773,7 +773,7 @@ rte_eal_pci_init(void)\n \tif (internal_config.no_pci)\n \t\treturn 0;\n \n-\tif (pci_scan() < 0) {\n+\tif (rte_eal_pci_scan() < 0) {\n \t\tRTE_LOG(ERR, EAL, \"%s(): Cannot scan PCI bus\\n\", __func__);\n \t\treturn -1;\n \t}\ndiff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\nindex 214643d..7c2aac3 100644\n--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map\n@@ -45,6 +45,7 @@ DPDK_2.0 {\n \trte_eal_pci_probe_one;\n \trte_eal_pci_register;\n \trte_eal_pci_unregister;\n+\trte_eal_pci_scan;\n \trte_eal_process_type;\n \trte_eal_remote_launch;\n \trte_eal_tailq_lookup;\ndiff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c\nindex b07f2df..868289c 100644\n--- a/lib/librte_ether/rte_ethdev.c\n+++ b/lib/librte_ether/rte_ethdev.c\n@@ -201,7 +201,7 @@ rte_eth_dev_data_alloc(void)\n \t\t\t\tRTE_MAX_ETHPORTS * sizeof(*rte_eth_dev_data));\n }\n \n-static struct rte_eth_dev *\n+struct rte_eth_dev *\n rte_eth_dev_allocated(const char *name)\n {\n \tunsigned i;\n@@ -270,7 +270,6 @@ rte_eth_dev_create_unique_device_name(char *name, size_t size,\n \t\t\tpci_dev->addr.function);\n \tif (ret < 0)\n \t\treturn ret;\n-\n \treturn 0;\n }\n \n@@ -427,6 +426,306 @@ 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 -1;\n+\treturn rte_eth_devices[port_id].dev_type;\n+}\n+\n+static int\n+rte_eth_dev_save(struct rte_eth_dev *devs, size_t size)\n+{\n+\tif ((devs == NULL) ||\n+\t    (size != sizeof(struct rte_eth_dev) * RTE_MAX_ETHPORTS))\n+\t\treturn -EINVAL;\n+\n+\t/* save current rte_eth_devices */\n+\tmemcpy(devs, rte_eth_devices, size);\n+\treturn 0;\n+}\n+\n+static int\n+rte_eth_dev_get_changed_port(struct rte_eth_dev *devs, uint8_t *port_id)\n+{\n+\tif ((devs == NULL) || (port_id == NULL))\n+\t\treturn -EINVAL;\n+\n+\t/* check which port was attached or detached */\n+\tfor (*port_id = 0; *port_id < RTE_MAX_ETHPORTS; (*port_id)++, devs++) {\n+\t\tif (rte_eth_devices[*port_id].attached ^ devs->attached)\n+\t\t\treturn 0;\n+\t}\n+\treturn -ENODEV;\n+}\n+\n+static int\n+rte_eth_dev_get_addr_by_port(uint8_t port_id, struct rte_pci_addr *addr)\n+{\n+\tif (!rte_eth_dev_is_valid_port(port_id)) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (addr == NULL) {\n+\t\tPMD_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+\tif (!rte_eth_dev_is_valid_port(port_id)) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (name == NULL) {\n+\t\tPMD_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_is_detachable(uint8_t port_id)\n+{\n+\tuint32_t drv_flags;\n+\n+\tif (port_id >= RTE_MAX_ETHPORTS) {\n+\t\tPMD_DEBUG_TRACE(\"Invalid port_id=%d\\n\", port_id);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {\n+\t\tswitch (rte_eth_devices[port_id].pci_dev->pt_driver) {\n+\t\tcase RTE_PT_IGB_UIO:\n+\t\tcase RTE_PT_UIO_GENERIC:\n+\t\t\tbreak;\n+\t\tcase RTE_PT_VFIO:\n+\t\tdefault:\n+\t\t\treturn -ENOTSUP;\n+\t\t}\n+\t}\n+\n+\tdrv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;\n+\treturn !(drv_flags & RTE_PCI_DRV_DETACHABLE);\n+}\n+\n+/* So far, DPDK hotplug function only supports linux */\n+#ifdef RTE_LIBRTE_EAL_HOTPLUG\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+\tuint8_t new_port_id;\n+\tstruct rte_eth_dev devs[RTE_MAX_ETHPORTS];\n+\n+\tif ((addr == NULL) || (port_id == NULL))\n+\t\tgoto err;\n+\n+\t/* save current port status */\n+\tif (rte_eth_dev_save(devs, sizeof(devs)))\n+\t\tgoto err;\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+\t * TODO:\n+\t * rte_eal_pci_probe_one() should return port_id.\n+\t * And rte_eth_dev_save() and rte_eth_dev_get_changed_port()\n+\t * should be removed. */\n+\tif (rte_eal_pci_probe_one(addr))\n+\t\tgoto err;\n+\t/* get port_id enabled by above procedures */\n+\tif (rte_eth_dev_get_changed_port(devs, &new_port_id))\n+\t\tgoto err;\n+\n+\t*port_id = new_port_id;\n+\treturn 0;\n+err:\n+\tRTE_LOG(ERR, EAL, \"Driver, cannot attach the device\\n\");\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+\tif (addr == NULL)\n+\t\tgoto err;\n+\n+\t/* check whether the driver supports detach feature, or not */\n+\tif (rte_eth_dev_is_detachable(port_id))\n+\t\tgoto err;\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/* Zerod 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 close func of the driver,\n+\t * also remove the device from pci_device_list */\n+\tif (rte_eal_pci_close_one(&freed_addr))\n+\t\tgoto err;\n+\n+\t*addr = freed_addr;\n+\treturn 0;\n+err:\n+\tRTE_LOG(ERR, EAL, \"Driver, cannot detach the device\\n\");\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+\tuint8_t new_port_id;\n+\tstruct rte_eth_dev devs[RTE_MAX_ETHPORTS];\n+\tint ret = -1;\n+\n+\tif ((vdevargs == NULL) || (port_id == NULL))\n+\t\tgoto end;\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/* save current port status */\n+\tif (rte_eth_dev_save(devs, sizeof(devs)))\n+\t\tgoto end;\n+\t/* walk around dev_driver_list to find the driver of the device,\n+\t * then invoke probe function o the driver.\n+\t * TODO:\n+\t * rte_eal_vdev_init() should return port_id,\n+\t * And rte_eth_dev_save() and rte_eth_dev_get_changed_port()\n+\t * should be removed. */\n+\tif (rte_eal_vdev_init(name, args))\n+\t\tgoto end;\n+\t/* get port_id enabled by above procedures */\n+\tif (rte_eth_dev_get_changed_port(devs, &new_port_id))\n+\t\tgoto end;\n+\tret = 0;\n+\t*port_id = new_port_id;\n+end:\n+\tif (name)\n+\t\tfree(name);\n+\tif (args)\n+\t\tfree(args);\n+\n+\tif (ret < 0)\n+\t\tRTE_LOG(ERR, EAL, \"Driver, cannot attach the device\\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+\tif (vdevname == NULL)\n+\t\tgoto err;\n+\n+\t/* check whether the driver supports detach feature, or not */\n+\tif (rte_eth_dev_is_detachable(port_id))\n+\t\tgoto err;\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 close function o 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+\tRTE_LOG(ERR, EAL, \"Driver, cannot detach the device\\n\");\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+\n+\tif ((devargs == NULL) || (port_id == NULL))\n+\t\treturn -EINVAL;\n+\n+\tif (eal_parse_pci_DomBDF(devargs, &addr) == 0)\n+\t\treturn rte_eth_dev_attach_pdev(&addr, port_id);\n+\telse\n+\t\treturn rte_eth_dev_attach_vdev(devargs, port_id);\n+}\n+\n+/* detach the device, then store the name of the device */\n+int\n+rte_eth_dev_detach(uint8_t port_id, char *name)\n+{\n+\tstruct rte_pci_addr addr;\n+\tint ret;\n+\n+\tif (name == NULL)\n+\t\treturn -EINVAL;\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\treturn ret;\n+\n+\t\tret = rte_eth_dev_detach_pdev(port_id, &addr);\n+\t\tif (ret == 0)\n+\t\t\tsnprintf(name, RTE_ETH_NAME_MAX_LEN,\n+\t\t\t\t\"%04x:%02x:%02x.%d\",\n+\t\t\t\taddr.domain, addr.bus,\n+\t\t\t\taddr.devid, addr.function);\n+\n+\t\treturn ret;\n+\t} else\n+\t\treturn rte_eth_dev_detach_vdev(port_id, name);\n+}\n+#else /* RTE_LIBRTE_EAL_HOTPLUG */\n+int\n+rte_eth_dev_attach(const char *devargs __rte_unused,\n+\t\t\tuint8_t *port_id __rte_unused)\n+{\n+\tRTE_LOG(ERR, EAL, \"Hotplug support isn't enabled\\n\");\n+\treturn -1;\n+}\n+\n+/* detach the device, then store the name of the device */\n+int\n+rte_eth_dev_detach(uint8_t port_id __rte_unused,\n+\t\t\tchar *name __rte_unused)\n+{\n+\tRTE_LOG(ERR, EAL, \"Hotplug support isn't enabled\\n\");\n+\treturn -1;\n+}\n+#endif /* RTE_LIBRTE_EAL_HOTPLUG */\n+\n static int\n rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)\n {\ndiff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h\nindex 50c2dce..53d146c 100644\n--- a/lib/librte_ether/rte_ethdev.h\n+++ b/lib/librte_ether/rte_ethdev.h\n@@ -175,6 +175,8 @@ extern \"C\" {\n #include <rte_log.h>\n #include <rte_interrupts.h>\n #include <rte_pci.h>\n+#include <rte_dev.h>\n+#include <rte_devargs.h>\n #include <rte_mbuf.h>\n #include \"rte_ether.h\"\n #include \"rte_eth_ctrl.h\"\n@@ -1540,6 +1542,16 @@ extern struct rte_eth_dev rte_eth_devices[];\n extern uint8_t rte_eth_dev_count(void);\n \n /**\n+ * Function for internal use by port hotplug functions.\n+ * Returns a ethdev slot specified by the unique identifier name.\n+ * @param\tname\n+ *  The pointer to the Unique identifier name for each Ethernet device\n+ * @return\n+ *   - The pointer to the ethdev slot, on success. NULL on error\n+ */\n+extern struct rte_eth_dev *rte_eth_dev_allocated(const char *name);\n+\n+/**\n  * Function for internal use by dummy drivers primarily, e.g. ring-based\n  * driver.\n  * Allocates a new ethdev slot for an ethernet device and returns the pointer\n@@ -1565,6 +1577,32 @@ struct rte_eth_dev *rte_eth_dev_allocate(const char *name,\n  */\n int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);\n \n+/**\n+ * Attach a new Ethernet device specified by aruguments.\n+ *\n+ * @param devargs\n+ *  A pointer to a strings array describing the new device\n+ *  to be attached. The strings should be a pci address like\n+ *  '0000:01:00.0' or virtual device name like 'eth_pcap0'.\n+ * @param port_id\n+ *  A pointer to a port identifier actually attached.\n+ * @return\n+ *  0 on success and port_id is filled, negative on error\n+ */\n+int rte_eth_dev_attach(const char *devargs, uint8_t *port_id);\n+\n+/**\n+ * Detach a Ethernet device specified by port identifier.\n+ *\n+ * @param port_id\n+ *   The port identifier of the device to detach.\n+ * @param addr\n+ *  A pointer to a device name actually detached.\n+ * @return\n+ *  0 on success and devname is filled, negative on error\n+ */\n+int rte_eth_dev_detach(uint8_t port_id, char *devname);\n+\n struct eth_driver;\n /**\n  * @internal\ndiff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map\nindex 94fd685..0d46578 100644\n--- a/lib/librte_ether/rte_ether_version.map\n+++ b/lib/librte_ether/rte_ether_version.map\n@@ -8,6 +8,8 @@ DPDK_2.0 {\n \trte_eth_allmulticast_enable;\n \trte_eth_allmulticast_get;\n \trte_eth_dev_allocate;\n+\trte_eth_dev_allocated;\n+\trte_eth_dev_attach;\n \trte_eth_dev_bypass_event_show;\n \trte_eth_dev_bypass_event_store;\n \trte_eth_dev_bypass_init;\n@@ -22,6 +24,7 @@ DPDK_2.0 {\n \trte_eth_dev_close;\n \trte_eth_dev_configure;\n \trte_eth_dev_count;\n+\trte_eth_dev_detach;\n \trte_eth_dev_fdir_add_perfect_filter;\n \trte_eth_dev_fdir_add_signature_filter;\n \trte_eth_dev_fdir_get_infos;\n",
    "prefixes": [
        "dpdk-dev",
        "v15",
        "12/13"
    ]
}