1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2008-2016 Freescale Semiconductor, Inc.
8 #ifndef HEADER_COMPAT_H
9 #define HEADER_COMPAT_H
20 #include <linux/types.h>
21 #include <rte_atomic.h>
23 /* The following definitions are primarily to allow the single-source driver
24 * interfaces to be included by arbitrary program code. Ie. for interfaces that
25 * are also available in kernel-space, these definitions provide compatibility
26 * with certain attributes and types used in those interfaces.
29 /* Required compiler attributes */
30 #define likely(x) __builtin_expect(!!(x), 1)
31 #define unlikely(x) __builtin_expect(!!(x), 0)
34 typedef uint64_t dma_addr_t;
37 #define prflush(fmt, args...) \
39 printf(fmt, ##args); \
42 #define pr_crit(fmt, args...) prflush("CRIT:" fmt, ##args)
43 #define pr_err(fmt, args...) prflush("ERR:" fmt, ##args)
44 #define pr_warn(fmt, args...) prflush("WARN:" fmt, ##args)
45 #define pr_info(fmt, args...) prflush(fmt, ##args)
47 #ifdef RTE_LIBRTE_DPAA2_DEBUG_BUS
49 /* Trace the 3 different classes of read/write access to QBMan. #undef as
52 #define QBMAN_CCSR_TRACE
53 #define QBMAN_CINH_TRACE
54 #define QBMAN_CENA_TRACE
56 #define QBMAN_CHECKING
61 #define pr_debug(fmt, args...) printf(fmt, ##args)
62 #define QBMAN_BUG_ON(c) \
64 static int warned_##__LINE__; \
65 if ((c) && !warned_##__LINE__) { \
66 pr_warn("(%s:%d)\n", __FILE__, __LINE__); \
67 warned_##__LINE__ = 1; \
71 #define QBMAN_BUG_ON(c) {}
72 #define pr_debug(fmt, args...) {}
75 /* Other miscellaneous interfaces our APIs depend on; */
77 #define lower_32_bits(x) ((uint32_t)(x))
78 #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
82 #define __raw_readb(p) (*(const volatile unsigned char *)(p))
83 #define __raw_readl(p) (*(const volatile unsigned int *)(p))
84 #define __raw_writel(v, p) {*(volatile unsigned int *)(p) = (v); }
86 #define dma_wmb() rte_smp_mb()
88 #define atomic_t rte_atomic32_t
89 #define atomic_read(v) rte_atomic32_read(v)
90 #define atomic_set(v, i) rte_atomic32_set(v, i)
92 #define atomic_inc(v) rte_atomic32_add(v, 1)
93 #define atomic_dec(v) rte_atomic32_sub(v, 1)
95 #define atomic_inc_and_test(v) rte_atomic32_inc_and_test(v)
96 #define atomic_dec_and_test(v) rte_atomic32_dec_and_test(v)
98 #define atomic_inc_return(v) rte_atomic32_add_return(v, 1)
99 #define atomic_dec_return(v) rte_atomic32_sub_return(v, 1)
100 #define atomic_sub_and_test(i, v) (rte_atomic32_sub_return(v, i) == 0)
102 #endif /* HEADER_COMPAT_H */