xref: /illumos-gate/usr/src/uts/common/sys/nxge/nxge_mac_hw.h (revision e38a713ad4e0a9c42f8cccd9350412b2c6ccccdb)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_MAC_NXGE_MAC_HW_H
27 #define	_SYS_MAC_NXGE_MAC_HW_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <nxge_defs.h>
36 
37 /* -------------------------- From May's template --------------------------- */
38 
39 #define	NXGE_1GETHERMIN			255
40 #define	NXGE_ETHERMIN			97
41 #define	NXGE_MAX_HEADER			250
42 
43 /* Hardware reset */
44 typedef enum  {
45 	NXGE_TX_DISABLE,			/* Disable Tx side */
46 	NXGE_RX_DISABLE,			/* Disable Rx side */
47 	NXGE_CHIP_RESET				/* Full chip reset */
48 } nxge_reset_t;
49 
50 #define	NXGE_DELAY_AFTER_TXRX		10000	/* 10ms after idling rx/tx */
51 #define	NXGE_DELAY_AFTER_RESET		1000	/* 1ms after the reset */
52 #define	NXGE_DELAY_AFTER_EE_RESET	10000	/* 10ms after EEPROM reset */
53 #define	NXGE_DELAY_AFTER_LINK_RESET	13	/* 13 Us after link reset */
54 #define	NXGE_LINK_RESETS		8	/* Max PHY resets to wait for */
55 						/* linkup */
56 
57 #define	FILTER_M_CTL 			0xDCEF1
58 #define	HASH_BITS			8
59 #define	NMCFILTER_BITS			(1 << HASH_BITS)
60 #define	HASH_REG_WIDTH			16
61 #define	BROADCAST_HASH_WORD		0x0f
62 #define	BROADCAST_HASH_BIT		0x8000
63 #define	NMCFILTER_REGS			NMCFILTER_BITS / HASH_REG_WIDTH
64 					/* Number of multicast filter regs */
65 
66 /* -------------------------------------------------------------------------- */
67 
68 #define	XMAC_PORT_0			0
69 #define	XMAC_PORT_1			1
70 #define	BMAC_PORT_0			2
71 #define	BMAC_PORT_1			3
72 
73 #define	MAC_RESET_WAIT			10	/* usecs */
74 
75 #define	MAC_ADDR_REG_MASK		0xFFFF
76 
77 /*
78  * Neptune port PHY type and Speed encoding.
79  *
80  * Per port, 4 bits are reserved for port speed (1G/10G) and 4 bits
81  * are reserved for port PHY type (Copper/Fibre). Bits 0 thru 3 are for port0
82  * speed, bits 4 thru 7 are for port1 speed, bits 8 thru 11 are for port2 speed
83  * and bits 12 thru 15 are for port3 speed. Thus, the first 16 bits hold the
84  * speed encoding for the 4 ports. The next 16 bits (16 thru 31) hold the phy
85  * type encoding for the ports 0 thru 3.
86  *
87  *  p3phy  p2phy  p1phy  p0phy  p3spd p2spd  p1spd p0spd
88  *    |      |      |      |      |     |      |     |
89  *   ---    ---    ---    ---    ---   ---    ---   ---
90  *  /   \  /   \  /   \  /   \  /   \ /   \  /   \ /   \
91  * 31..28 27..24 23..20 19..16 15..12 11.. 8 7.. 4 3.. 0
92  */
93 
94 #define	NXGE_PORT_SPD_NONE	0x0
95 #define	NXGE_PORT_SPD_1G	0x1
96 #define	NXGE_PORT_SPD_10G	0x2
97 #define	NXGE_PORT_SPD_RSVD	0x7
98 
99 #define	NXGE_PHY_NONE		0x0
100 #define	NXGE_PHY_COPPER		0x1
101 #define	NXGE_PHY_FIBRE		0x2
102 #define	NXGE_PHY_SERDES		0x3
103 #define	NXGE_PHY_RGMII_FIBER	0x4
104 #define	NXGE_PHY_RSVD		0x7
105 
106 #define	NXGE_PORT_SPD_SHIFT	0
107 #define	NXGE_PORT_SPD_MASK	0x0f
108 
109 #define	NXGE_PHY_SHIFT		16
110 #define	NXGE_PHY_MASK		0x0f0000
111 
112 #define	NXGE_PORT_1G_COPPER	(NXGE_PORT_SPD_1G |	\
113 	(NXGE_PHY_COPPER << NXGE_PHY_SHIFT))
114 #define	NXGE_PORT_10G_COPPER	(NXGE_PORT_SPD_10G |	\
115 	(NXGE_PHY_COPPER << NXGE_PHY_SHIFT))
116 #define	NXGE_PORT_1G_FIBRE	(NXGE_PORT_SPD_1G |	\
117 	(NXGE_PHY_FIBRE << NXGE_PHY_SHIFT))
118 #define	NXGE_PORT_10G_FIBRE	(NXGE_PORT_SPD_10G |	\
119 	(NXGE_PHY_FIBRE << NXGE_PHY_SHIFT))
120 #define	NXGE_PORT_1G_SERDES	(NXGE_PORT_SPD_1G |	\
121 	(NXGE_PHY_SERDES << NXGE_PHY_SHIFT))
122 #define	NXGE_PORT_10G_SERDES	(NXGE_PORT_SPD_10G |	\
123 	(NXGE_PHY_SERDES << NXGE_PHY_SHIFT))
124 #define	NXGE_PORT_1G_RGMII_FIBER	(NXGE_PORT_SPD_1G |	\
125 	(NXGE_PHY_RGMII_FIBER << NXGE_PHY_SHIFT))
126 #define	NXGE_PORT_NONE		(NXGE_PORT_SPD_NONE |	\
127 	(NXGE_PHY_NONE << NXGE_PHY_SHIFT))
128 #define	NXGE_PORT_RSVD		(NXGE_PORT_SPD_RSVD |	\
129 	(NXGE_PHY_RSVD << NXGE_PHY_SHIFT))
130 
131 #define	NXGE_PORT_TYPE_MASK	(NXGE_PORT_SPD_MASK | NXGE_PHY_MASK)
132 
133 /* number of bits used for phy/spd encoding per port */
134 #define	NXGE_PORT_TYPE_SHIFT	4
135 
136 /* Network Modes */
137 
138 typedef enum nxge_network_mode {
139 	NET_2_10GE_FIBER = 1,
140 	NET_2_10GE_COPPER,
141 	NET_1_10GE_FIBER_3_1GE_COPPER,
142 	NET_1_10GE_COPPER_3_1GE_COPPER,
143 	NET_1_10GE_FIBER_3_1GE_FIBER,
144 	NET_1_10GE_COPPER_3_1GE_FIBER,
145 	NET_2_1GE_FIBER_2_1GE_COPPER,
146 	NET_QGE_FIBER,
147 	NET_QGE_COPPER
148 } nxge_network_mode_t;
149 
150 typedef	enum nxge_port {
151 	PORT_TYPE_XMAC = 1,
152 	PORT_TYPE_BMAC
153 } nxge_port_t;
154 
155 typedef	enum nxge_port_mode {
156 	PORT_1G_COPPER = 1,
157 	PORT_1G_FIBER,
158 	PORT_10G_COPPER,
159 	PORT_10G_FIBER,
160 	PORT_10G_SERDES,
161 	PORT_1G_SERDES,
162 	PORT_1G_RGMII_FIBER,
163 	PORT_HSP_MODE
164 } nxge_port_mode_t;
165 
166 typedef	enum nxge_linkchk_mode {
167 	LINKCHK_INTR = 1,
168 	LINKCHK_TIMER
169 } nxge_linkchk_mode_t;
170 
171 typedef enum {
172 	LINK_INTR_STOP,
173 	LINK_INTR_START
174 } link_intr_enable_t, *link_intr_enable_pt;
175 
176 typedef	enum {
177 	LINK_MONITOR_STOP,
178 	LINK_MONITOR_START,
179 	LINK_MONITOR_STOPPING
180 } link_mon_enable_t, *link_mon_enable_pt;
181 
182 typedef enum {
183 	NO_XCVR,
184 	INT_MII_XCVR,
185 	EXT_MII_XCVR,
186 	PCS_XCVR,
187 	XPCS_XCVR,
188 	HSP_XCVR
189 } xcvr_inuse_t;
190 
191 /* macros for port offset calculations */
192 
193 #define	PORT_1_OFFSET			0x6000
194 #define	PORT_GT_1_OFFSET		0x4000
195 
196 /* XMAC address macros */
197 
198 #define	XMAC_ADDR_OFFSET_0		0
199 #define	XMAC_ADDR_OFFSET_1		0x6000
200 
201 #define	XMAC_ADDR_OFFSET(port_num)\
202 	(XMAC_ADDR_OFFSET_0 + ((port_num) * PORT_1_OFFSET))
203 
204 #define	XMAC_REG_ADDR(port_num, reg)\
205 	(FZC_MAC + (XMAC_ADDR_OFFSET(port_num)) + (reg))
206 
207 #define	XMAC_PORT_ADDR(port_num)\
208 	(FZC_MAC + XMAC_ADDR_OFFSET(port_num))
209 
210 /* BMAC address macros */
211 
212 #define	BMAC_ADDR_OFFSET_2		0x0C000
213 #define	BMAC_ADDR_OFFSET_3		0x10000
214 
215 #define	BMAC_ADDR_OFFSET(port_num)\
216 	(BMAC_ADDR_OFFSET_2 + (((port_num) - 2) * PORT_GT_1_OFFSET))
217 
218 #define	BMAC_REG_ADDR(port_num, reg)\
219 	(FZC_MAC + (BMAC_ADDR_OFFSET(port_num)) + (reg))
220 
221 #define	BMAC_PORT_ADDR(port_num)\
222 	(FZC_MAC + BMAC_ADDR_OFFSET(port_num))
223 
224 /* PCS address macros */
225 
226 #define	PCS_ADDR_OFFSET_0		0x04000
227 #define	PCS_ADDR_OFFSET_1		0x0A000
228 #define	PCS_ADDR_OFFSET_2		0x0E000
229 #define	PCS_ADDR_OFFSET_3		0x12000
230 
231 #define	PCS_ADDR_OFFSET(port_num)\
232 	((port_num <= 1) ? \
233 	(PCS_ADDR_OFFSET_0 + (port_num) * PORT_1_OFFSET) : \
234 	(PCS_ADDR_OFFSET_2 + (((port_num) - 2) * PORT_GT_1_OFFSET)))
235 
236 #define	PCS_REG_ADDR(port_num, reg)\
237 	(FZC_MAC + (PCS_ADDR_OFFSET((port_num)) + (reg)))
238 
239 #define	PCS_PORT_ADDR(port_num)\
240 	(FZC_MAC + (PCS_ADDR_OFFSET(port_num)))
241 
242 /* XPCS address macros */
243 
244 #define	XPCS_ADDR_OFFSET_0		0x02000
245 #define	XPCS_ADDR_OFFSET_1		0x08000
246 #define	XPCS_ADDR_OFFSET(port_num)\
247 	(XPCS_ADDR_OFFSET_0 + ((port_num) * PORT_1_OFFSET))
248 
249 #define	XPCS_ADDR(port_num, reg)\
250 	(FZC_MAC + (XPCS_ADDR_OFFSET((port_num)) + (reg)))
251 
252 #define	XPCS_PORT_ADDR(port_num)\
253 	(FZC_MAC + (XPCS_ADDR_OFFSET(port_num)))
254 
255 /* ESR address macro */
256 #define	ESR_ADDR_OFFSET		0x14000
257 #define	ESR_ADDR(reg)\
258 	(FZC_MAC + (ESR_ADDR_OFFSET) + (reg))
259 
260 /* MIF address macros */
261 #define	MIF_ADDR_OFFSET		0x16000
262 #define	MIF_ADDR(reg)\
263 	(FZC_MAC + (MIF_ADDR_OFFSET) + (reg))
264 
265 /* BMAC registers offset */
266 #define	BTXMAC_SW_RST_REG		0x000	/* TX MAC software reset */
267 #define	BRXMAC_SW_RST_REG		0x008	/* RX MAC software reset */
268 #define	MAC_SEND_PAUSE_REG		0x010	/* send pause command */
269 #define	BTXMAC_STATUS_REG		0x020	/* TX MAC status */
270 #define	BRXMAC_STATUS_REG		0x028	/* RX MAC status */
271 #define	BMAC_CTRL_STAT_REG		0x030	/* MAC control status */
272 #define	BTXMAC_STAT_MSK_REG		0x040	/* TX MAC mask */
273 #define	BRXMAC_STAT_MSK_REG		0x048	/* RX MAC mask */
274 #define	BMAC_C_S_MSK_REG		0x050	/* MAC control mask */
275 #define	TXMAC_CONFIG_REG		0x060	/* TX MAC config */
276 /* cfg register bitmap */
277 
278 typedef union _btxmac_config_t {
279 	uint64_t value;
280 
281 	struct {
282 #if defined(_BIG_ENDIAN)
283 		uint32_t msw;	/* Most significant word */
284 		uint32_t lsw;	/* Least significant word */
285 #elif defined(_LITTLE_ENDIAN)
286 		uint32_t lsw;	/* Least significant word */
287 		uint32_t msw;	/* Most significant word */
288 #endif
289 	} val;
290 	struct {
291 #if defined(_BIG_ENDIAN)
292 		uint32_t	w1;
293 #endif
294 		struct {
295 #if defined(_BIT_FIELDS_HTOL)
296 			uint32_t rsrvd	: 22;
297 			uint32_t hdx_ctrl2	: 1;
298 			uint32_t no_fcs	: 1;
299 			uint32_t hdx_ctrl	: 7;
300 			uint32_t txmac_enable	: 1;
301 #elif defined(_BIT_FIELDS_LTOH)
302 			uint32_t txmac_enable	: 1;
303 			uint32_t hdx_ctrl	: 7;
304 			uint32_t no_fcs	: 1;
305 			uint32_t hdx_ctrl2	: 1;
306 			uint32_t rsrvd	: 22;
307 #endif
308 		} w0;
309 
310 #if defined(_LITTLE_ENDIAN)
311 		uint32_t	w1;
312 #endif
313 	} bits;
314 } btxmac_config_t, *p_btxmac_config_t;
315 
316 #define	RXMAC_CONFIG_REG		0x068	/* RX MAC config */
317 
318 typedef union _brxmac_config_t {
319 	uint64_t value;
320 
321 	struct {
322 #if defined(_BIG_ENDIAN)
323 		uint32_t msw;	/* Most significant word */
324 		uint32_t lsw;	/* Least significant word */
325 #elif defined(_LITTLE_ENDIAN)
326 		uint32_t lsw;	/* Least significant word */
327 		uint32_t msw;	/* Most significant word */
328 #endif
329 	} val;
330 	struct {
331 #if defined(_BIG_ENDIAN)
332 		uint32_t	w1;
333 #endif
334 		struct {
335 #if defined(_BIT_FIELDS_HTOL)
336 			uint32_t rsrvd	: 20;
337 			uint32_t mac_reg_sw_test : 2;
338 			uint32_t mac2ipp_pkt_cnt_en : 1;
339 			uint32_t rx_crs_extend_en : 1;
340 			uint32_t error_chk_dis	: 1;
341 			uint32_t addr_filter_en	: 1;
342 			uint32_t hash_filter_en	: 1;
343 			uint32_t promiscuous_group	: 1;
344 			uint32_t promiscuous	: 1;
345 			uint32_t strip_fcs	: 1;
346 			uint32_t strip_pad	: 1;
347 			uint32_t rxmac_enable	: 1;
348 #elif defined(_BIT_FIELDS_LTOH)
349 			uint32_t rxmac_enable	: 1;
350 			uint32_t strip_pad	: 1;
351 			uint32_t strip_fcs	: 1;
352 			uint32_t promiscuous	: 1;
353 			uint32_t promiscuous_group	: 1;
354 			uint32_t hash_filter_en	: 1;
355 			uint32_t addr_filter_en	: 1;
356 			uint32_t error_chk_dis	: 1;
357 			uint32_t rx_crs_extend_en : 1;
358 			uint32_t mac2ipp_pkt_cnt_en : 1;
359 			uint32_t mac_reg_sw_test : 2;
360 			uint32_t rsrvd	: 20;
361 #endif
362 		} w0;
363 
364 #if defined(_LITTLE_ENDIAN)
365 		uint32_t	w1;
366 #endif
367 	} bits;
368 } brxmac_config_t, *p_brxmac_config_t;
369 
370 #define	MAC_CTRL_CONFIG_REG		0x070	/* MAC control config */
371 #define	MAC_XIF_CONFIG_REG		0x078	/* XIF config */
372 
373 typedef union _bxif_config_t {
374 	uint64_t value;
375 
376 	struct {
377 #if defined(_BIG_ENDIAN)
378 		uint32_t msw;	/* Most significant word */
379 		uint32_t lsw;	/* Least significant word */
380 #elif defined(_LITTLE_ENDIAN)
381 		uint32_t lsw;	/* Least significant word */
382 		uint32_t msw;	/* Most significant word */
383 #endif
384 	} val;
385 	struct {
386 #if defined(_BIG_ENDIAN)
387 		uint32_t	w1;
388 #endif
389 		struct {
390 #if defined(_BIT_FIELDS_HTOL)
391 			uint32_t rsrvd2		: 24;
392 			uint32_t sel_clk_25mhz	: 1;
393 			uint32_t led_polarity	: 1;
394 			uint32_t force_led_on	: 1;
395 			uint32_t used		: 1;
396 			uint32_t gmii_mode	: 1;
397 			uint32_t rsrvd		: 1;
398 			uint32_t loopback	: 1;
399 			uint32_t tx_output_en	: 1;
400 #elif defined(_BIT_FIELDS_LTOH)
401 			uint32_t tx_output_en	: 1;
402 			uint32_t loopback	: 1;
403 			uint32_t rsrvd		: 1;
404 			uint32_t gmii_mode	: 1;
405 			uint32_t used		: 1;
406 			uint32_t force_led_on	: 1;
407 			uint32_t led_polarity	: 1;
408 			uint32_t sel_clk_25mhz	: 1;
409 			uint32_t rsrvd2		: 24;
410 #endif
411 		} w0;
412 
413 #if defined(_LITTLE_ENDIAN)
414 		uint32_t	w1;
415 #endif
416 	} bits;
417 } bxif_config_t, *p_bxif_config_t;
418 
419 #define	BMAC_MIN_REG			0x0a0	/* min frame size */
420 #define	BMAC_MAX_REG			0x0a8	/* max frame size reg */
421 #define	MAC_PA_SIZE_REG			0x0b0	/* num of preamble bytes */
422 #define	MAC_CTRL_TYPE_REG		0x0c8	/* type field of MAC ctrl */
423 #define	BMAC_ADDR0_REG			0x100	/* MAC unique ad0 reg (HI 0) */
424 #define	BMAC_ADDR1_REG			0x108	/* MAC unique ad1 reg */
425 #define	BMAC_ADDR2_REG			0x110	/* MAC unique ad2 reg */
426 #define	BMAC_ADDR3_REG			0x118	/* MAC alt ad0 reg (HI 1) */
427 #define	BMAC_ADDR4_REG			0x120	/* MAC alt ad0 reg */
428 #define	BMAC_ADDR5_REG			0x128	/* MAC alt ad0 reg */
429 #define	BMAC_ADDR6_REG			0x130	/* MAC alt ad1 reg (HI 2) */
430 #define	BMAC_ADDR7_REG			0x138	/* MAC alt ad1 reg */
431 #define	BMAC_ADDR8_REG			0x140	/* MAC alt ad1 reg */
432 #define	BMAC_ADDR9_REG			0x148	/* MAC alt ad2 reg (HI 3) */
433 #define	BMAC_ADDR10_REG			0x150	/* MAC alt ad2 reg */
434 #define	BMAC_ADDR11_REG			0x158	/* MAC alt ad2 reg */
435 #define	BMAC_ADDR12_REG			0x160	/* MAC alt ad3 reg (HI 4) */
436 #define	BMAC_ADDR13_REG			0x168	/* MAC alt ad3 reg */
437 #define	BMAC_ADDR14_REG			0x170	/* MAC alt ad3 reg */
438 #define	BMAC_ADDR15_REG			0x178	/* MAC alt ad4 reg (HI 5) */
439 #define	BMAC_ADDR16_REG			0x180	/* MAC alt ad4 reg */
440 #define	BMAC_ADDR17_REG			0x188	/* MAC alt ad4 reg */
441 #define	BMAC_ADDR18_REG			0x190	/* MAC alt ad5 reg (HI 6) */
442 #define	BMAC_ADDR19_REG			0x198	/* MAC alt ad5 reg */
443 #define	BMAC_ADDR20_REG			0x1a0	/* MAC alt ad5 reg */
444 #define	BMAC_ADDR21_REG			0x1a8	/* MAC alt ad6 reg (HI 7) */
445 #define	BMAC_ADDR22_REG			0x1b0	/* MAC alt ad6 reg */
446 #define	BMAC_ADDR23_REG			0x1b8	/* MAC alt ad6 reg */
447 #define	MAC_FC_ADDR0_REG		0x268	/* FC frame addr0 (HI 0, p3) */
448 #define	MAC_FC_ADDR1_REG		0x270	/* FC frame addr1 */
449 #define	MAC_FC_ADDR2_REG		0x278	/* FC frame addr2 */
450 #define	MAC_ADDR_FILT0_REG		0x298	/* bits [47:32] (HI 0, p2) */
451 #define	MAC_ADDR_FILT1_REG		0x2a0	/* bits [31:16] */
452 #define	MAC_ADDR_FILT2_REG		0x2a8	/* bits [15:0]  */
453 #define	MAC_ADDR_FILT12_MASK_REG 	0x2b0	/* addr filter 2 & 1 mask */
454 #define	MAC_ADDR_FILT00_MASK_REG	0x2b8	/* addr filter 0 mask */
455 #define	MAC_HASH_TBL0_REG		0x2c0	/* hash table 0 reg */
456 #define	MAC_HASH_TBL1_REG		0x2c8	/* hash table 1 reg */
457 #define	MAC_HASH_TBL2_REG		0x2d0	/* hash table 2 reg */
458 #define	MAC_HASH_TBL3_REG		0x2d8	/* hash table 3 reg */
459 #define	MAC_HASH_TBL4_REG		0x2e0	/* hash table 4 reg */
460 #define	MAC_HASH_TBL5_REG		0x2e8	/* hash table 5 reg */
461 #define	MAC_HASH_TBL6_REG		0x2f0	/* hash table 6 reg */
462 #define	MAC_HASH_TBL7_REG		0x2f8	/* hash table 7 reg */
463 #define	MAC_HASH_TBL8_REG		0x300	/* hash table 8 reg */
464 #define	MAC_HASH_TBL9_REG		0x308	/* hash table 9 reg */
465 #define	MAC_HASH_TBL10_REG		0x310	/* hash table 10 reg */
466 #define	MAC_HASH_TBL11_REG		0x318	/* hash table 11 reg */
467 #define	MAC_HASH_TBL12_REG		0x320	/* hash table 12 reg */
468 #define	MAC_HASH_TBL13_REG		0x328	/* hash table 13 reg */
469 #define	MAC_HASH_TBL14_REG		0x330	/* hash table 14 reg */
470 #define	MAC_HASH_TBL15_REG		0x338	/* hash table 15 reg */
471 #define	RXMAC_FRM_CNT_REG		0x370	/* receive frame counter */
472 #define	MAC_LEN_ER_CNT_REG		0x378	/* length error counter */
473 #define	BMAC_AL_ER_CNT_REG		0x380	/* alignment error counter */
474 #define	BMAC_CRC_ER_CNT_REG		0x388	/* FCS error counter */
475 #define	BMAC_CD_VIO_CNT_REG		0x390	/* RX code violation err */
476 #define	BMAC_SM_REG			0x3a0	/* (ro) state machine reg */
477 #define	BMAC_ALTAD_CMPEN_REG		0x3f8	/* Alt addr compare enable */
478 #define	BMAC_HOST_INF0_REG		0x400	/* Host info */
479 						/* (own da, add filter, fc) */
480 #define	BMAC_HOST_INF1_REG		0x408	/* Host info (alt ad 0) */
481 #define	BMAC_HOST_INF2_REG		0x410	/* Host info (alt ad 1) */
482 #define	BMAC_HOST_INF3_REG		0x418	/* Host info (alt ad 2) */
483 #define	BMAC_HOST_INF4_REG		0x420	/* Host info (alt ad 3) */
484 #define	BMAC_HOST_INF5_REG		0x428	/* Host info (alt ad 4) */
485 #define	BMAC_HOST_INF6_REG		0x430	/* Host info (alt ad 5) */
486 #define	BMAC_HOST_INF7_REG		0x438	/* Host info (alt ad 6) */
487 #define	BMAC_HOST_INF8_REG		0x440	/* Host info (hash hit, miss) */
488 #define	BTXMAC_BYTE_CNT_REG		0x448	/* Tx byte count */
489 #define	BTXMAC_FRM_CNT_REG		0x450	/* frame count */
490 #define	BRXMAC_BYTE_CNT_REG		0x458	/* Rx byte count */
491 /* x ranges from 0 to 6 (BMAC_MAX_ALT_ADDR_ENTRY - 1) */
492 #define	BMAC_ALT_ADDR0N_REG_ADDR(x)	(BMAC_ADDR3_REG + (x) * 24)
493 #define	BMAC_ALT_ADDR1N_REG_ADDR(x)	(BMAC_ADDR3_REG + 8 + (x) * 24)
494 #define	BMAC_ALT_ADDR2N_REG_ADDR(x)	(BMAC_ADDR3_REG + 0x10 + (x) * 24)
495 #define	BMAC_HASH_TBLN_REG_ADDR(x)	(MAC_HASH_TBL0_REG + (x) * 8)
496 #define	BMAC_HOST_INFN_REG_ADDR(x)	(BMAC_HOST_INF0_REG + (x) * 8)
497 
498 /* XMAC registers offset */
499 #define	XTXMAC_SW_RST_REG		0x000	/* XTX MAC soft reset */
500 #define	XRXMAC_SW_RST_REG		0x008	/* XRX MAC soft reset */
501 #define	XTXMAC_STATUS_REG		0x020	/* XTX MAC status */
502 #define	XRXMAC_STATUS_REG		0x028	/* XRX MAC status */
503 #define	XMAC_CTRL_STAT_REG		0x030	/* Control / Status */
504 #define	XTXMAC_STAT_MSK_REG		0x040	/* XTX MAC Status mask */
505 #define	XRXMAC_STAT_MSK_REG		0x048	/* XRX MAC Status mask */
506 #define	XMAC_C_S_MSK_REG		0x050	/* Control / Status mask */
507 #define	XMAC_CONFIG_REG			0x060	/* Configuration */
508 
509 /* xmac config bit fields */
510 typedef union _xmac_cfg_t {
511 	uint64_t value;
512 
513 	struct {
514 #if defined(_BIG_ENDIAN)
515 		uint32_t msw;	/* Most significant word */
516 		uint32_t lsw;	/* Least significant word */
517 #elif defined(_LITTLE_ENDIAN)
518 		uint32_t lsw;	/* Least significant word */
519 		uint32_t msw;	/* Most significant word */
520 #endif
521 	} val;
522 	struct {
523 #if defined(_BIG_ENDIAN)
524 		uint32_t	w1;
525 #endif
526 		struct {
527 #if defined(_BIT_FIELDS_HTOL)
528 		uint32_t sel_clk_25mhz : 1;
529 		uint32_t pcs_bypass	: 1;
530 		uint32_t xpcs_bypass	: 1;
531 		uint32_t mii_gmii_mode	: 2;
532 		uint32_t lfs_disable	: 1;
533 		uint32_t loopback	: 1;
534 		uint32_t tx_output_en	: 1;
535 		uint32_t sel_por_clk_src : 1;
536 		uint32_t led_polarity	: 1;
537 		uint32_t force_led_on	: 1;
538 		uint32_t pass_fctl_frames : 1;
539 		uint32_t recv_pause_en	: 1;
540 		uint32_t mac2ipp_pkt_cnt_en : 1;
541 		uint32_t strip_crc	: 1;
542 		uint32_t addr_filter_en	: 1;
543 		uint32_t hash_filter_en	: 1;
544 		uint32_t code_viol_chk_dis	: 1;
545 		uint32_t reserved_mcast	: 1;
546 		uint32_t rx_crc_chk_dis	: 1;
547 		uint32_t error_chk_dis	: 1;
548 		uint32_t promisc_grp	: 1;
549 		uint32_t promiscuous	: 1;
550 		uint32_t rx_mac_enable	: 1;
551 		uint32_t warning_msg_en	: 1;
552 		uint32_t used		: 3;
553 		uint32_t always_no_crc	: 1;
554 		uint32_t var_min_ipg_en	: 1;
555 		uint32_t strech_mode	: 1;
556 		uint32_t tx_enable	: 1;
557 #elif defined(_BIT_FIELDS_LTOH)
558 		uint32_t tx_enable	: 1;
559 		uint32_t strech_mode	: 1;
560 		uint32_t var_min_ipg_en	: 1;
561 		uint32_t always_no_crc	: 1;
562 		uint32_t used		: 3;
563 		uint32_t warning_msg_en	: 1;
564 		uint32_t rx_mac_enable	: 1;
565 		uint32_t promiscuous	: 1;
566 		uint32_t promisc_grp	: 1;
567 		uint32_t error_chk_dis	: 1;
568 		uint32_t rx_crc_chk_dis	: 1;
569 		uint32_t reserved_mcast	: 1;
570 		uint32_t code_viol_chk_dis	: 1;
571 		uint32_t hash_filter_en	: 1;
572 		uint32_t addr_filter_en	: 1;
573 		uint32_t strip_crc	: 1;
574 		uint32_t mac2ipp_pkt_cnt_en : 1;
575 		uint32_t recv_pause_en	: 1;
576 		uint32_t pass_fctl_frames : 1;
577 		uint32_t force_led_on	: 1;
578 		uint32_t led_polarity	: 1;
579 		uint32_t sel_por_clk_src : 1;
580 		uint32_t tx_output_en	: 1;
581 		uint32_t loopback	: 1;
582 		uint32_t lfs_disable	: 1;
583 		uint32_t mii_gmii_mode	: 2;
584 		uint32_t xpcs_bypass	: 1;
585 		uint32_t pcs_bypass	: 1;
586 		uint32_t sel_clk_25mhz : 1;
587 #endif
588 		} w0;
589 
590 #if defined(_LITTLE_ENDIAN)
591 		uint32_t	w1;
592 #endif
593 	} bits;
594 } xmac_cfg_t, *p_xmac_cfg_t;
595 
596 #define	XMAC_IPG_REG			0x080	/* Inter-Packet-Gap */
597 #define	XMAC_MIN_REG			0x088	/* min frame size register */
598 #define	XMAC_MAX_REG			0x090	/* max frame/burst size */
599 #define	XMAC_ADDR0_REG			0x0a0	/* [47:32] of MAC addr (HI17) */
600 #define	XMAC_ADDR1_REG			0x0a8	/* [31:16] of MAC addr */
601 #define	XMAC_ADDR2_REG			0x0b0	/* [15:0] of MAC addr */
602 #define	XRXMAC_BT_CNT_REG		0x100	/* bytes received / 8 */
603 #define	XRXMAC_BC_FRM_CNT_REG		0x108	/* good BC frames received */
604 #define	XRXMAC_MC_FRM_CNT_REG		0x110	/* good MC frames received */
605 #define	XRXMAC_FRAG_CNT_REG		0x118	/* frag frames rejected */
606 #define	XRXMAC_HIST_CNT1_REG		0x120	/* 64 bytes frames */
607 #define	XRXMAC_HIST_CNT2_REG		0x128	/* 65-127 bytes frames */
608 #define	XRXMAC_HIST_CNT3_REG		0x130	/* 128-255 bytes frames */
609 #define	XRXMAC_HIST_CNT4_REG		0x138	/* 256-511 bytes frames */
610 #define	XRXMAC_HIST_CNT5_REG		0x140	/* 512-1023 bytes frames */
611 #define	XRXMAC_HIST_CNT6_REG		0x148	/* 1024-1522 bytes frames */
612 #define	XRXMAC_MPSZER_CNT_REG		0x150	/* frames > maxframesize */
613 #define	XRXMAC_CRC_ER_CNT_REG		0x158	/* frames failed CRC */
614 #define	XRXMAC_CD_VIO_CNT_REG		0x160	/* frames with code vio */
615 #define	XRXMAC_AL_ER_CNT_REG		0x168	/* frames with align error */
616 #define	XTXMAC_FRM_CNT_REG		0x170	/* tx frames */
617 #define	XTXMAC_BYTE_CNT_REG		0x178	/* tx bytes / 8 */
618 #define	XMAC_LINK_FLT_CNT_REG		0x180	/* link faults */
619 #define	XRXMAC_HIST_CNT7_REG		0x188	/* MAC2IPP/>1523 bytes frames */
620 #define	XMAC_SM_REG			0x1a8	/* State machine */
621 #define	XMAC_INTERN1_REG		0x1b0	/* internal signals for diag */
622 #define	XMAC_INTERN2_REG		0x1b8	/* internal signals for diag */
623 #define	XMAC_ADDR_CMPEN_REG		0x208	/* alt MAC addr check */
624 #define	XMAC_ADDR3_REG			0x218	/* alt MAC addr 0 (HI 0) */
625 #define	XMAC_ADDR4_REG			0x220	/* alt MAC addr 0 */
626 #define	XMAC_ADDR5_REG			0x228	/* alt MAC addr 0 */
627 #define	XMAC_ADDR6_REG			0x230	/* alt MAC addr 1 (HI 1) */
628 #define	XMAC_ADDR7_REG			0x238	/* alt MAC addr 1 */
629 #define	XMAC_ADDR8_REG			0x240	/* alt MAC addr 1 */
630 #define	XMAC_ADDR9_REG			0x248	/* alt MAC addr 2 (HI 2) */
631 #define	XMAC_ADDR10_REG			0x250	/* alt MAC addr 2 */
632 #define	XMAC_ADDR11_REG			0x258	/* alt MAC addr 2 */
633 #define	XMAC_ADDR12_REG			0x260	/* alt MAC addr 3 (HI 3) */
634 #define	XMAC_ADDR13_REG			0x268	/* alt MAC addr 3 */
635 #define	XMAC_ADDR14_REG			0x270	/* alt MAC addr 3 */
636 #define	XMAC_ADDR15_REG			0x278	/* alt MAC addr 4 (HI 4) */
637 #define	XMAC_ADDR16_REG			0x280	/* alt MAC addr 4 */
638 #define	XMAC_ADDR17_REG			0x288	/* alt MAC addr 4 */
639 #define	XMAC_ADDR18_REG			0x290	/* alt MAC addr 5 (HI 5) */
640 #define	XMAC_ADDR19_REG			0x298	/* alt MAC addr 5 */
641 #define	XMAC_ADDR20_REG			0x2a0	/* alt MAC addr 5 */
642 #define	XMAC_ADDR21_REG			0x2a8	/* alt MAC addr 6 (HI 6) */
643 #define	XMAC_ADDR22_REG			0x2b0	/* alt MAC addr 6 */
644 #define	XMAC_ADDR23_REG			0x2b8	/* alt MAC addr 6 */
645 #define	XMAC_ADDR24_REG			0x2c0	/* alt MAC addr 7 (HI 7) */
646 #define	XMAC_ADDR25_REG			0x2c8	/* alt MAC addr 7 */
647 #define	XMAC_ADDR26_REG			0x2d0	/* alt MAC addr 7 */
648 #define	XMAC_ADDR27_REG			0x2d8	/* alt MAC addr 8 (HI 8) */
649 #define	XMAC_ADDR28_REG			0x2e0	/* alt MAC addr 8 */
650 #define	XMAC_ADDR29_REG			0x2e8	/* alt MAC addr 8 */
651 #define	XMAC_ADDR30_REG			0x2f0	/* alt MAC addr 9 (HI 9) */
652 #define	XMAC_ADDR31_REG			0x2f8	/* alt MAC addr 9 */
653 #define	XMAC_ADDR32_REG			0x300	/* alt MAC addr 9 */
654 #define	XMAC_ADDR33_REG			0x308	/* alt MAC addr 10 (HI 10) */
655 #define	XMAC_ADDR34_REG			0x310	/* alt MAC addr 10 */
656 #define	XMAC_ADDR35_REG			0x318	/* alt MAC addr 10 */
657 #define	XMAC_ADDR36_REG			0x320	/* alt MAC addr 11 (HI 11) */
658 #define	XMAC_ADDR37_REG			0x328	/* alt MAC addr 11 */
659 #define	XMAC_ADDR38_REG			0x330	/* alt MAC addr 11 */
660 #define	XMAC_ADDR39_REG			0x338	/* alt MAC addr 12 (HI 12) */
661 #define	XMAC_ADDR40_REG			0x340	/* alt MAC addr 12 */
662 #define	XMAC_ADDR41_REG			0x348	/* alt MAC addr 12 */
663 #define	XMAC_ADDR42_REG			0x350	/* alt MAC addr 13 (HI 13) */
664 #define	XMAC_ADDR43_REG			0x358	/* alt MAC addr 13 */
665 #define	XMAC_ADDR44_REG			0x360	/* alt MAC addr 13 */
666 #define	XMAC_ADDR45_REG			0x368	/* alt MAC addr 14 (HI 14) */
667 #define	XMAC_ADDR46_REG			0x370	/* alt MAC addr 14 */
668 #define	XMAC_ADDR47_REG			0x378	/* alt MAC addr 14 */
669 #define	XMAC_ADDR48_REG			0x380	/* alt MAC addr 15 (HI 15) */
670 #define	XMAC_ADDR49_REG			0x388	/* alt MAC addr 15 */
671 #define	XMAC_ADDR50_REG			0x390	/* alt MAC addr 15 */
672 #define	XMAC_ADDR_FILT0_REG		0x818	/* [47:32] addr filter (HI18) */
673 #define	XMAC_ADDR_FILT1_REG		0x820	/* [31:16] of addr filter */
674 #define	XMAC_ADDR_FILT2_REG		0x828	/* [15:0] of addr filter */
675 #define	XMAC_ADDR_FILT12_MASK_REG 	0x830	/* addr filter 2 & 1 mask */
676 #define	XMAC_ADDR_FILT0_MASK_REG	0x838	/* addr filter 0 mask */
677 #define	XMAC_HASH_TBL0_REG		0x840	/* hash table 0 reg */
678 #define	XMAC_HASH_TBL1_REG		0x848	/* hash table 1 reg */
679 #define	XMAC_HASH_TBL2_REG		0x850	/* hash table 2 reg */
680 #define	XMAC_HASH_TBL3_REG		0x858	/* hash table 3 reg */
681 #define	XMAC_HASH_TBL4_REG		0x860	/* hash table 4 reg */
682 #define	XMAC_HASH_TBL5_REG		0x868	/* hash table 5 reg */
683 #define	XMAC_HASH_TBL6_REG		0x870	/* hash table 6 reg */
684 #define	XMAC_HASH_TBL7_REG		0x878	/* hash table 7 reg */
685 #define	XMAC_HASH_TBL8_REG		0x880	/* hash table 8 reg */
686 #define	XMAC_HASH_TBL9_REG		0x888	/* hash table 9 reg */
687 #define	XMAC_HASH_TBL10_REG		0x890	/* hash table 10 reg */
688 #define	XMAC_HASH_TBL11_REG		0x898	/* hash table 11 reg */
689 #define	XMAC_HASH_TBL12_REG		0x8a0	/* hash table 12 reg */
690 #define	XMAC_HASH_TBL13_REG		0x8a8	/* hash table 13 reg */
691 #define	XMAC_HASH_TBL14_REG		0x8b0	/* hash table 14 reg */
692 #define	XMAC_HASH_TBL15_REG		0x8b8	/* hash table 15 reg */
693 #define	XMAC_HOST_INF0_REG		0x900	/* Host info 0 (alt ad 0) */
694 #define	XMAC_HOST_INF1_REG		0x908	/* Host info 1 (alt ad 1) */
695 #define	XMAC_HOST_INF2_REG		0x910	/* Host info 2 (alt ad 2) */
696 #define	XMAC_HOST_INF3_REG		0x918	/* Host info 3 (alt ad 3) */
697 #define	XMAC_HOST_INF4_REG		0x920	/* Host info 4 (alt ad 4) */
698 #define	XMAC_HOST_INF5_REG		0x928	/* Host info 5 (alt ad 5) */
699 #define	XMAC_HOST_INF6_REG		0x930	/* Host info 6 (alt ad 6) */
700 #define	XMAC_HOST_INF7_REG		0x938	/* Host info 7 (alt ad 7) */
701 #define	XMAC_HOST_INF8_REG		0x940	/* Host info 8 (alt ad 8) */
702 #define	XMAC_HOST_INF9_REG		0x948	/* Host info 9 (alt ad 9) */
703 #define	XMAC_HOST_INF10_REG		0x950	/* Host info 10 (alt ad 10) */
704 #define	XMAC_HOST_INF11_REG		0x958	/* Host info 11 (alt ad 11) */
705 #define	XMAC_HOST_INF12_REG		0x960	/* Host info 12 (alt ad 12) */
706 #define	XMAC_HOST_INF13_REG		0x968	/* Host info 13 (alt ad 13) */
707 #define	XMAC_HOST_INF14_REG		0x970	/* Host info 14 (alt ad 14) */
708 #define	XMAC_HOST_INF15_REG		0x978	/* Host info 15 (alt ad 15) */
709 #define	XMAC_HOST_INF16_REG		0x980	/* Host info 16 (hash hit) */
710 #define	XMAC_HOST_INF17_REG		0x988	/* Host info 17 (own da) */
711 #define	XMAC_HOST_INF18_REG		0x990	/* Host info 18 (filter hit) */
712 #define	XMAC_HOST_INF19_REG		0x998	/* Host info 19 (fc hit) */
713 #define	XMAC_PA_DATA0_REG		0xb80	/* preamble [31:0] */
714 #define	XMAC_PA_DATA1_REG		0xb88	/* preamble [63:32] */
715 #define	XMAC_DEBUG_SEL_REG		0xb90	/* debug select */
716 #define	XMAC_TRAINING_VECT_REG		0xb98	/* training vector */
717 /* x ranges from 0 to 15 (XMAC_MAX_ALT_ADDR_ENTRY - 1) */
718 #define	XMAC_ALT_ADDR0N_REG_ADDR(x)	(XMAC_ADDR3_REG + (x) * 24)
719 #define	XMAC_ALT_ADDR1N_REG_ADDR(x)	(XMAC_ADDR3_REG + 8 + (x) * 24)
720 #define	XMAC_ALT_ADDR2N_REG_ADDR(x)	(XMAC_ADDR3_REG + 16 + (x) * 24)
721 #define	XMAC_HASH_TBLN_REG_ADDR(x)	(XMAC_HASH_TBL0_REG + (x) * 8)
722 #define	XMAC_HOST_INFN_REG_ADDR(x)	(XMAC_HOST_INF0_REG + (x) * 8)
723 
724 /* MIF registers offset */
725 #define	MIF_BB_MDC_REG			0	   /* MIF bit-bang clock */
726 #define	MIF_BB_MDO_REG			0x008	   /* MIF bit-bang data */
727 #define	MIF_BB_MDO_EN_REG		0x010	   /* MIF bit-bang output en */
728 #define	MIF_OUTPUT_FRAME_REG		0x018	   /* MIF frame/output reg */
729 #define	MIF_CONFIG_REG			0x020	   /* MIF config reg */
730 #define	MIF_POLL_STATUS_REG		0x028	   /* MIF poll status reg */
731 #define	MIF_POLL_MASK_REG		0x030	   /* MIF poll mask reg */
732 #define	MIF_STATE_MACHINE_REG		0x038	   /* MIF state machine reg */
733 #define	MIF_STATUS_REG			0x040	   /* MIF status reg */
734 #define	MIF_MASK_REG			0x048	   /* MIF mask reg */
735 
736 
737 /* PCS registers offset */
738 #define	PCS_MII_CTRL_REG		0	   /* PCS MII control reg */
739 #define	PCS_MII_STATUS_REG		0x008	   /* PCS MII status reg */
740 #define	PCS_MII_ADVERT_REG		0x010	   /* PCS MII advertisement */
741 #define	PCS_MII_LPA_REG			0x018	   /* link partner ability */
742 #define	PCS_CONFIG_REG			0x020	   /* PCS config reg */
743 #define	PCS_STATE_MACHINE_REG		0x028	   /* PCS state machine */
744 #define	PCS_INTR_STATUS_REG		0x030	/* PCS interrupt status */
745 #define	PCS_DATAPATH_MODE_REG		0x0a0	   /* datapath mode reg */
746 #define	PCS_PACKET_COUNT_REG		0x0c0	   /* PCS packet counter */
747 
748 #define	XPCS_CTRL_1_REG			0	/* Control */
749 #define	XPCS_STATUS_1_REG		0x008
750 #define	XPCS_DEV_ID_REG			0x010	/* 32bits IEEE manufacture ID */
751 #define	XPCS_SPEED_ABILITY_REG		0x018
752 #define	XPCS_DEV_IN_PKG_REG		0x020
753 #define	XPCS_CTRL_2_REG			0x028
754 #define	XPCS_STATUS_2_REG		0x030
755 #define	XPCS_PKG_ID_REG			0x038	/* Package ID */
756 #define	XPCS_STATUS_REG			0x040
757 #define	XPCS_TEST_CTRL_REG		0x048
758 #define	XPCS_CFG_VENDOR_1_REG		0x050
759 #define	XPCS_DIAG_VENDOR_2_REG		0x058
760 #define	XPCS_MASK_1_REG			0x060
761 #define	XPCS_PKT_CNTR_REG		0x068
762 #define	XPCS_TX_STATE_MC_REG		0x070
763 #define	XPCS_DESKEW_ERR_CNTR_REG	0x078
764 #define	XPCS_SYM_ERR_CNTR_L0_L1_REG	0x080
765 #define	XPCS_SYM_ERR_CNTR_L2_L3_REG	0x088
766 #define	XPCS_TRAINING_VECTOR_REG	0x090
767 
768 /* ESR registers offset */
769 #define	ESR_RESET_REG			0
770 #define	ESR_CONFIG_REG			0x008
771 #define	ESR_0_PLL_CONFIG_REG		0x010
772 #define	ESR_0_CONTROL_REG		0x018
773 #define	ESR_0_TEST_CONFIG_REG		0x020
774 #define	ESR_1_PLL_CONFIG_REG		0x028
775 #define	ESR_1_CONTROL_REG		0x030
776 #define	ESR_1_TEST_CONFIG_REG		0x038
777 #define	ESR_ENET_RGMII_CFG_REG		0x040
778 #define	ESR_INTERNAL_SIGNALS_REG	0x800
779 #define	ESR_DEBUG_SEL_REG		0x808
780 
781 
782 /* Reset Register */
783 #define	MAC_SEND_PAUSE_TIME_MASK	0x0000FFFF /* value of pause time */
784 #define	MAC_SEND_PAUSE_SEND		0x00010000 /* send pause flow ctrl */
785 
786 /* Tx MAC Status Register */
787 #define	MAC_TX_FRAME_XMIT		0x00000001 /* successful tx frame */
788 #define	MAC_TX_UNDERRUN			0x00000002 /* starvation in xmit */
789 #define	MAC_TX_MAX_PACKET_ERR		0x00000004 /* TX frame exceeds max */
790 #define	MAC_TX_BYTE_CNT_EXP		0x00000400 /* TX byte cnt overflow */
791 #define	MAC_TX_FRAME_CNT_EXP		0x00000800 /* Tx frame cnt overflow */
792 
793 /* Rx MAC Status Register */
794 #define	MAC_RX_FRAME_RECV		0x00000001 /* successful rx frame */
795 #define	MAC_RX_OVERFLOW			0x00000002 /* RX FIFO overflow */
796 #define	MAC_RX_FRAME_COUNT		0x00000004 /* rx frame cnt rollover */
797 #define	MAC_RX_ALIGN_ERR		0x00000008 /* alignment err rollover */
798 #define	MAC_RX_CRC_ERR			0x00000010 /* crc error cnt rollover */
799 #define	MAC_RX_LEN_ERR			0x00000020 /* length err cnt rollover */
800 #define	MAC_RX_VIOL_ERR			0x00000040 /* code vio err rollover */
801 #define	MAC_RX_BYTE_CNT_EXP		0x00000080 /* RX MAC byte rollover */
802 
803 /* MAC Control Status Register */
804 #define	MAC_CTRL_PAUSE_RECEIVED		0x00000001 /* successful pause frame */
805 #define	MAC_CTRL_PAUSE_STATE		0x00000002 /* notpause-->pause */
806 #define	MAC_CTRL_NOPAUSE_STATE		0x00000004 /* pause-->notpause */
807 #define	MAC_CTRL_PAUSE_TIME_MASK	0xFFFF0000 /* value of pause time */
808 #define	MAC_CTRL_PAUSE_TIME_SHIFT	16
809 
810 /* Tx MAC Configuration Register */
811 #define	MAC_TX_CFG_TXMAC_ENABLE		0x00000001 /* enable TX MAC. */
812 #define	MAC_TX_CFG_NO_FCS		0x00000100 /* TX not generate CRC */
813 
814 /* Rx MAC Configuration Register */
815 #define	MAC_RX_CFG_RXMAC_ENABLE		0x00000001 /* enable RX MAC */
816 #define	MAC_RX_CFG_STRIP_PAD		0x00000002 /* not supported, set to 0 */
817 #define	MAC_RX_CFG_STRIP_FCS		0x00000004 /* strip last 4bytes (CRC) */
818 #define	MAC_RX_CFG_PROMISC		0x00000008 /* promisc mode enable */
819 #define	MAC_RX_CFG_PROMISC_GROUP  	0x00000010 /* accept all MC frames */
820 #define	MAC_RX_CFG_HASH_FILTER_EN	0x00000020 /* use hash table */
821 #define	MAC_RX_CFG_ADDR_FILTER_EN    	0x00000040 /* use address filter */
822 #define	MAC_RX_CFG_DISABLE_DISCARD	0x00000080 /* do not set abort bit */
823 #define	MAC_RX_MAC2IPP_PKT_CNT_EN	0x00000200 /* rx pkt cnt -> BMAC-IPP */
824 #define	MAC_RX_MAC_REG_RW_TEST_MASK	0x00000c00 /* BMAC reg RW test */
825 #define	MAC_RX_MAC_REG_RW_TEST_SHIFT	10
826 
827 /* MAC Control Configuration Register */
828 #define	MAC_CTRL_CFG_SEND_PAUSE_EN	0x00000001 /* send pause flow ctrl */
829 #define	MAC_CTRL_CFG_RECV_PAUSE_EN	0x00000002 /* receive pause flow ctrl */
830 #define	MAC_CTRL_CFG_PASS_CTRL		0x00000004 /* accept MAC ctrl pkts */
831 
832 /* MAC XIF Configuration Register */
833 #define	MAC_XIF_TX_OUTPUT_EN		0x00000001 /* enable Tx output driver */
834 #define	MAC_XIF_MII_INT_LOOPBACK	0x00000002 /* loopback GMII xmit data */
835 #define	MAC_XIF_GMII_MODE		0x00000008 /* operates with GMII clks */
836 #define	MAC_XIF_LINK_LED		0x00000020 /* LINKLED# active (low) */
837 #define	MAC_XIF_LED_POLARITY		0x00000040 /* LED polarity */
838 #define	MAC_XIF_SEL_CLK_25MHZ		0x00000080 /* Select 10/100Mbps */
839 
840 /* MAC IPG Registers */
841 #define	BMAC_MIN_FRAME_MASK		0x3FF	   /* 10-bit reg */
842 
843 /* MAC Max Frame Size Register */
844 #define	BMAC_MAX_BURST_MASK    		0x3FFF0000 /* max burst size [30:16] */
845 #define	BMAC_MAX_BURST_SHIFT   		16
846 #define	BMAC_MAX_FRAME_MASK    		0x00007FFF /* max frame size [14:0] */
847 #define	BMAC_MAX_FRAME_SHIFT   		0
848 
849 /* MAC Preamble size register */
850 #define	BMAC_PA_SIZE_MASK		0x000003FF
851 	/* # of preable bytes TxMAC sends at the beginning of each frame */
852 
853 /*
854  * mac address registers:
855  *	register	contains			comparison
856  *	--------	--------			----------
857  *	0		16 MSB of primary MAC addr	[47:32] of DA field
858  *	1		16 middle bits ""		[31:16] of DA field
859  *	2		16 LSB ""			[15:0] of DA field
860  *	3*x		16MSB of alt MAC addr 1-7	[47:32] of DA field
861  *	4*x		16 middle bits ""		[31:16]
862  *	5*x		16 LSB ""			[15:0]
863  *	42		16 MSB of MAC CTRL addr		[47:32] of DA.
864  *	43		16 middle bits ""		[31:16]
865  *	44		16 LSB ""			[15:0]
866  *	MAC CTRL addr must be the reserved multicast addr for MAC CTRL frames.
867  *	if there is a match, MAC will set the bit for alternative address
868  *	filter pass [15]
869  *
870  *	here is the map of registers given MAC address notation: a:b:c:d:e:f
871  *			ab		cd		ef
872  *	primary addr	reg 2		reg 1		reg 0
873  *	alt addr 1	reg 5		reg 4		reg 3
874  *	alt addr x	reg 5*x		reg 4*x		reg 3*x
875  *	|		|		|		|
876  *	|		|		|		|
877  *	alt addr 7	reg 23		reg 22		reg 21
878  *	ctrl addr	reg 44		reg 43		reg 42
879  */
880 
881 #define	BMAC_ALT_ADDR_BASE		0x118
882 #define	BMAC_MAX_ALT_ADDR_ENTRY		7	   /* 7 alternate MAC addr */
883 #define	BMAC_MAX_ADDR_ENTRY		(BMAC_MAX_ALT_ADDR_ENTRY + 1)
884 
885 /* hash table registers */
886 #define	MAC_MAX_HASH_ENTRY		16
887 
888 /* 27-bit register has the current state for key state machines in the MAC */
889 #define	MAC_SM_RLM_MASK			0x07800000
890 #define	MAC_SM_RLM_SHIFT		23
891 #define	MAC_SM_RX_FC_MASK		0x00700000
892 #define	MAC_SM_RX_FC_SHIFT		20
893 #define	MAC_SM_TLM_MASK			0x000F0000
894 #define	MAC_SM_TLM_SHIFT		16
895 #define	MAC_SM_ENCAP_SM_MASK		0x0000F000
896 #define	MAC_SM_ENCAP_SM_SHIFT		12
897 #define	MAC_SM_TX_REQ_MASK		0x00000C00
898 #define	MAC_SM_TX_REQ_SHIFT		10
899 #define	MAC_SM_TX_FC_MASK		0x000003C0
900 #define	MAC_SM_TX_FC_SHIFT		6
901 #define	MAC_SM_FIFO_WRITE_SEL_MASK	0x00000038
902 #define	MAC_SM_FIFO_WRITE_SEL_SHIFT	3
903 #define	MAC_SM_TX_FIFO_EMPTY_MASK	0x00000007
904 #define	MAC_SM_TX_FIFO_EMPTY_SHIFT	0
905 
906 #define	BMAC_ADDR0_CMPEN		0x00000001
907 #define	BMAC_ADDRN_CMPEN(x)		(BMAC_ADDR0_CMP_EN << (x))
908 
909 /* MAC Host Info Table Registers */
910 #define	BMAC_MAX_HOST_INFO_ENTRY	9 	/* 9 host entries */
911 
912 /*
913  * ********************* XMAC registers *********************************
914  */
915 
916 /* Reset Register */
917 #define	XTXMAC_SOFT_RST			0x00000001 /* XTX MAC software reset */
918 #define	XTXMAC_REG_RST			0x00000002 /* XTX MAC registers reset */
919 #define	XRXMAC_SOFT_RST			0x00000001 /* XRX MAC software reset */
920 #define	XRXMAC_REG_RST			0x00000002 /* XRX MAC registers reset */
921 
922 /* XTX MAC Status Register */
923 #define	XMAC_TX_FRAME_XMIT		0x00000001 /* successful tx frame */
924 #define	XMAC_TX_UNDERRUN		0x00000002 /* starvation in xmit */
925 #define	XMAC_TX_MAX_PACKET_ERR		0x00000004 /* XTX frame exceeds max */
926 #define	XMAC_TX_OVERFLOW		0x00000008 /* XTX byte cnt overflow */
927 #define	XMAC_TX_FIFO_XFR_ERR		0x00000010 /* xtlm state mach error */
928 #define	XMAC_TX_BYTE_CNT_EXP		0x00000400 /* XTX byte cnt overflow */
929 #define	XMAC_TX_FRAME_CNT_EXP		0x00000800 /* XTX frame cnt overflow */
930 
931 /* XRX MAC Status Register */
932 #define	XMAC_RX_FRAME_RCVD		0x00000001 /* successful rx frame */
933 #define	XMAC_RX_OVERFLOW		0x00000002 /* RX FIFO overflow */
934 #define	XMAC_RX_UNDERFLOW		0x00000004 /* RX FIFO underrun */
935 #define	XMAC_RX_CRC_ERR_CNT_EXP		0x00000008 /* crc error cnt rollover */
936 #define	XMAC_RX_LEN_ERR_CNT_EXP		0x00000010 /* length err cnt rollover */
937 #define	XMAC_RX_VIOL_ERR_CNT_EXP	0x00000020 /* code vio err rollover */
938 #define	XMAC_RX_OCT_CNT_EXP		0x00000040 /* XRX MAC byte rollover */
939 #define	XMAC_RX_HST_CNT1_EXP		0x00000080 /* XRX MAC hist1 rollover */
940 #define	XMAC_RX_HST_CNT2_EXP		0x00000100 /* XRX MAC hist2 rollover */
941 #define	XMAC_RX_HST_CNT3_EXP		0x00000200 /* XRX MAC hist3 rollover */
942 #define	XMAC_RX_HST_CNT4_EXP		0x00000400 /* XRX MAC hist4 rollover */
943 #define	XMAC_RX_HST_CNT5_EXP		0x00000800 /* XRX MAC hist5 rollover */
944 #define	XMAC_RX_HST_CNT6_EXP		0x00001000 /* XRX MAC hist6 rollover */
945 #define	XMAC_RX_BCAST_CNT_EXP		0x00002000 /* XRX BC cnt rollover */
946 #define	XMAC_RX_MCAST_CNT_EXP		0x00004000 /* XRX MC cnt rollover */
947 #define	XMAC_RX_FRAG_CNT_EXP		0x00008000 /* fragment cnt rollover */
948 #define	XMAC_RX_ALIGNERR_CNT_EXP	0x00010000 /* framealign err rollover */
949 #define	XMAC_RX_LINK_FLT_CNT_EXP	0x00020000 /* link fault cnt rollover */
950 #define	XMAC_RX_REMOTE_FLT_DET		0x00040000 /* Remote Fault detected */
951 #define	XMAC_RX_LOCAL_FLT_DET		0x00080000 /* Local Fault detected */
952 #define	XMAC_RX_HST_CNT7_EXP		0x00100000 /* XRX MAC hist7 rollover */
953 
954 
955 #define	XMAC_CTRL_PAUSE_RCVD		0x00000001 /* successful pause frame */
956 #define	XMAC_CTRL_PAUSE_STATE		0x00000002 /* notpause-->pause */
957 #define	XMAC_CTRL_NOPAUSE_STATE		0x00000004 /* pause-->notpause */
958 #define	XMAC_CTRL_PAUSE_TIME_MASK	0xFFFF0000 /* value of pause time */
959 #define	XMAC_CTRL_PAUSE_TIME_SHIFT	16
960 
961 /* XMAC Configuration Register */
962 #define	XMAC_CONFIG_TX_BIT_MASK		0x000000ff /* bits [7:0] */
963 #define	XMAC_CONFIG_RX_BIT_MASK		0x001fff00 /* bits [20:8] */
964 #define	XMAC_CONFIG_XIF_BIT_MASK	0xffe00000 /* bits [31:21] */
965 
966 /* XTX MAC config bits */
967 #define	XMAC_TX_CFG_TX_ENABLE		0x00000001 /* enable XTX MAC */
968 #define	XMAC_TX_CFG_STRETCH_MD		0x00000002 /* WAN application */
969 #define	XMAC_TX_CFG_VAR_MIN_IPG_EN	0x00000004 /* Transmit pkts < minpsz */
970 #define	XMAC_TX_CFG_ALWAYS_NO_CRC	0x00000008 /* No CRC generated */
971 
972 #define	XMAC_WARNING_MSG_ENABLE		0x00000080 /* Sim warning msg enable */
973 
974 /* XRX MAC config bits */
975 #define	XMAC_RX_CFG_RX_ENABLE		0x00000100 /* enable XRX MAC */
976 #define	XMAC_RX_CFG_PROMISC		0x00000200 /* promisc mode enable */
977 #define	XMAC_RX_CFG_PROMISC_GROUP  	0x00000400 /* accept all MC frames */
978 #define	XMAC_RX_CFG_ERR_CHK_DISABLE	0x00000800 /* do not set abort bit */
979 #define	XMAC_RX_CFG_CRC_CHK_DISABLE	0x00001000 /* disable CRC logic */
980 #define	XMAC_RX_CFG_RESERVED_MCAST	0x00002000 /* reserved MCaddr compare */
981 #define	XMAC_RX_CFG_CD_VIO_CHK		0x00004000 /* rx code violation chk */
982 #define	XMAC_RX_CFG_HASH_FILTER_EN	0x00008000 /* use hash table */
983 #define	XMAC_RX_CFG_ADDR_FILTER_EN	0x00010000 /* use alt addr filter */
984 #define	XMAC_RX_CFG_STRIP_CRC		0x00020000 /* strip last 4bytes (CRC) */
985 #define	XMAC_RX_MAC2IPP_PKT_CNT_EN	0x00040000 /* histo_cntr7 cnt mode */
986 #define	XMAC_RX_CFG_RX_PAUSE_EN		0x00080000 /* receive pause flow ctrl */
987 #define	XMAC_RX_CFG_PASS_FLOW_CTRL	0x00100000 /* accept MAC ctrl pkts */
988 
989 
990 /* MAC transceiver (XIF) configuration registers */
991 
992 #define	XMAC_XIF_FORCE_LED_ON		0x00200000 /* Force Link LED on */
993 #define	XMAC_XIF_LED_POLARITY		0x00400000 /* LED polarity */
994 #define	XMAC_XIF_SEL_POR_CLK_SRC	0x00800000 /* Select POR clk src */
995 #define	XMAC_XIF_TX_OUTPUT_EN		0x01000000 /* enable MII/GMII modes */
996 #define	XMAC_XIF_LOOPBACK		0x02000000 /* loopback xmac xgmii tx */
997 #define	XMAC_XIF_LFS_DISABLE		0x04000000 /* disable link fault sig */
998 #define	XMAC_XIF_MII_MODE_MASK		0x18000000 /* MII/GMII/XGMII mode */
999 #define	XMAC_XIF_MII_MODE_SHIFT		27
1000 #define	XMAC_XIF_XGMII_MODE		0x00
1001 #define	XMAC_XIF_GMII_MODE		0x01
1002 #define	XMAC_XIF_MII_MODE		0x02
1003 #define	XMAC_XIF_ILLEGAL_MODE		0x03
1004 #define	XMAC_XIF_XPCS_BYPASS		0x20000000 /* use external xpcs */
1005 #define	XMAC_XIF_1G_PCS_BYPASS		0x40000000 /* use external pcs */
1006 #define	XMAC_XIF_SEL_CLK_25MHZ		0x80000000 /* 25Mhz clk for 100mbps */
1007 
1008 /* IPG register */
1009 #define	XMAC_IPG_VALUE_MASK		0x00000007 /* IPG in XGMII mode */
1010 #define	XMAC_IPG_VALUE_SHIFT		0
1011 #define	XMAC_IPG_VALUE1_MASK		0x0000ff00 /* IPG in GMII/MII mode */
1012 #define	XMAC_IPG_VALUE1_SHIFT		8
1013 #define	XMAC_IPG_STRETCH_RATIO_MASK	0x001f0000
1014 #define	XMAC_IPG_STRETCH_RATIO_SHIFT	16
1015 #define	XMAC_IPG_STRETCH_CONST_MASK	0x00e00000
1016 #define	XMAC_IPG_STRETCH_CONST_SHIFT	21
1017 
1018 #define	IPG_12_15_BYTE			3
1019 #define	IPG_16_19_BYTE			4
1020 #define	IPG_20_23_BYTE			5
1021 #define	IPG1_12_BYTES			10
1022 #define	IPG1_13_BYTES			11
1023 #define	IPG1_14_BYTES			12
1024 #define	IPG1_15_BYTES			13
1025 #define	IPG1_16_BYTES			14
1026 
1027 
1028 #define	XMAC_MIN_TX_FRM_SZ_MASK		0x3ff	   /* Min tx frame size */
1029 #define	XMAC_MIN_TX_FRM_SZ_SHIFT	0
1030 #define	XMAC_SLOT_TIME_MASK		0x0003fc00 /* slot time */
1031 #define	XMAC_SLOT_TIME_SHIFT		10
1032 #define	XMAC_MIN_RX_FRM_SZ_MASK		0x3ff00000 /* Min rx frame size */
1033 #define	XMAC_MIN_RX_FRM_SZ_SHIFT	20
1034 #define	XMAC_MAX_FRM_SZ_MASK		0x00003fff /* max tx frame size */
1035 
1036 /* State Machine Register */
1037 #define	XMAC_SM_TX_LNK_MGMT_MASK	0x00000007
1038 #define	XMAC_SM_TX_LNK_MGMT_SHIFT	0
1039 #define	XMAC_SM_SOP_DETECT		0x00000008
1040 #define	XMAC_SM_LNK_FLT_SIG_MASK	0x00000030
1041 #define	XMAC_SM_LNK_FLT_SIG_SHIFT	4
1042 #define	XMAC_SM_MII_GMII_MD_RX_LNK	0x00000040
1043 #define	XMAC_SM_XGMII_MD_RX_LNK		0x00000080
1044 #define	XMAC_SM_XGMII_ONLY_VAL_SIG	0x00000100
1045 #define	XMAC_SM_ALT_ADR_N_HSH_FN_SIG	0x00000200
1046 #define	XMAC_SM_RXMAC_IPP_STAT_MASK	0x00001c00
1047 #define	XMAC_SM_RXMAC_IPP_STAT_SHIFT	10
1048 #define	XMAC_SM_RXFIFO_WPTR_CLK_MASK	0x007c0000
1049 #define	XMAC_SM_RXFIFO_WPTR_CLK_SHIFT	18
1050 #define	XMAC_SM_RXFIFO_RPTR_CLK_MASK	0x0F800000
1051 #define	XMAC_SM_RXFIFO_RPTR_CLK_SHIFT	23
1052 #define	XMAC_SM_TXFIFO_FULL_CLK		0x10000000
1053 #define	XMAC_SM_TXFIFO_EMPTY_CLK	0x20000000
1054 #define	XMAC_SM_RXFIFO_FULL_CLK		0x40000000
1055 #define	XMAC_SM_RXFIFO_EMPTY_CLK	0x80000000
1056 
1057 /* Internal Signals 1 Register */
1058 #define	XMAC_IS1_OPP_TXMAC_STAT_MASK	0x0000000F
1059 #define	XMAC_IS1_OPP_TXMAC_STAT_SHIFT	0
1060 #define	XMAC_IS1_OPP_TXMAC_ABORT	0x00000010
1061 #define	XMAC_IS1_OPP_TXMAC_TAG 		0x00000020
1062 #define	XMAC_IS1_OPP_TXMAC_ACK		0x00000040
1063 #define	XMAC_IS1_TXMAC_OPP_REQ		0x00000080
1064 #define	XMAC_IS1_RXMAC_IPP_STAT_MASK	0x0FFFFF00
1065 #define	XMAC_IS1_RXMAC_IPP_STAT_SHIFT	8
1066 #define	XMAC_IS1_RXMAC_IPP_CTRL		0x10000000
1067 #define	XMAC_IS1_RXMAC_IPP_TAG		0x20000000
1068 #define	XMAC_IS1_IPP_RXMAC_REQ		0x40000000
1069 #define	XMAC_IS1_RXMAC_IPP_ACK		0x80000000
1070 
1071 /* Internal Signals 2 Register */
1072 #define	XMAC_IS2_TX_HB_TIMER_MASK	0x0000000F
1073 #define	XMAC_IS2_TX_HB_TIMER_SHIFT	0
1074 #define	XMAC_IS2_RX_HB_TIMER_MASK	0x000000F0
1075 #define	XMAC_IS2_RX_HB_TIMER_SHIFT	4
1076 #define	XMAC_IS2_XPCS_RXC_MASK		0x0000FF00
1077 #define	XMAC_IS2_XPCS_RXC_SHIFT		8
1078 #define	XMAC_IS2_XPCS_TXC_MASK		0x00FF0000
1079 #define	XMAC_IS2_XPCS_TXC_SHIFT		16
1080 #define	XMAC_IS2_LOCAL_FLT_OC_SYNC	0x01000000
1081 #define	XMAC_IS2_RMT_FLT_OC_SYNC	0x02000000
1082 
1083 /* Register size masking */
1084 
1085 #define	XTXMAC_FRM_CNT_MASK		0xFFFFFFFF
1086 #define	XTXMAC_BYTE_CNT_MASK		0xFFFFFFFF
1087 #define	XRXMAC_CRC_ER_CNT_MASK		0x000000FF
1088 #define	XRXMAC_MPSZER_CNT_MASK		0x000000FF
1089 #define	XRXMAC_CD_VIO_CNT_MASK		0x000000FF
1090 #define	XRXMAC_BT_CNT_MASK		0xFFFFFFFF
1091 #define	XRXMAC_HIST_CNT1_MASK		0x001FFFFF
1092 #define	XRXMAC_HIST_CNT2_MASK		0x001FFFFF
1093 #define	XRXMAC_HIST_CNT3_MASK		0x000FFFFF
1094 #define	XRXMAC_HIST_CNT4_MASK		0x0007FFFF
1095 #define	XRXMAC_HIST_CNT5_MASK		0x0003FFFF
1096 #define	XRXMAC_HIST_CNT6_MASK		0x0001FFFF
1097 #define	XRXMAC_BC_FRM_CNT_MASK		0x001FFFFF
1098 #define	XRXMAC_MC_FRM_CNT_MASK		0x001FFFFF
1099 #define	XRXMAC_FRAG_CNT_MASK		0x001FFFFF
1100 #define	XRXMAC_AL_ER_CNT_MASK		0x000000FF
1101 #define	XMAC_LINK_FLT_CNT_MASK		0x000000FF
1102 #define	BTXMAC_FRM_CNT_MASK		0x001FFFFF
1103 #define	BTXMAC_BYTE_CNT_MASK		0x07FFFFFF
1104 #define	RXMAC_FRM_CNT_MASK		0x0000FFFF
1105 #define	BRXMAC_BYTE_CNT_MASK		0x07FFFFFF
1106 #define	BMAC_AL_ER_CNT_MASK		0x0000FFFF
1107 #define	MAC_LEN_ER_CNT_MASK		0x0000FFFF
1108 #define	BMAC_CRC_ER_CNT_MASK		0x0000FFFF
1109 #define	BMAC_CD_VIO_CNT_MASK		0x0000FFFF
1110 #define	XMAC_XPCS_DESKEW_ERR_CNT_MASK	0x000000FF
1111 #define	XMAC_XPCS_SYM_ERR_CNT_L0_MASK	0x0000FFFF
1112 #define	XMAC_XPCS_SYM_ERR_CNT_L1_MASK	0xFFFF0000
1113 #define	XMAC_XPCS_SYM_ERR_CNT_L1_SHIFT	16
1114 #define	XMAC_XPCS_SYM_ERR_CNT_L2_MASK	0x0000FFFF
1115 #define	XMAC_XPCS_SYM_ERR_CNT_L3_MASK	0xFFFF0000
1116 #define	XMAC_XPCS_SYM_ERR_CNT_L3_SHIFT	16
1117 
1118 /* Alternate MAC address registers */
1119 #define	XMAC_MAX_ALT_ADDR_ENTRY		16	   /* 16 alternate MAC addrs */
1120 #define	XMAC_MAX_ADDR_ENTRY		(XMAC_MAX_ALT_ADDR_ENTRY + 1)
1121 
1122 /* Max / Min parameters for Neptune MAC */
1123 
1124 #define	MAC_MAX_ALT_ADDR_ENTRY		XMAC_MAX_ALT_ADDR_ENTRY
1125 #define	MAC_MAX_HOST_INFO_ENTRY		XMAC_MAX_HOST_INFO_ENTRY
1126 
1127 /* HostInfo entry for the unique MAC address */
1128 #define	XMAC_UNIQUE_HOST_INFO_ENTRY	17
1129 #define	BMAC_UNIQUE_HOST_INFO_ENTRY	0
1130 
1131 /* HostInfo entry for the multicat address */
1132 #define	XMAC_MULTI_HOST_INFO_ENTRY	16
1133 #define	BMAC_MULTI_HOST_INFO_ENTRY	8
1134 
1135 /* XMAC Host Info Register */
1136 typedef union hostinfo {
1137 
1138 	uint64_t value;
1139 
1140 	struct {
1141 #if defined(_BIG_ENDIAN)
1142 		uint32_t msw;	/* Most significant word */
1143 		uint32_t lsw;	/* Least significant word */
1144 #elif defined(_LITTLE_ENDIAN)
1145 		uint32_t lsw;	/* Least significant word */
1146 		uint32_t msw;	/* Most significant word */
1147 #endif
1148 	} val;
1149 	struct {
1150 #if defined(_BIG_ENDIAN)
1151 		uint32_t	w1;
1152 #endif
1153 		struct {
1154 #if defined(_BIT_FIELDS_HTOL)
1155 		uint32_t reserved2	: 23;
1156 		uint32_t mac_pref	: 1;
1157 		uint32_t reserved1	: 5;
1158 		uint32_t rdc_tbl_num	: 3;
1159 #elif defined(_BIT_FIELDS_LTOH)
1160 		uint32_t rdc_tbl_num	: 3;
1161 		uint32_t reserved1	: 5;
1162 		uint32_t mac_pref	: 1;
1163 		uint32_t reserved2	: 23;
1164 #endif
1165 		} w0;
1166 
1167 #if defined(_LITTLE_ENDIAN)
1168 		uint32_t	w1;
1169 #endif
1170 	} bits;
1171 
1172 } hostinfo_t;
1173 
1174 typedef union hostinfo *hostinfo_pt;
1175 
1176 #define	XMAC_HI_RDC_TBL_NUM_MASK	0x00000007
1177 #define	XMAC_HI_MAC_PREF		0x00000100
1178 
1179 #define	XMAC_MAX_HOST_INFO_ENTRY	20	   /* 20 host entries */
1180 
1181 /*
1182  * ******************** MIF registers *********************************
1183  */
1184 
1185 /*
1186  * 32-bit register serves as an instruction register when the MIF is
1187  * programmed in frame mode. load this register w/ a valid instruction
1188  * (as per IEEE 802.3u MII spec). poll this register to check for instruction
1189  * execution completion. during a read operation, this register will also
1190  * contain the 16-bit data returned by the transceiver. unless specified
1191  * otherwise, fields are considered "don't care" when polling for
1192  * completion.
1193  */
1194 
1195 #define	MIF_FRAME_START_MASK		0xC0000000 /* start of frame mask */
1196 #define	MIF_FRAME_ST_22			0x40000000 /* STart of frame, Cl 22 */
1197 #define	MIF_FRAME_ST_45			0x00000000 /* STart of frame, Cl 45 */
1198 #define	MIF_FRAME_OPCODE_MASK		0x30000000 /* opcode */
1199 #define	MIF_FRAME_OP_READ_22		0x20000000 /* read OPcode, Cl 22 */
1200 #define	MIF_FRAME_OP_WRITE_22		0x10000000 /* write OPcode, Cl 22 */
1201 #define	MIF_FRAME_OP_ADDR_45		0x00000000 /* addr of reg to access */
1202 #define	MIF_FRAME_OP_READ_45		0x30000000 /* read OPcode, Cl 45 */
1203 #define	MIF_FRAME_OP_WRITE_45		0x10000000 /* write OPcode, Cl 45 */
1204 #define	MIF_FRAME_OP_P_R_I_A_45		0x10000000 /* post-read-inc-addr */
1205 #define	MIF_FRAME_PHY_ADDR_MASK		0x0F800000 /* phy address mask */
1206 #define	MIF_FRAME_PHY_ADDR_SHIFT	23
1207 #define	MIF_FRAME_REG_ADDR_MASK		0x007C0000 /* reg addr in Cl 22 */
1208 						/* dev addr in Cl 45 */
1209 #define	MIF_FRAME_REG_ADDR_SHIFT	18
1210 #define	MIF_FRAME_TURN_AROUND_MSB	0x00020000 /* turn around, MSB. */
1211 #define	MIF_FRAME_TURN_AROUND_LSB	0x00010000 /* turn around, LSB. */
1212 #define	MIF_FRAME_DATA_MASK		0x0000FFFF /* instruction payload */
1213 
1214 /* Clause 45 frame field values */
1215 #define	FRAME45_ST		0
1216 #define	FRAME45_OP_ADDR		0
1217 #define	FRAME45_OP_WRITE	1
1218 #define	FRAME45_OP_READ_INC	2
1219 #define	FRAME45_OP_READ		3
1220 
1221 typedef union _mif_frame_t {
1222 
1223 	uint64_t value;
1224 
1225 	struct {
1226 #if defined(_BIG_ENDIAN)
1227 		uint32_t msw;	/* Most significant word */
1228 		uint32_t lsw;	/* Least significant word */
1229 #elif defined(_LITTLE_ENDIAN)
1230 		uint32_t lsw;	/* Least significant word */
1231 		uint32_t msw;	/* Most significant word */
1232 #endif
1233 	} val;
1234 	struct {
1235 #if defined(_BIG_ENDIAN)
1236 		uint32_t	w1;
1237 #endif
1238 		struct {
1239 #if defined(_BIT_FIELDS_HTOL)
1240 		uint32_t st		: 2;
1241 		uint32_t op		: 2;
1242 		uint32_t phyad		: 5;
1243 		uint32_t regad		: 5;
1244 		uint32_t ta_msb		: 1;
1245 		uint32_t ta_lsb		: 1;
1246 		uint32_t data		: 16;
1247 #elif defined(_BIT_FIELDS_LTOH)
1248 		uint32_t data		: 16;
1249 		uint32_t ta_lsb		: 1;
1250 		uint32_t ta_msb		: 1;
1251 		uint32_t regad		: 5;
1252 		uint32_t phyad		: 5;
1253 		uint32_t op		: 2;
1254 		uint32_t st		: 2;
1255 #endif
1256 		} w0;
1257 
1258 #if defined(_LITTLE_ENDIAN)
1259 		uint32_t	w1;
1260 #endif
1261 	} bits;
1262 } mif_frame_t;
1263 
1264 #define	MIF_CFG_POLL_EN			0x00000008 /* enable polling */
1265 #define	MIF_CFG_BB_MODE			0x00000010 /* bit-bang mode */
1266 #define	MIF_CFG_POLL_REG_MASK		0x000003E0 /* reg addr to be polled */
1267 #define	MIF_CFG_POLL_REG_SHIFT		5
1268 #define	MIF_CFG_POLL_PHY_MASK		0x00007C00 /* XCVR addr to be polled */
1269 #define	MIF_CFG_POLL_PHY_SHIFT		10
1270 #define	MIF_CFG_INDIRECT_MODE		0x0000800
1271 					/* used to decide if Cl 22 */
1272 					/* or Cl 45 frame is */
1273 					/* constructed. */
1274 					/* 1 = Clause 45,ST = '00' */
1275 					/* 0 = Clause 22,ST = '01' */
1276 #define	MIF_CFG_ATCE_GE_EN	0x00010000 /* Enable ATCA gigabit mode */
1277 
1278 typedef union _mif_cfg_t {
1279 
1280 	uint64_t value;
1281 
1282 	struct {
1283 #if defined(_BIG_ENDIAN)
1284 		uint32_t msw;	/* Most significant word */
1285 		uint32_t lsw;	/* Least significant word */
1286 
1287 #elif defined(_LITTLE_ENDIAN)
1288 		uint32_t lsw;	/* Least significant word */
1289 		uint32_t msw;	/* Most significant word */
1290 #endif
1291 	} val;
1292 	struct {
1293 #if defined(_BIG_ENDIAN)
1294 		uint32_t	w1;
1295 #endif
1296 		struct {
1297 #if defined(_BIT_FIELDS_HTOL)
1298 		uint32_t res2		: 15;
1299 		uint32_t atca_ge	: 1;
1300 		uint32_t indirect_md	: 1;
1301 		uint32_t phy_addr	: 5;
1302 		uint32_t reg_addr	: 5;
1303 		uint32_t bb_mode	: 1;
1304 		uint32_t poll_en	: 1;
1305 		uint32_t res1		: 2;
1306 		uint32_t res		: 1;
1307 #elif defined(_BIT_FIELDS_LTOH)
1308 		uint32_t res		: 1;
1309 		uint32_t res1		: 2;
1310 		uint32_t poll_en	: 1;
1311 		uint32_t bb_mode	: 1;
1312 		uint32_t reg_addr	: 5;
1313 		uint32_t phy_addr	: 5;
1314 		uint32_t indirect_md	: 1;
1315 		uint32_t atca_ge	: 1;
1316 		uint32_t res2		: 15;
1317 #endif
1318 		} w0;
1319 
1320 #if defined(_LITTLE_ENDIAN)
1321 		uint32_t	w1;
1322 #endif
1323 	} bits;
1324 
1325 } mif_cfg_t;
1326 
1327 #define	MIF_POLL_STATUS_DATA_MASK	0xffff0000
1328 #define	MIF_POLL_STATUS_STAT_MASK	0x0000ffff
1329 
1330 typedef union _mif_poll_stat_t {
1331 	uint64_t value;
1332 
1333 	struct {
1334 #if defined(_BIG_ENDIAN)
1335 		uint32_t msw;	/* Most significant word */
1336 		uint32_t lsw;	/* Least significant word */
1337 #elif defined(_LITTLE_ENDIAN)
1338 		uint32_t lsw;	/* Least significant word */
1339 		uint32_t msw;	/* Most significant word */
1340 #endif
1341 	} val;
1342 	struct {
1343 #if defined(_BIG_ENDIAN)
1344 		uint32_t	w1;
1345 #endif
1346 		struct {
1347 #if defined(_BIT_FIELDS_HTOL)
1348 		uint16_t data;
1349 		uint16_t status;
1350 #elif defined(_BIT_FIELDS_LTOH)
1351 		uint16_t status;
1352 		uint16_t data;
1353 #endif
1354 		} w0;
1355 
1356 #if defined(_LITTLE_ENDIAN)
1357 		uint32_t	w1;
1358 #endif
1359 	} bits;
1360 } mif_poll_stat_t;
1361 
1362 
1363 #define	MIF_POLL_MASK_MASK	0x0000ffff
1364 
1365 typedef union _mif_poll_mask_t {
1366 	uint64_t value;
1367 
1368 	struct {
1369 #if defined(_BIG_ENDIAN)
1370 		uint32_t msw;	/* Most significant word */
1371 		uint32_t lsw;	/* Least significant word */
1372 #elif defined(_LITTLE_ENDIAN)
1373 		uint32_t lsw;	/* Least significant word */
1374 		uint32_t msw;	/* Most significant word */
1375 #endif
1376 	} val;
1377 	struct {
1378 #if defined(_BIG_ENDIAN)
1379 		uint32_t	w1;
1380 #endif
1381 		struct {
1382 #if defined(_BIT_FIELDS_HTOL)
1383 		uint16_t rsvd;
1384 		uint16_t mask;
1385 #elif defined(_BIT_FIELDS_LTOH)
1386 		uint16_t mask;
1387 		uint16_t rsvd;
1388 #endif
1389 		} w0;
1390 
1391 #if defined(_LITTLE_ENDIAN)
1392 		uint32_t	w1;
1393 #endif
1394 	} bits;
1395 } mif_poll_mask_t;
1396 
1397 #define	MIF_STATUS_INIT_DONE_MASK	0x00000001
1398 #define	MIF_STATUS_XGE_ERR0_MASK	0x00000002
1399 #define	MIF_STATUS_XGE_ERR1_MASK	0x00000004
1400 #define	MIF_STATUS_PEU_ERR_MASK		0x00000008
1401 #define	MIF_STATUS_EXT_PHY_INTR0_MASK	0x00000010
1402 #define	MIF_STATUS_EXT_PHY_INTR1_MASK	0x00000020
1403 
1404 typedef union _mif_stat_t {
1405 	uint64_t value;
1406 
1407 	struct {
1408 #if defined(_BIG_ENDIAN)
1409 		uint32_t msw;	/* Most significant word */
1410 		uint32_t lsw;	/* Least significant word */
1411 #elif defined(_LITTLE_ENDIAN)
1412 		uint32_t lsw;	/* Least significant word */
1413 		uint32_t msw;	/* Most significant word */
1414 #endif
1415 	} val;
1416 	struct {
1417 #if defined(_BIG_ENDIAN)
1418 		uint32_t	w1;
1419 #endif
1420 		struct {
1421 #if defined(_BIT_FIELDS_HTOL)
1422 		uint32_t rsvd:26;
1423 		uint32_t ext_phy_intr_flag1:1;
1424 		uint32_t ext_phy_intr_flag0:1;
1425 		uint32_t peu_err:1;
1426 		uint32_t xge_err1:1;
1427 		uint32_t xge_err0:1;
1428 		uint32_t mif_init_done_stat:1;
1429 
1430 #elif defined(_BIT_FIELDS_LTOH)
1431 		uint32_t mif_init_done_stat:1;
1432 		uint32_t xge_err0:1;
1433 		uint32_t xge_err1:1;
1434 		uint32_t ext_phy_intr_flag0:1;
1435 		uint32_t ext_phy_intr_flag1:1;
1436 		uint32_t rsvd:26;
1437 #endif
1438 		} w0;
1439 
1440 #if defined(_LITTLE_ENDIAN)
1441 		uint32_t	w1;
1442 #endif
1443 	} bits;
1444 } mif_stat_t;
1445 
1446 /* MIF State Machine Register */
1447 
1448 #define	MIF_SM_EXECUTION_MASK		0x0000003f /* execution state */
1449 #define	MIF_SM_EXECUTION_SHIFT		0
1450 #define	MIF_SM_CONTROL_MASK		0x000001c0 /* control state */
1451 #define	MIF_SM_CONTROL_MASK_SHIFT	6
1452 #define	MIF_SM_MDI			0x00000200
1453 #define	MIF_SM_MDO			0x00000400
1454 #define	MIF_SM_MDO_EN			0x00000800
1455 #define	MIF_SM_MDC			0x00001000
1456 #define	MIF_SM_MDI_0			0x00002000
1457 #define	MIF_SM_MDI_1			0x00004000
1458 #define	MIF_SM_MDI_2			0x00008000
1459 #define	MIF_SM_PORT_ADDR_MASK		0x001f0000
1460 #define	MIF_SM_PORT_ADDR_SHIFT		16
1461 #define	MIF_SM_INT_SIG_MASK		0xffe00000
1462 #define	MIF_SM_INT_SIG_SHIFT		21
1463 
1464 
1465 /*
1466  * ******************** PCS registers *********************************
1467  */
1468 
1469 /* PCS Registers */
1470 #define	PCS_MII_CTRL_1000_SEL		0x0040	   /* reads 1. ignored on wr */
1471 #define	PCS_MII_CTRL_COLLISION_TEST	0x0080	   /* COL signal */
1472 #define	PCS_MII_CTRL_DUPLEX		0x0100	   /* forced 0x0. */
1473 #define	PCS_MII_RESTART_AUTONEG		0x0200	   /* self clearing. */
1474 #define	PCS_MII_ISOLATE			0x0400	   /* read 0. ignored on wr */
1475 #define	PCS_MII_POWER_DOWN		0x0800	   /* read 0. ignored on wr */
1476 #define	PCS_MII_AUTONEG_EN		0x1000	   /* autonegotiation */
1477 #define	PCS_MII_10_100_SEL		0x2000	   /* read 0. ignored on wr */
1478 #define	PCS_MII_RESET			0x8000	   /* reset PCS. */
1479 
1480 typedef union _pcs_ctrl_t {
1481 	uint64_t value;
1482 
1483 	struct {
1484 #if defined(_BIG_ENDIAN)
1485 		uint32_t msw;	/* Most significant word */
1486 		uint32_t lsw;	/* Least significant word */
1487 #elif defined(_LITTLE_ENDIAN)
1488 		uint32_t lsw;	/* Least significant word */
1489 		uint32_t msw;	/* Most significant word */
1490 #endif
1491 	} val;
1492 	struct {
1493 #if defined(_BIG_ENDIAN)
1494 		uint32_t	w1;
1495 #endif
1496 		struct {
1497 #if defined(_BIT_FIELDS_HTOL)
1498 			uint32_t res0		: 16;
1499 			uint32_t reset		: 1;
1500 			uint32_t res1		: 1;
1501 			uint32_t sel_10_100	: 1;
1502 			uint32_t an_enable	: 1;
1503 			uint32_t pwr_down	: 1;
1504 			uint32_t isolate	: 1;
1505 			uint32_t restart_an	: 1;
1506 			uint32_t duplex		: 1;
1507 			uint32_t col_test	: 1;
1508 			uint32_t sel_1000	: 1;
1509 			uint32_t res2		: 6;
1510 #elif defined(_BIT_FIELDS_LTOH)
1511 			uint32_t res2		: 6;
1512 			uint32_t sel_1000	: 1;
1513 			uint32_t col_test	: 1;
1514 			uint32_t duplex		: 1;
1515 			uint32_t restart_an	: 1;
1516 			uint32_t isolate	: 1;
1517 			uint32_t pwr_down	: 1;
1518 			uint32_t an_enable	: 1;
1519 			uint32_t sel_10_100	: 1;
1520 			uint32_t res1		: 1;
1521 			uint32_t reset		: 1;
1522 			uint32_t res0		: 16;
1523 #endif
1524 		} w0;
1525 
1526 #if defined(_LITTLE_ENDIAN)
1527 		uint32_t	w1;
1528 #endif
1529 	} bits;
1530 } pcs_ctrl_t;
1531 
1532 #define	PCS_MII_STATUS_EXTEND_CAP	0x0001	   /* reads 0 */
1533 #define	PCS_MII_STATUS_JABBER_DETECT	0x0002	   /* reads 0 */
1534 #define	PCS_MII_STATUS_LINK_STATUS	0x0004	   /* link status */
1535 #define	PCS_MII_STATUS_AUTONEG_ABLE	0x0008	   /* reads 1 */
1536 #define	PCS_MII_STATUS_REMOTE_FAULT	0x0010	   /* remote fault detected */
1537 #define	PCS_MII_STATUS_AUTONEG_COMP	0x0020	   /* auto-neg completed */
1538 #define	PCS_MII_STATUS_EXTEND_STATUS	0x0100	   /* 1000 Base-X PHY */
1539 
1540 typedef union _pcs_stat_t {
1541 	uint64_t value;
1542 
1543 	struct {
1544 #if defined(_BIG_ENDIAN)
1545 		uint32_t msw;	/* Most significant word */
1546 		uint32_t lsw;	/* Least significant word */
1547 #elif defined(_LITTLE_ENDIAN)
1548 		uint32_t lsw;	/* Least significant word */
1549 		uint32_t msw;	/* Most significant word */
1550 #endif
1551 	} val;
1552 	struct {
1553 #if defined(_BIG_ENDIAN)
1554 		uint32_t	w1;
1555 #endif
1556 		struct {
1557 #if defined(_BIT_FIELDS_HTOL)
1558 		uint32_t res0		: 23;
1559 		uint32_t ext_stat	: 1;
1560 		uint32_t res1		: 2;
1561 		uint32_t an_complete	: 1;
1562 		uint32_t remote_fault	: 1;
1563 		uint32_t an_able	: 1;
1564 		uint32_t link_stat	: 1;
1565 		uint32_t jabber_detect	: 1;
1566 		uint32_t ext_cap	: 1;
1567 #elif defined(_BIT_FIELDS_LTOH)
1568 		uint32_t ext_cap	: 1;
1569 		uint32_t jabber_detect	: 1;
1570 		uint32_t link_stat	: 1;
1571 		uint32_t an_able	: 1;
1572 		uint32_t remote_fault	: 1;
1573 		uint32_t an_complete	: 1;
1574 		uint32_t res1		: 2;
1575 		uint32_t ext_stat	: 1;
1576 		uint32_t res0		: 23;
1577 #endif
1578 		} w0;
1579 
1580 #if defined(_LITTLE_ENDIAN)
1581 		uint32_t	w1;
1582 #endif
1583 	} bits;
1584 } pcs_stat_t;
1585 
1586 #define	PCS_MII_ADVERT_FD		0x0020	   /* advertise full duplex */
1587 #define	PCS_MII_ADVERT_HD		0x0040	   /* advertise half-duplex */
1588 #define	PCS_MII_ADVERT_SYM_PAUSE	0x0080	   /* advertise PAUSE sym */
1589 #define	PCS_MII_ADVERT_ASYM_PAUSE	0x0100	   /* advertises PAUSE asym */
1590 #define	PCS_MII_ADVERT_RF_MASK		0x3000	   /* remote fault */
1591 #define	PCS_MII_ADVERT_RF_SHIFT		12
1592 #define	PCS_MII_ADVERT_ACK		0x4000	   /* (ro) */
1593 #define	PCS_MII_ADVERT_NEXT_PAGE	0x8000	   /* (ro) forced 0x0 */
1594 
1595 #define	PCS_MII_LPA_FD			PCS_MII_ADVERT_FD
1596 #define	PCS_MII_LPA_HD			PCS_MII_ADVERT_HD
1597 #define	PCS_MII_LPA_SYM_PAUSE		PCS_MII_ADVERT_SYM_PAUSE
1598 #define	PCS_MII_LPA_ASYM_PAUSE		PCS_MII_ADVERT_ASYM_PAUSE
1599 #define	PCS_MII_LPA_RF_MASK		PCS_MII_ADVERT_RF_MASK
1600 #define	PCS_MII_LPA_RF_SHIFT		PCS_MII_ADVERT_RF_SHIFT
1601 #define	PCS_MII_LPA_ACK			PCS_MII_ADVERT_ACK
1602 #define	PCS_MII_LPA_NEXT_PAGE		PCS_MII_ADVERT_NEXT_PAGE
1603 
1604 typedef union _pcs_anar_t {
1605 	uint64_t value;
1606 
1607 	struct {
1608 #if defined(_BIG_ENDIAN)
1609 		uint32_t msw;	/* Most significant word */
1610 		uint32_t lsw;	/* Least significant word */
1611 #elif defined(_LITTLE_ENDIAN)
1612 		uint32_t lsw;	/* Least significant word */
1613 		uint32_t msw;	/* Most significant word */
1614 #endif
1615 	} val;
1616 	struct {
1617 #if defined(_BIG_ENDIAN)
1618 		uint32_t	w1;
1619 #endif
1620 		struct {
1621 #if defined(_BIT_FIELDS_HTOL)
1622 		uint32_t res0		: 16;
1623 		uint32_t next_page	: 1;
1624 		uint32_t ack		: 1;
1625 		uint32_t remote_fault	: 2;
1626 		uint32_t res1		: 3;
1627 		uint32_t asm_pause	: 1;
1628 		uint32_t pause		: 1;
1629 		uint32_t half_duplex	: 1;
1630 		uint32_t full_duplex	: 1;
1631 		uint32_t res2		: 5;
1632 #elif defined(_BIT_FIELDS_LTOH)
1633 		uint32_t res2		: 5;
1634 		uint32_t full_duplex	: 1;
1635 		uint32_t half_duplex	: 1;
1636 		uint32_t pause		: 1;
1637 		uint32_t asm_pause	: 1;
1638 		uint32_t res1		: 3;
1639 		uint32_t remore_fault	: 2;
1640 		uint32_t ack		: 1;
1641 		uint32_t next_page	: 1;
1642 		uint32_t res0		: 16;
1643 #endif
1644 		} w0;
1645 
1646 #if defined(_LITTLE_ENDIAN)
1647 		uint32_t	w1;
1648 #endif
1649 	} bits;
1650 } pcs_anar_t, *p_pcs_anar_t;
1651 
1652 #define	PCS_CFG_EN			0x0001	   /* enable PCS. */
1653 #define	PCS_CFG_SD_OVERRIDE		0x0002
1654 #define	PCS_CFG_SD_ACTIVE_LOW		0x0004	   /* sig detect active low */
1655 #define	PCS_CFG_JITTER_STUDY_MASK	0x0018	   /* jitter measurements */
1656 #define	PCS_CFG_JITTER_STUDY_SHIFT	4
1657 #define	PCS_CFG_10MS_TIMER_OVERRIDE	0x0020	   /* shortens autoneg timer */
1658 #define	PCS_CFG_MASK			0x0040	   /* PCS global mask bit */
1659 
1660 typedef union _pcs_cfg_t {
1661 	uint64_t value;
1662 
1663 	struct {
1664 #if defined(_BIG_ENDIAN)
1665 		uint32_t msw;	/* Most significant word */
1666 		uint32_t lsw;	/* Least significant word */
1667 #elif defined(_LITTLE_ENDIAN)
1668 		uint32_t lsw;	/* Least significant word */
1669 		uint32_t msw;	/* Most significant word */
1670 #endif
1671 	} val;
1672 	struct {
1673 #if defined(_BIG_ENDIAN)
1674 		uint32_t	w1;
1675 #endif
1676 		struct {
1677 #if defined(_BIT_FIELDS_HTOL)
1678 		uint32_t res0			: 25;
1679 		uint32_t mask			: 1;
1680 		uint32_t override_10ms_timer	: 1;
1681 		uint32_t jitter_study		: 2;
1682 		uint32_t sig_det_a_low		: 1;
1683 		uint32_t sig_det_override	: 1;
1684 		uint32_t enable			: 1;
1685 #elif defined(_BIT_FIELDS_LTOH)
1686 		uint32_t enable			: 1;
1687 		uint32_t sig_det_override	: 1;
1688 		uint32_t sig_det_a_low		: 1;
1689 		uint32_t jitter_study		: 2;
1690 		uint32_t override_10ms_timer	: 1;
1691 		uint32_t mask			: 1;
1692 		uint32_t res0			: 25;
1693 #endif
1694 		} w0;
1695 
1696 #if defined(_LITTLE_ENDIAN)
1697 		uint32_t	w1;
1698 #endif
1699 	} bits;
1700 } pcs_cfg_t, *p_pcs_cfg_t;
1701 
1702 
1703 /* used for diagnostic purposes. bits 20-22 autoclear on read */
1704 #define	PCS_SM_TX_STATE_MASK		0x0000000F /* Tx idle state mask */
1705 #define	PCS_SM_TX_STATE_SHIFT		0
1706 #define	PCS_SM_RX_STATE_MASK		0x000000F0 /* Rx idle state mask */
1707 #define	PCS_SM_RX_STATE_SHIFT		4
1708 #define	PCS_SM_WORD_SYNC_STATE_MASK	0x00000700 /* loss of sync state mask */
1709 #define	PCS_SM_WORD_SYNC_STATE_SHIFT	8
1710 #define	PCS_SM_SEQ_DETECT_STATE_MASK	0x00001800 /* sequence detect */
1711 #define	PCS_SM_SEQ_DETECT_STATE_SHIFT	11
1712 #define	PCS_SM_LINK_STATE_MASK		0x0001E000 /* link state */
1713 #define	PCS_SM_LINK_STATE_SHIFT		13
1714 #define	PCS_SM_LOSS_LINK_C		0x00100000 /* loss of link */
1715 #define	PCS_SM_LOSS_LINK_SYNC		0x00200000 /* loss of sync */
1716 #define	PCS_SM_LOSS_SIGNAL_DETECT	0x00400000 /* signal detect fail */
1717 #define	PCS_SM_NO_LINK_BREAKLINK	0x01000000 /* receipt of breaklink */
1718 #define	PCS_SM_NO_LINK_SERDES		0x02000000 /* serdes initializing */
1719 #define	PCS_SM_NO_LINK_C		0x04000000 /* C codes not stable */
1720 #define	PCS_SM_NO_LINK_SYNC		0x08000000 /* word sync not achieved */
1721 #define	PCS_SM_NO_LINK_WAIT_C		0x10000000 /* waiting for C codes */
1722 #define	PCS_SM_NO_LINK_NO_IDLE		0x20000000 /* linkpartner send C code */
1723 
1724 typedef union _pcs_stat_mc_t {
1725 	uint64_t value;
1726 
1727 	struct {
1728 #if defined(_BIG_ENDIAN)
1729 		uint32_t msw;	/* Most significant word */
1730 		uint32_t lsw;	/* Least significant word */
1731 #elif defined(_LITTLE_ENDIAN)
1732 		uint32_t lsw;	/* Least significant word */
1733 		uint32_t msw;	/* Most significant word */
1734 #endif
1735 	} val;
1736 	struct {
1737 #if defined(_BIG_ENDIAN)
1738 		uint32_t	w1;
1739 #endif
1740 		struct {
1741 #if defined(_BIT_FIELDS_HTOL)
1742 		uint32_t res2		: 2;
1743 		uint32_t lnk_dwn_ni	: 1;
1744 		uint32_t lnk_dwn_wc	: 1;
1745 		uint32_t lnk_dwn_ls	: 1;
1746 		uint32_t lnk_dwn_nc	: 1;
1747 		uint32_t lnk_dwn_ser	: 1;
1748 		uint32_t lnk_loss_bc	: 1;
1749 		uint32_t res1		: 1;
1750 		uint32_t loss_sd	: 1;
1751 		uint32_t lnk_loss_sync	: 1;
1752 		uint32_t lnk_loss_c	: 1;
1753 		uint32_t res0		: 3;
1754 		uint32_t link_cfg_stat	: 4;
1755 		uint32_t seq_detc_stat	: 2;
1756 		uint32_t word_sync	: 3;
1757 		uint32_t rx_ctrl	: 4;
1758 		uint32_t tx_ctrl	: 4;
1759 #elif defined(_BIT_FIELDS_LTOH)
1760 		uint32_t tx_ctrl	: 4;
1761 		uint32_t rx_ctrl	: 4;
1762 		uint32_t word_sync	: 3;
1763 		uint32_t seq_detc_stat	: 2;
1764 		uint32_t link_cfg_stat	: 4;
1765 		uint32_t res0		: 3;
1766 		uint32_t lnk_loss_c	: 1;
1767 		uint32_t lnk_loss_sync	: 1;
1768 		uint32_t loss_sd	: 1;
1769 		uint32_t res1		: 1;
1770 		uint32_t lnk_loss_bc	: 1;
1771 		uint32_t lnk_dwn_ser	: 1;
1772 		uint32_t lnk_dwn_nc	: 1;
1773 		uint32_t lnk_dwn_ls	: 1;
1774 		uint32_t lnk_dwn_wc	: 1;
1775 		uint32_t lnk_dwn_ni	: 1;
1776 		uint32_t res2		: 2;
1777 #endif
1778 		} w0;
1779 
1780 #if defined(_LITTLE_ENDIAN)
1781 		uint32_t	w1;
1782 #endif
1783 	} bits;
1784 } pcs_stat_mc_t, *p_pcs_stat_mc_t;
1785 
1786 #define	PCS_INTR_STATUS_LINK_CHANGE	0x04	/* link status has changed */
1787 
1788 /*
1789  * control which network interface is used. no more than one bit should
1790  * be set.
1791  */
1792 #define	PCS_DATAPATH_MODE_PCS		0	   /* Internal PCS is used */
1793 #define	PCS_DATAPATH_MODE_MII		0x00000002 /* GMII/RGMII is selected. */
1794 
1795 #define	PCS_PACKET_COUNT_TX_MASK	0x000007FF /* pkts xmitted by PCS */
1796 #define	PCS_PACKET_COUNT_RX_MASK	0x07FF0000 /* pkts recvd by PCS */
1797 #define	PCS_PACKET_COUNT_RX_SHIFT	16
1798 
1799 /*
1800  * ******************** XPCS registers *********************************
1801  */
1802 
1803 /* XPCS Base 10G Control1 Register */
1804 #define	XPCS_CTRL1_RST			0x8000 /* Self clearing reset. */
1805 #define	XPCS_CTRL1_LOOPBK		0x4000 /* xpcs Loopback */
1806 #define	XPCS_CTRL1_SPEED_SEL_3		0x2000 /* 1 indicates 10G speed */
1807 #define	XPCS_CTRL1_LOW_PWR		0x0800 /* low power mode. */
1808 #define	XPCS_CTRL1_SPEED_SEL_1		0x0040 /* 1 indicates 10G speed */
1809 #define	XPCS_CTRL1_SPEED_SEL_0_MASK	0x003c /* 0 indicates 10G speed. */
1810 #define	XPCS_CTRL1_SPEED_SEL_0_SHIFT	2
1811 
1812 
1813 
1814 typedef union _xpcs_ctrl1_t {
1815 	uint64_t value;
1816 
1817 	struct {
1818 #if defined(_BIG_ENDIAN)
1819 		uint32_t msw;	/* Most significant word */
1820 		uint32_t lsw;	/* Least significant word */
1821 #elif defined(_LITTLE_ENDIAN)
1822 		uint32_t lsw;	/* Least significant word */
1823 		uint32_t msw;	/* Most significant word */
1824 #endif
1825 	} val;
1826 	struct {
1827 #if defined(_BIG_ENDIAN)
1828 		uint32_t	w1;
1829 #endif
1830 		struct {
1831 #if defined(_BIT_FIELDS_HTOL)
1832 		uint32_t res3		: 16;
1833 		uint32_t reset		: 1;
1834 		uint32_t csr_lb		: 1;
1835 		uint32_t csr_speed_sel3	: 1;
1836 		uint32_t res2		: 1;
1837 		uint32_t csr_low_pwr	: 1;
1838 		uint32_t res1		: 4;
1839 		uint32_t csr_speed_sel1	: 1;
1840 		uint32_t csr_speed_sel0	: 4;
1841 		uint32_t res0		: 2;
1842 #elif defined(_BIT_FIELDS_LTOH)
1843 		uint32_t res0		: 2;
1844 		uint32_t csr_speed_sel0	: 4;
1845 		uint32_t csr_speed_sel1	: 1;
1846 		uint32_t res1		: 4;
1847 		uint32_t csr_low_pwr	: 1;
1848 		uint32_t res2		: 1;
1849 		uint32_t csr_speed_sel3	: 1;
1850 		uint32_t csr_lb		: 1;
1851 		uint32_t reset		: 1;
1852 		uint32_t res3		: 16;
1853 #endif
1854 		} w0;
1855 
1856 #if defined(_LITTLE_ENDIAN)
1857 		uint32_t	w1;
1858 #endif
1859 	} bits;
1860 } xpcs_ctrl1_t;
1861 
1862 
1863 /* XPCS Base 10G Status1 Register (Read Only) */
1864 #define	XPCS_STATUS1_FAULT		0x0080
1865 #define	XPCS_STATUS1_RX_LINK_STATUS_UP	0x0004 /* Link status interrupt */
1866 #define	XPCS_STATUS1_LOW_POWER_ABILITY	0x0002 /* low power mode */
1867 
1868 
1869 typedef	union _xpcs_stat1_t {
1870 	uint64_t value;
1871 
1872 	struct {
1873 #if defined(_BIG_ENDIAN)
1874 		uint32_t msw;	/* Most significant word */
1875 		uint32_t lsw;	/* Least significant word */
1876 #elif defined(_LITTLE_ENDIAN)
1877 		uint32_t lsw;	/* Least significant word */
1878 		uint32_t msw;	/* Most significant word */
1879 #endif
1880 	} val;
1881 	struct {
1882 #if defined(_BIG_ENDIAN)
1883 		uint32_t	w1;
1884 #endif
1885 		struct {
1886 #if defined(_BIT_FIELDS_HTOL)
1887 		uint32_t res4			: 16;
1888 		uint32_t res3			: 8;
1889 		uint32_t csr_fault		: 1;
1890 		uint32_t res1			: 4;
1891 		uint32_t csr_rx_link_stat	: 1;
1892 		uint32_t csr_low_pwr_ability	: 1;
1893 		uint32_t res0			: 1;
1894 #elif defined(_BIT_FIELDS_LTOH)
1895 		uint32_t res0			: 1;
1896 		uint32_t csr_low_pwr_ability	: 1;
1897 		uint32_t csr_rx_link_stat	: 1;
1898 		uint32_t res1			: 4;
1899 		uint32_t csr_fault		: 1;
1900 		uint32_t res3			: 8;
1901 		uint32_t res4			: 16;
1902 #endif
1903 		} w0;
1904 
1905 #if defined(_LITTLE_ENDIAN)
1906 		uint32_t	w1;
1907 #endif
1908 	} bits;
1909 } xpcs_stat1_t;
1910 
1911 
1912 /* XPCS Base Speed Ability Register. Indicates 10G capability */
1913 #define	XPCS_SPEED_ABILITY_10_GIG	0x0001
1914 
1915 
1916 typedef	union _xpcs_speed_ab_t {
1917 	uint64_t value;
1918 
1919 	struct {
1920 #if defined(_BIG_ENDIAN)
1921 		uint32_t msw;	/* Most significant word */
1922 		uint32_t lsw;	/* Least significant word */
1923 #elif defined(_LITTLE_ENDIAN)
1924 		uint32_t lsw;	/* Least significant word */
1925 		uint32_t msw;	/* Most significant word */
1926 #endif
1927 	} val;
1928 	struct {
1929 #if defined(_BIG_ENDIAN)
1930 		uint32_t	w1;
1931 #endif
1932 		struct {
1933 #if defined(_BIT_FIELDS_HTOL)
1934 		uint32_t res1		: 16;
1935 		uint32_t res0		: 15;
1936 		uint32_t csr_10gig	: 1;
1937 #elif defined(_BIT_FIELDS_LTOH)
1938 		uint32_t csr_10gig	: 1;
1939 		uint32_t res0		: 15;
1940 		uint32_t res1		: 16;
1941 #endif
1942 		} w0;
1943 
1944 #if defined(_LITTLE_ENDIAN)
1945 		uint32_t	w1;
1946 #endif
1947 	} bits;
1948 } xpcs_speed_ab_t;
1949 
1950 
1951 /* XPCS Base 10G Devices in Package Register */
1952 #define	XPCS_DEV_IN_PKG_CSR_VENDOR2	0x80000000
1953 #define	XPCS_DEV_IN_PKG_CSR_VENDOR1	0x40000000
1954 #define	XPCS_DEV_IN_PKG_DTE_XS		0x00000020
1955 #define	XPCS_DEV_IN_PKG_PHY_XS		0x00000010
1956 #define	XPCS_DEV_IN_PKG_PCS		0x00000008
1957 #define	XPCS_DEV_IN_PKG_WIS		0x00000004
1958 #define	XPCS_DEV_IN_PKG_PMD_PMA		0x00000002
1959 #define	XPCS_DEV_IN_PKG_CLS_22_REG	0x00000000
1960 
1961 
1962 
1963 typedef	union _xpcs_dev_in_pkg_t {
1964 	uint64_t value;
1965 
1966 	struct {
1967 #if defined(_BIG_ENDIAN)
1968 		uint32_t msw;	/* Most significant word */
1969 		uint32_t lsw;	/* Least significant word */
1970 #elif defined(_LITTLE_ENDIAN)
1971 		uint32_t lsw;	/* Least significant word */
1972 		uint32_t msw;	/* Most significant word */
1973 #endif
1974 	} val;
1975 	struct {
1976 #if defined(_BIG_ENDIAN)
1977 		uint32_t	w1;
1978 #endif
1979 		struct {
1980 #if defined(_BIT_FIELDS_HTOL)
1981 		uint32_t csr_vendor2	: 1;
1982 		uint32_t csr_vendor1	: 1;
1983 		uint32_t res1		: 14;
1984 		uint32_t res0		: 10;
1985 		uint32_t dte_xs		: 1;
1986 		uint32_t phy_xs		: 1;
1987 		uint32_t pcs		: 1;
1988 		uint32_t wis		: 1;
1989 		uint32_t pmd_pma	: 1;
1990 		uint32_t clause_22_reg	: 1;
1991 #elif defined(_BIT_FIELDS_LTOH)
1992 		uint32_t clause_22_reg	: 1;
1993 		uint32_t pmd_pma	: 1;
1994 		uint32_t wis		: 1;
1995 		uint32_t pcs		: 1;
1996 		uint32_t phy_xs		: 1;
1997 		uint32_t dte_xs		: 1;
1998 		uint32_t res0		: 10;
1999 		uint32_t res1		: 14;
2000 		uint32_t csr_vendor1	: 1;
2001 		uint32_t csr_vendor2	: 1;
2002 #endif
2003 		} w0;
2004 
2005 #if defined(_LITTLE_ENDIAN)
2006 		uint32_t	w1;
2007 #endif
2008 	} bits;
2009 } xpcs_dev_in_pkg_t;
2010 
2011 
2012 /* XPCS Base 10G Control2 Register */
2013 #define	XPCS_PSC_SEL_MASK		0x0003
2014 #define	PSC_SEL_10G_BASE_X_PCS		0x0001
2015 
2016 
2017 typedef	union _xpcs_ctrl2_t {
2018 	uint64_t value;
2019 
2020 	struct {
2021 #if defined(_BIG_ENDIAN)
2022 		uint32_t msw;	/* Most significant word */
2023 		uint32_t lsw;	/* Least significant word */
2024 #elif defined(_LITTLE_ENDIAN)
2025 		uint32_t lsw;	/* Least significant word */
2026 		uint32_t msw;	/* Most significant word */
2027 #endif
2028 	} val;
2029 	struct {
2030 #if defined(_BIG_ENDIAN)
2031 		uint32_t	w1;
2032 #endif
2033 		struct {
2034 #if defined(_BIT_FIELDS_HTOL)
2035 		uint32_t res1		: 16;
2036 		uint32_t res0		: 14;
2037 		uint32_t csr_psc_sel	: 2;
2038 #elif defined(_BIT_FIELDS_LTOH)
2039 		uint32_t csr_psc_sel	: 2;
2040 		uint32_t res0		: 14;
2041 		uint32_t res1		: 16;
2042 #endif
2043 		} w0;
2044 
2045 #if defined(_LITTLE_ENDIAN)
2046 		uint32_t	w1;
2047 #endif
2048 	} bits;
2049 } xpcs_ctrl2_t;
2050 
2051 
2052 /* XPCS Base10G Status2 Register */
2053 #define	XPCS_STATUS2_DEV_PRESENT_MASK	0xc000	/* ?????? */
2054 #define	XPCS_STATUS2_TX_FAULT		0x0800	/* Fault on tx path */
2055 #define	XPCS_STATUS2_RX_FAULT		0x0400	/* Fault on rx path */
2056 #define	XPCS_STATUS2_TEN_GBASE_W	0x0004	/* 10G-Base-W */
2057 #define	XPCS_STATUS2_TEN_GBASE_X	0x0002	/* 10G-Base-X */
2058 #define	XPCS_STATUS2_TEN_GBASE_R	0x0001	/* 10G-Base-R */
2059 
2060 typedef	union _xpcs_stat2_t {
2061 	uint64_t value;
2062 
2063 	struct {
2064 #if defined(_BIG_ENDIAN)
2065 		uint32_t msw;	/* Most significant word */
2066 		uint32_t lsw;	/* Least significant word */
2067 #elif defined(_LITTLE_ENDIAN)
2068 		uint32_t lsw;	/* Least significant word */
2069 		uint32_t msw;	/* Most significant word */
2070 #endif
2071 	} val;
2072 	struct {
2073 #if defined(_BIG_ENDIAN)
2074 		uint32_t	w1;
2075 #endif
2076 		struct {
2077 #if defined(_BIT_FIELDS_HTOL)
2078 		uint32_t res2		: 16;
2079 		uint32_t csr_dev_pres	: 2;
2080 		uint32_t res1		: 2;
2081 		uint32_t csr_tx_fault	: 1;
2082 		uint32_t csr_rx_fault	: 1;
2083 		uint32_t res0		: 7;
2084 		uint32_t ten_gbase_w	: 1;
2085 		uint32_t ten_gbase_x	: 1;
2086 		uint32_t ten_gbase_r	: 1;
2087 #elif defined(_BIT_FIELDS_LTOH)
2088 		uint32_t ten_gbase_r	: 1;
2089 		uint32_t ten_gbase_x	: 1;
2090 		uint32_t ten_gbase_w	: 1;
2091 		uint32_t res0		: 7;
2092 		uint32_t csr_rx_fault	: 1;
2093 		uint32_t csr_tx_fault	: 1;
2094 		uint32_t res1		: 2;
2095 		uint32_t csr_dev_pres	: 2;
2096 		uint32_t res2		: 16;
2097 #endif
2098 		} w0;
2099 
2100 #if defined(_LITTLE_ENDIAN)
2101 		uint32_t	w1;
2102 #endif
2103 	} bits;
2104 } xpcs_stat2_t;
2105 
2106 
2107 
2108 /* XPCS Base10G Status Register */
2109 #define	XPCS_STATUS_LANE_ALIGN		0x1000 /* 10GBaseX PCS rx lanes align */
2110 #define	XPCS_STATUS_PATTERN_TEST_ABLE	0x0800 /* able to generate patterns. */
2111 #define	XPCS_STATUS_LANE3_SYNC		0x0008 /* Lane 3 is synchronized */
2112 #define	XPCS_STATUS_LANE2_SYNC		0x0004 /* Lane 2 is synchronized */
2113 #define	XPCS_STATUS_LANE1_SYNC		0x0002 /* Lane 1 is synchronized */
2114 #define	XPCS_STATUS_LANE0_SYNC		0x0001 /* Lane 0 is synchronized */
2115 
2116 typedef	union _xpcs_stat_t {
2117 	uint64_t value;
2118 
2119 	struct {
2120 #if defined(_BIG_ENDIAN)
2121 		uint32_t msw;	/* Most significant word */
2122 		uint32_t lsw;	/* Least significant word */
2123 #elif defined(_LITTLE_ENDIAN)
2124 		uint32_t lsw;	/* Least significant word */
2125 		uint32_t msw;	/* Most significant word */
2126 #endif
2127 	} val;
2128 	struct {
2129 #if defined(_BIG_ENDIAN)
2130 		uint32_t	w1;
2131 #endif
2132 		struct {
2133 #if defined(_BIT_FIELDS_HTOL)
2134 		uint32_t res2			: 16;
2135 		uint32_t res1			: 3;
2136 		uint32_t csr_lane_align		: 1;
2137 		uint32_t csr_pattern_test_able	: 1;
2138 		uint32_t res0			: 7;
2139 		uint32_t csr_lane3_sync		: 1;
2140 		uint32_t csr_lane2_sync		: 1;
2141 		uint32_t csr_lane1_sync		: 1;
2142 		uint32_t csr_lane0_sync		: 1;
2143 #elif defined(_BIT_FIELDS_LTOH)
2144 		uint32_t csr_lane0_sync		: 1;
2145 		uint32_t csr_lane1_sync		: 1;
2146 		uint32_t csr_lane2_sync		: 1;
2147 		uint32_t csr_lane3_sync		: 1;
2148 		uint32_t res0			: 7;
2149 		uint32_t csr_pat_test_able	: 1;
2150 		uint32_t csr_lane_align		: 1;
2151 		uint32_t res1			: 3;
2152 		uint32_t res2			: 16;
2153 #endif
2154 		} w0;
2155 
2156 #if defined(_LITTLE_ENDIAN)
2157 		uint32_t	w1;
2158 #endif
2159 	} bits;
2160 } xpcs_stat_t;
2161 
2162 /* XPCS Base10G Test Control Register */
2163 #define	XPCS_TEST_CTRL_TX_TEST_ENABLE		0x0004
2164 #define	XPCS_TEST_CTRL_TEST_PATTERN_SEL_MASK	0x0003
2165 #define	TEST_PATTERN_HIGH_FREQ			0
2166 #define	TEST_PATTERN_LOW_FREQ			1
2167 #define	TEST_PATTERN_MIXED_FREQ			2
2168 
2169 typedef	union _xpcs_test_ctl_t {
2170 	uint64_t value;
2171 
2172 	struct {
2173 #if defined(_BIG_ENDIAN)
2174 		uint32_t msw;	/* Most significant word */
2175 		uint32_t lsw;	/* Least significant word */
2176 #elif defined(_LITTLE_ENDIAN)
2177 		uint32_t lsw;	/* Least significant word */
2178 		uint32_t msw;	/* Most significant word */
2179 #endif
2180 	} val;
2181 	struct {
2182 #if defined(_BIG_ENDIAN)
2183 		uint32_t	w1;
2184 #endif
2185 		struct {
2186 #if defined(_BIT_FIELDS_HTOL)
2187 		uint32_t res1			: 16;
2188 		uint32_t res0			: 13;
2189 		uint32_t csr_tx_test_en		: 1;
2190 		uint32_t csr_test_pat_sel	: 2;
2191 #elif defined(_BIT_FIELDS_LTOH)
2192 		uint32_t csr_test_pat_sel	: 2;
2193 		uint32_t csr_tx_test_en		: 1;
2194 		uint32_t res0			: 13;
2195 		uint32_t res1			: 16;
2196 #endif
2197 		} w0;
2198 
2199 #if defined(_LITTLE_ENDIAN)
2200 		uint32_t	w1;
2201 #endif
2202 	} bits;
2203 } xpcs_test_ctl_t;
2204 
2205 /* XPCS Base10G Diagnostic Register */
2206 #define	XPCS_DIAG_EB_ALIGN_ERR3		0x40
2207 #define	XPCS_DIAG_EB_ALIGN_ERR2		0x20
2208 #define	XPCS_DIAG_EB_ALIGN_ERR1		0x10
2209 #define	XPCS_DIAG_EB_DESKEW_OK		0x08
2210 #define	XPCS_DIAG_EB_ALIGN_DET3		0x04
2211 #define	XPCS_DIAG_EB_ALIGN_DET2		0x02
2212 #define	XPCS_DIAG_EB_ALIGN_DET1		0x01
2213 #define	XPCS_DIAG_EB_DESKEW_LOSS	0
2214 
2215 #define	XPCS_DIAG_SYNC_3_INVALID	0x8
2216 #define	XPCS_DIAG_SYNC_2_INVALID	0x4
2217 #define	XPCS_DIAG_SYNC_1_INVALID	0x2
2218 #define	XPCS_DIAG_SYNC_IN_SYNC		0x1
2219 #define	XPCS_DIAG_SYNC_LOSS_SYNC	0
2220 
2221 #define	XPCS_RX_SM_RECEIVE_STATE	1
2222 #define	XPCS_RX_SM_FAULT_STATE		0
2223 
2224 typedef	union _xpcs_diag_t {
2225 	uint64_t value;
2226 
2227 	struct {
2228 #if defined(_BIG_ENDIAN)
2229 		uint32_t msw;	/* Most significant word */
2230 		uint32_t lsw;	/* Least significant word */
2231 #elif defined(_LITTLE_ENDIAN)
2232 		uint32_t lsw;	/* Least significant word */
2233 		uint32_t msw;	/* Most significant word */
2234 #endif
2235 	} val;
2236 	struct {
2237 #if defined(_BIG_ENDIAN)
2238 		uint32_t	w1;
2239 #endif
2240 		struct {
2241 #if defined(_BIT_FIELDS_HTOL)
2242 		uint32_t res1			: 7;
2243 		uint32_t sync_sm_lane3		: 4;
2244 		uint32_t sync_sm_lane2		: 4;
2245 		uint32_t sync_sm_lane1		: 4;
2246 		uint32_t sync_sm_lane0		: 4;
2247 		uint32_t elastic_buffer_sm	: 8;
2248 		uint32_t receive_sm		: 1;
2249 #elif defined(_BIT_FIELDS_LTOH)
2250 		uint32_t receive_sm		: 1;
2251 		uint32_t elastic_buffer_sm	: 8;
2252 		uint32_t sync_sm_lane0		: 4;
2253 		uint32_t sync_sm_lane1		: 4;
2254 		uint32_t sync_sm_lane2		: 4;
2255 		uint32_t sync_sm_lane3		: 4;
2256 		uint32_t res1			: 7;
2257 #endif
2258 		} w0;
2259 
2260 #if defined(_LITTLE_ENDIAN)
2261 		uint32_t	w1;
2262 #endif
2263 	} bits;
2264 } xpcs_diag_t;
2265 
2266 /* XPCS Base10G Tx State Machine Register */
2267 #define	XPCS_TX_SM_SEND_UNDERRUN	0x9
2268 #define	XPCS_TX_SM_SEND_RANDOM_Q	0x8
2269 #define	XPCS_TX_SM_SEND_RANDOM_K	0x7
2270 #define	XPCS_TX_SM_SEND_RANDOM_A	0x6
2271 #define	XPCS_TX_SM_SEND_RANDOM_R	0x5
2272 #define	XPCS_TX_SM_SEND_Q		0x4
2273 #define	XPCS_TX_SM_SEND_K		0x3
2274 #define	XPCS_TX_SM_SEND_A		0x2
2275 #define	XPCS_TX_SM_SEND_SDP		0x1
2276 #define	XPCS_TX_SM_SEND_DATA		0
2277 
2278 /* XPCS Base10G Configuration Register */
2279 #define	XPCS_CFG_VENDOR_DBG_SEL_MASK	0x78
2280 #define	XPCS_CFG_VENDOR_DBG_SEL_SHIFT	3
2281 #define	XPCS_CFG_BYPASS_SIG_DETECT	0x0004
2282 #define	XPCS_CFG_ENABLE_TX_BUFFERS	0x0002
2283 #define	XPCS_CFG_XPCS_ENABLE		0x0001
2284 
2285 typedef	union _xpcs_config_t {
2286 	uint64_t value;
2287 
2288 	struct {
2289 #if defined(_BIG_ENDIAN)
2290 		uint32_t msw;	/* Most significant word */
2291 		uint32_t lsw;	/* Least significant word */
2292 #elif defined(_LITTLE_ENDIAN)
2293 		uint32_t lsw;	/* Least significant word */
2294 		uint32_t msw;	/* Most significant word */
2295 #endif
2296 	} val;
2297 	struct {
2298 #if defined(_BIG_ENDIAN)
2299 		uint32_t	w1;
2300 #endif
2301 		struct {
2302 #if defined(_BIT_FIELDS_HTOL)
2303 		uint32_t res1			: 16;
2304 		uint32_t res0			: 9;
2305 		uint32_t csr_vendor_dbg_sel	: 4;
2306 		uint32_t csr_bypass_sig_detect	: 1;
2307 		uint32_t csr_en_tx_buf		: 1;
2308 		uint32_t csr_xpcs_en		: 1;
2309 #elif defined(_BIT_FIELDS_LTOH)
2310 		uint32_t csr_xpcs_en		: 1;
2311 		uint32_t csr_en_tx_buf		: 1;
2312 		uint32_t csr_bypass_sig_detect	: 1;
2313 		uint32_t csr_vendor_dbg_sel	: 4;
2314 		uint32_t res0			: 9;
2315 		uint32_t res1			: 16;
2316 #endif
2317 		} w0;
2318 
2319 #if defined(_LITTLE_ENDIAN)
2320 		uint32_t	w1;
2321 #endif
2322 	} bits;
2323 } xpcs_config_t;
2324 
2325 
2326 
2327 /* XPCS Base10G Mask1 Register */
2328 #define	XPCS_MASK1_FAULT_MASK		0x0080	/* mask fault interrupt. */
2329 #define	XPCS_MASK1_RX_LINK_STATUS_MASK	0x0040	/* mask linkstat interrupt */
2330 
2331 /* XPCS Base10G Packet Counter */
2332 #define	XPCS_PKT_CNTR_TX_PKT_CNT_MASK	0xffff0000
2333 #define	XPCS_PKT_CNTR_TX_PKT_CNT_SHIFT	16
2334 #define	XPCS_PKT_CNTR_RX_PKT_CNT_MASK	0x0000ffff
2335 #define	XPCS_PKT_CNTR_RX_PKT_CNT_SHIFT	0
2336 
2337 /* XPCS Base10G TX State Machine status register */
2338 #define	XPCS_TX_STATE_MC_TX_STATE_MASK	0x0f
2339 #define	XPCS_DESKEW_ERR_CNTR_MASK	0xff
2340 
2341 /* XPCS Base10G Lane symbol error counters */
2342 #define	XPCS_SYM_ERR_CNT_L1_MASK  0xffff0000
2343 #define	XPCS_SYM_ERR_CNT_L0_MASK  0x0000ffff
2344 #define	XPCS_SYM_ERR_CNT_L3_MASK  0xffff0000
2345 #define	XPCS_SYM_ERR_CNT_L2_MASK  0x0000ffff
2346 
2347 #define	XPCS_SYM_ERR_CNT_MULTIPLIER	16
2348 
2349 /* ESR Reset Register */
2350 #define	ESR_RESET_1			2
2351 #define	ESR_RESET_0			1
2352 
2353 /* ESR Configuration Register */
2354 #define	ESR_BLUNT_END_LOOPBACK		2
2355 #define	ESR_FORCE_SERDES_SERDES_RDY	1
2356 
2357 /* ESR Neptune Serdes PLL Configuration */
2358 #define	ESR_PLL_CFG_FBDIV_0		0x1
2359 #define	ESR_PLL_CFG_FBDIV_1		0x2
2360 #define	ESR_PLL_CFG_FBDIV_2		0x4
2361 #define	ESR_PLL_CFG_HALF_RATE_0		0x8
2362 #define	ESR_PLL_CFG_HALF_RATE_1		0x10
2363 #define	ESR_PLL_CFG_HALF_RATE_2		0x20
2364 #define	ESR_PLL_CFG_HALF_RATE_3		0x40
2365 #define	ESR_PLL_CFG_1G_SERDES		(ESR_PLL_CFG_FBDIV_0 | \
2366 					ESR_PLL_CFG_HALF_RATE_0 | \
2367 					ESR_PLL_CFG_HALF_RATE_1 | \
2368 					ESR_PLL_CFG_HALF_RATE_2 | \
2369 					ESR_PLL_CFG_HALF_RATE_3)
2370 
2371 /* ESR Neptune Serdes Control Register */
2372 #define	ESR_CTL_EN_SYNCDET_0		0x00000001
2373 #define	ESR_CTL_EN_SYNCDET_1		0x00000002
2374 #define	ESR_CTL_EN_SYNCDET_2		0x00000004
2375 #define	ESR_CTL_EN_SYNCDET_3		0x00000008
2376 #define	ESR_CTL_OUT_EMPH_0_MASK		0x00000070
2377 #define	ESR_CTL_OUT_EMPH_0_SHIFT	4
2378 #define	ESR_CTL_OUT_EMPH_1_MASK		0x00000380
2379 #define	ESR_CTL_OUT_EMPH_1_SHIFT	7
2380 #define	ESR_CTL_OUT_EMPH_2_MASK		0x00001c00
2381 #define	ESR_CTL_OUT_EMPH_2_SHIFT	10
2382 #define	ESR_CTL_OUT_EMPH_3_MASK		0x0000e000
2383 #define	ESR_CTL_OUT_EMPH_3_SHIFT	13
2384 #define	ESR_CTL_LOSADJ_0_MASK		0x00070000
2385 #define	ESR_CTL_LOSADJ_0_SHIFT		16
2386 #define	ESR_CTL_LOSADJ_1_MASK		0x00380000
2387 #define	ESR_CTL_LOSADJ_1_SHIFT		19
2388 #define	ESR_CTL_LOSADJ_2_MASK		0x01c00000
2389 #define	ESR_CTL_LOSADJ_2_SHIFT		22
2390 #define	ESR_CTL_LOSADJ_3_MASK		0x0e000000
2391 #define	ESR_CTL_LOSADJ_3_SHIFT		25
2392 #define	ESR_CTL_RXITERM_0		0x10000000
2393 #define	ESR_CTL_RXITERM_1		0x20000000
2394 #define	ESR_CTL_RXITERM_2		0x40000000
2395 #define	ESR_CTL_RXITERM_3		0x80000000
2396 #define	ESR_CTL_1G_SERDES		(ESR_CTL_EN_SYNCDET_0 | \
2397 					ESR_CTL_EN_SYNCDET_1 |	\
2398 					ESR_CTL_EN_SYNCDET_2 |	\
2399 					ESR_CTL_EN_SYNCDET_3 |  \
2400 					(0x1 << ESR_CTL_OUT_EMPH_0_SHIFT) | \
2401 					(0x1 << ESR_CTL_OUT_EMPH_1_SHIFT) | \
2402 					(0x1 << ESR_CTL_OUT_EMPH_2_SHIFT) | \
2403 					(0x1 << ESR_CTL_OUT_EMPH_3_SHIFT) | \
2404 					(0x1 << ESR_CTL_OUT_EMPH_3_SHIFT) | \
2405 					(0x1 << ESR_CTL_LOSADJ_0_SHIFT) | \
2406 					(0x1 << ESR_CTL_LOSADJ_1_SHIFT) | \
2407 					(0x1 << ESR_CTL_LOSADJ_2_SHIFT) | \
2408 					(0x1 << ESR_CTL_LOSADJ_3_SHIFT))
2409 
2410 /* ESR Neptune Serdes Test Configuration Register */
2411 #define	ESR_TSTCFG_LBTEST_MD_0_MASK	0x00000003
2412 #define	ESR_TSTCFG_LBTEST_MD_0_SHIFT	0
2413 #define	ESR_TSTCFG_LBTEST_MD_1_MASK	0x0000000c
2414 #define	ESR_TSTCFG_LBTEST_MD_1_SHIFT	2
2415 #define	ESR_TSTCFG_LBTEST_MD_2_MASK	0x00000030
2416 #define	ESR_TSTCFG_LBTEST_MD_2_SHIFT	4
2417 #define	ESR_TSTCFG_LBTEST_MD_3_MASK	0x000000c0
2418 #define	ESR_TSTCFG_LBTEST_MD_3_SHIFT	6
2419 #define	ESR_TSTCFG_LBTEST_PAD		(ESR_PAD_LOOPBACK_CH3 | \
2420 					ESR_PAD_LOOPBACK_CH2 | \
2421 					ESR_PAD_LOOPBACK_CH1 | \
2422 					ESR_PAD_LOOPBACK_CH0)
2423 
2424 /* ESR Neptune Ethernet RGMII Configuration Register */
2425 #define	ESR_RGMII_PT0_IN_USE		0x00000001
2426 #define	ESR_RGMII_PT1_IN_USE		0x00000002
2427 #define	ESR_RGMII_PT2_IN_USE		0x00000004
2428 #define	ESR_RGMII_PT3_IN_USE		0x00000008
2429 #define	ESR_RGMII_REG_RW_TEST		0x00000010
2430 
2431 /* ESR Internal Signals Observation Register */
2432 #define	ESR_SIG_MASK			0xFFFFFFFF
2433 #define	ESR_SIG_P0_BITS_MASK		0x33E0000F
2434 #define	ESR_SIG_P1_BITS_MASK		0x0C1F00F0
2435 #define	ESR_SIG_SERDES_RDY0_P0		0x20000000
2436 #define	ESR_SIG_DETECT0_P0		0x10000000
2437 #define	ESR_SIG_SERDES_RDY0_P1		0x08000000
2438 #define	ESR_SIG_DETECT0_P1		0x04000000
2439 #define	ESR_SIG_XSERDES_RDY_P0		0x02000000
2440 #define	ESR_SIG_XDETECT_P0_CH3		0x01000000
2441 #define	ESR_SIG_XDETECT_P0_CH2		0x00800000
2442 #define	ESR_SIG_XDETECT_P0_CH1		0x00400000
2443 #define	ESR_SIG_XDETECT_P0_CH0		0x00200000
2444 #define	ESR_SIG_XSERDES_RDY_P1		0x00100000
2445 #define	ESR_SIG_XDETECT_P1_CH3		0x00080000
2446 #define	ESR_SIG_XDETECT_P1_CH2		0x00040000
2447 #define	ESR_SIG_XDETECT_P1_CH1		0x00020000
2448 #define	ESR_SIG_XDETECT_P1_CH0		0x00010000
2449 #define	ESR_SIG_LOS_P1_CH3		0x00000080
2450 #define	ESR_SIG_LOS_P1_CH2		0x00000040
2451 #define	ESR_SIG_LOS_P1_CH1		0x00000020
2452 #define	ESR_SIG_LOS_P1_CH0		0x00000010
2453 #define	ESR_SIG_LOS_P0_CH3		0x00000008
2454 #define	ESR_SIG_LOS_P0_CH2		0x00000004
2455 #define	ESR_SIG_LOS_P0_CH1		0x00000002
2456 #define	ESR_SIG_LOS_P0_CH0		0x00000001
2457 #define	ESR_SIG_P0_BITS_MASK_1G		(ESR_SIG_SERDES_RDY0_P0 | \
2458 					ESR_SIG_DETECT0_P0)
2459 #define	ESR_SIG_P1_BITS_MASK_1G		(ESR_SIG_SERDES_RDY0_P1 | \
2460 					ESR_SIG_DETECT0_P1)
2461 
2462 /* ESR Debug Selection Register */
2463 #define	ESR_DEBUG_SEL_MASK		0x00000003f
2464 
2465 /* ESR Test Configuration Register */
2466 #define	ESR_NO_LOOPBACK_CH3		(0x0 << 6)
2467 #define	ESR_EWRAP_CH3			(0x1 << 6)
2468 #define	ESR_PAD_LOOPBACK_CH3		(0x2 << 6)
2469 #define	ESR_REVLOOPBACK_CH3		(0x3 << 6)
2470 #define	ESR_NO_LOOPBACK_CH2		(0x0 << 4)
2471 #define	ESR_EWRAP_CH2			(0x1 << 4)
2472 #define	ESR_PAD_LOOPBACK_CH2		(0x2 << 4)
2473 #define	ESR_REVLOOPBACK_CH2		(0x3 << 4)
2474 #define	ESR_NO_LOOPBACK_CH1		(0x0 << 2)
2475 #define	ESR_EWRAP_CH1			(0x1 << 2)
2476 #define	ESR_PAD_LOOPBACK_CH1		(0x2 << 2)
2477 #define	ESR_REVLOOPBACK_CH1		(0x3 << 2)
2478 #define	ESR_NO_LOOPBACK_CH0		0x0
2479 #define	ESR_EWRAP_CH0			0x1
2480 #define	ESR_PAD_LOOPBACK_CH0		0x2
2481 #define	ESR_REVLOOPBACK_CH0		0x3
2482 
2483 /* convert values */
2484 #define	NXGE_BASE(x, y)	\
2485 	(((y) << (x ## _SHIFT)) & (x ## _MASK))
2486 
2487 #define	NXGE_VAL_GET(fieldname, regval)		\
2488 	(((regval) & ((fieldname) ## _MASK)) >> ((fieldname) ## _SHIFT))
2489 
2490 #define	NXGE_VAL_SET(fieldname, regval, val)		\
2491 {							\
2492 	(regval) &= ~((fieldname) ## _MASK);		\
2493 	(regval) |= ((val) << (fieldname ## _SHIFT)); 	\
2494 }
2495 
2496 
2497 #ifdef	__cplusplus
2498 }
2499 #endif
2500 
2501 #endif	/* _SYS_MAC_NXGE_MAC_HW_H */
2502