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 6BF9741FC8; Wed, 30 Aug 2023 04:17:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73530402EC; Wed, 30 Aug 2023 04:15:59 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2090.outbound.protection.outlook.com [40.107.212.90]) by mails.dpdk.org (Postfix) with ESMTP id CCE4D402E8 for ; Wed, 30 Aug 2023 04:15:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VslU3MuAPjCEJmIIcBxb+2gXGAPZfC6vcaEQvMoz/7RwXJEsoVypg+qZ4ZFb/OHkXHaHt3rllazYOdgoPIcxphVIACXZflUKrQwp1+zjoHFtPGxe60JejfgfeWHnE67Ig7RukpTORsQ5ZFK3/aOxa14uEgYR/hiQwc0YnBRHmgEScZ8WHvicerhsg8y4OiyTU+EvcPppuO+hOmaqjnL4hajv+X3YTtMjQoOzqzRXeJt+It6cqXeIbRLu3qZ2cfOh1bWrQi3Mlj85vz3Sh9cMsq7uXcAJ9vGndJ5aGCE+VnbJRD8+JRN2gQFtHfokY4G8PbofCCvLEZr5lf8tNTnboQ== 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=DDNDgVkzzhDORW79TC2slL5gIiAp3b4gaqcVWnejs/1IiPLp1Pvli/xBnmQJoWtS71ZOUKQqJaTEDELiRr4smo7yEGAR5qDw2ztDfu1deYgD0drxn5+Tkk2TvZNjt/Ix0nKaxdxcXTYBHxawM3D2tJDyPJUIySMAjvyqdR/988tYglbFOYtODNyPZV9B7878g7CjZJjbm/Jd+CREY97ewZWcK3RKikBMBIruEILRyz+2s3dMTUl1giNVwg27Wcg+6/ZMsPAq3Bb7qcGgQStHMMaYRKxMkNSVPnQWhbjZS46NJ1E6jBdM7akWBEZsbKA55D6sIUtPjCWdRnn02GQgHQ== 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=giVA5fRElxhR9VuDxBNxpIMQF+GHQe8FhCv0My/hnZ0brooFD1ylXg2ycs3fahQDQF+UB4p+hXNyy/mgqa6BbN3d/m61yUUxjDkIOmPYrIsTpVGalLpIRAZYYFhTl6MXbJsGf97yQ05bf5SCNT9uSOevt0r2FD0h9kyW1kjGw0Y= 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 DM6PR13MB3786.namprd13.prod.outlook.com (2603:10b6:5:229::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18; Wed, 30 Aug 2023 02:15:54 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c0f3:c2cc:b5bb:4192]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c0f3:c2cc:b5bb:4192%4]) with mapi id 15.20.6699.034; Wed, 30 Aug 2023 02:15:54 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 16/27] net/nfp: refact the resource module Date: Wed, 30 Aug 2023 10:14:46 +0800 Message-Id: <20230830021457.2064750-17-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230830021457.2064750-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> <20230830021457.2064750-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH0PR07CA0113.namprd07.prod.outlook.com (2603:10b6:510:4::28) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DM6PR13MB3786:EE_ X-MS-Office365-Filtering-Correlation-Id: b9a45f1d-2d35-4dd3-a6d1-08dba8ff09fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: saZQ8NCDbjijLYdw8BSvI/fmqJuFJGYfe5pG2LGB/AkT+JAnlZtNHpdDKsakvrK7LQW7/pHBaRjEyZFRI6Z2ziQ7rpPASvOCgQh5HBJ0FZa5Avw3ILnlQKgRZnVD7TLWokP5sEp4OwC/bT0e8IMLsCBodNed6GZLYWS0hqSLPhsuDeMiXtpkjMbFP7DmM1SsBGbW6bibdAajlKlCjn2KKsSKNG+nM+zKxAiLU4gAukyhMxRDMjhvcfXIn1B5rh9hQ96UTI71vYnvDPLP5RHGGF0e7waI8RPLdhhcMf0TDInLqTKCUEnNW3U4SMl6STat+dHPPVXH9ArItm1iXuXOPkRfbFaF1QGDOaCGM76yXWt22Bc2LDyCOeLNYHYQxB7TJOtiBjltfr6PUl9fMLlj9bMvEnX8g839qTTxwbnEpTqduR1KPMe65/e0lr5jpsinYEU+O3HeUKZrTVL5cODg9thVuu1H6lJGbDrA2bd0rk59ksfeaCXsaTv4AdPunv3a998T9Po0CNEj0IuhnSsimgl3KDU4h2RCGJT8Oes1/GQJSsvk1YDKVDmzfPlgeKzFvCW+mgnJqAu7c1KDl9/jxrznSB93rN3e4Ecpd1/CE2fiMU+aan34Le3WXNGlhsr0U3JZRKhSFXFjlOR85lPlKodHsp6OvZrQ4KpXnyn1rTE= 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)(136003)(366004)(376002)(346002)(396003)(39830400003)(451199024)(186009)(1800799009)(6512007)(6916009)(316002)(38100700002)(41300700001)(38350700002)(2906002)(4326008)(83380400001)(2616005)(86362001)(44832011)(26005)(36756003)(1076003)(8676002)(5660300002)(107886003)(8936002)(6666004)(6506007)(6486002)(66556008)(66946007)(66476007)(52116002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RE5ackluc3hKSzR3VTlwUmxkSlJJZU1oV3dqamFqSE1HbW90Z0daUnNQWlZh?= =?utf-8?B?anU0bVI2aDNhMG1zS0RMeTVrQmRYbFZ4WmdoMjA2b0NUeURmY2VhZzF1OTlQ?= =?utf-8?B?WGVGTlA5c21wWUZBL0xodjRMQi9CQjdPWDZBbXlzb3R5RFkwd1l5Z0ZBYmNn?= =?utf-8?B?TWtpcnQ3bE5kMjhFRm5wbHhnbXlKRGZKaVB1RjdmT2hFeFlQZTNXLzlDOHVt?= =?utf-8?B?dUVqdWVqWnQ0K2xVb1drWjBPMnpsS205VFdrcUZGa0xHTUtBbEdySmJIOXRz?= =?utf-8?B?cVlNaFdobG12a0FKTXNQdUU3U3gwVHRCQlZlMWJnSzFpaFlOVHA3aHZ1THkz?= =?utf-8?B?K1ViMW5P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8?B?RXc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9a45f1d-2d35-4dd3-a6d1-08dba8ff09fc X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2023 02:15:54.4178 (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: IYtdmL+DoNNvqalCdFvX2nCHtnjAbueNIyyW11kvCowzQStxfUWhkzC1hQupLxiWTsckjiIft+9ADCI9eEZmY9waYegt1jb7TjDIPvtwr2Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB3786 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