xref: /titanic_41/usr/src/uts/common/io/ixgbe/ixgbe_stat.c (revision bbb1277b6ec1b0daad4e3ed1a2b891d3e2ece2eb)
1 /*
2  * CDDL HEADER START
3  *
4  * Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #include "ixgbe_sw.h"
29 
30 /*
31  * Update driver private statistics.
32  */
33 static int
34 ixgbe_update_stats(kstat_t *ks, int rw)
35 {
36 	ixgbe_t *ixgbe;
37 	struct ixgbe_hw *hw;
38 	ixgbe_stat_t *ixgbe_ks;
39 	int i;
40 
41 	if (rw == KSTAT_WRITE)
42 		return (EACCES);
43 
44 	ixgbe = (ixgbe_t *)ks->ks_private;
45 	ixgbe_ks = (ixgbe_stat_t *)ks->ks_data;
46 	hw = &ixgbe->hw;
47 
48 	mutex_enter(&ixgbe->gen_lock);
49 
50 	/*
51 	 * Basic information
52 	 */
53 	ixgbe_ks->link_speed.value.ui64 = ixgbe->link_speed;
54 	ixgbe_ks->reset_count.value.ui64 = ixgbe->reset_count;
55 
56 #ifdef IXGBE_DEBUG
57 	ixgbe_ks->rx_frame_error.value.ui64 = 0;
58 	ixgbe_ks->rx_cksum_error.value.ui64 = 0;
59 	ixgbe_ks->rx_exceed_pkt.value.ui64 = 0;
60 	for (i = 0; i < ixgbe->num_rx_rings; i++) {
61 		ixgbe_ks->rx_frame_error.value.ui64 +=
62 		    ixgbe->rx_rings[i].stat_frame_error;
63 		ixgbe_ks->rx_cksum_error.value.ui64 +=
64 		    ixgbe->rx_rings[i].stat_cksum_error;
65 		ixgbe_ks->rx_exceed_pkt.value.ui64 +=
66 		    ixgbe->rx_rings[i].stat_exceed_pkt;
67 	}
68 
69 	ixgbe_ks->tx_overload.value.ui64 = 0;
70 	ixgbe_ks->tx_fail_no_tbd.value.ui64 = 0;
71 	ixgbe_ks->tx_fail_no_tcb.value.ui64 = 0;
72 	ixgbe_ks->tx_fail_dma_bind.value.ui64 = 0;
73 	ixgbe_ks->tx_reschedule.value.ui64 = 0;
74 	for (i = 0; i < ixgbe->num_tx_rings; i++) {
75 		ixgbe_ks->tx_overload.value.ui64 +=
76 		    ixgbe->tx_rings[i].stat_overload;
77 		ixgbe_ks->tx_fail_no_tbd.value.ui64 +=
78 		    ixgbe->tx_rings[i].stat_fail_no_tbd;
79 		ixgbe_ks->tx_fail_no_tcb.value.ui64 +=
80 		    ixgbe->tx_rings[i].stat_fail_no_tcb;
81 		ixgbe_ks->tx_fail_dma_bind.value.ui64 +=
82 		    ixgbe->tx_rings[i].stat_fail_dma_bind;
83 		ixgbe_ks->tx_reschedule.value.ui64 +=
84 		    ixgbe->tx_rings[i].stat_reschedule;
85 	}
86 #endif
87 
88 	/*
89 	 * Hardware calculated statistics.
90 	 */
91 	ixgbe_ks->gprc.value.ui64 = 0;
92 	ixgbe_ks->gptc.value.ui64 = 0;
93 	ixgbe_ks->tor.value.ui64 = 0;
94 	ixgbe_ks->tot.value.ui64 = 0;
95 	for (i = 0; i < 16; i++) {
96 		ixgbe_ks->qprc[i].value.ui64 +=
97 		    IXGBE_READ_REG(hw, IXGBE_QPRC(i));
98 		ixgbe_ks->gprc.value.ui64 += ixgbe_ks->qprc[i].value.ui64;
99 		ixgbe_ks->qptc[i].value.ui64 +=
100 		    IXGBE_READ_REG(hw, IXGBE_QPTC(i));
101 		ixgbe_ks->gptc.value.ui64 += ixgbe_ks->qptc[i].value.ui64;
102 		ixgbe_ks->qbrc[i].value.ui64 +=
103 		    IXGBE_READ_REG(hw, IXGBE_QBRC(i));
104 		ixgbe_ks->tor.value.ui64 += ixgbe_ks->qbrc[i].value.ui64;
105 		if (hw->mac.type >= ixgbe_mac_82599EB) {
106 			ixgbe_ks->qbtc[i].value.ui64 +=
107 			    IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
108 			ixgbe_ks->qbtc[i].value.ui64 += ((uint64_t)
109 			    (IXGBE_READ_REG(hw, IXGBE_QBTC_H(i))) << 32);
110 		} else {
111 			ixgbe_ks->qbtc[i].value.ui64 +=
112 			    IXGBE_READ_REG(hw, IXGBE_QBTC(i));
113 		}
114 		ixgbe_ks->tot.value.ui64 += ixgbe_ks->qbtc[i].value.ui64;
115 	}
116 	/*
117 	 * This is a Workaround:
118 	 * Currently h/w GORCH, GOTCH, TORH registers are not
119 	 * correctly implemented. We found that the values in
120 	 * these registers are same as those in corresponding
121 	 * *L registers (i.e. GORCL, GOTCL, and TORL). Here the
122 	 * gor and got stat data will not be retrieved through
123 	 * GORC{H/L} and GOTC{H/L} registers but be obtained by
124 	 * simply assigning tor/tot stat data, so the gor/got
125 	 * stat data will not be accurate.
126 	 */
127 	ixgbe_ks->gor.value.ui64 = ixgbe_ks->tor.value.ui64;
128 	ixgbe_ks->got.value.ui64 = ixgbe_ks->tot.value.ui64;
129 
130 	ixgbe_ks->prc64.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC64);
131 	ixgbe_ks->prc127.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC127);
132 	ixgbe_ks->prc255.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC255);
133 	ixgbe_ks->prc511.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC511);
134 	ixgbe_ks->prc1023.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC1023);
135 	ixgbe_ks->prc1522.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC1522);
136 	ixgbe_ks->ptc64.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC64);
137 	ixgbe_ks->ptc127.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC127);
138 	ixgbe_ks->ptc255.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC255);
139 	ixgbe_ks->ptc511.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC511);
140 	ixgbe_ks->ptc1023.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC1023);
141 	ixgbe_ks->ptc1522.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC1522);
142 
143 	ixgbe_ks->mspdc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MSPDC);
144 	for (i = 0; i < 8; i++)
145 		ixgbe_ks->mpc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MPC(i));
146 	ixgbe_ks->mlfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MLFC);
147 	ixgbe_ks->mrfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MRFC);
148 	ixgbe_ks->rlec.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RLEC);
149 	ixgbe_ks->lxontxc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_LXONTXC);
150 	if (hw->mac.type == ixgbe_mac_82598EB) {
151 		ixgbe_ks->lxonrxc.value.ui64 += IXGBE_READ_REG(hw,
152 		    IXGBE_LXONRXC);
153 	} else {
154 		ixgbe_ks->lxonrxc.value.ui64 += IXGBE_READ_REG(hw,
155 		    IXGBE_LXONRXCNT);
156 	}
157 	ixgbe_ks->lxofftxc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
158 	if (hw->mac.type == ixgbe_mac_82598EB) {
159 		ixgbe_ks->lxoffrxc.value.ui64 += IXGBE_READ_REG(hw,
160 		    IXGBE_LXOFFRXC);
161 	} else {
162 		ixgbe_ks->lxoffrxc.value.ui64 += IXGBE_READ_REG(hw,
163 		    IXGBE_LXOFFRXCNT);
164 	}
165 	ixgbe_ks->ruc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RUC);
166 	ixgbe_ks->rfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RFC);
167 	ixgbe_ks->roc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_ROC);
168 	ixgbe_ks->rjc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RJC);
169 
170 	mutex_exit(&ixgbe->gen_lock);
171 
172 	if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK)
173 		ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_UNAFFECTED);
174 
175 	return (0);
176 }
177 
178 /*
179  * Create and initialize the driver private statistics.
180  */
181 int
182 ixgbe_init_stats(ixgbe_t *ixgbe)
183 {
184 	kstat_t *ks;
185 	ixgbe_stat_t *ixgbe_ks;
186 
187 	/*
188 	 * Create and init kstat
189 	 */
190 	ks = kstat_create(MODULE_NAME, ddi_get_instance(ixgbe->dip),
191 	    "statistics", "net", KSTAT_TYPE_NAMED,
192 	    sizeof (ixgbe_stat_t) / sizeof (kstat_named_t), 0);
193 
194 	if (ks == NULL) {
195 		ixgbe_error(ixgbe,
196 		    "Could not create kernel statistics");
197 		return (IXGBE_FAILURE);
198 	}
199 
200 	ixgbe->ixgbe_ks = ks;
201 
202 	ixgbe_ks = (ixgbe_stat_t *)ks->ks_data;
203 
204 	/*
205 	 * Initialize all the statistics.
206 	 */
207 	kstat_named_init(&ixgbe_ks->link_speed, "link_speed",
208 	    KSTAT_DATA_UINT64);
209 	kstat_named_init(&ixgbe_ks->reset_count, "reset_count",
210 	    KSTAT_DATA_UINT64);
211 
212 #ifdef IXGBE_DEBUG
213 	kstat_named_init(&ixgbe_ks->rx_frame_error, "rx_frame_error",
214 	    KSTAT_DATA_UINT64);
215 	kstat_named_init(&ixgbe_ks->rx_cksum_error, "rx_cksum_error",
216 	    KSTAT_DATA_UINT64);
217 	kstat_named_init(&ixgbe_ks->rx_exceed_pkt, "rx_exceed_pkt",
218 	    KSTAT_DATA_UINT64);
219 	kstat_named_init(&ixgbe_ks->tx_overload, "tx_overload",
220 	    KSTAT_DATA_UINT64);
221 	kstat_named_init(&ixgbe_ks->tx_fail_no_tbd, "tx_fail_no_tbd",
222 	    KSTAT_DATA_UINT64);
223 	kstat_named_init(&ixgbe_ks->tx_fail_no_tcb, "tx_fail_no_tcb",
224 	    KSTAT_DATA_UINT64);
225 	kstat_named_init(&ixgbe_ks->tx_fail_dma_bind, "tx_fail_dma_bind",
226 	    KSTAT_DATA_UINT64);
227 	kstat_named_init(&ixgbe_ks->tx_reschedule, "tx_reschedule",
228 	    KSTAT_DATA_UINT64);
229 #endif
230 
231 	kstat_named_init(&ixgbe_ks->gprc, "good_pkts_recvd",
232 	    KSTAT_DATA_UINT64);
233 	kstat_named_init(&ixgbe_ks->gptc, "good_pkts_xmitd",
234 	    KSTAT_DATA_UINT64);
235 	kstat_named_init(&ixgbe_ks->gor, "good_octets_recvd",
236 	    KSTAT_DATA_UINT64);
237 	kstat_named_init(&ixgbe_ks->got, "good_octets_xmitd",
238 	    KSTAT_DATA_UINT64);
239 	kstat_named_init(&ixgbe_ks->prc64, "pkts_recvd_(  64b)",
240 	    KSTAT_DATA_UINT64);
241 	kstat_named_init(&ixgbe_ks->prc127, "pkts_recvd_(  65- 127b)",
242 	    KSTAT_DATA_UINT64);
243 	kstat_named_init(&ixgbe_ks->prc255, "pkts_recvd_( 127- 255b)",
244 	    KSTAT_DATA_UINT64);
245 	kstat_named_init(&ixgbe_ks->prc511, "pkts_recvd_( 256- 511b)",
246 	    KSTAT_DATA_UINT64);
247 	kstat_named_init(&ixgbe_ks->prc1023, "pkts_recvd_( 511-1023b)",
248 	    KSTAT_DATA_UINT64);
249 	kstat_named_init(&ixgbe_ks->prc1522, "pkts_recvd_(1024-1522b)",
250 	    KSTAT_DATA_UINT64);
251 	kstat_named_init(&ixgbe_ks->ptc64, "pkts_xmitd_(  64b)",
252 	    KSTAT_DATA_UINT64);
253 	kstat_named_init(&ixgbe_ks->ptc127, "pkts_xmitd_(  65- 127b)",
254 	    KSTAT_DATA_UINT64);
255 	kstat_named_init(&ixgbe_ks->ptc255, "pkts_xmitd_( 128- 255b)",
256 	    KSTAT_DATA_UINT64);
257 	kstat_named_init(&ixgbe_ks->ptc511, "pkts_xmitd_( 255- 511b)",
258 	    KSTAT_DATA_UINT64);
259 	kstat_named_init(&ixgbe_ks->ptc1023, "pkts_xmitd_( 512-1023b)",
260 	    KSTAT_DATA_UINT64);
261 	kstat_named_init(&ixgbe_ks->ptc1522, "pkts_xmitd_(1024-1522b)",
262 	    KSTAT_DATA_UINT64);
263 
264 	kstat_named_init(&ixgbe_ks->qprc[0], "queue_pkts_recvd [ 0]",
265 	    KSTAT_DATA_UINT64);
266 	kstat_named_init(&ixgbe_ks->qprc[1], "queue_pkts_recvd [ 1]",
267 	    KSTAT_DATA_UINT64);
268 	kstat_named_init(&ixgbe_ks->qprc[2], "queue_pkts_recvd [ 2]",
269 	    KSTAT_DATA_UINT64);
270 	kstat_named_init(&ixgbe_ks->qprc[3], "queue_pkts_recvd [ 3]",
271 	    KSTAT_DATA_UINT64);
272 	kstat_named_init(&ixgbe_ks->qprc[4], "queue_pkts_recvd [ 4]",
273 	    KSTAT_DATA_UINT64);
274 	kstat_named_init(&ixgbe_ks->qprc[5], "queue_pkts_recvd [ 5]",
275 	    KSTAT_DATA_UINT64);
276 	kstat_named_init(&ixgbe_ks->qprc[6], "queue_pkts_recvd [ 6]",
277 	    KSTAT_DATA_UINT64);
278 	kstat_named_init(&ixgbe_ks->qprc[7], "queue_pkts_recvd [ 7]",
279 	    KSTAT_DATA_UINT64);
280 	kstat_named_init(&ixgbe_ks->qprc[8], "queue_pkts_recvd [ 8]",
281 	    KSTAT_DATA_UINT64);
282 	kstat_named_init(&ixgbe_ks->qprc[9], "queue_pkts_recvd [ 9]",
283 	    KSTAT_DATA_UINT64);
284 	kstat_named_init(&ixgbe_ks->qprc[10], "queue_pkts_recvd [10]",
285 	    KSTAT_DATA_UINT64);
286 	kstat_named_init(&ixgbe_ks->qprc[11], "queue_pkts_recvd [11]",
287 	    KSTAT_DATA_UINT64);
288 	kstat_named_init(&ixgbe_ks->qprc[12], "queue_pkts_recvd [12]",
289 	    KSTAT_DATA_UINT64);
290 	kstat_named_init(&ixgbe_ks->qprc[13], "queue_pkts_recvd [13]",
291 	    KSTAT_DATA_UINT64);
292 	kstat_named_init(&ixgbe_ks->qprc[14], "queue_pkts_recvd [14]",
293 	    KSTAT_DATA_UINT64);
294 	kstat_named_init(&ixgbe_ks->qprc[15], "queue_pkts_recvd [15]",
295 	    KSTAT_DATA_UINT64);
296 
297 	kstat_named_init(&ixgbe_ks->qptc[0], "queue_pkts_xmitd [ 0]",
298 	    KSTAT_DATA_UINT64);
299 	kstat_named_init(&ixgbe_ks->qptc[1], "queue_pkts_xmitd [ 1]",
300 	    KSTAT_DATA_UINT64);
301 	kstat_named_init(&ixgbe_ks->qptc[2], "queue_pkts_xmitd [ 2]",
302 	    KSTAT_DATA_UINT64);
303 	kstat_named_init(&ixgbe_ks->qptc[3], "queue_pkts_xmitd [ 3]",
304 	    KSTAT_DATA_UINT64);
305 	kstat_named_init(&ixgbe_ks->qptc[4], "queue_pkts_xmitd [ 4]",
306 	    KSTAT_DATA_UINT64);
307 	kstat_named_init(&ixgbe_ks->qptc[5], "queue_pkts_xmitd [ 5]",
308 	    KSTAT_DATA_UINT64);
309 	kstat_named_init(&ixgbe_ks->qptc[6], "queue_pkts_xmitd [ 6]",
310 	    KSTAT_DATA_UINT64);
311 	kstat_named_init(&ixgbe_ks->qptc[7], "queue_pkts_xmitd [ 7]",
312 	    KSTAT_DATA_UINT64);
313 	kstat_named_init(&ixgbe_ks->qptc[8], "queue_pkts_xmitd [ 8]",
314 	    KSTAT_DATA_UINT64);
315 	kstat_named_init(&ixgbe_ks->qptc[9], "queue_pkts_xmitd [ 9]",
316 	    KSTAT_DATA_UINT64);
317 	kstat_named_init(&ixgbe_ks->qptc[10], "queue_pkts_xmitd [10]",
318 	    KSTAT_DATA_UINT64);
319 	kstat_named_init(&ixgbe_ks->qptc[11], "queue_pkts_xmitd [11]",
320 	    KSTAT_DATA_UINT64);
321 	kstat_named_init(&ixgbe_ks->qptc[12], "queue_pkts_xmitd [12]",
322 	    KSTAT_DATA_UINT64);
323 	kstat_named_init(&ixgbe_ks->qptc[13], "queue_pkts_xmitd [13]",
324 	    KSTAT_DATA_UINT64);
325 	kstat_named_init(&ixgbe_ks->qptc[14], "queue_pkts_xmitd [14]",
326 	    KSTAT_DATA_UINT64);
327 	kstat_named_init(&ixgbe_ks->qptc[15], "queue_pkts_xmitd [15]",
328 	    KSTAT_DATA_UINT64);
329 
330 	kstat_named_init(&ixgbe_ks->qbrc[0], "queue_bytes_recvd [ 0]",
331 	    KSTAT_DATA_UINT64);
332 	kstat_named_init(&ixgbe_ks->qbrc[1], "queue_bytes_recvd [ 1]",
333 	    KSTAT_DATA_UINT64);
334 	kstat_named_init(&ixgbe_ks->qbrc[2], "queue_bytes_recvd [ 2]",
335 	    KSTAT_DATA_UINT64);
336 	kstat_named_init(&ixgbe_ks->qbrc[3], "queue_bytes_recvd [ 3]",
337 	    KSTAT_DATA_UINT64);
338 	kstat_named_init(&ixgbe_ks->qbrc[4], "queue_bytes_recvd [ 4]",
339 	    KSTAT_DATA_UINT64);
340 	kstat_named_init(&ixgbe_ks->qbrc[5], "queue_bytes_recvd [ 5]",
341 	    KSTAT_DATA_UINT64);
342 	kstat_named_init(&ixgbe_ks->qbrc[6], "queue_bytes_recvd [ 6]",
343 	    KSTAT_DATA_UINT64);
344 	kstat_named_init(&ixgbe_ks->qbrc[7], "queue_bytes_recvd [ 7]",
345 	    KSTAT_DATA_UINT64);
346 	kstat_named_init(&ixgbe_ks->qbrc[8], "queue_bytes_recvd [ 8]",
347 	    KSTAT_DATA_UINT64);
348 	kstat_named_init(&ixgbe_ks->qbrc[9], "queue_bytes_recvd [ 9]",
349 	    KSTAT_DATA_UINT64);
350 	kstat_named_init(&ixgbe_ks->qbrc[10], "queue_bytes_recvd [10]",
351 	    KSTAT_DATA_UINT64);
352 	kstat_named_init(&ixgbe_ks->qbrc[11], "queue_bytes_recvd [11]",
353 	    KSTAT_DATA_UINT64);
354 	kstat_named_init(&ixgbe_ks->qbrc[12], "queue_bytes_recvd [12]",
355 	    KSTAT_DATA_UINT64);
356 	kstat_named_init(&ixgbe_ks->qbrc[13], "queue_bytes_recvd [13]",
357 	    KSTAT_DATA_UINT64);
358 	kstat_named_init(&ixgbe_ks->qbrc[14], "queue_bytes_recvd [14]",
359 	    KSTAT_DATA_UINT64);
360 	kstat_named_init(&ixgbe_ks->qbrc[15], "queue_bytes_recvd [15]",
361 	    KSTAT_DATA_UINT64);
362 
363 	kstat_named_init(&ixgbe_ks->qbtc[0], "queue_bytes_xmitd [ 0]",
364 	    KSTAT_DATA_UINT64);
365 	kstat_named_init(&ixgbe_ks->qbtc[1], "queue_bytes_xmitd [ 1]",
366 	    KSTAT_DATA_UINT64);
367 	kstat_named_init(&ixgbe_ks->qbtc[2], "queue_bytes_xmitd [ 2]",
368 	    KSTAT_DATA_UINT64);
369 	kstat_named_init(&ixgbe_ks->qbtc[3], "queue_bytes_xmitd [ 3]",
370 	    KSTAT_DATA_UINT64);
371 	kstat_named_init(&ixgbe_ks->qbtc[4], "queue_bytes_xmitd [ 4]",
372 	    KSTAT_DATA_UINT64);
373 	kstat_named_init(&ixgbe_ks->qbtc[5], "queue_bytes_xmitd [ 5]",
374 	    KSTAT_DATA_UINT64);
375 	kstat_named_init(&ixgbe_ks->qbtc[6], "queue_bytes_xmitd [ 6]",
376 	    KSTAT_DATA_UINT64);
377 	kstat_named_init(&ixgbe_ks->qbtc[7], "queue_bytes_xmitd [ 7]",
378 	    KSTAT_DATA_UINT64);
379 	kstat_named_init(&ixgbe_ks->qbtc[8], "queue_bytes_xmitd [ 8]",
380 	    KSTAT_DATA_UINT64);
381 	kstat_named_init(&ixgbe_ks->qbtc[9], "queue_bytes_xmitd [ 9]",
382 	    KSTAT_DATA_UINT64);
383 	kstat_named_init(&ixgbe_ks->qbtc[10], "queue_bytes_xmitd [10]",
384 	    KSTAT_DATA_UINT64);
385 	kstat_named_init(&ixgbe_ks->qbtc[11], "queue_bytes_xmitd [11]",
386 	    KSTAT_DATA_UINT64);
387 	kstat_named_init(&ixgbe_ks->qbtc[12], "queue_bytes_xmitd [12]",
388 	    KSTAT_DATA_UINT64);
389 	kstat_named_init(&ixgbe_ks->qbtc[13], "queue_bytes_xmitd [13]",
390 	    KSTAT_DATA_UINT64);
391 	kstat_named_init(&ixgbe_ks->qbtc[14], "queue_bytes_xmitd [14]",
392 	    KSTAT_DATA_UINT64);
393 	kstat_named_init(&ixgbe_ks->qbtc[15], "queue_bytes_xmitd [15]",
394 	    KSTAT_DATA_UINT64);
395 
396 	kstat_named_init(&ixgbe_ks->mspdc, "mac_short_packet_discard",
397 	    KSTAT_DATA_UINT64);
398 	kstat_named_init(&ixgbe_ks->mpc, "missed_packets",
399 	    KSTAT_DATA_UINT64);
400 	kstat_named_init(&ixgbe_ks->mlfc, "mac_local_fault",
401 	    KSTAT_DATA_UINT64);
402 	kstat_named_init(&ixgbe_ks->mrfc, "mac_remote_fault",
403 	    KSTAT_DATA_UINT64);
404 	kstat_named_init(&ixgbe_ks->rlec, "recv_length_err",
405 	    KSTAT_DATA_UINT64);
406 	kstat_named_init(&ixgbe_ks->lxontxc, "link_xon_xmitd",
407 	    KSTAT_DATA_UINT64);
408 	kstat_named_init(&ixgbe_ks->lxonrxc, "link_xon_recvd",
409 	    KSTAT_DATA_UINT64);
410 	kstat_named_init(&ixgbe_ks->lxofftxc, "link_xoff_xmitd",
411 	    KSTAT_DATA_UINT64);
412 	kstat_named_init(&ixgbe_ks->lxoffrxc, "link_xoff_recvd",
413 	    KSTAT_DATA_UINT64);
414 	kstat_named_init(&ixgbe_ks->ruc, "recv_undersize",
415 	    KSTAT_DATA_UINT64);
416 	kstat_named_init(&ixgbe_ks->rfc, "recv_fragment",
417 	    KSTAT_DATA_UINT64);
418 	kstat_named_init(&ixgbe_ks->roc, "recv_oversize",
419 	    KSTAT_DATA_UINT64);
420 	kstat_named_init(&ixgbe_ks->rjc, "recv_jabber",
421 	    KSTAT_DATA_UINT64);
422 	kstat_named_init(&ixgbe_ks->rnbc, "recv_no_buffer",
423 	    KSTAT_DATA_UINT64);
424 
425 	/*
426 	 * Function to provide kernel stat update on demand
427 	 */
428 	ks->ks_update = ixgbe_update_stats;
429 
430 	ks->ks_private = (void *)ixgbe;
431 
432 	/*
433 	 * Add kstat to systems kstat chain
434 	 */
435 	kstat_install(ks);
436 
437 	return (IXGBE_SUCCESS);
438 }
439