xref: /titanic_52/usr/src/uts/common/io/hxge/hxge_kstats.c (revision 5ce95b09f57d17f7d100337b98c95ecd81ea2979)
13dec9fcdSqs148142 /*
23dec9fcdSqs148142  * CDDL HEADER START
33dec9fcdSqs148142  *
43dec9fcdSqs148142  * The contents of this file are subject to the terms of the
53dec9fcdSqs148142  * Common Development and Distribution License (the "License").
63dec9fcdSqs148142  * You may not use this file except in compliance with the License.
73dec9fcdSqs148142  *
83dec9fcdSqs148142  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93dec9fcdSqs148142  * or http://www.opensolaris.org/os/licensing.
103dec9fcdSqs148142  * See the License for the specific language governing permissions
113dec9fcdSqs148142  * and limitations under the License.
123dec9fcdSqs148142  *
133dec9fcdSqs148142  * When distributing Covered Code, include this CDDL HEADER in each
143dec9fcdSqs148142  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153dec9fcdSqs148142  * If applicable, add the following below this CDDL HEADER, with the
163dec9fcdSqs148142  * fields enclosed by brackets "[]" replaced with your own identifying
173dec9fcdSqs148142  * information: Portions Copyright [yyyy] [name of copyright owner]
183dec9fcdSqs148142  *
193dec9fcdSqs148142  * CDDL HEADER END
203dec9fcdSqs148142  */
213dec9fcdSqs148142 /*
220dc2366fSVenugopal Iyer  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
233dec9fcdSqs148142  * Use is subject to license terms.
243dec9fcdSqs148142  */
253dec9fcdSqs148142 
263dec9fcdSqs148142 #include <hxge_impl.h>
273dec9fcdSqs148142 #include <inet/mi.h>
283dec9fcdSqs148142 #include <sys/cmn_err.h>
293dec9fcdSqs148142 
303dec9fcdSqs148142 #define	RDC_NAME_FORMAT1 "RDC_"
313dec9fcdSqs148142 #define	TDC_NAME_FORMAT1 "TDC_"
323dec9fcdSqs148142 #define	CH_NAME_FORMAT "%d"
333dec9fcdSqs148142 
341ed83081SMichael Speer static int hxge_mmac_stat_update(kstat_t *ksp, int rw);
351ed83081SMichael Speer 
363dec9fcdSqs148142 void
373dec9fcdSqs148142 hxge_init_statsp(p_hxge_t hxgep)
383dec9fcdSqs148142 {
393dec9fcdSqs148142 	size_t stats_size;
403dec9fcdSqs148142 
413dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_init_statsp"));
423dec9fcdSqs148142 
433dec9fcdSqs148142 	stats_size = sizeof (hxge_stats_t);
443dec9fcdSqs148142 	hxgep->statsp = KMEM_ZALLOC(stats_size, KM_SLEEP);
453dec9fcdSqs148142 	hxgep->statsp->stats_size = stats_size;
463dec9fcdSqs148142 
473dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, " <== hxge_init_statsp"));
483dec9fcdSqs148142 }
493dec9fcdSqs148142 
503dec9fcdSqs148142 typedef struct {
513dec9fcdSqs148142 	uint8_t index;
523dec9fcdSqs148142 	uint8_t type;
533dec9fcdSqs148142 	char *name;
543dec9fcdSqs148142 } hxge_kstat_index_t;
553dec9fcdSqs148142 
563dec9fcdSqs148142 typedef enum {
573dec9fcdSqs148142 	RDC_STAT_PACKETS = 0,
583dec9fcdSqs148142 	RDC_STAT_BYTES,
593dec9fcdSqs148142 	RDC_STAT_ERRORS,
603dec9fcdSqs148142 	RDC_STAT_JUMBO_PKTS,
613dec9fcdSqs148142 	RDC_STAT_RCR_UNKNOWN_ERR,
623dec9fcdSqs148142 	RDC_STAT_RCR_SHA_PAR_ERR,
633dec9fcdSqs148142 	RDC_STAT_RBR_PRE_PAR_ERR,
643dec9fcdSqs148142 	RDC_STAT_RBR_PRE_EMTY,
653dec9fcdSqs148142 	RDC_STAT_RCR_SHADOW_FULL,
663dec9fcdSqs148142 	RDC_STAT_RBR_TMOUT,
673dec9fcdSqs148142 	RDC_STAT_PEU_RESP_ERR,
683dec9fcdSqs148142 	RDC_STAT_CTRL_FIFO_ECC_ERR,
693dec9fcdSqs148142 	RDC_STAT_DATA_FIFO_ECC_ERR,
703dec9fcdSqs148142 	RDC_STAT_RCRFULL,
713dec9fcdSqs148142 	RDC_STAT_RBR_EMPTY,
72b83cd2c3SMichael Speer 	RDC_STAT_RBR_EMPTY_FAIL,
731c29f7e3SQiyan Sun - Sun Microsystems - San Diego United States 	RDC_STAT_RBR_EMPTY_RESTORE,
743dec9fcdSqs148142 	RDC_STAT_RBR_FULL,
758ad8db65SMichael Speer 	RDC_STAT_RCR_INVALIDS,
763dec9fcdSqs148142 	RDC_STAT_RCRTO,
773dec9fcdSqs148142 	RDC_STAT_RCRTHRES,
78fd9489ceSQiyan Sun - Sun Microsystems - San Diego United States 	RDC_STAT_PKT_DROP,
793dec9fcdSqs148142 	RDC_STAT_END
803dec9fcdSqs148142 } hxge_rdc_stat_index_t;
813dec9fcdSqs148142 
823dec9fcdSqs148142 hxge_kstat_index_t hxge_rdc_stats[] = {
833dec9fcdSqs148142 	{RDC_STAT_PACKETS, KSTAT_DATA_UINT64, "rdc_packets"},
843dec9fcdSqs148142 	{RDC_STAT_BYTES, KSTAT_DATA_UINT64, "rdc_bytes"},
85a512c5d1SQiyan Sun - Sun Microsystems - San Diego United States 	{RDC_STAT_ERRORS, KSTAT_DATA_ULONG, "rdc_errors"},
863dec9fcdSqs148142 	{RDC_STAT_JUMBO_PKTS, KSTAT_DATA_ULONG, "rdc_jumbo_pkts"},
873dec9fcdSqs148142 	{RDC_STAT_RCR_UNKNOWN_ERR, KSTAT_DATA_ULONG, "rdc_rcr_unknown_err"},
883dec9fcdSqs148142 	{RDC_STAT_RCR_SHA_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rcr_sha_par_err"},
893dec9fcdSqs148142 	{RDC_STAT_RBR_PRE_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rbr_pre_par_err"},
903dec9fcdSqs148142 	{RDC_STAT_RBR_PRE_EMTY, KSTAT_DATA_ULONG, "rdc_rbr_pre_empty"},
913dec9fcdSqs148142 	{RDC_STAT_RCR_SHADOW_FULL, KSTAT_DATA_ULONG, "rdc_rcr_shadow_full"},
923dec9fcdSqs148142 	{RDC_STAT_RBR_TMOUT, KSTAT_DATA_ULONG, "rdc_rbr_tmout"},
933dec9fcdSqs148142 	{RDC_STAT_PEU_RESP_ERR, KSTAT_DATA_ULONG, "peu_resp_err"},
943dec9fcdSqs148142 	{RDC_STAT_CTRL_FIFO_ECC_ERR, KSTAT_DATA_ULONG, "ctrl_fifo_ecc_err"},
953dec9fcdSqs148142 	{RDC_STAT_DATA_FIFO_ECC_ERR, KSTAT_DATA_ULONG, "data_fifo_ecc_err"},
963dec9fcdSqs148142 	{RDC_STAT_RCRFULL, KSTAT_DATA_ULONG, "rdc_rcrfull"},
973dec9fcdSqs148142 	{RDC_STAT_RBR_EMPTY, KSTAT_DATA_ULONG, "rdc_rbr_empty"},
98b83cd2c3SMichael Speer 	{RDC_STAT_RBR_EMPTY_FAIL, KSTAT_DATA_ULONG, "rdc_rbr_empty_fail"},
991c29f7e3SQiyan Sun - Sun Microsystems - San Diego United States 	{RDC_STAT_RBR_EMPTY_FAIL, KSTAT_DATA_ULONG, "rdc_rbr_empty_restore"},
1003dec9fcdSqs148142 	{RDC_STAT_RBR_FULL, KSTAT_DATA_ULONG, "rdc_rbrfull"},
1018ad8db65SMichael Speer 	{RDC_STAT_RCR_INVALIDS, KSTAT_DATA_ULONG, "rdc_rcr_invalids"},
1023dec9fcdSqs148142 	{RDC_STAT_RCRTO, KSTAT_DATA_ULONG, "rdc_rcrto"},
1033dec9fcdSqs148142 	{RDC_STAT_RCRTHRES, KSTAT_DATA_ULONG, "rdc_rcrthres"},
104fd9489ceSQiyan Sun - Sun Microsystems - San Diego United States 	{RDC_STAT_PKT_DROP, KSTAT_DATA_ULONG, "rdc_pkt_drop"},
1053dec9fcdSqs148142 	{RDC_STAT_END, NULL, NULL}
1063dec9fcdSqs148142 };
1073dec9fcdSqs148142 
1083dec9fcdSqs148142 typedef enum {
1093dec9fcdSqs148142 	RDC_SYS_STAT_CTRL_FIFO_SEC = 0,
1103dec9fcdSqs148142 	RDC_SYS_STAT_CTRL_FIFO_DED,
1113dec9fcdSqs148142 	RDC_SYS_STAT_DATA_FIFO_SEC,
1123dec9fcdSqs148142 	RDC_SYS_STAT_DATA_FIFO_DED,
1133dec9fcdSqs148142 	RDC_SYS_STAT_END
1143dec9fcdSqs148142 } hxge_rdc_sys_stat_idx_t;
1153dec9fcdSqs148142 
1163dec9fcdSqs148142 hxge_kstat_index_t hxge_rdc_sys_stats[] = {
1173dec9fcdSqs148142 	{RDC_SYS_STAT_CTRL_FIFO_SEC, KSTAT_DATA_UINT64, "rdc_ctrl_fifo_sec"},
1183dec9fcdSqs148142 	{RDC_SYS_STAT_CTRL_FIFO_DED, KSTAT_DATA_UINT64, "rdc_ctrl_fifo_ded"},
1193dec9fcdSqs148142 	{RDC_SYS_STAT_DATA_FIFO_SEC, KSTAT_DATA_UINT64, "rdc_data_fifo_sec"},
1203dec9fcdSqs148142 	{RDC_SYS_STAT_DATA_FIFO_DED, KSTAT_DATA_UINT64, "tdc_data_fifo_ded"},
1213dec9fcdSqs148142 	{RDC_SYS_STAT_END, NULL, NULL}
1223dec9fcdSqs148142 };
1233dec9fcdSqs148142 
1243dec9fcdSqs148142 typedef enum {
1253dec9fcdSqs148142 	TDC_STAT_PACKETS = 0,
1263dec9fcdSqs148142 	TDC_STAT_BYTES,
1273dec9fcdSqs148142 	TDC_STAT_BYTES_WITH_PAD,
1283dec9fcdSqs148142 	TDC_STAT_ERRORS,
1293dec9fcdSqs148142 	TDC_STAT_TX_INITS,
1303dec9fcdSqs148142 	TDC_STAT_TX_NO_BUF,
1313dec9fcdSqs148142 	TDC_STAT_PEU_RESP_ERR,
1323dec9fcdSqs148142 	TDC_STAT_PKT_SIZE_ERR,
1333dec9fcdSqs148142 	TDC_STAT_TX_RNG_OFLOW,
1343dec9fcdSqs148142 	TDC_STAT_PKT_SIZE_HDR_ERR,
1353dec9fcdSqs148142 	TDC_STAT_RUNT_PKT_DROP_ERR,
1363dec9fcdSqs148142 	TDC_STAT_PREF_PAR_ERR,
1373dec9fcdSqs148142 	TDC_STAT_TDR_PREF_CPL_TO,
1383dec9fcdSqs148142 	TDC_STAT_PKT_CPL_TO,
1393dec9fcdSqs148142 	TDC_STAT_INVALID_SOP,
1403dec9fcdSqs148142 	TDC_STAT_UNEXPECTED_SOP,
1413dec9fcdSqs148142 	TDC_STAT_COUNT_HDR_SIZE_ERR,
1423dec9fcdSqs148142 	TDC_STAT_COUNT_RUNT,
1433dec9fcdSqs148142 	TDC_STAT_COUNT_ABORT,
1443dec9fcdSqs148142 	TDC_STAT_TX_STARTS,
1453dec9fcdSqs148142 	TDC_STAT_TX_NO_DESC,
1463dec9fcdSqs148142 	TDC_STAT_TX_DMA_BIND_FAIL,
1473dec9fcdSqs148142 	TDC_STAT_TX_HDR_PKTS,
1483dec9fcdSqs148142 	TDC_STAT_TX_DDI_PKTS,
1493dec9fcdSqs148142 	TDC_STAT_TX_JUMBO_PKTS,
1503dec9fcdSqs148142 	TDC_STAT_TX_MAX_PEND,
1513dec9fcdSqs148142 	TDC_STAT_TX_MARKS,
1523dec9fcdSqs148142 	TDC_STAT_END
1533dec9fcdSqs148142 } hxge_tdc_stats_index_t;
1543dec9fcdSqs148142 
1553dec9fcdSqs148142 hxge_kstat_index_t hxge_tdc_stats[] = {
1563dec9fcdSqs148142 	{TDC_STAT_PACKETS, KSTAT_DATA_UINT64, "tdc_packets"},
1573dec9fcdSqs148142 	{TDC_STAT_BYTES, KSTAT_DATA_UINT64, "tdc_bytes"},
1583dec9fcdSqs148142 	{TDC_STAT_BYTES_WITH_PAD, KSTAT_DATA_UINT64, "tdc_bytes_with_pad"},
1593dec9fcdSqs148142 	{TDC_STAT_ERRORS, KSTAT_DATA_UINT64, "tdc_errors"},
1603dec9fcdSqs148142 	{TDC_STAT_TX_INITS, KSTAT_DATA_ULONG, "tdc_tx_inits"},
1613dec9fcdSqs148142 	{TDC_STAT_TX_NO_BUF, KSTAT_DATA_ULONG, "tdc_tx_no_buf"},
1623dec9fcdSqs148142 
1633dec9fcdSqs148142 	{TDC_STAT_PEU_RESP_ERR, KSTAT_DATA_ULONG, "tdc_peu_resp_err"},
1643dec9fcdSqs148142 	{TDC_STAT_PKT_SIZE_ERR, KSTAT_DATA_ULONG, "tdc_pkt_size_err"},
1653dec9fcdSqs148142 	{TDC_STAT_TX_RNG_OFLOW, KSTAT_DATA_ULONG, "tdc_tx_rng_oflow"},
1663dec9fcdSqs148142 	{TDC_STAT_PKT_SIZE_HDR_ERR, KSTAT_DATA_ULONG, "tdc_pkt_size_hdr_err"},
1673dec9fcdSqs148142 	{TDC_STAT_RUNT_PKT_DROP_ERR, KSTAT_DATA_ULONG, "tdc_runt_pkt_drop_err"},
1683dec9fcdSqs148142 	{TDC_STAT_PREF_PAR_ERR, KSTAT_DATA_ULONG, "tdc_pref_par_err"},
1693dec9fcdSqs148142 	{TDC_STAT_TDR_PREF_CPL_TO, KSTAT_DATA_ULONG, "tdc_tdr_pref_cpl_to"},
1703dec9fcdSqs148142 	{TDC_STAT_PKT_CPL_TO, KSTAT_DATA_ULONG, "tdc_pkt_cpl_to"},
1713dec9fcdSqs148142 	{TDC_STAT_INVALID_SOP, KSTAT_DATA_ULONG, "tdc_invalid_sop"},
1723dec9fcdSqs148142 	{TDC_STAT_UNEXPECTED_SOP, KSTAT_DATA_ULONG, "tdc_unexpected_sop"},
1733dec9fcdSqs148142 
1743dec9fcdSqs148142 	{TDC_STAT_COUNT_HDR_SIZE_ERR, KSTAT_DATA_ULONG,
1753dec9fcdSqs148142 	    "tdc_count_hdr_size_err"},
1763dec9fcdSqs148142 	{TDC_STAT_COUNT_RUNT, KSTAT_DATA_ULONG, "tdc_count_runt"},
1773dec9fcdSqs148142 	{TDC_STAT_COUNT_ABORT, KSTAT_DATA_ULONG, "tdc_count_abort"},
1783dec9fcdSqs148142 
1793dec9fcdSqs148142 	{TDC_STAT_TX_STARTS, KSTAT_DATA_ULONG, "tdc_tx_starts"},
1803dec9fcdSqs148142 	{TDC_STAT_TX_NO_DESC, KSTAT_DATA_ULONG, "tdc_tx_no_desc"},
1813dec9fcdSqs148142 	{TDC_STAT_TX_DMA_BIND_FAIL, KSTAT_DATA_ULONG, "tdc_tx_dma_bind_fail"},
1823dec9fcdSqs148142 	{TDC_STAT_TX_HDR_PKTS, KSTAT_DATA_ULONG, "tdc_tx_hdr_pkts"},
1833dec9fcdSqs148142 	{TDC_STAT_TX_DDI_PKTS, KSTAT_DATA_ULONG, "tdc_tx_ddi_pkts"},
1843dec9fcdSqs148142 	{TDC_STAT_TX_JUMBO_PKTS, KSTAT_DATA_ULONG, "tdc_tx_jumbo_pkts"},
1853dec9fcdSqs148142 	{TDC_STAT_TX_MAX_PEND, KSTAT_DATA_ULONG, "tdc_tx_max_pend"},
1863dec9fcdSqs148142 	{TDC_STAT_TX_MARKS, KSTAT_DATA_ULONG, "tdc_tx_marks"},
1873dec9fcdSqs148142 	{TDC_STAT_END, NULL, NULL}
1883dec9fcdSqs148142 };
1893dec9fcdSqs148142 
1903dec9fcdSqs148142 typedef enum {
1913dec9fcdSqs148142 	REORD_TBL_PAR_ERR = 0,
1923dec9fcdSqs148142 	REORD_BUF_DED_ERR,
1933dec9fcdSqs148142 	REORD_BUF_SEC_ERR,
1943dec9fcdSqs148142 	TDC_SYS_STAT_END
1953dec9fcdSqs148142 } hxge_tdc_sys_stat_idx_t;
1963dec9fcdSqs148142 
1973dec9fcdSqs148142 hxge_kstat_index_t hxge_tdc_sys_stats[] = {
1983dec9fcdSqs148142 	{REORD_TBL_PAR_ERR, KSTAT_DATA_UINT64, "reord_tbl_par_err"},
1993dec9fcdSqs148142 	{REORD_BUF_DED_ERR, KSTAT_DATA_UINT64, "reord_buf_ded_err"},
2003dec9fcdSqs148142 	{REORD_BUF_SEC_ERR, KSTAT_DATA_UINT64, "reord_buf_sec_err"},
2013dec9fcdSqs148142 	{TDC_SYS_STAT_END, NULL, NULL}
2023dec9fcdSqs148142 };
2033dec9fcdSqs148142 
2043dec9fcdSqs148142 typedef enum {
2053dec9fcdSqs148142 	VMAC_STAT_TX_FRAME_CNT,		/* vmac_tx_frame_cnt_t */
2063dec9fcdSqs148142 	VMAC_STAT_TX_BYTE_CNT,		/* vmac_tx_byte_cnt_t */
2073dec9fcdSqs148142 
2083dec9fcdSqs148142 	VMAC_STAT_RX_FRAME_CNT,		/* vmac_rx_frame_cnt_t */
2093dec9fcdSqs148142 	VMAC_STAT_RX_BYTE_CNT,		/* vmac_rx_byte_cnt_t */
2103dec9fcdSqs148142 	VMAC_STAT_RX_DROP_FRAME_CNT,	/* vmac_rx_drop_fr_cnt_t */
2113dec9fcdSqs148142 	VMAC_STAT_RX_DROP_BYTE_CNT,	/* vmac_rx_drop_byte_cnt_t */
2123dec9fcdSqs148142 	VMAC_STAT_RX_CRC_CNT,		/* vmac_rx_crc_cnt_t */
2133dec9fcdSqs148142 	VMAC_STAT_RX_PAUSE_CNT,		/* vmac_rx_pause_cnt_t */
2143dec9fcdSqs148142 	VMAC_STAT_RX_BCAST_FR_CNT,	/* vmac_rx_bcast_fr_cnt_t */
2153dec9fcdSqs148142 	VMAC_STAT_RX_MCAST_FR_CNT,	/* vmac_rx_mcast_fr_cnt_t */
2163dec9fcdSqs148142 	VMAC_STAT_END
2173dec9fcdSqs148142 } hxge_vmac_stat_index_t;
2183dec9fcdSqs148142 
2193dec9fcdSqs148142 hxge_kstat_index_t hxge_vmac_stats[] = {
220fe930412Sqs148142 	{VMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_UINT64, "vmac_tx_frame_cnt"},
221fe930412Sqs148142 	{VMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_UINT64, "vmac_tx_byte_cnt"},
2223dec9fcdSqs148142 
223fe930412Sqs148142 	{VMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_UINT64, "vmac_rx_frame_cnt"},
224fe930412Sqs148142 	{VMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_UINT64, "vmac_rx_byte_cnt"},
225fe930412Sqs148142 	{VMAC_STAT_RX_DROP_FRAME_CNT, KSTAT_DATA_UINT64,
2263dec9fcdSqs148142 		"vmac_rx_drop_frame_cnt"},
227fe930412Sqs148142 	{VMAC_STAT_RX_DROP_BYTE_CNT, KSTAT_DATA_UINT64,
228fe930412Sqs148142 		"vmac_rx_drop_byte_cnt"},
229fe930412Sqs148142 	{VMAC_STAT_RX_CRC_CNT, KSTAT_DATA_UINT64, "vmac_rx_crc_cnt"},
230fe930412Sqs148142 	{VMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_UINT64, "vmac_rx_pause_cnt"},
231fe930412Sqs148142 	{VMAC_STAT_RX_BCAST_FR_CNT, KSTAT_DATA_UINT64, "vmac_rx_bcast_fr_cnt"},
232fe930412Sqs148142 	{VMAC_STAT_RX_MCAST_FR_CNT, KSTAT_DATA_UINT64, "vmac_rx_mcast_fr_cnt"},
2333dec9fcdSqs148142 	{VMAC_STAT_END, NULL, NULL}
2343dec9fcdSqs148142 };
2353dec9fcdSqs148142 
2363dec9fcdSqs148142 typedef enum {
2373dec9fcdSqs148142 	PFC_STAT_PKT_DROP,
2383dec9fcdSqs148142 	PFC_STAT_TCAM_PARITY_ERR,
2393dec9fcdSqs148142 	PFC_STAT_VLAN_PARITY_ERR,
2403dec9fcdSqs148142 	PFC_STAT_BAD_CS_COUNT,
2413dec9fcdSqs148142 	PFC_STAT_DROP_COUNT,
2423dec9fcdSqs148142 	PFC_STAT_TCP_CTRL_DROP,
2433dec9fcdSqs148142 	PFC_STAT_L2_ADDR_DROP,
2443dec9fcdSqs148142 	PFC_STAT_CLASS_CODE_DROP,
2453dec9fcdSqs148142 	PFC_STAT_TCAM_DROP,
2463dec9fcdSqs148142 	PFC_STAT_VLAN_DROP,
2473dec9fcdSqs148142 	PFC_STAT_END
2483dec9fcdSqs148142 } hxge_pfc_stat_index_t;
2493dec9fcdSqs148142 
2503dec9fcdSqs148142 hxge_kstat_index_t hxge_pfc_stats[] = {
2513dec9fcdSqs148142 	{PFC_STAT_PKT_DROP, KSTAT_DATA_ULONG, "pfc_pkt_drop"},
2523dec9fcdSqs148142 	{PFC_STAT_TCAM_PARITY_ERR, KSTAT_DATA_ULONG, "pfc_tcam_parity_err"},
2533dec9fcdSqs148142 	{PFC_STAT_VLAN_PARITY_ERR, KSTAT_DATA_ULONG, "pfc_vlan_parity_err"},
2543dec9fcdSqs148142 	{PFC_STAT_BAD_CS_COUNT, KSTAT_DATA_ULONG, "pfc_bad_cs_count"},
2553dec9fcdSqs148142 	{PFC_STAT_DROP_COUNT, KSTAT_DATA_ULONG, "pfc_drop_count"},
2563dec9fcdSqs148142 	{PFC_STAT_TCP_CTRL_DROP, KSTAT_DATA_ULONG, "  pfc_pkt_drop_tcp_ctrl"},
2573dec9fcdSqs148142 	{PFC_STAT_L2_ADDR_DROP, KSTAT_DATA_ULONG, "  pfc_pkt_drop_l2_addr"},
2583dec9fcdSqs148142 	{PFC_STAT_CLASS_CODE_DROP, KSTAT_DATA_ULONG,
2593dec9fcdSqs148142 	    "  pfc_pkt_drop_class_code"},
2603dec9fcdSqs148142 	{PFC_STAT_TCAM_DROP, KSTAT_DATA_ULONG, "  pfc_pkt_drop_tcam"},
2613dec9fcdSqs148142 	{PFC_STAT_VLAN_DROP, KSTAT_DATA_ULONG, "  pfc_pkt_drop_vlan"},
2623dec9fcdSqs148142 	{PFC_STAT_END, NULL, NULL}
2633dec9fcdSqs148142 };
2643dec9fcdSqs148142 
2653dec9fcdSqs148142 typedef enum {
2663dec9fcdSqs148142 	SPC_ACC_ERR = 0,
2673dec9fcdSqs148142 	TDC_PIOACC_ERR,
2683dec9fcdSqs148142 	RDC_PIOACC_ERR,
2693dec9fcdSqs148142 	PFC_PIOACC_ERR,
2703dec9fcdSqs148142 	VMAC_PIOACC_ERR,
2713dec9fcdSqs148142 	CPL_HDRQ_PARERR,
2723dec9fcdSqs148142 	CPL_DATAQ_PARERR,
2733dec9fcdSqs148142 	RETRYRAM_XDLH_PARERR,
2743dec9fcdSqs148142 	RETRYSOTRAM_XDLH_PARERR,
2753dec9fcdSqs148142 	P_HDRQ_PARERR,
2763dec9fcdSqs148142 	P_DATAQ_PARERR,
2773dec9fcdSqs148142 	NP_HDRQ_PARERR,
2783dec9fcdSqs148142 	NP_DATAQ_PARERR,
2793dec9fcdSqs148142 	EIC_MSIX_PARERR,
2803dec9fcdSqs148142 	HCR_PARERR,
2813dec9fcdSqs148142 	PEU_SYS_STAT_END
2823dec9fcdSqs148142 } hxge_peu_sys_stat_idx_t;
2833dec9fcdSqs148142 
2843dec9fcdSqs148142 hxge_kstat_index_t hxge_peu_sys_stats[] = {
2853dec9fcdSqs148142 	{SPC_ACC_ERR, KSTAT_DATA_UINT64, "spc_acc_err"},
2863dec9fcdSqs148142 	{TDC_PIOACC_ERR, KSTAT_DATA_UINT64, "tdc_pioacc_err"},
2873dec9fcdSqs148142 	{RDC_PIOACC_ERR, KSTAT_DATA_UINT64, "rdc_pioacc_err"},
2883dec9fcdSqs148142 	{PFC_PIOACC_ERR, KSTAT_DATA_UINT64, "pfc_pioacc_err"},
2893dec9fcdSqs148142 	{VMAC_PIOACC_ERR, KSTAT_DATA_UINT64, "vmac_pioacc_err"},
2903dec9fcdSqs148142 	{CPL_HDRQ_PARERR, KSTAT_DATA_UINT64, "cpl_hdrq_parerr"},
2913dec9fcdSqs148142 	{CPL_DATAQ_PARERR, KSTAT_DATA_UINT64, "cpl_dataq_parerr"},
2923dec9fcdSqs148142 	{RETRYRAM_XDLH_PARERR, KSTAT_DATA_UINT64, "retryram_xdlh_parerr"},
2933dec9fcdSqs148142 	{RETRYSOTRAM_XDLH_PARERR, KSTAT_DATA_UINT64, "retrysotram_xdlh_parerr"},
2943dec9fcdSqs148142 	{P_HDRQ_PARERR, KSTAT_DATA_UINT64, "p_hdrq_parerr"},
2953dec9fcdSqs148142 	{P_DATAQ_PARERR, KSTAT_DATA_UINT64, "p_dataq_parerr"},
2963dec9fcdSqs148142 	{NP_HDRQ_PARERR, KSTAT_DATA_UINT64, "np_hdrq_parerr"},
2973dec9fcdSqs148142 	{NP_DATAQ_PARERR, KSTAT_DATA_UINT64, "np_dataq_parerr"},
2983dec9fcdSqs148142 	{EIC_MSIX_PARERR, KSTAT_DATA_UINT64, "eic_msix_parerr"},
2993dec9fcdSqs148142 	{HCR_PARERR, KSTAT_DATA_UINT64, "hcr_parerr"},
3003dec9fcdSqs148142 	{TDC_SYS_STAT_END, NULL, NULL}
3013dec9fcdSqs148142 };
3023dec9fcdSqs148142 
3031ed83081SMichael Speer typedef enum {
3041ed83081SMichael Speer 	MMAC_MAX_ADDR,
3051ed83081SMichael Speer 	MMAC_AVAIL_ADDR,
3061ed83081SMichael Speer 	MMAC_ADDR_POOL1,
3071ed83081SMichael Speer 	MMAC_ADDR_POOL2,
3081ed83081SMichael Speer 	MMAC_ADDR_POOL3,
3091ed83081SMichael Speer 	MMAC_ADDR_POOL4,
3101ed83081SMichael Speer 	MMAC_ADDR_POOL5,
3111ed83081SMichael Speer 	MMAC_ADDR_POOL6,
3121ed83081SMichael Speer 	MMAC_ADDR_POOL7,
3131ed83081SMichael Speer 	MMAC_ADDR_POOL8,
3141ed83081SMichael Speer 	MMAC_ADDR_POOL9,
3151ed83081SMichael Speer 	MMAC_ADDR_POOL10,
3161ed83081SMichael Speer 	MMAC_ADDR_POOL11,
3171ed83081SMichael Speer 	MMAC_ADDR_POOL12,
3181ed83081SMichael Speer 	MMAC_ADDR_POOL13,
3191ed83081SMichael Speer 	MMAC_ADDR_POOL14,
3201ed83081SMichael Speer 	MMAC_ADDR_POOL15,
3211ed83081SMichael Speer 	MMAC_ADDR_POOL16,
3221ed83081SMichael Speer 	MMAC_STATS_END
3231ed83081SMichael Speer } hxge_mmac_stat_index_t;
3241ed83081SMichael Speer 
3251ed83081SMichael Speer hxge_kstat_index_t hxge_mmac_stats[] = {
3261ed83081SMichael Speer 	{MMAC_MAX_ADDR, KSTAT_DATA_UINT64, "max_mmac_addr"},
3271ed83081SMichael Speer 	{MMAC_AVAIL_ADDR, KSTAT_DATA_UINT64, "avail_mmac_addr"},
3281ed83081SMichael Speer 	{MMAC_ADDR_POOL1, KSTAT_DATA_UINT64, "mmac_addr_1"},
3291ed83081SMichael Speer 	{MMAC_ADDR_POOL2, KSTAT_DATA_UINT64, "mmac_addr_2"},
3301ed83081SMichael Speer 	{MMAC_ADDR_POOL3, KSTAT_DATA_UINT64, "mmac_addr_3"},
3311ed83081SMichael Speer 	{MMAC_ADDR_POOL4, KSTAT_DATA_UINT64, "mmac_addr_4"},
3321ed83081SMichael Speer 	{MMAC_ADDR_POOL5, KSTAT_DATA_UINT64, "mmac_addr_5"},
3331ed83081SMichael Speer 	{MMAC_ADDR_POOL6, KSTAT_DATA_UINT64, "mmac_addr_6"},
3341ed83081SMichael Speer 	{MMAC_ADDR_POOL7, KSTAT_DATA_UINT64, "mmac_addr_7"},
3351ed83081SMichael Speer 	{MMAC_ADDR_POOL8, KSTAT_DATA_UINT64, "mmac_addr_8"},
3361ed83081SMichael Speer 	{MMAC_ADDR_POOL9, KSTAT_DATA_UINT64, "mmac_addr_9"},
3371ed83081SMichael Speer 	{MMAC_ADDR_POOL10, KSTAT_DATA_UINT64, "mmac_addr_10"},
3381ed83081SMichael Speer 	{MMAC_ADDR_POOL11, KSTAT_DATA_UINT64, "mmac_addr_11"},
3391ed83081SMichael Speer 	{MMAC_ADDR_POOL12, KSTAT_DATA_UINT64, "mmac_addr_12"},
3401ed83081SMichael Speer 	{MMAC_ADDR_POOL13, KSTAT_DATA_UINT64, "mmac_addr_13"},
3411ed83081SMichael Speer 	{MMAC_ADDR_POOL14, KSTAT_DATA_UINT64, "mmac_addr_14"},
3421ed83081SMichael Speer 	{MMAC_ADDR_POOL15, KSTAT_DATA_UINT64, "mmac_addr_15"},
3431ed83081SMichael Speer 	{MMAC_ADDR_POOL16, KSTAT_DATA_UINT64, "mmac_addr_16"},
3441ed83081SMichael Speer 	{MMAC_STATS_END, NULL, NULL},
3451ed83081SMichael Speer };
3461ed83081SMichael Speer 
3471ed83081SMichael Speer 
3483dec9fcdSqs148142 /* ARGSUSED */
3493dec9fcdSqs148142 int
3503dec9fcdSqs148142 hxge_tdc_stat_update(kstat_t *ksp, int rw)
3513dec9fcdSqs148142 {
3523dec9fcdSqs148142 	p_hxge_t		hxgep;
3533dec9fcdSqs148142 	p_hxge_tdc_kstat_t	tdc_kstatsp;
3543dec9fcdSqs148142 	p_hxge_tx_ring_stats_t	statsp;
3553dec9fcdSqs148142 	int			channel;
3563dec9fcdSqs148142 	char			*ch_name, *end;
3573dec9fcdSqs148142 
3583dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
3593dec9fcdSqs148142 	if (hxgep == NULL)
3603dec9fcdSqs148142 		return (-1);
3613dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_rxstat_update"));
3623dec9fcdSqs148142 
3633dec9fcdSqs148142 	ch_name = ksp->ks_name;
3643dec9fcdSqs148142 	ch_name += strlen(TDC_NAME_FORMAT1);
3653dec9fcdSqs148142 	channel = mi_strtol(ch_name, &end, 10);
3663dec9fcdSqs148142 
3673dec9fcdSqs148142 	tdc_kstatsp = (p_hxge_tdc_kstat_t)ksp->ks_data;
3683dec9fcdSqs148142 	statsp = (p_hxge_tx_ring_stats_t)&hxgep->statsp->tdc_stats[channel];
3693dec9fcdSqs148142 
3703dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL,
3713dec9fcdSqs148142 	    "hxge_tdc_stat_update data $%p statsp $%p channel %d",
3723dec9fcdSqs148142 	    ksp->ks_data, statsp, channel));
3733dec9fcdSqs148142 
3743dec9fcdSqs148142 	tdc_kstatsp->opackets.value.ull = statsp->opackets;
3753dec9fcdSqs148142 	tdc_kstatsp->obytes.value.ull = statsp->obytes;
3763dec9fcdSqs148142 	tdc_kstatsp->obytes_with_pad.value.ull = statsp->obytes_with_pad;
3773dec9fcdSqs148142 	tdc_kstatsp->oerrors.value.ull = statsp->oerrors;
3783dec9fcdSqs148142 	tdc_kstatsp->tx_hdr_pkts.value.ull = statsp->tx_hdr_pkts;
3793dec9fcdSqs148142 	tdc_kstatsp->tx_ddi_pkts.value.ull = statsp->tx_ddi_pkts;
3803dec9fcdSqs148142 	tdc_kstatsp->tx_jumbo_pkts.value.ull = statsp->tx_jumbo_pkts;
3813dec9fcdSqs148142 	tdc_kstatsp->tx_max_pend.value.ull = statsp->tx_max_pend;
3823dec9fcdSqs148142 	tdc_kstatsp->peu_resp_err.value.ul = statsp->peu_resp_err;
3833dec9fcdSqs148142 	tdc_kstatsp->pkt_size_err.value.ul = statsp->pkt_size_err;
3843dec9fcdSqs148142 	tdc_kstatsp->tx_rng_oflow.value.ul = statsp->tx_rng_oflow;
3853dec9fcdSqs148142 	tdc_kstatsp->pkt_size_hdr_err.value.ul = statsp->pkt_size_hdr_err;
3863dec9fcdSqs148142 	tdc_kstatsp->runt_pkt_drop_err.value.ul = statsp->runt_pkt_drop_err;
3873dec9fcdSqs148142 	tdc_kstatsp->pref_par_err.value.ul = statsp->pref_par_err;
3883dec9fcdSqs148142 	tdc_kstatsp->tdr_pref_cpl_to.value.ul = statsp->tdr_pref_cpl_to;
3893dec9fcdSqs148142 	tdc_kstatsp->pkt_cpl_to.value.ul = statsp->pkt_cpl_to;
3903dec9fcdSqs148142 	tdc_kstatsp->invalid_sop.value.ul = statsp->invalid_sop;
3913dec9fcdSqs148142 	tdc_kstatsp->unexpected_sop.value.ul = statsp->unexpected_sop;
3923dec9fcdSqs148142 	tdc_kstatsp->tx_starts.value.ul = statsp->tx_starts;
3933dec9fcdSqs148142 	tdc_kstatsp->tx_no_desc.value.ul = statsp->tx_no_desc;
3943dec9fcdSqs148142 	tdc_kstatsp->tx_dma_bind_fail.value.ul = statsp->tx_dma_bind_fail;
3953dec9fcdSqs148142 
3963dec9fcdSqs148142 	tdc_kstatsp->count_hdr_size_err.value.ul =
3973dec9fcdSqs148142 	    statsp->count_hdr_size_err;
3983dec9fcdSqs148142 	tdc_kstatsp->count_runt.value.ul = statsp->count_runt;
3993dec9fcdSqs148142 	tdc_kstatsp->count_abort.value.ul = statsp->count_abort;
4003dec9fcdSqs148142 	tdc_kstatsp->tx_marks.value.ul = statsp->tx_marks;
4013dec9fcdSqs148142 
4023dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, " <== hxge_tdc_stat_update"));
4033dec9fcdSqs148142 	return (0);
4043dec9fcdSqs148142 }
4053dec9fcdSqs148142 
4063dec9fcdSqs148142 /* ARGSUSED */
4073dec9fcdSqs148142 int
4083dec9fcdSqs148142 hxge_tdc_sys_stat_update(kstat_t *ksp, int rw)
4093dec9fcdSqs148142 {
4103dec9fcdSqs148142 	p_hxge_t		hxgep;
4113dec9fcdSqs148142 	p_hxge_tdc_sys_kstat_t	tdc_sys_kstatsp;
4123dec9fcdSqs148142 	p_hxge_tdc_sys_stats_t	statsp;
4133dec9fcdSqs148142 
4143dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
4153dec9fcdSqs148142 	if (hxgep == NULL)
4163dec9fcdSqs148142 		return (-1);
4173dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_tdc_sys_stat_update"));
4183dec9fcdSqs148142 
4193dec9fcdSqs148142 	tdc_sys_kstatsp = (p_hxge_tdc_sys_kstat_t)ksp->ks_data;
4203dec9fcdSqs148142 	statsp = (p_hxge_tdc_sys_stats_t)&hxgep->statsp->tdc_sys_stats;
4213dec9fcdSqs148142 
4223dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "hxge_tdc_sys_stat_update %llx",
4233dec9fcdSqs148142 	    ksp->ks_data));
4243dec9fcdSqs148142 
4253dec9fcdSqs148142 	tdc_sys_kstatsp->reord_tbl_par_err.value.ul =
4263dec9fcdSqs148142 	    statsp->reord_tbl_par_err;
4273dec9fcdSqs148142 	tdc_sys_kstatsp->reord_buf_ded_err.value.ul =
4283dec9fcdSqs148142 	    statsp->reord_buf_ded_err;
4293dec9fcdSqs148142 	tdc_sys_kstatsp->reord_buf_sec_err.value.ul =
4303dec9fcdSqs148142 	    statsp->reord_buf_sec_err;
4313dec9fcdSqs148142 
4323dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, " <== hxge_tdc_sys_stat_update"));
4333dec9fcdSqs148142 	return (0);
4343dec9fcdSqs148142 }
4353dec9fcdSqs148142 
4363dec9fcdSqs148142 /* ARGSUSED */
4373dec9fcdSqs148142 int
4383dec9fcdSqs148142 hxge_rdc_stat_update(kstat_t *ksp, int rw)
4393dec9fcdSqs148142 {
4403dec9fcdSqs148142 	p_hxge_t		hxgep;
4413dec9fcdSqs148142 	p_hxge_rdc_kstat_t	rdc_kstatsp;
4423dec9fcdSqs148142 	p_hxge_rx_ring_stats_t	statsp;
4433dec9fcdSqs148142 	int			channel;
4443dec9fcdSqs148142 	char			*ch_name, *end;
4453dec9fcdSqs148142 
4463dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
4473dec9fcdSqs148142 	if (hxgep == NULL)
4483dec9fcdSqs148142 		return (-1);
4493dec9fcdSqs148142 
4503dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_rdc_stat_update"));
4513dec9fcdSqs148142 
4523dec9fcdSqs148142 	ch_name = ksp->ks_name;
4533dec9fcdSqs148142 	ch_name += strlen(RDC_NAME_FORMAT1);
4543dec9fcdSqs148142 	channel = mi_strtol(ch_name, &end, 10);
4553dec9fcdSqs148142 
4563dec9fcdSqs148142 	rdc_kstatsp = (p_hxge_rdc_kstat_t)ksp->ks_data;
4573dec9fcdSqs148142 	statsp = (p_hxge_rx_ring_stats_t)&hxgep->statsp->rdc_stats[channel];
4583dec9fcdSqs148142 
4593dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL,
4603dec9fcdSqs148142 	    "hxge_rdc_stat_update $%p statsp $%p channel %d",
4613dec9fcdSqs148142 	    ksp->ks_data, statsp, channel));
4623dec9fcdSqs148142 
4633dec9fcdSqs148142 	rdc_kstatsp->ipackets.value.ull = statsp->ipackets;
4643dec9fcdSqs148142 	rdc_kstatsp->rbytes.value.ull = statsp->ibytes;
4653dec9fcdSqs148142 	rdc_kstatsp->jumbo_pkts.value.ul = statsp->jumbo_pkts;
4663dec9fcdSqs148142 	rdc_kstatsp->rcr_unknown_err.value.ul = statsp->rcr_unknown_err;
4673dec9fcdSqs148142 	rdc_kstatsp->errors.value.ul = statsp->ierrors;
4683dec9fcdSqs148142 	rdc_kstatsp->rcr_sha_par_err.value.ul = statsp->rcr_sha_par;
4693dec9fcdSqs148142 	rdc_kstatsp->rbr_pre_par_err.value.ul = statsp->rbr_pre_par;
4703dec9fcdSqs148142 	rdc_kstatsp->rbr_pre_emty.value.ul = statsp->rbr_pre_empty;
4713dec9fcdSqs148142 	rdc_kstatsp->rcr_shadow_full.value.ul = statsp->rcr_shadow_full;
4723dec9fcdSqs148142 	rdc_kstatsp->rbr_tmout.value.ul = statsp->rbr_tmout;
4733dec9fcdSqs148142 	rdc_kstatsp->peu_resp_err.value.ul = statsp->peu_resp_err;
4743dec9fcdSqs148142 	rdc_kstatsp->ctrl_fifo_ecc_err.value.ul = statsp->ctrl_fifo_ecc_err;
4753dec9fcdSqs148142 	rdc_kstatsp->data_fifo_ecc_err.value.ul = statsp->data_fifo_ecc_err;
4763dec9fcdSqs148142 	rdc_kstatsp->rcrfull.value.ul = statsp->rcrfull;
4773dec9fcdSqs148142 	rdc_kstatsp->rbr_empty.value.ul = statsp->rbr_empty;
478b83cd2c3SMichael Speer 	rdc_kstatsp->rbr_empty_fail.value.ul = statsp->rbr_empty_fail;
4791c29f7e3SQiyan Sun - Sun Microsystems - San Diego United States 	rdc_kstatsp->rbr_empty_restore.value.ul = statsp->rbr_empty_restore;
4803dec9fcdSqs148142 	rdc_kstatsp->rbrfull.value.ul = statsp->rbrfull;
4818ad8db65SMichael Speer 	rdc_kstatsp->rcr_invalids.value.ul = statsp->rcr_invalids;
4823dec9fcdSqs148142 	rdc_kstatsp->rcr_to.value.ul = statsp->rcr_to;
4833dec9fcdSqs148142 	rdc_kstatsp->rcr_thresh.value.ul = statsp->rcr_thres;
484fd9489ceSQiyan Sun - Sun Microsystems - San Diego United States 	rdc_kstatsp->pkt_drop.value.ul = statsp->pkt_drop;
4853dec9fcdSqs148142 
4863dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, " <== hxge_rdc_stat_update"));
4873dec9fcdSqs148142 	return (0);
4883dec9fcdSqs148142 }
4893dec9fcdSqs148142 
4903dec9fcdSqs148142 /* ARGSUSED */
4913dec9fcdSqs148142 int
4923dec9fcdSqs148142 hxge_rdc_sys_stat_update(kstat_t *ksp, int rw)
4933dec9fcdSqs148142 {
4943dec9fcdSqs148142 	p_hxge_t		hxgep;
4953dec9fcdSqs148142 	p_hxge_rdc_sys_kstat_t	rdc_sys_kstatsp;
4963dec9fcdSqs148142 	p_hxge_rdc_sys_stats_t	statsp;
4973dec9fcdSqs148142 
4983dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
4993dec9fcdSqs148142 	if (hxgep == NULL)
5003dec9fcdSqs148142 		return (-1);
5013dec9fcdSqs148142 
5023dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_rdc_sys_stat_update"));
5033dec9fcdSqs148142 
5043dec9fcdSqs148142 	rdc_sys_kstatsp = (p_hxge_rdc_sys_kstat_t)ksp->ks_data;
5053dec9fcdSqs148142 	statsp = (p_hxge_rdc_sys_stats_t)&hxgep->statsp->rdc_sys_stats;
5063dec9fcdSqs148142 
5073dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "hxge_rdc_sys_stat_update %llx",
5083dec9fcdSqs148142 	    ksp->ks_data));
5093dec9fcdSqs148142 
5103dec9fcdSqs148142 	rdc_sys_kstatsp->ctrl_fifo_sec.value.ul = statsp->ctrl_fifo_sec;
5113dec9fcdSqs148142 	rdc_sys_kstatsp->ctrl_fifo_ded.value.ul = statsp->ctrl_fifo_ded;
5123dec9fcdSqs148142 	rdc_sys_kstatsp->data_fifo_sec.value.ul = statsp->data_fifo_sec;
5133dec9fcdSqs148142 	rdc_sys_kstatsp->data_fifo_ded.value.ul = statsp->data_fifo_ded;
5143dec9fcdSqs148142 
5153dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, " <== hxge_rdc_sys_stat_update"));
5163dec9fcdSqs148142 	return (0);
5173dec9fcdSqs148142 }
5183dec9fcdSqs148142 
5193dec9fcdSqs148142 /* ARGSUSED */
5203dec9fcdSqs148142 int
5213dec9fcdSqs148142 hxge_vmac_stat_update(kstat_t *ksp, int rw)
5223dec9fcdSqs148142 {
5233dec9fcdSqs148142 	p_hxge_t		hxgep;
5243dec9fcdSqs148142 	p_hxge_vmac_kstat_t	vmac_kstatsp;
5253dec9fcdSqs148142 	p_hxge_vmac_stats_t	statsp;
5263dec9fcdSqs148142 
5273dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
5283dec9fcdSqs148142 	if (hxgep == NULL)
5293dec9fcdSqs148142 		return (-1);
5303dec9fcdSqs148142 
5313dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_vmac_stat_update"));
5323dec9fcdSqs148142 
5333dec9fcdSqs148142 	hxge_save_cntrs(hxgep);
5343dec9fcdSqs148142 
5353dec9fcdSqs148142 	vmac_kstatsp = (p_hxge_vmac_kstat_t)ksp->ks_data;
5363dec9fcdSqs148142 	statsp = (p_hxge_vmac_stats_t)&hxgep->statsp->vmac_stats;
5373dec9fcdSqs148142 
5383dec9fcdSqs148142 	vmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
5393dec9fcdSqs148142 	vmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
5403dec9fcdSqs148142 
5413dec9fcdSqs148142 	vmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
5423dec9fcdSqs148142 	vmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
5433dec9fcdSqs148142 	vmac_kstatsp->rx_drop_frame_cnt.value.ul = statsp->rx_drop_frame_cnt;
5443dec9fcdSqs148142 	vmac_kstatsp->rx_drop_byte_cnt.value.ul = statsp->rx_drop_byte_cnt;
5453dec9fcdSqs148142 	vmac_kstatsp->rx_crc_cnt.value.ul = statsp->rx_crc_cnt;
5463dec9fcdSqs148142 	vmac_kstatsp->rx_pause_cnt.value.ul = statsp->rx_pause_cnt;
5473dec9fcdSqs148142 	vmac_kstatsp->rx_bcast_fr_cnt.value.ul = statsp->rx_bcast_fr_cnt;
5483dec9fcdSqs148142 	vmac_kstatsp->rx_mcast_fr_cnt.value.ul = statsp->rx_mcast_fr_cnt;
5493dec9fcdSqs148142 
5503dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_vmac_stat_update"));
5513dec9fcdSqs148142 	return (0);
5523dec9fcdSqs148142 }
5533dec9fcdSqs148142 
5543dec9fcdSqs148142 /* ARGSUSED */
5553dec9fcdSqs148142 int
5563dec9fcdSqs148142 hxge_pfc_stat_update(kstat_t *ksp, int rw)
5573dec9fcdSqs148142 {
5583dec9fcdSqs148142 	p_hxge_t		hxgep;
5593dec9fcdSqs148142 	p_hxge_pfc_kstat_t	kstatsp;
5603dec9fcdSqs148142 	p_hxge_pfc_stats_t	statsp;
5613dec9fcdSqs148142 
5623dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
5633dec9fcdSqs148142 	if (hxgep == NULL)
5643dec9fcdSqs148142 		return (-1);
5653dec9fcdSqs148142 
5663dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_pfc_stat_update"));
5673dec9fcdSqs148142 
5683dec9fcdSqs148142 	kstatsp = (p_hxge_pfc_kstat_t)ksp->ks_data;
5693dec9fcdSqs148142 	statsp = (p_hxge_pfc_stats_t)&hxgep->statsp->pfc_stats;
5703dec9fcdSqs148142 
5713dec9fcdSqs148142 	kstatsp->pfc_pkt_drop.value.ul = statsp->pkt_drop;
5723dec9fcdSqs148142 	kstatsp->pfc_tcam_parity_err.value.ul = statsp->tcam_parity_err;
5733dec9fcdSqs148142 	kstatsp->pfc_vlan_parity_err.value.ul = statsp->vlan_parity_err;
5743dec9fcdSqs148142 	kstatsp->pfc_bad_cs_count.value.ul = statsp->bad_cs_count;
5753dec9fcdSqs148142 	kstatsp->pfc_drop_count.value.ul = statsp->drop_count;
5763dec9fcdSqs148142 	kstatsp->pfc_tcp_ctrl_drop.value.ul = statsp->errlog.tcp_ctrl_drop;
5773dec9fcdSqs148142 	kstatsp->pfc_l2_addr_drop.value.ul = statsp->errlog.l2_addr_drop;
5783dec9fcdSqs148142 	kstatsp->pfc_class_code_drop.value.ul = statsp->errlog.class_code_drop;
5793dec9fcdSqs148142 	kstatsp->pfc_tcam_drop.value.ul = statsp->errlog.tcam_drop;
5803dec9fcdSqs148142 	kstatsp->pfc_vlan_drop.value.ul = statsp->errlog.vlan_drop;
5813dec9fcdSqs148142 
5823dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_pfc_stat_update"));
5833dec9fcdSqs148142 	return (0);
5843dec9fcdSqs148142 }
5853dec9fcdSqs148142 
5863dec9fcdSqs148142 /* ARGSUSED */
5873dec9fcdSqs148142 int
5883dec9fcdSqs148142 hxge_peu_sys_stat_update(kstat_t *ksp, int rw)
5893dec9fcdSqs148142 {
5903dec9fcdSqs148142 	p_hxge_t		hxgep;
5913dec9fcdSqs148142 	p_hxge_peu_sys_kstat_t	peu_kstatsp;
5923dec9fcdSqs148142 	p_hxge_peu_sys_stats_t	statsp;
5933dec9fcdSqs148142 
5943dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
5953dec9fcdSqs148142 	if (hxgep == NULL)
5963dec9fcdSqs148142 		return (-1);
5973dec9fcdSqs148142 
5983dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_peu_sys_stat_update"));
5993dec9fcdSqs148142 
6003dec9fcdSqs148142 	peu_kstatsp = (p_hxge_peu_sys_kstat_t)ksp->ks_data;
6013dec9fcdSqs148142 	statsp = (p_hxge_peu_sys_stats_t)&hxgep->statsp->peu_sys_stats;
6023dec9fcdSqs148142 
6033dec9fcdSqs148142 	peu_kstatsp->spc_acc_err.value.ul = statsp->spc_acc_err;
6043dec9fcdSqs148142 	peu_kstatsp->tdc_pioacc_err.value.ul = statsp->tdc_pioacc_err;
6053dec9fcdSqs148142 	peu_kstatsp->rdc_pioacc_err.value.ul = statsp->rdc_pioacc_err;
6063dec9fcdSqs148142 	peu_kstatsp->pfc_pioacc_err.value.ul = statsp->pfc_pioacc_err;
6073dec9fcdSqs148142 	peu_kstatsp->vmac_pioacc_err.value.ul = statsp->vmac_pioacc_err;
6083dec9fcdSqs148142 	peu_kstatsp->cpl_hdrq_parerr.value.ul = statsp->cpl_hdrq_parerr;
6093dec9fcdSqs148142 	peu_kstatsp->cpl_dataq_parerr.value.ul = statsp->cpl_dataq_parerr;
6103dec9fcdSqs148142 	peu_kstatsp->retryram_xdlh_parerr.value.ul =
6113dec9fcdSqs148142 	    statsp->retryram_xdlh_parerr;
6123dec9fcdSqs148142 	peu_kstatsp->retrysotram_xdlh_parerr.value.ul =
6133dec9fcdSqs148142 	    statsp->retrysotram_xdlh_parerr;
6143dec9fcdSqs148142 	peu_kstatsp->p_hdrq_parerr.value.ul = statsp->p_hdrq_parerr;
6153dec9fcdSqs148142 	peu_kstatsp->p_dataq_parerr.value.ul = statsp->p_dataq_parerr;
6163dec9fcdSqs148142 	peu_kstatsp->np_hdrq_parerr.value.ul = statsp->np_hdrq_parerr;
6173dec9fcdSqs148142 	peu_kstatsp->np_dataq_parerr.value.ul = statsp->np_dataq_parerr;
6183dec9fcdSqs148142 	peu_kstatsp->eic_msix_parerr.value.ul = statsp->eic_msix_parerr;
6193dec9fcdSqs148142 	peu_kstatsp->hcr_parerr.value.ul = statsp->hcr_parerr;
6203dec9fcdSqs148142 
6213dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_peu_sys_stat_update"));
6223dec9fcdSqs148142 	return (0);
6233dec9fcdSqs148142 }
6243dec9fcdSqs148142 
6253dec9fcdSqs148142 static kstat_t *
6263dec9fcdSqs148142 hxge_setup_local_kstat(p_hxge_t hxgep, int instance, char *name,
6273dec9fcdSqs148142 	const hxge_kstat_index_t *ksip, size_t count,
6283dec9fcdSqs148142 	int (*update) (kstat_t *, int))
6293dec9fcdSqs148142 {
6303dec9fcdSqs148142 	kstat_t		*ksp;
6313dec9fcdSqs148142 	kstat_named_t	*knp;
6323dec9fcdSqs148142 	int		i;
6333dec9fcdSqs148142 
6343dec9fcdSqs148142 	ksp = kstat_create(HXGE_DRIVER_NAME, instance, name, "net",
6353dec9fcdSqs148142 	    KSTAT_TYPE_NAMED, count, 0);
6363dec9fcdSqs148142 	if (ksp == NULL)
6373dec9fcdSqs148142 		return (NULL);
6383dec9fcdSqs148142 
6393dec9fcdSqs148142 	ksp->ks_private = (void *) hxgep;
6403dec9fcdSqs148142 	ksp->ks_update = update;
6413dec9fcdSqs148142 	knp = ksp->ks_data;
6423dec9fcdSqs148142 
6433dec9fcdSqs148142 	for (i = 0; ksip[i].name != NULL; i++) {
6443dec9fcdSqs148142 		kstat_named_init(&knp[i], ksip[i].name, ksip[i].type);
6453dec9fcdSqs148142 	}
6463dec9fcdSqs148142 
6473dec9fcdSqs148142 	kstat_install(ksp);
6483dec9fcdSqs148142 
6493dec9fcdSqs148142 	return (ksp);
6503dec9fcdSqs148142 }
6513dec9fcdSqs148142 
6523dec9fcdSqs148142 void
6533dec9fcdSqs148142 hxge_setup_kstats(p_hxge_t hxgep)
6543dec9fcdSqs148142 {
6553dec9fcdSqs148142 	struct kstat		*ksp;
6563dec9fcdSqs148142 	p_hxge_port_kstat_t	hxgekp;
6573dec9fcdSqs148142 	size_t			hxge_kstat_sz;
6583dec9fcdSqs148142 	char			stat_name[64];
6593dec9fcdSqs148142 	int			i;
6603dec9fcdSqs148142 
6613dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_setup_kstats"));
6623dec9fcdSqs148142 
6633dec9fcdSqs148142 	/* Setup RDC statistics */
6643dec9fcdSqs148142 	for (i = 0; i < hxgep->nrdc; i++) {
6653dec9fcdSqs148142 		(void) sprintf(stat_name, "%s"CH_NAME_FORMAT,
6663dec9fcdSqs148142 		    RDC_NAME_FORMAT1, i);
6673dec9fcdSqs148142 		hxgep->statsp->rdc_ksp[i] = hxge_setup_local_kstat(hxgep,
6683dec9fcdSqs148142 		    hxgep->instance, stat_name, &hxge_rdc_stats[0],
6693dec9fcdSqs148142 		    RDC_STAT_END, hxge_rdc_stat_update);
6703dec9fcdSqs148142 		if (hxgep->statsp->rdc_ksp[i] == NULL)
6713dec9fcdSqs148142 			cmn_err(CE_WARN,
6723dec9fcdSqs148142 			    "kstat_create failed for rdc channel %d", i);
6733dec9fcdSqs148142 	}
6743dec9fcdSqs148142 
6753dec9fcdSqs148142 	/* Setup RDC System statistics */
6763dec9fcdSqs148142 	hxgep->statsp->rdc_sys_ksp = hxge_setup_local_kstat(hxgep,
6773dec9fcdSqs148142 	    hxgep->instance, "RDC_system", &hxge_rdc_sys_stats[0],
6783dec9fcdSqs148142 	    RDC_SYS_STAT_END, hxge_rdc_sys_stat_update);
6793dec9fcdSqs148142 	if (hxgep->statsp->rdc_sys_ksp == NULL)
6803dec9fcdSqs148142 		cmn_err(CE_WARN, "kstat_create failed for rdc_sys_ksp");
6813dec9fcdSqs148142 
6823dec9fcdSqs148142 	/* Setup TDC statistics */
6833dec9fcdSqs148142 	for (i = 0; i < hxgep->ntdc; i++) {
6843dec9fcdSqs148142 		(void) sprintf(stat_name, "%s"CH_NAME_FORMAT,
6853dec9fcdSqs148142 		    TDC_NAME_FORMAT1, i);
6863dec9fcdSqs148142 		hxgep->statsp->tdc_ksp[i] = hxge_setup_local_kstat(hxgep,
6873dec9fcdSqs148142 		    hxgep->instance, stat_name, &hxge_tdc_stats[0],
6883dec9fcdSqs148142 		    TDC_STAT_END, hxge_tdc_stat_update);
6893dec9fcdSqs148142 		if (hxgep->statsp->tdc_ksp[i] == NULL)
6903dec9fcdSqs148142 			cmn_err(CE_WARN,
6913dec9fcdSqs148142 			    "kstat_create failed for tdc channel %d", i);
6923dec9fcdSqs148142 	}
6933dec9fcdSqs148142 
6943dec9fcdSqs148142 	/* Setup TDC System statistics */
6953dec9fcdSqs148142 	hxgep->statsp->tdc_sys_ksp = hxge_setup_local_kstat(hxgep,
6963dec9fcdSqs148142 	    hxgep->instance, "TDC_system", &hxge_tdc_sys_stats[0],
6973dec9fcdSqs148142 	    RDC_SYS_STAT_END, hxge_tdc_sys_stat_update);
6983dec9fcdSqs148142 	if (hxgep->statsp->tdc_sys_ksp == NULL)
6993dec9fcdSqs148142 		cmn_err(CE_WARN, "kstat_create failed for tdc_sys_ksp");
7003dec9fcdSqs148142 
7013dec9fcdSqs148142 	/* Setup PFC statistics */
7023dec9fcdSqs148142 	hxgep->statsp->pfc_ksp = hxge_setup_local_kstat(hxgep,
7033dec9fcdSqs148142 	    hxgep->instance, "PFC", &hxge_pfc_stats[0],
7043dec9fcdSqs148142 	    PFC_STAT_END, hxge_pfc_stat_update);
7053dec9fcdSqs148142 	if (hxgep->statsp->pfc_ksp == NULL)
7063dec9fcdSqs148142 		cmn_err(CE_WARN, "kstat_create failed for pfc");
7073dec9fcdSqs148142 
7083dec9fcdSqs148142 	/* Setup VMAC statistics */
7093dec9fcdSqs148142 	hxgep->statsp->vmac_ksp = hxge_setup_local_kstat(hxgep,
7103dec9fcdSqs148142 	    hxgep->instance, "VMAC", &hxge_vmac_stats[0],
7113dec9fcdSqs148142 	    VMAC_STAT_END, hxge_vmac_stat_update);
7123dec9fcdSqs148142 	if (hxgep->statsp->vmac_ksp == NULL)
7133dec9fcdSqs148142 		cmn_err(CE_WARN, "kstat_create failed for vmac");
7143dec9fcdSqs148142 
7151ed83081SMichael Speer 	/* Setup MMAC Statistics. */
7161ed83081SMichael Speer 	hxgep->statsp->mmac_ksp = hxge_setup_local_kstat(hxgep,
7171ed83081SMichael Speer 	    hxgep->instance, "MMAC", &hxge_mmac_stats[0],
7181ed83081SMichael Speer 	    MMAC_STATS_END, hxge_mmac_stat_update);
7191ed83081SMichael Speer 	if (hxgep->statsp->mmac_ksp == NULL)
7201ed83081SMichael Speer 		cmn_err(CE_WARN, "kstat_create failed for mmac");
7211ed83081SMichael Speer 
7223dec9fcdSqs148142 	/* Setup PEU System statistics */
7233dec9fcdSqs148142 	hxgep->statsp->peu_sys_ksp = hxge_setup_local_kstat(hxgep,
7243dec9fcdSqs148142 	    hxgep->instance, "PEU", &hxge_peu_sys_stats[0],
7253dec9fcdSqs148142 	    PEU_SYS_STAT_END, hxge_peu_sys_stat_update);
7263dec9fcdSqs148142 	if (hxgep->statsp->peu_sys_ksp == NULL)
7273dec9fcdSqs148142 		cmn_err(CE_WARN, "kstat_create failed for peu sys");
7283dec9fcdSqs148142 
7293dec9fcdSqs148142 	/* Port stats */
7303dec9fcdSqs148142 	hxge_kstat_sz = sizeof (hxge_port_kstat_t);
7313dec9fcdSqs148142 
7323dec9fcdSqs148142 	if ((ksp = kstat_create(HXGE_DRIVER_NAME, hxgep->instance,
7333dec9fcdSqs148142 	    "Port", "net", KSTAT_TYPE_NAMED,
7343dec9fcdSqs148142 	    hxge_kstat_sz / sizeof (kstat_named_t), 0)) == NULL) {
7353dec9fcdSqs148142 		cmn_err(CE_WARN, "kstat_create failed for port stat");
7363dec9fcdSqs148142 		return;
7373dec9fcdSqs148142 	}
7383dec9fcdSqs148142 
7393dec9fcdSqs148142 	hxgekp = (p_hxge_port_kstat_t)ksp->ks_data;
7403dec9fcdSqs148142 
7413dec9fcdSqs148142 	kstat_named_init(&hxgekp->cap_10gfdx, "cap_10gfdx", KSTAT_DATA_ULONG);
7423dec9fcdSqs148142 
7433dec9fcdSqs148142 	/*
7443dec9fcdSqs148142 	 * Link partner capabilities.
7453dec9fcdSqs148142 	 */
7463dec9fcdSqs148142 	kstat_named_init(&hxgekp->lp_cap_10gfdx, "lp_cap_10gfdx",
7473dec9fcdSqs148142 	    KSTAT_DATA_ULONG);
7483dec9fcdSqs148142 
7493dec9fcdSqs148142 	/*
7503dec9fcdSqs148142 	 * Shared link setup.
7513dec9fcdSqs148142 	 */
7523dec9fcdSqs148142 	kstat_named_init(&hxgekp->link_speed, "link_speed", KSTAT_DATA_ULONG);
7533dec9fcdSqs148142 	kstat_named_init(&hxgekp->link_duplex, "link_duplex", KSTAT_DATA_CHAR);
7543dec9fcdSqs148142 	kstat_named_init(&hxgekp->link_up, "link_up", KSTAT_DATA_ULONG);
7553dec9fcdSqs148142 
7563dec9fcdSqs148142 	/*
7573dec9fcdSqs148142 	 * Loopback statistics.
7583dec9fcdSqs148142 	 */
7593dec9fcdSqs148142 	kstat_named_init(&hxgekp->lb_mode, "lb_mode", KSTAT_DATA_ULONG);
7603dec9fcdSqs148142 
7613dec9fcdSqs148142 	/* General MAC statistics */
7623dec9fcdSqs148142 
7633dec9fcdSqs148142 	kstat_named_init(&hxgekp->ifspeed, "ifspeed", KSTAT_DATA_UINT64);
7643dec9fcdSqs148142 	kstat_named_init(&hxgekp->promisc, "promisc", KSTAT_DATA_CHAR);
7653dec9fcdSqs148142 
7663dec9fcdSqs148142 	ksp->ks_update = hxge_port_kstat_update;
7673dec9fcdSqs148142 	ksp->ks_private = (void *) hxgep;
7683dec9fcdSqs148142 	kstat_install(ksp);
7693dec9fcdSqs148142 	hxgep->statsp->port_ksp = ksp;
7703dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_setup_kstats"));
7713dec9fcdSqs148142 }
7723dec9fcdSqs148142 
7733dec9fcdSqs148142 void
7743dec9fcdSqs148142 hxge_destroy_kstats(p_hxge_t hxgep)
7753dec9fcdSqs148142 {
7763dec9fcdSqs148142 	int			channel;
7773dec9fcdSqs148142 	p_hxge_dma_pt_cfg_t	p_dma_cfgp;
7783dec9fcdSqs148142 	p_hxge_hw_pt_cfg_t	p_cfgp;
7793dec9fcdSqs148142 
7803dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_destroy_kstats"));
7813dec9fcdSqs148142 	if (hxgep->statsp == NULL)
7823dec9fcdSqs148142 		return;
7833dec9fcdSqs148142 
7843dec9fcdSqs148142 	if (hxgep->statsp->ksp)
7853dec9fcdSqs148142 		kstat_delete(hxgep->statsp->ksp);
7863dec9fcdSqs148142 
7873dec9fcdSqs148142 	p_dma_cfgp = (p_hxge_dma_pt_cfg_t)&hxgep->pt_config;
7883dec9fcdSqs148142 	p_cfgp = (p_hxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config;
7893dec9fcdSqs148142 
7903dec9fcdSqs148142 	for (channel = 0; channel < p_cfgp->max_rdcs; channel++) {
7913dec9fcdSqs148142 		if (hxgep->statsp->rdc_ksp[channel]) {
7923dec9fcdSqs148142 			kstat_delete(hxgep->statsp->rdc_ksp[channel]);
7933dec9fcdSqs148142 		}
7943dec9fcdSqs148142 	}
7953dec9fcdSqs148142 
7963dec9fcdSqs148142 	for (channel = 0; channel < p_cfgp->max_tdcs; channel++) {
7973dec9fcdSqs148142 		if (hxgep->statsp->tdc_ksp[channel]) {
7983dec9fcdSqs148142 			kstat_delete(hxgep->statsp->tdc_ksp[channel]);
7993dec9fcdSqs148142 		}
8003dec9fcdSqs148142 	}
8013dec9fcdSqs148142 
8023dec9fcdSqs148142 	if (hxgep->statsp->rdc_sys_ksp)
8033dec9fcdSqs148142 		kstat_delete(hxgep->statsp->rdc_sys_ksp);
8043dec9fcdSqs148142 
8053dec9fcdSqs148142 	if (hxgep->statsp->tdc_sys_ksp)
8063dec9fcdSqs148142 		kstat_delete(hxgep->statsp->tdc_sys_ksp);
8073dec9fcdSqs148142 
8083dec9fcdSqs148142 	if (hxgep->statsp->peu_sys_ksp)
8093dec9fcdSqs148142 		kstat_delete(hxgep->statsp->peu_sys_ksp);
8103dec9fcdSqs148142 
8113dec9fcdSqs148142 	if (hxgep->statsp->mmac_ksp)
8123dec9fcdSqs148142 		kstat_delete(hxgep->statsp->mmac_ksp);
8133dec9fcdSqs148142 
8143dec9fcdSqs148142 	if (hxgep->statsp->pfc_ksp)
8153dec9fcdSqs148142 		kstat_delete(hxgep->statsp->pfc_ksp);
8163dec9fcdSqs148142 
8173dec9fcdSqs148142 	if (hxgep->statsp->vmac_ksp)
8183dec9fcdSqs148142 		kstat_delete(hxgep->statsp->vmac_ksp);
8193dec9fcdSqs148142 
8203dec9fcdSqs148142 	if (hxgep->statsp->port_ksp)
8213dec9fcdSqs148142 		kstat_delete(hxgep->statsp->port_ksp);
8223dec9fcdSqs148142 
8233dec9fcdSqs148142 	if (hxgep->statsp)
8243dec9fcdSqs148142 		KMEM_FREE(hxgep->statsp, hxgep->statsp->stats_size);
8253dec9fcdSqs148142 
8263dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_destroy_kstats"));
8273dec9fcdSqs148142 }
8283dec9fcdSqs148142 
8293dec9fcdSqs148142 /* ARGSUSED */
8303dec9fcdSqs148142 int
8313dec9fcdSqs148142 hxge_port_kstat_update(kstat_t *ksp, int rw)
8323dec9fcdSqs148142 {
8333dec9fcdSqs148142 	p_hxge_t		hxgep;
8343dec9fcdSqs148142 	p_hxge_stats_t		statsp;
8353dec9fcdSqs148142 	p_hxge_port_kstat_t	hxgekp;
8363dec9fcdSqs148142 	p_hxge_port_stats_t	psp;
8373dec9fcdSqs148142 
8383dec9fcdSqs148142 	hxgep = (p_hxge_t)ksp->ks_private;
8393dec9fcdSqs148142 	if (hxgep == NULL)
8403dec9fcdSqs148142 		return (-1);
8413dec9fcdSqs148142 
8423dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_port_kstat_update"));
8433dec9fcdSqs148142 	statsp = (p_hxge_stats_t)hxgep->statsp;
8443dec9fcdSqs148142 	hxgekp = (p_hxge_port_kstat_t)ksp->ks_data;
8453dec9fcdSqs148142 	psp = &statsp->port_stats;
8463dec9fcdSqs148142 
8473dec9fcdSqs148142 	if (hxgep->filter.all_phys_cnt)
8483dec9fcdSqs148142 		(void) strcpy(hxgekp->promisc.value.c, "phys");
8493dec9fcdSqs148142 	else if (hxgep->filter.all_multicast_cnt)
8503dec9fcdSqs148142 		(void) strcpy(hxgekp->promisc.value.c, "multi");
8513dec9fcdSqs148142 	else
8523dec9fcdSqs148142 		(void) strcpy(hxgekp->promisc.value.c, "off");
8533dec9fcdSqs148142 	hxgekp->ifspeed.value.ul = statsp->mac_stats.link_speed * 1000000ULL;
8543dec9fcdSqs148142 
8553dec9fcdSqs148142 	/*
8563dec9fcdSqs148142 	 * transceiver state informations.
8573dec9fcdSqs148142 	 */
8583dec9fcdSqs148142 	hxgekp->cap_10gfdx.value.ul = statsp->mac_stats.cap_10gfdx;
8593dec9fcdSqs148142 
8603dec9fcdSqs148142 	/*
8613dec9fcdSqs148142 	 * Link partner capabilities.
8623dec9fcdSqs148142 	 */
8633dec9fcdSqs148142 	hxgekp->lp_cap_10gfdx.value.ul = statsp->mac_stats.lp_cap_10gfdx;
8643dec9fcdSqs148142 
8653dec9fcdSqs148142 	/*
8663dec9fcdSqs148142 	 * Physical link statistics.
8673dec9fcdSqs148142 	 */
8683dec9fcdSqs148142 	hxgekp->link_speed.value.ul = statsp->mac_stats.link_speed;
8693dec9fcdSqs148142 	if (statsp->mac_stats.link_duplex == 2)
8703dec9fcdSqs148142 		(void) strcpy(hxgekp->link_duplex.value.c, "full");
8713dec9fcdSqs148142 	else
8723dec9fcdSqs148142 		(void) strcpy(hxgekp->link_duplex.value.c, "unknown");
8733dec9fcdSqs148142 	hxgekp->link_up.value.ul = statsp->mac_stats.link_up;
8743dec9fcdSqs148142 
8753dec9fcdSqs148142 	/*
8763dec9fcdSqs148142 	 * Loopback statistics.
8773dec9fcdSqs148142 	 */
8783dec9fcdSqs148142 	hxgekp->lb_mode.value.ul = psp->lb_mode;
8793dec9fcdSqs148142 
8803dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_port_kstat_update"));
8813dec9fcdSqs148142 	return (0);
8823dec9fcdSqs148142 }
8833dec9fcdSqs148142 
8840dc2366fSVenugopal Iyer /*
8850dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics for a particular rx ring
8860dc2366fSVenugopal Iyer  */
8870dc2366fSVenugopal Iyer int
8880dc2366fSVenugopal Iyer hxge_rx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
8890dc2366fSVenugopal Iyer {
8900dc2366fSVenugopal Iyer 	p_hxge_ring_handle_t	rhp = (p_hxge_ring_handle_t)rdriver;
8910dc2366fSVenugopal Iyer 	p_hxge_t		hxgep = rhp->hxgep;
8920dc2366fSVenugopal Iyer 
8930dc2366fSVenugopal Iyer 	ASSERT(rhp != NULL);
8940dc2366fSVenugopal Iyer 	ASSERT(hxgep != NULL);
8950dc2366fSVenugopal Iyer 	ASSERT(hxgep->statsp != NULL);
896*5ce95b09SHengqing Hu 	ASSERT((rhp->index >= 0) && (rhp->index < HXGE_MAX_RDCS));
8970dc2366fSVenugopal Iyer 
8980dc2366fSVenugopal Iyer 	switch (stat) {
8990dc2366fSVenugopal Iyer 	case MAC_STAT_IERRORS:
9000dc2366fSVenugopal Iyer 		*val = hxgep->statsp->rdc_stats[rhp->index].ierrors;
9010dc2366fSVenugopal Iyer 		break;
9020dc2366fSVenugopal Iyer 	case MAC_STAT_RBYTES:
9030dc2366fSVenugopal Iyer 		*val = hxgep->statsp->rdc_stats[rhp->index].ibytes;
9040dc2366fSVenugopal Iyer 		break;
9050dc2366fSVenugopal Iyer 	case MAC_STAT_IPACKETS:
9060dc2366fSVenugopal Iyer 		*val = hxgep->statsp->rdc_stats[rhp->index].ipackets;
9070dc2366fSVenugopal Iyer 		break;
9080dc2366fSVenugopal Iyer 	default:
9090dc2366fSVenugopal Iyer 		*val = 0;
9100dc2366fSVenugopal Iyer 		return (ENOTSUP);
9110dc2366fSVenugopal Iyer 	}
9120dc2366fSVenugopal Iyer 
9130dc2366fSVenugopal Iyer 	return (0);
9140dc2366fSVenugopal Iyer }
9150dc2366fSVenugopal Iyer 
9160dc2366fSVenugopal Iyer /*
9170dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics for a particular tx ring
9180dc2366fSVenugopal Iyer  */
9190dc2366fSVenugopal Iyer int
9200dc2366fSVenugopal Iyer hxge_tx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
9210dc2366fSVenugopal Iyer {
9220dc2366fSVenugopal Iyer 	p_hxge_ring_handle_t    rhp = (p_hxge_ring_handle_t)rdriver;
9230dc2366fSVenugopal Iyer 	p_hxge_t		hxgep = rhp->hxgep;
9240dc2366fSVenugopal Iyer 
9250dc2366fSVenugopal Iyer 	ASSERT(rhp != NULL);
9260dc2366fSVenugopal Iyer 	ASSERT(hxgep != NULL);
9270dc2366fSVenugopal Iyer 	ASSERT(hxgep->statsp != NULL);
928*5ce95b09SHengqing Hu 	ASSERT((rhp->index >= 0) && (rhp->index < HXGE_MAX_TDCS));
9290dc2366fSVenugopal Iyer 
9300dc2366fSVenugopal Iyer 	switch (stat) {
9310dc2366fSVenugopal Iyer 	case MAC_STAT_OERRORS:
9320dc2366fSVenugopal Iyer 		*val = hxgep->statsp->tdc_stats[rhp->index].oerrors;
9330dc2366fSVenugopal Iyer 		break;
9340dc2366fSVenugopal Iyer 	case MAC_STAT_OBYTES:
9350dc2366fSVenugopal Iyer 		*val = hxgep->statsp->tdc_stats[rhp->index].obytes;
9360dc2366fSVenugopal Iyer 		break;
9370dc2366fSVenugopal Iyer 	case MAC_STAT_OPACKETS:
9380dc2366fSVenugopal Iyer 		*val = hxgep->statsp->tdc_stats[rhp->index].opackets;
9390dc2366fSVenugopal Iyer 		break;
9400dc2366fSVenugopal Iyer 	default:
9410dc2366fSVenugopal Iyer 		*val = 0;
9420dc2366fSVenugopal Iyer 		return (ENOTSUP);
9430dc2366fSVenugopal Iyer 	}
9440dc2366fSVenugopal Iyer 
9450dc2366fSVenugopal Iyer 	return (0);
9460dc2366fSVenugopal Iyer }
9470dc2366fSVenugopal Iyer 
9483dec9fcdSqs148142 int
9493dec9fcdSqs148142 hxge_m_stat(void *arg, uint_t stat, uint64_t *value)
9503dec9fcdSqs148142 {
9513dec9fcdSqs148142 	p_hxge_t		hxgep = (p_hxge_t)arg;
9523dec9fcdSqs148142 	p_hxge_stats_t		statsp;
9533dec9fcdSqs148142 	hxge_tx_ring_stats_t	*tx_stats;
9543dec9fcdSqs148142 	uint64_t		val = 0;
9553dec9fcdSqs148142 	int			channel;
9563dec9fcdSqs148142 
9573dec9fcdSqs148142 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_m_stat"));
9583dec9fcdSqs148142 	statsp = (p_hxge_stats_t)hxgep->statsp;
9593dec9fcdSqs148142 
9603dec9fcdSqs148142 	switch (stat) {
9613dec9fcdSqs148142 	case MAC_STAT_IFSPEED:
9623dec9fcdSqs148142 		val = statsp->mac_stats.link_speed * 1000000ull;
9633dec9fcdSqs148142 		break;
9643dec9fcdSqs148142 
9653dec9fcdSqs148142 	case MAC_STAT_MULTIRCV:
9663dec9fcdSqs148142 		val = 0;
9673dec9fcdSqs148142 		break;
9683dec9fcdSqs148142 
9693dec9fcdSqs148142 	case MAC_STAT_BRDCSTRCV:
9703dec9fcdSqs148142 		val = 0;
9713dec9fcdSqs148142 		break;
9723dec9fcdSqs148142 
9733dec9fcdSqs148142 	case MAC_STAT_MULTIXMT:
9743dec9fcdSqs148142 		val = 0;
9753dec9fcdSqs148142 		break;
9763dec9fcdSqs148142 
9773dec9fcdSqs148142 	case MAC_STAT_BRDCSTXMT:
9783dec9fcdSqs148142 		val = 0;
9793dec9fcdSqs148142 		break;
9803dec9fcdSqs148142 
9813dec9fcdSqs148142 	case MAC_STAT_NORCVBUF:
9823dec9fcdSqs148142 		val = 0;
9833dec9fcdSqs148142 		break;
9843dec9fcdSqs148142 
9853dec9fcdSqs148142 	case MAC_STAT_IERRORS:
9863dec9fcdSqs148142 	case ETHER_STAT_MACRCV_ERRORS:
9873dec9fcdSqs148142 		val = 0;
9883dec9fcdSqs148142 		for (channel = 0; channel < hxgep->nrdc; channel++) {
9893dec9fcdSqs148142 			val += statsp->rdc_stats[channel].ierrors;
9903dec9fcdSqs148142 		}
9913dec9fcdSqs148142 		break;
9923dec9fcdSqs148142 
9933dec9fcdSqs148142 	case MAC_STAT_NOXMTBUF:
9943dec9fcdSqs148142 		val = 0;
9953dec9fcdSqs148142 		break;
9963dec9fcdSqs148142 
9973dec9fcdSqs148142 	case MAC_STAT_OERRORS:
9983dec9fcdSqs148142 		for (channel = 0; channel < hxgep->ntdc; channel++) {
9993dec9fcdSqs148142 			val += statsp->tdc_stats[channel].oerrors;
10003dec9fcdSqs148142 		}
10013dec9fcdSqs148142 		break;
10023dec9fcdSqs148142 
10033dec9fcdSqs148142 	case MAC_STAT_COLLISIONS:
10043dec9fcdSqs148142 		val = 0;
10053dec9fcdSqs148142 		break;
10063dec9fcdSqs148142 
10073dec9fcdSqs148142 	case MAC_STAT_RBYTES:
10083dec9fcdSqs148142 		for (channel = 0; channel < hxgep->nrdc; channel++) {
10093dec9fcdSqs148142 			val += statsp->rdc_stats[channel].ibytes;
10103dec9fcdSqs148142 		}
10113dec9fcdSqs148142 		break;
10123dec9fcdSqs148142 
10133dec9fcdSqs148142 	case MAC_STAT_IPACKETS:
10143dec9fcdSqs148142 		for (channel = 0; channel < hxgep->nrdc; channel++) {
10153dec9fcdSqs148142 			val += statsp->rdc_stats[channel].ipackets;
10163dec9fcdSqs148142 		}
10173dec9fcdSqs148142 		break;
10183dec9fcdSqs148142 
10193dec9fcdSqs148142 	case MAC_STAT_OBYTES:
10203dec9fcdSqs148142 		for (channel = 0; channel < hxgep->ntdc; channel++) {
10213dec9fcdSqs148142 			val += statsp->tdc_stats[channel].obytes;
10223dec9fcdSqs148142 		}
10233dec9fcdSqs148142 		break;
10243dec9fcdSqs148142 
10253dec9fcdSqs148142 	case MAC_STAT_OPACKETS:
10263dec9fcdSqs148142 		for (channel = 0; channel < hxgep->ntdc; channel++) {
10273dec9fcdSqs148142 			val += statsp->tdc_stats[channel].opackets;
10283dec9fcdSqs148142 		}
10293dec9fcdSqs148142 		break;
10303dec9fcdSqs148142 
10313dec9fcdSqs148142 	case MAC_STAT_UNKNOWNS:
10323dec9fcdSqs148142 		val = 0;
10333dec9fcdSqs148142 		break;
10343dec9fcdSqs148142 
10353dec9fcdSqs148142 	case MAC_STAT_UNDERFLOWS:
10363dec9fcdSqs148142 		val = 0;
10373dec9fcdSqs148142 		break;
10383dec9fcdSqs148142 
10393dec9fcdSqs148142 	case MAC_STAT_OVERFLOWS:
10403dec9fcdSqs148142 		val = 0;
10413dec9fcdSqs148142 		break;
10423dec9fcdSqs148142 
10433dec9fcdSqs148142 	case MAC_STAT_LINK_STATE:
10443dec9fcdSqs148142 		val = statsp->mac_stats.link_duplex;
10453dec9fcdSqs148142 		break;
10463dec9fcdSqs148142 	case MAC_STAT_LINK_UP:
10473dec9fcdSqs148142 		val = statsp->mac_stats.link_up;
10483dec9fcdSqs148142 		break;
10493dec9fcdSqs148142 	case MAC_STAT_PROMISC:
10503dec9fcdSqs148142 		val = statsp->mac_stats.promisc;
10513dec9fcdSqs148142 		break;
10523dec9fcdSqs148142 	case ETHER_STAT_SQE_ERRORS:
10533dec9fcdSqs148142 		val = 0;
10543dec9fcdSqs148142 		break;
10553dec9fcdSqs148142 
10563dec9fcdSqs148142 	case ETHER_STAT_ALIGN_ERRORS:
10573dec9fcdSqs148142 		/*
10583dec9fcdSqs148142 		 * No similar error in Hydra receive channels
10593dec9fcdSqs148142 		 */
10603dec9fcdSqs148142 		val = 0;
10613dec9fcdSqs148142 		break;
10623dec9fcdSqs148142 
10633dec9fcdSqs148142 	case ETHER_STAT_FCS_ERRORS:
10643dec9fcdSqs148142 		/*
10653dec9fcdSqs148142 		 * No similar error in Hydra receive channels
10663dec9fcdSqs148142 		 */
10673dec9fcdSqs148142 		val = 0;
10683dec9fcdSqs148142 		break;
10693dec9fcdSqs148142 
10703dec9fcdSqs148142 	case ETHER_STAT_FIRST_COLLISIONS:
10713dec9fcdSqs148142 		val = 0;
10723dec9fcdSqs148142 		break;
10733dec9fcdSqs148142 
10743dec9fcdSqs148142 	case ETHER_STAT_MULTI_COLLISIONS:
10753dec9fcdSqs148142 		val = 0;
10763dec9fcdSqs148142 		break;
10773dec9fcdSqs148142 
10783dec9fcdSqs148142 	case ETHER_STAT_TX_LATE_COLLISIONS:
10793dec9fcdSqs148142 		val = 0;
10803dec9fcdSqs148142 		break;
10813dec9fcdSqs148142 
10823dec9fcdSqs148142 	case ETHER_STAT_EX_COLLISIONS:
10833dec9fcdSqs148142 		val = 0;
10843dec9fcdSqs148142 		break;
10853dec9fcdSqs148142 
10863dec9fcdSqs148142 	case ETHER_STAT_DEFER_XMTS:
10873dec9fcdSqs148142 		val = 0;
10883dec9fcdSqs148142 		break;
10893dec9fcdSqs148142 
10903dec9fcdSqs148142 	case ETHER_STAT_MACXMT_ERRORS:
10913dec9fcdSqs148142 		/*
10923dec9fcdSqs148142 		 * A count of frames for which transmission on a
10933dec9fcdSqs148142 		 * particular interface fails due to an internal
10943dec9fcdSqs148142 		 * MAC sublayer transmit error
10953dec9fcdSqs148142 		 */
10963dec9fcdSqs148142 		for (channel = 0; channel < hxgep->ntdc; channel++) {
10973dec9fcdSqs148142 			tx_stats = &statsp->tdc_stats[channel];
10983dec9fcdSqs148142 			val += tx_stats->pkt_size_hdr_err +
10993dec9fcdSqs148142 			    tx_stats->pkt_size_err +
11003dec9fcdSqs148142 			    tx_stats->tx_rng_oflow +
11013dec9fcdSqs148142 			    tx_stats->peu_resp_err +
11023dec9fcdSqs148142 			    tx_stats->runt_pkt_drop_err +
11033dec9fcdSqs148142 			    tx_stats->pref_par_err +
11043dec9fcdSqs148142 			    tx_stats->tdr_pref_cpl_to +
11053dec9fcdSqs148142 			    tx_stats->pkt_cpl_to +
11063dec9fcdSqs148142 			    tx_stats->invalid_sop +
11073dec9fcdSqs148142 			    tx_stats->unexpected_sop;
11083dec9fcdSqs148142 		}
11093dec9fcdSqs148142 		break;
11103dec9fcdSqs148142 
11113dec9fcdSqs148142 	case ETHER_STAT_CARRIER_ERRORS:
11123dec9fcdSqs148142 		/*
11133dec9fcdSqs148142 		 * The number of times that the carrier sense
11143dec9fcdSqs148142 		 * condition was lost or never asserted when
11153dec9fcdSqs148142 		 * attempting to transmit a frame on a particular interface
11163dec9fcdSqs148142 		 */
11173dec9fcdSqs148142 		for (channel = 0; channel < hxgep->ntdc; channel++) {
11183dec9fcdSqs148142 			tx_stats = &statsp->tdc_stats[channel];
11193dec9fcdSqs148142 			val += tx_stats->tdr_pref_cpl_to + tx_stats->pkt_cpl_to;
11203dec9fcdSqs148142 		}
11213dec9fcdSqs148142 		break;
11223dec9fcdSqs148142 
11233dec9fcdSqs148142 	case ETHER_STAT_TOOLONG_ERRORS:
11243dec9fcdSqs148142 		/*
11253dec9fcdSqs148142 		 * A count of frames received on a particular
11263dec9fcdSqs148142 		 * interface that exceed the maximum permitted frame size
11273dec9fcdSqs148142 		 */
11283dec9fcdSqs148142 		for (channel = 0; channel < hxgep->ntdc; channel++) {
11293dec9fcdSqs148142 			tx_stats = &statsp->tdc_stats[channel];
11303dec9fcdSqs148142 			val += tx_stats->pkt_size_err;
11313dec9fcdSqs148142 		}
11323dec9fcdSqs148142 		break;
11333dec9fcdSqs148142 
11343dec9fcdSqs148142 	case ETHER_STAT_XCVR_ADDR:
11353dec9fcdSqs148142 		val = 0;
11363dec9fcdSqs148142 		break;
11373dec9fcdSqs148142 	case ETHER_STAT_XCVR_ID:
11383dec9fcdSqs148142 		val = 0;
11393dec9fcdSqs148142 		break;
11403dec9fcdSqs148142 
11413dec9fcdSqs148142 	case ETHER_STAT_XCVR_INUSE:
11423dec9fcdSqs148142 		val = 0;
11433dec9fcdSqs148142 		break;
11443dec9fcdSqs148142 
11453dec9fcdSqs148142 	case ETHER_STAT_CAP_1000FDX:
11463dec9fcdSqs148142 		val = 0;
11473dec9fcdSqs148142 		break;
11483dec9fcdSqs148142 
11493dec9fcdSqs148142 	case ETHER_STAT_CAP_1000HDX:
11503dec9fcdSqs148142 		val = 0;
11513dec9fcdSqs148142 		break;
11523dec9fcdSqs148142 
11533dec9fcdSqs148142 	case ETHER_STAT_CAP_100FDX:
11543dec9fcdSqs148142 		val = 0;
11553dec9fcdSqs148142 		break;
11563dec9fcdSqs148142 
11573dec9fcdSqs148142 	case ETHER_STAT_CAP_100HDX:
11583dec9fcdSqs148142 		val = 0;
11593dec9fcdSqs148142 		break;
11603dec9fcdSqs148142 
11613dec9fcdSqs148142 	case ETHER_STAT_CAP_10FDX:
11623dec9fcdSqs148142 		val = 0;
11633dec9fcdSqs148142 		break;
11643dec9fcdSqs148142 
11653dec9fcdSqs148142 	case ETHER_STAT_CAP_10HDX:
11663dec9fcdSqs148142 		val = 0;
11673dec9fcdSqs148142 		break;
11683dec9fcdSqs148142 
11693dec9fcdSqs148142 	case ETHER_STAT_CAP_ASMPAUSE:
11703dec9fcdSqs148142 		val = 0;
11713dec9fcdSqs148142 		break;
11723dec9fcdSqs148142 
11733dec9fcdSqs148142 	case ETHER_STAT_CAP_PAUSE:
11743dec9fcdSqs148142 		val = 0;
11753dec9fcdSqs148142 		break;
11763dec9fcdSqs148142 
11773dec9fcdSqs148142 	case ETHER_STAT_CAP_AUTONEG:
11783dec9fcdSqs148142 		val = 0;
11793dec9fcdSqs148142 		break;
11803dec9fcdSqs148142 
11813dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_1000FDX:
11823dec9fcdSqs148142 		val = 0;
11833dec9fcdSqs148142 		break;
11843dec9fcdSqs148142 
11853dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_1000HDX:
11863dec9fcdSqs148142 		val = 0;
11873dec9fcdSqs148142 		break;
11883dec9fcdSqs148142 
11893dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_100FDX:
11903dec9fcdSqs148142 		val = 0;
11913dec9fcdSqs148142 		break;
11923dec9fcdSqs148142 
11933dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_100HDX:
11943dec9fcdSqs148142 		val = 0;
11953dec9fcdSqs148142 		break;
11963dec9fcdSqs148142 
11973dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_10FDX:
11983dec9fcdSqs148142 		val = 0;
11993dec9fcdSqs148142 		break;
12003dec9fcdSqs148142 
12013dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_10HDX:
12023dec9fcdSqs148142 		val = 0;
12033dec9fcdSqs148142 		break;
12043dec9fcdSqs148142 
12053dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_ASMPAUSE:
12063dec9fcdSqs148142 		val = 0;
12073dec9fcdSqs148142 		break;
12083dec9fcdSqs148142 
12093dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_PAUSE:
12103dec9fcdSqs148142 		val = 0;
12113dec9fcdSqs148142 		break;
12123dec9fcdSqs148142 
12133dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_AUTONEG:
12143dec9fcdSqs148142 		val = 0;
12153dec9fcdSqs148142 		break;
12163dec9fcdSqs148142 
12173dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_1000FDX:
12183dec9fcdSqs148142 		val = 0;
12193dec9fcdSqs148142 		break;
12203dec9fcdSqs148142 
12213dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_1000HDX:
12223dec9fcdSqs148142 		val = 0;
12233dec9fcdSqs148142 		break;
12243dec9fcdSqs148142 
12253dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_100FDX:
12263dec9fcdSqs148142 		val = 0;
12273dec9fcdSqs148142 		break;
12283dec9fcdSqs148142 
12293dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_100HDX:
12303dec9fcdSqs148142 		val = 0;
12313dec9fcdSqs148142 		break;
12323dec9fcdSqs148142 
12333dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_10FDX:
12343dec9fcdSqs148142 		val = 0;
12353dec9fcdSqs148142 		break;
12363dec9fcdSqs148142 
12373dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_10HDX:
12383dec9fcdSqs148142 		val = 0;
12393dec9fcdSqs148142 		break;
12403dec9fcdSqs148142 
12413dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_ASMPAUSE:
12423dec9fcdSqs148142 		val = 0;
12433dec9fcdSqs148142 		break;
12443dec9fcdSqs148142 
12453dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_PAUSE:
12463dec9fcdSqs148142 		val = 0;
12473dec9fcdSqs148142 		break;
12483dec9fcdSqs148142 
12493dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_AUTONEG:
12503dec9fcdSqs148142 		val = 0;
12513dec9fcdSqs148142 		break;
12523dec9fcdSqs148142 
12533dec9fcdSqs148142 	case ETHER_STAT_LINK_ASMPAUSE:
12543dec9fcdSqs148142 		val = 0;
12553dec9fcdSqs148142 		break;
12563dec9fcdSqs148142 
12573dec9fcdSqs148142 	case ETHER_STAT_LINK_PAUSE:
12583dec9fcdSqs148142 		val = 0;
12593dec9fcdSqs148142 		break;
12603dec9fcdSqs148142 
12613dec9fcdSqs148142 	case ETHER_STAT_LINK_AUTONEG:
12623dec9fcdSqs148142 		val = 0;
12633dec9fcdSqs148142 		break;
12643dec9fcdSqs148142 
12653dec9fcdSqs148142 	case ETHER_STAT_LINK_DUPLEX:
12663dec9fcdSqs148142 		val = statsp->mac_stats.link_duplex;
12673dec9fcdSqs148142 		break;
12683dec9fcdSqs148142 
12693dec9fcdSqs148142 	case ETHER_STAT_TOOSHORT_ERRORS:
12703dec9fcdSqs148142 		val = 0;
12713dec9fcdSqs148142 		break;
12723dec9fcdSqs148142 
12733dec9fcdSqs148142 	case ETHER_STAT_CAP_REMFAULT:
12743dec9fcdSqs148142 		val = 0;
12753dec9fcdSqs148142 		break;
12763dec9fcdSqs148142 
12773dec9fcdSqs148142 	case ETHER_STAT_ADV_REMFAULT:
12783dec9fcdSqs148142 		val = 0;
12793dec9fcdSqs148142 		break;
12803dec9fcdSqs148142 
12813dec9fcdSqs148142 	case ETHER_STAT_LP_REMFAULT:
12823dec9fcdSqs148142 		val = 0;
12833dec9fcdSqs148142 		break;
12843dec9fcdSqs148142 
12853dec9fcdSqs148142 	case ETHER_STAT_JABBER_ERRORS:
12863dec9fcdSqs148142 		val = 0;
12873dec9fcdSqs148142 		break;
12883dec9fcdSqs148142 
12893dec9fcdSqs148142 	case ETHER_STAT_CAP_100T4:
12903dec9fcdSqs148142 		val = 0;
12913dec9fcdSqs148142 		break;
12923dec9fcdSqs148142 
12933dec9fcdSqs148142 	case ETHER_STAT_ADV_CAP_100T4:
12943dec9fcdSqs148142 		val = 0;
12953dec9fcdSqs148142 		break;
12963dec9fcdSqs148142 
12973dec9fcdSqs148142 	case ETHER_STAT_LP_CAP_100T4:
12983dec9fcdSqs148142 		val = 0;
12993dec9fcdSqs148142 		break;
13003dec9fcdSqs148142 
13016ffca240SMichael Speer 	case ETHER_STAT_ADV_CAP_10GFDX:
13026ffca240SMichael Speer 	case ETHER_STAT_CAP_10GFDX:
13036ffca240SMichael Speer 	case ETHER_STAT_LP_CAP_10GFDX:
13046ffca240SMichael Speer 		val = 0;
13056ffca240SMichael Speer 		break;
13066ffca240SMichael Speer 
13073dec9fcdSqs148142 	default:
13083dec9fcdSqs148142 		/*
13093dec9fcdSqs148142 		 * Shouldn't reach here...
13103dec9fcdSqs148142 		 */
13113dec9fcdSqs148142 		cmn_err(CE_WARN,
13123dec9fcdSqs148142 		    "hxge_m_stat: unrecognized parameter value = 0x%x", stat);
13133dec9fcdSqs148142 		return (ENOTSUP);
13143dec9fcdSqs148142 	}
13153dec9fcdSqs148142 	*value = val;
13163dec9fcdSqs148142 	return (0);
13173dec9fcdSqs148142 }
13181ed83081SMichael Speer 
13191ed83081SMichael Speer static uint64_t
13201ed83081SMichael Speer hxge_mac_octet_to_u64(uint8_t *addr)
13211ed83081SMichael Speer {
13221ed83081SMichael Speer 	int		i;
13231ed83081SMichael Speer 	uint64_t	addr64 = 0;
13241ed83081SMichael Speer 
13251ed83081SMichael Speer 	for (i = ETHERADDRL - 1; i >= 0; i--) {
13261ed83081SMichael Speer 		addr64 <<= 8;
13271ed83081SMichael Speer 		addr64 |= addr[i];
13281ed83081SMichael Speer 	}
13291ed83081SMichael Speer 	return (addr64);
13301ed83081SMichael Speer }
13311ed83081SMichael Speer 
13321ed83081SMichael Speer /*ARGSUSED*/
13331ed83081SMichael Speer static int
13341ed83081SMichael Speer hxge_mmac_stat_update(kstat_t *ksp, int rw)
13351ed83081SMichael Speer {
13361ed83081SMichael Speer 	p_hxge_t		hxgep;
13371ed83081SMichael Speer 	p_hxge_mmac_kstat_t	mmac_kstatsp;
13381ed83081SMichael Speer 
13391ed83081SMichael Speer 	hxgep = (p_hxge_t)ksp->ks_private;
13401ed83081SMichael Speer 	if (hxgep == NULL)
13411ed83081SMichael Speer 		return (-1);
13421ed83081SMichael Speer 
13431ed83081SMichael Speer 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "==> hxge_mmac_stat_update"));
13441ed83081SMichael Speer 
13451ed83081SMichael Speer 	if (rw == KSTAT_WRITE) {
13461ed83081SMichael Speer 		cmn_err(CE_WARN, "Can not write mmac stats");
13471ed83081SMichael Speer 	} else {
13481ed83081SMichael Speer 		MUTEX_ENTER(hxgep->genlock);
13491ed83081SMichael Speer 		mmac_kstatsp = (p_hxge_mmac_kstat_t)ksp->ks_data;
13501ed83081SMichael Speer 		mmac_kstatsp->mmac_max_addr_cnt.value.ul = hxgep->mmac.total;
13511ed83081SMichael Speer 		mmac_kstatsp->mmac_avail_addr_cnt.value.ul =
13521ed83081SMichael Speer 		    hxgep->mmac.available;
13531ed83081SMichael Speer 		mmac_kstatsp->mmac_addr1.value.ul =
13541ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[0].addr);
13551ed83081SMichael Speer 		mmac_kstatsp->mmac_addr2.value.ul =
13561ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[1].addr);
13571ed83081SMichael Speer 		mmac_kstatsp->mmac_addr3.value.ul =
13581ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[2].addr);
13591ed83081SMichael Speer 		mmac_kstatsp->mmac_addr4.value.ul =
13601ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[3].addr);
13611ed83081SMichael Speer 		mmac_kstatsp->mmac_addr5.value.ul =
13621ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[4].addr);
13631ed83081SMichael Speer 		mmac_kstatsp->mmac_addr6.value.ul =
13641ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[5].addr);
13651ed83081SMichael Speer 		mmac_kstatsp->mmac_addr7.value.ul =
13661ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[6].addr);
13671ed83081SMichael Speer 		mmac_kstatsp->mmac_addr8.value.ul =
13681ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[7].addr);
13691ed83081SMichael Speer 		mmac_kstatsp->mmac_addr9.value.ul =
13701ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[8].addr);
13711ed83081SMichael Speer 		mmac_kstatsp->mmac_addr10.value.ul =
13721ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[9].addr);
13731ed83081SMichael Speer 		mmac_kstatsp->mmac_addr11.value.ul =
13741ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[10].addr);
13751ed83081SMichael Speer 		mmac_kstatsp->mmac_addr12.value.ul =
13761ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[11].addr);
13771ed83081SMichael Speer 		mmac_kstatsp->mmac_addr13.value.ul =
13781ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[12].addr);
13791ed83081SMichael Speer 		mmac_kstatsp->mmac_addr14.value.ul =
13801ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[13].addr);
13811ed83081SMichael Speer 		mmac_kstatsp->mmac_addr15.value.ul =
13821ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[14].addr);
13831ed83081SMichael Speer 		mmac_kstatsp->mmac_addr16.value.ul =
13841ed83081SMichael Speer 		    hxge_mac_octet_to_u64(hxgep->mmac.addrs[15].addr);
13851ed83081SMichael Speer 		MUTEX_EXIT(hxgep->genlock);
13861ed83081SMichael Speer 	}
13871ed83081SMichael Speer 
13881ed83081SMichael Speer 	HXGE_DEBUG_MSG((hxgep, KST_CTL, "<== hxge_mmac_stat_update"));
13891ed83081SMichael Speer 	return (0);
13901ed83081SMichael Speer }
1391