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 7562442600; Tue, 19 Sep 2023 11:56:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C08A40A7A; Tue, 19 Sep 2023 11:55:50 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2125.outbound.protection.outlook.com [40.107.96.125]) by mails.dpdk.org (Postfix) with ESMTP id 2A08140A70 for ; Tue, 19 Sep 2023 11:55:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dbL5AK+mhkmsV5yfSzyugwLFb9KSALxiIB/ZVF9Y/yVjDavLqtNjT7n91ckMShegrNVA8NPmtyrdvq72GYIoE4yw5Fu2njxAveR943+dHpsZax1WvuoVIlY5QhjqiPf80kkkCdl1EVJLTyGJJlU3ZhNfsD2lUlsbmnIsZlRwsaYwTadcybywoaHQfKMIB1Z4ulETiOXosRkOQDX9+quFCHtqm3JBD361kwSVyeKuqY4bfQhITcENQbFQo3xPEAucYeaJZeBUuCBKCsqwUv5PHoJQYew/Oexg1mBaKM62NukZK5gLVQ0GdK68qUXrn6/Yn5/IddWbjXjhJcWWzuYq6A== 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=0XFQsboa05+NMmdpaLBgRUiXY3lgeexishQIqkvOWxw=; b=ioUrzei8qDgd82qzI8FhNAcAnsZ7NNFf4jwcbYvvDpkBjfjVoqukCsTcJEbUVlWdNcr4O+u5mkX2mcCJsSWVEYWf3GKwwRjkOjniChibuFfsocS6f783v99ncj0HbGD2wbpS2ztJelwNSxYaRBi2LIawTNnyq2Mq2YPzJ/dDlzFZWYKuc3aKNkCJzLlLtJn3jnwn2pFweoCwtSJiIwP+WmlQGkSuoKHgl2JzsOdqnssYCYWfL1Mxi+7a1pbfspio8bqx2aHrSVuuuHMUzXzSiEKYxct0DjHOW6Po6ouerm+wS36IY1uUS/KBFm+8fJvafKTLSku/Uo4bfHXwaJx+qQ== 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=0XFQsboa05+NMmdpaLBgRUiXY3lgeexishQIqkvOWxw=; b=aiCgKeZ+MqTalt7OlW4e0cS+EICURrhDhJsuKbrREqbNDsSZFWu9f8A3bAmuPuggBU0CUksI/Bvsntgdqg29nnu/+8kQQarhgdtvdwmpVmVXGBdc/jlkiJi7tKNYiF+0riolLnucKbyvE3/ZSCUjXmkaXYavltHw8JgBNfhKCRk= 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 PH7PR13MB5868.namprd13.prod.outlook.com (2603:10b6:510:15a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Tue, 19 Sep 2023 09:55:45 +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; Tue, 19 Sep 2023 09:55:45 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He Subject: [PATCH v5 15/26] net/nfp: refact the resource module Date: Tue, 19 Sep 2023 17:54:29 +0800 Message-Id: <20230919095440.45445-16-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230919095440.45445-1-chaoyong.he@corigine.com> References: <20230918024612.1600536-1-chaoyong.he@corigine.com> <20230919095440.45445-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5868:EE_ X-MS-Office365-Filtering-Correlation-Id: a4ca27d3-24f4-444e-5be2-08dbb8f69796 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2kW/Bi8DdqaMrwaLKk8XzXZCPwWbMpLXYS+Y8oSwZQ0xczZQm1tHJ/g7IzoacdlxnUJc4jeqUi8TKEvAsPxfnxl55ISb61VO+OUnaSxFHnxU772y51RSWYhhBmIFfxGHT2Ppo9zwI9KhedpjHk+kDuSqf3e4Q5PYvVhBiw7c6xo8MB0MoqUVJiiPx4pibkztrD4iXGR26sGU1xQLqBA1xypq1CmjRf45W6Topj8N588Dt3Yst6QPrwl3feiPz3FppkMfPCe3rdlPKpqZguOPXumpik4woODm7QokxYkA8nXnJ/NzpceMrSF0Aj+NbSkBpqJvWWkry6w7sjKEDOzjgXKN+1y0lOOcodVnJudx8aKShIH4pvxx/vlSjXkVz6z9cAFK+pyRdy1jj1FlS38ekZljG/GrV6A13BKPCHMpZNRWNc6iYRPVrnvZCXHbwqtyXdcaeNoKnI44A9tjT1jXu439pNikIdD92xqnM4i3BsZaK3+snl985aLP37cKHFnt1rQ0zrAwthzONeXwAb6q4SMvWl/35EHeDbnt40OruXrRsabSVz2Y4H8RBzffTnc0Yu8bIZkD0wk09LOvAEqu9zvTUsPVwM6nqK3K0uQqwY+o4pHdQfHJrjrBVH+UIu6Z61ovmTkUYwh99/IqpTfYJlHc+XprMOROR4EAHLu2XsY= 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)(346002)(376002)(396003)(39840400004)(1800799009)(186009)(451199024)(26005)(8936002)(2616005)(1076003)(8676002)(4326008)(107886003)(83380400001)(2906002)(36756003)(44832011)(86362001)(52116002)(6506007)(6486002)(478600001)(5660300002)(6666004)(6916009)(316002)(6512007)(38100700002)(66946007)(66476007)(41300700001)(66556008)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?3Y5B8DzAJ837/50RZWbpVr9FenvAlPwYw0ekobR3mydcNLM3uQfrmmv4oI52?= =?us-ascii?Q?OAfGW9jkg2wpFJBa2b2STIuGvapUfSO/sBF35YXr7B1bp1OmtDMm9w+aOPQU?= =?us-ascii?Q?3e4uxmi5HzzCKqXc0hvEk/6yqji9o2Fi3dsf+ojj5lkgLtgAZfGyr726hSgT?= =?us-ascii?Q?eRsUuM2vVOH/T/Qrb2kjQwnqz3ZkGGJ11CWVinrYTc+JpFopP+eNDWfxiRgT?= =?us-ascii?Q?cQizeIiOJEprjpzhkkg4SDabeymYgRtwS7FHlmu6oyLNZs1p3QGeCiVOu+wy?= =?us-ascii?Q?ZEgkA5xCdVPzCYgOGikzeN6VCSlSASZyMp9/P0AzVnqW9ltPmzesZ9zDMOIe?= =?us-ascii?Q?ELdkW+fs93pVw2ggWGwJVq1L7NTUYJsOVpXF7jNK85Vty9L6HJZaNYXY4fiN?= =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IOkfqDJaXynku7v4JAaMt?= =?us-ascii?Q?ad6NoCXGEpwALaeqgNQytpzMmqOlo1wDMyoGQ61sF0J6EvEWKtYbZp6d6Yw6?= =?us-ascii?Q?3ttw4tzbQ9AnD969tlSkvPPQW60OIJWiYrqyekPKTBpjc/HMFvrL61Im6mfv?= =?us-ascii?Q?5mfQQCCGDayZGoHGncGouI8sxS5nQILsvLp6eztawxtqBTVf2LbGYP8tmXnV?= =?us-ascii?Q?XpJG8gg1x6ES3iPkvjyTNC0stu/hloUlQKAvKRBKZ7J/tO5zV9DaceTP5nM2?= =?us-ascii?Q?4H2g0779qqNBrP6AW+6grBocYL9tuEEgTXb52yZKvW3KaC/l7wBZP5xhvYdl?= =?us-ascii?Q?3A=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4ca27d3-24f4-444e-5be2-08dbb8f69796 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 09:55:45.0591 (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: +kekz8sraL0LdjOqHvP4yQCrzKjnLsCv3Y7irQLUi0og8113pqOv41X44YJoZ7HhahMCvUW3oiTheKUVP9fVeSJ+EaJ2knzYEfuJHM+dwYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5868 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 --- 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