From patchwork Mon Sep 28 10:54:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sachin Saxena (OSS)" X-Patchwork-Id: 79005 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 789A4A04C3; Mon, 28 Sep 2020 12:54:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5F3861D627; Mon, 28 Sep 2020 12:54:45 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140045.outbound.protection.outlook.com [40.107.14.45]) by dpdk.org (Postfix) with ESMTP id 7F9FE1D621 for ; Mon, 28 Sep 2020 12:54:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jHslzQutxCU1YC3rJGO3QLOMq84xBbMWbIr5hX5jMhV3/sISlgEn3mfAbKyX/b+wvTCLzNHqd2WVC4EzdoUReNCLOR6qyHGIZJsPTPtY2T8wHhdbEvXGsLNw6qW6xrdX9G+a1fLdgV+zoQvzyuDPG4yTs31Cl1+5VIEc+9vw5I+RZtnyk1VKlb4sxSXZetQ9Fd9AVv24+mDQb/u0zE5vm7AX1dqnJO2mNf1EzcMvqWvKl2PzJLjUVzHq9zQUFjxFPvZ6+PAJPBGy21LBO6CV5f0vfHdnLf0yqdc+/XbKe5O1z3Q13A53YJMj/IXtm1Y7x2wKV+iyVzjnqTGXGLb3jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2U/D0H8Wax29+3rlJJUYDbmFfmhvvE1lOSsAnm27eCo=; b=IrrlW6BquCjFeSAZCsSPv7tR49Fq5T6wVG8rS6xRdDV5yYPhvdoy8Uef4u478H97jUqRdtYyUE1QqA2yJaGZMPwuNArJnvXWoNzCNjrIkU88fWpNxKh5/dXi9bdr+CNh5xrgKQ6aGf1do8vcQU1jtCdCIkqLHMC8SiMxrslyAQ85zUe2s5bth3+7wbWQ0ip2W/6iLvVLf+e8TRe56NTIprv9gWyxm/R+zdw6RdmpxEBuV1LEjLGLFRwV+GrogGmEjQiV4XD0DGhwhVD2c6fm7VnlYGr+Z050fsEsEyJHa+VsF2YH4acbUiBc+7ApZcy40IWPjQ3M5u11KlrnCSYCfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2U/D0H8Wax29+3rlJJUYDbmFfmhvvE1lOSsAnm27eCo=; b=FILsqzl5OWnab93giXyEm2PlgB42EYe742q7qu49XYmtqLVLCD20MpDpCgVpkL6LxolVduF68eARFCwJ2LQZgopXzzOTvAts0xNL+8M9C+ZgbfpxJTfG20iyaAx8minOJCygLyRPltIDlmXdqQbfRfbi1bCP10+QN8WDaNbCPkw= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5837.eurprd04.prod.outlook.com (2603:10a6:803:ec::28) by VE1PR04MB7342.eurprd04.prod.outlook.com (2603:10a6:800:1a0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22; Mon, 28 Sep 2020 10:54:40 +0000 Received: from VI1PR04MB5837.eurprd04.prod.outlook.com ([fe80::cc01:9fe2:2544:8a4b]) by VI1PR04MB5837.eurprd04.prod.outlook.com ([fe80::cc01:9fe2:2544:8a4b%7]) with mapi id 15.20.3391.030; Mon, 28 Sep 2020 10:54:40 +0000 From: "Sachin Saxena (OSS)" To: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@intel.com Date: Mon, 28 Sep 2020 16:24:28 +0530 Message-Id: <20200928105428.14197-1-sachin.saxena@oss.nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928085713.13560-3-sachin.saxena@oss.nxp.com> References: <20200928085713.13560-3-sachin.saxena@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0113.apcprd02.prod.outlook.com (2603:1096:4:92::29) To VI1PR04MB5837.eurprd04.prod.outlook.com (2603:10a6:803:ec::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03161.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0113.apcprd02.prod.outlook.com (2603:1096:4:92::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3412.20 via Frontend Transport; Mon, 28 Sep 2020 10:54:38 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a4a5a52a-decc-433a-f719-08d8639ce5e7 X-MS-TrafficTypeDiagnostic: VE1PR04MB7342: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3wvJlMLSwqPjIQjO926nnLCbz/LSKZubACq1FLAyaIEKgdzth4z2luLHvkybg8vY1FcuWdaEwGQa9Yru33/lEtuZvksx7Uc5lmpL8RaV7yr/GfHsh/hgc/mIYXO6kVAmdxJlFe/OeNyqPMf/56PA1Gvb5X7wAX7CBz6IkVmvUmTUmorahTXdNWO3syXLJoWLNIs/lw86YxJt53U9AcETdwUSd6wwFMNn5pL7/wvUt1PxeFHi62JI4ldTbf3l6Ja2D5UbzF2DP3HAwP5TVImkHJO8JtcMjl7BxIkgq58AlsWsRhuQ8RhJfziwgfTdvxKpb7Xv4E9sHCLnQS9lX8YHqDFPpWUpbZNjdngXbus0S7cQHUaPifIpeJb8fgfqF//LbFYe8+/Qlgqqf3t6edn2mhu9Gn6YTErrPFMXq9RFTgk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5837.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(376002)(346002)(396003)(366004)(136003)(6506007)(55236004)(316002)(66476007)(66556008)(5660300002)(16526019)(186003)(6512007)(26005)(1076003)(6486002)(6666004)(1006002)(83380400001)(8936002)(66946007)(86362001)(8676002)(52116002)(478600001)(2906002)(956004)(2616005)(110426005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: xSy3PU3Mup6PUYII2rjjN6bjWO9SJOZOJeNAlG+UE56azVwm06YMdQlwLCtdJ/6qT76B5nZ3BuacZTZOVXJmVBWqcJA4fal+KeSYKFRK9BWlyAtCASYXoBUEt07tD5JucmGXebNrY2wefQQf7I6USPs3KocBmxG6oeVIVgxK/EVp3z0vf4lEjDMwAYE7E5cerKC4ZrQGYI2MtR5lJjq9GCF+1cHtm3GkzCHSdj2e4Auj2oq1vWfcWMuAU9d7uXcSdtGi9SBdpOIfh7HZnVzlODQN7MrAaUidZMx9jKs/15IPlrLjtSDzg8hOLJBbWvjskIGb9w1oy7rXIs3Usejh2OK8Awd6RoknfL9u4a2T9SnhVJHhamQ9VxUInSz2oEmghBe2ELiDzkl06PN1G5X66ufQCD9oZWzUw/yqM+y4oc/cPoyV1gwFFCjFco/CPu8Gt+Pmnw7p+lTMLGunvkCPegYHdjBMkT32943VxG4LXVKMd39z91tvMHBln1fgIoPJ6jnxyKvTmiNiz1CkJ4W0WviFIom8h3ynYqRtemiCOURJpjnQin6F3j41l8gR1F5owfgAUvEz+87RKl8ihHAboYEx05QL/C5qWdqfAWMXDxxpuFVmw976TBYOESiXpilAYV6etU3UVaoD4sCns0Bzeg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4a5a52a-decc-433a-f719-08d8639ce5e7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5837.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2020 10:54:40.6362 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PsxB7aRIeR5126eLmkRcDfzsNYwUaIVZfzqxprGm4g36IKEFFojfUAzsQLNHkyZLqSAnd7P29rNKhO1vmQ3tmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7342 Subject: [dpdk-dev] [PATCH v2] 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 | 83 ++++++++++++-------------------- 1 file changed, 32 insertions(+), 51 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index c81e75d53..ba99a524f 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,7 +1240,7 @@ 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(); @@ -1249,8 +1248,12 @@ dpaa2_dev_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - dpaa2_flow_clean(dev); + 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) { @@ -1261,6 +1264,27 @@ 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); + + DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name); return 0; } @@ -2712,52 +2736,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); - - DPAA2_PMD_INFO("%s: netdev deleted", eth_dev->data->name); - return 0; + return ret; } static int @@ -2826,13 +2807,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); - - rte_eth_dev_release_port(eth_dev); + dpaa2_dev_close(eth_dev); + ret = rte_eth_dev_release_port(eth_dev); - return 0; + return ret; } static struct rte_dpaa2_driver rte_dpaa2_pmd = {