[dpdk-dev] [RFC] eal: allow hotplug to skip an already probed device
Thomas Monjalon
thomas at monjalon.net
Sat Sep 8 01:09:58 CEST 2018
In the devargs syntax for device representors, it is possible to add
several devices at once: -w dbdf,representor=[0-3]
It will become a more frequent case when introducing wildcards
and ranges in the new devargs syntax.
If a devargs string is provided for probing, and updated with a bigger
range for a new probing, then we do not want it to fail because
part of this range was already probed previously.
On the opposite, we could require rte_eal_hotplug_add() to try
to add all matching devices, and fail if one is already probed.
That's why a new parameter is added to specify if the function
must fail or not when trying to add an already probed device.
Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
This patch contains only the change in the function itself as RFC.
This idea was presented at Dublin during the "hotplug talk".
---
lib/librte_eal/common/eal_common_dev.c | 4 +++-
lib/librte_eal/common/include/rte_dev.h | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 678dbcac7..17d7e9089 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -128,7 +128,7 @@ int rte_eal_dev_detach(struct rte_device *dev)
}
int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname,
- const char *devargs)
+ const char *devargs, bool fail_existing)
{
struct rte_bus *bus;
struct rte_device *dev;
@@ -173,6 +173,8 @@ int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devn
}
if (dev->driver != NULL) {
+ if (!fail_existing)
+ return 0;
RTE_LOG(ERR, EAL, "Device is already plugged\n");
return -EEXIST;
}
diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h
index b80a80598..10a1cd2b4 100644
--- a/lib/librte_eal/common/include/rte_dev.h
+++ b/lib/librte_eal/common/include/rte_dev.h
@@ -201,11 +201,14 @@ int rte_eal_dev_detach(struct rte_device *dev);
* capable of handling it and pass it to the driver probing function.
* @param devargs
* Device arguments to be passed to the driver.
+ * @param fail_existing
+ * If true and a matching device is already probed, then return -EEXIST.
+ * If false, then skip the already probed device without returning an error.
* @return
* 0 on success, negative on error.
*/
int __rte_experimental rte_eal_hotplug_add(const char *busname, const char *devname,
- const char *devargs);
+ const char *devargs, bool fail_existing);
/**
* @warning
--
2.18.0
More information about the dev
mailing list