1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
6 #ifndef _ENIC_COMPAT_H_
7 #define _ENIC_COMPAT_H_
12 #include <rte_atomic.h>
13 #include <rte_malloc.h>
17 #define ENIC_PAGE_ALIGN 4096UL
18 #define ENIC_ALIGN ENIC_PAGE_ALIGN
24 #define rmb() rte_rmb() /* dpdk rte provided rmb */
25 #define wmb() rte_wmb() /* dpdk rte provided wmb */
35 #define offsetof(t, m) ((size_t) &((t *)0)->m)
38 #define pr_err(y, args...) dev_err(0, y, ##args)
39 #define pr_warn(y, args...) dev_warning(0, y, ##args)
40 #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
42 #define VNIC_ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
43 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
45 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
47 #define kzalloc(size, flags) calloc(1, size)
48 #define kfree(x) free(x)
50 extern int enic_pmd_logtype;
52 #define dev_printk(level, fmt, args...) \
53 rte_log(RTE_LOG_ ## level, enic_pmd_logtype, \
54 "PMD: rte_enic_pmd: " fmt, ##args)
56 #define dev_err(x, args...) dev_printk(ERR, args)
57 #define dev_info(x, args...) dev_printk(INFO, args)
58 #define dev_warning(x, args...) dev_printk(WARNING, args)
59 #define dev_debug(x, args...) dev_printk(DEBUG, args)
61 #define ENICPMD_LOG(level, fmt, args...) \
62 rte_log(RTE_LOG_ ## level, enic_pmd_logtype, \
63 "%s" fmt "\n", __func__, ##args)
64 #define ENICPMD_FUNC_TRACE() ENICPMD_LOG(DEBUG, " >>")
70 typedef unsigned char u8;
71 typedef unsigned short u16;
72 typedef unsigned int u32;
73 typedef unsigned long long u64;
74 typedef unsigned long long dma_addr_t;
76 static inline uint32_t ioread32(volatile void *addr)
78 return rte_read32(addr);
81 static inline uint8_t ioread8(volatile void *addr)
83 return rte_read8(addr);
86 static inline void iowrite32(uint32_t val, volatile void *addr)
88 rte_write32(val, addr);
91 static inline void iowrite32_relaxed(uint32_t val, volatile void *addr)
93 rte_write32_relaxed(val, addr);
96 static inline unsigned int readl(volatile void __iomem *addr)
98 return rte_read32(addr);
101 static inline void writel(unsigned int val, volatile void __iomem *addr)
103 rte_write32(val, addr);
106 #define min_t(type, x, y) ({ \
109 __min1 < __min2 ? __min1 : __min2; })
111 #define max_t(type, x, y) ({ \
114 __max1 > __max2 ? __max1 : __max2; })
116 #endif /* _ENIC_COMPAT_H_ */