[dpdk-dev,RFC,v2,11/28] ethdev: Add rte_eth_dev_check_detachable

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

Commit Message

Tetsuya Mukawa Nov. 4, 2014, 3:45 a.m. UTC
The function returns whether a PMD supports detach function, or not.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_ether/rte_ethdev.c |  9 +++++++++
 lib/librte_ether/rte_ethdev.h | 11 +++++++++++
 2 files changed, 20 insertions(+)
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e3f2713..17f3ae4 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -451,6 +451,15 @@  rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
 	return 0;
 }
 
+int
+rte_eth_dev_check_detachable(uint8_t port_id)
+{
+	uint32_t drv_flags;
+
+	drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
+	return !!(drv_flags & RTE_PCI_DRV_DETACHABLE);
+}
+
 static int
 rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 11853f5..5cc438c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1677,6 +1677,17 @@  extern int rte_eth_dev_get_port_by_addr(
 extern int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name);
 
 /**
+ * Function for internal use by port hotplug functions.
+ * Check whether or not, a PMD that is handling the ethdev specified by port
+ * identifier can support detach function.
+ * @param	port_id
+ *   The port identifier
+ * @return
+ *   - 0 on supporting detach function, negative on not supporting
+ */
+extern int rte_eth_dev_check_detachable(uint8_t port_id);
+
+/**
  * Function for internal use by dummy drivers primarily, e.g. ring-based
  * driver.
  * Allocates a new ethdev slot for an ethernet device and returns the pointer