From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C5AA5C768 for ; Fri, 19 Jun 2015 10:32:09 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 19 Jun 2015 01:32:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,643,1427785200"; d="scan'208";a="746364551" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 19 Jun 2015 01:32:07 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t5J8W5mV010026; Fri, 19 Jun 2015 16:32:05 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t5J8W202011918; Fri, 19 Jun 2015 16:32:04 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t5J8W2je011914; Fri, 19 Jun 2015 16:32:02 +0800 From: Michael Qiu To: dev@dpdk.org Date: Fri, 19 Jun 2015 16:31:56 +0800 Message-Id: <1434702717-11877-2-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1434702717-11877-1-git-send-email-michael.qiu@intel.com> References: <1433938895-16331-1-git-send-email-michael.qiu@intel.com> <1434702717-11877-1-git-send-email-michael.qiu@intel.com> Cc: shaopeng.he@intel.com Subject: [dpdk-dev] [PATCH 1/2 v3] fm10k: Free queues when close port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2015 08:32:10 -0000 When close a port, lots of memory should be released, such as software rings, queues, etc. Signed-off-by: Michael Qiu --- drivers/net/fm10k/fm10k_ethdev.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 4afd5ab..6a14633 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -52,6 +52,10 @@ static void fm10k_close_mbx_service(struct fm10k_hw *hw); +static void fm10k_tx_queue_release(void *queue); + +static void fm10k_rx_queue_release(void *queue); + static void fm10k_mbx_initlock(struct fm10k_hw *hw) { @@ -665,11 +669,37 @@ fm10k_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - for (i = 0; i < dev->data->nb_tx_queues; i++) - fm10k_dev_tx_queue_stop(dev, i); + if (dev->data->tx_queues) + for (i = 0; i < dev->data->nb_tx_queues; i++) + fm10k_dev_tx_queue_stop(dev, i); + + if (dev->data->rx_queues) + for (i = 0; i < dev->data->nb_rx_queues; i++) + fm10k_dev_rx_queue_stop(dev, i); +} - for (i = 0; i < dev->data->nb_rx_queues; i++) - fm10k_dev_rx_queue_stop(dev, i); +static void +fm10k_dev_queue_release(struct rte_eth_dev *dev) +{ + int i; + + PMD_INIT_FUNC_TRACE(); + + if (dev->data->tx_queues) { + for (i = 0; i < dev->data->nb_tx_queues; i++) + fm10k_tx_queue_release(dev->data->tx_queues[i]); + rte_free(dev->data->tx_queues); + dev->data->tx_queues = NULL; + dev->data->nb_tx_queues = 0; + } + + if (dev->data->rx_queues) { + for (i = 0; i < dev->data->nb_rx_queues; i++) + fm10k_rx_queue_release(dev->data->rx_queues[i]); + rte_free(dev->data->rx_queues); + dev->data->rx_queues = NULL; + dev->data->nb_rx_queues = 0; + } } static void @@ -682,6 +712,7 @@ fm10k_dev_close(struct rte_eth_dev *dev) /* Stop mailbox service first */ fm10k_close_mbx_service(hw); fm10k_dev_stop(dev); + fm10k_dev_queue_release(dev); fm10k_stop_hw(hw); } -- 1.9.3