0001
0002
0003
0004 #ifndef _ICE_OSDEP_H_
0005 #define _ICE_OSDEP_H_
0006
0007 #include <linux/types.h>
0008 #include <linux/ctype.h>
0009 #include <linux/delay.h>
0010 #include <linux/io.h>
0011 #include <linux/bitops.h>
0012 #include <linux/ethtool.h>
0013 #include <linux/etherdevice.h>
0014 #include <linux/if_ether.h>
0015 #include <linux/pci_ids.h>
0016 #ifndef CONFIG_64BIT
0017 #include <linux/io-64-nonatomic-lo-hi.h>
0018 #endif
0019 #include <net/udp_tunnel.h>
0020
0021 #define wr32(a, reg, value) writel((value), ((a)->hw_addr + (reg)))
0022 #define rd32(a, reg) readl((a)->hw_addr + (reg))
0023 #define wr64(a, reg, value) writeq((value), ((a)->hw_addr + (reg)))
0024 #define rd64(a, reg) readq((a)->hw_addr + (reg))
0025
0026 #define ice_flush(a) rd32((a), GLGEN_STAT)
0027 #define ICE_M(m, s) ((m) << (s))
0028
0029 struct ice_dma_mem {
0030 void *va;
0031 dma_addr_t pa;
0032 size_t size;
0033 };
0034
0035 struct ice_hw;
0036 struct device *ice_hw_to_dev(struct ice_hw *hw);
0037
0038 #ifdef CONFIG_DYNAMIC_DEBUG
0039 #define ice_debug(hw, type, fmt, args...) \
0040 dev_dbg(ice_hw_to_dev(hw), fmt, ##args)
0041
0042 #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \
0043 print_hex_dump_debug(KBUILD_MODNAME " ", \
0044 DUMP_PREFIX_OFFSET, rowsize, \
0045 groupsize, buf, len, false)
0046 #else
0047 #define ice_debug(hw, type, fmt, args...) \
0048 do { \
0049 if ((type) & (hw)->debug_mask) \
0050 dev_info(ice_hw_to_dev(hw), fmt, ##args); \
0051 } while (0)
0052
0053 #ifdef DEBUG
0054 #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \
0055 do { \
0056 if ((type) & (hw)->debug_mask) \
0057 print_hex_dump_debug(KBUILD_MODNAME, \
0058 DUMP_PREFIX_OFFSET, \
0059 rowsize, groupsize, buf, \
0060 len, false); \
0061 } while (0)
0062 #else
0063 #define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \
0064 do { \
0065 struct ice_hw *hw_l = hw; \
0066 if ((type) & (hw_l)->debug_mask) { \
0067 u16 len_l = len; \
0068 u8 *buf_l = buf; \
0069 int i; \
0070 for (i = 0; i < (len_l - 16); i += 16) \
0071 ice_debug(hw_l, type, "0x%04X %16ph\n",\
0072 i, ((buf_l) + i)); \
0073 if (i < len_l) \
0074 ice_debug(hw_l, type, "0x%04X %*ph\n", \
0075 i, ((len_l) - i), ((buf_l) + i));\
0076 } \
0077 } while (0)
0078 #endif
0079 #endif
0080
0081 #endif