]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/staging/sxg/sxghw.h
Staging: sxg: remove firmware files from sgx_ethtool.c
[linux-2.6-omap-h63xx.git] / drivers / staging / sxg / sxghw.h
1 /*************************************************************
2  * Copyright © 1997-2007 Alacritech, Inc. All rights reserved
3  *
4  * $Id: sxghw.h,v 1.2 2008/07/24 17:24:23 chris Exp $
5  *
6  * sxghw.h:
7  *
8  * This file contains structures and definitions for the
9  * Alacritech Sahara hardware
10  *
11  **********************************************************/
12
13
14 /* PCI Configuration space */
15 /*  PCI Vendor ID */
16 #define SXG_VENDOR_ID                   0x139A  /* Alacritech's Vendor ID */
17
18 /*  PCI Device ID */
19 #define SXG_DEVICE_ID                   0x0009  /* Sahara Device ID */
20
21 /*
22  * Subsystem IDs.
23  *
24  * The subsystem ID value is broken into bit fields as follows:
25  *              Bits [15:12] - Function
26  *              Bits [11:8]  - OEM and/or operating system.
27  *              Bits [7:0]   - Base SID.
28  */
29
30 /* SSID field (bit) masks */
31 #define SSID_BASE_MASK          0x00FF  /* Base subsystem ID mask */
32 #define SSID_OEM_MASK           0x0F00  /* Subsystem OEM mask */
33 #define SSID_FUNC_MASK          0xF000  /* Subsystem function mask */
34
35 /* Base SSID's */
36 /* 100022 Sahara prototype (XenPak) board */
37 #define SSID_SAHARA_PROTO       0x0018
38 #define SSID_SAHARA_FIBER       0x0019  /* 100023 Sahara 1-port fiber board */
39 #define SSID_SAHARA_COPPER      0x001A  /* 100024 Sahara 1-port copper board */
40
41 /* Useful SSID macros */
42 /* isolate base SSID bits */
43 #define SSID_BASE(ssid)         ((ssid) & SSID_BASE_MASK)
44 /* isolate SSID OEM bits */
45 #define SSID_OEM(ssid)          ((ssid) & SSID_OEM_MASK)
46 /* isolate SSID function bits */
47 #define SSID_FUNC(ssid)         ((ssid) & SSID_FUNC_MASK)
48
49
50 /* HW Register Space */
51 #define SXG_HWREG_MEMSIZE       0x4000          /* 16k */
52
53 #pragma pack(push, 1)
54 struct sxg_hw_regs {
55         u32     Reset;          /* Write 0xdead to invoke soft reset */
56         u32     Pad1;           /* No register defined at offset 4 */
57         u32     InterruptMask0; /* Deassert legacy interrupt on function 0 */
58         u32     InterruptMask1; /* Deassert legacy interrupt on function 1 */
59         u32     UcodeDataLow;   /* Store microcode instruction bits 31-0 */
60         u32     UcodeDataMiddle;        /* Store microcode instruction bits 63-32 */
61         u32     UcodeDataHigh;  /* Store microcode instruction bits 95-64 */
62         u32     UcodeAddr;      /* Store microcode address - See flags below */
63         u32     PadTo0x80[24];  /* Pad to Xcv configuration registers */
64         u32     MacConfig0;     /* 0x80 - AXGMAC Configuration Register 0 */
65         u32     MacConfig1;     /* 0x84 - AXGMAC Configuration Register 1 */
66         u32     MacConfig2;     /* 0x88 - AXGMAC Configuration Register 2 */
67         u32     MacConfig3;     /* 0x8C - AXGMAC Configuration Register 3 */
68         u32     MacAddressLow;  /* 0x90 - AXGMAC MAC Station Address - octets 1-4 */
69         u32     MacAddressHigh; /* 0x94 - AXGMAC MAC Station Address - octets 5-6 */
70         u32     MacReserved1[2];        /* 0x98 - AXGMAC Reserved */
71         u32     MacMaxFrameLen; /* 0xA0 - AXGMAC Maximum Frame Length */
72         u32     MacReserved2[2];        /* 0xA4 - AXGMAC Reserved */
73         u32     MacRevision;    /* 0xAC - AXGMAC Revision Level Register */
74         u32     MacReserved3[4];        /* 0xB0 - AXGMAC Reserved */
75         u32     MacAmiimCmd;    /* 0xC0 - AXGMAC AMIIM Command Register */
76         u32     MacAmiimField;  /* 0xC4 - AXGMAC AMIIM Field Register */
77         u32     MacAmiimConfig; /* 0xC8 - AXGMAC AMIIM Configuration Register */
78         u32     MacAmiimLink;   /* 0xCC - AXGMAC AMIIM Link Fail Vector Register */
79         u32     MacAmiimIndicator;      /* 0xD0 - AXGMAC AMIIM Indicator Registor */
80         u32     PadTo0x100[11];         /* 0xD4 - 0x100 - Pad */
81         u32     XmtConfig;      /* 0x100 - Transmit Configuration Register */
82         u32     RcvConfig;      /* 0x104 - Receive Configuration Register 1 */
83         u32     LinkAddress0Low;        /* 0x108 - Link address 0 */
84         u32     LinkAddress0High;       /* 0x10C - Link address 0 */
85         u32     LinkAddress1Low;        /* 0x110 - Link address 1 */
86         u32     LinkAddress1High;       /* 0x114 - Link address 1 */
87         u32     LinkAddress2Low;        /* 0x118 - Link address 2 */
88         u32     LinkAddress2High;       /* 0x11C - Link address 2 */
89         u32     LinkAddress3Low;        /* 0x120 - Link address 3 */
90         u32     LinkAddress3High;       /* 0x124 - Link address 3 */
91         u32     ToeplitzKey[10];        /* 0x128 - 0x150 - Toeplitz key */
92         u32     SocketKey[10];          /* 0x150 - 0x178 - Socket Key */
93         u32     LinkStatus;             /* 0x178 - Link status */
94         u32     ClearStats;             /* 0x17C - Clear Stats */
95         u32     XmtErrorsLow;           /* 0x180 - Transmit stats - errors */
96         u32     XmtErrorsHigh;          /* 0x184 - Transmit stats - errors */
97         u32     XmtFramesLow;   /* 0x188 - Transmit stats - frame count */
98         u32     XmtFramesHigh;  /* 0x18C - Transmit stats - frame count */
99         u32     XmtBytesLow;    /* 0x190 - Transmit stats - byte count */
100         u32     XmtBytesHigh;   /* 0x194 - Transmit stats - byte count */
101         u32     XmtTcpSegmentsLow;      /* 0x198 - Transmit stats - TCP segments */
102         u32     XmtTcpSegmentsHigh;     /* 0x19C - Transmit stats - TCP segments */
103         u32     XmtTcpBytesLow;         /* 0x1A0 - Transmit stats - TCP bytes */
104         u32     XmtTcpBytesHigh;        /* 0x1A4 - Transmit stats - TCP bytes */
105         u32     RcvErrorsLow;           /* 0x1A8 - Receive stats - errors */
106         u32     RcvErrorsHigh;          /* 0x1AC - Receive stats - errors */
107         u32     RcvFramesLow;           /* 0x1B0 - Receive stats - frame count */
108         u32     RcvFramesHigh;          /* 0x1B4 - Receive stats - frame count */
109         u32     RcvBytesLow;            /* 0x1B8 - Receive stats - byte count */
110         u32     RcvBytesHigh;           /* 0x1BC - Receive stats - byte count */
111         u32     RcvTcpSegmentsLow;      /* 0x1C0 - Receive stats - TCP segments */
112         u32     RcvTcpSegmentsHigh;     /* 0x1C4 - Receive stats - TCP segments */
113         u32     RcvTcpBytesLow;         /* 0x1C8 - Receive stats - TCP bytes */
114         u32     RcvTcpBytesHigh;        /* 0x1CC - Receive stats - TCP bytes */
115         u32     PadTo0x200[12];         /* 0x1D0 - 0x200 - Pad */
116         u32     Software[1920];         /* 0x200 - 0x2000 - Software defined (not used) */
117         u32     MsixTable[1024];        /* 0x2000 - 0x3000 - MSIX Table */
118         u32     MsixBitArray[1024];     /* 0x3000 - 0x4000 - MSIX Pending Bit Array */
119 };
120 #pragma pack(pop)
121
122 /* Microcode Address Flags */
123 #define MICROCODE_ADDRESS_GO            0x80000000      /* Start microcode */
124 #define MICROCODE_ADDRESS_WRITE         0x40000000      /* Store microcode */
125 #define MICROCODE_ADDRESS_READ          0x20000000      /* Read microcode */
126 #define MICROCODE_ADDRESS_PARITY        0x10000000/* Parity error detected */
127 #define MICROCODE_ADDRESS_MASK          0x00001FFF      /* Address bits */
128
129 /* Link Address Registers */
130 /* Applied to link address high */
131 #define LINK_ADDRESS_ENABLE     0x80000000
132
133 /* Microsoft register space size */
134 #define SXG_UCODEREG_MEMSIZE    0x40000         /* 256k */
135
136 /*
137  * Sahara microcode register address format.  The command code,
138  * extended command code, and associated processor are encoded in
139  * the address bits as follows
140  */
141 #define SXG_ADDRESS_CODE_SHIFT          2               /* Base command code */
142 #define SXG_ADDRESS_CODE_MASK           0x0000003C
143 /* Extended (or sub) command code */
144 #define SXG_ADDRESS_EXCODE_SHIFT        6
145 #define SXG_ADDRESS_EXCODE_MASK         0x00001FC0
146 #define SXG_ADDRESS_CPUID_SHIFT         13              /* CPU */
147 #define SXG_ADDRESS_CPUID_MASK          0x0003E000
148 /* Used to sanity check UCODE_REGS structure */
149 #define SXG_REGISTER_SIZE_PER_CPU       0x00002000
150
151 /* Sahara receive sequencer status values */
152 #define SXG_RCV_STATUS_ATTN                     0x80000000 /* Attention */
153 #define SXG_RCV_STATUS_TRANSPORT_MASK           0x3F000000 /* Transport mask */
154 #define SXG_RCV_STATUS_TRANSPORT_ERROR          0x20000000 /* Transport error */
155 /* Transport cksum error */
156 #define SXG_RCV_STATUS_TRANSPORT_CSUM           0x23000000
157 /* Transport underflow */
158 #define SXG_RCV_STATUS_TRANSPORT_UFLOW          0x22000000
159  /* Transport header length */
160 #define SXG_RCV_STATUS_TRANSPORT_HDRLEN         0x20000000
161 /* Transport flags detected */
162 #define SXG_RCV_STATUS_TRANSPORT_FLAGS          0x10000000
163  /* Transport options detected */
164 #define SXG_RCV_STATUS_TRANSPORT_OPTS           0x08000000
165 #define SXG_RCV_STATUS_TRANSPORT_SESS_MASK      0x07000000 /* Transport DDP */
166 #define SXG_RCV_STATUS_TRANSPORT_DDP            0x06000000 /* Transport DDP */
167 #define SXG_RCV_STATUS_TRANSPORT_iSCSI          0x05000000 /* Transport iSCSI */
168 #define SXG_RCV_STATUS_TRANSPORT_NFS            0x04000000 /* Transport NFS */
169 #define SXG_RCV_STATUS_TRANSPORT_FTP            0x03000000 /* Transport FTP */
170 #define SXG_RCV_STATUS_TRANSPORT_HTTP           0x02000000 /* Transport HTTP */
171 #define SXG_RCV_STATUS_TRANSPORT_SMB            0x01000000 /* Transport SMB */
172 #define SXG_RCV_STATUS_NETWORK_MASK             0x00FF0000 /* Network mask */
173 #define SXG_RCV_STATUS_NETWORK_ERROR            0x00800000 /* Network error */
174 /* Network cksum error */
175 #define SXG_RCV_STATUS_NETWORK_CSUM             0x00830000
176 /* Network underflow error */
177 #define SXG_RCV_STATUS_NETWORK_UFLOW            0x00820000
178  /* Network header length */
179 #define SXG_RCV_STATUS_NETWORK_HDRLEN           0x00800000
180  /* Network overflow detected */
181 #define SXG_RCV_STATUS_NETWORK_OFLOW            0x00400000
182 /* Network multicast detected */
183 #define SXG_RCV_STATUS_NETWORK_MCAST            0x00200000
184 /* Network options detected */
185 #define SXG_RCV_STATUS_NETWORK_OPTIONS          0x00100000
186 /* Network offset detected */
187 #define SXG_RCV_STATUS_NETWORK_OFFSET           0x00080000
188 /* Network fragment detected */
189 #define SXG_RCV_STATUS_NETWORK_FRAGMENT         0x00040000
190 /* Network transport type mask */
191 #define SXG_RCV_STATUS_NETWORK_TRANS_MASK       0x00030000
192 #define SXG_RCV_STATUS_NETWORK_UDP              0x00020000 /* UDP */
193 #define SXG_RCV_STATUS_NETWORK_TCP              0x00010000 /* TCP */
194 #define SXG_RCV_STATUS_IPONLY                   0x00008000 /* IP-only not TCP */
195 /* Receive priority */
196 #define SXG_RCV_STATUS_PKT_PRI                  0x00006000
197 /* Receive priority shift */
198 #define SXG_RCV_STATUS_PKT_PRI_SHFT             13
199 /* MAC Receive RAM parity error */
200 #define SXG_RCV_STATUS_PARITY                   0x00001000
201 /* Link address detection mask */
202 #define SXG_RCV_STATUS_ADDRESS_MASK             0x00000F00
203
204 #define SXG_RCV_STATUS_ADDRESS_D                0x00000B00 /* Link address D */
205 #define SXG_RCV_STATUS_ADDRESS_C                0x00000A00 /* Link address C */
206 #define SXG_RCV_STATUS_ADDRESS_B                0x00000900 /* Link address B */
207 #define SXG_RCV_STATUS_ADDRESS_A                0x00000800 /* Link address A */
208 /* Link address broadcast */
209 #define SXG_RCV_STATUS_ADDRESS_BCAST            0x00000300
210  /* Link address multicast */
211 #define SXG_RCV_STATUS_ADDRESS_MCAST            0x00000200
212 /* Link control multicast */
213 #define SXG_RCV_STATUS_ADDRESS_CMCAST           0x00000100
214 /* Link status mask */
215 #define SXG_RCV_STATUS_LINK_MASK                0x000000FF
216 #define SXG_RCV_STATUS_LINK_ERROR               0x00000080 /* Link error */
217 /* Link status mask */
218 #define SXG_RCV_STATUS_LINK_MASK                0x000000FF
219 /* RcvMacQ parity error */
220 #define SXG_RCV_STATUS_LINK_PARITY              0x00000087
221 #define SXG_RCV_STATUS_LINK_EARLY               0x00000086 /* Data early */
222 #define SXG_RCV_STATUS_LINK_BUFOFLOW            0x00000085 /* Buffer overflow */
223 #define SXG_RCV_STATUS_LINK_CODE                0x00000084 /* Link code error */
224 #define SXG_RCV_STATUS_LINK_DRIBBLE             0x00000083 /* Dribble nibble */
225 #define SXG_RCV_STATUS_LINK_CRC                 0x00000082 /* CRC error */
226 #define SXG_RCV_STATUS_LINK_OFLOW               0x00000081 /* Link overflow */
227 #define SXG_RCV_STATUS_LINK_UFLOW               0x00000080 /* Link underflow */
228 #define SXG_RCV_STATUS_LINK_8023                0x00000020 /* 802.3 */
229 #define SXG_RCV_STATUS_LINK_SNAP                0x00000010 /* Snap */
230 #define SXG_RCV_STATUS_LINK_VLAN                0x00000008 /* VLAN */
231 /* Network type mask */
232 #define SXG_RCV_STATUS_LINK_TYPE_MASK           0x00000007
233 #define SXG_RCV_STATUS_LINK_CONTROL             0x00000003 /* Control packet */
234 #define SXG_RCV_STATUS_LINK_IPV6                0x00000002 /* IPv6 packet */
235 #define SXG_RCV_STATUS_LINK_IPV4                0x00000001 /* IPv4 packet */
236
237 /* Sahara receive and transmit configuration registers */
238 /* RcvConfig register reset */
239 #define RCV_CONFIG_RESET                0x80000000
240 /* Enable the receive logic */
241 #define RCV_CONFIG_ENABLE               0x40000000
242 /* Enable the receive parser */
243 #define RCV_CONFIG_ENPARSE              0x20000000
244 /* Enable the socket detector */
245 #define RCV_CONFIG_SOCKET               0x10000000
246 #define RCV_CONFIG_RCVBAD               0x08000000 /* Receive all bad frames */
247 /* Receive all control frames */
248 #define RCV_CONFIG_CONTROL              0x04000000
249 /* Enable pause transmit when attn */
250 #define RCV_CONFIG_RCVPAUSE             0x02000000
251 /* Include TCP port w/ IPv6 toeplitz */
252 #define RCV_CONFIG_TZIPV6               0x01000000
253 /* Include TCP port w/ IPv4 toeplitz */
254 #define RCV_CONFIG_TZIPV4               0x00800000
255 #define RCV_CONFIG_FLUSH                0x00400000 /* Flush buffers */
256 #define RCV_CONFIG_PRIORITY_MASK        0x00300000 /* Priority level */
257 #define RCV_CONFIG_CONN_MASK            0x000C0000 /* Number of connections */
258 #define RCV_CONFIG_CONN_4K              0x00000000 /* 4k connections */
259 #define RCV_CONFIG_CONN_2K              0x00040000 /* 2k connections */
260 #define RCV_CONFIG_CONN_1K              0x00080000 /* 1k connections */
261 #define RCV_CONFIG_CONN_512             0x000C0000 /* 512 connections */
262 #define RCV_CONFIG_HASH_MASK            0x00030000 /* Hash depth */
263 #define RCV_CONFIG_HASH_8               0x00000000 /* Hash depth 8 */
264 #define RCV_CONFIG_HASH_16              0x00010000 /* Hash depth 16 */
265 #define RCV_CONFIG_HASH_4               0x00020000 /* Hash depth 4 */
266 #define RCV_CONFIG_HASH_2               0x00030000 /* Hash depth 2 */
267 /* Buffer length bits 15:4. ie multiple of 16. */
268 #define RCV_CONFIG_BUFLEN_MASK          0x0000FFF0
269 /* Disable socket detection on attn */
270 #define RCV_CONFIG_SKT_DIS              0x00000008
271 /*
272  * Macro to determine RCV_CONFIG_BUFLEN based on maximum frame size.
273  * We add 18 bytes for Sahara receive status and padding, plus 4 bytes for CRC,
274  * and round up to nearest 16 byte boundary
275  */
276 #define RCV_CONFIG_BUFSIZE(_MaxFrame)                                   \
277                 ((((_MaxFrame) + 22) + 15) & RCV_CONFIG_BUFLEN_MASK)
278
279 /* XmtConfig register reset */
280 #define XMT_CONFIG_RESET                0x80000000
281 #define XMT_CONFIG_ENABLE               0x40000000 /* Enable transmit logic */
282 /* Inhibit MAC RAM parity error */
283 #define XMT_CONFIG_MAC_PARITY           0x20000000
284 /* Inhibit D2F buffer parity error */
285 #define XMT_CONFIG_BUF_PARITY           0x10000000
286 /* Inhibit 1T SRAM parity error */
287 #define XMT_CONFIG_MEM_PARITY           0x08000000
288 #define XMT_CONFIG_INVERT_PARITY        0x04000000 /* Invert MAC RAM parity */
289 #define XMT_CONFIG_INITIAL_IPID         0x0000FFFF /* Initial IPID */
290
291 /*
292  * A-XGMAC Registers - Occupy 0x80 - 0xD4 of the struct sxg_hw_regs
293  *
294  * Full register descriptions can be found in axgmac.pdf
295  */
296 /* A-XGMAC Configuration Register 0 */
297 #define AXGMAC_CFG0_SUB_RESET           0x80000000 /* Sub module reset */
298 #define AXGMAC_CFG0_RCNTRL_RESET        0x00400000 /* Receive control reset */
299 #define AXGMAC_CFG0_RFUNC_RESET         0x00200000 /* Receive function reset */
300 #define AXGMAC_CFG0_TCNTRL_RESET        0x00040000 /* Transmit control reset */
301 #define AXGMAC_CFG0_TFUNC_RESET         0x00020000 /* Transmit function reset */
302 #define AXGMAC_CFG0_MII_RESET           0x00010000 /* MII Management reset */
303
304 /* A-XGMAC Configuration Register 1 */
305 /* Allow the sending of Pause frames */
306 #define AXGMAC_CFG1_XMT_PAUSE           0x80000000
307 #define AXGMAC_CFG1_XMT_EN              0x40000000 /* Enable transmit */
308 /* Allow the detection of Pause frames */
309 #define AXGMAC_CFG1_RCV_PAUSE           0x20000000
310 #define AXGMAC_CFG1_RCV_EN              0x10000000 /* Enable receive */
311 /* Current transmit state - READ ONLY */
312 #define AXGMAC_CFG1_XMT_STATE           0x04000000
313 /* Current receive state - READ ONLY */
314 #define AXGMAC_CFG1_RCV_STATE           0x01000000
315 /* Only pause for 64 slot on XOFF */
316 #define AXGMAC_CFG1_XOFF_SHORT          0x00001000
317 /* Delay transmit FCS 1 4-byte word */
318 #define AXGMAC_CFG1_XMG_FCS1            0x00000400
319 /* Delay transmit FCS 2 4-byte words */
320 #define AXGMAC_CFG1_XMG_FCS2            0x00000800
321 /* Delay transmit FCS 3 4-byte words */
322 #define AXGMAC_CFG1_XMG_FCS3            0x00000C00
323 /* Delay receive FCS 1 4-byte word */
324 #define AXGMAC_CFG1_RCV_FCS1            0x00000100
325 /* Delay receive FCS 2 4-byte words */
326 #define AXGMAC_CFG1_RCV_FCS2            0x00000200
327 /* Delay receive FCS 3 4-byte words */
328 #define AXGMAC_CFG1_RCV_FCS3            0x00000300
329 /* Per-packet override enable */
330 #define AXGMAC_CFG1_PKT_OVERRIDE        0x00000080
331 #define AXGMAC_CFG1_SWAP                0x00000040 /* Byte swap enable */
332 /* ASSERT srdrpfrm on short frame (<64) */
333 #define AXGMAC_CFG1_SHORT_ASSERT        0x00000020
334 /* RCV only 802.3AE when CLEAR */
335 #define AXGMAC_CFG1_RCV_STRICT          0x00000010
336 #define AXGMAC_CFG1_CHECK_LEN           0x00000008 /* Verify frame length */
337 #define AXGMAC_CFG1_GEN_FCS             0x00000004 /* Generate FCS */
338 #define AXGMAC_CFG1_PAD_MASK            0x00000003 /* Mask for pad bits */
339 #define AXGMAC_CFG1_PAD_64              0x00000001 /* Pad frames to 64 bytes */
340 /* Detect VLAN and pad to 68 bytes */
341 #define AXGMAC_CFG1_PAD_VLAN            0x00000002
342 #define AXGMAC_CFG1_PAD_68              0x00000003 /* Pad to 68 bytes */
343
344 /* A-XGMAC Configuration Register 2 */
345 /* Generate single pause frame (test) */
346 #define AXGMAC_CFG2_GEN_PAUSE           0x80000000
347 /* Manual link fault sequence */
348 #define AXGMAC_CFG2_LF_MANUAL           0x08000000
349 /* Auto link fault sequence */
350 #define AXGMAC_CFG2_LF_AUTO             0x04000000
351 /* Remote link fault (READ ONLY) */
352 #define AXGMAC_CFG2_LF_REMOTE           0x02000000
353 /* Local link fault (READ ONLY) */
354 #define AXGMAC_CFG2_LF_LOCAL            0x01000000
355 #define AXGMAC_CFG2_IPG_MASK            0x001F0000 /* Inter packet gap */
356 #define AXGMAC_CFG2_IPG_SHIFT                   16
357 #define AXGMAC_CFG2_PAUSE_XMT           0x00008000 /* Pause transmit module */
358 /* Enable IPG extension algorithm */
359 #define AXGMAC_CFG2_IPG_EXTEN           0x00000020
360 #define AXGMAC_CFG2_IPGEX_MASK          0x0000001F /* IPG extension */
361
362 /* A-XGMAC Configuration Register 3 */
363 /* Receive frame drop filter */
364 #define AXGMAC_CFG3_RCV_DROP            0xFFFF0000
365 /* Receive frame don't care filter */
366 #define AXGMAC_CFG3_RCV_DONT_CARE       0x0000FFFF
367
368 /* A-XGMAC Station Address Register - Octets 1-4 */
369 #define AXGMAC_SARLOW_OCTET_ONE         0xFF000000      /* First octet */
370 #define AXGMAC_SARLOW_OCTET_TWO         0x00FF0000      /* Second octet */
371 #define AXGMAC_SARLOW_OCTET_THREE       0x0000FF00      /* Third octet */
372 #define AXGMAC_SARLOW_OCTET_FOUR        0x000000FF      /* Fourth octet */
373
374 /* A-XGMAC Station Address Register - Octets 5-6 */
375 #define AXGMAC_SARHIGH_OCTET_FIVE       0xFF000000      /* Fifth octet */
376 #define AXGMAC_SARHIGH_OCTET_SIX        0x00FF0000      /* Sixth octet */
377
378 /* A-XGMAC Maximum frame length register */
379 /* Maximum transmit frame length */
380 #define AXGMAC_MAXFRAME_XMT             0x3FFF0000
381 #define AXGMAC_MAXFRAME_XMT_SHIFT       16
382 /* Maximum receive frame length */
383 #define AXGMAC_MAXFRAME_RCV             0x0000FFFF
384 /*
385  * This register doesn't need to be written for standard MTU.
386  * For jumbo, I'll just statically define the value here.  This
387  * value sets the receive byte count to 9036 (0x234C) and the
388  * transmit WORD count to 2259 (0x8D3).  These values include 22
389  * bytes of padding beyond the jumbo MTU of 9014
390  */
391 #define AXGMAC_MAXFRAME_JUMBO           0x08D3234C
392
393 /* A-XGMAC Revision level */
394 #define AXGMAC_REVISION_MASK            0x0000FFFF      /* Revision level */
395
396 /* A-XGMAC AMIIM Command Register */
397 #define AXGMAC_AMIIM_CMD_START          0x00000008      /* Command start */
398 #define AXGMAC_AMIIM_CMD_MASK           0x00000007      /* Command */
399 /* 10/100/1000 Mbps Phy Write */
400 #define AXGMAC_AMIIM_CMD_LEGACY_WRITE           1
401 /* 10/100/1000 Mbps Phy Read */
402 #define AXGMAC_AMIIM_CMD_LEGACY_READ            2
403 #define AXGMAC_AMIIM_CMD_MONITOR_SINGLE         3       /* Monitor single PHY */
404 /* Monitor multiple contiguous PHYs */
405 #define AXGMAC_AMIIM_CMD_MONITOR_MULTIPLE       4
406 /* Present AMIIM Field Reg */
407 #define AXGMAC_AMIIM_CMD_10G_OPERATION          5
408 /* Clear Link Fail Bit in MIIM */
409 #define AXGMAC_AMIIM_CMD_CLEAR_LINK_FAIL        6
410
411 /* A-XGMAC AMIIM Field Register */
412 #define AXGMAC_AMIIM_FIELD_ST           0xC0000000      /* 2-bit ST field */
413 #define AXGMAC_AMIIM_FIELD_ST_SHIFT             30
414 #define AXGMAC_AMIIM_FIELD_OP           0x30000000      /* 2-bit OP field */
415 #define AXGMAC_AMIIM_FIELD_OP_SHIFT             28
416 /* Port address field (hstphyadx in spec) */
417 #define AXGMAC_AMIIM_FIELD_PORT_ADDR    0x0F800000
418 #define AXGMAC_AMIIM_FIELD_PORT_SHIFT           23
419 /* Device address field (hstregadx in spec) */
420 #define AXGMAC_AMIIM_FIELD_DEV_ADDR     0x007C0000
421 #define AXGMAC_AMIIM_FIELD_DEV_SHIFT            18
422 #define AXGMAC_AMIIM_FIELD_TA           0x00030000      /* 2-bit TA field */
423 #define AXGMAC_AMIIM_FIELD_TA_SHIFT             16
424 #define AXGMAC_AMIIM_FIELD_DATA         0x0000FFFF      /* Data field */
425
426 /* Values for the AXGMAC_AMIIM_FIELD_OP field in the A-XGMAC AMIIM Field Register */
427 #define MIIM_OP_ADDR            0       /* MIIM Address set operation */
428 #define MIIM_OP_WRITE           1       /* MIIM Write register operation */
429 #define MIIM_OP_READ            2       /* MIIM Read register operation */
430 #define MIIM_OP_ADDR_SHIFT      (MIIM_OP_ADDR << AXGMAC_AMIIM_FIELD_OP_SHIFT)
431
432 /*
433  * Values for the AXGMAC_AMIIM_FIELD_PORT_ADDR field in the A-XGMAC AMIIM
434  * Field Register
435  */
436 #define MIIM_PORT_NUM           1       /* All Sahara MIIM modules use port 1 */
437
438 /*
439  * Values for the AXGMAC_AMIIM_FIELD_DEV_ADDR field in the A-XGMAC AMIIM
440  * Field Register
441  */
442 /* PHY PMA/PMD module MIIM device number */
443 #define MIIM_DEV_PHY_PMA        1
444 /* PHY PCS module MIIM device number */
445 #define MIIM_DEV_PHY_PCS        3
446 /* PHY XS module MIIM device number */
447 #define MIIM_DEV_PHY_XS         4
448 #define MIIM_DEV_XGXS           5       /* XGXS MIIM device number */
449
450 /*
451  * Values for the AXGMAC_AMIIM_FIELD_TA field in the A-XGMAC AMIIM Field
452  * Register
453  */
454 #define MIIM_TA_10GB            2       /* set to 2 for 10 GB operation */
455
456 /* A-XGMAC AMIIM Configuration Register */
457 /* Bypass preamble of mngmt frame */
458 #define AXGMAC_AMIIM_CFG_NOPREAM        0x00000080
459 /* half-clock duration of MDC output */
460 #define AXGMAC_AMIIM_CFG_HALF_CLOCK     0x0000007F
461
462 /* A-XGMAC AMIIM Indicator Register */
463 /* Link status from legacy PHY or MMD */
464 #define AXGMAC_AMIIM_INDC_LINK          0x00000010
465 /* Multiple phy operation in progress */
466 #define AXGMAC_AMIIM_INDC_MPHY          0x00000008
467 /* Single phy operation in progress */
468 #define AXGMAC_AMIIM_INDC_SPHY          0x00000004
469 /* Single or multiple monitor cmd */
470 #define AXGMAC_AMIIM_INDC_MON           0x00000002
471 /* Set until cmd operation complete */
472 #define AXGMAC_AMIIM_INDC_BUSY          0x00000001
473
474 /* Link Status and Control Register */
475 #define LS_PHY_CLR_RESET        0x80000000      /* Clear reset signal to PHY */
476 #define LS_SERDES_POWER_DOWN    0x40000000      /* Power down the Sahara Serdes */
477 #define LS_XGXS_ENABLE          0x20000000      /* Enable the XAUI XGXS logic */
478 /* Hold XAUI XGXS logic reset until Serdes is up */
479 #define LS_XGXS_CTL             0x10000000
480 /* When 0, XAUI Serdes is up and initialization is complete */
481 #define LS_SERDES_DOWN          0x08000000
482 /* When 0, Trace Serdes is up and initialization is complete */
483 #define LS_TRACE_DOWN           0x04000000
484 /* Set PHY clock to 25 MHz (else 156.125 MHz) */
485 #define LS_PHY_CLK_25MHZ        0x02000000
486 #define LS_PHY_CLK_EN           0x01000000      /* Enable clock to PHY */
487 #define LS_XAUI_LINK_UP         0x00000010      /* XAUI link is up */
488 /* XAUI link status has changed */
489 #define LS_XAUI_LINK_CHNG       0x00000008
490 #define LS_LINK_ALARM           0x00000004      /* Link alarm pin */
491 /* Mask link attention control bits */
492 #define LS_ATTN_CTRL_MASK       0x00000003
493 #define LS_ATTN_ALARM           0x00000000      /* 00 => Attn on link alarm */
494 /* 01 => Attn on link alarm or status change */
495 #define LS_ATTN_ALARM_OR_STAT_CHNG      0x00000001
496 /* 10 => Attn on link status change */
497 #define LS_ATTN_STAT_CHNG       0x00000002
498 #define LS_ATTN_NONE            0x00000003      /* 11 => no Attn */
499
500 /* Link Address High Registers */
501 #define LINK_ADDR_ENABLE        0x80000000      /* Enable this link address */
502
503
504 /*
505  * XGXS XAUI XGMII Extender registers
506  *
507  * Full register descriptions can be found in mxgxs.pdf
508  */
509 /* XGXS Register Map */
510 #define XGXS_ADDRESS_CONTROL1   0x0000          /* XS Control 1 */
511 #define XGXS_ADDRESS_STATUS1    0x0001          /* XS Status 1 */
512 #define XGXS_ADDRESS_DEVID_LOW  0x0002          /* XS Device ID (low) */
513 #define XGXS_ADDRESS_DEVID_HIGH 0x0003          /* XS Device ID (high) */
514 #define XGXS_ADDRESS_SPEED      0x0004          /* XS Speed ability */
515 #define XGXS_ADDRESS_DEV_LOW    0x0005          /* XS Devices in package */
516 #define XGXS_ADDRESS_DEV_HIGH   0x0006          /* XS Devices in package */
517 #define XGXS_ADDRESS_STATUS2    0x0008          /* XS Status 2 */
518 #define XGXS_ADDRESS_PKGID_lOW  0x000E          /* XS Package Identifier */
519 #define XGXS_ADDRESS_PKGID_HIGH 0x000F          /* XS Package Identifier */
520 #define XGXS_ADDRESS_LANE_STATUS        0x0018  /* 10G XGXS Lane Status */
521 #define XGXS_ADDRESS_TEST_CTRL  0x0019          /* 10G XGXS Test Control */
522 #define XGXS_ADDRESS_RESET_LO1  0x8000          /* Vendor-Specific Reset Lo 1 */
523 #define XGXS_ADDRESS_RESET_LO2  0x8001          /* Vendor-Specific Reset Lo 2 */
524 #define XGXS_ADDRESS_RESET_HI1  0x8002          /* Vendor-Specific Reset Hi 1 */
525 #define XGXS_ADDRESS_RESET_HI2  0x8003          /* Vendor-Specific Reset Hi 2 */
526
527 /* XS Control 1 register bit definitions */
528 #define XGXS_CONTROL1_RESET     0x8000          /* Reset - self clearing */
529 #define XGXS_CONTROL1_LOOPBACK  0x4000          /* Enable loopback */
530 #define XGXS_CONTROL1_SPEED1    0x2000          /* 0 = unspecified, 1 = 10Gb+ */
531 #define XGXS_CONTROL1_LOWPOWER  0x0400          /* 1 = Low power mode */
532 #define XGXS_CONTROL1_SPEED2    0x0040          /* Same as SPEED1 (?) */
533 /* Everything reserved except zero (?) */
534 #define XGXS_CONTROL1_SPEED     0x003C
535
536 /* XS Status 1 register bit definitions */
537 #define XGXS_STATUS1_FAULT      0x0080          /* Fault detected */
538 #define XGXS_STATUS1_LINK       0x0004          /* 1 = Link up */
539 #define XGXS_STATUS1_LOWPOWER   0x0002          /* 1 = Low power supported */
540
541 /* XS Speed register bit definitions */
542 #define XGXS_SPEED_10G          0x0001          /* 1 = 10G capable */
543
544 /* XS Devices register bit definitions */
545 #define XGXS_DEVICES_DTE        0x0020          /* DTE XS Present */
546 #define XGXS_DEVICES_PHY        0x0010          /* PHY XS Present */
547 #define XGXS_DEVICES_PCS        0x0008          /* PCS Present */
548 #define XGXS_DEVICES_WIS        0x0004          /* WIS Present */
549 #define XGXS_DEVICES_PMD        0x0002          /* PMD/PMA Present */
550 #define XGXS_DEVICES_CLAUSE22   0x0001          /* Clause 22 registers present*/
551
552 /* XS Devices High register bit definitions */
553 #define XGXS_DEVICES_VENDOR2    0x8000          /* Vendor specific device 2 */
554 #define XGXS_DEVICES_VENDOR1    0x4000          /* Vendor specific device 1 */
555
556 /* XS Status 2 register bit definitions */
557 #define XGXS_STATUS2_DEV_MASK   0xC000          /* Device present mask */
558 #define XGXS_STATUS2_DEV_RESPOND        0x8000  /* Device responding */
559 #define XGXS_STATUS2_XMT_FAULT  0x0800          /* Transmit fault */
560 #define XGXS_STATUS2_RCV_FAULT  0x0400          /* Receive fault */
561
562 /* XS Package ID High register bit definitions */
563 #define XGXS_PKGID_HIGH_ORG     0xFC00          /* Organizationally Unique */
564 #define XGXS_PKGID_HIGH_MFG     0x03F0          /* Manufacturer Model */
565 #define XGXS_PKGID_HIGH_REV     0x000F          /* Revision Number */
566
567 /* XS Lane Status register bit definitions */
568 #define XGXS_LANE_PHY           0x1000  /* PHY/DTE lane alignment status */
569 #define XGXS_LANE_PATTERN       0x0800          /* Pattern testing ability */
570 #define XGXS_LANE_LOOPBACK      0x0400          /* PHY loopback ability */
571 #define XGXS_LANE_SYNC3         0x0008          /* Lane 3 sync */
572 #define XGXS_LANE_SYNC2         0x0004          /* Lane 2 sync */
573 #define XGXS_LANE_SYNC1         0x0002          /* Lane 1 sync */
574 #define XGXS_LANE_SYNC0         0x0001          /* Lane 0 sync */
575
576 /* XS Test Control register bit definitions */
577 #define XGXS_TEST_PATTERN_ENABLE        0x0004  /* Test pattern enabled */
578 #define XGXS_TEST_PATTERN_MASK  0x0003          /* Test patterns */
579 #define XGXS_TEST_PATTERN_RSVD  0x0003          /* Test pattern - reserved */
580 #define XGXS_TEST_PATTERN_MIX   0x0002          /* Test pattern - mixed */
581 #define XGXS_TEST_PATTERN_LOW   0x0001          /* Test pattern - low */
582 #define XGXS_TEST_PATTERN_HIGH  0x0001          /* Test pattern - high */
583
584 /*
585  * External MDIO Bus Registers
586  *
587  * Full register descriptions can be found in PHY/XENPAK/IEEE specs
588  */
589 /*
590  * LASI (Link Alarm Status Interrupt) Registers (located in
591  * MIIM_DEV_PHY_PMA device)
592  */
593 #define LASI_RX_ALARM_CONTROL   0x9000          /* LASI RX_ALARM Control */
594 #define LASI_TX_ALARM_CONTROL   0x9001          /* LASI TX_ALARM Control */
595 #define LASI_CONTROL            0x9002          /* LASI Control */
596 #define LASI_RX_ALARM_STATUS    0x9003          /* LASI RX_ALARM Status */
597 #define LASI_TX_ALARM_STATUS    0x9004          /* LASI TX_ALARM Status */
598 #define LASI_STATUS             0x9005          /* LASI Status */
599
600 /* LASI_CONTROL bit definitions */
601 /* Enable RX_ALARM interrupts */
602 #define LASI_CTL_RX_ALARM_ENABLE        0x0004
603 /* Enable TX_ALARM interrupts */
604 #define LASI_CTL_TX_ALARM_ENABLE        0x0002
605 /* Enable Link Status interrupts */
606 #define LASI_CTL_LS_ALARM_ENABLE        0x0001
607
608 /* LASI_STATUS bit definitions */
609 #define LASI_STATUS_RX_ALARM    0x0004          /* RX_ALARM status */
610 #define LASI_STATUS_TX_ALARM    0x0002          /* TX_ALARM status */
611 #define LASI_STATUS_LS_ALARM    0x0001          /* Link Status */
612
613 /* PHY registers - PMA/PMD (device 1) */
614 #define PHY_PMA_CONTROL1        0x0000          /* PMA/PMD Control 1 */
615 #define PHY_PMA_STATUS1         0x0001          /* PMA/PMD Status 1 */
616 #define PHY_PMA_RCV_DET         0x000A  /* PMA/PMD Receive Signal Detect */
617                 /* other PMA/PMD registers exist and can be defined as needed */
618
619 /* PHY registers - PCS (device 3) */
620 #define PHY_PCS_CONTROL1        0x0000          /* PCS Control 1 */
621 #define PHY_PCS_STATUS1         0x0001          /* PCS Status 1 */
622 #define PHY_PCS_10G_STATUS1     0x0020          /* PCS 10GBASE-R Status 1 */
623                 /* other PCS registers exist and can be defined as needed */
624
625 /* PHY registers - XS (device 4) */
626 #define PHY_XS_CONTROL1         0x0000          /* XS Control 1 */
627 #define PHY_XS_STATUS1          0x0001          /* XS Status 1 */
628 #define PHY_XS_LANE_STATUS      0x0018          /* XS Lane Status */
629                 /* other XS registers exist and can be defined as needed */
630
631 /* PHY_PMA_CONTROL1 register bit definitions */
632 #define PMA_CONTROL1_RESET      0x8000          /* PMA/PMD reset */
633
634 /* PHY_PMA_RCV_DET register bit definitions */
635 #define PMA_RCV_DETECT          0x0001  /* PMA/PMD receive signal detect */
636
637 /* PHY_PCS_10G_STATUS1 register bit definitions */
638 #define PCS_10B_BLOCK_LOCK      0x0001  /* PCS 10GBASE-R locked to receive blocks */
639
640 /* PHY_XS_LANE_STATUS register bit definitions */
641 #define XS_LANE_ALIGN           0x1000          /* XS transmit lanes aligned */
642
643 /* PHY Microcode download data structure */
644 struct phy_ucode {
645         ushort  Addr;
646         ushort  Data;
647 };
648
649 /* Slow Bus Register Definitions */
650
651 /* Module 0 registers */
652 #define GPIO_L_IN               0x15            /* GPIO input (low) */
653 #define GPIO_L_OUT              0x16            /* GPIO output (low) */
654 #define GPIO_L_DIR              0x17            /* GPIO direction (low) */
655 #define GPIO_H_IN               0x19            /* GPIO input (high) */
656 #define GPIO_H_OUT              0x1A            /* GPIO output (high) */
657 #define GPIO_H_DIR              0x1B            /* GPIO direction (high) */
658
659 /* Definitions for other slow bus registers can be added as needed */
660
661
662 /*
663  * Transmit Sequencer Command Descriptor definitions
664  *
665  * This descriptor must be placed in GRAM.  The address of this descriptor
666  * (along with a couple of control bits) is pushed onto the PxhCmdQ or PxlCmdQ
667  * (Proxy high or low command queue).  This data is read by the Proxy Sequencer,
668  * which pushes it onto the XmtCmdQ, which is (eventually) read by the Transmit
669  * Sequencer, causing a packet to be transmitted.  Not all fields are valid for
670  * all commands - see the Sahara spec for details.  Note that this structure is
671  * only valid when compiled on a little endian machine.
672  */
673 #pragma pack(push, 1)
674 struct xmt_desc {
675         ushort          XmtLen;     /* word 0, bits [15:0] -  transmit length */
676         /* word 0, bits [23:16] - transmit control byte */
677         unsigned char   XmtCtl;
678         /* word 0, bits [31:24] - transmit command plus misc. */
679         unsigned char   Cmd;
680         /* word 1, bits [31:0] -  transmit buffer ID */
681         u32     XmtBufId;
682         /* word 2, bits [7:0] -   byte address of TCP header */
683         unsigned char   TcpStrt;
684         /* word 2, bits [15:8] -  byte address of IP header */
685         unsigned char   IpStrt;
686         /* word 2, bits [31:16] - partial IP checksum */
687         ushort  IpCkSum;
688         /* word 3, bits [15:0] -  partial TCP checksum */
689         ushort  TcpCkSum;
690         ushort  Rsvd1;              /* word 3, bits [31:16] - PAD */
691         u32     Rsvd2;              /* word 4, bits [31:0] -  PAD */
692         u32     Rsvd3;              /* word 5, bits [31:0] -  PAD */
693         u32     Rsvd4;              /* word 6, bits [31:0] -  PAD */
694         u32     Rsvd5;              /* word 7, bits [31:0] -  PAD */
695 };
696 #pragma pack(pop)
697
698 /* struct xmt_desc Cmd byte definitions */
699                 /* command codes */
700 #define XMT_DESC_CMD_RAW_SEND           0       /* raw send descriptor */
701 #define XMT_DESC_CMD_CSUM_INSERT        1       /* checksum insert descriptor */
702 #define XMT_DESC_CMD_FORMAT             2       /* format descriptor */
703 #define XMT_DESC_CMD_PRIME              3       /* prime descriptor */
704 /* comand code shift (shift to bits [31:30] in word 0) */
705 #define XMT_DESC_CMD_CODE_SHFT          6
706                 /* shifted command codes */
707 #define XMT_RAW_SEND    (XMT_DESC_CMD_RAW_SEND    << XMT_DESC_CMD_CODE_SHFT)
708 #define XMT_CSUM_INSERT (XMT_DESC_CMD_CSUM_INSERT << XMT_DESC_CMD_CODE_SHFT)
709 #define XMT_FORMAT      (XMT_DESC_CMD_FORMAT      << XMT_DESC_CMD_CODE_SHFT)
710 #define XMT_PRIME       (XMT_DESC_CMD_PRIME       << XMT_DESC_CMD_CODE_SHFT)
711
712 /*
713  * struct xmt_desc Control Byte (XmtCtl) definitions
714  * NOTE:  These bits do not work on Sahara (Rev A)!
715  */
716 /* current frame is a pause control frame (for statistics) */
717 #define XMT_CTL_PAUSE_FRAME             0x80
718 /* current frame is a control frame (for statistics) */
719 #define XMT_CTL_CONTROL_FRAME           0x40
720 #define XMT_CTL_PER_PKT_QUAL            0x20    /* per packet qualifier */
721 #define XMT_CTL_PAD_MODE_NONE           0x00    /* do not pad frame */
722 #define XMT_CTL_PAD_MODE_64             0x08    /* pad frame to 64 bytes */
723 /* pad frame to 64 bytes, and VLAN frames to 68 bytes */
724 #define XMT_CTL_PAD_MODE_VLAN_68        0x10
725 #define XMT_CTL_PAD_MODE_68             0x18    /* pad frame to 68 bytes */
726 /* generate FCS (CRC) for this frame */
727 #define XMT_CTL_GEN_FCS                 0x04
728 #define XMT_CTL_DELAY_FCS_0             0x00    /* do not delay FCS calcution */
729 /* delay FCS calculation by 1 (4-byte) word */
730 #define XMT_CTL_DELAY_FCS_1             0x01
731 /* delay FCS calculation by 2 (4-byte) words */
732 #define XMT_CTL_DELAY_FCS_2             0x02
733 /* delay FCS calculation by 3 (4-byte) words */
734 #define XMT_CTL_DELAY_FCS_3             0x03
735
736 /* struct xmt_desc XmtBufId definition */
737 /*
738  * The Xmt buffer ID is formed by dividing the buffer (DRAM) address
739  * by 256 (or << 8)
740  */
741
742 #define XMT_BUF_ID_SHFT         8
743
744 /* Receiver Sequencer Definitions */
745
746 /* Receive Event Queue (queues 3 - 6) bit definitions */
747 /* bit mask for the Receive Buffer ID */
748 #define RCV_EVTQ_RBFID_MASK     0x0000FFFF
749
750 /* Receive Buffer ID definition */
751 /*
752  * The Rcv buffer ID is formed by dividing the buffer (DRAM) address
753  * by 32 (or << 5)
754  */
755 #define RCV_BUF_ID_SHFT         5
756
757 /*
758  * Format of the 18 byte Receive Buffer returned by the
759  * Receive Sequencer for received packets
760  */
761 #pragma pack(push, 1)
762 struct rcv_buf_hdr {
763         u32     Status;         /* Status word from Rcv Seq Parser */
764         ushort  Length;         /* Rcv packet byte count */
765         union {
766                 ushort          TcpCsum;        /* TCP checksum */
767                 struct {
768                         /* lower 8 bits of the TCP checksum */
769                         unsigned char   TcpCsumL;
770                         /* Link hash (multicast frames only) */
771                         unsigned char   LinkHash;
772                 };
773         };
774         ushort  SktHash;                /* Socket hash */
775         unsigned char   TcpHdrOffset;   /* TCP header offset into packet */
776         unsigned char   IpHdrOffset;    /* IP header offset into packet */
777         u32             TpzHash;        /* Toeplitz hash */
778         ushort          Reserved;       /* Reserved */
779 };
780 #pragma pack(pop)
781
782 /* Queue definitions */
783
784 /* Ingress (read only) queue numbers */
785 #define PXY_BUF_Q       0       /* Proxy Buffer Queue */
786 #define HST_EVT_Q       1       /* Host Event Queue */
787 #define XMT_BUF_Q       2       /* Transmit Buffer Queue */
788 #define SKT_EVL_Q       3       /* RcvSqr Socket Event Low Priority Queue */
789 #define RCV_EVL_Q       4       /* RcvSqr Rcv Event Low Priority Queue */
790 #define SKT_EVH_Q       5       /* RcvSqr Socket Event High Priority Queue */
791 #define RCV_EVH_Q       6       /* RcvSqr Rcv Event High Priority Queue */
792 #define DMA_RSP_Q       7       /* Dma Response Queue - one per CPU context */
793 /* Local (read/write) queue numbers */
794 #define LOCAL_A_Q       8       /* Spare local Queue */
795 #define LOCAL_B_Q       9       /* Spare local Queue */
796 #define LOCAL_C_Q       10      /* Spare local Queue */
797 #define FSM_EVT_Q       11      /* Finite-State-Machine Event Queue */
798 #define SBF_PAL_Q       12      /* System Buffer Physical Address (low) Queue */
799 #define SBF_PAH_Q       13      /* System Buffer Physical Address (high) Queue*/
800 #define SBF_VAL_Q       14      /* System Buffer Virtual Address (low) Queue */
801 #define SBF_VAH_Q       15      /* System Buffer Virtual Address (high) Queue */
802 /* Egress (write only) queue numbers */
803 #define H2G_CMD_Q       16      /* Host to GlbRam DMA Command Queue */
804 #define H2D_CMD_Q       17      /* Host to DRAM DMA Command Queue */
805 #define G2H_CMD_Q       18      /* GlbRam to Host DMA Command Queue */
806 #define G2D_CMD_Q       19      /* GlbRam to DRAM DMA Command Queue */
807 #define D2H_CMD_Q       20      /* DRAM to Host DMA Command Queue */
808 #define D2G_CMD_Q       21      /* DRAM to GlbRam DMA Command Queue */
809 #define D2D_CMD_Q       22      /* DRAM to DRAM DMA Command Queue */
810 #define PXL_CMD_Q       23      /* Low Priority Proxy Command Queue */
811 #define PXH_CMD_Q       24      /* High Priority Proxy Command Queue */
812 #define RSQ_CMD_Q       25      /* Receive Sequencer Command Queue */
813 #define RCV_BUF_Q       26      /* Receive Buffer Queue */
814
815 /* Bit definitions for the Proxy Command queues (PXL_CMD_Q and PXH_CMD_Q) */
816 /* enable copy of xmt descriptor to xmt command queue */
817 #define PXY_COPY_EN     0x00200000
818 #define PXY_SIZE_16     0x00000000      /* copy 16 bytes */
819 #define PXY_SIZE_32     0x00100000      /* copy 32 bytes */
820
821 /* SXG EEPROM/Flash Configuration Definitions */
822
823 /* Location of configuration data in EEPROM or Flash */
824 /* start addr for config info in EEPROM */
825 #define EEPROM_CONFIG_START_ADDR        0x00
826 /* start addr for config info in Flash */
827 #define FLASH_CONFIG_START_ADDR         0x80
828
829 /* Configuration data section defines */
830 #define HW_CFG_SECTION_SIZE     512     /* size of H/W section */
831 #define HW_CFG_SECTION_SIZE_A   256     /* size of H/W section (Sahara rev A) */
832 /* starting location (offset) of S/W section */
833 #define SW_CFG_SECTION_START    512
834 /* starting location (offset) of S/W section (Sahara rev A) */
835 #define SW_CFG_SECTION_START_A  256
836 #define SW_CFG_SECTION_SIZE     128     /* size of S/W section */
837 /*
838  * H/W configuration data magic word Goes in Addr field of first
839  * struct hw_cfg_data entry
840  */
841 #define HW_CFG_MAGIC_WORD       0xA5A5
842 /*
843  * H/W configuration data terminator  Goes in Addr field of last
844  * struct hw_cfg_data entry
845  */
846 #define HW_CFG_TERMINATOR       0xFFFF
847
848 #define SW_CFG_MAGIC_WORD       0x5A5A  /* S/W configuration data magic word */
849
850 #pragma pack(push, 1)
851 /*
852  * Structure for an element of H/W configuration data.
853  * Read by the Sahara hardware
854  */
855 struct hw_cfg_data {
856         ushort  Addr;
857         ushort  Data;
858 };
859
860 /*
861  * Number of struct hw_cfg_data structures to put in the configuration data
862  * data structure (struct sxg_config or struct sxg_config_a).  The number is
863  * computed to fill the entire H/W config section of the structure.
864  */
865 #define NUM_HW_CFG_ENTRIES                                              \
866                         (HW_CFG_SECTION_SIZE / sizeof(struct hw_cfg_data))
867 #define NUM_HW_CFG_ENTRIES_A                                            \
868                         (HW_CFG_SECTION_SIZE_A / sizeof(struct hw_cfg_data))
869
870 /* MAC address structure */
871 struct sxg_config_mac {
872         unsigned char   MacAddr[6];     /* MAC Address */
873 };
874
875 /* FRU data structure */
876 struct atk_fru {
877         unsigned char           PartNum[6];
878         unsigned char           Revision[2];
879         unsigned char           Serial[14];
880 };
881
882 /* OEM FRU Format types */
883 #define ATK_FRU_FORMAT          0x0000
884 #define CPQ_FRU_FORMAT          0x0001
885 #define DELL_FRU_FORMAT         0x0002
886 #define HP_FRU_FORMAT           0x0003
887 #define IBM_FRU_FORMAT          0x0004
888 #define EMC_FRU_FORMAT          0x0005
889 #define NO_FRU_FORMAT           0xFFFF
890
891 #define ATK_OEM_ASSY_SIZE       10      /* assy num is 9 chars plus \0 */
892
893 /* OEM FRU structure for Alacritech */
894 struct atk_oem {
895         unsigned char Assy[ATK_OEM_ASSY_SIZE];
896 };
897
898 #define OEM_EEPROM_FRUSIZE      74      /* size of OEM fru info - size */
899 /* chosen to fill out the S/W section */
900
901 union oem_fru {                 /* OEM FRU information */
902         unsigned char OemFru[OEM_EEPROM_FRUSIZE];
903         struct atk_oem AtkOem;
904 };
905
906 /* Structure to hold the S/W configuration data. */
907 struct sw_cfg_data {
908         ushort                  MagicWord;      /* Magic word for section 2 */
909         ushort                  Version;        /* Format version */
910         struct sxg_config_mac   MacAddr[4];     /* space for 4 MAC addresses */
911         struct atk_fru          AtkFru;         /* FRU information */
912         ushort                  OemFruFormat;   /* OEM FRU format type */
913         union oem_fru           OemFru;         /* OEM FRU information */
914         ushort                  Checksum;       /* Checksum of section 2 */
915 };
916
917
918 /* EEPROM/Flash Format */
919 struct sxg_config {
920         /* H/W Section - Read by Sahara hardware (512 bytes) */
921         struct hw_cfg_data              HwCfg[NUM_HW_CFG_ENTRIES];
922         /* S/W Section - Other configuration data (128 bytes) */
923         struct sw_cfg_data      SwCfg;
924 };
925
926 /* EEPROM/Flash Format (Sahara rev A) */
927 struct sxg_config_a {
928         /* H/W Section - Read by Sahara hardware (256 bytes)  */
929         struct hw_cfg_data              HwCfg[NUM_HW_CFG_ENTRIES_A];
930
931         /* S/W Section - Other configuration data (128 bytes) */
932         struct sw_cfg_data              SwCfg;
933 };
934
935 #ifdef WINDOWS_COMPILER
936 /*
937  *  The following macro is something of a kludge, but it is the only way
938  * that I could find to catch certain programming errors at compile time.
939  * If the asserted condition is true, then nothing happens.  If false, then
940  * the compiler tries to typedef an array with -1 members, which generates
941  * an error.  Unfortunately, the error message is meaningless, but at least
942  * it catches the problem.  This macro would be unnecessary if the compiler
943  * allowed the sizeof and offsetof macros to be used in the #if directive.
944  */
945 #define compile_time_assert(cond) \
946     typedef char comp_error[(cond) ? 1 : -1]
947
948 /*
949  * A compiler error on either of the next two lines indicates that the struct sxg_config
950  * structure was built incorrectly.  Unfortunately, the error message produced
951  * is meaningless.  But this is apparently the only way to catch this problem
952  * at compile time.
953  */
954 compile_time_assert (offsetof(struct sxg_config, SwCfg) == SW_CFG_SECTION_START);
955 compile_time_assert (sizeof(struct sxg_config) == HW_CFG_SECTION_SIZE
956                                                         + SW_CFG_SECTION_SIZE);
957
958 compile_time_assert (offsetof(struct sxg_config_a, SwCfg)
959                                                  == SW_CFG_SECTION_START_A);
960 compile_time_assert (sizeof(struct sxg_config_a) == HW_CFG_SECTION_SIZE_A
961                                                  + SW_CFG_SECTION_SIZE);
962 #endif
963 /*
964  * Structure used to pass information between driver and user-mode
965  * control application
966  */
967 struct adapt_userinfo {
968         bool                LinkUp;
969         /* use LinkUp - any need for other states? */
970         /* u32              LinkState; */
971         u32                 LinkSpeed;          /* not currently needed */
972         u32                 LinkDuplex;         /* not currently needed */
973         u32                 Port;               /* not currently needed */
974         u32                 PhysPort;           /* not currently needed */
975         ushort              PciLanes;
976         unsigned char   MacAddr[6];
977         unsigned char   CurrMacAddr[6];
978         struct atk_fru      AtkFru;
979         ushort              OemFruFormat;
980         union oem_fru       OemFru;
981 };
982
983 #pragma pack(pop)
984
985 /* Miscellaneous Hardware definitions */
986
987 /* Type of ASIC in use */
988 enum ASIC_TYPE{
989         SAHARA_REV_A,
990         SAHARA_REV_B
991 };
992
993 /* Sahara (ASIC level) defines */
994 #define SAHARA_GRAM_SIZE        0x020000        /* GRAM size - 128 KB */
995 #define SAHARA_DRAM_SIZE        0x200000        /* DRAM size - 2 MB */
996 /* QRAM size - 16K entries (64 KB) */
997 #define SAHARA_QRAM_SIZE        0x004000
998 /* WCS - 8K instructions (x 108 bits) */
999 #define SAHARA_WCS_SIZE         0x002000
1000
1001 /* Arabia (board level) defines */
1002 #define FLASH_SIZE              0x080000        /* 512 KB (4 Mb) */
1003 /* EEPROM size (bytes), including xfmr area */
1004 #define EEPROM_SIZE_XFMR        1024
1005 /* EEPROM size excluding xfmr area (512 + 128) */
1006 #define EEPROM_SIZE_NO_XFMR     640
1007 /* EEPROM size for Sahara rev A */
1008 #define EEPROM_SIZE_REV_A       512