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 5ED8EA0613 for ; Tue, 27 Aug 2019 22:06:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 960DC1C1C3; Tue, 27 Aug 2019 22:06:53 +0200 (CEST) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 321331C1BA for ; Tue, 27 Aug 2019 22:06:52 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id s18so114226wrn.1 for ; Tue, 27 Aug 2019 13:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netcope.com; s=google; h=from:to:cc:subject:date:message-id; bh=N8qlZEWzjTS8HtjZ8i+nhHUM7PjjZy7R43tJLC3Y5SY=; b=S0B+gTHhH5sJUhbBuz0I624umHHCRUczFWZJGDgCMQsQFhPx6UMImM7nrGnBVFWFxo JrvaDR9ukHDdmKYCg7qm+mTK4KwvMevmFQ819RLDLyPPg0r87bKrgZkTM4gAflB2zI+r Od5jSzPDtiRnu/T+zZB9eyADWnYBQvOALOL3MS/8FBHHYdWmhvJA8Zd/uJh8Ni2lMQVq StN1U4HatvyNevxfRE4k+4XBQppOY6MfkbzPSs1IYeP4BqWBpGLnCr7KN9MAAogQTthb Bl0pkGmu+x/Tbj1YKnA1Sr358S8kW+43bjKfzHcOgiBzZcIXdxrLJ5QqOnL2jGpIedUd pVWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N8qlZEWzjTS8HtjZ8i+nhHUM7PjjZy7R43tJLC3Y5SY=; b=VC6AIY5QflChH8MrDDSATnYtbNyhiEaaSvwoINyxexLBjsdp05BkOcqxl9qkEkIZ5S vHdtXrzS04hj4nYFnxCchh3bBThwbH1buawb7raV/0Uj6UJ3dHbvAFFb4grM0fyoHW1Z Jkww3UwSWONWPuYBmjvBLyGpgsaZLux1EGDSrfDX/RXwH2db/enNrUVltpFAuzG0oE8z GF2N2sWsYy29qv87gCcHRTgYVBt19Euu3lUSFsJNt/gKr3n3jqM3r5ghn2cmVNO5pa+x A7BUXnrF/cNaRi9WpTqvzzyx+1QejX+hfRArrQatJYEaIBwUP802YHxBvXfq06iyaSzU KJ3w== X-Gm-Message-State: APjAAAXtNraybuKZWh5Or1dRTXGb3fHxV7hVeB9R0z3Rw092BNPIg9x4 KDJ9GYhGI+Kb/K9fxEKh7C6pirWAndcWKA== X-Google-Smtp-Source: APXvYqxHFjrOA+Fo02UNo9HEWlwaaNSg/dVie8YFtaaOctIaQemBqti/X83M0htFLdTFRt24/olNyQ== X-Received: by 2002:a5d:4946:: with SMTP id r6mr33247844wrs.266.1566936411695; Tue, 27 Aug 2019 13:06:51 -0700 (PDT) Received: from sw-c1.int.netcope.com ([5.180.196.50]) by smtp.gmail.com with ESMTPSA id o8sm437095wma.1.2019.08.27.13.06.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Aug 2019 13:06:51 -0700 (PDT) From: Rastislav Cernay X-Google-Original-From: Rastislav Cernay To: dev@dpdk.org Cc: Rastislav Cernay Date: Tue, 27 Aug 2019 23:04:19 +0200 Message-Id: <1566939859-1805-1-git-send-email-cernay@netcope.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/szedata2: remove resources when port is closed 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: Rastislav Cernay The rte_eth_dev_close() function now handles freeing resources for devices (e.g., mac_addrs). To conform with the new close() behaviour we are asserting the RTE_ETH_DEV_CLOSE_REMOVE flag so that rte_eth_dev_close() releases all device level dynamic memory. Signed-off-by: Rastislav Cernay Acked-by: Jan Remes --- drivers/net/szedata2/rte_eth_szedata2.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index d5dec1b..99d5ca5 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1157,12 +1157,15 @@ struct szedata2_tx_queue { static void eth_dev_close(struct rte_eth_dev *dev) { + struct pmd_internals *internals = dev->data->dev_private; uint16_t i; uint16_t nb_rx = dev->data->nb_rx_queues; uint16_t nb_tx = dev->data->nb_tx_queues; eth_dev_stop(dev); + free(internals->sze_dev_path); + for (i = 0; i < nb_rx; i++) { eth_rx_queue_release(dev->data->rx_queues[i]); dev->data->rx_queues[i] = NULL; @@ -1173,6 +1176,9 @@ struct szedata2_tx_queue { dev->data->tx_queues[i] = NULL; } dev->data->nb_tx_queues = 0; + + rte_free(dev->data->mac_addrs); + dev->data->mac_addrs = NULL; } static int @@ -1475,6 +1481,9 @@ struct szedata2_tx_queue { PMD_INIT_LOG(INFO, "Initializing eth_dev %s (driver %s)", data->name, RTE_STR(RTE_SZEDATA2_DRIVER_NAME)); + /* Let rte_eth_dev_close() release the port resources */ + dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + /* Fill internal private structure. */ internals->dev = dev; /* Get index of szedata2 device file and create path to device file */ @@ -1537,12 +1546,9 @@ struct szedata2_tx_queue { static int rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev) { - struct pmd_internals *internals = (struct pmd_internals *) - dev->data->dev_private; - PMD_INIT_FUNC_TRACE(); - free(internals->sze_dev_path); + eth_dev_close(dev); PMD_DRV_LOG(INFO, "%s device %s successfully uninitialized", RTE_STR(RTE_SZEDATA2_DRIVER_NAME), dev->data->name); -- 1.8.3.1