4 * Copyright (c) 2008-2016 Freescale Semiconductor, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * * Neither the name of Freescale Semiconductor nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef HEADER_COMPAT_H
31 #define HEADER_COMPAT_H
43 #include <linux/types.h>
44 #include <rte_atomic.h>
46 /* The following definitions are primarily to allow the single-source driver
47 * interfaces to be included by arbitrary program code. Ie. for interfaces that
48 * are also available in kernel-space, these definitions provide compatibility
49 * with certain attributes and types used in those interfaces.
52 /* Required compiler attributes */
53 #define likely(x) __builtin_expect(!!(x), 1)
54 #define unlikely(x) __builtin_expect(!!(x), 0)
57 typedef uint64_t dma_addr_t;
60 #define prflush(fmt, args...) \
62 printf(fmt, ##args); \
65 #define pr_crit(fmt, args...) prflush("CRIT:" fmt, ##args)
66 #define pr_err(fmt, args...) prflush("ERR:" fmt, ##args)
67 #define pr_warn(fmt, args...) prflush("WARN:" fmt, ##args)
68 #define pr_info(fmt, args...) prflush(fmt, ##args)
70 #ifdef RTE_LIBRTE_DPAA2_DEBUG_BUS
72 /* Trace the 3 different classes of read/write access to QBMan. #undef as
75 #define QBMAN_CCSR_TRACE
76 #define QBMAN_CINH_TRACE
77 #define QBMAN_CENA_TRACE
79 #define QBMAN_CHECKING
84 #define pr_debug(fmt, args...) printf(fmt, ##args)
85 #define QBMAN_BUG_ON(c) \
87 static int warned_##__LINE__; \
88 if ((c) && !warned_##__LINE__) { \
89 pr_warn("(%s:%d)\n", __FILE__, __LINE__); \
90 warned_##__LINE__ = 1; \
94 #define QBMAN_BUG_ON(c) {}
95 #define pr_debug(fmt, args...) {}
98 /* Other miscellaneous interfaces our APIs depend on; */
100 #define lower_32_bits(x) ((uint32_t)(x))
101 #define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
106 #define __raw_readb(p) (*(const volatile unsigned char *)(p))
107 #define __raw_readl(p) (*(const volatile unsigned int *)(p))
108 #define __raw_writel(v, p) {*(volatile unsigned int *)(p) = (v); }
110 #define atomic_t rte_atomic32_t
111 #define atomic_read(v) rte_atomic32_read(v)
112 #define atomic_set(v, i) rte_atomic32_set(v, i)
114 #define atomic_inc(v) rte_atomic32_add(v, 1)
115 #define atomic_dec(v) rte_atomic32_sub(v, 1)
117 #define atomic_inc_and_test(v) rte_atomic32_inc_and_test(v)
118 #define atomic_dec_and_test(v) rte_atomic32_dec_and_test(v)
120 #define atomic_inc_return(v) rte_atomic32_add_return(v, 1)
121 #define atomic_dec_return(v) rte_atomic32_sub_return(v, 1)
122 #define atomic_sub_and_test(i, v) (rte_atomic32_sub_return(v, i) == 0)
124 #endif /* HEADER_COMPAT_H */