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 C0DD0425A3; Fri, 15 Sep 2023 11:18:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8AE3542B71; Fri, 15 Sep 2023 11:16:54 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2113.outbound.protection.outlook.com [40.107.223.113]) by mails.dpdk.org (Postfix) with ESMTP id CF79B42830 for ; Fri, 15 Sep 2023 11:16:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=irIfUMZ1ZK2LuLEEUlR93S7s9xcZFlph6/Mds/MI85qpETLAZdLeOzOz4NcBO5YJQlumQAPAm/u2EhFS+MdIq7kkx5yyN5bziNUAaiLBIpQFA4gtkh82uKCE9hvCXY0LGIbsgxz4yXLRLY6nG9xl9CtcK5GIOiqrLhfVlnygPLaQ27VCOUky5hT+IBel3um+zukf0UAailhzk8jSjDq/Oi7Q+RYU1mmFsDMXaPcfPxhS3p2ZeflIZIFIMji6F5K5zNbmg2FEO5JxGbVQpnm+j5ymIjmk3xe9tCwkQ1jj6TCInRZ/Pj/HfF3ojiU0lxxpClSWd1yn0MZOIvd7Yv7jyQ== 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=q16+IN2xi/GkmJ6ciaCjjDI3UZe3FwA9+0RN8yyh3yA=; b=KwDG2OpWoIiXFEMjmaR0drgUkiZiVw3MxqK8nbDhkzbVgUvof556Jl3u7cYYQqRuFSSjSu+qY37K5rvlLDoYPoocwgNElmeD9khukcVXYFVuNNam+MvYj+cOkXIjI+WcpU4xVihPY+ijyfDrJvwY6k9Cr2B5xk5jAITkPDzBXHp5O8Rfpqkf+LVNw4IGuPeYter46Ziivjfbq+eycr36xli569qwlJvTIgj+mLhumE/5eWYQNBJlttnxaikLonqmRprcmttqeZFuCbgrQsWiGfXKKkkPHgrokquM77chixp/DmbFlcz8pH1dcS+lw/qnaK/q6Z/Zd674D2D9o7j4/A== 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=q16+IN2xi/GkmJ6ciaCjjDI3UZe3FwA9+0RN8yyh3yA=; b=eJbViHryYiL8StmZ9Z3AUNiATDURBrzStNjmffVZmcnmF5lxfYOwHcI8DMRBCDpN16QiOdniO12159fKt3e0lfSSwxJT0xPQNalbJdIDKCHVUPfoch4s8wD04Ob7ZfSVw8SWkA/gX1CK32KuUQg4XWWByGajyIpejVA/QGBtsHQ= 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:51 +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:51 +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 18/27] net/nfp: add a new header file Date: Fri, 15 Sep 2023 17:15:42 +0800 Message-Id: <20230915091551.1459606-19-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: 100024f9-65da-46ed-aae4-08dbb5cc7ec9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: exVJ3ameaI4MPtmpTtLZAbOqxCNTPeGqFVTK3NFlh/h5OXsO+7O8EWgfY5VNyNWPgFTpFKUcrQ85XQL3/N9ZvdhefDgv+CKs5iiemQP6ihHUA5LM4tya42R4pBVxnpJfkZqPwLCdRJtd90veae2CO7K0tr2NsQsdEl+8JWGwElRPmP5zMmSGYXGIP3RbiG1+80lR6Eqr4VCLloTpzYBTbJ+PhNJHVbht29fgcUZpk74bbdjezH3Z+l0/BYeetb317N3yDALXfiJ1jpDdyhBkCwmnSws47FDa/0XhJKE1pg9xXM2hVf75AQBfAcMfpQHgjeXnCg1odFA5XrBEDXYWJqs5EqKFwrlXrRbmH4cQu00TJj87uMnk0GTxQ9K/6xLQjbKHFM8Cu/ppJifRKHhRu0RzguonyYMKr+HL6oQqpHuaVEyKy8PctluvBrqjTz4etuxqMkGOy454MW7phOmIMEjIuhOm6CYwG7d8Evs5iaEwF8N07yKJdyg8TUOzb/MT5RuUg9SWSjutjUI5LBEyctRpB7bp1KLbbAb43c0VyV/BqzZ7irvGyeyPN7BejgyYJ1x7FhZa2jrMehw144hNsRREoUdxq3dvTX0FXK339uxT6MYJBGjqj2bKMAkY3Qbmp5e5rIa6w8vr+eAXqpSIwNIiPtXHNrdihqeD+rGOvH0= 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?RWhBa2EyZlBKSkhPd0JEdVJDc3JQMWRlS1Njek5oWTVRMmJsTXE4eXFYVENF?= =?utf-8?B?S0VRTDAyaGgva0x0c004cHZoenFZRStYY1NZaWluQ2R3U0h4UXhvWlBEdzE4?= =?utf-8?B?T05iN1RkWjFaN084Mnc2YnIrZndTclJVRVp6RFNuZFNiMlAxZlJtQk9kbm1N?= =?utf-8?B?NTZvUXNtUHBYUm11ZjZaZG94cm1XU0RGZjdLMnZZQWxabHUwVDc4RHUrTWky?= =?utf-8?B?Tk9mRlYxYTBmVHV5ZEFpL0RBRi9Wd2xVcFhCZ2NEV20wU2Q2Y1NQSGcyalFV?= =?utf-8?B?bnFGRVRiY3pLcFZMTFpwRkhOMFAvU0llcTl4d2ZUMUhUdjZidzFFeUxVTmpY?= =?utf-8?B?RDl3SHkrSGk3c3FPV3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QXV3L1U2?= =?utf-8?B?K3c9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 100024f9-65da-46ed-aae4-08dbb5cc7ec9 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:51.4945 (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: OTZpTOX1MVLnesbSmPjbFnZIwP2ZeyMUGkgym+bovDtIZp/8BKnclQsuhcztDoWkzuIl44BpcYqcnuDfgjJ9zLxbKoxuJ4IlLO8DUzZ7M98= 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 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 7d8d35e3dd..dd17d0f5f6 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