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 3DC8CA0352; Thu, 16 Jan 2020 13:49:09 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A8AF1D511; Thu, 16 Jan 2020 13:48:04 +0100 (CET) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id C0CA31D17E for ; Thu, 16 Jan 2020 13:47:49 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 4AB6A28F56B; Thu, 16 Jan 2020 04:47:49 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 4AB6A28F56B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1579178869; bh=0EFeSHNPeJP9+XP+KNBUFs/ZZFklk45/IQ/rJdWAYpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+XsbrHR/vhmnZ450Q2rpxgZRP3OwC23eFbd1RglsH0NXYTjSGP9z+jZndE1elxKA qGRbji+f2qn0I6SM3nMC7S2W9EE2XsW5drUSMbe9ZbwXg3Xa1rRR1CDELTr4kpYQqt /QrL+AjwPihWH2TzTMzwRy2HPgs6eeW0v+dUZpxk= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Date: Thu, 16 Jan 2020 18:34:54 +0530 Message-Id: <20200116130455.30193-10-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20200116130455.30193-1-kalesh-anakkur.purayil@broadcom.com> References: <20200116130455.30193-1-kalesh-anakkur.purayil@broadcom.com> Subject: [dpdk-dev] [PATCH V4 09/10] net/bnxt: 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: Somnath Kotur 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: Somnath Kotur Reviewed-by: Kalesh Anakkur Purayil Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 53 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ba3f0a7..2ef1169 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -986,16 +986,22 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) if (bp->dev_stopped == 0) bnxt_dev_stop_op(eth_dev); - if (eth_dev->data->mac_addrs != NULL) { - rte_free(eth_dev->data->mac_addrs); - eth_dev->data->mac_addrs = NULL; - } - if (bp->grp_info != NULL) { - rte_free(bp->grp_info); - bp->grp_info = NULL; - } + bnxt_uninit_resources(bp, false); - bnxt_dev_uninit(eth_dev); + eth_dev->dev_ops = NULL; + eth_dev->rx_pkt_burst = NULL; + eth_dev->tx_pkt_burst = NULL; + + rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone); + bp->tx_mem_zone = NULL; + rte_memzone_free((const struct rte_memzone *)bp->rx_mem_zone); + bp->rx_mem_zone = NULL; + + rte_free(bp->pf.vf_info); + bp->pf.vf_info = NULL; + + rte_free(bp->grp_info); + bp->grp_info = NULL; } static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev, @@ -4856,6 +4862,11 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) if (rc) goto error_free; + /* 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; + PMD_DRV_LOG(INFO, DRV_MODULE_NAME "found at mem %" PRIX64 ", node addr %pM\n", pci_dev->mem_resource[0].phys_addr, @@ -4904,35 +4915,15 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev) static int bnxt_dev_uninit(struct rte_eth_dev *eth_dev) { - struct bnxt *bp = eth_dev->data->dev_private; - int rc; - if (rte_eal_process_type() != RTE_PROC_PRIMARY) return -EPERM; PMD_DRV_LOG(DEBUG, "Calling Device uninit\n"); - rc = bnxt_uninit_resources(bp, false); - - if (bp->tx_mem_zone) { - rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone); - bp->tx_mem_zone = NULL; - } - - if (bp->rx_mem_zone) { - rte_memzone_free((const struct rte_memzone *)bp->rx_mem_zone); - bp->rx_mem_zone = NULL; - } - - if (bp->dev_stopped == 0) + if (eth_dev->state != RTE_ETH_DEV_UNUSED) bnxt_dev_close_op(eth_dev); - if (bp->pf.vf_info) - rte_free(bp->pf.vf_info); - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - return rc; + return 0; } static int bnxt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, -- 2.10.1