The function rte_dev_is_probed() is added in order to improve semantic
and enforce proper check of the probing status of a device.
It will answer this rte_device query:
Is it already successfully probed or not?
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Tested-by: Andrew Rybchenko <arybchenko@solarflare.com>
return -1;
/* Check if a driver is already loaded */
return -1;
/* Check if a driver is already loaded */
- if (afu_dev->device.driver != NULL)
+ if (rte_dev_is_probed(&afu_dev->device))
return 0;
TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
return 0;
TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
int ret = 0;
TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) {
int ret = 0;
TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) {
- if (afu_dev->device.driver)
+ if (rte_dev_is_probed(&afu_dev->device))
continue;
ret = ifpga_probe_all_drivers(afu_dev);
continue;
ret = ifpga_probe_all_drivers(afu_dev);
return -1;
/* Check if a driver is already loaded */
return -1;
/* Check if a driver is already loaded */
- if (dev->device.driver != NULL)
+ if (rte_dev_is_probed(&dev->device))
return 0;
FOREACH_DRIVER_ON_PCIBUS(dr) {
return 0;
FOREACH_DRIVER_ON_PCIBUS(dr) {
* we call each driver probe.
*/
* we call each driver probe.
*/
- if (dev->device.driver)
+ if (rte_dev_is_probed(&dev->device))
continue;
if (vdev_probe_all_drivers(dev)) {
continue;
if (vdev_probe_all_drivers(dev)) {
int rc;
/* Check if a driver is already loaded */
int rc;
/* Check if a driver is already loaded */
- if (dev->device.driver != NULL) {
+ if (rte_dev_is_probed(&dev->device)) {
VMBUS_LOG(DEBUG, "VMBUS driver already loaded");
return 0;
}
VMBUS_LOG(DEBUG, "VMBUS driver already loaded");
return 0;
}
return strcmp(dev->name, name);
}
return strcmp(dev->name, name);
}
+int __rte_experimental
+rte_dev_is_probed(const struct rte_device *dev)
+{
+ /* The field driver should be set only when the probe is successful. */
+ return dev->driver != NULL;
+}
+
int rte_eal_dev_attach(const char *name, const char *devargs)
{
struct rte_bus *bus;
int rte_eal_dev_attach(const char *name, const char *devargs)
{
struct rte_bus *bus;
- if (dev->driver != NULL) {
+ if (rte_dev_is_probed(dev)) {
RTE_LOG(ERR, EAL, "Device is already plugged\n");
return -EEXIST;
}
RTE_LOG(ERR, EAL, "Device is already plugged\n");
return -EEXIST;
}
- if (dev->driver == NULL) {
- RTE_LOG(ERR, EAL, "Device is already unplugged\n");
- return -ENOENT;
- }
-
if (dev->bus->unplug == NULL) {
RTE_LOG(ERR, EAL, "Function unplug not supported by bus (%s)\n",
dev->bus->name);
if (dev->bus->unplug == NULL) {
RTE_LOG(ERR, EAL, "Function unplug not supported by bus (%s)\n",
dev->bus->name);
+ if (!rte_dev_is_probed(dev)) {
+ RTE_LOG(ERR, EAL, "Device is not probed\n");
+ return -ENOENT;
+ }
+
ret = build_devargs(dev->devargs->bus->name, dev->name, "", &devargs);
if (ret != 0)
return ret;
ret = build_devargs(dev->devargs->bus->name, dev->name, "", &devargs);
if (ret != 0)
return ret;
struct rte_devargs *devargs; /**< Device user arguments */
};
struct rte_devargs *devargs; /**< Device user arguments */
};
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Query status of a device.
+ *
+ * @param dev
+ * Generic device pointer.
+ * @return
+ * (int)true if already probed successfully, 0 otherwise.
+ */
+__rte_experimental
+int rte_dev_is_probed(const struct rte_device *dev);
+
/**
* Attach a device to a registered driver.
*
/**
* Attach a device to a registered driver.
*
rte_dev_event_monitor_stop;
rte_dev_hotplug_handle_disable;
rte_dev_hotplug_handle_enable;
rte_dev_event_monitor_stop;
rte_dev_hotplug_handle_disable;
rte_dev_hotplug_handle_enable;
rte_dev_iterator_init;
rte_dev_iterator_next;
rte_dev_probe;
rte_dev_iterator_init;
rte_dev_iterator_next;
rte_dev_probe;