diff mbox

[dpdk-dev,RFC,v2,22/28] eal/pci: Add pci_close_all_drivers

Message ID 1415072748-31937-23-git-send-email-mukawa@igel.co.jp (mailing list archive)
State RFC, archived
Headers show

Commit Message

Tetsuya Mukawa Nov. 4, 2014, 3:45 a.m. UTC
The function tries to find a driver for the specified device, and then
close the driver.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_eal/common/eal_common_pci.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox

Patch

diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 1e3efea..b404ee0 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -100,6 +100,7 @@  static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 }
 
 #define INVOKE_PROBE	(0)
+#define INVOKE_CLOSE	(1)
 
 static int
 pci_invoke_all_drivers(struct rte_pci_device *dev, int type)
@@ -112,6 +113,11 @@  pci_invoke_all_drivers(struct rte_pci_device *dev, int type)
 		case INVOKE_PROBE:
 			rc = rte_eal_pci_probe_one_driver(dr, dev);
 			break;
+#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP)
+		case INVOKE_CLOSE:
+			rc = rte_eal_pci_close_one_driver(dr, dev);
+			break;
+#endif
 		}
 		if (rc < 0)
 			/* negative value is an error */
@@ -135,6 +141,19 @@  pci_probe_all_drivers(struct rte_pci_device *dev)
 	return pci_invoke_all_drivers(dev, INVOKE_PROBE);
 }
 
+#if defined(RTE_LIBRTE_EAL_HOTPLUG) && defined(RTE_LIBRTE_EAL_LINUXAPP)
+/*
+ * If vendor/device ID match, call the devclose() function of all
+ * registered driver for the given device. Return -1 if initialization
+ * failed, return 1 if no driver is found for this device.
+ */
+static int
+pci_close_all_drivers(struct rte_pci_device *dev)
+{
+	return pci_invoke_all_drivers(dev, INVOKE_CLOSE);
+}
+#endif /* RTE_LIBRTE_EAL_HOTPLUG & RTE_LIBRTE_EAL_LINUXAPP */
+
 /*
  * Scan the content of the PCI bus, and call the devinit() function for
  * all registered drivers that have a matching entry in its id_table