ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / net / ixgb / ixgb_hw.h
1 /*******************************************************************************
2
3   
4   Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
5   
6   This program is free software; you can redistribute it and/or modify it 
7   under the terms of the GNU General Public License as published by the Free 
8   Software Foundation; either version 2 of the License, or (at your option) 
9   any later version.
10   
11   This program is distributed in the hope that it will be useful, but WITHOUT 
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
14   more details.
15   
16   You should have received a copy of the GNU General Public License along with
17   this program; if not, write to the Free Software Foundation, Inc., 59 
18   Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19   
20   The full GNU General Public License is included in this distribution in the
21   file called LICENSE.
22   
23   Contact Information:
24   Linux NICS <linux.nics@intel.com>
25   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 *******************************************************************************/
27
28 #ifndef _IXGB_HW_H_
29 #define _IXGB_HW_H_
30
31 #include "ixgb_osdep.h"
32
33 /* Enums */
34 typedef enum {
35         ixgb_mac_unknown = 0,
36         ixgb_82597,
37         ixgb_num_macs
38 } ixgb_mac_type;
39
40 /* Media Types */
41 typedef enum {
42         ixgb_media_type_unknown = 0,
43         ixgb_media_type_fiber = 1,
44         ixgb_num_media_types
45 } ixgb_media_type;
46
47 /* Flow Control Settings */
48 typedef enum {
49         ixgb_fc_none = 0,
50         ixgb_fc_rx_pause = 1,
51         ixgb_fc_tx_pause = 2,
52         ixgb_fc_full = 3,
53         ixgb_fc_default = 0xFF
54 } ixgb_fc_type;
55
56 /* PCI bus types */
57 typedef enum {
58         ixgb_bus_type_unknown = 0,
59         ixgb_bus_type_pci,
60         ixgb_bus_type_pcix
61 } ixgb_bus_type;
62
63 /* PCI bus speeds */
64 typedef enum {
65         ixgb_bus_speed_unknown = 0,
66         ixgb_bus_speed_33,
67         ixgb_bus_speed_66,
68         ixgb_bus_speed_100,
69         ixgb_bus_speed_133,
70         ixgb_bus_speed_reserved
71 } ixgb_bus_speed;
72
73 /* PCI bus widths */
74 typedef enum {
75         ixgb_bus_width_unknown = 0,
76         ixgb_bus_width_32,
77         ixgb_bus_width_64
78 } ixgb_bus_width;
79
80 #define IXGB_ETH_LENGTH_OF_ADDRESS   6
81
82 #define IXGB_EEPROM_SIZE    64  /* Size in words */
83
84 #define SPEED_10000  10000
85 #define FULL_DUPLEX  2
86
87 #define IXGB_DELAY_BEFORE_RESET        10       /* allow 10ms after idling rx/tx units      */
88 #define IXGB_DELAY_AFTER_RESET          1       /* allow 1ms after the reset                */
89 #define IXGB_DELAY_AFTER_EE_RESET      10       /* allow 10ms after the EEPROM reset        */
90
91 #define IXGB_DELAY_USECS_AFTER_LINK_RESET    13 /* allow 13 microseconds after the reset    */
92                                            /* NOTE: this is MICROSECONDS               */
93 #define MAX_RESET_ITERATIONS            8       /* number of iterations to get things right */
94
95 /* General Registers */
96 #define IXGB_CTRL0   0x00000    /* Device Control Register 0 - RW */
97 #define IXGB_CTRL1   0x00008    /* Device Control Register 1 - RW */
98 #define IXGB_STATUS  0x00010    /* Device Status Register - RO */
99 #define IXGB_EECD    0x00018    /* EEPROM/Flash Control/Data Register - RW */
100 #define IXGB_MFS     0x00020    /* Maximum Frame Size - RW */
101
102 /* Interrupt */
103 #define IXGB_ICR     0x00080    /* Interrupt Cause Read - R/clr */
104 #define IXGB_ICS     0x00088    /* Interrupt Cause Set - RW */
105 #define IXGB_IMS     0x00090    /* Interrupt Mask Set/Read - RW */
106 #define IXGB_IMC     0x00098    /* Interrupt Mask Clear - WO */
107
108 /* Receive */
109 #define IXGB_RCTL    0x00100    /* RX Control - RW */
110 #define IXGB_FCRTL   0x00108    /* Flow Control Receive Threshold Low - RW */
111 #define IXGB_FCRTH   0x00110    /* Flow Control Receive Threshold High - RW */
112 #define IXGB_RDBAL   0x00118    /* RX Descriptor Base Low - RW */
113 #define IXGB_RDBAH   0x0011C    /* RX Descriptor Base High - RW */
114 #define IXGB_RDLEN   0x00120    /* RX Descriptor Length - RW */
115 #define IXGB_RDH     0x00128    /* RX Descriptor Head - RW */
116 #define IXGB_RDT     0x00130    /* RX Descriptor Tail - RW */
117 #define IXGB_RDTR    0x00138    /* RX Delay Timer Ring - RW */
118 #define IXGB_RXDCTL  0x00140    /* Receive Descriptor Control - RW */
119 #define IXGB_RAIDC   0x00148    /* Receive Adaptive Interrupt Delay Control - RW */
120 #define IXGB_RXCSUM  0x00158    /* Receive Checksum Control - RW */
121 #define IXGB_RA      0x00180    /* Receive Address Array Base - RW */
122 #define IXGB_RAL     0x00180    /* Receive Address Low [0:15] - RW */
123 #define IXGB_RAH     0x00184    /* Receive Address High [0:15] - RW */
124 #define IXGB_MTA     0x00200    /* Multicast Table Array [0:127] - RW */
125 #define IXGB_VFTA    0x00400    /* VLAN Filter Table Array [0:127] - RW */
126 #define IXGB_REQ_RX_DESCRIPTOR_MULTIPLE 8
127
128 /* Transmit */
129 #define IXGB_TCTL    0x00600    /* TX Control - RW */
130 #define IXGB_TDBAL   0x00608    /* TX Descriptor Base Low - RW */
131 #define IXGB_TDBAH   0x0060C    /* TX Descriptor Base High - RW */
132 #define IXGB_TDLEN   0x00610    /* TX Descriptor Length - RW */
133 #define IXGB_TDH     0x00618    /* TX Descriptor Head - RW */
134 #define IXGB_TDT     0x00620    /* TX Descriptor Tail - RW */
135 #define IXGB_TIDV    0x00628    /* TX Interrupt Delay Value - RW */
136 #define IXGB_TXDCTL  0x00630    /* Transmit Descriptor Control - RW */
137 #define IXGB_TSPMT   0x00638    /* TCP Segmentation PAD & Min Threshold - RW */
138 #define IXGB_PAP     0x00640    /* Pause and Pace - RW */
139 #define IXGB_REQ_TX_DESCRIPTOR_MULTIPLE 8
140
141 /* Physical */
142 #define IXGB_PCSC1   0x00700    /* PCS Control 1 - RW */
143 #define IXGB_PCSC2   0x00708    /* PCS Control 2 - RW */
144 #define IXGB_PCSS1   0x00710    /* PCS Status 1 - RO */
145 #define IXGB_PCSS2   0x00718    /* PCS Status 2 - RO */
146 #define IXGB_XPCSS   0x00720    /* 10GBASE-X PCS Status (or XGXS Lane Status) - RO */
147 #define IXGB_UCCR    0x00728    /* Unilink Circuit Control Register */
148 #define IXGB_XPCSTC  0x00730    /* 10GBASE-X PCS Test Control */
149 #define IXGB_MACA    0x00738    /* MDI Autoscan Command and Address - RW */
150 #define IXGB_APAE    0x00740    /* Autoscan PHY Address Enable - RW */
151 #define IXGB_ARD     0x00748    /* Autoscan Read Data - RO */
152 #define IXGB_AIS     0x00750    /* Autoscan Interrupt Status - RO */
153 #define IXGB_MSCA    0x00758    /* MDI Single Command and Address - RW */
154 #define IXGB_MSRWD   0x00760    /* MDI Single Read and Write Data - RW, RO */
155
156 /* Wake-up */
157 #define IXGB_WUFC    0x00808    /* Wake Up Filter Control - RW */
158 #define IXGB_WUS     0x00810    /* Wake Up Status - RO */
159 #define IXGB_FFLT    0x01000    /* Flexible Filter Length Table - RW */
160 #define IXGB_FFMT    0x01020    /* Flexible Filter Mask Table - RW */
161 #define IXGB_FTVT    0x01420    /* Flexible Filter Value Table - RW */
162
163 /* Statistics */
164 #define IXGB_TPRL    0x02000    /* Total Packets Received (Low) */
165 #define IXGB_TPRH    0x02004    /* Total Packets Received (High) */
166 #define IXGB_GPRCL   0x02008    /* Good Packets Received Count (Low) */
167 #define IXGB_GPRCH   0x0200C    /* Good Packets Received Count (High) */
168 #define IXGB_BPRCL   0x02010    /* Broadcast Packets Received Count (Low) */
169 #define IXGB_BPRCH   0x02014    /* Broadcast Packets Received Count (High) */
170 #define IXGB_MPRCL   0x02018    /* Multicast Packets Received Count (Low) */
171 #define IXGB_MPRCH   0x0201C    /* Multicast Packets Received Count (High) */
172 #define IXGB_UPRCL   0x02020    /* Unicast Packets Received Count (Low) */
173 #define IXGB_UPRCH   0x02024    /* Unicast Packets Received Count (High) */
174 #define IXGB_VPRCL   0x02028    /* VLAN Packets Received Count (Low) */
175 #define IXGB_VPRCH   0x0202C    /* VLAN Packets Received Count (High) */
176 #define IXGB_JPRCL   0x02030    /* Jumbo Packets Received Count (Low) */
177 #define IXGB_JPRCH   0x02034    /* Jumbo Packets Received Count (High) */
178 #define IXGB_GORCL   0x02038    /* Good Octets Received Count (Low) */
179 #define IXGB_GORCH   0x0203C    /* Good Octets Received Count (High) */
180 #define IXGB_TORL    0x02040    /* Total Octets Received (Low) */
181 #define IXGB_TORH    0x02044    /* Total Octets Received (High) */
182 #define IXGB_RNBC    0x02048    /* Receive No Buffers Count */
183 #define IXGB_RUC     0x02050    /* Receive Undersize Count */
184 #define IXGB_ROC     0x02058    /* Receive Oversize Count */
185 #define IXGB_RLEC    0x02060    /* Receive Length Error Count */
186 #define IXGB_CRCERRS 0x02068    /* CRC Error Count */
187 #define IXGB_ICBC    0x02070    /* Illegal control byte in mid-packet Count */
188 #define IXGB_ECBC    0x02078    /* Error Control byte in mid-packet Count */
189 #define IXGB_MPC     0x02080    /* Missed Packets Count */
190 #define IXGB_TPTL    0x02100    /* Total Packets Transmitted (Low) */
191 #define IXGB_TPTH    0x02104    /* Total Packets Transmitted (High) */
192 #define IXGB_GPTCL   0x02108    /* Good Packets Transmitted Count (Low) */
193 #define IXGB_GPTCH   0x0210C    /* Good Packets Transmitted Count (High) */
194 #define IXGB_BPTCL   0x02110    /* Broadcast Packets Transmitted Count (Low) */
195 #define IXGB_BPTCH   0x02114    /* Broadcast Packets Transmitted Count (High) */
196 #define IXGB_MPTCL   0x02118    /* Multicast Packets Transmitted Count (Low) */
197 #define IXGB_MPTCH   0x0211C    /* Multicast Packets Transmitted Count (High) */
198 #define IXGB_UPTCL   0x02120    /* Unicast Packets Transmitted Count (Low) */
199 #define IXGB_UPTCH   0x02124    /* Unicast Packets Transmitted Count (High) */
200 #define IXGB_VPTCL   0x02128    /* VLAN Packets Transmitted Count (Low) */
201 #define IXGB_VPTCH   0x0212C    /* VLAN Packets Transmitted Count (High) */
202 #define IXGB_JPTCL   0x02130    /* Jumbo Packets Transmitted Count (Low) */
203 #define IXGB_JPTCH   0x02134    /* Jumbo Packets Transmitted Count (High) */
204 #define IXGB_GOTCL   0x02138    /* Good Octets Transmitted Count (Low) */
205 #define IXGB_GOTCH   0x0213C    /* Good Octets Transmitted Count (High) */
206 #define IXGB_TOTL    0x02140    /* Total Octets Transmitted Count (Low) */
207 #define IXGB_TOTH    0x02144    /* Total Octets Transmitted Count (High) */
208 #define IXGB_DC      0x02148    /* Defer Count */
209 #define IXGB_PLT64C  0x02150    /* Packet Transmitted was less than 64 bytes Count */
210 #define IXGB_TSCTC   0x02170    /* TCP Segmentation Context Transmitted Count */
211 #define IXGB_TSCTFC  0x02178    /* TCP Segmentation Context Tx Fail Count */
212 #define IXGB_IBIC    0x02180    /* Illegal byte during Idle stream count */
213 #define IXGB_RFC     0x02188    /* Remote Fault Count */
214 #define IXGB_LFC     0x02190    /* Local Fault Count */
215 #define IXGB_PFRC    0x02198    /* Pause Frame Receive Count */
216 #define IXGB_PFTC    0x021A0    /* Pause Frame Transmit Count */
217 #define IXGB_MCFRC   0x021A8    /* MAC Control Frames (non-Pause) Received Count */
218 #define IXGB_MCFTC   0x021B0    /* MAC Control Frames (non-Pause) Transmitted Count */
219 #define IXGB_XONRXC  0x021B8    /* XON Received Count */
220 #define IXGB_XONTXC  0x021C0    /* XON Transmitted Count */
221 #define IXGB_XOFFRXC 0x021C8    /* XOFF Received Count */
222 #define IXGB_XOFFTXC 0x021D0    /* XOFF Transmitted Count */
223 #define IXGB_RJC     0x021D8    /* Receive Jabber Count */
224
225 /* CTRL0 Bit Masks */
226 #define IXGB_CTRL0_LRST     0x00000008
227 #define IXGB_CTRL0_JFE      0x00000010
228 #define IXGB_CTRL0_SDP0     0x00040000
229 #define IXGB_CTRL0_SDP1     0x00080000
230 #define IXGB_CTRL0_SDP2     0x00100000
231 #define IXGB_CTRL0_SDP3     0x00200000
232 #define IXGB_CTRL0_SDP0_DIR 0x00400000
233 #define IXGB_CTRL0_SDP1_DIR 0x00800000
234 #define IXGB_CTRL0_SDP2_DIR 0x01000000
235 #define IXGB_CTRL0_SDP3_DIR 0x02000000
236 #define IXGB_CTRL0_RST      0x04000000
237 #define IXGB_CTRL0_RPE      0x08000000
238 #define IXGB_CTRL0_TPE      0x10000000
239 #define IXGB_CTRL0_VME      0x40000000
240
241 /* CTRL1 Bit Masks */
242
243 #define IXGB_CTRL1_EE_RST      0x00002000
244
245 /* STATUS Bit Masks */
246 #define IXGB_STATUS_LU            0x00000002
247
248 #define IXGB_STATUS_TXOFF         0x00000010
249
250 #define IXGB_STATUS_PCI_SPD       0x00000800
251 #define IXGB_STATUS_BUS64         0x00001000
252 #define IXGB_STATUS_PCIX_MODE     0x00002000
253 #define IXGB_STATUS_PCIX_SPD_MASK 0x0000C000
254 #define IXGB_STATUS_PCIX_SPD_66   0x00000000
255 #define IXGB_STATUS_PCIX_SPD_100  0x00004000
256 #define IXGB_STATUS_PCIX_SPD_133  0x00008000
257
258 /* EECD Bit Masks */
259 #define IXGB_EECD_SK       0x00000001
260 #define IXGB_EECD_CS       0x00000002
261 #define IXGB_EECD_DI       0x00000004
262 #define IXGB_EECD_DO       0x00000008
263
264 /* MFS */
265 #define IXGB_MFS_SHIFT 16
266
267 /* Interrupt Register Bit Masks (used for ICR, ICS, IMS, and IMC) */
268 #define IXGB_INT_TXDW     0x00000001
269 #define IXGB_INT_LSC      0x00000004
270 #define IXGB_INT_RXSEQ    0x00000008
271 #define IXGB_INT_RXDMT0   0x00000010
272 #define IXGB_INT_RXO      0x00000040
273 #define IXGB_INT_RXT0     0x00000080
274
275 /* RCTL Bit Masks */
276 #define IXGB_RCTL_RXEN        0x00000002
277 #define IXGB_RCTL_UPE         0x00000008
278 #define IXGB_RCTL_MPE         0x00000010
279 #define IXGB_RCTL_RDMTS_1_2   0x00000000
280 #define IXGB_RCTL_MO_SHIFT    12
281 #define IXGB_RCTL_BAM         0x00008000
282 #define IXGB_RCTL_BSIZE_2048  0x00000000
283 #define IXGB_RCTL_BSIZE_4096  0x00010000
284 #define IXGB_RCTL_BSIZE_8192  0x00020000
285 #define IXGB_RCTL_BSIZE_16384 0x00030000
286 #define IXGB_RCTL_VFE         0x00040000
287 #define IXGB_RCTL_CFIEN       0x00080000
288 #define IXGB_RCTL_CFI         0x00100000
289 #define IXGB_RCTL_CFF         0x00800000
290 #define IXGB_RCTL_SECRC       0x04000000
291
292 /* FCRTL Bit Masks */
293 #define IXGB_FCRTL_XONE       0x80000000
294
295 /* RXDCTL Bit Masks */
296 #define IXGB_RXDCTL_PTHRESH_SHIFT 0
297 #define IXGB_RXDCTL_HTHRESH_SHIFT 9
298 #define IXGB_RXDCTL_WTHRESH_SHIFT 18
299
300 /* RAIDC Bit Masks */
301 #define IXGB_RAIDC_DELAY_SHIFT   11
302 #define IXGB_RAIDC_POLL_SHIFT    20
303 #define IXGB_RAIDC_RXT_GATE      0x40000000
304 #define IXGB_RAIDC_EN            0x80000000
305
306 /* RXCSUM Bit Masks */
307 #define IXGB_RXCSUM_TUOFL 0x00000200
308
309 /* RAH Bit Masks */
310 #define IXGB_RAH_AV        0x80000000
311
312 /* TCTL Bit Masks */
313 #define IXGB_TCTL_TCE  0x00000001
314 #define IXGB_TCTL_TXEN 0x00000002
315 #define IXGB_TCTL_TPDE 0x00000004
316
317 /* TXDCTL Bit Masks */
318 #define IXGB_TXDCTL_HTHRESH_SHIFT 8
319
320 /* TSPMT Bit Masks */
321
322 /* PAP Bit Masks */
323
324 /* PCSC1 Bit Masks */
325
326 /* PCSC2 Bit Masks */
327
328 /* PCSS1 Bit Masks */
329
330 /* PCSS2 Bit Masks */
331
332 /* XPCSS Bit Masks */
333 #define IXGB_XPCSS_ALIGN_STATUS 0x00001000
334
335 /* XPCSTC Bit Masks */
336
337 /* MSCA bit Masks */
338 /* New Protocol Address */
339 #define IXGB_MSCA_NP_ADDR_SHIFT     0
340 /* Either Device Type or Register Address,depending on ST_CODE */
341 #define IXGB_MSCA_DEV_TYPE_SHIFT    16
342 #define IXGB_MSCA_PHY_ADDR_SHIFT    21
343 #define IXGB_MSCA_ADDR_CYCLE        0x00000000
344 #define IXGB_MSCA_WRITE             0x04000000
345 #define IXGB_MSCA_READ              0x08000000
346 /* Initiate command, self-clearing when command completes */
347 #define IXGB_MSCA_MDI_COMMAND       0x40000000
348 /*MDI In Progress Enable. */
349
350 /* MSRWD bit masks */
351 #define IXGB_MSRWD_READ_DATA_SHIFT  16
352
353 /* Definitions for the TXN17401 devices on the MDIO bus. */
354 #define IXGB_PHY_ADDRESS             0x0        /* Single PHY, multiple "Devices" */
355
356 /* Five bit Device IDs */
357 #define TXN17401_PMA_PMD_DID    0x01
358 #define TXN17401_PCS_DID        0x03
359 #define TXN17401_XGXS_DID       0x04
360
361 /* PMA/PMD registers and bit definitions. */
362 /* Note: This is a very limited set of definitions,      */
363 /* only implemented features are defined.                */
364 #define TXN17401_PMA_PMD_CR1        0x0000
365
366 #define TXN17401_PMA_PMD_CR1_RESET  0x8000
367
368 struct ixgb_rx_desc {
369         uint64_t buff_addr;
370         u16 length;
371         u16 reserved;
372         u8 status;
373         u8 errors;
374         u16 special;
375 };
376
377 #define IXGB_RX_DESC_STATUS_DD    0x01
378 #define IXGB_RX_DESC_STATUS_EOP   0x02
379 #define IXGB_RX_DESC_STATUS_IXSM  0x04
380 #define IXGB_RX_DESC_STATUS_VP    0x08
381 #define IXGB_RX_DESC_STATUS_TCPCS 0x20
382
383 #define IXGB_RX_DESC_ERRORS_CE   0x01
384 #define IXGB_RX_DESC_ERRORS_SE   0x02
385 #define IXGB_RX_DESC_ERRORS_P    0x08
386 #define IXGB_RX_DESC_ERRORS_TCPE 0x20
387 #define IXGB_RX_DESC_ERRORS_RXE  0x80
388
389 #define IXGB_RX_DESC_SPECIAL_VLAN_MASK  0x0FFF  /* VLAN ID is in lower 12 bits */
390
391 struct ixgb_tx_desc {
392         uint64_t buff_addr;
393         u32 cmd_type_len;
394         u8 status;
395         u8 popts;
396         u16 vlan;
397 };
398
399 #define IXGB_TX_DESC_CMD_EOP        0x01000000
400 #define IXGB_TX_DESC_CMD_TSE        0x04000000
401 #define IXGB_TX_DESC_CMD_RS         0x08000000
402 #define IXGB_TX_DESC_CMD_VLE        0x40000000
403 #define IXGB_TX_DESC_CMD_IDE        0x80000000
404
405 #define IXGB_TX_DESC_TYPE           0x00100000
406
407 #define IXGB_TX_DESC_STATUS_DD  0x01
408
409 #define IXGB_TX_DESC_POPTS_IXSM 0x01
410 #define IXGB_TX_DESC_POPTS_TXSM 0x02
411
412 struct ixgb_context_desc {
413         u8 ipcss;
414         u8 ipcso;
415         u16 ipcse;
416         u8 tucss;
417         u8 tucso;
418         u16 tucse;
419         u32 cmd_type_len;
420         u8 status;
421         u8 hdr_len;
422         u16 mss;
423 };
424
425 #define IXGB_CONTEXT_DESC_CMD_TCP 0x01000000
426 #define IXGB_CONTEXT_DESC_CMD_IP  0x02000000
427 #define IXGB_CONTEXT_DESC_CMD_TSE 0x04000000
428 #define IXGB_CONTEXT_DESC_CMD_RS  0x08000000
429 #define IXGB_CONTEXT_DESC_CMD_IDE 0x80000000
430
431 #define IXGB_CONTEXT_DESC_TYPE 0x00000000
432
433 /* Filters */
434 #define IXGB_RAR_ENTRIES          16    /* Number of entries in Rx Address array */
435 #define IXGB_MC_TBL_SIZE          128   /* Multicast Filter Table (4096 bits) */
436 #define IXGB_VLAN_FILTER_TBL_SIZE 128   /* VLAN Filter Table (4096 bits) */
437
438 #define ENET_HEADER_SIZE            14
439 #define ENET_FCS_LENGTH             4
440 #define IXGB_MAX_NUM_MULTICAST_ADDRESSES    128
441 #define IXGB_MIN_ENET_FRAME_SIZE_WITHOUT_FCS    60
442 #define IXGB_MAX_ENET_FRAME_SIZE_WITHOUT_FCS    1514
443 #define IXGB_MAX_JUMBO_FRAME_SIZE       0x3F00
444
445 /* Phy Addresses */
446
447 /*
448  * This is a little-endian specific check.
449  */
450 #define IS_MULTICAST(Address) \
451     (boolean_t)(((u8 *)(Address))[0] & ((u8)0x01))
452
453 /*
454  * Check whether an address is broadcast.
455  */
456 #define IS_BROADCAST(Address)               \
457     ((((u8 *)(Address))[0] == ((u8)0xff)) && (((u8 *)(Address))[1] == ((u8)0xff)))
458
459 /* Flow control parameters */
460 struct ixgb_fc {
461         u32 high_water; /* Flow Control High-water          */
462         u32 low_water;  /* Flow Control Low-water           */
463         u16 pause_time; /* Flow Control Pause timer         */
464         boolean_t send_xon;     /* Flow control send XON            */
465         ixgb_fc_type type;      /* Type of flow control             */
466 };
467
468 /* The historical defaults for the flow control values are given below. */
469
470 /* Phy definitions */
471 #define IXGB_MAX_PHY_REG_ADDRESS    0xFFFF
472 #define IXGB_MAX_PHY_ADDRESS        31
473 #define IXGB_MAX_PHY_DEV_TYPE       31
474
475 /* Bus parameters */
476 struct ixgb_bus {
477         ixgb_bus_speed speed;
478         ixgb_bus_width width;
479         ixgb_bus_type type;
480 };
481
482 struct ixgb_hw {
483         u8 *hw_addr;    /* Base Address of the hardware     */
484         void *back;             /* Pointer to OS-dependent struct   */
485         struct ixgb_fc fc;      /* Flow control parameters          */
486         struct ixgb_bus bus;    /* Bus parameters                   */
487         u32 phy_id;     /* Phy Identifier                   */
488         u32 phy_addr;   /* XGMII address of Phy             */
489         ixgb_mac_type mac_type; /* Identifier for MAC controller    */
490         u32 max_frame_size;     /* Maximum frame size supported     */
491         u32 mc_filter_type;     /* Multicast filter hash type       */
492         u32 num_mc_addrs;       /* Number of current Multicast addrs */
493         u8 curr_mac_addr[IXGB_ETH_LENGTH_OF_ADDRESS];   /* Individual address currently programmed in MAC */
494         u32 num_tx_desc;        /* Number of Transmit descriptors   */
495         u32 num_rx_desc;        /* Number of Receive descriptors    */
496         u32 rx_buffer_size;     /* Size of Receive buffer           */
497         boolean_t link_up;      /* TRUE if link is valid            */
498         boolean_t adapter_stopped;      /* State of adapter                 */
499         u16 device_id;  /* device id from PCI configuration space */
500         u16 vendor_id;  /* vendor id from PCI configuration space */
501         u16 subsystem_vendor_id;        /* subsystem vendor id from PCI configuration space */
502         u16 subsystem_id;       /* subsystem id from PCI configuration space */
503         u16 eeprom[IXGB_EEPROM_SIZE];   /* EEPROM contents read at init time  */
504         uint64_t io_base;       /* Our I/O mapped location */
505         u32 lastLFC;
506         u32 lastRFC;
507 };
508
509 struct ixgb_hw_stats {
510         uint64_t tprl;
511         uint64_t tprh;
512         uint64_t gprcl;
513         uint64_t gprch;
514         uint64_t bprcl;
515         uint64_t bprch;
516         uint64_t mprcl;
517         uint64_t mprch;
518         uint64_t uprcl;
519         uint64_t uprch;
520         uint64_t vprcl;
521         uint64_t vprch;
522         uint64_t jprcl;
523         uint64_t jprch;
524         uint64_t gorcl;
525         uint64_t gorch;
526         uint64_t torl;
527         uint64_t torh;
528         uint64_t rnbc;
529         uint64_t ruc;
530         uint64_t roc;
531         uint64_t rlec;
532         uint64_t crcerrs;
533         uint64_t icbc;
534         uint64_t ecbc;
535         uint64_t mpc;
536         uint64_t tptl;
537         uint64_t tpth;
538         uint64_t gptcl;
539         uint64_t gptch;
540         uint64_t bptcl;
541         uint64_t bptch;
542         uint64_t mptcl;
543         uint64_t mptch;
544         uint64_t uptcl;
545         uint64_t uptch;
546         uint64_t vptcl;
547         uint64_t vptch;
548         uint64_t jptcl;
549         uint64_t jptch;
550         uint64_t gotcl;
551         uint64_t gotch;
552         uint64_t totl;
553         uint64_t toth;
554         uint64_t dc;
555         uint64_t plt64c;
556         uint64_t tsctc;
557         uint64_t tsctfc;
558         uint64_t ibic;
559         uint64_t rfc;
560         uint64_t lfc;
561         uint64_t pfrc;
562         uint64_t pftc;
563         uint64_t mcfrc;
564         uint64_t mcftc;
565         uint64_t xonrxc;
566         uint64_t xontxc;
567         uint64_t xoffrxc;
568         uint64_t xofftxc;
569         uint64_t rjc;
570 };
571
572 /* Function Prototypes */
573 extern boolean_t ixgb_adapter_stop(struct ixgb_hw *hw);
574 extern boolean_t ixgb_init_hw(struct ixgb_hw *hw);
575 extern boolean_t ixgb_adapter_start(struct ixgb_hw *hw);
576 extern void ixgb_init_rx_addrs(struct ixgb_hw *hw);
577 extern void ixgb_check_for_link(struct ixgb_hw *hw);
578 extern boolean_t ixgb_check_for_bad_link(struct ixgb_hw *hw);
579 extern boolean_t ixgb_setup_fc(struct ixgb_hw *hw);
580 extern void ixgb_clear_hw_cntrs(struct ixgb_hw *hw);
581 extern boolean_t mac_addr_valid(u8 * mac_addr);
582
583 extern u16 ixgb_read_phy_reg(struct ixgb_hw *hw,
584                                   u32 reg_addr,
585                                   u32 phy_addr, u32 device_type);
586
587 extern void ixgb_write_phy_reg(struct ixgb_hw *hw,
588                                u32 reg_addr,
589                                u32 phy_addr,
590                                u32 device_type, u16 data);
591
592 extern void ixgb_rar_set(struct ixgb_hw *hw, u8 * addr, u32 index);
593
594 /* Filters (multicast, vlan, receive) */
595 extern void ixgb_mc_addr_list_update(struct ixgb_hw *hw,
596                                      u8 * mc_addr_list,
597                                      u32 mc_addr_count, u32 pad);
598
599 /* Vfta functions */
600 extern void ixgb_write_vfta(struct ixgb_hw *hw,
601                             u32 offset, u32 value);
602
603 extern void ixgb_clear_vfta(struct ixgb_hw *hw);
604
605 /* Access functions to eeprom data */
606 void ixgb_get_ee_mac_addr(struct ixgb_hw *hw, u8 * mac_addr);
607 u16 ixgb_get_ee_compatibility(struct ixgb_hw *hw);
608 u32 ixgb_get_ee_pba_number(struct ixgb_hw *hw);
609 u16 ixgb_get_ee_init_ctrl_reg_1(struct ixgb_hw *hw);
610 u16 ixgb_get_ee_init_ctrl_reg_2(struct ixgb_hw *hw);
611 u16 ixgb_get_ee_subsystem_id(struct ixgb_hw *hw);
612 u16 ixgb_get_ee_subvendor_id(struct ixgb_hw *hw);
613 u16 ixgb_get_ee_device_id(struct ixgb_hw *hw);
614 u16 ixgb_get_ee_vendor_id(struct ixgb_hw *hw);
615 u16 ixgb_get_ee_swdpins_reg(struct ixgb_hw *hw);
616 u8 ixgb_get_ee_d3_power(struct ixgb_hw *hw);
617 u8 ixgb_get_ee_d0_power(struct ixgb_hw *hw);
618 boolean_t ixgb_get_eeprom_data(struct ixgb_hw *hw);
619
620 /* Everything else */
621 void ixgb_led_on(struct ixgb_hw *hw);
622 void ixgb_led_off(struct ixgb_hw *hw);
623 void ixgb_write_pci_cfg(struct ixgb_hw *hw, u32 reg, u16 * value);
624
625 #endif                          /* _IXGB_HW_H_ */