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 923DA42600; Tue, 19 Sep 2023 11:56:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58B7A40EA5; Tue, 19 Sep 2023 11:55:57 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2130.outbound.protection.outlook.com [40.107.243.130]) by mails.dpdk.org (Postfix) with ESMTP id 7599C40DF6 for ; Tue, 19 Sep 2023 11:55:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ITA2r56dBe+js3XAVXicKS1DyCF6n7/KpM/JX1iuPSDm/ufIhe1Jfgx1zCH8qN+ziievwND+L67zH/h0cxi1VXj7pWoZ3AuT84juRdvF0Hf/aY8e0V0KDO7/zej4Nbfhe6jyM/2kYYjoYJgIxRrAKw4QzO2plzdoRfloFFWTbxwCDDPlNCbHcmDtZ6sr1ZYK0ozE0vPQBgJ+d6AFOH9dRRrIXKbVS7/A8gT4F/29hiGJfOojfFPmZiKFss2dC9DzetJa1hfuNyQiJCDCtpWDKXI5zDecRCdsV/l9ObuwQFuufnXwppVlnaQt8c5lyilKEuFBLMZw5X9w81kIDbxmNw== 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=Ny1hYdy+wq94U8+DcA3Fo5AFWBvG7w+oGySM0q5+d0Y=; b=fmxMwVqWRbyDkbiqHaftdFqzIsaeQl6DiFmJcUYV0ISTA8h4zuD9XCF7MT67gf7JQPpIfoVKr8ceoaPA8CPLovPs9b4dCvGexpkXMlFhkQb8qkMYKtpvjuI6FfZJfbTmO5bAxthLbTBipvC2SqkWafEWjcL9/vukfNXf0ekq6bkFoitJzpiHepk7kPxSbHFNiZ9zyUZmMjgc8K6r79MfVHFtSLEG+xL73rn5SMuDFn8kI0LeEpv6FjdEQtgfGuvGLI8rLtw+xR9JcZHhUaBOsViXiTQ7XXAxVsT+DkGN6PIOVUX/ZXW8dyh/McSz+iMUKmM2iOH/NZr+lD0fvVxerw== 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=Ny1hYdy+wq94U8+DcA3Fo5AFWBvG7w+oGySM0q5+d0Y=; b=LwNiHCDUAs2ZM1yUKXPd9eUoMhjEAZMHK2l/dRGNM+sv5kht2HaGM08vfDVSniBRNYuABfoPbXXG3C+DgA9GFLsS/H+Ae7PKmwhd3WZQ6x4C/KQfwxHOP4cQKsXzaQovx+GjPUphb97+XG3rS5nYKFERlV+3NGGRv1h4OqzLpgE= 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 MW5PR13MB5877.namprd13.prod.outlook.com (2603:10b6:303:1c7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Tue, 19 Sep 2023 09:55:48 +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:48 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He Subject: [PATCH v5 17/26] net/nfp: add a new header file Date: Tue, 19 Sep 2023 17:54:31 +0800 Message-Id: <20230919095440.45445-18-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_|MW5PR13MB5877:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b9f038e-6768-4a4a-e1c7-08dbb8f69958 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Au0DfCwiYJfu79vmOINUKPD51UtEZxcz00iFL23l7bOyxtphJnkFlSPV7pWS9Vdi9CSPOtndgywJzeOLUhb1qlg5XpiR6tioG15uBZSer8fBuz0VbD/dgJwdY1nuD8tVx4Kn79CJPeS17rB2EsIpcdg9pUs9pZaq/gaGS8mWFzhylDBfEqxm5WHi06lZuKY1Uuemb9Fa+54pkWbGTxBC8fQMTw+z1kfNZur5HEDIoVJrL+dTFQe0yG+MlHBWn4mFAPoD37ebk0Z+W26sPFQvgi2nJNy/uG5EqpjFfKIHazxEN9SGk2PChUhiXNtlt/WZnIGxSZbeeXcMileUJDNzwlC5/Rzqg7jtGy2+stRDOu8Z7eeI9rpddAMuYQQ3DTd6kZTeFpInIx0KMDpkaqipEsJaj12uWibbrb1aX+c5Ud8whCjgWCX6TmDmWmRUGbQOuTKpiemwzsbi5FpabLQ3EYxFw6QoavJVQpqn+B26U1wogzWsO7l3Uj5YUgcQk4N2bzH1vs+VXnGUq1vu1e0n+TC/IPOrtxfH+ygXwwAGPa4ik2eXZHrn/ICqZZJNh/4uztd4GCC1b3678v3Mdprj6UXSmoTpvohub+9h1rvkhY5w46IopYa2fDf9y8MZ6M5U9KuqhL66qlNBFcWP5PY8fQ== 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)(346002)(136003)(396003)(39840400004)(366004)(376002)(186009)(451199024)(1800799009)(6506007)(6486002)(6666004)(52116002)(86362001)(36756003)(38350700002)(38100700002)(2616005)(1076003)(107886003)(26005)(2906002)(6512007)(478600001)(83380400001)(8676002)(5660300002)(4326008)(41300700001)(8936002)(44832011)(66946007)(66556008)(66476007)(6916009)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?h7Zldv++9ReBr2/0Jl8sDZcOGEa1l9CZtkv327Ht+VX/Fvs+k4eEvwMQx8ZB?= =?us-ascii?Q?MifAWmrw2G3M3un6Tz6JCPbyuVT1x6TtDK0dxiZmDNeaxFJubA0nnlc/5jn2?= =?us-ascii?Q?2c40E27VrKcf4tIATsqNtT8E6csT0h0N2BlDDn18LKH7RM+Fq512E9PZPrqf?= =?us-ascii?Q?CsfK6w7epNGDBY9gPb3zSp4z7KK6CjIYd9dTMnW/CrqEjwqQ463roSS9LmR4?= =?us-ascii?Q?5KipJ9digdFBmo7qj9RZwSZbQH7ldF56f1a7ZQaBIpD1bBYyTM+9XaSFgK6i?= =?us-ascii?Q?LkcXlW7f90fGKkrIJPOlNwkAHiaalEYG0vMuUGe5ZzC9dEPMRloa23cL5r2T?= =?us-ascii?Q?gIZ0pth+XMYSQa3vuSSAOSRX8xj9f+Mc3r3Q0Yw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r52LOMYnWGytZlEiSTyxg0d7qJRq/VKyWrwvLhsmL?= =?us-ascii?Q?aZ/PBUm3Z8AGRxmhD3xFgA5DiIpZjSLJX3ZB2jtmsj7BzAk1O0vHVjBzhlzm?= =?us-ascii?Q?Y7ZEqsDfpZLnilvpXaf3fqnpQCdjT22MuNhwoZ1in0gypsniGD2Uzp9wZOz+?= =?us-ascii?Q?gW03ACTPMO3jqK7UmbXSYj66xa8BnatY2htRuYgmX1od3J6zR2W64agEOcUu?= =?us-ascii?Q?MolXKc+JkLJG5cJTZLTQqD8HHxos4IR9sMh13vgnC/NpNNoqig4Ocpp5hk6S?= =?us-ascii?Q?MA3HI7NBifPdKvSVCJJYN7lj/iUCX/HVyQVgobHwl6N7AVWBirDmhgF1AkEQ?= =?us-ascii?Q?8A=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b9f038e-6768-4a4a-e1c7-08dbb8f69958 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:48.0060 (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: Ku0yZ4eQJqVgm7cNCF0eZktlhYjHxREQvuLwdE+77DxasoZ71Wl+Tr2DbY7dcY4WVCD48Y4uHOQTxwgAoT51PWn5Fb30/Z8Y22J6wyXEwpg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR13MB5877 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 --- 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