xref: /freebsd/sys/dev/ti/if_tireg.h (revision e87631b976c21a7a44f30cc1393d216ff0c2bb9c)
1d02c2331SBill Paul /*
2d02c2331SBill Paul  * Copyright (c) 1997, 1998, 1999
3d02c2331SBill Paul  *	Bill Paul <wpaul@ctr.columbia.edu>.  All rights reserved.
4d02c2331SBill Paul  *
5d02c2331SBill Paul  * Redistribution and use in source and binary forms, with or without
6d02c2331SBill Paul  * modification, are permitted provided that the following conditions
7d02c2331SBill Paul  * are met:
8d02c2331SBill Paul  * 1. Redistributions of source code must retain the above copyright
9d02c2331SBill Paul  *    notice, this list of conditions and the following disclaimer.
10d02c2331SBill Paul  * 2. Redistributions in binary form must reproduce the above copyright
11d02c2331SBill Paul  *    notice, this list of conditions and the following disclaimer in the
12d02c2331SBill Paul  *    documentation and/or other materials provided with the distribution.
13d02c2331SBill Paul  * 3. All advertising materials mentioning features or use of this software
14d02c2331SBill Paul  *    must display the following acknowledgement:
15d02c2331SBill Paul  *	This product includes software developed by Bill Paul.
16d02c2331SBill Paul  * 4. Neither the name of the author nor the names of any co-contributors
17d02c2331SBill Paul  *    may be used to endorse or promote products derived from this software
18d02c2331SBill Paul  *    without specific prior written permission.
19d02c2331SBill Paul  *
20d02c2331SBill Paul  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21d02c2331SBill Paul  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22d02c2331SBill Paul  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23d02c2331SBill Paul  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24d02c2331SBill Paul  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25d02c2331SBill Paul  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26d02c2331SBill Paul  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27d02c2331SBill Paul  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28d02c2331SBill Paul  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29d02c2331SBill Paul  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30d02c2331SBill Paul  * THE POSSIBILITY OF SUCH DAMAGE.
31d02c2331SBill Paul  *
32c3aac50fSPeter Wemm  * $FreeBSD$
33d02c2331SBill Paul  */
34d02c2331SBill Paul 
35d02c2331SBill Paul /*
36d02c2331SBill Paul  * Tigon register offsets. These are memory mapped registers
37d02c2331SBill Paul  * which can be accessed with the CSR_READ_4()/CSR_WRITE_4() macros.
38d02c2331SBill Paul  * Each register must be accessed using 32 bit operations.
39d02c2331SBill Paul  *
40d02c2331SBill Paul  * All reegisters are accessed through a 16K shared memory block.
41d02c2331SBill Paul  * The first group of registers are actually copies of the PCI
42d02c2331SBill Paul  * configuration space registers.
43d02c2331SBill Paul  */
44d02c2331SBill Paul 
45d02c2331SBill Paul #define TI_PCI_ID			0x000 /* PCI device/vendor ID */
46d02c2331SBill Paul #define TI_PCI_CMDSTAT			0x004
47d02c2331SBill Paul #define TI_PCI_CLASSCODE		0x008
48d02c2331SBill Paul #define TI_PCI_BIST			0x00C
49d02c2331SBill Paul #define TI_PCI_LOMEM			0x010 /* Shared memory base address */
50d02c2331SBill Paul #define TI_PCI_SUBSYS			0x02C
51d02c2331SBill Paul #define TI_PCI_ROMBASE			0x030
52d02c2331SBill Paul #define TI_PCI_INT			0x03C
53d02c2331SBill Paul 
54d02c2331SBill Paul #ifndef PCIM_CMD_MWIEN
55d02c2331SBill Paul #define PCIM_CMD_MWIEN			0x0010
56d02c2331SBill Paul #endif
57d02c2331SBill Paul 
58d02c2331SBill Paul /*
59d02c2331SBill Paul  * Alteon AceNIC PCI vendor/device ID.
60d02c2331SBill Paul  */
61d02c2331SBill Paul #define ALT_VENDORID			0x12AE
62d02c2331SBill Paul #define ALT_DEVICEID_ACENIC		0x0001
63e87631b9SBill Paul #define ALT_DEVICEID_ACENIC_COPPER	0x0002
64d02c2331SBill Paul 
65d02c2331SBill Paul /*
66d02c2331SBill Paul  * 3Com 3c985 PCI vendor/device ID.
67d02c2331SBill Paul  */
68d02c2331SBill Paul #define TC_VENDORID			0x10B7
69d02c2331SBill Paul #define TC_DEVICEID_3C985		0x0001
70d02c2331SBill Paul 
71d02c2331SBill Paul /*
72d02c2331SBill Paul  * Netgear GA620 PCI vendor/device ID.
73d02c2331SBill Paul  */
74d02c2331SBill Paul #define NG_VENDORID			0x1385
75d02c2331SBill Paul #define NG_DEVICEID_GA620		0x620A
76d02c2331SBill Paul 
77d02c2331SBill Paul /*
78d02c2331SBill Paul  * SGI device/vendor ID.
79d02c2331SBill Paul  */
80d02c2331SBill Paul #define SGI_VENDORID			0x10A9
81d02c2331SBill Paul #define SGI_DEVICEID_TIGON		0x0009
82d02c2331SBill Paul 
83d02c2331SBill Paul /*
84b822a5eaSBill Paul  * DEC vendor ID, Farallon device ID. Apparently, Farallon used
85b822a5eaSBill Paul  * the DEC vendor ID in their cards by mistake.
86b822a5eaSBill Paul  */
87b822a5eaSBill Paul #define DEC_VENDORID			0x1011
88b822a5eaSBill Paul #define DEC_DEVICEID_FARALLON_PN9000SX	0x001a
89b822a5eaSBill Paul 
90b822a5eaSBill Paul /*
91d02c2331SBill Paul  * Tigon configuration and control registers.
92d02c2331SBill Paul  */
93d02c2331SBill Paul #define TI_MISC_HOST_CTL		0x040
94d02c2331SBill Paul #define TI_MISC_LOCAL_CTL		0x044
95d02c2331SBill Paul #define TI_SEM_AB			0x048 /* Tigon 2 only */
96d02c2331SBill Paul #define TI_MISC_CONF			0x050 /* Tigon 2 only */
97d02c2331SBill Paul #define TI_TIMER_BITS			0x054
98d02c2331SBill Paul #define TI_TIMERREF			0x058
99d02c2331SBill Paul #define TI_PCI_STATE			0x05C
100d02c2331SBill Paul #define TI_MAIN_EVENT_A			0x060
101d02c2331SBill Paul #define TI_MAILBOX_EVENT_A		0x064
102d02c2331SBill Paul #define TI_WINBASE			0x068
103d02c2331SBill Paul #define TI_WINDATA			0x06C
104d02c2331SBill Paul #define TI_MAIN_EVENT_B			0x070 /* Tigon 2 only */
105d02c2331SBill Paul #define TI_MAILBOX_EVENT_B		0x074 /* Tigon 2 only */
106d02c2331SBill Paul #define TI_TIMERREF_B			0x078 /* Tigon 2 only */
107d02c2331SBill Paul #define TI_SERIAL			0x07C
108d02c2331SBill Paul 
109d02c2331SBill Paul /*
110d02c2331SBill Paul  * Misc host control bits.
111d02c2331SBill Paul  */
112d02c2331SBill Paul #define TI_MHC_INTSTATE			0x00000001
113d02c2331SBill Paul #define TI_MHC_CLEARINT			0x00000002
114d02c2331SBill Paul #define TI_MHC_RESET			0x00000008
115d02c2331SBill Paul #define TI_MHC_BYTE_SWAP_ENB		0x00000010
116d02c2331SBill Paul #define TI_MHC_WORD_SWAP_ENB		0x00000020
117d02c2331SBill Paul #define TI_MHC_MASK_INTS		0x00000040
118d02c2331SBill Paul #define TI_MHC_CHIP_REV_MASK		0xF0000000
119d02c2331SBill Paul 
120d02c2331SBill Paul #define TI_MHC_BIGENDIAN_INIT	\
121d02c2331SBill Paul 	(TI_MHC_BYTE_SWAP_ENB|TI_MHC_WORD_SWAP_ENB|TI_MHC_CLEARINT)
122d02c2331SBill Paul 
123d02c2331SBill Paul #define TI_MHC_LITTLEENDIAN_INIT	\
124d02c2331SBill Paul 	(TI_MHC_WORD_SWAP_ENB|TI_MHC_CLEARINT)
125d02c2331SBill Paul 
126d02c2331SBill Paul /*
127d02c2331SBill Paul  * Tigon chip rev values. Rev 4 is the Tigon 1. Rev 6 is the Tigon 2.
128d02c2331SBill Paul  * Rev 5 is also the Tigon 2, but is a broken version which was never
129d02c2331SBill Paul  * used in any actual hardware, so we ignore it.
130d02c2331SBill Paul  */
131d02c2331SBill Paul #define TI_REV_TIGON_I			0x40000000
132d02c2331SBill Paul #define TI_REV_TIGON_II			0x60000000
133d02c2331SBill Paul 
134d02c2331SBill Paul /*
135d02c2331SBill Paul  * Firmware revision that we want.
136d02c2331SBill Paul  */
137d02c2331SBill Paul #define TI_FIRMWARE_MAJOR		0xc
138e87631b9SBill Paul #define TI_FIRMWARE_MINOR		0x4
139e87631b9SBill Paul #define TI_FIRMWARE_FIX			0xd
140d02c2331SBill Paul 
141d02c2331SBill Paul /*
142d02c2331SBill Paul  * Miscelaneous Local Control register.
143d02c2331SBill Paul  */
144d02c2331SBill Paul #define TI_MLC_EE_WRITE_ENB		0x00000010
145d02c2331SBill Paul #define TI_MLC_SRAM_BANK_256K		0x00000200
146d02c2331SBill Paul #define TI_MLC_SRAM_BANK_SIZE		0x00000300 /* Tigon 2 only */
147d02c2331SBill Paul #define TI_MLC_LOCALADDR_21		0x00004000
148d02c2331SBill Paul #define TI_MLC_LOCALADDR_22		0x00008000
149d02c2331SBill Paul #define TI_MLC_SBUS_WRITEERR		0x00080000
150d02c2331SBill Paul #define TI_MLC_EE_CLK			0x00100000
151d02c2331SBill Paul #define TI_MLC_EE_TXEN			0x00200000
152d02c2331SBill Paul #define TI_MLC_EE_DOUT			0x00400000
153d02c2331SBill Paul #define TI_MLC_EE_DIN			0x00800000
154d02c2331SBill Paul 
155d02c2331SBill Paul /*
156d02c2331SBill Paul  * Offset of MAC address inside EEPROM.
157d02c2331SBill Paul  */
158d02c2331SBill Paul #define TI_EE_MAC_OFFSET		0x8c
159d02c2331SBill Paul 
160d02c2331SBill Paul #define TI_DMA_ASSIST			0x11C
161d02c2331SBill Paul #define TI_CPU_STATE			0x140
162d02c2331SBill Paul #define TI_CPU_PROGRAM_COUNTER		0x144
163d02c2331SBill Paul #define TI_SRAM_ADDR			0x154
164d02c2331SBill Paul #define TI_SRAM_DATA			0x158
165d02c2331SBill Paul #define TI_GEN_0			0x180
166d02c2331SBill Paul #define TI_GEN_X			0x1FC
167d02c2331SBill Paul #define TI_MAC_TX_STATE			0x200
168d02c2331SBill Paul #define TI_MAC_RX_STATE			0x220
169d02c2331SBill Paul #define TI_CPU_CTL_B			0x240 /* Tigon 2 only */
170d02c2331SBill Paul #define TI_CPU_PROGRAM_COUNTER_B	0x244 /* Tigon 2 only */
171d02c2331SBill Paul #define TI_SRAM_ADDR_B			0x254 /* Tigon 2 only */
172d02c2331SBill Paul #define TI_SRAM_DATA_B			0x258 /* Tigon 2 only */
173d02c2331SBill Paul #define TI_GEN_B_0			0x280 /* Tigon 2 only */
174d02c2331SBill Paul #define TI_GEN_B_X			0x2FC /* Tigon 2 only */
175d02c2331SBill Paul 
176d02c2331SBill Paul /*
177d02c2331SBill Paul  * Misc config register.
178d02c2331SBill Paul  */
179d02c2331SBill Paul #define TI_MCR_SRAM_SYNCHRONOUS		0x00100000 /* Tigon 2 only */
180d02c2331SBill Paul 
181d02c2331SBill Paul /*
182d02c2331SBill Paul  * PCI state register.
183d02c2331SBill Paul  */
184d02c2331SBill Paul #define TI_PCISTATE_FORCE_RESET		0x00000001
185d02c2331SBill Paul #define TI_PCISTATE_PROVIDE_LEN		0x00000002
186d02c2331SBill Paul #define TI_PCISTATE_READ_MAXDMA		0x0000001C
187d02c2331SBill Paul #define TI_PCISTATE_WRITE_MAXDMA	0x000000E0
188d02c2331SBill Paul #define TI_PCISTATE_MINDMA		0x0000FF00
189d02c2331SBill Paul #define TI_PCISTATE_FIFO_RETRY_ENB	0x00010000
190d02c2331SBill Paul #define TI_PCISTATE_USE_MEM_RD_MULT	0x00020000
191d02c2331SBill Paul #define TI_PCISTATE_NO_SWAP_READ_DMA	0x00040000
192d02c2331SBill Paul #define TI_PCISTATE_NO_SWAP_WRITE_DMA	0x00080000
193d02c2331SBill Paul #define TI_PCISTATE_66MHZ_BUS		0x00080000 /* Tigon 2 only */
194d02c2331SBill Paul #define TI_PCISTATE_32BIT_BUS		0x00100000 /* Tigon 2 only */
195d02c2331SBill Paul #define TI_PCISTATE_ENB_BYTE_ENABLES	0x00800000 /* Tigon 2 only */
196d02c2331SBill Paul #define TI_PCISTATE_READ_CMD		0x0F000000
197d02c2331SBill Paul #define TI_PCISTATE_WRITE_CMD		0xF0000000
198d02c2331SBill Paul 
199d02c2331SBill Paul #define TI_PCI_READMAX_4		0x04
200d02c2331SBill Paul #define TI_PCI_READMAX_16		0x08
201d02c2331SBill Paul #define TI_PCI_READMAX_32		0x0C
202d02c2331SBill Paul #define TI_PCI_READMAX_64		0x10
203d02c2331SBill Paul #define TI_PCI_READMAX_128		0x14
204d02c2331SBill Paul #define TI_PCI_READMAX_256		0x18
205d02c2331SBill Paul #define TI_PCI_READMAX_1024		0x1C
206d02c2331SBill Paul 
207d02c2331SBill Paul #define TI_PCI_WRITEMAX_4		0x20
208d02c2331SBill Paul #define TI_PCI_WRITEMAX_16		0x40
209d02c2331SBill Paul #define TI_PCI_WRITEMAX_32		0x60
210d02c2331SBill Paul #define TI_PCI_WRITEMAX_64		0x80
211d02c2331SBill Paul #define TI_PCI_WRITEMAX_128		0xA0
212d02c2331SBill Paul #define TI_PCI_WRITEMAX_256		0xC0
213d02c2331SBill Paul #define TI_PCI_WRITEMAX_1024		0xE0
214d02c2331SBill Paul 
215d02c2331SBill Paul #define TI_PCI_READ_CMD			0x06000000
216d02c2331SBill Paul #define TI_PCI_WRITE_CMD		0x70000000
217d02c2331SBill Paul 
218d02c2331SBill Paul /*
219d02c2331SBill Paul  * DMA state register.
220d02c2331SBill Paul  */
221d02c2331SBill Paul #define TI_DMASTATE_ENABLE		0x00000001
222d02c2331SBill Paul #define TI_DMASTATE_PAUSE		0x00000002
223d02c2331SBill Paul 
224d02c2331SBill Paul /*
225d02c2331SBill Paul  * CPU state register.
226d02c2331SBill Paul  */
227d02c2331SBill Paul #define TI_CPUSTATE_RESET		0x00000001
228d02c2331SBill Paul #define TI_CPUSTATE_STEP		0x00000002
229d02c2331SBill Paul #define TI_CPUSTATE_ROMFAIL		0x00000010
230d02c2331SBill Paul #define TI_CPUSTATE_HALT		0x00010000
231d02c2331SBill Paul /*
232d02c2331SBill Paul  * MAC TX state register
233d02c2331SBill Paul  */
234d02c2331SBill Paul #define TI_TXSTATE_RESET		0x00000001
235d02c2331SBill Paul #define TI_TXSTATE_ENB			0x00000002
236d02c2331SBill Paul #define TI_TXSTATE_STOP			0x00000004
237d02c2331SBill Paul 
238d02c2331SBill Paul /*
239d02c2331SBill Paul  * MAC RX state register
240d02c2331SBill Paul  */
241d02c2331SBill Paul #define TI_RXSTATE_RESET		0x00000001
242d02c2331SBill Paul #define TI_RXSTATE_ENB			0x00000002
243d02c2331SBill Paul #define TI_RXSTATE_STOP			0x00000004
244d02c2331SBill Paul 
245d02c2331SBill Paul /*
246d02c2331SBill Paul  * Tigon 2 mailbox registers. The mailbox area consists of 256 bytes
247d02c2331SBill Paul  * split into 64 bit registers. Only the lower 32 bits of each mailbox
248d02c2331SBill Paul  * are used.
249d02c2331SBill Paul  */
250d02c2331SBill Paul #define TI_MB_HOSTINTR_HI		0x500
251d02c2331SBill Paul #define TI_MB_HOSTINTR_LO		0x504
252d02c2331SBill Paul #define TI_MB_HOSTINTR			TI_MB_HOSTINTR_LO
253d02c2331SBill Paul #define TI_MB_CMDPROD_IDX_HI		0x508
254d02c2331SBill Paul #define TI_MB_CMDPROD_IDX_LO		0x50C
255d02c2331SBill Paul #define TI_MB_CMDPROD_IDX		TI_MB_CMDPROD_IDX_LO
256d02c2331SBill Paul #define TI_MB_SENDPROD_IDX_HI		0x510
257d02c2331SBill Paul #define TI_MB_SENDPROD_IDX_LO		0x514
258d02c2331SBill Paul #define TI_MB_SENDPROD_IDX		TI_MB_SENDPROD_IDX_LO
259d02c2331SBill Paul #define TI_MB_STDRXPROD_IDX_HI		0x518 /* Tigon 2 only */
260d02c2331SBill Paul #define TI_MB_STDRXPROD_IDX_LO		0x51C /* Tigon 2 only */
261d02c2331SBill Paul #define TI_MB_STDRXPROD_IDX		TI_MB_STDRXPROD_IDX_LO
262d02c2331SBill Paul #define TI_MB_JUMBORXPROD_IDX_HI	0x520 /* Tigon 2 only */
263d02c2331SBill Paul #define TI_MB_JUMBORXPROD_IDX_LO	0x524 /* Tigon 2 only */
264d02c2331SBill Paul #define TI_MB_JUMBORXPROD_IDX		TI_MB_JUMBORXPROD_IDX_LO
265d02c2331SBill Paul #define TI_MB_MINIRXPROD_IDX_HI		0x528 /* Tigon 2 only */
266d02c2331SBill Paul #define TI_MB_MINIRXPROD_IDX_LO		0x52C /* Tigon 2 only */
267d02c2331SBill Paul #define TI_MB_MINIRXPROD_IDX		TI_MB_MINIRXPROD_IDX_LO
268d02c2331SBill Paul #define TI_MB_RSVD			0x530
269d02c2331SBill Paul 
270d02c2331SBill Paul /*
271d02c2331SBill Paul  * Tigon 2 general communication registers. These are 64 and 32 bit
272d02c2331SBill Paul  * registers which are only valid after the firmware has been
273d02c2331SBill Paul  * loaded and started. They actually exist in NIC memory but are
274d02c2331SBill Paul  * mapped into the host memory via the shared memory region.
275d02c2331SBill Paul  *
276d02c2331SBill Paul  * The NIC internally maps these registers starting at address 0,
277d02c2331SBill Paul  * so to determine the NIC address of any of these registers, we
278d02c2331SBill Paul  * subtract 0x600 (the address of the first register).
279d02c2331SBill Paul  */
280d02c2331SBill Paul 
281d02c2331SBill Paul #define TI_GCR_BASE			0x600
282d02c2331SBill Paul #define TI_GCR_MACADDR			0x600
283d02c2331SBill Paul #define TI_GCR_PAR0			0x600
284d02c2331SBill Paul #define TI_GCR_PAR1			0x604
285d02c2331SBill Paul #define TI_GCR_GENINFO_HI		0x608
286d02c2331SBill Paul #define TI_GCR_GENINFO_LO		0x60C
287d02c2331SBill Paul #define TI_GCR_MCASTADDR		0x610 /* obsolete */
288d02c2331SBill Paul #define TI_GCR_MAR0			0x610 /* obsolete */
289d02c2331SBill Paul #define TI_GCR_MAR1			0x614 /* obsolete */
290d02c2331SBill Paul #define TI_GCR_OPMODE			0x618
291d02c2331SBill Paul #define TI_GCR_DMA_READCFG		0x61C
292d02c2331SBill Paul #define TI_GCR_DMA_WRITECFG		0x620
293d02c2331SBill Paul #define TI_GCR_TX_BUFFER_RATIO		0x624
294d02c2331SBill Paul #define TI_GCR_EVENTCONS_IDX		0x628
295d02c2331SBill Paul #define TI_GCR_CMDCONS_IDX		0x62C
296d02c2331SBill Paul #define TI_GCR_TUNEPARMS		0x630
297d02c2331SBill Paul #define TI_GCR_RX_COAL_TICKS		0x630
298d02c2331SBill Paul #define TI_GCR_TX_COAL_TICKS		0x634
299d02c2331SBill Paul #define TI_GCR_STAT_TICKS		0x638
300d02c2331SBill Paul #define TI_GCR_TX_MAX_COAL_BD		0x63C
301d02c2331SBill Paul #define TI_GCR_RX_MAX_COAL_BD		0x640
302d02c2331SBill Paul #define TI_GCR_NIC_TRACING		0x644
303d02c2331SBill Paul #define TI_GCR_GLINK			0x648
304d02c2331SBill Paul #define TI_GCR_LINK			0x64C
305d02c2331SBill Paul #define TI_GCR_NICTRACE_PTR		0x650
306d02c2331SBill Paul #define TI_GCR_NICTRACE_START		0x654
307d02c2331SBill Paul #define TI_GCR_NICTRACE_LEN		0x658
308d02c2331SBill Paul #define TI_GCR_IFINDEX			0x65C
309d02c2331SBill Paul #define TI_GCR_IFMTU			0x660
310d02c2331SBill Paul #define TI_GCR_MASK_INTRS		0x664
311d02c2331SBill Paul #define TI_GCR_GLINK_STAT		0x668
312d02c2331SBill Paul #define TI_GCR_LINK_STAT		0x66C
313d02c2331SBill Paul #define TI_GCR_RXRETURNCONS_IDX		0x680
314d02c2331SBill Paul #define TI_GCR_CMDRING			0x700
315d02c2331SBill Paul 
316d02c2331SBill Paul #define TI_GCR_NIC_ADDR(x)		(x - TI_GCR_BASE);
317d02c2331SBill Paul 
318d02c2331SBill Paul /*
319d02c2331SBill Paul  * Local memory window. The local memory window is a 2K shared
320d02c2331SBill Paul  * memory region which can be used to access the NIC's internal
321d02c2331SBill Paul  * SRAM. The window can be mapped to a given 2K region using
322d02c2331SBill Paul  * the TI_WINDOW_BASE register.
323d02c2331SBill Paul  */
324d02c2331SBill Paul #define TI_WINDOW			0x800
325d02c2331SBill Paul #define TI_WINLEN			0x800
326d02c2331SBill Paul 
327d02c2331SBill Paul #define TI_TICKS_PER_SEC		1000000
328d02c2331SBill Paul 
329d02c2331SBill Paul /*
330d02c2331SBill Paul  * Operation mode register.
331d02c2331SBill Paul  */
332d02c2331SBill Paul #define TI_OPMODE_BYTESWAP_BD		0x00000002
333d02c2331SBill Paul #define TI_OPMODE_WORDSWAP_BD		0x00000004
334d02c2331SBill Paul #define TI_OPMODE_WARN_ENB		0x00000008 /* not yet implimented */
335d02c2331SBill Paul #define TI_OPMODE_BYTESWAP_DATA		0x00000010
336d02c2331SBill Paul #define TI_OPMODE_1_DMA_ACTIVE		0x00000040
337d02c2331SBill Paul #define TI_OPMODE_SBUS			0x00000100
338d02c2331SBill Paul #define TI_OPMODE_DONT_FRAG_JUMBO	0x00000200
339d02c2331SBill Paul #define TI_OPMODE_INCLUDE_CRC		0x00000400
340d02c2331SBill Paul #define TI_OPMODE_RX_BADFRAMES		0x00000800
341d02c2331SBill Paul #define TI_OPMODE_NO_EVENT_INTRS	0x00001000
342d02c2331SBill Paul #define TI_OPMODE_NO_TX_INTRS		0x00002000
343d02c2331SBill Paul #define TI_OPMODE_NO_RX_INTRS		0x00004000
344d02c2331SBill Paul #define TI_OPMODE_FATAL_ENB		0x40000000 /* not yet implimented */
345d02c2331SBill Paul 
346d02c2331SBill Paul /*
347d02c2331SBill Paul  * DMA configuration thresholds.
348d02c2331SBill Paul  */
349d02c2331SBill Paul #define TI_DMA_STATE_THRESH_16W		0x00000100
350d02c2331SBill Paul #define TI_DMA_STATE_THRESH_8W		0x00000080
351d02c2331SBill Paul #define TI_DMA_STATE_THRESH_4W		0x00000040
352d02c2331SBill Paul #define TI_DMA_STATE_THRESH_2W		0x00000020
353d02c2331SBill Paul #define TI_DMA_STATE_THRESH_1W		0x00000010
354d02c2331SBill Paul 
355d02c2331SBill Paul #define TI_DMA_STATE_FORCE_32_BIT	0x00000008
356d02c2331SBill Paul 
357d02c2331SBill Paul /*
358d02c2331SBill Paul  * Gigabit link status bits.
359d02c2331SBill Paul  */
360d02c2331SBill Paul #define TI_GLNK_SENSE_NO_BEG		0x00002000
361d02c2331SBill Paul #define TI_GLNK_LOOPBACK		0x00004000
362d02c2331SBill Paul #define TI_GLNK_PREF			0x00008000
363d02c2331SBill Paul #define TI_GLNK_1000MB			0x00040000
364d02c2331SBill Paul #define TI_GLNK_FULL_DUPLEX		0x00080000
365d02c2331SBill Paul #define TI_GLNK_TX_FLOWCTL_Y		0x00200000 /* Tigon 2 only */
366d02c2331SBill Paul #define TI_GLNK_RX_FLOWCTL_Y		0x00800000
367d02c2331SBill Paul #define TI_GLNK_AUTONEGENB		0x20000000
368d02c2331SBill Paul #define TI_GLNK_ENB			0x40000000
369d02c2331SBill Paul 
370d02c2331SBill Paul /*
371d02c2331SBill Paul  * Link status bits.
372d02c2331SBill Paul  */
373d02c2331SBill Paul #define TI_LNK_LOOPBACK			0x00004000
374d02c2331SBill Paul #define TI_LNK_PREF			0x00008000
375d02c2331SBill Paul #define TI_LNK_10MB			0x00010000
376d02c2331SBill Paul #define TI_LNK_100MB			0x00020000
377d02c2331SBill Paul #define TI_LNK_1000MB			0x00040000
378d02c2331SBill Paul #define TI_LNK_FULL_DUPLEX		0x00080000
379d02c2331SBill Paul #define TI_LNK_HALF_DUPLEX		0x00100000
380d02c2331SBill Paul #define TI_LNK_TX_FLOWCTL_Y		0x00200000 /* Tigon 2 only */
381d02c2331SBill Paul #define TI_LNK_RX_FLOWCTL_Y		0x00800000
382d02c2331SBill Paul #define TI_LNK_AUTONEGENB		0x20000000
383d02c2331SBill Paul #define TI_LNK_ENB			0x40000000
384d02c2331SBill Paul 
385d02c2331SBill Paul /*
386d02c2331SBill Paul  * Ring size constants.
387d02c2331SBill Paul  */
388d02c2331SBill Paul #define TI_EVENT_RING_CNT	256
389d02c2331SBill Paul #define TI_CMD_RING_CNT		64
390d02c2331SBill Paul #define TI_STD_RX_RING_CNT	512
391d02c2331SBill Paul #define TI_JUMBO_RX_RING_CNT	256
392d02c2331SBill Paul #define TI_MINI_RX_RING_CNT	1024
393d02c2331SBill Paul #define TI_RETURN_RING_CNT	2048
394d02c2331SBill Paul 
395d02c2331SBill Paul /*
396d02c2331SBill Paul  * Possible TX ring sizes.
397d02c2331SBill Paul  */
398d02c2331SBill Paul #define TI_TX_RING_CNT_128	128
399d02c2331SBill Paul #define TI_TX_RING_BASE_128	0x3800
400d02c2331SBill Paul 
401d02c2331SBill Paul #define TI_TX_RING_CNT_256	256
402d02c2331SBill Paul #define TI_TX_RING_BASE_256	0x3000
403d02c2331SBill Paul 
404d02c2331SBill Paul #define TI_TX_RING_CNT_512	512
405d02c2331SBill Paul #define TI_TX_RING_BASE_512	0x2000
406d02c2331SBill Paul 
407d02c2331SBill Paul #define TI_TX_RING_CNT		TI_TX_RING_CNT_512
408d02c2331SBill Paul #define TI_TX_RING_BASE		TI_TX_RING_BASE_512
409d02c2331SBill Paul 
410d02c2331SBill Paul /*
411d02c2331SBill Paul  * The Tigon can have up to 8MB of external SRAM, however the Tigon 1
412d02c2331SBill Paul  * is limited to 2MB total, and in general I think most adapters have
413d02c2331SBill Paul  * around 1MB. We use this value for zeroing the NIC's SRAM, so to
414d02c2331SBill Paul  * be safe we use the largest possible value (zeroing memory that
415d02c2331SBill Paul  * isn't there doesn't hurt anything).
416d02c2331SBill Paul  */
417d02c2331SBill Paul #define TI_MEM_MAX		0x7FFFFF
418d02c2331SBill Paul 
419d02c2331SBill Paul /*
420d02c2331SBill Paul  * Even on the alpha, pci addresses are 32-bit quantities
421d02c2331SBill Paul  */
422d02c2331SBill Paul 
423d02c2331SBill Paul #ifdef __64_bit_pci_addressing__
424d02c2331SBill Paul typedef struct {
425d02c2331SBill Paul 	u_int64_t		ti_addr;
426d02c2331SBill Paul } ti_hostaddr;
427d02c2331SBill Paul #define TI_HOSTADDR(x)	x.ti_addr
428d02c2331SBill Paul #else
429d02c2331SBill Paul typedef struct {
430d02c2331SBill Paul 	u_int32_t		ti_addr_hi;
431d02c2331SBill Paul 	u_int32_t		ti_addr_lo;
432d02c2331SBill Paul } ti_hostaddr;
433d02c2331SBill Paul #define TI_HOSTADDR(x)	x.ti_addr_lo
434d02c2331SBill Paul #endif
435d02c2331SBill Paul 
436d02c2331SBill Paul /*
437d02c2331SBill Paul  * Ring control block structure. The rules for the max_len field
438d02c2331SBill Paul  * are as follows:
439d02c2331SBill Paul  *
440d02c2331SBill Paul  * For the send ring, max_len indicates the number of entries in the
441d02c2331SBill Paul  * ring (128, 256 or 512).
442d02c2331SBill Paul  *
443d02c2331SBill Paul  * For the standard receive ring, max_len indicates the threshold
444d02c2331SBill Paul  * used to decide when a frame should be put in the jumbo receive ring
445d02c2331SBill Paul  * instead of the standard one.
446d02c2331SBill Paul  *
447d02c2331SBill Paul  * For the mini ring, max_len indicates the size of the buffers in the
448d02c2331SBill Paul  * ring. This is the value used to decide when a frame is small enough
449d02c2331SBill Paul  * to be placed in the mini ring.
450d02c2331SBill Paul  *
451d02c2331SBill Paul  * For the return receive ring, max_len indicates the number of entries
452d02c2331SBill Paul  * in the ring. It can be one of 2048, 1024 or 0 (which is the same as
453d02c2331SBill Paul  * 2048 for backwards compatibility). The value 1024 can only be used
454d02c2331SBill Paul  * if the mini ring is disabled.
455d02c2331SBill Paul  */
456d02c2331SBill Paul struct ti_rcb {
457d02c2331SBill Paul 	ti_hostaddr		ti_hostaddr;
458d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
459d02c2331SBill Paul 	u_int16_t		ti_max_len;
460d02c2331SBill Paul 	u_int16_t		ti_flags;
461d02c2331SBill Paul #else
462d02c2331SBill Paul 	u_int16_t		ti_flags;
463d02c2331SBill Paul 	u_int16_t		ti_max_len;
464d02c2331SBill Paul #endif
465d02c2331SBill Paul 	u_int32_t		ti_unused;
466d02c2331SBill Paul };
467d02c2331SBill Paul 
468d02c2331SBill Paul #define TI_RCB_FLAG_TCP_UDP_CKSUM	0x00000001
469d02c2331SBill Paul #define TI_RCB_FLAG_IP_CKSUM		0x00000002
470d02c2331SBill Paul #define TI_RCB_FLAG_NO_PHDR_CKSUM	0x00000008
471d02c2331SBill Paul #define TI_RCB_FLAG_VLAN_ASSIST		0x00000010
472d02c2331SBill Paul #define TI_RCB_FLAG_COAL_UPD_ONLY	0x00000020
473d02c2331SBill Paul #define TI_RCB_FLAG_HOST_RING		0x00000040
474d02c2331SBill Paul #define TI_RCB_FLAG_IEEE_SNAP_CKSUM	0x00000080
475d02c2331SBill Paul #define TI_RCB_FLAG_USE_EXT_RX_BD	0x00000100
476d02c2331SBill Paul #define TI_RCB_FLAG_RING_DISABLED	0x00000200
477d02c2331SBill Paul 
478d02c2331SBill Paul struct ti_producer {
479d02c2331SBill Paul 	u_int32_t		ti_idx;
480d02c2331SBill Paul 	u_int32_t		ti_unused;
481d02c2331SBill Paul };
482d02c2331SBill Paul 
483d02c2331SBill Paul /*
484d02c2331SBill Paul  * Tigon statistics counters.
485d02c2331SBill Paul  */
486d02c2331SBill Paul struct ti_stats {
487d02c2331SBill Paul 	/*
488d02c2331SBill Paul 	 * MAC stats, taken from RFC 1643, ethernet-like MIB
489d02c2331SBill Paul 	 */
490d02c2331SBill Paul 	volatile u_int32_t dot3StatsAlignmentErrors;		/* 0 */
491d02c2331SBill Paul 	volatile u_int32_t dot3StatsFCSErrors;			/* 1 */
492d02c2331SBill Paul 	volatile u_int32_t dot3StatsSingleCollisionFrames;	/* 2 */
493d02c2331SBill Paul 	volatile u_int32_t dot3StatsMultipleCollisionFrames;	/* 3 */
494d02c2331SBill Paul 	volatile u_int32_t dot3StatsSQETestErrors;		/* 4 */
495d02c2331SBill Paul 	volatile u_int32_t dot3StatsDeferredTransmissions;	/* 5 */
496d02c2331SBill Paul 	volatile u_int32_t dot3StatsLateCollisions;		/* 6 */
497d02c2331SBill Paul 	volatile u_int32_t dot3StatsExcessiveCollisions;	/* 7 */
498d02c2331SBill Paul 	volatile u_int32_t dot3StatsInternalMacTransmitErrors;	/* 8 */
499d02c2331SBill Paul 	volatile u_int32_t dot3StatsCarrierSenseErrors;		/* 9 */
500d02c2331SBill Paul 	volatile u_int32_t dot3StatsFrameTooLongs;		/* 10 */
501d02c2331SBill Paul 	volatile u_int32_t dot3StatsInternalMacReceiveErrors;	/* 11 */
502d02c2331SBill Paul 	/*
503d02c2331SBill Paul 	 * interface stats, taken from RFC 1213, MIB-II, interfaces group
504d02c2331SBill Paul 	 */
505d02c2331SBill Paul 	volatile u_int32_t ifIndex;				/* 12 */
506d02c2331SBill Paul 	volatile u_int32_t ifType;				/* 13 */
507d02c2331SBill Paul 	volatile u_int32_t ifMtu;				/* 14 */
508d02c2331SBill Paul 	volatile u_int32_t ifSpeed;				/* 15 */
509d02c2331SBill Paul 	volatile u_int32_t ifAdminStatus;			/* 16 */
510d02c2331SBill Paul #define IF_ADMIN_STATUS_UP      1
511d02c2331SBill Paul #define IF_ADMIN_STATUS_DOWN    2
512d02c2331SBill Paul #define IF_ADMIN_STATUS_TESTING 3
513d02c2331SBill Paul 	volatile u_int32_t ifOperStatus;			/* 17 */
514d02c2331SBill Paul #define IF_OPER_STATUS_UP       1
515d02c2331SBill Paul #define IF_OPER_STATUS_DOWN     2
516d02c2331SBill Paul #define IF_OPER_STATUS_TESTING  3
517d02c2331SBill Paul #define IF_OPER_STATUS_UNKNOWN  4
518d02c2331SBill Paul #define IF_OPER_STATUS_DORMANT  5
519d02c2331SBill Paul 	volatile u_int32_t ifLastChange;			/* 18 */
520d02c2331SBill Paul 	volatile u_int32_t ifInDiscards;			/* 19 */
521d02c2331SBill Paul 	volatile u_int32_t ifInErrors;				/* 20 */
522d02c2331SBill Paul 	volatile u_int32_t ifInUnknownProtos;			/* 21 */
523d02c2331SBill Paul 	volatile u_int32_t ifOutDiscards;			/* 22 */
524d02c2331SBill Paul 	volatile u_int32_t ifOutErrors;				/* 23 */
525d02c2331SBill Paul 	volatile u_int32_t ifOutQLen;     /* deprecated */	/* 24 */
526d02c2331SBill Paul 	volatile u_int8_t  ifPhysAddress[8]; /* 8 bytes */	/* 25 - 26 */
527d02c2331SBill Paul 	volatile u_int8_t  ifDescr[32];				/* 27 - 34 */
528d02c2331SBill Paul 	u_int32_t alignIt;      /* align to 64 bit for u_int64_ts following */
529d02c2331SBill Paul 	/*
530d02c2331SBill Paul 	 * more interface stats, taken from RFC 1573, MIB-IIupdate,
531d02c2331SBill Paul 	 * interfaces group
532d02c2331SBill Paul 	 */
533d02c2331SBill Paul 	volatile u_int64_t ifHCInOctets;			/* 36 - 37 */
534d02c2331SBill Paul 	volatile u_int64_t ifHCInUcastPkts;			/* 38 - 39 */
535d02c2331SBill Paul 	volatile u_int64_t ifHCInMulticastPkts;			/* 40 - 41 */
536d02c2331SBill Paul 	volatile u_int64_t ifHCInBroadcastPkts;			/* 42 - 43 */
537d02c2331SBill Paul 	volatile u_int64_t ifHCOutOctets;			/* 44 - 45 */
538d02c2331SBill Paul 	volatile u_int64_t ifHCOutUcastPkts;			/* 46 - 47 */
539d02c2331SBill Paul 	volatile u_int64_t ifHCOutMulticastPkts;		/* 48 - 49 */
540d02c2331SBill Paul 	volatile u_int64_t ifHCOutBroadcastPkts;		/* 50 - 51 */
541d02c2331SBill Paul 	volatile u_int32_t ifLinkUpDownTrapEnable;		/* 52 */
542d02c2331SBill Paul 	volatile u_int32_t ifHighSpeed;				/* 53 */
543d02c2331SBill Paul 	volatile u_int32_t ifPromiscuousMode; 			/* 54 */
544d02c2331SBill Paul 	volatile u_int32_t ifConnectorPresent; /* follow link state 55 */
545d02c2331SBill Paul 	/*
546d02c2331SBill Paul 	 * Host Commands
547d02c2331SBill Paul 	 */
548d02c2331SBill Paul 	volatile u_int32_t nicCmdsHostState;			/* 56 */
549d02c2331SBill Paul 	volatile u_int32_t nicCmdsFDRFiltering;			/* 57 */
550d02c2331SBill Paul 	volatile u_int32_t nicCmdsSetRecvProdIndex;		/* 58 */
551d02c2331SBill Paul 	volatile u_int32_t nicCmdsUpdateGencommStats;		/* 59 */
552d02c2331SBill Paul 	volatile u_int32_t nicCmdsResetJumboRing;		/* 60 */
553d02c2331SBill Paul 	volatile u_int32_t nicCmdsAddMCastAddr;			/* 61 */
554d02c2331SBill Paul 	volatile u_int32_t nicCmdsDelMCastAddr;			/* 62 */
555d02c2331SBill Paul 	volatile u_int32_t nicCmdsSetPromiscMode;		/* 63 */
556d02c2331SBill Paul 	volatile u_int32_t nicCmdsLinkNegotiate;		/* 64 */
557d02c2331SBill Paul 	volatile u_int32_t nicCmdsSetMACAddr;			/* 65 */
558d02c2331SBill Paul 	volatile u_int32_t nicCmdsClearProfile;			/* 66 */
559d02c2331SBill Paul 	volatile u_int32_t nicCmdsSetMulticastMode;		/* 67 */
560d02c2331SBill Paul 	volatile u_int32_t nicCmdsClearStats;			/* 68 */
561d02c2331SBill Paul 	volatile u_int32_t nicCmdsSetRecvJumboProdIndex;	/* 69 */
562d02c2331SBill Paul 	volatile u_int32_t nicCmdsSetRecvMiniProdIndex;		/* 70 */
563d02c2331SBill Paul 	volatile u_int32_t nicCmdsRefreshStats;			/* 71 */
564d02c2331SBill Paul 	volatile u_int32_t nicCmdsUnknown;			/* 72 */
565d02c2331SBill Paul 	/*
566d02c2331SBill Paul 	 * NIC Events
567d02c2331SBill Paul 	 */
568d02c2331SBill Paul 	volatile u_int32_t nicEventsNICFirmwareOperational;	/* 73 */
569d02c2331SBill Paul 	volatile u_int32_t nicEventsStatsUpdated;		/* 74 */
570d02c2331SBill Paul 	volatile u_int32_t nicEventsLinkStateChanged;		/* 75 */
571d02c2331SBill Paul 	volatile u_int32_t nicEventsError;			/* 76 */
572d02c2331SBill Paul 	volatile u_int32_t nicEventsMCastListUpdated;		/* 77 */
573d02c2331SBill Paul 	volatile u_int32_t nicEventsResetJumboRing;		/* 78 */
574d02c2331SBill Paul 	/*
575d02c2331SBill Paul 	 * Ring manipulation
576d02c2331SBill Paul 	 */
577d02c2331SBill Paul 	volatile u_int32_t nicRingSetSendProdIndex;		/* 79 */
578d02c2331SBill Paul 	volatile u_int32_t nicRingSetSendConsIndex;		/* 80 */
579d02c2331SBill Paul 	volatile u_int32_t nicRingSetRecvReturnProdIndex;	/* 81 */
580d02c2331SBill Paul 	/*
581d02c2331SBill Paul 	 * Interrupts
582d02c2331SBill Paul 	 */
583d02c2331SBill Paul 	volatile u_int32_t nicInterrupts;			/* 82 */
584d02c2331SBill Paul 	volatile u_int32_t nicAvoidedInterrupts;		/* 83 */
585d02c2331SBill Paul 	/*
586d02c2331SBill Paul 	 * BD Coalessing Thresholds
587d02c2331SBill Paul 	 */
588d02c2331SBill Paul 	volatile u_int32_t nicEventThresholdHit;		/* 84 */
589d02c2331SBill Paul 	volatile u_int32_t nicSendThresholdHit;			/* 85 */
590d02c2331SBill Paul 	volatile u_int32_t nicRecvThresholdHit;			/* 86 */
591d02c2331SBill Paul 	/*
592d02c2331SBill Paul 	 * DMA Attentions
593d02c2331SBill Paul 	 */
594d02c2331SBill Paul 	volatile u_int32_t nicDmaRdOverrun;			/* 87 */
595d02c2331SBill Paul 	volatile u_int32_t nicDmaRdUnderrun;			/* 88 */
596d02c2331SBill Paul 	volatile u_int32_t nicDmaWrOverrun;			/* 89 */
597d02c2331SBill Paul 	volatile u_int32_t nicDmaWrUnderrun;			/* 90 */
598d02c2331SBill Paul 	volatile u_int32_t nicDmaWrMasterAborts;		/* 91 */
599d02c2331SBill Paul 	volatile u_int32_t nicDmaRdMasterAborts;		/* 92 */
600d02c2331SBill Paul 	/*
601d02c2331SBill Paul 	 * NIC Resources
602d02c2331SBill Paul 	 */
603d02c2331SBill Paul 	volatile u_int32_t nicDmaWriteRingFull;			/* 93 */
604d02c2331SBill Paul 	volatile u_int32_t nicDmaReadRingFull;			/* 94 */
605d02c2331SBill Paul 	volatile u_int32_t nicEventRingFull;			/* 95 */
606d02c2331SBill Paul 	volatile u_int32_t nicEventProducerRingFull;		/* 96 */
607d02c2331SBill Paul 	volatile u_int32_t nicTxMacDescrRingFull;		/* 97 */
608d02c2331SBill Paul 	volatile u_int32_t nicOutOfTxBufSpaceFrameRetry;	/* 98 */
609d02c2331SBill Paul 	volatile u_int32_t nicNoMoreWrDMADescriptors;		/* 99 */
610d02c2331SBill Paul 	volatile u_int32_t nicNoMoreRxBDs;			/* 100 */
611d02c2331SBill Paul 	volatile u_int32_t nicNoSpaceInReturnRing;		/* 101 */
612d02c2331SBill Paul 	volatile u_int32_t nicSendBDs;            /* current count 102 */
613d02c2331SBill Paul 	volatile u_int32_t nicRecvBDs;            /* current count 103 */
614d02c2331SBill Paul 	volatile u_int32_t nicJumboRecvBDs;       /* current count 104 */
615d02c2331SBill Paul 	volatile u_int32_t nicMiniRecvBDs;        /* current count 105 */
616d02c2331SBill Paul 	volatile u_int32_t nicTotalRecvBDs;       /* current count 106 */
617d02c2331SBill Paul 	volatile u_int32_t nicTotalSendBDs;       /* current count 107 */
618d02c2331SBill Paul 	volatile u_int32_t nicJumboSpillOver;			/* 108 */
619d02c2331SBill Paul 	volatile u_int32_t nicSbusHangCleared;			/* 109 */
620d02c2331SBill Paul 	volatile u_int32_t nicEnqEventDelayed;			/* 110 */
621d02c2331SBill Paul 	/*
622d02c2331SBill Paul 	 * Stats from MAC rx completion
623d02c2331SBill Paul 	 */
624d02c2331SBill Paul 	volatile u_int32_t nicMacRxLateColls;			/* 111 */
625d02c2331SBill Paul 	volatile u_int32_t nicMacRxLinkLostDuringPkt;		/* 112 */
626d02c2331SBill Paul 	volatile u_int32_t nicMacRxPhyDecodeErr;		/* 113 */
627d02c2331SBill Paul 	volatile u_int32_t nicMacRxMacAbort;			/* 114 */
628d02c2331SBill Paul 	volatile u_int32_t nicMacRxTruncNoResources;		/* 115 */
629d02c2331SBill Paul 	/*
630d02c2331SBill Paul 	 * Stats from the mac_stats area
631d02c2331SBill Paul 	 */
632d02c2331SBill Paul 	volatile u_int32_t nicMacRxDropUla;			/* 116 */
633d02c2331SBill Paul 	volatile u_int32_t nicMacRxDropMcast;			/* 117 */
634d02c2331SBill Paul 	volatile u_int32_t nicMacRxFlowControl;			/* 118 */
635d02c2331SBill Paul 	volatile u_int32_t nicMacRxDropSpace;			/* 119 */
636d02c2331SBill Paul 	volatile u_int32_t nicMacRxColls;			/* 120 */
637d02c2331SBill Paul 	/*
638d02c2331SBill Paul  	 * MAC RX Attentions
639d02c2331SBill Paul 	 */
640d02c2331SBill Paul 	volatile u_int32_t nicMacRxTotalAttns;			/* 121 */
641d02c2331SBill Paul 	volatile u_int32_t nicMacRxLinkAttns;			/* 122 */
642d02c2331SBill Paul 	volatile u_int32_t nicMacRxSyncAttns;			/* 123 */
643d02c2331SBill Paul 	volatile u_int32_t nicMacRxConfigAttns;			/* 124 */
644d02c2331SBill Paul 	volatile u_int32_t nicMacReset;				/* 125 */
645d02c2331SBill Paul 	volatile u_int32_t nicMacRxBufDescrAttns;		/* 126 */
646d02c2331SBill Paul 	volatile u_int32_t nicMacRxBufAttns;			/* 127 */
647d02c2331SBill Paul 	volatile u_int32_t nicMacRxZeroFrameCleanup;		/* 128 */
648d02c2331SBill Paul 	volatile u_int32_t nicMacRxOneFrameCleanup;		/* 129 */
649d02c2331SBill Paul 	volatile u_int32_t nicMacRxMultipleFrameCleanup;	/* 130 */
650d02c2331SBill Paul 	volatile u_int32_t nicMacRxTimerCleanup;		/* 131 */
651d02c2331SBill Paul 	volatile u_int32_t nicMacRxDmaCleanup;			/* 132 */
652d02c2331SBill Paul 	/*
653d02c2331SBill Paul 	 * Stats from the mac_stats area
654d02c2331SBill Paul 	 */
655d02c2331SBill Paul 	volatile u_int32_t nicMacTxCollisionHistogram[15];	/* 133 */
656d02c2331SBill Paul 	/*
657d02c2331SBill Paul 	 * MAC TX Attentions
658d02c2331SBill Paul 	 */
659d02c2331SBill Paul 	volatile u_int32_t nicMacTxTotalAttns;			/* 134 */
660d02c2331SBill Paul 	/*
661d02c2331SBill Paul 	 * NIC Profile
662d02c2331SBill Paul 	 */
663d02c2331SBill Paul 	volatile u_int32_t nicProfile[32];			/* 135 */
664d02c2331SBill Paul 	/*
665d02c2331SBill Paul 	 * Pat to 1024 bytes.
666d02c2331SBill Paul 	 */
667d02c2331SBill Paul 	u_int32_t		pad[75];
668d02c2331SBill Paul };
669d02c2331SBill Paul /*
670d02c2331SBill Paul  * Tigon general information block. This resides in host memory
671d02c2331SBill Paul  * and contains the status counters, ring control blocks and
672d02c2331SBill Paul  * producer pointers.
673d02c2331SBill Paul  */
674d02c2331SBill Paul 
675d02c2331SBill Paul struct ti_gib {
676d02c2331SBill Paul 	struct ti_stats		ti_stats;
677d02c2331SBill Paul 	struct ti_rcb		ti_ev_rcb;
678d02c2331SBill Paul 	struct ti_rcb		ti_cmd_rcb;
679d02c2331SBill Paul 	struct ti_rcb		ti_tx_rcb;
680d02c2331SBill Paul 	struct ti_rcb		ti_std_rx_rcb;
681d02c2331SBill Paul 	struct ti_rcb		ti_jumbo_rx_rcb;
682d02c2331SBill Paul 	struct ti_rcb		ti_mini_rx_rcb;
683d02c2331SBill Paul 	struct ti_rcb		ti_return_rcb;
684d02c2331SBill Paul 	ti_hostaddr		ti_ev_prodidx_ptr;
685d02c2331SBill Paul 	ti_hostaddr		ti_return_prodidx_ptr;
686d02c2331SBill Paul 	ti_hostaddr		ti_tx_considx_ptr;
687d02c2331SBill Paul 	ti_hostaddr		ti_refresh_stats_ptr;
688d02c2331SBill Paul };
689d02c2331SBill Paul 
690d02c2331SBill Paul /*
691d02c2331SBill Paul  * Buffer descriptor structures. There are basically three types
692d02c2331SBill Paul  * of structures: normal receive descriptors, extended receive
693d02c2331SBill Paul  * descriptors and transmit descriptors. The extended receive
694d02c2331SBill Paul  * descriptors are optionally used only for the jumbo receive ring.
695d02c2331SBill Paul  */
696d02c2331SBill Paul 
697d02c2331SBill Paul struct ti_rx_desc {
698d02c2331SBill Paul 	ti_hostaddr		ti_addr;
699d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
700d02c2331SBill Paul 	u_int16_t		ti_idx;
701d02c2331SBill Paul 	u_int16_t		ti_len;
702d02c2331SBill Paul #else
703d02c2331SBill Paul 	u_int16_t		ti_len;
704d02c2331SBill Paul 	u_int16_t		ti_idx;
705d02c2331SBill Paul #endif
706d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
707d02c2331SBill Paul 	u_int16_t		ti_type;
708d02c2331SBill Paul 	u_int16_t		ti_flags;
709d02c2331SBill Paul #else
710d02c2331SBill Paul 	u_int16_t		ti_flags;
711d02c2331SBill Paul 	u_int16_t		ti_type;
712d02c2331SBill Paul #endif
713d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
714d02c2331SBill Paul 	u_int16_t		ti_ip_cksum;
715d02c2331SBill Paul 	u_int16_t		ti_tcp_udp_cksum;
716d02c2331SBill Paul #else
717d02c2331SBill Paul 	u_int16_t		ti_tcp_udp_cksum;
718d02c2331SBill Paul 	u_int16_t		ti_ip_cksum;
719d02c2331SBill Paul #endif
720d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
721d02c2331SBill Paul 	u_int16_t		ti_error_flags;
722d02c2331SBill Paul 	u_int16_t		ti_vlan_tag;
723d02c2331SBill Paul #else
724d02c2331SBill Paul 	u_int16_t		ti_vlan_tag;
725d02c2331SBill Paul 	u_int16_t		ti_error_flags;
726d02c2331SBill Paul #endif
727d02c2331SBill Paul 	u_int32_t		ti_rsvd;
728d02c2331SBill Paul 	u_int32_t		ti_opaque;
729d02c2331SBill Paul };
730d02c2331SBill Paul 
731d02c2331SBill Paul struct ti_rx_desc_ext {
732d02c2331SBill Paul 	ti_hostaddr		ti_addr1;
733d02c2331SBill Paul 	ti_hostaddr		ti_addr2;
734d02c2331SBill Paul 	ti_hostaddr		ti_addr3;
735d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
736d02c2331SBill Paul 	u_int16_t		ti_len1;
737d02c2331SBill Paul 	u_int16_t		ti_len2;
738d02c2331SBill Paul #else
739d02c2331SBill Paul 	u_int16_t		ti_len2;
740d02c2331SBill Paul 	u_int16_t		ti_len1;
741d02c2331SBill Paul #endif
742d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
743d02c2331SBill Paul 	u_int16_t		ti_len3;
744d02c2331SBill Paul 	u_int16_t		ti_rsvd0;
745d02c2331SBill Paul #else
746d02c2331SBill Paul 	u_int16_t		ti_rsvd0;
747d02c2331SBill Paul 	u_int16_t		ti_len3;
748d02c2331SBill Paul #endif
749d02c2331SBill Paul 	ti_hostaddr		ti_addr0;
750d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
751d02c2331SBill Paul 	u_int16_t		ti_idx;
752d02c2331SBill Paul 	u_int16_t		ti_len0;
753d02c2331SBill Paul #else
754d02c2331SBill Paul 	u_int16_t		ti_len0;
755d02c2331SBill Paul 	u_int16_t		ti_idx;
756d02c2331SBill Paul #endif
757d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
758d02c2331SBill Paul 	u_int16_t		ti_type;
759d02c2331SBill Paul 	u_int16_t		ti_flags;
760d02c2331SBill Paul #else
761d02c2331SBill Paul 	u_int16_t		ti_flags;
762d02c2331SBill Paul 	u_int16_t		ti_type;
763d02c2331SBill Paul #endif
764d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
765d02c2331SBill Paul 	u_int16_t		ti_ip_cksum;
766d02c2331SBill Paul 	u_int16_t		ti_tcp_udp_cksum;
767d02c2331SBill Paul #else
768d02c2331SBill Paul 	u_int16_t		ti_tcp_udp_cksum;
769d02c2331SBill Paul 	u_int16_t		ti_ip_cksum;
770d02c2331SBill Paul #endif
771d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
772d02c2331SBill Paul 	u_int16_t		ti_error_flags;
773d02c2331SBill Paul 	u_int16_t		ti_vlan_tag;
774d02c2331SBill Paul #else
775d02c2331SBill Paul 	u_int16_t		ti_vlan_tag;
776d02c2331SBill Paul 	u_int16_t		ti_error_flags;
777d02c2331SBill Paul #endif
778d02c2331SBill Paul 	u_int32_t		ti_rsvd1;
779d02c2331SBill Paul 	u_int32_t		ti_opaque;
780d02c2331SBill Paul };
781d02c2331SBill Paul 
782d02c2331SBill Paul /*
783d02c2331SBill Paul  * Transmit descriptors are, mercifully, very small.
784d02c2331SBill Paul  */
785d02c2331SBill Paul struct ti_tx_desc {
786d02c2331SBill Paul 	ti_hostaddr		ti_addr;
787d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
788d02c2331SBill Paul 	u_int16_t		ti_len;
789d02c2331SBill Paul 	u_int16_t		ti_flags;
790d02c2331SBill Paul #else
791d02c2331SBill Paul 	u_int16_t		ti_flags;
792d02c2331SBill Paul 	u_int16_t		ti_len;
793d02c2331SBill Paul #endif
794d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
795d02c2331SBill Paul 	u_int16_t		ti_rsvd;
796d02c2331SBill Paul 	u_int16_t		ti_vlan_tag;
797d02c2331SBill Paul #else
798d02c2331SBill Paul 	u_int16_t		ti_vlan_tag;
799d02c2331SBill Paul 	u_int16_t		ti_rsvd;
800d02c2331SBill Paul #endif
801d02c2331SBill Paul };
802d02c2331SBill Paul 
803d02c2331SBill Paul /*
804d02c2331SBill Paul  * NOTE!  On the Alpha, we have an alignment constraint.
805d02c2331SBill Paul  * The first thing in the packet is a 14-byte Ethernet header.
806d02c2331SBill Paul  * This means that the packet is misaligned.  To compensate,
807d02c2331SBill Paul  * we actually offset the data 2 bytes into the cluster.  This
808d02c2331SBill Paul  * alignes the packet after the Ethernet header at a 32-bit
809d02c2331SBill Paul  * boundary.
810d02c2331SBill Paul  */
811d02c2331SBill Paul 
812d02c2331SBill Paul #define ETHER_ALIGN 2
813d02c2331SBill Paul 
814d02c2331SBill Paul #define TI_FRAMELEN		1518
815571a80b2SBill Paul #define TI_JUMBO_FRAMELEN	9018
816d02c2331SBill Paul #define TI_JUMBO_MTU		(TI_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
817d02c2331SBill Paul #define TI_PAGE_SIZE		PAGE_SIZE
818d02c2331SBill Paul #define TI_MIN_FRAMELEN		60
819d02c2331SBill Paul 
820d02c2331SBill Paul /*
821d02c2331SBill Paul  * Buffer descriptor error flags.
822d02c2331SBill Paul  */
823d02c2331SBill Paul #define TI_BDERR_CRC			0x0001
824d02c2331SBill Paul #define TI_BDERR_COLLDETECT		0x0002
825d02c2331SBill Paul #define TI_BDERR_LINKLOST		0x0004
826d02c2331SBill Paul #define TI_BDERR_DECODE			0x0008
827d02c2331SBill Paul #define TI_BDERR_ODD_NIBBLES		0x0010
828d02c2331SBill Paul #define TI_BDERR_MAC_ABRT		0x0020
829d02c2331SBill Paul #define TI_BDERR_RUNT			0x0040
830d02c2331SBill Paul #define TI_BDERR_TRUNC			0x0080
831d02c2331SBill Paul #define TI_BDERR_GIANT			0x0100
832d02c2331SBill Paul 
833d02c2331SBill Paul /*
834d02c2331SBill Paul  * Buffer descriptor flags.
835d02c2331SBill Paul  */
836d02c2331SBill Paul #define TI_BDFLAG_TCP_UDP_CKSUM		0x0001
837d02c2331SBill Paul #define TI_BDFLAG_IP_CKSUM		0x0002
838d02c2331SBill Paul #define TI_BDFLAG_END			0x0004
839d02c2331SBill Paul #define TI_BDFLAG_MORE			0x0008
840d02c2331SBill Paul #define TI_BDFLAG_JUMBO_RING		0x0010
841d02c2331SBill Paul #define TI_BDFLAG_UCAST_PKT		0x0020
842d02c2331SBill Paul #define TI_BDFLAG_MCAST_PKT		0x0040
843d02c2331SBill Paul #define TI_BDFLAG_BCAST_PKT		0x0060
844d02c2331SBill Paul #define TI_BDFLAG_IP_FRAG		0x0080
845d02c2331SBill Paul #define TI_BDFLAG_IP_FRAG_END		0x0100
846d02c2331SBill Paul #define TI_BDFLAG_VLAN_TAG		0x0200
847d02c2331SBill Paul #define TI_BDFLAG_ERROR			0x0400
848d02c2331SBill Paul #define TI_BDFLAG_COAL_NOW		0x0800
849d02c2331SBill Paul #define	TI_BDFLAG_MINI_RING		0x1000
850d02c2331SBill Paul 
851d02c2331SBill Paul /*
852d02c2331SBill Paul  * Descriptor type flags. I think these only have meaning for
853d02c2331SBill Paul  * the Tigon 1. I had to extract them from the sample driver source
854d02c2331SBill Paul  * since they aren't in the manual.
855d02c2331SBill Paul  */
856d02c2331SBill Paul #define TI_BDTYPE_TYPE_NULL			0x0000
857d02c2331SBill Paul #define TI_BDTYPE_SEND_BD			0x0001
858d02c2331SBill Paul #define TI_BDTYPE_RECV_BD			0x0002
859d02c2331SBill Paul #define TI_BDTYPE_RECV_JUMBO_BD			0x0003
860d02c2331SBill Paul #define TI_BDTYPE_RECV_BD_LAST			0x0004
861d02c2331SBill Paul #define TI_BDTYPE_SEND_DATA			0x0005
862d02c2331SBill Paul #define TI_BDTYPE_SEND_DATA_LAST		0x0006
863d02c2331SBill Paul #define TI_BDTYPE_RECV_DATA			0x0007
864d02c2331SBill Paul #define TI_BDTYPE_RECV_DATA_LAST		0x000b
865d02c2331SBill Paul #define TI_BDTYPE_EVENT_RUPT			0x000c
866d02c2331SBill Paul #define TI_BDTYPE_EVENT_NO_RUPT			0x000d
867d02c2331SBill Paul #define TI_BDTYPE_ODD_START			0x000e
868d02c2331SBill Paul #define TI_BDTYPE_UPDATE_STATS			0x000f
869d02c2331SBill Paul #define TI_BDTYPE_SEND_DUMMY_DMA		0x0010
870d02c2331SBill Paul #define TI_BDTYPE_EVENT_PROD			0x0011
871d02c2331SBill Paul #define TI_BDTYPE_TX_CONS			0x0012
872d02c2331SBill Paul #define TI_BDTYPE_RX_PROD			0x0013
873d02c2331SBill Paul #define TI_BDTYPE_REFRESH_STATS			0x0014
874d02c2331SBill Paul #define TI_BDTYPE_SEND_DATA_LAST_VLAN		0x0015
875d02c2331SBill Paul #define TI_BDTYPE_SEND_DATA_COAL		0x0016
876d02c2331SBill Paul #define TI_BDTYPE_SEND_DATA_LAST_COAL		0x0017
877d02c2331SBill Paul #define TI_BDTYPE_SEND_DATA_LAST_VLAN_COAL	0x0018
878d02c2331SBill Paul #define TI_BDTYPE_TX_CONS_NO_INTR		0x0019
879d02c2331SBill Paul 
880d02c2331SBill Paul /*
881d02c2331SBill Paul  * Tigon command structure.
882d02c2331SBill Paul  */
883d02c2331SBill Paul struct ti_cmd_desc {
884d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
885d02c2331SBill Paul 	u_int32_t		ti_cmd:8;
886d02c2331SBill Paul 	u_int32_t		ti_code:12;
887d02c2331SBill Paul 	u_int32_t		ti_idx:12;
888d02c2331SBill Paul #else
889d02c2331SBill Paul 	u_int32_t		ti_idx:12;
890d02c2331SBill Paul 	u_int32_t		ti_code:12;
891d02c2331SBill Paul 	u_int32_t		ti_cmd:8;
892d02c2331SBill Paul #endif
893d02c2331SBill Paul };
894d02c2331SBill Paul 
895d02c2331SBill Paul #define TI_CMD_HOST_STATE		0x01
896d02c2331SBill Paul #define TI_CMD_CODE_STACK_UP		0x01
897d02c2331SBill Paul #define TI_CMD_CODE_STACK_DOWN		0x02
898d02c2331SBill Paul 
899d02c2331SBill Paul /*
900d02c2331SBill Paul  * This command enables software address filtering. It's a workaround
901d02c2331SBill Paul  * for a bug in the Tigon 1 and not implemented for the Tigon 2.
902d02c2331SBill Paul  */
903d02c2331SBill Paul #define TI_CMD_FDR_FILTERING		0x02
904d02c2331SBill Paul #define TI_CMD_CODE_FILT_ENB		0x01
905d02c2331SBill Paul #define TI_CMD_CODE_FILT_DIS		0x02
906d02c2331SBill Paul 
907d02c2331SBill Paul #define TI_CMD_SET_RX_PROD_IDX		0x03 /* obsolete */
908d02c2331SBill Paul #define TI_CMD_UPDATE_GENCOM		0x04
909d02c2331SBill Paul #define TI_CMD_RESET_JUMBO_RING		0x05
910d02c2331SBill Paul #define TI_CMD_SET_PARTIAL_RX_CNT	0x06
911d02c2331SBill Paul #define TI_CMD_ADD_MCAST_ADDR		0x08 /* obsolete */
912d02c2331SBill Paul #define TI_CMD_DEL_MCAST_ADDR		0x09 /* obsolete */
913d02c2331SBill Paul 
914d02c2331SBill Paul #define TI_CMD_SET_PROMISC_MODE		0x0A
915d02c2331SBill Paul #define TI_CMD_CODE_PROMISC_ENB		0x01
916d02c2331SBill Paul #define TI_CMD_CODE_PROMISC_DIS		0x02
917d02c2331SBill Paul 
918d02c2331SBill Paul #define TI_CMD_LINK_NEGOTIATION		0x0B
919d02c2331SBill Paul #define TI_CMD_CODE_NEGOTIATE_BOTH	0x00
920d02c2331SBill Paul #define TI_CMD_CODE_NEGOTIATE_GIGABIT	0x01
921d02c2331SBill Paul #define TI_CMD_CODE_NEGOTIATE_10_100	0x02
922d02c2331SBill Paul 
923d02c2331SBill Paul #define TI_CMD_SET_MAC_ADDR		0x0C
924d02c2331SBill Paul #define TI_CMD_CLR_PROFILE		0x0D
925d02c2331SBill Paul 
926d02c2331SBill Paul #define TI_CMD_SET_ALLMULTI		0x0E
927d02c2331SBill Paul #define TI_CMD_CODE_ALLMULTI_ENB	0x01
928d02c2331SBill Paul #define TI_CMD_CODE_ALLMULTI_DIS	0x02
929d02c2331SBill Paul 
930d02c2331SBill Paul #define TI_CMD_CLR_STATS		0x0F
931d02c2331SBill Paul #define TI_CMD_SET_RX_JUMBO_PROD_IDX	0x10 /* obsolete */
932d02c2331SBill Paul #define TI_CMD_RFRSH_STATS		0x11
933d02c2331SBill Paul 
934d02c2331SBill Paul #define TI_CMD_EXT_ADD_MCAST		0x12
935d02c2331SBill Paul #define TI_CMD_EXT_DEL_MCAST		0x13
936d02c2331SBill Paul 
937d02c2331SBill Paul /*
938d02c2331SBill Paul  * Utility macros to make issuing commands a little simpler. Assumes
939d02c2331SBill Paul  * that 'sc' and 'cmd' are in local scope.
940d02c2331SBill Paul  */
941d02c2331SBill Paul #define TI_DO_CMD(x, y, z)		\
942d02c2331SBill Paul 	cmd.ti_cmd = x;			\
943d02c2331SBill Paul 	cmd.ti_code = y;		\
944d02c2331SBill Paul 	cmd.ti_idx = z;			\
945d02c2331SBill Paul 	ti_cmd(sc, &cmd);
946d02c2331SBill Paul 
947d02c2331SBill Paul #define TI_DO_CMD_EXT(x, y, z, v, w)	\
948d02c2331SBill Paul 	cmd.ti_cmd = x;			\
949d02c2331SBill Paul 	cmd.ti_code = y;		\
950d02c2331SBill Paul 	cmd.ti_idx = z;			\
951d02c2331SBill Paul 	ti_cmd_ext(sc, &cmd, v, w);
952d02c2331SBill Paul 
953d02c2331SBill Paul /*
954d02c2331SBill Paul  * Other utility macros.
955d02c2331SBill Paul  */
956d02c2331SBill Paul #define TI_INC(x, y)	(x) = (x + 1) % y
957d02c2331SBill Paul 
958d02c2331SBill Paul #define TI_UPDATE_JUMBOPROD(x, y)					\
959d02c2331SBill Paul 	if (x->ti_hwrev == TI_HWREV_TIGON) {				\
960d02c2331SBill Paul 		TI_DO_CMD(TI_CMD_SET_RX_JUMBO_PROD_IDX, 0, y);	\
961d02c2331SBill Paul 	} else {							\
962d02c2331SBill Paul 		CSR_WRITE_4(x, TI_MB_JUMBORXPROD_IDX, y);		\
963d02c2331SBill Paul 	}
964d02c2331SBill Paul 
965d02c2331SBill Paul #define TI_UPDATE_MINIPROD(x, y)					\
966d02c2331SBill Paul 		CSR_WRITE_4(x, TI_MB_MINIRXPROD_IDX, y);
967d02c2331SBill Paul 
968d02c2331SBill Paul #define TI_UPDATE_STDPROD(x, y)						\
969d02c2331SBill Paul 	if (x->ti_hwrev == TI_HWREV_TIGON) {				\
970d02c2331SBill Paul 		TI_DO_CMD(TI_CMD_SET_RX_PROD_IDX, 0, y);		\
971d02c2331SBill Paul 	} else {							\
972d02c2331SBill Paul 		CSR_WRITE_4(x, TI_MB_STDRXPROD_IDX, y);			\
973d02c2331SBill Paul 	}
974d02c2331SBill Paul 
975d02c2331SBill Paul 
976d02c2331SBill Paul /*
977d02c2331SBill Paul  * Tigon event structure.
978d02c2331SBill Paul  */
979d02c2331SBill Paul struct ti_event_desc {
980d02c2331SBill Paul #if BYTE_ORDER == BIG_ENDIAN
981d02c2331SBill Paul 	u_int32_t		ti_event:8;
982d02c2331SBill Paul 	u_int32_t		ti_code:12;
983d02c2331SBill Paul 	u_int32_t		ti_idx:12;
984d02c2331SBill Paul #else
985d02c2331SBill Paul 	u_int32_t		ti_idx:12;
986d02c2331SBill Paul 	u_int32_t		ti_code:12;
987d02c2331SBill Paul 	u_int32_t		ti_event:8;
988d02c2331SBill Paul #endif
989d02c2331SBill Paul 	u_int32_t		ti_rsvd;
990d02c2331SBill Paul };
991d02c2331SBill Paul 
992d02c2331SBill Paul /*
993d02c2331SBill Paul  * Tigon events.
994d02c2331SBill Paul  */
995d02c2331SBill Paul #define TI_EV_FIRMWARE_UP		0x01
996d02c2331SBill Paul #define TI_EV_STATS_UPDATED		0x04
997d02c2331SBill Paul 
998d02c2331SBill Paul #define TI_EV_LINKSTAT_CHANGED		0x06
999d02c2331SBill Paul #define TI_EV_CODE_GIG_LINK_UP		0x01
1000d02c2331SBill Paul #define TI_EV_CODE_LINK_DOWN		0x02
1001d02c2331SBill Paul #define TI_EV_CODE_LINK_UP		0x03
1002d02c2331SBill Paul 
1003d02c2331SBill Paul #define TI_EV_ERROR			0x07
1004d02c2331SBill Paul #define TI_EV_CODE_ERR_INVAL_CMD	0x01
1005d02c2331SBill Paul #define TI_EV_CODE_ERR_UNIMP_CMD	0x02
1006d02c2331SBill Paul #define TI_EV_CODE_ERR_BADCFG		0x03
1007d02c2331SBill Paul 
1008d02c2331SBill Paul #define TI_EV_MCAST_UPDATED		0x08
1009d02c2331SBill Paul #define TI_EV_CODE_MCAST_ADD		0x01
1010d02c2331SBill Paul #define TI_EV_CODE_MCAST_DEL		0x02
1011d02c2331SBill Paul 
1012d02c2331SBill Paul #define TI_EV_RESET_JUMBO_RING		0x09
1013d02c2331SBill Paul /*
1014d02c2331SBill Paul  * Register access macros. The Tigon always uses memory mapped register
1015d02c2331SBill Paul  * accesses and all registers must be accessed with 32 bit operations.
1016d02c2331SBill Paul  */
1017d02c2331SBill Paul 
1018d02c2331SBill Paul #define CSR_WRITE_4(sc, reg, val)	\
1019d02c2331SBill Paul 	bus_space_write_4(sc->ti_btag, sc->ti_bhandle, reg, val)
1020d02c2331SBill Paul 
1021d02c2331SBill Paul #define CSR_READ_4(sc, reg)		\
1022d02c2331SBill Paul 	bus_space_read_4(sc->ti_btag, sc->ti_bhandle, reg)
1023d02c2331SBill Paul 
1024d02c2331SBill Paul #define TI_SETBIT(sc, reg, x)	\
1025d02c2331SBill Paul 	CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) | x))
1026d02c2331SBill Paul #define TI_CLRBIT(sc, reg, x)	\
1027d02c2331SBill Paul 	CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) & ~x))
1028d02c2331SBill Paul 
1029d02c2331SBill Paul /*
1030d02c2331SBill Paul  * Memory management stuff. Note: the SSLOTS, MSLOTS and JSLOTS
1031d02c2331SBill Paul  * values are tuneable. They control the actual amount of buffers
1032d02c2331SBill Paul  * allocated for the standard, mini and jumbo receive rings.
1033d02c2331SBill Paul  */
1034d02c2331SBill Paul 
1035d02c2331SBill Paul #define TI_SSLOTS	256
1036d02c2331SBill Paul #define TI_MSLOTS	256
1037e87631b9SBill Paul #define TI_JSLOTS	384
1038d02c2331SBill Paul 
1039571a80b2SBill Paul #define TI_JRAWLEN (TI_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
1040d02c2331SBill Paul #define TI_JLEN (TI_JRAWLEN + (sizeof(u_int64_t) - \
1041d02c2331SBill Paul 	(TI_JRAWLEN % sizeof(u_int64_t))))
1042d02c2331SBill Paul #define TI_JPAGESZ PAGE_SIZE
1043d02c2331SBill Paul #define TI_RESID (TI_JPAGESZ - (TI_JLEN * TI_JSLOTS) % TI_JPAGESZ)
1044d02c2331SBill Paul #define TI_JMEM ((TI_JLEN * TI_JSLOTS) + TI_RESID)
1045d02c2331SBill Paul 
1046d02c2331SBill Paul struct ti_jslot {
1047d02c2331SBill Paul 	caddr_t			ti_buf;
1048d02c2331SBill Paul 	int			ti_inuse;
1049d02c2331SBill Paul };
1050d02c2331SBill Paul 
1051d02c2331SBill Paul /*
1052d02c2331SBill Paul  * Ring structures. Most of these reside in host memory and we tell
1053d02c2331SBill Paul  * the NIC where they are via the ring control blocks. The exceptions
1054d02c2331SBill Paul  * are the tx and command rings, which live in NIC memory and which
1055d02c2331SBill Paul  * we access via the shared memory window.
1056d02c2331SBill Paul  */
1057d02c2331SBill Paul struct ti_ring_data {
1058d02c2331SBill Paul 	struct ti_rx_desc	ti_rx_std_ring[TI_STD_RX_RING_CNT];
1059d02c2331SBill Paul 	struct ti_rx_desc	ti_rx_jumbo_ring[TI_JUMBO_RX_RING_CNT];
1060d02c2331SBill Paul 	struct ti_rx_desc	ti_rx_mini_ring[TI_MINI_RX_RING_CNT];
1061d02c2331SBill Paul 	struct ti_rx_desc	ti_rx_return_ring[TI_RETURN_RING_CNT];
1062d02c2331SBill Paul 	struct ti_event_desc	ti_event_ring[TI_EVENT_RING_CNT];
1063d02c2331SBill Paul 	struct ti_tx_desc	ti_tx_ring[TI_TX_RING_CNT];
1064d02c2331SBill Paul 	/*
1065d02c2331SBill Paul 	 * Make sure producer structures are aligned on 32-byte cache
1066d02c2331SBill Paul 	 * line boundaries.
1067d02c2331SBill Paul 	 */
1068d02c2331SBill Paul 	struct ti_producer	ti_ev_prodidx_r;
1069d02c2331SBill Paul 	u_int32_t		ti_pad0[6];
1070d02c2331SBill Paul 	struct ti_producer	ti_return_prodidx_r;
1071d02c2331SBill Paul 	u_int32_t		ti_pad1[6];
1072d02c2331SBill Paul 	struct ti_producer	ti_tx_considx_r;
1073d02c2331SBill Paul 	u_int32_t		ti_pad2[6];
1074d02c2331SBill Paul 	struct ti_tx_desc	*ti_tx_ring_nic;/* pointer to shared mem */
1075d02c2331SBill Paul 	struct ti_cmd_desc	*ti_cmd_ring;	/* pointer to shared mem */
1076d02c2331SBill Paul 	struct ti_gib		ti_info;
1077d02c2331SBill Paul };
1078d02c2331SBill Paul 
1079d02c2331SBill Paul /*
1080d02c2331SBill Paul  * Mbuf pointers. We need these to keep track of the virtual addresses
1081d02c2331SBill Paul  * of our mbuf chains since we can only convert from physical to virtual,
1082d02c2331SBill Paul  * not the other way around.
1083d02c2331SBill Paul  */
1084d02c2331SBill Paul struct ti_chain_data {
1085d02c2331SBill Paul 	struct mbuf		*ti_tx_chain[TI_TX_RING_CNT];
1086d02c2331SBill Paul 	struct mbuf		*ti_rx_std_chain[TI_STD_RX_RING_CNT];
1087d02c2331SBill Paul 	struct mbuf		*ti_rx_jumbo_chain[TI_JUMBO_RX_RING_CNT];
1088d02c2331SBill Paul 	struct mbuf		*ti_rx_mini_chain[TI_MINI_RX_RING_CNT];
1089d02c2331SBill Paul 	/* Stick the jumbo mem management stuff here too. */
1090d02c2331SBill Paul 	struct ti_jslot		ti_jslots[TI_JSLOTS];
1091d02c2331SBill Paul 	void			*ti_jumbo_buf;
1092d02c2331SBill Paul };
1093d02c2331SBill Paul 
1094d02c2331SBill Paul struct ti_type {
1095d02c2331SBill Paul 	u_int16_t		ti_vid;
1096d02c2331SBill Paul 	u_int16_t		ti_did;
1097d02c2331SBill Paul 	char			*ti_name;
1098d02c2331SBill Paul };
1099d02c2331SBill Paul 
1100d02c2331SBill Paul #define TI_HWREV_TIGON		0x01
1101d02c2331SBill Paul #define TI_HWREV_TIGON_II	0x02
1102d02c2331SBill Paul #define TI_TIMEOUT		1000
1103d02c2331SBill Paul #define TI_TXCONS_UNSET		0xFFFF	/* impossible value */
1104d02c2331SBill Paul 
1105d02c2331SBill Paul struct ti_mc_entry {
1106d02c2331SBill Paul 	struct ether_addr		mc_addr;
1107e3975643SJake Burkholder 	SLIST_ENTRY(ti_mc_entry)	mc_entries;
1108d02c2331SBill Paul };
1109d02c2331SBill Paul 
1110d02c2331SBill Paul struct ti_jpool_entry {
1111d02c2331SBill Paul 	int                             slot;
1112e3975643SJake Burkholder 	SLIST_ENTRY(ti_jpool_entry)	jpool_entries;
1113d02c2331SBill Paul };
1114d02c2331SBill Paul 
1115d02c2331SBill Paul struct ti_softc {
1116d02c2331SBill Paul 	struct arpcom		arpcom;		/* interface info */
1117d02c2331SBill Paul 	bus_space_handle_t	ti_bhandle;
1118af1c0621SBill Paul 	vm_offset_t		ti_vhandle;
1119d02c2331SBill Paul 	bus_space_tag_t		ti_btag;
112089ca84e6SBill Paul 	void			*ti_intrhand;
112189ca84e6SBill Paul 	struct resource		*ti_irq;
112289ca84e6SBill Paul 	struct resource		*ti_res;
1123d02c2331SBill Paul 	struct ifmedia		ifmedia;	/* media info */
1124d02c2331SBill Paul 	u_int8_t		ti_unit;	/* interface number */
1125d02c2331SBill Paul 	u_int8_t		ti_hwrev;	/* Tigon rev (1 or 2) */
1126e87631b9SBill Paul 	u_int8_t		ti_copper;	/* 1000baseTX card */
1127d02c2331SBill Paul 	u_int8_t		ti_linkstat;	/* Link state */
1128d02c2331SBill Paul 	struct ti_ring_data	*ti_rdata;	/* rings */
1129d02c2331SBill Paul 	struct ti_chain_data	ti_cdata;	/* mbufs */
1130d02c2331SBill Paul #define ti_ev_prodidx		ti_rdata->ti_ev_prodidx_r
1131d02c2331SBill Paul #define ti_return_prodidx	ti_rdata->ti_return_prodidx_r
1132d02c2331SBill Paul #define ti_tx_considx		ti_rdata->ti_tx_considx_r
1133d02c2331SBill Paul 	u_int16_t		ti_tx_saved_considx;
1134d02c2331SBill Paul 	u_int16_t		ti_rx_saved_considx;
1135d02c2331SBill Paul 	u_int16_t		ti_ev_saved_considx;
1136d02c2331SBill Paul 	u_int16_t		ti_cmd_saved_prodidx;
1137d02c2331SBill Paul 	u_int16_t		ti_std;		/* current std ring head */
1138d02c2331SBill Paul 	u_int16_t		ti_mini;	/* current mini ring head */
1139d02c2331SBill Paul 	u_int16_t		ti_jumbo;	/* current jumo ring head */
1140e3975643SJake Burkholder 	SLIST_HEAD(__ti_mchead, ti_mc_entry)	ti_mc_listhead;
1141e3975643SJake Burkholder 	SLIST_HEAD(__ti_jfreehead, ti_jpool_entry)	ti_jfree_listhead;
1142e3975643SJake Burkholder 	SLIST_HEAD(__ti_jinusehead, ti_jpool_entry)	ti_jinuse_listhead;
1143d02c2331SBill Paul 	u_int32_t		ti_stat_ticks;
1144d02c2331SBill Paul 	u_int32_t		ti_rx_coal_ticks;
1145d02c2331SBill Paul 	u_int32_t		ti_tx_coal_ticks;
1146d02c2331SBill Paul 	u_int32_t		ti_rx_max_coal_bds;
1147d02c2331SBill Paul 	u_int32_t		ti_tx_max_coal_bds;
1148d02c2331SBill Paul 	u_int32_t		ti_tx_buf_ratio;
1149d02c2331SBill Paul 	int			ti_if_flags;
115027434230SBill Paul 	int			ti_txcnt;
1151d02c2331SBill Paul };
1152d02c2331SBill Paul 
1153d02c2331SBill Paul /*
1154d02c2331SBill Paul  * Microchip Technology 24Cxx EEPROM control bytes
1155d02c2331SBill Paul  */
1156d02c2331SBill Paul #define EEPROM_CTL_READ			0xA1	/* 0101 0001 */
1157d02c2331SBill Paul #define EEPROM_CTL_WRITE		0xA0	/* 0101 0000 */
1158d02c2331SBill Paul 
1159d02c2331SBill Paul /*
1160d02c2331SBill Paul  * Note that EEPROM_START leaves transmission enabled.
1161d02c2331SBill Paul  */
1162d02c2331SBill Paul #define EEPROM_START							\
1163d02c2331SBill Paul 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock pin high */\
1164d02c2331SBill Paul 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Set DATA bit to 1 */	\
1165d02c2331SBill Paul 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Enable xmit to write bit */\
1166d02c2331SBill Paul 	TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Pull DATA bit to 0 again */\
1167d02c2331SBill Paul 	TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */
1168d02c2331SBill Paul 
1169d02c2331SBill Paul /*
1170d02c2331SBill Paul  * EEPROM_STOP ends access to the EEPROM and clears the ETXEN bit so
1171d02c2331SBill Paul  * that no further data can be written to the EEPROM I/O pin.
1172d02c2331SBill Paul  */
1173d02c2331SBill Paul #define EEPROM_STOP							\
1174d02c2331SBill Paul 	TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Disable xmit */	\
1175d02c2331SBill Paul 	TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Pull DATA to 0 */	\
1176d02c2331SBill Paul 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock high */	\
1177d02c2331SBill Paul 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Enable xmit */	\
1178d02c2331SBill Paul 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Toggle DATA to 1 */	\
1179d02c2331SBill Paul 	TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Disable xmit. */	\
1180d02c2331SBill Paul 	TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */
1181d02c2331SBill Paul 
118239d837d4SBill Paul 
1183d02c2331SBill Paul #ifdef __alpha__
1184d02c2331SBill Paul #undef vtophys
118539d837d4SBill Paul #define vtophys(va)		alpha_XXX_dmamap((vm_offset_t)va)
1186d02c2331SBill Paul #endif
1187