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