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 7726A425C9; Mon, 18 Sep 2023 04:49:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE9B441149; Mon, 18 Sep 2023 04:47:44 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2113.outbound.protection.outlook.com [40.107.244.113]) by mails.dpdk.org (Postfix) with ESMTP id 249B3410E6 for ; Mon, 18 Sep 2023 04:47:39 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DfcOSXQThGG0N0Pxsm8t3rjU3pcmc9mHEd5lj2EbHsvWneHrSCoDh20ienX2iTUStojUGlCfDahFfB9DuCcNQ2Zz4dR/bcJANPH6TMmBaU5y2T3sMced0lA386XCsdUrq3TQbmV9YmBh3/gRNM8bfBW5lgu0s6jn3mnC5oN6+pUP6Rj3/3tLD3EEG7gTSHC/gcFUO4OkSTEozGZpyFhLTbBUWrKsP1olHAkpSn8869MVykt3aH5gsMimdA0G239rQx8RTafwUiRlXNNNbykolR2S70zP+qgaKlvSv63iPeLVPfRJMq/4fxZ45hbRoX8cCKbORYDaaPevpbAMBfFYRA== 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=BJoNp6A839VbF5LvaSGqGRDg9h1LHD/biHMEefc8G00=; b=QGQEvnEyEe0q8alryka1sEpuIGp+YvH7gXi3Br9KCc/vYKidUUdAFEDwOhcEy19yKEodWS8/O3Mv2dHvdjTmCq9Ho8up9IvRxilLiDLxb9gz1Xlrm3BFYgwYJz3jhA2ykzhtnV7HQWlCW0qjLJ/FEvaMvyLUd68bDqnlM8U5X2lk6j57ZHzJhXbcKbwZ1+z4DEnF3oF1FVxGdWZ6HpiNHxaNOm9rfXYzjAWc5v7Yy5RFH0I99ROBcxRNMM7JhOJscOz8Xd7gknPJ0PbASjmTigYK3SYTejSS0Qofs87kmCqaCRTkprRrhb5zmnO+xDNQOOu5KNBVm8ky77uCnzV4Fw== 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=BJoNp6A839VbF5LvaSGqGRDg9h1LHD/biHMEefc8G00=; b=GCj3JDEB6bY6hv0JWBxzUisHKTvt9UHpUVtFhn1JWU0eBFBkOx8l8PqQubYhpsuF/06NZWKNNUs89jpELN57cqwnXbLzkuyiYPtajlgkqtov4+/6+G4mv2+fp38r6dWPedqj4eQOkIk9FAWhFKwosvHPyfkTz7C82Rs1HTwZXgo= 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 PH7PR13MB6435.namprd13.prod.outlook.com (2603:10b6:510:2ea::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Mon, 18 Sep 2023 02:47:37 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd%6]) with mapi id 15.20.6792.026; Mon, 18 Sep 2023 02:47:37 +0000 From: Chaoyong He To: dev@dpdk.org Cc: Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v4 15/26] net/nfp: refact the resource module Date: Mon, 18 Sep 2023 10:46:01 +0800 Message-Id: <20230918024612.1600536-16-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230918024612.1600536-1-chaoyong.he@corigine.com> References: <20230915091551.1459606-1-chaoyong.he@corigine.com> <20230918024612.1600536-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SE2P216CA0016.KORP216.PROD.OUTLOOK.COM (2603:1096:101:114::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6435:EE_ X-MS-Office365-Filtering-Correlation-Id: c8fb4a00-86d4-4899-be38-08dbb7f19e65 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aE6knkr5GB7e1oTdSouvHMv1POJ/TJqo2UzcY7hkb6gz1xG1xQqwRZvtVudUxWF+pa91XAf2lgyxJSR31wIDJbqa8L6XlOijVwqjXJK95U6hYWmjL9QVaECNIpUFQauvNn4ySGeH8GY8MGY21pYiLakMTNjG53/Mq0w/KCpFGWqPzqEgRxcJKgyNyvGjc9H2t/9jpJ3E+ZRPJOZWR62OYDqo8SO348WJJfEodHrn/TsvGGAGgW8ke2kvjvuaFeYYa5JQwWNPUEY/lEH9DFb4hQs2CE3wLWr/f0ycQGm0teamhPDp2c8l2DG2eREc8+e6g4RGN+ys2//rPcHWQFckJGVk20BN0s/RhZDkMHw3YA0RchBwnHhyEDE0uY4EDYvH9XleeZH4/Narfc4galt0CJ04U3Q50MQQxkqeUdPn3eNKtIBpgdMqCL2+QIiuIng/zIrUe+x7zW3vNvAK+ja5ZsGkoM9V5tM53aSo4Tl7oad4FFB4zXgORd3ej7MEaVHpNYloK0u6nlgJGD8EE1bB8MviUF2MOMOOX7wiMDmFiG4s8LavBwurCHJkrJXs8Gg0ZRpBy18Ds1sEyXf9TPBuAcj/HXhVkkjW6m11knPk0ANSIxENX/htoANmTKeXGxThhOSgAauFi3WZrNgJpn9WT++4uXJP15YaoJCpIsG5FY8= 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)(39830400003)(136003)(346002)(366004)(376002)(396003)(1800799009)(451199024)(186009)(54906003)(66476007)(66946007)(41300700001)(6916009)(316002)(8676002)(4326008)(8936002)(52116002)(6506007)(6486002)(6512007)(478600001)(6666004)(83380400001)(26005)(1076003)(2616005)(107886003)(86362001)(2906002)(44832011)(38100700002)(38350700002)(5660300002)(36756003)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?THhHcThldkJ6SHRtdnBOSXU4c3JvVWdyOW5jMXE0aW9QcHdpSEJwYmVEMEh2?= =?utf-8?B?Sis3Qll0U2oyRmVDUXhpU3RVS0RQWDkrRk5FWGhuV3djaVN3VG1QOHJKVUR0?= =?utf-8?B?cXVhbTNHTkYwWjZ0SEpuSHNHc3V3WVVqOGJwVDhrMlJoSUlXaWNmTkFCV2N6?= =?utf-8?B?dVBUMFB5TWx6aWM0UXVOZUJlVU9rQlJ0aUpqRXVsb3NURVV5eGM0SXhwQmdO?= =?utf-8?B?REFEbUxxTzBvZTV0VnR4TTlUQkJ0MEd3Z0ZObjhtTXNMQkdKT3U0SHBlVmVH?= =?utf-8?B?SFNtNlE1Y1JvUXVQWjNxUGVSSEdtVHVpK200YWhsOVI0ZnRoL0laaUMzL3kr?= =?utf-8?B?R3pSYlJIcXRxVVc0dlF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utf-8?B?eVE9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8fb4a00-86d4-4899-be38-08dbb7f19e65 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2023 02:47:37.7225 (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: PAtxh2CLpmT1wunl7iymSnmKKPkwzM7AFBln7iGI8Z240+htzGQZN3FT7e6taD4DSLlvBs75Ur802bP06iLnHT/vdVPOjPyJzdr96MpAYLo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6435 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 54bcc5f234..c0afdbfdd2 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 { @@ -175,8 +171,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"); - free(res); - return NULL; + goto err_free; } wait.tv_sec = 0; @@ -188,13 +183,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); @@ -204,8 +198,9 @@ nfp_resource_acquire(struct nfp_cpp *cpp, return res; -err_free: +mutex_free: nfp_cpp_mutex_free(dev_mutex); +err_free: free(res); return NULL; } -- 2.39.1