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 126CE425C9; Mon, 18 Sep 2023 04:49:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80962427DB; Mon, 18 Sep 2023 04:47:47 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2095.outbound.protection.outlook.com [40.107.244.95]) by mails.dpdk.org (Postfix) with ESMTP id 433EB41141 for ; Mon, 18 Sep 2023 04:47:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P5PiJiD0N3NsbdTHIHG9t+wC0RC+F2H4hVdSL8U7I39ZVCj1xcD6mXkOt/RhLE5Milpw+hsjY5+OdWO6LvS8HQ+xXzUgNh0Yf8ikMYgBa0ydwwWX3xxtK1yvR+ywqjEzeanqAAtkH3la71LB48FjNPmFPn25swQHQmcXiOjalYF11nbylJQZ3ALhXVfUJWjGL3xgnprC4kuB9a0HWIsWzjtTsw7tdSCBsmiMBLQcWkFkhUqQf3LThJAbiUMWpcXf/TutPydYU8tda1us4sKlXxD/Xoc4ZF7oLKUuXqZSmGcfMYC+FEgMELBazSonSvk9//M+xcZIG4TtnLnZOKxiJg== 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=EqnrUwq6916XFmw1cf7siODpTcUKms1inMsWuYzAlzA=; b=h2ed8P5JkgCxowI0rMiu5YKA2KQY72bbP74wv074uPYtVJ7y6t5SUviviCYn30TtENzaEnssvYp4NBIdB85YzZEoHE/UWFEsTHuqEmSbTRkHwy98ARPhHx6j6g0xkfLqCdfcZC+nN4PQeyiHL8EsLl3kU2zz6Jfr91vIDbp0PmDsa0OhEWJ+GgfITPQZv0fq7gEzF+mMRSX4bvGeu6oBM7BNVqnmJNaGrCKwsa4sdv8C2z0jCfbxqmZ5S0+SjaYuMBLTXczMoCG5zLJbBWgUYy/TzLs/q0MzZC/9/4wf3n2oPawVVezlg1zmwrnWrdkwaacyDmAxHhQOuWHUqazRyg== 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=EqnrUwq6916XFmw1cf7siODpTcUKms1inMsWuYzAlzA=; b=FtxR6xMGx1cA0DTNCk+qxqKvpKjtoGFrgBJQLCrFHPH9swKcYJRJEuPxs0btB6rmBazCs/tjI+dHsjpmKDb+EZmUpLAv2hWuCNPmnCee2C7Shzp/uzmEVeaHnkbclqapI/68m+4oflgF5pUQJfC+6nnTAmoPsQBlCHbPCmTw7Gg= 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:40 +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:40 +0000 From: Chaoyong He To: dev@dpdk.org Cc: Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v4 17/26] net/nfp: add a new header file Date: Mon, 18 Sep 2023 10:46:03 +0800 Message-Id: <20230918024612.1600536-18-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: 026700b7-e754-49b8-05a1-08dbb7f1a04c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C/Bb/DsvDAOiJmj8S1WletGuiEHBauCj8h2u+ZNxLEzsJrWE/Dq3YlAA2UhSvU8hz2lCWC1kcxXW/mHVVfaccuxf6qoqAYX6GZZR6Ekype8EwKYxPVWTsoegJrMVY38AYMfYil8NyS8c4pLcokiLWYfceKxHR+pJ6U6dQ09K5JFAcT3HHc2LynScfIw89Y075EPu+khguaMdFaermJHgeffK0kRJqLXpYEj9KPNP4BA9uu1pbn+hnj+hpd68TpUN+9gY29S4kzUV8ZNjWwyl6iCEcd7KCPYwz8K40GfoMp0XLudfQ3oIklGewuw5/9LNFA4zyEWLnUSHvUxCRTQEO3QP3Y1PuaMhhHyr2sIN1vbqToItETANR5s7HnrSEJlYCKSUXVbXcYptQ4QM3XBqHm7hGiNdfocdHLE7r6X6twnbnbAW7/9bg0EtGGOMt6/6We8uqVMuaFGPZqiUUh3bVRHawtSBlKYR5nO+wpj8Du9sjdO6SqzLjsKR4reGV2r6T62/AxfW5L/+1T0rpJKKVoyhHGuJomjmuV5wABg2dFsSIrz1zpnOZzhABiZd650CkRdpDXC1gx/h9lxKjOkHnoPsYO6PJkzCP2ovMSg2baDgyuBWWmUdwVOhd3WrC6MxUU5T074s/7xre55B1uUoGQ== 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?Q0xVRW1jUkRpdXBiU3Y3d3E5cTh4cXNuWC9UdVd2dGZIL1hybjRabmFmYjYz?= =?utf-8?B?ZFZRRkdaVjRmZ2IycnhXY2FaQTl6NmI0T1JZUUo4dmhpaE41UDNvVlh1LzFs?= =?utf-8?B?TytnMzBlNXdVRHBialRpQUhNbnJCaW9ld0RySkJ5ZjFNdnJrbkYxVUpQSHFD?= =?utf-8?B?QVdqeVpaT3U4bnZKTE9yS0orN084Mzhldzh0UmZBeEZLZHlMcnBJQzB6Vm4y?= =?utf-8?B?aGRTQVFQZzNNdGVQdENtSGRtZkJ6S3YrWTFqTjhrVlVBQzJNd3Z0Qnk2SWtk?= =?utf-8?B?WmRjMUVGVEVWSU5HS3laZ2JaL1duWUttZXFRenJtbTQxRk9sbWs3UUdjbkZX?= =?utf-8?B?Yk1ncml2VHovbXl4M0svV0JYa2RpNzV6R2psS0YwRWxrdm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: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 026700b7-e754-49b8-05a1-08dbb7f1a04c 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:40.9327 (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: toXD0vFAsQ4bzgbsuzD4WHRbjex/27lwIdrcUm9n/NEPZO//zi5slZW03/lkTzYk7HeAxALdgPKylLDTWjbrA5nl2uxP+f/Fq2z2iivjCmg= 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 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 ca3fc2fa59..0f67148907 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 36bd49d659..eb30d8e779 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