xref: /onnv-gate/usr/src/uts/common/io/chxge/com/ch_mac.c (revision 3833:45d8d0ee8613)
1*3833Sxw161283 /*
2*3833Sxw161283  * CDDL HEADER START
3*3833Sxw161283  *
4*3833Sxw161283  * The contents of this file are subject to the terms of the
5*3833Sxw161283  * Common Development and Distribution License (the "License").
6*3833Sxw161283  * You may not use this file except in compliance with the License.
7*3833Sxw161283  *
8*3833Sxw161283  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*3833Sxw161283  * or http://www.opensolaris.org/os/licensing.
10*3833Sxw161283  * See the License for the specific language governing permissions
11*3833Sxw161283  * and limitations under the License.
12*3833Sxw161283  *
13*3833Sxw161283  * When distributing Covered Code, include this CDDL HEADER in each
14*3833Sxw161283  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*3833Sxw161283  * If applicable, add the following below this CDDL HEADER, with the
16*3833Sxw161283  * fields enclosed by brackets "[]" replaced with your own identifying
17*3833Sxw161283  * information: Portions Copyright [yyyy] [name of copyright owner]
18*3833Sxw161283  *
19*3833Sxw161283  * CDDL HEADER END
20*3833Sxw161283  */
21*3833Sxw161283 
22*3833Sxw161283 /*
23*3833Sxw161283  * Copyright (C) 2003-2005 Chelsio Communications.  All rights reserved.
24*3833Sxw161283  */
25*3833Sxw161283 
26*3833Sxw161283 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* ch_mac.c */
27*3833Sxw161283 
28*3833Sxw161283 #include "gmac.h"
29*3833Sxw161283 #include "regs.h"
30*3833Sxw161283 #include "fpga_defs.h"
31*3833Sxw161283 
32*3833Sxw161283 #define	MAC_CSR_INTERFACE_GMII	0x0
33*3833Sxw161283 #define	MAC_CSR_INTERFACE_TBI	0x1
34*3833Sxw161283 #define	MAC_CSR_INTERFACE_MII	0x2
35*3833Sxw161283 #define	MAC_CSR_INTERFACE_RMII	0x3
36*3833Sxw161283 
37*3833Sxw161283 /* Chelsio's MAC statistics. */
38*3833Sxw161283 struct mac_statistics {
39*3833Sxw161283 
40*3833Sxw161283 	/* Transmit */
41*3833Sxw161283 	u32 TxFramesTransmittedOK;
42*3833Sxw161283 	u32 TxReserved1;
43*3833Sxw161283 	u32 TxReserved2;
44*3833Sxw161283 	u32 TxOctetsTransmittedOK;
45*3833Sxw161283 	u32 TxFramesWithDeferredXmissions;
46*3833Sxw161283 	u32 TxLateCollisions;
47*3833Sxw161283 	u32 TxFramesAbortedDueToXSCollisions;
48*3833Sxw161283 	u32 TxFramesLostDueToIntMACXmitError;
49*3833Sxw161283 	u32 TxReserved3;
50*3833Sxw161283 	u32 TxMulticastFrameXmittedOK;
51*3833Sxw161283 	u32 TxBroadcastFramesXmittedOK;
52*3833Sxw161283 	u32 TxFramesWithExcessiveDeferral;
53*3833Sxw161283 	u32 TxPAUSEMACCtrlFramesTransmitted;
54*3833Sxw161283 
55*3833Sxw161283 	/* Receive */
56*3833Sxw161283 	u32 RxFramesReceivedOK;
57*3833Sxw161283 	u32 RxFrameCheckSequenceErrors;
58*3833Sxw161283 	u32 RxAlignmentErrors;
59*3833Sxw161283 	u32 RxOctetsReceivedOK;
60*3833Sxw161283 	u32 RxFramesLostDueToIntMACRcvError;
61*3833Sxw161283 	u32 RxMulticastFramesReceivedOK;
62*3833Sxw161283 	u32 RxBroadcastFramesReceivedOK;
63*3833Sxw161283 	u32 RxInRangeLengthErrors;
64*3833Sxw161283 	u32 RxTxOutOfRangeLengthField;
65*3833Sxw161283 	u32 RxFrameTooLongErrors;
66*3833Sxw161283 	u32 RxPAUSEMACCtrlFramesReceived;
67*3833Sxw161283 };
68*3833Sxw161283 
69*3833Sxw161283 static int static_aPorts[] = {
70*3833Sxw161283 	FPGA_GMAC_INTERRUPT_PORT0,
71*3833Sxw161283 	FPGA_GMAC_INTERRUPT_PORT1,
72*3833Sxw161283 	FPGA_GMAC_INTERRUPT_PORT2,
73*3833Sxw161283 	FPGA_GMAC_INTERRUPT_PORT3
74*3833Sxw161283 };
75*3833Sxw161283 
76*3833Sxw161283 struct _cmac_instance {
77*3833Sxw161283 	u32 index;
78*3833Sxw161283 };
79*3833Sxw161283 
mac_intr_enable(struct cmac * mac)80*3833Sxw161283 static int mac_intr_enable(struct cmac *mac)
81*3833Sxw161283 {
82*3833Sxw161283 	u32 mac_intr;
83*3833Sxw161283 
84*3833Sxw161283 	if (t1_is_asic(mac->adapter)) {
85*3833Sxw161283 		/* ASIC */
86*3833Sxw161283 		/*EMPTY*/
87*3833Sxw161283 		/* We don't use the on chip MAC for ASIC products. */
88*3833Sxw161283 	} else {
89*3833Sxw161283 		/* FPGA */
90*3833Sxw161283 
91*3833Sxw161283 		/* Set parent gmac interrupt. */
92*3833Sxw161283 		mac_intr = t1_read_reg_4(mac->adapter, A_PL_ENABLE);
93*3833Sxw161283 		mac_intr |= FPGA_PCIX_INTERRUPT_GMAC;
94*3833Sxw161283 		t1_write_reg_4(mac->adapter, A_PL_ENABLE, mac_intr);
95*3833Sxw161283 
96*3833Sxw161283 		mac_intr = t1_read_reg_4(mac->adapter,
97*3833Sxw161283 			FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
98*3833Sxw161283 		mac_intr |= static_aPorts[mac->instance->index];
99*3833Sxw161283 		t1_write_reg_4(mac->adapter,
100*3833Sxw161283 			FPGA_GMAC_ADDR_INTERRUPT_ENABLE, mac_intr);
101*3833Sxw161283 	}
102*3833Sxw161283 
103*3833Sxw161283 	return (0);
104*3833Sxw161283 }
105*3833Sxw161283 
mac_intr_disable(struct cmac * mac)106*3833Sxw161283 static int mac_intr_disable(struct cmac *mac)
107*3833Sxw161283 {
108*3833Sxw161283 	u32 mac_intr;
109*3833Sxw161283 
110*3833Sxw161283 	if (t1_is_asic(mac->adapter)) {
111*3833Sxw161283 		/* ASIC */
112*3833Sxw161283 		/*EMPTY*/
113*3833Sxw161283 		/* We don't use the on chip MAC for ASIC products. */
114*3833Sxw161283 	} else {
115*3833Sxw161283 		/* FPGA */
116*3833Sxw161283 
117*3833Sxw161283 		/* Set parent gmac interrupt. */
118*3833Sxw161283 		mac_intr = t1_read_reg_4(mac->adapter, A_PL_ENABLE);
119*3833Sxw161283 		mac_intr &= ~FPGA_PCIX_INTERRUPT_GMAC;
120*3833Sxw161283 		t1_write_reg_4(mac->adapter, A_PL_ENABLE, mac_intr);
121*3833Sxw161283 
122*3833Sxw161283 		mac_intr = t1_read_reg_4(mac->adapter,
123*3833Sxw161283 			FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
124*3833Sxw161283 		mac_intr &= ~(static_aPorts[mac->instance->index]);
125*3833Sxw161283 		t1_write_reg_4(mac->adapter,
126*3833Sxw161283 			FPGA_GMAC_ADDR_INTERRUPT_ENABLE, mac_intr);
127*3833Sxw161283 	}
128*3833Sxw161283 
129*3833Sxw161283 	return (0);
130*3833Sxw161283 }
131*3833Sxw161283 
mac_intr_clear(struct cmac * mac)132*3833Sxw161283 static int mac_intr_clear(struct cmac *mac)
133*3833Sxw161283 {
134*3833Sxw161283 	u32 mac_intr;
135*3833Sxw161283 
136*3833Sxw161283 	if (t1_is_asic(mac->adapter)) {
137*3833Sxw161283 		/* ASIC */
138*3833Sxw161283 		/*EMPTY*/
139*3833Sxw161283 		/* We don't use the on chip MAC for ASIC products. */
140*3833Sxw161283 	} else {
141*3833Sxw161283 		/* FPGA */
142*3833Sxw161283 
143*3833Sxw161283 		/* Set parent gmac interrupt. */
144*3833Sxw161283 		t1_write_reg_4(mac->adapter, A_PL_CAUSE,
145*3833Sxw161283 			FPGA_PCIX_INTERRUPT_GMAC);
146*3833Sxw161283 
147*3833Sxw161283 		mac_intr = t1_read_reg_4(mac->adapter,
148*3833Sxw161283 			FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
149*3833Sxw161283 		mac_intr |= (static_aPorts[mac->instance->index]);
150*3833Sxw161283 		t1_write_reg_4(mac->adapter,
151*3833Sxw161283 			FPGA_GMAC_ADDR_INTERRUPT_CAUSE, mac_intr);
152*3833Sxw161283 	}
153*3833Sxw161283 
154*3833Sxw161283 	return (0);
155*3833Sxw161283 }
156*3833Sxw161283 
mac_get_address(struct cmac * mac,u8 addr[6])157*3833Sxw161283 static int mac_get_address(struct cmac *mac, u8 addr[6])
158*3833Sxw161283 {
159*3833Sxw161283 	u32 data32_lo, data32_hi;
160*3833Sxw161283 
161*3833Sxw161283 	data32_lo = t1_read_reg_4(mac->adapter,
162*3833Sxw161283 			MAC_REG_IDLO(mac->instance->index));
163*3833Sxw161283 	data32_hi = t1_read_reg_4(mac->adapter,
164*3833Sxw161283 			MAC_REG_IDHI(mac->instance->index));
165*3833Sxw161283 
166*3833Sxw161283 	addr[0] = (u8) ((data32_hi >> 8) & 0xFF);
167*3833Sxw161283 	addr[1] = (u8) ((data32_hi) & 0xFF);
168*3833Sxw161283 	addr[2] = (u8) ((data32_lo >> 24) & 0xFF);
169*3833Sxw161283 	addr[3] = (u8) ((data32_lo >> 16) & 0xFF);
170*3833Sxw161283 	addr[4] = (u8) ((data32_lo >> 8) & 0xFF);
171*3833Sxw161283 	addr[5] = (u8) ((data32_lo) & 0xFF);
172*3833Sxw161283 	return (0);
173*3833Sxw161283 }
174*3833Sxw161283 
mac_reset(struct cmac * mac)175*3833Sxw161283 static int mac_reset(struct cmac *mac)
176*3833Sxw161283 {
177*3833Sxw161283 	u32 data32;
178*3833Sxw161283 	int mac_in_reset, time_out = 100;
179*3833Sxw161283 	int idx = mac->instance->index;
180*3833Sxw161283 
181*3833Sxw161283 	data32 = t1_read_reg_4(mac->adapter, MAC_REG_CSR(idx));
182*3833Sxw161283 	t1_write_reg_4(mac->adapter, MAC_REG_CSR(idx),
183*3833Sxw161283 		data32 | F_MAC_RESET);
184*3833Sxw161283 
185*3833Sxw161283 	do {
186*3833Sxw161283 		data32 = t1_read_reg_4(mac->adapter,
187*3833Sxw161283 			MAC_REG_CSR(idx));
188*3833Sxw161283 		mac_in_reset = data32 & F_MAC_RESET;
189*3833Sxw161283 		if (mac_in_reset)
190*3833Sxw161283 			DELAY_US(1);
191*3833Sxw161283 	} while (mac_in_reset && --time_out);
192*3833Sxw161283 
193*3833Sxw161283 	if (mac_in_reset) {
194*3833Sxw161283 		CH_ERR("%s: MAC %d reset timed out\n",
195*3833Sxw161283 			adapter_name(mac->adapter), idx);
196*3833Sxw161283 		return (2);
197*3833Sxw161283 	}
198*3833Sxw161283 
199*3833Sxw161283 	return (0);
200*3833Sxw161283 }
201*3833Sxw161283 
mac_set_rx_mode(struct cmac * mac,struct t1_rx_mode * rm)202*3833Sxw161283 static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
203*3833Sxw161283 {
204*3833Sxw161283 	u32 val;
205*3833Sxw161283 
206*3833Sxw161283 	val = t1_read_reg_4(mac->adapter,
207*3833Sxw161283 			    MAC_REG_CSR(mac->instance->index));
208*3833Sxw161283 	val &= ~(F_MAC_PROMISC | F_MAC_MC_ENABLE);
209*3833Sxw161283 	val |= V_MAC_PROMISC(t1_rx_mode_promisc(rm) != 0);
210*3833Sxw161283 	val |= V_MAC_MC_ENABLE(t1_rx_mode_allmulti(rm) != 0);
211*3833Sxw161283 	t1_write_reg_4(mac->adapter,
212*3833Sxw161283 		MAC_REG_CSR(mac->instance->index), val);
213*3833Sxw161283 
214*3833Sxw161283 	return (0);
215*3833Sxw161283 }
216*3833Sxw161283 
mac_set_speed_duplex_fc(struct cmac * mac,int speed,int duplex,int fc)217*3833Sxw161283 static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
218*3833Sxw161283 	int fc)
219*3833Sxw161283 {
220*3833Sxw161283 	u32 data32;
221*3833Sxw161283 
222*3833Sxw161283 	data32 = t1_read_reg_4(mac->adapter,
223*3833Sxw161283 		MAC_REG_CSR(mac->instance->index));
224*3833Sxw161283 	data32 &= ~(F_MAC_HALF_DUPLEX | V_MAC_SPEED(M_MAC_SPEED) |
225*3833Sxw161283 		V_INTERFACE(M_INTERFACE) | F_MAC_TX_PAUSE_ENABLE |
226*3833Sxw161283 		F_MAC_RX_PAUSE_ENABLE);
227*3833Sxw161283 
228*3833Sxw161283 	switch (speed) {
229*3833Sxw161283 	case SPEED_10:
230*3833Sxw161283 	case SPEED_100:
231*3833Sxw161283 		data32 |= V_INTERFACE(MAC_CSR_INTERFACE_MII);
232*3833Sxw161283 		data32 |= V_MAC_SPEED(speed == SPEED_10 ? 0 : 1);
233*3833Sxw161283 		break;
234*3833Sxw161283 	case SPEED_1000:
235*3833Sxw161283 		data32 |= V_INTERFACE(MAC_CSR_INTERFACE_GMII);
236*3833Sxw161283 		data32 |= V_MAC_SPEED(2);
237*3833Sxw161283 		break;
238*3833Sxw161283 	}
239*3833Sxw161283 
240*3833Sxw161283 	if (duplex >= 0)
241*3833Sxw161283 		data32 |= V_MAC_HALF_DUPLEX(duplex == DUPLEX_HALF);
242*3833Sxw161283 
243*3833Sxw161283 	if (fc >= 0) {
244*3833Sxw161283 		data32 |= V_MAC_RX_PAUSE_ENABLE((fc & PAUSE_RX) != 0);
245*3833Sxw161283 		data32 |= V_MAC_TX_PAUSE_ENABLE((fc & PAUSE_TX) != 0);
246*3833Sxw161283 	}
247*3833Sxw161283 
248*3833Sxw161283 	t1_write_reg_4(mac->adapter,
249*3833Sxw161283 		MAC_REG_CSR(mac->instance->index), data32);
250*3833Sxw161283 	return (0);
251*3833Sxw161283 }
252*3833Sxw161283 
mac_enable(struct cmac * mac,int which)253*3833Sxw161283 static int mac_enable(struct cmac *mac, int which)
254*3833Sxw161283 {
255*3833Sxw161283 	u32 val;
256*3833Sxw161283 
257*3833Sxw161283 	val = t1_read_reg_4(mac->adapter,
258*3833Sxw161283 			    MAC_REG_CSR(mac->instance->index));
259*3833Sxw161283 	if (which & MAC_DIRECTION_RX)
260*3833Sxw161283 		val |= F_MAC_RX_ENABLE;
261*3833Sxw161283 	if (which & MAC_DIRECTION_TX)
262*3833Sxw161283 		val |= F_MAC_TX_ENABLE;
263*3833Sxw161283 	t1_write_reg_4(mac->adapter,
264*3833Sxw161283 		MAC_REG_CSR(mac->instance->index), val);
265*3833Sxw161283 	return (0);
266*3833Sxw161283 }
267*3833Sxw161283 
mac_disable(struct cmac * mac,int which)268*3833Sxw161283 static int mac_disable(struct cmac *mac, int which)
269*3833Sxw161283 {
270*3833Sxw161283 	u32 val;
271*3833Sxw161283 
272*3833Sxw161283 	val = t1_read_reg_4(mac->adapter,
273*3833Sxw161283 		MAC_REG_CSR(mac->instance->index));
274*3833Sxw161283 	if (which & MAC_DIRECTION_RX)
275*3833Sxw161283 		val &= ~F_MAC_RX_ENABLE;
276*3833Sxw161283 	if (which & MAC_DIRECTION_TX)
277*3833Sxw161283 		val &= ~F_MAC_TX_ENABLE;
278*3833Sxw161283 	t1_write_reg_4(mac->adapter,
279*3833Sxw161283 		MAC_REG_CSR(mac->instance->index), val);
280*3833Sxw161283 	return (0);
281*3833Sxw161283 }
282*3833Sxw161283 
283*3833Sxw161283 int
mac_set_ifs(struct cmac * mac,u32 mode)284*3833Sxw161283 mac_set_ifs(struct cmac *mac, u32 mode)
285*3833Sxw161283 {
286*3833Sxw161283 	t1_write_reg_4(mac->adapter,
287*3833Sxw161283 		MAC_REG_IFS(mac->instance->index), mode);
288*3833Sxw161283 
289*3833Sxw161283 	return (0);
290*3833Sxw161283 }
291*3833Sxw161283 
292*3833Sxw161283 int
mac_enable_isl(struct cmac * mac)293*3833Sxw161283 mac_enable_isl(struct cmac *mac)
294*3833Sxw161283 {
295*3833Sxw161283 	u32 data32 = t1_read_reg_4(mac->adapter,
296*3833Sxw161283 		MAC_REG_CSR(mac->instance->index));
297*3833Sxw161283 	data32 |= F_MAC_RX_ENABLE | F_MAC_TX_ENABLE;
298*3833Sxw161283 	t1_write_reg_4(mac->adapter,
299*3833Sxw161283 		MAC_REG_CSR(mac->instance->index), data32);
300*3833Sxw161283 
301*3833Sxw161283 	return (0);
302*3833Sxw161283 }
303*3833Sxw161283 
mac_set_mtu(struct cmac * mac,int mtu)304*3833Sxw161283 static int mac_set_mtu(struct cmac *mac, int mtu)
305*3833Sxw161283 {
306*3833Sxw161283 	if (mtu > 9600)
307*3833Sxw161283 		return (-EINVAL);
308*3833Sxw161283 	t1_write_reg_4(mac->adapter,
309*3833Sxw161283 		MAC_REG_LARGEFRAMELENGTH(mac->instance->index),
310*3833Sxw161283 		mtu + 14 + 4);
311*3833Sxw161283 	return (0);
312*3833Sxw161283 }
313*3833Sxw161283 
314*3833Sxw161283 /* ARGSUSED */
mac_update_statistics(struct cmac * mac,int flag)315*3833Sxw161283 static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
316*3833Sxw161283 	int flag)
317*3833Sxw161283 {
318*3833Sxw161283 	struct mac_statistics st;
319*3833Sxw161283 	u32 *p = (u32 *) & st, i;
320*3833Sxw161283 
321*3833Sxw161283 	t1_write_reg_4(mac->adapter,
322*3833Sxw161283 		MAC_REG_RMCNT(mac->instance->index), 0);
323*3833Sxw161283 	for (i = 0; i < sizeof (st) / sizeof (u32); i++)
324*3833Sxw161283 		*p++ = t1_read_reg_4(mac->adapter,
325*3833Sxw161283 			MAC_REG_RMDATA(mac->instance->index));
326*3833Sxw161283 
327*3833Sxw161283 	/* XXX convert stats */
328*3833Sxw161283 	return (&mac->stats);
329*3833Sxw161283 }
330*3833Sxw161283 
mac_destroy(struct cmac * mac)331*3833Sxw161283 static void mac_destroy(struct cmac *mac)
332*3833Sxw161283 {
333*3833Sxw161283 	t1_os_free((void *)mac, sizeof (*mac) + sizeof (cmac_instance));
334*3833Sxw161283 }
335*3833Sxw161283 
336*3833Sxw161283 #ifdef C99_NOT_SUPPORTED
337*3833Sxw161283 static struct cmac_ops chelsio_mac_ops = {
338*3833Sxw161283 	mac_destroy,
339*3833Sxw161283 	mac_reset,
340*3833Sxw161283 	mac_intr_enable,
341*3833Sxw161283 	mac_intr_disable,
342*3833Sxw161283 	mac_intr_clear,
343*3833Sxw161283 	NULL,
344*3833Sxw161283 	mac_enable,
345*3833Sxw161283 	mac_disable,
346*3833Sxw161283 	NULL,
347*3833Sxw161283 	NULL,
348*3833Sxw161283 	mac_set_mtu,
349*3833Sxw161283 	mac_set_rx_mode,
350*3833Sxw161283 	mac_set_speed_duplex_fc,
351*3833Sxw161283 	NULL,
352*3833Sxw161283 	mac_update_statistics,
353*3833Sxw161283 	mac_get_address,
354*3833Sxw161283 	NULL
355*3833Sxw161283 };
356*3833Sxw161283 #else
357*3833Sxw161283 static struct cmac_ops chelsio_mac_ops = {
358*3833Sxw161283 	.destroy		= mac_destroy,
359*3833Sxw161283 	.reset			= mac_reset,
360*3833Sxw161283 	.interrupt_enable	= mac_intr_enable,
361*3833Sxw161283 	.interrupt_disable	= mac_intr_disable,
362*3833Sxw161283 	.interrupt_clear	= mac_intr_clear,
363*3833Sxw161283 	.enable			= mac_enable,
364*3833Sxw161283 	.disable		= mac_disable,
365*3833Sxw161283 	.set_mtu		= mac_set_mtu,
366*3833Sxw161283 	.set_rx_mode		= mac_set_rx_mode,
367*3833Sxw161283 	.set_speed_duplex_fc	= mac_set_speed_duplex_fc,
368*3833Sxw161283 	.macaddress_get		= mac_get_address,
369*3833Sxw161283 	.statistics_update	= mac_update_statistics,
370*3833Sxw161283 };
371*3833Sxw161283 #endif
372*3833Sxw161283 
mac_create(adapter_t * adapter,int index)373*3833Sxw161283 static struct cmac *mac_create(adapter_t *adapter, int index)
374*3833Sxw161283 {
375*3833Sxw161283 	struct cmac *mac;
376*3833Sxw161283 	u32 data32;
377*3833Sxw161283 
378*3833Sxw161283 	if (index >= 4)
379*3833Sxw161283 		return (NULL);
380*3833Sxw161283 
381*3833Sxw161283 	mac = t1_os_malloc_wait_zero(sizeof (*mac) + sizeof (cmac_instance));
382*3833Sxw161283 	if (!mac)
383*3833Sxw161283 		return (NULL);
384*3833Sxw161283 
385*3833Sxw161283 	mac->ops = &chelsio_mac_ops;
386*3833Sxw161283 	mac->instance = (cmac_instance *) (mac + 1);
387*3833Sxw161283 
388*3833Sxw161283 	mac->instance->index = index;
389*3833Sxw161283 	mac->adapter = adapter;
390*3833Sxw161283 
391*3833Sxw161283 	data32 = t1_read_reg_4(adapter, MAC_REG_CSR(mac->instance->index));
392*3833Sxw161283 	data32 &= ~(F_MAC_RESET | F_MAC_PROMISC | F_MAC_PROMISC |
393*3833Sxw161283 		    F_MAC_LB_ENABLE | F_MAC_RX_ENABLE | F_MAC_TX_ENABLE);
394*3833Sxw161283 	data32 |= F_MAC_JUMBO_ENABLE;
395*3833Sxw161283 	t1_write_reg_4(adapter, MAC_REG_CSR(mac->instance->index), data32);
396*3833Sxw161283 
397*3833Sxw161283 	/* Initialize the random backoff seed. */
398*3833Sxw161283 	data32 = 0x55aa + (3 * index);
399*3833Sxw161283 	t1_write_reg_4(adapter,
400*3833Sxw161283 		MAC_REG_GMRANDBACKOFFSEED(mac->instance->index), data32);
401*3833Sxw161283 
402*3833Sxw161283 	/* Check to see if the mac address needs to be set manually. */
403*3833Sxw161283 	data32 = t1_read_reg_4(adapter, MAC_REG_IDLO(mac->instance->index));
404*3833Sxw161283 	if (data32 == 0 || data32 == 0xffffffff) {
405*3833Sxw161283 		/*
406*3833Sxw161283 		 * Add a default MAC address if we can't read one.
407*3833Sxw161283 		 */
408*3833Sxw161283 		t1_write_reg_4(adapter, MAC_REG_IDLO(mac->instance->index),
409*3833Sxw161283 			0x43FFFFFF - index);
410*3833Sxw161283 		t1_write_reg_4(adapter, MAC_REG_IDHI(mac->instance->index),
411*3833Sxw161283 			0x0007);
412*3833Sxw161283 	}
413*3833Sxw161283 
414*3833Sxw161283 	(void) mac_set_mtu(mac, 1500);
415*3833Sxw161283 	return (mac);
416*3833Sxw161283 }
417*3833Sxw161283 
418*3833Sxw161283 struct gmac t1_chelsio_mac_ops = {
419*3833Sxw161283 	0,
420*3833Sxw161283 	mac_create
421*3833Sxw161283 };
422