]> git.droids-corp.org - dpdk.git/commitdiff
drivers/net: check process type in close operation
authorThomas Monjalon <thomas@monjalon.net>
Mon, 28 Sep 2020 23:14:31 +0000 (01:14 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:14 +0000 (19:19 +0200)
The secondary processes are not allowed to release shared resources.
Only process-private resources should be freed in a secondary process.
Most of the time, there is no process-private resource,
so the close operation is just forbidden in a secondary process.

After adding proper check in the port close functions,
some redundant checks in the device remove functions are dropped.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Reviewed-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
Reviewed-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Jeff Guo <jia.guo@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
37 files changed:
drivers/net/af_xdp/rte_eth_af_xdp.c
drivers/net/ark/ark_ethdev.c
drivers/net/avp/avp_ethdev.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_reps.c
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/e1000/em_ethdev.c
drivers/net/e1000/igb_ethdev.c
drivers/net/ena/ena_ethdev.c
drivers/net/enetc/enetc_ethdev.c
drivers/net/enic/enic_ethdev.c
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/hinic/hinic_pmd_ethdev.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/i40e/i40e_ethdev_vf.c
drivers/net/iavf/iavf_ethdev.c
drivers/net/ice/ice_ethdev.c
drivers/net/igc/igc_ethdev.c
drivers/net/ionic/ionic_ethdev.c
drivers/net/ipn3ke/ipn3ke_representor.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/kni/rte_eth_kni.c
drivers/net/liquidio/lio_ethdev.c
drivers/net/mlx4/mlx4.c
drivers/net/mvneta/mvneta_ethdev.c
drivers/net/mvpp2/mrvl_ethdev.c
drivers/net/netvsc/hn_ethdev.c
drivers/net/nfb/nfb_ethdev.c
drivers/net/nfp/nfp_net.c
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/pfe/pfe_ethdev.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/szedata2/rte_eth_szedata2.c
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/vhost/rte_eth_vhost.c
drivers/net/virtio/virtio_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c

index 5480d2a39e8a27974dbed74c5ca591743bf76bef..99f977f8ac88fc849a99ab2a1719f64b4814476b 100644 (file)
@@ -821,6 +821,9 @@ eth_dev_close(struct rte_eth_dev *dev)
        struct pkt_rx_queue *rxq;
        int i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        AF_XDP_LOG(INFO, "Closing AF_XDP ethdev on numa socket %u\n",
                rte_socket_id());
 
index 83dc4ecd2cff3fa19858e90f1dbc82459d4eb5b6..3e96445fdbb98e370c1a44c58f221876f6243618 100644 (file)
@@ -680,6 +680,9 @@ eth_ark_dev_close(struct rte_eth_dev *dev)
        struct ark_adapter *ark = dev->data->dev_private;
        uint16_t i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        if (ark->user_ext.dev_close)
                ark->user_ext.dev_close(dev,
                 ark->user_data[dev->data->port_id]);
index c730b7ab86b69480c74af14d79bce36c9b8cb126..95fdb574516cb888fa0e913b430e945a33579175 100644 (file)
@@ -2107,6 +2107,9 @@ avp_dev_close(struct rte_eth_dev *eth_dev)
        struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
        int ret;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        rte_spinlock_lock(&avp->lock);
        if (avp->flags & AVP_F_DETACHED) {
                PMD_DRV_LOG(ERR, "Operation not supported during VM live migration\n");
index 5ef9e1ea98c353934bf7c1a16b7d5ba68af635ce..a6812c1a66b64b3e607e11ce3f85ffd67dfd5d90 100644 (file)
@@ -1408,6 +1408,9 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 {
        struct bnxt *bp = eth_dev->data->dev_private;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        /* cancel the recovery handler before remove dev */
        rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp);
        rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp);
index cc1189de1b144a8a6a43c60e5780550ca0046925..74a76fce5712b4b47682cd2f7c28a454750b3857 100644 (file)
@@ -250,6 +250,9 @@ int bnxt_representor_uninit(struct rte_eth_dev *eth_dev)
                (struct bnxt_representor *)eth_dev->data->dev_private;
        uint16_t vf_id;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        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;
index e4bbba5c325712ec7b8f814f461293622d50898a..16beb2d435c2c9fedf07c853d489dea2a2191eb3 100644 (file)
@@ -326,6 +326,9 @@ int cxgbe_dev_close(struct rte_eth_dev *eth_dev)
 
        CXGBE_FUNC_TRACE();
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        if (!(adapter->flags & FULL_INIT_DONE))
                return 0;
 
index 6a6ae0e9d57c940b4bd8c974c67215b6ecdc9fed..d050eb478a48a604c624ff942979810fb969e09c 100644 (file)
@@ -762,6 +762,9 @@ eth_em_close(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;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        eth_em_stop(dev);
        adapter->stopped = 1;
        em_dev_free_queues(dev);
index f8778207efe7d54af47969090001ee04887a2dc6..cb3d97e2a385d9af1d39c2de91469b4226ed1973 100644 (file)
@@ -1535,6 +1535,9 @@ eth_igb_close(struct rte_eth_dev *dev)
        struct e1000_filter_info *filter_info =
                E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        eth_igb_stop(dev);
 
        e1000_phy_hw_reset(hw);
@@ -3382,6 +3385,9 @@ igbvf_dev_close(struct rte_eth_dev *dev)
 
        PMD_INIT_FUNC_TRACE();
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        e1000_reset_hw(hw);
 
        igbvf_dev_stop(dev);
index ae410d1af9bb1da7e1b4985e9b5a28a4596431fb..d32fa43837531916183c60b99eaa2e3e2690f8aa 100644 (file)
@@ -506,6 +506,9 @@ static int ena_close(struct rte_eth_dev *dev)
        struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
        struct ena_adapter *adapter = dev->data->dev_private;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        if (adapter->state == ENA_ADAPTER_STATE_RUNNING)
                ena_stop(dev);
        adapter->state = ENA_ADAPTER_STATE_CLOSED;
index 325c93b92aa91dc66b3fea6683898c8dbe5cc6c9..b3dec7e64dc7a0f4925997ef07df35e6797b18c2 100644 (file)
@@ -551,6 +551,9 @@ enetc_dev_close(struct rte_eth_dev *dev)
        uint16_t i;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        enetc_dev_stop(dev);
 
        for (i = 0; i < dev->data->nb_rx_queues; i++) {
index 27f60b45b8f3b4a1f1cdf222a83de20bebefc071..60ee5e01deeabcc597fafe351f986d7664bafa9f 100644 (file)
@@ -451,6 +451,9 @@ static int enicpmd_dev_close(struct rte_eth_dev *eth_dev)
        struct enic *enic = pmd_priv(eth_dev);
 
        ENICPMD_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        enic_remove(enic);
 
        return 0;
index 37193985a729f1c04c49502c8bd47a5d2bb18276..30963707185de904400161671e25957b1c52979a 100644 (file)
@@ -2785,6 +2785,8 @@ fm10k_dev_close(struct rte_eth_dev *dev)
        struct rte_intr_handle *intr_handle = &pdev->intr_handle;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        fm10k_mbx_lock(hw);
        hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map,
@@ -3237,14 +3239,7 @@ static int
 eth_fm10k_dev_uninit(struct rte_eth_dev *dev)
 {
        PMD_INIT_FUNC_TRACE();
-
-       /* only uninitialize in the primary process */
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return 0;
-
-       /* safe to close dev here */
        fm10k_dev_close(dev);
-
        return 0;
 }
 
index 7e0e6d896d31ead2c495f8ff234a0236628ceb62..6061f61fd6ea0e5b07ef3f3922b8e218ddadb0c4 100644 (file)
@@ -2969,6 +2969,9 @@ static int hinic_dev_close(struct rte_eth_dev *dev)
 {
        struct hinic_nic_dev *nic_dev = HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(dev);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        if (rte_bit_relaxed_test_and_set32(HINIC_DEV_CLOSE,
                                           &nic_dev->dev_status)) {
                PMD_DRV_LOG(WARNING, "Device %s already closed",
index a8e8f6b865fdd33bc080948b1d1752e8d91ec9e2..943cfe71dc41578e5efba9311ce3f05f768c334f 100644 (file)
@@ -2620,6 +2620,8 @@ i40e_dev_close(struct rte_eth_dev *dev)
        int retries = 0;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        ret = rte_eth_switch_domain_free(pf->switch_domain_id);
        if (ret)
index 4aaf41956c117236b6cac690a539a4a65e9f12a3..4d6510d1ff6967cd64a9b9222aa4643880a2e808 100644 (file)
@@ -2402,6 +2402,9 @@ i40evf_dev_close(struct rte_eth_dev *dev)
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        i40evf_dev_stop(dev);
        i40e_dev_free_queues(dev);
        /*
index 512ade2ad0cd72be238ed74a232d68cc1b9a078c..a5b14333062562cb969f55c4a72ac47b79beb7fd 100644 (file)
@@ -1468,6 +1468,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
                IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
        struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        iavf_dev_stop(dev);
        iavf_flow_flush(dev, NULL);
        iavf_flow_uninit(adapter);
index 72375fe481c9f42a3bf6f2ae263009bd960192d8..5f7b58a787b7e5f0b7ce62e01abc8133ff427b0b 100644 (file)
@@ -2388,6 +2388,9 @@ ice_dev_close(struct rte_eth_dev *dev)
        struct ice_adapter *ad =
                ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        /* Since stop will make link down, then the link event will be
         * triggered, disable the irq firstly to avoid the port_infoe etc
         * resources deallocation causing the interrupt service thread
index 9d27fc0d0733374fb648937da86b4fa80fdd3432..7f5066df4b7514de38bb5a6a20edba55db0afc58 100644 (file)
@@ -1175,6 +1175,8 @@ eth_igc_close(struct rte_eth_dev *dev)
        int retry = 0;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        if (!adapter->stopped)
                eth_igc_stop(dev);
@@ -1363,10 +1365,6 @@ static int
 eth_igc_dev_uninit(__rte_unused struct rte_eth_dev *eth_dev)
 {
        PMD_INIT_FUNC_TRACE();
-
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return 0;
-
        eth_igc_close(eth_dev);
        return 0;
 }
index 1775fd29b7a9afbe8164ec3cf7a42f7687c107ff..ef7d06e526bf1b387945a4a7377044c0488095d0 100644 (file)
@@ -963,6 +963,8 @@ ionic_dev_close(struct rte_eth_dev *eth_dev)
        int err;
 
        IONIC_PRINT_CALL();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        err = ionic_lif_stop(lif);
        if (err) {
index d49abbf7589d908e0f527e1ff1d1ecdfc55d6227..b9fb4d4e469e1468cbc2214dfb2f7285254e827f 100644 (file)
@@ -214,6 +214,9 @@ ipn3ke_rpst_dev_close(struct rte_eth_dev *dev)
        struct ipn3ke_hw *hw = IPN3KE_DEV_PRIVATE_TO_HW(dev);
        struct ipn3ke_rpst *rpst = IPN3KE_DEV_PRIVATE_TO_RPST(dev);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        if (hw->retimer.mac_type == IFPGA_RAWDEV_RETIMER_MAC_TYPE_10GE_XFI) {
                /* Disable the TX path */
                ipn3ke_xmac_tx_disable(hw, rpst->port_id, 0);
index a0784789f8c744dc0852c2610df5d9e5dddcf15a..0b98e210e7fd0c3adc2c304850e479e124740c51 100644 (file)
@@ -2995,6 +2995,8 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
        int ret;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        ixgbe_pf_reset_hw(hw);
 
@@ -5448,6 +5450,8 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
        struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        ixgbe_reset_hw(hw);
 
index 2a4058f7b06aff8bde9d159495f6a4a2bc56c5ec..be747adf867bdfb187f845a28413f0f9022627a4 100644 (file)
@@ -204,6 +204,9 @@ eth_kni_close(struct rte_eth_dev *eth_dev)
        struct pmd_internals *internals;
        int ret;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        eth_kni_dev_stop(eth_dev);
 
        /* mac_addrs must not be freed alone because part of dev_private */
index 93e2ed56705ab358948780222c24aebac66b2772..1a41f2719872ac6da04d387450247090d8bdc2a3 100644 (file)
@@ -1555,6 +1555,9 @@ lio_dev_close(struct rte_eth_dev *eth_dev)
 {
        struct lio_device *lio_dev = LIO_DEV(eth_dev);
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        lio_dev_info(lio_dev, "closing port %d\n", eth_dev->data->port_id);
 
        if (lio_dev->intf_open)
index 3e578754140084fc5ef04eea2ae83c404f594e35..cfcfb8a8fcaad8ead8c816c05437505ee6091f2d 100644 (file)
@@ -376,6 +376,8 @@ mlx4_dev_close(struct rte_eth_dev *dev)
        struct mlx4_priv *priv = dev->data->dev_private;
        unsigned int i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
        DEBUG("%p: closing device \"%s\"",
              (void *)dev,
              ((priv->ctx != NULL) ? priv->ctx->device->name : ""));
index db142bec23c078796dd1f46be57f52a46b042ec3..607771149a2f664e9aa84f712f78013e239887d9 100644 (file)
@@ -435,6 +435,9 @@ mvneta_dev_close(struct rte_eth_dev *dev)
        struct mvneta_priv *priv = dev->data->dev_private;
        int i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        if (priv->ppio)
                mvneta_dev_stop(dev);
 
index cfb97e4f8f7fb34047c307eebca783a7e0fe41be..a230a9684028796bb1a20a783916a88159129dcb 100644 (file)
@@ -861,6 +861,9 @@ mrvl_dev_close(struct rte_eth_dev *dev)
        struct mrvl_priv *priv = dev->data->dev_private;
        size_t i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        mrvl_flush_rx_queues(dev);
        mrvl_flush_tx_shadow_queues(dev);
        mrvl_flow_deinit(dev);
index 19a9eb6bc2dd965dd616a0b5f4bd66368eef38c1..5ae2d469c8954350a25d1c6068838d045f68e06e 100644 (file)
@@ -842,6 +842,8 @@ static int
 hn_dev_close(struct rte_eth_dev *dev)
 {
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        hn_vf_close(dev);
        hn_dev_free_queues(dev);
index d937ac6922e13c6119c8a78dc873a5d2fb5d4674..7ee7294143a295d3a790e73b1fff7e8e1e1fc6c8 100644 (file)
@@ -217,6 +217,9 @@ nfb_eth_dev_close(struct rte_eth_dev *dev)
        uint16_t nb_rx = dev->data->nb_rx_queues;
        uint16_t nb_tx = dev->data->nb_tx_queues;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        nfb_eth_dev_stop(dev);
 
        nfb_nc_rxmac_deinit(internals->rxmac, internals->max_rxmac);
index ce25cf1ed47bc16bc035b448d956af0f445a3a13..c1da66e3d62eaf2f3c9e6d2a5aa90fcd12da7b08 100644 (file)
@@ -871,6 +871,9 @@ nfp_net_close(struct rte_eth_dev *dev)
        struct rte_pci_device *pci_dev;
        int i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        PMD_INIT_LOG(DEBUG, "Close");
 
        hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
index a263f45399e9e9dc20937c74748f35639a7b59b6..aa9ef3bb70085fb8e358c16c887a90ded63ded3c 100644 (file)
@@ -487,6 +487,8 @@ octeontx_dev_close(struct rte_eth_dev *dev)
        int ret;
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        rte_event_dev_close(nic->evdev);
 
index bb2ae0df34bf95c718f5da5bfa14968f51911017..f0de1c8a2e62ea306e5cd7a90c8081ba4a5fa3bd 100644 (file)
@@ -396,6 +396,9 @@ pfe_eth_close(struct rte_eth_dev *dev)
        if (!g_pfe)
                return -1;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        pfe_eth_stop(dev);
        /* Close the device file for link status */
        pfe_eth_close_cdev(dev->data->dev_private);
index f6828436e9bc0c372390985fd990cf68bb545d1f..6e6eb16860c7cbb9df78318dd9fe115a0ded2a52 100644 (file)
@@ -318,6 +318,17 @@ sfc_dev_set_link_down(struct rte_eth_dev *dev)
        return 0;
 }
 
+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;
+}
+
 static int
 sfc_dev_close(struct rte_eth_dev *dev)
 {
@@ -325,6 +336,11 @@ sfc_dev_close(struct rte_eth_dev *dev)
 
        sfc_log_init(sa, "entry");
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+               sfc_eth_dev_secondary_clear_ops(dev);
+               return 0;
+       }
+
        sfc_adapter_lock(sa);
        switch (sa->state) {
        case SFC_ADAPTER_STARTED:
@@ -2101,17 +2117,6 @@ fail_alloc_priv:
        return rc;
 }
 
-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;
-}
-
 static void
 sfc_register_dp(void)
 {
@@ -2258,11 +2263,6 @@ fail_alloc_sa:
 static int
 sfc_eth_dev_uninit(struct rte_eth_dev *dev)
 {
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
-               sfc_eth_dev_secondary_clear_ops(dev);
-               return 0;
-       }
-
        sfc_dev_close(dev);
 
        return 0;
index 5f589dfa4c93de11c590a7957d246e7de2bd4ca5..7e9fafdcf7df294c1d710d8bbb06a2b2ed2ffc89 100644 (file)
@@ -1163,6 +1163,9 @@ eth_dev_close(struct rte_eth_dev *dev)
        uint16_t nb_rx = dev->data->nb_rx_queues;
        uint16_t nb_tx = dev->data->nb_tx_queues;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        eth_dev_stop(dev);
 
        free(internals->sze_dev_path);
index 3d7348771a5e7dd7023266b3d075e20cb03a6ebd..cc6eb4ba245d0b04789328cc4d044f0cd87fe27a 100644 (file)
@@ -1859,6 +1859,8 @@ nicvf_dev_close(struct rte_eth_dev *dev)
        struct nicvf *nic = nicvf_pmd_priv(dev);
 
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        nicvf_dev_stop_cleanup(dev, true);
        nicvf_periodic_alarm_stop(nicvf_interrupt, dev);
@@ -2119,10 +2121,7 @@ static int
 nicvf_eth_dev_uninit(struct rte_eth_dev *dev)
 {
        PMD_INIT_FUNC_TRACE();
-
-       if (rte_eal_process_type() == RTE_PROC_PRIMARY)
-               nicvf_dev_close(dev);
-
+       nicvf_dev_close(dev);
        return 0;
 }
 static int
index 45552ef742affd6dcd521d66878c273120ad2392..32ad27fe4e09d73edc7c2c3ef7f5c4585c1146cb 100644 (file)
@@ -1171,6 +1171,9 @@ eth_dev_close(struct rte_eth_dev *dev)
        struct internal_list *list;
        unsigned int i;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
+
        internal = dev->data->dev_private;
        if (!internal)
                return 0;
@@ -1655,11 +1658,7 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev)
        if (eth_dev == NULL)
                return 0;
 
-       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
-               return rte_eth_dev_release_port(eth_dev);
-
        eth_dev_close(eth_dev);
-
        rte_eth_dev_release_port(eth_dev);
 
        return 0;
index b6ed5829bd1d1dfcfb3c0a7e80d7fe7447b25918..f2117675b3107eab2f00ac8d1552881e1df947d5 100644 (file)
@@ -711,6 +711,8 @@ virtio_dev_close(struct rte_eth_dev *dev)
        struct rte_intr_conf *intr_conf = &dev->data->dev_conf.intr_conf;
 
        PMD_INIT_LOG(DEBUG, "virtio_dev_close");
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        if (!hw->opened)
                return 0;
index 34a169d2c04e91bde7c56457e1859409fc744b33..fa950e1ba0f4e829f9e91d4623ceb8d18d78ec1e 100644 (file)
@@ -889,6 +889,8 @@ static int
 vmxnet3_dev_close(struct rte_eth_dev *dev)
 {
        PMD_INIT_FUNC_TRACE();
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
 
        vmxnet3_dev_stop(dev);
        vmxnet3_free_queues(dev);