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. 4 */ 5 6 #ifndef _ENIC_COMPAT_H_ 7 #define _ENIC_COMPAT_H_ 8 9 #include <stdio.h> 10 #include <unistd.h> 11 12 #include <rte_atomic.h> 13 #include <rte_malloc.h> 14 #include <rte_log.h> 15 #include <rte_io.h> 16 17 #define ETH_ALEN 6 18 19 #define __iomem 20 21 #define pr_err(y, ...) dev_err(0, y, ##__VA_ARGS__) 22 #define pr_warn(y, ...) dev_warning(0, y, ##__VA_ARGS__) 23 #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__) 24 25 #define VNIC_ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1) 26 #define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask)) 27 28 extern int enic_pmd_logtype; 29 #define RTE_LOGTYPE_ENIC_PMD enic_pmd_logtype 30 31 #define dev_printk(level, fmt, ...) \ 32 rte_log(RTE_LOG_ ## level, enic_pmd_logtype, \ 33 "PMD: rte_enic_pmd: " fmt, ##__VA_ARGS__) 34 35 #define dev_err(x, ...) dev_printk(ERR, __VA_ARGS__) 36 #define dev_info(x, ...) dev_printk(INFO, __VA_ARGS__) 37 #define dev_warning(x, ...) dev_printk(WARNING, __VA_ARGS__) 38 #define dev_debug(x, ...) dev_printk(DEBUG, __VA_ARGS__) 39 40 #define ENICPMD_LOG(level, ...) \ 41 RTE_LOG_LINE_PREFIX(level, ENIC_PMD, "%s ", __func__, __VA_ARGS__) 42 #define ENICPMD_FUNC_TRACE() ENICPMD_LOG(DEBUG, ">>") 43 44 typedef unsigned long long dma_addr_t; 45 46 static inline uint32_t ioread32(volatile void *addr) 47 { 48 return rte_read32(addr); 49 } 50 51 static inline uint8_t ioread8(volatile void *addr) 52 { 53 return rte_read8(addr); 54 } 55 56 static inline void iowrite32(uint32_t val, volatile void *addr) 57 { 58 rte_write32(val, addr); 59 } 60 61 static inline void iowrite32_relaxed(uint32_t val, volatile void *addr) 62 { 63 rte_write32_relaxed(val, addr); 64 } 65 66 static inline unsigned int readl(volatile void __iomem *addr) 67 { 68 return rte_read32(addr); 69 } 70 71 static inline void writel(unsigned int val, volatile void __iomem *addr) 72 { 73 rte_write32(val, addr); 74 } 75 76 #endif /* _ENIC_COMPAT_H_ */ 77