xref: /illumos-gate/usr/src/uts/common/io/rge/rge_hw.h (revision 9e1a9180)
1c7fd2ed0Sgs /*
2c7fd2ed0Sgs  * CDDL HEADER START
3c7fd2ed0Sgs  *
4c7fd2ed0Sgs  * The contents of this file are subject to the terms of the
5aa817493Sgs  * Common Development and Distribution License (the "License").
6aa817493Sgs  * You may not use this file except in compliance with the License.
7c7fd2ed0Sgs  *
8c7fd2ed0Sgs  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c7fd2ed0Sgs  * or http://www.opensolaris.org/os/licensing.
10c7fd2ed0Sgs  * See the License for the specific language governing permissions
11c7fd2ed0Sgs  * and limitations under the License.
12c7fd2ed0Sgs  *
13c7fd2ed0Sgs  * When distributing Covered Code, include this CDDL HEADER in each
14c7fd2ed0Sgs  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c7fd2ed0Sgs  * If applicable, add the following below this CDDL HEADER, with the
16c7fd2ed0Sgs  * fields enclosed by brackets "[]" replaced with your own identifying
17c7fd2ed0Sgs  * information: Portions Copyright [yyyy] [name of copyright owner]
18c7fd2ed0Sgs  *
19c7fd2ed0Sgs  * CDDL HEADER END
20c7fd2ed0Sgs  */
21c7fd2ed0Sgs /*
22bdb9230aSGarrett D'Amore  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23c7fd2ed0Sgs  * Use is subject to license terms.
24c7fd2ed0Sgs  */
25c7fd2ed0Sgs 
26c7fd2ed0Sgs #ifndef _RGE_HW_H
27c7fd2ed0Sgs #define	_RGE_HW_H
28c7fd2ed0Sgs 
29c7fd2ed0Sgs #ifdef __cplusplus
30c7fd2ed0Sgs extern "C" {
31c7fd2ed0Sgs #endif
32c7fd2ed0Sgs 
33c7fd2ed0Sgs #include <sys/types.h>
34c7fd2ed0Sgs 
35c7fd2ed0Sgs 
36c7fd2ed0Sgs /*
37c7fd2ed0Sgs  * First section:
38c7fd2ed0Sgs  *	Identification of the various Realtek GigE chips
39c7fd2ed0Sgs  */
40c7fd2ed0Sgs 
41c7fd2ed0Sgs /*
42c7fd2ed0Sgs  * Driver support device
43c7fd2ed0Sgs  */
44c7fd2ed0Sgs #define	VENDOR_ID_REALTECK		0x10EC
4552643194Sgs #define	DEVICE_ID_8169			0x8169	/* PCI */
4652643194Sgs #define	DEVICE_ID_8110			0x8169	/* PCI */
4752643194Sgs #define	DEVICE_ID_8168			0x8168	/* PCI-E */
4852643194Sgs #define	DEVICE_ID_8111			0x8168	/* PCI-E */
4952643194Sgs #define	DEVICE_ID_8169SC		0x8167	/* PCI */
5052643194Sgs #define	DEVICE_ID_8110SC		0x8167	/* PCI */
51dfc2d53eSmx #define	DEVICE_ID_8101E			0x8136	/* 10/100M PCI-E */
52c7fd2ed0Sgs 
53c7fd2ed0Sgs #define	RGE_REGISTER_MAX		0x0100
54c7fd2ed0Sgs 
55c7fd2ed0Sgs 
56c7fd2ed0Sgs /*
57c7fd2ed0Sgs  * Second section:
58c7fd2ed0Sgs  *	Offsets of important registers & definitions for bits therein
59c7fd2ed0Sgs  */
60c7fd2ed0Sgs /*
61c7fd2ed0Sgs  * MAC address register, initial value is autoloaded from the
62c7fd2ed0Sgs  * EEPROM EthernetID field
63c7fd2ed0Sgs  */
64c7fd2ed0Sgs #define	ID_0_REG			0x0000
65c7fd2ed0Sgs #define	ID_1_REG			0x0001
66c7fd2ed0Sgs #define	ID_2_REG			0x0002
67c7fd2ed0Sgs #define	ID_3_REG			0x0003
68c7fd2ed0Sgs #define	ID_4_REG			0x0004
69c7fd2ed0Sgs #define	ID_5_REG			0x0005
70c7fd2ed0Sgs 
71c7fd2ed0Sgs /*
72c7fd2ed0Sgs  * Multicast register
73c7fd2ed0Sgs  */
74c7fd2ed0Sgs #define	MULTICAST_0_REG			0x0008
75c7fd2ed0Sgs #define	MULTICAST_1_REG			0x0009
76c7fd2ed0Sgs #define	MULTICAST_2_REG			0x000a
77c7fd2ed0Sgs #define	MULTICAST_3_REG			0x000b
78c7fd2ed0Sgs #define	MULTICAST_4_REG			0x000c
79c7fd2ed0Sgs #define	MULTICAST_5_REG			0x000d
80c7fd2ed0Sgs #define	MULTICAST_6_REG			0x000e
81c7fd2ed0Sgs #define	MULTICAST_7_REG			0x000f
82aa817493Sgs #define	RGE_MCAST_NUM			8 /* total 8 registers: MAR0 - MAR7 */
83c7fd2ed0Sgs 
84c7fd2ed0Sgs /*
85c7fd2ed0Sgs  * Dump Tally Counter Command register
86c7fd2ed0Sgs  */
87c7fd2ed0Sgs #define	DUMP_COUNTER_REG_0		0x0010
88c7fd2ed0Sgs #define	DUMP_COUNTER_REG_RESV		0x00000037
89c7fd2ed0Sgs #define	DUMP_START			0x00000008
90c7fd2ed0Sgs #define	DUMP_COUNTER_REG_1		0x0014
91c7fd2ed0Sgs 
92c7fd2ed0Sgs /*
93c7fd2ed0Sgs  * Register for start address of transmit descriptors
94c7fd2ed0Sgs  */
95c7fd2ed0Sgs #define	NORMAL_TX_RING_ADDR_LO_REG	0x0020
96c7fd2ed0Sgs #define	NORMAL_TX_RING_ADDR_HI_REG	0x0024
97c7fd2ed0Sgs #define	HIGH_TX_RING_ADDR_LO_REG	0x0028
98c7fd2ed0Sgs #define	HIGH_TX_RING_ADDR_HI_REG	0x002c
99c7fd2ed0Sgs 
100c7fd2ed0Sgs /*
101c7fd2ed0Sgs  * Commond register
102c7fd2ed0Sgs  */
103c7fd2ed0Sgs #define	RT_COMMAND_REG			0x0037
104c7fd2ed0Sgs #define	RT_COMMAND_RESV			0xe3
105c7fd2ed0Sgs #define	RT_COMMAND_RESET		0x10
106c7fd2ed0Sgs #define	RT_COMMAND_RX_ENABLE		0x08
107c7fd2ed0Sgs #define	RT_COMMAND_TX_ENABLE		0x04
108c7fd2ed0Sgs 
109c7fd2ed0Sgs /*
110c7fd2ed0Sgs  * Transmit priority polling register
111c7fd2ed0Sgs  */
112c7fd2ed0Sgs #define	TX_RINGS_POLL_REG		0x0038
113c7fd2ed0Sgs #define	HIGH_TX_RING_POLL		0x80
114c7fd2ed0Sgs #define	NORMAL_TX_RING_POLL		0x40
115c7fd2ed0Sgs #define	FORCE_SW_INT			0x01
116c7fd2ed0Sgs 
117c7fd2ed0Sgs /*
118c7fd2ed0Sgs  * Interrupt mask & status register
119c7fd2ed0Sgs  */
120c7fd2ed0Sgs #define	INT_MASK_REG			0x003c
121c7fd2ed0Sgs #define	INT_STATUS_REG			0x003e
122c7fd2ed0Sgs #define	SYS_ERR_INT			0x8000
123c7fd2ed0Sgs #define	TIME_OUT_INT			0x4000
124c7fd2ed0Sgs #define	SW_INT				0x0100
125c7fd2ed0Sgs #define	NO_TXDESC_INT			0x0080
126c7fd2ed0Sgs #define	RX_FIFO_OVERFLOW_INT		0x0040
127c7fd2ed0Sgs #define	LINK_CHANGE_INT			0x0020
128c7fd2ed0Sgs #define	NO_RXDESC_INT			0x0010
129c7fd2ed0Sgs #define	TX_ERR_INT			0x0008
130c7fd2ed0Sgs #define	TX_OK_INT			0x0004
131c7fd2ed0Sgs #define	RX_ERR_INT			0x0002
132c7fd2ed0Sgs #define	RX_OK_INT			0x0001
133c7fd2ed0Sgs 
134c7fd2ed0Sgs #define	INT_REG_RESV			0x3e00
135c7fd2ed0Sgs #define	INT_MASK_ALL			0xffff
136c7fd2ed0Sgs #define	INT_MASK_NONE			0x0000
137c7fd2ed0Sgs #define	RGE_RX_INT			(RX_OK_INT | RX_ERR_INT | \
138aa817493Sgs 					    NO_RXDESC_INT)
1393a84c50fSWinson Wang - Sun Microsystems - Beijing China #define	RGE_INT_MASK			(TX_OK_INT | TX_ERR_INT | \
1403a84c50fSWinson Wang - Sun Microsystems - Beijing China 					    RGE_RX_INT | LINK_CHANGE_INT | \
141*9e1a9180SLi-Zhen You 					    TIME_OUT_INT | SYS_ERR_INT)
142c7fd2ed0Sgs 
143c7fd2ed0Sgs /*
144c7fd2ed0Sgs  * Transmit configuration register
145c7fd2ed0Sgs  */
146c7fd2ed0Sgs #define	TX_CONFIG_REG			0x0040
147c7fd2ed0Sgs #define	TX_CONFIG_REG_RESV		0x8070f8ff
148c7fd2ed0Sgs #define	HW_VERSION_ID_0			0x7c000000
149c7fd2ed0Sgs #define	INTER_FRAME_GAP_BITS		0x03080000
150c7fd2ed0Sgs #define	TX_INTERFRAME_GAP_802_3		0x03000000
151c7fd2ed0Sgs #define	HW_VERSION_ID_1			0x00800000
152c7fd2ed0Sgs #define	MAC_LOOPBACK_ENABLE		0x00060000
153c7fd2ed0Sgs #define	CRC_APPEND_ENABLE		0x00010000
154c7fd2ed0Sgs #define	TX_DMA_BURST_BITS		0x00000700
155c7fd2ed0Sgs 
156c7fd2ed0Sgs #define	TX_DMA_BURST_UNLIMIT		0x00000700
157c7fd2ed0Sgs #define	TX_DMA_BURST_1024B		0x00000600
158c7fd2ed0Sgs #define	TX_DMA_BURST_512B		0x00000500
159c7fd2ed0Sgs #define	TX_DMA_BURST_256B		0x00000400
160c7fd2ed0Sgs #define	TX_DMA_BURST_128B		0x00000300
161c7fd2ed0Sgs #define	TX_DMA_BURST_64B		0x00000200
162c7fd2ed0Sgs #define	TX_DMA_BURST_32B		0x00000100
163c7fd2ed0Sgs #define	TX_DMA_BURST_16B		0x00000000
164c7fd2ed0Sgs 
165aa817493Sgs #define	MAC_VER_8169			0x00000000
166aa817493Sgs #define	MAC_VER_8169S_D			0x00800000
167aa817493Sgs #define	MAC_VER_8169S_E			0x04000000
168aa817493Sgs #define	MAC_VER_8169SB			0x10000000
16952643194Sgs #define	MAC_VER_8169SC			0x18000000
170aa817493Sgs #define	MAC_VER_8168			0x20000000
171aa817493Sgs #define	MAC_VER_8168B_B			0x30000000
172aa817493Sgs #define	MAC_VER_8168B_C			0x38000000
1735927ab2bSKHF #define	MAC_VER_8168C			0x3c000000
174dfc2d53eSmx #define	MAC_VER_8101E			0x34000000
175834a2629Syong tan - Sun Microsystems - Beijing China #define	MAC_VER_8101E_B			0x24800000
176834a2629Syong tan - Sun Microsystems - Beijing China #define	MAC_VER_8101E_C			0x34800000
177c7fd2ed0Sgs 
178c7fd2ed0Sgs #define	TX_CONFIG_DEFAULT		(TX_INTERFRAME_GAP_802_3 | \
179c7fd2ed0Sgs 					    TX_DMA_BURST_1024B)
180c7fd2ed0Sgs /*
181c7fd2ed0Sgs  * Receive configuration register
182c7fd2ed0Sgs  */
183c7fd2ed0Sgs #define	RX_CONFIG_REG			0x0044
184c7fd2ed0Sgs #define	RX_CONFIG_REG_RESV		0xfffe1880
185c7fd2ed0Sgs #define	RX_RER8_ENABLE			0x00010000
186c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_BITS		0x0000e000
187c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_NONE		0x0000e000
188c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_1024B		0x0000c000
189c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_512B		0x0000a000
190c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_256B		0x00008000
191c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_128B		0x00006000
192c7fd2ed0Sgs #define	RX_FIFO_THRESHOLD_64B		0x00004000
193c7fd2ed0Sgs #define	RX_DMA_BURST_BITS		0x00000700
194c7fd2ed0Sgs #define	RX_DMA_BURST_UNLIMITED		0x00000700
195c7fd2ed0Sgs #define	RX_DMA_BURST_1024B		0x00000600
196c7fd2ed0Sgs #define	RX_DMA_BURST_512B		0x00000500
197c7fd2ed0Sgs #define	RX_DMA_BURST_256B		0x00000400
198c7fd2ed0Sgs #define	RX_DMA_BURST_128B		0x00000300
199c7fd2ed0Sgs #define	RX_DMA_BURST_64B		0x00000200
200c7fd2ed0Sgs #define	RX_EEPROM_9356			0x00000040
201c7fd2ed0Sgs #define	RX_ACCEPT_ERR_PKT		0x00000020
202c7fd2ed0Sgs #define	RX_ACCEPT_RUNT_PKT		0x00000010
203c7fd2ed0Sgs #define	RX_ACCEPT_BROADCAST_PKT		0x000000008
204c7fd2ed0Sgs #define	RX_ACCEPT_MULTICAST_PKT		0x000000004
205c7fd2ed0Sgs #define	RX_ACCEPT_MAC_MATCH_PKT		0x000000002
206c7fd2ed0Sgs #define	RX_ACCEPT_ALL_PKT		0x000000001
207c7fd2ed0Sgs 
208c7fd2ed0Sgs #define	RX_CONFIG_DEFAULT		(RX_FIFO_THRESHOLD_NONE | \
209c7fd2ed0Sgs 					    RX_DMA_BURST_1024B | \
210c7fd2ed0Sgs 					    RX_ACCEPT_BROADCAST_PKT | \
211c7fd2ed0Sgs 					    RX_ACCEPT_MULTICAST_PKT | \
212c7fd2ed0Sgs 					    RX_ACCEPT_MAC_MATCH_PKT)
213c7fd2ed0Sgs 
214c7fd2ed0Sgs /*
215c7fd2ed0Sgs  * Timer count register
216c7fd2ed0Sgs  */
217c7fd2ed0Sgs #define	TIMER_COUNT_REG			0x0048
2183a84c50fSWinson Wang - Sun Microsystems - Beijing China #define	TIMER_CLK_PCIE			(125*1000*1000)
2193a84c50fSWinson Wang - Sun Microsystems - Beijing China #define	TIMER_CLK_PCI			(33*1000*1000)
220c7fd2ed0Sgs 
221c7fd2ed0Sgs /*
222c7fd2ed0Sgs  * Missed packet counter: indicates the number of packets
223c7fd2ed0Sgs  * discarded due to Rx FIFO overflow
224c7fd2ed0Sgs  */
225c7fd2ed0Sgs #define	RX_PKT_MISS_COUNT_REG		0x004c
226c7fd2ed0Sgs 
227c7fd2ed0Sgs /*
228c7fd2ed0Sgs  * 93c46(93c56) commond register:
229c7fd2ed0Sgs  */
230c7fd2ed0Sgs #define	RT_93c46_COMMOND_REG		0x0050
231c7fd2ed0Sgs #define	RT_93c46_MODE_BITS		0xc0
232c7fd2ed0Sgs #define	RT_93c46_MODE_NORMAL		0x00
233c7fd2ed0Sgs #define	RT_93c46_MODE_AUTOLOAD		0x40
234c7fd2ed0Sgs #define	RT_93c46_MODE_PROGRAM		0x80
235c7fd2ed0Sgs #define	RT_93c46_MODE_CONFIG		0xc0
236c7fd2ed0Sgs 
237c7fd2ed0Sgs #define	RT_93c46_EECS			0x08
238c7fd2ed0Sgs #define	RT_93c46_EESK			0x04
239c7fd2ed0Sgs #define	RT_93c46_EEDI			0x02
240c7fd2ed0Sgs #define	RT_93c46_EEDO			0x01
241c7fd2ed0Sgs 
242c7fd2ed0Sgs /*
243c7fd2ed0Sgs  * Configuration registers
244c7fd2ed0Sgs  */
245c7fd2ed0Sgs #define	RT_CONFIG_0_REG			0x0051
246c7fd2ed0Sgs #define	RT_CONFIG_1_REG			0x0052
247c7fd2ed0Sgs #define	RT_CONFIG_2_REG			0x0053
248c7fd2ed0Sgs #define	RT_CONFIG_3_REG			0x0054
249c7fd2ed0Sgs #define	RT_CONFIG_4_REG			0x0055
250c7fd2ed0Sgs #define	RT_CONFIG_5_REG			0x0056
251c7fd2ed0Sgs 
252368a5ef8SMiles Xu, Sun Microsystems /*
253368a5ef8SMiles Xu, Sun Microsystems  * Config 5 Register Bits
254368a5ef8SMiles Xu, Sun Microsystems  */
255368a5ef8SMiles Xu, Sun Microsystems #define	RT_UNI_WAKE_FRAME		0x10
256368a5ef8SMiles Xu, Sun Microsystems #define	RT_MUL_WAKE_FRAME		0x20
257368a5ef8SMiles Xu, Sun Microsystems #define	RT_BRO_WAKE_FRAME		0x40
258368a5ef8SMiles Xu, Sun Microsystems 
259c7fd2ed0Sgs /*
260c7fd2ed0Sgs  * Timer interrupt register
261c7fd2ed0Sgs  */
262c7fd2ed0Sgs #define	TIMER_INT_REG			0x0058
263c7fd2ed0Sgs #define	TIMER_INT_NONE			0x00000000
264c7fd2ed0Sgs 
265c7fd2ed0Sgs /*
266c7fd2ed0Sgs  * PHY access register
267c7fd2ed0Sgs  */
268c7fd2ed0Sgs #define	PHY_ACCESS_REG			0x0060
269c7fd2ed0Sgs #define	PHY_ACCESS_WR_FLAG		0x80000000
270c7fd2ed0Sgs #define	PHY_ACCESS_REG_BITS		0x001f0000
271c7fd2ed0Sgs #define	PHY_ACCESS_DATA_BITS		0x0000ffff
272c7fd2ed0Sgs #define	PHY_DATA_MASK			0xffff
273c7fd2ed0Sgs #define	PHY_REG_MASK			0x1f
274c7fd2ed0Sgs #define	PHY_REG_SHIFT			16
275c7fd2ed0Sgs 
276aa817493Sgs /*
277aa817493Sgs  * CSI data register (for PCIE chipset)
278aa817493Sgs  */
279aa817493Sgs #define	RT_CSI_DATA_REG			0x0064
280aa817493Sgs 
281aa817493Sgs /*
282aa817493Sgs  * CSI access register  (for PCIE chipset)
283aa817493Sgs  */
284aa817493Sgs #define	RT_CSI_ACCESS_REG		0x0068
285aa817493Sgs 
286c7fd2ed0Sgs /*
287c7fd2ed0Sgs  * PHY status register
288c7fd2ed0Sgs  */
289c7fd2ed0Sgs #define	PHY_STATUS_REG			0x006c
290c7fd2ed0Sgs #define	PHY_STATUS_TBI			0x80
291c7fd2ed0Sgs #define	PHY_STATUS_TX_FLOW		0x40
292c7fd2ed0Sgs #define	PHY_STATUS_RX_FLOW		0x20
293c7fd2ed0Sgs #define	PHY_STATUS_1000MF		0x10
294c7fd2ed0Sgs #define	PHY_STATUS_100M			0x08
295c7fd2ed0Sgs #define	PHY_STATUS_10M			0x04
296c7fd2ed0Sgs #define	PHY_STATUS_LINK_UP		0x02
297c7fd2ed0Sgs #define	PHY_STATUS_DUPLEX_FULL		0x01
298c7fd2ed0Sgs 
299c7fd2ed0Sgs #define	RGE_SPEED_1000M			1000
300c7fd2ed0Sgs #define	RGE_SPEED_100M			100
301c7fd2ed0Sgs #define	RGE_SPEED_10M			10
302c7fd2ed0Sgs #define	RGE_SPEED_UNKNOWN		0
303c7fd2ed0Sgs 
304aa817493Sgs /*
305aa817493Sgs  * EPHY access register (for PCIE chipset)
306aa817493Sgs  */
307aa817493Sgs #define	EPHY_ACCESS_REG			0x0080
308aa817493Sgs #define	EPHY_ACCESS_WR_FLAG		0x80000000
309aa817493Sgs #define	EPHY_ACCESS_REG_BITS		0x001f0000
310aa817493Sgs #define	EPHY_ACCESS_DATA_BITS		0x0000ffff
311aa817493Sgs #define	EPHY_DATA_MASK			0xffff
312aa817493Sgs #define	EPHY_REG_MASK			0x1f
313aa817493Sgs #define	EPHY_REG_SHIFT			16
314aa817493Sgs 
315c7fd2ed0Sgs /*
316c7fd2ed0Sgs  * Receive packet maximum size register
317c7fd2ed0Sgs  * -- the maximum rx size supported is (16K - 1) bytes
318c7fd2ed0Sgs  */
319c7fd2ed0Sgs #define	RX_MAX_PKTSIZE_REG		0x00da
320c7fd2ed0Sgs #define	RX_PKTSIZE_JUMBO		0x1bfa	/* 7K bytes */
321c7fd2ed0Sgs #define	RX_PKTSIZE_STD			0x05fa	/* 1530 bytes */
322dfc2d53eSmx #define	RX_PKTSIZE_STD_8101E		0x3fff
323c7fd2ed0Sgs 
324c7fd2ed0Sgs /*
325c7fd2ed0Sgs  * C+ command register
326c7fd2ed0Sgs  */
327c7fd2ed0Sgs #define	CPLUS_COMMAND_REG		0x00e0
328c7fd2ed0Sgs #define	CPLUS_RESERVE			0xfd87
329c7fd2ed0Sgs #define	CPLUS_BIT14			0x4000
330c7fd2ed0Sgs #define	CPLUS_BIG_ENDIAN		0x0400
331c7fd2ed0Sgs #define	RX_VLAN_DETAG			0x0040
332c7fd2ed0Sgs #define	RX_CKSM_OFFLOAD			0x0020
333c7fd2ed0Sgs #define	DUAL_PCI_CYCLE			0x0010
334c7fd2ed0Sgs #define	MUL_PCI_RW_ENABLE		0x0008
335c7fd2ed0Sgs 
336c7fd2ed0Sgs /*
337c7fd2ed0Sgs  * Receive descriptor start address
338c7fd2ed0Sgs  */
339c7fd2ed0Sgs #define	RX_RING_ADDR_LO_REG		0x00e4
340c7fd2ed0Sgs #define	RX_RING_ADDR_HI_REG		0x00e8
341c7fd2ed0Sgs 
342c7fd2ed0Sgs /*
343c7fd2ed0Sgs  * Max transmit packet size register
344c7fd2ed0Sgs  */
345c7fd2ed0Sgs #define	TX_MAX_PKTSIZE_REG		0x00ec
346c7fd2ed0Sgs #define	TX_MAX_PKTSIZE_REG_RESV		0xc0
347c7fd2ed0Sgs #define	TX_PKTSIZE_JUMBO		0x3b	/* Realtek suggested value */
348c7fd2ed0Sgs #define	TX_PKTSIZE_STD			0x32	/* document suggested value */
349dfc2d53eSmx #define	TX_PKTSIZE_STD_8101E		0x3f
350c7fd2ed0Sgs 
351c7fd2ed0Sgs #define	RESV_82_REG			0x0082
352c7fd2ed0Sgs #define	RESV_E2_REG			0x00e2
353c7fd2ed0Sgs 
354c7fd2ed0Sgs /*
355c7fd2ed0Sgs  * PHY registers
356c7fd2ed0Sgs  */
357c7fd2ed0Sgs /*
358c7fd2ed0Sgs  * Basic mode control register
359c7fd2ed0Sgs  */
360c7fd2ed0Sgs #define	PHY_BMCR_REG			0x00
361c7fd2ed0Sgs #define	PHY_RESET			0x8000
362c7fd2ed0Sgs #define	PHY_LOOPBACK			0x4000
363c7fd2ed0Sgs #define	PHY_SPEED_0			0x2000
364c7fd2ed0Sgs #define	PHY_SPEED_1			0x0040
365c7fd2ed0Sgs #define	PHY_SPEED_BITS			(PHY_SPEED_0 | PHY_SPEED_1)
366c7fd2ed0Sgs #define	PHY_SPEED_1000M			PHY_SPEED_1
367c7fd2ed0Sgs #define	PHY_SPEED_100M			PHY_SPEED_0
368c7fd2ed0Sgs #define	PHY_SPEED_10M			0x0000
369c7fd2ed0Sgs #define	PHY_SPEED_RES			(PHY_SPEED_0 | PHY_SPEED_1)
370c7fd2ed0Sgs #define	PHY_AUTO_NEGO			0x1000
371c7fd2ed0Sgs #define	PHY_RESTART_ANTO_NEGO		0x0200
372c7fd2ed0Sgs #define	PHY_DUPLEX_FULL			0x0100
373c7fd2ed0Sgs #define	PHY_BMCR_CLEAR			0xff40
374c7fd2ed0Sgs 
375c7fd2ed0Sgs /*
376c7fd2ed0Sgs  * Basic mode status register
377c7fd2ed0Sgs  */
378c7fd2ed0Sgs #define	PHY_BMSR_REG			0x01
379c7fd2ed0Sgs #define	PHY_100BASE_T4			0x8000
380c7fd2ed0Sgs #define	PHY_100BASE_TX_FULL		0x4000
381c7fd2ed0Sgs #define	PHY_100BASE_TX_HALF		0x2000
382c7fd2ed0Sgs #define	PHY_10BASE_T_FULL		0x1000
383c7fd2ed0Sgs #define	PHY_10BASE_T_HALF		0x0800
384c7fd2ed0Sgs #define	PHY_100BASE_T2_FULL		0x0400
385c7fd2ed0Sgs #define	PHY_100BASE_T2_HALF		0x0200
386c7fd2ed0Sgs #define	PHY_1000BASE_T_EXT		0x0100
387c7fd2ed0Sgs #define	PHY_AUTO_NEGO_END		0x0020
388c7fd2ed0Sgs #define	PHY_REMOTE_FAULT		0x0010
389c7fd2ed0Sgs #define	PHY_AUTO_NEGO_ABLE		0x0008
390c7fd2ed0Sgs #define	PHY_LINK_UP			0x0004
391c7fd2ed0Sgs #define	PHY_JABBER_DETECT		0x0002
392c7fd2ed0Sgs #define	PHY_EXT_ABLE			0x0001
393c7fd2ed0Sgs 
394c7fd2ed0Sgs /*
395c7fd2ed0Sgs  * PHY identifier register
396c7fd2ed0Sgs  */
397c7fd2ed0Sgs #define	PHY_ID_REG_1			0x02
398c7fd2ed0Sgs #define	PHY_ID_REG_2			0x03
399c7fd2ed0Sgs #define	PHY_VER_MASK			0x000f
400c7fd2ed0Sgs #define	PHY_VER_S			0x0000
401c7fd2ed0Sgs #define	PHY_VER_SB			0x0010
402c7fd2ed0Sgs 
403c7fd2ed0Sgs /*
404c7fd2ed0Sgs  * Auto-negotiation advertising register
405c7fd2ed0Sgs  */
406c7fd2ed0Sgs #define	PHY_ANAR_REG			0x04
407c7fd2ed0Sgs #define	ANAR_NEXT_PAGE			0x8000
408c7fd2ed0Sgs #define	ANAR_REMOTE_FAULT		0x2000
409c7fd2ed0Sgs #define	ANAR_ASY_PAUSE			0x0800
410c7fd2ed0Sgs #define	ANAR_PAUSE			0x0400
411c7fd2ed0Sgs #define	ANAR_100BASE_T4			0x0200
412c7fd2ed0Sgs #define	ANAR_100BASE_TX_FULL		0x0100
413c7fd2ed0Sgs #define	ANAR_100BASE_TX_HALF		0x0080
414c7fd2ed0Sgs #define	ANAR_10BASE_T_FULL		0x0040
415c7fd2ed0Sgs #define	ANAR_10BASE_T_HALF		0x0020
416c7fd2ed0Sgs #define	ANAR_RESV_BITS			0x501f
417c7fd2ed0Sgs 
418c7fd2ed0Sgs /*
419c7fd2ed0Sgs  * Auto-negotiation link partner ability register
420c7fd2ed0Sgs  */
421c7fd2ed0Sgs #define	PHY_ANLPAR_REG			0x05
422c7fd2ed0Sgs 
423c7fd2ed0Sgs /*
424c7fd2ed0Sgs  * Auto-negotiation expansion register
425c7fd2ed0Sgs  */
426c7fd2ed0Sgs #define	PHY_ANER_REG			0x06
427c7fd2ed0Sgs 
428c7fd2ed0Sgs /*
429c7fd2ed0Sgs  * Auto-negotiation next page transmit register
430c7fd2ed0Sgs  */
431c7fd2ed0Sgs #define	PHY_ANNPTR_REG			0x07
432c7fd2ed0Sgs 
433c7fd2ed0Sgs /*
434c7fd2ed0Sgs  * Auto-negotiation next page receive register
435c7fd2ed0Sgs  */
436c7fd2ed0Sgs #define	PHY_ANNPRR_REG			0x08
437c7fd2ed0Sgs 
438c7fd2ed0Sgs /*
439c7fd2ed0Sgs  * 1000Base-T control register
440c7fd2ed0Sgs  */
441c7fd2ed0Sgs #define	PHY_GBCR_REG			0x09
442c7fd2ed0Sgs #define	GBCR_MODE_JITTER		0x2000
443c7fd2ed0Sgs #define	GBCR_MODE_MASTER		0x4000
444c7fd2ed0Sgs #define	GBCR_MODE_SLAVE			0x6000
445c7fd2ed0Sgs #define	GBCR_1000BASE_T_FULL		0x0200
446c7fd2ed0Sgs #define	GBCR_1000BASE_T_HALF		0x0100
447c7fd2ed0Sgs #define	GBCR_DEFAULT			0x273a
448c7fd2ed0Sgs 
449c7fd2ed0Sgs /*
450c7fd2ed0Sgs  * 1000Base-T status register
451c7fd2ed0Sgs  */
452c7fd2ed0Sgs #define	PHY_GBSR_REG			0x0a
453c7fd2ed0Sgs #define	LP_1000BASE_T_FULL		0x0800
454c7fd2ed0Sgs #define	LP_1000BASE_T_HALF		0x0400
455c7fd2ed0Sgs 
456c7fd2ed0Sgs /*
457c7fd2ed0Sgs  * 1000Base-T extended status register
458c7fd2ed0Sgs  */
459c7fd2ed0Sgs #define	PHY_GBESR_REG			0x0f
460c7fd2ed0Sgs 
461c7fd2ed0Sgs #define	PHY_1F_REG			0x1f
46252643194Sgs #define	PHY_1D_REG			0x1d
463aa817493Sgs #define	PHY_1C_REG			0x1c
464c7fd2ed0Sgs #define	PHY_1B_REG			0x1b
465c7fd2ed0Sgs #define	PHY_18_REG			0x18
466aa817493Sgs #define	PHY_15_REG			0x15
46752643194Sgs #define	PHY_13_REG			0x13
468aa817493Sgs #define	PHY_12_REG			0x12
469c7fd2ed0Sgs #define	PHY_0E_REG			0x0e
47052643194Sgs #define	PHY_0C_REG			0x0c
471aa817493Sgs #define	PHY_0B_REG			0x0b
472c7fd2ed0Sgs 
473c7fd2ed0Sgs /*
474c7fd2ed0Sgs  * MII (PHY) registers, beyond those already defined in <sys/miiregs.h>
475c7fd2ed0Sgs  */
476c7fd2ed0Sgs 
477c7fd2ed0Sgs #define	MII_AN_LPNXTPG			8
478c7fd2ed0Sgs #define	MII_1000BASE_T_CONTROL		9
479c7fd2ed0Sgs #define	MII_1000BASE_T_STATUS		10
480c7fd2ed0Sgs #define	MII_IEEE_EXT_STATUS		15
481c7fd2ed0Sgs 
482c7fd2ed0Sgs /*
483c7fd2ed0Sgs  * Bits in the MII_1000BASE_T_CONTROL register
484c7fd2ed0Sgs  *
485c7fd2ed0Sgs  * The MASTER_CFG bit enables manual configuration of Master/Slave mode
486c7fd2ed0Sgs  * (otherwise, roles are automatically negotiated).  When this bit is set,
487c7fd2ed0Sgs  * the MASTER_SEL bit forces Master mode, otherwise Slave mode is forced.
488c7fd2ed0Sgs  */
489c7fd2ed0Sgs #define	MII_1000BT_CTL_MASTER_CFG	0x1000	/* enable role select	*/
490c7fd2ed0Sgs #define	MII_1000BT_CTL_MASTER_SEL	0x0800	/* role select bit	*/
491c7fd2ed0Sgs #define	MII_1000BT_CTL_ADV_FDX		0x0200
492c7fd2ed0Sgs #define	MII_1000BT_CTL_ADV_HDX		0x0100
493c7fd2ed0Sgs 
494c7fd2ed0Sgs /*
495c7fd2ed0Sgs  * Vendor-specific MII registers
496c7fd2ed0Sgs  */
497c7fd2ed0Sgs #define	MII_EXT_CONTROL			MII_VENDOR(0)
498c7fd2ed0Sgs #define	MII_EXT_STATUS			MII_VENDOR(1)
499c7fd2ed0Sgs #define	MII_RCV_ERR_COUNT		MII_VENDOR(2)
500c7fd2ed0Sgs #define	MII_FALSE_CARR_COUNT		MII_VENDOR(3)
501c7fd2ed0Sgs #define	MII_RCV_NOT_OK_COUNT		MII_VENDOR(4)
502c7fd2ed0Sgs #define	MII_AUX_CONTROL			MII_VENDOR(8)
503c7fd2ed0Sgs #define	MII_AUX_STATUS			MII_VENDOR(9)
504c7fd2ed0Sgs #define	MII_INTR_STATUS			MII_VENDOR(10)
505c7fd2ed0Sgs #define	MII_INTR_MASK			MII_VENDOR(11)
506c7fd2ed0Sgs #define	MII_HCD_STATUS			MII_VENDOR(13)
507c7fd2ed0Sgs 
508c7fd2ed0Sgs #define	MII_MAXREG			MII_VENDOR(15)	/* 31, 0x1f	*/
509c7fd2ed0Sgs 
510c7fd2ed0Sgs /*
511c7fd2ed0Sgs  * Bits in the MII_AUX_STATUS register
512c7fd2ed0Sgs  */
513c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_MASK	0x0700
514c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_1000_F	0x0700
515c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_1000_H	0x0600
516c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_100_F	0x0500
517c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_100_4	0x0400
518c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_100_H	0x0300
519c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_10_F	0x0200
520c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_10_H	0x0100
521c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_NONE	0x0000
522c7fd2ed0Sgs #define	MII_AUX_STATUS_MODE_SHIFT	8
523c7fd2ed0Sgs 
524c7fd2ed0Sgs #define	MII_AUX_STATUS_PAR_FAULT	0x0080
525c7fd2ed0Sgs #define	MII_AUX_STATUS_REM_FAULT	0x0040
526c7fd2ed0Sgs #define	MII_AUX_STATUS_LP_ANEG_ABLE	0x0010
527c7fd2ed0Sgs #define	MII_AUX_STATUS_LP_NP_ABLE	0x0008
528c7fd2ed0Sgs 
529c7fd2ed0Sgs #define	MII_AUX_STATUS_LINKUP		0x0004
530c7fd2ed0Sgs #define	MII_AUX_STATUS_RX_PAUSE		0x0002
531c7fd2ed0Sgs #define	MII_AUX_STATUS_TX_PAUSE		0x0001
532c7fd2ed0Sgs 
533c7fd2ed0Sgs /*
534c7fd2ed0Sgs  * Third section:
535c7fd2ed0Sgs  * 	Hardware-defined data structures
536c7fd2ed0Sgs  *
537c7fd2ed0Sgs  * Note that the chip is naturally little-endian, so, for a little-endian
538c7fd2ed0Sgs  * host, the structures defined below match those descibed in the PRM.
539c7fd2ed0Sgs  * For big-endian hosts, some structures have to be swapped around.
540c7fd2ed0Sgs  */
541c7fd2ed0Sgs 
542c7fd2ed0Sgs #if	!defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
543c7fd2ed0Sgs #error	Host endianness not defined
544c7fd2ed0Sgs #endif
545c7fd2ed0Sgs 
546c7fd2ed0Sgs /*
547c7fd2ed0Sgs  * Architectural constants: absolute maximum numbers of each type of ring
548c7fd2ed0Sgs  */
549c7fd2ed0Sgs 
550c7fd2ed0Sgs #define	RGE_SEND_SLOTS			1024
551c7fd2ed0Sgs #define	RGE_RECV_SLOTS			1024
552c7fd2ed0Sgs #define	RGE_BUFF_SIZE_STD		1536	/* 1536 bytes */
553c7fd2ed0Sgs #define	RGE_BUFF_SIZE_JUMBO		7168	/* maximum 7K */
554c7fd2ed0Sgs #define	RGE_JUMBO_SIZE			7014
555aa817493Sgs #define	RGE_JUMBO_MTU			7000
556c7fd2ed0Sgs #define	RGE_STATS_DUMP_SIZE		64
557c7fd2ed0Sgs 
558c7fd2ed0Sgs typedef struct rge_bd {
559c7fd2ed0Sgs 	volatile uint32_t	flags_len;
560c7fd2ed0Sgs 	volatile uint32_t	vlan_tag;
561c7fd2ed0Sgs 	volatile uint32_t	host_buf_addr;
562c7fd2ed0Sgs 	volatile uint32_t	host_buf_addr_hi;
563c7fd2ed0Sgs } rge_bd_t;
564c7fd2ed0Sgs 
565c7fd2ed0Sgs #define	BD_FLAG_HW_OWN			0x80000000
566c7fd2ed0Sgs #define	BD_FLAG_EOR			0x40000000
567c7fd2ed0Sgs #define	BD_FLAG_PKT_START		0x20000000
568c7fd2ed0Sgs #define	BD_FLAG_PKT_END			0x10000000
569c7fd2ed0Sgs 
570c7fd2ed0Sgs #define	RBD_FLAG_MULTICAST		0x08000000
571c7fd2ed0Sgs #define	RBD_FLAG_UNICAST		0x04000000
572c7fd2ed0Sgs #define	RBD_FLAG_BROADCAST		0x02000000
573c7fd2ed0Sgs #define	RBD_FLAG_PKT_4096		0x00400000
574c7fd2ed0Sgs #define	RBD_FLAG_ERROR			0x00200000
575c7fd2ed0Sgs #define	RBD_FLAG_RUNT			0x00100000
576c7fd2ed0Sgs #define	RBD_FLAG_CRC_ERR		0x00080000
577c7fd2ed0Sgs #define	RBD_FLAG_PROTOCOL		0x00060000
578c7fd2ed0Sgs #define	RBD_FLAG_IP			0x00060000
579c7fd2ed0Sgs #define	RBD_FLAG_UDP			0x00040000
580c7fd2ed0Sgs #define	RBD_FLAG_TCP			0x00020000
581c7fd2ed0Sgs #define	RBD_FLAG_NONE_IP		0x00000000
582c7fd2ed0Sgs #define	RBD_IP_CKSUM_ERR		0x00010000
583c7fd2ed0Sgs #define	RBD_UDP_CKSUM_ERR		0x00008000
584c7fd2ed0Sgs #define	RBD_TCP_CKSUM_ERR		0x00004000
585c7fd2ed0Sgs #define	RBD_CKSUM_ERR			0x0001c000
586c7fd2ed0Sgs #define	RBD_FLAGS_MASK			0xffffc000
587c7fd2ed0Sgs #define	RBD_LEN_MASK			0x00003fff
588c7fd2ed0Sgs 
589c7fd2ed0Sgs #define	RBD_VLAN_PKT			0x00010000
590c7fd2ed0Sgs #define	RBD_VLAN_TAG			0x0000ffff
591c7fd2ed0Sgs 
592c7fd2ed0Sgs 
593c7fd2ed0Sgs #define	SBD_FLAG_LARGE_SEND		0x08000000
594c7fd2ed0Sgs #define	SBD_FLAG_SEG_MAX		0x07ff0000
595c7fd2ed0Sgs #define	SBD_FLAG_IP_CKSUM		0x00040000
596c7fd2ed0Sgs #define	SBD_FLAG_UDP_CKSUM		0x00020000
597c7fd2ed0Sgs #define	SBD_FLAG_TCP_CKSUM		0x00010000
598c7fd2ed0Sgs #define	SBD_FLAG_TCP_UDP_CKSUM		0x00030000
599c7fd2ed0Sgs #define	SBD_LEN_MASK			0x0000ffff
600c7fd2ed0Sgs 
601c7fd2ed0Sgs #define	SBD_VLAN_PKT			0x00020000
602c7fd2ed0Sgs #define	SBD_VLAN_TAG			0x0000ffff
603c7fd2ed0Sgs 
604c7fd2ed0Sgs #define	SBD_FLAG_TX_PKT			(BD_FLAG_HW_OWN | BD_FLAG_PKT_START | \
605c7fd2ed0Sgs 					    BD_FLAG_PKT_END)
606c7fd2ed0Sgs 
607c7fd2ed0Sgs /*
608c7fd2ed0Sgs  * Chip VLAN TCI format
609c7fd2ed0Sgs  *	bit0-3: VIDH The high 4 bits of a 12-bit VLAN ID
610c7fd2ed0Sgs  *	bit4: CFI Canonical format indicator
611c7fd2ed0Sgs  *	bit5-7: 3-bit 8-level priority
612c7fd2ed0Sgs  *	bit8-15: The low 8 bits of a 12-bit VLAN ID
613c7fd2ed0Sgs  */
614c7fd2ed0Sgs #define	TCI_OS2CHIP(tci)		(((tci & 0xff) << 8) | (tci >> 8))
615c7fd2ed0Sgs #define	TCI_CHIP2OS(tci)		(((tci & 0xff00) >> 8) | (tci << 8))
616c7fd2ed0Sgs 
617c7fd2ed0Sgs /*
618c7fd2ed0Sgs  * Hardware-defined Status Block
619c7fd2ed0Sgs  */
620c7fd2ed0Sgs typedef struct rge_hw_stats {
621c7fd2ed0Sgs 	uint64_t	xmt_ok;
622c7fd2ed0Sgs 	uint64_t	rcv_ok;
623c7fd2ed0Sgs 	uint64_t	xmt_err;
624c7fd2ed0Sgs 	uint32_t	rcv_err;
625c7fd2ed0Sgs 	uint16_t	in_discards;
626c7fd2ed0Sgs 	uint16_t	frame_err;
627c7fd2ed0Sgs 	uint32_t	xmt_1col;
628c7fd2ed0Sgs 	uint32_t	xmt_mcol;
629c7fd2ed0Sgs 	uint64_t	unicast_rcv;
630c7fd2ed0Sgs 	uint64_t	brdcst_rcv;
631c7fd2ed0Sgs 	uint32_t	multi_rcv;
632c7fd2ed0Sgs 	uint16_t	xmt_abt;
633c7fd2ed0Sgs 	uint16_t	xmt_undrn;
634c7fd2ed0Sgs } rge_hw_stats_t;	/* total 64 bytes */
635c7fd2ed0Sgs 
636c7fd2ed0Sgs #ifdef __cplusplus
637c7fd2ed0Sgs }
638c7fd2ed0Sgs #endif
639c7fd2ed0Sgs 
640c7fd2ed0Sgs #endif	/* _RGE_HW_H */
641