ice_osdep.h 2.6 KB
Newer Older
1 2 3 4 5 6 7
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2018, Intel Corporation. */

#ifndef _ICE_OSDEP_H_
#define _ICE_OSDEP_H_

#include <linux/types.h>
8 9
#include <linux/ctype.h>
#include <linux/delay.h>
10
#include <linux/io.h>
11 12 13 14
#include <linux/bitops.h>
#include <linux/ethtool.h>
#include <linux/etherdevice.h>
#include <linux/if_ether.h>
15
#include <linux/iopoll.h>
16
#include <linux/pci_ids.h>
17 18 19
#ifndef CONFIG_64BIT
#include <linux/io-64-nonatomic-lo-hi.h>
#endif
Brett Creeley's avatar
Brett Creeley committed
20
#include <net/udp_tunnel.h>
21 22 23 24 25 26

#define wr32(a, reg, value)	writel((value), ((a)->hw_addr + (reg)))
#define rd32(a, reg)		readl((a)->hw_addr + (reg))
#define wr64(a, reg, value)	writeq((value), ((a)->hw_addr + (reg)))
#define rd64(a, reg)		readq((a)->hw_addr + (reg))

27 28 29
#define rd32_poll_timeout(a, addr, val, cond, delay_us, timeout_us) \
	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))
32 33 34 35 36 37 38

struct ice_dma_mem {
	void *va;
	dma_addr_t pa;
	size_t size;
};

39 40
struct ice_hw;
struct device *ice_hw_to_dev(struct ice_hw *hw);
41 42 43 44 45

#ifdef CONFIG_DYNAMIC_DEBUG
#define ice_debug(hw, type, fmt, args...) \
	dev_dbg(ice_hw_to_dev(hw), fmt, ##args)

46 47 48 49
#define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \
	print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET,		 \
			     rowsize, groupsize, buf, len, false)
#else /* CONFIG_DYNAMIC_DEBUG */
50 51 52 53 54 55 56
#define ice_debug(hw, type, fmt, args...)			\
do {								\
	if ((type) & (hw)->debug_mask)				\
		dev_info(ice_hw_to_dev(hw), fmt, ##args);	\
} while (0)

#ifdef DEBUG
57
#define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \
58 59
do {								\
	if ((type) & (hw)->debug_mask)				\
60
		print_hex_dump_debug(prefix, DUMP_PREFIX_OFFSET,\
61 62 63
				     rowsize, groupsize, buf,	\
				     len, false);		\
} while (0)
64 65
#else /* DEBUG */
#define _ice_debug_array(hw, type, prefix, rowsize, groupsize, buf, len) \
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
do {								\
	struct ice_hw *hw_l = hw;				\
	if ((type) & (hw_l)->debug_mask) {			\
		u16 len_l = len;				\
		u8 *buf_l = buf;				\
		int i;						\
		for (i = 0; i < (len_l - 16); i += 16)		\
			ice_debug(hw_l, type, "0x%04X  %16ph\n",\
				  i, ((buf_l) + i));		\
		if (i < len_l)					\
			ice_debug(hw_l, type, "0x%04X  %*ph\n", \
				  i, ((len_l) - i), ((buf_l) + i));\
	}							\
} while (0)
#endif /* DEBUG */
#endif /* CONFIG_DYNAMIC_DEBUG */

83 84 85 86 87 88
#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \
	_ice_debug_array(hw, type, KBUILD_MODNAME, rowsize, groupsize, buf, len)

#define ice_debug_array_w_prefix(hw, type, prefix, buf, len) \
	_ice_debug_array(hw, type, prefix, 16, 1, buf, len)

89
#endif /* _ICE_OSDEP_H_ */