]> git.droids-corp.org - dpdk.git/commitdiff
eal: add hotplug operations for PCI and vdev
authorDavid Marchand <david.marchand@6wind.com>
Tue, 20 Sep 2016 12:41:24 +0000 (18:11 +0530)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 3 Oct 2016 14:33:32 +0000 (16:33 +0200)
Hotplug invocations, which deals with devices, should come from the layer
that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus
that will handle the request.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
lib/librte_eal/bsdapp/eal/rte_eal_version.map
lib/librte_eal/common/eal_common_dev.c
lib/librte_eal/common/include/rte_dev.h
lib/librte_eal/linuxapp/eal/rte_eal_version.map

index a06acc1c023ce5be80e0fc68819d09cb914a5021..fa8a13898666ae56a55dd00b2396d75a16a2fbc0 100644 (file)
@@ -168,5 +168,7 @@ DPDK_16.11 {
 
        rte_delay_us_block;
        rte_delay_us_callback_register;
+       rte_eal_dev_attach;
+       rte_eal_dev_detach;
 
 } DPDK_16.07;
index a8a4146c63f9247fd7c8abb677190eb6dd602be1..88f9d3fd0bc8190dadd885a33b7cd4773ea6c54e 100644 (file)
@@ -150,3 +150,51 @@ rte_eal_vdev_uninit(const char *name)
        RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
        return -EINVAL;
 }
+
+int rte_eal_dev_attach(const char *name, const char *devargs)
+{
+       struct rte_pci_addr addr;
+
+       if (name == NULL || devargs == NULL) {
+               RTE_LOG(ERR, EAL, "Invalid device or arguments provided\n");
+               return -EINVAL;
+       }
+
+       if (eal_parse_pci_DomBDF(name, &addr) == 0) {
+               if (rte_eal_pci_probe_one(&addr) < 0)
+                       goto err;
+
+       } else {
+               if (rte_eal_vdev_init(name, devargs))
+                       goto err;
+       }
+
+       return 0;
+
+err:
+       RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", name);
+       return -EINVAL;
+}
+
+int rte_eal_dev_detach(const char *name)
+{
+       struct rte_pci_addr addr;
+
+       if (name == NULL) {
+               RTE_LOG(ERR, EAL, "Invalid device provided.\n");
+               return -EINVAL;
+       }
+
+       if (eal_parse_pci_DomBDF(name, &addr) == 0) {
+               if (rte_eal_pci_detach(&addr) < 0)
+                       goto err;
+       } else {
+               if (rte_eal_vdev_uninit(name))
+                       goto err;
+       }
+       return 0;
+
+err:
+       RTE_LOG(ERR, EAL, "Driver cannot detach the device (%s)\n", name);
+       return -EINVAL;
+}
index 94ae14e4ea17a0e925da08f31920b743acf97394..6cc9b017ca83bcf87c5e1737bd65b3f494055d59 100644 (file)
@@ -178,6 +178,32 @@ int rte_eal_vdev_init(const char *name, const char *args);
  */
 int rte_eal_vdev_uninit(const char *name);
 
+/**
+ * Attach a device to a registered driver.
+ *
+ * @param name
+ *   The device name, that refers to a pci device (or some private
+ *   way of designating a vdev device). 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_dev_attach(const char *name, const char *devargs);
+
+/**
+ * Detach a device from its driver.
+ *
+ * @param name
+ *   Same description as for rte_eal_dev_attach().
+ *   Here, eal will call the driver detaching function.
+ * @return
+ *   0 on success, negative on error.
+ */
+int rte_eal_dev_detach(const char *name);
+
 #define DRIVER_EXPORT_NAME_ARRAY(n, idx) n##idx[]
 
 #define DRIVER_EXPORT_NAME(name, idx) \
index db216cca176eec2a187f423c93911910719dd9a2..cdd0033b59a5df097c036c732a0ed8617b4a1b26 100644 (file)
@@ -172,5 +172,7 @@ DPDK_16.11 {
 
        rte_delay_us_block;
        rte_delay_us_callback_register;
+       rte_eal_dev_attach;
+       rte_eal_dev_detach;
 
 } DPDK_16.07;