144961713Sgirish /*
244961713Sgirish  * CDDL HEADER START
344961713Sgirish  *
444961713Sgirish  * The contents of this file are subject to the terms of the
544961713Sgirish  * Common Development and Distribution License (the "License").
644961713Sgirish  * You may not use this file except in compliance with the License.
744961713Sgirish  *
844961713Sgirish  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
944961713Sgirish  * or http://www.opensolaris.org/os/licensing.
1044961713Sgirish  * See the License for the specific language governing permissions
1144961713Sgirish  * and limitations under the License.
1244961713Sgirish  *
1344961713Sgirish  * When distributing Covered Code, include this CDDL HEADER in each
1444961713Sgirish  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1544961713Sgirish  * If applicable, add the following below this CDDL HEADER, with the
1644961713Sgirish  * fields enclosed by brackets "[]" replaced with your own identifying
1744961713Sgirish  * information: Portions Copyright [yyyy] [name of copyright owner]
1844961713Sgirish  *
1944961713Sgirish  * CDDL HEADER END
2044961713Sgirish  */
2144961713Sgirish /*
220dc2366fSVenugopal Iyer  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2344961713Sgirish  * Use is subject to license terms.
2444961713Sgirish  */
2544961713Sgirish 
26a3c5bd6dSspeer #include <sys/nxge/nxge_impl.h>
27678453a8Sspeer #include <sys/nxge/nxge_hio.h>
28678453a8Sspeer 
2944961713Sgirish #include <inet/mi.h>
30a3c5bd6dSspeer 
3144961713Sgirish #define	RDC_NAME_FORMAT1	"RDC Channel"
3244961713Sgirish #define	TDC_NAME_FORMAT1	"TDC Channel"
3344961713Sgirish #define	CH_NAME_FORMAT		" %d Stats"
3444961713Sgirish #define	TDC_NAME_FORMAT		"TDC Channel %d Stats"
3544961713Sgirish #define	RDC_NAME_FORMAT		"RDC Channel %d Stats"
3644961713Sgirish 
3744961713Sgirish void nxge_mac_init_kstats(p_nxge_t, struct kstat *);
3844961713Sgirish void nxge_xmac_init_kstats(struct kstat *);
3944961713Sgirish void nxge_bmac_init_kstats(struct kstat *);
4044961713Sgirish 
41a3c5bd6dSspeer /* ARGSUSED */
4244961713Sgirish void
nxge_init_statsp(p_nxge_t nxgep)4344961713Sgirish nxge_init_statsp(p_nxge_t nxgep)
4444961713Sgirish {
4544961713Sgirish 	size_t stats_size;
4644961713Sgirish 
4744961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_init_statsp"));
4844961713Sgirish 
4944961713Sgirish 	stats_size = sizeof (nxge_stats_t);
5044961713Sgirish 	nxgep->statsp = KMEM_ZALLOC(stats_size, KM_SLEEP);
5144961713Sgirish 	nxgep->statsp->stats_size = stats_size;
5244961713Sgirish 
5344961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_init_statsp"));
5444961713Sgirish }
5544961713Sgirish 
5644961713Sgirish typedef struct {
57a3c5bd6dSspeer 	uint8_t index;
58a3c5bd6dSspeer 	uint8_t type;
59a3c5bd6dSspeer 	char *name;
6044961713Sgirish } nxge_kstat_index_t;
6144961713Sgirish 
62a3c5bd6dSspeer typedef enum {
6344961713Sgirish 	RDC_STAT_PACKETS = 0,
6444961713Sgirish 	RDC_STAT_BYTES,
6544961713Sgirish 	RDC_STAT_ERRORS,
6644961713Sgirish 	RDC_STAT_DCF_ERR,
6744961713Sgirish 	RDC_STAT_RCR_ACK_ERR,
6844961713Sgirish 	RDC_STAT_RCR_DC_FIFOFLOW_ERR,
6944961713Sgirish 	RDC_STAT_RCR_SHA_PAR_ERR,
7044961713Sgirish 	RDC_STAT_RBR_PRE_PAR_ERR,
7144961713Sgirish 	RDC_STAT_WRED_DROP,
7244961713Sgirish 	RDC_STAT_RBR_PRE_EMTY,
7344961713Sgirish 	RDC_STAT_RCR_SHADOW_FULL,
7444961713Sgirish 	RDC_STAT_RBR_TMOUT,
7544961713Sgirish 	RDC_STAT_RSP_CNT_ERR,
7644961713Sgirish 	RDC_STAT_BYTE_EN_BUS,
7744961713Sgirish 	RDC_STAT_RSP_DAT_ERR,
784202ea4bSsbehera 	RDC_STAT_PKT_TOO_LONG_ERR,
7944961713Sgirish 	RDC_STAT_COMPL_L2_ERR,
8044961713Sgirish 	RDC_STAT_COMPL_L4_CKSUM_ERR,
8144961713Sgirish 	RDC_STAT_COMPL_ZCP_SOFT_ERR,
8244961713Sgirish 	RDC_STAT_COMPL_FFLP_SOFT_ERR,
8344961713Sgirish 	RDC_STAT_CONFIG_ERR,
8444961713Sgirish 	RDC_STAT_RCRINCON,
8544961713Sgirish 	RDC_STAT_RCRFULL,
8644961713Sgirish 	RDC_STAT_RBR_EMPTY,
8744961713Sgirish 	RDC_STAT_RBR_FULL,
8844961713Sgirish 	RDC_STAT_RBRLOGPAGE,
8944961713Sgirish 	RDC_STAT_CFIGLOGPAGE,
9044961713Sgirish 	RDC_STAT_PORT_DROP_PKT,
9144961713Sgirish 	RDC_STAT_RCRTO,
9244961713Sgirish 	RDC_STAT_RCRTHRES,
9344961713Sgirish 	RDC_STAT_MEX,
9444961713Sgirish 	RDC_STAT_ID_MIS,
9544961713Sgirish 	RDC_STAT_ZCP_EOP,
9644961713Sgirish 	RDC_STAT_IPP_EOP,
9744961713Sgirish 	RDC_STAT_END
9844961713Sgirish } nxge_rdc_stat_index_t;
9944961713Sgirish 
10044961713Sgirish nxge_kstat_index_t nxge_rdc_stats[] = {
101a3c5bd6dSspeer 	{RDC_STAT_PACKETS, KSTAT_DATA_UINT64, "rdc_packets"},
102a3c5bd6dSspeer 	{RDC_STAT_BYTES, KSTAT_DATA_UINT64, "rdc_bytes"},
103a3c5bd6dSspeer 	{RDC_STAT_ERRORS, KSTAT_DATA_ULONG, "rdc_errors"},
104a3c5bd6dSspeer 	{RDC_STAT_DCF_ERR, KSTAT_DATA_ULONG, "rdc_dcf_err"},
105a3c5bd6dSspeer 	{RDC_STAT_RCR_ACK_ERR, KSTAT_DATA_ULONG, "rdc_rcr_ack_err"},
106a3c5bd6dSspeer 	{RDC_STAT_RCR_DC_FIFOFLOW_ERR, KSTAT_DATA_ULONG, "rdc_dc_fifoflow_err"},
107a3c5bd6dSspeer 	{RDC_STAT_RCR_SHA_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rcr_sha_par_err"},
108a3c5bd6dSspeer 	{RDC_STAT_RBR_PRE_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rbr_pre_par_err"},
109a3c5bd6dSspeer 	{RDC_STAT_WRED_DROP, KSTAT_DATA_ULONG, "rdc_wred_drop"},
110a3c5bd6dSspeer 	{RDC_STAT_RBR_PRE_EMTY, KSTAT_DATA_ULONG, "rdc_rbr_pre_empty"},
111a3c5bd6dSspeer 	{RDC_STAT_RCR_SHADOW_FULL, KSTAT_DATA_ULONG, "rdc_rcr_shadow_full"},
112a3c5bd6dSspeer 	{RDC_STAT_RBR_TMOUT, KSTAT_DATA_ULONG, "rdc_rbr_tmout"},
113a3c5bd6dSspeer 	{RDC_STAT_RSP_CNT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_cnt_err"},
114a3c5bd6dSspeer 	{RDC_STAT_BYTE_EN_BUS, KSTAT_DATA_ULONG, "rdc_byte_en_bus"},
115a3c5bd6dSspeer 	{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"},
117a3c5bd6dSspeer 	{RDC_STAT_COMPL_L2_ERR, KSTAT_DATA_ULONG, "rdc_compl_l2_err"},
118a3c5bd6dSspeer 	{RDC_STAT_COMPL_L4_CKSUM_ERR, KSTAT_DATA_ULONG, "rdc_compl_l4_cksum"},
119a3c5bd6dSspeer 	{RDC_STAT_COMPL_ZCP_SOFT_ERR, KSTAT_DATA_ULONG,
120a3c5bd6dSspeer 		"rdc_compl_zcp_soft_err"},
121a3c5bd6dSspeer 	{RDC_STAT_COMPL_FFLP_SOFT_ERR, KSTAT_DATA_ULONG,
122a3c5bd6dSspeer 		"rdc_compl_fflp_soft_err"},
123a3c5bd6dSspeer 	{RDC_STAT_CONFIG_ERR, KSTAT_DATA_ULONG, "rdc_config_err"},
124a3c5bd6dSspeer 	{RDC_STAT_RCRINCON, KSTAT_DATA_ULONG, "rdc_rcrincon"},
125a3c5bd6dSspeer 	{RDC_STAT_RCRFULL, KSTAT_DATA_ULONG, "rdc_rcrfull"},
126a3c5bd6dSspeer 	{RDC_STAT_RBR_EMPTY, KSTAT_DATA_ULONG, "rdc_rbr_empty"},
127a3c5bd6dSspeer 	{RDC_STAT_RBR_FULL, KSTAT_DATA_ULONG, "rdc_rbrfull"},
128a3c5bd6dSspeer 	{RDC_STAT_RBRLOGPAGE, KSTAT_DATA_ULONG, "rdc_rbrlogpage"},
129a3c5bd6dSspeer 	{RDC_STAT_CFIGLOGPAGE, KSTAT_DATA_ULONG, "rdc_cfiglogpage"},
130a3c5bd6dSspeer 	{RDC_STAT_PORT_DROP_PKT, KSTAT_DATA_ULONG, "rdc_port_drop_pkt"},
131a3c5bd6dSspeer 	{RDC_STAT_RCRTO, KSTAT_DATA_ULONG, "rdc_rcrto"},
132a3c5bd6dSspeer 	{RDC_STAT_RCRTHRES, KSTAT_DATA_ULONG, "rdc_rcrthres"},
133a3c5bd6dSspeer 	{RDC_STAT_MEX, KSTAT_DATA_ULONG, "rdc_mex"},
134a3c5bd6dSspeer 	{RDC_STAT_ID_MIS, KSTAT_DATA_ULONG, "rdc_id_mismatch"},
135a3c5bd6dSspeer 	{RDC_STAT_ZCP_EOP, KSTAT_DATA_ULONG, "rdc_zcp_eop"},
136a3c5bd6dSspeer 	{RDC_STAT_IPP_EOP, KSTAT_DATA_ULONG, "rdc_ipp_eop"},
137*b37cc459SToomas Soome 	{RDC_STAT_END, KSTAT_DATA_ULONG, NULL}
13844961713Sgirish };
13944961713Sgirish 
14044961713Sgirish typedef enum {
14144961713Sgirish 	RDC_SYS_STAT_PRE_PAR_ERR = 0,
14244961713Sgirish 	RDC_SYS_STAT_SHA_PAR_ERR,
14344961713Sgirish 	RDC_SYS_STAT_ID_MISMATCH,
14444961713Sgirish 	RDC_SYS_STAT_IPP_EOP_ERR,
14544961713Sgirish 	RDC_SYS_STAT_ZCP_EOP_ERR,
14644961713Sgirish 	RDC_SYS_STAT_END
14744961713Sgirish } nxge_rdc_sys_stat_idx_t;
14844961713Sgirish 
14944961713Sgirish nxge_kstat_index_t nxge_rdc_sys_stats[] = {
150a3c5bd6dSspeer 	{RDC_SYS_STAT_PRE_PAR_ERR, KSTAT_DATA_UINT64, "rdc_pre_par_err"},
151a3c5bd6dSspeer 	{RDC_SYS_STAT_SHA_PAR_ERR, KSTAT_DATA_UINT64, "rdc_sha_par_err"},
152a3c5bd6dSspeer 	{RDC_SYS_STAT_ID_MISMATCH, KSTAT_DATA_UINT64, "rdc_stat_id_mismatch"},
153a3c5bd6dSspeer 	{RDC_SYS_STAT_IPP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_ipp_eop_err"},
154a3c5bd6dSspeer 	{RDC_SYS_STAT_ZCP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_zcp_eop_err"},
155*b37cc459SToomas Soome 	{RDC_SYS_STAT_END, KSTAT_DATA_UINT64, NULL}
15644961713Sgirish };
15744961713Sgirish 
158a3c5bd6dSspeer typedef enum {
15944961713Sgirish 	TDC_STAT_PACKETS = 0,
16044961713Sgirish 	TDC_STAT_BYTES,
16144961713Sgirish 	TDC_STAT_ERRORS,
16244961713Sgirish 	TDC_STAT_TX_INITS,
16344961713Sgirish 	TDC_STAT_TX_NO_BUF,
16444961713Sgirish 	TDC_STAT_MBOX_ERR,
16544961713Sgirish 	TDC_STAT_PKT_SIZE_ERR,
16644961713Sgirish 	TDC_STAT_TX_RING_OFLOW,
16744961713Sgirish 	TDC_STAT_PREF_BUF_ECC_ERR,
16844961713Sgirish 	TDC_STAT_NACK_PREF,
16944961713Sgirish 	TDC_STAT_NACK_PKT_RD,
17044961713Sgirish 	TDC_STAT_CONF_PART_ERR,
17144961713Sgirish 	TDC_STAT_PKT_PRT_ERR,
17244961713Sgirish 	TDC_STAT_RESET_FAIL,
17344961713Sgirish 	TDC_STAT_TX_STARTS,
17444961713Sgirish 	TDC_STAT_TX_NOCANPUT,
17544961713Sgirish 	TDC_STAT_TX_MSGDUP_FAIL,
17644961713Sgirish 	TDC_STAT_TX_ALLOCB_FAIL,
17744961713Sgirish 	TDC_STAT_TX_NO_DESC,
17844961713Sgirish 	TDC_STAT_TX_DMA_BIND_FAIL,
17944961713Sgirish 	TDC_STAT_TX_UFLOW,
18044961713Sgirish 	TDC_STAT_TX_HDR_PKTS,
18144961713Sgirish 	TDC_STAT_TX_DDI_PKTS,
18244961713Sgirish 	TDC_STAT_TX_DVMA_PKTS,
18344961713Sgirish 	TDC_STAT_TX_MAX_PEND,
18444961713Sgirish 	TDC_STAT_END
18544961713Sgirish } nxge_tdc_stats_index_t;
18644961713Sgirish 
18744961713Sgirish nxge_kstat_index_t nxge_tdc_stats[] = {
188a3c5bd6dSspeer 	{TDC_STAT_PACKETS, KSTAT_DATA_UINT64, "tdc_packets"},
189a3c5bd6dSspeer 	{TDC_STAT_BYTES, KSTAT_DATA_UINT64, "tdc_bytes"},
190a3c5bd6dSspeer 	{TDC_STAT_ERRORS, KSTAT_DATA_UINT64, "tdc_errors"},
191a3c5bd6dSspeer 	{TDC_STAT_TX_INITS, KSTAT_DATA_ULONG, "tdc_tx_inits"},
192a3c5bd6dSspeer 	{TDC_STAT_TX_NO_BUF, KSTAT_DATA_ULONG, "tdc_tx_no_buf"},
193a3c5bd6dSspeer 	{TDC_STAT_MBOX_ERR, KSTAT_DATA_ULONG, "tdc_mbox_err"},
194a3c5bd6dSspeer 	{TDC_STAT_PKT_SIZE_ERR, KSTAT_DATA_ULONG, "tdc_pkt_size_err"},
19544961713Sgirish 	{TDC_STAT_TX_RING_OFLOW,
196a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "tdc_tx_ring_oflow"},
19744961713Sgirish 	{TDC_STAT_PREF_BUF_ECC_ERR,
198a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "tdc_pref_buf_err_err"},
199a3c5bd6dSspeer 	{TDC_STAT_NACK_PREF, KSTAT_DATA_ULONG, "tdc_nack_pref"},
200a3c5bd6dSspeer 	{TDC_STAT_NACK_PKT_RD, KSTAT_DATA_ULONG, "tdc_nack_pkt_rd"},
20144961713Sgirish 	{TDC_STAT_CONF_PART_ERR,
202a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "tdc_conf_part_err"},
203a3c5bd6dSspeer 	{TDC_STAT_PKT_PRT_ERR, KSTAT_DATA_ULONG, "tdc_pkt_prt_err"},
204a3c5bd6dSspeer 	{TDC_STAT_RESET_FAIL, KSTAT_DATA_ULONG, "tdc_reset_fail"},
205a3c5bd6dSspeer 	{TDC_STAT_TX_STARTS, KSTAT_DATA_ULONG, "tdc_tx_starts"},
206a3c5bd6dSspeer 	{TDC_STAT_TX_NOCANPUT, KSTAT_DATA_ULONG, "tdc_tx_nocanput"},
20744961713Sgirish 	{TDC_STAT_TX_MSGDUP_FAIL, KSTAT_DATA_ULONG, "tdc_tx_msgdup_fail"},
20844961713Sgirish 	{TDC_STAT_TX_ALLOCB_FAIL, KSTAT_DATA_ULONG, "tdc_tx_allocb_fail"},
20944961713Sgirish 	{TDC_STAT_TX_NO_DESC, KSTAT_DATA_ULONG, "tdc_tx_no_desc"},
21044961713Sgirish 	{TDC_STAT_TX_DMA_BIND_FAIL, KSTAT_DATA_ULONG, "tdc_tx_dma_bind_fail"},
211a3c5bd6dSspeer 	{TDC_STAT_TX_UFLOW, KSTAT_DATA_ULONG, "tdc_tx_uflow"},
212a3c5bd6dSspeer 	{TDC_STAT_TX_HDR_PKTS, KSTAT_DATA_ULONG, "tdc_tx_hdr_pkts"},
213a3c5bd6dSspeer 	{TDC_STAT_TX_DDI_PKTS, KSTAT_DATA_ULONG, "tdc_tx_ddi_pkts"},
214a3c5bd6dSspeer 	{TDC_STAT_TX_DVMA_PKTS, KSTAT_DATA_ULONG, "tdc_tx_dvma_pkts"},
215a3c5bd6dSspeer 	{TDC_STAT_TX_MAX_PEND, KSTAT_DATA_ULONG, "tdc_tx_max_pend"},
216*b37cc459SToomas Soome 	{TDC_STAT_END, KSTAT_DATA_ULONG, NULL}
21744961713Sgirish };
21844961713Sgirish 
21944961713Sgirish /* IPP Statistics definitions */
220a3c5bd6dSspeer typedef enum {
22144961713Sgirish 	IPP_STAT_EOP_MISS = 0,
22244961713Sgirish 	IPP_STAT_SOP_MISS,
22344961713Sgirish 	IPP_STAT_DFIFO_UE,
22444961713Sgirish 	IPP_STAT_ECC_ERR,
225846a903dSml 	IPP_STAT_PFIFO_PERR,
22644961713Sgirish 	IPP_STAT_PFIFO_OVER,
22744961713Sgirish 	IPP_STAT_PFIFO_UND,
22844961713Sgirish 	IPP_STAT_BAD_CS,
22944961713Sgirish 	IPP_STAT_BAD_DIS,
23044961713Sgirish 	IPP_STAT_END
23144961713Sgirish } nxge_ipp_stat_index_t;
23244961713Sgirish 
23344961713Sgirish nxge_kstat_index_t nxge_ipp_stats[] = {
234a3c5bd6dSspeer 	{IPP_STAT_EOP_MISS, KSTAT_DATA_ULONG, "rxipp_eop_miss"},
235a3c5bd6dSspeer 	{IPP_STAT_SOP_MISS, KSTAT_DATA_ULONG, "rxipp_sop_miss"},
236a3c5bd6dSspeer 	{IPP_STAT_DFIFO_UE, KSTAT_DATA_ULONG, "rxipp_dfifo_ue"},
237a3c5bd6dSspeer 	{IPP_STAT_ECC_ERR, KSTAT_DATA_ULONG, "rxipp_ecc_err"},
238846a903dSml 	{IPP_STAT_PFIFO_PERR, KSTAT_DATA_ULONG, "rxipp_pfifo_perr"},
239a3c5bd6dSspeer 	{IPP_STAT_PFIFO_OVER, KSTAT_DATA_ULONG, "rxipp_pfifo_over"},
240a3c5bd6dSspeer 	{IPP_STAT_PFIFO_UND, KSTAT_DATA_ULONG, "rxipp_pfifo_und"},
241a3c5bd6dSspeer 	{IPP_STAT_BAD_CS, KSTAT_DATA_ULONG, "rxipp_bad_cs"},
242a3c5bd6dSspeer 	{IPP_STAT_BAD_DIS, KSTAT_DATA_ULONG, "rxipp_bad_dis"},
243*b37cc459SToomas Soome 	{IPP_STAT_END, KSTAT_DATA_ULONG, NULL}
24444961713Sgirish };
24544961713Sgirish 
24644961713Sgirish /* TXC Statistics definitions */
247a3c5bd6dSspeer typedef enum {
24844961713Sgirish 	TXC_STAT_PKT_STUFFED = 0,
24944961713Sgirish 	TXC_STAT_PKT_XMIT,
25044961713Sgirish 	TXC_STAT_RO_CORRECT_ERR,
25144961713Sgirish 	TXC_STAT_RO_UNCORRECT_ERR,
25244961713Sgirish 	TXC_STAT_SF_CORRECT_ERR,
25344961713Sgirish 	TXC_STAT_SF_UNCORRECT_ERR,
25444961713Sgirish 	TXC_STAT_ADDRESS_FAILED,
25544961713Sgirish 	TXC_STAT_DMA_FAILED,
25644961713Sgirish 	TXC_STAT_LENGTH_FAILED,
25744961713Sgirish 	TXC_STAT_PKT_ASSY_DEAD,
25844961713Sgirish 	TXC_STAT_REORDER_ERR,
25944961713Sgirish 	TXC_STAT_END
26044961713Sgirish } nxge_txc_stat_index_t;
26144961713Sgirish 
26244961713Sgirish nxge_kstat_index_t nxge_txc_stats[] = {
263a3c5bd6dSspeer 	{TXC_STAT_PKT_STUFFED, KSTAT_DATA_ULONG, "txc_pkt_stuffed"},
264a3c5bd6dSspeer 	{TXC_STAT_PKT_XMIT, KSTAT_DATA_ULONG, "txc_pkt_xmit"},
265a3c5bd6dSspeer 	{TXC_STAT_RO_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_correct_err"},
266a3c5bd6dSspeer 	{TXC_STAT_RO_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_uncorrect_err"},
267a3c5bd6dSspeer 	{TXC_STAT_SF_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_correct_err"},
268a3c5bd6dSspeer 	{TXC_STAT_SF_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_uncorrect_err"},
269a3c5bd6dSspeer 	{TXC_STAT_ADDRESS_FAILED, KSTAT_DATA_ULONG, "txc_address_failed"},
270a3c5bd6dSspeer 	{TXC_STAT_DMA_FAILED, KSTAT_DATA_ULONG, "txc_dma_failed"},
271a3c5bd6dSspeer 	{TXC_STAT_LENGTH_FAILED, KSTAT_DATA_ULONG, "txc_length_failed"},
272a3c5bd6dSspeer 	{TXC_STAT_PKT_ASSY_DEAD, KSTAT_DATA_ULONG, "txc_pkt_assy_dead"},
273a3c5bd6dSspeer 	{TXC_STAT_REORDER_ERR, KSTAT_DATA_ULONG, "txc_reorder_err"},
274*b37cc459SToomas Soome 	{TXC_STAT_END, KSTAT_DATA_ULONG, NULL}
27544961713Sgirish };
27644961713Sgirish 
277a3c5bd6dSspeer typedef enum {
27844961713Sgirish 	XMAC_STAT_TX_FRAME_CNT = 0,
27944961713Sgirish 	XMAC_STAT_TX_UNDERFLOW_ERR,
28044961713Sgirish 	XMAC_STAT_TX_MAXPKTSIZE_ERR,
28144961713Sgirish 	XMAC_STAT_TX_OVERFLOW_ERR,
28244961713Sgirish 	XMAC_STAT_TX_FIFO_XFR_ERR,
28344961713Sgirish 	XMAC_STAT_TX_BYTE_CNT,
28444961713Sgirish 	XMAC_STAT_RX_FRAME_CNT,
28544961713Sgirish 	XMAC_STAT_RX_UNDERFLOW_ERR,
28644961713Sgirish 	XMAC_STAT_RX_OVERFLOW_ERR,
28744961713Sgirish 	XMAC_STAT_RX_CRC_ERR_CNT,
28844961713Sgirish 	XMAC_STAT_RX_LEN_ERR_CNT,
28944961713Sgirish 	XMAC_STAT_RX_VIOL_ERR_CNT,
29044961713Sgirish 	XMAC_STAT_RX_BYTE_CNT,
29144961713Sgirish 	XMAC_STAT_RX_HIST1_CNT,
29244961713Sgirish 	XMAC_STAT_RX_HIST2_CNT,
29344961713Sgirish 	XMAC_STAT_RX_HIST3_CNT,
29444961713Sgirish 	XMAC_STAT_RX_HIST4_CNT,
29544961713Sgirish 	XMAC_STAT_RX_HIST5_CNT,
29644961713Sgirish 	XMAC_STAT_RX_HIST6_CNT,
29744961713Sgirish 	XMAC_STAT_RX_HIST7_CNT,
29844961713Sgirish 	XMAC_STAT_RX_BROADCAST_CNT,
29944961713Sgirish 	XMAC_STAT_RX_MULT_CNT,
30044961713Sgirish 	XMAC_STAT_RX_FRAG_CNT,
30144961713Sgirish 	XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT,
30244961713Sgirish 	XMAC_STAT_RX_LINKFAULT_ERR_CNT,
30344961713Sgirish 	XMAC_STAT_RX_REMOTEFAULT_ERR,
30444961713Sgirish 	XMAC_STAT_RX_LOCALFAULT_ERR,
30544961713Sgirish 	XMAC_STAT_RX_PAUSE_CNT,
30644961713Sgirish 	XMAC_STAT_TX_PAUSE_STATE,
30744961713Sgirish 	XMAC_STAT_TX_NOPAUSE_STATE,
30844961713Sgirish 	XMAC_STAT_XPCS_DESKEW_ERR_CNT,
30914ea4bb7Ssd #ifdef	NXGE_DEBUG_SYMBOL_ERR
31044961713Sgirish 	XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT,
31144961713Sgirish 	XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT,
31244961713Sgirish 	XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT,
31344961713Sgirish 	XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT,
31414ea4bb7Ssd #endif
31544961713Sgirish 	XMAC_STAT_END
31644961713Sgirish } nxge_xmac_stat_index_t;
31744961713Sgirish 
31844961713Sgirish nxge_kstat_index_t nxge_xmac_stats[] = {
319a3c5bd6dSspeer 	{XMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"},
320a3c5bd6dSspeer 	{XMAC_STAT_TX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "tmac_underflow_err"},
321a3c5bd6dSspeer 	{XMAC_STAT_TX_MAXPKTSIZE_ERR, KSTAT_DATA_ULONG, "txmac_maxpktsize_err"},
322a3c5bd6dSspeer 	{XMAC_STAT_TX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "txmac_overflow_err"},
323a3c5bd6dSspeer 	{XMAC_STAT_TX_FIFO_XFR_ERR, KSTAT_DATA_ULONG, "txmac_fifo_xfr_err"},
324a3c5bd6dSspeer 	{XMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"},
325a3c5bd6dSspeer 	{XMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"},
326a3c5bd6dSspeer 	{XMAC_STAT_RX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_underflow_err"},
327a3c5bd6dSspeer 	{XMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"},
328a3c5bd6dSspeer 	{XMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err"},
329a3c5bd6dSspeer 	{XMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_length_err"},
33044961713Sgirish 	{XMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_code_violations"},
331a3c5bd6dSspeer 	{XMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"},
332a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST1_CNT, KSTAT_DATA_ULONG, "rxmac_64_cnt"},
333a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST2_CNT, KSTAT_DATA_ULONG, "rxmac_65_127_cnt"},
334a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST3_CNT, KSTAT_DATA_ULONG, "rxmac_128_255_cnt"},
335a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST4_CNT, KSTAT_DATA_ULONG, "rxmac_256_511_cnt"},
336a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST5_CNT, KSTAT_DATA_ULONG, "rxmac_512_1023_cnt"},
337a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST6_CNT, KSTAT_DATA_ULONG, "rxmac_1024_1522_cnt"},
338a3c5bd6dSspeer 	{XMAC_STAT_RX_HIST7_CNT, KSTAT_DATA_ULONG, "rxmac_jumbo_cnt"},
339a3c5bd6dSspeer 	{XMAC_STAT_RX_BROADCAST_CNT, KSTAT_DATA_ULONG, "rxmac_broadcast_cnt"},
340a3c5bd6dSspeer 	{XMAC_STAT_RX_MULT_CNT, KSTAT_DATA_ULONG, "rxmac_multicast_cnt"},
341a3c5bd6dSspeer 	{XMAC_STAT_RX_FRAG_CNT, KSTAT_DATA_ULONG, "rxmac_fragment_cnt"},
34244961713Sgirish 	{XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT,
343a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "rxmac_alignment_err"},
34444961713Sgirish 	{XMAC_STAT_RX_LINKFAULT_ERR_CNT,
345a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "rxmac_linkfault_errs"},
34644961713Sgirish 	{XMAC_STAT_RX_REMOTEFAULT_ERR,
347a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "rxmac_remote_faults"},
34844961713Sgirish 	{XMAC_STAT_RX_LOCALFAULT_ERR,
349a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "rxmac_local_faults"},
350a3c5bd6dSspeer 	{XMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"},
351a3c5bd6dSspeer 	{XMAC_STAT_TX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"},
352a3c5bd6dSspeer 	{XMAC_STAT_TX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "txmac_nopause_state"},
35344961713Sgirish 	{XMAC_STAT_XPCS_DESKEW_ERR_CNT,
354a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "xpcs_deskew_err_cnt"},
35514ea4bb7Ssd #ifdef	NXGE_DEBUG_SYMBOL_ERR
35644961713Sgirish 	{XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT,
357a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "xpcs_ln0_symbol_err_cnt"},
35844961713Sgirish 	{XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT,
359a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "xpcs_ln1_symbol_err_cnt"},
36044961713Sgirish 	{XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT,
361a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "xpcs_ln2_symbol_err_cnt"},
36244961713Sgirish 	{XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT,
363a3c5bd6dSspeer 		KSTAT_DATA_ULONG, "xpcs_ln3_symbol_err_cnt"},
36414ea4bb7Ssd #endif
365*b37cc459SToomas Soome 	{XMAC_STAT_END, KSTAT_DATA_ULONG, NULL}
36644961713Sgirish };
36744961713Sgirish 
368a3c5bd6dSspeer typedef enum {
36944961713Sgirish 	BMAC_STAT_TX_FRAME_CNT = 0,
37044961713Sgirish 	BMAC_STAT_TX_UNDERRUN_ERR,
37144961713Sgirish 	BMAC_STAT_TX_MAX_PKT_ERR,
37244961713Sgirish 	BMAC_STAT_TX_BYTE_CNT,
37344961713Sgirish 	BMAC_STAT_RX_FRAME_CNT,
37444961713Sgirish 	BMAC_STAT_RX_BYTE_CNT,
37544961713Sgirish 	BMAC_STAT_RX_OVERFLOW_ERR,
37644961713Sgirish 	BMAC_STAT_RX_ALIGN_ERR_CNT,
37744961713Sgirish 	BMAC_STAT_RX_CRC_ERR_CNT,
37844961713Sgirish 	BMAC_STAT_RX_LEN_ERR_CNT,
37944961713Sgirish 	BMAC_STAT_RX_VIOL_ERR_CNT,
38044961713Sgirish 	BMAC_STAT_RX_PAUSE_CNT,
38144961713Sgirish 	BMAC_STAT_RX_PAUSE_STATE,
38244961713Sgirish 	BMAC_STAT_RX_NOPAUSE_STATE,
38344961713Sgirish 	BMAC_STAT_END
38444961713Sgirish } nxge_bmac_stat_index_t;
38544961713Sgirish 
38644961713Sgirish nxge_kstat_index_t nxge_bmac_stats[] = {
387a3c5bd6dSspeer 	{BMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"},
388a3c5bd6dSspeer 	{BMAC_STAT_TX_UNDERRUN_ERR, KSTAT_DATA_ULONG, "txmac_underrun_err"},
389a3c5bd6dSspeer 	{BMAC_STAT_TX_MAX_PKT_ERR, KSTAT_DATA_ULONG, "txmac_max_pkt_err"},
390a3c5bd6dSspeer 	{BMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"},
391a3c5bd6dSspeer 	{BMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"},
392a3c5bd6dSspeer 	{BMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"},
393a3c5bd6dSspeer 	{BMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"},
394a3c5bd6dSspeer 	{BMAC_STAT_RX_ALIGN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_align_err_cnt"},
395a3c5bd6dSspeer 	{BMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err_cnt"},
396a3c5bd6dSspeer 	{BMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_len_err_cnt"},
397a3c5bd6dSspeer 	{BMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_viol_err_cnt"},
398a3c5bd6dSspeer 	{BMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"},
399a3c5bd6dSspeer 	{BMAC_STAT_RX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"},
400a3c5bd6dSspeer 	{BMAC_STAT_RX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "tx_nopause_state"},
401*b37cc459SToomas Soome 	{BMAC_STAT_END, KSTAT_DATA_ULONG, NULL}
40244961713Sgirish };
40344961713Sgirish 
404a3c5bd6dSspeer typedef enum {
40544961713Sgirish 	ZCP_STAT_ERRORS,
40644961713Sgirish 	ZCP_STAT_INITS,
40744961713Sgirish 	ZCP_STAT_RRFIFO_UNDERRUN,
40844961713Sgirish 	ZCP_STAT_RRFIFO_OVERRUN,
40944961713Sgirish 	ZCP_STAT_RSPFIFO_UNCORR_ERR,
41044961713Sgirish 	ZCP_STAT_BUFFER_OVERFLOW,
41144961713Sgirish 	ZCP_STAT_STAT_TBL_PERR,
41244961713Sgirish 	ZCP_STAT_DYN_TBL_PERR,
41344961713Sgirish 	ZCP_STAT_BUF_TBL_PERR,
41444961713Sgirish 	ZCP_STAT_TT_PROGRAM_ERR,
41544961713Sgirish 	ZCP_STAT_RSP_TT_INDEX_ERR,
41644961713Sgirish 	ZCP_STAT_SLV_TT_INDEX_ERR,
41744961713Sgirish 	ZCP_STAT_ZCP_TT_INDEX_ERR,
41844961713Sgirish 	ZCP_STAT_ZCP_ACCESS_FAIL,
41944961713Sgirish 	ZCP_CFIFO_ECC,
42044961713Sgirish 	ZCP_STAT_END
42144961713Sgirish } nxge_zcp_stat_index_t;
42244961713Sgirish 
42344961713Sgirish nxge_kstat_index_t nxge_zcp_stats[] = {
424a3c5bd6dSspeer 	{ZCP_STAT_ERRORS, KSTAT_DATA_ULONG, "zcp_erros"},
425a3c5bd6dSspeer 	{ZCP_STAT_INITS, KSTAT_DATA_ULONG, "zcp_inits"},
426a3c5bd6dSspeer 	{ZCP_STAT_RRFIFO_UNDERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_underrun"},
427a3c5bd6dSspeer 	{ZCP_STAT_RRFIFO_OVERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_overrun"},
42844961713Sgirish 	{ZCP_STAT_RSPFIFO_UNCORR_ERR, KSTAT_DATA_ULONG,
429a3c5bd6dSspeer 	"zcp_rspfifo_uncorr_err"},
430a3c5bd6dSspeer 	{ZCP_STAT_BUFFER_OVERFLOW, KSTAT_DATA_ULONG, "zcp_buffer_overflow"},
431a3c5bd6dSspeer 	{ZCP_STAT_STAT_TBL_PERR, KSTAT_DATA_ULONG, "zcp_stat_tbl_perr"},
432a3c5bd6dSspeer 	{ZCP_STAT_DYN_TBL_PERR, KSTAT_DATA_ULONG, "zcp_dyn_tbl_perr"},
433a3c5bd6dSspeer 	{ZCP_STAT_BUF_TBL_PERR, KSTAT_DATA_ULONG, "zcp_buf_tbl_perr"},
434a3c5bd6dSspeer 	{ZCP_STAT_TT_PROGRAM_ERR, KSTAT_DATA_ULONG, "zcp_tt_program_err"},
435a3c5bd6dSspeer 	{ZCP_STAT_RSP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_rsp_tt_index_err"},
436a3c5bd6dSspeer 	{ZCP_STAT_SLV_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_slv_tt_index_err"},
437a3c5bd6dSspeer 	{ZCP_STAT_ZCP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_zcp_tt_index_err"},
438a3c5bd6dSspeer 	{ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_access_fail"},
439a3c5bd6dSspeer 	{ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_cfifo_ecc"},
440*b37cc459SToomas Soome 	{ZCP_STAT_END, KSTAT_DATA_ULONG, NULL}
44144961713Sgirish };
44244961713Sgirish 
443a3c5bd6dSspeer typedef enum {
44444961713Sgirish 	FFLP_STAT_TCAM_PERR,
44544961713Sgirish 	FFLP_STAT_TCAM_ECC_ERR,
44644961713Sgirish 	FFLP_STAT_VLAN_PERR,
44744961713Sgirish 	FFLP_STAT_HASH_LOOKUP_ERR,
44844961713Sgirish 	FFLP_STAT_HASH_P0_PIO_ERR,
44944961713Sgirish 	FFLP_STAT_HASH_P1_PIO_ERR,
45044961713Sgirish 	FFLP_STAT_HASH_P2_PIO_ERR,
45144961713Sgirish 	FFLP_STAT_HASH_P3_PIO_ERR,
45244961713Sgirish 	FFLP_STAT_HASH_P4_PIO_ERR,
45344961713Sgirish 	FFLP_STAT_HASH_P5_PIO_ERR,
45444961713Sgirish 	FFLP_STAT_HASH_P6_PIO_ERR,
45544961713Sgirish 	FFLP_STAT_HASH_P7_PIO_ERR,
45644961713Sgirish 	FFLP_STAT_END
45744961713Sgirish } nxge_fflp_stat_index_t;
45844961713Sgirish 
45944961713Sgirish nxge_kstat_index_t nxge_fflp_stats[] = {
460a3c5bd6dSspeer 	{FFLP_STAT_TCAM_PERR, KSTAT_DATA_ULONG, "fflp_tcam_perr"},
461a3c5bd6dSspeer 	{FFLP_STAT_TCAM_ECC_ERR, KSTAT_DATA_ULONG, "fflp_tcam_ecc_err"},
462a3c5bd6dSspeer 	{FFLP_STAT_VLAN_PERR, KSTAT_DATA_ULONG, "fflp_vlan_perr"},
463a3c5bd6dSspeer 	{FFLP_STAT_HASH_LOOKUP_ERR, KSTAT_DATA_ULONG, "fflp_hash_lookup_err"},
464a3c5bd6dSspeer 	{FFLP_STAT_HASH_P0_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p0_pio_err"},
465a3c5bd6dSspeer 	{FFLP_STAT_HASH_P1_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p1_pio_err"},
466a3c5bd6dSspeer 	{FFLP_STAT_HASH_P2_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p2_pio_err"},
467a3c5bd6dSspeer 	{FFLP_STAT_HASH_P3_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p3_pio_err"},
468a3c5bd6dSspeer 	{FFLP_STAT_HASH_P4_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p4_pio_err"},
469a3c5bd6dSspeer 	{FFLP_STAT_HASH_P5_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p5_pio_err"},
470a3c5bd6dSspeer 	{FFLP_STAT_HASH_P6_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p6_pio_err"},
471a3c5bd6dSspeer 	{FFLP_STAT_HASH_P7_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p7_pio_err"},
472*b37cc459SToomas Soome 	{FFLP_STAT_END, KSTAT_DATA_ULONG, NULL}
47344961713Sgirish };
47444961713Sgirish 
47544961713Sgirish typedef enum {
47644961713Sgirish 	MMAC_MAX_ADDR,
47744961713Sgirish 	MMAC_AVAIL_ADDR,
47844961713Sgirish 	MMAC_ADDR_POOL1,
47944961713Sgirish 	MMAC_ADDR_POOL2,
48044961713Sgirish 	MMAC_ADDR_POOL3,
48144961713Sgirish 	MMAC_ADDR_POOL4,
48244961713Sgirish 	MMAC_ADDR_POOL5,
48344961713Sgirish 	MMAC_ADDR_POOL6,
48444961713Sgirish 	MMAC_ADDR_POOL7,
48544961713Sgirish 	MMAC_ADDR_POOL8,
48644961713Sgirish 	MMAC_ADDR_POOL9,
48744961713Sgirish 	MMAC_ADDR_POOL10,
48844961713Sgirish 	MMAC_ADDR_POOL11,
48944961713Sgirish 	MMAC_ADDR_POOL12,
49044961713Sgirish 	MMAC_ADDR_POOL13,
49144961713Sgirish 	MMAC_ADDR_POOL14,
49244961713Sgirish 	MMAC_ADDR_POOL15,
49344961713Sgirish 	MMAC_ADDR_POOL16,
49444961713Sgirish 	MMAC_STATS_END
49544961713Sgirish } nxge_mmac_stat_index_t;
49644961713Sgirish 
49744961713Sgirish nxge_kstat_index_t nxge_mmac_stats[] = {
49858324dfcSspeer 	{MMAC_MAX_ADDR, KSTAT_DATA_UINT64, "max_mmac_addr"},
49958324dfcSspeer 	{MMAC_AVAIL_ADDR, KSTAT_DATA_UINT64, "avail_mmac_addr"},
50044961713Sgirish 	{MMAC_ADDR_POOL1, KSTAT_DATA_UINT64, "mmac_addr_1"},
50144961713Sgirish 	{MMAC_ADDR_POOL2, KSTAT_DATA_UINT64, "mmac_addr_2"},
50244961713Sgirish 	{MMAC_ADDR_POOL3, KSTAT_DATA_UINT64, "mmac_addr_3"},
50344961713Sgirish 	{MMAC_ADDR_POOL4, KSTAT_DATA_UINT64, "mmac_addr_4"},
50444961713Sgirish 	{MMAC_ADDR_POOL5, KSTAT_DATA_UINT64, "mmac_addr_5"},
50544961713Sgirish 	{MMAC_ADDR_POOL6, KSTAT_DATA_UINT64, "mmac_addr_6"},
50644961713Sgirish 	{MMAC_ADDR_POOL7, KSTAT_DATA_UINT64, "mmac_addr_7"},
50744961713Sgirish 	{MMAC_ADDR_POOL8, KSTAT_DATA_UINT64, "mmac_addr_8"},
50844961713Sgirish 	{MMAC_ADDR_POOL9, KSTAT_DATA_UINT64, "mmac_addr_9"},
50944961713Sgirish 	{MMAC_ADDR_POOL10, KSTAT_DATA_UINT64, "mmac_addr_10"},
51044961713Sgirish 	{MMAC_ADDR_POOL11, KSTAT_DATA_UINT64, "mmac_addr_11"},
51144961713Sgirish 	{MMAC_ADDR_POOL12, KSTAT_DATA_UINT64, "mmac_addr_12"},
51244961713Sgirish 	{MMAC_ADDR_POOL13, KSTAT_DATA_UINT64, "mmac_addr_13"},
51344961713Sgirish 	{MMAC_ADDR_POOL14, KSTAT_DATA_UINT64, "mmac_addr_14"},
51444961713Sgirish 	{MMAC_ADDR_POOL15, KSTAT_DATA_UINT64, "mmac_addr_15"},
51544961713Sgirish 	{MMAC_ADDR_POOL16, KSTAT_DATA_UINT64, "mmac_addr_16"},
516*b37cc459SToomas Soome 	{MMAC_STATS_END, KSTAT_DATA_UINT64, NULL},
51744961713Sgirish };
51844961713Sgirish 
519a3c5bd6dSspeer /* ARGSUSED */
52044961713Sgirish int
nxge_tdc_stat_update(kstat_t * ksp,int rw)52144961713Sgirish nxge_tdc_stat_update(kstat_t *ksp, int rw)
52244961713Sgirish {
523a3c5bd6dSspeer 	p_nxge_t nxgep;
524a3c5bd6dSspeer 	p_nxge_tdc_kstat_t tdc_kstatsp;
525a3c5bd6dSspeer 	p_nxge_tx_ring_stats_t statsp;
526a3c5bd6dSspeer 	int channel;
527a3c5bd6dSspeer 	char *ch_name, *end;
52844961713Sgirish 
52944961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
53044961713Sgirish 	if (nxgep == NULL)
53144961713Sgirish 		return (-1);
532a3c5bd6dSspeer 
53344961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rxstat_update"));
53444961713Sgirish 
53544961713Sgirish 	ch_name = ksp->ks_name;
53644961713Sgirish 	ch_name += strlen(TDC_NAME_FORMAT1);
53744961713Sgirish 	channel = mi_strtol(ch_name, &end, 10);
53844961713Sgirish 
53944961713Sgirish 	tdc_kstatsp = (p_nxge_tdc_kstat_t)ksp->ks_data;
54044961713Sgirish 	statsp = (p_nxge_tx_ring_stats_t)&nxgep->statsp->tdc_stats[channel];
54144961713Sgirish 
54244961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL,
54371cd5202Smisaki 	    "nxge_tdc_stat_update data $%p statsp $%p channel %d",
54471cd5202Smisaki 	    ksp->ks_data, statsp, channel));
54544961713Sgirish 
54644961713Sgirish 	if (rw == KSTAT_WRITE) {
54744961713Sgirish 		statsp->opackets = tdc_kstatsp->opackets.value.ull;
54844961713Sgirish 		statsp->obytes = tdc_kstatsp->obytes.value.ull;
54944961713Sgirish 		statsp->oerrors = tdc_kstatsp->oerrors.value.ull;
55044961713Sgirish 		statsp->mbox_err = tdc_kstatsp->mbox_err.value.ul;
55144961713Sgirish 		statsp->pkt_size_err = tdc_kstatsp->pkt_size_err.value.ul;
55244961713Sgirish 		statsp->tx_ring_oflow = tdc_kstatsp->tx_ring_oflow.value.ul;
55344961713Sgirish 		statsp->pre_buf_par_err =
55471cd5202Smisaki 		    tdc_kstatsp->pref_buf_ecc_err.value.ul;
55544961713Sgirish 		statsp->nack_pref = tdc_kstatsp->nack_pref.value.ul;
55644961713Sgirish 		statsp->nack_pkt_rd = tdc_kstatsp->nack_pkt_rd.value.ul;
55744961713Sgirish 		statsp->conf_part_err = tdc_kstatsp->conf_part_err.value.ul;
55844961713Sgirish 		statsp->pkt_part_err = tdc_kstatsp->pkt_prt_err.value.ul;
55944961713Sgirish 	} else {
56044961713Sgirish 		tdc_kstatsp->opackets.value.ull = statsp->opackets;
56144961713Sgirish 		tdc_kstatsp->obytes.value.ull = statsp->obytes;
56244961713Sgirish 		tdc_kstatsp->oerrors.value.ull = statsp->oerrors;
56344961713Sgirish 		tdc_kstatsp->tx_hdr_pkts.value.ull = statsp->tx_hdr_pkts;
56444961713Sgirish 		tdc_kstatsp->tx_ddi_pkts.value.ull = statsp->tx_ddi_pkts;
56544961713Sgirish 		tdc_kstatsp->tx_dvma_pkts.value.ull = statsp->tx_dvma_pkts;
56644961713Sgirish 		tdc_kstatsp->tx_max_pend.value.ull = statsp->tx_max_pend;
56744961713Sgirish 		tdc_kstatsp->mbox_err.value.ul = statsp->mbox_err;
56844961713Sgirish 		tdc_kstatsp->pkt_size_err.value.ul = statsp->pkt_size_err;
56944961713Sgirish 		tdc_kstatsp->tx_ring_oflow.value.ul = statsp->tx_ring_oflow;
57044961713Sgirish 		tdc_kstatsp->pref_buf_ecc_err.value.ul =
57171cd5202Smisaki 		    statsp->pre_buf_par_err;
57244961713Sgirish 		tdc_kstatsp->nack_pref.value.ul = statsp->nack_pref;
57344961713Sgirish 		tdc_kstatsp->nack_pkt_rd.value.ul = statsp->nack_pkt_rd;
57444961713Sgirish 		tdc_kstatsp->conf_part_err.value.ul = statsp->conf_part_err;
57544961713Sgirish 		tdc_kstatsp->pkt_prt_err.value.ul = statsp->pkt_part_err;
57644961713Sgirish 		tdc_kstatsp->tx_starts.value.ul = statsp->tx_starts;
57744961713Sgirish 		tdc_kstatsp->tx_nocanput.value.ul = statsp->tx_nocanput;
57844961713Sgirish 		tdc_kstatsp->tx_msgdup_fail.value.ul = statsp->tx_msgdup_fail;
57944961713Sgirish 		tdc_kstatsp->tx_allocb_fail.value.ul = statsp->tx_allocb_fail;
58044961713Sgirish 		tdc_kstatsp->tx_no_desc.value.ul = statsp->tx_no_desc;
58144961713Sgirish 		tdc_kstatsp->tx_dma_bind_fail.value.ul =
58271cd5202Smisaki 		    statsp->tx_dma_bind_fail;
58344961713Sgirish 	}
58444961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_tdc_stat_update"));
58544961713Sgirish 	return (0);
58644961713Sgirish }
58744961713Sgirish 
588a3c5bd6dSspeer /* ARGSUSED */
58944961713Sgirish int
nxge_rdc_stat_update(kstat_t * ksp,int rw)59044961713Sgirish nxge_rdc_stat_update(kstat_t *ksp, int rw)
59144961713Sgirish {
592a3c5bd6dSspeer 	p_nxge_t nxgep;
593a3c5bd6dSspeer 	p_nxge_rdc_kstat_t rdc_kstatsp;
594a3c5bd6dSspeer 	p_nxge_rx_ring_stats_t statsp;
595a3c5bd6dSspeer 	int channel;
59644961713Sgirish 	char *ch_name, *end;
59744961713Sgirish 
59844961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
59944961713Sgirish 	if (nxgep == NULL)
60044961713Sgirish 		return (-1);
601a3c5bd6dSspeer 
60244961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_stat_update"));
60344961713Sgirish 
60444961713Sgirish 	ch_name = ksp->ks_name;
60544961713Sgirish 	ch_name += strlen(RDC_NAME_FORMAT1);
60644961713Sgirish 	channel = mi_strtol(ch_name, &end, 10);
60744961713Sgirish 
60844961713Sgirish 	rdc_kstatsp = (p_nxge_rdc_kstat_t)ksp->ks_data;
60944961713Sgirish 	statsp = (p_nxge_rx_ring_stats_t)&nxgep->statsp->rdc_stats[channel];
61044961713Sgirish 
61144961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL,
61271cd5202Smisaki 	    "nxge_rdc_stat_update $%p statsp $%p channel %d",
61371cd5202Smisaki 	    ksp->ks_data, statsp, channel));
61444961713Sgirish 
61544961713Sgirish 	if (rw == KSTAT_WRITE) {
61644961713Sgirish 		statsp->dcf_err = rdc_kstatsp->dcf_err.value.ul;
61744961713Sgirish 		statsp->rcr_ack_err = rdc_kstatsp->rcr_ack_err.value.ul;
61844961713Sgirish 		statsp->dc_fifo_err = rdc_kstatsp->dc_fifoflow_err.value.ul;
61944961713Sgirish 		statsp->rcr_sha_par = rdc_kstatsp->rcr_sha_par_err.value.ul;
62044961713Sgirish 		statsp->rbr_pre_par = rdc_kstatsp->rbr_pre_par_err.value.ul;
62144961713Sgirish 		statsp->wred_drop = rdc_kstatsp->wred_drop.value.ul;
62244961713Sgirish 		statsp->rbr_pre_empty = rdc_kstatsp->rbr_pre_emty.value.ul;
62344961713Sgirish 		statsp->rcr_shadow_full = rdc_kstatsp->rcr_shadow_full.value.ul;
62444961713Sgirish 		statsp->rx_rbr_tmout = rdc_kstatsp->rbr_tmout.value.ul;
62544961713Sgirish 		statsp->rsp_cnt_err = rdc_kstatsp->rsp_cnt_err.value.ul;
62644961713Sgirish 		statsp->byte_en_bus = rdc_kstatsp->byte_en_bus.value.ul;
62744961713Sgirish 		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;
63044961713Sgirish 		statsp->l2_err = rdc_kstatsp->compl_l2_err.value.ul;
63144961713Sgirish 		statsp->l4_cksum_err = rdc_kstatsp->compl_l4_cksum_err.value.ul;
63244961713Sgirish 		statsp->fflp_soft_err =
63371cd5202Smisaki 		    rdc_kstatsp->compl_fflp_soft_err.value.ul;
63444961713Sgirish 		statsp->zcp_soft_err = rdc_kstatsp->compl_zcp_soft_err.value.ul;
63544961713Sgirish 		statsp->config_err = rdc_kstatsp->config_err.value.ul;
63644961713Sgirish 		statsp->rcrincon = rdc_kstatsp->rcrincon.value.ul;
63744961713Sgirish 		statsp->rcrfull = rdc_kstatsp->rcrfull.value.ul;
63844961713Sgirish 		statsp->rbr_empty = rdc_kstatsp->rbr_empty.value.ul;
63944961713Sgirish 		statsp->rbrfull = rdc_kstatsp->rbrfull.value.ul;
64044961713Sgirish 		statsp->rbrlogpage = rdc_kstatsp->rbrlogpage.value.ul;
64144961713Sgirish 		statsp->cfiglogpage = rdc_kstatsp->cfiglogpage.value.ul;
64244961713Sgirish 	} else {
64344961713Sgirish 		rdc_kstatsp->ipackets.value.ull = statsp->ipackets;
64444961713Sgirish 		rdc_kstatsp->rbytes.value.ull = statsp->ibytes;
64544961713Sgirish 		rdc_kstatsp->errors.value.ul = statsp->ierrors;
64644961713Sgirish 		rdc_kstatsp->dcf_err.value.ul = statsp->dcf_err;
64744961713Sgirish 		rdc_kstatsp->rcr_ack_err.value.ul = statsp->rcr_ack_err;
64844961713Sgirish 		rdc_kstatsp->dc_fifoflow_err.value.ul = statsp->dc_fifo_err;
64944961713Sgirish 		rdc_kstatsp->rcr_sha_par_err.value.ul = statsp->rcr_sha_par;
65044961713Sgirish 		rdc_kstatsp->rbr_pre_par_err.value.ul = statsp->rbr_pre_par;
651a3c5bd6dSspeer 		rdc_kstatsp->wred_drop.value.ul = statsp->wred_drop;
652a3c5bd6dSspeer 		rdc_kstatsp->port_drop_pkt.value.ul = statsp->port_drop_pkt;
65344961713Sgirish 		rdc_kstatsp->rbr_pre_emty.value.ul = statsp->rbr_pre_empty;
65444961713Sgirish 		rdc_kstatsp->rcr_shadow_full.value.ul = statsp->rcr_shadow_full;
65544961713Sgirish 		rdc_kstatsp->rbr_tmout.value.ul = statsp->rx_rbr_tmout;
65644961713Sgirish 		rdc_kstatsp->rsp_cnt_err.value.ul = statsp->rsp_cnt_err;
65744961713Sgirish 		rdc_kstatsp->byte_en_bus.value.ul = statsp->byte_en_bus;
65844961713Sgirish 		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;
66144961713Sgirish 		rdc_kstatsp->compl_l2_err.value.ul = statsp->l2_err;
66244961713Sgirish 		rdc_kstatsp->compl_l4_cksum_err.value.ul = statsp->l4_cksum_err;
66344961713Sgirish 		rdc_kstatsp->compl_fflp_soft_err.value.ul =
66471cd5202Smisaki 		    statsp->fflp_soft_err;
66544961713Sgirish 		rdc_kstatsp->compl_zcp_soft_err.value.ul = statsp->zcp_soft_err;
66644961713Sgirish 		rdc_kstatsp->config_err.value.ul = statsp->config_err;
66744961713Sgirish 		rdc_kstatsp->rcrincon.value.ul = statsp->rcrincon;
66844961713Sgirish 		rdc_kstatsp->rcrfull.value.ul = statsp->rcrfull;
66944961713Sgirish 		rdc_kstatsp->rbr_empty.value.ul = statsp->rbr_empty;
67044961713Sgirish 		rdc_kstatsp->rbrfull.value.ul = statsp->rbrfull;
67144961713Sgirish 		rdc_kstatsp->rbrlogpage.value.ul = statsp->rbrlogpage;
67244961713Sgirish 		rdc_kstatsp->cfiglogpage.value.ul = statsp->cfiglogpage;
67344961713Sgirish 	}
674a3c5bd6dSspeer 
67544961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_stat_update"));
67644961713Sgirish 	return (0);
67744961713Sgirish }
67844961713Sgirish 
679a3c5bd6dSspeer /* ARGSUSED */
68044961713Sgirish int
nxge_rdc_sys_stat_update(kstat_t * ksp,int rw)68144961713Sgirish nxge_rdc_sys_stat_update(kstat_t *ksp, int rw)
68244961713Sgirish {
683a3c5bd6dSspeer 	p_nxge_t nxgep;
684a3c5bd6dSspeer 	p_nxge_rdc_sys_kstat_t rdc_sys_kstatsp;
685a3c5bd6dSspeer 	p_nxge_rdc_sys_stats_t statsp;
68644961713Sgirish 
68744961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
68844961713Sgirish 	if (nxgep == NULL)
68944961713Sgirish 		return (-1);
690a3c5bd6dSspeer 
69144961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_sys_stat_update"));
69244961713Sgirish 
69344961713Sgirish 	rdc_sys_kstatsp = (p_nxge_rdc_sys_kstat_t)ksp->ks_data;
69444961713Sgirish 	statsp = (p_nxge_rdc_sys_stats_t)&nxgep->statsp->rdc_sys_stats;
69544961713Sgirish 
69644961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "nxge_rdc_sys_stat_update %llx",
69771cd5202Smisaki 	    ksp->ks_data));
69844961713Sgirish 
69944961713Sgirish 	if (rw == KSTAT_WRITE) {
70044961713Sgirish 		statsp->id_mismatch = rdc_sys_kstatsp->id_mismatch.value.ul;
70144961713Sgirish 		statsp->ipp_eop_err = rdc_sys_kstatsp->ipp_eop_err.value.ul;
70244961713Sgirish 		statsp->zcp_eop_err = rdc_sys_kstatsp->zcp_eop_err.value.ul;
70344961713Sgirish 	} else {
70444961713Sgirish 		rdc_sys_kstatsp->id_mismatch.value.ul = statsp->id_mismatch;
70544961713Sgirish 		rdc_sys_kstatsp->ipp_eop_err.value.ul = statsp->ipp_eop_err;
70644961713Sgirish 		rdc_sys_kstatsp->zcp_eop_err.value.ul = statsp->zcp_eop_err;
70744961713Sgirish 	}
70844961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_sys_stat_update"));
70944961713Sgirish 	return (0);
71044961713Sgirish }
71144961713Sgirish 
712a3c5bd6dSspeer /* ARGSUSED */
71344961713Sgirish static int
nxge_txc_stat_update(kstat_t * ksp,int rw)71444961713Sgirish nxge_txc_stat_update(kstat_t *ksp, int rw)
71544961713Sgirish {
716a3c5bd6dSspeer 	p_nxge_t nxgep;
717a3c5bd6dSspeer 	p_nxge_txc_kstat_t txc_kstatsp;
718a3c5bd6dSspeer 	p_nxge_txc_stats_t statsp;
71944961713Sgirish 
72044961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
72144961713Sgirish 
72244961713Sgirish 	if (nxgep == NULL)
72344961713Sgirish 		return (-1);
72444961713Sgirish 
72544961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_txc_stat_update"));
72644961713Sgirish 
72744961713Sgirish 	txc_kstatsp = (p_nxge_txc_kstat_t)ksp->ks_data;
72844961713Sgirish 	statsp = (p_nxge_txc_stats_t)&nxgep->statsp->txc_stats;
72944961713Sgirish 
73044961713Sgirish 	if (rw == KSTAT_WRITE) {
73144961713Sgirish 		statsp->pkt_stuffed = txc_kstatsp->pkt_stuffed.value.ul;
73244961713Sgirish 		statsp->pkt_xmit = txc_kstatsp->pkt_xmit.value.ul;
73344961713Sgirish 		statsp->ro_correct_err = txc_kstatsp->ro_correct_err.value.ul;
73444961713Sgirish 		statsp->ro_uncorrect_err =
73571cd5202Smisaki 		    txc_kstatsp->ro_uncorrect_err.value.ul;
73644961713Sgirish 		statsp->sf_correct_err = txc_kstatsp->sf_correct_err.value.ul;
73744961713Sgirish 		statsp->sf_uncorrect_err =
73871cd5202Smisaki 		    txc_kstatsp->sf_uncorrect_err.value.ul;
73944961713Sgirish 		statsp->address_failed = txc_kstatsp->address_failed.value.ul;
74044961713Sgirish 		statsp->dma_failed = txc_kstatsp->dma_failed.value.ul;
74144961713Sgirish 		statsp->length_failed = txc_kstatsp->length_failed.value.ul;
74244961713Sgirish 		statsp->pkt_assy_dead = txc_kstatsp->pkt_assy_dead.value.ul;
74344961713Sgirish 		statsp->reorder_err = txc_kstatsp->reorder_err.value.ul;
74444961713Sgirish 	} else {
74544961713Sgirish 		txc_kstatsp->pkt_stuffed.value.ul = statsp->pkt_stuffed;
74644961713Sgirish 		txc_kstatsp->pkt_xmit.value.ul = statsp->pkt_xmit;
74744961713Sgirish 		txc_kstatsp->ro_correct_err.value.ul = statsp->ro_correct_err;
74844961713Sgirish 		txc_kstatsp->ro_uncorrect_err.value.ul =
74971cd5202Smisaki 		    statsp->ro_uncorrect_err;
75044961713Sgirish 		txc_kstatsp->sf_correct_err.value.ul = statsp->sf_correct_err;
75144961713Sgirish 		txc_kstatsp->sf_uncorrect_err.value.ul =
75271cd5202Smisaki 		    statsp->sf_uncorrect_err;
75344961713Sgirish 		txc_kstatsp->address_failed.value.ul = statsp->address_failed;
75444961713Sgirish 		txc_kstatsp->dma_failed.value.ul = statsp->dma_failed;
75544961713Sgirish 		txc_kstatsp->length_failed.value.ul = statsp->length_failed;
75644961713Sgirish 		txc_kstatsp->pkt_assy_dead.value.ul = statsp->pkt_assy_dead;
75744961713Sgirish 		txc_kstatsp->reorder_err.value.ul = statsp->reorder_err;
75844961713Sgirish 	}
75944961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_txc_stat_update"));
76044961713Sgirish 	return (0);
76144961713Sgirish }
76244961713Sgirish 
763a3c5bd6dSspeer /* ARGSUSED */
76444961713Sgirish int
nxge_ipp_stat_update(kstat_t * ksp,int rw)76544961713Sgirish nxge_ipp_stat_update(kstat_t *ksp, int rw)
76644961713Sgirish {
767a3c5bd6dSspeer 	p_nxge_t nxgep;
768a3c5bd6dSspeer 	p_nxge_ipp_kstat_t ipp_kstatsp;
769a3c5bd6dSspeer 	p_nxge_ipp_stats_t statsp;
77044961713Sgirish 
77144961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
77244961713Sgirish 	if (nxgep == NULL)
77344961713Sgirish 		return (-1);
77444961713Sgirish 
77544961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_ipp_stat_update"));
77644961713Sgirish 
77744961713Sgirish 	ipp_kstatsp = (p_nxge_ipp_kstat_t)ksp->ks_data;
77844961713Sgirish 	statsp = (p_nxge_ipp_stats_t)&nxgep->statsp->ipp_stats;
77944961713Sgirish 
78044961713Sgirish 	if (rw == KSTAT_WRITE) {
78144961713Sgirish 		statsp->eop_miss = ipp_kstatsp->eop_miss.value.ul;
78244961713Sgirish 		statsp->sop_miss = ipp_kstatsp->sop_miss.value.ul;
78344961713Sgirish 		statsp->dfifo_ue = ipp_kstatsp->dfifo_ue.value.ul;
78444961713Sgirish 		statsp->ecc_err_cnt = ipp_kstatsp->ecc_err_cnt.value.ul;
785846a903dSml 		statsp->pfifo_perr = ipp_kstatsp->pfifo_perr.value.ul;
78644961713Sgirish 		statsp->pfifo_over = ipp_kstatsp->pfifo_over.value.ul;
78744961713Sgirish 		statsp->pfifo_und = ipp_kstatsp->pfifo_und.value.ul;
78844961713Sgirish 		statsp->bad_cs_cnt = ipp_kstatsp->bad_cs_cnt.value.ul;
78944961713Sgirish 		statsp->pkt_dis_cnt = ipp_kstatsp->pkt_dis_cnt.value.ul;
79044961713Sgirish 	} else {
79144961713Sgirish 		ipp_kstatsp->eop_miss.value.ul = statsp->eop_miss;
79244961713Sgirish 		ipp_kstatsp->sop_miss.value.ul = statsp->sop_miss;
79344961713Sgirish 		ipp_kstatsp->dfifo_ue.value.ul = statsp->dfifo_ue;
79444961713Sgirish 		ipp_kstatsp->ecc_err_cnt.value.ul = statsp->ecc_err_cnt;
795846a903dSml 		ipp_kstatsp->pfifo_perr.value.ul = statsp->pfifo_perr;
79644961713Sgirish 		ipp_kstatsp->pfifo_over.value.ul = statsp->pfifo_over;
79744961713Sgirish 		ipp_kstatsp->pfifo_und.value.ul = statsp->pfifo_und;
79844961713Sgirish 		ipp_kstatsp->bad_cs_cnt.value.ul = statsp->bad_cs_cnt;
79944961713Sgirish 		ipp_kstatsp->pkt_dis_cnt.value.ul = statsp->pkt_dis_cnt;
80044961713Sgirish 	}
80144961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_ipp_stat_update"));
80244961713Sgirish 	return (0);
80344961713Sgirish }
80444961713Sgirish 
805a3c5bd6dSspeer /* ARGSUSED */
80644961713Sgirish int
nxge_xmac_stat_update(kstat_t * ksp,int rw)80744961713Sgirish nxge_xmac_stat_update(kstat_t *ksp, int rw)
80844961713Sgirish {
809a3c5bd6dSspeer 	p_nxge_t nxgep;
810a3c5bd6dSspeer 	p_nxge_xmac_kstat_t xmac_kstatsp;
811a3c5bd6dSspeer 	p_nxge_xmac_stats_t statsp;
81244961713Sgirish 
81344961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
81444961713Sgirish 	if (nxgep == NULL)
81544961713Sgirish 		return (-1);
81644961713Sgirish 
81744961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_xmac_stat_update"));
81844961713Sgirish 
81944961713Sgirish 	xmac_kstatsp = (p_nxge_xmac_kstat_t)ksp->ks_data;
82044961713Sgirish 	statsp = (p_nxge_xmac_stats_t)&nxgep->statsp->xmac_stats;
82144961713Sgirish 
82244961713Sgirish 	if (rw == KSTAT_WRITE) {
82344961713Sgirish 		statsp->tx_frame_cnt = xmac_kstatsp->tx_frame_cnt.value.ul;
82444961713Sgirish 		statsp->tx_underflow_err =
82571cd5202Smisaki 		    xmac_kstatsp->tx_underflow_err.value.ul;
82644961713Sgirish 		statsp->tx_maxpktsize_err =
82771cd5202Smisaki 		    xmac_kstatsp->tx_maxpktsize_err.value.ul;
82844961713Sgirish 		statsp->tx_overflow_err =
82971cd5202Smisaki 		    xmac_kstatsp->tx_overflow_err.value.ul;
83044961713Sgirish 		statsp->tx_fifo_xfr_err =
83171cd5202Smisaki 		    xmac_kstatsp->tx_fifo_xfr_err.value.ul;
83244961713Sgirish 		statsp->tx_byte_cnt = xmac_kstatsp->tx_byte_cnt.value.ul;
83344961713Sgirish 		statsp->rx_underflow_err =
83471cd5202Smisaki 		    xmac_kstatsp->rx_underflow_err.value.ul;
83544961713Sgirish 		statsp->rx_overflow_err =
83671cd5202Smisaki 		    xmac_kstatsp->rx_overflow_err.value.ul;
83744961713Sgirish 		statsp->rx_crc_err_cnt = xmac_kstatsp->rx_crc_err_cnt.value.ul;
83844961713Sgirish 		statsp->rx_len_err_cnt = xmac_kstatsp->rx_len_err_cnt.value.ul;
83944961713Sgirish 		statsp->rx_viol_err_cnt =
84071cd5202Smisaki 		    xmac_kstatsp->rx_viol_err_cnt.value.ul;
84144961713Sgirish 		statsp->rx_byte_cnt = xmac_kstatsp->rx_byte_cnt.value.ul;
842321febdeSsbehera 		statsp->rx_frame_cnt = xmac_kstatsp->rx_frame_cnt.value.ul;
84344961713Sgirish 		statsp->rx_hist1_cnt = xmac_kstatsp->rx_hist1_cnt.value.ul;
84444961713Sgirish 		statsp->rx_hist2_cnt = xmac_kstatsp->rx_hist2_cnt.value.ul;
84544961713Sgirish 		statsp->rx_hist3_cnt = xmac_kstatsp->rx_hist3_cnt.value.ul;
84644961713Sgirish 		statsp->rx_hist4_cnt = xmac_kstatsp->rx_hist4_cnt.value.ul;
84744961713Sgirish 		statsp->rx_hist5_cnt = xmac_kstatsp->rx_hist5_cnt.value.ul;
84844961713Sgirish 		statsp->rx_hist6_cnt = xmac_kstatsp->rx_hist6_cnt.value.ul;
849321febdeSsbehera 		statsp->rx_hist7_cnt = xmac_kstatsp->rx_hist7_cnt.value.ul;
85044961713Sgirish 		statsp->rx_mult_cnt = xmac_kstatsp->rx_mult_cnt.value.ul;
85144961713Sgirish 		statsp->rx_frag_cnt = xmac_kstatsp->rx_frag_cnt.value.ul;
85244961713Sgirish 		statsp->rx_frame_align_err_cnt =
85371cd5202Smisaki 		    xmac_kstatsp->rx_frame_align_err_cnt.value.ul;
85444961713Sgirish 		statsp->rx_linkfault_err_cnt =
85571cd5202Smisaki 		    xmac_kstatsp->rx_linkfault_err_cnt.value.ul;
85644961713Sgirish 		statsp->rx_localfault_err =
85771cd5202Smisaki 		    xmac_kstatsp->rx_local_fault_err_cnt.value.ul;
85844961713Sgirish 		statsp->rx_remotefault_err =
85971cd5202Smisaki 		    xmac_kstatsp->rx_remote_fault_err_cnt.value.ul;
86044961713Sgirish 		statsp->xpcs_deskew_err_cnt =
86171cd5202Smisaki 		    xmac_kstatsp->xpcs_deskew_err_cnt.value.ul;
86214ea4bb7Ssd #ifdef	NXGE_DEBUG_SYMBOL_ERR
86344961713Sgirish 		statsp->xpcs_ln0_symbol_err_cnt =
86471cd5202Smisaki 		    xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul;
86544961713Sgirish 		statsp->xpcs_ln1_symbol_err_cnt =
86671cd5202Smisaki 		    xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul;
86744961713Sgirish 		statsp->xpcs_ln2_symbol_err_cnt =
86871cd5202Smisaki 		    xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul;
86944961713Sgirish 		statsp->xpcs_ln3_symbol_err_cnt =
87071cd5202Smisaki 		    xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul;
87114ea4bb7Ssd #endif
87244961713Sgirish 	} else {
87344961713Sgirish 		xmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
87444961713Sgirish 		xmac_kstatsp->tx_underflow_err.value.ul =
87571cd5202Smisaki 		    statsp->tx_underflow_err;
87644961713Sgirish 		xmac_kstatsp->tx_maxpktsize_err.value.ul =
87771cd5202Smisaki 		    statsp->tx_maxpktsize_err;
87844961713Sgirish 		xmac_kstatsp->tx_overflow_err.value.ul =
87971cd5202Smisaki 		    statsp->tx_overflow_err;
88044961713Sgirish 		xmac_kstatsp->tx_fifo_xfr_err.value.ul =
88171cd5202Smisaki 		    statsp->tx_fifo_xfr_err;
88244961713Sgirish 		xmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
88344961713Sgirish 		xmac_kstatsp->rx_underflow_err.value.ul =
88471cd5202Smisaki 		    statsp->rx_underflow_err;
88544961713Sgirish 		xmac_kstatsp->rx_overflow_err.value.ul =
88671cd5202Smisaki 		    statsp->rx_overflow_err;
88744961713Sgirish 		xmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
88844961713Sgirish 		xmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
88944961713Sgirish 		xmac_kstatsp->rx_viol_err_cnt.value.ul =
89071cd5202Smisaki 		    statsp->rx_viol_err_cnt;
89144961713Sgirish 		xmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
892321febdeSsbehera 		xmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
89344961713Sgirish 		xmac_kstatsp->rx_hist1_cnt.value.ul = statsp->rx_hist1_cnt;
89444961713Sgirish 		xmac_kstatsp->rx_hist2_cnt.value.ul = statsp->rx_hist2_cnt;
89544961713Sgirish 		xmac_kstatsp->rx_hist3_cnt.value.ul = statsp->rx_hist3_cnt;
89644961713Sgirish 		xmac_kstatsp->rx_hist4_cnt.value.ul = statsp->rx_hist4_cnt;
89744961713Sgirish 		xmac_kstatsp->rx_hist5_cnt.value.ul = statsp->rx_hist5_cnt;
89844961713Sgirish 		xmac_kstatsp->rx_hist6_cnt.value.ul = statsp->rx_hist6_cnt;
899321febdeSsbehera 		xmac_kstatsp->rx_hist7_cnt.value.ul = statsp->rx_hist7_cnt;
90044961713Sgirish 		xmac_kstatsp->rx_mult_cnt.value.ul = statsp->rx_mult_cnt;
90144961713Sgirish 		xmac_kstatsp->rx_frag_cnt.value.ul = statsp->rx_frag_cnt;
90244961713Sgirish 		xmac_kstatsp->rx_frame_align_err_cnt.value.ul =
90371cd5202Smisaki 		    statsp->rx_frame_align_err_cnt;
90444961713Sgirish 		xmac_kstatsp->rx_linkfault_err_cnt.value.ul =
90571cd5202Smisaki 		    statsp->rx_linkfault_err_cnt;
90644961713Sgirish 		xmac_kstatsp->rx_local_fault_err_cnt.value.ul =
90771cd5202Smisaki 		    statsp->rx_localfault_err;
90844961713Sgirish 		xmac_kstatsp->rx_remote_fault_err_cnt.value.ul =
90971cd5202Smisaki 		    statsp->rx_remotefault_err;
91044961713Sgirish 		xmac_kstatsp->xpcs_deskew_err_cnt.value.ul =
91171cd5202Smisaki 		    statsp->xpcs_deskew_err_cnt;
91214ea4bb7Ssd #ifdef	NXGE_DEBUG_SYMBOL_ERR
91344961713Sgirish 		xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul =
91471cd5202Smisaki 		    statsp->xpcs_ln0_symbol_err_cnt;
91544961713Sgirish 		xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul =
91671cd5202Smisaki 		    statsp->xpcs_ln1_symbol_err_cnt;
91744961713Sgirish 		xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul =
91871cd5202Smisaki 		    statsp->xpcs_ln2_symbol_err_cnt;
91944961713Sgirish 		xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul =
92071cd5202Smisaki 		    statsp->xpcs_ln3_symbol_err_cnt;
92114ea4bb7Ssd #endif
92244961713Sgirish 	}
92344961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_xmac_stat_update"));
92444961713Sgirish 	return (0);
92544961713Sgirish }
92644961713Sgirish 
927a3c5bd6dSspeer /* ARGSUSED */
92844961713Sgirish int
nxge_bmac_stat_update(kstat_t * ksp,int rw)92944961713Sgirish nxge_bmac_stat_update(kstat_t *ksp, int rw)
93044961713Sgirish {
931a3c5bd6dSspeer 	p_nxge_t nxgep;
932a3c5bd6dSspeer 	p_nxge_bmac_kstat_t bmac_kstatsp;
933a3c5bd6dSspeer 	p_nxge_bmac_stats_t statsp;
93444961713Sgirish 
93544961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
93644961713Sgirish 	if (nxgep == NULL)
93744961713Sgirish 		return (-1);
93844961713Sgirish 
93944961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_bmac_stat_update"));
94044961713Sgirish 
94144961713Sgirish 	bmac_kstatsp = (p_nxge_bmac_kstat_t)ksp->ks_data;
94244961713Sgirish 	statsp = (p_nxge_bmac_stats_t)&nxgep->statsp->bmac_stats;
94344961713Sgirish 
94444961713Sgirish 	if (rw == KSTAT_WRITE) {
94544961713Sgirish 		statsp->tx_frame_cnt = bmac_kstatsp->tx_frame_cnt.value.ul;
94644961713Sgirish 		statsp->tx_underrun_err =
94771cd5202Smisaki 		    bmac_kstatsp->tx_underrun_err.value.ul;
94844961713Sgirish 		statsp->tx_max_pkt_err = bmac_kstatsp->tx_max_pkt_err.value.ul;
94944961713Sgirish 		statsp->tx_byte_cnt = bmac_kstatsp->tx_byte_cnt.value.ul;
95044961713Sgirish 		statsp->rx_frame_cnt = bmac_kstatsp->rx_frame_cnt.value.ul;
95144961713Sgirish 		statsp->rx_byte_cnt = bmac_kstatsp->rx_byte_cnt.value.ul;
95244961713Sgirish 		statsp->rx_overflow_err =
95371cd5202Smisaki 		    bmac_kstatsp->rx_overflow_err.value.ul;
95444961713Sgirish 		statsp->rx_align_err_cnt =
95571cd5202Smisaki 		    bmac_kstatsp->rx_align_err_cnt.value.ul;
95644961713Sgirish 		statsp->rx_crc_err_cnt = bmac_kstatsp->rx_crc_err_cnt.value.ul;
95744961713Sgirish 		statsp->rx_len_err_cnt = bmac_kstatsp->rx_len_err_cnt.value.ul;
95844961713Sgirish 		statsp->rx_viol_err_cnt =
95971cd5202Smisaki 		    bmac_kstatsp->rx_viol_err_cnt.value.ul;
96044961713Sgirish 	} else {
96144961713Sgirish 		bmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt;
96244961713Sgirish 		bmac_kstatsp->tx_underrun_err.value.ul =
96371cd5202Smisaki 		    statsp->tx_underrun_err;
96444961713Sgirish 		bmac_kstatsp->tx_max_pkt_err.value.ul = statsp->tx_max_pkt_err;
96544961713Sgirish 		bmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt;
96644961713Sgirish 		bmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt;
96744961713Sgirish 		bmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt;
96844961713Sgirish 		bmac_kstatsp->rx_overflow_err.value.ul =
96971cd5202Smisaki 		    statsp->rx_overflow_err;
97044961713Sgirish 		bmac_kstatsp->rx_align_err_cnt.value.ul =
97171cd5202Smisaki 		    statsp->rx_align_err_cnt;
97244961713Sgirish 		bmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt;
97344961713Sgirish 		bmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt;
97444961713Sgirish 		bmac_kstatsp->rx_viol_err_cnt.value.ul =
97571cd5202Smisaki 		    statsp->rx_viol_err_cnt;
97644961713Sgirish 	}
97744961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_bmac_stat_update"));
97844961713Sgirish 	return (0);
97944961713Sgirish }
98044961713Sgirish 
981a3c5bd6dSspeer /* ARGSUSED */
98244961713Sgirish int
nxge_zcp_stat_update(kstat_t * ksp,int rw)98344961713Sgirish nxge_zcp_stat_update(kstat_t *ksp, int rw)
98444961713Sgirish {
985a3c5bd6dSspeer 	p_nxge_t nxgep;
986a3c5bd6dSspeer 	p_nxge_zcp_kstat_t zcp_kstatsp;
987a3c5bd6dSspeer 	p_nxge_zcp_stats_t statsp;
98844961713Sgirish 
98944961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
99044961713Sgirish 	if (nxgep == NULL)
99144961713Sgirish 		return (-1);
99244961713Sgirish 
99344961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_zcp_stat_update"));
99444961713Sgirish 
99544961713Sgirish 	zcp_kstatsp = (p_nxge_zcp_kstat_t)ksp->ks_data;
99644961713Sgirish 	statsp = (p_nxge_zcp_stats_t)&nxgep->statsp->zcp_stats;
99744961713Sgirish 
99844961713Sgirish 	if (rw == KSTAT_WRITE) {
99944961713Sgirish 		statsp->rrfifo_underrun = zcp_kstatsp->rrfifo_underrun.value.ul;
100044961713Sgirish 		statsp->rrfifo_overrun = zcp_kstatsp->rrfifo_overrun.value.ul;
100144961713Sgirish 		statsp->rspfifo_uncorr_err =
100271cd5202Smisaki 		    zcp_kstatsp->rspfifo_uncorr_err.value.ul;
100344961713Sgirish 		statsp->buffer_overflow = zcp_kstatsp->buffer_overflow.value.ul;
100444961713Sgirish 		statsp->stat_tbl_perr = zcp_kstatsp->stat_tbl_perr.value.ul;
100544961713Sgirish 		statsp->dyn_tbl_perr = zcp_kstatsp->dyn_tbl_perr.value.ul;
100644961713Sgirish 		statsp->buf_tbl_perr = zcp_kstatsp->buf_tbl_perr.value.ul;
100744961713Sgirish 		statsp->tt_program_err = zcp_kstatsp->tt_program_err.value.ul;
100844961713Sgirish 		statsp->rsp_tt_index_err =
100971cd5202Smisaki 		    zcp_kstatsp->rsp_tt_index_err.value.ul;
101044961713Sgirish 		statsp->slv_tt_index_err =
101171cd5202Smisaki 		    zcp_kstatsp->slv_tt_index_err.value.ul;
101244961713Sgirish 		statsp->zcp_tt_index_err =
101371cd5202Smisaki 		    zcp_kstatsp->zcp_tt_index_err.value.ul;
101444961713Sgirish 		statsp->cfifo_ecc = zcp_kstatsp->cfifo_ecc.value.ul;
101544961713Sgirish 	} else {
101644961713Sgirish 		zcp_kstatsp->rrfifo_underrun.value.ul = statsp->rrfifo_underrun;
101744961713Sgirish 		zcp_kstatsp->rrfifo_overrun.value.ul = statsp->rrfifo_overrun;
101844961713Sgirish 		zcp_kstatsp->rspfifo_uncorr_err.value.ul =
101971cd5202Smisaki 		    statsp->rspfifo_uncorr_err;
102044961713Sgirish 		zcp_kstatsp->buffer_overflow.value.ul =
102171cd5202Smisaki 		    statsp->buffer_overflow;
102244961713Sgirish 		zcp_kstatsp->stat_tbl_perr.value.ul = statsp->stat_tbl_perr;
102344961713Sgirish 		zcp_kstatsp->dyn_tbl_perr.value.ul = statsp->dyn_tbl_perr;
1024a3c5bd6dSspeer 		zcp_kstatsp->buf_tbl_perr.value.ul = statsp->buf_tbl_perr;
102544961713Sgirish 		zcp_kstatsp->tt_program_err.value.ul = statsp->tt_program_err;
102644961713Sgirish 		zcp_kstatsp->rsp_tt_index_err.value.ul =
102771cd5202Smisaki 		    statsp->rsp_tt_index_err;
102844961713Sgirish 		zcp_kstatsp->slv_tt_index_err.value.ul =
102971cd5202Smisaki 		    statsp->slv_tt_index_err;
103044961713Sgirish 		zcp_kstatsp->zcp_tt_index_err.value.ul =
103171cd5202Smisaki 		    statsp->zcp_tt_index_err;
1032a3c5bd6dSspeer 		zcp_kstatsp->cfifo_ecc.value.ul = statsp->cfifo_ecc;
103344961713Sgirish 	}
103444961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_zcp_stat_update"));
103544961713Sgirish 	return (0);
103644961713Sgirish }
103744961713Sgirish 
1038a3c5bd6dSspeer /* ARGSUSED */
103944961713Sgirish int
nxge_fflp_stat_update(kstat_t * ksp,int rw)104044961713Sgirish nxge_fflp_stat_update(kstat_t *ksp, int rw)
104144961713Sgirish {
1042a3c5bd6dSspeer 	p_nxge_t nxgep;
1043a3c5bd6dSspeer 	p_nxge_fflp_kstat_t fflp_kstatsp;
1044a3c5bd6dSspeer 	p_nxge_fflp_stats_t statsp;
1045a3c5bd6dSspeer 	int ldc_grp;
104644961713Sgirish 
104744961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
104844961713Sgirish 	if (nxgep == NULL)
104944961713Sgirish 		return (-1);
105044961713Sgirish 
105144961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_fflp_stat_update"));
105244961713Sgirish 
105344961713Sgirish 	fflp_kstatsp = (p_nxge_fflp_kstat_t)ksp->ks_data;
105444961713Sgirish 	statsp = (p_nxge_fflp_stats_t)&nxgep->statsp->fflp_stats;
105544961713Sgirish 
105644961713Sgirish 	if (rw == KSTAT_WRITE) {
105744961713Sgirish 		statsp->tcam_parity_err = fflp_kstatsp->fflp_tcam_perr.value.ul;
105844961713Sgirish 		statsp->tcam_ecc_err = fflp_kstatsp->fflp_tcam_ecc_err.value.ul;
105944961713Sgirish 		statsp->vlan_parity_err = fflp_kstatsp->fflp_vlan_perr.value.ul;
106044961713Sgirish 		statsp->hash_lookup_err =
106171cd5202Smisaki 		    fflp_kstatsp->fflp_hasht_lookup_err.value.ul;
106244961713Sgirish 		for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
106344961713Sgirish 			statsp->hash_pio_err[ldc_grp] =
106471cd5202Smisaki 			    fflp_kstatsp->fflp_hasht_data_err[ldc_grp].
106571cd5202Smisaki 			    value.ul;
106644961713Sgirish 		}
106744961713Sgirish 	} else {
106844961713Sgirish 		fflp_kstatsp->fflp_tcam_perr.value.ul =
106971cd5202Smisaki 		    fflp_kstatsp->fflp_tcam_perr.value.ul;
107044961713Sgirish 		fflp_kstatsp->fflp_tcam_ecc_err.value.ul = statsp->tcam_ecc_err;
107144961713Sgirish 		fflp_kstatsp->fflp_vlan_perr.value.ul = statsp->vlan_parity_err;
107244961713Sgirish 		fflp_kstatsp->fflp_hasht_lookup_err.value.ul =
107371cd5202Smisaki 		    statsp->hash_lookup_err;
107444961713Sgirish 		for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) {
107544961713Sgirish 			fflp_kstatsp->fflp_hasht_data_err[ldc_grp].value.ul =
107671cd5202Smisaki 			    statsp->hash_pio_err[ldc_grp];
107744961713Sgirish 		}
107844961713Sgirish 	}
107944961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_fflp_stat_update"));
108044961713Sgirish 	return (0);
108144961713Sgirish }
108244961713Sgirish 
1083a3c5bd6dSspeer /* ARGSUSED */
108444961713Sgirish static uint64_t
nxge_mac_octet_to_u64(struct ether_addr addr)108544961713Sgirish nxge_mac_octet_to_u64(struct ether_addr addr)
108644961713Sgirish {
108744961713Sgirish 	int i;
108844961713Sgirish 	uint64_t addr64 = 0;
1089a3c5bd6dSspeer 
109044961713Sgirish 	for (i = ETHERADDRL - 1; i >= 0; i--) {
109144961713Sgirish 		addr64 <<= 8;
109244961713Sgirish 		addr64 |= addr.ether_addr_octet[i];
109344961713Sgirish 	}
109444961713Sgirish 	return (addr64);
109544961713Sgirish }
109644961713Sgirish 
1097a3c5bd6dSspeer /* ARGSUSED */
109844961713Sgirish int
nxge_mmac_stat_update(kstat_t * ksp,int rw)109944961713Sgirish nxge_mmac_stat_update(kstat_t *ksp, int rw)
110044961713Sgirish {
1101a3c5bd6dSspeer 	p_nxge_t nxgep;
1102a3c5bd6dSspeer 	p_nxge_mmac_kstat_t mmac_kstatsp;
1103a3c5bd6dSspeer 	p_nxge_mmac_stats_t statsp;
110444961713Sgirish 
110544961713Sgirish 	nxgep = (p_nxge_t)ksp->ks_private;
110644961713Sgirish 	if (nxgep == NULL)
110744961713Sgirish 		return (-1);
110844961713Sgirish 
110944961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_mmac_stat_update"));
111044961713Sgirish 
111144961713Sgirish 	mmac_kstatsp = (p_nxge_mmac_kstat_t)ksp->ks_data;
111244961713Sgirish 	statsp = (p_nxge_mmac_stats_t)&nxgep->statsp->mmac_stats;
111344961713Sgirish 
111444961713Sgirish 	if (rw == KSTAT_WRITE) {
111544961713Sgirish 		cmn_err(CE_WARN, "Can not write mmac stats");
111644961713Sgirish 	} else {
111744961713Sgirish 		mmac_kstatsp->mmac_max_addr_cnt.value.ul =
111871cd5202Smisaki 		    statsp->mmac_max_cnt;
111944961713Sgirish 		mmac_kstatsp->mmac_avail_addr_cnt.value.ul =
112071cd5202Smisaki 		    statsp->mmac_avail_cnt;
112144961713Sgirish 		mmac_kstatsp->mmac_addr1.value.ul =
112271cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[0]);
112344961713Sgirish 		mmac_kstatsp->mmac_addr2.value.ul =
112471cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[1]);
112544961713Sgirish 		mmac_kstatsp->mmac_addr3.value.ul =
112671cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[2]);
112744961713Sgirish 		mmac_kstatsp->mmac_addr4.value.ul =
112871cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[3]);
112944961713Sgirish 		mmac_kstatsp->mmac_addr5.value.ul =
113071cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[4]);
113144961713Sgirish 		mmac_kstatsp->mmac_addr6.value.ul =
113271cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[5]);
113344961713Sgirish 		mmac_kstatsp->mmac_addr7.value.ul =
113471cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[6]);
113544961713Sgirish 		mmac_kstatsp->mmac_addr8.value.ul =
113671cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[7]);
113744961713Sgirish 		mmac_kstatsp->mmac_addr9.value.ul =
113871cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[8]);
113944961713Sgirish 		mmac_kstatsp->mmac_addr10.value.ul =
114071cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[9]);
114144961713Sgirish 		mmac_kstatsp->mmac_addr11.value.ul =
114271cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[10]);
114344961713Sgirish 		mmac_kstatsp->mmac_addr12.value.ul =
114471cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[11]);
114544961713Sgirish 		mmac_kstatsp->mmac_addr13.value.ul =
114671cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[12]);
114744961713Sgirish 		mmac_kstatsp->mmac_addr14.value.ul =
114871cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[13]);
114944961713Sgirish 		mmac_kstatsp->mmac_addr15.value.ul =
115071cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[14]);
115144961713Sgirish 		mmac_kstatsp->mmac_addr16.value.ul =
115271cd5202Smisaki 		    nxge_mac_octet_to_u64(statsp->mmac_avail_pool[15]);
115344961713Sgirish 	}
115444961713Sgirish 	NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_mmac_stat_update"));
115544961713Sgirish 	return (0);
115644961713Sgirish }
115744961713Sgirish 
1158a3c5bd6dSspeer /* ARGSUSED */
115944961713Sgirish 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))116044961713Sgirish nxge_setup_local_kstat(p_nxge_t nxgep, int instance, char *name,
1161a3c5bd6dSspeer 	const nxge_kstat_index_t *ksip, size_t count,
1162a3c5bd6dSspeer 	int (*update) (kstat_t *, int))
116344961713Sgirish {
116444961713Sgirish 	kstat_t *ksp;
116544961713Sgirish 	kstat_named_t *knp;
116644961713Sgirish 	int i;
1167a3c5bd6dSspeer 
116844961713Sgirish 	ksp = kstat_create(NXGE_DRIVER_NAME, instance, name, "net",
116971cd5202Smisaki 	    KSTAT_TYPE_NAMED, count, 0);
117044961713Sgirish 	if (ksp == NULL)
117144961713Sgirish 		return (NULL);
117244961713Sgirish 
117344961713Sgirish 	ksp->ks_private = (void *)nxgep;
117444961713Sgirish 	ksp->ks_update = update;
117544961713Sgirish 	knp = ksp->ks_data;
117644961713Sgirish 
117744961713Sgirish 	for (i = 0; ksip[i].name != NULL; i++) {
117844961713Sgirish 		kstat_named_init(&knp[i], ksip[i].name, ksip[i].type);
117944961713Sgirish 	}
118044961713Sgirish 
118144961713Sgirish 	kstat_install(ksp);
118244961713Sgirish 	return (ksp);
118344961713Sgirish }
118444961713Sgirish 
1185a3c5bd6dSspeer /* ARGSUSED */
1186678453a8Sspeer 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,
120371cd5202Smisaki 		    "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,
122471cd5202Smisaki 		    "kstat_create failed for tdc channel %d", channel));
1225678453a8Sspeer 	}
1226678453a8Sspeer #endif
1227678453a8Sspeer }
1228678453a8Sspeer 
122944961713Sgirish void
nxge_setup_kstats(p_nxge_t nxgep)123044961713