ethdev: reset all when releasing a port
authorThomas Monjalon <thomas@monjalon.net>
Fri, 16 Oct 2020 13:32:58 +0000 (15:32 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 16 Oct 2020 20:26:41 +0000 (22:26 +0200)
The function rte_eth_dev_release_port() is partially resetting
the struct rte_eth_dev. The drivers were completing this reset
with more pointers set to NULL in the close or remove operations.

More pointers are reset at ethdev level,
and some redundant assignments are removed from PMDs.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Jeff Guo <jia.guo@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
31 files changed:
drivers/net/ark/ark_ethdev.c
drivers/net/atlantic/atl_ethdev.c
drivers/net/axgbe/axgbe_ethdev.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_reps.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/dpaa/dpaa_ethdev.c
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/e1000/em_ethdev.c
drivers/net/e1000/igb_ethdev.c
drivers/net/ena/ena_ethdev.c
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/hinic/hinic_pmd_ethdev.c
drivers/net/hns3/hns3_ethdev.c
drivers/net/hns3/hns3_ethdev_vf.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/i40e/i40e_ethdev_vf.c
drivers/net/iavf/iavf_ethdev.c
drivers/net/ice/ice_dcf_ethdev.c
drivers/net/ice/ice_ethdev.c
drivers/net/ionic/ionic_ethdev.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/liquidio/lio_ethdev.c
drivers/net/netvsc/hn_ethdev.c
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/qede/qede_ethdev.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/tap/rte_eth_tap.c
drivers/net/virtio/virtio_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
lib/librte_ethdev/rte_ethdev.c

index f135558..dc14f0f 100644 (file)
@@ -504,9 +504,6 @@ eth_ark_dev_uninit(struct rte_eth_dev *dev)
        ark_pktgen_uninit(ark->pg);
        ark_pktchkr_uninit(ark->pc);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
        return 0;
 }
 
index f2e48e1..d96865d 100644 (file)
@@ -702,10 +702,6 @@ atl_dev_close(struct rte_eth_dev *dev)
 
        atl_free_queues(dev);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* disable uio intr before callback unregister */
        rte_intr_disable(intr_handle);
        rte_intr_callback_unregister(intr_handle,
index cf08548..39087f3 100644 (file)
@@ -2134,9 +2134,6 @@ axgbe_dev_close(struct rte_eth_dev *eth_dev)
                return 0;
 
        pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
        axgbe_dev_clear_queues(eth_dev);
 
        /* disable uio intr before callback unregister */
index 8dd4ec3..64c67e7 100644 (file)
@@ -1433,10 +1433,6 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
        bnxt_free_pf_info(bp);
        bnxt_free_parent_info(bp);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-
        rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone);
        bp->tx_mem_zone = NULL;
        rte_memzone_free((const struct rte_memzone *)bp->rx_mem_zone);
index 74a76fc..012ccc7 100644 (file)
@@ -255,7 +255,6 @@ int bnxt_representor_uninit(struct rte_eth_dev *eth_dev)
 
        PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR uninit\n", eth_dev->data->port_id);
        eth_dev->data->mac_addrs = NULL;
-       eth_dev->dev_ops = NULL;
 
        parent_bp = rep->parent_dev->data->dev_private;
        if (!parent_bp) {
index 1c404b2..99910e9 100644 (file)
@@ -2130,10 +2130,6 @@ bond_ethdev_close(struct rte_eth_dev *dev)
         */
        rte_mempool_free(internals->mode6.mempool);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        return 0;
 }
 
index 952e8f7..6d27d74 100644 (file)
@@ -504,10 +504,6 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
        rte_free(dpaa_intf->tx_queues);
        dpaa_intf->tx_queues = NULL;
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        return 0;
 }
 
index d862451..ba99a52 100644 (file)
@@ -1284,10 +1284,6 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
        if (priv->extract.qos_extract_param)
                rte_free((void *)(size_t)priv->extract.qos_extract_param);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name);
        return 0;
 }
index dd9238a..304c040 100644 (file)
@@ -774,10 +774,6 @@ eth_em_close(struct rte_eth_dev *dev)
        em_release_manageability(hw);
        em_hw_control_release(hw);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* disable uio intr before callback unregister */
        rte_intr_disable(intr_handle);
        rte_intr_callback_unregister(intr_handle,
index f697b0e..9a3f9cb 100644 (file)
@@ -1565,10 +1565,6 @@ eth_igb_close(struct rte_eth_dev *dev)
        memset(&link, 0, sizeof(link));
        rte_eth_linkstatus_set(dev, &link);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* Reset any pending lock */
        igb_reset_swfw_lock(hw);
 
@@ -3405,10 +3401,6 @@ igbvf_dev_close(struct rte_eth_dev *dev)
        memset(&addr, 0, sizeof(addr));
        igbvf_default_mac_addr_set(dev, &addr);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        rte_intr_callback_unregister(&pci_dev->intr_handle,
                                     eth_igbvf_interrupt_handler,
                                     (void *)dev);
index e02d340..bdb8fe7 100644 (file)
@@ -1956,11 +1956,6 @@ static int eth_ena_dev_uninit(struct rte_eth_dev *eth_dev)
 
        ena_destroy_device(eth_dev);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->tx_pkt_prepare = NULL;
-
        return 0;
 }
 
index 0c13fd5..bada69c 100644 (file)
@@ -2805,10 +2805,6 @@ fm10k_dev_close(struct rte_eth_dev *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);
 
index daf8f33..2504228 100644 (file)
@@ -3253,10 +3253,6 @@ static int hinic_dev_uninit(struct rte_eth_dev *dev)
 
        hinic_dev_close(dev);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        rte_free(nic_dev->mc_list);
 
        return HINIC_OK;
index 8fcc0f1..c850e5e 100644 (file)
@@ -6201,10 +6201,6 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return -EPERM;
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->tx_pkt_prepare = NULL;
        if (hw->adapter_state < HNS3_NIC_CLOSING)
                hns3_dev_close(eth_dev);
 
index b203839..6e16958 100644 (file)
@@ -2847,11 +2847,6 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return -EPERM;
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->tx_pkt_prepare = NULL;
-
        if (hw->adapter_state < HNS3_NIC_CLOSING)
                hns3vf_dev_close(eth_dev);
 
index 825de51..605a179 100644 (file)
@@ -2693,10 +2693,6 @@ i40e_dev_close(struct rte_eth_dev *dev)
                        (reg | I40E_PFGEN_CTRL_PFSWR_MASK));
        I40E_WRITE_FLUSH(hw);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* Clear PXE mode */
        i40e_clear_pxe_mode(hw);
 
index 40c9745..3dcd50c 100644 (file)
@@ -2421,10 +2421,6 @@ i40evf_dev_close(struct rte_eth_dev *dev)
        i40e_shutdown_adminq(hw);
        i40evf_disable_irq0(hw);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        rte_free(vf->vf_res);
        vf->vf_res = NULL;
        rte_free(vf->aq_resp);
index 8bd2c04..c951e75 100644 (file)
@@ -1525,10 +1525,6 @@ iavf_dev_close(struct rte_eth_dev *dev)
                                     iavf_dev_interrupt_handler, dev);
        iavf_disable_irq0(hw);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
                if (vf->rss_lut) {
                        rte_free(vf->rss_lut);
index 33dd0c4..f2056e2 100644 (file)
@@ -855,10 +855,6 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
        if (rte_eal_process_type() != RTE_PROC_PRIMARY)
                return 0;
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        ice_dcf_uninit_parent_adapter(dev);
        ice_dcf_uninit_hw(dev, &adapter->real_hw);
 
index 468a6d7..d80c0a9 100644 (file)
@@ -2410,10 +2410,6 @@ ice_dev_close(struct rte_eth_dev *dev)
        rte_free(pf->proto_xtr);
        pf->proto_xtr = NULL;
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* disable uio intr before callback unregister */
        rte_intr_disable(intr_handle);
 
index ef7d06e..1387253 100644 (file)
@@ -1065,11 +1065,6 @@ eth_ionic_dev_uninit(struct rte_eth_dev *eth_dev)
        ionic_lif_deinit(lif);
        ionic_lif_free(lif);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->tx_pkt_prepare = NULL;
-
        return 0;
 }
 
index a45c596..841c687 100644 (file)
@@ -3010,10 +3010,6 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
        /* reprogram the RAR[0] in case user changed it. */
        ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        /* Unlock any pending hardware semaphore */
        ixgbe_swfw_lock_reset(hw);
 
@@ -5468,10 +5464,6 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
         **/
        ixgbevf_remove_mac_addr(dev, 0);
 
-       dev->dev_ops = NULL;
-       dev->rx_pkt_burst = NULL;
-       dev->tx_pkt_burst = NULL;
-
        rte_intr_disable(intr_handle);
        rte_intr_callback_unregister(intr_handle,
                                     ixgbevf_dev_interrupt_handler, dev);
index 52bcefc..1b01502 100644 (file)
@@ -2068,10 +2068,6 @@ lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
        /* lio_free_sc_buffer_pool */
        lio_free_sc_buffer_pool(lio_dev);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-
        return 0;
 }
 
index be3713d..8743e6e 100644 (file)
@@ -1050,10 +1050,6 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev)
        hn_dev_stop(eth_dev);
        hn_dev_close(eth_dev);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-
        hn_detach(hv);
        hn_chim_uninit(eth_dev);
        rte_vmbus_chan_close(hv->primary->chan);
index aa9ef3b..0ea6de4 100644 (file)
@@ -513,9 +513,6 @@ octeontx_dev_close(struct rte_eth_dev *dev)
 
        octeontx_port_close(nic);
 
-       dev->tx_pkt_burst = NULL;
-       dev->rx_pkt_burst = NULL;
-
        return 0;
 }
 
index 88389c9..0dd2f78 100644 (file)
@@ -1594,10 +1594,6 @@ static int qede_dev_close(struct rte_eth_dev *eth_dev)
        if (ECORE_IS_CMT(edev))
                rte_eal_alarm_cancel(qede_poll_sp_sb_cb, (void *)eth_dev);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-
        return 0;
 }
 
index 165776b..46042b2 100644 (file)
@@ -324,11 +324,7 @@ static void
 sfc_eth_dev_secondary_clear_ops(struct rte_eth_dev *dev)
 {
        free(dev->process_private);
-       dev->process_private = NULL;
-       dev->dev_ops = NULL;
-       dev->tx_pkt_prepare = NULL;
-       dev->tx_pkt_burst = NULL;
-       dev->rx_pkt_burst = NULL;
+       rte_eth_dev_release_port(dev);
 }
 
 static int
@@ -380,7 +376,6 @@ sfc_dev_close(struct rte_eth_dev *dev)
        /* Required for logging, so cleanup last */
        sa->eth_dev = NULL;
 
-       dev->process_private = NULL;
        free(sa);
 
        return 0;
index e592a46..6f2aa62 100644 (file)
@@ -1133,7 +1133,6 @@ tap_dev_close(struct rte_eth_dev *dev)
                internals->ioctl_sock = -1;
        }
        rte_free(dev->process_private);
-       dev->process_private = NULL;
        if (tap_devices_count == 1)
                rte_mp_action_unregister(TAP_MP_KEY);
        tap_devices_count--;
index aa8de55..e492e82 100644 (file)
@@ -2001,10 +2001,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
        virtio_dev_stop(eth_dev);
        virtio_dev_close(eth_dev);
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-
        PMD_INIT_LOG(DEBUG, "dev_uninit completed");
 
        return 0;
index 828043a..1d070fb 100644 (file)
@@ -368,11 +368,6 @@ eth_vmxnet3_dev_uninit(struct rte_eth_dev *eth_dev)
                return -EBUSY;
        }
 
-       eth_dev->dev_ops = NULL;
-       eth_dev->rx_pkt_burst = NULL;
-       eth_dev->tx_pkt_burst = NULL;
-       eth_dev->tx_pkt_prepare = NULL;
-
        return 0;
 }
 
index fe63965..2b56dd7 100644 (file)
@@ -561,7 +561,16 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 
        eth_dev->state = RTE_ETH_DEV_UNUSED;
        eth_dev->device = NULL;
+       eth_dev->process_private = NULL;
        eth_dev->intr_handle = NULL;
+       eth_dev->rx_pkt_burst = NULL;
+       eth_dev->tx_pkt_burst = NULL;
+       eth_dev->tx_pkt_prepare = NULL;
+       eth_dev->rx_queue_count = NULL;
+       eth_dev->rx_descriptor_done = NULL;
+       eth_dev->rx_descriptor_status = NULL;
+       eth_dev->tx_descriptor_status = NULL;
+       eth_dev->dev_ops = NULL;
 
        if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
                rte_free(eth_dev->data->rx_queues);