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) {
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);
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) {
* we call each driver probe.
*/
- if (dev->device.driver)
+ if (rte_dev_is_probed(&dev->device))
continue;
if (vdev_probe_all_drivers(dev)) {
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;
}
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;
goto err_devarg;
}
- if (dev->driver != NULL) {
+ if (rte_dev_is_probed(dev)) {
RTE_LOG(ERR, EAL, "Device is already plugged\n");
return -EEXIST;
}
{
int ret;
- 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);
char *devargs;
int ret;
+ 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;
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.
*
rte_dev_event_monitor_stop;
rte_dev_hotplug_handle_disable;
rte_dev_hotplug_handle_enable;
+ rte_dev_is_probed;
rte_dev_iterator_init;
rte_dev_iterator_next;
rte_dev_probe;