xref: /freebsd/sys/dev/enic/enic_compat.h (revision 9768746b)
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 <sys/param.h>
10 #include <sys/socket.h>
11 #include <sys/kernel.h>
12 #include <sys/bus.h>
13 #include <sys/module.h>
14 #include <sys/rman.h>
15 #include <sys/endian.h>
16 #include <sys/sockio.h>
17 #include <sys/priv.h>
18 
19 #include <machine/bus.h>
20 #include <machine/resource.h>
21 
22 #define ETH_ALEN	ETHER_ADDR_LEN
23 
24 #define typeof		__typeof__
25 #define __iomem
26 #define unlikely(x)	__builtin_expect((x),0)
27 
28 #define le16_to_cpu
29 #define le32_to_cpu
30 #define le64_to_cpu
31 #define cpu_to_le16
32 #define cpu_to_le32
33 #define cpu_to_le64
34 
35 #define pr_err(y, args...) dev_err(0, y, ##args)
36 #define pr_warn(y, args...) dev_warning(0, y, ##args)
37 #define BUG() pr_err("BUG at %s:%d", __func__, __LINE__)
38 
39 #define VNIC_ALIGN(x, a)	__ALIGN_MASK(x, (typeof(x))(a)-1)
40 #define __ALIGN_MASK(x, mask)	(((x)+(mask))&~(mask))
41 #define udelay(t) DELAY(t)
42 #define usleep(x) pause("ENIC usleep", ((x) * 1000000 / hz + 1))
43 
44 #define dev_printk(level, fmt, args...)	\
45 	printf(fmt, ## args)
46 
47 #define dev_err(x, args...) dev_printk(ERR, args)
48 /*#define dev_info(x, args...) dev_printk(INFO,  args)*/
49 #define dev_info(x, args...)
50 
51 #define __le16 uint16_t
52 #define __le32 uint32_t
53 #define __le64 uint64_t
54 
55 #define min_t(type, x, y) ({			\
56 	type __min1 = (x);			\
57 	type __min2 = (y);			\
58 	__min1 < __min2 ? __min1 : __min2; })
59 
60 #define max_t(type, x, y) ({			\
61 	type __max1 = (x);			\
62 	type __max2 = (y);			\
63 	__max1 > __max2 ? __max1 : __max2; })
64 
65 #endif /* _ENIC_COMPAT_H_ */
66