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