net/fm10k: release port upon close
authorChenxu Di <chenxux.di@intel.com>
Fri, 27 Sep 2019 09:09:45 +0000 (09:09 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:57 +0000 (15:00 +0200)
Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private resources
 for the port can be freed by rte_eth_dev_close().

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
doc/guides/rel_notes/release_19_11.rst
drivers/net/fm10k/fm10k_ethdev.c

index 87c6a65..1b3c417 100644 (file)
@@ -66,6 +66,10 @@ New Features
 
   Added support for the ``RTE_ETH_DEV_CLOSE_REMOVE`` flag.
 
+* **Updated the Intel fm10k driver.**
+
+  Added support for the ``RTE_ETH_DEV_CLOSE_REMOVE`` flag.
+
 * **Updated the Intel ice driver.**
 
   Updated the Intel ice driver with new features and improvements, including:
index 9fbedbf..dc8bc75 100644 (file)
@@ -1210,28 +1210,6 @@ fm10k_dev_queue_release(struct rte_eth_dev *dev)
        }
 }
 
-static void
-fm10k_dev_close(struct rte_eth_dev *dev)
-{
-       struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
-       PMD_INIT_FUNC_TRACE();
-
-       fm10k_mbx_lock(hw);
-       hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map,
-               MAX_LPORT_NUM, false);
-       fm10k_mbx_unlock(hw);
-
-       /* allow 100ms for device to quiesce */
-       rte_delay_us(FM10K_SWITCH_QUIESCE_US);
-
-       /* Stop mailbox service first */
-       fm10k_close_mbx_service(hw);
-       fm10k_dev_stop(dev);
-       fm10k_dev_queue_release(dev);
-       fm10k_stop_hw(hw);
-}
-
 static int
 fm10k_link_update(struct rte_eth_dev *dev,
        __rte_unused int wait_to_complete)
@@ -2819,6 +2797,53 @@ fm10k_close_mbx_service(struct fm10k_hw *hw)
        hw->mbx.ops.disconnect(hw, &hw->mbx);
 }
 
+static void
+fm10k_dev_close(struct rte_eth_dev *dev)
+{
+       struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(dev);
+       struct rte_intr_handle *intr_handle = &pdev->intr_handle;
+
+       PMD_INIT_FUNC_TRACE();
+
+       fm10k_mbx_lock(hw);
+       hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map,
+               MAX_LPORT_NUM, false);
+       fm10k_mbx_unlock(hw);
+
+       /* allow 100ms for device to quiesce */
+       rte_delay_us(FM10K_SWITCH_QUIESCE_US);
+
+       /* Stop mailbox service first */
+       fm10k_close_mbx_service(hw);
+       fm10k_dev_stop(dev);
+       fm10k_dev_queue_release(dev);
+       fm10k_stop_hw(hw);
+
+       dev->dev_ops = NULL;
+       dev->rx_pkt_burst = NULL;
+       dev->tx_pkt_burst = NULL;
+
+       /* disable uio/vfio intr */
+       rte_intr_disable(intr_handle);
+
+       /*PF/VF has different interrupt handling mechanism */
+       if (hw->mac.type == fm10k_mac_pf) {
+               /* disable interrupt */
+               fm10k_dev_disable_intr_pf(dev);
+
+               /* unregister callback func to eal lib */
+               rte_intr_callback_unregister(intr_handle,
+                       fm10k_dev_interrupt_handler_pf, (void *)dev);
+       } else {
+               /* disable interrupt */
+               fm10k_dev_disable_intr_vf(dev);
+
+               rte_intr_callback_unregister(intr_handle,
+                       fm10k_dev_interrupt_handler_vf, (void *)dev);
+       }
+}
+
 static const struct eth_dev_ops fm10k_eth_dev_ops = {
        .dev_configure          = fm10k_dev_configure,
        .dev_start              = fm10k_dev_start,
@@ -3123,6 +3148,11 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
                &dev->data->mac_addrs[0]);
        }
 
+       /* Pass the information to the rte_eth_dev_close() that it should also
+        * release the private port resources.
+        */
+       dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
        /* Reset the hw statistics */
        diag = fm10k_stats_reset(dev);
        if (diag != 0) {
@@ -3229,9 +3259,6 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 static int
 eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
 {
-       struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pdev->intr_handle;
        PMD_INIT_FUNC_TRACE();
 
        /* only uninitialize in the primary process */
@@ -3241,29 +3268,6 @@ eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
        /* safe to close dev here */
        fm10k_dev_close(dev);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
-       /* disable uio/vfio intr */
-       rte_intr_disable(intr_handle);
-
-       /*PF/VF has different interrupt handling mechanism */
-       if (hw->mac.type == fm10k_mac_pf) {
-               /* disable interrupt */
-               fm10k_dev_disable_intr_pf(dev);
-
-               /* unregister callback func to eal lib */
-               rte_intr_callback_unregister(intr_handle,
-                       fm10k_dev_interrupt_handler_pf, (void *)dev);
-       } else {
-               /* disable interrupt */
-               fm10k_dev_disable_intr_vf(dev);
-
-               rte_intr_callback_unregister(intr_handle,
-                       fm10k_dev_interrupt_handler_vf, (void *)dev);
-       }
-
        return 0;
 }