1 /*
2  * This file is provided under a CDDLv1 license.  When using or
3  * redistributing this file, you may do so under this license.
4  * In redistributing this file this license must be included
5  * and no other modification of this header file is permitted.
6  *
7  * CDDL LICENSE SUMMARY
8  *
9  * Copyright(c) 1999 - 2007 Intel Corporation. All rights reserved.
10  *
11  * The contents of this file are subject to the terms of Version
12  * 1.0 of the Common Development and Distribution License (the "License").
13  *
14  * You should have received a copy of the License with this software.
15  * You can obtain a copy of the License at
16  *	http://www.opensolaris.org/os/licensing.
17  * See the License for the specific language governing permissions
18  * and limitations under the License.
19  */
20 
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms of the CDDLv1.
24  */
25 
26 #ifndef _E1000G_SW_H
27 #define	_E1000G_SW_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * **********************************************************************
37  * Module Name:								*
38  *   e1000g_sw.h							*
39  *									*
40  * Abstract:								*
41  *   This header file contains Software-related data structures		*
42  *   definitions.							*
43  *									*
44  *   This driver runs on the following hardware:			*
45  *   - Wisemane based PCI gigabit ethernet adapters			*
46  *									*
47  * Environment:								*
48  *   Kernel Mode -							*
49  *									*
50  * **********************************************************************
51  */
52 
53 #ifdef DEBUG
54 #define	e1000g_DEBUG
55 #endif
56 
57 /*
58  *  Solaris Multithreaded GLD wiseman PCI Ethernet Driver
59  */
60 
61 #include <sys/types.h>
62 #include <sys/conf.h>
63 #include <sys/debug.h>
64 #include <sys/stropts.h>
65 #include <sys/stream.h>
66 #include <sys/strsun.h>
67 #include <sys/strlog.h>
68 #include <sys/kmem.h>
69 #include <sys/stat.h>
70 #include <sys/kstat.h>
71 #include <sys/modctl.h>
72 #include <sys/errno.h>
73 #include <sys/mac.h>
74 #include <sys/mac_ether.h>
75 #include <sys/vlan.h>
76 #include <sys/ddi.h>
77 #include <sys/sunddi.h>
78 #include <sys/pci.h>
79 #include <sys/sdt.h>
80 #include <sys/ethernet.h>
81 #include <sys/pattr.h>
82 #include <sys/strsubr.h>
83 #include <sys/netlb.h>
84 #include <inet/common.h>
85 #include <inet/ip.h>
86 #include <inet/mi.h>
87 #include <inet/nd.h>
88 #include "e1000_hw.h"
89 
90 /*
91  * PCI Command Register Bit Definitions
92  * Configuration Space Header
93  */
94 #define	CMD_IO_SPACE			0x0001	/* BIT_0 */
95 #define	CMD_MEMORY_SPACE		0x0002	/* BIT_1 */
96 #define	CMD_BUS_MASTER			0x0004	/* BIT_2 */
97 #define	CMD_SPECIAL_CYCLES		0x0008	/* BIT_3 */
98 
99 #define	CMD_VGA_PALLETTE_SNOOP		0x0020	/* BIT_5 */
100 #define	CMD_PARITY_RESPONSE		0x0040	/* BIT_6 */
101 #define	CMD_WAIT_CYCLE_CONTROL		0x0080	/* BIT_7 */
102 #define	CMD_SERR_ENABLE			0x0100	/* BIT_8 */
103 #define	CMD_BACK_TO_BACK		0x0200	/* BIT_9 */
104 
105 #define	WSDRAINTIME		(200)	/* # milliseconds xmit drain */
106 
107 #ifdef __sparc
108 #ifdef _LP64
109 #define	DWORD_SWAP(value)	(value)
110 #else
111 #define	DWORD_SWAP(value)	\
112 	(uint64_t)((((uint64_t)value & 0x00000000FFFFFFFF) << 32) | \
113 	(((uint64_t)value & 0xFFFFFFFF00000000) >> 32))
114 #endif
115 #else
116 #define	DWORD_SWAP(value)	(value)
117 #endif
118 
119 #define	JUMBO_FRAG_LENGTH		4096
120 
121 #define	LAST_RAR_ENTRY			(E1000_RAR_ENTRIES - 1)
122 #define	MAX_NUM_UNICAST_ADDRESSES	E1000_RAR_ENTRIES
123 #define	MAX_NUM_MULTICAST_ADDRESSES	256
124 
125 #define	MAX_TX_DESC_PER_PACKET		16
126 
127 /*
128  * constants used in setting flow control thresholds
129  */
130 #define	E1000_PBA_MASK		0xffff
131 #define	E1000_PBA_SHIFT		10
132 #define	E1000_FC_HIGH_DIFF	0x1638 /* High: 5688 bytes below Rx FIFO size */
133 #define	E1000_FC_LOW_DIFF	0x1640 /* Low: 5696 bytes below Rx FIFO size */
134 #define	E1000_FC_PAUSE_TIME	0x0680 /* 858 usec */
135 
136 #define	MAXNUMTXDESCRIPTOR		4096
137 #define	MAXNUMRXDESCRIPTOR		4096
138 #define	MAXNUMRXFREELIST		4096
139 #define	MAXNUMTXSWPACKET		4096
140 #define	MAXNUMRCVPKTONINTR		4096
141 #define	MAXTXFRAGSLIMIT			1024
142 #define	MAXTXINTERRUPTDELAYVAL		65535
143 #define	MAXINTERRUPTTHROTTLINGVAL	65535
144 #define	MAXRXBCOPYTHRESHOLD		E1000_RX_BUFFER_SIZE_2K
145 #define	MAXTXBCOPYTHRESHOLD		E1000_TX_BUFFER_SIZE_2K
146 #define	MAXTXRECYCLELOWWATER		\
147 	(DEFAULTNUMTXDESCRIPTOR - MAX_TX_DESC_PER_PACKET)
148 #define	MAXTXRECYCLENUM			DEFAULTNUMTXDESCRIPTOR
149 
150 #define	MINNUMTXDESCRIPTOR		80
151 #define	MINNUMRXDESCRIPTOR		80
152 #define	MINNUMRXFREELIST		64
153 #define	MINNUMTXSWPACKET		80
154 #define	MINNUMRCVPKTONINTR		16
155 #define	MINTXFRAGSLIMIT			2
156 #define	MINTXINTERRUPTDELAYVAL		0
157 #define	MININTERRUPTTHROTTLINGVAL	0
158 #define	MINRXBCOPYTHRESHOLD		0
159 #define	MINTXBCOPYTHRESHOLD		MINIMUM_ETHERNET_PACKET_SIZE
160 #define	MINTXRECYCLELOWWATER		MAX_TX_DESC_PER_PACKET
161 #define	MINTXRECYCLENUM			MAX_TX_DESC_PER_PACKET
162 
163 #define	DEFAULTNUMTXDESCRIPTOR		2048
164 #define	DEFAULTNUMRXDESCRIPTOR		2048
165 #define	DEFAULTNUMRXFREELIST		4096
166 #define	DEFAULTNUMTXSWPACKET		2048
167 #define	DEFAULTMAXNUMRCVPKTONINTR	256
168 #define	DEFAULTTXFRAGSLIMIT		4
169 #define	DEFAULTFLOWCONTROLVAL		3
170 #define	DEFAULTTXINTERRUPTDELAYVAL	300
171 #define	DEFAULTINTERRUPTTHROTTLINGVAL	0x225
172 #define	DEFAULTMWIENABLEVAL		1	/* Only PCI 450NX chipset */
173 						/* needs this value to be 0 */
174 #define	DEFAULTMASTERLATENCYTIMERVAL	0	/* BIOS should decide */
175 						/* which is normally 0x040 */
176 #define	DEFAULTRXPCIPRIORITYVAL		1	/* Boolean value */
177 #define	DEFAULTPROFILEJUMBOTRAFFIC	1	/* Profile Jumbo Traffic */
178 #define	DEFAULTTBICOMPATIBILITYENABLE	1	/* Enable SBP workaround */
179 #define	DEFAULTMSIENABLE		1	/* MSI Enable */
180 
181 #define	DEFAULTRXBCOPYTHRESHOLD		0
182 #define	DEFAULTTXBCOPYTHRESHOLD		512
183 #define	DEFAULTTXRECYCLELOWWATER	64
184 #define	DEFAULTTXRECYCLENUM		128
185 
186 /*
187  * The size of the receive/transmite buffers
188  */
189 #define	E1000_RX_BUFFER_SIZE_2K		(2048)
190 #define	E1000_RX_BUFFER_SIZE_4K		(4096)
191 #define	E1000_RX_BUFFER_SIZE_8K		(8192)
192 #define	E1000_RX_BUFFER_SIZE_16K	(16384)
193 
194 #define	E1000_TX_BUFFER_SIZE_2K		(2048)
195 #define	E1000_TX_BUFFER_SIZE_4K		(4096)
196 #define	E1000_TX_BUFFER_SIZE_8K		(8192)
197 #define	E1000_TX_BUFFER_SIZE_16K	(16384)
198 
199 #define	FORCE_BCOPY_EXCEED_FRAGS	0x1
200 #define	FORCE_BCOPY_UNDER_SIZE		0x2
201 
202 #define	E1000G_RX_SW_FREE		0x0
203 #define	E1000G_RX_SW_SENDUP		0x1
204 #define	E1000G_RX_SW_DETACHED		0x2
205 
206 /*
207  * By default it will print only to log
208  */
209 #define	DEFAULTDEBUGLEVEL		0x004
210 #define	DEFAULTDISPLAYONLY		0
211 #define	DEFAULTPRINTONLY		1
212 
213 /*
214  * definitions for smartspeed workaround
215  */
216 #define	  E1000_SMARTSPEED_MAX		30	/* 30 watchdog iterations */
217 						/* or 30 seconds */
218 #define	  E1000_SMARTSPEED_DOWNSHIFT	6	/* 6 watchdog iterations */
219 						/* or 6 seconds */
220 
221 /*
222  * Definitions for module_info.
223  */
224 #define	 WSNAME			"e1000g"	/* module name */
225 
226 /*
227  * Defined for IP header alignment. We also need to preserve space for
228  * VLAN tag (4 bytes)
229  */
230 #define	E1000G_IPALIGNROOM		6
231 #define	E1000G_IPALIGNPRESERVEROOM	64
232 
233 #define	E1000G_IMS_TX_INTR	(E1000_IMS_TXDW | E1000_IMS_TXQE)
234 #define	E1000G_IMC_TX_INTR	(E1000_IMC_TXDW | E1000_IMC_TXQE)
235 #define	E1000G_ICR_TX_INTR	(E1000_ICR_TXDW | E1000_ICR_TXQE)
236 
237 /*
238  * bit flags for 'attach_progress' which is a member variable in struct e1000g
239  */
240 #define	ATTACH_PROGRESS_SOFTINTR	0x0001	/* Soft interrupt added */
241 #define	ATTACH_PROGRESS_REGSMAPPED	0x0002	/* registers mapped */
242 #define	ATTACH_PROGRESS_LOCKS		0x0004	/* locks initialized */
243 #define	ATTACH_PROGRESS_PCICONFIG	0x0008	/* PCI config set up */
244 #define	ATTACH_PROGRESS_KSTATS		0x0010	/* kstats created */
245 #define	ATTACH_PROGRESS_INIT		0x0020	/* reset */
246 #define	ATTACH_PROGRESS_INTRADDED	0x0040	/* interrupts added */
247 #define	ATTACH_PROGRESS_MACREGISTERED	0x0080	/* MAC registered */
248 #define	ATTACH_PROGRESS_PROP		0x0100	/* properties initialized */
249 #define	ATTACH_PROGRESS_NDD		0x0200	/* NDD initialized */
250 #define	ATTACH_PROGRESS_INTRENABLED	0x0400	/* DDI interrupts enabled */
251 #define	ATTACH_PROGRESS_ALLOC		0x0800	/* DMA resources allocated */
252 
253 /*
254  * Speed and Duplex Settings
255  */
256 #define	GDIAG_10_HALF		1
257 #define	GDIAG_10_FULL		2
258 #define	GDIAG_100_HALF		3
259 #define	GDIAG_100_FULL		4
260 #define	GDIAG_1000_FULL		6
261 #define	GDIAG_ANY		7
262 #define	MAX_DEVICES		256
263 
264 /*
265  * Coexist Workaround RP: 07/04/03
266  * 82544 Workaround : Co-existence
267  */
268 #define	MAX_TX_BUF_SIZE		(8 * 1024)
269 
270 #define	ROUNDOFF		0x1000
271 
272 /*
273  * Defines for Jumbo Frame
274  */
275 #define	FRAME_SIZE_UPTO_2K	2048
276 #define	FRAME_SIZE_UPTO_4K	4096
277 #define	FRAME_SIZE_UPTO_8K	8192
278 #define	FRAME_SIZE_UPTO_16K	16384
279 #define	FRAME_SIZE_UPTO_10K	10500
280 
281 /*
282  * Max microsecond for ITR (Interrupt Throttling Register)
283  */
284 #define	E1000_ITR_MAX_MICROSECOND	0x3fff
285 
286 /* Defines for Tx stall check */
287 #define	E1000G_STALL_WATCHDOG_COUNT	8
288 
289 #define	MAX_TX_LINK_DOWN_TIMEOUT	8
290 
291 /* Defines for DVMA */
292 #ifdef __sparc
293 #define	E1000G_DEFAULT_DVMA_PAGE_NUM	2
294 #endif
295 
296 /*
297  * Loopback definitions
298  */
299 #define	E1000G_LB_NONE			0
300 #define	E1000G_LB_EXTERNAL_1000		1
301 #define	E1000G_LB_EXTERNAL_100		2
302 #define	E1000G_LB_EXTERNAL_10		3
303 #define	E1000G_LB_INTERNAL_PHY		4
304 
305 
306 #define	GET_ETHER_TYPE(ptr)	(\
307 	(((uint8_t *)&((struct ether_header *)ptr)->ether_type)[0] << 8) | \
308 	(((uint8_t *)&((struct ether_header *)ptr)->ether_type)[1]))
309 
310 /*
311  * QUEUE_INIT_LIST -- Macro which will init ialize a queue to NULL.
312  */
313 #define	QUEUE_INIT_LIST(_LH)	\
314 	(_LH)->Flink = (_LH)->Blink = (PSINGLE_LIST_LINK)0
315 
316 /*
317  * IS_QUEUE_EMPTY -- Macro which checks to see if a queue is empty.
318  */
319 #define	IS_QUEUE_EMPTY(_LH)	\
320 	((_LH)->Flink == (PSINGLE_LIST_LINK)0)
321 
322 /*
323  * QUEUE_GET_HEAD -- Macro which returns the head of the queue, but does
324  * not remove the head from the queue.
325  */
326 #define	QUEUE_GET_HEAD(_LH)	((PSINGLE_LIST_LINK)((_LH)->Flink))
327 
328 /*
329  * QUEUE_REMOVE_HEAD -- Macro which removes the head of the head of a queue.
330  */
331 #define	QUEUE_REMOVE_HEAD(_LH)	\
332 { \
333 	PSINGLE_LIST_LINK ListElem; \
334 	if (ListElem = (_LH)->Flink) \
335 	{ \
336 		if (!((_LH)->Flink = ListElem->Flink)) \
337 			(_LH)->Blink = (PSINGLE_LIST_LINK) 0; \
338 	} \
339 }
340 
341 /*
342  * QUEUE_POP_HEAD -- Macro which  will pop the head off of a queue (list),
343  *	and return it (this differs from QUEUE_REMOVE_HEAD only in
344  *	the 1st line).
345  */
346 #define	QUEUE_POP_HEAD(_LH)	\
347 	(PSINGLE_LIST_LINK)(_LH)->Flink; \
348 	{ \
349 		PSINGLE_LIST_LINK ListElem; \
350 		ListElem = (_LH)->Flink; \
351 		if (ListElem) \
352 		{ \
353 			(_LH)->Flink = ListElem->Flink; \
354 			if (!(_LH)->Flink) \
355 				(_LH)->Blink = (PSINGLE_LIST_LINK)0; \
356 		} \
357 	}
358 
359 /*
360  * QUEUE_GET_TAIL -- Macro which returns the tail of the queue, but does not
361  *	remove the tail from the queue.
362  */
363 #define	QUEUE_GET_TAIL(_LH)	((PSINGLE_LIST_LINK)((_LH)->Blink))
364 
365 /*
366  * QUEUE_PUSH_TAIL -- Macro which puts an element at the tail (end) of the queue
367  */
368 #define	QUEUE_PUSH_TAIL(_LH, _E)	\
369 	if ((_LH)->Blink) \
370 	{ \
371 		((PSINGLE_LIST_LINK)(_LH)->Blink)->Flink = \
372 			(PSINGLE_LIST_LINK)(_E); \
373 		(_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \
374 	} else { \
375 		(_LH)->Flink = \
376 			(_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \
377 	} \
378 	(_E)->Flink = (PSINGLE_LIST_LINK)0;
379 
380 /*
381  * QUEUE_PUSH_HEAD -- Macro which puts an element at the head of the queue.
382  */
383 #define	QUEUE_PUSH_HEAD(_LH, _E)	\
384 	if (!((_E)->Flink = (_LH)->Flink)) \
385 	{ \
386 		(_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \
387 	} \
388 	(_LH)->Flink = (PSINGLE_LIST_LINK)(_E);
389 
390 /*
391  * QUEUE_GET_NEXT -- Macro which returns the next element linked to the
392  *	current element.
393  */
394 #define	QUEUE_GET_NEXT(_LH, _E)		\
395 	(PSINGLE_LIST_LINK)((((_LH)->Blink) == (_E)) ? \
396 	(0) : ((_E)->Flink))
397 
398 /*
399  * QUEUE_APPEND -- Macro which appends a queue to the tail of another queue
400  */
401 #define	QUEUE_APPEND(_LH1, _LH2)	\
402 	if ((_LH2)->Flink) { \
403 		if ((_LH1)->Flink) { \
404 			((PSINGLE_LIST_LINK)(_LH1)->Blink)->Flink = \
405 				((PSINGLE_LIST_LINK)(_LH2)->Flink); \
406 		} else { \
407 			(_LH1)->Flink = \
408 				((PSINGLE_LIST_LINK)(_LH2)->Flink); \
409 		} \
410 		(_LH1)->Blink = ((PSINGLE_LIST_LINK)(_LH2)->Blink); \
411 	}
412 
413 /*
414  * Property lookups
415  */
416 #define	E1000G_PROP_EXISTS(d, n)	ddi_prop_exists(DDI_DEV_T_ANY, (d), \
417 						DDI_PROP_DONTPASS, (n))
418 #define	E1000G_PROP_GET_INT(d, n)	ddi_prop_get_int(DDI_DEV_T_ANY, (d), \
419 						DDI_PROP_DONTPASS, (n), -1)
420 
421 /*
422  * Shorthand for the NDD parameters
423  */
424 #define	param_adv_autoneg	nd_params[PARAM_ADV_AUTONEG_CAP].ndp_val
425 #define	param_adv_pause		nd_params[PARAM_ADV_PAUSE_CAP].ndp_val
426 #define	param_adv_asym_pause	nd_params[PARAM_ADV_ASYM_PAUSE_CAP].ndp_val
427 #define	param_adv_1000fdx	nd_params[PARAM_ADV_1000FDX_CAP].ndp_val
428 #define	param_adv_1000hdx	nd_params[PARAM_ADV_1000HDX_CAP].ndp_val
429 #define	param_adv_100fdx	nd_params[PARAM_ADV_100FDX_CAP].ndp_val
430 #define	param_adv_100hdx	nd_params[PARAM_ADV_100HDX_CAP].ndp_val
431 #define	param_adv_10fdx		nd_params[PARAM_ADV_10FDX_CAP].ndp_val
432 #define	param_adv_10hdx		nd_params[PARAM_ADV_10HDX_CAP].ndp_val
433 
434 #define	param_force_speed_duplex nd_params[PARAM_FORCE_SPEED_DUPLEX].ndp_val
435 
436 #define	param_link_up		nd_params[PARAM_LINK_STATUS].ndp_val
437 #define	param_link_speed	nd_params[PARAM_LINK_SPEED].ndp_val
438 #define	param_link_duplex	nd_params[PARAM_LINK_DUPLEX].ndp_val
439 #define	param_link_autoneg	nd_params[PARAM_LINK_AUTONEG].ndp_val
440 
441 /*
442  * E1000G-specific ioctls ...
443  */
444 #define	E1000G_IOC		((((((('E' << 4) + '1') << 4) \
445 				+ 'K') << 4) + 'G') << 4)
446 
447 /*
448  * These diagnostic IOCTLS are enabled only in DEBUG drivers
449  */
450 #define	E1000G_IOC_REG_PEEK	(E1000G_IOC | 1)
451 #define	E1000G_IOC_REG_POKE	(E1000G_IOC | 2)
452 #define	E1000G_IOC_CHIP_RESET	(E1000G_IOC | 3)
453 
454 #define	E1000G_PP_SPACE_REG	0	/* PCI memory space	*/
455 #define	E1000G_PP_SPACE_E1000G	1	/* driver's soft state	*/
456 
457 typedef struct {
458 	uint64_t pp_acc_size;	/* It's 1, 2, 4 or 8	*/
459 	uint64_t pp_acc_space;	/* See #defines below	*/
460 	uint64_t pp_acc_offset;	/* See regs definition	*/
461 	uint64_t pp_acc_data;	/* output for peek	*/
462 				/* input for poke	*/
463 } e1000g_peekpoke_t;
464 
465 /*
466  * (Internal) return values from ioctl subroutines
467  */
468 enum ioc_reply {
469 	IOC_INVAL = -1,		/* bad, NAK with EINVAL	*/
470 	IOC_DONE,		/* OK, reply sent	*/
471 	IOC_ACK,		/* OK, just send ACK	*/
472 	IOC_REPLY		/* OK, just send reply	*/
473 };
474 
475 /*
476  * Named Data (ND) Parameter Management Structure
477  */
478 typedef struct {
479 	uint32_t ndp_info;
480 	uint32_t ndp_min;
481 	uint32_t ndp_max;
482 	uint32_t ndp_val;
483 	struct e1000g *ndp_instance;
484 	char *ndp_name;
485 } nd_param_t;
486 
487 /*
488  * NDD parameter indexes, divided into:
489  *
490  *	read-only parameters describing the hardware's capabilities
491  *	read-write parameters controlling the advertised capabilities
492  *	read-only parameters describing the partner's capabilities
493  *	read-write parameters controlling the force speed and duplex
494  *	read-only parameters describing the link state
495  *	read-only parameters describing the driver properties
496  *	read-write parameters controlling the driver properties
497  */
498 enum {
499 	PARAM_AUTONEG_CAP,
500 	PARAM_PAUSE_CAP,
501 	PARAM_ASYM_PAUSE_CAP,
502 	PARAM_1000FDX_CAP,
503 	PARAM_1000HDX_CAP,
504 	PARAM_100T4_CAP,
505 	PARAM_100FDX_CAP,
506 	PARAM_100HDX_CAP,
507 	PARAM_10FDX_CAP,
508 	PARAM_10HDX_CAP,
509 
510 	PARAM_ADV_AUTONEG_CAP,
511 	PARAM_ADV_PAUSE_CAP,
512 	PARAM_ADV_ASYM_PAUSE_CAP,
513 	PARAM_ADV_1000FDX_CAP,
514 	PARAM_ADV_1000HDX_CAP,
515 	PARAM_ADV_100T4_CAP,
516 	PARAM_ADV_100FDX_CAP,
517 	PARAM_ADV_100HDX_CAP,
518 	PARAM_ADV_10FDX_CAP,
519 	PARAM_ADV_10HDX_CAP,
520 
521 	PARAM_LP_AUTONEG_CAP,
522 	PARAM_LP_PAUSE_CAP,
523 	PARAM_LP_ASYM_PAUSE_CAP,
524 	PARAM_LP_1000FDX_CAP,
525 	PARAM_LP_1000HDX_CAP,
526 	PARAM_LP_100T4_CAP,
527 	PARAM_LP_100FDX_CAP,
528 	PARAM_LP_100HDX_CAP,
529 	PARAM_LP_10FDX_CAP,
530 	PARAM_LP_10HDX_CAP,
531 
532 	PARAM_FORCE_SPEED_DUPLEX,
533 
534 	PARAM_LINK_STATUS,
535 	PARAM_LINK_SPEED,
536 	PARAM_LINK_DUPLEX,
537 	PARAM_LINK_AUTONEG,
538 
539 	PARAM_MAX_FRAME_SIZE,
540 	PARAM_LOOP_MODE,
541 	PARAM_INTR_TYPE,
542 
543 	PARAM_TX_BCOPY_THRESHOLD,
544 	PARAM_TX_FRAGS_LIMIT,
545 	PARAM_TX_RECYCLE_LOW_WATER,
546 	PARAM_TX_RECYCLE_NUM,
547 	PARAM_TX_INTR_ENABLE,
548 	PARAM_TX_INTR_DELAY,
549 	PARAM_RX_BCOPY_THRESHOLD,
550 	PARAM_RX_PKT_ON_INTR,
551 	PARAM_RX_RDTR,
552 	PARAM_RX_RADV,
553 
554 	PARAM_COUNT
555 };
556 
557 static struct ether_addr etherbroadcastaddr = {
558 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff
559 };
560 
561 /*
562  * DMA access attributes <Little Endian Card>
563  */
564 static ddi_device_acc_attr_t accattr = {
565 	DDI_DEVICE_ATTR_V0,
566 	DDI_STRUCTURE_LE_ACC,
567 	DDI_STRICTORDER_ACC,
568 };
569 
570 /*
571  * DMA access attributes for receive buffer <Big Endian> for Sparc
572  */
573 #ifdef __sparc
574 static ddi_device_acc_attr_t accattr2 = {
575 	DDI_DEVICE_ATTR_V0,
576 	DDI_STRUCTURE_BE_ACC,
577 	DDI_STRICTORDER_ACC,
578 };
579 #else
580 static ddi_device_acc_attr_t accattr2 = {
581 	DDI_DEVICE_ATTR_V0,
582 	DDI_STRUCTURE_LE_ACC,
583 	DDI_STRICTORDER_ACC,
584 };
585 #endif
586 
587 /*
588  * A structure that points to the next entry in the queue.
589  */
590 typedef struct _SINGLE_LIST_LINK {
591 	struct _SINGLE_LIST_LINK *Flink;
592 } SINGLE_LIST_LINK, *PSINGLE_LIST_LINK;
593 
594 /*
595  * A "ListHead" structure that points to the head and tail of a queue
596  */
597 typedef struct _LIST_DESCRIBER {
598 	struct _SINGLE_LIST_LINK *volatile Flink;
599 	struct _SINGLE_LIST_LINK *volatile Blink;
600 } LIST_DESCRIBER, *PLIST_DESCRIBER;
601 
602 /*
603  * Address-Length pair structure that stores descriptor info
604  */
605 typedef struct _ADDRESS_LENGTH_PAIR {
606 	uint64_t Address;
607 	uint32_t Length;
608 } ADDRESS_LENGTH_PAIR, *PADDRESS_LENGTH_PAIR;
609 
610 typedef struct _DESCRIPTOR_PAIR {
611 	ADDRESS_LENGTH_PAIR Descriptor[4];
612 	uint32_t Elements;
613 } DESC_ARRAY, *PDESC_ARRAY;
614 
615 typedef enum {
616 	USE_NONE,
617 	USE_BCOPY,
618 	USE_DVMA,
619 	USE_DMA
620 } dma_type_t;
621 
622 typedef struct _dma_buffer {
623 	caddr_t address;
624 	uint64_t dma_address;
625 	ddi_acc_handle_t acc_handle;
626 	ddi_dma_handle_t dma_handle;
627 	size_t size;
628 	size_t len;
629 } dma_buffer_t, *pdma_buffer_t;
630 
631 /*
632  * Transmit Control Block (TCB), Ndis equiv of SWPacket This
633  * structure stores the additional information that is
634  * associated with every packet to be transmitted. It stores the
635  * message block pointer and the TBD addresses associated with
636  * the m_blk and also the link to the next tcb in the chain
637  */
638 typedef struct _TX_SW_PACKET_ {
639 	/* Link to the next TX_SW_PACKET in the list */
640 	SINGLE_LIST_LINK Link;
641 	mblk_t *mp;
642 	UINT num_desc;
643 	UINT num_mblk_frag;
644 	dma_type_t dma_type;
645 	dma_type_t data_transfer_type;
646 	ddi_dma_handle_t tx_dma_handle;
647 	dma_buffer_t tx_buf[1];
648 	ADDRESS_LENGTH_PAIR desc[MAX_TX_DESC_PER_PACKET + 1];
649 } TX_SW_PACKET, *PTX_SW_PACKET;
650 
651 /*
652  * This structure is similar to the RX_SW_PACKET structure used
653  * for Ndis. This structure stores information about the 2k
654  * aligned receive buffer into which the FX1000 DMA's frames.
655  * This structure is maintained as a linked list of many
656  * receiver buffer pointers.
657  */
658 typedef struct _RX_SW_PACKET {
659 	/* Link to the next RX_SW_PACKET in the list */
660 	SINGLE_LIST_LINK Link;
661 	struct _RX_SW_PACKET *next;
662 	uint16_t flag;
663 	mblk_t *mp;
664 	caddr_t rx_ring;
665 	dma_type_t dma_type;
666 	frtn_t free_rtn;
667 	dma_buffer_t rx_buf[1];
668 } RX_SW_PACKET, *PRX_SW_PACKET;
669 
670 typedef struct _e1000g_msg_chain {
671 	mblk_t *head;
672 	mblk_t *tail;
673 	kmutex_t lock;
674 } e1000g_msg_chain_t;
675 
676 typedef struct _cksum_data {
677 	uint32_t ether_header_size;
678 	uint32_t cksum_flags;
679 	uint32_t cksum_start;
680 	uint32_t cksum_stuff;
681 } cksum_data_t;
682 
683 /*
684  * MultiCast Command Block (MULTICAST_CB) The multicast
685  * structure contains an array of multicast addresses and
686  * also a count of the total number of addresses.
687  */
688 typedef struct _multicast_cb_t {
689 	ushort_t mc_count;	/* Number of multicast addresses */
690 	uchar_t MulticastBuffer[(ETH_LENGTH_OF_ADDRESS *
691 		MAX_NUM_MULTICAST_ADDRESSES)];
692 } mltcst_cb_t, *pmltcst_cb_t;
693 
694 typedef union _e1000g_ether_addr {
695 	struct {
696 		uint32_t high;
697 		uint32_t low;
698 	} reg;
699 	struct {
700 		uint8_t set;
701 		uint8_t redundant;
702 		uint8_t addr[NODE_ADDRESS_SIZE];
703 	} mac;
704 } e1000g_ether_addr_t;
705 
706 typedef struct _e1000gstat {
707 
708 	kstat_named_t link_speed;	/* Link Speed */
709 	kstat_named_t rx_none;		/* Rx No Incoming Data */
710 	kstat_named_t rx_error;		/* Rx Error in Packet */
711 	kstat_named_t rx_exceed_pkt;	/* Rx Exceed Max Pkt Count */
712 	kstat_named_t rx_multi_desc;	/* Rx Multi Spanned Pkt */
713 	kstat_named_t rx_no_freepkt;	/* Rx No Free Pkt */
714 	kstat_named_t rx_avail_freepkt;	/* Rx Freelist Avail Buffers */
715 	kstat_named_t rx_esballoc_fail;	/* Rx Desballoc Failure */
716 	kstat_named_t rx_allocb_fail;	/* Rx Allocb Failure */
717 	kstat_named_t rx_seq_intr;	/* Rx Sequencing Errors Intr */
718 	kstat_named_t tx_lack_desc;	/* Tx Lack of Desc */
719 	kstat_named_t tx_no_desc;	/* Tx No Desc */
720 	kstat_named_t tx_no_swpkt;	/* Tx No Pkt Buffer */
721 	kstat_named_t tx_send_fail;	/* Tx SendPkt Failure */
722 	kstat_named_t tx_multi_cookie;	/* Tx Pkt Span Multi Cookies */
723 	kstat_named_t tx_over_size;	/* Tx Pkt Too Long */
724 	kstat_named_t tx_under_size;	/* Tx Allocb Failure */
725 	kstat_named_t tx_reschedule;	/* Tx Reschedule */
726 	kstat_named_t tx_empty_frags;	/* Tx Empty Frags */
727 	kstat_named_t tx_exceed_frags;	/* Tx Exceed Max Frags */
728 	kstat_named_t tx_recycle;	/* Tx Recycle */
729 	kstat_named_t tx_recycle_retry;	/* Tx Recycle Retry */
730 	kstat_named_t tx_recycle_intr;	/* Tx Recycle in Intr */
731 	kstat_named_t tx_recycle_none;	/* Tx No Desc Recycled */
732 	kstat_named_t tx_copy;		/* Tx Send Copy */
733 	kstat_named_t tx_bind;		/* Tx Send Bind */
734 	kstat_named_t tx_multi_copy;	/* Tx Copy Multi Fragments */
735 	kstat_named_t StallWatchdog;	/* Tx Stall Watchdog */
736 	kstat_named_t reset_count;	/* Reset Count */
737 	kstat_named_t intr_type;	/* Interrupt Type */
738 	kstat_named_t Crcerrs;	/* CRC Error Count */
739 	kstat_named_t Symerrs;	/* Symbol Error Count */
740 	kstat_named_t Mpc;	/* Missed Packet Count */
741 	kstat_named_t Scc;	/* Single Collision Count */
742 	kstat_named_t Ecol;	/* Excessive Collision Count */
743 	kstat_named_t Mcc;	/* Multiple Collision Count */
744 	kstat_named_t Latecol;	/* Late Collision Count */
745 	kstat_named_t Colc;	/* Collision Count */
746 	kstat_named_t Dc;	/* Defer Count */
747 	kstat_named_t Sec;	/* Sequence Error Count */
748 	kstat_named_t Rlec;	/* Receive Length Error Count */
749 	kstat_named_t Xonrxc;	/* XON Received Count */
750 	kstat_named_t Xontxc;	/* XON Xmitted Count */
751 	kstat_named_t Xoffrxc;	/* XOFF Received Count */
752 	kstat_named_t Xofftxc;	/* Xoff Xmitted Count */
753 	kstat_named_t Fcruc;	/* Unknown Flow Conrol Packet Rcvd Count */
754 	kstat_named_t Prc64;	/* Packets Received - 64b */
755 	kstat_named_t Prc127;	/* Packets Received - 65-127b */
756 	kstat_named_t Prc255;	/* Packets Received - 127-255b */
757 	kstat_named_t Prc511;	/* Packets Received - 256-511b */
758 	kstat_named_t Prc1023;	/* Packets Received - 511-1023b */
759 	kstat_named_t Prc1522;	/* Packets Received - 1024-1522b */
760 	kstat_named_t Gprc;	/* Good Packets Received Count */
761 	kstat_named_t Bprc;	/* Broadcasts Pkts Received Count */
762 	kstat_named_t Mprc;	/* Multicast Pkts Received Count */
763 	kstat_named_t Gptc;	/* Good Packets Xmitted Count */
764 	kstat_named_t Gorl;	/* Good Octets Recvd Lo Count */
765 	kstat_named_t Gorh;	/* Good Octets Recvd Hi Count */
766 	kstat_named_t Gotl;	/* Good Octets Xmitd Lo Count */
767 	kstat_named_t Goth;	/* Good Octets Xmitd Hi Count */
768 	kstat_named_t Rnbc;	/* Receive No Buffers Count */
769 	kstat_named_t Ruc;	/* Receive Undersize Count */
770 	kstat_named_t Rfc;	/* Receive Frag Count */
771 	kstat_named_t Roc;	/* Receive Oversize Count */
772 	kstat_named_t Rjc;	/* Receive Jabber Count */
773 	kstat_named_t Torl;	/* Total Octets Recvd Lo Count */
774 	kstat_named_t Torh;	/* Total Octets Recvd Hi Count */
775 	kstat_named_t Totl;	/* Total Octets Xmted Lo Count */
776 	kstat_named_t Toth;	/* Total Octets Xmted Hi Count */
777 	kstat_named_t Tpr;	/* Total Packets Received */
778 	kstat_named_t Tpt;	/* Total Packets Xmitted */
779 	kstat_named_t Ptc64;	/* Packets Xmitted (64b) */
780 	kstat_named_t Ptc127;	/* Packets Xmitted (64-127b) */
781 	kstat_named_t Ptc255;	/* Packets Xmitted (128-255b) */
782 	kstat_named_t Ptc511;	/* Packets Xmitted (255-511b) */
783 	kstat_named_t Ptc1023;	/* Packets Xmitted (512-1023b) */
784 	kstat_named_t Ptc1522;	/* Packets Xmitted (1024-1522b */
785 	kstat_named_t Mptc;	/* Multicast Packets Xmited Count */
786 	kstat_named_t Bptc;	/* Broadcast Packets Xmited Count */
787 	/*
788 	 * New Livengood Stat Counters
789 	 */
790 	kstat_named_t Algnerrc;	/* Alignment Error count */
791 	kstat_named_t Tuc;	/* Transmit Underrun count */
792 	kstat_named_t Rxerrc;	/* Rx Error Count */
793 	kstat_named_t Tncrs;	/* Transmit with no CRS */
794 	kstat_named_t Cexterr;	/* Carrier Extension Error count */
795 	kstat_named_t Rutec;	/* Receive DMA too Early count */
796 	kstat_named_t Tsctc;	/* TCP seg contexts xmit count */
797 	kstat_named_t Tsctfc;	/* TCP seg contexts xmit fail count */
798 	/*
799 	 * Jumbo Frame Counters
800 	 */
801 	kstat_named_t JumboTx_4K;	/* 4k Jumbo Frames Transmitted */
802 	kstat_named_t JumboRx_4K;	/* 4k Jumbo Frames Received */
803 	kstat_named_t JumboTx_8K;	/* 8k Jumbo Frames Transmitted */
804 	kstat_named_t JumboRx_8K;	/* 8k Jumbo Frames Received */
805 	kstat_named_t JumboTx_16K;	/* 16k Jumbo Frames Transmitted */
806 	kstat_named_t JumboRx_16K;	/* 16k Jumbo Frames Received */
807 
808 } e1000gstat, *e1000gstatp;
809 
810 typedef struct _e1000g_tx_ring {
811 	kmutex_t tx_lock;
812 	kmutex_t freelist_lock;
813 	kmutex_t usedlist_lock;
814 	/*
815 	 * Descriptor queue definitions
816 	 */
817 	ddi_dma_handle_t tbd_dma_handle;
818 	ddi_acc_handle_t tbd_acc_handle;
819 	struct e1000_tx_desc *tbd_area;
820 	uint64_t tbd_dma_addr;
821 	struct e1000_tx_desc *tbd_first;
822 	struct e1000_tx_desc *tbd_last;
823 	struct e1000_tx_desc *tbd_oldest;
824 	struct e1000_tx_desc *tbd_next;
825 	/*
826 	 * Software packet structures definitions
827 	 */
828 	PTX_SW_PACKET packet_area;
829 	LIST_DESCRIBER used_list;
830 	LIST_DESCRIBER free_list;
831 	/*
832 	 * TCP/UDP checksum offload
833 	 */
834 	cksum_data_t cksum_data;
835 	/*
836 	 * Timer definitions for 82547
837 	 */
838 	timeout_id_t timer_id_82547;
839 	boolean_t timer_enable_82547;
840 	/*
841 	 * Pointer to the adapter
842 	 */
843 	struct e1000g *adapter;
844 } e1000g_tx_ring_t, *pe1000g_tx_ring_t;
845 
846 typedef struct _e1000g_rx_ring {
847 	kmutex_t rx_lock;
848 	kmutex_t freelist_lock;
849 	/*
850 	 * Descriptor queue definitions
851 	 */
852 	ddi_dma_handle_t rbd_dma_handle;
853 	ddi_acc_handle_t rbd_acc_handle;
854 	struct e1000_rx_desc *rbd_area;
855 	uint64_t rbd_dma_addr;
856 	struct e1000_rx_desc *rbd_first;
857 	struct e1000_rx_desc *rbd_last;
858 	struct e1000_rx_desc *rbd_next;
859 	/*
860 	 * Software packet structures definitions
861 	 */
862 	PRX_SW_PACKET packet_area;
863 	LIST_DESCRIBER recv_list;
864 	LIST_DESCRIBER free_list;
865 	/*
866 	 * Pointer to the adapter
867 	 */
868 	struct e1000g *adapter;
869 } e1000g_rx_ring_t, *pe1000g_rx_ring_t;
870 
871 typedef struct e1000g {
872 	mac_handle_t mh;
873 	dev_info_t *dip;
874 	ddi_acc_handle_t handle;
875 	ddi_acc_handle_t E1000_handle;		/* Ws-PCI handle to regs */
876 	int AdapterInstance;
877 	struct e1000_hw Shared;
878 	struct e1000g_osdep osdep;
879 
880 	link_state_t link_state;
881 	UINT link_speed;
882 	UINT link_duplex;
883 	UINT NumRxDescriptors;
884 	UINT NumRxFreeList;
885 	UINT NumTxDescriptors;
886 	UINT NumTxSwPacket;
887 	UINT MaxNumReceivePackets;
888 	UINT bar64;
889 	USHORT TxInterruptDelay;
890 	USHORT MWIEnable;
891 	UINT MasterLatencyTimer;
892 #ifdef e1000g_DEBUG
893 	UINT DebugLevel;
894 	UINT DisplayOnly;
895 	UINT PrintOnly;
896 #endif
897 	UINT smartspeed;	/* smartspeed w/a counter */
898 	uint32_t init_count;
899 	size_t TxBufferSize;
900 	size_t RxBufferSize;
901 	boolean_t intr_adaptive;
902 	uint32_t intr_throttling_rate;
903 	timeout_id_t WatchDogTimer_id;
904 	timeout_id_t link_tid;
905 	boolean_t link_complete;
906 
907 	/*
908 	 * The e1000g_timeout_lock must be held when updateing the
909 	 * timeout fields in struct e1000g, that is,
910 	 * WatchDogTimer_id, timeout_enabled, timeout_started.
911 	 */
912 	kmutex_t e1000g_timeout_lock;
913 	/*
914 	 * The e1000g_linklock protects the link fields in struct e1000g,
915 	 * such as link_state, link_speed, link_duplex, link_complete, and
916 	 * link_tid.
917 	 */
918 	kmutex_t e1000g_linklock;
919 	kmutex_t TbiCntrMutex;
920 	/*
921 	 * The chip_lock assures that the Rx/Tx process must be
922 	 * stopped while other functions change the hardware
923 	 * configuration of e1000g card, such as e1000g_reset(),
924 	 * e1000g_reset_hw() etc are executed.
925 	 */
926 	krwlock_t chip_lock;
927 
928 	e1000g_rx_ring_t rx_ring[1];
929 	e1000g_tx_ring_t tx_ring[1];
930 
931 	uint32_t rx_bcopy_thresh;
932 	uint32_t tx_bcopy_thresh;
933 	uint32_t tx_recycle_low_water;
934 	uint32_t tx_recycle_num;
935 	uint32_t tx_frags_limit;
936 	uint32_t tx_link_down_timeout;
937 
938 	boolean_t tx_intr_enable;
939 	ddi_softint_handle_t tx_softint_handle;
940 	int tx_softint_pri;
941 	/*
942 	 * Message chain that needs to be freed
943 	 */
944 	e1000g_msg_chain_t tx_msg_chain[1];
945 
946 	mblk_t *rx_mblk;
947 	mblk_t *rx_mblk_tail;
948 	USHORT rx_packet_len;
949 
950 	kstat_t *e1000g_ksp;
951 
952 	uint32_t rx_none;
953 	uint32_t rx_error;
954 	uint32_t rx_exceed_pkt;
955 	uint32_t rx_multi_desc;
956 	uint32_t rx_no_freepkt;
957 	uint32_t rx_esballoc_fail;
958 	uint32_t rx_avail_freepkt;
959 	uint32_t rx_allocb_fail;
960 	uint32_t rx_seq_intr;
961 	uint32_t tx_lack_desc;
962 	uint32_t tx_no_desc;
963 	uint32_t tx_no_swpkt;
964 	uint32_t tx_send_fail;
965 	uint32_t tx_multi_cookie;
966 	uint32_t tx_over_size;
967 	uint32_t tx_under_size;
968 	uint32_t tx_reschedule;
969 	uint32_t tx_empty_frags;
970 	uint32_t tx_exceed_frags;
971 	uint32_t tx_recycle;
972 	uint32_t tx_recycle_retry;
973 	uint32_t tx_recycle_intr;
974 	uint32_t tx_recycle_none;
975 	uint32_t tx_copy;
976 	uint32_t tx_bind;
977 	uint32_t tx_multi_copy;
978 
979 	uint32_t JumboTx_4K;
980 	uint32_t JumboRx_4K;
981 	uint32_t JumboTx_8K;
982 	uint32_t JumboRx_8K;
983 	uint32_t JumboTx_16K;
984 	uint32_t JumboRx_16K;
985 
986 	uint32_t StallWatchdog;
987 	uint32_t tx_recycle_fail;
988 	uint32_t reset_count;
989 
990 	uint32_t unicst_avail;
991 	uint32_t unicst_total;
992 	e1000g_ether_addr_t unicst_addr[MAX_NUM_UNICAST_ADDRESSES];
993 
994 	uint32_t mcast_count;
995 	struct ether_addr mcast_table[MAX_NUM_MULTICAST_ADDRESSES];
996 
997 	uint32_t loopback_mode;
998 
999 	UINT ProfileJumboTraffic;
1000 	UINT RcvBufferAlignment;
1001 
1002 	boolean_t timeout_enabled;
1003 	boolean_t timeout_started;
1004 
1005 	boolean_t e1000g_promisc;
1006 	boolean_t started;
1007 	mac_resource_handle_t mrh;
1008 
1009 	uint32_t attach_progress;	/* attach tracking */
1010 	/*
1011 	 * reschedule when tx resource is available
1012 	 */
1013 	boolean_t resched_needed;
1014 
1015 #ifdef __sparc
1016 	ulong_t sys_page_sz;
1017 	uint_t dvma_page_num;
1018 #endif
1019 
1020 	boolean_t msi_enabled;
1021 	int intr_type;
1022 	int intr_cnt;
1023 	int intr_cap;
1024 	size_t intr_size;
1025 	uint_t intr_pri;
1026 	ddi_intr_handle_t *htable;
1027 
1028 	/*
1029 	 * NDD parameters
1030 	 */
1031 	caddr_t nd_data;
1032 	nd_param_t nd_params[PARAM_COUNT];
1033 
1034 } e1000g, *Pe1000g, ADAPTER_STRUCT, *PADAPTER_STRUCT;
1035 
1036 
1037 static ddi_dma_attr_t tx_dma_attr = {
1038 	DMA_ATTR_V0,		/* version of this structure */
1039 	0,			/* lowest usable address */
1040 	0xffffffffffffffffULL,	/* highest usable address */
1041 	0x7fffffff,		/* maximum DMAable byte count */
1042 	1,			/* alignment in bytes */
1043 	0x7ff,			/* burst sizes (any?) */
1044 	1,			/* minimum transfer */
1045 	0xffffffffU,		/* maximum transfer */
1046 	0xffffffffffffffffULL,	/* maximum segment length */
1047 	16,			/* maximum number of segments */
1048 	1,			/* granularity */
1049 	0,			/* flags (reserved) */
1050 };
1051 
1052 static ddi_dma_attr_t buf_dma_attr = {
1053 	DMA_ATTR_V0,		/* version of this structure */
1054 	0,			/* lowest usable address */
1055 	0xffffffffffffffffULL,	/* highest usable address */
1056 	0x7fffffff,		/* maximum DMAable byte count */
1057 	1,			/* alignment in bytes */
1058 	0x7ff,			/* burst sizes (any?) */
1059 	1,			/* minimum transfer */
1060 	0xffffffffU,		/* maximum transfer */
1061 	0xffffffffffffffffULL,	/* maximum segment length */
1062 	1,			/* maximum number of segments */
1063 	1,			/* granularity */
1064 	0,			/* flags (reserved) */
1065 };
1066 
1067 static ddi_dma_attr_t tbd_dma_attr = {
1068 	DMA_ATTR_V0,		/* version of this structure */
1069 	0,			/* lowest usable address */
1070 	0xffffffffffffffffULL,	/* highest usable address */
1071 	0x7fffffff,		/* maximum DMAable byte count */
1072 	E1000_MDALIGN,		/* alignment in bytes 4K! */
1073 	0x7ff,			/* burst sizes (any?) */
1074 	1,			/* minimum transfer */
1075 	0xffffffffU,		/* maximum transfer */
1076 	0xffffffffffffffffULL,	/* maximum segment length */
1077 	1,			/* maximum number of segments */
1078 	1,			/* granularity */
1079 	0,			/* flags (reserved) */
1080 };
1081 
1082 /*
1083  * Function prototypes
1084  */
1085 int e1000g_alloc_dma_resources(struct e1000g *Adapter);
1086 void e1000g_release_dma_resources(struct e1000g *Adapter);
1087 void e1000g_free_rx_sw_packet(PRX_SW_PACKET packet);
1088 void SetupTransmitStructures(struct e1000g *Adapter);
1089 void SetupReceiveStructures(struct e1000g *Adapter);
1090 void SetupMulticastTable(struct e1000g *Adapter);
1091 boolean_t e1000g_reset(struct e1000g *Adapter);
1092 
1093 int e1000g_recycle(e1000g_tx_ring_t *tx_ring);
1094 void FreeTxSwPacket(PTX_SW_PACKET packet);
1095 uint_t e1000g_tx_freemsg(caddr_t arg1, caddr_t arg2);
1096 mblk_t *e1000g_m_tx(void *arg, mblk_t *mp);
1097 mblk_t *e1000g_receive(struct e1000g *Adapter);
1098 void e1000g_rxfree_func(PRX_SW_PACKET packet);
1099 
1100 int e1000g_m_stat(void *arg, uint_t stat, uint64_t *val);
1101 int InitStatsCounters(struct e1000g *Adapter);
1102 void AdjustTbiAcceptedStats(struct e1000g *Adapter, UINT32 FrameLength,
1103     PUCHAR MacAddress);
1104 enum ioc_reply e1000g_nd_ioctl(struct e1000g *Adapter,
1105     queue_t *wq, mblk_t *mp, struct iocblk *iocp);
1106 void e1000g_nd_cleanup(struct e1000g *Adapter);
1107 int e1000g_nd_init(struct e1000g *Adapter);
1108 
1109 void e1000g_DisableInterrupt(struct e1000g *Adapter);
1110 void e1000g_EnableInterrupt(struct e1000g *Adapter);
1111 void e1000g_DisableAllInterrupts(struct e1000g *Adapter);
1112 void e1000g_DisableTxInterrupt(struct e1000g *Adapter);
1113 void e1000g_EnableTxInterrupt(struct e1000g *Adapter);
1114 void phy_spd_state(struct e1000_hw *hw, boolean_t enable);
1115 void e1000_enable_pciex_master(struct e1000_hw *hw);
1116 
1117 /*
1118  * Global variables
1119  */
1120 extern boolean_t force_detach_enabled;
1121 extern uint32_t e1000g_mblks_pending;
1122 extern krwlock_t e1000g_rx_detach_lock;
1123 
1124 
1125 #ifdef __cplusplus
1126 }
1127 #endif
1128 
1129 #endif	/* _E1000G_SW_H */
1130