From patchwork Mon Sep 28 08:57:11 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: 78983 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 57A7BA04C0; Mon, 28 Sep 2020 10:58:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6070C1D685; Mon, 28 Sep 2020 10:57:40 +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 E76591D5E2 for ; Mon, 28 Sep 2020 10:57:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8sSxnm6CgFATOWWyZbwnXZWQxPQ30lbbkqMC55tMA0rTGhAH+AyZ9sWfmUEmtas9uRHnHlwS2/8g4mkXHMLRIBZn7ouu+Y6I8gkrChXyGQjqH89l0eDiikyvha9twujNXhAM71uOW8DPg3Ukg6/8p6pP6JKJ+MlKq2FbiGbjK6IB5KnO5EGfJ4dIt8uEO7mGGdSID713dIiRQcb59RHHE5XW4B2+fkuPXxtmOer3KwB+2gL78bgXUCKagmGtY/SYy3mcbQUN+o/13PkbMFCCQCocbfTvj2xwpAZOlm1Z+3Ct9KpqacpfQeV+VZ7ZviraczpFRtWzxaWy9KuC9gBlQ== 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=EPV6bqjVW+r0v1oXy4ZICfppW6oM2WGe5cebFS7xquc=; b=Fd/t0IDDDF/Wh5D3FgBubFdAKfj+xHcC6sygBTlHmrrIbQ7XY5lZv+Nywb1SmAzUMKw70R3JSBCY+A2EuKOcs2DFHW6aB0P4cq/WjNeD1iuJ8yWK5hLhR0CDueyZeGkAEg31AS8rIktiezY0TAkjzuRKVfQ4DW0CcQFDd+zFuKCa0XNrNlxu82yPkG/cPqWsRcAw6lAarE91Nl7nQmW/0bKHvoBmlByl51q1IoGghdKmAo54PJwgOxhSDb0bzLX5R1UT49gR8j++Fc32ANOEtNKdGkE17yh0P/BfB3+/blt3Jm9Icmrj8x3bw/fO3/z/Mnv+chpRUHZcAjsJAI0Fjw== 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=EPV6bqjVW+r0v1oXy4ZICfppW6oM2WGe5cebFS7xquc=; b=KUsWs5oy7GGWX3KCpJT4AcTV+CxHmHyycEsmF+QtJwW9kinxWvPK8xLlQmivKPttHrImcGhmmuA3tcAszNZSjOJqfDEpXmuxf0kjhxPZZDcCTNGatQhbZBjGHhNpOK1wOTWGVG8wnfpdgqIcS3zTH6CcYWc68Mh4rC8Qf/um2Jk= 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:31 +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:31 +0000 From: "Sachin Saxena (OSS)" To: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@intel.com Date: Mon, 28 Sep 2020 14:27:11 +0530 Message-Id: <20200928085713.13560-3-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:29 +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: 8f9d5ba8-2e4d-4537-8c6e-08d8638c8873 X-MS-TrafficTypeDiagnostic: VE1PR04MB6542: 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: wrq39AW6yjrMkVG6gkihmV9XIzR4vmmkNYdLe+mJ+JFF5HgwUOxqSvS97dVm7qWvi402qz01PGZnbfL7LCY5yzQrHZTUnKW7k8wcRd6g9I1ET4KevLID2yaR/0AJ+WRStj8HOFGkV03zERSPi9FROtdicDj66+Bc3KeyP9/RVKKV/Ki1eUH5RkeNIXVdibV4Af3gTqSbTop1bLDY52UXDBaDgQf81xz16FIHI9OQHG959FZ19GC/NjX3WKmne8LOH44V/Pjll5mSi299Ik9VjtVoLZ4EKthFPFPT92BQqwPKS+Ax314tSOf3GHUbhFd2eaGFyNEIvcG2y+tRjoNVrl7LaGQ/ZDitOaMAu0H44AJyEiKvMpU2IEa6yDe8tjg4FETnz3Nczm5Z/qJYKuVcv64bQNHOc9pBKBeTUu2o3NY= 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: tRRrM5A+l9XVkxIWzq8rWOxMHsUa90bJbqhSYgWdfKMqBclhgU/94JOImHF3xc1do4lGAuA6wuuwOlEFs8THgx2hfzKJ5WQMkAVdDKjowlU/CCi0pg2hnBCjeP8B/O14NhX4F3X0e4qK5RAmnOOuab9uLtY3PT2yayMYmmbwwGzOFrDCWvmBJwsdO0PsU6ybgn1Q+edDlc0fyi1m6pfBN9Gqv9eCsRNpsGzBx6uJ2BtpjFLVjRfp4qRWkK9GLTOvxAZ21wKy5rzPi0icR23+wMRh9DNL5aID2GeXsUdGkO0QyqA66ZWnSiHqLHcXstZvtQr03nu89sAJzT7gjVGPMLs3FocgTryLPSJysuK4riEWwpRHXee0wLxt2bIoMvYUaJ88kppsUa5AxXyf6xI31RK5P0NL/fZ3ROyAscty5k5hgg05rsHiK33IPEYvtlDUlT4eZhUF5u0017oHfBYWhV61guK4Dlkk4lamGQ9uBYmTtG3A6zpC0JSxl0nowRgWvfTHQIU5UvAQEwmnGNZNKq6zWJ8j8BF8EAILPCW9GXQjXm3p5msh95Ai7DtYrdEi3VC+bR07/59qWgAbZFLF0ckDQqhZmYwtIyo+e4zRN/eW1g9NuAwKxlLX0yToT2KOErxJVTjWFgCfkt4aj5EK9w== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f9d5ba8-2e4d-4537-8c6e-08d8638c8873 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:31.1039 (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: FYCgZNSkBFUfDGguXFgnQCHdjj2c3iYdiKfXnsWRV2NeKhSZceLOcz9JioYGrsGBFvpU8I5GAlzxWkIWRZxWxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6542 Subject: [dpdk-dev] [PATCH v1 2/4] 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 | 86 +++++++++++++------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index c81e75d53..3b87e8428 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,12 @@ 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; - } - + /* With new implementation of .close, port private data + * will also be release by close callback. + */ 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 +2810,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 = {