From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E512543BBA for ; Thu, 7 Mar 2024 12:20:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0976427D8; Thu, 7 Mar 2024 12:20:50 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id 0093F42EB5 for ; Thu, 7 Mar 2024 12:20:48 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8KE2MPEzLpNfDNlrP3dTzR6Jna9mgaZxLuCE62fCsmMZiAn0wUAI1PBtzDpxHBOQT2C+QD9TD1dzqVslqGcb9RJbONn/QnbRDI/v/sBSzodDTB3E6q0+yGd2hRM0TRMZLrFu11uUrNNOdkb76sbCPBaphJpXkUPSql6KfSyPXKuwFw4HSvfH9PwzdWILgui7FhXJUhvrfKPMSkn3vQB6/PQubhJ9HOvKT4tIb5AF+6LxjzHUMGCvdsercCTpZx1xDBy7VziA4tv7psl9ySciqebdbmSsyzG7Bwa5d0A8N4V1tCnM7TSAxtr9FWXfgI4y7GXHwBJL/NwvvLRVIRZnQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ak0HG6Tpxx3cJHbqbG8tR/CEKx8S2VsXbeuLuYSlStY=; b=b0zqMbjlAqMDUpx/qL6Wh4jMvenEmYu3wwLhtULnIGaI2spqoh0ZDE2pLEtNrDOnirvZWjxZANfsW7SMWETKBLL6J4QH+ZCOnwEdp8+Om70MFf2aHU8d22hfQUwzXGBxruhJcvKaWPNvelFeq2NDsY1yy7pTysNNTv6CF4yQ5NhcSnpcyA05HX54JlLHMNa2pwlxhdfxT9cHoYHHyq/x1obPWKqC5rwEHC3VQdyrsV6BIYLoQU88VDfQ2xQ81/genMWipZkXgP1MC5+sqE2AzNa/6MBO4gQM6qwT64P1k5R6P4OEGZNIbmIJ2i8XoJ373GBhMf4fYAh+azkaNmpBfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ak0HG6Tpxx3cJHbqbG8tR/CEKx8S2VsXbeuLuYSlStY=; b=oxoGdup3zklI6BqnL6jexfbq0fkLiQpTwoT5xo8zYl9DfXbnu+FBXHrgfBvstBqPmTKbFb6+enk9jhQDP6K72/Zs6ZqY5ebaGqaKa/NtK1p37p9YykMNk8332+yio14owmIJrSGEfrmUhRitIZY4WfMoFpRbwEIj9dKLmRl/4GQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH7PR13MB5959.namprd13.prod.outlook.com (2603:10b6:510:15d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26; Thu, 7 Mar 2024 11:20:47 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7339.035; Thu, 7 Mar 2024 11:20:47 +0000 From: Chaoyong He To: stable@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He Subject: [PATCH 22.11 v2 4/7] net/nfp: fix resource leak for exit of flower firmware Date: Thu, 7 Mar 2024 19:20:20 +0800 Message-Id: <20240307112023.1867765-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240307112023.1867765-1-chaoyong.he@corigine.com> References: <20240307112023.1867765-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR01CA0045.prod.exchangelabs.com (2603:10b6:a03:94::22) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5959:EE_ X-MS-Office365-Filtering-Correlation-Id: e9e1866b-34c1-4a56-604f-08dc3e98a316 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: adjCPkYxjL1kNe0p34CwSiEoGOXFuK8KsUA9rx0a5SUbjsbzGsHzL/PZ2ngsrUrdZGDNmqd1i3poTtYaY4e+20iyfRco8og8nslj3AVZ/QtujQi5oG4TkLu/PtM47X0gumSYyoAtJJ377EHh2xlTZNH3X5XscFX+OE31vZ4rPcbStsBwkO+w0Ls6vAV1oRtV2ykkfbLU9V5WtKFgy0T/VAa4DZ/BJ9MB+XNi3zdIyeSgT8OU9XBDHQ4BLHtFSaTUqfk9ZNMA29SoCZWbmRO1y/CFZHv45RKzLDVJDTDCuYZ5o6bMiru9Idv77pQcnYJVFumj21DEDyHz+1EXOl/1vOzEuAF7B1OkUTA9uVYdMdZy7+Sf1LKbzXd4AEWSFgfQ+SPLEt9NcDw+Qf/HagyF62Qbzx6pqDb/jrd4+ByTgHEuoLe8wYsfCPGcIIzODI2+AqczaASRClgJmg/JszarTVkTY8TowHWqBFoVAHmZ+OmJYaLDgqVwr4mR33eHh8haDKHdIT3DdEb3UHBxup5n4pGolbKkr3FqBP7RPbldlfw8DQ6FQNhl3K1gmNZE4XVIP44CGNM6Fr3pQbA2sb/gdaXcYCdZzoW31GBoqTiz7rxKGk+oizba9IthZ5lq4qrYS6QlKqeasNqqT7bm++VlhmA2Sb+Hr6mzoKqiMthpCjcFHcz+vrbwIZOMMCus4fCazk7D7wVztd6+6RbuC9HnZwRpl6IMSysHl0Ue5GrkgBk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?x+vE2ooL/EKqHv38Oo1I0jK6cukeTLTGyPcSkGFaCydIHt76C5IZv12dXgGi?= =?us-ascii?Q?vIxC6CGAiMIm5TyYjRpP9DeVgCXBqEA9p43xggHjV3hvvj6I3bU3Pz8LrjNR?= =?us-ascii?Q?vjCfdUgWzJCPJircK1urPf75iixICdQQN74aujb3q8W9yzgvreY23UGn8N/h?= =?us-ascii?Q?QWRnQYppyyLK1dwaTwGuftrqPB7/Bbx993I0gkKzw6jWAk3fNaDGHP4M/xvB?= =?us-ascii?Q?mlGJHidipQpksigY5ELz7i0kB/sc2OnOY0QHvR2dT/ATqaLESWT+a5qdxDoV?= =?us-ascii?Q?mzD6JMLulEquyFov60NgswUmxGXLDZ67riBDogPC+Gi+m0BZYefqdhuGTins?= =?us-ascii?Q?KC4j3HjcImQUrZMqBEWWaha7IGfva9GN9q1WBET9udhKZ59y9go3LolWdTri?= =?us-ascii?Q?t6D7h6O4JtDdqQYNnzU0e5y5B2SOWWizPGpCcCqy8NcX48+hcpk4Ku2AhSL0?= =?us-ascii?Q?8JYACDHusM8+b0i+5R2RqjLb2RDhK3BJcAFzq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lmJr4gwxCFkcDEauRz7NY6edZvFesQV9NESa136wkViixabD0kTer?= =?us-ascii?Q?ik4XmEAruiBA5rH/RQ/STjrC94GxbhNu8bnX4Q4yyEvK62MyJaq5mrYoDMkN?= =?us-ascii?Q?YFsS5Hv0MjgnxDMb/QFlcOQRiL9ulor+EeHGxX1yPPwKN4+4Dut31MOp1h/J?= =?us-ascii?Q?gVFz1DcNBBnOilz+264m7zLTJi/HwPlnzLwXVEPTvK3zHaKO8JNk0YlT1twC?= =?us-ascii?Q?YQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9e1866b-34c1-4a56-604f-08dc3e98a316 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 11:20:47.4932 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JP7e0Xqy6Mi4E5S/qXguidj8rNKdcTyypI0oS3DFLZZXVwtmZgnWQR6p1KEV5KtsRcfWYIjB977Cq/CWVdXqlsgOokaqOsEX0gtww+ZVgMU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5959 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit a256a1227dbe0eac576a42b6c336ce55b7713109 ] Fix the resource leak problem in the exit logic of flower firmware. Fixes: e1124c4f8a45 ("net/nfp: add flower representor framework") Signed-off-by: Chaoyong He --- drivers/net/nfp/flower/nfp_flower.c | 70 ++++--------------- drivers/net/nfp/flower/nfp_flower.h | 1 + .../net/nfp/flower/nfp_flower_representor.c | 64 +++++++++++++++++ 3 files changed, 79 insertions(+), 56 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index 5896d20..28be1b9 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -182,61 +182,6 @@ nfp_flower_pf_stop(struct rte_eth_dev *dev) return 0; } -/* Reset and stop device. The device can not be restarted. */ -static int -nfp_flower_pf_close(struct rte_eth_dev *dev) -{ - uint16_t i; - struct nfp_net_hw *hw; - struct nfp_pf_dev *pf_dev; - struct nfp_net_txq *this_tx_q; - struct nfp_net_rxq *this_rx_q; - struct nfp_flower_representor *repr; - struct nfp_app_fw_flower *app_fw_flower; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - repr = (struct nfp_flower_representor *)dev->data->dev_private; - hw = repr->app_fw_flower->pf_hw; - pf_dev = hw->pf_dev; - app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv); - - /* - * We assume that the DPDK application is stopping all the - * threads/queues before calling the device close function. - */ - nfp_pf_repr_disable_queues(dev); - - /* Clear queues */ - for (i = 0; i < dev->data->nb_tx_queues; i++) { - this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i]; - nfp_net_reset_tx_queue(this_tx_q); - } - - for (i = 0; i < dev->data->nb_rx_queues; i++) { - this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i]; - nfp_net_reset_rx_queue(this_rx_q); - } - - /* Cancel possible impending LSC work here before releasing the port*/ - rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler, (void *)dev); - - nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff); - - /* Now it is safe to free all PF resources */ - PMD_DRV_LOG(INFO, "Freeing PF resources"); - nfp_cpp_area_free(pf_dev->ctrl_area); - nfp_cpp_area_free(pf_dev->hwqueues_area); - free(pf_dev->hwinfo); - free(pf_dev->sym_tbl); - nfp_cpp_free(pf_dev->cpp); - rte_free(app_fw_flower); - rte_free(pf_dev); - - return 0; -} - static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_infos_get = nfp_net_infos_get, .link_update = nfp_net_link_update, @@ -244,7 +189,6 @@ static const struct eth_dev_ops nfp_flower_pf_vnic_ops = { .dev_start = nfp_flower_pf_start, .dev_stop = nfp_flower_pf_stop, - .dev_close = nfp_flower_pf_close, }; static inline void @@ -1221,6 +1165,20 @@ nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev) return ret; } +void +nfp_uninit_app_fw_flower(struct nfp_pf_dev *pf_dev) +{ + struct nfp_app_fw_flower *app_fw_flower; + + app_fw_flower = pf_dev->app_fw_priv; + nfp_flower_cleanup_ctrl_vnic(app_fw_flower->ctrl_hw); + nfp_cpp_area_free(app_fw_flower->ctrl_hw->ctrl_area); + nfp_cpp_area_free(pf_dev->ctrl_area); + rte_free(app_fw_flower->pf_hw); + nfp_flow_priv_uninit(pf_dev); + rte_free(app_fw_flower); +} + int nfp_secondary_init_app_fw_flower(struct nfp_cpp *cpp) { diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index c05a761..d82e35f 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -85,6 +85,7 @@ nfp_flower_support_decap_v2(const struct nfp_app_fw_flower *app_fw_flower) } int nfp_init_app_fw_flower(struct nfp_pf_dev *pf_dev); +void nfp_uninit_app_fw_flower(struct nfp_pf_dev *pf_dev); int nfp_secondary_init_app_fw_flower(struct nfp_cpp *cpp); uint16_t nfp_flower_pf_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 3ff54a9..b3359d3 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -561,12 +561,75 @@ nfp_flower_repr_free(struct nfp_flower_representor *repr, } } +/* Reset and stop device. The device can not be restarted. */ +static int +nfp_flower_repr_dev_close(struct rte_eth_dev *dev) +{ + uint16_t i; + struct nfp_net_hw *hw; + struct nfp_pf_dev *pf_dev; + struct nfp_net_txq *this_tx_q; + struct nfp_net_rxq *this_rx_q; + struct nfp_flower_representor *repr; + struct nfp_app_fw_flower *app_fw_flower; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + repr = dev->data->dev_private; + app_fw_flower = repr->app_fw_flower; + hw = app_fw_flower->pf_hw; + pf_dev = hw->pf_dev; + + /* + * We assume that the DPDK application is stopping all the + * threads/queues before calling the device close function. + */ + nfp_net_disable_queues(dev); + + /* Clear queues */ + for (i = 0; i < dev->data->nb_tx_queues; i++) { + this_tx_q = dev->data->tx_queues[i]; + nfp_net_reset_tx_queue(this_tx_q); + } + + for (i = 0; i < dev->data->nb_rx_queues; i++) { + this_rx_q = dev->data->rx_queues[i]; + nfp_net_reset_rx_queue(this_rx_q); + } + + if (pf_dev->app_fw_id != NFP_APP_FW_FLOWER_NIC) + return -EINVAL; + + nfp_flower_repr_free(repr, repr->repr_type); + + for (i = 0; i < MAX_FLOWER_VFS; i++) { + if (app_fw_flower->vf_reprs[i] != NULL) + return 0; + } + + for (i = 0; i < MAX_FLOWER_PHYPORTS; i++) { + if (app_fw_flower->phy_reprs[i] != NULL) + return 0; + } + + if (app_fw_flower->pf_repr != NULL) + return 0; + + /* Now it is safe to free all PF resources */ + nfp_uninit_app_fw_flower(pf_dev); + nfp_pf_uninit(pf_dev); + + return 0; +} + static const struct eth_dev_ops nfp_flower_pf_repr_dev_ops = { .dev_infos_get = nfp_flower_repr_dev_infos_get, .dev_start = nfp_flower_pf_start, .dev_configure = nfp_flower_repr_dev_configure, .dev_stop = nfp_flower_pf_stop, + .dev_close = nfp_flower_repr_dev_close, .rx_queue_setup = nfp_pf_repr_rx_queue_setup, .tx_queue_setup = nfp_pf_repr_tx_queue_setup, @@ -588,6 +651,7 @@ static const struct eth_dev_ops nfp_flower_repr_dev_ops = { .dev_start = nfp_flower_repr_dev_start, .dev_configure = nfp_flower_repr_dev_configure, .dev_stop = nfp_flower_repr_dev_stop, + .dev_close = nfp_flower_repr_dev_close, .rx_queue_setup = nfp_flower_repr_rx_queue_setup, .tx_queue_setup = nfp_flower_repr_tx_queue_setup, -- 2.39.1