From: Jan Blunck <jblunck@infradead.org>
To: dev@dpdk.org
Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com
Subject: [dpdk-dev] [PATCH v8 12/14] eal: add hotplug add/remove functions
Date: Fri, 30 Jun 2017 20:19:41 +0200 [thread overview]
Message-ID: <20170630181943.23929-13-jblunck@infradead.org> (raw)
In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org>
Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 8 +++
lib/librte_eal/common/eal_common_dev.c | 88 +++++++++++++++++++++++++
lib/librte_eal/common/include/rte_dev.h | 34 ++++++++++
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 8 +++
4 files changed, 138 insertions(+)
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index d138a96..0295ea9 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -202,3 +202,11 @@ DPDK_17.08 {
rte_bus_find_by_name;
} DPDK_17.05;
+
+EXPERIMENTAL {
+ global:
+
+ rte_eal_hotplug_add;
+ rte_eal_hotplug_remove;
+
+} DPDK_17.08;
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index a400ddd..3606332 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -37,6 +37,7 @@
#include <inttypes.h>
#include <sys/queue.h>
+#include <rte_bus.h>
#include <rte_dev.h>
#include <rte_devargs.h>
#include <rte_debug.h>
@@ -45,6 +46,25 @@
#include "eal_private.h"
+static int cmp_detached_dev_name(const struct rte_device *dev,
+ const void *_name)
+{
+ const char *name = _name;
+
+ /* skip attached devices */
+ if (dev->driver != NULL)
+ return 1;
+
+ return strcmp(dev->name, name);
+}
+
+static int cmp_dev_name(const struct rte_device *dev, const void *_name)
+{
+ const char *name = _name;
+
+ return strcmp(dev->name, name);
+}
+
int rte_eal_dev_attach(const char *name, const char *devargs)
{
struct rte_pci_addr addr;
@@ -92,3 +112,71 @@ int rte_eal_dev_detach(const char *name)
RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", name);
return -EINVAL;
}
+
+int rte_eal_hotplug_add(const char *busname, const char *devname,
+ const char *devargs)
+{
+ struct rte_bus *bus;
+ struct rte_device *dev;
+ int ret;
+
+ bus = rte_bus_find_by_name(busname);
+ if (bus == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", busname);
+ return -ENOENT;
+ }
+
+ if (bus->plug == NULL) {
+ RTE_LOG(ERR, EAL, "Function plug not supported by bus (%s)\n",
+ bus->name);
+ return -ENOTSUP;
+ }
+
+ ret = bus->scan();
+ if (ret)
+ return ret;
+
+ dev = bus->find_device(NULL, cmp_detached_dev_name, devname);
+ if (dev == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot find unplugged device (%s)\n",
+ devname);
+ return -EINVAL;
+ }
+
+ ret = bus->plug(dev, devargs);
+ if (ret)
+ RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
+ dev->name);
+ return ret;
+}
+
+int rte_eal_hotplug_remove(const char *busname, const char *devname)
+{
+ struct rte_bus *bus;
+ struct rte_device *dev;
+ int ret;
+
+ bus = rte_bus_find_by_name(busname);
+ if (bus == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", busname);
+ return -ENOENT;
+ }
+
+ if (bus->unplug == NULL) {
+ RTE_LOG(ERR, EAL, "Function unplug not supported by bus (%s)\n",
+ bus->name);
+ return -ENOTSUP;
+ }
+
+ dev = bus->find_device(NULL, cmp_dev_name, devname);
+ if (dev == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", devname);
+ return -EINVAL;
+ }
+
+ ret = bus->unplug(dev);
+ if (ret)
+ RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n",
+ dev->name);
+ return ret;
+}
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index 04d9c28..a0d67d0 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -192,6 +192,40 @@ int rte_eal_dev_attach(const char *name, const char *devargs);
int rte_eal_dev_detach(const char *name);
/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Hotplug add a given device to a specific bus.
+ *
+ * @param busname
+ * The bus name the device is added to.
+ * @param devname
+ * The device name. Based on this device name, eal will identify a driver
+ * capable of handling it and pass it to the driver probing function.
+ * @param devargs
+ * Device arguments to be passed to the driver.
+ * @return
+ * 0 on success, negative on error.
+ */
+int rte_eal_hotplug_add(const char *busname, const char *devname,
+ const char *devargs);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Hotplug remove a given device from a specific bus.
+ *
+ * @param busname
+ * The bus name the device is removed from.
+ * @param devname
+ * The device name being removed.
+ * @return
+ * 0 on success, negative on error.
+ */
+int rte_eal_hotplug_remove(const char *busname, const char *devname);
+
+/**
* Device comparison function.
*
* This type of function is used to compare an rte_device with arbitrary
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 643ec1c..a118fb1 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -207,3 +207,11 @@ DPDK_17.08 {
rte_bus_find_by_name;
} DPDK_17.05;
+
+EXPERIMENTAL {
+ global:
+
+ rte_eal_hotplug_add;
+ rte_eal_hotplug_remove;
+
+} DPDK_17.08;
--
2.9.4
next prev parent reply other threads:[~2017-06-30 18:20 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-26 0:21 [dpdk-dev] [PATCH v5 00/12] bus: attach / detach API Gaetan Rivet
2017-06-26 0:21 ` [dpdk-dev] [PATCH v5 01/12] bus: add bus iterator to find a bus Gaetan Rivet
2017-06-26 15:30 ` Bruce Richardson
2017-06-26 20:53 ` Gaëtan Rivet
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 02/12] bus: add device iterator method Gaetan Rivet
2017-06-26 16:20 ` Bruce Richardson
2017-06-26 21:13 ` Gaëtan Rivet
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 03/12] bus: add helper to find which bus holds a device Gaetan Rivet
2017-06-26 16:31 ` Bruce Richardson
2017-06-26 22:16 ` Gaëtan Rivet
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 04/12] bus: add bus iterator to find " Gaetan Rivet
2017-06-27 10:14 ` Bruce Richardson
2017-06-27 13:54 ` Bruce Richardson
2017-06-27 15:05 ` Gaëtan Rivet
2017-06-27 15:08 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 05/12] bus: introduce hotplug functionality Gaetan Rivet
2017-06-27 12:23 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 06/12] vdev: implement find_device bus operation Gaetan Rivet
2017-06-27 12:25 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 07/12] vdev: implement hotplug functionality Gaetan Rivet
2017-06-27 12:41 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 08/12] vdev: expose bus name Gaetan Rivet
2017-06-27 12:45 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 09/12] vdev: use standard bus registration function Gaetan Rivet
2017-06-27 12:59 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 10/12] pci: implement find_device bus operation Gaetan Rivet
2017-06-27 13:36 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 11/12] pci: implement hotplug " Gaetan Rivet
2017-06-27 13:49 ` Bruce Richardson
2017-06-26 0:22 ` [dpdk-dev] [PATCH v5 12/12] eal: make virtual driver probe and remove take rte_vdev_device Gaetan Rivet
2017-06-27 13:58 ` Bruce Richardson
2017-06-27 14:47 ` Gaëtan Rivet
2017-06-27 15:06 ` Bruce Richardson
2017-06-27 14:00 ` Bruce Richardson
2017-06-27 14:08 ` [dpdk-dev] [PATCH v5 00/12] bus: attach / detach API Bruce Richardson
2017-06-27 14:48 ` Gaëtan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 00/11] " Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 01/11] bus: add bus iterator to find a bus Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 02/11] bus: add device iterator method Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 03/11] bus: add helper to find which bus holds a device Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 04/11] bus: add bus iterator to find " Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 05/11] bus: introduce hotplug functionality Gaetan Rivet
2017-06-27 19:03 ` Jan Blunck
2017-06-28 11:44 ` Thomas Monjalon
2017-06-28 11:58 ` Jan Blunck
2017-06-28 12:11 ` Thomas Monjalon
2017-06-28 13:09 ` Jan Blunck
2017-06-28 13:30 ` Thomas Monjalon
2017-06-28 15:11 ` Jan Blunck
2017-06-28 15:33 ` Bruce Richardson
2017-06-29 12:59 ` Gaëtan Rivet
2017-06-29 19:20 ` Jan Blunck
2017-06-30 11:32 ` Gaëtan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 06/11] vdev: implement find_device bus operation Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 07/11] vdev: implement hotplug " Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 08/11] vdev: use standard bus registration function Gaetan Rivet
2017-07-03 22:15 ` Thomas Monjalon
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 09/11] pci: implement find_device bus operation Gaetan Rivet
2017-06-27 23:35 ` Stephen Hemminger
2017-06-28 9:17 ` Gaëtan Rivet
2017-06-28 9:52 ` Richardson, Bruce
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 10/11] pci: implement hotplug " Gaetan Rivet
2017-06-27 16:11 ` [dpdk-dev] [PATCH v6 11/11] dev: use new hotplug API in attach / detach Gaetan Rivet
2017-06-29 18:21 ` [dpdk-dev] [PATCH 00/15] bus attach/detach API and hotplug rework Jan Blunck
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 01/15] bus: add bus iterator to find a bus Jan Blunck
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 02/15] bus: add find_device bus operation Jan Blunck
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 03/15] vdev: implement " Jan Blunck
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 04/15] pci: " Jan Blunck
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 05/15] bus/fslmc: " Jan Blunck
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 06/15] bus: add helper to find which bus holds a device Jan Blunck
2017-06-30 9:16 ` Thomas Monjalon
2017-06-30 16:46 ` Jan Blunck
2017-06-30 18:29 ` Thomas Monjalon
2017-06-30 21:24 ` Bruce Richardson
2017-06-30 21:25 ` Bruce Richardson
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 07/15] bus: add bus iterator to find " Jan Blunck
2017-06-30 9:17 ` Thomas Monjalon
2017-06-29 18:21 ` [dpdk-dev] [PATCH v7 08/15] bus: require buses to implement find_device operation Jan Blunck
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 09/15] bus: add rte_bus_find_by_name Jan Blunck
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 10/15] bus: introduce device plug/unplug functionality Jan Blunck
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 11/15] vdev: implement unplug bus operation Jan Blunck
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 12/15] pci: implement hotplug " Jan Blunck
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 13/15] eal: add hotplug add/remove functions Jan Blunck
2017-06-30 9:06 ` Thomas Monjalon
2017-06-30 9:11 ` Gaëtan Rivet
2017-06-30 9:20 ` Bruce Richardson
2017-06-30 15:44 ` Jan Blunck
2017-06-30 16:03 ` Thomas Monjalon
2017-06-30 16:13 ` Gaëtan Rivet
2017-06-30 16:25 ` Bruce Richardson
2017-06-30 16:29 ` Thomas Monjalon
2017-06-30 12:54 ` Thomas Monjalon
2017-06-30 15:12 ` Jan Blunck
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 14/15] dev: use new hotplug API in attach / detach Jan Blunck
2017-06-29 21:05 ` Thomas Monjalon
2017-06-29 18:22 ` [dpdk-dev] [PATCH v7 15/15] ethdev: Use embedded rte_device to detach driver Jan Blunck
2017-06-29 20:58 ` Thomas Monjalon
2017-06-30 9:59 ` [dpdk-dev] [PATCH 00/15] bus attach/detach API and hotplug rework Thomas Monjalon
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 00/14] " Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 01/14] bus: add bus iterator to find a bus Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 02/14] bus: add find_device bus operation Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 03/14] vdev: implement " Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 04/14] pci: " Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 05/14] bus/fslmc: " Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 06/14] bus: add helper to find which bus holds a device Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 07/14] bus: require buses to implement find_device operation Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 08/14] bus: add rte_bus_find_by_name Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 09/14] bus: introduce device plug/unplug functionality Jan Blunck
2017-06-30 18:38 ` Gaëtan Rivet
2017-06-30 18:52 ` Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 10/14] vdev: implement unplug bus operation Jan Blunck
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 11/14] pci: implement hotplug " Jan Blunck
2017-06-30 18:19 ` Jan Blunck [this message]
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 13/14] ethdev: Use embedded rte_device to detach driver Jan Blunck
2017-07-03 23:17 ` Thomas Monjalon
2017-06-30 18:19 ` [dpdk-dev] [PATCH v8 14/14] dev: use new hotplug API in attach Jan Blunck
2017-07-03 22:59 ` [dpdk-dev] [PATCH v8 00/14] bus attach/detach API and hotplug rework Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170630181943.23929-13-jblunck@infradead.org \
--to=jblunck@infradead.org \
--cc=dev@dpdk.org \
--cc=gaetan.rivet@6wind.com \
--cc=shreyansh.jain@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).