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 4BE11A04C5; Tue, 11 Aug 2020 09:32:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DB0F11B203; Tue, 11 Aug 2020 09:32:14 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id CDE0AE07 for ; Tue, 11 Aug 2020 09:32:12 +0200 (CEST) IronPort-SDR: 1QITmRtcDDyUsRUT7qTl3HcIIvr1inraMccLhZP89zxNqg9JVmV0G78a70ra+qPjpZAGYuARRB /ApFGYBz6wUQ== X-IronPort-AV: E=McAfee;i="6000,8403,9709"; a="238515555" X-IronPort-AV: E=Sophos;i="5.75,460,1589266800"; d="scan'208";a="238515555" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2020 00:32:11 -0700 IronPort-SDR: F5WcENnvbh/KWvgsRyWJsVUCyXLWlzoxqMeGjFl/3JDe1T+UDkZfzYe77N5GbKnEb0Ajn8sGiB N71V0MflHsaw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,460,1589266800"; d="scan'208";a="398453072" Received: from intel-npg-odc-srv01.cd.intel.com ([10.240.178.134]) by fmsmga001.fm.intel.com with ESMTP; 11 Aug 2020 00:32:09 -0700 From: SteveX Yang To: qiming.yang@intel.com, beilei.xing@intel.com, jingjing.wu@intel.com, dev@dpdk.org Cc: SteveX Yang Date: Tue, 11 Aug 2020 07:27:52 +0000 Message-Id: <20200811072752.20813-1-stevex.yang@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] 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" 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: SteveX Yang --- drivers/net/iavf/iavf_ethdev.c | 43 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index c3aa4cd72..ebff4d40b 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,20 +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); -} - -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; @@ -1449,15 +1456,15 @@ 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; - } +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.17.1