16621Sbt150084 /*
26621Sbt150084 * CDDL HEADER START
36621Sbt150084 *
46621Sbt150084 * The contents of this file are subject to the terms of the
56621Sbt150084 * Common Development and Distribution License (the "License").
66621Sbt150084 * You may not use this file except in compliance with the License.
76621Sbt150084 *
88275SEric Cheng * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98275SEric Cheng * or http://www.opensolaris.org/os/licensing.
106621Sbt150084 * See the License for the specific language governing permissions
116621Sbt150084 * and limitations under the License.
126621Sbt150084 *
138275SEric Cheng * When distributing Covered Code, include this CDDL HEADER in each
148275SEric Cheng * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156621Sbt150084 * If applicable, add the following below this CDDL HEADER, with the
166621Sbt150084 * fields enclosed by brackets "[]" replaced with your own identifying
176621Sbt150084 * information: Portions Copyright [yyyy] [name of copyright owner]
186621Sbt150084 *
196621Sbt150084 * CDDL HEADER END
206621Sbt150084 */
216621Sbt150084
226621Sbt150084 /*
23*13006SChenlu.Chen@Sun.COM * Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
24*13006SChenlu.Chen@Sun.COM */
25*13006SChenlu.Chen@Sun.COM
26*13006SChenlu.Chen@Sun.COM /*
27*13006SChenlu.Chen@Sun.COM * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
288275SEric Cheng */
296621Sbt150084
306621Sbt150084 #include "ixgbe_sw.h"
316621Sbt150084
326621Sbt150084 /*
336621Sbt150084 * Update driver private statistics.
346621Sbt150084 */
356621Sbt150084 static int
ixgbe_update_stats(kstat_t * ks,int rw)366621Sbt150084 ixgbe_update_stats(kstat_t *ks, int rw)
376621Sbt150084 {
386621Sbt150084 ixgbe_t *ixgbe;
396621Sbt150084 struct ixgbe_hw *hw;
406621Sbt150084 ixgbe_stat_t *ixgbe_ks;
416621Sbt150084 int i;
426621Sbt150084
436621Sbt150084 if (rw == KSTAT_WRITE)
446621Sbt150084 return (EACCES);
456621Sbt150084
466621Sbt150084 ixgbe = (ixgbe_t *)ks->ks_private;
476621Sbt150084 ixgbe_ks = (ixgbe_stat_t *)ks->ks_data;
486621Sbt150084 hw = &ixgbe->hw;
496621Sbt150084
506621Sbt150084 mutex_enter(&ixgbe->gen_lock);
516621Sbt150084
526621Sbt150084 /*
536621Sbt150084 * Basic information
546621Sbt150084 */
556621Sbt150084 ixgbe_ks->link_speed.value.ui64 = ixgbe->link_speed;
5610998SChenlu.Chen@Sun.COM ixgbe_ks->reset_count.value.ui64 = ixgbe->reset_count;
5711486SZhen.W@Sun.COM ixgbe_ks->lroc.value.ui64 = ixgbe->lro_pkt_count;
586621Sbt150084
596621Sbt150084 #ifdef IXGBE_DEBUG
606621Sbt150084 ixgbe_ks->rx_frame_error.value.ui64 = 0;
616621Sbt150084 ixgbe_ks->rx_cksum_error.value.ui64 = 0;
626621Sbt150084 ixgbe_ks->rx_exceed_pkt.value.ui64 = 0;
636621Sbt150084 for (i = 0; i < ixgbe->num_rx_rings; i++) {
646621Sbt150084 ixgbe_ks->rx_frame_error.value.ui64 +=
656621Sbt150084 ixgbe->rx_rings[i].stat_frame_error;
666621Sbt150084 ixgbe_ks->rx_cksum_error.value.ui64 +=
676621Sbt150084 ixgbe->rx_rings[i].stat_cksum_error;
686621Sbt150084 ixgbe_ks->rx_exceed_pkt.value.ui64 +=
696621Sbt150084 ixgbe->rx_rings[i].stat_exceed_pkt;
706621Sbt150084 }
716621Sbt150084
726621Sbt150084 ixgbe_ks->tx_overload.value.ui64 = 0;
736621Sbt150084 ixgbe_ks->tx_fail_no_tbd.value.ui64 = 0;
746621Sbt150084 ixgbe_ks->tx_fail_no_tcb.value.ui64 = 0;
756621Sbt150084 ixgbe_ks->tx_fail_dma_bind.value.ui64 = 0;
766621Sbt150084 ixgbe_ks->tx_reschedule.value.ui64 = 0;
776621Sbt150084 for (i = 0; i < ixgbe->num_tx_rings; i++) {
786621Sbt150084 ixgbe_ks->tx_overload.value.ui64 +=
796621Sbt150084 ixgbe->tx_rings[i].stat_overload;
806621Sbt150084 ixgbe_ks->tx_fail_no_tbd.value.ui64 +=
816621Sbt150084 ixgbe->tx_rings[i].stat_fail_no_tbd;
826621Sbt150084 ixgbe_ks->tx_fail_no_tcb.value.ui64 +=
836621Sbt150084 ixgbe->tx_rings[i].stat_fail_no_tcb;
846621Sbt150084 ixgbe_ks->tx_fail_dma_bind.value.ui64 +=
856621Sbt150084 ixgbe->tx_rings[i].stat_fail_dma_bind;
866621Sbt150084 ixgbe_ks->tx_reschedule.value.ui64 +=
876621Sbt150084 ixgbe->tx_rings[i].stat_reschedule;
886621Sbt150084 }
898275SEric Cheng #endif
906621Sbt150084
916621Sbt150084 /*
926621Sbt150084 * Hardware calculated statistics.
936621Sbt150084 */
948275SEric Cheng ixgbe_ks->gprc.value.ui64 = 0;
958275SEric Cheng ixgbe_ks->gptc.value.ui64 = 0;
968275SEric Cheng ixgbe_ks->tor.value.ui64 = 0;
978275SEric Cheng ixgbe_ks->tot.value.ui64 = 0;
986621Sbt150084 for (i = 0; i < 16; i++) {
998275SEric Cheng ixgbe_ks->qprc[i].value.ui64 +=
1008275SEric Cheng IXGBE_READ_REG(hw, IXGBE_QPRC(i));
1018275SEric Cheng ixgbe_ks->gprc.value.ui64 += ixgbe_ks->qprc[i].value.ui64;
1028275SEric Cheng ixgbe_ks->qptc[i].value.ui64 +=
1038275SEric Cheng IXGBE_READ_REG(hw, IXGBE_QPTC(i));
1048275SEric Cheng ixgbe_ks->gptc.value.ui64 += ixgbe_ks->qptc[i].value.ui64;
1058275SEric Cheng ixgbe_ks->qbrc[i].value.ui64 +=
1068275SEric Cheng IXGBE_READ_REG(hw, IXGBE_QBRC(i));
1078275SEric Cheng ixgbe_ks->tor.value.ui64 += ixgbe_ks->qbrc[i].value.ui64;
108*13006SChenlu.Chen@Sun.COM switch (hw->mac.type) {
109*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82598EB:
110*13006SChenlu.Chen@Sun.COM ixgbe_ks->qbtc[i].value.ui64 +=
111*13006SChenlu.Chen@Sun.COM IXGBE_READ_REG(hw, IXGBE_QBTC(i));
112*13006SChenlu.Chen@Sun.COM break;
113*13006SChenlu.Chen@Sun.COM
114*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82599EB:
1159353SSamuel.Tu@Sun.COM ixgbe_ks->qbtc[i].value.ui64 +=
1169353SSamuel.Tu@Sun.COM IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
1179353SSamuel.Tu@Sun.COM ixgbe_ks->qbtc[i].value.ui64 +=
118*13006SChenlu.Chen@Sun.COM ((uint64_t)((IXGBE_READ_REG(hw,
119*13006SChenlu.Chen@Sun.COM IXGBE_QBTC_H(i))) & 0xF) << 32);
120*13006SChenlu.Chen@Sun.COM break;
121*13006SChenlu.Chen@Sun.COM
122*13006SChenlu.Chen@Sun.COM default:
123*13006SChenlu.Chen@Sun.COM break;
1249353SSamuel.Tu@Sun.COM }
1258275SEric Cheng ixgbe_ks->tot.value.ui64 += ixgbe_ks->qbtc[i].value.ui64;
1266621Sbt150084 }
1277245Sgg161487 /*
1287245Sgg161487 * This is a Workaround:
1297245Sgg161487 * Currently h/w GORCH, GOTCH, TORH registers are not
1307245Sgg161487 * correctly implemented. We found that the values in
1317245Sgg161487 * these registers are same as those in corresponding
1327245Sgg161487 * *L registers (i.e. GORCL, GOTCL, and TORL). Here the
1337245Sgg161487 * gor and got stat data will not be retrieved through
1347245Sgg161487 * GORC{H/L} and GOTC{H/L} registers but be obtained by
1357245Sgg161487 * simply assigning tor/tot stat data, so the gor/got
1367245Sgg161487 * stat data will not be accurate.
1377245Sgg161487 */
1386621Sbt150084 ixgbe_ks->gor.value.ui64 = ixgbe_ks->tor.value.ui64;
1397245Sgg161487 ixgbe_ks->got.value.ui64 = ixgbe_ks->tot.value.ui64;
1406621Sbt150084
1416621Sbt150084 ixgbe_ks->prc64.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC64);
1426621Sbt150084 ixgbe_ks->prc127.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC127);
1436621Sbt150084 ixgbe_ks->prc255.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC255);
1446621Sbt150084 ixgbe_ks->prc511.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC511);
1456621Sbt150084 ixgbe_ks->prc1023.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC1023);
1466621Sbt150084 ixgbe_ks->prc1522.value.ul += IXGBE_READ_REG(hw, IXGBE_PRC1522);
1476621Sbt150084 ixgbe_ks->ptc64.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC64);
1486621Sbt150084 ixgbe_ks->ptc127.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC127);
1496621Sbt150084 ixgbe_ks->ptc255.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC255);
1506621Sbt150084 ixgbe_ks->ptc511.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC511);
1516621Sbt150084 ixgbe_ks->ptc1023.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC1023);
1526621Sbt150084 ixgbe_ks->ptc1522.value.ul += IXGBE_READ_REG(hw, IXGBE_PTC1522);
1536621Sbt150084
1546621Sbt150084 ixgbe_ks->mspdc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MSPDC);
1556621Sbt150084 for (i = 0; i < 8; i++)
1566621Sbt150084 ixgbe_ks->mpc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MPC(i));
1576621Sbt150084 ixgbe_ks->mlfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MLFC);
1586621Sbt150084 ixgbe_ks->mrfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_MRFC);
1596621Sbt150084 ixgbe_ks->rlec.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RLEC);
1606621Sbt150084 ixgbe_ks->lxontxc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_LXONTXC);
161*13006SChenlu.Chen@Sun.COM switch (hw->mac.type) {
162*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82598EB:
1639353SSamuel.Tu@Sun.COM ixgbe_ks->lxonrxc.value.ui64 += IXGBE_READ_REG(hw,
1649353SSamuel.Tu@Sun.COM IXGBE_LXONRXC);
165*13006SChenlu.Chen@Sun.COM break;
166*13006SChenlu.Chen@Sun.COM
167*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82599EB:
1689353SSamuel.Tu@Sun.COM ixgbe_ks->lxonrxc.value.ui64 += IXGBE_READ_REG(hw,
1699353SSamuel.Tu@Sun.COM IXGBE_LXONRXCNT);
170*13006SChenlu.Chen@Sun.COM break;
171*13006SChenlu.Chen@Sun.COM
172*13006SChenlu.Chen@Sun.COM default:
173*13006SChenlu.Chen@Sun.COM break;
1749353SSamuel.Tu@Sun.COM }
1756621Sbt150084 ixgbe_ks->lxofftxc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
176*13006SChenlu.Chen@Sun.COM switch (hw->mac.type) {
177*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82598EB:
1789353SSamuel.Tu@Sun.COM ixgbe_ks->lxoffrxc.value.ui64 += IXGBE_READ_REG(hw,
1799353SSamuel.Tu@Sun.COM IXGBE_LXOFFRXC);
180*13006SChenlu.Chen@Sun.COM break;
181*13006SChenlu.Chen@Sun.COM
182*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82599EB:
1839353SSamuel.Tu@Sun.COM ixgbe_ks->lxoffrxc.value.ui64 += IXGBE_READ_REG(hw,
1849353SSamuel.Tu@Sun.COM IXGBE_LXOFFRXCNT);
185*13006SChenlu.Chen@Sun.COM break;
186*13006SChenlu.Chen@Sun.COM
187*13006SChenlu.Chen@Sun.COM default:
188*13006SChenlu.Chen@Sun.COM break;
1899353SSamuel.Tu@Sun.COM }
1906621Sbt150084 ixgbe_ks->ruc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RUC);
1916621Sbt150084 ixgbe_ks->rfc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RFC);
1926621Sbt150084 ixgbe_ks->roc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_ROC);
1936621Sbt150084 ixgbe_ks->rjc.value.ui64 += IXGBE_READ_REG(hw, IXGBE_RJC);
1946621Sbt150084
1956621Sbt150084 mutex_exit(&ixgbe->gen_lock);
1966621Sbt150084
1976621Sbt150084 if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK)
1986621Sbt150084 ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_UNAFFECTED);
1996621Sbt150084
2006621Sbt150084 return (0);
2016621Sbt150084 }
2026621Sbt150084
2036621Sbt150084 /*
2046621Sbt150084 * Create and initialize the driver private statistics.
2056621Sbt150084 */
2066621Sbt150084 int
ixgbe_init_stats(ixgbe_t * ixgbe)2076621Sbt150084 ixgbe_init_stats(ixgbe_t *ixgbe)
2086621Sbt150084 {
2096621Sbt150084 kstat_t *ks;
2106621Sbt150084 ixgbe_stat_t *ixgbe_ks;
2116621Sbt150084
2126621Sbt150084 /*
2136621Sbt150084 * Create and init kstat
2146621Sbt150084 */
2156621Sbt150084 ks = kstat_create(MODULE_NAME, ddi_get_instance(ixgbe->dip),
2166621Sbt150084 "statistics", "net", KSTAT_TYPE_NAMED,
2176621Sbt150084 sizeof (ixgbe_stat_t) / sizeof (kstat_named_t), 0);
2186621Sbt150084
2196621Sbt150084 if (ks == NULL) {
2206621Sbt150084 ixgbe_error(ixgbe,
2216621Sbt150084 "Could not create kernel statistics");
2226621Sbt150084 return (IXGBE_FAILURE);
2236621Sbt150084 }
2246621Sbt150084
2256621Sbt150084 ixgbe->ixgbe_ks = ks;
2266621Sbt150084
2276621Sbt150084 ixgbe_ks = (ixgbe_stat_t *)ks->ks_data;
2286621Sbt150084
2296621Sbt150084 /*
2306621Sbt150084 * Initialize all the statistics.
2316621Sbt150084 */
2326621Sbt150084 kstat_named_init(&ixgbe_ks->link_speed, "link_speed",
2336621Sbt150084 KSTAT_DATA_UINT64);
23410998SChenlu.Chen@Sun.COM kstat_named_init(&ixgbe_ks->reset_count, "reset_count",
23510998SChenlu.Chen@Sun.COM KSTAT_DATA_UINT64);
2366621Sbt150084
2376621Sbt150084 #ifdef IXGBE_DEBUG
2386621Sbt150084 kstat_named_init(&ixgbe_ks->rx_frame_error, "rx_frame_error",
2396621Sbt150084 KSTAT_DATA_UINT64);
2406621Sbt150084 kstat_named_init(&ixgbe_ks->rx_cksum_error, "rx_cksum_error",
2416621Sbt150084 KSTAT_DATA_UINT64);
2426621Sbt150084 kstat_named_init(&ixgbe_ks->rx_exceed_pkt, "rx_exceed_pkt",
2436621Sbt150084 KSTAT_DATA_UINT64);
2446621Sbt150084 kstat_named_init(&ixgbe_ks->tx_overload, "tx_overload",
2456621Sbt150084 KSTAT_DATA_UINT64);
2466621Sbt150084 kstat_named_init(&ixgbe_ks->tx_fail_no_tbd, "tx_fail_no_tbd",
2476621Sbt150084 KSTAT_DATA_UINT64);
2486621Sbt150084 kstat_named_init(&ixgbe_ks->tx_fail_no_tcb, "tx_fail_no_tcb",
2496621Sbt150084 KSTAT_DATA_UINT64);
2506621Sbt150084 kstat_named_init(&ixgbe_ks->tx_fail_dma_bind, "tx_fail_dma_bind",
2516621Sbt150084 KSTAT_DATA_UINT64);
2526621Sbt150084 kstat_named_init(&ixgbe_ks->tx_reschedule, "tx_reschedule",
2536621Sbt150084 KSTAT_DATA_UINT64);
2548275SEric Cheng #endif
2556621Sbt150084
2566621Sbt150084 kstat_named_init(&ixgbe_ks->gprc, "good_pkts_recvd",
2576621Sbt150084 KSTAT_DATA_UINT64);
2586621Sbt150084 kstat_named_init(&ixgbe_ks->gptc, "good_pkts_xmitd",
2596621Sbt150084 KSTAT_DATA_UINT64);
2606621Sbt150084 kstat_named_init(&ixgbe_ks->gor, "good_octets_recvd",
2616621Sbt150084 KSTAT_DATA_UINT64);
2626621Sbt150084 kstat_named_init(&ixgbe_ks->got, "good_octets_xmitd",
2636621Sbt150084 KSTAT_DATA_UINT64);
2646621Sbt150084 kstat_named_init(&ixgbe_ks->prc64, "pkts_recvd_( 64b)",
2656621Sbt150084 KSTAT_DATA_UINT64);
2666621Sbt150084 kstat_named_init(&ixgbe_ks->prc127, "pkts_recvd_( 65- 127b)",
2676621Sbt150084 KSTAT_DATA_UINT64);
2686621Sbt150084 kstat_named_init(&ixgbe_ks->prc255, "pkts_recvd_( 127- 255b)",
2696621Sbt150084 KSTAT_DATA_UINT64);
2706621Sbt150084 kstat_named_init(&ixgbe_ks->prc511, "pkts_recvd_( 256- 511b)",
2716621Sbt150084 KSTAT_DATA_UINT64);
2726621Sbt150084 kstat_named_init(&ixgbe_ks->prc1023, "pkts_recvd_( 511-1023b)",
2736621Sbt150084 KSTAT_DATA_UINT64);
2746621Sbt150084 kstat_named_init(&ixgbe_ks->prc1522, "pkts_recvd_(1024-1522b)",
2756621Sbt150084 KSTAT_DATA_UINT64);
2766621Sbt150084 kstat_named_init(&ixgbe_ks->ptc64, "pkts_xmitd_( 64b)",
2776621Sbt150084 KSTAT_DATA_UINT64);
2786621Sbt150084 kstat_named_init(&ixgbe_ks->ptc127, "pkts_xmitd_( 65- 127b)",
2796621Sbt150084 KSTAT_DATA_UINT64);
2806621Sbt150084 kstat_named_init(&ixgbe_ks->ptc255, "pkts_xmitd_( 128- 255b)",
2816621Sbt150084 KSTAT_DATA_UINT64);
2826621Sbt150084 kstat_named_init(&ixgbe_ks->ptc511, "pkts_xmitd_( 255- 511b)",
2836621Sbt150084 KSTAT_DATA_UINT64);
2846621Sbt150084 kstat_named_init(&ixgbe_ks->ptc1023, "pkts_xmitd_( 512-1023b)",
2856621Sbt150084 KSTAT_DATA_UINT64);
2866621Sbt150084 kstat_named_init(&ixgbe_ks->ptc1522, "pkts_xmitd_(1024-1522b)",
2876621Sbt150084 KSTAT_DATA_UINT64);
2888275SEric Cheng
2898275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[0], "queue_pkts_recvd [ 0]",
2908275SEric Cheng KSTAT_DATA_UINT64);
2918275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[1], "queue_pkts_recvd [ 1]",
2928275SEric Cheng KSTAT_DATA_UINT64);
2938275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[2], "queue_pkts_recvd [ 2]",
2948275SEric Cheng KSTAT_DATA_UINT64);
2958275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[3], "queue_pkts_recvd [ 3]",
2968275SEric Cheng KSTAT_DATA_UINT64);
2978275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[4], "queue_pkts_recvd [ 4]",
2988275SEric Cheng KSTAT_DATA_UINT64);
2998275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[5], "queue_pkts_recvd [ 5]",
3008275SEric Cheng KSTAT_DATA_UINT64);
3018275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[6], "queue_pkts_recvd [ 6]",
3028275SEric Cheng KSTAT_DATA_UINT64);
3038275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[7], "queue_pkts_recvd [ 7]",
3048275SEric Cheng KSTAT_DATA_UINT64);
3058275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[8], "queue_pkts_recvd [ 8]",
3068275SEric Cheng KSTAT_DATA_UINT64);
3078275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[9], "queue_pkts_recvd [ 9]",
3088275SEric Cheng KSTAT_DATA_UINT64);
3098275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[10], "queue_pkts_recvd [10]",
3108275SEric Cheng KSTAT_DATA_UINT64);
3118275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[11], "queue_pkts_recvd [11]",
3128275SEric Cheng KSTAT_DATA_UINT64);
3138275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[12], "queue_pkts_recvd [12]",
3148275SEric Cheng KSTAT_DATA_UINT64);
3158275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[13], "queue_pkts_recvd [13]",
3168275SEric Cheng KSTAT_DATA_UINT64);
3178275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[14], "queue_pkts_recvd [14]",
3188275SEric Cheng KSTAT_DATA_UINT64);
3198275SEric Cheng kstat_named_init(&ixgbe_ks->qprc[15], "queue_pkts_recvd [15]",
3208275SEric Cheng KSTAT_DATA_UINT64);
3218275SEric Cheng
3228275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[0], "queue_pkts_xmitd [ 0]",
3238275SEric Cheng KSTAT_DATA_UINT64);
3248275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[1], "queue_pkts_xmitd [ 1]",
3258275SEric Cheng KSTAT_DATA_UINT64);
3268275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[2], "queue_pkts_xmitd [ 2]",
3278275SEric Cheng KSTAT_DATA_UINT64);
3288275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[3], "queue_pkts_xmitd [ 3]",
3298275SEric Cheng KSTAT_DATA_UINT64);
3308275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[4], "queue_pkts_xmitd [ 4]",
3318275SEric Cheng KSTAT_DATA_UINT64);
3328275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[5], "queue_pkts_xmitd [ 5]",
3338275SEric Cheng KSTAT_DATA_UINT64);
3348275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[6], "queue_pkts_xmitd [ 6]",
3358275SEric Cheng KSTAT_DATA_UINT64);
3368275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[7], "queue_pkts_xmitd [ 7]",
3378275SEric Cheng KSTAT_DATA_UINT64);
3388275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[8], "queue_pkts_xmitd [ 8]",
3398275SEric Cheng KSTAT_DATA_UINT64);
3408275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[9], "queue_pkts_xmitd [ 9]",
3418275SEric Cheng KSTAT_DATA_UINT64);
3428275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[10], "queue_pkts_xmitd [10]",
3438275SEric Cheng KSTAT_DATA_UINT64);
3448275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[11], "queue_pkts_xmitd [11]",
3458275SEric Cheng KSTAT_DATA_UINT64);
3468275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[12], "queue_pkts_xmitd [12]",
3478275SEric Cheng KSTAT_DATA_UINT64);
3488275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[13], "queue_pkts_xmitd [13]",
3498275SEric Cheng KSTAT_DATA_UINT64);
3508275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[14], "queue_pkts_xmitd [14]",
3518275SEric Cheng KSTAT_DATA_UINT64);
3528275SEric Cheng kstat_named_init(&ixgbe_ks->qptc[15], "queue_pkts_xmitd [15]",
3538275SEric Cheng KSTAT_DATA_UINT64);
3548275SEric Cheng
3558275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[0], "queue_bytes_recvd [ 0]",
3568275SEric Cheng KSTAT_DATA_UINT64);
3578275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[1], "queue_bytes_recvd [ 1]",
3588275SEric Cheng KSTAT_DATA_UINT64);
3598275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[2], "queue_bytes_recvd [ 2]",
3608275SEric Cheng KSTAT_DATA_UINT64);
3618275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[3], "queue_bytes_recvd [ 3]",
3628275SEric Cheng KSTAT_DATA_UINT64);
3638275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[4], "queue_bytes_recvd [ 4]",
3648275SEric Cheng KSTAT_DATA_UINT64);
3658275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[5], "queue_bytes_recvd [ 5]",
3668275SEric Cheng KSTAT_DATA_UINT64);
3678275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[6], "queue_bytes_recvd [ 6]",
3688275SEric Cheng KSTAT_DATA_UINT64);
3698275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[7], "queue_bytes_recvd [ 7]",
3708275SEric Cheng KSTAT_DATA_UINT64);
3718275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[8], "queue_bytes_recvd [ 8]",
3728275SEric Cheng KSTAT_DATA_UINT64);
3738275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[9], "queue_bytes_recvd [ 9]",
3748275SEric Cheng KSTAT_DATA_UINT64);
3758275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[10], "queue_bytes_recvd [10]",
3768275SEric Cheng KSTAT_DATA_UINT64);
3778275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[11], "queue_bytes_recvd [11]",
3788275SEric Cheng KSTAT_DATA_UINT64);
3798275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[12], "queue_bytes_recvd [12]",
3808275SEric Cheng KSTAT_DATA_UINT64);
3818275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[13], "queue_bytes_recvd [13]",
3828275SEric Cheng KSTAT_DATA_UINT64);
3838275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[14], "queue_bytes_recvd [14]",
3848275SEric Cheng KSTAT_DATA_UINT64);
3858275SEric Cheng kstat_named_init(&ixgbe_ks->qbrc[15], "queue_bytes_recvd [15]",
3868275SEric Cheng KSTAT_DATA_UINT64);
3878275SEric Cheng
3888275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[0], "queue_bytes_xmitd [ 0]",
3898275SEric Cheng KSTAT_DATA_UINT64);
3908275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[1], "queue_bytes_xmitd [ 1]",
3918275SEric Cheng KSTAT_DATA_UINT64);
3928275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[2], "queue_bytes_xmitd [ 2]",
3938275SEric Cheng KSTAT_DATA_UINT64);
3948275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[3], "queue_bytes_xmitd [ 3]",
3958275SEric Cheng KSTAT_DATA_UINT64);
3968275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[4], "queue_bytes_xmitd [ 4]",
3978275SEric Cheng KSTAT_DATA_UINT64);
3988275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[5], "queue_bytes_xmitd [ 5]",
3998275SEric Cheng KSTAT_DATA_UINT64);
4008275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[6], "queue_bytes_xmitd [ 6]",
4018275SEric Cheng KSTAT_DATA_UINT64);
4028275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[7], "queue_bytes_xmitd [ 7]",
4038275SEric Cheng KSTAT_DATA_UINT64);
4048275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[8], "queue_bytes_xmitd [ 8]",
4058275SEric Cheng KSTAT_DATA_UINT64);
4068275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[9], "queue_bytes_xmitd [ 9]",
4078275SEric Cheng KSTAT_DATA_UINT64);
4088275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[10], "queue_bytes_xmitd [10]",
4098275SEric Cheng KSTAT_DATA_UINT64);
4108275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[11], "queue_bytes_xmitd [11]",
4118275SEric Cheng KSTAT_DATA_UINT64);
4128275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[12], "queue_bytes_xmitd [12]",
4138275SEric Cheng KSTAT_DATA_UINT64);
4148275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[13], "queue_bytes_xmitd [13]",
4158275SEric Cheng KSTAT_DATA_UINT64);
4168275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[14], "queue_bytes_xmitd [14]",
4178275SEric Cheng KSTAT_DATA_UINT64);
4188275SEric Cheng kstat_named_init(&ixgbe_ks->qbtc[15], "queue_bytes_xmitd [15]",
4198275SEric Cheng KSTAT_DATA_UINT64);
4206621Sbt150084
4216621Sbt150084 kstat_named_init(&ixgbe_ks->mspdc, "mac_short_packet_discard",
4226621Sbt150084 KSTAT_DATA_UINT64);
4236621Sbt150084 kstat_named_init(&ixgbe_ks->mpc, "missed_packets",
4246621Sbt150084 KSTAT_DATA_UINT64);
4256621Sbt150084 kstat_named_init(&ixgbe_ks->mlfc, "mac_local_fault",
4266621Sbt150084 KSTAT_DATA_UINT64);
4276621Sbt150084 kstat_named_init(&ixgbe_ks->mrfc, "mac_remote_fault",
4286621Sbt150084 KSTAT_DATA_UINT64);
4296621Sbt150084 kstat_named_init(&ixgbe_ks->rlec, "recv_length_err",
4306621Sbt150084 KSTAT_DATA_UINT64);
4316621Sbt150084 kstat_named_init(&ixgbe_ks->lxontxc, "link_xon_xmitd",
4326621Sbt150084 KSTAT_DATA_UINT64);
4336621Sbt150084 kstat_named_init(&ixgbe_ks->lxonrxc, "link_xon_recvd",
4346621Sbt150084 KSTAT_DATA_UINT64);
4356621Sbt150084 kstat_named_init(&ixgbe_ks->lxofftxc, "link_xoff_xmitd",
4366621Sbt150084 KSTAT_DATA_UINT64);
4376621Sbt150084 kstat_named_init(&ixgbe_ks->lxoffrxc, "link_xoff_recvd",
4386621Sbt150084 KSTAT_DATA_UINT64);
4396621Sbt150084 kstat_named_init(&ixgbe_ks->ruc, "recv_undersize",
4406621Sbt150084 KSTAT_DATA_UINT64);
4416621Sbt150084 kstat_named_init(&ixgbe_ks->rfc, "recv_fragment",
4426621Sbt150084 KSTAT_DATA_UINT64);
4436621Sbt150084 kstat_named_init(&ixgbe_ks->roc, "recv_oversize",
4446621Sbt150084 KSTAT_DATA_UINT64);
4456621Sbt150084 kstat_named_init(&ixgbe_ks->rjc, "recv_jabber",
4466621Sbt150084 KSTAT_DATA_UINT64);
4478490SPaul.Guo@Sun.COM kstat_named_init(&ixgbe_ks->rnbc, "recv_no_buffer",
4488490SPaul.Guo@Sun.COM KSTAT_DATA_UINT64);
44911486SZhen.W@Sun.COM kstat_named_init(&ixgbe_ks->lroc, "lro_pkt_count",
45011486SZhen.W@Sun.COM KSTAT_DATA_UINT64);
4516621Sbt150084 /*
4526621Sbt150084 * Function to provide kernel stat update on demand
4536621Sbt150084 */
4546621Sbt150084 ks->ks_update = ixgbe_update_stats;
4556621Sbt150084
4566621Sbt150084 ks->ks_private = (void *)ixgbe;
4576621Sbt150084
4586621Sbt150084 /*
4596621Sbt150084 * Add kstat to systems kstat chain
4606621Sbt150084 */
4616621Sbt150084 kstat_install(ks);
4626621Sbt150084
4636621Sbt150084 return (IXGBE_SUCCESS);
4646621Sbt150084 }
46511878SVenu.Iyer@Sun.COM
46611878SVenu.Iyer@Sun.COM /*
46711878SVenu.Iyer@Sun.COM * Retrieve a value for one of the statistics.
46811878SVenu.Iyer@Sun.COM */
46911878SVenu.Iyer@Sun.COM int
ixgbe_m_stat(void * arg,uint_t stat,uint64_t * val)47011878SVenu.Iyer@Sun.COM ixgbe_m_stat(void *arg, uint_t stat, uint64_t *val)
47111878SVenu.Iyer@Sun.COM {
47211878SVenu.Iyer@Sun.COM ixgbe_t *ixgbe = (ixgbe_t *)arg;
47311878SVenu.Iyer@Sun.COM struct ixgbe_hw *hw = &ixgbe->hw;
47411878SVenu.Iyer@Sun.COM ixgbe_stat_t *ixgbe_ks;
47511878SVenu.Iyer@Sun.COM int i;
47611878SVenu.Iyer@Sun.COM
47711878SVenu.Iyer@Sun.COM ixgbe_ks = (ixgbe_stat_t *)ixgbe->ixgbe_ks->ks_data;
47811878SVenu.Iyer@Sun.COM
47911878SVenu.Iyer@Sun.COM mutex_enter(&ixgbe->gen_lock);
48011878SVenu.Iyer@Sun.COM
48111878SVenu.Iyer@Sun.COM if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
48211878SVenu.Iyer@Sun.COM mutex_exit(&ixgbe->gen_lock);
48311878SVenu.Iyer@Sun.COM return (ECANCELED);
48411878SVenu.Iyer@Sun.COM }
48511878SVenu.Iyer@Sun.COM
48611878SVenu.Iyer@Sun.COM switch (stat) {
48711878SVenu.Iyer@Sun.COM case MAC_STAT_IFSPEED:
48811878SVenu.Iyer@Sun.COM *val = ixgbe->link_speed * 1000000ull;
48911878SVenu.Iyer@Sun.COM break;
49011878SVenu.Iyer@Sun.COM
49111878SVenu.Iyer@Sun.COM case MAC_STAT_MULTIRCV:
49211878SVenu.Iyer@Sun.COM ixgbe_ks->mprc.value.ui64 +=
49311878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_MPRC);
49411878SVenu.Iyer@Sun.COM *val = ixgbe_ks->mprc.value.ui64;
49511878SVenu.Iyer@Sun.COM break;
49611878SVenu.Iyer@Sun.COM
49711878SVenu.Iyer@Sun.COM case MAC_STAT_BRDCSTRCV:
49811878SVenu.Iyer@Sun.COM ixgbe_ks->bprc.value.ui64 +=
49911878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_BPRC);
50011878SVenu.Iyer@Sun.COM *val = ixgbe_ks->bprc.value.ui64;
50111878SVenu.Iyer@Sun.COM break;
50211878SVenu.Iyer@Sun.COM
50311878SVenu.Iyer@Sun.COM case MAC_STAT_MULTIXMT:
50411878SVenu.Iyer@Sun.COM ixgbe_ks->mptc.value.ui64 +=
50511878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_MPTC);
50611878SVenu.Iyer@Sun.COM *val = ixgbe_ks->mptc.value.ui64;
50711878SVenu.Iyer@Sun.COM break;
50811878SVenu.Iyer@Sun.COM
50911878SVenu.Iyer@Sun.COM case MAC_STAT_BRDCSTXMT:
51011878SVenu.Iyer@Sun.COM ixgbe_ks->bptc.value.ui64 +=
51111878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_BPTC);
51211878SVenu.Iyer@Sun.COM *val = ixgbe_ks->bptc.value.ui64;
51311878SVenu.Iyer@Sun.COM break;
51411878SVenu.Iyer@Sun.COM
51511878SVenu.Iyer@Sun.COM case MAC_STAT_NORCVBUF:
51611878SVenu.Iyer@Sun.COM for (i = 0; i < 8; i++) {
51711878SVenu.Iyer@Sun.COM ixgbe_ks->rnbc.value.ui64 +=
51811878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_RNBC(i));
51911878SVenu.Iyer@Sun.COM }
52011878SVenu.Iyer@Sun.COM *val = ixgbe_ks->rnbc.value.ui64;
52111878SVenu.Iyer@Sun.COM break;
52211878SVenu.Iyer@Sun.COM
52311878SVenu.Iyer@Sun.COM case MAC_STAT_IERRORS:
52411878SVenu.Iyer@Sun.COM ixgbe_ks->crcerrs.value.ui64 +=
52511878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_CRCERRS);
52611878SVenu.Iyer@Sun.COM ixgbe_ks->illerrc.value.ui64 +=
52711878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_ILLERRC);
52811878SVenu.Iyer@Sun.COM ixgbe_ks->errbc.value.ui64 +=
52911878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_ERRBC);
53011878SVenu.Iyer@Sun.COM ixgbe_ks->rlec.value.ui64 +=
53111878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_RLEC);
53211878SVenu.Iyer@Sun.COM *val = ixgbe_ks->crcerrs.value.ui64 +
53311878SVenu.Iyer@Sun.COM ixgbe_ks->illerrc.value.ui64 +
53411878SVenu.Iyer@Sun.COM ixgbe_ks->errbc.value.ui64 +
53511878SVenu.Iyer@Sun.COM ixgbe_ks->rlec.value.ui64;
53611878SVenu.Iyer@Sun.COM break;
53711878SVenu.Iyer@Sun.COM
53811878SVenu.Iyer@Sun.COM case MAC_STAT_RBYTES:
53911878SVenu.Iyer@Sun.COM ixgbe_ks->tor.value.ui64 = 0;
54011878SVenu.Iyer@Sun.COM for (i = 0; i < 16; i++) {
54111878SVenu.Iyer@Sun.COM ixgbe_ks->qbrc[i].value.ui64 +=
54211878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_QBRC(i));
54311878SVenu.Iyer@Sun.COM ixgbe_ks->tor.value.ui64 +=
54411878SVenu.Iyer@Sun.COM ixgbe_ks->qbrc[i].value.ui64;
54511878SVenu.Iyer@Sun.COM }
54611878SVenu.Iyer@Sun.COM *val = ixgbe_ks->tor.value.ui64;
54711878SVenu.Iyer@Sun.COM break;
54811878SVenu.Iyer@Sun.COM
54911878SVenu.Iyer@Sun.COM case MAC_STAT_OBYTES:
55011878SVenu.Iyer@Sun.COM ixgbe_ks->tot.value.ui64 = 0;
55111878SVenu.Iyer@Sun.COM for (i = 0; i < 16; i++) {
552*13006SChenlu.Chen@Sun.COM switch (hw->mac.type) {
553*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82598EB:
554*13006SChenlu.Chen@Sun.COM ixgbe_ks->qbtc[i].value.ui64 +=
555*13006SChenlu.Chen@Sun.COM IXGBE_READ_REG(hw, IXGBE_QBTC(i));
556*13006SChenlu.Chen@Sun.COM break;
557*13006SChenlu.Chen@Sun.COM
558*13006SChenlu.Chen@Sun.COM case ixgbe_mac_82599EB:
55911878SVenu.Iyer@Sun.COM ixgbe_ks->qbtc[i].value.ui64 +=
56011878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
56111878SVenu.Iyer@Sun.COM ixgbe_ks->qbtc[i].value.ui64 +=
562*13006SChenlu.Chen@Sun.COM ((uint64_t)((IXGBE_READ_REG(hw,
563*13006SChenlu.Chen@Sun.COM IXGBE_QBTC_H(i))) & 0xF) << 32);
564*13006SChenlu.Chen@Sun.COM break;
565*13006SChenlu.Chen@Sun.COM
566*13006SChenlu.Chen@Sun.COM default:
567*13006SChenlu.Chen@Sun.COM break;
56811878SVenu.Iyer@Sun.COM }
56911878SVenu.Iyer@Sun.COM ixgbe_ks->tot.value.ui64 +=
57011878SVenu.Iyer@Sun.COM ixgbe_ks->qbtc[i].value.ui64;
57111878SVenu.Iyer@Sun.COM }
57211878SVenu.Iyer@Sun.COM *val = ixgbe_ks->tot.value.ui64;
57311878SVenu.Iyer@Sun.COM break;
57411878SVenu.Iyer@Sun.COM
57511878SVenu.Iyer@Sun.COM case MAC_STAT_IPACKETS:
57611878SVenu.Iyer@Sun.COM ixgbe_ks->tpr.value.ui64 +=
57711878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_TPR);
57811878SVenu.Iyer@Sun.COM *val = ixgbe_ks->tpr.value.ui64;
57911878SVenu.Iyer@Sun.COM break;
58011878SVenu.Iyer@Sun.COM
58111878SVenu.Iyer@Sun.COM case MAC_STAT_OPACKETS:
58211878SVenu.Iyer@Sun.COM ixgbe_ks->tpt.value.ui64 +=
58311878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_TPT);
58411878SVenu.Iyer@Sun.COM *val = ixgbe_ks->tpt.value.ui64;
58511878SVenu.Iyer@Sun.COM break;
58611878SVenu.Iyer@Sun.COM
58711878SVenu.Iyer@Sun.COM /* RFC 1643 stats */
58811878SVenu.Iyer@Sun.COM case ETHER_STAT_FCS_ERRORS:
58911878SVenu.Iyer@Sun.COM ixgbe_ks->crcerrs.value.ui64 +=
59011878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_CRCERRS);
59111878SVenu.Iyer@Sun.COM *val = ixgbe_ks->crcerrs.value.ui64;
59211878SVenu.Iyer@Sun.COM break;
59311878SVenu.Iyer@Sun.COM
59411878SVenu.Iyer@Sun.COM case ETHER_STAT_TOOLONG_ERRORS:
59511878SVenu.Iyer@Sun.COM ixgbe_ks->roc.value.ui64 +=
59611878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_ROC);
59711878SVenu.Iyer@Sun.COM *val = ixgbe_ks->roc.value.ui64;
59811878SVenu.Iyer@Sun.COM break;
59911878SVenu.Iyer@Sun.COM
60011878SVenu.Iyer@Sun.COM case ETHER_STAT_MACRCV_ERRORS:
60111878SVenu.Iyer@Sun.COM ixgbe_ks->crcerrs.value.ui64 +=
60211878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_CRCERRS);
60311878SVenu.Iyer@Sun.COM ixgbe_ks->illerrc.value.ui64 +=
60411878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_ILLERRC);
60511878SVenu.Iyer@Sun.COM ixgbe_ks->errbc.value.ui64 +=
60611878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_ERRBC);
60711878SVenu.Iyer@Sun.COM ixgbe_ks->rlec.value.ui64 +=
60811878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_RLEC);
60911878SVenu.Iyer@Sun.COM *val = ixgbe_ks->crcerrs.value.ui64 +
61011878SVenu.Iyer@Sun.COM ixgbe_ks->illerrc.value.ui64 +
61111878SVenu.Iyer@Sun.COM ixgbe_ks->errbc.value.ui64 +
61211878SVenu.Iyer@Sun.COM ixgbe_ks->rlec.value.ui64;
61311878SVenu.Iyer@Sun.COM break;
61411878SVenu.Iyer@Sun.COM
61511878SVenu.Iyer@Sun.COM /* MII/GMII stats */
61611878SVenu.Iyer@Sun.COM case ETHER_STAT_XCVR_ADDR:
61711878SVenu.Iyer@Sun.COM /* The Internal PHY's MDI address for each MAC is 1 */
61811878SVenu.Iyer@Sun.COM *val = 1;
61911878SVenu.Iyer@Sun.COM break;
62011878SVenu.Iyer@Sun.COM
62111878SVenu.Iyer@Sun.COM case ETHER_STAT_XCVR_ID:
62211878SVenu.Iyer@Sun.COM *val = hw->phy.id;
62311878SVenu.Iyer@Sun.COM break;
62411878SVenu.Iyer@Sun.COM
62511878SVenu.Iyer@Sun.COM case ETHER_STAT_XCVR_INUSE:
62611878SVenu.Iyer@Sun.COM switch (ixgbe->link_speed) {
62711878SVenu.Iyer@Sun.COM case IXGBE_LINK_SPEED_1GB_FULL:
62811878SVenu.Iyer@Sun.COM *val =
62911878SVenu.Iyer@Sun.COM (hw->phy.media_type == ixgbe_media_type_copper) ?
63011878SVenu.Iyer@Sun.COM XCVR_1000T : XCVR_1000X;
63111878SVenu.Iyer@Sun.COM break;
63211878SVenu.Iyer@Sun.COM case IXGBE_LINK_SPEED_100_FULL:
63311878SVenu.Iyer@Sun.COM *val = (hw->phy.media_type == ixgbe_media_type_copper) ?
63411878SVenu.Iyer@Sun.COM XCVR_100T2 : XCVR_100X;
63511878SVenu.Iyer@Sun.COM break;
63611878SVenu.Iyer@Sun.COM default:
63711878SVenu.Iyer@Sun.COM *val = XCVR_NONE;
63811878SVenu.Iyer@Sun.COM break;
63911878SVenu.Iyer@Sun.COM }
64011878SVenu.Iyer@Sun.COM break;
64111878SVenu.Iyer@Sun.COM
64211878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_10GFDX:
64311878SVenu.Iyer@Sun.COM *val = 1;
64411878SVenu.Iyer@Sun.COM break;
64511878SVenu.Iyer@Sun.COM
64611878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_1000FDX:
64711878SVenu.Iyer@Sun.COM *val = 1;
64811878SVenu.Iyer@Sun.COM break;
64911878SVenu.Iyer@Sun.COM
65011878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_100FDX:
65111878SVenu.Iyer@Sun.COM *val = 1;
65211878SVenu.Iyer@Sun.COM break;
65311878SVenu.Iyer@Sun.COM
65411878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_ASMPAUSE:
65511878SVenu.Iyer@Sun.COM *val = ixgbe->param_asym_pause_cap;
65611878SVenu.Iyer@Sun.COM break;
65711878SVenu.Iyer@Sun.COM
65811878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_PAUSE:
65911878SVenu.Iyer@Sun.COM *val = ixgbe->param_pause_cap;
66011878SVenu.Iyer@Sun.COM break;
66111878SVenu.Iyer@Sun.COM
66211878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_AUTONEG:
66311878SVenu.Iyer@Sun.COM *val = 1;
66411878SVenu.Iyer@Sun.COM break;
66511878SVenu.Iyer@Sun.COM
66611878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_CAP_10GFDX:
66711878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_10000fdx_cap;
66811878SVenu.Iyer@Sun.COM break;
66911878SVenu.Iyer@Sun.COM
67011878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_CAP_1000FDX:
67111878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_1000fdx_cap;
67211878SVenu.Iyer@Sun.COM break;
67311878SVenu.Iyer@Sun.COM
67411878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_CAP_100FDX:
67511878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_100fdx_cap;
67611878SVenu.Iyer@Sun.COM break;
67711878SVenu.Iyer@Sun.COM
67811878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_CAP_ASMPAUSE:
67911878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_asym_pause_cap;
68011878SVenu.Iyer@Sun.COM break;
68111878SVenu.Iyer@Sun.COM
68211878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_CAP_PAUSE:
68311878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_pause_cap;
68411878SVenu.Iyer@Sun.COM break;
68511878SVenu.Iyer@Sun.COM
68611878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_CAP_AUTONEG:
68711878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_autoneg_cap;
68811878SVenu.Iyer@Sun.COM break;
68911878SVenu.Iyer@Sun.COM
69011878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_CAP_10GFDX:
69111878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_10000fdx_cap;
69211878SVenu.Iyer@Sun.COM break;
69311878SVenu.Iyer@Sun.COM
69411878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_CAP_1000FDX:
69511878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_1000fdx_cap;
69611878SVenu.Iyer@Sun.COM break;
69711878SVenu.Iyer@Sun.COM
69811878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_CAP_100FDX:
69911878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_100fdx_cap;
70011878SVenu.Iyer@Sun.COM break;
70111878SVenu.Iyer@Sun.COM
70211878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_CAP_ASMPAUSE:
70311878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_asym_pause_cap;
70411878SVenu.Iyer@Sun.COM break;
70511878SVenu.Iyer@Sun.COM
70611878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_CAP_PAUSE:
70711878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_pause_cap;
70811878SVenu.Iyer@Sun.COM break;
70911878SVenu.Iyer@Sun.COM
71011878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_CAP_AUTONEG:
71111878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_autoneg_cap;
71211878SVenu.Iyer@Sun.COM break;
71311878SVenu.Iyer@Sun.COM
71411878SVenu.Iyer@Sun.COM case ETHER_STAT_LINK_ASMPAUSE:
71511878SVenu.Iyer@Sun.COM *val = ixgbe->param_asym_pause_cap;
71611878SVenu.Iyer@Sun.COM break;
71711878SVenu.Iyer@Sun.COM
71811878SVenu.Iyer@Sun.COM case ETHER_STAT_LINK_PAUSE:
71911878SVenu.Iyer@Sun.COM *val = ixgbe->param_pause_cap;
72011878SVenu.Iyer@Sun.COM break;
72111878SVenu.Iyer@Sun.COM
72211878SVenu.Iyer@Sun.COM case ETHER_STAT_LINK_AUTONEG:
72311878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_autoneg_cap;
72411878SVenu.Iyer@Sun.COM break;
72511878SVenu.Iyer@Sun.COM
72611878SVenu.Iyer@Sun.COM case ETHER_STAT_LINK_DUPLEX:
72711878SVenu.Iyer@Sun.COM *val = ixgbe->link_duplex;
72811878SVenu.Iyer@Sun.COM break;
72911878SVenu.Iyer@Sun.COM
73011878SVenu.Iyer@Sun.COM case ETHER_STAT_TOOSHORT_ERRORS:
73111878SVenu.Iyer@Sun.COM ixgbe_ks->ruc.value.ui64 +=
73211878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_RUC);
73311878SVenu.Iyer@Sun.COM *val = ixgbe_ks->ruc.value.ui64;
73411878SVenu.Iyer@Sun.COM break;
73511878SVenu.Iyer@Sun.COM
73611878SVenu.Iyer@Sun.COM case ETHER_STAT_CAP_REMFAULT:
73711878SVenu.Iyer@Sun.COM *val = ixgbe->param_rem_fault;
73811878SVenu.Iyer@Sun.COM break;
73911878SVenu.Iyer@Sun.COM
74011878SVenu.Iyer@Sun.COM case ETHER_STAT_ADV_REMFAULT:
74111878SVenu.Iyer@Sun.COM *val = ixgbe->param_adv_rem_fault;
74211878SVenu.Iyer@Sun.COM break;
74311878SVenu.Iyer@Sun.COM
74411878SVenu.Iyer@Sun.COM case ETHER_STAT_LP_REMFAULT:
74511878SVenu.Iyer@Sun.COM *val = ixgbe->param_lp_rem_fault;
74611878SVenu.Iyer@Sun.COM break;
74711878SVenu.Iyer@Sun.COM
74811878SVenu.Iyer@Sun.COM case ETHER_STAT_JABBER_ERRORS:
74911878SVenu.Iyer@Sun.COM ixgbe_ks->rjc.value.ui64 +=
75011878SVenu.Iyer@Sun.COM IXGBE_READ_REG(hw, IXGBE_RJC);
75111878SVenu.Iyer@Sun.COM *val = ixgbe_ks->rjc.value.ui64;
75211878SVenu.Iyer@Sun.COM break;
75311878SVenu.Iyer@Sun.COM
75411878SVenu.Iyer@Sun.COM default:
75511878SVenu.Iyer@Sun.COM mutex_exit(&ixgbe->gen_lock);
75611878SVenu.Iyer@Sun.COM return (ENOTSUP);
75711878SVenu.Iyer@Sun.COM }
75811878SVenu.Iyer@Sun.COM
75911878SVenu.Iyer@Sun.COM mutex_exit(&ixgbe->gen_lock);
76011878SVenu.Iyer@Sun.COM
76111878SVenu.Iyer@Sun.COM if (ixgbe_check_acc_handle(ixgbe->osdep.reg_handle) != DDI_FM_OK) {
76211878SVenu.Iyer@Sun.COM ddi_fm_service_impact(ixgbe->dip, DDI_SERVICE_DEGRADED);
76311878SVenu.Iyer@Sun.COM return (EIO);
76411878SVenu.Iyer@Sun.COM }
76511878SVenu.Iyer@Sun.COM
76611878SVenu.Iyer@Sun.COM return (0);
76711878SVenu.Iyer@Sun.COM }
76811878SVenu.Iyer@Sun.COM
76911878SVenu.Iyer@Sun.COM /*
77011878SVenu.Iyer@Sun.COM * Retrieve a value for one of the statistics for a particular rx ring
77111878SVenu.Iyer@Sun.COM */
77211878SVenu.Iyer@Sun.COM int
ixgbe_rx_ring_stat(mac_ring_driver_t rh,uint_t stat,uint64_t * val)77311878SVenu.Iyer@Sun.COM ixgbe_rx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
77411878SVenu.Iyer@Sun.COM {
77511878SVenu.Iyer@Sun.COM ixgbe_rx_ring_t *rx_ring = (ixgbe_rx_ring_t *)rh;
77611878SVenu.Iyer@Sun.COM ixgbe_t *ixgbe = rx_ring->ixgbe;
77711878SVenu.Iyer@Sun.COM
77811878SVenu.Iyer@Sun.COM if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
77911878SVenu.Iyer@Sun.COM return (ECANCELED);
78011878SVenu.Iyer@Sun.COM }
78111878SVenu.Iyer@Sun.COM
78211878SVenu.Iyer@Sun.COM switch (stat) {
78311878SVenu.Iyer@Sun.COM case MAC_STAT_RBYTES:
78411878SVenu.Iyer@Sun.COM *val = rx_ring->stat_rbytes;
78511878SVenu.Iyer@Sun.COM break;
78611878SVenu.Iyer@Sun.COM
78711878SVenu.Iyer@Sun.COM case MAC_STAT_IPACKETS:
78811878SVenu.Iyer@Sun.COM *val = rx_ring->stat_ipackets;
78911878SVenu.Iyer@Sun.COM break;
79011878SVenu.Iyer@Sun.COM
79111878SVenu.Iyer@Sun.COM default:
79211878SVenu.Iyer@Sun.COM *val = 0;
79311878SVenu.Iyer@Sun.COM return (ENOTSUP);
79411878SVenu.Iyer@Sun.COM }
79511878SVenu.Iyer@Sun.COM
79611878SVenu.Iyer@Sun.COM return (0);
79711878SVenu.Iyer@Sun.COM }
79811878SVenu.Iyer@Sun.COM
79911878SVenu.Iyer@Sun.COM /*
80011878SVenu.Iyer@Sun.COM * Retrieve a value for one of the statistics for a particular tx ring
80111878SVenu.Iyer@Sun.COM */
80211878SVenu.Iyer@Sun.COM int
ixgbe_tx_ring_stat(mac_ring_driver_t rh,uint_t stat,uint64_t * val)80311878SVenu.Iyer@Sun.COM ixgbe_tx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
80411878SVenu.Iyer@Sun.COM {
80511878SVenu.Iyer@Sun.COM ixgbe_tx_ring_t *tx_ring = (ixgbe_tx_ring_t *)rh;
80611878SVenu.Iyer@Sun.COM ixgbe_t *ixgbe = tx_ring->ixgbe;
80711878SVenu.Iyer@Sun.COM
80811878SVenu.Iyer@Sun.COM if (ixgbe->ixgbe_state & IXGBE_SUSPENDED) {
80911878SVenu.Iyer@Sun.COM return (ECANCELED);
81011878SVenu.Iyer@Sun.COM }
81111878SVenu.Iyer@Sun.COM
81211878SVenu.Iyer@Sun.COM switch (stat) {
81311878SVenu.Iyer@Sun.COM case MAC_STAT_OBYTES:
81411878SVenu.Iyer@Sun.COM *val = tx_ring->stat_obytes;
81511878SVenu.Iyer@Sun.COM break;
81611878SVenu.Iyer@Sun.COM
81711878SVenu.Iyer@Sun.COM case MAC_STAT_OPACKETS:
81811878SVenu.Iyer@Sun.COM *val = tx_ring->stat_opackets;
81911878SVenu.Iyer@Sun.COM break;
82011878SVenu.Iyer@Sun.COM
82111878SVenu.Iyer@Sun.COM default:
82211878SVenu.Iyer@Sun.COM *val = 0;
82311878SVenu.Iyer@Sun.COM return (ENOTSUP);
82411878SVenu.Iyer@Sun.COM }
82511878SVenu.Iyer@Sun.COM
82611878SVenu.Iyer@Sun.COM return (0);
82711878SVenu.Iyer@Sun.COM }
828