[v4,17/26] net/nfp: add a new header file
Checks
Commit Message
Split out the macro which are not easily find a DPDK substitute into
a new header file.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@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
@@ -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
@@ -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)
@@ -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)
new file mode 100644
@@ -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__ */