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 817D7A04C0; Tue, 29 Sep 2020 01:17:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A3C821D92B; Tue, 29 Sep 2020 01:15:23 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id A4FD21D8E9 for ; Tue, 29 Sep 2020 01:15:08 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 4AD145C01A2; Mon, 28 Sep 2020 19:15:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 28 Sep 2020 19:15:08 -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=gv0hf8Iw0cR8i E1pLEfCw+w4cgogEdl1BTmWol/yafI=; b=twJSraiS1D+FqeGwi7KLmlsXzVjax TGEjifjwV05AqGdyRoKkspyynBqE8yOGX05jv12k4hcBhCF9kU0eeX0FO8ryZP9P LXWkwFoLjcsNcoO6x0Ha2KqpeI7GgxvInzkubZ4Jl6NTFA9IDVoer7DwztbO0DaS Q8zlSH53a6Fi/gqHyYiyfAHyBFAFlQIYk6cSym+xz5DQ70o6usRsylaOUOzIj1vD 01uckMW+CgdMLqi0xgjvWTOanWwsMsKEVxTG1Uh7NTVpE46Q9eNfB1C8uP8YiVlG fwHdI/gxIVwSrh8cU64TJZavuAvWXaz3sLqydEfJS9uF2maytQfH0ry/w== 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=gv0hf8Iw0cR8iE1pLEfCw+w4cgogEdl1BTmWol/yafI=; b=A9BBTnVq QzRIJERwdtWTM7FhoB0IYYkvSxuBxrWFfZUCAsEgn/tn6CI5+n+Alyr4Wsz3NfDA jYt2uMDiDowYxvfi67HBi7jcjiESBqsUTEg8frRPI7LIxXXzwGgKihnhUvEtqyzf TgJYmGOH5SizfBNY7aZp/ovISPkbId9VHTS/q8F5JN/PuXo1IixhFAq7BCKerHXN dOc/Vuy39L+U1ZuwYmPOMgFctXspHIC393TJOR4iHaBu6Z2hFW3p2Lk7tiCwwo1o 0nDj/01FIIIj5m1R2Rs0cbohjj3FDXq14G86h00OfvhGwGek91Rxt7RcPidMSk2T vcMR1IqLq17rbQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdejgddulecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedvhefgiedvjeegtdevheefhfetleefgfeivefgffevfeejgedtgfeu tdehtdegveenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgepkeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho 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 3E6CE3064610; Mon, 28 Sep 2020 19:15:07 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@intel.com, arybchenko@solarflare.com, Sachin Saxena , Hemant Agrawal , Anatoly Burakov Date: Tue, 29 Sep 2020 01:14:17 +0200 Message-Id: <20200928231437.414489-10-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 09/29] net/dpaa2: 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: Sachin Saxena With removal of old close behavior, the private port resources must be released in the .dev_close callback. Freeing of port private resources is moved from the ".remove(device)" to the ".dev_close(port)" operation Signed-off-by: Sachin Saxena --- drivers/net/dpaa2/dpaa2_ethdev.c | 95 ++++++++++++++------------------ 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index fb4165fa03..7bd3208a19 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -99,7 +99,6 @@ static const enum rte_filter_op dpaa2_supported_filter_ops[] = { }; static struct rte_dpaa2_driver rte_dpaa2_pmd; -static int dpaa2_dev_uninit(struct rte_eth_dev *eth_dev); static int dpaa2_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev); @@ -1241,13 +1240,20 @@ dpaa2_dev_close(struct rte_eth_dev *dev) { struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private; - int ret; + int i, ret; struct rte_eth_link link; PMD_INIT_FUNC_TRACE(); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + if (!dpni) { + DPAA2_PMD_WARN("Already closed or not started"); + return -1; + } + dpaa2_flow_clean(dev); - /* Clean the device first */ ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token); if (ret) { @@ -1258,6 +1264,31 @@ dpaa2_dev_close(struct rte_eth_dev *dev) memset(&link, 0, sizeof(link)); rte_eth_linkstatus_set(dev, &link); + /* Free private queues memory */ + dpaa2_free_rx_tx_queues(dev); + /* Close the device at underlying layer*/ + ret = dpni_close(dpni, CMD_PRI_LOW, priv->token); + if (ret) { + DPAA2_PMD_ERR("Failure closing dpni device with err code %d", + ret); + } + + /* Free the allocated memory for ethernet private data and dpni*/ + priv->hw = NULL; + dev->process_private = NULL; + rte_free(dpni); + + for (i = 0; i < MAX_TCS; i++) + rte_free((void *)(size_t)priv->extract.tc_extract_param[i]); + + if (priv->extract.qos_extract_param) + rte_free((void *)(size_t)priv->extract.qos_extract_param); + + dev->dev_ops = NULL; + dev->rx_pkt_burst = NULL; + dev->tx_pkt_burst = NULL; + + DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name); return 0; } @@ -2709,56 +2740,9 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name); return 0; init_err: - dpaa2_dev_uninit(eth_dev); - return ret; -} - -static int -dpaa2_dev_uninit(struct rte_eth_dev *eth_dev) -{ - struct dpaa2_dev_priv *priv = eth_dev->data->dev_private; - struct fsl_mc_io *dpni = (struct fsl_mc_io *)eth_dev->process_private; - int i, ret; - - PMD_INIT_FUNC_TRACE(); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - if (!dpni) { - DPAA2_PMD_WARN("Already closed or not started"); - return -1; - } - dpaa2_dev_close(eth_dev); - dpaa2_free_rx_tx_queues(eth_dev); - - /* Close the device at underlying layer*/ - ret = dpni_close(dpni, CMD_PRI_LOW, priv->token); - if (ret) { - DPAA2_PMD_ERR( - "Failure closing dpni device with err code %d", - ret); - } - - /* Free the allocated memory for ethernet private data and dpni*/ - priv->hw = NULL; - eth_dev->process_private = NULL; - rte_free(dpni); - - for (i = 0; i < MAX_TCS; i++) - rte_free((void *)(size_t)priv->extract.tc_extract_param[i]); - - if (priv->extract.qos_extract_param) - rte_free((void *)(size_t)priv->extract.qos_extract_param); - - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - - DPAA2_PMD_INFO("%s: netdev deleted", eth_dev->data->name); - return 0; + return ret; } static int @@ -2809,6 +2793,7 @@ rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv, dpaa2_dev->eth_dev = eth_dev; eth_dev->data->rx_mbuf_alloc_failed = 0; + eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC) eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; @@ -2827,13 +2812,13 @@ static int rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev) { struct rte_eth_dev *eth_dev; + int ret; eth_dev = dpaa2_dev->eth_dev; - dpaa2_dev_uninit(eth_dev); + dpaa2_dev_close(eth_dev); + ret = rte_eth_dev_release_port(eth_dev); - rte_eth_dev_release_port(eth_dev); - - return 0; + return ret; } static struct rte_dpaa2_driver rte_dpaa2_pmd = { -- 2.28.0