1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2018, Intel Corporation. */
7 #include <linux/types.h>
8 #include <linux/ctype.h>
9 #include <linux/delay.h>
11 #include <linux/bitops.h>
12 #include <linux/ethtool.h>
13 #include <linux/etherdevice.h>
14 #include <linux/if_ether.h>
15 #include <linux/iopoll.h>
16 #include <linux/pci_ids.h>
18 #include <linux/io-64-nonatomic-lo-hi.h>
20 #include <net/udp_tunnel.h>
22 #define wr32(a, reg, value) writel((value), ((a)->hw_addr + (reg)))
23 #define rd32(a, reg) readl((a)->hw_addr + (reg))
24 #define wr64(a, reg, value) writeq((value), ((a)->hw_addr + (reg)))
25 #define rd64(a, reg) readq((a)->hw_addr + (reg))
27 #define rd32_poll_timeout(a, addr, val, cond, delay_us, timeout_us) \
28 read_poll_timeout(rd32, val, cond, delay_us, timeout_us, false, a, addr)
30 #define ice_flush(a) rd32((a), GLGEN_STAT)
31 #define ICE_M(m, s) ((m ## U) << (s))
40 struct device *ice_hw_to_dev(struct ice_hw *hw);
42 #ifdef CONFIG_DYNAMIC_DEBUG
43 #define ice_debug(hw, type, fmt, args...) \
44 dev_dbg(ice_hw_to_dev(hw), fmt, ##args)
46 #define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \
47 print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET, \
48 rowsize, groupsize, buf, len, false)
49 #else /* CONFIG_DYNAMIC_DEBUG */
50 #define ice_debug(hw, type, fmt, args...) \
52 if ((type) & (hw)->debug_mask) \
53 dev_info(ice_hw_to_dev(hw), fmt, ##args); \
57 #define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \
59 if ((type) & (hw)->debug_mask) \
60 print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET,\
61 rowsize, groupsize, buf, \
65 #define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \
67 struct ice_hw *hw_l = hw; \
68 if ((type) & (hw_l)->debug_mask) { \
72 for (i = 0; i < (len_l - 16); i += 16) \
73 ice_debug(hw_l, type, "0x%04X %16ph\n",\
76 ice_debug(hw_l, type, "0x%04X %*ph\n", \
77 i, ((len_l) - i), ((buf_l) + i));\
81 #endif /* CONFIG_DYNAMIC_DEBUG */
83 #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \
84 _ice_debug_array(hw, type, KBUILD_MODNAME, rowsize, groupsize, buf, len)
86 #define ice_debug_array_w_prefix(hw, type, prefix, buf, len) \
87 _ice_debug_array(hw, type, prefix, 16, 1, buf, len)
89 #endif /* _ICE_OSDEP_H_ */