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 7F7C3425A3; Fri, 15 Sep 2023 11:18:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F0D9542D3F; Fri, 15 Sep 2023 11:16:49 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2139.outbound.protection.outlook.com [40.107.237.139]) by mails.dpdk.org (Postfix) with ESMTP id 2CF7742830 for ; Fri, 15 Sep 2023 11:16:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WFSVNYiOKDzGUUD2+JF4ilb6G0npmyClwDvum79LN07NRdPeWmM8HSRrJnwZuR7VvjUljh5txGHSnS5PhAfurmkESAG8hy15d/DbRwkbgSngkGH17752on4UU4624uvzRo0KMwei6HghY2u/4trX3Pw6/5cRe6Cgtf3FfsFfgiuLHdFG6JoHo5wrssOB8wRi4M7RGrRTZiiVERaLJDH1se6rfoydKTOSpDsxlahZw6NsPdHFUNMym/Ca2LSk86993Vx7/7r6D0tZe8NoJWjEQEHQ0JeaMhkaaB2hJmIjohtseCmd/3KF8gFjHUnzGjKLL9BeAgGNuUy9N5LImJXN4w== 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=KZRQG3/XGgh/3W3HFBFnLoZs+hBuYScU3Bc0TUHmQQNoVHx8w+reaGqX+ILbInoniV+IAQ3UELZBCI0jMp44uUiRCcWuo5Teih6lCbRx5UylzVZ4DpYwVo4Uv2eiMKjUo7bGb4UYzBCvSCnTpd5xJKx1kEoeD2FY2zANZkBejA+azB4bHE6g3b7QNSTdSwO+6xxc9yjkYa46K33AS2k2HQDvwSgkXd7zkmcrWZ+ybttN97bx+Tgs0hGS17Y+ld/JZpgPOZOLAFejo+zvLvI3IC3NejWDTstLpFNnvJXy70vDKn24JKyHucy4hf4X1Kciia9eA94PIxZUXn0gCkIa1A== 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=UsjfCMkPt/3/kL17sywwgRtLrObg7FnBKgnBQNuqQLfOZsq2HH86/YQ2xX+OMv469vf+WuLLDwtwkTdPLP1q+vglU+WafYwT7SCh6f301Cybg4+YPU/rymdl5FYdNEBqr3dUHln8MT4u4yBi72Jk9ui7xtmWWPmvOCMzuvOQPLE= 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 CO1PR13MB4773.namprd13.prod.outlook.com (2603:10b6:303:fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 15 Sep 2023 09:16:46 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4%7]) with mapi id 15.20.6768.029; Fri, 15 Sep 2023 09:16:46 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v3 16/27] net/nfp: refact the resource module Date: Fri, 15 Sep 2023 17:15:40 +0800 Message-Id: <20230915091551.1459606-17-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230915091551.1459606-1-chaoyong.he@corigine.com> References: <20230830021457.2064750-1-chaoyong.he@corigine.com> <20230915091551.1459606-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH7PR10CA0017.namprd10.prod.outlook.com (2603:10b6:510:23d::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_|CO1PR13MB4773:EE_ X-MS-Office365-Filtering-Correlation-Id: b3bcce25-c996-4770-9bf9-08dbb5cc7c30 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +LVDwP4uokXNYnxjtAk2+IbbIUQdubZ8gTCvKjHZjAa7N0GSXk6ZY+/09FIDjJsumS/zKZBR/v/Cl9VaaGQijlg3BMt6B9CgurMVrPcMOuXkZRHCIZIuTVezIcptXGpmR9pkZPJH1wrDBS7ZO5gKIV9IAManUMJ4Ye0h/xtyjuzBHX3RHhtFtx9tL4I+MT28jVhEiL3bI6jucvpBfbSeH0yqGSkqRNb+PDdFxQbxPnhN6xfMFXGg88yevSzhHTcdfUBdooqscz5lyHG/iBLWVf6oQBTh3oReZfdOJ0NDofHe6VEKT9urKB7pzDPH0h1D/Xt3/UMLbdYhOUnbzFk+59qmAoF9uOtCwKWs9lIp+xOXFxFAjXghXcB0vJ3z/PTfT/fqJ6io/deP+7C3TYVlQUtcl7xeZvTiSgTUM1UCcfKtX40fd5Xu+6YpS4xMcAoGXA+9o+XVjJE6CNxo8q+b3IWgFLU8xnWbAZWOWhAFFa46jwfbutNKnah45uTtVZq91MADIAxi84Izo4TKz7f2Po3qHLHnHW776qgDgkQLMV0g+hcMmTXuPF5L0/YPfQlQV9R9iGOupTixXyUdEVCiAq6bYihUhKAMAUYFen34drwX3YVFEAASnUmAOI/XzOhEQZ4zqqfDPYxzKIuKYgC83QJbg3aw72EyLJrY9UpXTSk= 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)(39840400004)(346002)(136003)(376002)(396003)(366004)(451199024)(186009)(1800799009)(6512007)(107886003)(1076003)(2616005)(6666004)(52116002)(6506007)(6486002)(66946007)(26005)(316002)(41300700001)(66476007)(66556008)(6916009)(54906003)(5660300002)(4326008)(8676002)(38350700002)(8936002)(38100700002)(478600001)(83380400001)(36756003)(44832011)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Tnl2SnVQNy9aaU9pRW56ZTgvRFAxSXYybVBaU0FuQ1Y5MVgrU01DcWd3NjJB?= =?utf-8?B?YmhJY281SE40R2tnRnpzUmVsMzdXRHBtNGJjcU1pd2QxQUs0U2ZkUTZ2a0Ro?= =?utf-8?B?UmZDYTZJbGFyTnpBNFJIcDRyVWNCdURFUnQxcHlib05OemJFWkhHNXI3RjZE?= =?utf-8?B?QlRPc2lGRnRsWnlkL05vT2hjQ2lkQkpTbHNRdW53NnM1SEN3ay9NR0JEdXZ2?= =?utf-8?B?OHZpTnhhMDlwaE9PZXN1VjcxcWJ3K1d1Z1ArR1R6d1BRQWxudURnNnE4VGJE?= =?utf-8?B?dUtIY0lxa2JpMXV6RDVzYmU3U0FPVjVPaFF1OHRJSTNFMXplVEhqenc1U1Zp?= =?utf-8?B?UldFc1FC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= =?utf-8?B?QkE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3bcce25-c996-4770-9bf9-08dbb5cc7c30 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 09:16:46.7572 (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: ad0zGR9xQcs6ykQtPSnQj4HhhTbRmpNR5yty4XvzyUSuqyCB9qBn77qfiH3926CHufoxFO4GG/zRyfzlHCaQcjUFaitbdpM6LH/gAW48W9o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR13MB4773 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