xref: /titanic_50/usr/src/uts/common/io/nxge/nxge_kstats.c (revision 0dc2366f7b9f9f36e10909b1e95edbf2a261c2ac)
16f45ec7bSml29623 /*
26f45ec7bSml29623  * CDDL HEADER START
36f45ec7bSml29623  *
46f45ec7bSml29623  * The contents of this file are subject to the terms of the
56f45ec7bSml29623  * Common Development and Distribution License (the "License").
66f45ec7bSml29623  * You may not use this file except in compliance with the License.
76f45ec7bSml29623  *
86f45ec7bSml29623  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96f45ec7bSml29623  * or http://www.opensolaris.org/os/licensing.
106f45ec7bSml29623  * See the License for the specific language governing permissions
116f45ec7bSml29623  * and limitations under the License.
126f45ec7bSml29623  *
136f45ec7bSml29623  * When distributing Covered Code, include this CDDL HEADER in each
146f45ec7bSml29623  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156f45ec7bSml29623  * If applicable, add the following below this CDDL HEADER, with the
166f45ec7bSml29623  * fields enclosed by brackets "[]" replaced with your own identifying
176f45ec7bSml29623  * information: Portions Copyright [yyyy] [name of copyright owner]
186f45ec7bSml29623  *
196f45ec7bSml29623  * CDDL HEADER END
206f45ec7bSml29623  */
216f45ec7bSml29623 /*
22*0dc2366fSVenugopal Iyer  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
236f45ec7bSml29623  * Use is subject to license terms.
246f45ec7bSml29623  */
256f45ec7bSml29623 
266f45ec7bSml29623 #include <sys/nxge/nxge_impl.h>
27678453a8Sspeer #include <sys/nxge/nxge_hio.h>
28678453a8Sspeer 
296f45ec7bSml29623 #include <inet/mi.h>
306f45ec7bSml29623 
316f45ec7bSml29623 #define	RDC_NAME_FORMAT1	"RDC Channel"
326f45ec7bSml29623 #define	TDC_NAME_FORMAT1	"TDC Channel"
336f45ec7bSml29623 #define	CH_NAME_FORMAT		" %d Stats"
346f45ec7bSml29623 #define	TDC_NAME_FORMAT		"TDC Channel %d Stats"
356f45ec7bSml29623 #define	RDC_NAME_FORMAT		"RDC Channel %d Stats"
366f45ec7bSml29623 
376f45ec7bSml29623 void nxge_mac_init_kstats(p_nxge_t, struct kstat *);
386f45ec7bSml29623 void nxge_xmac_init_kstats(struct kstat *);
396f45ec7bSml29623 void nxge_bmac_init_kstats(struct kstat *);
406f45ec7bSml29623 
416f45ec7bSml29623 /* ARGSUSED */
426f45ec7bSml29623 void
nxge_init_statsp(p_nxge_t nxgep)436f45ec7bSml29623 nxge_init_statsp(p_nxge_t nxgep)
446f45ec7bSml29623 {
456f45ec7bSml29623 	size_t stats_size;
466f45ec7bSml29623 
476f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_init_statsp"));
486f45ec7bSml29623 
496f45ec7bSml29623 	stats_size = sizeof (nxge_stats_t);
506f45ec7bSml29623 	nxgep->statsp = KMEM_ZALLOC(stats_size, KM_SLEEP);
516f45ec7bSml29623 	nxgep->statsp->stats_size = stats_size;
526f45ec7bSml29623 
536f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_init_statsp"));
546f45ec7bSml29623 }
556f45ec7bSml29623 
566f45ec7bSml29623 typedef struct {
576f45ec7bSml29623 	uint8_t index;
586f45ec7bSml29623 	uint8_t type;
596f45ec7bSml29623 	char *name;
606f45ec7bSml29623 } nxge_kstat_index_t;
616f45ec7bSml29623 
626f45ec7bSml29623 typedef enum {
636f45ec7bSml29623 	RDC_STAT_PACKETS = 0,
646f45ec7bSml29623 	RDC_STAT_BYTES,
656f45ec7bSml29623 	RDC_STAT_ERRORS,
666f45ec7bSml29623 	RDC_STAT_DCF_ERR,
676f45ec7bSml29623 	RDC_STAT_RCR_ACK_ERR,
686f45ec7bSml29623 	RDC_STAT_RCR_DC_FIFOFLOW_ERR,
696f45ec7bSml29623 	RDC_STAT_RCR_SHA_PAR_ERR,
706f45ec7bSml29623 	RDC_STAT_RBR_PRE_PAR_ERR,
716f45ec7bSml29623 	RDC_STAT_WRED_DROP,
726f45ec7bSml29623 	RDC_STAT_RBR_PRE_EMTY,
736f45ec7bSml29623 	RDC_STAT_RCR_SHADOW_FULL,
746f45ec7bSml29623 	RDC_STAT_RBR_TMOUT,
756f45ec7bSml29623 	RDC_STAT_RSP_CNT_ERR,
766f45ec7bSml29623 	RDC_STAT_BYTE_EN_BUS,
776f45ec7bSml29623 	RDC_STAT_RSP_DAT_ERR,
784202ea4bSsbehera 	RDC_STAT_PKT_TOO_LONG_ERR,
796f45ec7bSml29623 	RDC_STAT_COMPL_L2_ERR,
806f45ec7bSml29623 	RDC_STAT_COMPL_L4_CKSUM_ERR,
816f45ec7bSml29623 	RDC_STAT_COMPL_ZCP_SOFT_ERR,
826f45ec7bSml29623 	RDC_STAT_COMPL_FFLP_SOFT_ERR,
836f45ec7bSml29623 	RDC_STAT_CONFIG_ERR,
846f45ec7bSml29623 	RDC_STAT_RCRINCON,
856f45ec7bSml29623 	RDC_STAT_RCRFULL,
866f45ec7bSml29623 	RDC_STAT_RBR_EMPTY,
876f45ec7bSml29623 	RDC_STAT_RBR_FULL,
886f45ec7bSml29623 	RDC_STAT_RBRLOGPAGE,
896f45ec7bSml29623 	RDC_STAT_CFIGLOGPAGE,
906f45ec7bSml29623 	RDC_STAT_PORT_DROP_PKT,
916f45ec7bSml29623 	RDC_STAT_RCRTO,
926f45ec7bSml29623 	RDC_STAT_RCRTHRES,
936f45ec7bSml29623 	RDC_STAT_MEX,
946f45ec7bSml29623 	RDC_STAT_ID_MIS,
956f45ec7bSml29623 	RDC_STAT_ZCP_EOP,
966f45ec7bSml29623 	RDC_STAT_IPP_EOP,
976f45ec7bSml29623 	RDC_STAT_END
986f45ec7bSml29623 } nxge_rdc_stat_index_t;
996f45ec7bSml29623 
1006f45ec7bSml29623 nxge_kstat_index_t nxge_rdc_stats[] = {
1016f45ec7bSml29623 	{RDC_STAT_PACKETS, KSTAT_DATA_UINT64, "rdc_packets"},
1026f45ec7bSml29623 	{RDC_STAT_BYTES, KSTAT_DATA_UINT64, "rdc_bytes"},
1036f45ec7bSml29623 	{RDC_STAT_ERRORS, KSTAT_DATA_ULONG, "rdc_errors"},
1046f45ec7bSml29623 	{RDC_STAT_DCF_ERR, KSTAT_DATA_ULONG, "rdc_dcf_err"},
1056f45ec7bSml29623 	{RDC_STAT_RCR_ACK_ERR, KSTAT_DATA_ULONG, "rdc_rcr_ack_err"},
1066f45ec7bSml29623 	{RDC_STAT_RCR_DC_FIFOFLOW_ERR, KSTAT_DATA_ULONG, "rdc_dc_fifoflow_err"},
1076f45ec7bSml29623 	{RDC_STAT_RCR_SHA_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rcr_sha_par_err"},
1086f45ec7bSml29623 	{RDC_STAT_RBR_PRE_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rbr_pre_par_err"},
1096f45ec7bSml29623 	{RDC_STAT_WRED_DROP, KSTAT_DATA_ULONG, "rdc_wred_drop"},
1106f45ec7bSml29623 	{RDC_STAT_RBR_PRE_EMTY, KSTAT_DATA_ULONG, "rdc_rbr_pre_empty"},
1116f45ec7bSml29623 	{RDC_STAT_RCR_SHADOW_FULL, KSTAT_DATA_ULONG, "rdc_rcr_shadow_full"},
1126f45ec7bSml29623 	{RDC_STAT_RBR_TMOUT, KSTAT_DATA_ULONG, "rdc_rbr_tmout"},
1136f45ec7bSml29623 	{RDC_STAT_RSP_CNT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_cnt_err"},
1146f45ec7bSml29623 	{RDC_STAT_BYTE_EN_BUS, KSTAT_DATA_ULONG, "rdc_byte_en_bus"},
1156f45ec7bSml29623 	{RDC_STAT_RSP_DAT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_dat_err"},
1164202ea4bSsbehera 	{RDC_STAT_PKT_TOO_LONG_ERR, KSTAT_DATA_ULONG, "rdc_pkt_too_long_err"},
1176f45ec7bSml29623 	{RDC_STAT_COMPL_L2_ERR, KSTAT_DATA_ULONG, "rdc_compl_l2_err"},
1186f45ec7bSml29623 	{RDC_STAT_COMPL_L4_CKSUM_ERR, KSTAT_DATA_ULONG, "rdc_compl_l4_cksum"},
1196f45ec7bSml29623 	{RDC_STAT_COMPL_ZCP_SOFT_ERR, KSTAT_DATA_ULONG,
1206f45ec7bSml29623 		"rdc_compl_zcp_soft_err"},
1216f45ec7bSml29623 	{RDC_STAT_COMPL_FFLP_SOFT_ERR, KSTAT_DATA_ULONG,
1226f45ec7bSml29623 		"rdc_compl_fflp_soft_err"},
1236f45ec7bSml29623 	{RDC_STAT_CONFIG_ERR, KSTAT_DATA_ULONG, "rdc_config_err"},
1246f45ec7bSml29623 	{RDC_STAT_RCRINCON, KSTAT_DATA_ULONG, "rdc_rcrincon"},
1256f45ec7bSml29623 	{RDC_STAT_RCRFULL, KSTAT_DATA_ULONG, "rdc_rcrfull"},
1266f45ec7bSml29623 	{RDC_STAT_RBR_EMPTY, KSTAT_DATA_ULONG, "rdc_rbr_empty"},
1276f45ec7bSml29623 	{RDC_STAT_RBR_FULL, KSTAT_DATA_ULONG, "rdc_rbrfull"},
1286f45ec7bSml29623 	{RDC_STAT_RBRLOGPAGE, KSTAT_DATA_ULONG, "rdc_rbrlogpage"},
1296f45ec7bSml29623 	{RDC_STAT_CFIGLOGPAGE, KSTAT_DATA_ULONG, "rdc_cfiglogpage"},
1306f45ec7bSml29623 	{RDC_STAT_PORT_DROP_PKT, KSTAT_DATA_ULONG, "rdc_port_drop_pkt"},
1316f45ec7bSml29623 	{RDC_STAT_RCRTO, KSTAT_DATA_ULONG, "rdc_rcrto"},
1326f45ec7bSml29623 	{RDC_STAT_RCRTHRES, KSTAT_DATA_ULONG, "rdc_rcrthres"},
1336f45ec7bSml29623 	{RDC_STAT_MEX, KSTAT_DATA_ULONG, "rdc_mex"},
1346f45ec7bSml29623 	{RDC_STAT_ID_MIS, KSTAT_DATA_ULONG, "rdc_id_mismatch"},
1356f45ec7bSml29623 	{RDC_STAT_ZCP_EOP, KSTAT_DATA_ULONG, "rdc_zcp_eop"},
1366f45ec7bSml29623 	{RDC_STAT_IPP_EOP, KSTAT_DATA_ULONG, "rdc_ipp_eop"},
1376f45ec7bSml29623 	{RDC_STAT_END, NULL, NULL}
1386f45ec7bSml29623 };
1396f45ec7bSml29623 
1406f45ec7bSml29623 typedef enum {
1416f45ec7bSml29623 	RDC_SYS_STAT_PRE_PAR_ERR = 0,
1426f45ec7bSml29623 	RDC_SYS_STAT_SHA_PAR_ERR,
1436f45ec7bSml29623 	RDC_SYS_STAT_ID_MISMATCH,
1446f45ec7bSml29623 	RDC_SYS_STAT_IPP_EOP_ERR,
1456f45ec7bSml29623 	RDC_SYS_STAT_ZCP_EOP_ERR,
1466f45ec7bSml29623 	RDC_SYS_STAT_END
1476f45ec7bSml29623 } nxge_rdc_sys_stat_idx_t;
1486f45ec7bSml29623 
1496f45ec7bSml29623 nxge_kstat_index_t nxge_rdc_sys_stats[] = {
1506f45ec7bSml29623 	{RDC_SYS_STAT_PRE_PAR_ERR, KSTAT_DATA_UINT64, "rdc_pre_par_err"},
1516f45ec7bSml29623 	{RDC_SYS_STAT_SHA_PAR_ERR, KSTAT_DATA_UINT64, "rdc_sha_par_err"},
1526f45ec7bSml29623 	{RDC_SYS_STAT_ID_MISMATCH, KSTAT_DATA_UINT64, "rdc_stat_id_mismatch"},
1536f45ec7bSml29623 	{RDC_SYS_STAT_IPP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_ipp_eop_err"},
1546f45ec7bSml29623 	{RDC_SYS_STAT_ZCP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_zcp_eop_err"},
1556f45ec7bSml29623 	{RDC_SYS_STAT_END, NULL, NULL}
1566f45ec7bSml29623 };
1576f45ec7bSml29623 
1586f45ec7bSml29623 typedef enum {
1596f45ec7bSml29623 	TDC_STAT_PACKETS = 0,
1606f45ec7bSml29623 	TDC_STAT_BYTES,
1616f45ec7bSml29623 	TDC_STAT_ERRORS,
1626f45ec7bSml29623 	TDC_STAT_TX_INITS,
1636f45ec7bSml29623 	TDC_STAT_TX_NO_BUF,
1646f45ec7bSml29623 	TDC_STAT_MBOX_ERR,
1656f45ec7bSml29623 	TDC_STAT_PKT_SIZE_ERR,
1666f45ec7bSml29623 	TDC_STAT_TX_RING_OFLOW,
1676f45ec7bSml29623 	TDC_STAT_PREF_BUF_ECC_ERR,
1686f45ec7bSml29623 	TDC_STAT_NACK_PREF,
1696f45ec7bSml29623 	TDC_STAT_NACK_PKT_RD,
1706f45ec7bSml29623 	TDC_STAT_CONF_PART_ERR,
1716f45ec7bSml29623 	TDC_STAT_PKT_PRT_ERR,
1726f45ec7bSml29623 	TDC_STAT_RESET_FAIL,
1736f45ec7bSml29623 	TDC_STAT_TX_STARTS,
1746f45ec7bSml29623 	TDC_STAT_TX_NOCANPUT,
1756f45ec7bSml29623 	TDC_STAT_TX_MSGDUP_FAIL,
1766f45ec7bSml29623 	TDC_STAT_TX_ALLOCB_FAIL,
1776f45ec7bSml29623 	TDC_STAT_TX_NO_DESC,
1786f45ec7bSml29623 	TDC_STAT_TX_DMA_BIND_FAIL,
1796f45ec7bSml29623 	TDC_STAT_TX_UFLOW,
1806f45ec7bSml29623 	TDC_STAT_TX_HDR_PKTS,
1816f45ec7bSml29623 	TDC_STAT_TX_DDI_PKTS,
1826f45ec7bSml29623 	TDC_STAT_TX_DVMA_PKTS,
1836f45ec7bSml29623 	TDC_STAT_TX_MAX_PEND,
1846f45ec7bSml29623 	TDC_STAT_END
1856f45ec7bSml29623 } nxge_tdc_stats_index_t;
1866f45ec7bSml29623 
1876f45ec7bSml29623 nxge_kstat_index_t nxge_tdc_stats[] = {
1886f45ec7bSml29623 	{TDC_STAT_PACKETS, KSTAT_DATA_UINT64, "tdc_packets"},
1896f45ec7bSml29623 	{TDC_STAT_BYTES, KSTAT_DATA_UINT64, "tdc_bytes"},
1906f45ec7bSml29623 	{TDC_STAT_ERRORS, KSTAT_DATA_UINT64, "tdc_errors"},
1916f45ec7bSml29623 	{TDC_STAT_TX_INITS, KSTAT_DATA_ULONG, "tdc_tx_inits"},
1926f45ec7bSml29623 	{TDC_STAT_TX_NO_BUF, KSTAT_DATA_ULONG, "tdc_tx_no_buf"},
1936f45ec7bSml29623 	{TDC_STAT_MBOX_ERR, KSTAT_DATA_ULONG, "tdc_mbox_err"},
1946f45ec7bSml29623 	{TDC_STAT_PKT_SIZE_ERR, KSTAT_DATA_ULONG, "tdc_pkt_size_err"},
1956f45ec7bSml29623 	{TDC_STAT_TX_RING_OFLOW,
1966f45ec7bSml29623 		KSTAT_DATA_ULONG, "tdc_tx_ring_oflow"},
1976f45ec7bSml29623 	{TDC_STAT_PREF_BUF_ECC_ERR,
1986f45ec7bSml29623 		KSTAT_DATA_ULONG, "tdc_pref_buf_err_err"},
1996f45ec7bSml29623 	{TDC_STAT_NACK_PREF, KSTAT_DATA_ULONG, "tdc_nack_pref"},
2006f45ec7bSml29623 	{TDC_STAT_NACK_PKT_RD, KSTAT_DATA_ULONG, "tdc_nack_pkt_rd"},
2016f45ec7bSml29623 	{TDC_STAT_CONF_PART_ERR,
2026f45ec7bSml29623 		KSTAT_DATA_ULONG, "tdc_conf_part_err"},
2036f45ec7bSml29623 	{TDC_STAT_PKT_PRT_ERR, KSTAT_DATA_ULONG, "tdc_pkt_prt_err"},
2046f45ec7bSml29623 	{TDC_STAT_RESET_FAIL, KSTAT_DATA_ULONG, "tdc_reset_fail"},
2056f45ec7bSml29623 	{TDC_STAT_TX_STARTS, KSTAT_DATA_ULONG, "tdc_tx_starts"},
2066f45ec7bSml29623 	{TDC_STAT_TX_NOCANPUT, KSTAT_DATA_ULONG, "tdc_tx_nocanput"},
2076f45ec7bSml29623 	{TDC_STAT_TX_MSGDUP_FAIL, KSTAT_DATA_ULONG, "tdc_tx_msgdup_fail"},
2086f45ec7bSml29623 	{TDC_STAT_TX_ALLOCB_FAIL, KSTAT_DATA_ULONG, "tdc_tx_allocb_fail"},
2096f45ec7bSml29623 	{TDC_STAT_TX_NO_DESC, KSTAT_DATA_ULONG, "tdc_tx_no_desc"},
2106f45ec7bSml29623 	{TDC_STAT_TX_DMA_BIND_FAIL, KSTAT_DATA_ULONG, "tdc_tx_dma_bind_fail"},
2116f45ec7bSml29623 	{TDC_STAT_TX_UFLOW, KSTAT_DATA_ULONG, "tdc_tx_uflow"},
2126f45ec7bSml29623 	{TDC_STAT_TX_HDR_PKTS, KSTAT_DATA_ULONG, "tdc_tx_hdr_pkts"},
2136f45ec7bSml29623 	{TDC_STAT_TX_DDI_PKTS, KSTAT_DATA_ULONG, "tdc_tx_ddi_pkts"},
2146f45ec7bSml29623 	{TDC_STAT_TX_DVMA_PKTS, KSTAT_DATA_ULONG, "tdc_tx_dvma_pkts"},
2156f45ec7bSml29623 	{TDC_STAT_TX_MAX_PEND, KSTAT_DATA_ULONG, "tdc_tx_max_pend"},
2166f45ec7bSml29623 	{TDC_STAT_END, NULL, NULL}
2176f45ec7bSml29623 };
2186f45ec7bSml29623 
2196f45ec7bSml29623 /* IPP Statistics definitions */
2206f45ec7bSml29623 typedef enum {
2216f45ec7bSml29623 	IPP_STAT_EOP_MISS = 0,
2226f45ec7bSml29623 	IPP_STAT_SOP_MISS,
2236f45ec7bSml29623 	IPP_STAT_DFIFO_UE,
2246f45ec7bSml29623 	IPP_STAT_ECC_ERR,
225846a903dSml29623 	IPP_STAT_PFIFO_PERR,
2266f45ec7bSml29623 	IPP_STAT_PFIFO_OVER,
2276f45ec7bSml29623 	IPP_STAT_PFIFO_UND,
2286f45ec7bSml29623 	IPP_STAT_BAD_CS,
2296f45ec7bSml29623 	IPP_STAT_BAD_DIS,
2306f45ec7bSml29623 	IPP_STAT_END
2316f45ec7bSml29623 } nxge_ipp_stat_index_t;
2326f45ec7bSml29623 
2336f45ec7bSml29623 nxge_kstat_index_t nxge_ipp_stats[] = {
2346f45ec7bSml29623 	{IPP_STAT_EOP_MISS, KSTAT_DATA_ULONG, "rxipp_eop_miss"},
2356f45ec7bSml29623 	{IPP_STAT_SOP_MISS, KSTAT_DATA_ULONG, "rxipp_sop_miss"},
2366f45ec7bSml29623 	{IPP_STAT_DFIFO_UE, KSTAT_DATA_ULONG, "rxipp_dfifo_ue"},
2376f45ec7bSml29623 	{IPP_STAT_ECC_ERR, KSTAT_DATA_ULONG, "rxipp_ecc_err"},
238846a903dSml29623 	{IPP_STAT_PFIFO_PERR, KSTAT_DATA_ULONG, "rxipp_pfifo_perr"},
2396f45ec7bSml29623 	{IPP_STAT_PFIFO_OVER, KSTAT_DATA_ULONG, "rxipp_pfifo_over"},
2406f45ec7bSml29623 	{IPP_STAT_PFIFO_UND, KSTAT_DATA_ULONG, "rxipp_pfifo_und"},
2416f45ec7bSml29623 	{IPP_STAT_BAD_CS, KSTAT_DATA_ULONG, "rxipp_bad_cs"},
2426f45ec7bSml29623 	{IPP_STAT_BAD_DIS, KSTAT_DATA_ULONG, "rxipp_bad_dis"},
2436f45ec7bSml29623 	{IPP_STAT_END, NULL, NULL}
2446f45ec7bSml29623 };
2456f45ec7bSml29623 
2466f45ec7bSml29623 /* TXC Statistics definitions */
2476f45ec7bSml29623 typedef enum {
2486f45ec7bSml29623 	TXC_STAT_PKT_STUFFED = 0,
2496f45ec7bSml29623 	TXC_STAT_PKT_XMIT,
2506f45ec7bSml29623 	TXC_STAT_RO_CORRECT_ERR,
2516f45ec7bSml29623 	TXC_STAT_RO_UNCORRECT_ERR,
2526f45ec7bSml29623 	TXC_STAT_SF_CORRECT_ERR,
2536f45ec7bSml29623 	TXC_STAT_SF_UNCORRECT_ERR,
2546f45ec7bSml29623 	TXC_STAT_ADDRESS_FAILED,
2556f45ec7bSml29623 	TXC_STAT_DMA_FAILED,
2566f45ec7bSml29623 	TXC_STAT_LENGTH_FAILED,
2576f45ec7bSml29623 	TXC_STAT_PKT_ASSY_DEAD,
2586f45ec7bSml29623 	TXC_STAT_REORDER_ERR,
2596f45ec7bSml29623 	TXC_STAT_END
2606f45ec7bSml29623 } nxge_txc_stat_index_t;
2616f45ec7bSml29623 
2626f45ec7bSml29623 nxge_kstat_index_t nxge_txc_stats[] = {
2636f45ec7bSml29623 	{TXC_STAT_PKT_STUFFED, KSTAT_DATA_ULONG, "txc_pkt_stuffed"},
2646f45ec7bSml29623 	{TXC_STAT_PKT_XMIT, KSTAT_DATA_ULONG, "txc_pkt_xmit"},
2656f45ec7bSml29623 	{TXC_STAT_RO_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_correct_err"},
2666f45ec7bSml29623 	{TXC_STAT_RO_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_uncorrect_err"},
2676f45ec7bSml29623 	{TXC_STAT_SF_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_correct_err"},
2686f45ec7bSml29623 	{TXC_STAT_SF_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_uncorrect_err"},
2696f45ec7bSml29623 	{TXC_STAT_ADDRESS_FAILED, KSTAT_DATA_ULONG, "txc_address_failed"},
2706f45ec7bSml29623 	{TXC_STAT_DMA_FAILED, KSTAT_DATA_ULONG, "txc_dma_failed"},
2716f45ec7bSml29623 	{TXC_STAT_LENGTH_FAILED, KSTAT_DATA_ULONG, "txc_length_failed"},
2726f45ec7bSml29623 	{TXC_STAT_PKT_ASSY_DEAD, KSTAT_DATA_ULONG, "txc_pkt_assy_dead"},
2736f45ec7bSml29623 	{TXC_STAT_REORDER_ERR, KSTAT_DATA_ULONG, "txc_reorder_err"},
2746f45ec7bSml29623 	{TXC_STAT_END, NULL, NULL}
2756f45ec7bSml29623 };
2766f45ec7bSml29623 
2776f45ec7bSml29623 typedef enum {
2786f45ec7bSml29623 	XMAC_STAT_TX_FRAME_CNT = 0,
2796f45ec7bSml29623 	XMAC_STAT_TX_UNDERFLOW_ERR,
2806f45ec7bSml29623 	XMAC_STAT_TX_MAXPKTSIZE_ERR,
2816f45ec7bSml29623 	XMAC_STAT_TX_OVERFLOW_ERR,
2826f45ec7bSml29623 	XMAC_STAT_TX_FIFO_XFR_ERR,
2836f45ec7bSml29623 	XMAC_STAT_TX_BYTE_CNT,
2846f45ec7bSml29623 	XMAC_STAT_RX_FRAME_CNT,
2856f45ec7bSml29623 	XMAC_STAT_RX_UNDERFLOW_ERR,
2866f45ec7bSml29623 	XMAC_STAT_RX_OVERFLOW_ERR,
2876f45ec7bSml29623 	XMAC_STAT_RX_CRC_ERR_CNT,
2886f45ec7bSml29623 	XMAC_STAT_RX_LEN_ERR_CNT,
2896f45ec7bSml29623 	XMAC_STAT_RX_VIOL_ERR_CNT,
2906f45ec7bSml29623 	XMAC_STAT_RX_BYTE_CNT,
2916f45ec7bSml29623 	XMAC_STAT_RX_HIST1_CNT,
2926f45ec7bSml29623 	XMAC_STAT_RX_HIST2_CNT,
2936f45ec7bSml29623 	XMAC_STAT_RX_HIST3_CNT,
2946f45ec7bSml29623 	XMAC_STAT_RX_HIST4_CNT,
2956f45ec7bSml29623 	XMAC_STAT_RX_HIST5_CNT,
2966f45ec7bSml29623 	XMAC_STAT_RX_HIST6_CNT,
2976f45ec7bSml29623 	XMAC_STAT_RX_HIST7_CNT,
2986f45ec7bSml29623 	XMAC_STAT_RX_BROADCAST_CNT,
2996f45ec7bSml29623 	XMAC_STAT_RX_MULT_CNT,
3006f45ec7bSml29623 	XMAC_STAT_RX_FRAG_CNT,
3016f45ec7bSml29623 	XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT,
3026f45ec7bSml29623 	XMAC_STAT_RX_LINKFAULT_ERR_CNT,
3036f45ec7bSml29623 	XMAC_STAT_RX_REMOTEFAULT_ERR,
3046f45ec7bSml29623 	XMAC_STAT_RX_LOCALFAULT_ERR,
3056f45ec7bSml29623 	XMAC_STAT_RX_PAUSE_CNT,
3066f45ec7bSml29623 	XMAC_STAT_TX_PAUSE_STATE,
3076f45ec7bSml29623 	XMAC_STAT_TX_NOPAUSE_STATE,
3086f45ec7bSml29623 	XMAC_STAT_XPCS_DESKEW_ERR_CNT,
3096f45ec7bSml29623 #ifdef	NXGE_DEBUG_SYMBOL_ERR
3106f45ec7bSml29623 	XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT,
3116f45ec7bSml29623 	XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT,
3126f45ec7bSml29623 	XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT,
3136f45ec7bSml29623 	XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT,
3146f45ec7bSml29623 #endif
3156f45ec7bSml29623 	XMAC_STAT_END
3166f45ec7bSml29623 } nxge_xmac_stat_index_t;
3176f45ec7bSml29623 
3186f45ec7bSml29623 nxge_kstat_index_t nxge_xmac_stats[] = {
3196f45ec7bSml29623 	{XMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"},
3206f45ec7bSml29623 	{XMAC_STAT_TX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "tmac_underflow_err"},
3216f45ec7bSml29623 	{XMAC_STAT_TX_MAXPKTSIZE_ERR, KSTAT_DATA_ULONG, "txmac_maxpktsize_err"},
3226f45ec7bSml29623 	{XMAC_STAT_TX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "txmac_overflow_err"},
3236f45ec7bSml29623 	{XMAC_STAT_TX_FIFO_XFR_ERR, KSTAT_DATA_ULONG, "txmac_fifo_xfr_err"},
3246f45ec7bSml29623 	{XMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"},
3256f45ec7bSml29623 	{XMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"},
3266f45ec7bSml29623 	{XMAC_STAT_RX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_underflow_err"},
3276f45ec7bSml29623 	{XMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"},
3286f45ec7bSml29623 	{XMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err"},
3296f45ec7bSml29623 	{XMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_length_err"},
3306f45ec7bSml29623 	{XMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_code_violations"},
3316f45ec7bSml29623 	{XMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"},
3326f45ec7bSml29623 	{XMAC_STAT_RX_HIST1_CNT, KSTAT_DATA_ULONG, "rxmac_64_cnt"},
3336f45ec7bSml29623 	{XMAC_STAT_RX_HIST2_CNT, KSTAT_DATA_ULONG, "rxmac_65_127_cnt"},
3346f45ec7bSml29623 	{XMAC_STAT_RX_HIST3_CNT, KSTAT_DATA_ULONG, "rxmac_128_255_cnt"},
3356f45ec7bSml29623 	{XMAC_STAT_RX_HIST4_CNT, KSTAT_DATA_ULONG, "rxmac_256_511_cnt"},
3366f45ec7bSml29623 	{XMAC_STAT_RX_HIST5_CNT, KSTAT_DATA_ULONG, "rxmac_512_1023_cnt"},
3376f45ec7bSml29623 	{XMAC_STAT_RX_HIST6_CNT, KSTAT_DATA_ULONG, "rxmac_1024_1522_cnt"},
3386f45ec7bSml29623 	{XMAC_STAT_RX_HIST7_CNT, KSTAT_DATA_ULONG, "rxmac_jumbo_cnt"},
3396f45ec7bSml29623 	{XMAC_STAT_RX_BROADCAST_CNT, KSTAT_DATA_ULONG, "rxmac_broadcast_cnt"},
3406f45ec7bSml29623 	{XMAC_STAT_RX_MULT_CNT, KSTAT_DATA_ULONG, "rxmac_multicast_cnt"},
3416f45ec7bSml29623 	{XMAC_STAT_RX_FRAG_CNT, KSTAT_DATA_ULONG, "rxmac_fragment_cnt"},
3426f45ec7bSml29623 	{XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT,
3436f45ec7bSml29623 		KSTAT_DATA_ULONG, "rxmac_alignment_err"},
3446f45ec7bSml29623 	{XMAC_STAT_RX_LINKFAULT_ERR_CNT,
3456f45ec7bSml29623 		KSTAT_DATA_ULONG, "rxmac_linkfault_errs"},
3466f45ec7bSml29623 	{XMAC_STAT_RX_REMOTEFAULT_ERR,
3476f45ec7bSml29623 		KSTAT_DATA_ULONG, "rxmac_remote_faults"},
3486f45ec7bSml29623 	{XMAC_STAT_RX_LOCALFAULT_ERR,
3496f45ec7bSml29623 		KSTAT_DATA_ULONG, "rxmac_local_faults"},
3506f45ec7bSml29623 	{XMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"},
3516f45ec7bSml29623 	{XMAC_STAT_TX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"},
3526f45ec7bSml29623 	{XMAC_STAT_TX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "txmac_nopause_state"},
3536f45ec7bSml29623 	{XMAC_STAT_XPCS_DESKEW_ERR_CNT,
3546f45ec7bSml29623 		KSTAT_DATA_ULONG, "xpcs_deskew_err_cnt"},
3556f45ec7bSml29623 #ifdef	NXGE_DEBUG_SYMBOL_ERR
3566f45ec7bSml29623 	{XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT,
3576f45ec7bSml29623 		KSTAT_DATA_ULONG, "xpcs_ln0_symbol_err_cnt"},
3586f45ec7bSml29623 	{XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT,
3596f45ec7bSml29623 		KSTAT_DATA_ULONG, "xpcs_ln1_symbol_err_cnt"},
3606f45ec7bSml29623 	{XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT,
3616f45ec7bSml29623 		KSTAT_DATA_ULONG, "xpcs_ln2_symbol_err_cnt"},
3626f45ec7bSml29623 	{XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT,
3636f45ec7bSml29623 		KSTAT_DATA_ULONG, "xpcs_ln3_symbol_err_cnt"},
3646f45ec7bSml29623 #endif
3656f45ec7bSml29623 	{XMAC_STAT_END, NULL, NULL}
3666f45ec7bSml29623 };
3676f45ec7bSml29623 
3686f45ec7bSml29623 typedef enum {
3696f45ec7bSml29623 	BMAC_STAT_TX_FRAME_CNT = 0,
3706f45ec7bSml29623 	BMAC_STAT_TX_UNDERRUN_ERR,
3716f45ec7bSml29623 	BMAC_STAT_TX_MAX_PKT_ERR,
3726f45ec7bSml29623 	BMAC_STAT_TX_BYTE_CNT,
3736f45ec7bSml29623 	BMAC_STAT_RX_FRAME_CNT,
3746f45ec7bSml29623 	BMAC_STAT_RX_BYTE_CNT,
3756f45ec7bSml29623 	BMAC_STAT_RX_OVERFLOW_ERR,
3766f45ec7bSml29623 	BMAC_STAT_RX_ALIGN_ERR_CNT,
3776f45ec7bSml29623 	BMAC_STAT_RX_CRC_ERR_CNT,
3786f45ec7bSml29623 	BMAC_STAT_RX_LEN_ERR_CNT,
3796f45ec7bSml29623 	BMAC_STAT_RX_VIOL_ERR_CNT,
3806f45ec7bSml29623 	BMAC_STAT_RX_PAUSE_CNT,
3816f45ec7bSml29623 	BMAC_STAT_RX_PAUSE_STATE,
3826f45ec7bSml29623 	BMAC_STAT_RX_NOPAUSE_STATE,
3836f45ec7bSml29623 	BMAC_STAT_END
3846f45ec7bSml29623 } nxge_bmac_stat_index_t;
3856f45ec7bSml29623 
3866f45ec7bSml29623 nxge_kstat_index_t nxge_bmac_stats[] = {
3876f45ec7bSml29623 	{BMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"},
3886f45ec7bSml29623 	{BMAC_STAT_TX_UNDERRUN_ERR, KSTAT_DATA_ULONG, "txmac_underrun_err"},
3896f45ec7bSml29623 	{BMAC_STAT_TX_MAX_PKT_ERR, KSTAT_DATA_ULONG, "txmac_max_pkt_err"},
3906f45ec7bSml29623 	{BMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"},
3916f45ec7bSml29623 	{BMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"},
3926f45ec7bSml29623 	{BMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"},
3936f45ec7bSml29623 	{BMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"},
3946f45ec7bSml29623 	{BMAC_STAT_RX_ALIGN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_align_err_cnt"},
3956f45ec7bSml29623 	{BMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err_cnt"},
3966f45ec7bSml29623 	{BMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_len_err_cnt"},
3976f45ec7bSml29623 	{BMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_viol_err_cnt"},
3986f45ec7bSml29623 	{BMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"},
3996f45ec7bSml29623 	{BMAC_STAT_RX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"},
4006f45ec7bSml29623 	{BMAC_STAT_RX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "tx_nopause_state"},
4016f45ec7bSml29623 	{BMAC_STAT_END, NULL, NULL}
4026f45ec7bSml29623 };
4036f45ec7bSml29623 
4046f45ec7bSml29623 typedef enum {
4056f45ec7bSml29623 	ZCP_STAT_ERRORS,
4066f45ec7bSml29623 	ZCP_STAT_INITS,
4076f45ec7bSml29623 	ZCP_STAT_RRFIFO_UNDERRUN,
4086f45ec7bSml29623 	ZCP_STAT_RRFIFO_OVERRUN,
4096f45ec7bSml29623 	ZCP_STAT_RSPFIFO_UNCORR_ERR,
4106f45ec7bSml29623 	ZCP_STAT_BUFFER_OVERFLOW,
4116f45ec7bSml29623 	ZCP_STAT_STAT_TBL_PERR,
4126f45ec7bSml29623 	ZCP_STAT_DYN_TBL_PERR,
4136f45ec7bSml29623 	ZCP_STAT_BUF_TBL_PERR,
4146f45ec7bSml29623 	ZCP_STAT_TT_PROGRAM_ERR,
4156f45ec7bSml29623 	ZCP_STAT_RSP_TT_INDEX_ERR,
4166f45ec7bSml29623 	ZCP_STAT_SLV_TT_INDEX_ERR,
4176f45ec7bSml29623 	ZCP_STAT_ZCP_TT_INDEX_ERR,
4186f45ec7bSml29623 	ZCP_STAT_ZCP_ACCESS_FAIL,
4196f45ec7bSml29623 	ZCP_CFIFO_ECC,
4206f45ec7bSml29623 	ZCP_STAT_END
4216f45ec7bSml29623 } nxge_zcp_stat_index_t;
4226f45ec7bSml29623 
4236f45ec7bSml29623 nxge_kstat_index_t nxge_zcp_stats[] = {
4246f45ec7bSml29623 	{ZCP_STAT_ERRORS, KSTAT_DATA_ULONG, "zcp_erros"},
4256f45ec7bSml29623 	{ZCP_STAT_INITS, KSTAT_DATA_ULONG, "zcp_inits"},
4266f45ec7bSml29623 	{ZCP_STAT_RRFIFO_UNDERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_underrun"},
4276f45ec7bSml29623 	{ZCP_STAT_RRFIFO_OVERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_overrun"},
4286f45ec7bSml29623 	{ZCP_STAT_RSPFIFO_UNCORR_ERR, KSTAT_DATA_ULONG,
4296f45ec7bSml29623 	"zcp_rspfifo_uncorr_err"},
4306f45ec7bSml29623 	{ZCP_STAT_BUFFER_OVERFLOW, KSTAT_DATA_ULONG, "zcp_buffer_overflow"},
4316f45ec7bSml29623 	{ZCP_STAT_STAT_TBL_PERR, KSTAT_DATA_ULONG, "zcp_stat_tbl_perr"},
4326f45ec7bSml29623 	{ZCP_STAT_DYN_TBL_PERR, KSTAT_DATA_ULONG, "zcp_dyn_tbl_perr"},
4336f45ec7bSml29623 	{ZCP_STAT_BUF_TBL_PERR, KSTAT_DATA_ULONG, "zcp_buf_tbl_perr"},
4346f45ec7bSml29623 	{ZCP_STAT_TT_PROGRAM_ERR, KSTAT_DATA_ULONG, "zcp_tt_program_err"},
4356f45ec7bSml29623 	{ZCP_STAT_RSP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_rsp_tt_index_err"},
4366f45ec7bSml29623 	{ZCP_STAT_SLV_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_slv_tt_index_err"},
4376f45ec7bSml29623 	{ZCP_STAT_ZCP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_zcp_tt_index_err"},
4386f45ec7bSml29623 	{ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_access_fail"},
4396f45ec7bSml29623 	{ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_cfifo_ecc"},
4406f45ec7bSml29623 	{ZCP_STAT_END, NULL, NULL}
4416f45ec7bSml29623 };
4426f45ec7bSml29623 
4436f45ec7bSml29623 typedef enum {
4446f45ec7bSml29623 	FFLP_STAT_TCAM_PERR,
4456f45ec7bSml29623 	FFLP_STAT_TCAM_ECC_ERR,
4466f45ec7bSml29623 	FFLP_STAT_VLAN_PERR,
4476f45ec7bSml29623 	FFLP_STAT_HASH_LOOKUP_ERR,
4486f45ec7bSml29623 	FFLP_STAT_HASH_P0_PIO_ERR,
4496f45ec7bSml29623 	FFLP_STAT_HASH_P1_PIO_ERR,
4506f45ec7bSml29623 	FFLP_STAT_HASH_P2_PIO_ERR,
4516f45ec7bSml29623 	FFLP_STAT_HASH_P3_PIO_ERR,
4526f45ec7bSml29623 	FFLP_STAT_HASH_P4_PIO_ERR,
4536f45ec7bSml29623 	FFLP_STAT_HASH_P5_PIO_ERR,
4546f45ec7bSml29623 	FFLP_STAT_HASH_P6_PIO_ERR,
4556f45ec7bSml29623 	FFLP_STAT_HASH_P7_PIO_ERR,
4566f45ec7bSml29623 	FFLP_STAT_END
4576f45ec7bSml29623 } nxge_fflp_stat_index_t;
4586f45ec7bSml29623 
4596f45ec7bSml29623 nxge_kstat_index_t nxge_fflp_stats[] = {
4606f45ec7bSml29623 	{FFLP_STAT_TCAM_PERR, KSTAT_DATA_ULONG, "fflp_tcam_perr"},
4616f45ec7bSml29623 	{FFLP_STAT_TCAM_ECC_ERR, KSTAT_DATA_ULONG, "fflp_tcam_ecc_err"},
4626f45ec7bSml29623 	{FFLP_STAT_VLAN_PERR, KSTAT_DATA_ULONG, "fflp_vlan_perr"},
4636f45ec7bSml29623 	{FFLP_STAT_HASH_LOOKUP_ERR, KSTAT_DATA_ULONG, "fflp_hash_lookup_err"},
4646f45ec7bSml29623 	{FFLP_STAT_HASH_P0_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p0_pio_err"},
4656f45ec7bSml29623 	{FFLP_STAT_HASH_P1_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p1_pio_err"},
4666f45ec7bSml29623 	{FFLP_STAT_HASH_P2_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p2_pio_err"},
4676f45ec7bSml29623 	{FFLP_STAT_HASH_P3_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p3_pio_err"},
4686f45ec7bSml29623 	{FFLP_STAT_HASH_P4_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p4_pio_err"},
4696f45ec7bSml29623 	{FFLP_STAT_HASH_P5_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p5_pio_err"},
4706f45ec7bSml29623 	{FFLP_STAT_HASH_P6_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p6_pio_err"},
4716f45ec7bSml29623 	{FFLP_STAT_HASH_P7_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p7_pio_err"},
4726f45ec7bSml29623 	{FFLP_STAT_END, NULL, NULL}
4736f45ec7bSml29623 };
4746f45ec7bSml29623 
4756f45ec7bSml29623 typedef enum {
4766f45ec7bSml29623 	MMAC_MAX_ADDR,
4776f45ec7bSml29623 	MMAC_AVAIL_ADDR,
4786f45ec7bSml29623 	MMAC_ADDR_POOL1,
4796f45ec7bSml29623 	MMAC_ADDR_POOL2,
4806f45ec7bSml29623 	MMAC_ADDR_POOL3,
4816f45ec7bSml29623 	MMAC_ADDR_POOL4,
4826f45ec7bSml29623 	MMAC_ADDR_POOL5,
4836f45ec7bSml29623 	MMAC_ADDR_POOL6,
4846f45ec7bSml29623 	MMAC_ADDR_POOL7,
4856f45ec7bSml29623 	MMAC_ADDR_POOL8,
4866f45ec7bSml29623 	MMAC_ADDR_POOL9,
4876f45ec7bSml29623 	MMAC_ADDR_POOL10,
4886f45ec7bSml29623 	MMAC_ADDR_POOL11,
4896f45ec7bSml29623 	MMAC_ADDR_POOL12,
4906f45ec7bSml29623 	MMAC_ADDR_POOL13,
4916f45ec7bSml29623 	MMAC_ADDR_POOL14,
4926f45ec7bSml29623 	MMAC_ADDR_POOL15,
4936f45ec7bSml29623 	MMAC_ADDR_POOL16,
4946f45ec7bSml29623 	MMAC_STATS_END
4956f45ec7bSml29623 } nxge_mmac_stat_index_t;
4966f45ec7bSml29623 
4976f45ec7bSml29623 nxge_kstat_index_t nxge_mmac_stats[] = {
4986f45ec7bSml29623 	{MMAC_MAX_ADDR, KSTAT_DATA_UINT64, "max_mmac_addr"},
4996f45ec7bSml29623 	{MMAC_AVAIL_ADDR, KSTAT_DATA_UINT64, "avail_mmac_addr"},
5006f45ec7bSml29623 	{MMAC_ADDR_POOL1, KSTAT_DATA_UINT64, "mmac_addr_1"},
5016f45ec7bSml29623 	{MMAC_ADDR_POOL2, KSTAT_DATA_UINT64, "mmac_addr_2"},
5026f45ec7bSml29623 	{MMAC_ADDR_POOL3, KSTAT_DATA_UINT64, "mmac_addr_3"},
5036f45ec7bSml29623 	{MMAC_ADDR_POOL4, KSTAT_DATA_UINT64, "mmac_addr_4"},
5046f45ec7bSml29623 	{MMAC_ADDR_POOL5, KSTAT_DATA_UINT64, "mmac_addr_5"},
5056f45ec7bSml29623 	{MMAC_ADDR_POOL6, KSTAT_DATA_UINT64, "mmac_addr_6"},
5066f45ec7bSml29623 	{MMAC_ADDR_POOL7, KSTAT_DATA_UINT64, "mmac_addr_7"},
5076f45ec7bSml29623 	{MMAC_ADDR_POOL8, KSTAT_DATA_UINT64, "mmac_addr_8"},
5086f45ec7bSml29623 	{MMAC_ADDR_POOL9, KSTAT_DATA_UINT64, "mmac_addr_9"},
5096f45ec7bSml29623 	{MMAC_ADDR_POOL10, KSTAT_DATA_UINT64, "mmac_addr_10"},
5106f45ec7bSml29623 	{MMAC_ADDR_POOL11, KSTAT_DATA_UINT64, "mmac_addr_11"},
5116f45ec7bSml29623 	{MMAC_ADDR_POOL12, KSTAT_DATA_UINT64, "mmac_addr_12"},
5126f45ec7bSml29623 	{MMAC_ADDR_POOL13, KSTAT_DATA_UINT64, "mmac_addr_13"},
5136f45ec7bSml29623 	{MMAC_ADDR_POOL14, KSTAT_DATA_UINT64, "mmac_addr_14"},
5146f45ec7bSml29623 	{MMAC_ADDR_POOL15, KSTAT_DATA_UINT64, "mmac_addr_15"},
5156f45ec7bSml29623 	{MMAC_ADDR_POOL16, KSTAT_DATA_UINT64, "mmac_addr_16"},
5166f45ec7bSml29623 	{MMAC_STATS_END, NULL, NULL},
5176f45ec7bSml29623 };
5186f45ec7bSml29623 
5196f45ec7bSml29623 /* ARGSUSED */
5206f45ec7bSml29623 int
nxge_tdc_stat_update(kstat_t * ksp,int rw)5216f45ec7bSml29623 nxge_tdc_stat_update(kstat_t *ksp, int rw)
5226f45ec7bSml29623 {
5236f45ec7bSml29623 	p_nxge_t nxgep;
5246f45ec7bSml29623 	p_nxge_tdc_kstat_t tdc_kstatsp;
5256f45ec7bSml29623 	p_nxge_tx_ring_stats_t statsp;
5266f45ec7bSml29623 	int channel;
5276f45ec7bSml29623 	char *ch_name, *end;
5286f45ec7bSml29623 
5296f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
5306f45ec7bSml29623 	if (nxgep == NULL)
5316f45ec7bSml29623 		return (-1);
5326f45ec7bSml29623 
5336f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rxstat_update"));
5346f45ec7bSml29623 
5356f45ec7bSml29623 	ch_name = ksp->ks_name;
5366f45ec7bSml29623 	ch_name += strlen(TDC_NAME_FORMAT1);
5376f45ec7bSml29623 	channel = mi_strtol(ch_name, &end, 10);
5386f45ec7bSml29623 
5396f45ec7bSml29623 	tdc_kstatsp = (p_nxge_tdc_kstat_t)ksp->ks_data;
5406f45ec7bSml29623 	statsp = (p_nxge_tx_ring_stats_t)&nxgep->statsp->tdc_stats[channel];
5416f45ec7bSml29623 
5426f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL,
5436f45ec7bSml29623 	    "nxge_tdc_stat_update data $%p statsp $%p channel %d",
5446f45ec7bSml29623 	    ksp->ks_data, statsp, channel));
5456f45ec7bSml29623 
5466f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
5476f45ec7bSml29623 		statsp->opackets = tdc_kstatsp->opackets.value.ull;
5486f45ec7bSml29623 		statsp->obytes = tdc_kstatsp->obytes.value.ull;
5496f45ec7bSml29623 		statsp->oerrors = tdc_kstatsp->oerrors.value.ull;
5506f45ec7bSml29623 		statsp->mbox_err = tdc_kstatsp->mbox_err.value.ul;
5516f45ec7bSml29623 		statsp->pkt_size_err = tdc_kstatsp->pkt_size_err.value.ul;
5526f45ec7bSml29623 		statsp->tx_ring_oflow = tdc_kstatsp->tx_ring_oflow.value.ul;
5536f45ec7bSml29623 		statsp->pre_buf_par_err =
5546f45ec7bSml29623 		    tdc_kstatsp->pref_buf_ecc_err.value.ul;
5556f45ec7bSml29623 		statsp->nack_pref = tdc_kstatsp->nack_pref.value.ul;
5566f45ec7bSml29623 		statsp->nack_pkt_rd = tdc_kstatsp->nack_pkt_rd.value.ul;
5576f45ec7bSml29623 		statsp->conf_part_err = tdc_kstatsp->conf_part_err.value.ul;
5586f45ec7bSml29623 		statsp->pkt_part_err = tdc_kstatsp->pkt_prt_err.value.ul;
5596f45ec7bSml29623 	} else {
5606f45ec7bSml29623 		tdc_kstatsp->opackets.value.ull = statsp->opackets;
5616f45ec7bSml29623 		tdc_kstatsp->obytes.value.ull = statsp->obytes;
5626f45ec7bSml29623 		tdc_kstatsp->oerrors.value.ull = statsp->oerrors;
5636f45ec7bSml29623 		tdc_kstatsp->tx_hdr_pkts.value.ull = statsp->tx_hdr_pkts;
5646f45ec7bSml29623 		tdc_kstatsp->tx_ddi_pkts.value.ull = statsp->tx_ddi_pkts;
5656f45ec7bSml29623 		tdc_kstatsp->tx_dvma_pkts.value.ull = statsp->tx_dvma_pkts;
5666f45ec7bSml29623 		tdc_kstatsp->tx_max_pend.value.ull = statsp->tx_max_pend;
5676f45ec7bSml29623 		tdc_kstatsp->mbox_err.value.ul = statsp->mbox_err;
5686f45ec7bSml29623 		tdc_kstatsp->pkt_size_err.value.ul = statsp->pkt_size_err;
5696f45ec7bSml29623 		tdc_kstatsp->tx_ring_oflow.value.ul = statsp->tx_ring_oflow;
5706f45ec7bSml29623 		tdc_kstatsp->pref_buf_ecc_err.value.ul =
5716f45ec7bSml29623 		    statsp->pre_buf_par_err;
5726f45ec7bSml29623 		tdc_kstatsp->nack_pref.value.ul = statsp->nack_pref;
5736f45ec7bSml29623 		tdc_kstatsp->nack_pkt_rd.value.ul = statsp->nack_pkt_rd;
5746f45ec7bSml29623 		tdc_kstatsp->conf_part_err.value.ul = statsp->conf_part_err;
5756f45ec7bSml29623 		tdc_kstatsp->pkt_prt_err.value.ul = statsp->pkt_part_err;
5766f45ec7bSml29623 		tdc_kstatsp->tx_starts.value.ul = statsp->tx_starts;
5776f45ec7bSml29623 		tdc_kstatsp->tx_nocanput.value.ul = statsp->tx_nocanput;
5786f45ec7bSml29623 		tdc_kstatsp->tx_msgdup_fail.value.ul = statsp->tx_msgdup_fail;
5796f45ec7bSml29623 		tdc_kstatsp->tx_allocb_fail.value.ul = statsp->tx_allocb_fail;
5806f45ec7bSml29623 		tdc_kstatsp->tx_no_desc.value.ul = statsp->tx_no_desc;
5816f45ec7bSml29623 		tdc_kstatsp->tx_dma_bind_fail.value.ul =
5826f45ec7bSml29623 		    statsp->tx_dma_bind_fail;
5836f45ec7bSml29623 	}
5846f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_tdc_stat_update"));
5856f45ec7bSml29623 	return (0);
5866f45ec7bSml29623 }
5876f45ec7bSml29623 
5886f45ec7bSml29623 /* ARGSUSED */
5896f45ec7bSml29623 int
nxge_rdc_stat_update(kstat_t * ksp,int rw)5906f45ec7bSml29623 nxge_rdc_stat_update(kstat_t *ksp, int rw)
5916f45ec7bSml29623 {
5926f45ec7bSml29623 	p_nxge_t nxgep;
5936f45ec7bSml29623 	p_nxge_rdc_kstat_t rdc_kstatsp;
5946f45ec7bSml29623 	p_nxge_rx_ring_stats_t statsp;
5956f45ec7bSml29623 	int channel;
5966f45ec7bSml29623 	char *ch_name, *end;
5976f45ec7bSml29623 
5986f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
5996f45ec7bSml29623 	if (nxgep == NULL)
6006f45ec7bSml29623 		return (-1);
6016f45ec7bSml29623 
6026f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_stat_update"));
6036f45ec7bSml29623 
6046f45ec7bSml29623 	ch_name = ksp->ks_name;
6056f45ec7bSml29623 	ch_name += strlen(RDC_NAME_FORMAT1);
6066f45ec7bSml29623 	channel = mi_strtol(ch_name, &end, 10);
6076f45ec7bSml29623 
6086f45ec7bSml29623 	rdc_kstatsp = (p_nxge_rdc_kstat_t)ksp->ks_data;
6096f45ec7bSml29623 	statsp = (p_nxge_rx_ring_stats_t)&nxgep->statsp->rdc_stats[channel];
6106f45ec7bSml29623 
6116f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL,
6126f45ec7bSml29623 	    "nxge_rdc_stat_update $%p statsp $%p channel %d",
6136f45ec7bSml29623 	    ksp->ks_data, statsp, channel));
6146f45ec7bSml29623 
6156f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
6166f45ec7bSml29623 		statsp->dcf_err = rdc_kstatsp->dcf_err.value.ul;
6176f45ec7bSml29623 		statsp->rcr_ack_err = rdc_kstatsp->rcr_ack_err.value.ul;
6186f45ec7bSml29623 		statsp->dc_fifo_err = rdc_kstatsp->dc_fifoflow_err.value.ul;
6196f45ec7bSml29623 		statsp->rcr_sha_par = rdc_kstatsp->rcr_sha_par_err.value.ul;
6206f45ec7bSml29623 		statsp->rbr_pre_par = rdc_kstatsp->rbr_pre_par_err.value.ul;
6216f45ec7bSml29623 		statsp->wred_drop = rdc_kstatsp->wred_drop.value.ul;
6226f45ec7bSml29623 		statsp->rbr_pre_empty = rdc_kstatsp->rbr_pre_emty.value.ul;
6236f45ec7bSml29623 		statsp->rcr_shadow_full = rdc_kstatsp->rcr_shadow_full.value.ul;
6246f45ec7bSml29623 		statsp->rx_rbr_tmout = rdc_kstatsp->rbr_tmout.value.ul;
6256f45ec7bSml29623 		statsp->rsp_cnt_err = rdc_kstatsp->rsp_cnt_err.value.ul;
6266f45ec7bSml29623 		statsp->byte_en_bus = rdc_kstatsp->byte_en_bus.value.ul;
6276f45ec7bSml29623 		statsp->rsp_dat_err = rdc_kstatsp->rsp_dat_err.value.ul;
6284202ea4bSsbehera 		statsp->pkt_too_long_err =
6294202ea4bSsbehera 		    rdc_kstatsp->pkt_too_long_err.value.ul;
6306f45ec7bSml29623 		statsp->l2_err = rdc_kstatsp->compl_l2_err.value.ul;
6316f45ec7bSml29623 		statsp->l4_cksum_err = rdc_kstatsp->compl_l4_cksum_err.value.ul;
6326f45ec7bSml29623 		statsp->fflp_soft_err =
6336f45ec7bSml29623 		    rdc_kstatsp->compl_fflp_soft_err.value.ul;
6346f45ec7bSml29623 		statsp->zcp_soft_err = rdc_kstatsp->compl_zcp_soft_err.value.ul;
6356f45ec7bSml29623 		statsp->config_err = rdc_kstatsp->config_err.value.ul;
6366f45ec7bSml29623 		statsp->rcrincon = rdc_kstatsp->rcrincon.value.ul;
6376f45ec7bSml29623 		statsp->rcrfull = rdc_kstatsp->rcrfull.value.ul;
6386f45ec7bSml29623 		statsp->rbr_empty = rdc_kstatsp->rbr_empty.value.ul;
6396f45ec7bSml29623 		statsp->rbrfull = rdc_kstatsp->rbrfull.value.ul;
6406f45ec7bSml29623 		statsp->rbrlogpage = rdc_kstatsp->rbrlogpage.value.ul;
6416f45ec7bSml29623 		statsp->cfiglogpage = rdc_kstatsp->cfiglogpage.value.ul;
6426f45ec7bSml29623 	} else {
6436f45ec7bSml29623 		rdc_kstatsp->ipackets.value.ull = statsp->ipackets;
6446f45ec7bSml29623 		rdc_kstatsp->rbytes.value.ull = statsp->ibytes;
6456f45ec7bSml29623 		rdc_kstatsp->errors.value.ul = statsp->ierrors;
6466f45ec7bSml29623 		rdc_kstatsp->dcf_err.value.ul = statsp->dcf_err;
6476f45ec7bSml29623 		rdc_kstatsp->rcr_ack_err.value.ul = statsp->rcr_ack_err;
6486f45ec7bSml29623 		rdc_kstatsp->dc_fifoflow_err.value.ul = statsp->dc_fifo_err;
6496f45ec7bSml29623 		rdc_kstatsp->rcr_sha_par_err.value.ul = statsp->rcr_sha_par;
6506f45ec7bSml29623 		rdc_kstatsp->rbr_pre_par_err.value.ul = statsp->rbr_pre_par;
6516f45ec7bSml29623 		rdc_kstatsp->wred_drop.value.ul = statsp->wred_drop;
6526f45ec7bSml29623 		rdc_kstatsp->port_drop_pkt.value.ul = statsp->port_drop_pkt;
6536f45ec7bSml29623 		rdc_kstatsp->rbr_pre_emty.value.ul = statsp->rbr_pre_empty;
6546f45ec7bSml29623 		rdc_kstatsp->rcr_shadow_full.value.ul = statsp->rcr_shadow_full;
6556f45ec7bSml29623 		rdc_kstatsp->rbr_tmout.value.ul = statsp->rx_rbr_tmout;
6566f45ec7bSml29623 		rdc_kstatsp->rsp_cnt_err.value.ul = statsp->rsp_cnt_err;
6576f45ec7bSml29623 		rdc_kstatsp->byte_en_bus.value.ul = statsp->byte_en_bus;
6586f45ec7bSml29623 		rdc_kstatsp->rsp_dat_err.value.ul = statsp->rsp_dat_err;
6594202ea4bSsbehera 		rdc_kstatsp->pkt_too_long_err.value.ul =
6604202ea4bSsbehera 		    statsp->pkt_too_long_err;
6616f45ec7bSml29623 		rdc_kstatsp->compl_l2_err.value.ul = statsp->l2_err;
6626f45ec7bSml29623 		rdc_kstatsp->compl_l4_cksum_err.value.ul = statsp->l4_cksum_err;
6636f45ec7bSml29623 		rdc_kstatsp->compl_fflp_soft_err.value.ul =
6646f45ec7bSml29623 		    statsp->fflp_soft_err;
6656f45ec7bSml29623 		rdc_kstatsp->compl_zcp_soft_err.value.ul = statsp->zcp_soft_err;
6666f45ec7bSml29623 		rdc_kstatsp->config_err.value.ul = statsp->config_err;
6676f45ec7bSml29623 		rdc_kstatsp->rcrincon.value.ul = statsp->rcrincon;
6686f45ec7bSml29623 		rdc_kstatsp->rcrfull.value.ul = statsp->rcrfull;
6696f45ec7bSml29623 		rdc_kstatsp->rbr_empty.value.ul = statsp->rbr_empty;
6706f45ec7bSml29623 		rdc_kstatsp->rbrfull.value.ul = statsp->rbrfull;
6716f45ec7bSml29623 		rdc_kstatsp->rbrlogpage.value.ul = statsp->rbrlogpage;
6726f45ec7bSml29623 		rdc_kstatsp->cfiglogpage.value.ul = statsp->cfiglogpage;
6736f45ec7bSml29623 	}
6746f45ec7bSml29623 
6756f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_stat_update"));
6766f45ec7bSml29623 	return (0);
6776f45ec7bSml29623 }
6786f45ec7bSml29623 
6796f45ec7bSml29623 /* ARGSUSED */
6806f45ec7bSml29623 int
nxge_rdc_sys_stat_update(kstat_t * ksp,int rw)6816f45ec7bSml29623 nxge_rdc_sys_stat_update(kstat_t *ksp, int rw)
6826f45ec7bSml29623 {
6836f45ec7bSml29623 	p_nxge_t nxgep;
6846f45ec7bSml29623 	p_nxge_rdc_sys_kstat_t rdc_sys_kstatsp;
6856f45ec7bSml29623 	p_nxge_rdc_sys_stats_t statsp;
6866f45ec7bSml29623 
6876f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
6886f45ec7bSml29623 	if (nxgep == NULL)
6896f45ec7bSml29623 		return (-1);
6906f45ec7bSml29623 
6916f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_sys_stat_update"));
6926f45ec7bSml29623 
6936f45ec7bSml29623 	rdc_sys_kstatsp = (p_nxge_rdc_sys_kstat_t)ksp->ks_data;
6946f45ec7bSml29623 	statsp = (p_nxge_rdc_sys_stats_t)&nxgep->statsp->rdc_sys_stats;
6956f45ec7bSml29623 
6966f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "nxge_rdc_sys_stat_update %llx",
6976f45ec7bSml29623 	    ksp->ks_data));
6986f45ec7bSml29623 
6996f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
7006f45ec7bSml29623 		statsp->id_mismatch = rdc_sys_kstatsp->id_mismatch.value.ul;
7016f45ec7bSml29623 		statsp->ipp_eop_err = rdc_sys_kstatsp->ipp_eop_err.value.ul;
7026f45ec7bSml29623 		statsp->zcp_eop_err = rdc_sys_kstatsp->zcp_eop_err.value.ul;
7036f45ec7bSml29623 	} else {
7046f45ec7bSml29623 		rdc_sys_kstatsp->id_mismatch.value.ul = statsp->id_mismatch;
7056f45ec7bSml29623 		rdc_sys_kstatsp->ipp_eop_err.value.ul = statsp->ipp_eop_err;
7066f45ec7bSml29623 		rdc_sys_kstatsp->zcp_eop_err.value.ul = statsp->zcp_eop_err;
7076f45ec7bSml29623 	}
7086f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_sys_stat_update"));
7096f45ec7bSml29623 	return (0);
7106f45ec7bSml29623 }
7116f45ec7bSml29623 
7126f45ec7bSml29623 /* ARGSUSED */
7136f45ec7bSml29623 static int
nxge_txc_stat_update(kstat_t * ksp,int rw)7146f45ec7bSml29623 nxge_txc_stat_update(kstat_t *ksp, int rw)
7156f45ec7bSml29623 {
7166f45ec7bSml29623 	p_nxge_t nxgep;
7176f45ec7bSml29623 	p_nxge_txc_kstat_t txc_kstatsp;
7186f45ec7bSml29623 	p_nxge_txc_stats_t statsp;
7196f45ec7bSml29623 
7206f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
7216f45ec7bSml29623 
7226f45ec7bSml29623 	if (nxgep == NULL)
7236f45ec7bSml29623 		return (-1);
7246f45ec7bSml29623 
7256f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_txc_stat_update"));
7266f45ec7bSml29623 
7276f45ec7bSml29623 	txc_kstatsp = (p_nxge_txc_kstat_t)ksp->ks_data;
7286f45ec7bSml29623 	statsp = (p_nxge_txc_stats_t)&nxgep->statsp->txc_stats;
7296f45ec7bSml29623 
7306f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
7316f45ec7bSml29623 		statsp->pkt_stuffed = txc_kstatsp->pkt_stuffed.value.ul;
7326f45ec7bSml29623 		statsp->pkt_xmit = txc_kstatsp->pkt_xmit.value.ul;
7336f45ec7bSml29623 		statsp->ro_correct_err = txc_kstatsp->ro_correct_err.value.ul;
7346f45ec7bSml29623 		statsp->ro_uncorrect_err =
7356f45ec7bSml29623 		    txc_kstatsp->ro_uncorrect_err.value.ul;
7366f45ec7bSml29623 		statsp->sf_correct_err = txc_kstatsp->sf_correct_err.value.ul;
7376f45ec7bSml29623 		statsp->sf_uncorrect_err =
7386f45ec7bSml29623 		    txc_kstatsp->sf_uncorrect_err.value.ul;
7396f45ec7bSml29623 		statsp->address_failed = txc_kstatsp->address_failed.value.ul;
7406f45ec7bSml29623 		statsp->dma_failed = txc_kstatsp->dma_failed.value.ul;
7416f45ec7bSml29623 		statsp->length_failed = txc_kstatsp->length_failed.value.ul;
7426f45ec7bSml29623 		statsp->pkt_assy_dead = txc_kstatsp->pkt_assy_dead.value.ul;
7436f45ec7bSml29623 		statsp->reorder_err = txc_kstatsp->reorder_err.value.ul;
7446f45ec7bSml29623 	} else {
7456f45ec7bSml29623 		txc_kstatsp->pkt_stuffed.value.ul = statsp->pkt_stuffed;
7466f45ec7bSml29623 		txc_kstatsp->pkt_xmit.value.ul = statsp->pkt_xmit;
7476f45ec7bSml29623 		txc_kstatsp->ro_correct_err.value.ul = statsp->ro_correct_err;
7486f45ec7bSml29623 		txc_kstatsp->ro_uncorrect_err.value.ul =
7496f45ec7bSml29623 		    statsp->ro_uncorrect_err;
7506f45ec7bSml29623 		txc_kstatsp->sf_correct_err.value.ul = statsp->sf_correct_err;
7516f45ec7bSml29623 		txc_kstatsp->sf_uncorrect_err.value.ul =
7526f45ec7bSml29623 		    statsp->sf_uncorrect_err;
7536f45ec7bSml29623 		txc_kstatsp->address_failed.value.ul = statsp->address_failed;
7546f45ec7bSml29623 		txc_kstatsp->dma_failed.value.ul = statsp->dma_failed;
7556f45ec7bSml29623 		txc_kstatsp->length_failed.value.ul = statsp->length_failed;
7566f45ec7bSml29623 		txc_kstatsp->pkt_assy_dead.value.ul = statsp->pkt_assy_dead;
7576f45ec7bSml29623 		txc_kstatsp->reorder_err.value.ul = statsp->reorder_err;
7586f45ec7bSml29623 	}
7596f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_txc_stat_update"));
7606f45ec7bSml29623 	return (0);
7616f45ec7bSml29623 }
7626f45ec7bSml29623 
7636f45ec7bSml29623 /* ARGSUSED */
7646f45ec7bSml29623 int
nxge_ipp_stat_update(kstat_t * ksp,int rw)7656f45ec7bSml29623 nxge_ipp_stat_update(kstat_t *ksp, int rw)
7666f45ec7bSml29623 {
7676f45ec7bSml29623 	p_nxge_t nxgep;
7686f45ec7bSml29623 	p_nxge_ipp_kstat_t ipp_kstatsp;
7696f45ec7bSml29623 	p_nxge_ipp_stats_t statsp;
7706f45ec7bSml29623 
7716f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
7726f45ec7bSml29623 	if (nxgep == NULL)
7736f45ec7bSml29623 		return (-1);
7746f45ec7bSml29623 
7756f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_ipp_stat_update"));
7766f45ec7bSml29623 
7776f45ec7bSml29623 	ipp_kstatsp = (p_nxge_ipp_kstat_t)ksp->ks_data;
7786f45ec7bSml29623 	statsp = (p_nxge_ipp_stats_t)&nxgep->statsp->ipp_stats;
7796f45ec7bSml29623 
7806f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
7816f45ec7bSml29623 		statsp->eop_miss = ipp_kstatsp->eop_miss.value.ul;
7826f45ec7bSml29623 		statsp->sop_miss = ipp_kstatsp->sop_miss.value.ul;
7836f45ec7bSml29623 		statsp->dfifo_ue = ipp_kstatsp->dfifo_ue.value.ul;
7846f45ec7bSml29623 		statsp->ecc_err_cnt = ipp_kstatsp->ecc_err_cnt.value.ul;
785846a903dSml29623 		statsp->pfifo_perr = ipp_kstatsp->pfifo_perr.value.ul;
7866f45ec7bSml29623 		statsp->pfifo_over = ipp_kstatsp->pfifo_over.value.ul;
7876f45ec7bSml29623 		statsp->pfifo_und = ipp_kstatsp->pfifo_und.value.ul;
7886f45ec7bSml29623 		statsp->bad_cs_cnt = ipp_kstatsp->bad_cs_cnt.value.ul;
7896f45ec7bSml29623 		statsp->pkt_dis_cnt = ipp_kstatsp->pkt_dis_cnt.value.ul;
7906f45ec7bSml29623 	} else {
7916f45ec7bSml29623 		ipp_kstatsp->eop_miss.value.ul = statsp->eop_miss;
7926f45ec7bSml29623 		ipp_kstatsp->sop_miss.value.ul = statsp->sop_miss;
7936f45ec7bSml29623 		ipp_kstatsp->dfifo_ue.value.ul = statsp->dfifo_ue;
7946f45ec7bSml29623 		ipp_kstatsp->ecc_err_cnt.value.ul = statsp->ecc_err_cnt;
795846a903dSml29623 		ipp_kstatsp->pfifo_perr.value.ul = statsp->pfifo_perr;
7966f45ec7bSml29623 		ipp_kstatsp->pfifo_over.value.ul = statsp->pfifo_over;
7976f45ec7bSml29623 		ipp_kstatsp->pfifo_und.value.ul = statsp->pfifo_und;
7986f45ec7bSml29623 		ipp_kstatsp->bad_cs_cnt.value.ul = statsp->bad_cs_cnt;
7996f45ec7bSml29623 		ipp_kstatsp->pkt_dis_cnt.value.ul = statsp->pkt_dis_cnt;
8006f45ec7bSml29623 	}
8016f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_ipp_stat_update"));
8026f45ec7bSml29623 	return (0);
8036f45ec7bSml29623 }
8046f45ec7bSml29623 
8056f45ec7bSml29623 /* ARGSUSED */
8066f45ec7bSml29623 int
nxge_xmac_stat_update(kstat_t * ksp,int rw)8076f45ec7bSml29623 nxge_xmac_stat_update(kstat_t *ksp, int rw)
8086f45ec7bSml29623 {
8096f45ec7bSml29623 	p_nxge_t nxgep;
8106f45ec7bSml29623 	p_nxge_xmac_kstat_t xmac_kstatsp;
8116f45ec7bSml29623 	p_nxge_xmac_stats_t statsp;
8126f45ec7bSml29623 
8136f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
8146f45ec7bSml29623 	if (nxgep == NULL)
8156f45ec7bSml29623 		return (-1);
8166f45ec7bSml29623 
8176f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_xmac_stat_update"));
8186f45ec7bSml29623 
8196f45ec7bSml29623 	xmac_kstatsp = (p_nxge_xmac_kstat_t)ksp->ks_data;
8206f45ec7bSml29623 	statsp = (p_nxge_xmac_stats_t)&nxgep->statsp->xmac_stats;
8216f45ec7bSml29623 
8226f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
8236f45ec7bSml29623 		statsp->tx_frame_cnt = xmac_kstatsp->tx_frame_cnt.value.ul;
8246f45ec7bSml29623 		statsp->tx_underflow_err =
8256f45ec7bSml29623 		    xmac_kstatsp->tx_underflow_err.value.ul;
8266f45ec7bSml29623 		statsp->tx_maxpktsize_err =
8276f45ec7bSml29623 		    xmac_kstatsp->tx_maxpktsize_err.value.ul;
8286f45ec7bSml29623 		statsp->tx_overflow_err =
8296f45ec7bSml29623 		    xmac_kstatsp->tx_overflow_err.value.ul;
8306f45ec7bSml29623 		statsp->tx_fifo_xfr_err =
8316f45ec7bSml29623 		    xmac_kstatsp->tx_fifo_xfr_err.value.ul;
8326f45ec7bSml29623 		statsp->tx_byte_cnt = xmac_kstatsp->tx_byte_cnt.value.ul;
8336f45ec7bSml29623 		statsp->rx_underflow_err =
8346f45ec7bSml29623 		    xmac_kstatsp->rx_underflow_err.value.ul;
8356f45ec7bSml29623 		statsp->rx_overflow_err =
8366f45ec7bSml29623 		    xmac_kstatsp->rx_overflow_err.value.ul;
8376f45ec7bSml29623 		statsp->rx_crc_err_cnt = xmac_kstatsp->rx_crc_err_cnt.value.ul;
8386f45ec7bSml29623 		statsp->rx_len_err_cnt = xmac_kstatsp->rx_len_err_cnt.value.ul;
8396f45ec7bSml29623 		statsp->rx_viol_err_cnt =
8406f45ec7bSml29623 		    xmac_kstatsp->rx_viol_err_cnt.value.ul;
8416f45ec7bSml29623 		statsp->rx_byte_cnt = xmac_kstatsp->rx_byte_cnt.value.ul;
842321febdeSsbehera 		statsp->rx_frame_cnt = xmac_kstatsp->rx_frame_cnt.value.ul;
8436f45ec7bSml29623 		statsp->rx_hist1_cnt = xmac_kstatsp->rx_hist1_cnt.value.ul;
8446f45ec7bSml29623 		statsp->rx_hist2_cnt = xmac_kstatsp->rx_hist2_cnt.value.ul;
8456f45ec7bSml29623 		statsp->rx_hist3_cnt = xmac_kstatsp->rx_hist3_cnt.value.ul;
8466f45ec7bSml29623 		statsp->rx_hist4_cnt = xmac_kstatsp->rx_hist4_cnt.value.ul;
8476f45ec7bSml29623 		statsp->rx_hist5_cnt = xmac_kstatsp->rx_hist5_cnt.value.ul;
8486f45ec7bSml29623 		statsp->rx_hist6_cnt = xmac_kstatsp->rx_hist6_cnt.value.ul;
849321febdeSsbehera 		statsp->rx_hist7_cnt = xmac_kstatsp->rx_hist7_cnt.value.ul;
8506f45ec7bSml29623 		statsp->rx_mult_cnt = xmac_kstatsp->rx_mult_cnt.value.ul;
8516f45ec7bSml29623 		statsp->rx_frag_cnt = xmac_kstatsp->rx_frag_cnt.value.ul;
8526f45ec7bSml29623 		statsp->rx_frame_align_err_cnt =
8536f45ec7bSml29623 		    xmac_kstatsp->rx_frame_align_err_cnt.value.ul;
8546f45ec7bSml29623 		statsp->rx_linkfault_err_cnt =
8556f45ec7bSml29623 		    xmac_kstatsp->rx_linkfault_err_cnt.value.ul;
8566f45ec7bSml29623 		statsp->rx_localfault_err =
8576f45ec7bSml29623 		    xmac_kstatsp->rx_local_fault_err_cnt.value.ul;
8586f45ec7bSml29623 		statsp->rx_remotefault_err =
8596f45ec7bSml29623 		    xmac_kstatsp->rx_remote_fault_err_cnt.value.ul;
8606f45ec7bSml29623 		statsp->xpcs_deskew_err_cnt =
8616f45ec7bSml29623 		    xmac_kstatsp->xpcs_deskew_err_cnt.value.ul;
8626f45ec7bSml29623 #ifdef	NXGE_DEBUG_SYMBOL_ERR
8636f45ec7bSml29623 		statsp->xpcs_ln0_symbol_err_cnt =
8646f45ec7bSml29623 		    xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul;
8656f45ec7bSml29623 		statsp->xpcs_ln1_symbol_err_cnt =
8666f45ec7bSml29623 		    xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul;
8676f45ec7bSml29623 		statsp->xpcs_ln2_symbol_err_cnt =
8686f45ec7bSml29623 		    xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul;
8696f45ec7bSml29623 		statsp->xpcs_ln3_symbol_err_cnt =
8706f45ec7bSml29623 		    xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul;
8716f45ec7bSml29623 #endif
8726f45ec7bSml29623 	} else {
8736f45ec7bSml29623 		xmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
8746f45ec7bSml29623 		xmac_kstatsp->tx_underflow_err.value.ul =
8756f45ec7bSml29623 		    statsp->tx_underflow_err;
8766f45ec7bSml29623 		xmac_kstatsp->tx_maxpktsize_err.value.ul =
8776f45ec7bSml29623 		    statsp->tx_maxpktsize_err;
8786f45ec7bSml29623 		xmac_kstatsp->tx_overflow_err.value.ul =
8796f45ec7bSml29623 		    statsp->tx_overflow_err;
8806f45ec7bSml29623 		xmac_kstatsp->tx_fifo_xfr_err.value.ul =
8816f45ec7bSml29623 		    statsp->tx_fifo_xfr_err;
8826f45ec7bSml29623 		xmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
8836f45ec7bSml29623 		xmac_kstatsp->rx_underflow_err.value.ul =
8846f45ec7bSml29623 		    statsp->rx_underflow_err;
8856f45ec7bSml29623 		xmac_kstatsp->rx_overflow_err.value.ul =
8866f45ec7bSml29623 		    statsp->rx_overflow_err;
8876f45ec7bSml29623 		xmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
8886f45ec7bSml29623 		xmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
8896f45ec7bSml29623 		xmac_kstatsp->rx_viol_err_cnt.value.ul =
8906f45ec7bSml29623 		    statsp->rx_viol_err_cnt;
8916f45ec7bSml29623 		xmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
892321febdeSsbehera 		xmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
8936f45ec7bSml29623 		xmac_kstatsp->rx_hist1_cnt.value.ul = statsp->rx_hist1_cnt;
8946f45ec7bSml29623 		xmac_kstatsp->rx_hist2_cnt.value.ul = statsp->rx_hist2_cnt;
8956f45ec7bSml29623 		xmac_kstatsp->rx_hist3_cnt.value.ul = statsp->rx_hist3_cnt;
8966f45ec7bSml29623 		xmac_kstatsp->rx_hist4_cnt.value.ul = statsp->rx_hist4_cnt;
8976f45ec7bSml29623 		xmac_kstatsp->rx_hist5_cnt.value.ul = statsp->rx_hist5_cnt;
8986f45ec7bSml29623 		xmac_kstatsp->rx_hist6_cnt.value.ul = statsp->rx_hist6_cnt;
899321febdeSsbehera 		xmac_kstatsp->rx_hist7_cnt.value.ul = statsp->rx_hist7_cnt;
9006f45ec7bSml29623 		xmac_kstatsp->rx_mult_cnt.value.ul = statsp->rx_mult_cnt;
9016f45ec7bSml29623 		xmac_kstatsp->rx_frag_cnt.value.ul = statsp->rx_frag_cnt;
9026f45ec7bSml29623 		xmac_kstatsp->rx_frame_align_err_cnt.value.ul =
9036f45ec7bSml29623 		    statsp->rx_frame_align_err_cnt;
9046f45ec7bSml29623 		xmac_kstatsp->rx_linkfault_err_cnt.value.ul =
9056f45ec7bSml29623 		    statsp->rx_linkfault_err_cnt;
9066f45ec7bSml29623 		xmac_kstatsp->rx_local_fault_err_cnt.value.ul =
9076f45ec7bSml29623 		    statsp->rx_localfault_err;
9086f45ec7bSml29623 		xmac_kstatsp->rx_remote_fault_err_cnt.value.ul =
9096f45ec7bSml29623 		    statsp->rx_remotefault_err;
9106f45ec7bSml29623 		xmac_kstatsp->xpcs_deskew_err_cnt.value.ul =
9116f45ec7bSml29623 		    statsp->xpcs_deskew_err_cnt;
9126f45ec7bSml29623 #ifdef	NXGE_DEBUG_SYMBOL_ERR
9136f45ec7bSml29623 		xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul =
9146f45ec7bSml29623 		    statsp->xpcs_ln0_symbol_err_cnt;
9156f45ec7bSml29623 		xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul =
9166f45ec7bSml29623 		    statsp->xpcs_ln1_symbol_err_cnt;
9176f45ec7bSml29623 		xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul =
9186f45ec7bSml29623 		    statsp->xpcs_ln2_symbol_err_cnt;
9196f45ec7bSml29623 		xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul =
9206f45ec7bSml29623 		    statsp->xpcs_ln3_symbol_err_cnt;
9216f45ec7bSml29623 #endif
9226f45ec7bSml29623 	}
9236f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_xmac_stat_update"));
9246f45ec7bSml29623 	return (0);
9256f45ec7bSml29623 }
9266f45ec7bSml29623 
9276f45ec7bSml29623 /* ARGSUSED */
9286f45ec7bSml29623 int
nxge_bmac_stat_update(kstat_t * ksp,int rw)9296f45ec7bSml29623 nxge_bmac_stat_update(kstat_t *ksp, int rw)
9306f45ec7bSml29623 {
9316f45ec7bSml29623 	p_nxge_t nxgep;
9326f45ec7bSml29623 	p_nxge_bmac_kstat_t bmac_kstatsp;
9336f45ec7bSml29623 	p_nxge_bmac_stats_t statsp;
9346f45ec7bSml29623 
9356f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
9366f45ec7bSml29623 	if (nxgep == NULL)
9376f45ec7bSml29623 		return (-1);
9386f45ec7bSml29623 
9396f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_bmac_stat_update"));
9406f45ec7bSml29623 
9416f45ec7bSml29623 	bmac_kstatsp = (p_nxge_bmac_kstat_t)ksp->ks_data;
9426f45ec7bSml29623 	statsp = (p_nxge_bmac_stats_t)&nxgep->statsp->bmac_stats;
9436f45ec7bSml29623 
9446f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
9456f45ec7bSml29623 		statsp->tx_frame_cnt = bmac_kstatsp->tx_frame_cnt.value.ul;
9466f45ec7bSml29623 		statsp->tx_underrun_err =
9476f45ec7bSml29623 		    bmac_kstatsp->tx_underrun_err.value.ul;
9486f45ec7bSml29623 		statsp->tx_max_pkt_err = bmac_kstatsp->tx_max_pkt_err.value.ul;
9496f45ec7bSml29623 		statsp->tx_byte_cnt = bmac_kstatsp->tx_byte_cnt.value.ul;
9506f45ec7bSml29623 		statsp->rx_frame_cnt = bmac_kstatsp->rx_frame_cnt.value.ul;
9516f45ec7bSml29623 		statsp->rx_byte_cnt = bmac_kstatsp->rx_byte_cnt.value.ul;
9526f45ec7bSml29623 		statsp->rx_overflow_err =
9536f45ec7bSml29623 		    bmac_kstatsp->rx_overflow_err.value.ul;
9546f45ec7bSml29623 		statsp->rx_align_err_cnt =
9556f45ec7bSml29623 		    bmac_kstatsp->rx_align_err_cnt.value.ul;
9566f45ec7bSml29623 		statsp->rx_crc_err_cnt = bmac_kstatsp->rx_crc_err_cnt.value.ul;
9576f45ec7bSml29623 		statsp->rx_len_err_cnt = bmac_kstatsp->rx_len_err_cnt.value.ul;
9586f45ec7bSml29623 		statsp->rx_viol_err_cnt =
9596f45ec7bSml29623 		    bmac_kstatsp->rx_viol_err_cnt.value.ul;
9606f45ec7bSml29623 	} else {
9616f45ec7bSml29623 		bmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
9626f45ec7bSml29623 		bmac_kstatsp->tx_underrun_err.value.ul =
9636f45ec7bSml29623 		    statsp->tx_underrun_err;
9646f45ec7bSml29623 		bmac_kstatsp->tx_max_pkt_err.value.ul = statsp->tx_max_pkt_err;
9656f45ec7bSml29623 		bmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
9666f45ec7bSml29623 		bmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
9676f45ec7bSml29623 		bmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
9686f45ec7bSml29623 		bmac_kstatsp->rx_overflow_err.value.ul =
9696f45ec7bSml29623 		    statsp->rx_overflow_err;
9706f45ec7bSml29623 		bmac_kstatsp->rx_align_err_cnt.value.ul =
9716f45ec7bSml29623 		    statsp->rx_align_err_cnt;
9726f45ec7bSml29623 		bmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
9736f45ec7bSml29623 		bmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
9746f45ec7bSml29623 		bmac_kstatsp->rx_viol_err_cnt.value.ul =
9756f45ec7bSml29623 		    statsp->rx_viol_err_cnt;
9766f45ec7bSml29623 	}
9776f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_bmac_stat_update"));
9786f45ec7bSml29623 	return (0);
9796f45ec7bSml29623 }
9806f45ec7bSml29623 
9816f45ec7bSml29623 /* ARGSUSED */
9826f45ec7bSml29623 int
nxge_zcp_stat_update(kstat_t * ksp,int rw)9836f45ec7bSml29623 nxge_zcp_stat_update(kstat_t *ksp, int rw)
9846f45ec7bSml29623 {
9856f45ec7bSml29623 	p_nxge_t nxgep;
9866f45ec7bSml29623 	p_nxge_zcp_kstat_t zcp_kstatsp;
9876f45ec7bSml29623 	p_nxge_zcp_stats_t statsp;
9886f45ec7bSml29623 
9896f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
9906f45ec7bSml29623 	if (nxgep == NULL)
9916f45ec7bSml29623 		return (-1);
9926f45ec7bSml29623 
9936f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_zcp_stat_update"));
9946f45ec7bSml29623 
9956f45ec7bSml29623 	zcp_kstatsp = (p_nxge_zcp_kstat_t)ksp->ks_data;
9966f45ec7bSml29623 	statsp = (p_nxge_zcp_stats_t)&nxgep->statsp->zcp_stats;
9976f45ec7bSml29623 
9986f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
9996f45ec7bSml29623 		statsp->rrfifo_underrun = zcp_kstatsp->rrfifo_underrun.value.ul;
10006f45ec7bSml29623 		statsp->rrfifo_overrun = zcp_kstatsp->rrfifo_overrun.value.ul;
10016f45ec7bSml29623 		statsp->rspfifo_uncorr_err =
10026f45ec7bSml29623 		    zcp_kstatsp->rspfifo_uncorr_err.value.ul;
10036f45ec7bSml29623 		statsp->buffer_overflow = zcp_kstatsp->buffer_overflow.value.ul;
10046f45ec7bSml29623 		statsp->stat_tbl_perr = zcp_kstatsp->stat_tbl_perr.value.ul;
10056f45ec7bSml29623 		statsp->dyn_tbl_perr = zcp_kstatsp->dyn_tbl_perr.value.ul;
10066f45ec7bSml29623 		statsp->buf_tbl_perr = zcp_kstatsp->buf_tbl_perr.value.ul;
10076f45ec7bSml29623 		statsp->tt_program_err = zcp_kstatsp->tt_program_err.value.ul;
10086f45ec7bSml29623 		statsp->rsp_tt_index_err =
10096f45ec7bSml29623 		    zcp_kstatsp->rsp_tt_index_err.value.ul;
10106f45ec7bSml29623 		statsp->slv_tt_index_err =
10116f45ec7bSml29623 		    zcp_kstatsp->slv_tt_index_err.value.ul;
10126f45ec7bSml29623 		statsp->zcp_tt_index_err =
10136f45ec7bSml29623 		    zcp_kstatsp->zcp_tt_index_err.value.ul;
10146f45ec7bSml29623 		statsp->cfifo_ecc = zcp_kstatsp->cfifo_ecc.value.ul;
10156f45ec7bSml29623 	} else {
10166f45ec7bSml29623 		zcp_kstatsp->rrfifo_underrun.value.ul = statsp->rrfifo_underrun;
10176f45ec7bSml29623 		zcp_kstatsp->rrfifo_overrun.value.ul = statsp->rrfifo_overrun;
10186f45ec7bSml29623 		zcp_kstatsp->rspfifo_uncorr_err.value.ul =
10196f45ec7bSml29623 		    statsp->rspfifo_uncorr_err;
10206f45ec7bSml29623 		zcp_kstatsp->buffer_overflow.value.ul =
10216f45ec7bSml29623 		    statsp->buffer_overflow;
10226f45ec7bSml29623 		zcp_kstatsp->stat_tbl_perr.value.ul = statsp->stat_tbl_perr;
10236f45ec7bSml29623 		zcp_kstatsp->dyn_tbl_perr.value.ul = statsp->dyn_tbl_perr;
10246f45ec7bSml29623 		zcp_kstatsp->buf_tbl_perr.value.ul = statsp->buf_tbl_perr;
10256f45ec7bSml29623 		zcp_kstatsp->tt_program_err.value.ul = statsp->tt_program_err;
10266f45ec7bSml29623 		zcp_kstatsp->rsp_tt_index_err.value.ul =
10276f45ec7bSml29623 		    statsp->rsp_tt_index_err;
10286f45ec7bSml29623 		zcp_kstatsp->slv_tt_index_err.value.ul =
10296f45ec7bSml29623 		    statsp->slv_tt_index_err;
10306f45ec7bSml29623 		zcp_kstatsp->zcp_tt_index_err.value.ul =
10316f45ec7bSml29623 		    statsp->zcp_tt_index_err;
10326f45ec7bSml29623 		zcp_kstatsp->cfifo_ecc.value.ul = statsp->cfifo_ecc;
10336f45ec7bSml29623 	}
10346f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_zcp_stat_update"));
10356f45ec7bSml29623 	return (0);
10366f45ec7bSml29623 }
10376f45ec7bSml29623 
10386f45ec7bSml29623 /* ARGSUSED */
10396f45ec7bSml29623 int
nxge_fflp_stat_update(kstat_t * ksp,int rw)10406f45ec7bSml29623 nxge_fflp_stat_update(kstat_t *ksp, int rw)
10416f45ec7bSml29623 {
10426f45ec7bSml29623 	p_nxge_t nxgep;
10436f45ec7bSml29623 	p_nxge_fflp_kstat_t fflp_kstatsp;
10446f45ec7bSml29623 	p_nxge_fflp_stats_t statsp;
10456f45ec7bSml29623 	int ldc_grp;
10466f45ec7bSml29623 
10476f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
10486f45ec7bSml29623 	if (nxgep == NULL)
10496f45ec7bSml29623 		return (-1);
10506f45ec7bSml29623 
10516f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_fflp_stat_update"));
10526f45ec7bSml29623 
10536f45ec7bSml29623 	fflp_kstatsp = (p_nxge_fflp_kstat_t)ksp->ks_data;
10546f45ec7bSml29623 	statsp = (p_nxge_fflp_stats_t)&nxgep->statsp->fflp_stats;
10556f45ec7bSml29623 
10566f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
10576f45ec7bSml29623 		statsp->tcam_parity_err = fflp_kstatsp->fflp_tcam_perr.value.ul;
10586f45ec7bSml29623 		statsp->tcam_ecc_err = fflp_kstatsp->fflp_tcam_ecc_err.value.ul;
10596f45ec7bSml29623 		statsp->vlan_parity_err = fflp_kstatsp->fflp_vlan_perr.value.ul;
10606f45ec7bSml29623 		statsp->hash_lookup_err =
10616f45ec7bSml29623 		    fflp_kstatsp->fflp_hasht_lookup_err.value.ul;
10626f45ec7bSml29623 		for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
10636f45ec7bSml29623 			statsp->hash_pio_err[ldc_grp] =
10646f45ec7bSml29623 			    fflp_kstatsp->fflp_hasht_data_err[ldc_grp].
10656f45ec7bSml29623 			    value.ul;
10666f45ec7bSml29623 		}
10676f45ec7bSml29623 	} else {
10686f45ec7bSml29623 		fflp_kstatsp->fflp_tcam_perr.value.ul =
10696f45ec7bSml29623 		    fflp_kstatsp->fflp_tcam_perr.value.ul;
10706f45ec7bSml29623 		fflp_kstatsp->fflp_tcam_ecc_err.value.ul = statsp->tcam_ecc_err;
10716f45ec7bSml29623 		fflp_kstatsp->fflp_vlan_perr.value.ul = statsp->vlan_parity_err;
10726f45ec7bSml29623 		fflp_kstatsp->fflp_hasht_lookup_err.value.ul =
10736f45ec7bSml29623 		    statsp->hash_lookup_err;
10746f45ec7bSml29623 		for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
10756f45ec7bSml29623 			fflp_kstatsp->fflp_hasht_data_err[ldc_grp].value.ul =
10766f45ec7bSml29623 			    statsp->hash_pio_err[ldc_grp];
10776f45ec7bSml29623 		}
10786f45ec7bSml29623 	}
10796f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_fflp_stat_update"));
10806f45ec7bSml29623 	return (0);
10816f45ec7bSml29623 }
10826f45ec7bSml29623 
10836f45ec7bSml29623 /* ARGSUSED */
10846f45ec7bSml29623 static uint64_t
nxge_mac_octet_to_u64(struct ether_addr addr)10856f45ec7bSml29623 nxge_mac_octet_to_u64(struct ether_addr addr)
10866f45ec7bSml29623 {
10876f45ec7bSml29623 	int i;
10886f45ec7bSml29623 	uint64_t addr64 = 0;
10896f45ec7bSml29623 
10906f45ec7bSml29623 	for (i = ETHERADDRL - 1; i >= 0; i--) {
10916f45ec7bSml29623 		addr64 <<= 8;
10926f45ec7bSml29623 		addr64 |= addr.ether_addr_octet[i];
10936f45ec7bSml29623 	}
10946f45ec7bSml29623 	return (addr64);
10956f45ec7bSml29623 }
10966f45ec7bSml29623 
10976f45ec7bSml29623 /* ARGSUSED */
10986f45ec7bSml29623 int
nxge_mmac_stat_update(kstat_t * ksp,int rw)10996f45ec7bSml29623 nxge_mmac_stat_update(kstat_t *ksp, int rw)
11006f45ec7bSml29623 {
11016f45ec7bSml29623 	p_nxge_t nxgep;
11026f45ec7bSml29623 	p_nxge_mmac_kstat_t mmac_kstatsp;
11036f45ec7bSml29623 	p_nxge_mmac_stats_t statsp;
11046f45ec7bSml29623 
11056f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
11066f45ec7bSml29623 	if (nxgep == NULL)
11076f45ec7bSml29623 		return (-1);
11086f45ec7bSml29623 
11096f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_mmac_stat_update"));
11106f45ec7bSml29623 
11116f45ec7bSml29623 	mmac_kstatsp = (p_nxge_mmac_kstat_t)ksp->ks_data;
11126f45ec7bSml29623 	statsp = (p_nxge_mmac_stats_t)&nxgep->statsp->mmac_stats;
11136f45ec7bSml29623 
11146f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
11156f45ec7bSml29623 		cmn_err(CE_WARN, "Can not write mmac stats");
11166f45ec7bSml29623 	} else {
11176f45ec7bSml29623 		mmac_kstatsp->mmac_max_addr_cnt.value.ul =
11186f45ec7bSml29623 		    statsp->mmac_max_cnt;
11196f45ec7bSml29623 		mmac_kstatsp->mmac_avail_addr_cnt.value.ul =
11206f45ec7bSml29623 		    statsp->mmac_avail_cnt;
11216f45ec7bSml29623 		mmac_kstatsp->mmac_addr1.value.ul =
11226f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[0]);
11236f45ec7bSml29623 		mmac_kstatsp->mmac_addr2.value.ul =
11246f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[1]);
11256f45ec7bSml29623 		mmac_kstatsp->mmac_addr3.value.ul =
11266f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[2]);
11276f45ec7bSml29623 		mmac_kstatsp->mmac_addr4.value.ul =
11286f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[3]);
11296f45ec7bSml29623 		mmac_kstatsp->mmac_addr5.value.ul =
11306f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[4]);
11316f45ec7bSml29623 		mmac_kstatsp->mmac_addr6.value.ul =
11326f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[5]);
11336f45ec7bSml29623 		mmac_kstatsp->mmac_addr7.value.ul =
11346f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[6]);
11356f45ec7bSml29623 		mmac_kstatsp->mmac_addr8.value.ul =
11366f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[7]);
11376f45ec7bSml29623 		mmac_kstatsp->mmac_addr9.value.ul =
11386f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[8]);
11396f45ec7bSml29623 		mmac_kstatsp->mmac_addr10.value.ul =
11406f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[9]);
11416f45ec7bSml29623 		mmac_kstatsp->mmac_addr11.value.ul =
11426f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[10]);
11436f45ec7bSml29623 		mmac_kstatsp->mmac_addr12.value.ul =
11446f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[11]);
11456f45ec7bSml29623 		mmac_kstatsp->mmac_addr13.value.ul =
11466f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[12]);
11476f45ec7bSml29623 		mmac_kstatsp->mmac_addr14.value.ul =
11486f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[13]);
11496f45ec7bSml29623 		mmac_kstatsp->mmac_addr15.value.ul =
11506f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[14]);
11516f45ec7bSml29623 		mmac_kstatsp->mmac_addr16.value.ul =
11526f45ec7bSml29623 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[15]);
11536f45ec7bSml29623 	}
11546f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_mmac_stat_update"));
11556f45ec7bSml29623 	return (0);
11566f45ec7bSml29623 }
11576f45ec7bSml29623 
11586f45ec7bSml29623 /* ARGSUSED */
11596f45ec7bSml29623 static kstat_t *
nxge_setup_local_kstat(p_nxge_t nxgep,int instance,char * name,const nxge_kstat_index_t * ksip,size_t count,int (* update)(kstat_t *,int))11606f45ec7bSml29623 nxge_setup_local_kstat(p_nxge_t nxgep, int instance, char *name,
11616f45ec7bSml29623 	const nxge_kstat_index_t *ksip, size_t count,
11626f45ec7bSml29623 	int (*update) (kstat_t *, int))
11636f45ec7bSml29623 {
11646f45ec7bSml29623 	kstat_t *ksp;
11656f45ec7bSml29623 	kstat_named_t *knp;
11666f45ec7bSml29623 	int i;
11676f45ec7bSml29623 
11686f45ec7bSml29623 	ksp = kstat_create(NXGE_DRIVER_NAME, instance, name, "net",
11696f45ec7bSml29623 	    KSTAT_TYPE_NAMED, count, 0);
11706f45ec7bSml29623 	if (ksp == NULL)
11716f45ec7bSml29623 		return (NULL);
11726f45ec7bSml29623 
11736f45ec7bSml29623 	ksp->ks_private = (void *)nxgep;
11746f45ec7bSml29623 	ksp->ks_update = update;
11756f45ec7bSml29623 	knp = ksp->ks_data;
11766f45ec7bSml29623 
11776f45ec7bSml29623 	for (i = 0; ksip[i].name != NULL; i++) {
11786f45ec7bSml29623 		kstat_named_init(&knp[i], ksip[i].name, ksip[i].type);
11796f45ec7bSml29623 	}
11806f45ec7bSml29623 
11816f45ec7bSml29623 	kstat_install(ksp);
11826f45ec7bSml29623 	return (ksp);
11836f45ec7bSml29623 }
11846f45ec7bSml29623 
11856f45ec7bSml29623 /* ARGSUSED */
11866f45ec7bSml29623 void
nxge_setup_rdc_kstats(p_nxge_t nxgep,int channel)1187678453a8Sspeer nxge_setup_rdc_kstats(p_nxge_t nxgep, int channel)
1188678453a8Sspeer {
1189678453a8Sspeer 	char stat_name[64];
1190678453a8Sspeer 
1191678453a8Sspeer 	/* Setup RDC statistics */
1192678453a8Sspeer 	(void) sprintf(stat_name, "%s" CH_NAME_FORMAT,
1193678453a8Sspeer 	    RDC_NAME_FORMAT1, channel);
1194678453a8Sspeer 	nxgep->statsp->rdc_ksp[channel] = nxge_setup_local_kstat(nxgep,
1195678453a8Sspeer 	    nxgep->instance,
1196678453a8Sspeer 	    stat_name,
1197678453a8Sspeer 	    nxge_rdc_stats,
1198678453a8Sspeer 	    RDC_STAT_END,
1199678453a8Sspeer 	    nxge_rdc_stat_update);
1200678453a8Sspeer #ifdef	NXGE_DEBUG_ERROR
1201678453a8Sspeer 	if (nxgep->statsp->rdc_ksp[channel] == NULL)
1202678453a8Sspeer 		NXGE_DEBUG_MSG((nxgep, KST_CTL,
1203678453a8Sspeer 		    "kstat_create failed for rdc channel %d", channel));
1204678453a8Sspeer #endif
1205678453a8Sspeer }
1206678453a8Sspeer 
1207678453a8Sspeer void
nxge_setup_tdc_kstats(p_nxge_t nxgep,int channel)1208678453a8Sspeer nxge_setup_tdc_kstats(p_nxge_t nxgep, int channel)
1209678453a8Sspeer {
1210678453a8Sspeer 	char stat_name[64];
1211678453a8Sspeer 
1212678453a8Sspeer 	/* Setup TDC statistics */
1213678453a8Sspeer 	(void) sprintf(stat_name, "%s" CH_NAME_FORMAT,
1214678453a8Sspeer 	    TDC_NAME_FORMAT1, channel);
1215678453a8Sspeer 	nxgep->statsp->tdc_ksp[channel] = nxge_setup_local_kstat(nxgep,
1216678453a8Sspeer 	    nxgep->instance,
1217678453a8Sspeer 	    stat_name,
1218678453a8Sspeer 	    nxge_tdc_stats,
1219678453a8Sspeer 	    TDC_STAT_END,
1220678453a8Sspeer 	    nxge_tdc_stat_update);
1221678453a8Sspeer #ifdef	NXGE_DEBUG_ERROR
1222678453a8Sspeer 	if (nxgep->statsp->tdc_ksp[channel] == NULL) {
1223678453a8Sspeer 		NXGE_DEBUG_MSG((nxgep, KST_CTL,
1224678453a8Sspeer 		    "kstat_create failed for tdc channel %d", channel));
1225678453a8Sspeer 	}
1226678453a8Sspeer #endif
1227678453a8Sspeer }
1228678453a8Sspeer 
1229678453a8Sspeer void
nxge_setup_kstats(p_nxge_t nxgep)12306f45ec7bSml29623 nxge_setup_kstats(p_nxge_t nxgep)
12316f45ec7bSml29623 {
12326f45ec7bSml29623 	struct kstat *ksp;
12336f45ec7bSml29623 	p_nxge_port_kstat_t nxgekp;
12346f45ec7bSml29623 	size_t nxge_kstat_sz;
12356f45ec7bSml29623 	char mmac_name[64];
12366f45ec7bSml29623 
12376f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_setup_kstats"));
12386f45ec7bSml29623 
12396f45ec7bSml29623 	/* Setup RDC System statistics */
12406f45ec7bSml29623 	nxgep->statsp->rdc_sys_ksp = nxge_setup_local_kstat(nxgep,
12416f45ec7bSml29623 	    nxgep->instance,
12426f45ec7bSml29623 	    "RDC System Stats",
12436f45ec7bSml29623 	    &nxge_rdc_sys_stats[0],
12446f45ec7bSml29623 	    RDC_SYS_STAT_END,
12456f45ec7bSml29623 	    nxge_rdc_sys_stat_update);
12466f45ec7bSml29623 
12476f45ec7bSml29623 	/* Setup IPP statistics */
12486f45ec7bSml29623 	nxgep->statsp->ipp_ksp = nxge_setup_local_kstat(nxgep,
12496f45ec7bSml29623 	    nxgep->instance,
12506f45ec7bSml29623 	    "IPP Stats",
12516f45ec7bSml29623 	    &nxge_ipp_stats[0],
12526f45ec7bSml29623 	    IPP_STAT_END,
12536f45ec7bSml29623 	    nxge_ipp_stat_update);
12546f45ec7bSml29623 #ifdef	NXGE_DEBUG_ERROR
12556f45ec7bSml29623 	if (nxgep->istatsp->pp_ksp == NULL)
12566f45ec7bSml29623 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for ipp"));
12576f45ec7bSml29623 #endif
12586f45ec7bSml29623 
12596f45ec7bSml29623 	/* Setup TXC statistics */
12606f45ec7bSml29623 	nxgep->statsp->txc_ksp = nxge_setup_local_kstat(nxgep,
12616f45ec7bSml29623 	    nxgep->instance, "TXC Stats", &nxge_txc_stats[0],
12626f45ec7bSml29623 	    TXC_STAT_END, nxge_txc_stat_update);
12636f45ec7bSml29623 #ifdef	NXGE_DEBUG_ERROR
12646f45ec7bSml29623 	if (nxgep->statsp->txc_ksp == NULL)
12656f45ec7bSml29623 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for txc"));
12666f45ec7bSml29623 #endif
12676f45ec7bSml29623 
12686f45ec7bSml29623 	/* Setup ZCP statistics */
12696f45ec7bSml29623 	nxgep->statsp->zcp_ksp = nxge_setup_local_kstat(nxgep,
12706f45ec7bSml29623 	    nxgep->instance, "ZCP Stats", &nxge_zcp_stats[0],
12716f45ec7bSml29623 	    ZCP_STAT_END, nxge_zcp_stat_update);
12726f45ec7bSml29623 #ifdef	NXGE_DEBUG_ERROR
12736f45ec7bSml29623 	if (nxgep->statsp->zcp_ksp == NULL)
12746f45ec7bSml29623 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for zcp"));
12756f45ec7bSml29623 #endif
12766f45ec7bSml29623 
12776f45ec7bSml29623 	/* Setup FFLP statistics */
12786f45ec7bSml29623 	nxgep->statsp->fflp_ksp[0] = nxge_setup_local_kstat(nxgep,
12796f45ec7bSml29623 	    nxgep->instance, "FFLP Stats", &nxge_fflp_stats[0],
12806f45ec7bSml29623 	    FFLP_STAT_END, nxge_fflp_stat_update);
12816f45ec7bSml29623 
12826f45ec7bSml29623 #ifdef	NXGE_DEBUG_ERROR
12836f45ec7bSml29623 	if (nxgep->statsp->fflp_ksp == NULL)
12846f45ec7bSml29623 		NXGE_DEBUG_MSG((nxgep, KST_CTL,
12856f45ec7bSml29623 		    "kstat_create failed for fflp"));
12866f45ec7bSml29623 #endif
12876f45ec7bSml29623 
12886f45ec7bSml29623 	(void) sprintf(mmac_name, "MMAC Stats%d", nxgep->instance);
12896f45ec7bSml29623 	nxgep->statsp->mmac_ksp = nxge_setup_local_kstat(nxgep,
12906f45ec7bSml29623 	    nxgep->instance, "MMAC Stats", &nxge_mmac_stats[0],
12916f45ec7bSml29623 	    MMAC_STATS_END, nxge_mmac_stat_update);
12926f45ec7bSml29623 
12936f45ec7bSml29623 	nxge_kstat_sz = sizeof (nxge_port_kstat_t) +
12946f45ec7bSml29623 	    sizeof (nxge_mac_kstat_t) - sizeof (kstat_named_t);
12956f45ec7bSml29623 
12966f45ec7bSml29623 	if ((ksp = kstat_create(NXGE_DRIVER_NAME, nxgep->instance,
12976f45ec7bSml29623 	    "Port Stats", "net", KSTAT_TYPE_NAMED,
12986f45ec7bSml29623 	    nxge_kstat_sz / sizeof (kstat_named_t), 0)) == NULL) {
12996f45ec7bSml29623 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed"));
13006f45ec7bSml29623 		NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats"));
13016f45ec7bSml29623 		return;
13026f45ec7bSml29623 	}
13036f45ec7bSml29623 
13046f45ec7bSml29623 	/*
13056f45ec7bSml29623 	 * kstats
13066f45ec7bSml29623 	 */
13076f45ec7bSml29623 	nxgekp = (p_nxge_port_kstat_t)ksp->ks_data;
13086f45ec7bSml29623 
13096f45ec7bSml29623 	/*
13106f45ec7bSml29623 	 * transceiver state informations.
13116f45ec7bSml29623 	 */
13126f45ec7bSml29623 	kstat_named_init(&nxgekp->xcvr_inits, "xcvr_inits",
13136f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13146f45ec7bSml29623 	kstat_named_init(&nxgekp->xcvr_inuse, "xcvr_inuse",
13156f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13166f45ec7bSml29623 	kstat_named_init(&nxgekp->xcvr_addr, "xcvr_addr",
13176f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13186f45ec7bSml29623 	kstat_named_init(&nxgekp->xcvr_id, "xcvr_id",
13196f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13206f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_autoneg, "cap_autoneg",
13216f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13226f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_10gfdx, "cap_10gfdx",
13236f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13246f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_10ghdx, "cap_10ghdx",
13256f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13266f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_1000fdx, "cap_1000fdx",
13276f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13286f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_1000hdx, "cap_1000hdx",
13296f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13306f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_100T4, "cap_100T4",
13316f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13326f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_100fdx, "cap_100fdx",
13336f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13346f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_100hdx, "cap_100hdx",
13356f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13366f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_10fdx, "cap_10fdx",
13376f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13386f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_10hdx, "cap_10hdx",
13396f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13406f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_asmpause, "cap_asmpause",
13416f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13426f45ec7bSml29623 	kstat_named_init(&nxgekp->cap_pause, "cap_pause",
13436f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13446f45ec7bSml29623 
13456f45ec7bSml29623 	/*
13466f45ec7bSml29623 	 * Link partner capabilities.
13476f45ec7bSml29623 	 */
13486f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_autoneg, "lp_cap_autoneg",
13496f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13506f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_10gfdx, "lp_cap_10gfdx",
13516f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13526f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_10ghdx, "lp_cap_10ghdx",
13536f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13546f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_1000fdx, "lp_cap_1000fdx",
13556f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13566f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_1000hdx, "lp_cap_1000hdx",
13576f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13586f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_100T4, "lp_cap_100T4",
13596f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13606f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_100fdx, "lp_cap_100fdx",
13616f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13626f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_100hdx, "lp_cap_100hdx",
13636f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13646f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_10fdx, "lp_cap_10fdx",
13656f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13666f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_10hdx, "lp_cap_10hdx",
13676f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13686f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_asmpause, "lp_cap_asmpause",
13696f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13706f45ec7bSml29623 	kstat_named_init(&nxgekp->lp_cap_pause, "lp_cap_pause",
13716f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13726f45ec7bSml29623 	/*
13736f45ec7bSml29623 	 * Shared link setup.
13746f45ec7bSml29623 	 */
13756f45ec7bSml29623 	kstat_named_init(&nxgekp->link_T4, "link_T4",
13766f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13776f45ec7bSml29623 	kstat_named_init(&nxgekp->link_speed, "link_speed",
13786f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13796f45ec7bSml29623 	kstat_named_init(&nxgekp->link_duplex, "link_duplex",
13806f45ec7bSml29623 	    KSTAT_DATA_CHAR);
13816f45ec7bSml29623 	kstat_named_init(&nxgekp->link_asmpause, "link_asmpause",
13826f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13836f45ec7bSml29623 	kstat_named_init(&nxgekp->link_pause, "link_pause",
13846f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13856f45ec7bSml29623 	kstat_named_init(&nxgekp->link_up, "link_up",
13866f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13876f45ec7bSml29623 
13886f45ec7bSml29623 	/*
13896f45ec7bSml29623 	 * Let the user know the MTU currently in use by the physical MAC
13906f45ec7bSml29623 	 * port.
13916f45ec7bSml29623 	 */
13926f45ec7bSml29623 	kstat_named_init(&nxgekp->mac_mtu, "mac_mtu",
13936f45ec7bSml29623 	    KSTAT_DATA_ULONG);
13946f45ec7bSml29623 
13956f45ec7bSml29623 	/*
13966f45ec7bSml29623 	 * Loopback statistics.
13976f45ec7bSml29623 	 */
13986f45ec7bSml29623 	kstat_named_init(&nxgekp->lb_mode, "lb_mode",
13996f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14006f45ec7bSml29623 
14016f45ec7bSml29623 	/*
14026f45ec7bSml29623 	 * This tells the user whether the driver is in QOS mode or not.
14036f45ec7bSml29623 	 */
14046f45ec7bSml29623 	kstat_named_init(&nxgekp->qos_mode, "qos_mode",
14056f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14066f45ec7bSml29623 
14076f45ec7bSml29623 	/*
14086f45ec7bSml29623 	 * This tells whether the instance is trunked or not
14096f45ec7bSml29623 	 */
14106f45ec7bSml29623 	kstat_named_init(&nxgekp->trunk_mode, "trunk_mode",
14116f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14126f45ec7bSml29623 
14136f45ec7bSml29623 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
14146f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_reqs, "mdt_reqs",
14156f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14166f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_hdr_bufs, "mdt_hdr_bufs",
14176f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14186f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_pld_bufs, "mdt_pld_bufs",
14196f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14206f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_pkts, "mdt_pkts",
14216f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14226f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_hdrs, "mdt_hdrs",
14236f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14246f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_plds, "mdt_plds",
14256f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14266f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_hdr_bind_fail, "mdt_hdr_bind_fail",
14276f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14286f45ec7bSml29623 	kstat_named_init(&nxgekp->mdt_pld_bind_fail, "mdt_pld_bind_fail",
14296f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14306f45ec7bSml29623 #endif
1431321febdeSsbehera #ifdef ACCEPT_JUMBO
14326f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_jumbo_pkts, "tx_jumbo_pkts",
14336f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14346f45ec7bSml29623 #endif
14356f45ec7bSml29623 
14366f45ec7bSml29623 	/*
14376f45ec7bSml29623 	 * Rx Statistics.
14386f45ec7bSml29623 	 */
1439321febdeSsbehera #ifdef ACCEPT_JUMBO
14406f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_jumbo_pkts, "rx_jumbo_pkts",
14416f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14426f45ec7bSml29623 #endif
14436f45ec7bSml29623 	/* General MAC statistics */
14446f45ec7bSml29623 	kstat_named_init(&nxgekp->ifspeed, "ifspeed",
14456f45ec7bSml29623 	    KSTAT_DATA_UINT64);
14466f45ec7bSml29623 	kstat_named_init(&nxgekp->promisc, "promisc",
14476f45ec7bSml29623 	    KSTAT_DATA_CHAR);
14486f45ec7bSml29623 	kstat_named_init(&nxgekp->rev_id, "rev_id",
14496f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14506f45ec7bSml29623 
14516f45ec7bSml29623 	ksp->ks_update = nxge_port_kstat_update;
14526f45ec7bSml29623 	ksp->ks_private = (void *) nxgep;
14536f45ec7bSml29623 	if (nxgep->mac.porttype == PORT_TYPE_XMAC)
14546f45ec7bSml29623 		nxge_xmac_init_kstats(ksp);
14556f45ec7bSml29623 	else
14566f45ec7bSml29623 		nxge_bmac_init_kstats(ksp);
14576f45ec7bSml29623 	kstat_install(ksp);
14586f45ec7bSml29623 	nxgep->statsp->port_ksp = ksp;
14596f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats"));
14606f45ec7bSml29623 }
14616f45ec7bSml29623 
14626f45ec7bSml29623 /* ARGSUSED */
14636f45ec7bSml29623 void
nxge_xmac_init_kstats(struct kstat * ksp)14646f45ec7bSml29623 nxge_xmac_init_kstats(struct kstat *ksp)
14656f45ec7bSml29623 {
14666f45ec7bSml29623 	p_nxge_xmac_kstat_t nxgekp;
14676f45ec7bSml29623 
14686f45ec7bSml29623 	nxgekp = (p_nxge_xmac_kstat_t)ksp->ks_data;
14696f45ec7bSml29623 
14706f45ec7bSml29623 	/*
14716f45ec7bSml29623 	 * Transmit MAC statistics.
14726f45ec7bSml29623 	 */
14736f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
14746f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14756f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err",
14766f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14776f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err",
14786f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14796f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err",
14806f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14816f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err",
14826f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14836f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
14846f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14856f45ec7bSml29623 
14866f45ec7bSml29623 	/* Receive MAC statistics */
1487321febdeSsbehera 	kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1488321febdeSsbehera 	    KSTAT_DATA_ULONG);
14896f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
14906f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14916f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err",
14926f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14936f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
14946f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14956f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
14966f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14976f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
14986f45ec7bSml29623 	    KSTAT_DATA_ULONG);
14996f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
15006f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15016f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_frame_align_err_cnt,
15026f45ec7bSml29623 	    "rxmac_alignment_err",
15036f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15046f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt",
15056f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15066f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt",
15076f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15086f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt",
15096f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15106f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt",
15116f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15126f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt",
15136f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15146f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt",
15156f45ec7bSml29623 	    KSTAT_DATA_ULONG);
1516321febdeSsbehera 	kstat_named_init(&nxgekp->rx_hist7_cnt, "rxmac_jumbo_cnt",
1517321febdeSsbehera 	    KSTAT_DATA_ULONG);
15186f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_broadcast_cnt, "rxmac_broadcast_cnt",
15196f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15206f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt",
15216f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15226f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt",
15236f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15246f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_linkfault_err_cnt, "rxmac_linkfault_errs",
15256f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15266f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_remote_fault_err_cnt,
15276f45ec7bSml29623 	    "rxmac_remote_faults",
15286f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15296f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_local_fault_err_cnt, "rxmac_local_faults",
15306f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15316f45ec7bSml29623 
15326f45ec7bSml29623 	/* XPCS statistics */
15336f45ec7bSml29623 
15346f45ec7bSml29623 	kstat_named_init(&nxgekp->xpcs_deskew_err_cnt, "xpcs_deskew_err_cnt",
15356f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15366f45ec7bSml29623 #ifdef	NXGE_DEBUG_SYMBOL_ERR
15376f45ec7bSml29623 	kstat_named_init(&nxgekp->xpcs_ln0_symbol_err_cnt,
15386f45ec7bSml29623 	    "xpcs_ln0_symbol_err_cnt",
15396f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15406f45ec7bSml29623 	kstat_named_init(&nxgekp->xpcs_ln1_symbol_err_cnt,
15416f45ec7bSml29623 	    "xpcs_ln1_symbol_err_cnt",
15426f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15436f45ec7bSml29623 	kstat_named_init(&nxgekp->xpcs_ln2_symbol_err_cnt,
15446f45ec7bSml29623 	    "xpcs_ln2_symbol_err_cnt",
15456f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15466f45ec7bSml29623 	kstat_named_init(&nxgekp->xpcs_ln3_symbol_err_cnt,
15476f45ec7bSml29623 	    "xpcs_ln3_symbol_err_cnt",
15486f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15496f45ec7bSml29623 #endif
15506f45ec7bSml29623 }
15516f45ec7bSml29623 
15526f45ec7bSml29623 /* ARGSUSED */
15536f45ec7bSml29623 void
nxge_bmac_init_kstats(struct kstat * ksp)15546f45ec7bSml29623 nxge_bmac_init_kstats(struct kstat *ksp)
15556f45ec7bSml29623 {
15566f45ec7bSml29623 	p_nxge_bmac_kstat_t nxgekp;
15576f45ec7bSml29623 
15586f45ec7bSml29623 	nxgekp = (p_nxge_bmac_kstat_t)ksp->ks_data;
15596f45ec7bSml29623 
15606f45ec7bSml29623 	/*
15616f45ec7bSml29623 	 * Transmit MAC statistics.
15626f45ec7bSml29623 	 */
15636f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
15646f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15656f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_underrun_err, "txmac_underflow_err",
15666f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15676f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_max_pkt_err, "txmac_maxpktsize_err",
15686f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15696f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
15706f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15716f45ec7bSml29623 
15726f45ec7bSml29623 	/* Receive MAC statistics */
15736f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
15746f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15756f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
15766f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15776f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
15786f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15796f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
15806f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15816f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
15826f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15836f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_align_err_cnt, "rxmac_alignment_err",
15846f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15856f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
15866f45ec7bSml29623 	    KSTAT_DATA_ULONG);
15876f45ec7bSml29623 }
15886f45ec7bSml29623 
15896f45ec7bSml29623 /* ARGSUSED */
15906f45ec7bSml29623 void
nxge_mac_init_kstats(p_nxge_t nxgep,struct kstat * ksp)15916f45ec7bSml29623 nxge_mac_init_kstats(p_nxge_t nxgep, struct kstat *ksp)
15926f45ec7bSml29623 {
15936f45ec7bSml29623 	p_nxge_mac_kstat_t nxgekp;
15946f45ec7bSml29623 
15956f45ec7bSml29623 	nxgekp = (p_nxge_mac_kstat_t)ksp->ks_data;
15966f45ec7bSml29623 
15976f45ec7bSml29623 	/*
15986f45ec7bSml29623 	 * Transmit MAC statistics.
15996f45ec7bSml29623 	 */
16006f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt",
16016f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16026f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err",
16036f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16046f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err",
16056f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16066f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err",
16076f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16086f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err",
16096f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16106f45ec7bSml29623 	kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt",
16116f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16126f45ec7bSml29623 
16136f45ec7bSml29623 	/*
16146f45ec7bSml29623 	 * Receive MAC statistics
16156f45ec7bSml29623 	 */
16166f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err",
16176f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16186f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err",
16196f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16206f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err",
16216f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16226f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err",
16236f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16246f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations",
16256f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16266f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt",
16276f45ec7bSml29623 	    KSTAT_DATA_ULONG);
16286f45ec7bSml29623 	kstat_named_init(&nxgekp->rx_frame_align_err_cnt,
16296f45ec7bSml29623 	    "rxmac_alignment_err",
16306f45ec7bSml29623 	    KSTAT_DATA_ULONG);
1631321febdeSsbehera 	kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt",
1632321febdeSsbehera 	    KSTAT_DATA_ULONG);
16336f45ec7bSml29623 	if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
16346f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt",
16356f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16366f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt",
16376f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16386f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt",
16396f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16406f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt",
16416f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16426f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt",
16436f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16446f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt",
16456f45ec7bSml29623 		    KSTAT_DATA_ULONG);
1646321febdeSsbehera 		kstat_named_init(&nxgekp->rx_hist7_cnt, "rxmac_jumbo_cnt",
1647321febdeSsbehera 		    KSTAT_DATA_ULONG);
16486f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_broadcast_cnt,
16496f45ec7bSml29623 		    "rxmac_broadcast_cnt",
16506f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16516f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt",
16526f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16536f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt",
16546f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16556f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_linkfault_err_cnt,
16566f45ec7bSml29623 		    "rxmac_linkfault_errs",
16576f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16586f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_remote_fault_err_cnt,
16596f45ec7bSml29623 		    "rxmac_remote_faults",
16606f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16616f45ec7bSml29623 		kstat_named_init(&nxgekp->rx_local_fault_err_cnt,
16626f45ec7bSml29623 		    "rxmac_local_faults",
16636f45ec7bSml29623 		    KSTAT_DATA_ULONG);
16646f45ec7bSml29623 	}
16656f45ec7bSml29623 }
16666f45ec7bSml29623 
16676f45ec7bSml29623 /* ARGSUSED */
16686f45ec7bSml29623 void
nxge_destroy_kstats(p_nxge_t nxgep)16696f45ec7bSml29623 nxge_destroy_kstats(p_nxge_t nxgep)
16706f45ec7bSml29623 {
16716f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_destroy_kstats"));
16726f45ec7bSml29623 
16736f45ec7bSml29623 	if (nxgep->statsp == NULL)
16746f45ec7bSml29623 		return;
16756f45ec7bSml29623 	if (nxgep->statsp->ksp)
16766f45ec7bSml29623 		kstat_delete(nxgep->statsp->ksp);
16776f45ec7bSml29623 
16786f45ec7bSml29623 	if (nxgep->statsp->rdc_sys_ksp)
16796f45ec7bSml29623 		kstat_delete(nxgep->statsp->rdc_sys_ksp);
16806f45ec7bSml29623 	if (nxgep->statsp->fflp_ksp[0])
16816f45ec7bSml29623 		kstat_delete(nxgep->statsp->fflp_ksp[0]);
16826f45ec7bSml29623 	if (nxgep->statsp->ipp_ksp)
16836f45ec7bSml29623 		kstat_delete(nxgep->statsp->ipp_ksp);
16846f45ec7bSml29623 	if (nxgep->statsp->txc_ksp)
16856f45ec7bSml29623 		kstat_delete(nxgep->statsp->txc_ksp);
16866f45ec7bSml29623 	if (nxgep->statsp->mac_ksp)
16876f45ec7bSml29623 		kstat_delete(nxgep->statsp->mac_ksp);
16886f45ec7bSml29623 	if (nxgep->statsp->zcp_ksp)
16896f45ec7bSml29623 		kstat_delete(nxgep->statsp->zcp_ksp);
16906f45ec7bSml29623 	if (nxgep->statsp->port_ksp)
16916f45ec7bSml29623 		kstat_delete(nxgep->statsp->port_ksp);
16926f45ec7bSml29623 	if (nxgep->statsp->mmac_ksp)
16936f45ec7bSml29623 		kstat_delete(nxgep->statsp->mmac_ksp);
16946f45ec7bSml29623 	if (nxgep->statsp)
16956f45ec7bSml29623 		KMEM_FREE(nxgep->statsp, nxgep->statsp->stats_size);
16966f45ec7bSml29623 
16976f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_destroy_kstats"));
16986f45ec7bSml29623 }
16996f45ec7bSml29623 
17006f45ec7bSml29623 /* ARGSUSED */
17016f45ec7bSml29623 int
nxge_port_kstat_update(kstat_t * ksp,int rw)17026f45ec7bSml29623 nxge_port_kstat_update(kstat_t *ksp, int rw)
17036f45ec7bSml29623 {
17046f45ec7bSml29623 	p_nxge_t nxgep;
17056f45ec7bSml29623 	p_nxge_stats_t statsp;
17066f45ec7bSml29623 	p_nxge_port_kstat_t nxgekp;
17076f45ec7bSml29623 
17086f45ec7bSml29623 	nxgep = (p_nxge_t)ksp->ks_private;
17096f45ec7bSml29623 	if (nxgep == NULL)
17106f45ec7bSml29623 		return (-1);
17116f45ec7bSml29623 
17126f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_port_kstat_update"));
17136f45ec7bSml29623 	statsp = (p_nxge_stats_t)nxgep->statsp;
17146f45ec7bSml29623 	nxgekp = (p_nxge_port_kstat_t)ksp->ks_data;
17156f45ec7bSml29623 	nxge_save_cntrs(nxgep);
17166f45ec7bSml29623 
17176f45ec7bSml29623 	if (rw == KSTAT_WRITE) {
17186f45ec7bSml29623 		/*
17196f45ec7bSml29623 		 * transceiver state informations.
17206f45ec7bSml29623 		 */
17216f45ec7bSml29623 		statsp->mac_stats.xcvr_inits = nxgekp->xcvr_inits.value.ul;
17226f45ec7bSml29623 
17236f45ec7bSml29623 		/*
17246f45ec7bSml29623 		 * Tx Statistics.
17256f45ec7bSml29623 		 */
17266f45ec7bSml29623 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
17276f45ec7bSml29623 		statsp->port_stats.mdt_reqs = nxgekp->mdt_reqs.value.ul;
17286f45ec7bSml29623 		statsp->port_stats.mdt_hdr_bufs = nxgekp->mdt_hdr_bufs.value.ul;
17296f45ec7bSml29623 		statsp->port_stats.mdt_pld_bufs = nxgekp->mdt_pld_bufs.value.ul;
17306f45ec7bSml29623 		statsp->port_stats.mdt_pkts = nxgekp->mdt_pkts.value.ul;
17316f45ec7bSml29623 		statsp->port_stats.mdt_hdrs = nxgekp->mdt_hdrs.value.ul;
17326f45ec7bSml29623 		statsp->port_stats.mdt_plds = nxgekp->mdt_plds.value.ul;
17336f45ec7bSml29623 		statsp->port_stats.mdt_hdr_bind_fail =
17346f45ec7bSml29623 		    nxgekp->mdt_hdr_bind_fail.value.ul;
17356f45ec7bSml29623 		statsp->port_stats.mdt_pld_bind_fail =
17366f45ec7bSml29623 		    nxgekp->mdt_pld_bind_fail.value.ul;
17376f45ec7bSml29623 #endif
17386f45ec7bSml29623 #ifdef ACCEPT_JUMBO
17396f45ec7bSml29623 		statsp->port_stats.tx_jumbo_pkts =
17406f45ec7bSml29623 		    nxgekp->tx_jumbo_pkts.value.ul;
17416f45ec7bSml29623 #endif
17426f45ec7bSml29623 		/*
17436f45ec7bSml29623 		 * Rx Statistics.
17446f45ec7bSml29623 		 */
1745321febdeSsbehera #ifdef ACCEPT_JUMBO
17466f45ec7bSml29623 		statsp->port_stats.rx_jumbo_pkts =
17476f45ec7bSml29623 		    nxgekp->rx_jumbo_pkts.value.ul;
17486f45ec7bSml29623 #endif
1749321febdeSsbehera 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
17506f45ec7bSml29623 			(void) nxge_xmac_stat_update(ksp, KSTAT_WRITE);
1751321febdeSsbehera 		} else {
1752321febdeSsbehera 			(void) nxge_bmac_stat_update(ksp, KSTAT_WRITE);
1753321febdeSsbehera 		}
17546f45ec7bSml29623 		return (0);
17556f45ec7bSml29623 	} else {
17566f45ec7bSml29623 		if (nxgep->filter.all_phys_cnt)
17576f45ec7bSml29623 			(void) strcpy(nxgekp->promisc.value.c, "phys");
17586f45ec7bSml29623 		else if (nxgep->filter.all_multicast_cnt)
17596f45ec7bSml29623 			(void) strcpy(nxgekp->promisc.value.c, "multi");
17606f45ec7bSml29623 		else
17616f45ec7bSml29623 			(void) strcpy(nxgekp->promisc.value.c, "off");
17626f45ec7bSml29623 		nxgekp->ifspeed.value.ul =
17636f45ec7bSml29623 		    statsp->mac_stats.link_speed * 1000000ULL;
17646f45ec7bSml29623 		nxgekp->rev_id.value.ul = statsp->mac_stats.rev_id;
17656f45ec7bSml29623 
17666f45ec7bSml29623 		/*
17676f45ec7bSml29623 		 * transceiver state informations.
17686f45ec7bSml29623 		 */
17696f45ec7bSml29623 		nxgekp->xcvr_inits.value.ul = statsp->mac_stats.xcvr_inits;
17706f45ec7bSml29623 		nxgekp->xcvr_inuse.value.ul = statsp->mac_stats.xcvr_inuse;
17716f45ec7bSml29623 		nxgekp->xcvr_addr.value.ul = statsp->mac_stats.xcvr_portn;
17726f45ec7bSml29623 		nxgekp->xcvr_id.value.ul = statsp->mac_stats.xcvr_id;
17736f45ec7bSml29623 		nxgekp->cap_autoneg.value.ul = statsp->mac_stats.cap_autoneg;
17746f45ec7bSml29623 		nxgekp->cap_10gfdx.value.ul = statsp->mac_stats.cap_10gfdx;
17756f45ec7bSml29623 		nxgekp->cap_10ghdx.value.ul = statsp->mac_stats.cap_10ghdx;
17766f45ec7bSml29623 		nxgekp->cap_1000fdx.value.ul = statsp->mac_stats.cap_1000fdx;
17776f45ec7bSml29623 		nxgekp->cap_1000hdx.value.ul = statsp->mac_stats.cap_1000hdx;
17786f45ec7bSml29623 		nxgekp->cap_100T4.value.ul = statsp->mac_stats.cap_100T4;
17796f45ec7bSml29623 		nxgekp->cap_100fdx.value.ul = statsp->mac_stats.cap_100fdx;
17806f45ec7bSml29623 		nxgekp->cap_100hdx.value.ul = statsp->mac_stats.cap_100hdx;
17816f45ec7bSml29623 		nxgekp->cap_10fdx.value.ul = statsp->mac_stats.cap_10fdx;
17826f45ec7bSml29623 		nxgekp->cap_10hdx.value.ul = statsp->mac_stats.cap_10hdx;
17836f45ec7bSml29623 		nxgekp->cap_asmpause.value.ul =
17846f45ec7bSml29623 		    statsp->mac_stats.cap_asmpause;
17856f45ec7bSml29623 		nxgekp->cap_pause.value.ul = statsp->mac_stats.cap_pause;
17866f45ec7bSml29623 
17876f45ec7bSml29623 		/*
17886f45ec7bSml29623 		 * Link partner capabilities.
17896f45ec7bSml29623 		 */
17906f45ec7bSml29623 		nxgekp->lp_cap_autoneg.value.ul =
17916f45ec7bSml29623 		    statsp->mac_stats.lp_cap_autoneg;
17926f45ec7bSml29623 		nxgekp->lp_cap_10gfdx.value.ul =
17936f45ec7bSml29623 		    statsp->mac_stats.lp_cap_10gfdx;
17946f45ec7bSml29623 		nxgekp->lp_cap_10ghdx.value.ul =
17956f45ec7bSml29623 		    statsp->mac_stats.lp_cap_10ghdx;
17966f45ec7bSml29623 		nxgekp->lp_cap_1000fdx.value.ul =
17976f45ec7bSml29623 		    statsp->mac_stats.lp_cap_1000fdx;
17986f45ec7bSml29623 		nxgekp->lp_cap_1000hdx.value.ul =
17996f45ec7bSml29623 		    statsp->mac_stats.lp_cap_1000hdx;
18006f45ec7bSml29623 		nxgekp->lp_cap_100T4.value.ul =
18016f45ec7bSml29623 		    statsp->mac_stats.lp_cap_100T4;
18026f45ec7bSml29623 		nxgekp->lp_cap_100fdx.value.ul =
18036f45ec7bSml29623 		    statsp->mac_stats.lp_cap_100fdx;
18046f45ec7bSml29623 		nxgekp->lp_cap_100hdx.value.ul =
18056f45ec7bSml29623 		    statsp->mac_stats.lp_cap_100hdx;
18066f45ec7bSml29623 		nxgekp->lp_cap_10fdx.value.ul =
18076f45ec7bSml29623 		    statsp->mac_stats.lp_cap_10fdx;
18086f45ec7bSml29623 		nxgekp->lp_cap_10hdx.value.ul =
18096f45ec7bSml29623 		    statsp->mac_stats.lp_cap_10hdx;
18106f45ec7bSml29623 		nxgekp->lp_cap_asmpause.value.ul =
18116f45ec7bSml29623 		    statsp->mac_stats.lp_cap_asmpause;
18126f45ec7bSml29623 		nxgekp->lp_cap_pause.value.ul =
18136f45ec7bSml29623 		    statsp->mac_stats.lp_cap_pause;
18146f45ec7bSml29623 
18156f45ec7bSml29623 		/*
18166f45ec7bSml29623 		 * Physical link statistics.
18176f45ec7bSml29623 		 */
18186f45ec7bSml29623 		nxgekp->link_T4.value.ul = statsp->mac_stats.link_T4;
18196f45ec7bSml29623 		nxgekp->link_speed.value.ul = statsp->mac_stats.link_speed;
18206f45ec7bSml29623 		if (statsp->mac_stats.link_duplex == 2)
18216f45ec7bSml29623 			(void) strcpy(nxgekp->link_duplex.value.c, "full");
18226f45ec7bSml29623 		else if (statsp->mac_stats.link_duplex == 1)
18236f45ec7bSml29623 			(void) strcpy(nxgekp->link_duplex.value.c, "half");
18246f45ec7bSml29623 		else
18256f45ec7bSml29623 			(void) strcpy(nxgekp->link_duplex.value.c, "unknown");
18266f45ec7bSml29623 		nxgekp->link_asmpause.value.ul =
18276f45ec7bSml29623 		    statsp->mac_stats.link_asmpause;
18286f45ec7bSml29623 		nxgekp->link_pause.value.ul = statsp->mac_stats.link_pause;
18296f45ec7bSml29623 		nxgekp->link_up.value.ul = statsp->mac_stats.link_up;
18306f45ec7bSml29623 
18316f45ec7bSml29623 		/*
18326f45ec7bSml29623 		 * Lets the user know the MTU currently in use by the physical
18336f45ec7bSml29623 		 * MAC port.
18346f45ec7bSml29623 		 */
18356f45ec7bSml29623 		nxgekp->mac_mtu.value.ul = statsp->mac_stats.mac_mtu;
18366f45ec7bSml29623 
18376f45ec7bSml29623 		/*
18386f45ec7bSml29623 		 * Loopback statistics.
18396f45ec7bSml29623 		 */
18406f45ec7bSml29623 		nxgekp->lb_mode.value.ul = statsp->port_stats.lb_mode;
18416f45ec7bSml29623 
18426f45ec7bSml29623 		/*
18436f45ec7bSml29623 		 * This tells the user whether the driver is in QOS mode or
18446f45ec7bSml29623 		 * not.
18456f45ec7bSml29623 		 */
18466f45ec7bSml29623 		nxgekp->qos_mode.value.ul = statsp->port_stats.qos_mode;
18476f45ec7bSml29623 
18486f45ec7bSml29623 		/*
18496f45ec7bSml29623 		 * This tells whether the instance is trunked or not
18506f45ec7bSml29623 		 */
18516f45ec7bSml29623 		nxgekp->trunk_mode.value.ul = statsp->port_stats.trunk_mode;
18526f45ec7bSml29623 
18536f45ec7bSml29623 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2
18546f45ec7bSml29623 		nxgekp->mdt_reqs.value.ul = statsp->port_stats.mdt_reqs;
18556f45ec7bSml29623 		nxgekp->mdt_hdr_bufs.value.ul =
18566f45ec7bSml29623 		    statsp->port_stats.mdt_hdr_bufs;
18576f45ec7bSml29623 		nxgekp->mdt_pld_bufs.value.ul =
18586f45ec7bSml29623 		    statsp->port_stats.mdt_pld_bufs;
18596f45ec7bSml29623 		nxgekp->mdt_pkts.value.ul = statsp->port_stats.mdt_pkts;
18606f45ec7bSml29623 		nxgekp->mdt_hdrs.value.ul = statsp->port_stats.mdt_hdrs;
18616f45ec7bSml29623 		nxgekp->mdt_plds.value.ul = statsp->port_stats.mdt_plds;
18626f45ec7bSml29623 		nxgekp->mdt_hdr_bind_fail.value.ul =
18636f45ec7bSml29623 		    statsp->port_stats.mdt_hdr_bind_fail;
18646f45ec7bSml29623 		nxgekp->mdt_pld_bind_fail.value.ul =
18656f45ec7bSml29623 		    statsp->port_stats.mdt_pld_bind_fail;
18666f45ec7bSml29623 #endif
18676f45ec7bSml29623 #ifdef ACCEPT_JUMBO
18686f45ec7bSml29623 		nxgekp->tx_jumbo_pkts.value.ul =
18696f45ec7bSml29623 		    statsp->port_stats.tx_jumbo_pkts;
18706f45ec7bSml29623 #endif
18716f45ec7bSml29623 #ifdef TX_MBLK_DEST
18726f45ec7bSml29623 		nxgekp->tx_1_desc.value.ul = statsp->port_stats.tx_1_desc;
18736f45ec7bSml29623 		nxgekp->tx_2_desc.value.ul = statsp->port_stats.tx_2_desc;
18746f45ec7bSml29623 		nxgekp->tx_3_desc.value.ul = statsp->port_stats.tx_3_desc;
18756f45ec7bSml29623 		nxgekp->tx_4_desc.value.ul = statsp->port_stats.tx_4_desc;
18766f45ec7bSml29623 		nxgekp->tx_5_desc.value.ul = statsp->port_stats.tx_5_desc;
18776f45ec7bSml29623 		nxgekp->tx_6_desc.value.ul = statsp->port_stats.tx_6_desc;
18786f45ec7bSml29623 		nxgekp->tx_7_desc.value.ul = statsp->port_stats.tx_7_desc;
18796f45ec7bSml29623 		nxgekp->tx_8_desc.value.ul = statsp->port_stats.tx_8_desc;
18806f45ec7bSml29623 		nxgekp->tx_max_desc.value.ul =
18816f45ec7bSml29623 		    statsp->port_stats.tx_max_desc;
18826f45ec7bSml29623 #endif
18836f45ec7bSml29623 		/*
18846f45ec7bSml29623 		 * Rx Statistics.
18856f45ec7bSml29623 		 */
18866f45ec7bSml29623 #ifdef ACCEPT_JUMBO
18876f45ec7bSml29623 		nxgekp->rx_jumbo_pkts.value.ul =
18886f45ec7bSml29623 		    statsp->port_stats.rx_jumbo_pkts;
18896f45ec7bSml29623 #endif
1890321febdeSsbehera 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
18916f45ec7bSml29623 			(void) nxge_xmac_stat_update(ksp, KSTAT_READ);
1892321febdeSsbehera 		} else {
1893321febdeSsbehera 			(void) nxge_bmac_stat_update(ksp, KSTAT_READ);
1894321febdeSsbehera 		}
18956f45ec7bSml29623 	}
18966f45ec7bSml29623 
18976f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_port_kstat_update"));
18986f45ec7bSml29623 	return (0);
18996f45ec7bSml29623 }
19006f45ec7bSml29623 
19016f45ec7bSml29623 /*
19026f45ec7bSml29623  * if this is the first init do not bother to save the
19036f45ec7bSml29623  * counters.
19046f45ec7bSml29623  */
19056f45ec7bSml29623 /* ARGSUSED */
19066f45ec7bSml29623 void
nxge_save_cntrs(p_nxge_t nxgep)19076f45ec7bSml29623 nxge_save_cntrs(p_nxge_t nxgep)
19086f45ec7bSml29623 {
19096f45ec7bSml29623 	p_nxge_stats_t statsp;
19106f45ec7bSml29623 	uint64_t val;
19116f45ec7bSml29623 	npi_handle_t handle;
19126f45ec7bSml29623 	uint8_t portn;
19136f45ec7bSml29623 	uint8_t cnt8;
19146f45ec7bSml29623 	uint16_t cnt16;
19156f45ec7bSml29623 	uint32_t cnt32;
19166f45ec7bSml29623 
19176f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_save_cntrs"));
19186f45ec7bSml29623 
19196f45ec7bSml29623 	statsp = (p_nxge_stats_t)nxgep->statsp;
19206f45ec7bSml29623 	handle = nxgep->npi_handle;
19216f45ec7bSml29623 	portn = nxgep->mac.portnum;
19226f45ec7bSml29623 
19236f45ec7bSml29623 	MUTEX_ENTER(&nxgep->ouraddr_lock);
19246f45ec7bSml29623 
19256f45ec7bSml29623 	if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
19266f45ec7bSml29623 		/*
19276f45ec7bSml29623 		 * Transmit MAC statistics.
19286f45ec7bSml29623 		 */
19296f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XTXMAC_FRM_CNT_REG, &val);
19306f45ec7bSml29623 		statsp->xmac_stats.tx_frame_cnt += (val & XTXMAC_FRM_CNT_MASK);
19316f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XTXMAC_BYTE_CNT_REG, &val);
19326f45ec7bSml29623 		statsp->xmac_stats.tx_byte_cnt += (val & XTXMAC_BYTE_CNT_MASK);
19336f45ec7bSml29623 		/*
19346f45ec7bSml29623 		 * Receive XMAC statistics.
19356f45ec7bSml29623 		 */
19366f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_CRC_ER_CNT_REG, &val);
19376f45ec7bSml29623 		statsp->xmac_stats.rx_crc_err_cnt +=
19386f45ec7bSml29623 		    (val & XRXMAC_CRC_ER_CNT_MASK);
1939321febdeSsbehera 
19406f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_MPSZER_CNT_REG, &val);
19416f45ec7bSml29623 		statsp->xmac_stats.rx_len_err_cnt +=
19426f45ec7bSml29623 		    (val & XRXMAC_MPSZER_CNT_MASK);
1943321febdeSsbehera 
19446f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_CD_VIO_CNT_REG, &val);
19456f45ec7bSml29623 		statsp->xmac_stats.rx_viol_err_cnt +=
19466f45ec7bSml29623 		    (val & XRXMAC_CD_VIO_CNT_MASK);
1947321febdeSsbehera 
19486f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_BT_CNT_REG, &val);
19496f45ec7bSml29623 		statsp->xmac_stats.rx_byte_cnt += (val & XRXMAC_BT_CNT_MASK);
1950321febdeSsbehera 
19516f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT1_REG, &val);
19526f45ec7bSml29623 		statsp->xmac_stats.rx_hist1_cnt +=
19536f45ec7bSml29623 		    (val & XRXMAC_HIST_CNT1_MASK);
1954321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1955321febdeSsbehera 		    (val & XRXMAC_HIST_CNT1_MASK);
1956321febdeSsbehera 
19576f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT2_REG, &val);
19586f45ec7bSml29623 		statsp->xmac_stats.rx_hist2_cnt +=
19596f45ec7bSml29623 		    (val & XRXMAC_HIST_CNT2_MASK);
1960321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1961321febdeSsbehera 		    (val & XRXMAC_HIST_CNT2_MASK);
1962321febdeSsbehera 
19636f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT3_REG, &val);
19646f45ec7bSml29623 		statsp->xmac_stats.rx_hist3_cnt +=
19656f45ec7bSml29623 		    (val & XRXMAC_HIST_CNT3_MASK);
1966321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1967321febdeSsbehera 		    (val & XRXMAC_HIST_CNT3_MASK);
1968321febdeSsbehera 
19696f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT4_REG, &val);
19706f45ec7bSml29623 		statsp->xmac_stats.rx_hist4_cnt +=
19716f45ec7bSml29623 		    (val & XRXMAC_HIST_CNT4_MASK);
1972321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1973321febdeSsbehera 		    (val & XRXMAC_HIST_CNT4_MASK);
1974321febdeSsbehera 
19756f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT5_REG, &val);
19766f45ec7bSml29623 		statsp->xmac_stats.rx_hist5_cnt +=
19776f45ec7bSml29623 		    (val & XRXMAC_HIST_CNT5_MASK);
1978321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1979321febdeSsbehera 		    (val & XRXMAC_HIST_CNT5_MASK);
1980321febdeSsbehera 
19816f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT6_REG, &val);
19826f45ec7bSml29623 		statsp->xmac_stats.rx_hist6_cnt +=
19836f45ec7bSml29623 		    (val & XRXMAC_HIST_CNT6_MASK);
1984321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1985321febdeSsbehera 		    (val & XRXMAC_HIST_CNT6_MASK);
1986321febdeSsbehera 
1987321febdeSsbehera 		XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT7_REG, &val);
1988321febdeSsbehera 		statsp->xmac_stats.rx_hist7_cnt +=
1989321febdeSsbehera 		    (val & XRXMAC_HIST_CNT7_MASK);
1990321febdeSsbehera 		statsp->xmac_stats.rx_frame_cnt +=
1991321febdeSsbehera 		    (val & XRXMAC_HIST_CNT7_MASK);
1992321febdeSsbehera 
19936f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_BC_FRM_CNT_REG, &val);
19946f45ec7bSml29623 		statsp->xmac_stats.rx_broadcast_cnt +=
19956f45ec7bSml29623 		    (val & XRXMAC_BC_FRM_CNT_MASK);
1996321febdeSsbehera 
19976f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_MC_FRM_CNT_REG, &val);
19986f45ec7bSml29623 		statsp->xmac_stats.rx_mult_cnt +=
19996f45ec7bSml29623 		    (val & XRXMAC_MC_FRM_CNT_MASK);
2000321febdeSsbehera 
20016f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_FRAG_CNT_REG, &val);
20026f45ec7bSml29623 		statsp->xmac_stats.rx_frag_cnt += (val & XRXMAC_FRAG_CNT_MASK);
2003321febdeSsbehera 
20046f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XRXMAC_AL_ER_CNT_REG, &val);
20056f45ec7bSml29623 		statsp->xmac_stats.rx_frame_align_err_cnt +=
20066f45ec7bSml29623 		    (val & XRXMAC_AL_ER_CNT_MASK);
2007321febdeSsbehera 
20086f45ec7bSml29623 		XMAC_REG_RD(handle, portn, XMAC_LINK_FLT_CNT_REG, &val);
20096f45ec7bSml29623 		statsp->xmac_stats.rx_linkfault_err_cnt +=
20106f45ec7bSml29623 		    (val & XMAC_LINK_FLT_CNT_MASK);
2011321febdeSsbehera 
20126f45ec7bSml29623 		(void) npi_xmac_xpcs_read(handle, portn,
20136f45ec7bSml29623 		    XPCS_REG_DESCWERR_COUNTER, &cnt32);
20146f45ec7bSml29623 		statsp->xmac_stats.xpcs_deskew_err_cnt +=
20156f45ec7bSml29623 		    (val & XMAC_XPCS_DESKEW_ERR_CNT_MASK);
2016321febdeSsbehera 
20176f45ec7bSml29623 #ifdef	NXGE_DEBUG_SYMBOL_ERR
20186f45ec7bSml29623 		(void) npi_xmac_xpcs_read(handle, portn,
20196f45ec7bSml29623 		    XPCS_REG_SYMBOL_ERR_L0_1_COUNTER, &cnt32);
20206f45ec7bSml29623 		statsp->xmac_stats.xpcs_ln0_symbol_err_cnt +=
20216f45ec7bSml29623 		    (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L0_MASK);
20226f45ec7bSml29623 		statsp->xmac_stats.xpcs_ln1_symbol_err_cnt +=
20236f45ec7bSml29623 		    ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L1_MASK) >>
20246f45ec7bSml29623 		    XMAC_XPCS_SYM_ERR_CNT_L1_SHIFT);
20256f45ec7bSml29623 		(void) npi_xmac_xpcs_read(handle, portn,
20266f45ec7bSml29623 		    XPCS_REG_SYMBOL_ERR_L2_3_COUNTER, &cnt32);
20276f45ec7bSml29623 		statsp->xmac_stats.xpcs_ln2_symbol_err_cnt +=
20286f45ec7bSml29623 		    (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L2_MASK);
20296f45ec7bSml29623 		statsp->xmac_stats.xpcs_ln3_symbol_err_cnt +=
20306f45ec7bSml29623 		    ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L3_MASK) >>
20316f45ec7bSml29623 		    XMAC_XPCS_SYM_ERR_CNT_L3_SHIFT);
20326f45ec7bSml29623 #endif
20336f45ec7bSml29623 	} else if (nxgep->mac.porttype == PORT_TYPE_BMAC) {
20346f45ec7bSml29623 		/*
20356f45ec7bSml29623 		 * Transmit MAC statistics.
20366f45ec7bSml29623 		 */
20376f45ec7bSml29623 		BMAC_REG_RD(handle, portn, BTXMAC_FRM_CNT_REG, &val);
20386f45ec7bSml29623 		statsp->bmac_stats.tx_frame_cnt += (val & BTXMAC_FRM_CNT_MASK);
2039321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2040321febdeSsbehera 		BMAC_REG_WR(handle, portn, BTXMAC_FRM_CNT_REG, 0);
2041321febdeSsbehera 
2042321febdeSsbehera 		BMAC_REG_RD(handle, portn, BTXMAC_BYTE_CNT_REG, &val);
20436f45ec7bSml29623 		statsp->bmac_stats.tx_byte_cnt += (val & BTXMAC_BYTE_CNT_MASK);
2044321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2045321febdeSsbehera 		BMAC_REG_WR(handle, portn, BTXMAC_BYTE_CNT_REG, 0);
20466f45ec7bSml29623 
20476f45ec7bSml29623 		/*
20486f45ec7bSml29623 		 * Receive MAC statistics.
20496f45ec7bSml29623 		 */
2050321febdeSsbehera 		BMAC_REG_RD(handle, portn, RXMAC_FRM_CNT_REG, &val);
20516f45ec7bSml29623 		statsp->bmac_stats.rx_frame_cnt += (val & RXMAC_FRM_CNT_MASK);
2052321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2053321febdeSsbehera 		BMAC_REG_WR(handle, portn, RXMAC_FRM_CNT_REG, 0);
2054321febdeSsbehera 
2055321febdeSsbehera 		BMAC_REG_RD(handle, portn, BRXMAC_BYTE_CNT_REG, &val);
20566f45ec7bSml29623 		statsp->bmac_stats.rx_byte_cnt += (val & BRXMAC_BYTE_CNT_MASK);
2057321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2058321febdeSsbehera 		BMAC_REG_WR(handle, portn, BRXMAC_BYTE_CNT_REG, 0);
2059321febdeSsbehera 
2060321febdeSsbehera 		BMAC_REG_RD(handle, portn, BMAC_AL_ER_CNT_REG, &val);
20616f45ec7bSml29623 		statsp->bmac_stats.rx_align_err_cnt +=
20626f45ec7bSml29623 		    (val & BMAC_AL_ER_CNT_MASK);
2063321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2064321febdeSsbehera 		BMAC_REG_WR(handle, portn, BMAC_AL_ER_CNT_REG, 0);
2065321febdeSsbehera 
2066321febdeSsbehera 		BMAC_REG_RD(handle, portn, MAC_LEN_ER_CNT_REG, &val);
20676f45ec7bSml29623 		statsp->bmac_stats.rx_len_err_cnt +=
20686f45ec7bSml29623 		    (val & MAC_LEN_ER_CNT_MASK);
2069321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2070321febdeSsbehera 		BMAC_REG_WR(handle, portn, MAC_LEN_ER_CNT_REG, 0);
2071321febdeSsbehera 
2072321febdeSsbehera 		BMAC_REG_RD(handle, portn, BMAC_CRC_ER_CNT_REG, &val);
20736f45ec7bSml29623 		statsp->bmac_stats.rx_crc_err_cnt +=
20746f45ec7bSml29623 		    (val & BMAC_CRC_ER_CNT_MASK);
2075321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2076321febdeSsbehera 		BMAC_REG_WR(handle, portn, BMAC_CRC_ER_CNT_REG, 0);
2077321febdeSsbehera 
2078321febdeSsbehera 		BMAC_REG_RD(handle, portn, BMAC_CD_VIO_CNT_REG, &val);
20796f45ec7bSml29623 		statsp->bmac_stats.rx_viol_err_cnt +=
20806f45ec7bSml29623 		    (val & BMAC_CD_VIO_CNT_MASK);
2081321febdeSsbehera 		/* Clear register as it is not auto clear on read */
2082321febdeSsbehera 		BMAC_REG_WR(handle, portn, BMAC_CD_VIO_CNT_REG, 0);
20836f45ec7bSml29623 	}
2084678453a8Sspeer 	if (isLDOMguest(nxgep)) {
2085678453a8Sspeer 		MUTEX_EXIT(&nxgep->ouraddr_lock);
2086678453a8Sspeer 		goto nxge_save_cntrs_exit;
2087678453a8Sspeer 	}
20886f45ec7bSml29623 	/* Update IPP counters */
20896f45ec7bSml29623 	(void) npi_ipp_get_ecc_err_count(handle, portn, &cnt8);
20906f45ec7bSml29623 	statsp->ipp_stats.ecc_err_cnt += cnt8;
20916f45ec7bSml29623 	(void) npi_ipp_get_pkt_dis_count(handle, portn, &cnt16);
20926f45ec7bSml29623 	statsp->ipp_stats.pkt_dis_cnt += cnt16;
20936f45ec7bSml29623 	(void) npi_ipp_get_cs_err_count(handle, portn, &cnt16);
20946f45ec7bSml29623 	statsp->ipp_stats.bad_cs_cnt += cnt16;
20956f45ec7bSml29623 
20966f45ec7bSml29623 	MUTEX_EXIT(&nxgep->ouraddr_lock);
20976f45ec7bSml29623 
20986f45ec7bSml29623 nxge_save_cntrs_exit:
20996f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_save_cntrs"));
21006f45ec7bSml29623 }
21016f45ec7bSml29623 
2102678453a8Sspeer uint64_t
nxge_m_rx_stat(nxge_t * nxgep,uint_t stat)2103678453a8Sspeer nxge_m_rx_stat(
2104678453a8Sspeer 	nxge_t *nxgep,
2105678453a8Sspeer 	uint_t stat)
2106678453a8Sspeer {
2107678453a8Sspeer 	p_nxge_stats_t statsp;
2108678453a8Sspeer 	nxge_grp_set_t *rx_set;
2109678453a8Sspeer 	int8_t set[NXGE_MAX_RDCS];
2110678453a8Sspeer 	int i, cursor;
2111678453a8Sspeer 
2112678453a8Sspeer 	uint64_t val = 0;
2113678453a8Sspeer 
2114678453a8Sspeer 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_rx_stat"));
2115678453a8Sspeer 	statsp = (p_nxge_stats_t)nxgep->statsp;
2116678453a8Sspeer 
2117678453a8Sspeer 	rx_set = &nxgep->rx_set;
2118678453a8Sspeer 	for (i = 0, cursor = 0; i < NXGE_MAX_RDCS; i++) {
2119678453a8Sspeer 		if ((1 << i) & rx_set->owned.map) {
2120678453a8Sspeer 			set[cursor++] = (uint8_t)i;
2121678453a8Sspeer 		}
2122678453a8Sspeer 	}
2123678453a8Sspeer 
2124678453a8Sspeer 	for (i = 0; i < cursor; i++) {
2125678453a8Sspeer 		int rdc = set[i];
2126678453a8Sspeer 		switch (stat) {
2127678453a8Sspeer 		case MAC_STAT_IERRORS:
2128678453a8Sspeer 		case ETHER_STAT_MACRCV_ERRORS:
2129678453a8Sspeer 			val += statsp->rdc_stats[rdc].ierrors;
2130678453a8Sspeer 			break;
2131678453a8Sspeer 
2132678453a8Sspeer 		case MAC_STAT_RBYTES:
2133678453a8Sspeer 			val += statsp->rdc_stats[rdc].ibytes;
2134678453a8Sspeer 			break;
2135678453a8Sspeer 
2136678453a8Sspeer 		case MAC_STAT_IPACKETS:
2137678453a8Sspeer 			val += statsp->rdc_stats[rdc].ipackets;
2138678453a8Sspeer 			break;
2139678453a8Sspeer 
2140678453a8Sspeer 		default:
2141678453a8Sspeer 			break;
2142678453a8Sspeer 		}
2143678453a8Sspeer 	}
2144678453a8Sspeer 
2145678453a8Sspeer 	return (val);
2146678453a8Sspeer }
2147678453a8Sspeer 
2148678453a8Sspeer uint64_t
nxge_m_tx_stat(nxge_t * nxgep,uint_t stat)2149678453a8Sspeer nxge_m_tx_stat(
2150678453a8Sspeer 	nxge_t *nxgep,
2151678453a8Sspeer 	uint_t stat)
2152678453a8Sspeer {
2153678453a8Sspeer 	p_nxge_stats_t statsp;
2154678453a8Sspeer 	nxge_grp_set_t *tx_set;
2155678453a8Sspeer 	int8_t set[NXGE_MAX_TDCS];
2156678453a8Sspeer 	int i, cursor;
2157678453a8Sspeer 
2158678453a8Sspeer 	uint64_t val = 0;
2159678453a8Sspeer 
2160678453a8Sspeer 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_tx_stat"));
2161678453a8Sspeer 	statsp = (p_nxge_stats_t)nxgep->statsp;
2162678453a8Sspeer 
2163678453a8Sspeer 	tx_set = &nxgep->tx_set;
2164d6d3405fSml29623 	for (i = 0, cursor = 0; i < NXGE_MAX_TDCS; i++) {
2165678453a8Sspeer 		if ((1 << i) & tx_set->owned.map) {
2166678453a8Sspeer 			set[cursor++] = (uint8_t)i;
2167678453a8Sspeer 		}
2168678453a8Sspeer 	}
2169678453a8Sspeer 
2170678453a8Sspeer 	for (i = 0; i < cursor; i++) {
2171678453a8Sspeer 		int tdc = set[i];
2172678453a8Sspeer 		switch (stat) {
2173678453a8Sspeer 		case MAC_STAT_OERRORS:
2174678453a8Sspeer 			val += statsp->tdc_stats[tdc].oerrors;
2175678453a8Sspeer 			break;
2176678453a8Sspeer 
2177678453a8Sspeer 		case MAC_STAT_OBYTES:
2178678453a8Sspeer 			val += statsp->tdc_stats[tdc].obytes;
2179678453a8Sspeer 			break;
2180678453a8Sspeer 
2181678453a8Sspeer 		case MAC_STAT_OPACKETS:
2182678453a8Sspeer 			val += statsp->tdc_stats[tdc].opackets;
2183678453a8Sspeer 			break;
2184678453a8Sspeer 
2185678453a8Sspeer 		default:
2186678453a8Sspeer 			break;
2187678453a8Sspeer 		}
2188678453a8Sspeer 	}
2189678453a8Sspeer 
2190678453a8Sspeer 	return (val);
2191678453a8Sspeer }
2192678453a8Sspeer 
2193*0dc2366fSVenugopal Iyer /*
2194*0dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics for a particular rx ring
2195*0dc2366fSVenugopal Iyer  */
2196*0dc2366fSVenugopal Iyer int
nxge_rx_ring_stat(mac_ring_driver_t rdriver,uint_t stat,uint64_t * val)2197*0dc2366fSVenugopal Iyer nxge_rx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
2198*0dc2366fSVenugopal Iyer {
2199*0dc2366fSVenugopal Iyer 	p_nxge_ring_handle_t    rhp = (p_nxge_ring_handle_t)rdriver;
2200*0dc2366fSVenugopal Iyer 	p_nxge_t		nxgep = rhp->nxgep;
2201*0dc2366fSVenugopal Iyer 	int			r_index;
2202*0dc2366fSVenugopal Iyer 	p_nxge_stats_t 		statsp;
2203*0dc2366fSVenugopal Iyer 
2204*0dc2366fSVenugopal Iyer 	ASSERT(nxgep != NULL);
2205*0dc2366fSVenugopal Iyer 	statsp = (p_nxge_stats_t)nxgep->statsp;
2206*0dc2366fSVenugopal Iyer 	ASSERT(statsp != NULL);
2207*0dc2366fSVenugopal Iyer 	r_index = rhp->index + nxgep->pt_config.hw_config.start_rdc;
2208*0dc2366fSVenugopal Iyer 
2209*0dc2366fSVenugopal Iyer 	if (statsp->rdc_ksp[r_index] == NULL)
2210*0dc2366fSVenugopal Iyer 		return (0);
2211*0dc2366fSVenugopal Iyer 
2212*0dc2366fSVenugopal Iyer 	switch (stat) {
2213*0dc2366fSVenugopal Iyer 	case MAC_STAT_IERRORS:
2214*0dc2366fSVenugopal Iyer 		*val = statsp->rdc_stats[r_index].ierrors;
2215*0dc2366fSVenugopal Iyer 		break;
2216*0dc2366fSVenugopal Iyer 
2217*0dc2366fSVenugopal Iyer 	case MAC_STAT_RBYTES:
2218*0dc2366fSVenugopal Iyer 		*val = statsp->rdc_stats[r_index].ibytes;
2219*0dc2366fSVenugopal Iyer 		break;
2220*0dc2366fSVenugopal Iyer 
2221*0dc2366fSVenugopal Iyer 	case MAC_STAT_IPACKETS:
2222*0dc2366fSVenugopal Iyer 		*val = statsp->rdc_stats[r_index].ipackets;
2223*0dc2366fSVenugopal Iyer 		break;
2224*0dc2366fSVenugopal Iyer 
2225*0dc2366fSVenugopal Iyer 	default:
2226*0dc2366fSVenugopal Iyer 		*val = 0;
2227*0dc2366fSVenugopal Iyer 		return (ENOTSUP);
2228*0dc2366fSVenugopal Iyer 	}
2229*0dc2366fSVenugopal Iyer 
2230*0dc2366fSVenugopal Iyer 	return (0);
2231*0dc2366fSVenugopal Iyer }
2232*0dc2366fSVenugopal Iyer 
2233*0dc2366fSVenugopal Iyer /*
2234*0dc2366fSVenugopal Iyer  * Retrieve a value for one of the statistics for a particular tx ring
2235*0dc2366fSVenugopal Iyer  */
2236*0dc2366fSVenugopal Iyer int
nxge_tx_ring_stat(mac_ring_driver_t rdriver,uint_t stat,uint64_t * val)2237*0dc2366fSVenugopal Iyer nxge_tx_ring_stat(mac_ring_driver_t rdriver, uint_t stat, uint64_t *val)
2238*0dc2366fSVenugopal Iyer {
2239*0dc2366fSVenugopal Iyer 	p_nxge_ring_handle_t    rhp = (p_nxge_ring_handle_t)rdriver;
2240*0dc2366fSVenugopal Iyer 	p_nxge_t		nxgep = rhp->nxgep;
2241*0dc2366fSVenugopal Iyer 	int			r_index;
2242*0dc2366fSVenugopal Iyer 	p_nxge_stats_t 		statsp;
2243*0dc2366fSVenugopal Iyer 
2244*0dc2366fSVenugopal Iyer 	ASSERT(nxgep != NULL);
2245*0dc2366fSVenugopal Iyer 	statsp = (p_nxge_stats_t)nxgep->statsp;
2246*0dc2366fSVenugopal Iyer 	ASSERT(statsp != NULL);
2247*0dc2366fSVenugopal Iyer 	r_index = nxgep->pt_config.hw_config.tdc.start + rhp->index;
2248*0dc2366fSVenugopal Iyer 
2249*0dc2366fSVenugopal Iyer 	if (statsp->tdc_ksp[r_index] == NULL)
2250*0dc2366fSVenugopal Iyer 		return (0);
2251*0dc2366fSVenugopal Iyer 
2252*0dc2366fSVenugopal Iyer 	switch (stat) {
2253*0dc2366fSVenugopal Iyer 	case MAC_STAT_OERRORS:
2254*0dc2366fSVenugopal Iyer 		*val = statsp->tdc_stats[r_index].oerrors;
2255*0dc2366fSVenugopal Iyer 		break;
2256*0dc2366fSVenugopal Iyer 
2257*0dc2366fSVenugopal Iyer 	case MAC_STAT_OBYTES:
2258*0dc2366fSVenugopal Iyer 		*val = statsp->tdc_stats[r_index].obytes;
2259*0dc2366fSVenugopal Iyer 		break;
2260*0dc2366fSVenugopal Iyer 
2261*0dc2366fSVenugopal Iyer 	case MAC_STAT_OPACKETS:
2262*0dc2366fSVenugopal Iyer 		*val = statsp->tdc_stats[r_index].opackets;
2263*0dc2366fSVenugopal Iyer 		break;
2264*0dc2366fSVenugopal Iyer 
2265*0dc2366fSVenugopal Iyer 	default:
2266*0dc2366fSVenugopal Iyer 		*val = 0;
2267*0dc2366fSVenugopal Iyer 		return (ENOTSUP);
2268*0dc2366fSVenugopal Iyer 	}
2269*0dc2366fSVenugopal Iyer 
2270*0dc2366fSVenugopal Iyer 	return (0);
2271*0dc2366fSVenugopal Iyer }
2272*0dc2366fSVenugopal Iyer 
22736f45ec7bSml29623 /* ARGSUSED */
22746f45ec7bSml29623 int
nxge_m_stat(void * arg,uint_t stat,uint64_t * value)22756f45ec7bSml29623 nxge_m_stat(void *arg, uint_t stat, uint64_t *value)
22766f45ec7bSml29623 {
22776f45ec7bSml29623 	p_nxge_t nxgep = (p_nxge_t)arg;
22786f45ec7bSml29623 	p_nxge_stats_t statsp;
22796f45ec7bSml29623 	uint64_t val = 0;
22806f45ec7bSml29623 
22816f45ec7bSml29623 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_stat"));
22826f45ec7bSml29623 	statsp = (p_nxge_stats_t)nxgep->statsp;
22836f45ec7bSml29623 
22846f45ec7bSml29623 	switch (stat) {
22856f45ec7bSml29623 	case MAC_STAT_IFSPEED:
22866f45ec7bSml29623 		val = statsp->mac_stats.link_speed * 1000000ull;
22876f45ec7bSml29623 		break;
22886f45ec7bSml29623 
22896f45ec7bSml29623 	case MAC_STAT_MULTIRCV:
22906f45ec7bSml29623 		val = statsp->port_stats.multircv;
22916f45ec7bSml29623 		break;
22926f45ec7bSml29623 
22936f45ec7bSml29623 	case MAC_STAT_BRDCSTRCV:
22946f45ec7bSml29623 		val = statsp->port_stats.brdcstrcv;
22956f45ec7bSml29623 		break;
22966f45ec7bSml29623 
22976f45ec7bSml29623 	case MAC_STAT_MULTIXMT:
22986f45ec7bSml29623 		val = statsp->port_stats.multixmt;
22996f45ec7bSml29623 		break;
23006f45ec7bSml29623 
23016f45ec7bSml29623 	case MAC_STAT_BRDCSTXMT:
23026f45ec7bSml29623 		val = statsp->port_stats.brdcstxmt;
23036f45ec7bSml29623 		break;
23046f45ec7bSml29623 
23056f45ec7bSml29623 	case MAC_STAT_NORCVBUF:
23066f45ec7bSml29623 		val = statsp->port_stats.norcvbuf;
23076f45ec7bSml29623 		break;
23086f45ec7bSml29623 
23096f45ec7bSml29623 	case MAC_STAT_IERRORS:
23106f45ec7bSml29623 	case ETHER_STAT_MACRCV_ERRORS:
2311678453a8Sspeer 		val = nxge_m_rx_stat(nxgep, stat);
2312678453a8Sspeer 		break;
2313678453a8Sspeer 
2314678453a8Sspeer 	case MAC_STAT_OERRORS:
2315678453a8Sspeer 		val = nxge_m_tx_stat(nxgep, stat);
23166f45ec7bSml29623 		break;
23176f45ec7bSml29623 
23186f45ec7bSml29623 	case MAC_STAT_NOXMTBUF:
23196f45ec7bSml29623 		val = statsp->port_stats.noxmtbuf;
23206f45ec7bSml29623 		break;
23216f45ec7bSml29623 
23226f45ec7bSml29623 	case MAC_STAT_COLLISIONS:
23236f45ec7bSml29623 		val = 0;
23246f45ec7bSml29623 		break;
23256f45ec7bSml29623 
23266f45ec7bSml29623 	case MAC_STAT_RBYTES:
2327678453a8Sspeer 		val = nxge_m_rx_stat(nxgep, stat);
23286f45ec7bSml29623 		break;
23296f45ec7bSml29623 
23306f45ec7bSml29623 	case MAC_STAT_IPACKETS:
2331678453a8Sspeer 		val = nxge_m_rx_stat(nxgep, stat);
23326f45ec7bSml29623 		break;
23336f45ec7bSml29623 
23346f45ec7bSml29623 	case MAC_STAT_OBYTES:
2335678453a8Sspeer 		val = nxge_m_tx_stat(nxgep, stat);
23366f45ec7bSml29623 		break;
23376f45ec7bSml29623 
23386f45ec7bSml29623 	case MAC_STAT_OPACKETS:
2339678453a8Sspeer 		val = nxge_m_tx_stat(nxgep, stat);
23406f45ec7bSml29623 		break;
23416f45ec7bSml29623 	case MAC_STAT_LINK_STATE:
23426f45ec7bSml29623 		val = statsp->mac_stats.link_duplex;
23436f45ec7bSml29623 		break;
23446f45ec7bSml29623 	case MAC_STAT_LINK_UP:
23456f45ec7bSml29623 		val = statsp->mac_stats.link_up;
23466f45ec7bSml29623 		break;
23476f45ec7bSml29623 	case MAC_STAT_PROMISC:
23486f45ec7bSml29623 		val = statsp->mac_stats.promisc;
23496f45ec7bSml29623 		break;
23506f45ec7bSml29623 	case ETHER_STAT_SQE_ERRORS:
23516f45ec7bSml29623 		val = 0;
23526f45ec7bSml29623 		break;
23536f45ec7bSml29623 
23546f45ec7bSml29623 	case ETHER_STAT_ALIGN_ERRORS:
23556f45ec7bSml29623 		if (nxgep->mac.porttype == PORT_TYPE_XMAC)
23566f45ec7bSml29623 			val = statsp->xmac_stats.rx_frame_align_err_cnt;
23576f45ec7bSml29623 		else if (nxgep->mac.porttype == PORT_TYPE_BMAC)
23586f45ec7bSml29623 			val = statsp->bmac_stats.rx_align_err_cnt;
23596f45ec7bSml29623 		else
23606f45ec7bSml29623 			val = 0;
23616f45ec7bSml29623 		break;
23626f45ec7bSml29623 
23636f45ec7bSml29623 	case ETHER_STAT_FCS_ERRORS:
23646f45ec7bSml29623 		if (nxgep->mac.porttype == PORT_TYPE_XMAC)
23656f45ec7bSml29623 			val = statsp->xmac_stats.rx_crc_err_cnt;
23666f45ec7bSml29623 		else if (nxgep->mac.porttype == PORT_TYPE_BMAC)
23676f45ec7bSml29623 			val = statsp->bmac_stats.rx_crc_err_cnt;
23686f45ec7bSml29623 		else
23696f45ec7bSml29623 			val = 0;
23706f45ec7bSml29623 		break;
23716f45ec7bSml29623 
23726f45ec7bSml29623 	case ETHER_STAT_FIRST_COLLISIONS:
23736f45ec7bSml29623 		val = 0;
23746f45ec7bSml29623 		break;
23756f45ec7bSml29623 
23766f45ec7bSml29623 	case ETHER_STAT_MULTI_COLLISIONS:
23776f45ec7bSml29623 		val = 0;
23786f45ec7bSml29623 		break;
23796f45ec7bSml29623 
23806f45ec7bSml29623 	case ETHER_STAT_TX_LATE_COLLISIONS:
23816f45ec7bSml29623 		val = 0;
23826f45ec7bSml29623 		break;
23836f45ec7bSml29623 
23846f45ec7bSml29623 	case ETHER_STAT_EX_COLLISIONS:
23856f45ec7bSml29623 		val = 0;
23866f45ec7bSml29623 		break;
23876f45ec7bSml29623 
23886f45ec7bSml29623 	case ETHER_STAT_DEFER_XMTS:
23896f45ec7bSml29623 		val = 0;
23906f45ec7bSml29623 		break;
23916f45ec7bSml29623 
23926f45ec7bSml29623 	case ETHER_STAT_MACXMT_ERRORS:
23936f45ec7bSml29623 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
23946f45ec7bSml29623 			val = statsp->xmac_stats.tx_underflow_err +
23956f45ec7bSml29623 			    statsp->xmac_stats.tx_maxpktsize_err +
23966f45ec7bSml29623 			    statsp->xmac_stats.tx_overflow_err +
23976f45ec7bSml29623 			    statsp->xmac_stats.tx_fifo_xfr_err;
23986f45ec7bSml29623 		} else {
23996f45ec7bSml29623 			val = statsp->bmac_stats.tx_underrun_err +
24006f45ec7bSml29623 			    statsp->bmac_stats.tx_max_pkt_err;
24016f45ec7bSml29623 		}
24026f45ec7bSml29623 		break;
24036f45ec7bSml29623 
24046f45ec7bSml29623 	case ETHER_STAT_CARRIER_ERRORS:
24056f45ec7bSml29623 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
24066f45ec7bSml29623 			val = statsp->xmac_stats.rx_linkfault_err_cnt;
24076f45ec7bSml29623 		} else {
24086f45ec7bSml29623 			val = statsp->mac_stats.xcvr_inits +
24096f45ec7bSml29623 			    statsp->mac_stats.serdes_inits;
24106f45ec7bSml29623 		}
24116f45ec7bSml29623 		break;
24126f45ec7bSml29623 
24136f45ec7bSml29623 	case ETHER_STAT_TOOLONG_ERRORS:
24146f45ec7bSml29623 		if (nxgep->mac.porttype == PORT_TYPE_XMAC) {
24156f45ec7bSml29623 			val = statsp->xmac_stats.tx_maxpktsize_err +
24166f45ec7bSml29623 			    statsp->xmac_stats.rx_len_err_cnt;
24176f45ec7bSml29623 
24186f45ec7bSml29623 		} else {
24196f45ec7bSml29623 			val = statsp->bmac_stats.rx_len_err_cnt +
24206f45ec7bSml29623 			    statsp->bmac_stats.tx_max_pkt_err;
24216f45ec7bSml29623 		}
24226f45ec7bSml29623 		break;
24236f45ec7bSml29623 
24246f45ec7bSml29623 
24256f45ec7bSml29623 	case ETHER_STAT_XCVR_ADDR:
24266f45ec7bSml29623 		val = statsp->mac_stats.xcvr_portn;
24276f45ec7bSml29623 		break;
24286f45ec7bSml29623 	case ETHER_STAT_XCVR_ID:
24296f45ec7bSml29623 		val = statsp->mac_stats.xcvr_id;
24306f45ec7bSml29623 		break;
24316f45ec7bSml29623 
24326f45ec7bSml29623 	case ETHER_STAT_XCVR_INUSE:
24336f45ec7bSml29623 		val = statsp->mac_stats.xcvr_inuse;
24346f45ec7bSml29623 		break;
24356f45ec7bSml29623 
24366f45ec7bSml29623 	case ETHER_STAT_CAP_1000FDX:
24376f45ec7bSml29623 		val = statsp->mac_stats.cap_1000fdx;
24386f45ec7bSml29623 		break;
24396f45ec7bSml29623 
24406f45ec7bSml29623 	case ETHER_STAT_CAP_1000HDX:
24416f45ec7bSml29623 		val = statsp->mac_stats.cap_1000hdx;
24426f45ec7bSml29623 		break;
24436f45ec7bSml29623 
24446f45ec7bSml29623 	case ETHER_STAT_CAP_100FDX:
24456f45ec7bSml29623 		val = statsp->mac_stats.cap_100fdx;
24466f45ec7bSml29623 		break;
24476f45ec7bSml29623 
24486f45ec7bSml29623 	case ETHER_STAT_CAP_100HDX:
24496f45ec7bSml29623 		val = statsp->mac_stats.cap_100hdx;
24506f45ec7bSml29623 		break;
24516f45ec7bSml29623 
24526f45ec7bSml29623 	case ETHER_STAT_CAP_10FDX:
24536f45ec7bSml29623 		val = statsp->mac_stats.cap_10fdx;
24546f45ec7bSml29623 		break;
24556f45ec7bSml29623 
24566f45ec7bSml29623 	case ETHER_STAT_CAP_10HDX:
24576f45ec7bSml29623 		val = statsp->mac_stats.cap_10hdx;
24586f45ec7bSml29623 		break;
24596f45ec7bSml29623 
24606f45ec7bSml29623 	case ETHER_STAT_CAP_ASMPAUSE:
24616f45ec7bSml29623 		val = statsp->mac_stats.cap_asmpause;
24626f45ec7bSml29623 		val = 1;
24636f45ec7bSml29623 		break;
24646f45ec7bSml29623 
24656f45ec7bSml29623 	case ETHER_STAT_CAP_PAUSE:
24666f45ec7bSml29623 		val = statsp->mac_stats.cap_pause;
24676f45ec7bSml29623 		break;
24686f45ec7bSml29623 
24696f45ec7bSml29623 	case ETHER_STAT_CAP_AUTONEG:
24706f45ec7bSml29623 		val = statsp->mac_stats.cap_autoneg;
24716f45ec7bSml29623 		break;
24726f45ec7bSml29623 
24736f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_1000FDX:
24746f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_1000fdx;
24756f45ec7bSml29623 		break;
24766f45ec7bSml29623 
24776f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_1000HDX:
24786f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_1000hdx;
24796f45ec7bSml29623 		break;
24806f45ec7bSml29623 
24816f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_100FDX:
24826f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_100fdx;
24836f45ec7bSml29623 		break;
24846f45ec7bSml29623 
24856f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_100HDX:
24866f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_100hdx;
24876f45ec7bSml29623 		break;
24886f45ec7bSml29623 
24896f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_10FDX:
24906f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_10fdx;
24916f45ec7bSml29623 		break;
24926f45ec7bSml29623 
24936f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_10HDX:
24946f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_10hdx;
24956f45ec7bSml29623 		break;
24966f45ec7bSml29623 
24976f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_ASMPAUSE:
24986f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_asmpause;
24996f45ec7bSml29623 		break;
25006f45ec7bSml29623 
25016f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_PAUSE:
25026f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_pause;
25036f45ec7bSml29623 		break;
25046f45ec7bSml29623 
25056f45ec7bSml29623 	case ETHER_STAT_ADV_CAP_AUTONEG:
25066f45ec7bSml29623 		val = statsp->mac_stats.adv_cap_autoneg;
25076f45ec7bSml29623 		break;
25086f45ec7bSml29623 
25096f45ec7bSml29623 	case ETHER_STAT_LP_CAP_1000FDX:
25106f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_1000fdx;
25116f45ec7bSml29623 		break;
25126f45ec7bSml29623 
25136f45ec7bSml29623 	case ETHER_STAT_LP_CAP_1000HDX:
25146f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_1000hdx;
25156f45ec7bSml29623 		break;
25166f45ec7bSml29623 
25176f45ec7bSml29623 	case ETHER_STAT_LP_CAP_100FDX:
25186f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_100fdx;
25196f45ec7bSml29623 		break;
25206f45ec7bSml29623 
25216f45ec7bSml29623 	case ETHER_STAT_LP_CAP_100HDX:
25226f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_100hdx;
25236f45ec7bSml29623 		break;
25246f45ec7bSml29623 
25256f45ec7bSml29623 	case ETHER_STAT_LP_CAP_10FDX:
25266f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_10fdx;
25276f45ec7bSml29623 		break;
25286f45ec7bSml29623 
25296f45ec7bSml29623 	case ETHER_STAT_LP_CAP_10HDX:
25306f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_10hdx;
25316f45ec7bSml29623 		break;
25326f45ec7bSml29623 
25336f45ec7bSml29623 	case ETHER_STAT_LP_CAP_ASMPAUSE:
25346f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_asmpause;
25356f45ec7bSml29623 		break;
25366f45ec7bSml29623 
25376f45ec7bSml29623 	case ETHER_STAT_LP_CAP_PAUSE:
25386f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_pause;
25396f45ec7bSml29623 		break;
25406f45ec7bSml29623 
25416f45ec7bSml29623 	case ETHER_STAT_LP_CAP_AUTONEG:
25426f45ec7bSml29623 		val = statsp->mac_stats.lp_cap_autoneg;
25436f45ec7bSml29623 		break;
25446f45ec7bSml29623 
25456f45ec7bSml29623 	case ETHER_STAT_LINK_ASMPAUSE:
25466f45ec7bSml29623 		val = statsp->mac_stats.link_asmpause;
25476f45ec7bSml29623 		break;
25486f45ec7bSml29623 
25496f45ec7bSml29623 	case ETHER_STAT_LINK_PAUSE:
25506f45ec7bSml29623 		val = statsp->mac_stats.link_pause;
25516f45ec7bSml29623 		break;
25526f45ec7bSml29623 
25536f45ec7bSml29623 	case ETHER_STAT_LINK_AUTONEG:
25546f45ec7bSml29623 		val = statsp->mac_stats.cap_autoneg;
25556f45ec7bSml29623 		break;
25566f45ec7bSml29623 
25576f45ec7bSml29623 	case ETHER_STAT_LINK_DUPLEX:
25586f45ec7bSml29623 		val = statsp->mac_stats.link_duplex;
25596f45ec7bSml29623 		break;
25606f45ec7bSml29623 
25616f45ec7bSml29623 	default:
25626f45ec7bSml29623 		/*
25636f45ec7bSml29623 		 * Shouldn't reach here...
25646f45ec7bSml29623 		 */
25656f45ec7bSml29623 #ifdef NXGE_DEBUG
25666f45ec7bSml29623 		NXGE_ERROR_MSG((nxgep, KST_CTL,
25676f45ec7bSml29623 		    "nxge_m_stat: unrecognized parameter value = 0x%x",
25686f45ec7bSml29623 		    stat));
25696f45ec7bSml29623 #endif
25706f45ec7bSml29623 
25716f45ec7bSml29623 		return (ENOTSUP);
25726f45ec7bSml29623 	}
25736f45ec7bSml29623 	*value = val;
25746f45ec7bSml29623 	return (0);
25756f45ec7bSml29623 }
2576