From patchwork Mon Sep 28 08:57:12 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: 78982 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 8DB75A04C0; Mon, 28 Sep 2020 10:58:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D7EC51D67F; Mon, 28 Sep 2020 10:57:38 +0200 (CEST) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20043.outbound.protection.outlook.com [40.107.2.43]) by dpdk.org (Postfix) with ESMTP id 027E31D5E4 for ; Mon, 28 Sep 2020 10:57:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m/avN73G7lgqZzNcV5GbIRMuLxw6QL5dEejOW8gWxktfvkJV0vSVXY2pFvLJFovqZp7Y8WRoXfMgKfmjd6FJOH8OioDOpHPNEwFg7fhIKWanSxZezjJWfDjQiArZxZZUWVQfKcWqqTX29G47fmQSDh7nYmMR35IFF0zc+bhPoagucXsW3S+VYx/eKMdaTBe0iFdR7eK5trm7l9vFbKrAh37K2vPzzqDy4sTfU5dX48mxaCBESoaxgLvuQuSvxwmHxR2Z6vN2M8cGBfwBtGEkeDMy01WNL5TkpG7ZnFU7rlzjSBtAsKUsF7UIYZQQ5R5ssbNA6iSwOXTVsPPKlCojmQ== 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=Re8X1VfPsfAHee8YBfmR4y3tYXS+CvLN/EblijQL9Us=; b=DhDugMM+96Y6ow4taWZS6dzYVbszxWA6iGWNYMHrr8j78mtGC2JSNa6VlWf+brI8YTUVDLEcjxX42w5GQOwrr2teYok0Vq/Zu0C6j4uiUWaZKEAtKnSCfo3Sy2hH/pyKS1niXo4k4uMg8qN0nL8TazNYtKofzrAfuQnopds0c2OdV3jG2C7uC5pqaO8TIzwS9Kkb+1If7/nEZDMfb2HCDHwdtd3Weceaoq9+SsRDiQpLoATo03eD9pflpGAVUv5VtWNW1d3nvwC6f/rnVH2JuMPY/p2dz/Clc2M6l4vRDk/yOE4S5xl48DUxB0lfjnIG6rNd3A8mvqY76aEvMeSeXg== 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=Re8X1VfPsfAHee8YBfmR4y3tYXS+CvLN/EblijQL9Us=; b=k0qO1Xj8/JkgaJQmc0huUrJldkgCiDuHpWUayEJvJVtVttz2EnlaP+XPOXHMUjyzhR5XzW4ZbqpbOXF7rSnE8GGr4C7vdCWBlJhDkmIvGQuOr5BLODijPpgjXhbA+V0No7hbBfT160QNAMadKn6GkkqqIJ9OX9f4Mt5AdfqAbPE= 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 VE1PR04MB6542.eurprd04.prod.outlook.com (2603:10a6:803:123::32) 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 08:57:32 +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 08:57:32 +0000 From: "Sachin Saxena (OSS)" To: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@intel.com Date: Mon, 28 Sep 2020 14:27:12 +0530 Message-Id: <20200928085713.13560-4-sachin.saxena@oss.nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928085713.13560-1-sachin.saxena@oss.nxp.com> References: <20200928085713.13560-1-sachin.saxena@oss.nxp.com> X-ClientProxiedBy: SG2PR06CA0206.apcprd06.prod.outlook.com (2603:1096:4:68::14) 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 SG2PR06CA0206.apcprd06.prod.outlook.com (2603:1096:4:68::14) 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 08:57:31 +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: 5a20c93c-70ba-405b-377b-08d8638c8962 X-MS-TrafficTypeDiagnostic: VE1PR04MB6542: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ymx3YmyiLT0O7xw4E4o8YCcCmfVJP3JvTV9LChXu8auO7R976+kNKV9RyM8nwaL09CBRpbn+nYg89MU817RfmdqhfQmgs0o/NTMAEGQoj5mbsO2/gbNbZdrgCOn6QjrQHJzqGtOzdW1R4mI7LMBqTV2u6dRaDlHYQ/TW2N2FKrDQXjJZO1IRRtxztu5W9faH+bNKq7IUr+05Bm6Ljot4eHL4r7Vrk6rAh1xkJSZ0U9eFJmF3Q3e/7LXIk6GrnOaoxE7AcZXUUXcWTmmL2dUJIwvyDk5fdrg30/PebM8GwuuWsxAIfrphFCqB0ZZW511ZFh31bjvDBs66iKJOYXAWTMfb12z8xOTmf2qTpJ10Arf69l5dgC9kxyZrMY8QcEaJDn7OQy09pFIS/3oZlxgCvmkKtG5jyRP8oNlGeZbBupg= 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)(376002)(396003)(39860400002)(346002)(366004)(136003)(6486002)(66946007)(186003)(478600001)(52116002)(5660300002)(16526019)(8676002)(316002)(6506007)(55236004)(83380400001)(8936002)(26005)(1076003)(2906002)(86362001)(1006002)(6666004)(66476007)(66556008)(6512007)(956004)(2616005)(110426005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: JEvoZy2xDrnasy1eN6ItSgmrTUs2t1mC7eDy9haZz2z/8p4E8y68IweRyVzLNaMNMd3wcNGBAufAp4GeJKl5fq2LExLyAvvmqKxpv+ouF4KqgaT0LCs1o9T1gBbiygDOC8Ft7aBOyYqUk9jKMSTAaK0K+rojhi0pVhm5yJbgYAnNL5AhCSmJuwoqHO3R99baoRYzOymFH72XIjDMmNpiDBhIYmH6if64Riyfh5ISFcAhYu9MpMaA3wfvm/b9VWXQ8yyoUau4Vw74sYKI3m6Amr9HXu9yVXFhGWSQI4N2lp+3GLs8YFUhihgumeQj/gQO+l4hocig0FHVmHTBOHTsJkiQc37aV2SR4tRqWghL5oviVcZ2hEei6ps1grF7lDhuUI4IeU97DpdSwNO8lEgq2UMpBB1wujwvhnpVEwGUcEqWJrlwC8pLgGz+NclRlsoT+72eFS3S0ZZdzt1FcApHmBdW484Areyq+mBBrZybY+jExeCDnYEbEMrtP7aRReI2cXFFux5V9STn9ZYzq4TS0nid0DSpcAcydNcG77uz/HkXVggzesfr/1k/5z2/40dxIR6bo5es+rtr5Sgax7ISDN0pHNhxa8ZkIYG301mGHrIcuIxsAR14K9SLYMDc8nGZ31VJfOb8csCihqHIQaedbg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a20c93c-70ba-405b-377b-08d8638c8962 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5837.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2020 08:57:32.6120 (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: 08rTEgF2bJituY4kj6b3Q4Bmq8UYZm/sQ4FITP9HOtAmYdU/xrk5T9Su5mrHw7ePtUHSZIUlbLgnbOBnNxGItQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6542 Subject: [dpdk-dev] [PATCH v1 3/4] net/pfe: 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/pfe/pfe_ethdev.c | 38 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c index a7e9d97ba..f0de1c8a2 100644 --- a/drivers/net/pfe/pfe_ethdev.c +++ b/drivers/net/pfe/pfe_ethdev.c @@ -385,22 +385,11 @@ pfe_eth_stop(struct rte_eth_dev *dev/*, int wake*/) dev->tx_pkt_burst = &pfe_dummy_xmit_pkts; } -static void -pfe_eth_exit(struct rte_eth_dev *dev, struct pfe *pfe) -{ - PMD_INIT_FUNC_TRACE(); - - pfe_eth_stop(dev); - /* Close the device file for link status */ - pfe_eth_close_cdev(dev->data->dev_private); - - rte_eth_dev_release_port(dev); - pfe->nb_devs--; -} - static int pfe_eth_close(struct rte_eth_dev *dev) { + PMD_INIT_FUNC_TRACE(); + if (!dev) return -1; @@ -410,7 +399,12 @@ pfe_eth_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - pfe_eth_exit(dev, g_pfe); + pfe_eth_stop(dev); + /* Close the device file for link status */ + pfe_eth_close_cdev(dev->data->dev_private); + + munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size); + g_pfe->nb_devs--; if (g_pfe->nb_devs == 0) { pfe_hif_exit(g_pfe); @@ -1147,6 +1141,7 @@ pmd_pfe_remove(struct rte_vdev_device *vdev) { const char *name; struct rte_eth_dev *eth_dev = NULL; + int ret = 0; name = rte_vdev_device_name(vdev); if (name == NULL) @@ -1158,17 +1153,12 @@ pmd_pfe_remove(struct rte_vdev_device *vdev) return 0; eth_dev = rte_eth_dev_allocated(name); - if (eth_dev != NULL) - pfe_eth_exit(eth_dev, g_pfe); - munmap(g_pfe->cbus_baseaddr, g_pfe->cbus_size); - - if (g_pfe->nb_devs == 0) { - pfe_hif_exit(g_pfe); - pfe_hif_lib_exit(g_pfe); - rte_free(g_pfe); - g_pfe = NULL; + if (eth_dev) { + pfe_eth_close(eth_dev); + ret = rte_eth_dev_release_port(eth_dev); } - return 0; + + return ret; } static