xref: /titanic_44/usr/src/uts/common/io/ixgbe/ixgbe_stat.c (revision 95342ccd87e1481982e8ebd57585074a177da551)
19da57d7bSbt150084 /*
29da57d7bSbt150084  * CDDL HEADER START
39da57d7bSbt150084  *
49da57d7bSbt150084  * The contents of this file are subject to the terms of the
59da57d7bSbt150084  * Common Development and Distribution License (the "License").
69da57d7bSbt150084  * You may not use this file except in compliance with the License.
79da57d7bSbt150084  *
8da14cebeSEric Cheng  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da14cebeSEric Cheng  * or http://www.opensolaris.org/os/licensing.
109da57d7bSbt150084  * See the License for the specific language governing permissions
119da57d7bSbt150084  * and limitations under the License.
129da57d7bSbt150084  *
13da14cebeSEric Cheng  * When distributing Covered Code, include this CDDL HEADER in each
14da14cebeSEric Cheng  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159da57d7bSbt150084  * If applicable, add the following below this CDDL HEADER, with the
169da57d7bSbt150084  * fields enclosed by brackets "[]" replaced with your own identifying
179da57d7bSbt150084  * information: Portions Copyright [yyyy] [name of copyright owner]
189da57d7bSbt150084  *
199da57d7bSbt150084  * CDDL HEADER END
209da57d7bSbt150084  */
219da57d7bSbt150084 
229da57d7bSbt150084 /*
235b6dd21fSchenlu chen - Sun Microsystems - Beijing China  * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
245b6dd21fSchenlu chen - Sun Microsystems - Beijing China  */
255b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
265b6dd21fSchenlu chen - Sun Microsystems - Beijing China /*
275b6dd21fSchenlu chen - Sun Microsystems - Beijing China  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2869b5a878SDan McDonald  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
29313ba796SDale Ghent  * Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved.
30*95342ccdSRobert Mustacchi  * Copyright (c) 2017, Joyent, Inc.
31da14cebeSEric Cheng  */
329da57d7bSbt150084 
339da57d7bSbt150084 #include "ixgbe_sw.h"
349da57d7bSbt150084 
359da57d7bSbt150084 /*
369da57d7bSbt150084  * Update driver private statistics.
379da57d7bSbt150084  */
389da57d7bSbt150084 static int
ixgbe_update_stats(kstat_t * ks,int rw)399da57d7bSbt150084 ixgbe_update_stats(kstat_t *ks, int rw)
409da57d7bSbt150084 {
419da57d7bSbt150084 	ixgbe_t *ixgbe;
429da57d7bSbt150084 	struct ixgbe_hw *hw;
439da57d7bSbt150084 	ixgbe_stat_t *ixgbe_ks;
449da57d7bSbt150084 	int i;
459da57d7bSbt150084 
469da57d7bSbt150084 	if (rw == KSTAT_WRITE)
479da57d7bSbt150084 		return (EACCES);
489da57d7bSbt150084 
499da57d7bSbt150084 	ixgbe = (ixgbe_t *)ks->ks_private;
509da57d7bSbt150084 	ixgbe_ks = (ixgbe_stat_t *)ks->ks_data;
519da57d7bSbt150084 	hw = &ixgbe->hw;
529da57d7bSbt150084 
539da57d7bSbt150084 	mutex_enter(&ixgbe->gen_lock);
549da57d7bSbt150084 
559da57d7bSbt150084 	/*
569da57d7bSbt150084 	 * Basic information
579da57d7bSbt150084 	 */
589da57d7bSbt150084 	ixgbe_ks->link_speed.value.ui64 = ixgbe->link_speed;
599da57d7bSbt150084 	ixgbe_ks->reset_count.value.ui64 = ixgbe->reset_count;
60ffd8e883SWinson Wang - Sun Microsystems - Beijing China 	ixgbe_ks->lroc.value.ui64 = ixgbe->lro_pkt_count;
619da57d7bSbt150084 
629da57d7bSbt150084 	ixgbe_ks->rx_frame_error.value.ui64 = 0;
639da57d7bSbt150084 	ixgbe_ks->rx_cksum_error.value.ui64 = 0;
649da57d7bSbt150084 	ixgbe_ks->rx_exceed_pkt.value.ui64 = 0;
659da57d7bSbt150084 	for (i = 0; i < ixgbe->num_rx_rings; i++) {
669da57d7bSbt150084 		ixgbe_ks->rx_frame_error.value.ui64 +=
679da57d7bSbt150084 		    ixgbe->rx_rings[i].stat_frame_error;
689da57d7bSbt150084 		ixgbe_ks->rx_cksum_error.value.ui64 +=
699da57d7bSbt150084 		    ixgbe->rx_rings[i].stat_cksum_error;
709da57d7bSbt150084 		ixgbe_ks->rx_exceed_pkt.value.ui64 +=
719da57d7bSbt150084 		    ixgbe->rx_rings[i].stat_exceed_pkt;
729da57d7bSbt150084 	}
739da57d7bSbt150084 
749da57d7bSbt150084 	ixgbe_ks->tx_overload.value.ui64 = 0;
759da57d7bSbt150084 	ixgbe_ks->tx_fail_no_tbd.value.ui64 = 0;
769da57d7bSbt150084 	ixgbe_ks->tx_fail_no_tcb.value.ui64 = 0;
779da57d7bSbt150084 	ixgbe_ks->tx_fail_dma_bind.value.ui64 = 0;
789da57d7bSbt150084 	ixgbe_ks->tx_reschedule.value.ui64 = 0;
79b7a75625SRyan Zezeski 	ixgbe_ks->tx_break_tbd_limit.value.ui64 = 0;
80b7a75625SRyan Zezeski 	ixgbe_ks->tx_lso_header_fail.value.ui64 = 0;
819da57d7bSbt150084 	for (i = 0; i < ixgbe->num_tx_rings; i++) {
829da57d7bSbt150084 		ixgbe_ks->tx_overload.value.ui64 +=
839da57d7bSbt150084 		    ixgbe->tx_rings[i].stat_overload;
849da57d7bSbt150084 		ixgbe_ks->tx_fail_no_tbd.value.ui64 +=
859da57d7bSbt150084 		    ixgbe->tx_rings[i].stat_fail_no_tbd;
869da57d7bSbt150084 		ixgbe_ks->tx_fail_no_tcb.value.ui64 +=
879da57d7bSbt150084 		    ixgbe->tx_rings[i].stat_fail_no_tcb;
889da57d7bSbt150084 		ixgbe_ks->tx_fail_dma_bind.value.ui64 +=
899da57d7bSbt150084 		    ixgbe->tx_rings[i].stat_fail_dma_bind;
909da57d7bSbt150084 		ixgbe_ks->tx_reschedule.value.ui64 +=
919da57d7bSbt150084 		    ixgbe->tx_rings[i].stat_reschedule;
92b7a75625SRyan Zezeski 		ixgbe_ks->tx_break_tbd_limit.value.ui64 +=
93b7a75625SRyan Zezeski 		    ixgbe->tx_rings[i].stat_break_tbd_limit;
94b7a75625SRyan Zezeski 		ixgbe_ks->tx_lso_header_fail.value.ui64 +=
95b7a75625SRyan Zezeski 		    ixgbe->tx_rings[i].stat_lso_header_fail;
969da57d7bSbt150084 	}
979da57d7bSbt150084 
989da57d7bSbt150084 	/*
999da57d7bSbt150084 	 * Hardware calculated statistics.
1009da57d7bSbt150084 	 */
101da14cebeSEric Cheng 	ixgbe_ks->gprc.value.ui64 = 0;
102da14cebeSEric Cheng 	ixgbe_ks->gptc.value.ui64 = 0;
103da14cebeSEric Cheng 	ixgbe_ks->tor.value.ui64 = 0;
104da14cebeSEric Cheng 	ixgbe_ks->tot.value.ui64 = 0;
1059da57d7bSbt150084 	for (i = 0; i < 16; i++) {
106da14cebeSEric Cheng 		ixgbe_ks->qprc[i].value.ui64 +=
107da14cebeSEric Cheng 		    IXGBE_READ_REG(hw, IXGBE_QPRC(i));
108da14cebeSEric Cheng 		ixgbe_ks->gprc.value.ui64 += ixgbe_ks->qprc[i].value.ui64;
109da14cebeSEric Cheng 		ixgbe_ks->qptc[i].value.ui64 +=
110da14cebeSEric Cheng 		    IXGBE_READ_REG(hw, IXGBE_QPTC(i));
111da14cebeSEric Cheng 		ixgbe_ks->gptc.value.ui64 += ixgbe_ks->qptc[i].value.ui64;
112da14cebeSEric Cheng 		ixgbe_ks->qbrc[i].value.ui64 +=
113da14cebeSEric Cheng 		    IXGBE_READ_REG(hw, IXGBE_QBRC(i));
114da14cebeSEric Cheng 		ixgbe_ks->tor.value.ui64 += ixgbe_ks->qbrc[i].value.ui64;
1155b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		switch (hw->mac.type) {
1165b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		case ixgbe_mac_82598EB:
117da14cebeSEric Cheng 			ixgbe_ks->qbtc[i].value.ui64 +=
118da14cebeSEric Cheng 			    IXGBE_READ_REG(hw, IXGBE_QBTC(i));
1195b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			break;
1205b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
1215b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		case ixgbe_mac_82599EB:
12269b5a878SDan McDonald 		case ixgbe_mac_X540:
123313ba796SDale Ghent 		case ixgbe_mac_X550:
124313ba796SDale Ghent 		case ixgbe_mac_X550EM_x:
1255b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			ixgbe_ks->qbtc[i].value.ui64 +=
1265b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			    IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
1275b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			ixgbe_ks->qbtc[i].value.ui64 +=
1285b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			    ((uint64_t)((IXGBE_READ_REG(hw,
1295b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			    IXGBE_QBTC_H(i))) & 0xF) << 32);
1305b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			break;
1315b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
1325b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		default:
1335b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			break;
13473cd555cSBin Tu - Sun Microsystems - Beijing China 		}
135da14cebeSEric Cheng 		ixgbe_ks->tot.value.ui64 += ixgbe_ks->qbtc[i].value.ui64;
1369da57d7bSbt150084 	}
137f27d3025Sgg161487 	/*
138f27d3025Sgg161487 	 * This is a Workaround:
139f27d3025Sgg161487 	 * Currently h/w GORCH, GOTCH, TORH registers are not
140f27d3025Sgg161487 	 * correctly implemented. We found that the values in
141f27d3025Sgg161487 	 * these registers are same as those in corresponding
142f27d3025Sgg161487 	 * *L registers (i.e. GORCL, GOTCL, and TORL). Here the
143f27d3025Sgg161487 	 * gor and got stat data will not be retrieved through
144f27d3025Sgg161487 	 * GORC{H/L} and GOTC{H/L} registers but be obtained by
145f27d3025Sgg161487 	 * simply assigning tor/tot stat data, so the gor/got
146f27d3025Sgg161487 	 * stat data will not be accurate.
147f27d3025Sgg161487 	 */
1489da57d7bSbt150084 	ixgbe_ks->gor.value.ui64 = ixgbe_ks->tor.value.ui64;
149f27d3025Sgg161487 	ixgbe_ks->got.value.ui64 = ixgbe_ks->tot.value.ui64;
1509da57d7bSbt150084 
1519da57d7bSbt150084 	ixgbe_ks->prc64.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC64);
1529da57d7bSbt150084 	ixgbe_ks->prc127.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC127);
1539da57d7bSbt150084 	ixgbe_ks->prc255.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC255);
1549da57d7bSbt150084 	ixgbe_ks->prc511.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC511);
1559da57d7bSbt150084 	ixgbe_ks->prc1023.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC1023);
1569da57d7bSbt150084 	ixgbe_ks->prc1522.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC1522);
1579da57d7bSbt150084 	ixgbe_ks->ptc64.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC64);
1589da57d7bSbt150084 	ixgbe_ks->ptc127.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC127);
1599da57d7bSbt150084 	ixgbe_ks->ptc255.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC255);
1609da57d7bSbt150084 	ixgbe_ks->ptc511.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC511);
1619da57d7bSbt150084 	ixgbe_ks->ptc1023.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC1023);
1629da57d7bSbt150084 	ixgbe_ks->ptc1522.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC1522);
1639da57d7bSbt150084 
1649da57d7bSbt150084 	ixgbe_ks->mspdc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MSPDC);
1659da57d7bSbt150084 	for (i = 0; i < 8; i++)
1669da57d7bSbt150084 		ixgbe_ks->mpc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MPC(i));
1679da57d7bSbt150084 	ixgbe_ks->mlfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MLFC);
1689da57d7bSbt150084 	ixgbe_ks->mrfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MRFC);
1699da57d7bSbt150084 	ixgbe_ks->rlec.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RLEC);
1709da57d7bSbt150084 	ixgbe_ks->lxontxc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_LXONTXC);
1715b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	switch (hw->mac.type) {
1725b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	case ixgbe_mac_82598EB:
17373cd555cSBin Tu - Sun Microsystems - Beijing China 		ixgbe_ks->lxonrxc.value.ui64 += IXGBE_READ_REG(hw,
17473cd555cSBin Tu - Sun Microsystems - Beijing China 		    IXGBE_LXONRXC);
1755b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		break;
1765b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
1775b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	case ixgbe_mac_82599EB:
17869b5a878SDan McDonald 	case ixgbe_mac_X540:
179313ba796SDale Ghent 	case ixgbe_mac_X550:
180313ba796SDale Ghent 	case ixgbe_mac_X550EM_x:
18173cd555cSBin Tu - Sun Microsystems - Beijing China 		ixgbe_ks->lxonrxc.value.ui64 += IXGBE_READ_REG(hw,
18273cd555cSBin Tu - Sun Microsystems - Beijing China 		    IXGBE_LXONRXCNT);
1835b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		break;
1845b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
1855b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	default:
1865b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		break;
18773cd555cSBin Tu - Sun Microsystems - Beijing China 	}
1889da57d7bSbt150084 	ixgbe_ks->lxofftxc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
1895b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	switch (hw->mac.type) {
1905b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	case ixgbe_mac_82598EB:
19173cd555cSBin Tu - Sun Microsystems - Beijing China 		ixgbe_ks->lxoffrxc.value.ui64 += IXGBE_READ_REG(hw,
19273cd555cSBin Tu - Sun Microsystems - Beijing China 		    IXGBE_LXOFFRXC);
1935b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		break;
1945b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
1955b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	case ixgbe_mac_82599EB:
19669b5a878SDan McDonald 	case ixgbe_mac_X540:
197313ba796SDale Ghent 	case ixgbe_mac_X550:
198313ba796SDale Ghent 	case ixgbe_mac_X550EM_x:
19973cd555cSBin Tu - Sun Microsystems - Beijing China 		ixgbe_ks->lxoffrxc.value.ui64 += IXGBE_READ_REG(hw,
20073cd555cSBin Tu - Sun Microsystems - Beijing China 		    IXGBE_LXOFFRXCNT);
2015b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		break;
2025b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
2035b6dd21fSchenlu chen - Sun Microsystems - Beijing China 	default:
2045b6dd21fSchenlu chen - Sun Microsystems - Beijing China 		break;
20573cd555cSBin Tu - Sun Microsystems - Beijing China 	}
2069da57d7bSbt150084 	ixgbe_ks->ruc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RUC);
2079da57d7bSbt150084 	ixgbe_ks->rfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RFC);
2089da57d7bSbt150084 	ixgbe_ks->roc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_ROC);
2099da57d7bSbt150084 	ixgbe_ks->rjc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RJC);
2109da57d7bSbt150084 
2119da57d7bSbt150084 	mutex_exit(&ixgbe->gen_lock);
2129da57d7bSbt150084 
2139da57d7bSbt150084 	if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK)
2149da57d7bSbt150084 		ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_UNAFFECTED);
2159da57d7bSbt150084 
2169da57d7bSbt150084 	return (0);
2179da57d7bSbt150084 }
2189da57d7bSbt150084 
2199da57d7bSbt150084 /*
2209da57d7bSbt150084  * Create and initialize the driver private statistics.
2219da57d7bSbt150084  */
2229da57d7bSbt150084 int
ixgbe_init_stats(ixgbe_t * ixgbe)2239da57d7bSbt150084 ixgbe_init_stats(ixgbe_t *ixgbe)
2249da57d7bSbt150084 {
2259da57d7bSbt150084 	kstat_t *ks;
2269da57d7bSbt150084 	ixgbe_stat_t *ixgbe_ks;
2279da57d7bSbt150084 
2289da57d7bSbt150084 	/*
2299da57d7bSbt150084 	 * Create and init kstat
2309da57d7bSbt150084 	 */
2319da57d7bSbt150084 	ks = kstat_create(MODULE_NAME, ddi_get_instance(ixgbe->dip),
2329da57d7bSbt150084 	    "statistics", "net", KSTAT_TYPE_NAMED,
2339da57d7bSbt150084 	    sizeof (ixgbe_stat_t) / sizeof (kstat_named_t), 0);
2349da57d7bSbt150084 
2359da57d7bSbt150084 	if (ks == NULL) {
2369da57d7bSbt150084 		ixgbe_error(ixgbe,
2379da57d7bSbt150084 		    "Could not create kernel statistics");
2389da57d7bSbt150084 		return (IXGBE_FAILURE);
2399da57d7bSbt150084 	}
2409da57d7bSbt150084 
2419da57d7bSbt150084 	ixgbe->ixgbe_ks = ks;
2429da57d7bSbt150084 
2439da57d7bSbt150084 	ixgbe_ks = (ixgbe_stat_t *)ks->ks_data;
2449da57d7bSbt150084 
2459da57d7bSbt150084 	/*
2469da57d7bSbt150084 	 * Initialize all the statistics.
2479da57d7bSbt150084 	 */
2489da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->link_speed, "link_speed",
2499da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2509da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->reset_count, "reset_count",
2519da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2523cfa0eb9Schenlu chen - Sun Microsystems - Beijing China 
2539da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->rx_frame_error, "rx_frame_error",
2549da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2559da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->rx_cksum_error, "rx_cksum_error",
2569da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2579da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->rx_exceed_pkt, "rx_exceed_pkt",
2589da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2599da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->tx_overload, "tx_overload",
2609da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2619da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->tx_fail_no_tbd, "tx_fail_no_tbd",
2629da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2639da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->tx_fail_no_tcb, "tx_fail_no_tcb",
2649da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2659da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->tx_fail_dma_bind, "tx_fail_dma_bind",
2669da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2679da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->tx_reschedule, "tx_reschedule",
2689da57d7bSbt150084 	    KSTAT_DATA_UINT64);
269b7a75625SRyan Zezeski 	kstat_named_init(&ixgbe_ks->tx_break_tbd_limit, "tx_break_tbd_limit",
270b7a75625SRyan Zezeski 	    KSTAT_DATA_UINT64);
271b7a75625SRyan Zezeski 	kstat_named_init(&ixgbe_ks->tx_lso_header_fail, "tx_lso_header_fail",
272b7a75625SRyan Zezeski 	    KSTAT_DATA_UINT64);
2739da57d7bSbt150084 
2749da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->gprc, "good_pkts_recvd",
2759da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2769da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->gptc, "good_pkts_xmitd",
2779da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2789da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->gor, "good_octets_recvd",
2799da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2809da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->got, "good_octets_xmitd",
2819da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2829da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->prc64, "pkts_recvd_(  64b)",
2839da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2849da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->prc127, "pkts_recvd_(  65- 127b)",
2859da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2869da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->prc255, "pkts_recvd_( 127- 255b)",
2879da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2889da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->prc511, "pkts_recvd_( 256- 511b)",
2899da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2909da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->prc1023, "pkts_recvd_( 511-1023b)",
2919da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2929da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->prc1522, "pkts_recvd_(1024-1522b)",
2939da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2949da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ptc64, "pkts_xmitd_(  64b)",
2959da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2969da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ptc127, "pkts_xmitd_(  65- 127b)",
2979da57d7bSbt150084 	    KSTAT_DATA_UINT64);
2989da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ptc255, "pkts_xmitd_( 128- 255b)",
2999da57d7bSbt150084 	    KSTAT_DATA_UINT64);
3009da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ptc511, "pkts_xmitd_( 255- 511b)",
3019da57d7bSbt150084 	    KSTAT_DATA_UINT64);
3029da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ptc1023, "pkts_xmitd_( 512-1023b)",
3039da57d7bSbt150084 	    KSTAT_DATA_UINT64);
3049da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ptc1522, "pkts_xmitd_(1024-1522b)",
3059da57d7bSbt150084 	    KSTAT_DATA_UINT64);
306da14cebeSEric Cheng 
307da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[0], "queue_pkts_recvd [ 0]",
308da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
309da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[1], "queue_pkts_recvd [ 1]",
310da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
311da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[2], "queue_pkts_recvd [ 2]",
312da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
313da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[3], "queue_pkts_recvd [ 3]",
314da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
315da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[4], "queue_pkts_recvd [ 4]",
316da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
317da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[5], "queue_pkts_recvd [ 5]",
318da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
319da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[6], "queue_pkts_recvd [ 6]",
320da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
321da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[7], "queue_pkts_recvd [ 7]",
322da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
323da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[8], "queue_pkts_recvd [ 8]",
324da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
325da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[9], "queue_pkts_recvd [ 9]",
326da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
327da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[10], "queue_pkts_recvd [10]",
328da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
329da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[11], "queue_pkts_recvd [11]",
330da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
331da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[12], "queue_pkts_recvd [12]",
332da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
333da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[13], "queue_pkts_recvd [13]",
334da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
335da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[14], "queue_pkts_recvd [14]",
336da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
337da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qprc[15], "queue_pkts_recvd [15]",
338da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
339da14cebeSEric Cheng 
340da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[0], "queue_pkts_xmitd [ 0]",
341da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
342da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[1], "queue_pkts_xmitd [ 1]",
343da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
344da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[2], "queue_pkts_xmitd [ 2]",
345da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
346da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[3], "queue_pkts_xmitd [ 3]",
347da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
348da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[4], "queue_pkts_xmitd [ 4]",
349da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
350da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[5], "queue_pkts_xmitd [ 5]",
351da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
352da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[6], "queue_pkts_xmitd [ 6]",
353da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
354da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[7], "queue_pkts_xmitd [ 7]",
355da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
356da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[8], "queue_pkts_xmitd [ 8]",
357da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
358da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[9], "queue_pkts_xmitd [ 9]",
359da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
360da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[10], "queue_pkts_xmitd [10]",
361da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
362da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[11], "queue_pkts_xmitd [11]",
363da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
364da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[12], "queue_pkts_xmitd [12]",
365da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
366da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[13], "queue_pkts_xmitd [13]",
367da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
368da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[14], "queue_pkts_xmitd [14]",
369da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
370da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qptc[15], "queue_pkts_xmitd [15]",
371da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
372da14cebeSEric Cheng 
373da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[0], "queue_bytes_recvd [ 0]",
374da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
375da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[1], "queue_bytes_recvd [ 1]",
376da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
377da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[2], "queue_bytes_recvd [ 2]",
378da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
379da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[3], "queue_bytes_recvd [ 3]",
380da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
381da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[4], "queue_bytes_recvd [ 4]",
382da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
383da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[5], "queue_bytes_recvd [ 5]",
384da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
385da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[6], "queue_bytes_recvd [ 6]",
386da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
387da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[7], "queue_bytes_recvd [ 7]",
388da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
389da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[8], "queue_bytes_recvd [ 8]",
390da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
391da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[9], "queue_bytes_recvd [ 9]",
392da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
393da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[10], "queue_bytes_recvd [10]",
394da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
395da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[11], "queue_bytes_recvd [11]",
396da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
397da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[12], "queue_bytes_recvd [12]",
398da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
399da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[13], "queue_bytes_recvd [13]",
400da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
401da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[14], "queue_bytes_recvd [14]",
402da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
403da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbrc[15], "queue_bytes_recvd [15]",
404da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
405da14cebeSEric Cheng 
406da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[0], "queue_bytes_xmitd [ 0]",
407da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
408da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[1], "queue_bytes_xmitd [ 1]",
409da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
410da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[2], "queue_bytes_xmitd [ 2]",
411da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
412da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[3], "queue_bytes_xmitd [ 3]",
413da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
414da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[4], "queue_bytes_xmitd [ 4]",
415da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
416da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[5], "queue_bytes_xmitd [ 5]",
417da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
418da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[6], "queue_bytes_xmitd [ 6]",
419da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
420da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[7], "queue_bytes_xmitd [ 7]",
421da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
422da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[8], "queue_bytes_xmitd [ 8]",
423da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
424da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[9], "queue_bytes_xmitd [ 9]",
425da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
426da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[10], "queue_bytes_xmitd [10]",
427da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
428da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[11], "queue_bytes_xmitd [11]",
429da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
430da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[12], "queue_bytes_xmitd [12]",
431da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
432da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[13], "queue_bytes_xmitd [13]",
433da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
434da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[14], "queue_bytes_xmitd [14]",
435da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
436da14cebeSEric Cheng 	kstat_named_init(&ixgbe_ks->qbtc[15], "queue_bytes_xmitd [15]",
437da14cebeSEric Cheng 	    KSTAT_DATA_UINT64);
4389da57d7bSbt150084 
4399da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->mspdc, "mac_short_packet_discard",
4409da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4419da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->mpc, "missed_packets",
4429da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4439da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->mlfc, "mac_local_fault",
4449da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4459da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->mrfc, "mac_remote_fault",
4469da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4479da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->rlec, "recv_length_err",
4489da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4499da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->lxontxc, "link_xon_xmitd",
4509da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4519da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->lxonrxc, "link_xon_recvd",
4529da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4539da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->lxofftxc, "link_xoff_xmitd",
4549da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4559da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->lxoffrxc, "link_xoff_recvd",
4569da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4579da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->ruc, "recv_undersize",
4589da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4599da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->rfc, "recv_fragment",
4609da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4619da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->roc, "recv_oversize",
4629da57d7bSbt150084 	    KSTAT_DATA_UINT64);
4639da57d7bSbt150084 	kstat_named_init(&ixgbe_ks->rjc, "recv_jabber",
4649da57d7bSbt150084 	    KSTAT_DATA_UINT64);
46513740cb2SPaul Guo 	kstat_named_init(&ixgbe_ks->rnbc, "recv_no_buffer",
46613740cb2SPaul Guo 	    KSTAT_DATA_UINT64);
467ffd8e883SWinson Wang - Sun Microsystems - Beijing China 	kstat_named_init(&ixgbe_ks->lroc, "lro_pkt_count",
468ffd8e883SWinson Wang - Sun Microsystems - Beijing China 	    KSTAT_DATA_UINT64);
469*95342ccdSRobert Mustacchi 
470*95342ccdSRobert Mustacchi 	kstat_named_init(&ixgbe_ks->dev_gone, "device_gone",
471*95342ccdSRobert Mustacchi 	    KSTAT_DATA_UINT64);
4729da57d7bSbt150084 	/*
4739da57d7bSbt150084 	 * Function to provide kernel stat update on demand
4749da57d7bSbt150084 	 */
4759da57d7bSbt150084 	ks->ks_update = ixgbe_update_stats;
4769da57d7bSbt150084 
4779da57d7bSbt150084 	ks->ks_private = (void *)ixgbe;
4789da57d7bSbt150084 
4799da57d7bSbt150084 	/*
4809da57d7bSbt150084 	 * Add kstat to systems kstat chain
4819da57d7bSbt150084 	 */
4829da57d7bSbt150084 	kstat_install(ks);
4839da57d7bSbt150084 
4849da57d7bSbt150084 	return (IXGBE_SUCCESS);
4859da57d7bSbt150084 }
4860dc2366fSVenugopal Iyer 
4870dc2366fSVenugopal Iyer /*
4880dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics.
4890dc2366fSVenugopal Iyer  */
4900dc2366fSVenugopal Iyer int
ixgbe_m_stat(void * arg,uint_t stat,uint64_t * val)4910dc2366fSVenugopal Iyer ixgbe_m_stat(void *arg, uint_t stat, uint64_t *val)
4920dc2366fSVenugopal Iyer {
4930dc2366fSVenugopal Iyer 	ixgbe_t *ixgbe = (ixgbe_t *)arg;
4940dc2366fSVenugopal Iyer 	struct ixgbe_hw *hw = &ixgbe->hw;
4950dc2366fSVenugopal Iyer 	ixgbe_stat_t *ixgbe_ks;
4960dc2366fSVenugopal Iyer 	int i;
497313ba796SDale Ghent 	ixgbe_link_speed speeds = 0;
4980dc2366fSVenugopal Iyer 
4990dc2366fSVenugopal Iyer 	ixgbe_ks = (ixgbe_stat_t *)ixgbe->ixgbe_ks->ks_data;
5000dc2366fSVenugopal Iyer 
5010dc2366fSVenugopal Iyer 	mutex_enter(&ixgbe->gen_lock);
5020dc2366fSVenugopal Iyer 
503313ba796SDale Ghent 	/*
504313ba796SDale Ghent 	 * We cannot always rely on the common code maintaining
505313ba796SDale Ghent 	 * hw->phy.speeds_supported, therefore we fall back to use the recorded
506313ba796SDale Ghent 	 * supported speeds which were obtained during instance init in
507313ba796SDale Ghent 	 * ixgbe_init_params().
508313ba796SDale Ghent 	 */
509313ba796SDale Ghent 	speeds = hw->phy.speeds_supported;
510313ba796SDale Ghent 	if (speeds == 0)
511313ba796SDale Ghent 		speeds = ixgbe->speeds_supported;
512313ba796SDale Ghent 
5130dc2366fSVenugopal Iyer 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
5140dc2366fSVenugopal Iyer 		mutex_exit(&ixgbe->gen_lock);
5150dc2366fSVenugopal Iyer 		return (ECANCELED);
5160dc2366fSVenugopal Iyer 	}
5170dc2366fSVenugopal Iyer 
5180dc2366fSVenugopal Iyer 	switch (stat) {
5190dc2366fSVenugopal Iyer 	case MAC_STAT_IFSPEED:
5200dc2366fSVenugopal Iyer 		*val = ixgbe->link_speed * 1000000ull;
5210dc2366fSVenugopal Iyer 		break;
5220dc2366fSVenugopal Iyer 
5230dc2366fSVenugopal Iyer 	case MAC_STAT_MULTIRCV:
5240dc2366fSVenugopal Iyer 		ixgbe_ks->mprc.value.ui64 +=
5250dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_MPRC);
5260dc2366fSVenugopal Iyer 		*val = ixgbe_ks->mprc.value.ui64;
5270dc2366fSVenugopal Iyer 		break;
5280dc2366fSVenugopal Iyer 
5290dc2366fSVenugopal Iyer 	case MAC_STAT_BRDCSTRCV:
5300dc2366fSVenugopal Iyer 		ixgbe_ks->bprc.value.ui64 +=
5310dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_BPRC);
5320dc2366fSVenugopal Iyer 		*val = ixgbe_ks->bprc.value.ui64;
5330dc2366fSVenugopal Iyer 		break;
5340dc2366fSVenugopal Iyer 
5350dc2366fSVenugopal Iyer 	case MAC_STAT_MULTIXMT:
5360dc2366fSVenugopal Iyer 		ixgbe_ks->mptc.value.ui64 +=
5370dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_MPTC);
5380dc2366fSVenugopal Iyer 		*val = ixgbe_ks->mptc.value.ui64;
5390dc2366fSVenugopal Iyer 		break;
5400dc2366fSVenugopal Iyer 
5410dc2366fSVenugopal Iyer 	case MAC_STAT_BRDCSTXMT:
5420dc2366fSVenugopal Iyer 		ixgbe_ks->bptc.value.ui64 +=
5430dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_BPTC);
5440dc2366fSVenugopal Iyer 		*val = ixgbe_ks->bptc.value.ui64;
5450dc2366fSVenugopal Iyer 		break;
5460dc2366fSVenugopal Iyer 
5470dc2366fSVenugopal Iyer 	case MAC_STAT_NORCVBUF:
5480dc2366fSVenugopal Iyer 		for (i = 0; i < 8; i++) {
5490dc2366fSVenugopal Iyer 			ixgbe_ks->rnbc.value.ui64 +=
5500dc2366fSVenugopal Iyer 			    IXGBE_READ_REG(hw, IXGBE_RNBC(i));
5510dc2366fSVenugopal Iyer 		}
5520dc2366fSVenugopal Iyer 		*val = ixgbe_ks->rnbc.value.ui64;
5530dc2366fSVenugopal Iyer 		break;
5540dc2366fSVenugopal Iyer 
5550dc2366fSVenugopal Iyer 	case MAC_STAT_IERRORS:
5560dc2366fSVenugopal Iyer 		ixgbe_ks->crcerrs.value.ui64 +=
5570dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_CRCERRS);
5580dc2366fSVenugopal Iyer 		ixgbe_ks->illerrc.value.ui64 +=
5590dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_ILLERRC);
5600dc2366fSVenugopal Iyer 		ixgbe_ks->errbc.value.ui64 +=
5610dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_ERRBC);
5620dc2366fSVenugopal Iyer 		ixgbe_ks->rlec.value.ui64 +=
5630dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_RLEC);
5640dc2366fSVenugopal Iyer 		*val = ixgbe_ks->crcerrs.value.ui64 +
5650dc2366fSVenugopal Iyer 		    ixgbe_ks->illerrc.value.ui64 +
5660dc2366fSVenugopal Iyer 		    ixgbe_ks->errbc.value.ui64 +
5670dc2366fSVenugopal Iyer 		    ixgbe_ks->rlec.value.ui64;
5680dc2366fSVenugopal Iyer 		break;
5690dc2366fSVenugopal Iyer 
5700dc2366fSVenugopal Iyer 	case MAC_STAT_RBYTES:
5710dc2366fSVenugopal Iyer 		ixgbe_ks->tor.value.ui64 = 0;
5720dc2366fSVenugopal Iyer 		for (i = 0; i < 16; i++) {
5730dc2366fSVenugopal Iyer 			ixgbe_ks->qbrc[i].value.ui64 +=
5740dc2366fSVenugopal Iyer 			    IXGBE_READ_REG(hw, IXGBE_QBRC(i));
5750dc2366fSVenugopal Iyer 			ixgbe_ks->tor.value.ui64 +=
5760dc2366fSVenugopal Iyer 			    ixgbe_ks->qbrc[i].value.ui64;
5770dc2366fSVenugopal Iyer 		}
5780dc2366fSVenugopal Iyer 		*val = ixgbe_ks->tor.value.ui64;
5790dc2366fSVenugopal Iyer 		break;
5800dc2366fSVenugopal Iyer 
5810dc2366fSVenugopal Iyer 	case MAC_STAT_OBYTES:
5820dc2366fSVenugopal Iyer 		ixgbe_ks->tot.value.ui64 = 0;
5830dc2366fSVenugopal Iyer 		for (i = 0; i < 16; i++) {
5845b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			switch (hw->mac.type) {
5855b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			case ixgbe_mac_82598EB:
5860dc2366fSVenugopal Iyer 				ixgbe_ks->qbtc[i].value.ui64 +=
5870dc2366fSVenugopal Iyer 				    IXGBE_READ_REG(hw, IXGBE_QBTC(i));
5885b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				break;
5895b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
5905b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			case ixgbe_mac_82599EB:
59169b5a878SDan McDonald 			case ixgbe_mac_X540:
592313ba796SDale Ghent 			case ixgbe_mac_X550:
593313ba796SDale Ghent 			case ixgbe_mac_X550EM_x:
5945b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				ixgbe_ks->qbtc[i].value.ui64 +=
5955b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				    IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
5965b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				ixgbe_ks->qbtc[i].value.ui64 +=
5975b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				    ((uint64_t)((IXGBE_READ_REG(hw,
5985b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				    IXGBE_QBTC_H(i))) & 0xF) << 32);
5995b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				break;
6005b6dd21fSchenlu chen - Sun Microsystems - Beijing China 
6015b6dd21fSchenlu chen - Sun Microsystems - Beijing China 			default:
6025b6dd21fSchenlu chen - Sun Microsystems - Beijing China 				break;
6030dc2366fSVenugopal Iyer 			}
6040dc2366fSVenugopal Iyer 			ixgbe_ks->tot.value.ui64 +=
6050dc2366fSVenugopal Iyer 			    ixgbe_ks->qbtc[i].value.ui64;
6060dc2366fSVenugopal Iyer 		}
6070dc2366fSVenugopal Iyer 		*val = ixgbe_ks->tot.value.ui64;
6080dc2366fSVenugopal Iyer 		break;
6090dc2366fSVenugopal Iyer 
6100dc2366fSVenugopal Iyer 	case MAC_STAT_IPACKETS:
6110dc2366fSVenugopal Iyer 		ixgbe_ks->tpr.value.ui64 +=
6120dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_TPR);
6130dc2366fSVenugopal Iyer 		*val = ixgbe_ks->tpr.value.ui64;
6140dc2366fSVenugopal Iyer 		break;
6150dc2366fSVenugopal Iyer 
6160dc2366fSVenugopal Iyer 	case MAC_STAT_OPACKETS:
6170dc2366fSVenugopal Iyer 		ixgbe_ks->tpt.value.ui64 +=
6180dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_TPT);
6190dc2366fSVenugopal Iyer 		*val = ixgbe_ks->tpt.value.ui64;
6200dc2366fSVenugopal Iyer 		break;
6210dc2366fSVenugopal Iyer 
6220dc2366fSVenugopal Iyer 	/* RFC 1643 stats */
6230dc2366fSVenugopal Iyer 	case ETHER_STAT_FCS_ERRORS:
6240dc2366fSVenugopal Iyer 		ixgbe_ks->crcerrs.value.ui64 +=
6250dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_CRCERRS);
6260dc2366fSVenugopal Iyer 		*val = ixgbe_ks->crcerrs.value.ui64;
6270dc2366fSVenugopal Iyer 		break;
6280dc2366fSVenugopal Iyer 
6290dc2366fSVenugopal Iyer 	case ETHER_STAT_TOOLONG_ERRORS:
6300dc2366fSVenugopal Iyer 		ixgbe_ks->roc.value.ui64 +=
6310dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_ROC);
6320dc2366fSVenugopal Iyer 		*val = ixgbe_ks->roc.value.ui64;
6330dc2366fSVenugopal Iyer 		break;
6340dc2366fSVenugopal Iyer 
6350dc2366fSVenugopal Iyer 	case ETHER_STAT_MACRCV_ERRORS:
6360dc2366fSVenugopal Iyer 		ixgbe_ks->crcerrs.value.ui64 +=
6370dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_CRCERRS);
6380dc2366fSVenugopal Iyer 		ixgbe_ks->illerrc.value.ui64 +=
6390dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_ILLERRC);
6400dc2366fSVenugopal Iyer 		ixgbe_ks->errbc.value.ui64 +=
6410dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_ERRBC);
6420dc2366fSVenugopal Iyer 		ixgbe_ks->rlec.value.ui64 +=
6430dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_RLEC);
6440dc2366fSVenugopal Iyer 		*val = ixgbe_ks->crcerrs.value.ui64 +
6450dc2366fSVenugopal Iyer 		    ixgbe_ks->illerrc.value.ui64 +
6460dc2366fSVenugopal Iyer 		    ixgbe_ks->errbc.value.ui64 +
6470dc2366fSVenugopal Iyer 		    ixgbe_ks->rlec.value.ui64;
6480dc2366fSVenugopal Iyer 		break;
6490dc2366fSVenugopal Iyer 
6500dc2366fSVenugopal Iyer 	/* MII/GMII stats */
6510dc2366fSVenugopal Iyer 	case ETHER_STAT_XCVR_ADDR:
6520dc2366fSVenugopal Iyer 		/* The Internal PHY's MDI address for each MAC is 1 */
6530dc2366fSVenugopal Iyer 		*val = 1;
6540dc2366fSVenugopal Iyer 		break;
6550dc2366fSVenugopal Iyer 
6560dc2366fSVenugopal Iyer 	case ETHER_STAT_XCVR_ID:
6570dc2366fSVenugopal Iyer 		*val = hw->phy.id;
6580dc2366fSVenugopal Iyer 		break;
6590dc2366fSVenugopal Iyer 
6600dc2366fSVenugopal Iyer 	case ETHER_STAT_XCVR_INUSE:
6610dc2366fSVenugopal Iyer 		switch (ixgbe->link_speed) {
6620dc2366fSVenugopal Iyer 		case IXGBE_LINK_SPEED_1GB_FULL:
6630dc2366fSVenugopal Iyer 			*val =
6640dc2366fSVenugopal Iyer 			    (hw->phy.media_type == ixgbe_media_type_copper) ?
6650dc2366fSVenugopal Iyer 			    XCVR_1000T : XCVR_1000X;
6660dc2366fSVenugopal Iyer 			break;
6670dc2366fSVenugopal Iyer 		case IXGBE_LINK_SPEED_100_FULL:
6680dc2366fSVenugopal Iyer 			*val = (hw->phy.media_type == ixgbe_media_type_copper) ?
6690dc2366fSVenugopal Iyer 			    XCVR_100T2 : XCVR_100X;
6700dc2366fSVenugopal Iyer 			break;
6710dc2366fSVenugopal Iyer 		default:
6720dc2366fSVenugopal Iyer 			*val = XCVR_NONE;
6730dc2366fSVenugopal Iyer 			break;
6740dc2366fSVenugopal Iyer 		}
6750dc2366fSVenugopal Iyer 		break;
6760dc2366fSVenugopal Iyer 
6770dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_10GFDX:
678313ba796SDale Ghent 		*val = (speeds & IXGBE_LINK_SPEED_10GB_FULL) ? 1 : 0;
679313ba796SDale Ghent 		break;
680313ba796SDale Ghent 
681313ba796SDale Ghent 	case ETHER_STAT_CAP_5000FDX:
682313ba796SDale Ghent 		*val = (speeds & IXGBE_LINK_SPEED_5GB_FULL) ? 1 : 0;
683313ba796SDale Ghent 		break;
684313ba796SDale Ghent 
685313ba796SDale Ghent 	case ETHER_STAT_CAP_2500FDX:
686313ba796SDale Ghent 		*val = (speeds & IXGBE_LINK_SPEED_2_5GB_FULL) ? 1 : 0;
6870dc2366fSVenugopal Iyer 		break;
6880dc2366fSVenugopal Iyer 
6890dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_1000FDX:
690313ba796SDale Ghent 		*val = (speeds & IXGBE_LINK_SPEED_1GB_FULL) ? 1 : 0;
6910dc2366fSVenugopal Iyer 		break;
6920dc2366fSVenugopal Iyer 
6930dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_100FDX:
694313ba796SDale Ghent 		*val = (speeds & IXGBE_LINK_SPEED_100_FULL) ? 1 : 0;
6950dc2366fSVenugopal Iyer 		break;
6960dc2366fSVenugopal Iyer 
6970dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_ASMPAUSE:
6980dc2366fSVenugopal Iyer 		*val = ixgbe->param_asym_pause_cap;
6990dc2366fSVenugopal Iyer 		break;
7000dc2366fSVenugopal Iyer 
7010dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_PAUSE:
7020dc2366fSVenugopal Iyer 		*val = ixgbe->param_pause_cap;
7030dc2366fSVenugopal Iyer 		break;
7040dc2366fSVenugopal Iyer 
7050dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_AUTONEG:
7060dc2366fSVenugopal Iyer 		*val = 1;
7070dc2366fSVenugopal Iyer 		break;
7080dc2366fSVenugopal Iyer 
7090dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_CAP_10GFDX:
7100dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_10000fdx_cap;
7110dc2366fSVenugopal Iyer 		break;
7120dc2366fSVenugopal Iyer 
713313ba796SDale Ghent 	case ETHER_STAT_ADV_CAP_5000FDX:
714313ba796SDale Ghent 		*val = ixgbe->param_adv_5000fdx_cap;
715313ba796SDale Ghent 		break;
716313ba796SDale Ghent 
717313ba796SDale Ghent 	case ETHER_STAT_ADV_CAP_2500FDX:
718313ba796SDale Ghent 		*val = ixgbe->param_adv_2500fdx_cap;
719313ba796SDale Ghent 		break;
720313ba796SDale Ghent 
7210dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_CAP_1000FDX:
7220dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_1000fdx_cap;
7230dc2366fSVenugopal Iyer 		break;
7240dc2366fSVenugopal Iyer 
7250dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_CAP_100FDX:
7260dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_100fdx_cap;
7270dc2366fSVenugopal Iyer 		break;
7280dc2366fSVenugopal Iyer 
7290dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_CAP_ASMPAUSE:
7300dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_asym_pause_cap;
7310dc2366fSVenugopal Iyer 		break;
7320dc2366fSVenugopal Iyer 
7330dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_CAP_PAUSE:
7340dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_pause_cap;
7350dc2366fSVenugopal Iyer 		break;
7360dc2366fSVenugopal Iyer 
7370dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_CAP_AUTONEG:
7380dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_autoneg_cap;
7390dc2366fSVenugopal Iyer 		break;
7400dc2366fSVenugopal Iyer 
7410dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_CAP_10GFDX:
7420dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_10000fdx_cap;
7430dc2366fSVenugopal Iyer 		break;
7440dc2366fSVenugopal Iyer 
745313ba796SDale Ghent 	case ETHER_STAT_LP_CAP_5000FDX:
746313ba796SDale Ghent 		*val = ixgbe->param_lp_5000fdx_cap;
747313ba796SDale Ghent 		break;
748313ba796SDale Ghent 
749313ba796SDale Ghent 	case ETHER_STAT_LP_CAP_2500FDX:
750313ba796SDale Ghent 		*val = ixgbe->param_lp_2500fdx_cap;
751313ba796SDale Ghent 		break;
752313ba796SDale Ghent 
7530dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_CAP_1000FDX:
7540dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_1000fdx_cap;
7550dc2366fSVenugopal Iyer 		break;
7560dc2366fSVenugopal Iyer 
7570dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_CAP_100FDX:
7580dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_100fdx_cap;
7590dc2366fSVenugopal Iyer 		break;
7600dc2366fSVenugopal Iyer 
7610dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_CAP_ASMPAUSE:
7620dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_asym_pause_cap;
7630dc2366fSVenugopal Iyer 		break;
7640dc2366fSVenugopal Iyer 
7650dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_CAP_PAUSE:
7660dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_pause_cap;
7670dc2366fSVenugopal Iyer 		break;
7680dc2366fSVenugopal Iyer 
7690dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_CAP_AUTONEG:
7700dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_autoneg_cap;
7710dc2366fSVenugopal Iyer 		break;
7720dc2366fSVenugopal Iyer 
7730dc2366fSVenugopal Iyer 	case ETHER_STAT_LINK_ASMPAUSE:
7740dc2366fSVenugopal Iyer 		*val = ixgbe->param_asym_pause_cap;
7750dc2366fSVenugopal Iyer 		break;
7760dc2366fSVenugopal Iyer 
7770dc2366fSVenugopal Iyer 	case ETHER_STAT_LINK_PAUSE:
7780dc2366fSVenugopal Iyer 		*val = ixgbe->param_pause_cap;
7790dc2366fSVenugopal Iyer 		break;
7800dc2366fSVenugopal Iyer 
7810dc2366fSVenugopal Iyer 	case ETHER_STAT_LINK_AUTONEG:
7820dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_autoneg_cap;
7830dc2366fSVenugopal Iyer 		break;
7840dc2366fSVenugopal Iyer 
7850dc2366fSVenugopal Iyer 	case ETHER_STAT_LINK_DUPLEX:
7860dc2366fSVenugopal Iyer 		*val = ixgbe->link_duplex;
7870dc2366fSVenugopal Iyer 		break;
7880dc2366fSVenugopal Iyer 
7890dc2366fSVenugopal Iyer 	case ETHER_STAT_TOOSHORT_ERRORS:
7900dc2366fSVenugopal Iyer 		ixgbe_ks->ruc.value.ui64 +=
7910dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_RUC);
7920dc2366fSVenugopal Iyer 		*val = ixgbe_ks->ruc.value.ui64;
7930dc2366fSVenugopal Iyer 		break;
7940dc2366fSVenugopal Iyer 
7950dc2366fSVenugopal Iyer 	case ETHER_STAT_CAP_REMFAULT:
7960dc2366fSVenugopal Iyer 		*val = ixgbe->param_rem_fault;
7970dc2366fSVenugopal Iyer 		break;
7980dc2366fSVenugopal Iyer 
7990dc2366fSVenugopal Iyer 	case ETHER_STAT_ADV_REMFAULT:
8000dc2366fSVenugopal Iyer 		*val = ixgbe->param_adv_rem_fault;
8010dc2366fSVenugopal Iyer 		break;
8020dc2366fSVenugopal Iyer 
8030dc2366fSVenugopal Iyer 	case ETHER_STAT_LP_REMFAULT:
8040dc2366fSVenugopal Iyer 		*val = ixgbe->param_lp_rem_fault;
8050dc2366fSVenugopal Iyer 		break;
8060dc2366fSVenugopal Iyer 
8070dc2366fSVenugopal Iyer 	case ETHER_STAT_JABBER_ERRORS:
8080dc2366fSVenugopal Iyer 		ixgbe_ks->rjc.value.ui64 +=
8090dc2366fSVenugopal Iyer 		    IXGBE_READ_REG(hw, IXGBE_RJC);
8100dc2366fSVenugopal Iyer 		*val = ixgbe_ks->rjc.value.ui64;
8110dc2366fSVenugopal Iyer 		break;
8120dc2366fSVenugopal Iyer 
8130dc2366fSVenugopal Iyer 	default:
8140dc2366fSVenugopal Iyer 		mutex_exit(&ixgbe->gen_lock);
8150dc2366fSVenugopal Iyer 		return (ENOTSUP);
8160dc2366fSVenugopal Iyer 	}
8170dc2366fSVenugopal Iyer 
8180dc2366fSVenugopal Iyer 	mutex_exit(&ixgbe->gen_lock);
8190dc2366fSVenugopal Iyer 
8200dc2366fSVenugopal Iyer 	if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
8210dc2366fSVenugopal Iyer 		ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
8220dc2366fSVenugopal Iyer 		return (EIO);
8230dc2366fSVenugopal Iyer 	}
8240dc2366fSVenugopal Iyer 
8250dc2366fSVenugopal Iyer 	return (0);
8260dc2366fSVenugopal Iyer }
8270dc2366fSVenugopal Iyer 
8280dc2366fSVenugopal Iyer /*
8290dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics for a particular rx ring
8300dc2366fSVenugopal Iyer  */
8310dc2366fSVenugopal Iyer int
ixgbe_rx_ring_stat(mac_ring_driver_t rh,uint_t stat,uint64_t * val)8320dc2366fSVenugopal Iyer ixgbe_rx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
8330dc2366fSVenugopal Iyer {
8340dc2366fSVenugopal Iyer 	ixgbe_rx_ring_t	*rx_ring = (ixgbe_rx_ring_t *)rh;
8350dc2366fSVenugopal Iyer 	ixgbe_t *ixgbe = rx_ring->ixgbe;
8360dc2366fSVenugopal Iyer 
8370dc2366fSVenugopal Iyer 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
8380dc2366fSVenugopal Iyer 		return (ECANCELED);
8390dc2366fSVenugopal Iyer 	}
8400dc2366fSVenugopal Iyer 
8410dc2366fSVenugopal Iyer 	switch (stat) {
8420dc2366fSVenugopal Iyer 	case MAC_STAT_RBYTES:
8430dc2366fSVenugopal Iyer 		*val = rx_ring->stat_rbytes;
8440dc2366fSVenugopal Iyer 		break;
8450dc2366fSVenugopal Iyer 
8460dc2366fSVenugopal Iyer 	case MAC_STAT_IPACKETS:
8470dc2366fSVenugopal Iyer 		*val = rx_ring->stat_ipackets;
8480dc2366fSVenugopal Iyer 		break;
8490dc2366fSVenugopal Iyer 
8500dc2366fSVenugopal Iyer 	default:
8510dc2366fSVenugopal Iyer 		*val = 0;
8520dc2366fSVenugopal Iyer 		return (ENOTSUP);
8530dc2366fSVenugopal Iyer 	}
8540dc2366fSVenugopal Iyer 
8550dc2366fSVenugopal Iyer 	return (0);
8560dc2366fSVenugopal Iyer }
8570dc2366fSVenugopal Iyer 
8580dc2366fSVenugopal Iyer /*
8590dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics for a particular tx ring
8600dc2366fSVenugopal Iyer  */
8610dc2366fSVenugopal Iyer int
ixgbe_tx_ring_stat(mac_ring_driver_t rh,uint_t stat,uint64_t * val)8620dc2366fSVenugopal Iyer ixgbe_tx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
8630dc2366fSVenugopal Iyer {
8640dc2366fSVenugopal Iyer 	ixgbe_tx_ring_t	*tx_ring = (ixgbe_tx_ring_t *)rh;
8650dc2366fSVenugopal Iyer 	ixgbe_t *ixgbe = tx_ring->ixgbe;
8660dc2366fSVenugopal Iyer 
8670dc2366fSVenugopal Iyer 	if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
8680dc2366fSVenugopal Iyer 		return (ECANCELED);
8690dc2366fSVenugopal Iyer 	}
8700dc2366fSVenugopal Iyer 
8710dc2366fSVenugopal Iyer 	switch (stat) {
8720dc2366fSVenugopal Iyer 	case MAC_STAT_OBYTES:
8730dc2366fSVenugopal Iyer 		*val = tx_ring->stat_obytes;
8740dc2366fSVenugopal Iyer 		break;
8750dc2366fSVenugopal Iyer 
8760dc2366fSVenugopal Iyer 	case MAC_STAT_OPACKETS:
8770dc2366fSVenugopal Iyer 		*val = tx_ring->stat_opackets;
8780dc2366fSVenugopal Iyer 		break;
8790dc2366fSVenugopal Iyer 
8800dc2366fSVenugopal Iyer 	default:
8810dc2366fSVenugopal Iyer 		*val = 0;
8820dc2366fSVenugopal Iyer 		return (ENOTSUP);
8830dc2366fSVenugopal Iyer 	}
8840dc2366fSVenugopal Iyer 
8850dc2366fSVenugopal Iyer 	return (0);
8860dc2366fSVenugopal Iyer }
887