xref: /dpdk/drivers/net/enic/enic_compat.h (revision fd51012de5369679e807be1d6a81d63ef15015ce)
12e99ea80SHyong Youb Kim /* SPDX-License-Identifier: BSD-3-Clause
22e99ea80SHyong Youb Kim  * Copyright 2008-2017 Cisco Systems, Inc.  All rights reserved.
372f3de30SBruce Richardson  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
472f3de30SBruce Richardson  */
572f3de30SBruce Richardson 
672f3de30SBruce Richardson #ifndef _ENIC_COMPAT_H_
772f3de30SBruce Richardson #define _ENIC_COMPAT_H_
872f3de30SBruce Richardson 
972f3de30SBruce Richardson #include <stdio.h>
1072f3de30SBruce Richardson #include <unistd.h>
1172f3de30SBruce Richardson 
1272f3de30SBruce Richardson #include <rte_atomic.h>
1372f3de30SBruce Richardson #include <rte_malloc.h>
1472f3de30SBruce Richardson #include <rte_log.h>
15dd7862baSSantosh Shukla #include <rte_io.h>
1672f3de30SBruce Richardson 
1772f3de30SBruce Richardson #define ETH_ALEN        6
1872f3de30SBruce Richardson 
1972f3de30SBruce Richardson #define __iomem
2072f3de30SBruce Richardson 
21*fd51012dSAndre Muezerie #define pr_err(y, ...) dev_err(0, y, ##__VA_ARGS__)
22*fd51012dSAndre Muezerie #define pr_warn(y, ...) dev_warning(0, y, ##__VA_ARGS__)
2372f3de30SBruce Richardson #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
2472f3de30SBruce Richardson 
2572f3de30SBruce Richardson #define VNIC_ALIGN(x, a)         __ALIGN_MASK(x, (typeof(x))(a)-1)
2672f3de30SBruce Richardson #define __ALIGN_MASK(x, mask)    (((x)+(mask))&~(mask))
2772f3de30SBruce Richardson 
28bbd8ecc0SJohn Daley extern int enic_pmd_logtype;
292b843cacSDavid Marchand #define RTE_LOGTYPE_ENIC_PMD enic_pmd_logtype
30bbd8ecc0SJohn Daley 
31*fd51012dSAndre Muezerie #define dev_printk(level, fmt, ...)	\
32bbd8ecc0SJohn Daley 	rte_log(RTE_LOG_ ## level, enic_pmd_logtype, \
33*fd51012dSAndre Muezerie 		"PMD: rte_enic_pmd: " fmt, ##__VA_ARGS__)
3472f3de30SBruce Richardson 
35*fd51012dSAndre Muezerie #define dev_err(x, ...) dev_printk(ERR, __VA_ARGS__)
36*fd51012dSAndre Muezerie #define dev_info(x, ...) dev_printk(INFO, __VA_ARGS__)
37*fd51012dSAndre Muezerie #define dev_warning(x, ...) dev_printk(WARNING, __VA_ARGS__)
38*fd51012dSAndre Muezerie #define dev_debug(x, ...) dev_printk(DEBUG, __VA_ARGS__)
3972f3de30SBruce Richardson 
402b843cacSDavid Marchand #define ENICPMD_LOG(level, ...) \
412b843cacSDavid Marchand 	RTE_LOG_LINE_PREFIX(level, ENIC_PMD, "%s ", __func__, __VA_ARGS__)
42bbd8ecc0SJohn Daley #define ENICPMD_FUNC_TRACE() ENICPMD_LOG(DEBUG, ">>")
4336efba2fSHyong Youb Kim 
4472f3de30SBruce Richardson typedef         unsigned long long  dma_addr_t;
4572f3de30SBruce Richardson 
4672f3de30SBruce Richardson static inline uint32_t ioread32(volatile void *addr)
4772f3de30SBruce Richardson {
48dd7862baSSantosh Shukla 	return rte_read32(addr);
4972f3de30SBruce Richardson }
5072f3de30SBruce Richardson 
5172f3de30SBruce Richardson static inline uint8_t ioread8(volatile void *addr)
5272f3de30SBruce Richardson {
53dd7862baSSantosh Shukla 	return rte_read8(addr);
5472f3de30SBruce Richardson }
5572f3de30SBruce Richardson 
5672f3de30SBruce Richardson static inline void iowrite32(uint32_t val, volatile void *addr)
5772f3de30SBruce Richardson {
58dd7862baSSantosh Shukla 	rte_write32(val, addr);
59dd7862baSSantosh Shukla }
60dd7862baSSantosh Shukla 
61dd7862baSSantosh Shukla static inline void iowrite32_relaxed(uint32_t val, volatile void *addr)
62dd7862baSSantosh Shukla {
63dd7862baSSantosh Shukla 	rte_write32_relaxed(val, addr);
6472f3de30SBruce Richardson }
6572f3de30SBruce Richardson 
6672f3de30SBruce Richardson static inline unsigned int readl(volatile void __iomem *addr)
6772f3de30SBruce Richardson {
68dd7862baSSantosh Shukla 	return rte_read32(addr);
69dd7862baSSantosh Shukla }
70dd7862baSSantosh Shukla 
7172f3de30SBruce Richardson static inline void writel(unsigned int val, volatile void __iomem *addr)
7272f3de30SBruce Richardson {
73dd7862baSSantosh Shukla 	rte_write32(val, addr);
7472f3de30SBruce Richardson }
7572f3de30SBruce Richardson 
7672f3de30SBruce Richardson #endif /* _ENIC_COMPAT_H_ */
77