net/ice: release port upon close
authorChenxu Di <chenxux.di@intel.com>
Fri, 27 Sep 2019 09:09:47 +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/ice/ice_ethdev.c

index ca93f9d..46d3145 100644 (file)
@@ -81,6 +81,7 @@ New Features
   * Added support for device-specific DDP package loading.
   * Added support for handling Receive Flex Descriptor.
   * Added support for protocol extraction on per Rx queue.
+  * Added support for the ``RTE_ETH_DEV_CLOSE_REMOVE`` flag.
 
 * **Added Marvell NITROX symmetric crypto PMD.**
 
index c126d96..dfccef6 100644 (file)
@@ -1924,6 +1924,11 @@ ice_dev_init(struct rte_eth_dev *dev)
                goto err_init_mac;
        }
 
+       /* 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;
+
        ret = ice_res_pool_init(&pf->msix_pool, 1,
                                hw->func_caps.common_cap.num_msix_vectors - 1);
        if (ret) {
@@ -2090,6 +2095,9 @@ ice_dev_close(struct rte_eth_dev *dev)
 {
        struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+       struct rte_flow *p_flow;
 
        /* Since stop will make link down, then the link event will be
         * triggered, disable the irq firstly to avoid the port_infoe etc
@@ -2109,22 +2117,6 @@ ice_dev_close(struct rte_eth_dev *dev)
        rte_free(hw->port_info);
        hw->port_info = NULL;
        ice_shutdown_all_ctrlq(hw);
-       rte_free(pf->proto_xtr);
-       pf->proto_xtr = NULL;
-}
-
-static int
-ice_dev_uninit(struct rte_eth_dev *dev)
-{
-       struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
-       struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
-       struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
-       struct rte_flow *p_flow;
-
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return 0;
-
-       ice_dev_close(dev);
 
        dev->dev_ops = NULL;
        dev->rx_pkt_burst = NULL;
@@ -2146,6 +2138,12 @@ ice_dev_uninit(struct rte_eth_dev *dev)
                ice_free_switch_filter_rule(p_flow->rule);
                rte_free(p_flow);
        }
+}
+
+static int
+ice_dev_uninit(struct rte_eth_dev *dev)
+{
+       ice_dev_close(dev);
 
        return 0;
 }