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
23 #define rmb() rte_rmb() /* dpdk rte provided rmb */
24 #define wmb() rte_wmb() /* dpdk rte provided wmb */
27 #define offsetof(t, m) ((size_t) &((t *)0)->m)
30 #define pr_err(y, args...) dev_err(0, y, ##args)
31 #define pr_warn(y, args...) dev_warning(0, y, ##args)
32 #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
34 #define VNIC_ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
35 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
37 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
39 #define kzalloc(size, flags) calloc(1, size)
40 #define kfree(x) free(x)
42 extern int enic_pmd_logtype;
44 #define dev_printk(level, fmt, args...) \
45 rte_log(RTE_LOG_ ## level, enic_pmd_logtype, \
46 "PMD: rte_enic_pmd: " fmt, ##args)
48 #define dev_err(x, args...) dev_printk(ERR, args)
49 #define dev_info(x, args...) dev_printk(INFO, args)
50 #define dev_warning(x, args...) dev_printk(WARNING, args)
51 #define dev_debug(x, args...) dev_printk(DEBUG, args)
53 #define ENICPMD_LOG(level, fmt, args...) \
54 rte_log(RTE_LOG_ ## level, enic_pmd_logtype, \
55 "%s " fmt "\n", __func__, ##args)
56 #define ENICPMD_FUNC_TRACE() ENICPMD_LOG(DEBUG, ">>")
62 typedef unsigned char u8;
63 typedef unsigned short u16;
64 typedef unsigned int u32;
65 typedef unsigned long long u64;
66 typedef unsigned long long dma_addr_t;
68 static inline uint32_t ioread32(volatile void *addr)
70 return rte_read32(addr);
73 static inline uint8_t ioread8(volatile void *addr)
75 return rte_read8(addr);
78 static inline void iowrite32(uint32_t val, volatile void *addr)
80 rte_write32(val, addr);
83 static inline void iowrite32_relaxed(uint32_t val, volatile void *addr)
85 rte_write32_relaxed(val, addr);
88 static inline unsigned int readl(volatile void __iomem *addr)
90 return rte_read32(addr);
93 static inline void writel(unsigned int val, volatile void __iomem *addr)
95 rte_write32(val, addr);
98 #define min_t(type, x, y) ({ \
101 __min1 < __min2 ? __min1 : __min2; })
103 #define max_t(type, x, y) ({ \
106 __max1 > __max2 ? __max1 : __max2; })
108 #endif /* _ENIC_COMPAT_H_ */