90 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/* Copyright (c) 2018, Intel Corporation. */3 4#ifndef _ICE_OSDEP_H_5#define _ICE_OSDEP_H_6 7#include <linux/types.h>8#include <linux/ctype.h>9#include <linux/delay.h>10#include <linux/io.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>17#ifndef CONFIG_64BIT18#include <linux/io-64-nonatomic-lo-hi.h>19#endif20#include <net/udp_tunnel.h>21 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))26 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)29 30#define ice_flush(a) rd32((a), GLGEN_STAT)31#define ICE_M(m, s) ((m ## U) << (s))32 33struct ice_dma_mem {34 void *va;35 dma_addr_t pa;36 size_t size;37};38 39struct ice_hw;40struct device *ice_hw_to_dev(struct ice_hw *hw);41 42#ifdef CONFIG_DYNAMIC_DEBUG43#define ice_debug(hw, type, fmt, args...) \44 dev_dbg(ice_hw_to_dev(hw), fmt, ##args)45 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...) \51do { \52 if ((type) & (hw)->debug_mask) \53 dev_info(ice_hw_to_dev(hw), fmt, ##args); \54} while (0)55 56#ifdef DEBUG57#define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \58do { \59 if ((type) & (hw)->debug_mask) \60 print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET,\61 rowsize, groupsize, buf, \62 len, false); \63} while (0)64#else /* DEBUG */65#define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \66do { \67 struct ice_hw *hw_l = hw; \68 if ((type) & (hw_l)->debug_mask) { \69 u16 len_l = len; \70 u8 *buf_l = buf; \71 int i; \72 for (i = 0; i < (len_l - 16); i += 16) \73 ice_debug(hw_l, type, "0x%04X %16ph\n",\74 i, ((buf_l) + i)); \75 if (i < len_l) \76 ice_debug(hw_l, type, "0x%04X %*ph\n", \77 i, ((len_l) - i), ((buf_l) + i));\78 } \79} while (0)80#endif /* DEBUG */81#endif /* CONFIG_DYNAMIC_DEBUG */82 83#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \84 _ice_debug_array(hw, type, KBUILD_MODNAME, rowsize, groupsize, buf, len)85 86#define ice_debug_array_w_prefix(hw, type, prefix, buf, len) \87 _ice_debug_array(hw, type, prefix, 16, 1, buf, len)88 89#endif /* _ICE_OSDEP_H_ */90