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 55D2CA04C9; Mon, 14 Sep 2020 00:08:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3BD821C112; Mon, 14 Sep 2020 00:08:04 +0200 (CEST) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by dpdk.org (Postfix) with ESMTP id 30A3E1C0CA for ; Mon, 14 Sep 2020 00:08:03 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 0043C5D2; Sun, 13 Sep 2020 18:08:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 13 Sep 2020 18:08:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=uRdi7fueOWjb0 yfAQEbrfBfqbqiO2EGRuWWeo2qMplk=; b=suRDlVt0YautxXmuEp6okqbPTKO80 t/IbXYdmDLr7iPQa1Fx/ppH466Vo3heEl8JC61vGAFsgRZTtC5cWIXb/5m4K7BK1 5VQ1ObsxYK1ypGGsFERAgXDAeNEhyJdTY9+I/yE1mUle8me5giWjmffe9VcQCpTk A49AAVXeZQm3baojk/KG7GzUBkQnBMebSmopZ0l2YsQsZ3T6TOPrDWpt9PE1p16i aCJUaC1EL1Jgf0LMr1UbH1f/KJdbmClRhepFzPiS4g34I62dW8kLA5jgnsMot04i hA+Xy0Ug8UBbZK01HMBvllQqXEcw13TSLLg3F9W+G45BOiQ1vhltoRnPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=uRdi7fueOWjb0yfAQEbrfBfqbqiO2EGRuWWeo2qMplk=; b=h78xQ38D wSLV7aNOFu7xzuK7NZ9wMDIOdCvVMeOaViGmJVcrPqMgebM2Qrqg0a4AceIR0rII F76bEndfRmmvX4y9eU2oJu7SrIHFdVd91HVjOFAvSPOUvOH+3HC5IlUgPwqb+nwI 6So3j+Eak1Ge0lI3Jr4niZaaJj1hqgoJ3cIfwmn9THZPeuXXza47NlVXWq8uHbpO fD4ortmVB4dXgmcbREm0kX31BB30LhjETsym3ckxm5i5jqgUYJlSeZRlJmdmtvyD UlVAe33oLw9RssqBsRlrEyj7X9J/qbK1xarG1y7Bm9dvT14UEd9oZ0ffqRlJnSva sO8mSp+EV+2VJA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeihedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdehgfeivdejgedtveehfefhteelfefgieevgfffveefjeegtdfg uedthedtgeevnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpeeknecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 95F653064674; Sun, 13 Sep 2020 18:08:00 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Steve Yang , Jingjing Wu , Beilei Xing , Anatoly Burakov Date: Mon, 14 Sep 2020 00:06:59 +0200 Message-Id: <20200913220711.3768597-9-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200913220711.3768597-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 08/20] net/iavf: 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" From: Steve Yang The flag RTE_ETH_DEV_CLOSE_REMOVE is set so all port resources can be freed by rte_eth_dev_close(). Freeing of private port resources is moved from the ".remove(device)" to the ".dev_close(port)" operation. Signed-off-by: Steve Yang --- [Thomas] Note: freeing in secondary process is inconsistent between .dev_close and .remove operations. --- drivers/net/iavf/iavf_ethdev.c | 46 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 4860a94d4c..f7552f33db 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -1362,6 +1362,11 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) adapter->eth_dev = eth_dev; adapter->stopped = 1; + /* Pass the information to the rte_eth_dev_close() that it should also + * release the private port resources. + */ + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + if (iavf_init_vf(eth_dev) != 0) { PMD_INIT_LOG(ERR, "Init vf failed"); return -1; @@ -1416,6 +1421,7 @@ iavf_dev_close(struct rte_eth_dev *dev) struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; struct iavf_adapter *adapter = IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); iavf_dev_stop(dev); iavf_flow_flush(dev, NULL); @@ -1428,21 +1434,21 @@ iavf_dev_close(struct rte_eth_dev *dev) rte_intr_callback_unregister(intr_handle, iavf_dev_interrupt_handler, dev); iavf_disable_irq0(hw); - return 0; -} - -static int -iavf_dev_uninit(struct rte_eth_dev *dev) -{ - struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return -EPERM; dev->dev_ops = NULL; dev->rx_pkt_burst = NULL; dev->tx_pkt_burst = NULL; - iavf_dev_close(dev); + + if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) { + if (vf->rss_lut) { + rte_free(vf->rss_lut); + vf->rss_lut = NULL; + } + if (vf->rss_key) { + rte_free(vf->rss_key); + vf->rss_key = NULL; + } + } rte_free(vf->vf_res); vf->vsi_res = NULL; @@ -1451,14 +1457,16 @@ iavf_dev_uninit(struct rte_eth_dev *dev) rte_free(vf->aq_resp); vf->aq_resp = NULL; - if (vf->rss_lut) { - rte_free(vf->rss_lut); - vf->rss_lut = NULL; - } - if (vf->rss_key) { - rte_free(vf->rss_key); - vf->rss_key = NULL; - } + return 0; +} + +static int +iavf_dev_uninit(struct rte_eth_dev *dev) +{ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -EPERM; + + iavf_dev_close(dev); return 0; } -- 2.28.0