xref: /titanic_52/usr/src/uts/common/io/e1000g/e1000g_stat.c (revision 573374d31f6a3da992a4aa77ca650864b49d7a76)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  * **********************************************************************
30  *									*
31  * Module Name:  e1000g_stat.c						*
32  *									*
33  * Abstract:     Functions for displaying statistics			*
34  *									*
35  * **********************************************************************
36  */
37 #include "e1000g_sw.h"
38 #include "e1000g_debug.h"
39 
40 static int UpdateStatsCounters(kstat_t *ksp, int rw);
41 
42 /*
43  * **********************************************************************
44  *									*
45  * Name:	    AdjustTbiAcceptedStats				*
46  *									*
47  * Description:     Adjusts statistic counters when a frame is accepted	*
48  *		  under the TBI workaround. This function has been	*
49  *		  adapted for Solaris from shared code.			*
50  *									*
51  * Author:	  Bill Campbell						*
52  *									*
53  * Born on Date:    4/12/2001						*
54  *									*
55  * Arguments:								*
56  *      Adapter     - Ptr to this card's adapter data structure.	*
57  *      FrameLength - Length as reported from Hardware			*
58  *      MacAddress  - Pointer to MAC address field in frame.		*
59  *									*
60  * Returns:								*
61  *      VOID								*
62  *									*
63  * **********************************************************************
64  */
65 void
66 AdjustTbiAcceptedStats(struct e1000g *Adapter,
67     UINT32 FrameLength, PUCHAR MacAddress)
68 {
69 	UINT32 CarryBit;
70 	e1000gstat *e1000g_ksp;
71 
72 	e1000g_ksp = (e1000gstat *)Adapter->e1000g_ksp->ks_data;
73 
74 	/*
75 	 * First adjust the frame length.
76 	 */
77 	FrameLength--;
78 	/*
79 	 * We need to adjust the statistics counters, since the hardware
80 	 * counters overcount this packet as a CRC error and undercount
81 	 * the packet as a good packet
82 	 */
83 
84 	/*
85 	 * This packet should not be counted as a CRC error.
86 	 */
87 	e1000g_ksp->Crcerrs.value.ul--;
88 	/*
89 	 * This packet does count as a Good Packet Received.
90 	 */
91 	e1000g_ksp->Gprc.value.ul++;
92 
93 	/*
94 	 * Adjust the Good Octets received counters
95 	 */
96 	CarryBit = 0x80000000 & e1000g_ksp->Gorl.value.ul;
97 	e1000g_ksp->Gorl.value.ul += FrameLength;
98 	/*
99 	 * If the high bit of Gorcl (the low 32 bits of the Good Octets
100 	 * Received Count) was one before the addition,
101 	 * AND it is zero after, then we lost the carry out,
102 	 * need to add one to Gorch (Good Octets Received Count High).
103 	 * This could be simplified if all environments supported
104 	 * 64-bit integers.
105 	 */
106 	if (CarryBit && ((e1000g_ksp->Gorl.value.ul & 0x80000000) == 0)) {
107 		e1000g_ksp->Gorh.value.ul++;
108 	}
109 	/*
110 	 * Is this a broadcast or multicast?  Check broadcast first,
111 	 * since the test for a multicast frame will test positive on
112 	 * a broadcast frame.
113 	 */
114 	if ((MacAddress[0] == (UCHAR) 0xff) &&
115 	    (MacAddress[1] == (UCHAR) 0xff)) {
116 		/*
117 		 * Broadcast packet
118 		 */
119 		e1000g_ksp->Bprc.value.ul++;
120 	} else if (*MacAddress & 0x01) {
121 		/*
122 		 * Multicast packet
123 		 */
124 		e1000g_ksp->Mprc.value.ul++;
125 	}
126 	if (FrameLength == Adapter->Shared.max_frame_size) {
127 		/*
128 		 * In this case, the hardware has overcounted the number of
129 		 * oversize frames.
130 		 */
131 		if (e1000g_ksp->Roc.value.ul > 0)
132 			e1000g_ksp->Roc.value.ul--;
133 	}
134 
135 	/*
136 	 * Adjust the bin counters when the extra byte put the frame in the
137 	 * wrong bin. Remember that the FrameLength was adjusted above.
138 	 */
139 	if (FrameLength == 64) {
140 		e1000g_ksp->Prc64.value.ul++;
141 		e1000g_ksp->Prc127.value.ul--;
142 	} else if (FrameLength == 127) {
143 		e1000g_ksp->Prc127.value.ul++;
144 		e1000g_ksp->Prc255.value.ul--;
145 	} else if (FrameLength == 255) {
146 		e1000g_ksp->Prc255.value.ul++;
147 		e1000g_ksp->Prc511.value.ul--;
148 	} else if (FrameLength == 511) {
149 		e1000g_ksp->Prc511.value.ul++;
150 		e1000g_ksp->Prc1023.value.ul--;
151 	} else if (FrameLength == 1023) {
152 		e1000g_ksp->Prc1023.value.ul++;
153 		e1000g_ksp->Prc1522.value.ul--;
154 	} else if (FrameLength == 1522) {
155 		e1000g_ksp->Prc1522.value.ul++;
156 	}
157 }
158 
159 
160 /*
161  * **********************************************************************
162  * Name:	UpdateStatsCounters					*
163  *									*
164  * Description: This routine will dump and reset the 1000's internal	*
165  *	      Statistics counters.  The current stats dump values will	*
166  *	      be sent to the kernel status area.			*
167  *									*
168  * Author:      Phil Cayton						*
169  *									*
170  * Born on Date:    7/13/98						*
171  *									*
172  * Arguments:								*
173  *     *ksp - A kernel stat pointer					*
174  *     rw   - Read/Write flag						*
175  *									*
176  * Returns:								*
177  *      (EACCES) If an attempt is made to write stats to the hw		*
178  *      (0) On successful read of statistics to kernel stats.		*
179  *									*
180  * File: e1000g_stat.c							*
181  *									*
182  * Modification log:							*
183  * Date      Who  Description						*
184  * --------  ---  ------------------------------------------------------*
185  * Sept 10,99 Vinay New Counters for Livengood have been added.		*
186  * **********************************************************************
187  */
188 static int
189 UpdateStatsCounters(IN kstat_t *ksp, int rw)
190 {
191 	uint16_t LineSpeed, Duplex;
192 	struct e1000g *Adapter;
193 	e1000gstat *e1000g_ksp;
194 	uint64_t val;
195 	uint32_t low_val, high_val;
196 
197 	if (rw == KSTAT_WRITE)
198 		return (EACCES);
199 
200 	Adapter = (struct e1000g *)ksp->ks_private;
201 	ASSERT(Adapter != NULL);
202 	e1000g_ksp = (e1000gstat *)ksp->ks_data;
203 	ASSERT(e1000g_ksp != NULL);
204 
205 	e1000g_ksp->link_speed.value.ul = Adapter->link_speed;
206 	e1000g_ksp->rx_none.value.ul = Adapter->rx_none;
207 	e1000g_ksp->rx_error.value.ul = Adapter->rx_error;
208 	e1000g_ksp->rx_no_freepkt.value.ul = Adapter->rx_no_freepkt;
209 	e1000g_ksp->rx_esballoc_fail.value.ul = Adapter->rx_esballoc_fail;
210 	e1000g_ksp->rx_exceed_pkt.value.ul = Adapter->rx_exceed_pkt;
211 	e1000g_ksp->rx_multi_desc.value.ul = Adapter->rx_multi_desc;
212 	e1000g_ksp->rx_allocb_fail.value.ul = Adapter->rx_allocb_fail;
213 	e1000g_ksp->rx_avail_freepkt.value.ul = Adapter->rx_avail_freepkt;
214 	e1000g_ksp->rx_seq_intr.value.ul = Adapter->rx_seq_intr;
215 	e1000g_ksp->tx_no_desc.value.ul = Adapter->tx_no_desc;
216 	e1000g_ksp->tx_no_swpkt.value.ul = Adapter->tx_no_swpkt;
217 	e1000g_ksp->tx_lack_desc.value.ul = Adapter->tx_lack_desc;
218 	e1000g_ksp->tx_send_fail.value.ul = Adapter->tx_send_fail;
219 	e1000g_ksp->tx_multi_cookie.value.ul = Adapter->tx_multi_cookie;
220 	e1000g_ksp->tx_over_size.value.ul = Adapter->tx_over_size;
221 	e1000g_ksp->tx_under_size.value.ul = Adapter->tx_under_size;
222 	e1000g_ksp->tx_copy.value.ul = Adapter->tx_copy;
223 	e1000g_ksp->tx_bind.value.ul = Adapter->tx_bind;
224 	e1000g_ksp->tx_multi_copy.value.ul = Adapter->tx_multi_copy;
225 	e1000g_ksp->tx_reschedule.value.ul = Adapter->tx_reschedule;
226 	e1000g_ksp->tx_empty_frags.value.ul = Adapter->tx_empty_frags;
227 	e1000g_ksp->tx_exceed_frags.value.ul = Adapter->tx_exceed_frags;
228 	e1000g_ksp->tx_recycle.value.ul = Adapter->tx_recycle;
229 	e1000g_ksp->tx_recycle_retry.value.ul = Adapter->tx_recycle_retry;
230 	e1000g_ksp->tx_recycle_intr.value.ul = Adapter->tx_recycle_intr;
231 	e1000g_ksp->tx_recycle_none.value.ul = Adapter->tx_recycle_none;
232 	e1000g_ksp->StallWatchdog.value.ul = Adapter->StallWatchdog;
233 	e1000g_ksp->reset_count.value.ul = Adapter->reset_count;
234 	e1000g_ksp->JumboTx_4K.value.ul = Adapter->JumboTx_4K;
235 	e1000g_ksp->JumboRx_4K.value.ul = Adapter->JumboRx_4K;
236 	e1000g_ksp->JumboTx_8K.value.ul = Adapter->JumboTx_8K;
237 	e1000g_ksp->JumboRx_8K.value.ul = Adapter->JumboRx_8K;
238 	e1000g_ksp->JumboTx_16K.value.ul = Adapter->JumboTx_16K;
239 	e1000g_ksp->JumboRx_16K.value.ul = Adapter->JumboRx_16K;
240 	e1000g_ksp->intr_type.value.ul = Adapter->intr_type;
241 
242 	/*
243 	 * Mutex required if in TBI mode
244 	 */
245 	if (Adapter->Shared.tbi_compatibility_on == 1) {
246 		mutex_enter(&Adapter->TbiCntrMutex);
247 	}
248 
249 	/*
250 	 * Standard Stats
251 	 */
252 	e1000g_ksp->Mpc.value.ul +=
253 	    E1000_READ_REG(&Adapter->Shared, MPC);
254 
255 	e1000g_ksp->Symerrs.value.ul +=
256 	    E1000_READ_REG(&Adapter->Shared, SYMERRS);
257 
258 	e1000g_ksp->Rlec.value.ul +=
259 	    E1000_READ_REG(&Adapter->Shared, RLEC);
260 
261 	e1000g_ksp->Xonrxc.value.ul +=
262 	    E1000_READ_REG(&Adapter->Shared, XONRXC);
263 
264 	e1000g_ksp->Xontxc.value.ul +=
265 	    E1000_READ_REG(&Adapter->Shared, XONTXC);
266 
267 	e1000g_ksp->Xoffrxc.value.ul +=
268 	    E1000_READ_REG(&Adapter->Shared, XOFFRXC);
269 
270 	e1000g_ksp->Xofftxc.value.ul +=
271 	    E1000_READ_REG(&Adapter->Shared, XOFFTXC);
272 
273 	e1000g_ksp->Fcruc.value.ul +=
274 	    E1000_READ_REG(&Adapter->Shared, FCRUC);
275 
276 	e1000g_ksp->Prc64.value.ul +=
277 	    E1000_READ_REG(&Adapter->Shared, PRC64);
278 
279 	e1000g_ksp->Prc127.value.ul +=
280 	    E1000_READ_REG(&Adapter->Shared, PRC127);
281 
282 	e1000g_ksp->Prc255.value.ul +=
283 	    E1000_READ_REG(&Adapter->Shared, PRC255);
284 
285 	e1000g_ksp->Prc511.value.ul +=
286 	    E1000_READ_REG(&Adapter->Shared, PRC511);
287 
288 	e1000g_ksp->Prc1023.value.ul +=
289 	    E1000_READ_REG(&Adapter->Shared, PRC1023);
290 
291 	e1000g_ksp->Prc1522.value.ul +=
292 	    E1000_READ_REG(&Adapter->Shared, PRC1522);
293 
294 	e1000g_ksp->Gprc.value.ul +=
295 	    E1000_READ_REG(&Adapter->Shared, GPRC);
296 
297 	e1000g_ksp->Gptc.value.ul +=
298 	    E1000_READ_REG(&Adapter->Shared, GPTC);
299 
300 	/*
301 	 * The 64-bit register will reset whenever the upper
302 	 * 32 bits are read. So we need to read the lower
303 	 * 32 bits first, then read the upper 32 bits.
304 	 */
305 	low_val = E1000_READ_REG(&Adapter->Shared, GORCL);
306 	high_val = E1000_READ_REG(&Adapter->Shared, GORCH);
307 	val = (uint64_t)e1000g_ksp->Gorh.value.ul << 32 |
308 	    (uint64_t)e1000g_ksp->Gorl.value.ul;
309 	val += (uint64_t)high_val << 32 | (uint64_t)low_val;
310 	e1000g_ksp->Gorl.value.ul = (uint32_t)val;
311 	e1000g_ksp->Gorh.value.ul = (uint32_t)(val >> 32);
312 
313 	low_val = E1000_READ_REG(&Adapter->Shared, GOTCL);
314 	high_val = E1000_READ_REG(&Adapter->Shared, GOTCH);
315 	val = (uint64_t)e1000g_ksp->Goth.value.ul << 32 |
316 	    (uint64_t)e1000g_ksp->Gotl.value.ul;
317 	val += (uint64_t)high_val << 32 | (uint64_t)low_val;
318 	e1000g_ksp->Gotl.value.ul = (uint32_t)val;
319 	e1000g_ksp->Goth.value.ul = (uint32_t)(val >> 32);
320 
321 	e1000g_ksp->Ruc.value.ul +=
322 	    E1000_READ_REG(&Adapter->Shared, RUC);
323 
324 	e1000g_ksp->Rfc.value.ul +=
325 	    E1000_READ_REG(&Adapter->Shared, RFC);
326 
327 	e1000g_ksp->Roc.value.ul +=
328 	    E1000_READ_REG(&Adapter->Shared, ROC);
329 
330 	e1000g_ksp->Rjc.value.ul +=
331 	    E1000_READ_REG(&Adapter->Shared, RJC);
332 
333 	low_val = E1000_READ_REG(&Adapter->Shared, TORL);
334 	high_val = E1000_READ_REG(&Adapter->Shared, TORH);
335 	val = (uint64_t)e1000g_ksp->Torh.value.ul << 32 |
336 	    (uint64_t)e1000g_ksp->Torl.value.ul;
337 	val += (uint64_t)high_val << 32 | (uint64_t)low_val;
338 	e1000g_ksp->Torl.value.ul = (uint32_t)val;
339 	e1000g_ksp->Torh.value.ul = (uint32_t)(val >> 32);
340 
341 	low_val = E1000_READ_REG(&Adapter->Shared, TOTL);
342 	high_val = E1000_READ_REG(&Adapter->Shared, TOTH);
343 	val = (uint64_t)e1000g_ksp->Toth.value.ul << 32 |
344 	    (uint64_t)e1000g_ksp->Totl.value.ul;
345 	val += (uint64_t)high_val << 32 | (uint64_t)low_val;
346 	e1000g_ksp->Totl.value.ul = (uint32_t)val;
347 	e1000g_ksp->Toth.value.ul = (uint32_t)(val >> 32);
348 
349 	e1000g_ksp->Tpr.value.ul +=
350 	    E1000_READ_REG(&Adapter->Shared, TPR);
351 
352 	/*
353 	 * Adaptive Calculations
354 	 */
355 	Adapter->Shared.tx_packet_delta =
356 	    E1000_READ_REG(&Adapter->Shared, TPT);
357 	e1000g_ksp->Tpt.value.ul +=
358 	    Adapter->Shared.tx_packet_delta;
359 
360 	e1000g_ksp->Ptc64.value.ul +=
361 	    E1000_READ_REG(&Adapter->Shared, PTC64);
362 
363 	e1000g_ksp->Ptc127.value.ul +=
364 	    E1000_READ_REG(&Adapter->Shared, PTC127);
365 
366 	e1000g_ksp->Ptc255.value.ul +=
367 	    E1000_READ_REG(&Adapter->Shared, PTC255);
368 
369 	e1000g_ksp->Ptc511.value.ul +=
370 	    E1000_READ_REG(&Adapter->Shared, PTC511);
371 
372 	e1000g_ksp->Ptc1023.value.ul +=
373 	    E1000_READ_REG(&Adapter->Shared, PTC1023);
374 
375 	e1000g_ksp->Ptc1522.value.ul +=
376 	    E1000_READ_REG(&Adapter->Shared, PTC1522);
377 
378 	/*
379 	 * Livengood Counters
380 	 */
381 	e1000g_ksp->Tncrs.value.ul +=
382 	    E1000_READ_REG(&Adapter->Shared, TNCRS);
383 
384 	e1000g_ksp->Tsctc.value.ul +=
385 	    E1000_READ_REG(&Adapter->Shared, TSCTC);
386 
387 	e1000g_ksp->Tsctfc.value.ul +=
388 	    E1000_READ_REG(&Adapter->Shared, TSCTFC);
389 
390 	/*
391 	 * Mutex required if in TBI mode
392 	 */
393 	if (Adapter->Shared.tbi_compatibility_on == 1) {
394 		mutex_exit(&Adapter->TbiCntrMutex);
395 	}
396 
397 	return (0);
398 }
399 
400 int
401 e1000g_m_stat(void *arg, uint_t stat, uint64_t *val)
402 {
403 	struct e1000g *Adapter = (struct e1000g *)arg;
404 	e1000gstat *e1000g_ksp;
405 	uint32_t low_val, high_val;
406 	uint16_t phy_reg, phy_reg_2;
407 
408 	e1000g_ksp = (e1000gstat *)Adapter->e1000g_ksp->ks_data;
409 
410 	switch (stat) {
411 	case MAC_STAT_IFSPEED:
412 		*val = Adapter->link_speed * 1000000ull;
413 		break;
414 
415 	case MAC_STAT_MULTIRCV:
416 		e1000g_ksp->Mprc.value.ul +=
417 		    E1000_READ_REG(&Adapter->Shared, MPRC);
418 		*val = e1000g_ksp->Mprc.value.ul;
419 		break;
420 
421 	case MAC_STAT_BRDCSTRCV:
422 		e1000g_ksp->Bprc.value.ul +=
423 		    E1000_READ_REG(&Adapter->Shared, BPRC);
424 		*val = e1000g_ksp->Bprc.value.ul;
425 		break;
426 
427 	case MAC_STAT_MULTIXMT:
428 		e1000g_ksp->Mptc.value.ul +=
429 		    E1000_READ_REG(&Adapter->Shared, MPTC);
430 		*val = e1000g_ksp->Mptc.value.ul;
431 		break;
432 
433 	case MAC_STAT_BRDCSTXMT:
434 		e1000g_ksp->Bptc.value.ul +=
435 		    E1000_READ_REG(&Adapter->Shared, BPTC);
436 		*val = e1000g_ksp->Bptc.value.ul;
437 		break;
438 
439 	case MAC_STAT_NORCVBUF:
440 		e1000g_ksp->Rnbc.value.ul +=
441 		    E1000_READ_REG(&Adapter->Shared, RNBC);
442 		*val = e1000g_ksp->Rnbc.value.ul;
443 		break;
444 
445 	case MAC_STAT_IERRORS:
446 		e1000g_ksp->Rxerrc.value.ul +=
447 		    E1000_READ_REG(&Adapter->Shared, RXERRC);
448 		e1000g_ksp->Algnerrc.value.ul +=
449 		    E1000_READ_REG(&Adapter->Shared, ALGNERRC);
450 		e1000g_ksp->Rlec.value.ul +=
451 		    E1000_READ_REG(&Adapter->Shared, RLEC);
452 		e1000g_ksp->Crcerrs.value.ul +=
453 		    E1000_READ_REG(&Adapter->Shared, CRCERRS);
454 		e1000g_ksp->Cexterr.value.ul +=
455 		    E1000_READ_REG(&Adapter->Shared, CEXTERR);
456 		*val = e1000g_ksp->Rxerrc.value.ul +
457 		    e1000g_ksp->Algnerrc.value.ul +
458 		    e1000g_ksp->Rlec.value.ul +
459 		    e1000g_ksp->Crcerrs.value.ul +
460 		    e1000g_ksp->Cexterr.value.ul;
461 		break;
462 
463 	case MAC_STAT_NOXMTBUF:
464 		*val = Adapter->tx_no_desc;
465 		break;
466 
467 	case MAC_STAT_OERRORS:
468 		e1000g_ksp->Ecol.value.ul +=
469 		    E1000_READ_REG(&Adapter->Shared, ECOL);
470 		*val = e1000g_ksp->Ecol.value.ul;
471 		break;
472 
473 	case MAC_STAT_COLLISIONS:
474 		e1000g_ksp->Colc.value.ul +=
475 		    E1000_READ_REG(&Adapter->Shared, COLC);
476 		*val = e1000g_ksp->Colc.value.ul;
477 		break;
478 
479 	case MAC_STAT_RBYTES:
480 		/*
481 		 * The 64-bit register will reset whenever the upper
482 		 * 32 bits are read. So we need to read the lower
483 		 * 32 bits first, then read the upper 32 bits.
484 		 */
485 		low_val = E1000_READ_REG(&Adapter->Shared, TORL);
486 		high_val = E1000_READ_REG(&Adapter->Shared, TORH);
487 		*val = (uint64_t)e1000g_ksp->Torh.value.ul << 32 |
488 		    (uint64_t)e1000g_ksp->Torl.value.ul;
489 		*val += (uint64_t)high_val << 32 | (uint64_t)low_val;
490 
491 		e1000g_ksp->Torl.value.ul = (uint32_t)*val;
492 		e1000g_ksp->Torh.value.ul = (uint32_t)(*val >> 32);
493 		break;
494 
495 	case MAC_STAT_IPACKETS:
496 		e1000g_ksp->Tpr.value.ul +=
497 		    E1000_READ_REG(&Adapter->Shared, TPR);
498 		*val = e1000g_ksp->Tpr.value.ul;
499 		break;
500 
501 	case MAC_STAT_OBYTES:
502 		/*
503 		 * The 64-bit register will reset whenever the upper
504 		 * 32 bits are read. So we need to read the lower
505 		 * 32 bits first, then read the upper 32 bits.
506 		 */
507 		low_val = E1000_READ_REG(&Adapter->Shared, TOTL);
508 		high_val = E1000_READ_REG(&Adapter->Shared, TOTH);
509 		*val = (uint64_t)e1000g_ksp->Toth.value.ul << 32 |
510 		    (uint64_t)e1000g_ksp->Totl.value.ul;
511 		*val += (uint64_t)high_val << 32 | (uint64_t)low_val;
512 
513 		e1000g_ksp->Totl.value.ul = (uint32_t)*val;
514 		e1000g_ksp->Toth.value.ul = (uint32_t)(*val >> 32);
515 		break;
516 
517 	case MAC_STAT_OPACKETS:
518 		e1000g_ksp->Tpt.value.ul +=
519 		    E1000_READ_REG(&Adapter->Shared, TPT);
520 		*val = e1000g_ksp->Tpt.value.ul;
521 		break;
522 
523 	case ETHER_STAT_ALIGN_ERRORS:
524 		e1000g_ksp->Algnerrc.value.ul +=
525 		    E1000_READ_REG(&Adapter->Shared, ALGNERRC);
526 		*val = e1000g_ksp->Algnerrc.value.ul;
527 		break;
528 
529 	case ETHER_STAT_FCS_ERRORS:
530 		e1000g_ksp->Crcerrs.value.ul +=
531 		    E1000_READ_REG(&Adapter->Shared, CRCERRS);
532 		*val = e1000g_ksp->Crcerrs.value.ul;
533 		break;
534 
535 	case ETHER_STAT_SQE_ERRORS:
536 		e1000g_ksp->Sec.value.ul +=
537 		    E1000_READ_REG(&Adapter->Shared, SEC);
538 		*val = e1000g_ksp->Sec.value.ul;
539 		break;
540 
541 	case ETHER_STAT_CARRIER_ERRORS:
542 		e1000g_ksp->Cexterr.value.ul +=
543 		    E1000_READ_REG(&Adapter->Shared, CEXTERR);
544 		*val = e1000g_ksp->Cexterr.value.ul;
545 		break;
546 
547 	case ETHER_STAT_EX_COLLISIONS:
548 		e1000g_ksp->Ecol.value.ul +=
549 		    E1000_READ_REG(&Adapter->Shared, ECOL);
550 		*val = e1000g_ksp->Ecol.value.ul;
551 		break;
552 
553 	case ETHER_STAT_TX_LATE_COLLISIONS:
554 		e1000g_ksp->Latecol.value.ul +=
555 		    E1000_READ_REG(&Adapter->Shared, LATECOL);
556 		*val = e1000g_ksp->Latecol.value.ul;
557 		break;
558 
559 	case ETHER_STAT_DEFER_XMTS:
560 		e1000g_ksp->Dc.value.ul +=
561 		    E1000_READ_REG(&Adapter->Shared, DC);
562 		*val = e1000g_ksp->Dc.value.ul;
563 		break;
564 
565 	case ETHER_STAT_FIRST_COLLISIONS:
566 		e1000g_ksp->Scc.value.ul +=
567 		    E1000_READ_REG(&Adapter->Shared, SCC);
568 		*val = e1000g_ksp->Scc.value.ul;
569 		break;
570 
571 	case ETHER_STAT_MULTI_COLLISIONS:
572 		e1000g_ksp->Mcc.value.ul +=
573 		    E1000_READ_REG(&Adapter->Shared, MCC);
574 		*val = e1000g_ksp->Mcc.value.ul;
575 		break;
576 
577 	case ETHER_STAT_MACRCV_ERRORS:
578 		e1000g_ksp->Rxerrc.value.ul +=
579 		    E1000_READ_REG(&Adapter->Shared, RXERRC);
580 		*val = e1000g_ksp->Rxerrc.value.ul;
581 		break;
582 
583 	case ETHER_STAT_MACXMT_ERRORS:
584 		e1000g_ksp->Ecol.value.ul +=
585 		    E1000_READ_REG(&Adapter->Shared, ECOL);
586 		*val = e1000g_ksp->Ecol.value.ul;
587 		break;
588 
589 	case ETHER_STAT_TOOLONG_ERRORS:
590 		e1000g_ksp->Roc.value.ul +=
591 		    E1000_READ_REG(&Adapter->Shared, ROC);
592 		*val = e1000g_ksp->Roc.value.ul;
593 		break;
594 
595 	case ETHER_STAT_XCVR_ADDR:
596 		/* The Internal PHY's MDI address for each MAC is 1 */
597 		*val = 1;
598 		break;
599 
600 	case ETHER_STAT_XCVR_ID:
601 		e1000_read_phy_reg(&Adapter->Shared, PHY_ID1, &phy_reg);
602 		e1000_read_phy_reg(&Adapter->Shared, PHY_ID2, &phy_reg_2);
603 		*val = (uint32_t)((phy_reg << 16) | phy_reg_2);
604 		break;
605 
606 	case ETHER_STAT_XCVR_INUSE:
607 		e1000_read_phy_reg(&Adapter->Shared, PHY_STATUS, &phy_reg);
608 		switch (Adapter->link_speed) {
609 		case SPEED_1000:
610 			*val =
611 			    (Adapter->Shared.media_type ==
612 			    e1000_media_type_copper) ? XCVR_1000T :
613 			    XCVR_1000X;
614 			break;
615 		case SPEED_100:
616 			*val =
617 			    (Adapter->Shared.media_type ==
618 			    e1000_media_type_copper) ? (phy_reg &
619 			    MII_SR_100T4_CAPS) ? XCVR_100T4 : XCVR_100T2 :
620 			    XCVR_100X;
621 			break;
622 		case SPEED_10:
623 			*val = XCVR_10;
624 			break;
625 		default:
626 			*val = XCVR_NONE;
627 			break;
628 		}
629 		break;
630 
631 	case ETHER_STAT_CAP_1000FDX:
632 		e1000_read_phy_reg(&Adapter->Shared, PHY_EXT_STATUS,
633 		    &phy_reg);
634 		*val = ((phy_reg & IEEE_ESR_1000T_FD_CAPS) ||
635 		    (phy_reg & IEEE_ESR_1000X_FD_CAPS)) ? 1 : 0;
636 		break;
637 
638 	case ETHER_STAT_CAP_1000HDX:
639 		e1000_read_phy_reg(&Adapter->Shared, PHY_EXT_STATUS,
640 		    &phy_reg);
641 		*val = ((phy_reg & IEEE_ESR_1000T_HD_CAPS) ||
642 		    (phy_reg & IEEE_ESR_1000X_HD_CAPS)) ? 1 : 0;
643 		break;
644 
645 	case ETHER_STAT_CAP_100FDX:
646 		e1000_read_phy_reg(&Adapter->Shared, PHY_STATUS, &phy_reg);
647 		*val = ((phy_reg & MII_SR_100X_FD_CAPS) ||
648 		    (phy_reg & MII_SR_100T2_FD_CAPS)) ? 1 : 0;
649 		break;
650 
651 	case ETHER_STAT_CAP_100HDX:
652 		e1000_read_phy_reg(&Adapter->Shared, PHY_STATUS, &phy_reg);
653 		*val = ((phy_reg & MII_SR_100X_HD_CAPS) ||
654 		    (phy_reg & MII_SR_100T2_HD_CAPS)) ? 1 : 0;
655 		break;
656 
657 	case ETHER_STAT_CAP_10FDX:
658 		e1000_read_phy_reg(&Adapter->Shared, PHY_STATUS, &phy_reg);
659 		*val = (phy_reg & MII_SR_10T_FD_CAPS) ? 1 : 0;
660 		break;
661 
662 	case ETHER_STAT_CAP_10HDX:
663 		e1000_read_phy_reg(&Adapter->Shared, PHY_STATUS, &phy_reg);
664 		*val = (phy_reg & MII_SR_10T_HD_CAPS) ? 1 : 0;
665 		break;
666 
667 	case ETHER_STAT_CAP_ASMPAUSE:
668 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
669 		    &phy_reg);
670 		*val = (phy_reg & NWAY_AR_ASM_DIR) ? 1 : 0;
671 		break;
672 
673 	case ETHER_STAT_CAP_PAUSE:
674 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
675 		    &phy_reg);
676 		*val = (phy_reg & NWAY_AR_PAUSE) ? 1 : 0;
677 		break;
678 
679 	case ETHER_STAT_CAP_AUTONEG:
680 		e1000_read_phy_reg(&Adapter->Shared, PHY_STATUS, &phy_reg);
681 		*val = (phy_reg & MII_SR_AUTONEG_CAPS) ? 1 : 0;
682 		break;
683 
684 	case ETHER_STAT_ADV_CAP_1000FDX:
685 		e1000_read_phy_reg(&Adapter->Shared, PHY_1000T_CTRL,
686 		    &phy_reg);
687 		*val = (phy_reg & CR_1000T_FD_CAPS) ? 1 : 0;
688 		break;
689 
690 	case ETHER_STAT_ADV_CAP_1000HDX:
691 		e1000_read_phy_reg(&Adapter->Shared, PHY_1000T_CTRL,
692 		    &phy_reg);
693 		*val = (phy_reg & CR_1000T_HD_CAPS) ? 1 : 0;
694 		break;
695 
696 	case ETHER_STAT_ADV_CAP_100FDX:
697 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
698 		    &phy_reg);
699 		*val = (phy_reg & NWAY_AR_100TX_FD_CAPS) ? 1 : 0;
700 		break;
701 
702 	case ETHER_STAT_ADV_CAP_100HDX:
703 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
704 		    &phy_reg);
705 		*val = (phy_reg & NWAY_AR_100TX_HD_CAPS) ? 1 : 0;
706 		break;
707 
708 	case ETHER_STAT_ADV_CAP_10FDX:
709 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
710 		    &phy_reg);
711 		*val = (phy_reg & NWAY_AR_10T_FD_CAPS) ? 1 : 0;
712 		break;
713 
714 	case ETHER_STAT_ADV_CAP_10HDX:
715 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
716 		    &phy_reg);
717 		*val = (phy_reg & NWAY_AR_10T_HD_CAPS) ? 1 : 0;
718 		break;
719 
720 	case ETHER_STAT_ADV_CAP_ASMPAUSE:
721 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
722 		    &phy_reg);
723 		*val = (phy_reg & NWAY_AR_ASM_DIR) ? 1 : 0;
724 		break;
725 
726 	case ETHER_STAT_ADV_CAP_PAUSE:
727 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
728 		    &phy_reg);
729 		*val = (phy_reg & NWAY_AR_PAUSE) ? 1 : 0;
730 		break;
731 
732 	case ETHER_STAT_ADV_CAP_AUTONEG:
733 		*val = Adapter->Shared.autoneg;
734 		break;
735 
736 	case ETHER_STAT_LP_CAP_1000FDX:
737 		e1000_read_phy_reg(&Adapter->Shared, PHY_1000T_STATUS,
738 		    &phy_reg);
739 		*val = (phy_reg & SR_1000T_LP_FD_CAPS) ? 1 : 0;
740 		break;
741 
742 	case ETHER_STAT_LP_CAP_1000HDX:
743 		e1000_read_phy_reg(&Adapter->Shared, PHY_1000T_STATUS,
744 		    &phy_reg);
745 		*val = (phy_reg & SR_1000T_LP_HD_CAPS) ? 1 : 0;
746 		break;
747 
748 	case ETHER_STAT_LP_CAP_100FDX:
749 		e1000_read_phy_reg(&Adapter->Shared, PHY_LP_ABILITY,
750 		    &phy_reg);
751 		*val = (phy_reg & NWAY_LPAR_100TX_FD_CAPS) ? 1 : 0;
752 		break;
753 
754 	case ETHER_STAT_LP_CAP_100HDX:
755 		e1000_read_phy_reg(&Adapter->Shared, PHY_LP_ABILITY,
756 		    &phy_reg);
757 		*val = (phy_reg & NWAY_LPAR_100TX_HD_CAPS) ? 1 : 0;
758 		break;
759 
760 	case ETHER_STAT_LP_CAP_10FDX:
761 		e1000_read_phy_reg(&Adapter->Shared, PHY_LP_ABILITY,
762 		    &phy_reg);
763 		*val = (phy_reg & NWAY_LPAR_10T_FD_CAPS) ? 1 : 0;
764 		break;
765 
766 	case ETHER_STAT_LP_CAP_10HDX:
767 		e1000_read_phy_reg(&Adapter->Shared, PHY_LP_ABILITY,
768 		    &phy_reg);
769 		*val = (phy_reg & NWAY_LPAR_10T_HD_CAPS) ? 1 : 0;
770 		break;
771 
772 	case ETHER_STAT_LP_CAP_ASMPAUSE:
773 		e1000_read_phy_reg(&Adapter->Shared, PHY_LP_ABILITY,
774 		    &phy_reg);
775 		*val = (phy_reg & NWAY_LPAR_ASM_DIR) ? 1 : 0;
776 		break;
777 
778 	case ETHER_STAT_LP_CAP_PAUSE:
779 		e1000_read_phy_reg(&Adapter->Shared, PHY_LP_ABILITY,
780 		    &phy_reg);
781 		*val = (phy_reg & NWAY_LPAR_PAUSE) ? 1 : 0;
782 		break;
783 
784 	case ETHER_STAT_LP_CAP_AUTONEG:
785 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_EXP,
786 		    &phy_reg);
787 		*val = (phy_reg & NWAY_ER_LP_NWAY_CAPS) ? 1 : 0;
788 		break;
789 
790 	case ETHER_STAT_LINK_ASMPAUSE:
791 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
792 		    &phy_reg);
793 		*val = (phy_reg & NWAY_AR_ASM_DIR) ? 1 : 0;
794 		break;
795 
796 	case ETHER_STAT_LINK_PAUSE:
797 		e1000_read_phy_reg(&Adapter->Shared, PHY_AUTONEG_ADV,
798 		    &phy_reg);
799 		*val = (phy_reg & NWAY_AR_PAUSE) ? 1 : 0;
800 		break;
801 
802 	case ETHER_STAT_LINK_AUTONEG:
803 		e1000_read_phy_reg(&Adapter->Shared, PHY_CTRL, &phy_reg);
804 		*val = (phy_reg & MII_CR_AUTO_NEG_EN) ? 1 : 0;
805 		break;
806 
807 	case ETHER_STAT_LINK_DUPLEX:
808 		*val = (Adapter->link_duplex == FULL_DUPLEX) ?
809 		    LINK_DUPLEX_FULL : LINK_DUPLEX_HALF;
810 		break;
811 
812 	default:
813 		return (ENOTSUP);
814 	}
815 
816 	return (0);
817 }
818 
819 /*
820  * **********************************************************************
821  * Name:	InitStatsCounters					*
822  *									*
823  * Description: This routine will create and initialize the kernel	*
824  *	       statistics counters.					*
825  *									*
826  * Author:      Phil Cayton						*
827  *									*
828  * Born on Date:    7/13/98						*
829  *									*
830  * Arguments:								*
831  *      Adapter - A pointer to our context sensitive "Adapter"		*
832  *		structure.						*
833  *									*
834  * Returns:								*
835  *      '0' if unable to create kernel statistics structure.		*
836  *      '1' if creation and initialization successful			*
837  *									*
838  * File: e1000g_stat.c							*
839  *									*
840  * Modification log:							*
841  * Date      Who  Description						*
842  * --------  ---  ------------------------------------------------------*
843  *									*
844  * **********************************************************************
845  */
846 int
847 InitStatsCounters(IN struct e1000g *Adapter)
848 {
849 	kstat_t *ksp;
850 	e1000gstat *e1000g_ksp;
851 
852 	/*
853 	 * Create and init kstat
854 	 */
855 	ksp = kstat_create(WSNAME, ddi_get_instance(Adapter->dip),
856 	    "statistics", "net", KSTAT_TYPE_NAMED,
857 	    sizeof (e1000gstat) / sizeof (kstat_named_t), 0);
858 
859 	if (ksp == NULL) {
860 		e1000g_log(Adapter, CE_WARN,
861 		    "Could not create kernel statistics\n");
862 		return (DDI_FAILURE);
863 	}
864 
865 	Adapter->e1000g_ksp = ksp;	/* Fill in the Adapters ksp */
866 
867 	e1000g_ksp = (e1000gstat *) ksp->ks_data;
868 
869 	/*
870 	 * Initialize all the statistics
871 	 */
872 	kstat_named_init(&e1000g_ksp->link_speed, "link_speed",
873 	    KSTAT_DATA_ULONG);
874 
875 	kstat_named_init(&e1000g_ksp->rx_none, "Rx No Data",
876 	    KSTAT_DATA_ULONG);
877 
878 	kstat_named_init(&e1000g_ksp->rx_error, "Rx Error",
879 	    KSTAT_DATA_ULONG);
880 
881 	kstat_named_init(&e1000g_ksp->rx_no_freepkt, "Rx Freelist Empty",
882 	    KSTAT_DATA_ULONG);
883 
884 	kstat_named_init(&e1000g_ksp->rx_avail_freepkt, "Rx Freelist Avail",
885 	    KSTAT_DATA_ULONG);
886 
887 	kstat_named_init(&e1000g_ksp->rx_esballoc_fail, "Rx Desballoc Failure",
888 	    KSTAT_DATA_ULONG);
889 
890 	kstat_named_init(&e1000g_ksp->rx_exceed_pkt, "Rx Exceed Max Pkt Count",
891 	    KSTAT_DATA_ULONG);
892 
893 	kstat_named_init(&e1000g_ksp->rx_multi_desc, "Rx Span Multi Desc",
894 	    KSTAT_DATA_ULONG);
895 
896 	kstat_named_init(&e1000g_ksp->rx_allocb_fail, "Rx Allocb Failure",
897 	    KSTAT_DATA_ULONG);
898 
899 	kstat_named_init(&e1000g_ksp->rx_seq_intr, "Rx Seq Err Intr",
900 	    KSTAT_DATA_ULONG);
901 
902 	kstat_named_init(&e1000g_ksp->tx_no_desc, "Tx No Desc",
903 	    KSTAT_DATA_ULONG);
904 
905 	kstat_named_init(&e1000g_ksp->tx_no_swpkt, "Tx No Buffer",
906 	    KSTAT_DATA_ULONG);
907 
908 	kstat_named_init(&e1000g_ksp->tx_lack_desc, "Tx Desc Insufficient",
909 	    KSTAT_DATA_ULONG);
910 
911 	kstat_named_init(&e1000g_ksp->tx_send_fail,
912 	    "Tx Send Failure", KSTAT_DATA_ULONG);
913 
914 	kstat_named_init(&e1000g_ksp->tx_multi_cookie,
915 	    "Tx Bind Multi Cookies", KSTAT_DATA_ULONG);
916 
917 	kstat_named_init(&e1000g_ksp->tx_over_size, "Tx Pkt Over Size",
918 	    KSTAT_DATA_ULONG);
919 
920 	kstat_named_init(&e1000g_ksp->tx_under_size, "Tx Pkt Under Size",
921 	    KSTAT_DATA_ULONG);
922 
923 	kstat_named_init(&e1000g_ksp->tx_copy, "Tx Send Copy",
924 	    KSTAT_DATA_ULONG);
925 
926 	kstat_named_init(&e1000g_ksp->tx_bind, "Tx Send Bind",
927 	    KSTAT_DATA_ULONG);
928 
929 	kstat_named_init(&e1000g_ksp->tx_multi_copy, "Tx Copy Multi Frags",
930 	    KSTAT_DATA_ULONG);
931 
932 	kstat_named_init(&e1000g_ksp->tx_reschedule, "Tx Reschedule",
933 	    KSTAT_DATA_ULONG);
934 
935 	kstat_named_init(&e1000g_ksp->tx_empty_frags, "Tx Empty Frags",
936 	    KSTAT_DATA_ULONG);
937 
938 	kstat_named_init(&e1000g_ksp->tx_exceed_frags, "Tx Exceed Max Frags",
939 	    KSTAT_DATA_ULONG);
940 
941 	kstat_named_init(&e1000g_ksp->tx_recycle,
942 	    "Tx Desc Recycle", KSTAT_DATA_ULONG);
943 
944 	kstat_named_init(&e1000g_ksp->tx_recycle_retry,
945 	    "Tx Desc Recycle Retry", KSTAT_DATA_ULONG);
946 
947 	kstat_named_init(&e1000g_ksp->tx_recycle_intr,
948 	    "Tx Desc Recycle Intr", KSTAT_DATA_ULONG);
949 
950 	kstat_named_init(&e1000g_ksp->tx_recycle_none,
951 	    "Tx Desc Recycled None", KSTAT_DATA_ULONG);
952 
953 	kstat_named_init(&e1000g_ksp->StallWatchdog,
954 	    "Tx Stall Watchdog", KSTAT_DATA_ULONG);
955 
956 	kstat_named_init(&e1000g_ksp->reset_count,
957 	    "Reset Count", KSTAT_DATA_ULONG);
958 
959 	kstat_named_init(&e1000g_ksp->intr_type,
960 	    "Interrupt Type", KSTAT_DATA_ULONG);
961 
962 	kstat_named_init(&e1000g_ksp->Mpc, "Recv_Missed_Packets",
963 	    KSTAT_DATA_ULONG);
964 
965 	kstat_named_init(&e1000g_ksp->Symerrs, "Recv_Symbol_Errors",
966 	    KSTAT_DATA_ULONG);
967 
968 	kstat_named_init(&e1000g_ksp->Rlec, "Recv_Length_Errors",
969 	    KSTAT_DATA_ULONG);
970 
971 	kstat_named_init(&e1000g_ksp->Xonrxc, "XONs_Recvd",
972 	    KSTAT_DATA_ULONG);
973 
974 	kstat_named_init(&e1000g_ksp->Xontxc, "XONs_Xmitd",
975 	    KSTAT_DATA_ULONG);
976 
977 	kstat_named_init(&e1000g_ksp->Xoffrxc, "XOFFs_Recvd",
978 	    KSTAT_DATA_ULONG);
979 
980 	kstat_named_init(&e1000g_ksp->Xofftxc, "XOFFs_Xmitd",
981 	    KSTAT_DATA_ULONG);
982 
983 	kstat_named_init(&e1000g_ksp->Fcruc, "Recv_Unsupport_FC_Pkts",
984 	    KSTAT_DATA_ULONG);
985 
986 	kstat_named_init(&e1000g_ksp->Prc64, "Pkts_Recvd_(  64b)",
987 	    KSTAT_DATA_ULONG);
988 
989 	kstat_named_init(&e1000g_ksp->Prc127, "Pkts_Recvd_(  65- 127b)",
990 	    KSTAT_DATA_ULONG);
991 
992 	kstat_named_init(&e1000g_ksp->Prc255, "Pkts_Recvd_( 127- 255b)",
993 	    KSTAT_DATA_ULONG);
994 
995 	kstat_named_init(&e1000g_ksp->Prc511, "Pkts_Recvd_( 256- 511b)",
996 	    KSTAT_DATA_ULONG);
997 
998 	kstat_named_init(&e1000g_ksp->Prc1023, "Pkts_Recvd_( 511-1023b)",
999 	    KSTAT_DATA_ULONG);
1000 
1001 	kstat_named_init(&e1000g_ksp->Prc1522, "Pkts_Recvd_(1024-1522b)",
1002 	    KSTAT_DATA_ULONG);
1003 
1004 	kstat_named_init(&e1000g_ksp->Gprc, "Good_Pkts_Recvd",
1005 	    KSTAT_DATA_ULONG);
1006 
1007 	kstat_named_init(&e1000g_ksp->Gptc, "Good_Pkts_Xmitd",
1008 	    KSTAT_DATA_ULONG);
1009 
1010 	kstat_named_init(&e1000g_ksp->Gorl, "Good_Octets_Recvd_Lo",
1011 	    KSTAT_DATA_ULONG);
1012 
1013 	kstat_named_init(&e1000g_ksp->Gorh, "Good_Octets_Recvd_Hi",
1014 	    KSTAT_DATA_ULONG);
1015 
1016 	kstat_named_init(&e1000g_ksp->Gotl, "Good_Octets_Xmitd_Lo",
1017 	    KSTAT_DATA_ULONG);
1018 
1019 	kstat_named_init(&e1000g_ksp->Goth, "Good_Octets_Xmitd_Hi",
1020 	    KSTAT_DATA_ULONG);
1021 
1022 	kstat_named_init(&e1000g_ksp->Ruc, "Recv_Undersize",
1023 	    KSTAT_DATA_ULONG);
1024 
1025 	kstat_named_init(&e1000g_ksp->Rfc, "Recv_Frag",
1026 	    KSTAT_DATA_ULONG);
1027 
1028 	kstat_named_init(&e1000g_ksp->Roc, "Recv_Oversize",
1029 	    KSTAT_DATA_ULONG);
1030 
1031 	kstat_named_init(&e1000g_ksp->Rjc, "Recv_Jabber",
1032 	    KSTAT_DATA_ULONG);
1033 
1034 	kstat_named_init(&e1000g_ksp->Torl, "Total_Octets_Recvd_Lo",
1035 	    KSTAT_DATA_ULONG);
1036 
1037 	kstat_named_init(&e1000g_ksp->Torh, "Total_Octets_Recvd_Hi",
1038 	    KSTAT_DATA_ULONG);
1039 
1040 	kstat_named_init(&e1000g_ksp->Totl, "Total_Octets_Xmitd_Lo",
1041 	    KSTAT_DATA_ULONG);
1042 
1043 	kstat_named_init(&e1000g_ksp->Toth, "Total_Octets_Xmitd_Hi",
1044 	    KSTAT_DATA_ULONG);
1045 
1046 	kstat_named_init(&e1000g_ksp->Tpr, "Total_Packets_Recvd",
1047 	    KSTAT_DATA_ULONG);
1048 
1049 	kstat_named_init(&e1000g_ksp->Tpt, "Total_Packets_Xmitd",
1050 	    KSTAT_DATA_ULONG);
1051 
1052 	kstat_named_init(&e1000g_ksp->Ptc64, "Pkts_Xmitd_(  64b)",
1053 	    KSTAT_DATA_ULONG);
1054 
1055 	kstat_named_init(&e1000g_ksp->Ptc127, "Pkts_Xmitd_(  65- 127b)",
1056 	    KSTAT_DATA_ULONG);
1057 
1058 	kstat_named_init(&e1000g_ksp->Ptc255, "Pkts_Xmitd_( 128- 255b)",
1059 	    KSTAT_DATA_ULONG);
1060 
1061 	kstat_named_init(&e1000g_ksp->Ptc511, "Pkts_Xmitd_( 255- 511b)",
1062 	    KSTAT_DATA_ULONG);
1063 
1064 	kstat_named_init(&e1000g_ksp->Ptc1023, "Pkts_Xmitd_( 512-1023b)",
1065 	    KSTAT_DATA_ULONG);
1066 
1067 	kstat_named_init(&e1000g_ksp->Ptc1522, "Pkts_Xmitd_(1024-1522b)",
1068 	    KSTAT_DATA_ULONG);
1069 
1070 	/*
1071 	 * Livengood Initializations
1072 	 */
1073 	kstat_named_init(&e1000g_ksp->Tncrs, "Xmit_with_No_CRS",
1074 	    KSTAT_DATA_ULONG);
1075 
1076 	kstat_named_init(&e1000g_ksp->Tsctc, "Xmit_TCP_Seg_Contexts",
1077 	    KSTAT_DATA_ULONG);
1078 
1079 	kstat_named_init(&e1000g_ksp->Tsctfc, "Xmit_TCP_Seg_Contexts_Fail",
1080 	    KSTAT_DATA_ULONG);
1081 
1082 	/*
1083 	 * Jumbo Frame Counters
1084 	 */
1085 	kstat_named_init(&e1000g_ksp->JumboTx_4K, "Jumbo Tx Frame  4K",
1086 	    KSTAT_DATA_ULONG);
1087 
1088 	kstat_named_init(&e1000g_ksp->JumboRx_4K, "Jumbo Rx Frame  4K",
1089 	    KSTAT_DATA_ULONG);
1090 
1091 	kstat_named_init(&e1000g_ksp->JumboTx_8K, "Jumbo Tx Frame  8K",
1092 	    KSTAT_DATA_ULONG);
1093 
1094 	kstat_named_init(&e1000g_ksp->JumboRx_8K, "Jumbo Rx Frame  8K",
1095 	    KSTAT_DATA_ULONG);
1096 
1097 	kstat_named_init(&e1000g_ksp->JumboTx_16K, "Jumbo Tx Frame 16K",
1098 	    KSTAT_DATA_ULONG);
1099 
1100 	kstat_named_init(&e1000g_ksp->JumboRx_16K, "Jumbo Rx Frame 16K",
1101 	    KSTAT_DATA_ULONG);
1102 
1103 	/*
1104 	 * Function to provide kernel stat update on demand
1105 	 */
1106 	ksp->ks_update = UpdateStatsCounters;
1107 
1108 	/*
1109 	 * Pointer into provider's raw statistics
1110 	 */
1111 	ksp->ks_private = (void *)Adapter;
1112 
1113 	/*
1114 	 * Add kstat to systems kstat chain
1115 	 */
1116 	kstat_install(ksp);
1117 
1118 	return (DDI_SUCCESS);
1119 }
1120