xref: /titanic_51/usr/src/uts/common/io/bge/bge_hw.h (revision 27c48ed935c6a5f6015c6534b98e3090b1ddfdb6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _BGE_HW_H
28 #define	_BGE_HW_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 
38 
39 /*
40  * First section:
41  *	Identification of the various Broadcom chips
42  *
43  * Note: the various ID values are *not* all unique ;-(
44  *
45  * Note: the presence of an ID here does *not* imply that the chip is
46  * supported.  At this time, only the 5703C, 5704C, and 5704S devices
47  * used on the motherboards of certain Sun products are supported.
48  *
49  * Note: the revision-id values in the PCI revision ID register are
50  * *NOT* guaranteed correct.  Use the chip ID from the MHCR instead.
51  */
52 
53 #define	VENDOR_ID_BROADCOM		0x14e4
54 #define	VENDOR_ID_SUN			0x108e
55 
56 #define	DEVICE_ID_5700			0x1644
57 #define	DEVICE_ID_5700x			0x0003
58 #define	DEVICE_ID_5701			0x1645
59 #define	DEVICE_ID_5702			0x16a6
60 #define	DEVICE_ID_5702fe		0x164d
61 #define	DEVICE_ID_5703C			0x1647
62 #define	DEVICE_ID_5703S			0x16a7
63 #define	DEVICE_ID_5703			0x16c7
64 #define	DEVICE_ID_5704C			0x1648
65 #define	DEVICE_ID_5704S			0x16a8
66 #define	DEVICE_ID_5704			0x1649
67 #define	DEVICE_ID_5705C			0x1653
68 #define	DEVICE_ID_5705_2		0x1654
69 #define	DEVICE_ID_5705M			0x165d
70 #define	DEVICE_ID_5705MA3		0x165e
71 #define	DEVICE_ID_5705F			0x166e
72 #define	DEVICE_ID_5706			0x164a
73 #define	DEVICE_ID_5782			0x1696
74 #define	DEVICE_ID_5788			0x169c
75 #define	DEVICE_ID_5789			0x169d
76 #define	DEVICE_ID_5751			0x1677
77 #define	DEVICE_ID_5751M			0x167d
78 #define	DEVICE_ID_5752			0x1600
79 #define	DEVICE_ID_5752M			0x1601
80 #define	DEVICE_ID_5754			0x167a
81 #define	DEVICE_ID_5755			0x167b
82 #define	DEVICE_ID_5721			0x1659
83 #define	DEVICE_ID_5714C			0x1668
84 #define	DEVICE_ID_5714S			0x1669
85 #define	DEVICE_ID_5715C			0x1678
86 #define	DEVICE_ID_5715S			0x1679
87 
88 #define	REVISION_ID_5700_B0		0x10
89 #define	REVISION_ID_5700_B2		0x12
90 #define	REVISION_ID_5700_B3		0x13
91 #define	REVISION_ID_5700_C0		0x20
92 #define	REVISION_ID_5700_C1		0x21
93 #define	REVISION_ID_5700_C2		0x22
94 
95 #define	REVISION_ID_5701_A0		0x08
96 #define	REVISION_ID_5701_A2		0x12
97 #define	REVISION_ID_5701_A3		0x15
98 
99 #define	REVISION_ID_5702_A0		0x00
100 
101 #define	REVISION_ID_5703_A0		0x00
102 #define	REVISION_ID_5703_A1		0x01
103 #define	REVISION_ID_5703_A2		0x02
104 
105 #define	REVISION_ID_5704_A0		0x00
106 #define	REVISION_ID_5704_A1		0x01
107 #define	REVISION_ID_5704_A2		0x02
108 #define	REVISION_ID_5704_A3		0x03
109 #define	REVISION_ID_5704_B0		0x10
110 
111 #define	REVISION_ID_5705_A0		0x00
112 #define	REVISION_ID_5705_A1		0x01
113 #define	REVISION_ID_5705_A2		0x02
114 #define	REVISION_ID_5705_A3		0x03
115 
116 #define	REVISION_ID_5721_A0		0x00
117 #define	REVISION_ID_5721_A1		0x01
118 
119 #define	REVISION_ID_5751_A0		0x00
120 #define	REVISION_ID_5751_A1		0x01
121 
122 #define	REVISION_ID_5714_A0		0x00
123 #define	REVISION_ID_5714_A1		0x01
124 #define	REVISION_ID_5714_A2		0xA2
125 #define	REVISION_ID_5714_A3		0xA3
126 
127 #define	REVISION_ID_5715_A0		0x00
128 #define	REVISION_ID_5715_A1		0x01
129 #define	REVISION_ID_5715_A2		0xA2
130 
131 #define	REVISION_ID_5715S_A0		0x00
132 #define	REVISION_ID_5715S_A1		0x01
133 
134 #define	REVISION_ID_5754_A0		0x00
135 #define	REVISION_ID_5754_A1		0x01
136 
137 #define	DEVICE_5704_SERIES_CHIPSETS(bgep)\
138 		((bgep->chipid.device == DEVICE_ID_5700) ||\
139 		(bgep->chipid.device == DEVICE_ID_5701) ||\
140 		(bgep->chipid.device == DEVICE_ID_5702) ||\
141 		(bgep->chipid.device == DEVICE_ID_5702fe)||\
142 		(bgep->chipid.device == DEVICE_ID_5703C) ||\
143 		(bgep->chipid.device == DEVICE_ID_5703S) ||\
144 		(bgep->chipid.device == DEVICE_ID_5703) ||\
145 		(bgep->chipid.device == DEVICE_ID_5704C) ||\
146 		(bgep->chipid.device == DEVICE_ID_5704S) ||\
147 		(bgep->chipid.device == DEVICE_ID_5704))
148 
149 #define	DEVICE_5702_SERIES_CHIPSETS(bgep) \
150 		((bgep->chipid.device == DEVICE_ID_5702) ||\
151 		(bgep->chipid.device == DEVICE_ID_5702fe))
152 
153 #define	DEVICE_5705_SERIES_CHIPSETS(bgep) \
154 		((bgep->chipid.device == DEVICE_ID_5705C) ||\
155 		(bgep->chipid.device == DEVICE_ID_5705M) ||\
156 		(bgep->chipid.device == DEVICE_ID_5705MA3) ||\
157 		(bgep->chipid.device == DEVICE_ID_5705F) ||\
158 		(bgep->chipid.device == DEVICE_ID_5782) ||\
159 		(bgep->chipid.device == DEVICE_ID_5788) ||\
160 		(bgep->chipid.device == DEVICE_ID_5705_2) ||\
161 		(bgep->chipid.device == DEVICE_ID_5754) ||\
162 		(bgep->chipid.device == DEVICE_ID_5755))
163 
164 #define	DEVICE_5721_SERIES_CHIPSETS(bgep) \
165 		((bgep->chipid.device == DEVICE_ID_5721) ||\
166 		(bgep->chipid.device == DEVICE_ID_5751) ||\
167 		(bgep->chipid.device == DEVICE_ID_5751M) ||\
168 		(bgep->chipid.device == DEVICE_ID_5752) ||\
169 		(bgep->chipid.device == DEVICE_ID_5752M) ||\
170 		(bgep->chipid.device == DEVICE_ID_5789))
171 
172 #define	DEVICE_5714_SERIES_CHIPSETS(bgep) \
173 		((bgep->chipid.device == DEVICE_ID_5714C) ||\
174 		(bgep->chipid.device == DEVICE_ID_5714S) ||\
175 		(bgep->chipid.device == DEVICE_ID_5715C) ||\
176 		(bgep->chipid.device == DEVICE_ID_5715S))
177 
178 /*
179  * Second section:
180  *	Offsets of important registers & definitions for bits therein
181  */
182 
183 /*
184  * PCI-X registers & bits
185  */
186 #define	PCIX_CONF_COMM			0x42
187 #define	PCIX_COMM_RELAXED		0x0002
188 
189 /*
190  * Miscellaneous Host Control Register, in PCI config space
191  */
192 #define	PCI_CONF_BGE_MHCR		0x68
193 #define	MHCR_CHIP_REV_MASK		0xffff0000
194 #define	MHCR_ENABLE_TAGGED_STATUS_MODE	0x00000200
195 #define	MHCR_MASK_INTERRUPT_MODE	0x00000100
196 #define	MHCR_ENABLE_INDIRECT_ACCESS	0x00000080
197 #define	MHCR_ENABLE_REGISTER_WORD_SWAP	0x00000040
198 #define	MHCR_ENABLE_CLOCK_CONTROL_WRITE	0x00000020
199 #define	MHCR_ENABLE_PCI_STATE_WRITE	0x00000010
200 #define	MHCR_ENABLE_ENDIAN_WORD_SWAP	0x00000008
201 #define	MHCR_ENABLE_ENDIAN_BYTE_SWAP	0x00000004
202 #define	MHCR_MASK_PCI_INT_OUTPUT	0x00000002
203 #define	MHCR_CLEAR_INTERRUPT_INTA	0x00000001
204 
205 #define	MHCR_CHIP_REV_5700_B0		0x71000000
206 #define	MHCR_CHIP_REV_5700_B2		0x71020000
207 #define	MHCR_CHIP_REV_5700_B3		0x71030000
208 #define	MHCR_CHIP_REV_5700_C0		0x72000000
209 #define	MHCR_CHIP_REV_5700_C1		0x72010000
210 #define	MHCR_CHIP_REV_5700_C2		0x72020000
211 
212 #define	MHCR_CHIP_REV_5701_A0		0x00000000
213 #define	MHCR_CHIP_REV_5701_A2		0x00020000
214 #define	MHCR_CHIP_REV_5701_A3		0x00030000
215 #define	MHCR_CHIP_REV_5701_A5		0x01050000
216 
217 #define	MHCR_CHIP_REV_5702_A0		0x10000000
218 #define	MHCR_CHIP_REV_5702_A1		0x10010000
219 #define	MHCR_CHIP_REV_5702_A2		0x10020000
220 
221 #define	MHCR_CHIP_REV_5703_A0		0x10000000
222 #define	MHCR_CHIP_REV_5703_A1		0x10010000
223 #define	MHCR_CHIP_REV_5703_A2		0x10020000
224 #define	MHCR_CHIP_REV_5703_B0		0x11000000
225 #define	MHCR_CHIP_REV_5703_B1		0x11010000
226 
227 #define	MHCR_CHIP_REV_5704_A0		0x20000000
228 #define	MHCR_CHIP_REV_5704_A1		0x20010000
229 #define	MHCR_CHIP_REV_5704_A2		0x20020000
230 #define	MHCR_CHIP_REV_5704_A3		0x20030000
231 #define	MHCR_CHIP_REV_5704_B0		0x21000000
232 
233 #define	MHCR_CHIP_REV_5705_A0		0x30000000
234 #define	MHCR_CHIP_REV_5705_A1		0x30010000
235 #define	MHCR_CHIP_REV_5705_A2		0x30020000
236 #define	MHCR_CHIP_REV_5705_A3		0x30030000
237 #define	MHCR_CHIP_REV_5705_A5		0x30050000
238 
239 #define	MHCR_CHIP_REV_5782_A0		0x30030000
240 #define	MHCR_CHIP_REV_5782_A1		0x30030088
241 
242 #define	MHCR_CHIP_REV_5788_A1		0x30050000
243 
244 #define	MHCR_CHIP_REV_5751_A0		0x40000000
245 #define	MHCR_CHIP_REV_5751_A1		0x40010000
246 
247 #define	MHCR_CHIP_REV_5721_A0		0x41000000
248 #define	MHCR_CHIP_REV_5721_A1		0x41010000
249 
250 #define	MHCR_CHIP_REV_5714_A0		0x50000000
251 #define	MHCR_CHIP_REV_5714_A1		0x90010000
252 
253 #define	MHCR_CHIP_REV_5715_A0		0x50000000
254 #define	MHCR_CHIP_REV_5715_A1		0x90010000
255 
256 #define	MHCR_CHIP_REV_5715S_A0		0x50000000
257 #define	MHCR_CHIP_REV_5715S_A1		0x90010000
258 
259 #define	MHCR_CHIP_REV_5754_A0		0xb0000000
260 #define	MHCR_CHIP_REV_5754_A1		0xb0010000
261 
262 #define	MHCR_CHIP_REV_5755_A0		0xa0000000
263 #define	MHCR_CHIP_REV_5755_A1		0xa0010000
264 
265 #define	MHCR_CHIP_ASIC_REV(ChipRevId)	((ChipRevId) & 0xf0000000)
266 #define	MHCR_CHIP_ASIC_REV_5700		(0x7 << 28)
267 #define	MHCR_CHIP_ASIC_REV_5701		(0x0 << 28)
268 #define	MHCR_CHIP_ASIC_REV_5703		(0x1 << 28)
269 #define	MHCR_CHIP_ASIC_REV_5704		(0x2 << 28)
270 #define	MHCR_CHIP_ASIC_REV_5705		(0x3 << 28)
271 #define	MHCR_CHIP_ASIC_REV_5721_5751	(0x4 << 28)
272 #define	MHCR_CHIP_ASIC_REV_5714 	(0x5 << 28)
273 #define	MHCR_CHIP_ASIC_REV_5752		(0x6 << 28)
274 #define	MHCR_CHIP_ASIC_REV_5754		(0xb << 28)
275 #define	MHCR_CHIP_ASIC_REV_5755		((uint32_t)0xa << 28)
276 #define	MHCR_CHIP_ASIC_REV_5715 	((uint32_t)0x9 << 28)
277 
278 
279 /*
280  * PCI DMA read/write Control Register, in PCI config space
281  *
282  * Note that several fields previously defined here have been deleted
283  * as they are not implemented in the 5703/4.
284  *
285  * Note: the value of this register is critical.  It is possible to
286  * cause various unpleasant effects (DTOs, transaction deadlock, etc)
287  * by programming the wrong value.  The value #defined below has been
288  * tested and shown to avoid all known problems.  If it is to be changed,
289  * correct operation must be reverified on all supported platforms.
290  *
291  * In particular, we set both watermark fields to 2xCacheLineSize (128)
292  * bytes and DMA_MIN_BEATS to 0 in order to avoid unfortunate interactions
293  * with Tomatillo's internal pipelines, that otherwise result in stalls,
294  * repeated retries, and DTOs.
295  */
296 #define	PCI_CONF_BGE_PDRWCR		0x6c
297 #define	PDRWCR_RWCMD_MASK		0xFF000000
298 #define	PDRWCR_PCIX32_BUGFIX_MASK	0x00800000
299 #define	PDRWCR_WRITE_WATERMARK_MASK	0x00380000
300 #define	PDRWCR_READ_WATERMARK_MASK	0x00070000
301 #define	PDRWCR_CONCURRENCY_MASK		0x0000c000
302 #define	PDRWCR_5704_FLOP_ON_RETRY	0x00008000
303 #define	PDRWCR_ONE_DMA_AT_ONCE		0x00004000
304 #define	PDRWCR_MIN_BEAT_MASK		0x000000ff
305 
306 /*
307  * These are the actual values to be put into the fields shown above
308  */
309 #define	PDRWCR_RWCMDS			0x76000000	/* MW and MR	*/
310 #define	PDRWCR_DMA_WRITE_WATERMARK	0x00180000	/* 011 => 128	*/
311 #define	PDRWCR_DMA_READ_WATERMARK	0x00030000	/* 011 => 128	*/
312 #define	PDRWCR_MIN_BEATS		0x00000000
313 
314 #define	PDRWCR_VAR_DEFAULT		0x761b0000
315 #define	PDRWCR_VAR_5721			0x76180000
316 #define	PDRWCR_VAR_5714			0x76148000	/* OR of above	*/
317 #define	PDRWCR_VAR_5715			0x76144000	/* OR of above	*/
318 
319 /*
320  * PCI State Register, in PCI config space
321  *
322  * Note: this register is read-only unless the ENABLE_PCI_STATE_WRITE bit
323  * is set in the MHCR, EXCEPT for the RETRY_SAME_DMA bit which is always RW
324  */
325 #define	PCI_CONF_BGE_PCISTATE		0x70
326 #define	PCISTATE_RETRY_SAME_DMA		0x00002000
327 #define	PCISTATE_FLAT_VIEW		0x00000100
328 #define	PCISTATE_EXT_ROM_RETRY		0x00000040
329 #define	PCISTATE_EXT_ROM_ENABLE		0x00000020
330 #define	PCISTATE_BUS_IS_32_BIT		0x00000010
331 #define	PCISTATE_BUS_IS_FAST		0x00000008
332 #define	PCISTATE_BUS_IS_PCI		0x00000004
333 #define	PCISTATE_INTA_STATE		0x00000002
334 #define	PCISTATE_FORCE_RESET		0x00000001
335 
336 /*
337  * PCI Clock Control Register, in PCI config space
338  */
339 #define	PCI_CONF_BGE_CLKCTL		0x74
340 #define	CLKCTL_PCIE_PLP_DISABLE		0x80000000
341 #define	CLKCTL_PCIE_DLP_DISABLE		0x40000000
342 #define	CLKCTL_PCIE_TLP_DISABLE		0x20000000
343 #define	CLKCTL_PCI_READ_TOO_LONG_FIX	0x04000000
344 #define	CLKCTL_PCI_WRITE_TOO_LONG_FIX	0x02000000
345 #define	CLKCTL_PCIE_A0_FIX		0x00101000
346 
347 /*
348  * Dual MAC Control Register, in PCI config space
349  */
350 #define	PCI_CONF_BGE_DUAL_MAC_CONTROL	0xB8
351 #define	DUALMAC_CHANNEL_CONTROL_MASK	0x00000003	/* RW	*/
352 #define	DUALMAC_CHANNEL_ID_MASK		0x00000004	/* RO	*/
353 
354 /*
355  * Register Indirect Access Address Register, 0x78 in PCI config
356  * space.  Once this is set, accesses to the Register Indirect
357  * Access Data Register (0x80) refer to the register whose address
358  * is given by *this* register.  This allows access to all the
359  * operating registers, while using only config space accesses.
360  *
361  * Note that the address written to the RIIAR should lie in one
362  * of the following ranges:
363  *	0x00000000 <= address < 0x00008000 (regular registers)
364  *	0x00030000 <= address < 0x00034000 (RxRISC scratchpad)
365  *	0x00034000 <= address < 0x00038000 (TxRISC scratchpad)
366  *	0x00038000 <= address < 0x00038800 (RxRISC ROM)
367  */
368 #define	PCI_CONF_BGE_RIAAR		0x78
369 #define	PCI_CONF_BGE_RIADR		0x80
370 
371 #define	RIAAR_REGISTER_MIN		0x00000000
372 #define	RIAAR_REGISTER_MAX		0x00008000
373 #define	RIAAR_RX_SCRATCH_MIN		0x00030000
374 #define	RIAAR_RX_SCRATCH_MAX		0x00034000
375 #define	RIAAR_TX_SCRATCH_MIN		0x00034000
376 #define	RIAAR_TX_SCRATCH_MAX		0x00038000
377 #define	RIAAR_RXROM_MIN			0x00038000
378 #define	RIAAR_RXROM_MAX			0x00038800
379 
380 /*
381  * Memory Window Base Address Register, 0x7c in PCI config space
382  * Once this is set, accesses to the Memory Window Data Access Register
383  * (0x84) refer to the word of NIC-local memory whose address is given
384  * by this register.  When used in this way, the whole of the address
385  * written to this register is significant.
386  *
387  * This register also provides the 32K-aligned base address for a 32K
388  * region of NIC-local memory that the host can directly address in
389  * the upper 32K of the 64K of PCI memory space allocated to the chip.
390  * In this case, the bottom 15 bits of the register are ignored.
391  *
392  * Note that the address written to the MWBAR should lie in the range
393  * 0x00000000 <= address < 0x00020000.  The rest of the range up to 1M
394  * (i.e. 0x00200000 <= address < 0x01000000) would be valid if external
395  * memory were present, but it's only supported on the 5700, not the
396  * 5701/5703/5704.
397  */
398 #define	PCI_CONF_BGE_MWBAR		0x7c
399 #define	PCI_CONF_BGE_MWDAR		0x84
400 #define	MWBAR_GRANULARITY		0x00008000	/* 32k	*/
401 #define	MWBAR_GRANULE_MASK		(MWBAR_GRANULARITY-1)
402 #define	MWBAR_ONCHIP_MAX		0x00020000	/* 128k */
403 
404 /*
405  * The PCI express device control register and device status register
406  * which are only applicable on BCM5751 and BCM5721.
407  */
408 #define	PCI_CONF_DEV_CTRL		0xd8
409 #define	READ_REQ_SIZE_MAX		0x5000
410 #define	DEV_CTRL_NO_SNOOP		0x0800
411 #define	DEV_CTRL_RELAXED		0x0010
412 
413 #define	PCI_CONF_DEV_STUS		0xda
414 #define	DEVICE_ERROR_STUS		0xf
415 
416 #define	NIC_MEM_WINDOW_OFFSET		0x00008000	/* 32k	*/
417 
418 /*
419  * Where to find things in NIC-local (on-chip) memory
420  */
421 #define	NIC_MEM_SEND_RINGS		0x0100
422 #define	NIC_MEM_SEND_RING(ring)		(0x0100+16*(ring))
423 #define	NIC_MEM_RECV_RINGS		0x0200
424 #define	NIC_MEM_RECV_RING(ring)		(0x0200+16*(ring))
425 #define	NIC_MEM_STATISTICS		0x0300
426 #define	NIC_MEM_STATISTICS_SIZE		0x0800
427 #define	NIC_MEM_STATUS_BLOCK		0x0b00
428 #define	NIC_MEM_STATUS_SIZE		0x0050
429 #define	NIC_MEM_GENCOMM			0x0b50
430 
431 
432 /*
433  * Note: the (non-bogus) values below are appropriate for systems
434  * without external memory.  They would be different on a 5700 with
435  * external memory.
436  *
437  * Note: The higher send ring addresses and the mini ring shadow
438  * buffer address are dummies - systems without external memory
439  * are limited to 4 send rings and no mini receive ring.
440  */
441 #define	NIC_MEM_SHADOW_DMA		0x2000
442 #define	NIC_MEM_SHADOW_SEND_1_4		0x4000
443 #define	NIC_MEM_SHADOW_SEND_5_6		0x6000		/* bogus	*/
444 #define	NIC_MEM_SHADOW_SEND_7_8		0x7000		/* bogus	*/
445 #define	NIC_MEM_SHADOW_SEND_9_16	0x8000		/* bogus	*/
446 #define	NIC_MEM_SHADOW_BUFF_STD		0x6000
447 #define	NIC_MEM_SHADOW_BUFF_JUMBO	0x7000
448 #define	NIC_MEM_SHADOW_BUFF_MINI	0x8000		/* bogus	*/
449 #define	NIC_MEM_SHADOW_SEND_RING(ring, nslots)	(0x4000 + 4*(ring)*(nslots))
450 
451 /*
452  * Put this in the GENCOMM port to tell the firmware not to run PXE
453  */
454 #define	T3_MAGIC_NUMBER			0x4b657654u
455 
456 /*
457  * The remaining registers appear in the low 32K of regular
458  * PCI Memory Address Space
459  */
460 
461 /*
462  * All the state machine control registers below have at least a
463  * <RESET> bit and an <ENABLE> bit as defined below.  Some also
464  * have an <ATTN_ENABLE> bit.
465  */
466 #define	STATE_MACHINE_ATTN_ENABLE_BIT	0x00000004
467 #define	STATE_MACHINE_ENABLE_BIT	0x00000002
468 #define	STATE_MACHINE_RESET_BIT		0x00000001
469 
470 #define	TRANSMIT_MAC_MODE_REG		0x045c
471 #define	SEND_DATA_INITIATOR_MODE_REG	0x0c00
472 #define	SEND_DATA_COMPLETION_MODE_REG	0x1000
473 #define	SEND_BD_SELECTOR_MODE_REG	0x1400
474 #define	SEND_BD_INITIATOR_MODE_REG	0x1800
475 #define	SEND_BD_COMPLETION_MODE_REG	0x1c00
476 
477 #define	RECEIVE_MAC_MODE_REG		0x0468
478 #define	RCV_LIST_PLACEMENT_MODE_REG	0x2000
479 #define	RCV_DATA_BD_INITIATOR_MODE_REG	0x2400
480 #define	RCV_DATA_COMPLETION_MODE_REG	0x2800
481 #define	RCV_BD_INITIATOR_MODE_REG	0x2c00
482 #define	RCV_BD_COMPLETION_MODE_REG	0x3000
483 #define	RCV_LIST_SELECTOR_MODE_REG	0x3400
484 
485 #define	MBUF_CLUSTER_FREE_MODE_REG	0x3800
486 #define	HOST_COALESCE_MODE_REG		0x3c00
487 #define	MEMORY_ARBITER_MODE_REG		0x4000
488 #define	BUFFER_MANAGER_MODE_REG		0x4400
489 #define	READ_DMA_MODE_REG		0x4800
490 #define	WRITE_DMA_MODE_REG		0x4c00
491 #define	DMA_COMPLETION_MODE_REG		0x6400
492 
493 /*
494  * Other bits in some of the above state machine control registers
495  */
496 
497 /*
498  * Transmit MAC Mode Register
499  * (TRANSMIT_MAC_MODE_REG, 0x045c)
500  */
501 #define	TRANSMIT_MODE_LONG_PAUSE	0x00000040
502 #define	TRANSMIT_MODE_BIG_BACKOFF	0x00000020
503 #define	TRANSMIT_MODE_FLOW_CONTROL	0x00000010
504 
505 /*
506  * Receive MAC Mode Register
507  * (RECEIVE_MAC_MODE_REG, 0x0468)
508  */
509 #define	RECEIVE_MODE_KEEP_VLAN_TAG	0x00000400
510 #define	RECEIVE_MODE_NO_CRC_CHECK	0x00000200
511 #define	RECEIVE_MODE_PROMISCUOUS	0x00000100
512 #define	RECEIVE_MODE_LENGTH_CHECK	0x00000080
513 #define	RECEIVE_MODE_ACCEPT_RUNTS	0x00000040
514 #define	RECEIVE_MODE_ACCEPT_OVERSIZE	0x00000020
515 #define	RECEIVE_MODE_KEEP_PAUSE		0x00000010
516 #define	RECEIVE_MODE_FLOW_CONTROL	0x00000004
517 
518 /*
519  * Receive BD Initiator Mode Register
520  * (RCV_BD_INITIATOR_MODE_REG, 0x2c00)
521  *
522  * Each of these bits controls whether ATTN is asserted
523  * on a particular condition
524  */
525 #define	RCV_BD_DISABLED_RING_ATTN	0x00000004
526 
527 /*
528  * Receive Data & Receive BD Initiator Mode Register
529  * (RCV_DATA_BD_INITIATOR_MODE_REG, 0x2400)
530  *
531  * Each of these bits controls whether ATTN is asserted
532  * on a particular condition
533  */
534 #define	RCV_DATA_BD_ILL_RING_ATTN	0x00000010
535 #define	RCV_DATA_BD_FRAME_SIZE_ATTN	0x00000008
536 #define	RCV_DATA_BD_NEED_JUMBO_ATTN	0x00000004
537 
538 #define	RCV_DATA_BD_ALL_ATTN_BITS	0x0000001c
539 
540 /*
541  * Host Coalescing Mode Control Register
542  * (HOST_COALESCE_MODE_REG, 0x3c00)
543  */
544 #define	COALESCE_64_BYTE_RINGS		12
545 #define	COALESCE_NO_INT_ON_COAL_FORCE	0x00001000
546 #define	COALESCE_NO_INT_ON_DMAD_FORCE	0x00000800
547 #define	COALESCE_CLR_TICKS_TX		0x00000400
548 #define	COALESCE_CLR_TICKS_RX		0x00000200
549 #define	COALESCE_32_BYTE_STATUS		0x00000100
550 #define	COALESCE_64_BYTE_STATUS		0x00000080
551 #define	COALESCE_NOW			0x00000008
552 
553 /*
554  * Memory Arbiter Mode Register
555  * (MEMORY_ARBITER_MODE_REG, 0x4000)
556  */
557 #define	MEMORY_ARBITER_ENABLE		0x00000002
558 
559 /*
560  * Buffer Manager Mode Register
561  * (BUFFER_MANAGER_MODE_REG, 0x4400)
562  *
563  * In addition to the usual error-attn common to most state machines
564  * this register has a separate bit for attn on running-low-on-mbufs
565  */
566 #define	BUFF_MGR_TEST_MODE		0x00000008
567 #define	BUFF_MGR_MBUF_LOW_ATTN_ENABLE	0x00000010
568 
569 #define	BUFF_MGR_ALL_ATTN_BITS		0x00000014
570 
571 /*
572  * Read and Write DMA Mode Registers (READ_DMA_MODE_REG,
573  * 0x4800 and WRITE_DMA_MODE_REG, 0x4c00)
574  *
575  * These registers each contain a 2-bit priority field, which controls
576  * the relative priority of that type of DMA (read vs. write vs. MSI),
577  * and a set of bits that control whether ATTN is asserted on each
578  * particular condition
579  */
580 #define	DMA_PRIORITY_MASK		0xc0000000
581 #define	DMA_PRIORITY_SHIFT		30
582 #define	ALL_DMA_ATTN_BITS		0x000003fc
583 
584 /*
585  * BCM5755, 5755M, 5906, 5906M only
586  * 1 - Enable Fix. Device will send out the status block before
587  *     the interrupt message
588  * 0 - Disable fix. Device will send out the interrupt message
589  *     before the status block
590  */
591 #define	DMA_STATUS_TAG_FIX_CQ12384	0x20000000
592 
593 /*
594  * End of state machine control register definitions
595  */
596 
597 
598 /*
599  * Mailbox Registers (8 bytes each, but high half unused)
600  */
601 #define	INTERRUPT_MBOX_0_REG		0x0200
602 #define	INTERRUPT_MBOX_1_REG		0x0208
603 #define	INTERRUPT_MBOX_2_REG		0x0210
604 #define	INTERRUPT_MBOX_3_REG		0x0218
605 #define	INTERRUPT_MBOX_REG(n)		(0x0200+8*(n))
606 
607 /*
608  * Ring Producer/Consumer Index (Mailbox) Registers
609  */
610 #define	RECV_STD_PROD_INDEX_REG		0x0268
611 #define	RECV_JUMBO_PROD_INDEX_REG	0x0270
612 #define	RECV_MINI_PROD_INDEX_REG	0x0278
613 #define	RECV_RING_CONS_INDEX_REGS	0x0280
614 #define	SEND_RING_HOST_PROD_INDEX_REGS	0x0300
615 #define	SEND_RING_NIC_PROD_INDEX_REGS	0x0380
616 
617 #define	RECV_RING_CONS_INDEX_REG(ring)	(0x0280+8*(ring))
618 #define	SEND_RING_HOST_INDEX_REG(ring)	(0x0300+8*(ring))
619 #define	SEND_RING_NIC_INDEX_REG(ring)	(0x0380+8*(ring))
620 
621 /*
622  * Ethernet MAC Mode Register
623  */
624 #define	ETHERNET_MAC_MODE_REG		0x0400
625 #define	ETHERNET_MODE_ENABLE_FHDE	0x00800000
626 #define	ETHERNET_MODE_ENABLE_RDE	0x00400000
627 #define	ETHERNET_MODE_ENABLE_TDE	0x00200000
628 #define	ETHERNET_MODE_ENABLE_MIP	0x00100000
629 #define	ETHERNET_MODE_ENABLE_ACPI	0x00080000
630 #define	ETHERNET_MODE_ENABLE_MAGIC_PKT	0x00040000
631 #define	ETHERNET_MODE_SEND_CFGS		0x00020000
632 #define	ETHERNET_MODE_FLUSH_TX_STATS	0x00010000
633 #define	ETHERNET_MODE_CLEAR_TX_STATS	0x00008000
634 #define	ETHERNET_MODE_ENABLE_TX_STATS	0x00004000
635 #define	ETHERNET_MODE_FLUSH_RX_STATS	0x00002000
636 #define	ETHERNET_MODE_CLEAR_RX_STATS	0x00001000
637 #define	ETHERNET_MODE_ENABLE_RX_STATS	0x00000800
638 #define	ETHERNET_MODE_LINK_POLARITY	0x00000400
639 #define	ETHERNET_MODE_MAX_DEFER		0x00000200
640 #define	ETHERNET_MODE_ENABLE_TX_BURST	0x00000100
641 #define	ETHERNET_MODE_TAGGED_MODE	0x00000080
642 #define	ETHERNET_MODE_MAC_LOOPBACK	0x00000010
643 #define	ETHERNET_MODE_PORTMODE_MASK	0x0000000c
644 #define	ETHERNET_MODE_PORTMODE_TBI	0x0000000c
645 #define	ETHERNET_MODE_PORTMODE_GMII	0x00000008
646 #define	ETHERNET_MODE_PORTMODE_MII	0x00000004
647 #define	ETHERNET_MODE_PORTMODE_NONE	0x00000000
648 #define	ETHERNET_MODE_HALF_DUPLEX	0x00000002
649 #define	ETHERNET_MODE_GLOBAL_RESET	0x00000001
650 
651 /*
652  * Ethernet MAC Status & Event Registers
653  */
654 #define	ETHERNET_MAC_STATUS_REG		0x0404
655 #define	ETHERNET_STATUS_MI_INT		0x00800000
656 #define	ETHERNET_STATUS_MI_COMPLETE	0x00400000
657 #define	ETHERNET_STATUS_LINK_CHANGED	0x00001000
658 #define	ETHERNET_STATUS_PCS_ERROR	0x00000400
659 #define	ETHERNET_STATUS_SYNC_CHANGED	0x00000010
660 #define	ETHERNET_STATUS_CFG_CHANGED	0x00000008
661 #define	ETHERNET_STATUS_RECEIVING_CFG	0x00000004
662 #define	ETHERNET_STATUS_SIGNAL_DETECT	0x00000002
663 #define	ETHERNET_STATUS_PCS_SYNCHED	0x00000001
664 
665 #define	ETHERNET_MAC_EVENT_ENABLE_REG	0x0408
666 #define	ETHERNET_EVENT_MI_INT		0x00800000
667 #define	ETHERNET_EVENT_LINK_INT		0x00001000
668 #define	ETHERNET_STATUS_PCS_ERROR_INT	0x00000400
669 
670 /*
671  * Ethernet MAC LED Control Register
672  *
673  * NOTE: PHY mode 1 *MUST* be selected; this is the hardware default and
674  * the external LED driver circuitry is wired up to assume that this mode
675  * will always be selected.  Software must not change it!
676  */
677 #define	ETHERNET_MAC_LED_CONTROL_REG	0x040c
678 #define	LED_CONTROL_OVERRIDE_BLINK	0x80000000
679 #define	LED_CONTROL_BLINK_PERIOD_MASK	0x7ff80000
680 #define	LED_CONTROL_LED_MODE_MASK	0x00001800
681 #define	LED_CONTROL_LED_MODE_5700	0x00000000
682 #define	LED_CONTROL_LED_MODE_PHY_1	0x00000800	/* mandatory	*/
683 #define	LED_CONTROL_LED_MODE_PHY_2	0x00001000
684 #define	LED_CONTROL_LED_MODE_RESERVED	0x00001800
685 #define	LED_CONTROL_TRAFFIC_LED_STATUS	0x00000400
686 #define	LED_CONTROL_10MBPS_LED_STATUS	0x00000200
687 #define	LED_CONTROL_100MBPS_LED_STATUS	0x00000100
688 #define	LED_CONTROL_1000MBPS_LED_STATUS	0x00000080
689 #define	LED_CONTROL_BLINK_TRAFFIC	0x00000040
690 #define	LED_CONTROL_TRAFFIC_LED		0x00000020
691 #define	LED_CONTROL_OVERRIDE_TRAFFIC	0x00000010
692 #define	LED_CONTROL_10MBPS_LED		0x00000008
693 #define	LED_CONTROL_100MBPS_LED		0x00000004
694 #define	LED_CONTROL_1000MBPS_LED	0x00000002
695 #define	LED_CONTROL_OVERRIDE_LINK	0x00000001
696 #define	LED_CONTROL_DEFAULT		0x02000800
697 
698 /*
699  * MAC Address registers
700  *
701  * These four eight-byte registers each hold one unicast address
702  * (six bytes), right justified & zero-filled on the left.
703  * They will normally all be set to the same value, as a station
704  * usually only has one h/w address.  The value in register 0 is
705  * used for pause packets; any of the four can be specified for
706  * substitution into other transmitted packets if required.
707  */
708 #define	MAC_ADDRESS_0_REG		0x0410
709 #define	MAC_ADDRESS_1_REG		0x0418
710 #define	MAC_ADDRESS_2_REG		0x0420
711 #define	MAC_ADDRESS_3_REG		0x0428
712 
713 #define	MAC_ADDRESS_REG(n)		(0x0410+8*(n))
714 #define	MAC_ADDRESS_REGS_MAX		4
715 
716 /*
717  * More MAC Registers ...
718  */
719 #define	MAC_TX_RANDOM_BACKOFF_REG	0x0438
720 #define	MAC_RX_MTU_SIZE_REG		0x043c
721 #define	MAC_RX_MTU_DEFAULT		0x000005f2	/* 1522	*/
722 #define	MAC_TX_LENGTHS_REG		0x0464
723 #define	MAC_TX_LENGTHS_DEFAULT		0x00002620
724 
725 /*
726  * MII access registers
727  */
728 #define	MI_COMMS_REG			0x044c
729 #define	MI_COMMS_START			0x20000000
730 #define	MI_COMMS_READ_FAILED		0x10000000
731 #define	MI_COMMS_COMMAND_MASK		0x0c000000
732 #define	MI_COMMS_COMMAND_READ		0x08000000
733 #define	MI_COMMS_COMMAND_WRITE		0x04000000
734 #define	MI_COMMS_ADDRESS_MASK		0x03e00000
735 #define	MI_COMMS_ADDRESS_SHIFT		21
736 #define	MI_COMMS_REGISTER_MASK		0x001f0000
737 #define	MI_COMMS_REGISTER_SHIFT		16
738 #define	MI_COMMS_DATA_MASK		0x0000ffff
739 #define	MI_COMMS_DATA_SHIFT		0
740 
741 #define	MI_STATUS_REG			0x0450
742 #define	MI_STATUS_10MBPS		0x00000002
743 #define	MI_STATUS_LINK			0x00000001
744 
745 #define	MI_MODE_REG			0x0454
746 #define	MI_MODE_CLOCK_MASK		0x001f0000
747 #define	MI_MODE_AUTOPOLL		0x00000010
748 #define	MI_MODE_POLL_SHORT_PREAMBLE	0x00000002
749 #define	MI_MODE_DEFAULT			0x000c0000
750 
751 #define	MI_AUTOPOLL_STATUS_REG		0x0458
752 #define	MI_AUTOPOLL_ERROR		0x00000001
753 
754 #define	TRANSMIT_MAC_STATUS_REG		0x0460
755 #define	TRANSMIT_STATUS_ODI_OVERRUN	0x00000020
756 #define	TRANSMIT_STATUS_ODI_UNDERRUN	0x00000010
757 #define	TRANSMIT_STATUS_LINK_UP		0x00000008
758 #define	TRANSMIT_STATUS_SENT_XON	0x00000004
759 #define	TRANSMIT_STATUS_SENT_XOFF	0x00000002
760 #define	TRANSMIT_STATUS_RCVD_XOFF	0x00000001
761 
762 #define	RECEIVE_MAC_STATUS_REG		0x046c
763 #define	RECEIVE_STATUS_RCVD_XON		0x00000004
764 #define	RECEIVE_STATUS_RCVD_XOFF	0x00000002
765 #define	RECEIVE_STATUS_SENT_XOFF	0x00000001
766 
767 /*
768  * These four-byte registers constitute a hash table for deciding
769  * whether to accept incoming multicast packets.  The bits are
770  * numbered in big-endian fashion, from hash 0 => the MSB of
771  * register 0 to hash 127 => the LSB of the highest-numbered
772  * register.
773  *
774  * NOTE: the 5704 can use a 256-bit table (registers 0-7) if
775  * enabled by setting the appropriate bit in the Rx MAC mode
776  * register.  Otherwise, and on all earlier chips, the table
777  * is only 128 bits (registers 0-3).
778  */
779 #define	MAC_HASH_0_REG			0x0470
780 #define	MAC_HASH_1_REG			0x0474
781 #define	MAC_HASH_2_REG			0x0478
782 #define	MAC_HASH_3_REG			0x047c
783 #define	MAC_HASH_4_REG			0x????
784 #define	MAC_HASH_5_REG			0x????
785 #define	MAC_HASH_6_REG			0x????
786 #define	MAC_HASH_7_REG			0x????
787 #define	MAC_HASH_REG(n)			(0x470+4*(n))
788 
789 /*
790  * Receive Rules Registers: 16 pairs of control+mask/value pairs
791  */
792 #define	RCV_RULES_CONTROL_0_REG		0x0480
793 #define	RCV_RULES_MASK_0_REG		0x0484
794 #define	RCV_RULES_CONTROL_15_REG	0x04f8
795 #define	RCV_RULES_MASK_15_REG		0x04fc
796 #define	RCV_RULES_CONFIG_REG		0x0500
797 #define	RCV_RULES_CONFIG_DEFAULT	0x00000008
798 
799 #define	RECV_RULES_NUM_MAX		16
800 #define	RECV_RULE_CONTROL_REG(rule)	(RCV_RULES_CONTROL_0_REG+8*(rule))
801 #define	RECV_RULE_MASK_REG(rule)	(RCV_RULES_MASK_0_REG+8*(rule))
802 
803 #define	RECV_RULE_CTL_ENABLE		0x80000000
804 #define	RECV_RULE_CTL_AND		0x40000000
805 #define	RECV_RULE_CTL_P1		0x20000000
806 #define	RECV_RULE_CTL_P2		0x10000000
807 #define	RECV_RULE_CTL_P3		0x08000000
808 #define	RECV_RULE_CTL_MASK		0x04000000
809 #define	RECV_RULE_CTL_DISCARD		0x02000000
810 #define	RECV_RULE_CTL_MAP		0x01000000
811 #define	RECV_RULE_CTL_RESV_BITS		0x00fc0000
812 #define	RECV_RULE_CTL_OP		0x00030000
813 #define	RECV_RULE_CTL_OP_EQ		0x00000000
814 #define	RECV_RULE_CTL_OP_NEQ		0x00010000
815 #define	RECV_RULE_CTL_OP_GREAT		0x00020000
816 #define	RECV_RULE_CTL_OP_LESS		0x00030000
817 #define	RECV_RULE_CTL_HEADER		0x0000e000
818 #define	RECV_RULE_CTL_HEADER_FRAME	0x00000000
819 #define	RECV_RULE_CTL_HEADER_IP		0x00002000
820 #define	RECV_RULE_CTL_HEADER_TCP	0x00004000
821 #define	RECV_RULE_CTL_HEADER_UDP	0x00006000
822 #define	RECV_RULE_CTL_HEADER_DATA	0x00008000
823 #define	RECV_RULE_CTL_CLASS_BITS	0x00001f00
824 #define	RECV_RULE_CTL_CLASS(ring)	(((ring) << 8) & \
825 					    RECV_RULE_CTL_CLASS_BITS)
826 #define	RECV_RULE_CTL_OFFSET		0x000000ff
827 
828 /*
829  * Receive Rules definition
830  */
831 #define	RULE_MATCH_TO_RING		2
832 	/* ring that traffic will go into when recv rule matches.	*/
833 	/* value is between 1 and 16, not 0 and 15 */
834 
835 #define	IPHEADER_PROTO_OFFSET		0x08
836 #define	IPHEADER_SIP_OFFSET		0x0c
837 
838 #define	RULE_PROTO_CONTROL	(RECV_RULE_CTL_ENABLE | RECV_RULE_CTL_MASK | \
839 				    RECV_RULE_CTL_OP_EQ | \
840 				    RECV_RULE_CTL_HEADER_IP | \
841 				    RECV_RULE_CTL_CLASS(RULE_MATCH_TO_RING) | \
842 				    IPHEADER_PROTO_OFFSET)
843 #define	RULE_TCP_MASK_VALUE		0x00ff0006
844 #define	RULE_UDP_MASK_VALUE		0x00ff0011
845 #define	RULE_ICMP_MASK_VALUE		0x00ff0001
846 
847 #define	RULE_SIP_ADDR			0x0a000001
848 	/* ip address in 32-bit integer,such as, 0x0a000001 is "10.0.0.1" */
849 
850 #define	RULE_SIP_CONTROL	(RECV_RULE_CTL_ENABLE | RECV_RULE_CTL_OP_EQ | \
851 				    RECV_RULE_CTL_HEADER_IP | \
852 				    RECV_RULE_CTL_CLASS(RULE_MATCH_TO_RING) | \
853 				    IPHEADER_SIP_OFFSET)
854 #define	RULE_SIP_MASK_VALUE		RULE_SIP_ADDR
855 
856 /*
857  * 1000BaseX low-level access registers
858  */
859 #define	MAC_GIGABIT_PCS_TEST_REG	0x0440
860 #define	MAC_GIGABIT_PCS_TEST_ENABLE	0x00100000
861 #define	MAC_GIGABIT_PCS_TEST_PATTERN	0x000fffff
862 #define	TX_1000BASEX_AUTONEG_REG	0x0444
863 #define	RX_1000BASEX_AUTONEG_REG	0x0448
864 
865 /*
866  * Autoneg code bits for the 1000BASE-X AUTONEG registers
867  */
868 #define	AUTONEG_CODE_PAUSE		0x00008000
869 #define	AUTONEG_CODE_HALF_DUPLEX	0x00004000
870 #define	AUTONEG_CODE_FULL_DUPLEX	0x00002000
871 #define	AUTONEG_CODE_NEXT_PAGE		0x00000080
872 #define	AUTONEG_CODE_ACKNOWLEDGE	0x00000040
873 #define	AUTONEG_CODE_FAULT_MASK		0x00000030
874 #define	AUTONEG_CODE_FAULT_ANEG_ERR	0x00000030
875 #define	AUTONEG_CODE_FAULT_LINK_FAIL	0x00000020
876 #define	AUTONEG_CODE_FAULT_OFFLINE	0x00000010
877 #define	AUTONEG_CODE_ASYM_PAUSE		0x00000001
878 
879 /*
880  * SerDes Registers (5703S/5704S only)
881  */
882 #define	SERDES_CONTROL_REG		0x0590
883 #define	SERDES_CONTROL_TBI_LOOPBACK	0x00020000
884 #define	SERDES_CONTROL_COMMA_DETECT	0x00010000
885 #define	SERDES_CONTROL_TX_DISABLE	0x00004000
886 #define	SERDES_STATUS_REG		0x0594
887 #define	SERDES_STATUS_COMMA_DETECTED	0x00000100
888 #define	SERDES_STATUS_RXSTAT		0x000000ff
889 
890 /*
891  * Statistic Registers (5705/5788/5721/5751/5752/5714/5715 only)
892  */
893 #define	STAT_IFHCOUT_OCTETS_REG		0x0800
894 #define	STAT_ETHER_COLLIS_REG		0x0808
895 #define	STAT_OUTXON_SENT_REG		0x080c
896 #define	STAT_OUTXOFF_SENT_REG		0x0810
897 #define	STAT_DOT3_INTMACTX_ERR_REG		0x0818
898 #define	STAT_DOT3_SCOLLI_FRAME_REG		0x081c
899 #define	STAT_DOT3_MCOLLI_FRAME_REG		0x0820
900 #define	STAT_DOT3_DEFERED_TX_REG		0x0824
901 #define	STAT_DOT3_EXCE_COLLI_REG		0x082c
902 #define	STAT_DOT3_LATE_COLLI_REG		0x0830
903 #define	STAT_IFHCOUT_UPKGS_REG		0x086c
904 #define	STAT_IFHCOUT_MPKGS_REG		0x0870
905 #define	STAT_IFHCOUT_BPKGS_REG		0x0874
906 
907 #define	STAT_IFHCIN_OCTETS_REG		0x0880
908 #define	STAT_ETHER_FRAGMENT_REG		0x0888
909 #define	STAT_IFHCIN_UPKGS_REG		0x088c
910 #define	STAT_IFHCIN_MPKGS_REG		0x0890
911 #define	STAT_IFHCIN_BPKGS_REG		0x0894
912 
913 #define	STAT_DOT3_FCS_ERR_REG		0x0898
914 #define	STAT_DOT3_ALIGN_ERR_REG		0x089c
915 #define	STAT_XON_PAUSE_RX_REG		0x08a0
916 #define	STAT_XOFF_PAUSE_RX_REG		0x08a4
917 #define	STAT_MAC_CTRL_RX_REG		0x08a8
918 #define	STAT_XOFF_STATE_ENTER_REG		0x08ac
919 #define	STAT_DOT3_FRAME_TOOLONG_REG		0x08b0
920 #define	STAT_ETHER_JABBERS_REG		0x08b4
921 #define	STAT_ETHER_UNDERSIZE_REG		0x08b8
922 #define	SIZE_OF_STATISTIC_REG		0x1B
923 /*
924  * Send Data Initiator Registers
925  */
926 #define	SEND_INIT_STATS_CONTROL_REG	0x0c08
927 #define	SEND_INIT_STATS_ZERO		0x00000010
928 #define	SEND_INIT_STATS_FLUSH		0x00000008
929 #define	SEND_INIT_STATS_CLEAR		0x00000004
930 #define	SEND_INIT_STATS_FASTER		0x00000002
931 #define	SEND_INIT_STATS_ENABLE		0x00000001
932 
933 #define	SEND_INIT_STATS_ENABLE_MASK_REG	0x0c0c
934 
935 /*
936  * Send Buffer Descriptor Selector Control Registers
937  */
938 #define	SEND_BD_SELECTOR_STATUS_REG	0x1404
939 #define	SEND_BD_SELECTOR_HWDIAG_REG	0x1408
940 #define	SEND_BD_SELECTOR_INDEX_REG(n)	(0x1440+4*(n))
941 
942 /*
943  * Receive List Placement Registers
944  */
945 #define	RCV_LP_CONFIG_REG		0x2010
946 #define	RCV_LP_CONFIG_DEFAULT		0x00000009
947 #define	RCV_LP_CONFIG(rings)		(((rings) << 3) | 0x1)
948 
949 #define	RCV_LP_STATS_CONTROL_REG	0x2014
950 #define	RCV_LP_STATS_ZERO		0x00000010
951 #define	RCV_LP_STATS_FLUSH		0x00000008
952 #define	RCV_LP_STATS_CLEAR		0x00000004
953 #define	RCV_LP_STATS_FASTER		0x00000002
954 #define	RCV_LP_STATS_ENABLE		0x00000001
955 
956 #define	RCV_LP_STATS_ENABLE_MASK_REG	0x2018
957 #define	RCV_LP_STATS_DISABLE_MACTQ	0x040000
958 
959 /*
960  * Receive Data & BD Initiator Registers
961  */
962 #define	RCV_INITIATOR_STATUS_REG	0x2404
963 
964 /*
965  * Receive Buffer Descriptor Ring Control Block Registers
966  * NB: sixteen bytes (128 bits) each
967  */
968 #define	JUMBO_RCV_BD_RING_RCB_REG	0x2440
969 #define	STD_RCV_BD_RING_RCB_REG		0x2450
970 #define	MINI_RCV_BD_RING_RCB_REG	0x2460
971 
972 /*
973  * Receive Buffer Descriptor Ring Replenish Threshold Registers
974  */
975 #define	MINI_RCV_BD_REPLENISH_REG	0x2c14
976 #define	MINI_RCV_BD_REPLENISH_DEFAULT	0x00000080	/* 128	*/
977 #define	STD_RCV_BD_REPLENISH_REG	0x2c18
978 #define	STD_RCV_BD_REPLENISH_DEFAULT	0x00000002	/* 2	*/
979 #define	JUMBO_RCV_BD_REPLENISH_REG	0x2c1c
980 #define	JUMBO_RCV_BD_REPLENISH_DEFAULT	0x00000020	/* 32	*/
981 
982 /*
983  * Host Coalescing Engine Control Registers
984  */
985 #define	RCV_COALESCE_TICKS_REG		0x3c08
986 #define	RCV_COALESCE_TICKS_DEFAULT	0x00000096	/* 150	*/
987 #define	SEND_COALESCE_TICKS_REG		0x3c0c
988 #define	SEND_COALESCE_TICKS_DEFAULT	0x00000096	/* 150	*/
989 #define	RCV_COALESCE_MAX_BD_REG		0x3c10
990 #define	RCV_COALESCE_MAX_BD_DEFAULT	0x0000000a	/* 10	*/
991 #define	SEND_COALESCE_MAX_BD_REG	0x3c14
992 #define	SEND_COALESCE_MAX_BD_DEFAULT	0x0000000a	/* 10	*/
993 #define	RCV_COALESCE_INT_TICKS_REG	0x3c18
994 #define	RCV_COALESCE_INT_TICKS_DEFAULT	0x00000000	/* 0	*/
995 #define	SEND_COALESCE_INT_TICKS_REG	0x3c1c
996 #define	SEND_COALESCE_INT_TICKS_DEFAULT	0x00000000	/* 0	*/
997 #define	RCV_COALESCE_INT_BD_REG		0x3c20
998 #define	RCV_COALESCE_INT_BD_DEFAULT	0x00000000	/* 0	*/
999 #define	SEND_COALESCE_INT_BD_REG	0x3c24
1000 #define	SEND_COALESCE_INT_BD_DEFAULT	0x00000000	/* 0	*/
1001 #define	STATISTICS_TICKS_REG		0x3c28
1002 #define	STATISTICS_TICKS_DEFAULT	0x000f4240	/* 1000000 */
1003 #define	STATISTICS_HOST_ADDR_REG	0x3c30
1004 #define	STATUS_BLOCK_HOST_ADDR_REG	0x3c38
1005 #define	STATISTICS_BASE_ADDR_REG	0x3c40
1006 #define	STATUS_BLOCK_BASE_ADDR_REG	0x3c44
1007 #define	FLOW_ATTN_REG			0x3c48
1008 
1009 #define	NIC_JUMBO_RECV_INDEX_REG	0x3c50
1010 #define	NIC_STD_RECV_INDEX_REG		0x3c54
1011 #define	NIC_MINI_RECV_INDEX_REG		0x3c58
1012 #define	NIC_DIAG_RETURN_INDEX_REG(n)	(0x3c80+4*(n))
1013 #define	NIC_DIAG_SEND_INDEX_REG(n)	(0x3cc0+4*(n))
1014 
1015 /*
1016  * Mbuf Pool Initialisation & Watermark Registers
1017  *
1018  * There are some conflicts in the PRM; compare the recommendations
1019  * on pp. 115, 236, and 339.  The values here were recommended by
1020  * dkim@broadcom.com (and the PRM should be corrected soon ;-)
1021  */
1022 #define	BUFFER_MANAGER_STATUS_REG	0x4404
1023 #define	MBUF_POOL_BASE_REG		0x4408
1024 #define	MBUF_POOL_BASE_DEFAULT		0x00008000
1025 #define	MBUF_POOL_BASE_5721		0x00010000
1026 #define	MBUF_POOL_BASE_5704		0x00010000
1027 #define	MBUF_POOL_BASE_5705		0x00010000
1028 #define	MBUF_POOL_LENGTH_REG		0x440c
1029 #define	MBUF_POOL_LENGTH_DEFAULT	0x00018000
1030 #define	MBUF_POOL_LENGTH_5704		0x00010000
1031 #define	MBUF_POOL_LENGTH_5705		0x00008000
1032 #define	MBUF_POOL_LENGTH_5721		0x00008000
1033 #define	RDMA_MBUF_LOWAT_REG		0x4410
1034 #define	RDMA_MBUF_LOWAT_DEFAULT		0x00000050
1035 #define	RDMA_MBUF_LOWAT_5705		0x00000000
1036 #define	RDMA_MBUF_LOWAT_JUMBO		0x00000130
1037 #define	RDMA_MBUF_LOWAT_5714_JUMBO	0x00000000
1038 #define	MAC_RX_MBUF_LOWAT_REG		0x4414
1039 #define	MAC_RX_MBUF_LOWAT_DEFAULT	0x00000020
1040 #define	MAC_RX_MBUF_LOWAT_5705		0x00000010
1041 #define	MAC_RX_MBUF_LOWAT_JUMBO		0x00000098
1042 #define	MAC_RX_MBUF_LOWAT_5714_JUMBO	0x0000004b
1043 #define	MBUF_HIWAT_REG			0x4418
1044 #define	MBUF_HIWAT_DEFAULT		0x00000060
1045 #define	MBUF_HIWAT_5705			0x00000060
1046 #define	MBUF_HIWAT_JUMBO		0x0000017c
1047 #define	MBUF_HIWAT_5714_JUMBO		0x00000096
1048 
1049 /*
1050  * DMA Descriptor Pool Initialisation & Watermark Registers
1051  */
1052 #define	DMAD_POOL_BASE_REG		0x442c
1053 #define	DMAD_POOL_BASE_DEFAULT		0x00002000
1054 #define	DMAD_POOL_LENGTH_REG		0x4430
1055 #define	DMAD_POOL_LENGTH_DEFAULT	0x00002000
1056 #define	DMAD_POOL_LOWAT_REG		0x4434
1057 #define	DMAD_POOL_LOWAT_DEFAULT		0x00000005	/* 5	*/
1058 #define	DMAD_POOL_HIWAT_REG		0x4438
1059 #define	DMAD_POOL_HIWAT_DEFAULT		0x0000000a	/* 10	*/
1060 
1061 /*
1062  * More threshold/watermark registers ...
1063  */
1064 #define	RECV_FLOW_THRESHOLD_REG		0x4458
1065 #define	LOWAT_MAX_RECV_FRAMES_REG	0x0504
1066 #define	LOWAT_MAX_RECV_FRAMES_DEFAULT	0x00000002
1067 
1068 /*
1069  * Read/Write DMA Status Registers
1070  */
1071 #define	READ_DMA_STATUS_REG		0x4804
1072 #define	WRITE_DMA_STATUS_REG		0x4c04
1073 
1074 /*
1075  * RX/TX RISC Registers
1076  */
1077 #define	RX_RISC_MODE_REG		0x5000
1078 #define	RX_RISC_STATE_REG		0x5004
1079 #define	RX_RISC_PC_REG			0x501c
1080 #define	TX_RISC_MODE_REG		0x5400
1081 #define	TX_RISC_STATE_REG		0x5404
1082 #define	TX_RISC_PC_REG			0x541c
1083 
1084 #define	FTQ_RESET_REG			0x5c00
1085 
1086 #define	MSI_MODE_REG			0x6000
1087 #define	MSI_PRI_HIGHEST			0xc0000000
1088 #define	MSI_MSI_ENABLE			0x00000002
1089 #define	MSI_ERROR_ATTENTION		0x0000001c
1090 
1091 #define	MSI_STATUS_REG			0x6004
1092 
1093 #define	MODE_CONTROL_REG		0x6800
1094 #define	MODE_ROUTE_MCAST_TO_RX_RISC	0x40000000
1095 #define	MODE_4X_NIC_SEND_RINGS		0x20000000
1096 #define	MODE_INT_ON_FLOW_ATTN		0x10000000
1097 #define	MODE_INT_ON_DMA_ATTN		0x08000000
1098 #define	MODE_INT_ON_MAC_ATTN		0x04000000
1099 #define	MODE_INT_ON_RXRISC_ATTN		0x02000000
1100 #define	MODE_INT_ON_TXRISC_ATTN		0x01000000
1101 #define	MODE_RECV_NO_PSEUDO_HDR_CSUM	0x00800000
1102 #define	MODE_SEND_NO_PSEUDO_HDR_CSUM	0x00100000
1103 #define	MODE_HOST_SEND_BDS		0x00020000
1104 #define	MODE_HOST_STACK_UP		0x00010000
1105 #define	MODE_FORCE_32_BIT_PCI		0x00008000
1106 #define	MODE_NO_INT_ON_RECV		0x00004000
1107 #define	MODE_NO_INT_ON_SEND		0x00002000
1108 #define	MODE_ALLOW_BAD_FRAMES		0x00000800
1109 #define	MODE_NO_CRC			0x00000400
1110 #define	MODE_NO_FRAME_CRACKING		0x00000200
1111 #define	MODE_WORD_SWAP_FRAME		0x00000020
1112 #define	MODE_BYTE_SWAP_FRAME		0x00000010
1113 #define	MODE_WORD_SWAP_NONFRAME		0x00000004
1114 #define	MODE_BYTE_SWAP_NONFRAME		0x00000002
1115 #define	MODE_UPDATE_ON_COAL_ONLY	0x00000001
1116 
1117 /*
1118  * Miscellaneous Configuration Register
1119  *
1120  * This contains various bits relating to power control (which differ
1121  * among different members of the chip family), but the important bits
1122  * for our purposes are the RESET bit and the Timer Prescaler field.
1123  *
1124  * The RESET bit in this register serves to reset the whole chip, even
1125  * including the PCI interface(!)  Once it's set, the chip will not
1126  * respond to ANY accesses -- not even CONFIG space -- until the reset
1127  * completes internally.  According to the PRM, this should take less
1128  * than 100us.  Any access during this period will get a bus error.
1129  *
1130  * The Timer Prescaler field must be programmed so that the timer period
1131  * is as near as possible to 1us.  The value in this field should be
1132  * the Core Clock frequency in MHz minus 1.  From my reading of the PRM,
1133  * the Core Clock should always be 66MHz (independently of the bus speed,
1134  * at least for PCI rather than PCI-X), so this register must be set to
1135  * the value 0x82 ((66-1) << 1).
1136  */
1137 #define	CORE_CLOCK_MHZ			66
1138 #define	MISC_CONFIG_REG			0x6804
1139 #define	MISC_CONFIG_GRC_RESET_DISABLE   0x20000000
1140 #define	MISC_CONFIG_GPHY_POWERDOWN_OVERRIDE 0x04000000
1141 #define	MISC_CONFIG_POWERDOWN		0x00100000
1142 #define	MISC_CONFIG_POWER_STATE		0x00060000
1143 #define	MISC_CONFIG_PRESCALE_MASK	0x000000fe
1144 #define	MISC_CONFIG_RESET_BIT		0x00000001
1145 #define	MISC_CONFIG_DEFAULT		(((CORE_CLOCK_MHZ)-1) << 1)
1146 
1147 /*
1148  * Miscellaneous Local Control Register (MLCR)
1149  */
1150 #define	MISC_LOCAL_CONTROL_REG		0x6808
1151 #define	MLCR_PCI_CTRL_SELECT		0x10000000
1152 #define	MLCR_LEGACY_PCI_MODE		0x08000000
1153 #define	MLCR_AUTO_SEEPROM_ACCESS	0x01000000
1154 #define	MLCR_SSRAM_CYCLE_DESELECT	0x00800000
1155 #define	MLCR_SSRAM_TYPE			0x00400000
1156 #define	MLCR_BANK_SELECT		0x00200000
1157 #define	MLCR_SRAM_SIZE_MASK		0x001c0000
1158 #define	MLCR_ENABLE_EXTERNAL_MEMORY	0x00020000
1159 
1160 #define	MLCR_MISC_PINS_OUTPUT_2		0x00010000
1161 #define	MLCR_MISC_PINS_OUTPUT_1		0x00008000
1162 #define	MLCR_MISC_PINS_OUTPUT_0		0x00004000
1163 #define	MLCR_MISC_PINS_OUTPUT_ENABLE_2	0x00002000
1164 #define	MLCR_MISC_PINS_OUTPUT_ENABLE_1	0x00001000
1165 #define	MLCR_MISC_PINS_OUTPUT_ENABLE_0	0x00000800
1166 #define	MLCR_MISC_PINS_INPUT_2		0x00000400	/* R/O	*/
1167 #define	MLCR_MISC_PINS_INPUT_1		0x00000200	/* R/O	*/
1168 #define	MLCR_MISC_PINS_INPUT_0		0x00000100	/* R/O	*/
1169 
1170 #define	MLCR_INT_ON_ATTN		0x00000008	/* R/W	*/
1171 #define	MLCR_SET_INT			0x00000004	/* W/O	*/
1172 #define	MLCR_CLR_INT			0x00000002	/* W/O	*/
1173 #define	MLCR_INTA_STATE			0x00000001	/* R/O	*/
1174 
1175 /*
1176  * This value defines all GPIO bits as INPUTS, but sets their default
1177  * values as outputs to HIGH, on the assumption that external circuits
1178  * (if any) will probably be active-LOW with passive pullups.
1179  *
1180  * The Claymore blade uses GPIO1 to control writing to the SEEPROM in
1181  * just this fashion.  It has to be set as an OUTPUT and driven LOW to
1182  * enable writing.  Otherwise, the SEEPROM is protected.
1183  */
1184 #define	MLCR_DEFAULT			0x0101c000
1185 #define	MLCR_DEFAULT_5714		0x1901c000
1186 
1187 /*
1188  * Serial EEPROM Data/Address Registers (auto-access mode)
1189  */
1190 #define	SERIAL_EEPROM_DATA_REG		0x683c
1191 #define	SERIAL_EEPROM_ADDRESS_REG	0x6838
1192 #define	SEEPROM_ACCESS_READ		0x80000000
1193 #define	SEEPROM_ACCESS_WRITE		0x00000000
1194 #define	SEEPROM_ACCESS_COMPLETE		0x40000000
1195 #define	SEEPROM_ACCESS_RESET		0x20000000
1196 #define	SEEPROM_ACCESS_DEVID_MASK	0x1c000000
1197 #define	SEEPROM_ACCESS_START		0x02000000
1198 #define	SEEPROM_ACCESS_HALFCLOCK_MASK	0x01ff0000
1199 #define	SEEPROM_ACCESS_ADDRESS_MASK	0x0000fffc
1200 
1201 #define	SEEPROM_ACCESS_DEVID_SHIFT	26		/* bits	*/
1202 #define	SEEPROM_ACCESS_HALFCLOCK_SHIFT	16		/* bits */
1203 #define	SEEPROM_ACCESS_ADDRESS_SIZE	16		/* bits	*/
1204 
1205 #define	SEEPROM_ACCESS_HALFCLOCK_340KHZ	0x0060		/* 340kHz */
1206 #define	SEEPROM_ACCESS_INIT		0x20600000	/* reset+clock	*/
1207 
1208 /*
1209  * "Linearised" address mask, treating multiple devices as consecutive
1210  */
1211 #define	SEEPROM_DEV_AND_ADDR_MASK	0x0007fffc	/* 8x64k devices */
1212 
1213 /*
1214  * Non-Volatile Memory Interface Registers
1215  * Note: on chips that support the flash interface (5702+), flash is the
1216  * default and the legacy seeprom interface must be explicitly enabled
1217  * if required. On older chips (5700/01), SEEPROM is the default (and
1218  * only) non-volatile memory available, and these registers don't exist!
1219  */
1220 #define	NVM_FLASH_CMD_REG		0x7000
1221 #define	NVM_FLASH_CMD_LAST		0x00000100
1222 #define	NVM_FLASH_CMD_FIRST		0x00000080
1223 #define	NVM_FLASH_CMD_RD		0x00000000
1224 #define	NVM_FLASH_CMD_WR		0x00000020
1225 #define	NVM_FLASH_CMD_DOIT		0x00000010
1226 #define	NVM_FLASH_CMD_DONE		0x00000008
1227 
1228 #define	NVM_FLASH_WRITE_REG		0x7008
1229 #define	NVM_FLASH_READ_REG		0x7010
1230 
1231 #define	NVM_FLASH_ADDR_REG		0x700c
1232 #define	NVM_FLASH_ADDR_MASK		0x00fffffc
1233 
1234 #define	NVM_CONFIG1_REG			0x7014
1235 #define	NVM_CFG1_LEGACY_SEEPROM_MODE	0x80000000
1236 #define	NVM_CFG1_SEE_CLK_DIV_MASK	0x003ff800
1237 #define	NVM_CFG1_SPI_CLK_DIV_MASK	0x00000780
1238 #define	NVM_CFG1_BUFFERED_MODE		0x00000002
1239 #define	NVM_CFG1_FLASH_MODE		0x00000001
1240 
1241 #define	NVM_SW_ARBITRATION_REG		0x7020
1242 #define	NVM_READ_REQ3			0X00008000
1243 #define	NVM_READ_REQ2			0X00004000
1244 #define	NVM_READ_REQ1			0X00002000
1245 #define	NVM_READ_REQ0			0X00001000
1246 #define	NVM_WON_REQ3			0X00000800
1247 #define	NVM_WON_REQ2			0X00000400
1248 #define	NVM_WON_REQ1			0X00000200
1249 #define	NVM_WON_REQ0			0X00000100
1250 #define	NVM_RESET_REQ3			0X00000080
1251 #define	NVM_RESET_REQ2			0X00000040
1252 #define	NVM_RESET_REQ1			0X00000020
1253 #define	NVM_RESET_REQ0			0X00000010
1254 #define	NVM_SET_REQ3			0X00000008
1255 #define	NVM_SET_REQ2			0X00000004
1256 #define	NVM_SET_REQ1			0X00000002
1257 #define	NVM_SET_REQ0			0X00000001
1258 
1259 /*
1260  * NVM access register
1261  * Applicable to BCM5721,BCM5751,BCM5752,BCM5714
1262  * and BCM5715 only.
1263  */
1264 #define	NVM_ACCESS_REG			0X7024
1265 #define	NVM_WRITE_ENABLE		0X00000002
1266 #define	NVM_ACCESS_ENABLE		0X00000001
1267 
1268 /*
1269  * TLP Control Register
1270  * Applicable to BCM5721 and BCM5751 only
1271  */
1272 #define	TLP_CONTROL_REG			0x7c00
1273 #define	TLP_DATA_FIFO_PROTECT		0x02000000
1274 
1275 /*
1276  * PHY Test Control Register
1277  * Applicable to BCM5721 and BCM5751 only
1278  */
1279 #define	PHY_TEST_CTRL_REG		0x7e2c
1280 #define	PHY_PCIE_SCRAM_MODE		0x20
1281 #define	PHY_PCIE_LTASS_MODE		0x40
1282 
1283 /*
1284  * The internal firmware expects a certain layout of the non-volatile
1285  * memory (if fitted), and will check for it during startup, and use the
1286  * contents to initialise various internal parameters if it looks good.
1287  *
1288  * The offsets and field definitions below refer to where to find some
1289  * important values, and how to interpret them ...
1290  */
1291 #define	NVMEM_DATA_MAC_ADDRESS		0x007c		/* 8 bytes	*/
1292 
1293 /*
1294  * MII (PHY) registers, beyond those already defined in <sys/miiregs.h>
1295  */
1296 
1297 #define	MII_AN_LPNXTPG			8
1298 #define	MII_1000BASE_T_CONTROL		9
1299 #define	MII_1000BASE_T_STATUS		10
1300 #define	MII_IEEE_EXT_STATUS		15
1301 
1302 /*
1303  * New bits in the MII_CONTROL register
1304  */
1305 #define	MII_CONTROL_1000MB		0x0040
1306 
1307 /*
1308  * New bits in the MII_AN_ADVERT register
1309  */
1310 #define	MII_ABILITY_ASYM_PAUSE		0x0800
1311 #define	MII_ABILITY_PAUSE		0x0400
1312 
1313 /*
1314  * Values for the <selector> field of the MII_AN_ADVERT register
1315  */
1316 #define	MII_AN_SELECTOR_8023		0x0001
1317 
1318 /*
1319  * Bits in the MII_1000BASE_T_CONTROL register
1320  *
1321  * The MASTER_CFG bit enables manual configuration of Master/Slave mode
1322  * (otherwise, roles are automatically negotiated).  When this bit is set,
1323  * the MASTER_SEL bit forces Master mode, otherwise Slave mode is forced.
1324  */
1325 #define	MII_1000BT_CTL_MASTER_CFG	0x1000	/* enable role select	*/
1326 #define	MII_1000BT_CTL_MASTER_SEL	0x0800	/* role select bit	*/
1327 #define	MII_1000BT_CTL_ADV_FDX		0x0200
1328 #define	MII_1000BT_CTL_ADV_HDX		0x0100
1329 
1330 /*
1331  * Bits in the MII_1000BASE_T_STATUS register
1332  */
1333 #define	MII_1000BT_STAT_MASTER_FAULT	0x8000
1334 #define	MII_1000BT_STAT_MASTER_MODE	0x4000	/* shows role selected	*/
1335 #define	MII_1000BT_STAT_LCL_RCV_OK	0x2000
1336 #define	MII_1000BT_STAT_RMT_RCV_OK	0x1000
1337 #define	MII_1000BT_STAT_LP_FDX_CAP	0x0800
1338 #define	MII_1000BT_STAT_LP_HDX_CAP	0x0400
1339 
1340 /*
1341  * Vendor-specific MII registers
1342  */
1343 #define	MII_EXT_CONTROL			MII_VENDOR(0)
1344 #define	MII_EXT_STATUS			MII_VENDOR(1)
1345 #define	MII_RCV_ERR_COUNT		MII_VENDOR(2)
1346 #define	MII_FALSE_CARR_COUNT		MII_VENDOR(3)
1347 #define	MII_RCV_NOT_OK_COUNT		MII_VENDOR(4)
1348 #define	MII_AUX_CONTROL			MII_VENDOR(8)
1349 #define	MII_AUX_STATUS			MII_VENDOR(9)
1350 #define	MII_INTR_STATUS			MII_VENDOR(10)
1351 #define	MII_INTR_MASK			MII_VENDOR(11)
1352 #define	MII_HCD_STATUS			MII_VENDOR(13)
1353 
1354 #define	MII_MAXREG			MII_VENDOR(15)	/* 31, 0x1f	*/
1355 
1356 /*
1357  * Bits in the MII_EXT_CONTROL register
1358  */
1359 #define	MII_EXT_CTRL_INTERFACE_TBI	0x8000
1360 #define	MII_EXT_CTRL_DISABLE_AUTO_MDIX	0x4000
1361 #define	MII_EXT_CTRL_DISABLE_TRANSMIT	0x2000
1362 #define	MII_EXT_CTRL_DISABLE_INTERRUPT	0x1000
1363 #define	MII_EXT_CTRL_FORCE_INTERRUPT	0x0800
1364 #define	MII_EXT_CTRL_BYPASS_4B5B	0x0400
1365 #define	MII_EXT_CTRL_BYPASS_SCRAMBLER	0x0200
1366 #define	MII_EXT_CTRL_BYPASS_MLT3	0x0100
1367 #define	MII_EXT_CTRL_BYPASS_RX_ALIGN	0x0080
1368 #define	MII_EXT_CTRL_RESET_SCRAMBLER	0x0040
1369 #define	MII_EXT_CTRL_LED_TRAFFIC_MODE	0x0020
1370 #define	MII_EXT_CTRL_FORCE_LEDS_ON	0x0010
1371 #define	MII_EXT_CTRL_FORCE_LEDS_OFF	0x0008
1372 #define	MII_EXT_CTRL_EXTEND_TX_IPG	0x0004
1373 #define	MII_EXT_CTRL_3LINK_LED_MODE	0x0002
1374 #define	MII_EXT_CTRL_FIFO_ELASTICITY	0x0001
1375 
1376 /*
1377  * Bits in the MII_EXT_STATUS register
1378  */
1379 #define	MII_EXT_STAT_S3MII_FIFO_ERROR	0x8000
1380 #define	MII_EXT_STAT_WIRESPEED_DOWNGRADE 0x4000
1381 #define	MII_EXT_STAT_MDIX_STATE		0x2000
1382 #define	MII_EXT_STAT_INTERRUPT_STATUS	0x1000
1383 #define	MII_EXT_STAT_REMOTE_RCVR_STATUS	0x0800
1384 #define	MII_EXT_STAT_LOCAL_RDVR_STATUS	0x0400
1385 #define	MII_EXT_STAT_DESCRAMBLER_LOCKED	0x0200
1386 #define	MII_EXT_STAT_LINK_STATUS	0x0100
1387 #define	MII_EXT_STAT_CRC_ERROR		0x0080
1388 #define	MII_EXT_STAT_CARR_EXT_ERROR	0x0040
1389 #define	MII_EXT_STAT_BAD_SSD_ERROR	0x0020
1390 #define	MII_EXT_STAT_BAD_ESD_ERROR	0x0010
1391 #define	MII_EXT_STAT_RECEIVE_ERROR	0x0008
1392 #define	MII_EXT_STAT_TRANSMIT_ERROR	0x0004
1393 #define	MII_EXT_STAT_LOCK_ERROR		0x0002
1394 #define	MII_EXT_STAT_MLT3_CODE_ERROR	0x0001
1395 
1396 /*
1397  * The AUX CONTROL register is seriously weird!
1398  *
1399  * It hides (up to) eight 'shadow' registers.  When writing, which one
1400  * of them is written is determined by the low-order bits of the data
1401  * written(!), but when reading, which one is read is determined by the
1402  * value previously written to (part of) one of the shadow registers!!!
1403  */
1404 
1405 /*
1406  * Shadow register numbers
1407  */
1408 #define	MII_AUX_CTRL_NORMAL		0
1409 #define	MII_AUX_CTRL_10BASE_T		1
1410 #define	MII_AUX_CTRL_POWER		2
1411 #define	MII_AUX_CTRL_TEST_1		4
1412 #define	MII_AUX_CTRL_MISC		7
1413 
1414 /*
1415  * Selected bits in some of the shadow registers ...
1416  */
1417 #define	MII_AUX_CTRL_NORM_EXT_LOOPBACK	0x8000
1418 #define	MII_AUX_CTRL_NORM_LONG_PKTS	0x4000
1419 #define	MII_AUX_CTRL_NORM_EDGE_CTRL	0x3000
1420 #define	MII_AUX_CTRL_NORM_TX_MODE	0x0400
1421 #define	MII_AUX_CTRL_NORM_CABLE_TEST	0x0008
1422 
1423 #define	MII_AUX_CTRL_TEST_TX_HALF	0x0008
1424 
1425 #define	MII_AUX_CTRL_MISC_WRITE_ENABLE	0x8000
1426 #define	MII_AUX_CTRL_MISC_WIRE_SPEED	0x0010
1427 
1428 /*
1429  * Write this value to the AUX control register
1430  * to select which shadow register will be read
1431  */
1432 #define	MII_AUX_CTRL_SHADOW_READ(x)	(((x) << 12) | MII_AUX_CTRL_MISC)
1433 
1434 /*
1435  * Bits in the MII_AUX_STATUS register
1436  */
1437 #define	MII_AUX_STATUS_MODE_MASK	0x0700
1438 #define	MII_AUX_STATUS_MODE_1000_F	0x0700
1439 #define	MII_AUX_STATUS_MODE_1000_H	0x0600
1440 #define	MII_AUX_STATUS_MODE_100_F	0x0500
1441 #define	MII_AUX_STATUS_MODE_100_4	0x0400
1442 #define	MII_AUX_STATUS_MODE_100_H	0x0300
1443 #define	MII_AUX_STATUS_MODE_10_F	0x0200
1444 #define	MII_AUX_STATUS_MODE_10_H	0x0100
1445 #define	MII_AUX_STATUS_MODE_NONE	0x0000
1446 #define	MII_AUX_STATUS_MODE_SHIFT	8
1447 
1448 #define	MII_AUX_STATUS_PAR_FAULT	0x0080
1449 #define	MII_AUX_STATUS_REM_FAULT	0x0040
1450 #define	MII_AUX_STATUS_LP_ANEG_ABLE	0x0010
1451 #define	MII_AUX_STATUS_LP_NP_ABLE	0x0008
1452 
1453 #define	MII_AUX_STATUS_LINKUP		0x0004
1454 #define	MII_AUX_STATUS_RX_PAUSE		0x0002
1455 #define	MII_AUX_STATUS_TX_PAUSE		0x0001
1456 
1457 /*
1458  * Bits in the MII_INTR_STATUS and MII_INTR_MASK registers
1459  */
1460 #define	MII_INTR_RMT_RX_STATUS_CHANGE	0x0020
1461 #define	MII_INTR_LCL_RX_STATUS_CHANGE	0x0010
1462 #define	MII_INTR_LINK_DUPLEX_CHANGE	0x0008
1463 #define	MII_INTR_LINK_SPEED_CHANGE	0x0004
1464 #define	MII_INTR_LINK_STATUS_CHANGE	0x0002
1465 
1466 
1467 /*
1468  * Third section:
1469  * 	Hardware-defined data structures
1470  *
1471  * Note that the chip is naturally BIG-endian, so, for a big-endian
1472  * host, the structures defined below match those described in the PRM.
1473  * For little-endian hosts, some structures have to be swapped around.
1474  */
1475 
1476 #if	!defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
1477 #error	Host endianness not defined
1478 #endif
1479 
1480 /*
1481  * Architectural constants: absolute maximum numbers of each type of ring
1482  */
1483 #ifdef BGE_EXT_MEM
1484 #define	BGE_SEND_RINGS_MAX		16	/* only with ext mem	*/
1485 #else
1486 #define	BGE_SEND_RINGS_MAX		4
1487 #endif
1488 #define	BGE_SEND_RINGS_MAX_5705		1
1489 #define	BGE_RECV_RINGS_MAX		16
1490 #define	BGE_RECV_RINGS_MAX_5705		1
1491 #define	BGE_BUFF_RINGS_MAX		3	/* jumbo/std/mini (mini	*/
1492 						/* only with ext mem)	*/
1493 
1494 #define	BGE_SEND_SLOTS_MAX		512
1495 #define	BGE_STD_SLOTS_MAX		512
1496 #define	BGE_JUMBO_SLOTS_MAX		256
1497 #define	BGE_MINI_SLOTS_MAX		1024
1498 #define	BGE_RECV_SLOTS_MAX		2048
1499 #define	BGE_RECV_SLOTS_5705		512
1500 #define	BGE_RECV_SLOTS_5782		512
1501 #define	BGE_RECV_SLOTS_5721		512
1502 
1503 /*
1504  * Hardware-defined Ring Control Block
1505  */
1506 typedef struct {
1507 	uint64_t	host_ring_addr;
1508 #ifdef	_BIG_ENDIAN
1509 	uint16_t	max_len;
1510 	uint16_t	flags;
1511 	uint32_t	nic_ring_addr;
1512 #else
1513 	uint32_t	nic_ring_addr;
1514 	uint16_t	flags;
1515 	uint16_t	max_len;
1516 #endif	/* _BIG_ENDIAN */
1517 } bge_rcb_t;
1518 
1519 #define	RCB_FLAG_USE_EXT_RCV_BD		0x0001
1520 #define	RCB_FLAG_RING_DISABLED		0x0002
1521 
1522 /*
1523  * Hardware-defined Send Buffer Descriptor
1524  */
1525 typedef struct {
1526 	uint64_t	host_buf_addr;
1527 #ifdef	_BIG_ENDIAN
1528 	uint16_t	len;
1529 	uint16_t	flags;
1530 	uint16_t	reserved;
1531 	uint16_t	vlan_tci;
1532 #else
1533 	uint16_t	vlan_tci;
1534 	uint16_t	reserved;
1535 	uint16_t	flags;
1536 	uint16_t	len;
1537 #endif	/* _BIG_ENDIAN */
1538 } bge_sbd_t;
1539 
1540 #define	SBD_FLAG_TCP_UDP_CKSUM		0x0001
1541 #define	SBD_FLAG_IP_CKSUM		0x0002
1542 #define	SBD_FLAG_PACKET_END		0x0004
1543 #define	SBD_FLAG_IP_FRAG		0x0008
1544 #define	SBD_FLAG_IP_FRAG_END		0x0010
1545 
1546 #define	SBD_FLAG_VLAN_TAG		0x0040
1547 #define	SBD_FLAG_COAL_NOW		0x0080
1548 #define	SBD_FLAG_CPU_PRE_DMA		0x0100
1549 #define	SBD_FLAG_CPU_POST_DMA		0x0200
1550 
1551 #define	SBD_FLAG_INSERT_SRC_ADDR	0x1000
1552 #define	SBD_FLAG_CHOOSE_SRC_ADDR	0x6000
1553 #define	SBD_FLAG_DONT_GEN_CRC		0x8000
1554 
1555 /*
1556  * Hardware-defined Receive Buffer Descriptor
1557  */
1558 typedef struct {
1559 	uint64_t	host_buf_addr;
1560 #ifdef	_BIG_ENDIAN
1561 	uint16_t	index;
1562 	uint16_t	len;
1563 	uint16_t	type;
1564 	uint16_t	flags;
1565 	uint16_t	ip_cksum;
1566 	uint16_t	tcp_udp_cksum;
1567 	uint16_t	error_flag;
1568 	uint16_t	vlan_tci;
1569 	uint32_t	reserved;
1570 	uint32_t	opaque;
1571 #else
1572 	uint16_t	flags;
1573 	uint16_t	type;
1574 	uint16_t	len;
1575 	uint16_t	index;
1576 	uint16_t	vlan_tci;
1577 	uint16_t	error_flag;
1578 	uint16_t	tcp_udp_cksum;
1579 	uint16_t	ip_cksum;
1580 	uint32_t	opaque;
1581 	uint32_t	reserved;
1582 #endif	/* _BIG_ENDIAN */
1583 } bge_rbd_t;
1584 
1585 #define	RBD_FLAG_STD_RING		0x0000
1586 #define	RBD_FLAG_PACKET_END		0x0004
1587 
1588 #define	RBD_FLAG_JUMBO_RING		0x0020
1589 #define	RBD_FLAG_VLAN_TAG		0x0040
1590 
1591 #define	RBD_FLAG_FRAME_HAS_ERROR	0x0400
1592 #define	RBD_FLAG_MINI_RING		0x0800
1593 #define	RBD_FLAG_IP_CHECKSUM		0x1000
1594 #define	RBD_FLAG_TCP_UDP_CHECKSUM	0x2000
1595 #define	RBD_FLAG_TCP_UDP_IS_TCP		0x4000
1596 
1597 #define	RBD_FLAG_DEFAULT		0x0000
1598 
1599 #define	RBD_ERROR_BAD_CRC		0x00010000
1600 #define	RBD_ERROR_COLL_DETECT		0x00020000
1601 #define	RBD_ERROR_LINK_LOST		0x00040000
1602 #define	RBD_ERROR_PHY_DECODE_ERR	0x00080000
1603 #define	RBD_ERROR_ODD_NIBBLE_RX_MII	0x00100000
1604 #define	RBD_ERROR_MAC_ABORT		0x00200000
1605 #define	RBD_ERROR_LEN_LESS_64		0x00400000
1606 #define	RBD_ERROR_TRUNC_NO_RES		0x00800000
1607 #define	RBD_ERROR_GIANT_PKT_RCVD	0x01000000
1608 
1609 /*
1610  * Hardware-defined Status Block,Size of status block
1611  * is actually 0x50 bytes.Use 0x80 bytes for cache line
1612  * alignment.For BCM5705/5788/5721/5751/5752/5714
1613  * and 5715,there is only 1 recv and send ring index,but
1614  * driver defined 16 indexs here,please pay attention only
1615  * one ring is enabled in these chipsets.
1616  */
1617 typedef struct {
1618 	uint64_t	flags_n_tag;
1619 	uint16_t	buff_cons_index[4];
1620 	struct {
1621 #ifdef	_BIG_ENDIAN
1622 		uint16_t	send_cons_index;
1623 		uint16_t	recv_prod_index;
1624 #else
1625 		uint16_t	recv_prod_index;
1626 		uint16_t	send_cons_index;
1627 #endif	/* _BIG_ENDIAN */
1628 	} index[16];
1629 } bge_status_t;
1630 
1631 /*
1632  * Hardware-defined Receive BD Rule
1633  */
1634 typedef struct {
1635 	uint32_t	control;
1636 	uint32_t	mask_value;
1637 } bge_recv_rule_t;
1638 
1639 /*
1640  * Indexes into the <buff_cons_index> array
1641  */
1642 #ifdef	_BIG_ENDIAN
1643 #define	STATUS_STD_BUFF_CONS_INDEX	0
1644 #define	STATUS_JUMBO_BUFF_CONS_INDEX	1
1645 #define	STATUS_MINI_BUFF_CONS_INDEX	3
1646 #define	SEND_INDEX_P(bsp, ring)	(&(bsp)->index[(ring)^0].send_cons_index)
1647 #define	RECV_INDEX_P(bsp, ring)	(&(bsp)->index[(ring)^0].recv_prod_index)
1648 #else
1649 #define	STATUS_STD_BUFF_CONS_INDEX	3
1650 #define	STATUS_JUMBO_BUFF_CONS_INDEX	2
1651 #define	STATUS_MINI_BUFF_CONS_INDEX	0
1652 #define	SEND_INDEX_P(bsp, ring)	(&(bsp)->index[(ring)^1].send_cons_index)
1653 #define	RECV_INDEX_P(bsp, ring)	(&(bsp)->index[(ring)^1].recv_prod_index)
1654 #endif	/* _BIG_ENDIAN */
1655 
1656 /*
1657  * Bits in the <flags_n_tag> word
1658  */
1659 #define	STATUS_FLAG_UPDATED		0x0000000100000000ull
1660 #define	STATUS_FLAG_LINK_CHANGED	0x0000000200000000ull
1661 #define	STATUS_FLAG_ERROR		0x0000000400000000ull
1662 #define	STATUS_TAG_MASK			0x00000000000000FFull
1663 
1664 /*
1665  * The tag from the status block is fed back to Interrupt Mailbox 0
1666  * (INTERRUPT_MBOX_0_REG, 0x0200) after servicing an interrupt.  This
1667  * lets the chip know what updates have been processed, so it can
1668  * reassert its interrupt if more updates have occurred since.
1669  *
1670  * These macros extract the tag from the <flags_n_tag> word, shift
1671  * it to the proper position in the Mailbox register, and provide
1672  * the complete values to write to INTERRUPT_MBOX_0_REG to disable
1673  * or enable interrupts
1674  */
1675 #define	STATUS_TAG(fnt)			((fnt) & STATUS_TAG_MASK)
1676 #define	INTERRUPT_TAG(fnt)		(STATUS_TAG(fnt) << 24)
1677 #define	INTERRUPT_MBOX_DISABLE(fnt)	(INTERRUPT_TAG(fnt) | 1)
1678 #define	INTERRUPT_MBOX_ENABLE(fnt)	(INTERRUPT_TAG(fnt) | 0)
1679 
1680 /*
1681  * Hardware-defined Statistics Block Offsets
1682  *
1683  * These are given in the manual as addresses in NIC memory, starting
1684  * from the NIC statistics area base address of 0x300; but here we
1685  * convert them into indexes into an array of (uint64_t)s, so we can
1686  * use them directly for accessing the copy of the statistics block
1687  * that the chip DMAs into main memory ...
1688  */
1689 
1690 #define	KS_BASE				0x300
1691 #define	KS_ADDR(x)			(((x)-KS_BASE)/sizeof (uint64_t))
1692 
1693 typedef enum {
1694 	KS_ifHCInOctets = KS_ADDR(0x400),
1695 	KS_etherStatsFragments = KS_ADDR(0x410),
1696 	KS_ifHCInUcastPkts,
1697 	KS_ifHCInMulticastPkts,
1698 	KS_ifHCInBroadcastPkts,
1699 	KS_dot3StatsFCSErrors,
1700 	KS_dot3StatsAlignmentErrors,
1701 	KS_xonPauseFramesReceived,
1702 	KS_xoffPauseFramesReceived,
1703 	KS_macControlFramesReceived,
1704 	KS_xoffStateEntered,
1705 	KS_dot3StatsFrameTooLongs,
1706 	KS_etherStatsJabbers,
1707 	KS_etherStatsUndersizePkts,
1708 	KS_inRangeLengthError,
1709 	KS_outRangeLengthError,
1710 	KS_etherStatsPkts64Octets,
1711 	KS_etherStatsPkts65to127Octets,
1712 	KS_etherStatsPkts128to255Octets,
1713 	KS_etherStatsPkts256to511Octets,
1714 	KS_etherStatsPkts512to1023Octets,
1715 	KS_etherStatsPkts1024to1518Octets,
1716 	KS_etherStatsPkts1519to2047Octets,
1717 	KS_etherStatsPkts2048to4095Octets,
1718 	KS_etherStatsPkts4096to8191Octets,
1719 	KS_etherStatsPkts8192to9022Octets,
1720 
1721 	KS_ifHCOutOctets = KS_ADDR(0x600),
1722 	KS_etherStatsCollisions = KS_ADDR(0x610),
1723 	KS_outXonSent,
1724 	KS_outXoffSent,
1725 	KS_flowControlDone,
1726 	KS_dot3StatsInternalMacTransmitErrors,
1727 	KS_dot3StatsSingleCollisionFrames,
1728 	KS_dot3StatsMultipleCollisionFrames,
1729 	KS_dot3StatsDeferredTransmissions,
1730 	KS_dot3StatsExcessiveCollisions = KS_ADDR(0x658),
1731 	KS_dot3StatsLateCollisions,
1732 	KS_dot3Collided2Times,
1733 	KS_dot3Collided3Times,
1734 	KS_dot3Collided4Times,
1735 	KS_dot3Collided5Times,
1736 	KS_dot3Collided6Times,
1737 	KS_dot3Collided7Times,
1738 	KS_dot3Collided8Times,
1739 	KS_dot3Collided9Times,
1740 	KS_dot3Collided10Times,
1741 	KS_dot3Collided11Times,
1742 	KS_dot3Collided12Times,
1743 	KS_dot3Collided13Times,
1744 	KS_dot3Collided14Times,
1745 	KS_dot3Collided15Times,
1746 	KS_ifHCOutUcastPkts,
1747 	KS_ifHCOutMulticastPkts,
1748 	KS_ifHCOutBroadcastPkts,
1749 	KS_dot3StatsCarrierSenseErrors,
1750 	KS_ifOutDiscards,
1751 	KS_ifOutErrors,
1752 
1753 	KS_COSIfHCInPkts_1 = KS_ADDR(0x800),		/* [16]	*/
1754 	KS_COSIfHCInPkts_2,
1755 	KS_COSIfHCInPkts_3,
1756 	KS_COSIfHCInPkts_4,
1757 	KS_COSIfHCInPkts_5,
1758 	KS_COSIfHCInPkts_6,
1759 	KS_COSIfHCInPkts_7,
1760 	KS_COSIfHCInPkts_8,
1761 	KS_COSIfHCInPkts_9,
1762 	KS_COSIfHCInPkts_10,
1763 	KS_COSIfHCInPkts_11,
1764 	KS_COSIfHCInPkts_12,
1765 	KS_COSIfHCInPkts_13,
1766 	KS_COSIfHCInPkts_14,
1767 	KS_COSIfHCInPkts_15,
1768 	KS_COSIfHCInPkts_16,
1769 	KS_COSFramesDroppedDueToFilters,
1770 	KS_nicDmaWriteQueueFull,
1771 	KS_nicDmaWriteHighPriQueueFull,
1772 	KS_nicNoMoreRxBDs,
1773 	KS_ifInDiscards,
1774 	KS_ifInErrors,
1775 	KS_nicRecvThresholdHit,
1776 
1777 	KS_COSIfHCOutPkts_1 = KS_ADDR(0x900),		/* [16]	*/
1778 	KS_COSIfHCOutPkts_2,
1779 	KS_COSIfHCOutPkts_3,
1780 	KS_COSIfHCOutPkts_4,
1781 	KS_COSIfHCOutPkts_5,
1782 	KS_COSIfHCOutPkts_6,
1783 	KS_COSIfHCOutPkts_7,
1784 	KS_COSIfHCOutPkts_8,
1785 	KS_COSIfHCOutPkts_9,
1786 	KS_COSIfHCOutPkts_10,
1787 	KS_COSIfHCOutPkts_11,
1788 	KS_COSIfHCOutPkts_12,
1789 	KS_COSIfHCOutPkts_13,
1790 	KS_COSIfHCOutPkts_14,
1791 	KS_COSIfHCOutPkts_15,
1792 	KS_COSIfHCOutPkts_16,
1793 	KS_nicDmaReadQueueFull,
1794 	KS_nicDmaReadHighPriQueueFull,
1795 	KS_nicSendDataCompQueueFull,
1796 	KS_nicRingSetSendProdIndex,
1797 	KS_nicRingStatusUpdate,
1798 	KS_nicInterrupts,
1799 	KS_nicAvoidedInterrupts,
1800 	KS_nicSendThresholdHit,
1801 
1802 	KS_STATS_SIZE = KS_ADDR(0xb00)
1803 } bge_stats_offset_t;
1804 
1805 /*
1806  * Hardware-defined Statistics Block
1807  *
1808  * Another view of the statistic block, as a array and a structure ...
1809  */
1810 
1811 typedef union {
1812 	uint64_t		a[KS_STATS_SIZE];
1813 	struct {
1814 		uint64_t	spare1[(0x400-0x300)/sizeof (uint64_t)];
1815 
1816 		uint64_t	ifHCInOctets;		/* 0x0400	*/
1817 		uint64_t	spare2[1];
1818 		uint64_t	etherStatsFragments;
1819 		uint64_t	ifHCInUcastPkts;
1820 		uint64_t	ifHCInMulticastPkts;
1821 		uint64_t	ifHCInBroadcastPkts;
1822 		uint64_t	dot3StatsFCSErrors;
1823 		uint64_t	dot3StatsAlignmentErrors;
1824 		uint64_t	xonPauseFramesReceived;
1825 		uint64_t	xoffPauseFramesReceived;
1826 		uint64_t	macControlFramesReceived;
1827 		uint64_t	xoffStateEntered;
1828 		uint64_t	dot3StatsFrameTooLongs;
1829 		uint64_t	etherStatsJabbers;
1830 		uint64_t	etherStatsUndersizePkts;
1831 		uint64_t	inRangeLengthError;
1832 		uint64_t	outRangeLengthError;
1833 		uint64_t	etherStatsPkts64Octets;
1834 		uint64_t	etherStatsPkts65to127Octets;
1835 		uint64_t	etherStatsPkts128to255Octets;
1836 		uint64_t	etherStatsPkts256to511Octets;
1837 		uint64_t	etherStatsPkts512to1023Octets;
1838 		uint64_t	etherStatsPkts1024to1518Octets;
1839 		uint64_t	etherStatsPkts1519to2047Octets;
1840 		uint64_t	etherStatsPkts2048to4095Octets;
1841 		uint64_t	etherStatsPkts4096to8191Octets;
1842 		uint64_t	etherStatsPkts8192to9022Octets;
1843 		uint64_t	spare3[(0x600-0x4d8)/sizeof (uint64_t)];
1844 
1845 		uint64_t	ifHCOutOctets;		/* 0x0600	*/
1846 		uint64_t	spare4[1];
1847 		uint64_t	etherStatsCollisions;
1848 		uint64_t	outXonSent;
1849 		uint64_t	outXoffSent;
1850 		uint64_t	flowControlDone;
1851 		uint64_t	dot3StatsInternalMacTransmitErrors;
1852 		uint64_t	dot3StatsSingleCollisionFrames;
1853 		uint64_t	dot3StatsMultipleCollisionFrames;
1854 		uint64_t	dot3StatsDeferredTransmissions;
1855 		uint64_t	spare5[1];
1856 		uint64_t	dot3StatsExcessiveCollisions;
1857 		uint64_t	dot3StatsLateCollisions;
1858 		uint64_t	dot3Collided2Times;
1859 		uint64_t	dot3Collided3Times;
1860 		uint64_t	dot3Collided4Times;
1861 		uint64_t	dot3Collided5Times;
1862 		uint64_t	dot3Collided6Times;
1863 		uint64_t	dot3Collided7Times;
1864 		uint64_t	dot3Collided8Times;
1865 		uint64_t	dot3Collided9Times;
1866 		uint64_t	dot3Collided10Times;
1867 		uint64_t	dot3Collided11Times;
1868 		uint64_t	dot3Collided12Times;
1869 		uint64_t	dot3Collided13Times;
1870 		uint64_t	dot3Collided14Times;
1871 		uint64_t	dot3Collided15Times;
1872 		uint64_t	ifHCOutUcastPkts;
1873 		uint64_t	ifHCOutMulticastPkts;
1874 		uint64_t	ifHCOutBroadcastPkts;
1875 		uint64_t	dot3StatsCarrierSenseErrors;
1876 		uint64_t	ifOutDiscards;
1877 		uint64_t	ifOutErrors;
1878 		uint64_t	spare6[(0x800-0x708)/sizeof (uint64_t)];
1879 
1880 		uint64_t	COSIfHCInPkts[16];	/* 0x0800	*/
1881 		uint64_t	COSFramesDroppedDueToFilters;
1882 		uint64_t	nicDmaWriteQueueFull;
1883 		uint64_t	nicDmaWriteHighPriQueueFull;
1884 		uint64_t	nicNoMoreRxBDs;
1885 		uint64_t	ifInDiscards;
1886 		uint64_t	ifInErrors;
1887 		uint64_t	nicRecvThresholdHit;
1888 		uint64_t	spare7[(0x900-0x8b8)/sizeof (uint64_t)];
1889 
1890 		uint64_t	COSIfHCOutPkts[16];	/* 0x0900	*/
1891 		uint64_t	nicDmaReadQueueFull;
1892 		uint64_t	nicDmaReadHighPriQueueFull;
1893 		uint64_t	nicSendDataCompQueueFull;
1894 		uint64_t	nicRingSetSendProdIndex;
1895 		uint64_t	nicRingStatusUpdate;
1896 		uint64_t	nicInterrupts;
1897 		uint64_t	nicAvoidedInterrupts;
1898 		uint64_t	nicSendThresholdHit;
1899 		uint64_t	spare8[(0xb00-0x9c0)/sizeof (uint64_t)];
1900 	} s;
1901 } bge_statistics_t;
1902 
1903 #define	KS_STAT_REG_SIZE	(0x1B)
1904 #define	KS_STAT_REG_BASE	(0x800)
1905 
1906 typedef struct {
1907 	uint32_t	ifHCOutOctets;
1908 	uint32_t	etherStatsCollisions;
1909 	uint32_t	outXonSent;
1910 	uint32_t	outXoffSent;
1911 	uint32_t	dot3StatsInternalMacTransmitErrors;
1912 	uint32_t	dot3StatsSingleCollisionFrames;
1913 	uint32_t	dot3StatsMultipleCollisionFrames;
1914 	uint32_t	dot3StatsDeferredTransmissions;
1915 	uint32_t	dot3StatsExcessiveCollisions;
1916 	uint32_t	dot3StatsLateCollisions;
1917 	uint32_t	ifHCOutUcastPkts;
1918 	uint32_t	ifHCOutMulticastPkts;
1919 	uint32_t	ifHCOutBroadcastPkts;
1920 	uint32_t	ifHCInOctets;
1921 	uint32_t	etherStatsFragments;
1922 	uint32_t	ifHCInUcastPkts;
1923 	uint32_t	ifHCInMulticastPkts;
1924 	uint32_t	ifHCInBroadcastPkts;
1925 	uint32_t	dot3StatsFCSErrors;
1926 	uint32_t	dot3StatsAlignmentErrors;
1927 	uint32_t	xonPauseFramesReceived;
1928 	uint32_t	xoffPauseFramesReceived;
1929 	uint32_t	macControlFramesReceived;
1930 	uint32_t	xoffStateEntered;
1931 	uint32_t	dot3StatsFrameTooLongs;
1932 	uint32_t	etherStatsJabbers;
1933 	uint32_t	etherStatsUndersizePkts;
1934 } bge_statistics_reg_t;
1935 
1936 
1937 #ifdef BGE_IPMI_ASF
1938 
1939 /*
1940  * Device internal memory entries
1941  */
1942 
1943 #define	BGE_FIRMWARE_MAILBOX				0x0b50
1944 #define	BGE_MAGIC_NUM_FIRMWARE_INIT_DONE		0x4b657654
1945 #define	BGE_MAGIC_NUM_DISABLE_DMAW_ON_LINK_CHANGE	0x4861764b
1946 
1947 
1948 #define	BGE_NIC_DATA_SIG_ADDR			0x0b54
1949 #define	BGE_NIC_DATA_SIG			0x4b657654
1950 
1951 
1952 #define	BGE_NIC_DATA_NIC_CFG_ADDR		0x0b58
1953 
1954 #define	BGE_NIC_CFG_LED_MODE_TRIPLE_SPEED	0x000004
1955 #define	BGE_NIC_CFG_LED_MODE_LINK_SPEED		0x000008
1956 #define	BGE_NIC_CFG_LED_MODE_OPEN_DRAIN		0x000004
1957 #define	BGE_NIC_CFG_LED_MODE_OUTPUT		0x000008
1958 #define	BGE_NIC_CFG_LED_MODE_MASK		0x00000c
1959 
1960 #define	BGE_NIC_CFG_PHY_TYPE_UNKNOWN		0x000000
1961 #define	BGE_NIC_CFG_PHY_TYPE_COPPER		0x000010
1962 #define	BGE_NIC_CFG_PHY_TYPE_FIBER		0x000020
1963 #define	BGE_NIC_CFG_PHY_TYPE_MASK		0x000030
1964 
1965 #define	BGE_NIC_CFG_ENABLE_WOL			0x000040
1966 #define	BGE_NIC_CFG_ENABLE_ASF			0x000080
1967 #define	BGE_NIC_CFG_EEPROM_WP			0x000100
1968 #define	BGE_NIC_CFG_POWER_SAVING		0x000200
1969 #define	BGE_NIC_CFG_SWAP_PORT			0x000800
1970 #define	BGE_NIC_CFG_MINI_PCI			0x001000
1971 #define	BGE_NIC_CFG_FIBER_WOL_CAPABLE		0x004000
1972 #define	BGE_NIC_CFG_5753_12x12			0x100000
1973 
1974 
1975 #define	BGE_NIC_DATA_FIRMWARE_VERSION		0x0b5c
1976 
1977 
1978 #define	BGE_NIC_DATA_PHY_ID_ADDR		0x0b74
1979 #define	BGE_NIC_PHY_ID1_MASK			0xffff0000
1980 #define	BGE_NIC_PHY_ID2_MASK			0x0000ffff
1981 
1982 
1983 #define	BGE_CMD_MAILBOX				0x0b78
1984 #define	BGE_CMD_NICDRV_ALIVE			0x00000001
1985 #define	BGE_CMD_NICDRV_PAUSE_FW			0x00000002
1986 #define	BGE_CMD_NICDRV_IPV4ADDR_CHANGE		0x00000003
1987 #define	BGE_CMD_NICDRV_IPV6ADDR_CHANGE		0x00000004
1988 
1989 
1990 #define	BGE_CMD_LENGTH_MAILBOX			0x0b7c
1991 #define	BGE_CMD_DATA_MAILBOX			0x0b80
1992 #define	BGE_ASF_FW_STATUS_MAILBOX		0x0c00
1993 
1994 #define	BGE_DRV_STATE_MAILBOX			0x0c04
1995 #define	BGE_DRV_STATE_START			0x00000001
1996 #define	BGE_DRV_STATE_START_DONE		0x80000001
1997 #define	BGE_DRV_STATE_UNLOAD			0x00000002
1998 #define	BGE_DRV_STATE_UNLOAD_DONE		0x80000002
1999 #define	BGE_DRV_STATE_WOL			0x00000003
2000 #define	BGE_DRV_STATE_SUSPEND			0x00000004
2001 
2002 
2003 #define	BGE_FW_LAST_RESET_TYPE_MAILBOX		0x0c08
2004 #define	BGE_FW_LAST_RESET_TYPE_WARM		0x0001
2005 #define	BGE_FW_LAST_RESET_TYPE_COLD		0x0002
2006 
2007 
2008 #define	BGE_MAC_ADDR_HIGH_MAILBOX		0x0c14
2009 #define	BGE_MAC_ADDR_LOW_MAILBOX		0x0c18
2010 
2011 
2012 /*
2013  * RX-RISC event register
2014  */
2015 #define	RX_RISC_EVENT_REG			0x6810
2016 #define	RRER_ASF_EVENT				0x4000
2017 
2018 #endif /* BGE_IPMI_ASF */
2019 
2020 #ifdef __cplusplus
2021 }
2022 #endif
2023 
2024 #endif	/* _BGE_HW_H */
2025