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 35F5E430EF; Thu, 24 Aug 2023 13:13:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E2E1432C3; Thu, 24 Aug 2023 13:11:22 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2126.outbound.protection.outlook.com [40.107.93.126]) by mails.dpdk.org (Postfix) with ESMTP id AD8AE432BD for ; Thu, 24 Aug 2023 13:11:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CWdPBxJXEj0Ou3gf+SqkcCkMoo6TBjllS8HZlLNfSsXbpY049XdFB0aFbZPHCjSnDFb3yOBmQiMfRoYhkwDzp5QRCuS6fIt/HHGdd6oDeNHRhvU9KAg1+m+AY5B5lyWA3a39PiRqJoNEkUKsnkgIrDF5X+4GoM49LB8V20j31MAFtT/rus4g6u3M2ejuNk4tLoX3tNye2MCP3q4KzyFfr1EBUKmw0dJunZw0gfYbG+M8ZPlhsCxYoq8APlg9FXnV239qApWTkBYT4mSCtQAuoxf7qxD15TtjS5P0OQ+NsqNwJcjWlPv884U65mwK9byw/t1roWYSNDHZwVKlMtZb0Q== 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=J9jP4yDVScmj8iIQZkkw7+3LBDKxSFbXDfgUF7FNSyh4raxfWEVchZ/wq+wGWOZw+kG8B5b7IfH4AP2/wxT9SBwjZ41lAh0jjK165NXgZ8E+XkZPC/2Kv98RcWBbbNOts3dIlNu9b6teHvvSpkRssaKgzTxo/mpnFFS1/FeeN3J1t4Nm2EtMz8CtYE9UM+S+ATZ3R+EtXHRYoLP/Ua/veTUDH+oV3vqoldvgCk8M3UutM8Xlb04MMZ7lnRMg3OWGZew0qGsyGrnyegbc35wgaqiiwJdL9OebIA5hoObXuaWTpeGmS/FTH8GY+WYqW3qIabRRwaLG1sZ0QqWddAgTvw== 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=gqokdvaDex+cTN7lS+V4Ybgkx94FOyQChYN7eB8MsazNEhGYAk/LqN3910he6cc0P6SlnOrxvNHGZ3l6bbqCFPUK8QDqaou4FeEXCnzfaPBbk/F+XIAEe8aJBUnbIgBjA2QrGAeSWpf9hHNfcFAnrvuz0uQAAK/Jb8YoDNdKnes= 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 PH7PR13MB6116.namprd13.prod.outlook.com (2603:10b6:510:2b7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Thu, 24 Aug 2023 11:11:18 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::51fe:5846:af8b:bace%3]) with mapi id 15.20.6699.020; Thu, 24 Aug 2023 11:11:18 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 18/27] net/nfp: add a new header file Date: Thu, 24 Aug 2023 19:09:47 +0800 Message-Id: <20230824110956.1943559-19-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230824110956.1943559-1-chaoyong.he@corigine.com> References: <20230824110956.1943559-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SJ0PR05CA0005.namprd05.prod.outlook.com (2603:10b6:a03:33b::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_|PH7PR13MB6116:EE_ X-MS-Office365-Filtering-Correlation-Id: 13f63055-2ba7-4ffe-41a4-08dba492d6d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SLt3Cud3w8yB7gFxjTqk62kS/cm3M/Qsaby0eTNxqpO/nUlz5XezXUwvYmT6j2bgOYMHkFaf9lQ4oM3uO3Y6wzFWRPC9UXWD/gvOu5i8SsbwRg4BIAM7QOiRfdG0rSn681VmwlODGa1YtSBHNIMgiKkgzKrQjlWtBrMSjmhEfxKQTVdaJIYens5DRCDflkZk7AaIW7Q0y4F5q7o35VU1uZxMIYv8a/1iPezkeQ9K5uenoGPHekdS5omXW5/RiX2XTnXgQMdHgsQPBbhP7rlpeCFSqeEic4PTMy0sQsVBm5+qF32vbWUh8mWy41XgE3lvKtBYC6gsQTwYYOp7N3w3WLE33FvWhfEAoiEx3voPT9X5/Ah09fqQzmrpkd14KM68glWq2sNPZJ8XwvcoYY8SfaDAY1rNcqAteOCLOFQXrjG0U87bAcTwHjL2IfT/RD3t0I0HrSxTqbh8h7A76/8Rx6C+CPUnV6F+LokFSnVNikXVcn2QrLWzlLvZI7pHWMUmROEe2kaitrNpdtJZrxbZuDkFhAbuCfJDHpMOYQUM/uBDNwa2qTTImb95Yj+UEqcfPVFRmto42q7flo31oYU10lc45XBOCEHGzsZmW8qYfQb7U9rjmOVdfFMAxHpAYBCHbOdkiHXKZ9xmmZm550LpIyS72wZ1QqkJiVgPO4mreRz86ZDY3Ldvh1g/TTUCbgO3 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)(366004)(39830400003)(346002)(396003)(136003)(376002)(1800799009)(186009)(451199024)(6506007)(26005)(1076003)(2616005)(107886003)(52116002)(12101799020)(6512007)(6486002)(83380400001)(38100700002)(8676002)(8936002)(36756003)(316002)(4326008)(41300700001)(2906002)(86362001)(5660300002)(44832011)(38350700002)(6666004)(6916009)(478600001)(66476007)(66946007)(66556008); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Q3pDa2szNjVLTnBuTjlwRlRCY3o3alEvTHZ5YWFlYTFNQVozSmxXekhKcHZk?= =?utf-8?B?aGlkUEN6RjZsZUljUkVDRFQwNEJxOUdFc1Q3WC9FckJKRlVCYnZDQ3lCMHhi?= =?utf-8?B?YXdQK1ZKT0RuS2dPVHJZbE8zN08wSGhIajRvZ0tTYkpROHBDZTJBdmNvNEF1?= =?utf-8?B?L0pSQ2lVOGVUVUVWL2JaRzBKbWszczE2Nk9zYTdyd1lVbCtRUFZxSElhMGVv?= =?utf-8?B?ZjJ1Y1ZzdldXOTNUemppdFdoQVpXdFZPbFd0bjN3VWhsVjRlRENJeTlaOE01?= =?utf-8?B?REpFcXYxVWY4WnFTZkJ2Z3JscFJIeEdxL3ozTmJuSlA2aWpxQ1YvbEpKWmpB?= =?utf-8?B?S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1BMnBwV2h5c1hjdW53eXkzM3NKd1Qrcmoz?= =?utf-8?B?Y3c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13f63055-2ba7-4ffe-41a4-08dba492d6d0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 11:11:18.2462 (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: FQQn2Jseayq8LDOKSxmv7t1IAXWbAG/ABA+zzfUgPDtKehdOJ9SoXUsiKMjs2vPtdSWkJY5UWNW+vDHUBcR4pNQqYu55AQ5CRynIiZYP3rM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6116 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