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 A7DAB41FC8; Wed, 30 Aug 2023 04:18:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B518340633; Wed, 30 Aug 2023 04:16:02 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2103.outbound.protection.outlook.com [40.107.93.103]) by mails.dpdk.org (Postfix) with ESMTP id 449E540282 for ; Wed, 30 Aug 2023 04:16:00 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U0FM62dMwaTGhUordwEhbe2Snpm+dsO5E2lsMEZY79+HqMrP8zM0nD/b/39JSgFDWi68DPqYoNii9l1mgT2RMZB/esGRIoCuob+y1rrRkS35b86lbKxXzvZ+sPqLGtWqMxy+PjIOR28lL/1Ncy5mp7D5Ad2oJhw7WhLB/hwW3TBwmgtS0ilW7E+ZAmRwhwTNv5se04Odhl4ZaIOVzCKbX6XeNS59KhTY3PoX8fbhXY/2VBPqsV83qo5PhWwYqRXmvAU9GnVbc8ZA83Vvzyr3fJgXxDsx9wRnxrrKAZRaBOo3cDt6wN8sJzq41GRdha/JTmXOknZVIi/hjFdyRzx3ig== 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=0aHM4yLXTCcWNIn8Jyx2RCtuK4jOHLmq2srn9Qg0N+s=; b=YaTtMQxcmfdlUPj6O9y76LjDIRh217+CSnrNbKNzH5FRIf09bkAffFeGNh0AwLJ842sN69O+y0XUIaoEzyqKD1fhUX9r3ZMOO9PnU4uMfZGgp3nk91O4vETnLmtHURyr1RHzPsnsXL3m77acLivjVXcK44LOXYGB6A3iXFx4xg0NsonurhyjEF5uDnz9RPkBPGWbcjVSmeRlmZXajRXV4xKadet0exD6VF1oCqtx3B59j/hhK3RGXWGQLsNL1ai6zNJmQa6XvTzX6+bhpOU0rxCzxGHFfrZYnhsOO6nhJu+nB/03+arTeEBDAKKTiDPTwi4En+jRd/TAw3WwKr/6/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=0aHM4yLXTCcWNIn8Jyx2RCtuK4jOHLmq2srn9Qg0N+s=; b=IMCDvCRFRFuxSAeqBGMPLI0J3Ag/Xf5+kNABqOfx3UT3HvdFGMCw9JirM6Dqe4nJyYFn5hIwDBeaMdd02R2T7JOh+osfK9hI6YgDnVkrrIXTra2s577dKEY5njfryYCGWO4Hm9y7CDVhm3UpM0Uo0/anxTJSlroZUDve0YPylQ8= 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:58 +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:58 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 18/27] net/nfp: add a new header file Date: Wed, 30 Aug 2023 10:14:48 +0800 Message-Id: <20230830021457.2064750-19-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: 72de25f4-26e6-4b06-3ec2-08dba8ff0c9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0GdGpD3QXWP+HElnOe1jjGX5GCKcAGbo/imFQuJzVdIWkV4h3cugjJ5M9uOaNEYXf6zOpuBlxZd2Xa3mBU5gd1p3vO4qhMSY87hfsktDesGcLOicRCpE5OEYKgHdeVwh3nEZftCKu6vNBhCwZbfpMLPkVc21WRg1pogDEMVDnnwe6WHgMPTLug2vvbVezWXDop8U0I4uzRGwd3NKzskCPfs784cdnca2EAjYNM79+nBGYnpgDiAwS9azXCMej4coSJJi05DzBS62Br4cP9AaGx3Wryr6yNRjE78b3KBHdAG0ytqug7uodNf3369KV73TNk5vuN6rFfRIH/Suhsx0XAk2/6FqFtk4QnhiezyGYajWHIp4cYspCJwSfGFKjw6O/03C9gP6YfKxZ7XNEqmMr1PMFg30au+9Lxnfwi3WqDPigxcjCzt8HRfvrXFVP533yRhrA9y272Ik4+hGe9NX0VQ8xIMz1heh1D3wZsTIG9xjBjiFkzIFyBYCd5HjyKNVs8m3xQUFWXg7ENg098+4bzBOq+tdXUdDw7SZGWynRbmAlfCKx6JjhSer+2pzn3s48BzbUfxXOkZmxWnlmow5LhfJw/0U6QmE7Hj1dVPTFkL7VQwiWa6x7OowIm2Fkat1oAmkTQmpBuHtqw9J5+qqig== 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?SUJldHlDNkMrRlNyUEFwZkFZRFBVNVBqaGloSThlcDNLdmVUY1pHT01NT0ZK?= =?utf-8?B?aXdGQWpUYWNocHFvbzN5ZG9KbjhCbXFNR1JQSTdPb0ZVNzcvNmgzUEJBQm9E?= =?utf-8?B?eWJGR3c2NXIyTFozMXdURGtkR2VIUjhDcGREK0dZMHRibExFdWdxOUFiSEhF?= =?utf-8?B?NGJyMXZKanJPRXhteTRkS0k4aXMrVWprNnM1UTEzMzE4MFpReDFEOGNvU2hP?= =?utf-8?B?UFZZcm5WRUs1YzQ1T2M4MkRzZDFCaTFIMjZrbEY1azQ3YkZ5YURkQ3liZi9k?= =?utf-8?B?L0xpbG9ZNXdYYkJzMGhuVmlFU1lmZFgzQ1I2dEU1a1ZSd2FFckd4V1Q3Uk9Y?= =?utf-8?B?RmRPN2ppY204M21jOGkybVF6MDlrZmFiM1JaMlR1RCtEVl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9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72de25f4-26e6-4b06-3ec2-08dba8ff0c9f 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:58.8334 (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: 6qPbcA76JcdK5gAjRWx7yCntO5+abWn9cpGij7375RsS9NYO83St9IxPyEP8Wk43h7Bzg9/sA/63G4MEzrMmKu2+5GO0j0C2WrXPGGg11dU= 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 Split out the macro which are not easily find a DPDK substitute into a new header file. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfpcore/nfp_nsp.c | 1 + drivers/net/nfp/nfpcore/nfp_nsp.h | 23 -------------- drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 1 + drivers/net/nfp/nfpcore/nfp_platform.h | 42 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 drivers/net/nfp/nfpcore/nfp_platform.h diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c index 9bb344aa5f..8e65064b10 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp.c @@ -13,6 +13,7 @@ #include "nfp_cpp.h" #include "nfp_logs.h" #include "nfp_nsp.h" +#include "nfp_platform.h" #include "nfp_resource.h" int diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h index 705574b900..14986a9130 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp.h +++ b/drivers/net/nfp/nfpcore/nfp_nsp.h @@ -9,29 +9,6 @@ #include "nfp_cpp.h" #include "nfp_nsp.h" -#define GENMASK_ULL(h, l) \ - (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (64 - 1 - (h)))) - -#define __bf_shf(x) (__builtin_ffsll(x) - 1) - -#define FIELD_GET(_mask, _reg) \ - (__extension__ ({ \ - typeof(_mask) _x = (_mask); \ - (typeof(_x))(((_reg) & (_x)) >> __bf_shf(_x)); \ - })) - -#define FIELD_FIT(_mask, _val) \ - (__extension__ ({ \ - typeof(_mask) _x = (_mask); \ - !((((typeof(_x))_val) << __bf_shf(_x)) & ~(_x)); \ - })) - -#define FIELD_PREP(_mask, _val) \ - (__extension__ ({ \ - typeof(_mask) _x = (_mask); \ - ((typeof(_x))(_val) << __bf_shf(_x)) & (_x); \ - })) - /* Offsets relative to the CSR base */ #define NSP_STATUS 0x00 #define NSP_STATUS_MAGIC GENMASK_ULL(63, 48) diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c index dbabffea9c..355d907f4d 100644 --- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c +++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c @@ -9,6 +9,7 @@ #include "nfp_cpp.h" #include "nfp_logs.h" #include "nfp_nsp.h" +#include "nfp_platform.h" #define NSP_ETH_NBI_PORT_COUNT 24 #define NSP_ETH_MAX_COUNT (2 * NSP_ETH_NBI_PORT_COUNT) diff --git a/drivers/net/nfp/nfpcore/nfp_platform.h b/drivers/net/nfp/nfpcore/nfp_platform.h new file mode 100644 index 0000000000..fcac6b05ff --- /dev/null +++ b/drivers/net/nfp/nfpcore/nfp_platform.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Corigine, Inc. + * All rights reserved. + */ + +#ifndef __NFP_PLATFORM_H__ +#define __NFP_PLATFORM_H__ + +#include + +#define DMA_BIT_MASK(n) ((1ULL << (n)) - 1) + +#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) +#define BITS_PER_LONG_LONG (__SIZEOF_LONG_LONG__ * 8) + +#define GENMASK(h, l) \ + ((~0UL << (l)) & (~0UL >> (BITS_PER_LONG - (h) - 1))) + +#define GENMASK_ULL(h, l) \ + ((~0ULL << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - (h) - 1))) + +#define __bf_shf(x) (__builtin_ffsll(x) - 1) + +#define FIELD_GET(_mask, _reg) \ + (__extension__ ({ \ + typeof(_mask) _x = (_mask); \ + (typeof(_x))(((_reg) & (_x)) >> __bf_shf(_x)); \ + })) + +#define FIELD_FIT(_mask, _val) \ + (__extension__ ({ \ + typeof(_mask) _x = (_mask); \ + !((((typeof(_x))_val) << __bf_shf(_x)) & ~(_x)); \ + })) + +#define FIELD_PREP(_mask, _val) \ + (__extension__ ({ \ + typeof(_mask) _x = (_mask); \ + ((typeof(_x))(_val) << __bf_shf(_x)) & (_x); \ + })) + +#endif /* __NFP_PLATFORM_H__ */ -- 2.39.1