kni: initial import
[dpdk.git] / lib / librte_eal / linuxapp / kni / ethtool / igb / e1000_osdep.h
1 /*******************************************************************************
2
3   Intel(R) Gigabit Ethernet Linux driver
4   Copyright(c) 2007-2012 Intel Corporation.
5
6   This program is free software; you can redistribute it and/or modify it
7   under the terms and conditions of the GNU General Public License,
8   version 2, as published by the Free Software Foundation.
9
10   This program is distributed in the hope it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13   more details.
14
15   You should have received a copy of the GNU General Public License along with
16   this program; if not, write to the Free Software Foundation, Inc.,
17   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19   The full GNU General Public License is included in this distribution in
20   the file called "COPYING".
21
22   Contact Information:
23   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25
26 *******************************************************************************/
27
28
29 /* glue for the OS independent part of e1000
30  * includes register access macros
31  */
32
33 #ifndef _E1000_OSDEP_H_
34 #define _E1000_OSDEP_H_
35
36 #include <linux/pci.h>
37 #include <linux/delay.h>
38 #include <linux/interrupt.h>
39 #include <linux/if_ether.h>
40 #include <linux/sched.h>
41 #include "kcompat.h"
42
43 #ifndef __INTEL_COMPILER
44 #pragma GCC diagnostic ignored "-Wunused-function"
45 #endif
46
47 #define usec_delay(x) udelay(x)
48 #ifndef msec_delay
49 #define msec_delay(x) do { \
50         /* Don't mdelay in interrupt context! */ \
51         if (in_interrupt()) \
52                 BUG(); \
53         else \
54                 msleep(x); \
55 } while (0)
56
57 /* Some workarounds require millisecond delays and are run during interrupt
58  * context.  Most notably, when establishing link, the phy may need tweaking
59  * but cannot process phy register reads/writes faster than millisecond
60  * intervals...and we establish link due to a "link status change" interrupt.
61  */
62 #define msec_delay_irq(x) mdelay(x)
63 #endif
64
65 #define PCI_COMMAND_REGISTER   PCI_COMMAND
66 #define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
67 #define ETH_ADDR_LEN           ETH_ALEN
68
69 #ifdef __BIG_ENDIAN
70 #define E1000_BIG_ENDIAN __BIG_ENDIAN
71 #endif
72
73
74 #define DEBUGOUT(S)
75 #define DEBUGOUT1(S, A...)
76
77 #define DEBUGFUNC(F)
78 #define DEBUGOUT2 DEBUGOUT1
79 #define DEBUGOUT3 DEBUGOUT2
80 #define DEBUGOUT7 DEBUGOUT3
81
82 #define E1000_REGISTER(a, reg) reg
83
84 #define E1000_WRITE_REG(a, reg, value) ( \
85     writel((value), ((a)->hw_addr + E1000_REGISTER(a, reg))))
86
87 #define E1000_READ_REG(a, reg) (readl((a)->hw_addr + E1000_REGISTER(a, reg)))
88
89 #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
90     writel((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 2))))
91
92 #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
93     readl((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 2)))
94
95 #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
96 #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
97
98 #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
99     writew((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 1))))
100
101 #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
102     readw((a)->hw_addr + E1000_REGISTER(a, reg) + ((offset) << 1)))
103
104 #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
105     writeb((value), ((a)->hw_addr + E1000_REGISTER(a, reg) + (offset))))
106
107 #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
108     readb((a)->hw_addr + E1000_REGISTER(a, reg) + (offset)))
109
110 #define E1000_WRITE_REG_IO(a, reg, offset) do { \
111     outl(reg, ((a)->io_base));                  \
112     outl(offset, ((a)->io_base + 4));      } while (0)
113
114 #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, E1000_STATUS)
115
116 #define E1000_WRITE_FLASH_REG(a, reg, value) ( \
117     writel((value), ((a)->flash_address + reg)))
118
119 #define E1000_WRITE_FLASH_REG16(a, reg, value) ( \
120     writew((value), ((a)->flash_address + reg)))
121
122 #define E1000_READ_FLASH_REG(a, reg) (readl((a)->flash_address + reg))
123
124 #define E1000_READ_FLASH_REG16(a, reg) (readw((a)->flash_address + reg))
125
126 #endif /* _E1000_OSDEP_H_ */