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 E1748430EF; Thu, 24 Aug 2023 13:13:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7576432B9; Thu, 24 Aug 2023 13:11:19 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2095.outbound.protection.outlook.com [40.107.93.95]) by mails.dpdk.org (Postfix) with ESMTP id 33CB1432B1 for ; Thu, 24 Aug 2023 13:11:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJshT83nq0PYMAPg/CoFLXh62Ms3OeYVXlL97OEjiPhEXaBP8TyHlhoMBoh8Ebvg6aktxqug2OUdjADa/mceHWC2fdyyhQ3wKtUPv6TUTRHIA5+Mpn12xpjn/cYKiHTTmhvzApsNBkSSHGkvQQAtwEXI1rhedhkzP4kTKL8SYMeEzxJ+3PQtpbV118MNSXb42eXXs+EsGa5XDSx7QC9gkElalnnYLZWkt+Qdyxn1i3DtC3/edA05i6lPFtCi8n/ktUynD2ax/XGUhb3YVGlhc6qiItf5zcI29QJPZ5d84f/TwO85/6kDLWoEgsogBzYn/XLW7LfUTy+g7bIpqIiFUg== 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=ptn9ydJjsqic/wGlPp8i1tyd6DcpDIJXBUlOIsCv9ts=; b=jhTipzK30KgKZb5raannXWlj1fnMObIIYD2TGRwGUQn5ak+3l38nVwXoRR/HfvJMTa4/mqdJAH35b9IADHv9MYMWiCBNwWwW0COkVaiJXzgVxHSNcC0hXSLP2h00HpuBIEEZ3aNKRKEoRbhsdFAQGeeAYrKR/xl8etP7Vjm8aqUoveBWBJwl8klVe5GnAelb8xKrdQQ6/5bjhof6LwbrcDwYq/d3JK2cAEsraIdUMq1iVcQ9e7RUx93gESkFbvORfg1PjRlZf8b0NRpO0KYGcSZyf13xBH2L9swezyG6hIMGeF1fgh9Sl/sKN7Q+eHdBwDgDV2zXDdP6LkgGPadH+Q== 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=ptn9ydJjsqic/wGlPp8i1tyd6DcpDIJXBUlOIsCv9ts=; b=Lxfne7wK5V7GB4BAGVCPKyj0hz05A8lczBHEyWhsyqswpnt6vWRk6lLRnGg3jUgg846EpyPV4teSWtPj8R/KMlNaahEV9k/tlewgbXDfZW5e6mTN+khCbcIXiZa/QTYnehEGULHaqGJPT9m3Y4UprNrAElvh5cDx3q7a5TqK+pw= 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 PH7PR13MB6116.namprd13.prod.outlook.com (2603:10b6:510:2b7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Thu, 24 Aug 2023 11:11:14 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace%3]) with mapi id 15.20.6699.020; Thu, 24 Aug 2023 11:11:14 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 16/27] net/nfp: refact the resource module Date: Thu, 24 Aug 2023 19:09:45 +0800 Message-Id: <20230824110956.1943559-17-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230824110956.1943559-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR05CA0005.namprd05.prod.outlook.com (2603:10b6:a03:33b::10) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 67e40506-9ff5-4f15-2535-08dba492d4b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lPwg+TqAOh0lR9/+rig4yPLNYBCQdzfZZ10kxwWyhwHHv6Y/x4P5YigDaK5awhObrO0nmmOSAjc4lB8CaeQeu3xdTgLLlXDugwTA1qzn234RsSk9Y+UY8ldTS1HCTdGbLgJHfKGCw7qNnHlsL+RJeeYktZk+6avbS36d3cTvScSGFmrVbJWHU6GDVOOpxyPmx4DqrQ7oWOrEz0+cVz9uIi27e4QRgRdX73pp0ndxUBlMxWesRJKLye+Jibjp9C8FQvMhDR2SxIkWtxKsuVKeVxY0hpn2WpbUcmr20v41N94roSuchFZMQihsknjQNV1fxTOU3Dnw5WJwoOUncmaVVs3RHnSaMoj/SLqf4NLHl68DWQtjIUobjBEwC2G/JHvPXmKzGcLB3PDM9hHU+Wg7kWLsexAt9PoswdRnGfawWOXL3GwXbdEJsI4LadNyEmF4yPgmrojGlkDpJsNPKcWr1kAoLErsCjTTYouttS+bvfeHPOYD21K6bQ+at8UbBuMl7c/w35xmsrHWZskz5sNCnLXsT+PbArZNRnngS/p4Uhm5ZO6e2bMCfjkRDZ04t/Co8DCWmGFaQSm8TNm1g2Jc8OhT8vA41b8GmnrKuKS7clTEa2J+nAoBYVd6evRYc9xQ7qhRrLrDi5FI6xKoy0aZB6cm8UQMlEHTtQU6Rsfv9mJxLg+akWwqr8JKhgG+4JGN 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)(366004)(39830400003)(346002)(396003)(136003)(376002)(1800799009)(186009)(451199024)(6506007)(26005)(1076003)(2616005)(107886003)(52116002)(12101799020)(6512007)(6486002)(83380400001)(38100700002)(8676002)(8936002)(36756003)(316002)(4326008)(41300700001)(2906002)(86362001)(5660300002)(44832011)(38350700002)(6666004)(6916009)(478600001)(66476007)(66946007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cDF2bVcrdlhTelVtSUFzeHVGMHRlN3gzUjAzUGt5ZjEzS1JUL0xGOFN0ekF5?= =?utf-8?B?d0JWQXl1SW5jVDdHSUZCRi9tMTIyemVZWUJMUWFDcWFQVndCMnJ6YUdFNG1x?= =?utf-8?B?NENFSk9aTEp1dDVzMWdzY29BWjZpNld0K2JZOU0wczB3N0pWSUFMaWRWNEc5?= =?utf-8?B?MjljUE9xUGo4MzJqV0k0c1UwamtWYUlUb0lqSUlhNlE0bFlwTng5cnBLQ2Uw?= =?utf-8?B?a3VZc3plOHUxdHF4cUVPOXV2WlhERXlYM3FrUTMzSTUvdjBYaERIR2VhWkx4?= =?utf-8?B?V2dUa0MzZ21VWTFiRHVUYzJSZnV3bDF2SEMra3JuT3pzc09vdGIrKzBoQksx?= =?utf-8?B?bXowV1NxR1laOGdiQkJHZC91NGhnZTZwZTZue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g: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67e40506-9ff5-4f15-2535-08dba492d4b3 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 11:11:14.7765 (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: PIEsmdw2oIHSaUvnavtlmcpPnExJOxQ1nmy2ZhYeXpcuirATexY469CI/A25KuIuv873mq/3eQ+DmaT+VPifZdZexC7FPBVpyqOpdVPRxR4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6116 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sync the logic from kernel driver and remove the unneeded header file include statements. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfpcore/nfp_resource.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c index e7e232eb4e..e4a3a42eea 100644 --- a/drivers/net/nfp/nfpcore/nfp_resource.c +++ b/drivers/net/nfp/nfpcore/nfp_resource.c @@ -3,15 +3,11 @@ * All rights reserved. */ -#include -#include -#include +#include "nfp_resource.h" -#include "nfp_cpp.h" +#include "nfp_crc.h" #include "nfp_logs.h" #include "nfp6000/nfp6000.h" -#include "nfp_resource.h" -#include "nfp_crc.h" #define NFP_RESOURCE_TBL_TARGET NFP_CPP_TARGET_MU #define NFP_RESOURCE_TBL_BASE 0x8100000000ULL @@ -43,7 +39,7 @@ struct nfp_resource_entry { }; #define NFP_RESOURCE_TBL_SIZE 4096 -#define NFP_RESOURCE_TBL_ENTRIES (int)(NFP_RESOURCE_TBL_SIZE / \ +#define NFP_RESOURCE_TBL_ENTRIES (NFP_RESOURCE_TBL_SIZE / \ sizeof(struct nfp_resource_entry)) struct nfp_resource { @@ -173,8 +169,7 @@ nfp_resource_acquire(struct nfp_cpp *cpp, NFP_RESOURCE_TBL_BASE, NFP_RESOURCE_TBL_KEY); if (dev_mutex == NULL) { PMD_DRV_LOG(ERR, "RESOURCE - CPP mutex alloc failed"); - rte_free(res); - return NULL; + goto err_free; } wait.tv_sec = 0; @@ -186,13 +181,12 @@ nfp_resource_acquire(struct nfp_cpp *cpp, break; if (err != -EBUSY) { PMD_DRV_LOG(ERR, "RESOURCE - try acquire failed"); - goto err_free; + goto mutex_free; } if (count++ > 1000) { /* 1ms * 1000 = 1s */ PMD_DRV_LOG(ERR, "Error: resource %s timed out", name); - err = -EBUSY; - goto err_free; + goto mutex_free; } nanosleep(&wait, NULL); @@ -202,8 +196,9 @@ nfp_resource_acquire(struct nfp_cpp *cpp, return res; -err_free: +mutex_free: nfp_cpp_mutex_free(dev_mutex); +err_free: rte_free(res); return NULL; } -- 2.39.1