[dpdk-dev,v3,2/2] net/i40e: add hot plug monitor in i40e

Message ID 1498711073-42917-3-git-send-email-jia.guo@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Guo, Jia June 29, 2017, 4:37 a.m. UTC
From: "Guo, Jia" <jia.guo@intel.com>

This patch enable the hot plug feature in i40e, by monitoring the
hot plug uevent of the device. When remove event got, call the app
callback function to handle the detach process.

Signed-off-by: Guo, Jia <jia.guo@intel.com>
---
v3->v2: refine the return issue if device remove
---
 drivers/net/i40e/i40e_ethdev.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
  

Comments

Jingjing Wu June 30, 2017, 3:38 a.m. UTC | #1
> -----Original Message-----
> From: Guo, Jia
> Sent: Thursday, June 29, 2017 12:38 PM
> To: Zhang, Helin <helin.zhang@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Guo, Jia <jia.guo@intel.com>
> Subject: [PATCH v3 2/2] net/i40e: add hot plug monitor in i40e
> 
> From: "Guo, Jia" <jia.guo@intel.com>
> 
> This patch enable the hot plug feature in i40e, by monitoring the hot plug
> uevent of the device. When remove event got, call the app callback function to
> handle the detach process.
> 
> Signed-off-by: Guo, Jia <jia.guo@intel.com>

Acked-by: Jingjing Wu <jingjing.wu@intel.com>
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 4ee1113..67ffc14 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1283,6 +1283,7 @@  static inline void i40e_GLQF_reg_init(struct i40e_hw *hw)
 
 	/* enable uio intr after callback register */
 	rte_intr_enable(intr_handle);
+
 	/*
 	 * Add an ethertype filter to drop all flow control frames transmitted
 	 * from VSIs. By doing so, we stop VF from sending out PAUSE or PFC
@@ -5832,11 +5833,29 @@  struct i40e_vsi *
 {
 	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct rte_uevent event;
 	uint32_t icr0;
+	struct rte_pci_device *pci_dev;
+	struct rte_intr_handle *intr_handle;
+
+	pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	intr_handle = &pci_dev->intr_handle;
 
 	/* Disable interrupt */
 	i40e_pf_disable_irq0(hw);
 
+	/* check device uevent */
+	if (rte_uevent_get(intr_handle->uevent_fd, &event) == 0) {
+		if (event.subsystem == RTE_UEVENT_SUBSYSTEM_UIO) {
+			if (event.action == RTE_UEVENT_REMOVE) {
+				_rte_eth_dev_callback_process(dev,
+					RTE_ETH_EVENT_INTR_RMV, NULL);
+				return;
+			}
+		}
+		goto done;
+	}
+
 	/* read out interrupt causes */
 	icr0 = I40E_READ_REG(hw, I40E_PFINT_ICR0);