1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
3 
4 #ifndef _I40E_OSDEP_H_
5 #define _I40E_OSDEP_H_
6 
7 #include <linux/types.h>
8 #include <linux/if_ether.h>
9 #include <linux/if_vlan.h>
10 #include <linux/tcp.h>
11 #include <linux/pci.h>
12 #include <linux/highuid.h>
13 
14 /* get readq/writeq support for 32 bit kernels, use the low-first version */
15 #include <linux/io-64-nonatomic-lo-hi.h>
16 
17 /* File to be the magic between shared code and
18  * actual OS primitives
19  */
20 
21 #define hw_dbg(hw, S, A...)	do {} while (0)
22 
23 #define wr32(a, reg, value)	writel((value), ((a)->hw_addr + (reg)))
24 #define rd32(a, reg)		readl((a)->hw_addr + (reg))
25 
26 #define wr64(a, reg, value)	writeq((value), ((a)->hw_addr + (reg)))
27 #define rd64(a, reg)		readq((a)->hw_addr + (reg))
28 #define i40e_flush(a)		readl((a)->hw_addr + I40E_GLGEN_STAT)
29 
30 /* memory allocation tracking */
31 struct i40e_dma_mem {
32 	void *va;
33 	dma_addr_t pa;
34 	u32 size;
35 };
36 
37 #define i40e_allocate_dma_mem(h, m, unused, s, a) \
38 			i40e_allocate_dma_mem_d(h, m, s, a)
39 #define i40e_free_dma_mem(h, m) i40e_free_dma_mem_d(h, m)
40 
41 struct i40e_virt_mem {
42 	void *va;
43 	u32 size;
44 };
45 
46 #define i40e_allocate_virt_mem(h, m, s) i40e_allocate_virt_mem_d(h, m, s)
47 #define i40e_free_virt_mem(h, m) i40e_free_virt_mem_d(h, m)
48 
49 #define i40e_debug(h, m, s, ...)				\
50 do {								\
51 	if (((m) & (h)->debug_mask))				\
52 		pr_info("i40e %02x:%02x.%x " s,			\
53 			(h)->bus.bus_id, (h)->bus.device,	\
54 			(h)->bus.func, ##__VA_ARGS__);		\
55 } while (0)
56 
57 typedef enum i40e_status_code i40e_status;
58 #endif /* _I40E_OSDEP_H_ */
59