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 3E037A04C0; Tue, 29 Sep 2020 01:16:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3EC591D8D5; Tue, 29 Sep 2020 01:15:06 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 7A2BD1D8CA for ; Tue, 29 Sep 2020 01:14:59 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 2059F5C012C; Mon, 28 Sep 2020 19:14:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:14:59 -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=voYUH0jPYjMto U1nk3G77U26oWjEXPaTiNRRGmS4BgI=; b=CnUnCy84xJ1QK12vGkhf7NNrT8UHH TARa76QrobrdCCSWCM2HVmhGC/6XhZDNZ70E3FjwLgeHUlKoZBAK9NL7TvqIUBZW obS18wvEx8qWCry5L+VIiX1dQAi8z8z/M16fTmuSfibrJ966ApAKRkZeEuQczDzu 9qfdb4arrrWLSGTyTOseTtk7Kcd2LCeKooft0bNJcM/XLauVOczJtUHolT0Y3d5U HlRQzvqOIYVd85OffgAamtN6ADCYBLEqDQ7JWdcWD6XMVMi8Ef7rcnQ1iY10g4YD F0oVpDPC3kxvvhzmu1o87z+eYwC3HNrwhR+9GbMH3ihBKsku1dc0xs8Ig== 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=voYUH0jPYjMtoU1nk3G77U26oWjEXPaTiNRRGmS4BgI=; b=GrpMiVyO HU/tsMh4Ez3PQ4Vow7vItJuktyTFDxZ2kWgt0of1n913lHXFx2YCNsEBkUp0fOHX xlItOUkAO/NLIZtEC33SKU/b0QGBxdvierZF8JERM72htBfCVC3zeWdMr1ssi9Uj vNccKy5jcRCszE4yHzweOYrkQvEWiHFeBkW2Tea5dnxkhl/KfzutR5i5cAj4ZfHp iyl3lBgoANdbx6gHfaaJk0rtppgz1aRcNAoTIfko04uml1JS5YTDYkhRU6YcFrpp J5FmSef5G2ZHY6pmNXPj37fgObEL3PhpMbeddaH3MfKjHk0tVUwy/WVu0qOVs2F1 sd8Sh1w1xyRx+A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepheenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth 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 006E2306467E; Mon, 28 Sep 2020 19:14:57 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Igor Russkikh , Igor Russkikh , Pavel Belous , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:12 +0200 Message-Id: <20200928231437.414489-5-thomas@monjalon.net> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928231437.414489-1-thomas@monjalon.net> References: <20200913220711.3768597-1-thomas@monjalon.net> <20200928231437.414489-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 04/29] net/atlantic: 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" 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: Thomas Monjalon Acked-by: Igor Russkikh --- drivers/net/atlantic/atl_ethdev.c | 62 ++++++++++++------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 254758fd66..d3babeff94 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -15,8 +15,6 @@ #include "hw_atl/hw_atl_b0_internal.h" static int eth_atl_dev_init(struct rte_eth_dev *eth_dev); -static int eth_atl_dev_uninit(struct rte_eth_dev *eth_dev); - static int atl_dev_configure(struct rte_eth_dev *dev); static int atl_dev_start(struct rte_eth_dev *dev); static void atl_dev_stop(struct rte_eth_dev *dev); @@ -382,6 +380,8 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + /* Vendor and Device ID need to be set before init of shared code */ hw->device_id = pci_dev->id.device_id; hw->vendor_id = pci_dev->id.vendor_id; @@ -442,40 +442,6 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) return err; } -static int -eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) -{ - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - struct aq_hw_s *hw; - - PMD_INIT_FUNC_TRACE(); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return -EPERM; - - hw = ATL_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - - if (hw->adapter_stopped == 0) - atl_dev_close(eth_dev); - - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - - /* disable uio intr before callback unregister */ - rte_intr_disable(intr_handle); - rte_intr_callback_unregister(intr_handle, - atl_dev_interrupt_handler, eth_dev); - - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - - pthread_mutex_destroy(&hw->mbox_mutex); - - return 0; -} - static int eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) @@ -487,7 +453,7 @@ eth_atl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, static int eth_atl_pci_remove(struct rte_pci_device *pci_dev) { - return rte_eth_dev_pci_generic_remove(pci_dev, eth_atl_dev_uninit); + return rte_eth_dev_pci_generic_remove(pci_dev, atl_dev_close); } static int @@ -722,12 +688,32 @@ atl_dev_set_link_down(struct rte_eth_dev *dev) static int atl_dev_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; + struct aq_hw_s *hw; + PMD_INIT_FUNC_TRACE(); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); + atl_dev_stop(dev); atl_free_queues(dev); + dev->dev_ops = NULL; + dev->rx_pkt_burst = NULL; + dev->tx_pkt_burst = NULL; + + /* disable uio intr before callback unregister */ + rte_intr_disable(intr_handle); + rte_intr_callback_unregister(intr_handle, + atl_dev_interrupt_handler, dev); + + pthread_mutex_destroy(&hw->mbox_mutex); + return 0; } @@ -736,7 +722,7 @@ atl_dev_reset(struct rte_eth_dev *dev) { int ret; - ret = eth_atl_dev_uninit(dev); + ret = atl_dev_close(dev); if (ret) return ret; -- 2.28.0