xref: /titanic_52/usr/src/uts/common/io/rtls/rtls.h (revision 2c6a6ad1e812de6043502f2f52d21711033ab43e)
1cde2885fSGarrett D'Amore /*
2cde2885fSGarrett D'Amore  * CDDL HEADER START
3cde2885fSGarrett D'Amore  *
4cde2885fSGarrett D'Amore  * The contents of this file are subject to the terms of the
5cde2885fSGarrett D'Amore  * Common Development and Distribution License (the "License").
6cde2885fSGarrett D'Amore  * You may not use this file except in compliance with the License.
7cde2885fSGarrett D'Amore  *
8cde2885fSGarrett D'Amore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9cde2885fSGarrett D'Amore  * or http://www.opensolaris.org/os/licensing.
10cde2885fSGarrett D'Amore  * See the License for the specific language governing permissions
11cde2885fSGarrett D'Amore  * and limitations under the License.
12cde2885fSGarrett D'Amore  *
13cde2885fSGarrett D'Amore  * When distributing Covered Code, include this CDDL HEADER in each
14cde2885fSGarrett D'Amore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15cde2885fSGarrett D'Amore  * If applicable, add the following below this CDDL HEADER, with the
16cde2885fSGarrett D'Amore  * fields enclosed by brackets "[]" replaced with your own identifying
17cde2885fSGarrett D'Amore  * information: Portions Copyright [yyyy] [name of copyright owner]
18cde2885fSGarrett D'Amore  *
19cde2885fSGarrett D'Amore  * CDDL HEADER END
20cde2885fSGarrett D'Amore  */
21cde2885fSGarrett D'Amore 
22cde2885fSGarrett D'Amore /*
23bbb1277bSGarrett D'Amore  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24cde2885fSGarrett D'Amore  * Use is subject to license terms.
25cde2885fSGarrett D'Amore  */
26cde2885fSGarrett D'Amore 
27cde2885fSGarrett D'Amore /*
28*2c6a6ad1SIlya Yanok  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
29*2c6a6ad1SIlya Yanok  */
30*2c6a6ad1SIlya Yanok 
31*2c6a6ad1SIlya Yanok /*
32cde2885fSGarrett D'Amore  * rtls -- REALTEK 8139-serials PCI Fast Ethernet Driver.
33cde2885fSGarrett D'Amore  *
34cde2885fSGarrett D'Amore  * This product is covered by one or more of the following patents:
35cde2885fSGarrett D'Amore  * US5,307,459, US5,434,872, US5,732,094, US6,570,884, US6,115,776, and
36cde2885fSGarrett D'Amore  * US6,327,625.
37cde2885fSGarrett D'Amore  *
38cde2885fSGarrett D'Amore  * Currently supports:
39cde2885fSGarrett D'Amore  *	RTL8139
40cde2885fSGarrett D'Amore  */
41cde2885fSGarrett D'Amore 
42cde2885fSGarrett D'Amore 
43cde2885fSGarrett D'Amore #ifndef _SYS_RTLS_H
44cde2885fSGarrett D'Amore #define	_SYS_RTLS_H
45cde2885fSGarrett D'Amore 
46cde2885fSGarrett D'Amore #ifdef __cplusplus
47cde2885fSGarrett D'Amore extern "C" {
48cde2885fSGarrett D'Amore #endif
49cde2885fSGarrett D'Amore 
50cde2885fSGarrett D'Amore /* Debug flags */
51cde2885fSGarrett D'Amore #define	RTLS_TRACE		0x01
52cde2885fSGarrett D'Amore #define	RTLS_ERRS		0x02
53cde2885fSGarrett D'Amore #define	RTLS_RECV		0x04
54cde2885fSGarrett D'Amore #define	RTLS_DDI		0x08
55cde2885fSGarrett D'Amore #define	RTLS_SEND		0x10
56cde2885fSGarrett D'Amore #define	RTLS_INT		0x20
57cde2885fSGarrett D'Amore #define	RTLS_SENSE		0x40
58cde2885fSGarrett D'Amore #define	RTLS_REGCFG		0x80
59cde2885fSGarrett D'Amore 
60cde2885fSGarrett D'Amore #ifdef DEBUG
61cde2885fSGarrett D'Amore #define	RTLS_DEBUG		1
62cde2885fSGarrett D'Amore #endif
63cde2885fSGarrett D'Amore 
64cde2885fSGarrett D'Amore /*
65cde2885fSGarrett D'Amore  * Driver support device
66cde2885fSGarrett D'Amore  */
67cde2885fSGarrett D'Amore #define	RT_VENDOR_ID		0x10EC	/* RealTek */
68cde2885fSGarrett D'Amore #define	RT_DEVICE_8139		0x8139
69cde2885fSGarrett D'Amore #define	RTLS_SUPPORT_DEVICE_1	((RT_VENDOR_ID << 16) | RT_DEVICE_8139)
70cde2885fSGarrett D'Amore 	/* bind vendor and device id together */
71cde2885fSGarrett D'Amore 
72cde2885fSGarrett D'Amore #define	RTLS_VENDOR_ID_2	0x1186	/* D-link */
73cde2885fSGarrett D'Amore #define	RTLS_DEVICE_ID_2	0x1301
74cde2885fSGarrett D'Amore #define	RTLS_SUPPORT_DEVICE_2	((RTLS_VENDOR_ID_2 << 16) | RTLS_DEVICE_ID_2)
75cde2885fSGarrett D'Amore 
76cde2885fSGarrett D'Amore #define	RTLS_VENDOR_ID_3	0x1113	/* Accton */
77cde2885fSGarrett D'Amore #define	RTLS_DEVICE_ID_3	0x1211
78cde2885fSGarrett D'Amore #define	RTLS_SUPPORT_DEVICE_3	((RTLS_VENDOR_ID_3 << 16) | RTLS_DEVICE_ID_3)
79cde2885fSGarrett D'Amore 
80bbb1277bSGarrett D'Amore #define	RTLS_VENDOR_ID_4	0x1186	/* D-link */
81bbb1277bSGarrett D'Amore #define	RTLS_DEVICE_ID_4	0x1300
82bbb1277bSGarrett D'Amore #define	RTLS_SUPPORT_DEVICE_4	((RTLS_VENDOR_ID_4 << 16) | RTLS_DEVICE_ID_4)
83bbb1277bSGarrett D'Amore 
84cde2885fSGarrett D'Amore /*
85cde2885fSGarrett D'Amore  * Driver tx/rx parameters
86cde2885fSGarrett D'Amore  */
87cde2885fSGarrett D'Amore #define	RTLS_MAX_TX_DESC	4
88cde2885fSGarrett D'Amore #define	RTLS_TX_BUF_COUNT	8
89cde2885fSGarrett D'Amore #define	RTLS_TX_BUF_SIZE	2048
90cde2885fSGarrett D'Amore #define	RTLS_RX_BUF_RING	(32*1024)	/* 32K */
91cde2885fSGarrett D'Amore #define	RTLS_RX_BUF_SIZE	(RTLS_RX_BUF_RING + 2*1024)
92cde2885fSGarrett D'Amore #define	RTLS_MCAST_BUF_SIZE	64	/* multicast hash table size in bits */
93cde2885fSGarrett D'Amore 
94cde2885fSGarrett D'Amore /*
95cde2885fSGarrett D'Amore  * RTL8139 CRC poly
96cde2885fSGarrett D'Amore  */
97cde2885fSGarrett D'Amore #define	RTLS_HASH_POLY		0x04C11DB7	/* 0x04C11DB6 */
98cde2885fSGarrett D'Amore #define	RTLS_HASH_CRC		0xFFFFFFFFU
99cde2885fSGarrett D'Amore 
100cde2885fSGarrett D'Amore /*
101cde2885fSGarrett D'Amore  * STREAMS parameters
102cde2885fSGarrett D'Amore  */
103cde2885fSGarrett D'Amore #define	RTLS_HIWAT		(RTLS_MAX_TX_DESC * ETHERMAX)
104cde2885fSGarrett D'Amore 					/* driver flow control high water */
105cde2885fSGarrett D'Amore #define	RTLS_LOWAT		1	/* driver flow control low water */
106cde2885fSGarrett D'Amore #define	RTLS_IDNUM		0	/* RTL Id; zero works */
107cde2885fSGarrett D'Amore 
108cde2885fSGarrett D'Amore /*
109cde2885fSGarrett D'Amore  * Helpful defines for register access
110cde2885fSGarrett D'Amore  */
111cde2885fSGarrett D'Amore #define	REG32(reg, off)		((uint32_t *)((uintptr_t)(reg) + off))
112cde2885fSGarrett D'Amore #define	REG16(reg, off)		((uint16_t *)((uintptr_t)(reg) + off))
113cde2885fSGarrett D'Amore #define	REG8(reg, off)		((uint8_t *)((uintptr_t)(reg) + off))
114cde2885fSGarrett D'Amore 
115cde2885fSGarrett D'Amore typedef struct {
116cde2885fSGarrett D'Amore 	ddi_acc_handle_t	acc_hdl;	/* handle for memory */
117cde2885fSGarrett D'Amore 	void			*mem_va;	/* CPU VA of memory */
118cde2885fSGarrett D'Amore 	size_t			alength;	/* allocated size */
119cde2885fSGarrett D'Amore 	ddi_dma_handle_t	dma_hdl;	/* DMA handle */
120cde2885fSGarrett D'Amore 	ddi_dma_cookie_t	cookie;		/* associated cookie */
121cde2885fSGarrett D'Amore 	uint32_t		ncookies;	/* must be 1 */
122cde2885fSGarrett D'Amore } dma_area_t;
123cde2885fSGarrett D'Amore 
124cde2885fSGarrett D'Amore typedef struct rtls_stats {
125cde2885fSGarrett D'Amore 	uint64_t	ipackets;
126cde2885fSGarrett D'Amore 	uint64_t	multi_rcv;	/* ifInMulticastPkts */
127cde2885fSGarrett D'Amore 	uint64_t	brdcst_rcv;	/* ifInBroadcastPkts */
128cde2885fSGarrett D'Amore 	uint64_t	rbytes;
129cde2885fSGarrett D'Amore 	uint64_t	opackets;
130cde2885fSGarrett D'Amore 	uint64_t	multi_xmt;
131cde2885fSGarrett D'Amore 	uint64_t	brdcst_xmt;
132cde2885fSGarrett D'Amore 	uint64_t	obytes;
133cde2885fSGarrett D'Amore 	uint32_t	collisions;
134cde2885fSGarrett D'Amore 	uint32_t	firstcol;
135cde2885fSGarrett D'Amore 	uint32_t	multicol;
136cde2885fSGarrett D'Amore 	uint32_t	rcv_err;	/* ifInErrors */
137cde2885fSGarrett D'Amore 	uint32_t	xmt_err;	/* ifOutErrors */
138cde2885fSGarrett D'Amore 	uint32_t	mac_rcv_err;
139cde2885fSGarrett D'Amore 	uint32_t	mac_xmt_err;
140cde2885fSGarrett D'Amore 	uint32_t	overflow;
141cde2885fSGarrett D'Amore 	uint32_t	underflow;
142cde2885fSGarrett D'Amore 	uint32_t	no_carrier;	/* dot3StatsCarrierSenseErrors */
143cde2885fSGarrett D'Amore 	uint32_t	xmt_latecoll;	/* dot3StatsLateCollisions */
144cde2885fSGarrett D'Amore 	uint32_t	defer;		/* dot3StatsDeferredTransmissions */
145cde2885fSGarrett D'Amore 	uint32_t	frame_err;	/* dot3StatsAlignErrors */
146cde2885fSGarrett D'Amore 	uint32_t	crc_err;	/* dot3StatsFCSErrors */
147cde2885fSGarrett D'Amore 	uint32_t	in_short;
148cde2885fSGarrett D'Amore 	uint32_t	too_long;
149cde2885fSGarrett D'Amore 	uint32_t	no_rcvbuf;	/* ifInDiscards */
150cde2885fSGarrett D'Amore } rtls_stats_t;
151cde2885fSGarrett D'Amore 
152cde2885fSGarrett D'Amore typedef struct rtls_instance {
153cde2885fSGarrett D'Amore 	mac_handle_t	mh;
154bbb1277bSGarrett D'Amore 	mii_handle_t	mii;
155cde2885fSGarrett D'Amore 	dev_info_t	*devinfo;	/* device instance */
156cde2885fSGarrett D'Amore 	int32_t		instance;
157cde2885fSGarrett D'Amore 
158cde2885fSGarrett D'Amore 	caddr_t		io_reg;		/* mapped chip register address */
159cde2885fSGarrett D'Amore 
160cde2885fSGarrett D'Amore 
161cde2885fSGarrett D'Amore 	/* io handle & iblock */
162cde2885fSGarrett D'Amore 	ddi_acc_handle_t	io_handle;	/* ddi I/O handle */
163cde2885fSGarrett D'Amore 	ddi_iblock_cookie_t	iblk;
164cde2885fSGarrett D'Amore 
165cde2885fSGarrett D'Amore 	/* dma buffer alloc used */
166cde2885fSGarrett D'Amore 	dma_area_t		dma_area_rx;	/* receive dma area */
167cde2885fSGarrett D'Amore 	dma_area_t		dma_area_tx[RTLS_MAX_TX_DESC];
168cde2885fSGarrett D'Amore 						/* transmit dma area */
169cde2885fSGarrett D'Amore 
170cde2885fSGarrett D'Amore 	uint8_t		netaddr[ETHERADDRL];	/* mac address */
171cde2885fSGarrett D'Amore 	uint16_t	int_mask;		/* interrupt mask */
172cde2885fSGarrett D'Amore 
173cde2885fSGarrett D'Amore 	/* used for multicast set */
174cde2885fSGarrett D'Amore 	char		multicast_cnt[RTLS_MCAST_BUF_SIZE];
175cde2885fSGarrett D'Amore 	uint32_t	multi_hash[2];
176cde2885fSGarrett D'Amore 
177cde2885fSGarrett D'Amore 	boolean_t	promisc;		/* promisc state flag */
178cde2885fSGarrett D'Amore 
179cde2885fSGarrett D'Amore 	/* used for send */
180cde2885fSGarrett D'Amore 	uint8_t		*tx_buf[RTLS_MAX_TX_DESC];
181cde2885fSGarrett D'Amore 	uint16_t	tx_current_desc;	/* Current Tx page */
182cde2885fSGarrett D'Amore 	uint16_t	tx_first_loop;
183cde2885fSGarrett D'Amore 
184cde2885fSGarrett D'Amore 	uint32_t	tx_retry;
185cde2885fSGarrett D'Amore 
186cde2885fSGarrett D'Amore 	/* used for recv */
187cde2885fSGarrett D'Amore 	uint8_t		*rx_ring;
188cde2885fSGarrett D'Amore 	uint32_t	cur_rx;
189cde2885fSGarrett D'Amore 
190cde2885fSGarrett D'Amore 	/* mutex */
191cde2885fSGarrett D'Amore 	kmutex_t	rtls_io_lock;	/* i/o reg access */
192cde2885fSGarrett D'Amore 	kmutex_t	rtls_tx_lock;	/* send access */
193cde2885fSGarrett D'Amore 	kmutex_t	rtls_rx_lock;	/* receive access */
194cde2885fSGarrett D'Amore 
195cde2885fSGarrett D'Amore 	/* send reschedule used */
196cde2885fSGarrett D'Amore 	boolean_t	need_sched;
197cde2885fSGarrett D'Amore 
198cde2885fSGarrett D'Amore 	boolean_t	chip_error;	/* chip error flag */
199cde2885fSGarrett D'Amore 
200cde2885fSGarrett D'Amore 	/* current MAC state */
201cde2885fSGarrett D'Amore 	boolean_t	rtls_running;
202cde2885fSGarrett D'Amore 	boolean_t	rtls_suspended;
203cde2885fSGarrett D'Amore 
204cde2885fSGarrett D'Amore 	/* rtls statistics */
205cde2885fSGarrett D'Amore 	rtls_stats_t	stats;
206cde2885fSGarrett D'Amore } rtls_t;
207cde2885fSGarrett D'Amore 
208cde2885fSGarrett D'Amore #define	RTLS_TX_RETRY_NUM	16
209cde2885fSGarrett D'Amore #define	RTLS_TX_WAIT_TIMEOUT	(void) (drv_usectohz(100 * 1000)) /* 100ms */
210cde2885fSGarrett D'Amore #define	RTLS_RESET_WAIT_NUM	0x100
211cde2885fSGarrett D'Amore #define	RTLS_RESET_WAIT_INTERVAL	(void) (drv_usecwait(100))
212cde2885fSGarrett D'Amore #define	RTLS_RX_ADDR_ALIGNED(addr)	(((addr + 3) & ~3) % RTLS_RX_BUF_RING)
213cde2885fSGarrett D'Amore 		/* 4-bytes aligned, also with RTLS_RX_BUF_RING boundary */
214cde2885fSGarrett D'Amore 
215cde2885fSGarrett D'Amore /* parameter definition in rtls.conf file */
216cde2885fSGarrett D'Amore #define	FOECE_NONE		0	/* no force */
217cde2885fSGarrett D'Amore #define	FORCE_AUTO_NEGO		5	/* auto negotioation mode */
218cde2885fSGarrett D'Amore #define	FORCE_100_FDX		4	/* 100 full_duplex mode */
219cde2885fSGarrett D'Amore #define	FORCE_100_HDX		3	/* 100 half_duplex mode */
220cde2885fSGarrett D'Amore #define	FORCE_10_FDX		2	/* 10 full_duplex mode */
221cde2885fSGarrett D'Amore #define	FORCE_10_HDX		1	/* 10 half_duplex mode */
222cde2885fSGarrett D'Amore 
223cde2885fSGarrett D'Amore /*
224cde2885fSGarrett D'Amore  * RealTek 8129/8139 register offsets definition
225cde2885fSGarrett D'Amore  */
226cde2885fSGarrett D'Amore 
227cde2885fSGarrett D'Amore /*
228cde2885fSGarrett D'Amore  * MAC address register, initial value isautoloaded from the
229cde2885fSGarrett D'Amore  * EEPROM EthernetID field
230cde2885fSGarrett D'Amore  */
231cde2885fSGarrett D'Amore #define	ID_0_REG	0x0000
232cde2885fSGarrett D'Amore #define	ID_1_REG	0x0001
233cde2885fSGarrett D'Amore #define	ID_2_REG	0x0002
234cde2885fSGarrett D'Amore #define	ID_3_REG	0x0003
235cde2885fSGarrett D'Amore #define	ID_4_REG	0x0004
236cde2885fSGarrett D'Amore #define	ID_5_REG	0x0005
237cde2885fSGarrett D'Amore 
238cde2885fSGarrett D'Amore /*
239cde2885fSGarrett D'Amore  * Multicast register
240cde2885fSGarrett D'Amore  */
241cde2885fSGarrett D'Amore #define	MULTICAST_0_REG 	0x0008
242cde2885fSGarrett D'Amore #define	MULTICAST_1_REG 	0x0009
243cde2885fSGarrett D'Amore #define	MULTICAST_2_REG		0x000a
244cde2885fSGarrett D'Amore #define	MULTICAST_3_REG		0x000b
245cde2885fSGarrett D'Amore #define	MULTICAST_4_REG		0x000c
246cde2885fSGarrett D'Amore #define	MULTICAST_5_REG		0x000d
247cde2885fSGarrett D'Amore #define	MULTICAST_6_REG		0x000e
248cde2885fSGarrett D'Amore #define	MULTICAST_7_REG		0x000f
249cde2885fSGarrett D'Amore 
250cde2885fSGarrett D'Amore #define	RCV_ALL_MULTI_PACKETS	0xffffffff
251cde2885fSGarrett D'Amore 
252cde2885fSGarrett D'Amore /*
253cde2885fSGarrett D'Amore  * Transmit status register
254cde2885fSGarrett D'Amore  */
255cde2885fSGarrett D'Amore #define	TX_STATUS_DESC0_REG	0x0010
256cde2885fSGarrett D'Amore #define	TX_STATUS_DESC1_REG	0x0014
257cde2885fSGarrett D'Amore #define	TX_STATUS_DESC2_REG	0x0018
258cde2885fSGarrett D'Amore #define	TX_STATUS_DESC3_REG	0x001c
259cde2885fSGarrett D'Amore #define	TX_STATUS_CS_LOST	0x80000000	/* Carrier Sense Lost */
260cde2885fSGarrett D'Amore #define	TX_STATUS_TX_ABORT	0x40000000	/* Transmit Abort */
261cde2885fSGarrett D'Amore #define	TX_STATUS_OWC		0x20000000	/* Out of Window Collision */
262cde2885fSGarrett D'Amore #define	TX_STATUS_CDH		0x10000000	/* CD Heart Beat */
263cde2885fSGarrett D'Amore #define	TX_STATUS_NCC		0x0f000000	/* Number of Collision Count */
264cde2885fSGarrett D'Amore #define	TX_STATUS_NCC_SHIFT	24
265cde2885fSGarrett D'Amore #define	TX_STATUS_TX_THRESHOLD	0x003f0000	/* Early Tx Threshold */
266cde2885fSGarrett D'Amore #define	TX_STATUS_TX_THRESHOLD_SHIFT	16
267cde2885fSGarrett D'Amore #define	TX_STATUS_TX_THRESHOLD_MAX	0x3f	/* 0x3f * 32 Bytes */
268cde2885fSGarrett D'Amore #define	TX_STATUS_TX_OK		0x00008000	/* Transmit OK */
269cde2885fSGarrett D'Amore #define	TX_STATUS_TX_UNDERRUN	0x00004000	/* Transmit FIFO Underrun */
270cde2885fSGarrett D'Amore #define	TX_STATUS_OWN		0x00002000	/* RTL8139 Own bit */
271cde2885fSGarrett D'Amore #define	TX_STATUS_PACKET_SIZE	0x00001fff
272cde2885fSGarrett D'Amore 	/* The total size in bytes of the data in this descriptor */
273cde2885fSGarrett D'Amore 
274cde2885fSGarrett D'Amore /*
275cde2885fSGarrett D'Amore  * The read-only bits (CRS, TABT, OWC, CDH, NCC3-0, TOK, TUN) will be cleared
276cde2885fSGarrett D'Amore  * by the RTL8139 when the Transmit Byte Count (bit12-0) in the corresponding
277cde2885fSGarrett D'Amore  * Tx descriptor is written. If h/w transmit finish, at least some of these
278cde2885fSGarrett D'Amore  * bits are none zero.
279cde2885fSGarrett D'Amore  */
280cde2885fSGarrett D'Amore #define	TX_COMPLETE_FLAG	(TX_STATUS_TX_ABORT | TX_STATUS_TX_OK | \
281cde2885fSGarrett D'Amore 				    TX_STATUS_TX_UNDERRUN)
282cde2885fSGarrett D'Amore #define	TX_ERR_FLAG		(TX_STATUS_TX_ABORT | TX_STATUS_TX_UNDERRUN | \
283cde2885fSGarrett D'Amore 				    TX_STATUS_CS_LOST | TX_STATUS_OWC)
284cde2885fSGarrett D'Amore 
285cde2885fSGarrett D'Amore /*
286cde2885fSGarrett D'Amore  * Transmit start address of descriptors
287cde2885fSGarrett D'Amore  */
288cde2885fSGarrett D'Amore #define	TX_ADDR_DESC0_REG	0x0020
289cde2885fSGarrett D'Amore #define	TX_ADDR_DESC1_REG	0x0024
290cde2885fSGarrett D'Amore #define	TX_ADDR_DESC2_REG	0x0028
291cde2885fSGarrett D'Amore #define	TX_ADDR_DESC3_REG	0x002c
292cde2885fSGarrett D'Amore 
293cde2885fSGarrett D'Amore /*
294cde2885fSGarrett D'Amore  * Receive buffer start address
295cde2885fSGarrett D'Amore  */
296cde2885fSGarrett D'Amore #define	RX_BUFF_ADDR_REG	0x0030
297cde2885fSGarrett D'Amore 
298cde2885fSGarrett D'Amore /*
299cde2885fSGarrett D'Amore  * Early receive byte count register
300cde2885fSGarrett D'Amore  */
301cde2885fSGarrett D'Amore #define	RX_STATUS_REG		0x0036
302cde2885fSGarrett D'Amore #define	RX_STATUS_GOOD		0x08
303cde2885fSGarrett D'Amore #define	RX_STARUS_BAD		0x04
304cde2885fSGarrett D'Amore #define	RX_STATUS_COVERWRITE	0x02
305cde2885fSGarrett D'Amore #define	RX_STATUS_OK		0x01
306cde2885fSGarrett D'Amore 
307cde2885fSGarrett D'Amore /*
308cde2885fSGarrett D'Amore  * Commond register
309cde2885fSGarrett D'Amore  */
310cde2885fSGarrett D'Amore #define	RT_COMMAND_REG		0x0037
311cde2885fSGarrett D'Amore #define	RT_COMMAND_REG_RESERVE	0xe0
312cde2885fSGarrett D'Amore #define	RT_COMMAND_RESET	0x10
313cde2885fSGarrett D'Amore #define	RT_COMMAND_RX_ENABLE	0x08
314cde2885fSGarrett D'Amore #define	RT_COMMAND_TX_ENABLE	0x04
315cde2885fSGarrett D'Amore #define	RT_COMMAND_BUFF_EMPTY	0x01
316cde2885fSGarrett D'Amore 
317cde2885fSGarrett D'Amore /*
318cde2885fSGarrett D'Amore  * Rx current read address register
319cde2885fSGarrett D'Amore  */
320cde2885fSGarrett D'Amore #define	RX_CURRENT_READ_ADDR_REG	0x0038
321cde2885fSGarrett D'Amore #define	RX_READ_RESET_VAL		0xfff0
322cde2885fSGarrett D'Amore /*
323cde2885fSGarrett D'Amore  * Value in RX_CURRENT_READ_ADDR_REG is 16 less than
324cde2885fSGarrett D'Amore  * the actual rx read address
325cde2885fSGarrett D'Amore  */
326cde2885fSGarrett D'Amore #define	READ_ADDR_GAP			16
327cde2885fSGarrett D'Amore 
328cde2885fSGarrett D'Amore #define	RX_CURRENT_BUFF_ADDR_REG	0x003a
329cde2885fSGarrett D'Amore 
330cde2885fSGarrett D'Amore /*
331cde2885fSGarrett D'Amore  * Interrupt register
332cde2885fSGarrett D'Amore  */
333cde2885fSGarrett D'Amore #define	RT_INT_MASK_REG		0x003c
334cde2885fSGarrett D'Amore #define	RT_INT_STATUS_REG	0x003e
335cde2885fSGarrett D'Amore #define	RT_INT_STATUS_INTS	0xe07f
336cde2885fSGarrett D'Amore #define	SYS_ERR_INT		0x8000
337cde2885fSGarrett D'Amore #define	TIME_OUT_INT		0x4000
338cde2885fSGarrett D'Amore #define	CABLE_LEN_CHANGE_INT	0x2000
339cde2885fSGarrett D'Amore #define	RX_FIFO_OVERFLOW_INT	0x0040
340cde2885fSGarrett D'Amore #define	LINK_CHANGE_INT		0x0020
341cde2885fSGarrett D'Amore #define	RX_BUF_OVERFLOW_INT	0x0010
342cde2885fSGarrett D'Amore #define	TX_ERR_INT		0x0008
343cde2885fSGarrett D'Amore #define	TX_OK_INT		0x0004
344cde2885fSGarrett D'Amore #define	RX_ERR_INT		0x0002
345cde2885fSGarrett D'Amore #define	RX_OK_INT		0x0001
346cde2885fSGarrett D'Amore 
347cde2885fSGarrett D'Amore #define	RTLS_INT_MASK_ALL	0xe07f
348cde2885fSGarrett D'Amore #define	RTLS_INT_MASK_NONE	0x0000
349cde2885fSGarrett D'Amore #define	RTLS_RX_INT	(RX_OK_INT | RX_ERR_INT | \
350cde2885fSGarrett D'Amore 			    RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT)
351cde2885fSGarrett D'Amore #define	RX_OVERFLOW_INT	(RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT)
352cde2885fSGarrett D'Amore #define	RTLS_INT_MASK	(LINK_CHANGE_INT | TX_ERR_INT | TX_OK_INT | \
353cde2885fSGarrett D'Amore 			    RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT | \
354cde2885fSGarrett D'Amore 			    RX_ERR_INT | RX_OK_INT)
355cde2885fSGarrett D'Amore 
356cde2885fSGarrett D'Amore /*
357cde2885fSGarrett D'Amore  * Transmit configuration register
358cde2885fSGarrett D'Amore  */
359cde2885fSGarrett D'Amore #define	TX_CONFIG_REG		0x0040
360cde2885fSGarrett D'Amore #define	TX_CONSIG_REG_RESERVE	0x8078f80e
361cde2885fSGarrett D'Amore #define	HW_VERSION_ID_5		0x7c000000
362cde2885fSGarrett D'Amore #define	TX_INTERFRAME_GAP_BITS	0x03000000
363cde2885fSGarrett D'Amore #define	TX_INTERFRAME_GAP_SHIFT	24
364cde2885fSGarrett D'Amore #define	TX_INTERFRAME_GAP_802_3	0x03000000
365cde2885fSGarrett D'Amore #define	HW_VERSION_ID_1		0x00800000
366cde2885fSGarrett D'Amore #define	LOOPBACK_MODE_ENABLE	0x00060000
367cde2885fSGarrett D'Amore #define	CRC_APPEND_ENABLE	0x00010000
368cde2885fSGarrett D'Amore #define	TX_DMA_BURST_BYTES	0x00000700
369cde2885fSGarrett D'Amore #define	TX_DMA_BURST_2048B	0x00000700
370cde2885fSGarrett D'Amore #define	TX_DMA_BURST_1024B	0x00000600
371cde2885fSGarrett D'Amore #define	TX_RETRY_COUNT_BITS	0x000000f0
372cde2885fSGarrett D'Amore #define	TX_RETRY_COUNT_DEFUALT	0x00000010
373cde2885fSGarrett D'Amore 	/* re-transmit count (16 + 1 * 16) = 32 times before aborting */
374cde2885fSGarrett D'Amore #define	TX_CLEAR_ABORT		0x00000001
375cde2885fSGarrett D'Amore 
376cde2885fSGarrett D'Amore #define	TX_CONFIG_DEFAULT	(TX_INTERFRAME_GAP_802_3 | \
377cde2885fSGarrett D'Amore 				    TX_DMA_BURST_1024B | \
378cde2885fSGarrett D'Amore 				    TX_RETRY_COUNT_DEFUALT)
379cde2885fSGarrett D'Amore #define	TX_FIFO_THRESHHOLD	1024
380cde2885fSGarrett D'Amore /*
381cde2885fSGarrett D'Amore  * Receive configuration register
382cde2885fSGarrett D'Amore  */
383cde2885fSGarrett D'Amore #define	RX_CONFIG_REG		0x0044
384cde2885fSGarrett D'Amore #define	RX_CONSIG_REG_RESERVE	0xf0fc0000
385cde2885fSGarrett D'Amore 
386cde2885fSGarrett D'Amore #define	RX_THRESHOLD_BITS	0x0f000000
387cde2885fSGarrett D'Amore #define	RX_EARLY_INT_SEL	0x00020000
388cde2885fSGarrett D'Amore #define	RX_RER8_ENABLE		0x00010000
389cde2885fSGarrett D'Amore 
390cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_BITS	0x0000e000
391cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_16B	0x00000000
392cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_32B	0x00002000
393cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_64B	0x00004000
394cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_128B	0x00006000
395cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_256B	0x00008000
396cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_512B	0x0000a000
397cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_1024B	0x0000c000
398cde2885fSGarrett D'Amore #define	RX_FIFO_THRESHOLD_NONE	0x0000e000
399cde2885fSGarrett D'Amore 
400cde2885fSGarrett D'Amore #define	RX_BUF_LEN_BITS		0x00001800
401cde2885fSGarrett D'Amore #define	RX_BUF_LEN_8K		0x00000000
402cde2885fSGarrett D'Amore #define	RX_BUF_LEN_16K		0x00000800
403cde2885fSGarrett D'Amore #define	RX_BUF_LEN_32K		0x00001000
404cde2885fSGarrett D'Amore #define	RX_BUF_LEN_64K		0x00001800
405cde2885fSGarrett D'Amore 
406cde2885fSGarrett D'Amore #define	RX_DMA_BURST_BYTES	0x00000700
407cde2885fSGarrett D'Amore #define	RX_DMA_BURST_16B	0x00000000
408cde2885fSGarrett D'Amore #define	RX_DMA_BURST_32B	0x00000100
409cde2885fSGarrett D'Amore #define	RX_DMA_BURST_64B	0x00000200
410cde2885fSGarrett D'Amore #define	RX_DMA_BURST_128B	0x00000300
411cde2885fSGarrett D'Amore #define	RX_DMA_BURST_256B	0x00000400
412cde2885fSGarrett D'Amore #define	RX_DMA_BURST_512B	0x00000500
413cde2885fSGarrett D'Amore #define	RX_DMA_BURST_1024B	0x00000600
414cde2885fSGarrett D'Amore #define	RX_DMA_BURST_UNLIMITED	0x00000700
415cde2885fSGarrett D'Amore 
416cde2885fSGarrett D'Amore #define	RX_NOWRAP_ENABLE	0x00000080
417cde2885fSGarrett D'Amore #define	RX_EEPROM_9356		0x00000040
418cde2885fSGarrett D'Amore #define	RX_ACCEPT_ERR_PACKET	0x00000020
419cde2885fSGarrett D'Amore #define	RX_ACCEPT_RUNT_PACKET	0x00000010
420cde2885fSGarrett D'Amore #define	RX_ACCEPT_BROADCAST_PACKET	0x000000008
421cde2885fSGarrett D'Amore #define	RX_ACCEPT_MULTICAST_PACKET	0x000000004
422cde2885fSGarrett D'Amore #define	RX_ACCEPT_MAC_MATCH_PACKET	0x000000002
423cde2885fSGarrett D'Amore #define	RX_ACCEPT_ALL_PACKET		0x000000001
424cde2885fSGarrett D'Amore 
425cde2885fSGarrett D'Amore #define	RX_CONFIG_DEFAULT	(RX_FIFO_THRESHOLD_NONE | \
426cde2885fSGarrett D'Amore 				    RX_BUF_LEN_32K | \
427cde2885fSGarrett D'Amore 				    RX_DMA_BURST_1024B | \
428cde2885fSGarrett D'Amore 				    RX_ACCEPT_BROADCAST_PACKET | \
429cde2885fSGarrett D'Amore 				    RX_ACCEPT_MULTICAST_PACKET | \
430cde2885fSGarrett D'Amore 				    RX_ACCEPT_MAC_MATCH_PACKET)
431cde2885fSGarrett D'Amore /*
432cde2885fSGarrett D'Amore  * Missed packet counter: indicates the number of packets
433cde2885fSGarrett D'Amore  * discarded due to rx FIFO overflow
434cde2885fSGarrett D'Amore  */
435cde2885fSGarrett D'Amore #define	RX_PACKET_MISS_COUNT_REG	0x004c
436cde2885fSGarrett D'Amore 
437cde2885fSGarrett D'Amore /*
438cde2885fSGarrett D'Amore  * 93c46(93c56) commond register:
439cde2885fSGarrett D'Amore  */
440bbb1277bSGarrett D'Amore #define	RT_93c46_COMMAND_REG	0x0050
441cde2885fSGarrett D'Amore #define	RT_93c46_MODE_BITS	0xc0
442cde2885fSGarrett D'Amore #define	RT_93c46_MODE_NORMAL	0x00
443cde2885fSGarrett D'Amore #define	RT_93c46_MODE_AUTOLOAD	0x40
444cde2885fSGarrett D'Amore #define	RT_93c46_MODE_PROGRAM	0x80
445cde2885fSGarrett D'Amore #define	RT_93c46_MODE_CONFIG	0xc0
446cde2885fSGarrett D'Amore 
447cde2885fSGarrett D'Amore #define	RT_93c46_EECS		0x08
448cde2885fSGarrett D'Amore #define	RT_93c46_EESK		0x04
449cde2885fSGarrett D'Amore #define	RT_93c46_EEDI		0x02
450cde2885fSGarrett D'Amore #define	RT_93c46_EEDO		0x01
451cde2885fSGarrett D'Amore 
452cde2885fSGarrett D'Amore /*
453cde2885fSGarrett D'Amore  * Configuration registers
454cde2885fSGarrett D'Amore  */
455cde2885fSGarrett D'Amore #define	RT_CONFIG_0_REG		0x0051
456cde2885fSGarrett D'Amore #define	RT_CONFIG_1_REG		0x0052
457cde2885fSGarrett D'Amore #define	RT_CONFIG_3_REG		0x0059
458cde2885fSGarrett D'Amore #define	RT_CONFIG_4_REG		0x005a
459cde2885fSGarrett D'Amore 
460cde2885fSGarrett D'Amore /*
461cde2885fSGarrett D'Amore  * Media status register
462cde2885fSGarrett D'Amore  */
463cde2885fSGarrett D'Amore #define	MEDIA_STATUS_REG	0x0058
464cde2885fSGarrett D'Amore #define	MEDIA_STATUS_LINK	0x04
465cde2885fSGarrett D'Amore #define	MEDIA_STATUS_SPEED	0x08
466cde2885fSGarrett D'Amore 
467cde2885fSGarrett D'Amore #define	RTLS_SPEED_100M		100000000
468cde2885fSGarrett D'Amore #define	RTLS_SPEED_10M		10000000
469cde2885fSGarrett D'Amore #define	RTLS_SPEED_UNKNOWN	0
470cde2885fSGarrett D'Amore /*
471cde2885fSGarrett D'Amore  * Multiple interrupt select register
472cde2885fSGarrett D'Amore  */
473cde2885fSGarrett D'Amore #define	RT_MUL_INTSEL_REG	0x005c
474cde2885fSGarrett D'Amore #define	RT_MUL_INTSEL_BITS	0x0fff
475cde2885fSGarrett D'Amore 
476cde2885fSGarrett D'Amore /*
477cde2885fSGarrett D'Amore  * Transmit status of all descriptor registers register
478cde2885fSGarrett D'Amore  */
479cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_REG		0x0060
480cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_OWN_0		0x0001
481cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_ABORT_0		0x0010
482cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_UNDERRUN_0	0x0100
483cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_TXOK_0		0x1000
484cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_OWN_1		0x0002
485cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_ABORT_1		0x0020
486cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_UNDERRUN_1	0x0200
487cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_TXOK_1		0x2000
488cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_OWN_2		0x0004
489cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_ABORT_2		0x0040
490cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_UNDERRUN_2	0x0400
491cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_TXOK_2		0x4000
492cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_OWN_3		0x0008
493cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_ABORT_3		0x0080
494cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_UNDERRUN_3	0x0800
495cde2885fSGarrett D'Amore #define	TX_DESC_STAUS_TXOK_3		0x8000
496cde2885fSGarrett D'Amore 
497cde2885fSGarrett D'Amore /*
498cde2885fSGarrett D'Amore  * Basic mode control register
499cde2885fSGarrett D'Amore  */
500cde2885fSGarrett D'Amore #define	BASIC_MODE_CONTROL_REG		0x0062
501cde2885fSGarrett D'Amore #define	BASIC_MODE_CONTROL_BITS		0x3300
502cde2885fSGarrett D'Amore 
503cde2885fSGarrett D'Amore #define	BASIC_MODE_SPEED		0x2000
504cde2885fSGarrett D'Amore #define	BASIC_MODE_SPEED_100		0x2000
505cde2885fSGarrett D'Amore 
506cde2885fSGarrett D'Amore #define	BASIC_MODE_AUTONEGO		0x1000
507cde2885fSGarrett D'Amore 
508cde2885fSGarrett D'Amore #define	BASIC_MODE_RESTAR_AUTONEGO	0x0200
509cde2885fSGarrett D'Amore 
510cde2885fSGarrett D'Amore #define	BASIC_MODE_DUPLEX		0x0100
511cde2885fSGarrett D'Amore #define	BASIC_MODE_DUPLEX_FULL		0x0100
512cde2885fSGarrett D'Amore 
513cde2885fSGarrett D'Amore /*
514cde2885fSGarrett D'Amore  * Basic mode status register
515cde2885fSGarrett D'Amore  */
516cde2885fSGarrett D'Amore #define	BASIC_MODE_STATUS_REG		0x0064
517cde2885fSGarrett D'Amore #define	BASIC_MODE_STATUS_AUTONEGO_DONE	0x0020
518cde2885fSGarrett D'Amore #define	BASIC_MODE_STATUS_REMOTE_FAULT	0x0010
519cde2885fSGarrett D'Amore 
520cde2885fSGarrett D'Amore /*
521cde2885fSGarrett D'Amore  * Auto-negotiation advertisement register
522cde2885fSGarrett D'Amore  */
523cde2885fSGarrett D'Amore #define	AUTO_NEGO_AD_REG		0x0066
524cde2885fSGarrett D'Amore #define	AUTO_NEGO_MODE_BITS		0x01e0
525cde2885fSGarrett D'Amore #define	AUTO_NEGO_100FULL		0x0100
526cde2885fSGarrett D'Amore #define	AUTO_NEGO_100HALF		0x0080
527cde2885fSGarrett D'Amore #define	AUTO_NEGO_10FULL		0x0040
528cde2885fSGarrett D'Amore #define	AUTO_NEGO_10HALF		0x0020
529cde2885fSGarrett D'Amore 
530cde2885fSGarrett D'Amore /*
531cde2885fSGarrett D'Amore  * Auto-negotiation link partner ability register
532cde2885fSGarrett D'Amore  */
533cde2885fSGarrett D'Amore #define	AUTO_NEGO_LP_REG		0x0068
534cde2885fSGarrett D'Amore 
535cde2885fSGarrett D'Amore /*
536cde2885fSGarrett D'Amore  * Auto-negotiation expansion register
537cde2885fSGarrett D'Amore  */
538cde2885fSGarrett D'Amore #define	AUTO_NEGO_EXP_REG		0x006a
539cde2885fSGarrett D'Amore #define	AUTO_NEGO_EXP_LPCANAN		0x0001
540cde2885fSGarrett D'Amore 
541cde2885fSGarrett D'Amore /*
542cde2885fSGarrett D'Amore  * Receive status in rx packet header
543cde2885fSGarrett D'Amore  */
544cde2885fSGarrett D'Amore #define	RX_HEADER_SIZE			4
545cde2885fSGarrett D'Amore 
546cde2885fSGarrett D'Amore #define	RX_HEADER_LEN_BITS		0xffff0000
547cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_BITS		0x0000ffff
548cde2885fSGarrett D'Amore #define	RX_STATUS_DMA_BUSY		0xfff0
549cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_MULTI		0x8000
550cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_PAM		0x4000
551cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_BCAST		0x2000
552cde2885fSGarrett D'Amore 
553cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_ISE		0x0020
554cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_RUNT		0x0010
555cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_LONG		0x0008
556cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_CRC		0x0004
557cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_FAE		0x0002
558cde2885fSGarrett D'Amore #define	RX_HEADER_STATUS_ROK		0x0001
559cde2885fSGarrett D'Amore 
560cde2885fSGarrett D'Amore #define	RX_ERR_FLAGS	(RX_HEADER_STATUS_ISE | RX_HEADER_STATUS_RUNT | \
561cde2885fSGarrett D'Amore 			RX_HEADER_STATUS_FAE | RX_HEADER_STATUS_CRC)
562cde2885fSGarrett D'Amore 
563cde2885fSGarrett D'Amore #ifdef __cplusplus
564cde2885fSGarrett D'Amore }
565cde2885fSGarrett D'Amore #endif
566cde2885fSGarrett D'Amore 
567cde2885fSGarrett D'Amore #endif	/* _SYS_RTLS_H */
568