xref: /titanic_51/usr/src/uts/intel/io/dnet/dnet.h (revision 98e8d17584d08c481c8a827f2311c1e3e6aceabb)
1bdb9230aSGarrett D'Amore /*
2bdb9230aSGarrett D'Amore  * CDDL HEADER START
3bdb9230aSGarrett D'Amore  *
4bdb9230aSGarrett D'Amore  * The contents of this file are subject to the terms of the
5bdb9230aSGarrett D'Amore  * Common Development and Distribution License (the "License").
6bdb9230aSGarrett D'Amore  * You may not use this file except in compliance with the License.
7bdb9230aSGarrett D'Amore  *
8bdb9230aSGarrett D'Amore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9bdb9230aSGarrett D'Amore  * or http://www.opensolaris.org/os/licensing.
10bdb9230aSGarrett D'Amore  * See the License for the specific language governing permissions
11bdb9230aSGarrett D'Amore  * and limitations under the License.
12bdb9230aSGarrett D'Amore  *
13bdb9230aSGarrett D'Amore  * When distributing Covered Code, include this CDDL HEADER in each
14bdb9230aSGarrett D'Amore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15bdb9230aSGarrett D'Amore  * If applicable, add the following below this CDDL HEADER, with the
16bdb9230aSGarrett D'Amore  * fields enclosed by brackets "[]" replaced with your own identifying
17bdb9230aSGarrett D'Amore  * information: Portions Copyright [yyyy] [name of copyright owner]
18bdb9230aSGarrett D'Amore  *
19bdb9230aSGarrett D'Amore  * CDDL HEADER END
20bdb9230aSGarrett D'Amore  */
21bdb9230aSGarrett D'Amore /*
22bdb9230aSGarrett D'Amore  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23bdb9230aSGarrett D'Amore  * Use is subject to license terms.
24bdb9230aSGarrett D'Amore  */
25bdb9230aSGarrett D'Amore 
26bdb9230aSGarrett D'Amore #ifndef _DNET_H
27bdb9230aSGarrett D'Amore #define	_DNET_H
28bdb9230aSGarrett D'Amore 
29bdb9230aSGarrett D'Amore /* debug flags */
30bdb9230aSGarrett D'Amore #define	DNETTRACE		0x01
31bdb9230aSGarrett D'Amore #define	DNETERRS		0x02
32bdb9230aSGarrett D'Amore #define	DNETRECV		0x04
33bdb9230aSGarrett D'Amore #define	DNETDDI			0x08
34bdb9230aSGarrett D'Amore #define	DNETSEND		0x10
35bdb9230aSGarrett D'Amore #define	DNETINT			0x20
36bdb9230aSGarrett D'Amore #define	DNETSENSE		0x40
37bdb9230aSGarrett D'Amore #define	DNETREGCFG		0x80
38bdb9230aSGarrett D'Amore 
39bdb9230aSGarrett D'Amore #ifdef DEBUG
40bdb9230aSGarrett D'Amore #define	DNETDEBUG 1
41bdb9230aSGarrett D'Amore #endif
42bdb9230aSGarrett D'Amore 
43bdb9230aSGarrett D'Amore /* Misc */
44bdb9230aSGarrett D'Amore #define	DNETHIWAT		32768	/* driver flow control high water */
45bdb9230aSGarrett D'Amore #define	DNETLOWAT		4096	/* driver flow control low water */
46bdb9230aSGarrett D'Amore #define	DNETMAXPKT		1500	/* maximum media frame size */
47bdb9230aSGarrett D'Amore #define	DNETIDNUM		0	/* DNET Id; zero works */
48bdb9230aSGarrett D'Amore #define	DNET_MAX_FRAG		6	/* max mblk in msg before we pullup */
49bdb9230aSGarrett D'Amore 
50bdb9230aSGarrett D'Amore /* board state */
51bdb9230aSGarrett D'Amore #define	DNET_IDLE		0
52bdb9230aSGarrett D'Amore #define	DNET_WAITRCV		1
53bdb9230aSGarrett D'Amore #define	DNET_XMTBUSY		2
54bdb9230aSGarrett D'Amore #define	DNET_ERROR		3
55bdb9230aSGarrett D'Amore 
56bdb9230aSGarrett D'Amore #define	SUCCESS			0
57bdb9230aSGarrett D'Amore #define	FAILURE			1
58bdb9230aSGarrett D'Amore 
59bdb9230aSGarrett D'Amore #define	DEC_VENDOR_ID		0x1011
60bdb9230aSGarrett D'Amore #define	DEVICE_ID_21040		0x0002
61bdb9230aSGarrett D'Amore #define	DEVICE_ID_21041		0x0014
62bdb9230aSGarrett D'Amore #define	DEVICE_ID_21140		0x0009
63bdb9230aSGarrett D'Amore 
64bdb9230aSGarrett D'Amore /* Apparently, the 21143 and 142 are distinguished by revision ID */
65bdb9230aSGarrett D'Amore #define	DEVICE_ID_21142		0x0019
66bdb9230aSGarrett D'Amore #define	DEVICE_ID_21143		0x0019
67bdb9230aSGarrett D'Amore #define	COGENT_EM100		0x12
68bdb9230aSGarrett D'Amore #define	COGENT_QUARTET400	0x13
69bdb9230aSGarrett D'Amore #define	COGENT_EM110TX		0x14
70bdb9230aSGarrett D'Amore #define	VENDOR_ID_OFFSET	32
71bdb9230aSGarrett D'Amore #define	VENDOR_REVISION_OFFSET	33	/* Cogent */
72bdb9230aSGarrett D'Amore #define	ASANTE_ETHER		0x000094
73bdb9230aSGarrett D'Amore #define	COGENT_ETHER		0x000092
74bdb9230aSGarrett D'Amore #define	ADAPTEC_ETHER		0x0000d1
75bdb9230aSGarrett D'Amore #define	ZNYX_ETHER		0x00c095
76bdb9230aSGarrett D'Amore #define	COGENT_SROM_ID		0x7c
77bdb9230aSGarrett D'Amore #define	COGENT_ANA6911A_C	0x2a
78bdb9230aSGarrett D'Amore #define	COGENT_ANA6911AC_C	0x2b
79bdb9230aSGarrett D'Amore enum	{ DEFAULT_TYPE, COGENT_EM_TYPE, ASANTE_TYPE};
80bdb9230aSGarrett D'Amore 
81bdb9230aSGarrett D'Amore #define	GLD_TX_RESEND		1 	/* return code for GLD resend */
82bdb9230aSGarrett D'Amore #define	GLD_TX_OK		0	/* return code for GLD Tx ok */
83bdb9230aSGarrett D'Amore 
84bdb9230aSGarrett D'Amore #ifndef GLD_INTR_WAIT
85bdb9230aSGarrett D'Amore /* Temporary until this makes it into the build environment's gld.h */
86bdb9230aSGarrett D'Amore #define	GLD_INTR_WAIT 0x0002	/* waiting for interrupt to do scheduling */
87bdb9230aSGarrett D'Amore #endif
88bdb9230aSGarrett D'Amore 
89bdb9230aSGarrett D'Amore #define	MAX_TX_DESC		128	/* Should be a multiple of 4 <= 256 */
90bdb9230aSGarrett D'Amore #define	MAX_RX_DESC_21040	16	/* Should be a multiple of 4 <= 256 */
91bdb9230aSGarrett D'Amore #define	MAX_RX_DESC_21140	32	/* Should be a multiple of 4 <= 256 */
92bdb9230aSGarrett D'Amore 
93bdb9230aSGarrett D'Amore #define	SROM_SIZE		128
94bdb9230aSGarrett D'Amore #define	SETUPBUF_SIZE		192	/* Setup buffer size */
95bdb9230aSGarrett D'Amore #define	MCASTBUF_SIZE		512	/* multicast hash table size in bits */
96bdb9230aSGarrett D'Amore #define	PRIORITY_LEVEL		5
97bdb9230aSGarrett D'Amore #define	HASH_POLY		0x04C11DB6
98bdb9230aSGarrett D'Amore #define	HASH_CRC		0xFFFFFFFFU
99bdb9230aSGarrett D'Amore 
100bdb9230aSGarrett D'Amore #define	DNET_100MBPS		100	/* 21140 chip speeds */
101bdb9230aSGarrett D'Amore #define	DNET_10MBPS		10
102bdb9230aSGarrett D'Amore 
103bdb9230aSGarrett D'Amore /* User defined PCI config space registers */
104bdb9230aSGarrett D'Amore #define	PCI_DNET_CONF_CFDD	0x40
105bdb9230aSGarrett D'Amore #define	CFDD_SLEEP		(1UL<<31)
106bdb9230aSGarrett D'Amore #define	CFDD_SNOOZE		(1UL<<30)
107bdb9230aSGarrett D'Amore /* CSR  Description */
108bdb9230aSGarrett D'Amore #define	BUS_MODE_REG		0x00
109bdb9230aSGarrett D'Amore #define	TX_POLL_REG		0x08
110bdb9230aSGarrett D'Amore #define	RX_POLL_REG		0x10
111bdb9230aSGarrett D'Amore #define	RX_BASE_ADDR_REG	0x18
112bdb9230aSGarrett D'Amore #define	TX_BASE_ADDR_REG	0x20
113bdb9230aSGarrett D'Amore #define	STATUS_REG		0x28
114bdb9230aSGarrett D'Amore #define	OPN_MODE_REG		0x30
115bdb9230aSGarrett D'Amore #define	INT_MASK_REG		0x38
116bdb9230aSGarrett D'Amore #define	MISSED_FRAME_REG	0x40
117bdb9230aSGarrett D'Amore #define	ETHER_ROM_REG		0x48
118bdb9230aSGarrett D'Amore #define	BOOT_ROM_REG		0x50 /* 041, 140A, 142 */
119bdb9230aSGarrett D'Amore #define	FULL_DUPLEX_REG		0x58 /* 040 */
120bdb9230aSGarrett D'Amore #define	GP_TIMER_REG		0x58 /* 140-143 */
121bdb9230aSGarrett D'Amore #define	SIA_STATUS_REG		0x60 /* 040, 041, 142 */
122bdb9230aSGarrett D'Amore #define	SIA_CONNECT_REG		0x68 /* 040, 041, 142 */
123bdb9230aSGarrett D'Amore #define	SIA_TXRX_REG		0x70 /* 041, 041, 142 */
124bdb9230aSGarrett D'Amore #define	SIA_GENERAL_REG		0x78 /* 040, 041, 142 */
125bdb9230aSGarrett D'Amore #define	GP_REG			0x60 /* 140, 140A */
126bdb9230aSGarrett D'Amore 
127bdb9230aSGarrett D'Amore /* Helpful defines for register access */
128bdb9230aSGarrett D'Amore #define	REG32(reg, off)		((uint32_t *)((uintptr_t)(reg) + off))
129bdb9230aSGarrett D'Amore #define	REG16(reg, off)		((uint16_t *)((uintptr_t)(reg) + off))
130bdb9230aSGarrett D'Amore #define	REG8(reg, off)		((uint8_t *)((uintptr_t)(reg) + off))
131bdb9230aSGarrett D'Amore 
132bdb9230aSGarrett D'Amore /* Bit descriptions of CSR registers */
133bdb9230aSGarrett D'Amore 
134bdb9230aSGarrett D'Amore /* BUS_MODE_REG, CSR0 */
135bdb9230aSGarrett D'Amore #define	SW_RESET		0x01UL
136bdb9230aSGarrett D'Amore #define	BURST_SIZE		0x2000UL
137bdb9230aSGarrett D'Amore #define	CACHE_ALIGN		0x04000UL /* 8 long word boundary align */
138bdb9230aSGarrett D'Amore 
139bdb9230aSGarrett D'Amore /* TX_POLL_REG, CSR1 */
140bdb9230aSGarrett D'Amore #define	TX_POLL_DEMAND  	0x01
141bdb9230aSGarrett D'Amore 
142bdb9230aSGarrett D'Amore /* RX_POLL_REG, CSR2 */
143bdb9230aSGarrett D'Amore #define	RX_POLL_DEMAND  	0x01
144bdb9230aSGarrett D'Amore 
145bdb9230aSGarrett D'Amore /* STATUS_REG, CSR5 */
146bdb9230aSGarrett D'Amore #define	TX_INTR			0x01UL
147bdb9230aSGarrett D'Amore #define	TX_STOPPED		0x02UL
148bdb9230aSGarrett D'Amore #define	TX_BUFFER_UNAVAILABLE	0x04UL
149bdb9230aSGarrett D'Amore #define	TX_JABBER_TIMEOUT	0x08UL
150bdb9230aSGarrett D'Amore #define	TX_UNDERFLOW		0x20UL
151bdb9230aSGarrett D'Amore #define	RX_INTR			0x40UL
152bdb9230aSGarrett D'Amore #define	RX_UNAVAIL_INTR		0x80UL
153bdb9230aSGarrett D'Amore #define	RX_STOP_INTR		0x0100UL
154bdb9230aSGarrett D'Amore #define	LINK_INTR		0x1000UL
155bdb9230aSGarrett D'Amore #define	SYS_ERR			0x2000UL
156bdb9230aSGarrett D'Amore #define	ABNORMAL_INTR_SUMM	0x8000UL
157bdb9230aSGarrett D'Amore #define	NORMAL_INTR_SUMM	0x10000UL
158bdb9230aSGarrett D'Amore #define	RECEIVE_PROCESS_STATE	0xe0000UL
159bdb9230aSGarrett D'Amore #define	SYS_ERR_BITS		0x3800000UL
160bdb9230aSGarrett D'Amore #define	PARITY_ERROR		0x00000000UL
161bdb9230aSGarrett D'Amore #define	MASTER_ABORT		0x00800000UL
162bdb9230aSGarrett D'Amore #define	TARGET_ABORT		0x01000000UL
163bdb9230aSGarrett D'Amore 
164bdb9230aSGarrett D'Amore /* OPN_REG , CSR6  */
165bdb9230aSGarrett D'Amore #define	HASH_FILTERING		(1UL<<0)
166bdb9230aSGarrett D'Amore #define	START_RECEIVE		(1UL<<1)
167bdb9230aSGarrett D'Amore #define	HASH_ONLY		(1UL<<2)
168bdb9230aSGarrett D'Amore #define	PASSBAD			(1UL<<3)
169bdb9230aSGarrett D'Amore #define	INV_FILTER		(1UL<<4)
170bdb9230aSGarrett D'Amore #define	START_BACKOFF		(1UL<<5)
171bdb9230aSGarrett D'Amore #define	PROM_MODE		(1UL<<6)
172bdb9230aSGarrett D'Amore #define	PASS_MULTICAST		(1UL<<7)
173bdb9230aSGarrett D'Amore #define	FULL_DUPLEX		(1UL<<9)
174bdb9230aSGarrett D'Amore #define	OPERATING_MODE		(3UL<<10)		/* 143 */
175bdb9230aSGarrett D'Amore #define	FORCE_COLLISION		(1UL<<12)
176bdb9230aSGarrett D'Amore #define	START_TRANSMIT 		(1UL<<13)
177bdb9230aSGarrett D'Amore #define	TX_THRESHOLD_160	(3UL<<14)
178bdb9230aSGarrett D'Amore #define	CAPTURE_ENABLE		(1UL<<17)
179bdb9230aSGarrett D'Amore #define	PORT_SELECT		(1UL<<18)		/* 140, 140A, 142 */
180bdb9230aSGarrett D'Amore #define	HEARTBEAT_DISABLE	(1UL<<19)		/* 140, 140A, 142 */
181bdb9230aSGarrett D'Amore #define	STORE_AND_FORWARD	(1UL<<21)		/* 140, 140A, 142 */
182bdb9230aSGarrett D'Amore #define	TX_THRESHOLD_MODE	(1UL<<22)		/* 140, 140A, 142 */
183bdb9230aSGarrett D'Amore #define	PCS_FUNCTION		(1UL<<23)		/* 140, 140A */
184bdb9230aSGarrett D'Amore #define	SCRAMBLER_MODE		(1UL<<24)		/* 140, 140A */
185bdb9230aSGarrett D'Amore #define	OPN_REG_MB1		(1UL<<25)
186bdb9230aSGarrett D'Amore #define	RECEIVEALL		(1UL<<30)
187bdb9230aSGarrett D'Amore #define	SPECIAL_CAPTURE		(1UL<<31)
188bdb9230aSGarrett D'Amore 
189bdb9230aSGarrett D'Amore /* INT_MASK_REG , CSR7  */
190bdb9230aSGarrett D'Amore #define	TX_INTERRUPT_MASK	0x01UL
191bdb9230aSGarrett D'Amore #define	TX_STOPPED_MASK		0x02UL
192bdb9230aSGarrett D'Amore #define	TX_BUFFER_UNAVAIL_MASK	0x04UL
193bdb9230aSGarrett D'Amore #define	TX_JABBER_MASK		0x08UL
194bdb9230aSGarrett D'Amore #define	TX_UNDERFLOW_MASK	0x20UL
195bdb9230aSGarrett D'Amore #define	RX_INTERRUPT_MASK	0x40UL
196bdb9230aSGarrett D'Amore #define	RX_UNAVAIL_MASK 	0x80UL
197bdb9230aSGarrett D'Amore #define	RX_STOP_MASK		0x00100UL
198bdb9230aSGarrett D'Amore #define	GPTIMER_INTR		0x800UL
199bdb9230aSGarrett D'Amore #define	LINK_INTR_MASK   	0x01000UL
200bdb9230aSGarrett D'Amore #define	SYSTEM_ERROR_MASK   	0x02000UL
201bdb9230aSGarrett D'Amore #define	ABNORMAL_INTR_MASK	0x08000UL
202bdb9230aSGarrett D'Amore #define	NORMAL_INTR_MASK	0x10000UL
203bdb9230aSGarrett D'Amore 
204bdb9230aSGarrett D'Amore /* MISSED_FRAME_REG, CSR8 */
205bdb9230aSGarrett D'Amore #define	MISSED_FRAME_MASK	0x0ffffUL
206bdb9230aSGarrett D'Amore #define	OVERFLOW_COUNTER_MASK	0xffe0000UL
207bdb9230aSGarrett D'Amore 
208bdb9230aSGarrett D'Amore /* Serial ROM Register CSR9 */
209bdb9230aSGarrett D'Amore #define	SROM_MAX_CYCLES		5UL
210bdb9230aSGarrett D'Amore #define	SEL_CHIP		0x01UL
211bdb9230aSGarrett D'Amore #define	SEL_CLK			0x02UL
212bdb9230aSGarrett D'Amore #define	DATA_IN			0x04UL
213bdb9230aSGarrett D'Amore #define	DATA_OUT		0x08UL
214bdb9230aSGarrett D'Amore #define	HIGH_ADDRESS_BIT	0x20UL
215bdb9230aSGarrett D'Amore #define	SEL_ROM			0x800UL
216bdb9230aSGarrett D'Amore #define	READ_OP			0x4000UL
217bdb9230aSGarrett D'Amore 
218bdb9230aSGarrett D'Amore #define	MII_WRITE		((uint32_t)(0x00002000))
219bdb9230aSGarrett D'Amore #define	MII_CLOCK		((uint32_t)(0x00010000))
220bdb9230aSGarrett D'Amore #define	MII_WRITE_DATA		((uint32_t)(0x00020000))
221bdb9230aSGarrett D'Amore #define	MII_DATA_IN		((uint32_t)(0x00080000))
222bdb9230aSGarrett D'Amore #define	MII_PHY_ADDR_ALIGN	23
223bdb9230aSGarrett D'Amore #define	MII_REG_ADDR_ALIGN	18
224bdb9230aSGarrett D'Amore #define	MII_WRITE_DATA_POSITION	17
225bdb9230aSGarrett D'Amore #define	MII_DATA_IN_POSITION	19
226bdb9230aSGarrett D'Amore #define	MII_DELAY		1  /* 1 microsecond */
227bdb9230aSGarrett D'Amore #define	MII_PRE			((uint32_t)(0xFFFFFFFF))
228bdb9230aSGarrett D'Amore #define	MII_READ_FRAME		((uint32_t)(0x60000000))
229bdb9230aSGarrett D'Amore #define	MII_WRITE_FRAME		((uint32_t)(0x50020000))
230bdb9230aSGarrett D'Amore #define	MII_READ		((uint32_t)(0x00044000))
231bdb9230aSGarrett D'Amore #define	MII_WRITE_TS		((uint32_t)(0x00042000))
232bdb9230aSGarrett D'Amore 
233bdb9230aSGarrett D'Amore 
234bdb9230aSGarrett D'Amore /* GPR Timer reg, CSR11 */
235bdb9230aSGarrett D'Amore #define	GPTIMER_CONT		(1UL<<16)
236bdb9230aSGarrett D'Amore /* SIA Connectivity reg, CSR13 (040, 041, 142) */
237bdb9230aSGarrett D'Amore #define	AUTO_CONFIG		0x05UL
238bdb9230aSGarrett D'Amore #define	BNC_CONFIG		0x0DUL
239bdb9230aSGarrett D'Amore #define	SIA_CONNECT_MASK	0xFFFF0000UL
240bdb9230aSGarrett D'Amore #define	SIA_TXRX_MASK		0xFFFFFFFFUL
241bdb9230aSGarrett D'Amore #define	SIA_GENERAL_MASK	0xFFFF0000UL
242bdb9230aSGarrett D'Amore 
243bdb9230aSGarrett D'Amore #define	SIA_TXRX_MASK_TP	0xFFFFFFFFUL
244bdb9230aSGarrett D'Amore #define	SIA_GENRL_MASK_TP	0x00UL
245bdb9230aSGarrett D'Amore #define	SIA_CONN_MASK_AUI	0xEF09UL
246bdb9230aSGarrett D'Amore #define	SIA_TXRX_MASK_AUI	0x0000F73DUL
247bdb9230aSGarrett D'Amore #define	SIA_GENRL_MASK_AUI	0x0000000EUL
248bdb9230aSGarrett D'Amore 
249bdb9230aSGarrett D'Amore #define	CWE_21140		0x00000100UL /* This is moved in the 21143 */
250bdb9230aSGarrett D'Amore #define	CSR15_C
251bdb9230aSGarrett D'Amore #define	MEDIA_TP		0
252bdb9230aSGarrett D'Amore #define	MEDIA_BNC		1
253bdb9230aSGarrett D'Amore #define	MEDIA_AUI		2
254bdb9230aSGarrett D'Amore #define	MEDIA_SYM_SCR		3
255bdb9230aSGarrett D'Amore #define	MEDIA_TP_FD		4
256bdb9230aSGarrett D'Amore #define	MEDIA_SYM_SCR_FD	5
257bdb9230aSGarrett D'Amore #define	MEDIA_100T4		6
258bdb9230aSGarrett D'Amore #define	MEDIA_100FX		7
259bdb9230aSGarrett D'Amore #define	MEDIA_100FX_FD		8
260bdb9230aSGarrett D'Amore #define	MEDIA_MII		9
261bdb9230aSGarrett D'Amore 
262bdb9230aSGarrett D'Amore 
263bdb9230aSGarrett D'Amore /* CSR15 */
264bdb9230aSGarrett D'Amore #define	CWE_21143		(1UL<<11)
265bdb9230aSGarrett D'Amore 
266bdb9230aSGarrett D'Amore #define	MEDIA_CAP_100T4		0x8000UL
267bdb9230aSGarrett D'Amore #define	MEDIA_CAP_100FDX	0x4000UL
268bdb9230aSGarrett D'Amore #define	MEDIA_CAP_100HDX	0x2000UL
269bdb9230aSGarrett D'Amore #define	MEDIA_CAP_10FDX		0x1000UL
270bdb9230aSGarrett D'Amore #define	MEDIA_CAP_10HDX		0x800UL
271bdb9230aSGarrett D'Amore 
272bdb9230aSGarrett D'Amore /*
273bdb9230aSGarrett D'Amore  * In GPR and reset sequences in the ROM this is used to decide wheather the
274bdb9230aSGarrett D'Amore  * CWE bit should be set when writing to the GPR. However, the CWE bit is
275bdb9230aSGarrett D'Amore  * different on the 143 and 140, so we pick a bit where we can safely store
276bdb9230aSGarrett D'Amore  * this information in the ROM structure before writing it out to the GPR
277bdb9230aSGarrett D'Amore  * register itself
278bdb9230aSGarrett D'Amore  */
279bdb9230aSGarrett D'Amore #define	GPR_CONTROL_WRITE	(1UL<<31)
280bdb9230aSGarrett D'Amore 
281bdb9230aSGarrett D'Amore /* command block bit flags from SROM */
282bdb9230aSGarrett D'Amore #define	CMD_PS			(1<<0)
283bdb9230aSGarrett D'Amore #define	CMD_TTM			(1<<4)
284bdb9230aSGarrett D'Amore #define	CMD_PCS			(1<<5)
285bdb9230aSGarrett D'Amore #define	CMD_SCR			(1<<6)
286bdb9230aSGarrett D'Amore #define	CMD_POL			(1<<7)
287bdb9230aSGarrett D'Amore #define	CMD_DEFAULT_MEDIUM	(1<<14)
288bdb9230aSGarrett D'Amore #define	CMD_ACTIVE_INVALID	(1<<15)
289bdb9230aSGarrett D'Amore #define	CMD_MEDIABIT_MASK	0xE
290bdb9230aSGarrett D'Amore 
291bdb9230aSGarrett D'Amore #define	MAX_SEQ			8
292bdb9230aSGarrett D'Amore #define	MAX_ADAPTERS		8
293bdb9230aSGarrett D'Amore #define	MAX_MEDIA		8
294bdb9230aSGarrett D'Amore 
295bdb9230aSGarrett D'Amore 
296bdb9230aSGarrett D'Amore 
297bdb9230aSGarrett D'Amore struct dnetinstance;
298bdb9230aSGarrett D'Amore 
299bdb9230aSGarrett D'Amore typedef void (*timercb_t)(struct dnetinstance *);
300bdb9230aSGarrett D'Amore 
301bdb9230aSGarrett D'Amore 
302bdb9230aSGarrett D'Amore typedef struct _media_block_t {
303bdb9230aSGarrett D'Amore 	int type;
304bdb9230aSGarrett D'Amore 	uint16_t command;
305bdb9230aSGarrett D'Amore 	int gprseqlen;
306bdb9230aSGarrett D'Amore 	int rstseqlen;
307bdb9230aSGarrett D'Amore 	int media_code;
308bdb9230aSGarrett D'Amore 	uint16_t gprseq[8];
309bdb9230aSGarrett D'Amore 	uint16_t rstseq[8];
310bdb9230aSGarrett D'Amore 	unsigned int hassia:1;
311bdb9230aSGarrett D'Amore 	union {
312bdb9230aSGarrett D'Amore 		struct {
313bdb9230aSGarrett D'Amore 			int phy_num;
314bdb9230aSGarrett D'Amore 			uint16_t nwayadvert;
315bdb9230aSGarrett D'Amore 			uint16_t fdxmask;
316bdb9230aSGarrett D'Amore 			uint16_t ttmmask;
317bdb9230aSGarrett D'Amore 			uint16_t miiintr;
318bdb9230aSGarrett D'Amore 			uint16_t mediacaps;
319bdb9230aSGarrett D'Amore 		} mii;
320bdb9230aSGarrett D'Amore 		struct {
321bdb9230aSGarrett D'Amore 			uint32_t csr13;
322bdb9230aSGarrett D'Amore 			uint32_t csr14;
323bdb9230aSGarrett D'Amore 			uint32_t csr15;
324bdb9230aSGarrett D'Amore 		} sia;
325bdb9230aSGarrett D'Amore 	} un;
326bdb9230aSGarrett D'Amore } media_block_t;
327bdb9230aSGarrett D'Amore 
328bdb9230aSGarrett D'Amore typedef struct leaf_format {
329bdb9230aSGarrett D'Amore 	uint16_t device_number;
330bdb9230aSGarrett D'Amore 	uint16_t gpr;
331bdb9230aSGarrett D'Amore 	uint16_t selected_contype;
332bdb9230aSGarrett D'Amore 	int block_count;
333bdb9230aSGarrett D'Amore 	media_block_t *default_block;
334bdb9230aSGarrett D'Amore 	media_block_t *mii_block;
335bdb9230aSGarrett D'Amore 	media_block_t block[MAX_MEDIA];
336bdb9230aSGarrett D'Amore 	int is_static;
337bdb9230aSGarrett D'Amore } LEAF_FORMAT;
338bdb9230aSGarrett D'Amore 
339bdb9230aSGarrett D'Amore 
340bdb9230aSGarrett D'Amore typedef struct srom_format {
341bdb9230aSGarrett D'Amore 	int	init_from_srom;
342bdb9230aSGarrett D'Amore 	/* elements used to store Version 1,3 and proprietary formats */
343bdb9230aSGarrett D'Amore 	uchar_t version;
344bdb9230aSGarrett D'Amore 	uchar_t adapters;
345bdb9230aSGarrett D'Amore 	uchar_t netaddr[ETHERADDRL];
346bdb9230aSGarrett D'Amore 	LEAF_FORMAT *leaf;
347bdb9230aSGarrett D'Amore } SROM_FORMAT;
348bdb9230aSGarrett D'Amore 
349bdb9230aSGarrett D'Amore #define	SROM_VERSION		18
350bdb9230aSGarrett D'Amore #define	SROM_ADAPTER_CNT	19
351bdb9230aSGarrett D'Amore #define	SROM_NETADDR		20
352bdb9230aSGarrett D'Amore #define	SROM_LEAF_OFFSET	26
353bdb9230aSGarrett D'Amore #define	SROM_MBZ		 6
354bdb9230aSGarrett D'Amore #define	SROM_MBZ2		15
355bdb9230aSGarrett D'Amore #define	SROM_MBZ3		17
356bdb9230aSGarrett D'Amore 
357bdb9230aSGarrett D'Amore #define	MEDIA_CODE_MASK		0x3F
358bdb9230aSGarrett D'Amore #define	EXT_BIT			0x40
359bdb9230aSGarrett D'Amore 
360bdb9230aSGarrett D'Amore struct dnetinstance {
361bdb9230aSGarrett D'Amore 	caddr_t			io_reg;		/* mapped register */
362bdb9230aSGarrett D'Amore 	int 			board_type;	/* board type: 21040 or 21140 */
363bdb9230aSGarrett D'Amore 	int			full_duplex;
364bdb9230aSGarrett D'Amore 	int 			bnc_indicator; 	/* Flag for BNC connector */
365bdb9230aSGarrett D'Amore 	uint64_t		speed;		/* data rate: 10 or 100 */
366bdb9230aSGarrett D'Amore 	int			secondary;	/* SROM read as all zero */
367bdb9230aSGarrett D'Amore 	SROM_FORMAT		sr;
368bdb9230aSGarrett D'Amore 	int			leaf;
369bdb9230aSGarrett D'Amore 	int			vendor_21140;
370bdb9230aSGarrett D'Amore 	int			vendor_revision;
371bdb9230aSGarrett D'Amore 	int			promisc;
372bdb9230aSGarrett D'Amore 	int			need_saddr;
373bdb9230aSGarrett D'Amore 	int			max_tx_desc;	/* max xmit descriptors */
374bdb9230aSGarrett D'Amore 	caddr_t 		setup_buf_vaddr; /* setup buffer (virt) */
375bdb9230aSGarrett D'Amore 	uint32_t 		setup_buf_paddr; /* setup buffer (phys) */
376bdb9230aSGarrett D'Amore 	struct tx_desc_type	*tx_desc;	/* virtual addr of xmit desc */
377bdb9230aSGarrett D'Amore 	uint32_t		tx_desc_paddr;	/* physical addr of xmit desc */
378bdb9230aSGarrett D'Amore 	struct rx_desc_type	*rx_desc;	/* virtual addr of recv desc */
379bdb9230aSGarrett D'Amore 	uint32_t		rx_desc_paddr;	/* physical addr of recv desc */
380bdb9230aSGarrett D'Amore 	char			multicast_cnt[MCASTBUF_SIZE];
381bdb9230aSGarrett D'Amore 	ddi_acc_handle_t	io_handle;	/* ddi I/O handle */
382bdb9230aSGarrett D'Amore 	dev_info_t		*devinfo;
383bdb9230aSGarrett D'Amore 	int			max_rx_desc;	/* max recv descriptors */
384bdb9230aSGarrett D'Amore 	ddi_dma_handle_t	dma_handle;
385bdb9230aSGarrett D'Amore 	ddi_dma_handle_t	dma_handle_tx;
386bdb9230aSGarrett D'Amore 	ddi_dma_handle_t	dma_handle_txdesc;
387bdb9230aSGarrett D'Amore 	ddi_dma_handle_t	dma_handle_setbuf;
388bdb9230aSGarrett D'Amore 	int			pgmask;
389bdb9230aSGarrett D'Amore 	ddi_acc_handle_t	setup_buf_acchdl;
390bdb9230aSGarrett D'Amore 	int			nxmit_desc;	/* #of xmit descriptors */
391bdb9230aSGarrett D'Amore 	int			nrecv_desc;	/* #of recv descriptors */
392bdb9230aSGarrett D'Amore 	ddi_acc_handle_t	tx_desc_acchdl;
393bdb9230aSGarrett D'Amore 	ddi_acc_handle_t	rx_desc_acchdl;
394bdb9230aSGarrett D'Amore 	mblk_t			**tx_msgbufp;	/* streams message buffers */
395bdb9230aSGarrett D'Amore 						/* used for xmit */
396bdb9230aSGarrett D'Amore 	caddr_t			*rx_buf_vaddr;	/* recv buf addresses (virt) */
397bdb9230aSGarrett D'Amore 	uint32_t		*rx_buf_paddr;	/* recv buf addresses (phys) */
398*98e8d175SSteven Stallion 	ddi_iblock_cookie_t	icookie;
399bdb9230aSGarrett D'Amore 	kmutex_t		txlock;
400bdb9230aSGarrett D'Amore 	kmutex_t		intrlock;
401bdb9230aSGarrett D'Amore 	boolean_t		suspended;
402bdb9230aSGarrett D'Amore 	boolean_t		running;
403*98e8d175SSteven Stallion 	boolean_t		need_tx_update;
404*98e8d175SSteven Stallion 	mac_handle_t		mac_handle;
405bdb9230aSGarrett D'Amore 	uint32_t	stat_errrcv;
406bdb9230aSGarrett D'Amore 	uint32_t	stat_overflow;
407bdb9230aSGarrett D'Amore 	uint32_t	stat_intr;
408bdb9230aSGarrett D'Amore 	uint32_t	stat_defer;
409bdb9230aSGarrett D'Amore 	uint32_t	stat_missed;
410bdb9230aSGarrett D'Amore 	uint32_t	stat_norcvbuf;
411bdb9230aSGarrett D'Amore 	uint32_t	stat_crc;
412bdb9230aSGarrett D'Amore 	uint32_t	stat_short;
413bdb9230aSGarrett D'Amore 	uint32_t	stat_frame;
414bdb9230aSGarrett D'Amore 	uint32_t	stat_errxmt;
415bdb9230aSGarrett D'Amore 	uint32_t	stat_collisions;
416bdb9230aSGarrett D'Amore 	uint32_t	stat_xmtlatecoll;
417bdb9230aSGarrett D'Amore 	uint32_t	stat_excoll;
418bdb9230aSGarrett D'Amore 	uint32_t	stat_underflow;
419bdb9230aSGarrett D'Amore 	uint32_t	stat_nocarrier;
420bdb9230aSGarrett D'Amore 	int			tx_current_desc; /* Current Tx descriptor */
421bdb9230aSGarrett D'Amore 	int 			rx_current_desc; /* Current descriptor of Rx  */
422bdb9230aSGarrett D'Amore 	int			transmitted_desc; /* Descriptor count xmitted */
423bdb9230aSGarrett D'Amore 	int 			free_desc;	/* Descriptors available */
424bdb9230aSGarrett D'Amore 	mii_handle_t		mii;
425bdb9230aSGarrett D'Amore 	int			mii_speed;
426bdb9230aSGarrett D'Amore 	int			mii_duplex;
427bdb9230aSGarrett D'Amore 	int			phyaddr;
428bdb9230aSGarrett D'Amore 	uchar_t		vendor_addr[ETHERADDRL];
429bdb9230aSGarrett D'Amore 	uchar_t		curr_macaddr[ETHERADDRL];
430bdb9230aSGarrett D'Amore 	media_block_t		*selected_media_block;
431bdb9230aSGarrett D'Amore 	uint32_t		disallowed_media;
432bdb9230aSGarrett D'Amore 	int			disable_scrambler;
433bdb9230aSGarrett D'Amore 	int			overrun_workaround;
434bdb9230aSGarrett D'Amore 	int			interrupts_disabled;
435bdb9230aSGarrett D'Amore 	int			mii_up;
436bdb9230aSGarrett D'Amore 	uint32_t		gprsia; /* Write-through for 143's gprsia reg */
437bdb9230aSGarrett D'Amore 	struct hackintr_inf	*hackintr_inf;
438bdb9230aSGarrett D'Amore 	struct {
439bdb9230aSGarrett D'Amore 		timercb_t	cb;
440bdb9230aSGarrett D'Amore 		uint32_t	start_ticks;
441bdb9230aSGarrett D'Amore 	} timer;
442bdb9230aSGarrett D'Amore };
443bdb9230aSGarrett D'Amore 
444bdb9230aSGarrett D'Amore #pragma pack(1)
445bdb9230aSGarrett D'Amore 
446bdb9230aSGarrett D'Amore #define	BCOPY(from, to, len) bcopy(from, to, len)
447bdb9230aSGarrett D'Amore 
448bdb9230aSGarrett D'Amore /*
449bdb9230aSGarrett D'Amore  * Receive descriptor description
450bdb9230aSGarrett D'Amore  */
451bdb9230aSGarrett D'Amore struct rx_desc_type {
452bdb9230aSGarrett D'Amore 	struct {
453bdb9230aSGarrett D'Amore 		volatile uint32_t
454bdb9230aSGarrett D'Amore 				overflow	: 01,
455bdb9230aSGarrett D'Amore 				crc 		: 01,
456bdb9230aSGarrett D'Amore 				dribbling	: 01,
457bdb9230aSGarrett D'Amore 				mii_err		: 01,
458bdb9230aSGarrett D'Amore 				rcv_watchdog 	: 01,
459bdb9230aSGarrett D'Amore 				frame_type	: 01,
460bdb9230aSGarrett D'Amore 				collision	: 01,
461bdb9230aSGarrett D'Amore 				frame2long   	: 01,
462bdb9230aSGarrett D'Amore 				last_desc	: 01,
463bdb9230aSGarrett D'Amore 				first_desc	: 01,
464bdb9230aSGarrett D'Amore 				multi_frame  	: 01,
465bdb9230aSGarrett D'Amore 				runt_frame	: 01,
466bdb9230aSGarrett D'Amore 				u_data_type	: 02,
467bdb9230aSGarrett D'Amore 				desc_err	: 01,
468bdb9230aSGarrett D'Amore 				err_summary  	: 01,
469bdb9230aSGarrett D'Amore 				frame_len	: 14,
470bdb9230aSGarrett D'Amore 				filter_fail	: 01,
471bdb9230aSGarrett D'Amore 				own		: 01;
472bdb9230aSGarrett D'Amore 	} desc0;
473bdb9230aSGarrett D'Amore 	struct {
474bdb9230aSGarrett D'Amore 		volatile uint32_t
475bdb9230aSGarrett D'Amore 				buffer_size1 	: 11,
476bdb9230aSGarrett D'Amore 				buffer_size2 	: 11,
477bdb9230aSGarrett D'Amore 				not_used	: 02,
478bdb9230aSGarrett D'Amore 				chaining	: 01,
479bdb9230aSGarrett D'Amore 				end_of_ring	: 01,
480bdb9230aSGarrett D'Amore 				rsvd1		: 06;
481bdb9230aSGarrett D'Amore 	} desc1;
482bdb9230aSGarrett D'Amore 	volatile uint32_t	buffer1;
483bdb9230aSGarrett D'Amore 	volatile uint32_t	buffer2;
484bdb9230aSGarrett D'Amore };
485bdb9230aSGarrett D'Amore 
486bdb9230aSGarrett D'Amore /*
487bdb9230aSGarrett D'Amore  * Receive descriptor description
488bdb9230aSGarrett D'Amore  */
489bdb9230aSGarrett D'Amore struct tx_desc_type {
490bdb9230aSGarrett D'Amore 	struct {
491bdb9230aSGarrett D'Amore 		volatile uint32_t
492bdb9230aSGarrett D'Amore 				deferred	: 1,
493bdb9230aSGarrett D'Amore 				underflow	: 1,
494bdb9230aSGarrett D'Amore 				link_fail	: 1,
495bdb9230aSGarrett D'Amore 				collision_count : 4,
496bdb9230aSGarrett D'Amore 				heartbeat_fail	: 1,
497bdb9230aSGarrett D'Amore 				excess_collision : 1,
498bdb9230aSGarrett D'Amore 				late_collision	: 1,
499bdb9230aSGarrett D'Amore 				no_carrier	: 1,
500bdb9230aSGarrett D'Amore 				carrier_loss	: 1,
501bdb9230aSGarrett D'Amore 				rsvd1		: 2,
502bdb9230aSGarrett D'Amore 				tx_jabber_to	: 1,
503bdb9230aSGarrett D'Amore 				err_summary	: 1,
504bdb9230aSGarrett D'Amore 				rsvd		: 15,
505bdb9230aSGarrett D'Amore 				own		: 1;
506bdb9230aSGarrett D'Amore 	} desc0;
507bdb9230aSGarrett D'Amore 	struct {
508bdb9230aSGarrett D'Amore 		volatile uint32_t
509bdb9230aSGarrett D'Amore 				buffer_size1 	: 11,
510bdb9230aSGarrett D'Amore 				buffer_size2 	: 11,
511bdb9230aSGarrett D'Amore 				filter_type0 	: 1,
512bdb9230aSGarrett D'Amore 				disable_padding : 1,
513bdb9230aSGarrett D'Amore 				chaining 	: 1,
514bdb9230aSGarrett D'Amore 				end_of_ring  	: 1,
515bdb9230aSGarrett D'Amore 				crc_disable  	: 1,
516bdb9230aSGarrett D'Amore 				setup_packet 	: 1,
517bdb9230aSGarrett D'Amore 				filter_type1 	: 1,
518bdb9230aSGarrett D'Amore 				first_desc   	: 1,
519bdb9230aSGarrett D'Amore 				last_desc    	: 1,
520bdb9230aSGarrett D'Amore 				int_on_comp  	: 1;
521bdb9230aSGarrett D'Amore 	} desc1;
522bdb9230aSGarrett D'Amore 	volatile uint32_t	buffer1;
523bdb9230aSGarrett D'Amore 	volatile uint32_t	buffer2;
524bdb9230aSGarrett D'Amore };
525bdb9230aSGarrett D'Amore 
526bdb9230aSGarrett D'Amore 
527bdb9230aSGarrett D'Amore #define	DNET_END_OF_RING	0x2000000
528bdb9230aSGarrett D'Amore 
529bdb9230aSGarrett D'Amore #pragma pack()
530bdb9230aSGarrett D'Amore 
531bdb9230aSGarrett D'Amore #endif	/* _DNET_H */
532