Split out the macro which are not easily find a DPDK substitute into
a new header file.

Signed-off-by: Chaoyong He <chaoyong...@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderl...@corigine.com>
---
 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 <stdint.h>
+
+#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

Reply via email to