vfio: document multiprocess limitation for container API
[dpdk.git] / lib / librte_eal / common / eal_common_dev.c
index 6ac3ee8..fd7f5ca 100644 (file)
@@ -83,59 +83,6 @@ rte_dev_is_probed(const struct rte_device *dev)
        return dev->driver != NULL;
 }
 
-int rte_eal_dev_attach(const char *name, const char *devargs)
-{
-       struct rte_bus *bus;
-
-       if (name == NULL || devargs == NULL) {
-               RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
-               return -EINVAL;
-       }
-
-       bus = rte_bus_find_by_device_name(name);
-       if (bus == NULL) {
-               RTE_LOG(ERR, EAL, "Unable to find a bus for the device '%s'\n",
-                       name);
-               return -EINVAL;
-       }
-       if (strcmp(bus->name, "pci") == 0 || strcmp(bus->name, "vdev") == 0)
-               return rte_eal_hotplug_add(bus->name, name, devargs);
-
-       RTE_LOG(ERR, EAL,
-               "Device attach is only supported for PCI and vdev devices.\n");
-
-       return -ENOTSUP;
-}
-
-int rte_eal_dev_detach(struct rte_device *dev)
-{
-       struct rte_bus *bus;
-       int ret;
-
-       if (dev == NULL) {
-               RTE_LOG(ERR, EAL, "Invalid device provided.\n");
-               return -EINVAL;
-       }
-
-       bus = rte_bus_find_by_device(dev);
-       if (bus == NULL) {
-               RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
-                       dev->name);
-               return -EINVAL;
-       }
-
-       if (bus->unplug == NULL) {
-               RTE_LOG(ERR, EAL, "Bus function not supported\n");
-               return -ENOTSUP;
-       }
-
-       ret = bus->unplug(dev);
-       if (ret)
-               RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n",
-                       dev->name);
-       return ret;
-}
-
 /* helper function to build devargs, caller should free the memory */
 static int
 build_devargs(const char *busname, const char *devname,
@@ -203,10 +150,11 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)
                goto err_devarg;
        }
 
-       ret = rte_devargs_insert(da);
+       ret = rte_devargs_insert(&da);
        if (ret)
                goto err_devarg;
 
+       /* the rte_devargs will be referenced in the matching rte_device */
        ret = da->bus->scan();
        if (ret)
                goto err_devarg;
@@ -218,18 +166,20 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev)
                ret = -ENODEV;
                goto err_devarg;
        }
+       /* Since there is a matching device, it is now its responsibility
+        * to manage the devargs we've just inserted. From this point
+        * those devargs shouldn't be removed manually anymore.
+        */
 
        ret = dev->bus->plug(dev);
-       if (ret) {
-               if (rte_dev_is_probed(dev)) /* if already succeeded earlier */
-                       return ret; /* no rollback */
+       if (ret && !rte_dev_is_probed(dev)) { /* if hasn't ever succeeded */
                RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
                        dev->name);
-               goto err_devarg;
+               return ret;
        }
 
        *new_dev = dev;
-       return 0;
+       return ret;
 
 err_devarg:
        if (rte_devargs_remove(da) != 0) {
@@ -239,7 +189,7 @@ err_devarg:
        return ret;
 }
 
-int __rte_experimental
+int
 rte_dev_probe(const char *devargs)
 {
        struct eal_dev_mp_req req;
@@ -375,7 +325,7 @@ local_dev_remove(struct rte_device *dev)
        return 0;
 }
 
-int __rte_experimental
+int
 rte_dev_remove(struct rte_device *dev)
 {
        struct eal_dev_mp_req req;