xref: /titanic_50/usr/src/uts/sun/io/eri/eri_common.h (revision 297a64e7779d7bd7140d1f3f2fa5db171aa21569)
1*297a64e7Sgd78059 /*
2*297a64e7Sgd78059  * CDDL HEADER START
3*297a64e7Sgd78059  *
4*297a64e7Sgd78059  * The contents of this file are subject to the terms of the
5*297a64e7Sgd78059  * Common Development and Distribution License (the "License").
6*297a64e7Sgd78059  * You may not use this file except in compliance with the License.
7*297a64e7Sgd78059  *
8*297a64e7Sgd78059  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*297a64e7Sgd78059  * or http://www.opensolaris.org/os/licensing.
10*297a64e7Sgd78059  * See the License for the specific language governing permissions
11*297a64e7Sgd78059  * and limitations under the License.
12*297a64e7Sgd78059  *
13*297a64e7Sgd78059  * When distributing Covered Code, include this CDDL HEADER in each
14*297a64e7Sgd78059  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*297a64e7Sgd78059  * If applicable, add the following below this CDDL HEADER, with the
16*297a64e7Sgd78059  * fields enclosed by brackets "[]" replaced with your own identifying
17*297a64e7Sgd78059  * information: Portions Copyright [yyyy] [name of copyright owner]
18*297a64e7Sgd78059  *
19*297a64e7Sgd78059  * CDDL HEADER END
20*297a64e7Sgd78059  */
21*297a64e7Sgd78059 /*
22*297a64e7Sgd78059  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*297a64e7Sgd78059  * Use is subject to license terms.
24*297a64e7Sgd78059  */
25*297a64e7Sgd78059 
26*297a64e7Sgd78059 #ifndef	_SYS_ERI_COMMON_H
27*297a64e7Sgd78059 #define	_SYS_ERI_COMMON_H
28*297a64e7Sgd78059 
29*297a64e7Sgd78059 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*297a64e7Sgd78059 
31*297a64e7Sgd78059 #ifdef	__cplusplus
32*297a64e7Sgd78059 extern "C" {
33*297a64e7Sgd78059 #endif
34*297a64e7Sgd78059 
35*297a64e7Sgd78059 #ifdef _KERNEL
36*297a64e7Sgd78059 
37*297a64e7Sgd78059 typedef void	(*fptrv_t)();
38*297a64e7Sgd78059 
39*297a64e7Sgd78059 typedef enum {
40*297a64e7Sgd78059 	ERI_NO_MSG		= 0,
41*297a64e7Sgd78059 	ERI_CON_MSG  		= 1,
42*297a64e7Sgd78059 	ERI_BUF_MSG		= 2,
43*297a64e7Sgd78059 	ERI_VERB_MSG		= 3,
44*297a64e7Sgd78059 	ERI_LOG_MSG		= 4
45*297a64e7Sgd78059 } msg_t;
46*297a64e7Sgd78059 
47*297a64e7Sgd78059 
48*297a64e7Sgd78059 #ifdef	DEBUG
49*297a64e7Sgd78059 static msg_t eri_msg_out = ERI_VERB_MSG;
50*297a64e7Sgd78059 #endif
51*297a64e7Sgd78059 
52*297a64e7Sgd78059 #ifdef	LATER
53*297a64e7Sgd78059 static char	*fault_msg_string[] = {
54*297a64e7Sgd78059 	"NONE       ",
55*297a64e7Sgd78059 	"LOW        ",
56*297a64e7Sgd78059 	"MID        ",
57*297a64e7Sgd78059 	"HIGH       ",
58*297a64e7Sgd78059 	"UNKNOWN    "
59*297a64e7Sgd78059 
60*297a64e7Sgd78059 };
61*297a64e7Sgd78059 #endif
62*297a64e7Sgd78059 
63*297a64e7Sgd78059 #define	SEVERITY_UNKNOWN 0
64*297a64e7Sgd78059 #define	SEVERITY_NONE   0
65*297a64e7Sgd78059 #define	SEVERITY_LOW    0
66*297a64e7Sgd78059 #define	SEVERITY_MID    1
67*297a64e7Sgd78059 #define	SEVERITY_HIGH   2
68*297a64e7Sgd78059 
69*297a64e7Sgd78059 
70*297a64e7Sgd78059 #define	ERI_FAULT_MSG1(p, t, f, a) \
71*297a64e7Sgd78059     eri_fault_msg((p), (t), (f), (a));
72*297a64e7Sgd78059 
73*297a64e7Sgd78059 #define	ERI_FAULT_MSG2(p, t, f, a, b) \
74*297a64e7Sgd78059     eri_fault_msg((p), (t), (f), (a), (b));
75*297a64e7Sgd78059 
76*297a64e7Sgd78059 #define	ERI_FAULT_MSG3(p, t, f, a, b, c) \
77*297a64e7Sgd78059     eri_fault_msg((p), (t), (f), (a), (b), (c));
78*297a64e7Sgd78059 
79*297a64e7Sgd78059 #define	ERI_FAULT_MSG4(p, t, f, a, b, c, d) \
80*297a64e7Sgd78059     eri_fault_msg((p), (t), (f), (a), (b), (c), (d));
81*297a64e7Sgd78059 
82*297a64e7Sgd78059 #ifdef  DEBUG
83*297a64e7Sgd78059 typedef enum {
84*297a64e7Sgd78059 	NO_MSG		= 0,
85*297a64e7Sgd78059 	AUTOCONFIG_MSG  = 1,
86*297a64e7Sgd78059 	STREAMS_MSG	= 2,
87*297a64e7Sgd78059 	IOCTL_MSG	= 3,
88*297a64e7Sgd78059 	PROTO_MSG	= 4,
89*297a64e7Sgd78059 	INIT_MSG	= 5,
90*297a64e7Sgd78059 	TX_MSG		= 6,
91*297a64e7Sgd78059 	RX_MSG		= 7,
92*297a64e7Sgd78059 	INTR_MSG	= 8,
93*297a64e7Sgd78059 	UNINIT_MSG	= 9,
94*297a64e7Sgd78059 	CONFIG_MSG	= 10,
95*297a64e7Sgd78059 	PROP_MSG	= 11,
96*297a64e7Sgd78059 	ENTER_MSG	= 12,
97*297a64e7Sgd78059 	RESUME_MSG	= 13,
98*297a64e7Sgd78059 	AUTONEG_MSG	= 14,
99*297a64e7Sgd78059 	NAUTONEG_MSG	= 15,
100*297a64e7Sgd78059 	FATAL_ERR_MSG   = 16,
101*297a64e7Sgd78059 	NONFATAL_MSG  = 17,
102*297a64e7Sgd78059 	NDD_MSG		= 18,
103*297a64e7Sgd78059 	PHY_MSG		= 19,
104*297a64e7Sgd78059 	XCVR_MSG	= 20,
105*297a64e7Sgd78059 	NSUPPORT_MSG	= 21,
106*297a64e7Sgd78059 	ERX_MSG		= 22,
107*297a64e7Sgd78059 	FREE_MSG	= 23,
108*297a64e7Sgd78059 	IPG_MSG		= 24,
109*297a64e7Sgd78059 	DDI_MSG		= 25,
110*297a64e7Sgd78059 	DEFAULT_MSG	= 26,
111*297a64e7Sgd78059 	DISPLAY_MSG	= 27,
112*297a64e7Sgd78059 	DIAG_MSG	= 28,
113*297a64e7Sgd78059 	END_TRACE1_MSG	= 29,
114*297a64e7Sgd78059 	END_TRACE2_MSG	= 30,
115*297a64e7Sgd78059 	ASSERT_MSG	= 31,
116*297a64e7Sgd78059 	FRM_MSG		= 32,
117*297a64e7Sgd78059 	MIF_MSG		= 33,
118*297a64e7Sgd78059 	LINK_MSG	= 34,
119*297a64e7Sgd78059 	RESOURCE_MSG	= 35,
120*297a64e7Sgd78059 	LOOPBACK_MSG	= 36,
121*297a64e7Sgd78059 	VERBOSE_MSG	= 37,
122*297a64e7Sgd78059 	MODCTL_MSG	= 38,
123*297a64e7Sgd78059 	HWCSUM_MSG	= 39,
124*297a64e7Sgd78059 	CORRUPTION_MSG	= 40,
125*297a64e7Sgd78059 	EXIT_MSG	= 41,
126*297a64e7Sgd78059 	DLCAPAB_MSG	= 42
127*297a64e7Sgd78059 
128*297a64e7Sgd78059 } debug_msg_t;
129*297a64e7Sgd78059 
130*297a64e7Sgd78059 static debug_msg_t	eri_debug_level = NO_MSG;
131*297a64e7Sgd78059 static debug_msg_t	eri_debug_all = NO_MSG;
132*297a64e7Sgd78059 
133*297a64e7Sgd78059 static char	*debug_msg_string[] = {
134*297a64e7Sgd78059 	"NONE       ",
135*297a64e7Sgd78059 	"AUTOCONFIG ",
136*297a64e7Sgd78059 	"STREAMS    ",
137*297a64e7Sgd78059 	"IOCTL      ",
138*297a64e7Sgd78059 	"PROTO      ",
139*297a64e7Sgd78059 	"INIT       ",
140*297a64e7Sgd78059 	"TX         ",
141*297a64e7Sgd78059 	"RX         ",
142*297a64e7Sgd78059 	"INTR       ",
143*297a64e7Sgd78059 	"UNINIT         ",
144*297a64e7Sgd78059 	"CONFIG ",
145*297a64e7Sgd78059 	"PROP   ",
146*297a64e7Sgd78059 	"ENTER  ",
147*297a64e7Sgd78059 	"RESUME ",
148*297a64e7Sgd78059 	"AUTONEG        ",
149*297a64e7Sgd78059 	"NAUTONEG       ",
150*297a64e7Sgd78059 	"FATAL_ERR      ",
151*297a64e7Sgd78059 	"NFATAL_ERR     ",
152*297a64e7Sgd78059 	"NDD    ",
153*297a64e7Sgd78059 	"PHY    ",
154*297a64e7Sgd78059 	"XCVR   ",
155*297a64e7Sgd78059 	"NSUPPOR        ",
156*297a64e7Sgd78059 	"ERX    ",
157*297a64e7Sgd78059 	"FREE   ",
158*297a64e7Sgd78059 	"IPG    ",
159*297a64e7Sgd78059 	"DDI    ",
160*297a64e7Sgd78059 	"DEFAULT        ",
161*297a64e7Sgd78059 	"DISPLAY        ",
162*297a64e7Sgd78059 	"DIAG	",
163*297a64e7Sgd78059 	"TRACE1 ",
164*297a64e7Sgd78059 	"TRACE2 ",
165*297a64e7Sgd78059 	"ASSERT",
166*297a64e7Sgd78059 	"FRM	",
167*297a64e7Sgd78059 	"MIF	",
168*297a64e7Sgd78059 	"LINK	",
169*297a64e7Sgd78059 	"RESOURCE",
170*297a64e7Sgd78059 	"LOOPBACK",
171*297a64e7Sgd78059 	"VERBOSE",
172*297a64e7Sgd78059 	"MODCTL",
173*297a64e7Sgd78059 	"HWCSUM",
174*297a64e7Sgd78059 	"CORRUPTION",
175*297a64e7Sgd78059 	"EXIT",
176*297a64e7Sgd78059 	"DLCAPAB"
177*297a64e7Sgd78059 };
178*297a64e7Sgd78059 
179*297a64e7Sgd78059 static void	eri_debug_msg(const char *, int, struct eri *, debug_msg_t,
180*297a64e7Sgd78059     const char *, ...);
181*297a64e7Sgd78059 
182*297a64e7Sgd78059 #define	ERI_DEBUG_MSG1(t, f, a) \
183*297a64e7Sgd78059     eri_debug_msg(__FILE__, __LINE__, (t), (f), (a));
184*297a64e7Sgd78059 
185*297a64e7Sgd78059 #define	ERI_DEBUG_MSG2(t, f, a, b) \
186*297a64e7Sgd78059     eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b));
187*297a64e7Sgd78059 
188*297a64e7Sgd78059 #define	ERI_DEBUG_MSG3(t, f, a, b, c) \
189*297a64e7Sgd78059     eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b), (c));
190*297a64e7Sgd78059 
191*297a64e7Sgd78059 #define	ERI_DEBUG_MSG4(t, f, a, b, c, d) \
192*297a64e7Sgd78059     eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b), (c), (d));
193*297a64e7Sgd78059 
194*297a64e7Sgd78059 #define	ERI_DEBUG_MSG5(t, f, a, b, c, d, e) \
195*297a64e7Sgd78059     eri_debug_msg(__FILE__, __LINE__, (t), (f), (a), (b), (c), (d), (e));
196*297a64e7Sgd78059 
197*297a64e7Sgd78059 #else
198*297a64e7Sgd78059 
199*297a64e7Sgd78059 #define	ERI_DEBUG_MSG1(t, f, a)
200*297a64e7Sgd78059 #define	ERI_DEBUG_MSG2(t, f, a, b)
201*297a64e7Sgd78059 #define	ERI_DEBUG_MSG3(t, f, a, b, c)
202*297a64e7Sgd78059 #define	ERI_DEBUG_MSG4(t, f, a, b, c, d)
203*297a64e7Sgd78059 #define	ERI_DEBUG_MSG5(t, f, a, b, c, d, e)
204*297a64e7Sgd78059 #define	ERI_DEBUG_MSG6(t, f, a, b, c, d, e, g, h)
205*297a64e7Sgd78059 #endif
206*297a64e7Sgd78059 
207*297a64e7Sgd78059 #define	ERI_HWCSUM
208*297a64e7Sgd78059 
209*297a64e7Sgd78059 /*
210*297a64e7Sgd78059  * ERI REV 1.0 has some hardware bugs which doesn't alow it
211*297a64e7Sgd78059  * to function to full features. We define this flag to disable
212*297a64e7Sgd78059  * the features affected by these bugs.
213*297a64e7Sgd78059  */
214*297a64e7Sgd78059 #ifdef ERI_ERI_REV_1_0
215*297a64e7Sgd78059 #define		RCV_OVRFLOW_CORRUPTION_BUG
216*297a64e7Sgd78059 #endif
217*297a64e7Sgd78059 
218*297a64e7Sgd78059 #define		ERI_HDX_BUG_WORKAROUND
219*297a64e7Sgd78059 #define		ERI_TX_HUNG
220*297a64e7Sgd78059 /*
221*297a64e7Sgd78059  * In forced speed mode when changing mode from 10 (force) to
222*297a64e7Sgd78059  * 10 (force), such as changing from 10/half to 10/full,
223*297a64e7Sgd78059  * the driver does not receive a MIF interrupt even though
224*297a64e7Sgd78059  * the XCVR status indicates that the link is up, and this
225*297a64e7Sgd78059  * is probably caused by the link for some reason does not
226*297a64e7Sgd78059  * go down.
227*297a64e7Sgd78059  *
228*297a64e7Sgd78059  * In forced mode, when changing speed/mode from 10 (force) to
229*297a64e7Sgd78059  * 100 (force), the user needs to make sure that the link
230*297a64e7Sgd78059  * partner is in forced mode as well by setting speed to
231*297a64e7Sgd78059  * 100 and the mode to either full or half duplex or
232*297a64e7Sgd78059  * else the link might not come up or come up with a mis-match mode.
233*297a64e7Sgd78059  */
234*297a64e7Sgd78059 #define		ERI_10_10_FORCE_SPEED_WORKAROUND
235*297a64e7Sgd78059 /*
236*297a64e7Sgd78059  * bits 15:0 of MIF status register contains 0 value
237*297a64e7Sgd78059  * and it is not defined as described on GEM specification
238*297a64e7Sgd78059  */
239*297a64e7Sgd78059 #define		ERI_MIF_POLL_STATUS_WORKAROUND
240*297a64e7Sgd78059 #define		ERI_STRETCH_RCV_BUFFER
241*297a64e7Sgd78059 
242*297a64e7Sgd78059 #ifdef		ERI_STRETCH_RCV_BUFFER
243*297a64e7Sgd78059 #undef		ERIBUFSIZE
244*297a64e7Sgd78059 #define		ERIBUFSIZE	3904
245*297a64e7Sgd78059 #endif
246*297a64e7Sgd78059 
247*297a64e7Sgd78059 #ifdef	notdef
248*297a64e7Sgd78059 #define		ERI_DONT_STRIP_CRC
249*297a64e7Sgd78059 #endif
250*297a64e7Sgd78059 
251*297a64e7Sgd78059 #ifdef ERI_HWCSUM
252*297a64e7Sgd78059 #define	ERI_RCV_CKSUM
253*297a64e7Sgd78059 #endif
254*297a64e7Sgd78059 
255*297a64e7Sgd78059 #ifdef	notdef
256*297a64e7Sgd78059 #define		ERI_SERVICE_ROUTINE
257*297a64e7Sgd78059 #endif
258*297a64e7Sgd78059 #define	ERIHIWAT	(128 * 1024)    /* hi-water mark */
259*297a64e7Sgd78059 #define	ERIRINDEX(i)	(i & erip->erirpending_mask)
260*297a64e7Sgd78059 #define	DONT_FLUSH	-1
261*297a64e7Sgd78059 
262*297a64e7Sgd78059 /*
263*297a64e7Sgd78059  * ddi_dma_sync() a TMD or RMD descriptor.
264*297a64e7Sgd78059  */
265*297a64e7Sgd78059 #define	ERI_SYNCIOPB(erip, a, size, who) \
266*297a64e7Sgd78059 	(void) ddi_dma_sync((erip)->md_h, \
267*297a64e7Sgd78059 		((uintptr_t)(a) - (erip)->iopbkbase), \
268*297a64e7Sgd78059 		(size), \
269*297a64e7Sgd78059 		(who))
270*297a64e7Sgd78059 
271*297a64e7Sgd78059 /* ------------------------------------------------------------------------- */
272*297a64e7Sgd78059 /*
273*297a64e7Sgd78059  * Patchable debug flag.
274*297a64e7Sgd78059  * Set this to nonzero to enable error messages.
275*297a64e7Sgd78059  */
276*297a64e7Sgd78059 
277*297a64e7Sgd78059 /*
278*297a64e7Sgd78059  * The following parameters may be configured by the user. If they are not
279*297a64e7Sgd78059  * configured by the user, the values will be based on the capabilities of
280*297a64e7Sgd78059  * the transceiver.
281*297a64e7Sgd78059  * The value "ERI_NOTUSR" is ORed with the parameter value to indicate values
282*297a64e7Sgd78059  * which are NOT configured by the user.
283*297a64e7Sgd78059  */
284*297a64e7Sgd78059 
285*297a64e7Sgd78059 /* command */
286*297a64e7Sgd78059 
287*297a64e7Sgd78059 #define	ND_BASE		('N' << 8)	/* base */
288*297a64e7Sgd78059 #define	ND_GET		(ND_BASE + 0)	/* Get a value */
289*297a64e7Sgd78059 #define	ND_SET		(ND_BASE + 1)	/* Set a value */
290*297a64e7Sgd78059 
291*297a64e7Sgd78059 #define	ERI_ND_GET	ND_GET
292*297a64e7Sgd78059 #define	ERI_ND_SET	ND_SET
293*297a64e7Sgd78059 #define	ERI_NOTUSR	0x0f000000
294*297a64e7Sgd78059 #define	ERI_MASK_1BIT	0x1
295*297a64e7Sgd78059 #define	ERI_MASK_2BIT	0x3
296*297a64e7Sgd78059 #define	ERI_MASK_8BIT	0xff
297*297a64e7Sgd78059 
298*297a64e7Sgd78059 #define	param_transceiver	(erip->param_arr[0].param_val)
299*297a64e7Sgd78059 #define	param_linkup		(erip->param_arr[1].param_val)
300*297a64e7Sgd78059 #define	param_speed		(erip->param_arr[2].param_val)
301*297a64e7Sgd78059 #define	param_mode		(erip->param_arr[3].param_val)
302*297a64e7Sgd78059 #define	param_ipg1		(erip->param_arr[4].param_val)
303*297a64e7Sgd78059 #define	param_ipg2		(erip->param_arr[5].param_val)
304*297a64e7Sgd78059 #define	param_use_intphy	(erip->param_arr[6].param_val)
305*297a64e7Sgd78059 #define	param_pace_count	(erip->param_arr[7].param_val)
306*297a64e7Sgd78059 #define	param_autoneg		(erip->param_arr[8].param_val)
307*297a64e7Sgd78059 #define	param_anar_100T4	(erip->param_arr[9].param_val)
308*297a64e7Sgd78059 
309*297a64e7Sgd78059 #define	param_anar_100fdx	(erip->param_arr[10].param_val)
310*297a64e7Sgd78059 #define	param_anar_100hdx	(erip->param_arr[11].param_val)
311*297a64e7Sgd78059 #define	param_anar_10fdx	(erip->param_arr[12].param_val)
312*297a64e7Sgd78059 #define	param_anar_10hdx	(erip->param_arr[13].param_val)
313*297a64e7Sgd78059 #define	param_bmsr_ancap	(erip->param_arr[14].param_val)
314*297a64e7Sgd78059 #define	param_bmsr_100T4	(erip->param_arr[15].param_val)
315*297a64e7Sgd78059 #define	param_bmsr_100fdx	(erip->param_arr[16].param_val)
316*297a64e7Sgd78059 #define	param_bmsr_100hdx	(erip->param_arr[17].param_val)
317*297a64e7Sgd78059 #define	param_bmsr_10fdx	(erip->param_arr[18].param_val)
318*297a64e7Sgd78059 #define	param_bmsr_10hdx	(erip->param_arr[19].param_val)
319*297a64e7Sgd78059 
320*297a64e7Sgd78059 #define	param_aner_lpancap	(erip->param_arr[20].param_val)
321*297a64e7Sgd78059 #define	param_anlpar_100T4	(erip->param_arr[21].param_val)
322*297a64e7Sgd78059 #define	param_anlpar_100fdx	(erip->param_arr[22].param_val)
323*297a64e7Sgd78059 #define	param_anlpar_100hdx	(erip->param_arr[23].param_val)
324*297a64e7Sgd78059 #define	param_anlpar_10fdx	(erip->param_arr[24].param_val)
325*297a64e7Sgd78059 #define	param_anlpar_10hdx	(erip->param_arr[25].param_val)
326*297a64e7Sgd78059 #define	param_lance_mode	(erip->param_arr[26].param_val)
327*297a64e7Sgd78059 #define	param_ipg0		(erip->param_arr[27].param_val)
328*297a64e7Sgd78059 #define	param_intr_blank_time		(erip->param_arr[28].param_val)
329*297a64e7Sgd78059 #define	param_intr_blank_packets	(erip->param_arr[29].param_val)
330*297a64e7Sgd78059 #define	param_serial_link	(erip->param_arr[30].param_val)
331*297a64e7Sgd78059 
332*297a64e7Sgd78059 #define	param_non_serial_link	(erip->param_arr[31].param_val)
333*297a64e7Sgd78059 #define	param_select_link	(erip->param_arr[32].param_val)
334*297a64e7Sgd78059 #define	param_default_link	(erip->param_arr[33].param_val)
335*297a64e7Sgd78059 #define	param_link_in_use	(erip->param_arr[34].param_val)
336*297a64e7Sgd78059 #define	param_anar_asm_dir	(erip->param_arr[35].param_val)
337*297a64e7Sgd78059 #define	param_anar_pause	(erip->param_arr[36].param_val)
338*297a64e7Sgd78059 #define	param_bmsr_asm_dir	(erip->param_arr[37].param_val)
339*297a64e7Sgd78059 #define	param_bmsr_pause	(erip->param_arr[38].param_val)
340*297a64e7Sgd78059 #define	param_anlpar_pauseTX 	(erip->param_arr[49].param_val)
341*297a64e7Sgd78059 #define	param_anlpar_pauseRX 	(erip->param_arr[40].param_val)
342*297a64e7Sgd78059 
343*297a64e7Sgd78059 /* <<<<<<<<<<<<<<<<<<<<<<  Register operations >>>>>>>>>>>>>>>>>>>>> */
344*297a64e7Sgd78059 #define	GET_PCSREG(reg) \
345*297a64e7Sgd78059 	ddi_get32(erip->pcsregh, (uint32_t *)&erip->pcsregp->reg)
346*297a64e7Sgd78059 #define	PUT_PCSREG(reg, value) \
347*297a64e7Sgd78059 	ddi_put32(erip->pcsregh, (uint32_t *)&erip->pcsregp->reg, value)
348*297a64e7Sgd78059 #define	GET_MIFREG(reg) \
349*297a64e7Sgd78059 	ddi_get32(erip->mifregh, (uint32_t *)&erip->mifregp->reg)
350*297a64e7Sgd78059 #define	PUT_MIFREG(reg, value) \
351*297a64e7Sgd78059 	ddi_put32(erip->mifregh, (uint32_t *)&erip->mifregp->reg, value)
352*297a64e7Sgd78059 #define	GET_ETXREG(reg) \
353*297a64e7Sgd78059 	ddi_get32(erip->etxregh, (uint32_t *)&erip->etxregp->reg)
354*297a64e7Sgd78059 #define	PUT_ETXREG(reg, value) \
355*297a64e7Sgd78059 	ddi_put32(erip->etxregh, (uint32_t *)&erip->etxregp->reg, value)
356*297a64e7Sgd78059 #define	GET_ERXREG(reg) \
357*297a64e7Sgd78059 	ddi_get32(erip->erxregh, (uint32_t *)&erip->erxregp->reg)
358*297a64e7Sgd78059 #define	PUT_ERXREG(reg, value) \
359*297a64e7Sgd78059 	ddi_put32(erip->erxregh, (uint32_t *)&erip->erxregp->reg, value)
360*297a64e7Sgd78059 #define	GET_MACREG(reg) \
361*297a64e7Sgd78059 	ddi_get32(erip->bmacregh, (uint32_t *)&erip->bmacregp->reg)
362*297a64e7Sgd78059 #define	PUT_MACREG(reg, value) \
363*297a64e7Sgd78059 	ddi_put32(erip->bmacregh, \
364*297a64e7Sgd78059 		(uint32_t *)&erip->bmacregp->reg, value)
365*297a64e7Sgd78059 #define	GET_GLOBREG(reg) \
366*297a64e7Sgd78059 	ddi_get32(erip->globregh, (uint32_t *)&erip->globregp->reg)
367*297a64e7Sgd78059 #define	PUT_GLOBREG(reg, value) \
368*297a64e7Sgd78059 	ddi_put32(erip->globregh, \
369*297a64e7Sgd78059 		(uint32_t *)&erip->globregp->reg, value)
370*297a64e7Sgd78059 
371*297a64e7Sgd78059 #define	GET_SWRSTREG(reg) \
372*297a64e7Sgd78059 	ddi_get32(erip->sw_reset_regh, (uint32_t *)erip->sw_reset_reg)
373*297a64e7Sgd78059 
374*297a64e7Sgd78059 #define	PUT_SWRSTREG(reg, value) \
375*297a64e7Sgd78059 	ddi_put32(erip->sw_reset_regh, \
376*297a64e7Sgd78059 	(uint32_t *)erip->sw_reset_reg, value)
377*297a64e7Sgd78059 
378*297a64e7Sgd78059 /* ********************** Descriptor OPerations ******************** */
379*297a64e7Sgd78059 
380*297a64e7Sgd78059 /* <<<<<<<<<<<<<<<<<<<<<  for Solaris 2.6 and 2.7 >>>>>>>>>>>>>>>>>>>> */
381*297a64e7Sgd78059 
382*297a64e7Sgd78059 /* TMD and RMD Descriptor Operations */
383*297a64e7Sgd78059 #define	PUT_TMD(ptr, cookie, len, flags) \
384*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_addr, \
385*297a64e7Sgd78059 		cookie.dmac_laddress); \
386*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_flags, len | flags)
387*297a64e7Sgd78059 
388*297a64e7Sgd78059 #define	PUT_TMD_FAST(ptr, cookie, len, flags) \
389*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_addr, \
390*297a64e7Sgd78059 		cookie.dmac_address); \
391*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->tmd_flags, len | flags)
392*297a64e7Sgd78059 
393*297a64e7Sgd78059 #define	GET_TMD_FLAGS(ptr) \
394*297a64e7Sgd78059 	ddi_get64(erip->mdm_h, (uint64_t *)&ptr->tmd_flags)
395*297a64e7Sgd78059 
396*297a64e7Sgd78059 #define	PUT_RMD(ptr, cookie) \
397*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_addr, \
398*297a64e7Sgd78059 		cookie.dmac_laddress); \
399*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags, \
400*297a64e7Sgd78059 	    (uint64_t)(ERI_BUFSIZE << ERI_RMD_BUFSIZE_SHIFT) | ERI_RMD_OWN)
401*297a64e7Sgd78059 
402*297a64e7Sgd78059 #define	UPDATE_RMD(ptr) \
403*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags, \
404*297a64e7Sgd78059 	    (uint64_t)(ERI_BUFSIZE << ERI_RMD_BUFSIZE_SHIFT) | ERI_RMD_OWN)
405*297a64e7Sgd78059 
406*297a64e7Sgd78059 #define	PUT_RMD_FAST(ptr, cookie) \
407*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_addr, \
408*297a64e7Sgd78059 		cookie.dmac_address); \
409*297a64e7Sgd78059 	ddi_put64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags, \
410*297a64e7Sgd78059 	    (uint64_t)(ERI_BUFSIZE << ERI_RMD_BUFSIZE_SHIFT) | ERI_RMD_OWN)
411*297a64e7Sgd78059 
412*297a64e7Sgd78059 #define	GET_RMD_FLAGS(ptr) \
413*297a64e7Sgd78059 	ddi_get64(erip->mdm_h, (uint64_t *)&ptr->rmd_flags)
414*297a64e7Sgd78059 
415*297a64e7Sgd78059 #define	ENABLE_TXMAC(erip) \
416*297a64e7Sgd78059 	PUT_MACREG(txcfg, GET_MACREG(txcfg) | BMAC_TXCFG_ENAB)
417*297a64e7Sgd78059 
418*297a64e7Sgd78059 #define	ENABLE_RXMAC(erip) \
419*297a64e7Sgd78059 	PUT_MACREG(rxcfg, GET_MACREG(rxcfg) | BMAC_RXCFG_ENAB)
420*297a64e7Sgd78059 
421*297a64e7Sgd78059 #define	DISABLE_RXMAC(erip) \
422*297a64e7Sgd78059 	PUT_MACREG(rxcfg, GET_MACREG(rxcfg) & ~BMAC_RXCFG_ENAB)
423*297a64e7Sgd78059 
424*297a64e7Sgd78059 #define	DISABLE_TXMAC(erip) \
425*297a64e7Sgd78059 	PUT_MACREG(txcfg, GET_MACREG(txcfg) & ~BMAC_TXCFG_ENAB)
426*297a64e7Sgd78059 
427*297a64e7Sgd78059 #define	ENABLE_MAC(erip) \
428*297a64e7Sgd78059 	ENABLE_RXMAC(erip); \
429*297a64e7Sgd78059 	ENABLE_TXMAC(erip)
430*297a64e7Sgd78059 
431*297a64e7Sgd78059 #define	DISABLE_MAC(erip) \
432*297a64e7Sgd78059 	DISABLE_RXMAC(erip); \
433*297a64e7Sgd78059 	DISABLE_TXMAC(erip)
434*297a64e7Sgd78059 
435*297a64e7Sgd78059 #define	ENABLE_TXDMA(erip) \
436*297a64e7Sgd78059 	PUT_ETXREG(config,  GET_ETXREG(config) | GET_CONFIG_TXDMA_EN)
437*297a64e7Sgd78059 
438*297a64e7Sgd78059 /* TODO : MBE : GER? */
439*297a64e7Sgd78059 #define	ENABLE_RXDMA(erip) \
440*297a64e7Sgd78059 	PUT_ERXREG(config,  GET_ERXREG(config) | GET_CONFIG_RXDMA_EN)
441*297a64e7Sgd78059 
442*297a64e7Sgd78059 
443*297a64e7Sgd78059 /*
444*297a64e7Sgd78059  * Ether-type is specifically big-endian, but data region is unknown endian
445*297a64e7Sgd78059  * Ether-type lives at offset 12 from the start of the packet.
446*297a64e7Sgd78059  */
447*297a64e7Sgd78059 
448*297a64e7Sgd78059 #define	get_ether_type(ptr) \
449*297a64e7Sgd78059 	(((((uint8_t *)ptr)[12] << 8) | (((uint8_t *)ptr)[13])))
450*297a64e7Sgd78059 
451*297a64e7Sgd78059 #endif	/* _KERNEL */
452*297a64e7Sgd78059 
453*297a64e7Sgd78059 #ifdef	__cplusplus
454*297a64e7Sgd78059 }
455*297a64e7Sgd78059 #endif
456*297a64e7Sgd78059 
457*297a64e7Sgd78059 #endif	/* _SYS_ERI_COMMON_H */
458