From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 55890A2E1B for ; Mon, 2 Sep 2019 17:53:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 32B7F1DFE7; Mon, 2 Sep 2019 17:53:49 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id F08E41C0D3 for ; Mon, 2 Sep 2019 17:53:46 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2019 08:53:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,459,1559545200"; d="scan'208";a="172960951" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.5]) by orsmga007.jf.intel.com with ESMTP; 02 Sep 2019 08:53:44 -0700 Date: Mon, 2 Sep 2019 23:51:53 +0800 From: Ye Xiaolong To: Di ChenxuX Cc: dev@dpdk.org, Wenzhuo Lu , Beilei Xing , Qi Zhang , Yang Qiming Message-ID: <20190902155153.GB4325@intel.com> References: <20190902102745.66695-1-chenxux.di@intel.com> <20190902102745.66695-5-chenxux.di@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190902102745.66695-5-chenxux.di@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 4/5] net/ice: release port upon close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, Chenxu On 09/02, Di ChenxuX wrote: >Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private resources > for the port can be freed by rte_eth_dev_close(). > >Signed-off-by: Di ChenxuX >--- > drivers/net/ice/ice_ethdev.c | 33 ++++++++++++++++++++++----------- > drivers/net/ice/ice_ethdev.h | 1 + > 2 files changed, 23 insertions(+), 11 deletions(-) > >diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c >index 44a14cb8a..d2e2085fa 100644 >--- a/drivers/net/ice/ice_ethdev.c >+++ b/drivers/net/ice/ice_ethdev.c >@@ -1488,6 +1488,11 @@ ice_dev_init(struct rte_eth_dev *dev) > goto err_init_mac; > } > >+ /* Pass the information to the rte_eth_dev_close() that it should also >+ * release the private port resources. >+ */ >+ dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; >+ > ret = ice_res_pool_init(&pf->msix_pool, 1, > hw->func_caps.common_cap.num_msix_vectors - 1); > if (ret) { >@@ -1536,6 +1541,9 @@ ice_dev_init(struct rte_eth_dev *dev) > > TAILQ_INIT(&pf->flow_list); > >+ pf->adapter_stopped = 0; >+ pf->adapter_closed = 0; >+ > return 0; > > err_pf_setup: >@@ -1653,6 +1661,9 @@ ice_dev_close(struct rte_eth_dev *dev) > { > struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); > struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); >+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); >+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; >+ struct rte_flow *p_flow; > > /* Since stop will make link down, then the link event will be > * triggered, disable the irq firstly to avoid the port_infoe etc >@@ -1672,17 +1683,6 @@ ice_dev_close(struct rte_eth_dev *dev) > rte_free(hw->port_info); > hw->port_info = NULL; > ice_shutdown_all_ctrlq(hw); >-} >- >-static int >-ice_dev_uninit(struct rte_eth_dev *dev) >-{ >- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); >- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; >- struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); >- struct rte_flow *p_flow; >- >- ice_dev_close(dev); > > dev->dev_ops = NULL; > dev->rx_pkt_burst = NULL; >@@ -1705,6 +1705,17 @@ ice_dev_uninit(struct rte_eth_dev *dev) > rte_free(p_flow); > } > >+ pf->adapter_closed = 1; >+} >+ >+static int >+ice_dev_uninit(struct rte_eth_dev *dev) >+{ >+ struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); >+ >+ if (pf->adapter_closed == 0) >+ ice_dev_close(dev); >+ > return 0; > } > >diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h >index f569da833..2d4a2b4bb 100644 >--- a/drivers/net/ice/ice_ethdev.h >+++ b/drivers/net/ice/ice_ethdev.h >@@ -270,6 +270,7 @@ struct ice_pf { > struct ice_eth_stats internal_stats; > bool offset_loaded; > bool adapter_stopped; >+ bool adapter_closed; I think the adapter_closed is useless here, unlike the adapter_stopped which can be set to false when the port restart, after closing a port with dev_close, it cannot be reopened. Thanks, Xiaolong > struct ice_flow_list flow_list; > }; > >-- >2.17.1 >