[v2,19/25] drivers/net: check process type in close operation
diff mbox series

Message ID 20200927234249.3198780-20-thomas@monjalon.net
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • cleanup ethdev close operation
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Thomas Monjalon Sept. 27, 2020, 11:42 p.m. UTC
The secondary processes are not allowed to release shared resources.
Only process-private ressources should be freed in a secondary process.
Most of the time, there is no process-private ressource,
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>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c     |  3 +++
 drivers/net/ark/ark_ethdev.c            |  3 +++
 drivers/net/avp/avp_ethdev.c            |  3 +++
 drivers/net/bnxt/bnxt_ethdev.c          |  3 +++
 drivers/net/bnxt/bnxt_reps.c            |  3 +++
 drivers/net/cxgbe/cxgbe_ethdev.c        |  3 +++
 drivers/net/dpaa/dpaa_ethdev.c          |  3 +++
 drivers/net/dpaa2/dpaa2_ethdev.c        |  3 +++
 drivers/net/e1000/em_ethdev.c           |  3 +++
 drivers/net/e1000/igb_ethdev.c          |  6 +++++
 drivers/net/ena/ena_ethdev.c            |  3 +++
 drivers/net/enetc/enetc_ethdev.c        |  3 +++
 drivers/net/enic/enic_ethdev.c          |  3 +++
 drivers/net/fm10k/fm10k_ethdev.c        |  9 ++-----
 drivers/net/hinic/hinic_pmd_ethdev.c    |  3 +++
 drivers/net/i40e/i40e_ethdev.c          |  2 ++
 drivers/net/i40e/i40e_ethdev_vf.c       |  3 +++
 drivers/net/iavf/iavf_ethdev.c          |  3 +++
 drivers/net/ice/ice_ethdev.c            |  3 +++
 drivers/net/igc/igc_ethdev.c            |  6 ++---
 drivers/net/ionic/ionic_ethdev.c        |  2 ++
 drivers/net/ipn3ke/ipn3ke_representor.c |  3 +++
 drivers/net/ixgbe/ixgbe_ethdev.c        |  4 ++++
 drivers/net/kni/rte_eth_kni.c           |  3 +++
 drivers/net/liquidio/lio_ethdev.c       |  3 +++
 drivers/net/mlx4/mlx4.c                 |  2 ++
 drivers/net/mvneta/mvneta_ethdev.c      |  3 +++
 drivers/net/mvpp2/mrvl_ethdev.c         |  3 +++
 drivers/net/netvsc/hn_ethdev.c          |  2 ++
 drivers/net/nfb/nfb_ethdev.c            |  3 +++
 drivers/net/nfp/nfp_net.c               |  3 +++
 drivers/net/octeontx/octeontx_ethdev.c  |  2 ++
 drivers/net/pfe/pfe_ethdev.c            |  3 +++
 drivers/net/sfc/sfc_ethdev.c            | 32 ++++++++++++-------------
 drivers/net/szedata2/rte_eth_szedata2.c |  3 +++
 drivers/net/thunderx/nicvf_ethdev.c     |  7 +++---
 drivers/net/vhost/rte_eth_vhost.c       |  7 +++---
 drivers/net/virtio/virtio_ethdev.c      |  2 ++
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  2 ++
 39 files changed, 125 insertions(+), 35 deletions(-)

Comments

Thomas Monjalon Sept. 27, 2020, 11:52 p.m. UTC | #1
> The secondary processes are not allowed to release shared resources.
> Only process-private ressources should be freed in a secondary process.
> Most of the time, there is no process-private ressource,
> so the close operation is just forbidden in a secondary process.

Missed a (double) typo in this commit log:
	"ressource" -> "resource"
Xu, Rosen Sept. 28, 2020, 12:50 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Monday, September 28, 2020 7:43
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; arybchenko@solarflare.com;
> Loftus, Ciara <ciara.loftus@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> Shepard Siegel <shepard.siegel@atomicrules.com>; Ed Czeck
> <ed.czeck@atomicrules.com>; John Miller <john.miller@atomicrules.com>;
> Steven Webster <steven.webster@windriver.com>; Matt Peters
> <matt.peters@windriver.com>; Ajit Khaparde
> <ajit.khaparde@broadcom.com>; Somnath Kotur
> <somnath.kotur@broadcom.com>; Rahul Lakkireddy
> <rahul.lakkireddy@chelsio.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Sachin Saxena <sachin.saxena@oss.nxp.com>;
> Guo, Jia <jia.guo@intel.com>; Wang, Haiyue <haiyue.wang@intel.com>;
> Marcin Wojtas <mw@semihalf.com>; Michal Krawczyk <mk@semihalf.com>;
> Guy Tzalik <gtzalik@amazon.com>; Evgeny Schemeilin
> <evgenys@amazon.com>; Igor Chauskin <igorch@amazon.com>;
> Gagandeep Singh <g.singh@nxp.com>; John Daley <johndale@cisco.com>;
> Hyong Youb Kim <hyonkim@cisco.com>; Wang, Xiao W
> <xiao.w.wang@intel.com>; Ziyang Xuan <xuanziyang2@huawei.com>;
> Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>; Guoyang Zhou
> <zhouguoyang@huawei.com>; Xing, Beilei <beilei.xing@intel.com>; Wu,
> Jingjing <jingjing.wu@intel.com>; Yang, Qiming <qiming.yang@intel.com>;
> Alfredo Cardigliano <cardigliano@ntop.org>; Xu, Rosen
> <rosen.xu@intel.com>; Shijith Thotton <sthotton@marvell.com>;
> Srisivasubramanian Srinivasan <srinivasan@marvell.com>; Matan Azrad
> <matan@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>; Zyta Szpak
> <zr@semihalf.com>; Liron Himi <lironh@marvell.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; K. Y. Srinivasan <kys@microsoft.com>;
> Haiyang Zhang <haiyangz@microsoft.com>; Long Li <longli@microsoft.com>;
> Martin Spinler <spinler@cesnet.cz>; Heinrich Kuhn
> <heinrich.kuhn@netronome.com>; Harman Kalra <hkalra@marvell.com>;
> Akhil Goyal <akhil.goyal@nxp.com>; Jerin Jacob <jerinj@marvell.com>;
> Maciej Czekaj <mczekaj@marvell.com>; Maxime Coquelin
> <maxime.coquelin@redhat.com>; Xia, Chenbo <chenbo.xia@intel.com>;
> Wang, Zhihong <zhihong.wang@intel.com>; Yong Wang
> <yongwang@vmware.com>; Burakov, Anatoly <anatoly.burakov@intel.com>
> Subject: [PATCH v2 19/25] drivers/net: check process type in close operation
> 
> The secondary processes are not allowed to release shared resources.
> Only process-private ressources should be freed in a secondary process.
> Most of the time, there is no process-private ressource, 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>
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c     |  3 +++
>  drivers/net/ark/ark_ethdev.c            |  3 +++
>  drivers/net/avp/avp_ethdev.c            |  3 +++
>  drivers/net/bnxt/bnxt_ethdev.c          |  3 +++
>  drivers/net/bnxt/bnxt_reps.c            |  3 +++
>  drivers/net/cxgbe/cxgbe_ethdev.c        |  3 +++
>  drivers/net/dpaa/dpaa_ethdev.c          |  3 +++
>  drivers/net/dpaa2/dpaa2_ethdev.c        |  3 +++
>  drivers/net/e1000/em_ethdev.c           |  3 +++
>  drivers/net/e1000/igb_ethdev.c          |  6 +++++
>  drivers/net/ena/ena_ethdev.c            |  3 +++
>  drivers/net/enetc/enetc_ethdev.c        |  3 +++
>  drivers/net/enic/enic_ethdev.c          |  3 +++
>  drivers/net/fm10k/fm10k_ethdev.c        |  9 ++-----
>  drivers/net/hinic/hinic_pmd_ethdev.c    |  3 +++
>  drivers/net/i40e/i40e_ethdev.c          |  2 ++
>  drivers/net/i40e/i40e_ethdev_vf.c       |  3 +++
>  drivers/net/iavf/iavf_ethdev.c          |  3 +++
>  drivers/net/ice/ice_ethdev.c            |  3 +++
>  drivers/net/igc/igc_ethdev.c            |  6 ++---
>  drivers/net/ionic/ionic_ethdev.c        |  2 ++
>  drivers/net/ipn3ke/ipn3ke_representor.c |  3 +++
>  drivers/net/ixgbe/ixgbe_ethdev.c        |  4 ++++
>  drivers/net/kni/rte_eth_kni.c           |  3 +++
>  drivers/net/liquidio/lio_ethdev.c       |  3 +++
>  drivers/net/mlx4/mlx4.c                 |  2 ++
>  drivers/net/mvneta/mvneta_ethdev.c      |  3 +++
>  drivers/net/mvpp2/mrvl_ethdev.c         |  3 +++
>  drivers/net/netvsc/hn_ethdev.c          |  2 ++
>  drivers/net/nfb/nfb_ethdev.c            |  3 +++
>  drivers/net/nfp/nfp_net.c               |  3 +++
>  drivers/net/octeontx/octeontx_ethdev.c  |  2 ++
>  drivers/net/pfe/pfe_ethdev.c            |  3 +++
>  drivers/net/sfc/sfc_ethdev.c            | 32 ++++++++++++-------------
>  drivers/net/szedata2/rte_eth_szedata2.c |  3 +++
>  drivers/net/thunderx/nicvf_ethdev.c     |  7 +++---
>  drivers/net/vhost/rte_eth_vhost.c       |  7 +++---
>  drivers/net/virtio/virtio_ethdev.c      |  2 ++
>  drivers/net/vmxnet3/vmxnet3_ethdev.c    |  2 ++
>  39 files changed, 125 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c
> b/drivers/net/ipn3ke/ipn3ke_representor.c
> index d49abbf758..b9fb4d4e46 100644
> --- a/drivers/net/ipn3ke/ipn3ke_representor.c
> +++ b/drivers/net/ipn3ke/ipn3ke_representor.c
> @@ -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); diff --git
> 2.28.0

For net/ipn3ke
Reviewed-by: Rosen Xu <rosen.xu@intel.com>
Sachin Saxena (OSS) Sept. 28, 2020, 9:55 a.m. UTC | #3
For dpaa, dpaa2, enetc and pfe

Reviewed-by: Sachin Saxena<sachin.saxena@oss.nxp.com>

On 28-Sep-20 5:12 AM, Thomas Monjalon wrote:
> The secondary processes are not allowed to release shared resources.
> Only process-private ressources should be freed in a secondary process.
> Most of the time, there is no process-private ressource,
> 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>
> ---
>   drivers/net/af_xdp/rte_eth_af_xdp.c     |  3 +++
>   drivers/net/ark/ark_ethdev.c            |  3 +++
>   drivers/net/avp/avp_ethdev.c            |  3 +++
>   drivers/net/bnxt/bnxt_ethdev.c          |  3 +++
>   drivers/net/bnxt/bnxt_reps.c            |  3 +++
>   drivers/net/cxgbe/cxgbe_ethdev.c        |  3 +++
>   drivers/net/dpaa/dpaa_ethdev.c          |  3 +++
>   drivers/net/dpaa2/dpaa2_ethdev.c        |  3 +++
>   drivers/net/e1000/em_ethdev.c           |  3 +++
>   drivers/net/e1000/igb_ethdev.c          |  6 +++++
>   drivers/net/ena/ena_ethdev.c            |  3 +++
>   drivers/net/enetc/enetc_ethdev.c        |  3 +++
>   drivers/net/enic/enic_ethdev.c          |  3 +++
>   drivers/net/fm10k/fm10k_ethdev.c        |  9 ++-----
>   drivers/net/hinic/hinic_pmd_ethdev.c    |  3 +++
>   drivers/net/i40e/i40e_ethdev.c          |  2 ++
>   drivers/net/i40e/i40e_ethdev_vf.c       |  3 +++
>   drivers/net/iavf/iavf_ethdev.c          |  3 +++
>   drivers/net/ice/ice_ethdev.c            |  3 +++
>   drivers/net/igc/igc_ethdev.c            |  6 ++---
>   drivers/net/ionic/ionic_ethdev.c        |  2 ++
>   drivers/net/ipn3ke/ipn3ke_representor.c |  3 +++
>   drivers/net/ixgbe/ixgbe_ethdev.c        |  4 ++++
>   drivers/net/kni/rte_eth_kni.c           |  3 +++
>   drivers/net/liquidio/lio_ethdev.c       |  3 +++
>   drivers/net/mlx4/mlx4.c                 |  2 ++
>   drivers/net/mvneta/mvneta_ethdev.c      |  3 +++
>   drivers/net/mvpp2/mrvl_ethdev.c         |  3 +++
>   drivers/net/netvsc/hn_ethdev.c          |  2 ++
>   drivers/net/nfb/nfb_ethdev.c            |  3 +++
>   drivers/net/nfp/nfp_net.c               |  3 +++
>   drivers/net/octeontx/octeontx_ethdev.c  |  2 ++
>   drivers/net/pfe/pfe_ethdev.c            |  3 +++
>   drivers/net/sfc/sfc_ethdev.c            | 32 ++++++++++++-------------
>   drivers/net/szedata2/rte_eth_szedata2.c |  3 +++
>   drivers/net/thunderx/nicvf_ethdev.c     |  7 +++---
>   drivers/net/vhost/rte_eth_vhost.c       |  7 +++---
>   drivers/net/virtio/virtio_ethdev.c      |  2 ++
>   drivers/net/vmxnet3/vmxnet3_ethdev.c    |  2 ++
>   39 files changed, 125 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 60add9ead4..b289076e01 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -708,6 +708,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());
>   
> diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
> index 83dc4ecd2c..3e96445fdb 100644
> --- a/drivers/net/ark/ark_ethdev.c
> +++ b/drivers/net/ark/ark_ethdev.c
> @@ -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]);
> diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
> index c730b7ab86..95fdb57451 100644
> --- a/drivers/net/avp/avp_ethdev.c
> +++ b/drivers/net/avp/avp_ethdev.c
> @@ -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");
> diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
> index a77bab661d..d45347e8ca 100644
> --- a/drivers/net/bnxt/bnxt_ethdev.c
> +++ b/drivers/net/bnxt/bnxt_ethdev.c
> @@ -1361,6 +1361,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);
> diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
> index df8680c113..c419fe63b8 100644
> --- a/drivers/net/bnxt/bnxt_reps.c
> +++ b/drivers/net/bnxt/bnxt_reps.c
> @@ -220,6 +220,9 @@ int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev)
>   		(struct bnxt_vf_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;
> diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
> index e4bbba5c32..16beb2d435 100644
> --- a/drivers/net/cxgbe/cxgbe_ethdev.c
> +++ b/drivers/net/cxgbe/cxgbe_ethdev.c
> @@ -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;
>   
> diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
> index 7fe06e1830..01632e591c 100644
> --- a/drivers/net/dpaa/dpaa_ethdev.c
> +++ b/drivers/net/dpaa/dpaa_ethdev.c
> @@ -379,6 +379,9 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
>   
>   	PMD_INIT_FUNC_TRACE();
>   
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +		return 0;
> +
>   	dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
>   	intr_handle = &dpaa_dev->intr_handle;
>   	__fif = container_of(fif, struct __fman_if, __if);
> diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
> index fb4165fa03..eb84d7231d 100644
> --- a/drivers/net/dpaa2/dpaa2_ethdev.c
> +++ b/drivers/net/dpaa2/dpaa2_ethdev.c
> @@ -1246,6 +1246,9 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
>   
>   	PMD_INIT_FUNC_TRACE();
>   
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> +		return 0;
> +
>   	dpaa2_flow_clean(dev);
>   
>   	/* Clean the device first */
> diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
> index 6a6ae0e9d5..d050eb478a 100644
> --- a/drivers/net/e1000/em_ethdev.c
> +++ b/drivers/net/e1000/em_ethdev.c
> @@ -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);
> diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
> index f8778207ef..cb3d97e2a3 100644
> --- a/drivers/net/e1000/igb_ethdev.c
> +++ b/drivers/net/e1000/igb_ethdev.c
> @@ -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);
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index cf1c0b9795..07ae9bab32 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -493,6 +493,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;
> diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
> index bdb32762ce..d42add3efb 100644
> --- a/drivers/net/enetc/enetc_ethdev.c
> +++ b/drivers/net/enetc/enetc_ethdev.c
> @@ -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++) {
> diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
> index 27f60b45b8..60ee5e01de 100644
> --- a/drivers/net/enic/enic_ethdev.c
> +++ b/drivers/net/enic/enic_ethdev.c
> @@ -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;
> diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
> index 23f4d04068..17cf0328c6 100644
> --- a/drivers/net/fm10k/fm10k_ethdev.c
> +++ b/drivers/net/fm10k/fm10k_ethdev.c
> @@ -2784,6 +2784,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,
> @@ -3236,14 +3238,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;
>   }
>   
> diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
> index 623534fda4..1b175aeace 100644
> --- a/drivers/net/hinic/hinic_pmd_ethdev.c
> +++ b/drivers/net/hinic/hinic_pmd_ethdev.c
> @@ -2940,6 +2940,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",
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 6fb88148b8..feeed2dec0 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -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)
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
> index 4aaf41956c..4d6510d1ff 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -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);
>   	/*
> diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
> index 512ade2ad0..a5b1433306 100644
> --- a/drivers/net/iavf/iavf_ethdev.c
> +++ b/drivers/net/iavf/iavf_ethdev.c
> @@ -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);
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> index 85a3ca6a2d..96159c92f2 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -2435,6 +2435,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
> diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
> index 9d27fc0d07..7f5066df4b 100644
> --- a/drivers/net/igc/igc_ethdev.c
> +++ b/drivers/net/igc/igc_ethdev.c
> @@ -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;
>   }
> diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
> index 1775fd29b7..ef7d06e526 100644
> --- a/drivers/net/ionic/ionic_ethdev.c
> +++ b/drivers/net/ionic/ionic_ethdev.c
> @@ -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) {
> diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c
> index d49abbf758..b9fb4d4e46 100644
> --- a/drivers/net/ipn3ke/ipn3ke_representor.c
> +++ b/drivers/net/ipn3ke/ipn3ke_representor.c
> @@ -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);
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 426b7c9fe5..f6e383b1c2 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -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);
>   
> @@ -5442,6 +5444,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);
>   
> diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
> index 2a4058f7b0..be747adf86 100644
> --- a/drivers/net/kni/rte_eth_kni.c
> +++ b/drivers/net/kni/rte_eth_kni.c
> @@ -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 */
> diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
> index 93e2ed5670..1a41f27198 100644
> --- a/drivers/net/liquidio/lio_ethdev.c
> +++ b/drivers/net/liquidio/lio_ethdev.c
> @@ -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)
> diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
> index 3e57875414..cfcfb8a8fc 100644
> --- a/drivers/net/mlx4/mlx4.c
> +++ b/drivers/net/mlx4/mlx4.c
> @@ -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 : ""));
> diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
> index db142bec23..607771149a 100644
> --- a/drivers/net/mvneta/mvneta_ethdev.c
> +++ b/drivers/net/mvneta/mvneta_ethdev.c
> @@ -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);
>   
> diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
> index cfb97e4f8f..a230a96840 100644
> --- a/drivers/net/mvpp2/mrvl_ethdev.c
> +++ b/drivers/net/mvpp2/mrvl_ethdev.c
> @@ -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);
> diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
> index 19a9eb6bc2..5ae2d469c8 100644
> --- a/drivers/net/netvsc/hn_ethdev.c
> +++ b/drivers/net/netvsc/hn_ethdev.c
> @@ -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);
> diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
> index d937ac6922..7ee7294143 100644
> --- a/drivers/net/nfb/nfb_ethdev.c
> +++ b/drivers/net/nfb/nfb_ethdev.c
> @@ -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);
> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> index ce25cf1ed4..c1da66e3d6 100644
> --- a/drivers/net/nfp/nfp_net.c
> +++ b/drivers/net/nfp/nfp_net.c
> @@ -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);
> diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
> index a263f45399..aa9ef3bb70 100644
> --- a/drivers/net/octeontx/octeontx_ethdev.c
> +++ b/drivers/net/octeontx/octeontx_ethdev.c
> @@ -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);
>   
> diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
> index 9d5415d9b1..a7e9d97ba9 100644
> --- a/drivers/net/pfe/pfe_ethdev.c
> +++ b/drivers/net/pfe/pfe_ethdev.c
> @@ -407,6 +407,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_exit(dev, g_pfe);
>   
>   	if (g_pfe->nb_devs == 0) {
> diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
> index 1c72e40b75..0558f1808d 100644
> --- a/drivers/net/sfc/sfc_ethdev.c
> +++ b/drivers/net/sfc/sfc_ethdev.c
> @@ -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 @@ sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main)
>   	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)
>   {
> @@ -2245,11 +2250,6 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)
>   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;
> diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
> index 5f589dfa4c..7e9fafdcf7 100644
> --- a/drivers/net/szedata2/rte_eth_szedata2.c
> +++ b/drivers/net/szedata2/rte_eth_szedata2.c
> @@ -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);
> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
> index 3d7348771a..cc6eb4ba24 100644
> --- a/drivers/net/thunderx/nicvf_ethdev.c
> +++ b/drivers/net/thunderx/nicvf_ethdev.c
> @@ -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
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index 45552ef742..32ad27fe4e 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -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;
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index b6ed5829bd..f2117675b3 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -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;
> diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
> index 34a169d2c0..fa950e1ba0 100644
> --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
> +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
> @@ -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);
Ajit Khaparde Sept. 28, 2020, 2:57 p.m. UTC | #4
On Mon, Sep 28, 2020 at 2:56 AM Sachin Saxena (OSS)
<sachin.saxena@oss.nxp.com> wrote:
>
> For dpaa, dpaa2, enetc and pfe
>
> Reviewed-by: Sachin Saxena <sachin.saxena@oss.nxp.com>
>
> On 28-Sep-20 5:12 AM, Thomas Monjalon wrote:
>
> The secondary processes are not allowed to release shared resources.
> Only process-private ressources should be freed in a secondary process.
> Most of the time, there is no process-private ressource,
> 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>
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c     |  3 +++
>  drivers/net/ark/ark_ethdev.c            |  3 +++
>  drivers/net/avp/avp_ethdev.c            |  3 +++
>  drivers/net/bnxt/bnxt_ethdev.c          |  3 +++
>  drivers/net/bnxt/bnxt_reps.c            |  3 +++
For bnxt,
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Liron Himi Sept. 28, 2020, 6:25 p.m. UTC | #5
For mvpp2, mvneta.

Reviewed-by: Liron Himi<lironh@marvell.com>

-----Original Message-----
From: Thomas Monjalon <thomas@monjalon.net> 
Sent: Monday, 28 September 2020 02:43
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com; arybchenko@solarflare.com; Ciara Loftus <ciara.loftus@intel.com>; Qi Zhang <qi.z.zhang@intel.com>; Shepard Siegel <shepard.siegel@atomicrules.com>; Ed Czeck <ed.czeck@atomicrules.com>; John Miller <john.miller@atomicrules.com>; Steven Webster <steven.webster@windriver.com>; Matt Peters <matt.peters@windriver.com>; Ajit Khaparde <ajit.khaparde@broadcom.com>; Somnath Kotur <somnath.kotur@broadcom.com>; Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>; Hemant Agrawal <hemant.agrawal@nxp.com>; Sachin Saxena <sachin.saxena@oss.nxp.com>; Jeff Guo <jia.guo@intel.com>; Haiyue Wang <haiyue.wang@intel.com>; Marcin Wojtas <mw@semihalf.com>; Michal Krawczyk <mk@semihalf.com>; Guy Tzalik <gtzalik@amazon.com>; Evgeny Schemeilin <evgenys@amazon.com>; Igor Chauskin <igorch@amazon.com>; Gagandeep Singh <g.singh@nxp.com>; John Daley <johndale@cisco.com>; Hyong Youb Kim <hyonkim@cisco.com>; Xiao Wang <xiao.w.wang@intel.com>; Ziyang Xuan <xuanziyang2@huawei.com>; Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>; Guoyang Zhou <zhouguoyang@huawei.com>; Beilei Xing <beilei.xing@intel.com>; Jingjing Wu <jingjing.wu@intel.com>; Qiming Yang <qiming.yang@intel.com>; Alfredo Cardigliano <cardigliano@ntop.org>; Rosen Xu <rosen.xu@intel.com>; Shijith Thotton <sthotton@marvell.com>; Srisivasubramanian Srinivasan <srinivasan@marvell.com>; Matan Azrad <matan@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>; Zyta Szpak <zr@semihalf.com>; Liron Himi <lironh@marvell.com>; Stephen Hemminger <sthemmin@microsoft.com>; K. Y. Srinivasan <kys@microsoft.com>; Haiyang Zhang <haiyangz@microsoft.com>; Long Li <longli@microsoft.com>; Martin Spinler <spinler@cesnet.cz>; Heinrich Kuhn <heinrich.kuhn@netronome.com>; Harman Kalra <hkalra@marvell.com>; Akhil Goyal <akhil.goyal@nxp.com>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Maciej Czekaj [C] <mczekaj@marvell.com>; Maxime Coquelin <maxime.coquelin@redhat.com>; Chenbo Xia <chenbo.xia@intel.com>; Zhihong Wang <zhihong.wang@intel.com>; Yong Wang <yongwang@vmware.com>; Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [EXT] [PATCH v2 19/25] drivers/net: check process type in close operation

External Email

----------------------------------------------------------------------
The secondary processes are not allowed to release shared resources.
Only process-private ressources should be freed in a secondary process.
Most of the time, there is no process-private ressource, 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>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c     |  3 +++
 drivers/net/ark/ark_ethdev.c            |  3 +++
 drivers/net/avp/avp_ethdev.c            |  3 +++
 drivers/net/bnxt/bnxt_ethdev.c          |  3 +++
 drivers/net/bnxt/bnxt_reps.c            |  3 +++
 drivers/net/cxgbe/cxgbe_ethdev.c        |  3 +++
 drivers/net/dpaa/dpaa_ethdev.c          |  3 +++
 drivers/net/dpaa2/dpaa2_ethdev.c        |  3 +++
 drivers/net/e1000/em_ethdev.c           |  3 +++
 drivers/net/e1000/igb_ethdev.c          |  6 +++++
 drivers/net/ena/ena_ethdev.c            |  3 +++
 drivers/net/enetc/enetc_ethdev.c        |  3 +++
 drivers/net/enic/enic_ethdev.c          |  3 +++
 drivers/net/fm10k/fm10k_ethdev.c        |  9 ++-----
 drivers/net/hinic/hinic_pmd_ethdev.c    |  3 +++
 drivers/net/i40e/i40e_ethdev.c          |  2 ++
 drivers/net/i40e/i40e_ethdev_vf.c       |  3 +++
 drivers/net/iavf/iavf_ethdev.c          |  3 +++
 drivers/net/ice/ice_ethdev.c            |  3 +++
 drivers/net/igc/igc_ethdev.c            |  6 ++---
 drivers/net/ionic/ionic_ethdev.c        |  2 ++
 drivers/net/ipn3ke/ipn3ke_representor.c |  3 +++
 drivers/net/ixgbe/ixgbe_ethdev.c        |  4 ++++
 drivers/net/kni/rte_eth_kni.c           |  3 +++
 drivers/net/liquidio/lio_ethdev.c       |  3 +++
 drivers/net/mlx4/mlx4.c                 |  2 ++
 drivers/net/mvneta/mvneta_ethdev.c      |  3 +++
 drivers/net/mvpp2/mrvl_ethdev.c         |  3 +++
 drivers/net/netvsc/hn_ethdev.c          |  2 ++
 drivers/net/nfb/nfb_ethdev.c            |  3 +++
 drivers/net/nfp/nfp_net.c               |  3 +++
 drivers/net/octeontx/octeontx_ethdev.c  |  2 ++
 drivers/net/pfe/pfe_ethdev.c            |  3 +++
 drivers/net/sfc/sfc_ethdev.c            | 32 ++++++++++++-------------
 drivers/net/szedata2/rte_eth_szedata2.c |  3 +++
 drivers/net/thunderx/nicvf_ethdev.c     |  7 +++---
 drivers/net/vhost/rte_eth_vhost.c       |  7 +++---
 drivers/net/virtio/virtio_ethdev.c      |  2 ++
 drivers/net/vmxnet3/vmxnet3_ethdev.c    |  2 ++
 39 files changed, 125 insertions(+), 35 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 60add9ead4..b289076e01 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -708,6 +708,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());
 
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c index 83dc4ecd2c..3e96445fdb 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -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]);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c index c730b7ab86..95fdb57451 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -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"); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index a77bab661d..d45347e8ca 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1361,6 +1361,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); diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index df8680c113..c419fe63b8 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -220,6 +220,9 @@ int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev)
 		(struct bnxt_vf_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;
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index e4bbba5c32..16beb2d435 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -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;
 
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 7fe06e1830..01632e591c 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -379,6 +379,9 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
 	intr_handle = &dpaa_dev->intr_handle;
 	__fif = container_of(fif, struct __fman_if, __if); diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index fb4165fa03..eb84d7231d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1246,6 +1246,9 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	dpaa2_flow_clean(dev);
 
 	/* Clean the device first */
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index 6a6ae0e9d5..d050eb478a 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -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);
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index f8778207ef..cb3d97e2a3 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -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);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index cf1c0b9795..07ae9bab32 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -493,6 +493,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; diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index bdb32762ce..d42add3efb 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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++) { diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 27f60b45b8..60ee5e01de 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -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;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 23f4d04068..17cf0328c6 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2784,6 +2784,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, @@ -3236,14 +3238,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;
 }
 
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 623534fda4..1b175aeace 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -2940,6 +2940,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", diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 6fb88148b8..feeed2dec0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -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)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 4aaf41956c..4d6510d1ff 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -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);
 	/*
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 512ade2ad0..a5b1433306 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -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);
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 85a3ca6a2d..96159c92f2 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2435,6 +2435,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 diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c index 9d27fc0d07..7f5066df4b 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -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;
 }
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 1775fd29b7..ef7d06e526 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -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) {
diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c
index d49abbf758..b9fb4d4e46 100644
--- a/drivers/net/ipn3ke/ipn3ke_representor.c
+++ b/drivers/net/ipn3ke/ipn3ke_representor.c
@@ -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); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 426b7c9fe5..f6e383b1c2 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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);
 
@@ -5442,6 +5444,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);
 
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 2a4058f7b0..be747adf86 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -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 */ diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index 93e2ed5670..1a41f27198 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -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)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 3e57875414..cfcfb8a8fc 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -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 : "")); diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index db142bec23..607771149a 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -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);
 
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index cfb97e4f8f..a230a96840 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -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);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 19a9eb6bc2..5ae2d469c8 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -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);
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c index d937ac6922..7ee7294143 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -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); diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index ce25cf1ed4..c1da66e3d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -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);
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index a263f45399..aa9ef3bb70 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -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);
 
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c index 9d5415d9b1..a7e9d97ba9 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -407,6 +407,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_exit(dev, g_pfe);
 
 	if (g_pfe->nb_devs == 0) {
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 1c72e40b75..0558f1808d 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -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 @@ sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main)
 	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)
 {
@@ -2245,11 +2250,6 @@ sfc_eth_dev_init(struct rte_eth_dev *dev)  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;
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 5f589dfa4c..7e9fafdcf7 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -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);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 3d7348771a..cc6eb4ba24 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -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
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 45552ef742..32ad27fe4e 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -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;
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b6ed5829bd..f2117675b3 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 34a169d2c0..fa950e1ba0 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -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);
--
2.28.0
Stephen Hemminger Sept. 28, 2020, 6:51 p.m. UTC | #6
On Mon, 28 Sep 2020 01:42:43 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:

> The secondary processes are not allowed to release shared resources.
> Only process-private ressources should be freed in a secondary process.
> Most of the time, there is no process-private ressource,
> 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>

Since this is a common issue across many drivers, my preference would be that the
check should be in common code of eth_dev_close.  It looks like only a few drivers
would allow close from secondary, and that would not be that helpful to a user.
Thomas Monjalon Sept. 28, 2020, 8:57 p.m. UTC | #7
28/09/2020 20:51, Stephen Hemminger:
> On Mon, 28 Sep 2020 01:42:43 +0200
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > The secondary processes are not allowed to release shared resources.
> > Only process-private ressources should be freed in a secondary process.
> > Most of the time, there is no process-private ressource,
> > 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>
> 
> Since this is a common issue across many drivers, my preference would be that the
> check should be in common code of eth_dev_close.  It looks like only a few drivers
> would allow close from secondary, and that would not be that helpful to a user.

It needs to be managed in the PMD to free secondary process resources.

Patch
diff mbox series

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 60add9ead4..b289076e01 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -708,6 +708,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());
 
diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 83dc4ecd2c..3e96445fdb 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -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]);
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index c730b7ab86..95fdb57451 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -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");
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a77bab661d..d45347e8ca 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -1361,6 +1361,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);
diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c
index df8680c113..c419fe63b8 100644
--- a/drivers/net/bnxt/bnxt_reps.c
+++ b/drivers/net/bnxt/bnxt_reps.c
@@ -220,6 +220,9 @@  int bnxt_vf_representor_uninit(struct rte_eth_dev *eth_dev)
 		(struct bnxt_vf_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;
diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index e4bbba5c32..16beb2d435 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -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;
 
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 7fe06e1830..01632e591c 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -379,6 +379,9 @@  static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
 	intr_handle = &dpaa_dev->intr_handle;
 	__fif = container_of(fif, struct __fman_if, __if);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index fb4165fa03..eb84d7231d 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1246,6 +1246,9 @@  dpaa2_dev_close(struct rte_eth_dev *dev)
 
 	PMD_INIT_FUNC_TRACE();
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
 	dpaa2_flow_clean(dev);
 
 	/* Clean the device first */
diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 6a6ae0e9d5..d050eb478a 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -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);
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f8778207ef..cb3d97e2a3 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -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);
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index cf1c0b9795..07ae9bab32 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -493,6 +493,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;
diff --git a/drivers/net/enetc/enetc_ethdev.c b/drivers/net/enetc/enetc_ethdev.c
index bdb32762ce..d42add3efb 100644
--- a/drivers/net/enetc/enetc_ethdev.c
+++ b/drivers/net/enetc/enetc_ethdev.c
@@ -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++) {
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 27f60b45b8..60ee5e01de 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -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;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 23f4d04068..17cf0328c6 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2784,6 +2784,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,
@@ -3236,14 +3238,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;
 }
 
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c b/drivers/net/hinic/hinic_pmd_ethdev.c
index 623534fda4..1b175aeace 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -2940,6 +2940,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",
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 6fb88148b8..feeed2dec0 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -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)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 4aaf41956c..4d6510d1ff 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -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);
 	/*
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 512ade2ad0..a5b1433306 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -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);
diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 85a3ca6a2d..96159c92f2 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -2435,6 +2435,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
diff --git a/drivers/net/igc/igc_ethdev.c b/drivers/net/igc/igc_ethdev.c
index 9d27fc0d07..7f5066df4b 100644
--- a/drivers/net/igc/igc_ethdev.c
+++ b/drivers/net/igc/igc_ethdev.c
@@ -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;
 }
diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c
index 1775fd29b7..ef7d06e526 100644
--- a/drivers/net/ionic/ionic_ethdev.c
+++ b/drivers/net/ionic/ionic_ethdev.c
@@ -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) {
diff --git a/drivers/net/ipn3ke/ipn3ke_representor.c b/drivers/net/ipn3ke/ipn3ke_representor.c
index d49abbf758..b9fb4d4e46 100644
--- a/drivers/net/ipn3ke/ipn3ke_representor.c
+++ b/drivers/net/ipn3ke/ipn3ke_representor.c
@@ -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);
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 426b7c9fe5..f6e383b1c2 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -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);
 
@@ -5442,6 +5444,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);
 
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index 2a4058f7b0..be747adf86 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -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 */
diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index 93e2ed5670..1a41f27198 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -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)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index 3e57875414..cfcfb8a8fc 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -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 : ""));
diff --git a/drivers/net/mvneta/mvneta_ethdev.c b/drivers/net/mvneta/mvneta_ethdev.c
index db142bec23..607771149a 100644
--- a/drivers/net/mvneta/mvneta_ethdev.c
+++ b/drivers/net/mvneta/mvneta_ethdev.c
@@ -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);
 
diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index cfb97e4f8f..a230a96840 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -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);
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 19a9eb6bc2..5ae2d469c8 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -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);
diff --git a/drivers/net/nfb/nfb_ethdev.c b/drivers/net/nfb/nfb_ethdev.c
index d937ac6922..7ee7294143 100644
--- a/drivers/net/nfb/nfb_ethdev.c
+++ b/drivers/net/nfb/nfb_ethdev.c
@@ -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);
diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index ce25cf1ed4..c1da66e3d6 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -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);
diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index a263f45399..aa9ef3bb70 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -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);
 
diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index 9d5415d9b1..a7e9d97ba9 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -407,6 +407,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_exit(dev, g_pfe);
 
 	if (g_pfe->nb_devs == 0) {
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 1c72e40b75..0558f1808d 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -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 @@  sfc_eth_dev_secondary_init(struct rte_eth_dev *dev, uint32_t logtype_main)
 	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)
 {
@@ -2245,11 +2250,6 @@  sfc_eth_dev_init(struct rte_eth_dev *dev)
 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;
diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c
index 5f589dfa4c..7e9fafdcf7 100644
--- a/drivers/net/szedata2/rte_eth_szedata2.c
+++ b/drivers/net/szedata2/rte_eth_szedata2.c
@@ -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);
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 3d7348771a..cc6eb4ba24 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -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
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 45552ef742..32ad27fe4e 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -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;
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b6ed5829bd..f2117675b3 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -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;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
index 34a169d2c0..fa950e1ba0 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
@@ -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);