1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #include <sys/nxge/nxge_impl.h> 29 #include <inet/mi.h> 30 31 #define RDC_NAME_FORMAT1 "RDC Channel" 32 #define TDC_NAME_FORMAT1 "TDC Channel" 33 #define CH_NAME_FORMAT " %d Stats" 34 #define TDC_NAME_FORMAT "TDC Channel %d Stats" 35 #define RDC_NAME_FORMAT "RDC Channel %d Stats" 36 37 void nxge_mac_init_kstats(p_nxge_t, struct kstat *); 38 void nxge_xmac_init_kstats(struct kstat *); 39 void nxge_bmac_init_kstats(struct kstat *); 40 41 /* ARGSUSED */ 42 void 43 nxge_init_statsp(p_nxge_t nxgep) 44 { 45 size_t stats_size; 46 47 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_init_statsp")); 48 49 stats_size = sizeof (nxge_stats_t); 50 nxgep->statsp = KMEM_ZALLOC(stats_size, KM_SLEEP); 51 nxgep->statsp->stats_size = stats_size; 52 53 NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_init_statsp")); 54 } 55 56 typedef struct { 57 uint8_t index; 58 uint8_t type; 59 char *name; 60 } nxge_kstat_index_t; 61 62 typedef enum { 63 RDC_STAT_PACKETS = 0, 64 RDC_STAT_BYTES, 65 RDC_STAT_ERRORS, 66 RDC_STAT_DCF_ERR, 67 RDC_STAT_RCR_ACK_ERR, 68 RDC_STAT_RCR_DC_FIFOFLOW_ERR, 69 RDC_STAT_RCR_SHA_PAR_ERR, 70 RDC_STAT_RBR_PRE_PAR_ERR, 71 RDC_STAT_WRED_DROP, 72 RDC_STAT_RBR_PRE_EMTY, 73 RDC_STAT_RCR_SHADOW_FULL, 74 RDC_STAT_RBR_TMOUT, 75 RDC_STAT_RSP_CNT_ERR, 76 RDC_STAT_BYTE_EN_BUS, 77 RDC_STAT_RSP_DAT_ERR, 78 RDC_STAT_COMPL_L2_ERR, 79 RDC_STAT_COMPL_L4_CKSUM_ERR, 80 RDC_STAT_COMPL_ZCP_SOFT_ERR, 81 RDC_STAT_COMPL_FFLP_SOFT_ERR, 82 RDC_STAT_CONFIG_ERR, 83 RDC_STAT_RCRINCON, 84 RDC_STAT_RCRFULL, 85 RDC_STAT_RBR_EMPTY, 86 RDC_STAT_RBR_FULL, 87 RDC_STAT_RBRLOGPAGE, 88 RDC_STAT_CFIGLOGPAGE, 89 RDC_STAT_PORT_DROP_PKT, 90 RDC_STAT_RCRTO, 91 RDC_STAT_RCRTHRES, 92 RDC_STAT_MEX, 93 RDC_STAT_ID_MIS, 94 RDC_STAT_ZCP_EOP, 95 RDC_STAT_IPP_EOP, 96 RDC_STAT_END 97 } nxge_rdc_stat_index_t; 98 99 nxge_kstat_index_t nxge_rdc_stats[] = { 100 {RDC_STAT_PACKETS, KSTAT_DATA_UINT64, "rdc_packets"}, 101 {RDC_STAT_BYTES, KSTAT_DATA_UINT64, "rdc_bytes"}, 102 {RDC_STAT_ERRORS, KSTAT_DATA_ULONG, "rdc_errors"}, 103 {RDC_STAT_DCF_ERR, KSTAT_DATA_ULONG, "rdc_dcf_err"}, 104 {RDC_STAT_RCR_ACK_ERR, KSTAT_DATA_ULONG, "rdc_rcr_ack_err"}, 105 {RDC_STAT_RCR_DC_FIFOFLOW_ERR, KSTAT_DATA_ULONG, "rdc_dc_fifoflow_err"}, 106 {RDC_STAT_RCR_SHA_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rcr_sha_par_err"}, 107 {RDC_STAT_RBR_PRE_PAR_ERR, KSTAT_DATA_ULONG, "rdc_rbr_pre_par_err"}, 108 {RDC_STAT_WRED_DROP, KSTAT_DATA_ULONG, "rdc_wred_drop"}, 109 {RDC_STAT_RBR_PRE_EMTY, KSTAT_DATA_ULONG, "rdc_rbr_pre_empty"}, 110 {RDC_STAT_RCR_SHADOW_FULL, KSTAT_DATA_ULONG, "rdc_rcr_shadow_full"}, 111 {RDC_STAT_RBR_TMOUT, KSTAT_DATA_ULONG, "rdc_rbr_tmout"}, 112 {RDC_STAT_RSP_CNT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_cnt_err"}, 113 {RDC_STAT_BYTE_EN_BUS, KSTAT_DATA_ULONG, "rdc_byte_en_bus"}, 114 {RDC_STAT_RSP_DAT_ERR, KSTAT_DATA_ULONG, "rdc_rsp_dat_err"}, 115 {RDC_STAT_COMPL_L2_ERR, KSTAT_DATA_ULONG, "rdc_compl_l2_err"}, 116 {RDC_STAT_COMPL_L4_CKSUM_ERR, KSTAT_DATA_ULONG, "rdc_compl_l4_cksum"}, 117 {RDC_STAT_COMPL_ZCP_SOFT_ERR, KSTAT_DATA_ULONG, 118 "rdc_compl_zcp_soft_err"}, 119 {RDC_STAT_COMPL_FFLP_SOFT_ERR, KSTAT_DATA_ULONG, 120 "rdc_compl_fflp_soft_err"}, 121 {RDC_STAT_CONFIG_ERR, KSTAT_DATA_ULONG, "rdc_config_err"}, 122 {RDC_STAT_RCRINCON, KSTAT_DATA_ULONG, "rdc_rcrincon"}, 123 {RDC_STAT_RCRFULL, KSTAT_DATA_ULONG, "rdc_rcrfull"}, 124 {RDC_STAT_RBR_EMPTY, KSTAT_DATA_ULONG, "rdc_rbr_empty"}, 125 {RDC_STAT_RBR_FULL, KSTAT_DATA_ULONG, "rdc_rbrfull"}, 126 {RDC_STAT_RBRLOGPAGE, KSTAT_DATA_ULONG, "rdc_rbrlogpage"}, 127 {RDC_STAT_CFIGLOGPAGE, KSTAT_DATA_ULONG, "rdc_cfiglogpage"}, 128 {RDC_STAT_PORT_DROP_PKT, KSTAT_DATA_ULONG, "rdc_port_drop_pkt"}, 129 {RDC_STAT_RCRTO, KSTAT_DATA_ULONG, "rdc_rcrto"}, 130 {RDC_STAT_RCRTHRES, KSTAT_DATA_ULONG, "rdc_rcrthres"}, 131 {RDC_STAT_MEX, KSTAT_DATA_ULONG, "rdc_mex"}, 132 {RDC_STAT_ID_MIS, KSTAT_DATA_ULONG, "rdc_id_mismatch"}, 133 {RDC_STAT_ZCP_EOP, KSTAT_DATA_ULONG, "rdc_zcp_eop"}, 134 {RDC_STAT_IPP_EOP, KSTAT_DATA_ULONG, "rdc_ipp_eop"}, 135 {RDC_STAT_END, NULL, NULL} 136 }; 137 138 typedef enum { 139 RDC_SYS_STAT_PRE_PAR_ERR = 0, 140 RDC_SYS_STAT_SHA_PAR_ERR, 141 RDC_SYS_STAT_ID_MISMATCH, 142 RDC_SYS_STAT_IPP_EOP_ERR, 143 RDC_SYS_STAT_ZCP_EOP_ERR, 144 RDC_SYS_STAT_END 145 } nxge_rdc_sys_stat_idx_t; 146 147 nxge_kstat_index_t nxge_rdc_sys_stats[] = { 148 {RDC_SYS_STAT_PRE_PAR_ERR, KSTAT_DATA_UINT64, "rdc_pre_par_err"}, 149 {RDC_SYS_STAT_SHA_PAR_ERR, KSTAT_DATA_UINT64, "rdc_sha_par_err"}, 150 {RDC_SYS_STAT_ID_MISMATCH, KSTAT_DATA_UINT64, "rdc_stat_id_mismatch"}, 151 {RDC_SYS_STAT_IPP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_ipp_eop_err"}, 152 {RDC_SYS_STAT_ZCP_EOP_ERR, KSTAT_DATA_UINT64, "rdc_zcp_eop_err"}, 153 {RDC_SYS_STAT_END, NULL, NULL} 154 }; 155 156 typedef enum { 157 TDC_STAT_PACKETS = 0, 158 TDC_STAT_BYTES, 159 TDC_STAT_ERRORS, 160 TDC_STAT_TX_INITS, 161 TDC_STAT_TX_NO_BUF, 162 TDC_STAT_MBOX_ERR, 163 TDC_STAT_PKT_SIZE_ERR, 164 TDC_STAT_TX_RING_OFLOW, 165 TDC_STAT_PREF_BUF_ECC_ERR, 166 TDC_STAT_NACK_PREF, 167 TDC_STAT_NACK_PKT_RD, 168 TDC_STAT_CONF_PART_ERR, 169 TDC_STAT_PKT_PRT_ERR, 170 TDC_STAT_RESET_FAIL, 171 TDC_STAT_TX_STARTS, 172 TDC_STAT_TX_NOCANPUT, 173 TDC_STAT_TX_MSGDUP_FAIL, 174 TDC_STAT_TX_ALLOCB_FAIL, 175 TDC_STAT_TX_NO_DESC, 176 TDC_STAT_TX_DMA_BIND_FAIL, 177 TDC_STAT_TX_UFLOW, 178 TDC_STAT_TX_HDR_PKTS, 179 TDC_STAT_TX_DDI_PKTS, 180 TDC_STAT_TX_DVMA_PKTS, 181 TDC_STAT_TX_MAX_PEND, 182 TDC_STAT_END 183 } nxge_tdc_stats_index_t; 184 185 nxge_kstat_index_t nxge_tdc_stats[] = { 186 {TDC_STAT_PACKETS, KSTAT_DATA_UINT64, "tdc_packets"}, 187 {TDC_STAT_BYTES, KSTAT_DATA_UINT64, "tdc_bytes"}, 188 {TDC_STAT_ERRORS, KSTAT_DATA_UINT64, "tdc_errors"}, 189 {TDC_STAT_TX_INITS, KSTAT_DATA_ULONG, "tdc_tx_inits"}, 190 {TDC_STAT_TX_NO_BUF, KSTAT_DATA_ULONG, "tdc_tx_no_buf"}, 191 {TDC_STAT_MBOX_ERR, KSTAT_DATA_ULONG, "tdc_mbox_err"}, 192 {TDC_STAT_PKT_SIZE_ERR, KSTAT_DATA_ULONG, "tdc_pkt_size_err"}, 193 {TDC_STAT_TX_RING_OFLOW, 194 KSTAT_DATA_ULONG, "tdc_tx_ring_oflow"}, 195 {TDC_STAT_PREF_BUF_ECC_ERR, 196 KSTAT_DATA_ULONG, "tdc_pref_buf_err_err"}, 197 {TDC_STAT_NACK_PREF, KSTAT_DATA_ULONG, "tdc_nack_pref"}, 198 {TDC_STAT_NACK_PKT_RD, KSTAT_DATA_ULONG, "tdc_nack_pkt_rd"}, 199 {TDC_STAT_CONF_PART_ERR, 200 KSTAT_DATA_ULONG, "tdc_conf_part_err"}, 201 {TDC_STAT_PKT_PRT_ERR, KSTAT_DATA_ULONG, "tdc_pkt_prt_err"}, 202 {TDC_STAT_RESET_FAIL, KSTAT_DATA_ULONG, "tdc_reset_fail"}, 203 {TDC_STAT_TX_STARTS, KSTAT_DATA_ULONG, "tdc_tx_starts"}, 204 {TDC_STAT_TX_NOCANPUT, KSTAT_DATA_ULONG, "tdc_tx_nocanput"}, 205 {TDC_STAT_TX_MSGDUP_FAIL, KSTAT_DATA_ULONG, "tdc_tx_msgdup_fail"}, 206 {TDC_STAT_TX_ALLOCB_FAIL, KSTAT_DATA_ULONG, "tdc_tx_allocb_fail"}, 207 {TDC_STAT_TX_NO_DESC, KSTAT_DATA_ULONG, "tdc_tx_no_desc"}, 208 {TDC_STAT_TX_DMA_BIND_FAIL, KSTAT_DATA_ULONG, "tdc_tx_dma_bind_fail"}, 209 {TDC_STAT_TX_UFLOW, KSTAT_DATA_ULONG, "tdc_tx_uflow"}, 210 {TDC_STAT_TX_HDR_PKTS, KSTAT_DATA_ULONG, "tdc_tx_hdr_pkts"}, 211 {TDC_STAT_TX_DDI_PKTS, KSTAT_DATA_ULONG, "tdc_tx_ddi_pkts"}, 212 {TDC_STAT_TX_DVMA_PKTS, KSTAT_DATA_ULONG, "tdc_tx_dvma_pkts"}, 213 {TDC_STAT_TX_MAX_PEND, KSTAT_DATA_ULONG, "tdc_tx_max_pend"}, 214 {TDC_STAT_END, NULL, NULL} 215 }; 216 217 /* IPP Statistics definitions */ 218 typedef enum { 219 IPP_STAT_EOP_MISS = 0, 220 IPP_STAT_SOP_MISS, 221 IPP_STAT_DFIFO_UE, 222 IPP_STAT_ECC_ERR, 223 IPP_STAT_PFIFO_OVER, 224 IPP_STAT_PFIFO_UND, 225 IPP_STAT_BAD_CS, 226 IPP_STAT_BAD_DIS, 227 IPP_STAT_CS_FAIL, 228 IPP_STAT_END 229 } nxge_ipp_stat_index_t; 230 231 nxge_kstat_index_t nxge_ipp_stats[] = { 232 {IPP_STAT_EOP_MISS, KSTAT_DATA_ULONG, "rxipp_eop_miss"}, 233 {IPP_STAT_SOP_MISS, KSTAT_DATA_ULONG, "rxipp_sop_miss"}, 234 {IPP_STAT_DFIFO_UE, KSTAT_DATA_ULONG, "rxipp_dfifo_ue"}, 235 {IPP_STAT_ECC_ERR, KSTAT_DATA_ULONG, "rxipp_ecc_err"}, 236 {IPP_STAT_PFIFO_OVER, KSTAT_DATA_ULONG, "rxipp_pfifo_over"}, 237 {IPP_STAT_PFIFO_UND, KSTAT_DATA_ULONG, "rxipp_pfifo_und"}, 238 {IPP_STAT_BAD_CS, KSTAT_DATA_ULONG, "rxipp_bad_cs"}, 239 {IPP_STAT_BAD_DIS, KSTAT_DATA_ULONG, "rxipp_bad_dis"}, 240 {IPP_STAT_CS_FAIL, KSTAT_DATA_ULONG, "rxipp_cs_fail"}, 241 {IPP_STAT_END, NULL, NULL} 242 }; 243 244 /* TXC Statistics definitions */ 245 typedef enum { 246 TXC_STAT_PKT_STUFFED = 0, 247 TXC_STAT_PKT_XMIT, 248 TXC_STAT_RO_CORRECT_ERR, 249 TXC_STAT_RO_UNCORRECT_ERR, 250 TXC_STAT_SF_CORRECT_ERR, 251 TXC_STAT_SF_UNCORRECT_ERR, 252 TXC_STAT_ADDRESS_FAILED, 253 TXC_STAT_DMA_FAILED, 254 TXC_STAT_LENGTH_FAILED, 255 TXC_STAT_PKT_ASSY_DEAD, 256 TXC_STAT_REORDER_ERR, 257 TXC_STAT_END 258 } nxge_txc_stat_index_t; 259 260 nxge_kstat_index_t nxge_txc_stats[] = { 261 {TXC_STAT_PKT_STUFFED, KSTAT_DATA_ULONG, "txc_pkt_stuffed"}, 262 {TXC_STAT_PKT_XMIT, KSTAT_DATA_ULONG, "txc_pkt_xmit"}, 263 {TXC_STAT_RO_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_correct_err"}, 264 {TXC_STAT_RO_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_ro_uncorrect_err"}, 265 {TXC_STAT_SF_CORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_correct_err"}, 266 {TXC_STAT_SF_UNCORRECT_ERR, KSTAT_DATA_ULONG, "txc_sf_uncorrect_err"}, 267 {TXC_STAT_ADDRESS_FAILED, KSTAT_DATA_ULONG, "txc_address_failed"}, 268 {TXC_STAT_DMA_FAILED, KSTAT_DATA_ULONG, "txc_dma_failed"}, 269 {TXC_STAT_LENGTH_FAILED, KSTAT_DATA_ULONG, "txc_length_failed"}, 270 {TXC_STAT_PKT_ASSY_DEAD, KSTAT_DATA_ULONG, "txc_pkt_assy_dead"}, 271 {TXC_STAT_REORDER_ERR, KSTAT_DATA_ULONG, "txc_reorder_err"}, 272 {TXC_STAT_END, NULL, NULL} 273 }; 274 275 typedef enum { 276 XMAC_STAT_TX_FRAME_CNT = 0, 277 XMAC_STAT_TX_UNDERFLOW_ERR, 278 XMAC_STAT_TX_MAXPKTSIZE_ERR, 279 XMAC_STAT_TX_OVERFLOW_ERR, 280 XMAC_STAT_TX_FIFO_XFR_ERR, 281 XMAC_STAT_TX_BYTE_CNT, 282 XMAC_STAT_RX_FRAME_CNT, 283 XMAC_STAT_RX_UNDERFLOW_ERR, 284 XMAC_STAT_RX_OVERFLOW_ERR, 285 XMAC_STAT_RX_CRC_ERR_CNT, 286 XMAC_STAT_RX_LEN_ERR_CNT, 287 XMAC_STAT_RX_VIOL_ERR_CNT, 288 XMAC_STAT_RX_BYTE_CNT, 289 XMAC_STAT_RX_HIST1_CNT, 290 XMAC_STAT_RX_HIST2_CNT, 291 XMAC_STAT_RX_HIST3_CNT, 292 XMAC_STAT_RX_HIST4_CNT, 293 XMAC_STAT_RX_HIST5_CNT, 294 XMAC_STAT_RX_HIST6_CNT, 295 XMAC_STAT_RX_HIST7_CNT, 296 XMAC_STAT_RX_BROADCAST_CNT, 297 XMAC_STAT_RX_MULT_CNT, 298 XMAC_STAT_RX_FRAG_CNT, 299 XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT, 300 XMAC_STAT_RX_LINKFAULT_ERR_CNT, 301 XMAC_STAT_RX_REMOTEFAULT_ERR, 302 XMAC_STAT_RX_LOCALFAULT_ERR, 303 XMAC_STAT_RX_PAUSE_CNT, 304 XMAC_STAT_TX_PAUSE_STATE, 305 XMAC_STAT_TX_NOPAUSE_STATE, 306 XMAC_STAT_XPCS_DESKEW_ERR_CNT, 307 #ifdef NXGE_DEBUG_SYMBOL_ERR 308 XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT, 309 XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT, 310 XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT, 311 XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT, 312 #endif 313 XMAC_STAT_END 314 } nxge_xmac_stat_index_t; 315 316 nxge_kstat_index_t nxge_xmac_stats[] = { 317 {XMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"}, 318 {XMAC_STAT_TX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "tmac_underflow_err"}, 319 {XMAC_STAT_TX_MAXPKTSIZE_ERR, KSTAT_DATA_ULONG, "txmac_maxpktsize_err"}, 320 {XMAC_STAT_TX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "txmac_overflow_err"}, 321 {XMAC_STAT_TX_FIFO_XFR_ERR, KSTAT_DATA_ULONG, "txmac_fifo_xfr_err"}, 322 {XMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"}, 323 {XMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"}, 324 {XMAC_STAT_RX_UNDERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_underflow_err"}, 325 {XMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"}, 326 {XMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err"}, 327 {XMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_length_err"}, 328 {XMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_code_violations"}, 329 {XMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"}, 330 {XMAC_STAT_RX_HIST1_CNT, KSTAT_DATA_ULONG, "rxmac_64_cnt"}, 331 {XMAC_STAT_RX_HIST2_CNT, KSTAT_DATA_ULONG, "rxmac_65_127_cnt"}, 332 {XMAC_STAT_RX_HIST3_CNT, KSTAT_DATA_ULONG, "rxmac_128_255_cnt"}, 333 {XMAC_STAT_RX_HIST4_CNT, KSTAT_DATA_ULONG, "rxmac_256_511_cnt"}, 334 {XMAC_STAT_RX_HIST5_CNT, KSTAT_DATA_ULONG, "rxmac_512_1023_cnt"}, 335 {XMAC_STAT_RX_HIST6_CNT, KSTAT_DATA_ULONG, "rxmac_1024_1522_cnt"}, 336 {XMAC_STAT_RX_HIST7_CNT, KSTAT_DATA_ULONG, "rxmac_jumbo_cnt"}, 337 {XMAC_STAT_RX_BROADCAST_CNT, KSTAT_DATA_ULONG, "rxmac_broadcast_cnt"}, 338 {XMAC_STAT_RX_MULT_CNT, KSTAT_DATA_ULONG, "rxmac_multicast_cnt"}, 339 {XMAC_STAT_RX_FRAG_CNT, KSTAT_DATA_ULONG, "rxmac_fragment_cnt"}, 340 {XMAC_STAT_RX_FRAME_ALIGN_ERR_CNT, 341 KSTAT_DATA_ULONG, "rxmac_alignment_err"}, 342 {XMAC_STAT_RX_LINKFAULT_ERR_CNT, 343 KSTAT_DATA_ULONG, "rxmac_linkfault_errs"}, 344 {XMAC_STAT_RX_REMOTEFAULT_ERR, 345 KSTAT_DATA_ULONG, "rxmac_remote_faults"}, 346 {XMAC_STAT_RX_LOCALFAULT_ERR, 347 KSTAT_DATA_ULONG, "rxmac_local_faults"}, 348 {XMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"}, 349 {XMAC_STAT_TX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"}, 350 {XMAC_STAT_TX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "txmac_nopause_state"}, 351 {XMAC_STAT_XPCS_DESKEW_ERR_CNT, 352 KSTAT_DATA_ULONG, "xpcs_deskew_err_cnt"}, 353 #ifdef NXGE_DEBUG_SYMBOL_ERR 354 {XMAC_STAT_XPCS_SYMBOL_L0_ERR_CNT, 355 KSTAT_DATA_ULONG, "xpcs_ln0_symbol_err_cnt"}, 356 {XMAC_STAT_XPCS_SYMBOL_L1_ERR_CNT, 357 KSTAT_DATA_ULONG, "xpcs_ln1_symbol_err_cnt"}, 358 {XMAC_STAT_XPCS_SYMBOL_L2_ERR_CNT, 359 KSTAT_DATA_ULONG, "xpcs_ln2_symbol_err_cnt"}, 360 {XMAC_STAT_XPCS_SYMBOL_L3_ERR_CNT, 361 KSTAT_DATA_ULONG, "xpcs_ln3_symbol_err_cnt"}, 362 #endif 363 {XMAC_STAT_END, NULL, NULL} 364 }; 365 366 typedef enum { 367 BMAC_STAT_TX_FRAME_CNT = 0, 368 BMAC_STAT_TX_UNDERRUN_ERR, 369 BMAC_STAT_TX_MAX_PKT_ERR, 370 BMAC_STAT_TX_BYTE_CNT, 371 BMAC_STAT_RX_FRAME_CNT, 372 BMAC_STAT_RX_BYTE_CNT, 373 BMAC_STAT_RX_OVERFLOW_ERR, 374 BMAC_STAT_RX_ALIGN_ERR_CNT, 375 BMAC_STAT_RX_CRC_ERR_CNT, 376 BMAC_STAT_RX_LEN_ERR_CNT, 377 BMAC_STAT_RX_VIOL_ERR_CNT, 378 BMAC_STAT_RX_PAUSE_CNT, 379 BMAC_STAT_RX_PAUSE_STATE, 380 BMAC_STAT_RX_NOPAUSE_STATE, 381 BMAC_STAT_END 382 } nxge_bmac_stat_index_t; 383 384 nxge_kstat_index_t nxge_bmac_stats[] = { 385 {BMAC_STAT_TX_FRAME_CNT, KSTAT_DATA_ULONG, "txmac_frame_cnt"}, 386 {BMAC_STAT_TX_UNDERRUN_ERR, KSTAT_DATA_ULONG, "txmac_underrun_err"}, 387 {BMAC_STAT_TX_MAX_PKT_ERR, KSTAT_DATA_ULONG, "txmac_max_pkt_err"}, 388 {BMAC_STAT_TX_BYTE_CNT, KSTAT_DATA_ULONG, "txmac_byte_cnt"}, 389 {BMAC_STAT_RX_FRAME_CNT, KSTAT_DATA_ULONG, "rxmac_frame_cnt"}, 390 {BMAC_STAT_RX_BYTE_CNT, KSTAT_DATA_ULONG, "rxmac_byte_cnt"}, 391 {BMAC_STAT_RX_OVERFLOW_ERR, KSTAT_DATA_ULONG, "rxmac_overflow_err"}, 392 {BMAC_STAT_RX_ALIGN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_align_err_cnt"}, 393 {BMAC_STAT_RX_CRC_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_crc_err_cnt"}, 394 {BMAC_STAT_RX_LEN_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_len_err_cnt"}, 395 {BMAC_STAT_RX_VIOL_ERR_CNT, KSTAT_DATA_ULONG, "rxmac_viol_err_cnt"}, 396 {BMAC_STAT_RX_PAUSE_CNT, KSTAT_DATA_ULONG, "rxmac_pause_cnt"}, 397 {BMAC_STAT_RX_PAUSE_STATE, KSTAT_DATA_ULONG, "txmac_pause_state"}, 398 {BMAC_STAT_RX_NOPAUSE_STATE, KSTAT_DATA_ULONG, "tx_nopause_state"}, 399 {BMAC_STAT_END, NULL, NULL} 400 }; 401 402 typedef enum { 403 ZCP_STAT_ERRORS, 404 ZCP_STAT_INITS, 405 ZCP_STAT_RRFIFO_UNDERRUN, 406 ZCP_STAT_RRFIFO_OVERRUN, 407 ZCP_STAT_RSPFIFO_UNCORR_ERR, 408 ZCP_STAT_BUFFER_OVERFLOW, 409 ZCP_STAT_STAT_TBL_PERR, 410 ZCP_STAT_DYN_TBL_PERR, 411 ZCP_STAT_BUF_TBL_PERR, 412 ZCP_STAT_TT_PROGRAM_ERR, 413 ZCP_STAT_RSP_TT_INDEX_ERR, 414 ZCP_STAT_SLV_TT_INDEX_ERR, 415 ZCP_STAT_ZCP_TT_INDEX_ERR, 416 ZCP_STAT_ZCP_ACCESS_FAIL, 417 ZCP_CFIFO_ECC, 418 ZCP_STAT_END 419 } nxge_zcp_stat_index_t; 420 421 nxge_kstat_index_t nxge_zcp_stats[] = { 422 {ZCP_STAT_ERRORS, KSTAT_DATA_ULONG, "zcp_erros"}, 423 {ZCP_STAT_INITS, KSTAT_DATA_ULONG, "zcp_inits"}, 424 {ZCP_STAT_RRFIFO_UNDERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_underrun"}, 425 {ZCP_STAT_RRFIFO_OVERRUN, KSTAT_DATA_ULONG, "zcp_rrfifo_overrun"}, 426 {ZCP_STAT_RSPFIFO_UNCORR_ERR, KSTAT_DATA_ULONG, 427 "zcp_rspfifo_uncorr_err"}, 428 {ZCP_STAT_BUFFER_OVERFLOW, KSTAT_DATA_ULONG, "zcp_buffer_overflow"}, 429 {ZCP_STAT_STAT_TBL_PERR, KSTAT_DATA_ULONG, "zcp_stat_tbl_perr"}, 430 {ZCP_STAT_DYN_TBL_PERR, KSTAT_DATA_ULONG, "zcp_dyn_tbl_perr"}, 431 {ZCP_STAT_BUF_TBL_PERR, KSTAT_DATA_ULONG, "zcp_buf_tbl_perr"}, 432 {ZCP_STAT_TT_PROGRAM_ERR, KSTAT_DATA_ULONG, "zcp_tt_program_err"}, 433 {ZCP_STAT_RSP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_rsp_tt_index_err"}, 434 {ZCP_STAT_SLV_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_slv_tt_index_err"}, 435 {ZCP_STAT_ZCP_TT_INDEX_ERR, KSTAT_DATA_ULONG, "zcp_zcp_tt_index_err"}, 436 {ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_access_fail"}, 437 {ZCP_STAT_ZCP_ACCESS_FAIL, KSTAT_DATA_ULONG, "zcp_cfifo_ecc"}, 438 {ZCP_STAT_END, NULL, NULL} 439 }; 440 441 typedef enum { 442 FFLP_STAT_TCAM_PERR, 443 FFLP_STAT_TCAM_ECC_ERR, 444 FFLP_STAT_VLAN_PERR, 445 FFLP_STAT_HASH_LOOKUP_ERR, 446 FFLP_STAT_HASH_P0_PIO_ERR, 447 FFLP_STAT_HASH_P1_PIO_ERR, 448 FFLP_STAT_HASH_P2_PIO_ERR, 449 FFLP_STAT_HASH_P3_PIO_ERR, 450 FFLP_STAT_HASH_P4_PIO_ERR, 451 FFLP_STAT_HASH_P5_PIO_ERR, 452 FFLP_STAT_HASH_P6_PIO_ERR, 453 FFLP_STAT_HASH_P7_PIO_ERR, 454 FFLP_STAT_END 455 } nxge_fflp_stat_index_t; 456 457 nxge_kstat_index_t nxge_fflp_stats[] = { 458 {FFLP_STAT_TCAM_PERR, KSTAT_DATA_ULONG, "fflp_tcam_perr"}, 459 {FFLP_STAT_TCAM_ECC_ERR, KSTAT_DATA_ULONG, "fflp_tcam_ecc_err"}, 460 {FFLP_STAT_VLAN_PERR, KSTAT_DATA_ULONG, "fflp_vlan_perr"}, 461 {FFLP_STAT_HASH_LOOKUP_ERR, KSTAT_DATA_ULONG, "fflp_hash_lookup_err"}, 462 {FFLP_STAT_HASH_P0_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p0_pio_err"}, 463 {FFLP_STAT_HASH_P1_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p1_pio_err"}, 464 {FFLP_STAT_HASH_P2_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p2_pio_err"}, 465 {FFLP_STAT_HASH_P3_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p3_pio_err"}, 466 {FFLP_STAT_HASH_P4_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p4_pio_err"}, 467 {FFLP_STAT_HASH_P5_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p5_pio_err"}, 468 {FFLP_STAT_HASH_P6_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p6_pio_err"}, 469 {FFLP_STAT_HASH_P7_PIO_ERR, KSTAT_DATA_ULONG, "fflp_hash_p7_pio_err"}, 470 {FFLP_STAT_END, NULL, NULL} 471 }; 472 473 typedef enum { 474 MMAC_MAX_ADDR, 475 MMAC_AVAIL_ADDR, 476 MMAC_ADDR_POOL1, 477 MMAC_ADDR_POOL2, 478 MMAC_ADDR_POOL3, 479 MMAC_ADDR_POOL4, 480 MMAC_ADDR_POOL5, 481 MMAC_ADDR_POOL6, 482 MMAC_ADDR_POOL7, 483 MMAC_ADDR_POOL8, 484 MMAC_ADDR_POOL9, 485 MMAC_ADDR_POOL10, 486 MMAC_ADDR_POOL11, 487 MMAC_ADDR_POOL12, 488 MMAC_ADDR_POOL13, 489 MMAC_ADDR_POOL14, 490 MMAC_ADDR_POOL15, 491 MMAC_ADDR_POOL16, 492 MMAC_STATS_END 493 } nxge_mmac_stat_index_t; 494 495 nxge_kstat_index_t nxge_mmac_stats[] = { 496 {MMAC_MAX_ADDR, KSTAT_DATA_UINT64, "max_mmac_addr"}, 497 {MMAC_AVAIL_ADDR, KSTAT_DATA_UINT64, "avail_mmac_addr"}, 498 {MMAC_ADDR_POOL1, KSTAT_DATA_UINT64, "mmac_addr_1"}, 499 {MMAC_ADDR_POOL2, KSTAT_DATA_UINT64, "mmac_addr_2"}, 500 {MMAC_ADDR_POOL3, KSTAT_DATA_UINT64, "mmac_addr_3"}, 501 {MMAC_ADDR_POOL4, KSTAT_DATA_UINT64, "mmac_addr_4"}, 502 {MMAC_ADDR_POOL5, KSTAT_DATA_UINT64, "mmac_addr_5"}, 503 {MMAC_ADDR_POOL6, KSTAT_DATA_UINT64, "mmac_addr_6"}, 504 {MMAC_ADDR_POOL7, KSTAT_DATA_UINT64, "mmac_addr_7"}, 505 {MMAC_ADDR_POOL8, KSTAT_DATA_UINT64, "mmac_addr_8"}, 506 {MMAC_ADDR_POOL9, KSTAT_DATA_UINT64, "mmac_addr_9"}, 507 {MMAC_ADDR_POOL10, KSTAT_DATA_UINT64, "mmac_addr_10"}, 508 {MMAC_ADDR_POOL11, KSTAT_DATA_UINT64, "mmac_addr_11"}, 509 {MMAC_ADDR_POOL12, KSTAT_DATA_UINT64, "mmac_addr_12"}, 510 {MMAC_ADDR_POOL13, KSTAT_DATA_UINT64, "mmac_addr_13"}, 511 {MMAC_ADDR_POOL14, KSTAT_DATA_UINT64, "mmac_addr_14"}, 512 {MMAC_ADDR_POOL15, KSTAT_DATA_UINT64, "mmac_addr_15"}, 513 {MMAC_ADDR_POOL16, KSTAT_DATA_UINT64, "mmac_addr_16"}, 514 {MMAC_STATS_END, NULL, NULL}, 515 }; 516 517 /* ARGSUSED */ 518 int 519 nxge_tdc_stat_update(kstat_t *ksp, int rw) 520 { 521 p_nxge_t nxgep; 522 p_nxge_tdc_kstat_t tdc_kstatsp; 523 p_nxge_tx_ring_stats_t statsp; 524 int channel; 525 char *ch_name, *end; 526 527 nxgep = (p_nxge_t)ksp->ks_private; 528 if (nxgep == NULL) 529 return (-1); 530 531 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rxstat_update")); 532 533 ch_name = ksp->ks_name; 534 ch_name += strlen(TDC_NAME_FORMAT1); 535 channel = mi_strtol(ch_name, &end, 10); 536 537 tdc_kstatsp = (p_nxge_tdc_kstat_t)ksp->ks_data; 538 statsp = (p_nxge_tx_ring_stats_t)&nxgep->statsp->tdc_stats[channel]; 539 540 NXGE_DEBUG_MSG((nxgep, KST_CTL, 541 "nxge_tdc_stat_update data $%p statsp $%p channel %d", 542 ksp->ks_data, statsp, channel)); 543 544 if (rw == KSTAT_WRITE) { 545 statsp->opackets = tdc_kstatsp->opackets.value.ull; 546 statsp->obytes = tdc_kstatsp->obytes.value.ull; 547 statsp->oerrors = tdc_kstatsp->oerrors.value.ull; 548 statsp->mbox_err = tdc_kstatsp->mbox_err.value.ul; 549 statsp->pkt_size_err = tdc_kstatsp->pkt_size_err.value.ul; 550 statsp->tx_ring_oflow = tdc_kstatsp->tx_ring_oflow.value.ul; 551 statsp->pre_buf_par_err = 552 tdc_kstatsp->pref_buf_ecc_err.value.ul; 553 statsp->nack_pref = tdc_kstatsp->nack_pref.value.ul; 554 statsp->nack_pkt_rd = tdc_kstatsp->nack_pkt_rd.value.ul; 555 statsp->conf_part_err = tdc_kstatsp->conf_part_err.value.ul; 556 statsp->pkt_part_err = tdc_kstatsp->pkt_prt_err.value.ul; 557 } else { 558 tdc_kstatsp->opackets.value.ull = statsp->opackets; 559 tdc_kstatsp->obytes.value.ull = statsp->obytes; 560 tdc_kstatsp->oerrors.value.ull = statsp->oerrors; 561 tdc_kstatsp->tx_hdr_pkts.value.ull = statsp->tx_hdr_pkts; 562 tdc_kstatsp->tx_ddi_pkts.value.ull = statsp->tx_ddi_pkts; 563 tdc_kstatsp->tx_dvma_pkts.value.ull = statsp->tx_dvma_pkts; 564 tdc_kstatsp->tx_max_pend.value.ull = statsp->tx_max_pend; 565 tdc_kstatsp->mbox_err.value.ul = statsp->mbox_err; 566 tdc_kstatsp->pkt_size_err.value.ul = statsp->pkt_size_err; 567 tdc_kstatsp->tx_ring_oflow.value.ul = statsp->tx_ring_oflow; 568 tdc_kstatsp->pref_buf_ecc_err.value.ul = 569 statsp->pre_buf_par_err; 570 tdc_kstatsp->nack_pref.value.ul = statsp->nack_pref; 571 tdc_kstatsp->nack_pkt_rd.value.ul = statsp->nack_pkt_rd; 572 tdc_kstatsp->conf_part_err.value.ul = statsp->conf_part_err; 573 tdc_kstatsp->pkt_prt_err.value.ul = statsp->pkt_part_err; 574 tdc_kstatsp->tx_starts.value.ul = statsp->tx_starts; 575 tdc_kstatsp->tx_nocanput.value.ul = statsp->tx_nocanput; 576 tdc_kstatsp->tx_msgdup_fail.value.ul = statsp->tx_msgdup_fail; 577 tdc_kstatsp->tx_allocb_fail.value.ul = statsp->tx_allocb_fail; 578 tdc_kstatsp->tx_no_desc.value.ul = statsp->tx_no_desc; 579 tdc_kstatsp->tx_dma_bind_fail.value.ul = 580 statsp->tx_dma_bind_fail; 581 } 582 NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_tdc_stat_update")); 583 return (0); 584 } 585 586 /* ARGSUSED */ 587 int 588 nxge_rdc_stat_update(kstat_t *ksp, int rw) 589 { 590 p_nxge_t nxgep; 591 p_nxge_rdc_kstat_t rdc_kstatsp; 592 p_nxge_rx_ring_stats_t statsp; 593 int channel; 594 char *ch_name, *end; 595 596 nxgep = (p_nxge_t)ksp->ks_private; 597 if (nxgep == NULL) 598 return (-1); 599 600 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_stat_update")); 601 602 ch_name = ksp->ks_name; 603 ch_name += strlen(RDC_NAME_FORMAT1); 604 channel = mi_strtol(ch_name, &end, 10); 605 606 rdc_kstatsp = (p_nxge_rdc_kstat_t)ksp->ks_data; 607 statsp = (p_nxge_rx_ring_stats_t)&nxgep->statsp->rdc_stats[channel]; 608 609 NXGE_DEBUG_MSG((nxgep, KST_CTL, 610 "nxge_rdc_stat_update $%p statsp $%p channel %d", 611 ksp->ks_data, statsp, channel)); 612 613 if (rw == KSTAT_WRITE) { 614 statsp->dcf_err = rdc_kstatsp->dcf_err.value.ul; 615 statsp->rcr_ack_err = rdc_kstatsp->rcr_ack_err.value.ul; 616 statsp->dc_fifo_err = rdc_kstatsp->dc_fifoflow_err.value.ul; 617 statsp->rcr_sha_par = rdc_kstatsp->rcr_sha_par_err.value.ul; 618 statsp->rbr_pre_par = rdc_kstatsp->rbr_pre_par_err.value.ul; 619 statsp->wred_drop = rdc_kstatsp->wred_drop.value.ul; 620 statsp->rbr_pre_empty = rdc_kstatsp->rbr_pre_emty.value.ul; 621 statsp->rcr_shadow_full = rdc_kstatsp->rcr_shadow_full.value.ul; 622 statsp->rx_rbr_tmout = rdc_kstatsp->rbr_tmout.value.ul; 623 statsp->rsp_cnt_err = rdc_kstatsp->rsp_cnt_err.value.ul; 624 statsp->byte_en_bus = rdc_kstatsp->byte_en_bus.value.ul; 625 statsp->rsp_dat_err = rdc_kstatsp->rsp_dat_err.value.ul; 626 statsp->l2_err = rdc_kstatsp->compl_l2_err.value.ul; 627 statsp->l4_cksum_err = rdc_kstatsp->compl_l4_cksum_err.value.ul; 628 statsp->fflp_soft_err = 629 rdc_kstatsp->compl_fflp_soft_err.value.ul; 630 statsp->zcp_soft_err = rdc_kstatsp->compl_zcp_soft_err.value.ul; 631 statsp->config_err = rdc_kstatsp->config_err.value.ul; 632 statsp->rcrincon = rdc_kstatsp->rcrincon.value.ul; 633 statsp->rcrfull = rdc_kstatsp->rcrfull.value.ul; 634 statsp->rbr_empty = rdc_kstatsp->rbr_empty.value.ul; 635 statsp->rbrfull = rdc_kstatsp->rbrfull.value.ul; 636 statsp->rbrlogpage = rdc_kstatsp->rbrlogpage.value.ul; 637 statsp->cfiglogpage = rdc_kstatsp->cfiglogpage.value.ul; 638 } else { 639 rdc_kstatsp->ipackets.value.ull = statsp->ipackets; 640 rdc_kstatsp->rbytes.value.ull = statsp->ibytes; 641 rdc_kstatsp->errors.value.ul = statsp->ierrors; 642 rdc_kstatsp->dcf_err.value.ul = statsp->dcf_err; 643 rdc_kstatsp->rcr_ack_err.value.ul = statsp->rcr_ack_err; 644 rdc_kstatsp->dc_fifoflow_err.value.ul = statsp->dc_fifo_err; 645 rdc_kstatsp->rcr_sha_par_err.value.ul = statsp->rcr_sha_par; 646 rdc_kstatsp->rbr_pre_par_err.value.ul = statsp->rbr_pre_par; 647 rdc_kstatsp->wred_drop.value.ul = statsp->wred_drop; 648 rdc_kstatsp->port_drop_pkt.value.ul = statsp->port_drop_pkt; 649 rdc_kstatsp->rbr_pre_emty.value.ul = statsp->rbr_pre_empty; 650 rdc_kstatsp->rcr_shadow_full.value.ul = statsp->rcr_shadow_full; 651 rdc_kstatsp->rbr_tmout.value.ul = statsp->rx_rbr_tmout; 652 rdc_kstatsp->rsp_cnt_err.value.ul = statsp->rsp_cnt_err; 653 rdc_kstatsp->byte_en_bus.value.ul = statsp->byte_en_bus; 654 rdc_kstatsp->rsp_dat_err.value.ul = statsp->rsp_dat_err; 655 rdc_kstatsp->compl_l2_err.value.ul = statsp->l2_err; 656 rdc_kstatsp->compl_l4_cksum_err.value.ul = statsp->l4_cksum_err; 657 rdc_kstatsp->compl_fflp_soft_err.value.ul = 658 statsp->fflp_soft_err; 659 rdc_kstatsp->compl_zcp_soft_err.value.ul = statsp->zcp_soft_err; 660 rdc_kstatsp->config_err.value.ul = statsp->config_err; 661 rdc_kstatsp->rcrincon.value.ul = statsp->rcrincon; 662 rdc_kstatsp->rcrfull.value.ul = statsp->rcrfull; 663 rdc_kstatsp->rbr_empty.value.ul = statsp->rbr_empty; 664 rdc_kstatsp->rbrfull.value.ul = statsp->rbrfull; 665 rdc_kstatsp->rbrlogpage.value.ul = statsp->rbrlogpage; 666 rdc_kstatsp->cfiglogpage.value.ul = statsp->cfiglogpage; 667 } 668 669 NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_stat_update")); 670 return (0); 671 } 672 673 /* ARGSUSED */ 674 int 675 nxge_rdc_sys_stat_update(kstat_t *ksp, int rw) 676 { 677 p_nxge_t nxgep; 678 p_nxge_rdc_sys_kstat_t rdc_sys_kstatsp; 679 p_nxge_rdc_sys_stats_t statsp; 680 681 nxgep = (p_nxge_t)ksp->ks_private; 682 if (nxgep == NULL) 683 return (-1); 684 685 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_rdc_sys_stat_update")); 686 687 rdc_sys_kstatsp = (p_nxge_rdc_sys_kstat_t)ksp->ks_data; 688 statsp = (p_nxge_rdc_sys_stats_t)&nxgep->statsp->rdc_sys_stats; 689 690 NXGE_DEBUG_MSG((nxgep, KST_CTL, "nxge_rdc_sys_stat_update %llx", 691 ksp->ks_data)); 692 693 if (rw == KSTAT_WRITE) { 694 statsp->id_mismatch = rdc_sys_kstatsp->id_mismatch.value.ul; 695 statsp->ipp_eop_err = rdc_sys_kstatsp->ipp_eop_err.value.ul; 696 statsp->zcp_eop_err = rdc_sys_kstatsp->zcp_eop_err.value.ul; 697 } else { 698 rdc_sys_kstatsp->id_mismatch.value.ul = statsp->id_mismatch; 699 rdc_sys_kstatsp->ipp_eop_err.value.ul = statsp->ipp_eop_err; 700 rdc_sys_kstatsp->zcp_eop_err.value.ul = statsp->zcp_eop_err; 701 } 702 NXGE_DEBUG_MSG((nxgep, KST_CTL, " <== nxge_rdc_sys_stat_update")); 703 return (0); 704 } 705 706 /* ARGSUSED */ 707 static int 708 nxge_txc_stat_update(kstat_t *ksp, int rw) 709 { 710 p_nxge_t nxgep; 711 p_nxge_txc_kstat_t txc_kstatsp; 712 p_nxge_txc_stats_t statsp; 713 714 nxgep = (p_nxge_t)ksp->ks_private; 715 716 if (nxgep == NULL) 717 return (-1); 718 719 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_txc_stat_update")); 720 721 txc_kstatsp = (p_nxge_txc_kstat_t)ksp->ks_data; 722 statsp = (p_nxge_txc_stats_t)&nxgep->statsp->txc_stats; 723 724 if (rw == KSTAT_WRITE) { 725 statsp->pkt_stuffed = txc_kstatsp->pkt_stuffed.value.ul; 726 statsp->pkt_xmit = txc_kstatsp->pkt_xmit.value.ul; 727 statsp->ro_correct_err = txc_kstatsp->ro_correct_err.value.ul; 728 statsp->ro_uncorrect_err = 729 txc_kstatsp->ro_uncorrect_err.value.ul; 730 statsp->sf_correct_err = txc_kstatsp->sf_correct_err.value.ul; 731 statsp->sf_uncorrect_err = 732 txc_kstatsp->sf_uncorrect_err.value.ul; 733 statsp->address_failed = txc_kstatsp->address_failed.value.ul; 734 statsp->dma_failed = txc_kstatsp->dma_failed.value.ul; 735 statsp->length_failed = txc_kstatsp->length_failed.value.ul; 736 statsp->pkt_assy_dead = txc_kstatsp->pkt_assy_dead.value.ul; 737 statsp->reorder_err = txc_kstatsp->reorder_err.value.ul; 738 } else { 739 txc_kstatsp->pkt_stuffed.value.ul = statsp->pkt_stuffed; 740 txc_kstatsp->pkt_xmit.value.ul = statsp->pkt_xmit; 741 txc_kstatsp->ro_correct_err.value.ul = statsp->ro_correct_err; 742 txc_kstatsp->ro_uncorrect_err.value.ul = 743 statsp->ro_uncorrect_err; 744 txc_kstatsp->sf_correct_err.value.ul = statsp->sf_correct_err; 745 txc_kstatsp->sf_uncorrect_err.value.ul = 746 statsp->sf_uncorrect_err; 747 txc_kstatsp->address_failed.value.ul = statsp->address_failed; 748 txc_kstatsp->dma_failed.value.ul = statsp->dma_failed; 749 txc_kstatsp->length_failed.value.ul = statsp->length_failed; 750 txc_kstatsp->pkt_assy_dead.value.ul = statsp->pkt_assy_dead; 751 txc_kstatsp->reorder_err.value.ul = statsp->reorder_err; 752 } 753 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_txc_stat_update")); 754 return (0); 755 } 756 757 /* ARGSUSED */ 758 int 759 nxge_ipp_stat_update(kstat_t *ksp, int rw) 760 { 761 p_nxge_t nxgep; 762 p_nxge_ipp_kstat_t ipp_kstatsp; 763 p_nxge_ipp_stats_t statsp; 764 765 nxgep = (p_nxge_t)ksp->ks_private; 766 if (nxgep == NULL) 767 return (-1); 768 769 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_ipp_stat_update")); 770 771 ipp_kstatsp = (p_nxge_ipp_kstat_t)ksp->ks_data; 772 statsp = (p_nxge_ipp_stats_t)&nxgep->statsp->ipp_stats; 773 774 if (rw == KSTAT_WRITE) { 775 statsp->eop_miss = ipp_kstatsp->eop_miss.value.ul; 776 statsp->sop_miss = ipp_kstatsp->sop_miss.value.ul; 777 statsp->dfifo_ue = ipp_kstatsp->dfifo_ue.value.ul; 778 statsp->ecc_err_cnt = ipp_kstatsp->ecc_err_cnt.value.ul; 779 statsp->pfifo_over = ipp_kstatsp->pfifo_over.value.ul; 780 statsp->pfifo_und = ipp_kstatsp->pfifo_und.value.ul; 781 statsp->bad_cs_cnt = ipp_kstatsp->bad_cs_cnt.value.ul; 782 statsp->pkt_dis_cnt = ipp_kstatsp->pkt_dis_cnt.value.ul; 783 statsp->bad_cs_cnt = ipp_kstatsp->cs_fail.value.ul; 784 } else { 785 ipp_kstatsp->eop_miss.value.ul = statsp->eop_miss; 786 ipp_kstatsp->sop_miss.value.ul = statsp->sop_miss; 787 ipp_kstatsp->dfifo_ue.value.ul = statsp->dfifo_ue; 788 ipp_kstatsp->ecc_err_cnt.value.ul = statsp->ecc_err_cnt; 789 ipp_kstatsp->pfifo_over.value.ul = statsp->pfifo_over; 790 ipp_kstatsp->pfifo_und.value.ul = statsp->pfifo_und; 791 ipp_kstatsp->bad_cs_cnt.value.ul = statsp->bad_cs_cnt; 792 ipp_kstatsp->pkt_dis_cnt.value.ul = statsp->pkt_dis_cnt; 793 ipp_kstatsp->cs_fail.value.ul = statsp->bad_cs_cnt; 794 } 795 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_ipp_stat_update")); 796 return (0); 797 } 798 799 /* ARGSUSED */ 800 int 801 nxge_xmac_stat_update(kstat_t *ksp, int rw) 802 { 803 p_nxge_t nxgep; 804 p_nxge_xmac_kstat_t xmac_kstatsp; 805 p_nxge_xmac_stats_t statsp; 806 807 nxgep = (p_nxge_t)ksp->ks_private; 808 if (nxgep == NULL) 809 return (-1); 810 811 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_xmac_stat_update")); 812 813 xmac_kstatsp = (p_nxge_xmac_kstat_t)ksp->ks_data; 814 statsp = (p_nxge_xmac_stats_t)&nxgep->statsp->xmac_stats; 815 816 if (rw == KSTAT_WRITE) { 817 statsp->tx_frame_cnt = xmac_kstatsp->tx_frame_cnt.value.ul; 818 statsp->tx_underflow_err = 819 xmac_kstatsp->tx_underflow_err.value.ul; 820 statsp->tx_maxpktsize_err = 821 xmac_kstatsp->tx_maxpktsize_err.value.ul; 822 statsp->tx_overflow_err = 823 xmac_kstatsp->tx_overflow_err.value.ul; 824 statsp->tx_fifo_xfr_err = 825 xmac_kstatsp->tx_fifo_xfr_err.value.ul; 826 statsp->tx_byte_cnt = xmac_kstatsp->tx_byte_cnt.value.ul; 827 statsp->rx_underflow_err = 828 xmac_kstatsp->rx_underflow_err.value.ul; 829 statsp->rx_overflow_err = 830 xmac_kstatsp->rx_overflow_err.value.ul; 831 statsp->rx_crc_err_cnt = xmac_kstatsp->rx_crc_err_cnt.value.ul; 832 statsp->rx_len_err_cnt = xmac_kstatsp->rx_len_err_cnt.value.ul; 833 statsp->rx_viol_err_cnt = 834 xmac_kstatsp->rx_viol_err_cnt.value.ul; 835 statsp->rx_byte_cnt = xmac_kstatsp->rx_byte_cnt.value.ul; 836 statsp->rx_hist1_cnt = xmac_kstatsp->rx_hist1_cnt.value.ul; 837 statsp->rx_hist2_cnt = xmac_kstatsp->rx_hist2_cnt.value.ul; 838 statsp->rx_hist3_cnt = xmac_kstatsp->rx_hist3_cnt.value.ul; 839 statsp->rx_hist4_cnt = xmac_kstatsp->rx_hist4_cnt.value.ul; 840 statsp->rx_hist5_cnt = xmac_kstatsp->rx_hist5_cnt.value.ul; 841 statsp->rx_hist6_cnt = xmac_kstatsp->rx_hist6_cnt.value.ul; 842 statsp->rx_mult_cnt = xmac_kstatsp->rx_mult_cnt.value.ul; 843 statsp->rx_frag_cnt = xmac_kstatsp->rx_frag_cnt.value.ul; 844 statsp->rx_frame_align_err_cnt = 845 xmac_kstatsp->rx_frame_align_err_cnt.value.ul; 846 statsp->rx_linkfault_err_cnt = 847 xmac_kstatsp->rx_linkfault_err_cnt.value.ul; 848 statsp->rx_localfault_err = 849 xmac_kstatsp->rx_local_fault_err_cnt.value.ul; 850 statsp->rx_remotefault_err = 851 xmac_kstatsp->rx_remote_fault_err_cnt.value.ul; 852 statsp->xpcs_deskew_err_cnt = 853 xmac_kstatsp->xpcs_deskew_err_cnt.value.ul; 854 #ifdef NXGE_DEBUG_SYMBOL_ERR 855 statsp->xpcs_ln0_symbol_err_cnt = 856 xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul; 857 statsp->xpcs_ln1_symbol_err_cnt = 858 xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul; 859 statsp->xpcs_ln2_symbol_err_cnt = 860 xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul; 861 statsp->xpcs_ln3_symbol_err_cnt = 862 xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul; 863 #endif 864 } else { 865 xmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt; 866 xmac_kstatsp->tx_underflow_err.value.ul = 867 statsp->tx_underflow_err; 868 xmac_kstatsp->tx_maxpktsize_err.value.ul = 869 statsp->tx_maxpktsize_err; 870 xmac_kstatsp->tx_overflow_err.value.ul = 871 statsp->tx_overflow_err; 872 xmac_kstatsp->tx_fifo_xfr_err.value.ul = 873 statsp->tx_fifo_xfr_err; 874 xmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt; 875 xmac_kstatsp->rx_underflow_err.value.ul = 876 statsp->rx_underflow_err; 877 xmac_kstatsp->rx_overflow_err.value.ul = 878 statsp->rx_overflow_err; 879 xmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt; 880 xmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt; 881 xmac_kstatsp->rx_viol_err_cnt.value.ul = 882 statsp->rx_viol_err_cnt; 883 xmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt; 884 xmac_kstatsp->rx_hist1_cnt.value.ul = statsp->rx_hist1_cnt; 885 xmac_kstatsp->rx_hist2_cnt.value.ul = statsp->rx_hist2_cnt; 886 xmac_kstatsp->rx_hist3_cnt.value.ul = statsp->rx_hist3_cnt; 887 xmac_kstatsp->rx_hist4_cnt.value.ul = statsp->rx_hist4_cnt; 888 xmac_kstatsp->rx_hist5_cnt.value.ul = statsp->rx_hist5_cnt; 889 xmac_kstatsp->rx_hist6_cnt.value.ul = statsp->rx_hist6_cnt; 890 xmac_kstatsp->rx_mult_cnt.value.ul = statsp->rx_mult_cnt; 891 xmac_kstatsp->rx_frag_cnt.value.ul = statsp->rx_frag_cnt; 892 xmac_kstatsp->rx_frame_align_err_cnt.value.ul = 893 statsp->rx_frame_align_err_cnt; 894 xmac_kstatsp->rx_linkfault_err_cnt.value.ul = 895 statsp->rx_linkfault_err_cnt; 896 xmac_kstatsp->rx_local_fault_err_cnt.value.ul = 897 statsp->rx_localfault_err; 898 xmac_kstatsp->rx_remote_fault_err_cnt.value.ul = 899 statsp->rx_remotefault_err; 900 xmac_kstatsp->xpcs_deskew_err_cnt.value.ul = 901 statsp->xpcs_deskew_err_cnt; 902 #ifdef NXGE_DEBUG_SYMBOL_ERR 903 xmac_kstatsp->xpcs_ln0_symbol_err_cnt.value.ul = 904 statsp->xpcs_ln0_symbol_err_cnt; 905 xmac_kstatsp->xpcs_ln1_symbol_err_cnt.value.ul = 906 statsp->xpcs_ln1_symbol_err_cnt; 907 xmac_kstatsp->xpcs_ln2_symbol_err_cnt.value.ul = 908 statsp->xpcs_ln2_symbol_err_cnt; 909 xmac_kstatsp->xpcs_ln3_symbol_err_cnt.value.ul = 910 statsp->xpcs_ln3_symbol_err_cnt; 911 #endif 912 } 913 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_xmac_stat_update")); 914 return (0); 915 } 916 917 /* ARGSUSED */ 918 int 919 nxge_bmac_stat_update(kstat_t *ksp, int rw) 920 { 921 p_nxge_t nxgep; 922 p_nxge_bmac_kstat_t bmac_kstatsp; 923 p_nxge_bmac_stats_t statsp; 924 925 nxgep = (p_nxge_t)ksp->ks_private; 926 if (nxgep == NULL) 927 return (-1); 928 929 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_bmac_stat_update")); 930 931 bmac_kstatsp = (p_nxge_bmac_kstat_t)ksp->ks_data; 932 statsp = (p_nxge_bmac_stats_t)&nxgep->statsp->bmac_stats; 933 934 if (rw == KSTAT_WRITE) { 935 statsp->tx_frame_cnt = bmac_kstatsp->tx_frame_cnt.value.ul; 936 statsp->tx_underrun_err = 937 bmac_kstatsp->tx_underrun_err.value.ul; 938 statsp->tx_max_pkt_err = bmac_kstatsp->tx_max_pkt_err.value.ul; 939 statsp->tx_byte_cnt = bmac_kstatsp->tx_byte_cnt.value.ul; 940 statsp->rx_frame_cnt = bmac_kstatsp->rx_frame_cnt.value.ul; 941 statsp->rx_byte_cnt = bmac_kstatsp->rx_byte_cnt.value.ul; 942 statsp->rx_overflow_err = 943 bmac_kstatsp->rx_overflow_err.value.ul; 944 statsp->rx_align_err_cnt = 945 bmac_kstatsp->rx_align_err_cnt.value.ul; 946 statsp->rx_crc_err_cnt = bmac_kstatsp->rx_crc_err_cnt.value.ul; 947 statsp->rx_len_err_cnt = bmac_kstatsp->rx_len_err_cnt.value.ul; 948 statsp->rx_viol_err_cnt = 949 bmac_kstatsp->rx_viol_err_cnt.value.ul; 950 } else { 951 bmac_kstatsp->tx_frame_cnt.value.ul = statsp->tx_frame_cnt; 952 bmac_kstatsp->tx_underrun_err.value.ul = 953 statsp->tx_underrun_err; 954 bmac_kstatsp->tx_max_pkt_err.value.ul = statsp->tx_max_pkt_err; 955 bmac_kstatsp->tx_byte_cnt.value.ul = statsp->tx_byte_cnt; 956 bmac_kstatsp->rx_frame_cnt.value.ul = statsp->rx_frame_cnt; 957 bmac_kstatsp->rx_byte_cnt.value.ul = statsp->rx_byte_cnt; 958 bmac_kstatsp->rx_overflow_err.value.ul = 959 statsp->rx_overflow_err; 960 bmac_kstatsp->rx_align_err_cnt.value.ul = 961 statsp->rx_align_err_cnt; 962 bmac_kstatsp->rx_crc_err_cnt.value.ul = statsp->rx_crc_err_cnt; 963 bmac_kstatsp->rx_len_err_cnt.value.ul = statsp->rx_len_err_cnt; 964 bmac_kstatsp->rx_viol_err_cnt.value.ul = 965 statsp->rx_viol_err_cnt; 966 } 967 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_bmac_stat_update")); 968 return (0); 969 } 970 971 /* ARGSUSED */ 972 int 973 nxge_zcp_stat_update(kstat_t *ksp, int rw) 974 { 975 p_nxge_t nxgep; 976 p_nxge_zcp_kstat_t zcp_kstatsp; 977 p_nxge_zcp_stats_t statsp; 978 979 nxgep = (p_nxge_t)ksp->ks_private; 980 if (nxgep == NULL) 981 return (-1); 982 983 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_zcp_stat_update")); 984 985 zcp_kstatsp = (p_nxge_zcp_kstat_t)ksp->ks_data; 986 statsp = (p_nxge_zcp_stats_t)&nxgep->statsp->zcp_stats; 987 988 if (rw == KSTAT_WRITE) { 989 statsp->rrfifo_underrun = zcp_kstatsp->rrfifo_underrun.value.ul; 990 statsp->rrfifo_overrun = zcp_kstatsp->rrfifo_overrun.value.ul; 991 statsp->rspfifo_uncorr_err = 992 zcp_kstatsp->rspfifo_uncorr_err.value.ul; 993 statsp->buffer_overflow = zcp_kstatsp->buffer_overflow.value.ul; 994 statsp->stat_tbl_perr = zcp_kstatsp->stat_tbl_perr.value.ul; 995 statsp->dyn_tbl_perr = zcp_kstatsp->dyn_tbl_perr.value.ul; 996 statsp->buf_tbl_perr = zcp_kstatsp->buf_tbl_perr.value.ul; 997 statsp->tt_program_err = zcp_kstatsp->tt_program_err.value.ul; 998 statsp->rsp_tt_index_err = 999 zcp_kstatsp->rsp_tt_index_err.value.ul; 1000 statsp->slv_tt_index_err = 1001 zcp_kstatsp->slv_tt_index_err.value.ul; 1002 statsp->zcp_tt_index_err = 1003 zcp_kstatsp->zcp_tt_index_err.value.ul; 1004 statsp->cfifo_ecc = zcp_kstatsp->cfifo_ecc.value.ul; 1005 } else { 1006 zcp_kstatsp->rrfifo_underrun.value.ul = statsp->rrfifo_underrun; 1007 zcp_kstatsp->rrfifo_overrun.value.ul = statsp->rrfifo_overrun; 1008 zcp_kstatsp->rspfifo_uncorr_err.value.ul = 1009 statsp->rspfifo_uncorr_err; 1010 zcp_kstatsp->buffer_overflow.value.ul = 1011 statsp->buffer_overflow; 1012 zcp_kstatsp->stat_tbl_perr.value.ul = statsp->stat_tbl_perr; 1013 zcp_kstatsp->dyn_tbl_perr.value.ul = statsp->dyn_tbl_perr; 1014 zcp_kstatsp->buf_tbl_perr.value.ul = statsp->buf_tbl_perr; 1015 zcp_kstatsp->tt_program_err.value.ul = statsp->tt_program_err; 1016 zcp_kstatsp->rsp_tt_index_err.value.ul = 1017 statsp->rsp_tt_index_err; 1018 zcp_kstatsp->slv_tt_index_err.value.ul = 1019 statsp->slv_tt_index_err; 1020 zcp_kstatsp->zcp_tt_index_err.value.ul = 1021 statsp->zcp_tt_index_err; 1022 zcp_kstatsp->cfifo_ecc.value.ul = statsp->cfifo_ecc; 1023 } 1024 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_zcp_stat_update")); 1025 return (0); 1026 } 1027 1028 /* ARGSUSED */ 1029 int 1030 nxge_fflp_stat_update(kstat_t *ksp, int rw) 1031 { 1032 p_nxge_t nxgep; 1033 p_nxge_fflp_kstat_t fflp_kstatsp; 1034 p_nxge_fflp_stats_t statsp; 1035 int ldc_grp; 1036 1037 nxgep = (p_nxge_t)ksp->ks_private; 1038 if (nxgep == NULL) 1039 return (-1); 1040 1041 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_fflp_stat_update")); 1042 1043 fflp_kstatsp = (p_nxge_fflp_kstat_t)ksp->ks_data; 1044 statsp = (p_nxge_fflp_stats_t)&nxgep->statsp->fflp_stats; 1045 1046 if (rw == KSTAT_WRITE) { 1047 statsp->tcam_parity_err = fflp_kstatsp->fflp_tcam_perr.value.ul; 1048 statsp->tcam_ecc_err = fflp_kstatsp->fflp_tcam_ecc_err.value.ul; 1049 statsp->vlan_parity_err = fflp_kstatsp->fflp_vlan_perr.value.ul; 1050 statsp->hash_lookup_err = 1051 fflp_kstatsp->fflp_hasht_lookup_err.value.ul; 1052 for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) { 1053 statsp->hash_pio_err[ldc_grp] = 1054 fflp_kstatsp->fflp_hasht_data_err[ldc_grp]. 1055 value.ul; 1056 } 1057 } else { 1058 fflp_kstatsp->fflp_tcam_perr.value.ul = 1059 fflp_kstatsp->fflp_tcam_perr.value.ul; 1060 fflp_kstatsp->fflp_tcam_ecc_err.value.ul = statsp->tcam_ecc_err; 1061 fflp_kstatsp->fflp_vlan_perr.value.ul = statsp->vlan_parity_err; 1062 fflp_kstatsp->fflp_hasht_lookup_err.value.ul = 1063 statsp->hash_lookup_err; 1064 for (ldc_grp = 0; ldc_grp < MAX_PARTITION; ldc_grp++) { 1065 fflp_kstatsp->fflp_hasht_data_err[ldc_grp].value.ul = 1066 statsp->hash_pio_err[ldc_grp]; 1067 } 1068 } 1069 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_fflp_stat_update")); 1070 return (0); 1071 } 1072 1073 /* ARGSUSED */ 1074 static uint64_t 1075 nxge_mac_octet_to_u64(struct ether_addr addr) 1076 { 1077 int i; 1078 uint64_t addr64 = 0; 1079 1080 for (i = ETHERADDRL - 1; i >= 0; i--) { 1081 addr64 <<= 8; 1082 addr64 |= addr.ether_addr_octet[i]; 1083 } 1084 return (addr64); 1085 } 1086 1087 /* ARGSUSED */ 1088 int 1089 nxge_mmac_stat_update(kstat_t *ksp, int rw) 1090 { 1091 p_nxge_t nxgep; 1092 p_nxge_mmac_kstat_t mmac_kstatsp; 1093 p_nxge_mmac_stats_t statsp; 1094 1095 nxgep = (p_nxge_t)ksp->ks_private; 1096 if (nxgep == NULL) 1097 return (-1); 1098 1099 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_mmac_stat_update")); 1100 1101 mmac_kstatsp = (p_nxge_mmac_kstat_t)ksp->ks_data; 1102 statsp = (p_nxge_mmac_stats_t)&nxgep->statsp->mmac_stats; 1103 1104 if (rw == KSTAT_WRITE) { 1105 cmn_err(CE_WARN, "Can not write mmac stats"); 1106 } else { 1107 mmac_kstatsp->mmac_max_addr_cnt.value.ul = 1108 statsp->mmac_max_cnt; 1109 mmac_kstatsp->mmac_avail_addr_cnt.value.ul = 1110 statsp->mmac_avail_cnt; 1111 mmac_kstatsp->mmac_addr1.value.ul = 1112 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[0]); 1113 mmac_kstatsp->mmac_addr2.value.ul = 1114 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[1]); 1115 mmac_kstatsp->mmac_addr3.value.ul = 1116 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[2]); 1117 mmac_kstatsp->mmac_addr4.value.ul = 1118 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[3]); 1119 mmac_kstatsp->mmac_addr5.value.ul = 1120 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[4]); 1121 mmac_kstatsp->mmac_addr6.value.ul = 1122 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[5]); 1123 mmac_kstatsp->mmac_addr7.value.ul = 1124 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[6]); 1125 mmac_kstatsp->mmac_addr8.value.ul = 1126 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[7]); 1127 mmac_kstatsp->mmac_addr9.value.ul = 1128 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[8]); 1129 mmac_kstatsp->mmac_addr10.value.ul = 1130 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[9]); 1131 mmac_kstatsp->mmac_addr11.value.ul = 1132 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[10]); 1133 mmac_kstatsp->mmac_addr12.value.ul = 1134 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[11]); 1135 mmac_kstatsp->mmac_addr13.value.ul = 1136 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[12]); 1137 mmac_kstatsp->mmac_addr14.value.ul = 1138 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[13]); 1139 mmac_kstatsp->mmac_addr15.value.ul = 1140 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[14]); 1141 mmac_kstatsp->mmac_addr16.value.ul = 1142 nxge_mac_octet_to_u64(statsp->mmac_avail_pool[15]); 1143 } 1144 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_mmac_stat_update")); 1145 return (0); 1146 } 1147 1148 /* ARGSUSED */ 1149 static kstat_t * 1150 nxge_setup_local_kstat(p_nxge_t nxgep, int instance, char *name, 1151 const nxge_kstat_index_t *ksip, size_t count, 1152 int (*update) (kstat_t *, int)) 1153 { 1154 kstat_t *ksp; 1155 kstat_named_t *knp; 1156 int i; 1157 1158 ksp = kstat_create(NXGE_DRIVER_NAME, instance, name, "net", 1159 KSTAT_TYPE_NAMED, count, 0); 1160 if (ksp == NULL) 1161 return (NULL); 1162 1163 ksp->ks_private = (void *)nxgep; 1164 ksp->ks_update = update; 1165 knp = ksp->ks_data; 1166 1167 for (i = 0; ksip[i].name != NULL; i++) { 1168 kstat_named_init(&knp[i], ksip[i].name, ksip[i].type); 1169 } 1170 1171 kstat_install(ksp); 1172 return (ksp); 1173 } 1174 1175 /* ARGSUSED */ 1176 void 1177 nxge_setup_kstats(p_nxge_t nxgep) 1178 { 1179 struct kstat *ksp; 1180 p_nxge_port_kstat_t nxgekp; 1181 size_t nxge_kstat_sz; 1182 char stat_name[64]; 1183 char mmac_name[64]; 1184 int i; 1185 1186 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_setup_kstats")); 1187 1188 1189 /* Setup RDC statistics */ 1190 for (i = 0; i < nxgep->nrdc; i++) { 1191 (void) sprintf(stat_name, "%s" CH_NAME_FORMAT, 1192 RDC_NAME_FORMAT1, i); 1193 nxgep->statsp->rdc_ksp[i] = nxge_setup_local_kstat(nxgep, 1194 nxgep->instance, stat_name, 1195 &nxge_rdc_stats[0], RDC_STAT_END, nxge_rdc_stat_update); 1196 #ifdef NXGE_DEBUG_ERROR 1197 if (nxgep->statsp->rdc_ksp[i] == NULL) 1198 NXGE_DEBUG_MSG((nxgep, KST_CTL, 1199 "kstat_create failed for rdc channel %d", i)); 1200 #endif 1201 } 1202 1203 /* Setup RDC System statistics */ 1204 nxgep->statsp->rdc_sys_ksp = nxge_setup_local_kstat(nxgep, 1205 nxgep->instance, 1206 "RDC System Stats", 1207 &nxge_rdc_sys_stats[0], 1208 RDC_SYS_STAT_END, 1209 nxge_rdc_sys_stat_update); 1210 1211 /* Setup IPP statistics */ 1212 nxgep->statsp->ipp_ksp = nxge_setup_local_kstat(nxgep, 1213 nxgep->instance, 1214 "IPP Stats", 1215 &nxge_ipp_stats[0], 1216 IPP_STAT_END, 1217 nxge_ipp_stat_update); 1218 #ifdef NXGE_DEBUG_ERROR 1219 if (nxgep->istatsp->pp_ksp == NULL) 1220 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for ipp")); 1221 #endif 1222 1223 /* Setup TDC statistics */ 1224 for (i = 0; i < nxgep->ntdc; i++) { 1225 (void) sprintf(stat_name, "%s" CH_NAME_FORMAT, 1226 TDC_NAME_FORMAT1, i); 1227 nxgep->statsp->tdc_ksp[i] = nxge_setup_local_kstat(nxgep, 1228 nxgep->instance, 1229 stat_name, 1230 &nxge_tdc_stats[0], 1231 TDC_STAT_END, 1232 nxge_tdc_stat_update); 1233 #ifdef NXGE_DEBUG_ERROR 1234 if (nxgep->statsp->tdc_ksp[i] == NULL) { 1235 NXGE_DEBUG_MSG((nxgep, KST_CTL, 1236 "kstat_create failed for tdc channel %d", i)); 1237 } 1238 #endif 1239 } 1240 1241 /* Setup TXC statistics */ 1242 nxgep->statsp->txc_ksp = nxge_setup_local_kstat(nxgep, 1243 nxgep->instance, "TXC Stats", &nxge_txc_stats[0], 1244 TXC_STAT_END, nxge_txc_stat_update); 1245 #ifdef NXGE_DEBUG_ERROR 1246 if (nxgep->statsp->txc_ksp == NULL) 1247 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for txc")); 1248 #endif 1249 1250 /* Setup ZCP statistics */ 1251 nxgep->statsp->zcp_ksp = nxge_setup_local_kstat(nxgep, 1252 nxgep->instance, "ZCP Stats", &nxge_zcp_stats[0], 1253 ZCP_STAT_END, nxge_zcp_stat_update); 1254 #ifdef NXGE_DEBUG_ERROR 1255 if (nxgep->statsp->zcp_ksp == NULL) 1256 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed for zcp")); 1257 #endif 1258 1259 /* Setup FFLP statistics */ 1260 nxgep->statsp->fflp_ksp[0] = nxge_setup_local_kstat(nxgep, 1261 nxgep->instance, "FFLP Stats", &nxge_fflp_stats[0], 1262 FFLP_STAT_END, nxge_fflp_stat_update); 1263 1264 #ifdef NXGE_DEBUG_ERROR 1265 if (nxgep->statsp->fflp_ksp == NULL) 1266 NXGE_DEBUG_MSG((nxgep, KST_CTL, 1267 "kstat_create failed for fflp")); 1268 #endif 1269 1270 (void) sprintf(mmac_name, "MMAC Stats%d", nxgep->instance); 1271 nxgep->statsp->mmac_ksp = nxge_setup_local_kstat(nxgep, 1272 nxgep->instance, "MMAC Stats", &nxge_mmac_stats[0], 1273 MMAC_STATS_END, nxge_mmac_stat_update); 1274 1275 nxge_kstat_sz = sizeof (nxge_port_kstat_t) + 1276 sizeof (nxge_mac_kstat_t) - sizeof (kstat_named_t); 1277 1278 if ((ksp = kstat_create(NXGE_DRIVER_NAME, nxgep->instance, 1279 "Port Stats", "net", KSTAT_TYPE_NAMED, 1280 nxge_kstat_sz / sizeof (kstat_named_t), 0)) == NULL) { 1281 NXGE_DEBUG_MSG((nxgep, KST_CTL, "kstat_create failed")); 1282 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats")); 1283 return; 1284 } 1285 1286 /* 1287 * kstats 1288 */ 1289 nxgekp = (p_nxge_port_kstat_t)ksp->ks_data; 1290 1291 /* 1292 * transceiver state informations. 1293 */ 1294 kstat_named_init(&nxgekp->xcvr_inits, "xcvr_inits", 1295 KSTAT_DATA_ULONG); 1296 kstat_named_init(&nxgekp->xcvr_inuse, "xcvr_inuse", 1297 KSTAT_DATA_ULONG); 1298 kstat_named_init(&nxgekp->xcvr_addr, "xcvr_addr", 1299 KSTAT_DATA_ULONG); 1300 kstat_named_init(&nxgekp->xcvr_id, "xcvr_id", 1301 KSTAT_DATA_ULONG); 1302 kstat_named_init(&nxgekp->cap_autoneg, "cap_autoneg", 1303 KSTAT_DATA_ULONG); 1304 kstat_named_init(&nxgekp->cap_10gfdx, "cap_10gfdx", 1305 KSTAT_DATA_ULONG); 1306 kstat_named_init(&nxgekp->cap_10ghdx, "cap_10ghdx", 1307 KSTAT_DATA_ULONG); 1308 kstat_named_init(&nxgekp->cap_1000fdx, "cap_1000fdx", 1309 KSTAT_DATA_ULONG); 1310 kstat_named_init(&nxgekp->cap_1000hdx, "cap_1000hdx", 1311 KSTAT_DATA_ULONG); 1312 kstat_named_init(&nxgekp->cap_100T4, "cap_100T4", 1313 KSTAT_DATA_ULONG); 1314 kstat_named_init(&nxgekp->cap_100fdx, "cap_100fdx", 1315 KSTAT_DATA_ULONG); 1316 kstat_named_init(&nxgekp->cap_100hdx, "cap_100hdx", 1317 KSTAT_DATA_ULONG); 1318 kstat_named_init(&nxgekp->cap_10fdx, "cap_10fdx", 1319 KSTAT_DATA_ULONG); 1320 kstat_named_init(&nxgekp->cap_10hdx, "cap_10hdx", 1321 KSTAT_DATA_ULONG); 1322 kstat_named_init(&nxgekp->cap_asmpause, "cap_asmpause", 1323 KSTAT_DATA_ULONG); 1324 kstat_named_init(&nxgekp->cap_pause, "cap_pause", 1325 KSTAT_DATA_ULONG); 1326 1327 /* 1328 * Link partner capabilities. 1329 */ 1330 kstat_named_init(&nxgekp->lp_cap_autoneg, "lp_cap_autoneg", 1331 KSTAT_DATA_ULONG); 1332 kstat_named_init(&nxgekp->lp_cap_10gfdx, "lp_cap_10gfdx", 1333 KSTAT_DATA_ULONG); 1334 kstat_named_init(&nxgekp->lp_cap_10ghdx, "lp_cap_10ghdx", 1335 KSTAT_DATA_ULONG); 1336 kstat_named_init(&nxgekp->lp_cap_1000fdx, "lp_cap_1000fdx", 1337 KSTAT_DATA_ULONG); 1338 kstat_named_init(&nxgekp->lp_cap_1000hdx, "lp_cap_1000hdx", 1339 KSTAT_DATA_ULONG); 1340 kstat_named_init(&nxgekp->lp_cap_100T4, "lp_cap_100T4", 1341 KSTAT_DATA_ULONG); 1342 kstat_named_init(&nxgekp->lp_cap_100fdx, "lp_cap_100fdx", 1343 KSTAT_DATA_ULONG); 1344 kstat_named_init(&nxgekp->lp_cap_100hdx, "lp_cap_100hdx", 1345 KSTAT_DATA_ULONG); 1346 kstat_named_init(&nxgekp->lp_cap_10fdx, "lp_cap_10fdx", 1347 KSTAT_DATA_ULONG); 1348 kstat_named_init(&nxgekp->lp_cap_10hdx, "lp_cap_10hdx", 1349 KSTAT_DATA_ULONG); 1350 kstat_named_init(&nxgekp->lp_cap_asmpause, "lp_cap_asmpause", 1351 KSTAT_DATA_ULONG); 1352 kstat_named_init(&nxgekp->lp_cap_pause, "lp_cap_pause", 1353 KSTAT_DATA_ULONG); 1354 /* 1355 * Shared link setup. 1356 */ 1357 kstat_named_init(&nxgekp->link_T4, "link_T4", 1358 KSTAT_DATA_ULONG); 1359 kstat_named_init(&nxgekp->link_speed, "link_speed", 1360 KSTAT_DATA_ULONG); 1361 kstat_named_init(&nxgekp->link_duplex, "link_duplex", 1362 KSTAT_DATA_CHAR); 1363 kstat_named_init(&nxgekp->link_asmpause, "link_asmpause", 1364 KSTAT_DATA_ULONG); 1365 kstat_named_init(&nxgekp->link_pause, "link_pause", 1366 KSTAT_DATA_ULONG); 1367 kstat_named_init(&nxgekp->link_up, "link_up", 1368 KSTAT_DATA_ULONG); 1369 1370 /* 1371 * Let the user know the MTU currently in use by the physical MAC 1372 * port. 1373 */ 1374 kstat_named_init(&nxgekp->mac_mtu, "mac_mtu", 1375 KSTAT_DATA_ULONG); 1376 1377 /* 1378 * Loopback statistics. 1379 */ 1380 kstat_named_init(&nxgekp->lb_mode, "lb_mode", 1381 KSTAT_DATA_ULONG); 1382 1383 /* 1384 * This tells the user whether the driver is in QOS mode or not. 1385 */ 1386 kstat_named_init(&nxgekp->qos_mode, "qos_mode", 1387 KSTAT_DATA_ULONG); 1388 1389 /* 1390 * This tells whether the instance is trunked or not 1391 */ 1392 kstat_named_init(&nxgekp->trunk_mode, "trunk_mode", 1393 KSTAT_DATA_ULONG); 1394 1395 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2 1396 kstat_named_init(&nxgekp->mdt_reqs, "mdt_reqs", 1397 KSTAT_DATA_ULONG); 1398 kstat_named_init(&nxgekp->mdt_hdr_bufs, "mdt_hdr_bufs", 1399 KSTAT_DATA_ULONG); 1400 kstat_named_init(&nxgekp->mdt_pld_bufs, "mdt_pld_bufs", 1401 KSTAT_DATA_ULONG); 1402 kstat_named_init(&nxgekp->mdt_pkts, "mdt_pkts", 1403 KSTAT_DATA_ULONG); 1404 kstat_named_init(&nxgekp->mdt_hdrs, "mdt_hdrs", 1405 KSTAT_DATA_ULONG); 1406 kstat_named_init(&nxgekp->mdt_plds, "mdt_plds", 1407 KSTAT_DATA_ULONG); 1408 kstat_named_init(&nxgekp->mdt_hdr_bind_fail, "mdt_hdr_bind_fail", 1409 KSTAT_DATA_ULONG); 1410 kstat_named_init(&nxgekp->mdt_pld_bind_fail, "mdt_pld_bind_fail", 1411 KSTAT_DATA_ULONG); 1412 #endif 1413 #ifdef ACNXGEPT_JUMBO 1414 kstat_named_init(&nxgekp->tx_jumbo_pkts, "tx_jumbo_pkts", 1415 KSTAT_DATA_ULONG); 1416 #endif 1417 1418 /* 1419 * Rx Statistics. 1420 */ 1421 #ifdef ACNXGEPT_JUMBO 1422 kstat_named_init(&nxgekp->rx_jumbo_pkts, "rx_jumbo_pkts", 1423 KSTAT_DATA_ULONG); 1424 #endif 1425 /* General MAC statistics */ 1426 kstat_named_init(&nxgekp->ifspeed, "ifspeed", 1427 KSTAT_DATA_UINT64); 1428 kstat_named_init(&nxgekp->promisc, "promisc", 1429 KSTAT_DATA_CHAR); 1430 kstat_named_init(&nxgekp->rev_id, "rev_id", 1431 KSTAT_DATA_ULONG); 1432 1433 ksp->ks_update = nxge_port_kstat_update; 1434 ksp->ks_private = (void *) nxgep; 1435 if (nxgep->mac.porttype == PORT_TYPE_XMAC) 1436 nxge_xmac_init_kstats(ksp); 1437 else 1438 nxge_bmac_init_kstats(ksp); 1439 kstat_install(ksp); 1440 nxgep->statsp->port_ksp = ksp; 1441 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_setup_kstats")); 1442 } 1443 1444 /* ARGSUSED */ 1445 void 1446 nxge_xmac_init_kstats(struct kstat *ksp) 1447 { 1448 p_nxge_xmac_kstat_t nxgekp; 1449 1450 nxgekp = (p_nxge_xmac_kstat_t)ksp->ks_data; 1451 1452 /* 1453 * Transmit MAC statistics. 1454 */ 1455 kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt", 1456 KSTAT_DATA_ULONG); 1457 kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err", 1458 KSTAT_DATA_ULONG); 1459 kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err", 1460 KSTAT_DATA_ULONG); 1461 kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err", 1462 KSTAT_DATA_ULONG); 1463 kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err", 1464 KSTAT_DATA_ULONG); 1465 kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt", 1466 KSTAT_DATA_ULONG); 1467 1468 /* Receive MAC statistics */ 1469 kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err", 1470 KSTAT_DATA_ULONG); 1471 kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err", 1472 KSTAT_DATA_ULONG); 1473 kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err", 1474 KSTAT_DATA_ULONG); 1475 kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err", 1476 KSTAT_DATA_ULONG); 1477 kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations", 1478 KSTAT_DATA_ULONG); 1479 kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt", 1480 KSTAT_DATA_ULONG); 1481 kstat_named_init(&nxgekp->rx_frame_align_err_cnt, 1482 "rxmac_alignment_err", 1483 KSTAT_DATA_ULONG); 1484 kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt", 1485 KSTAT_DATA_ULONG); 1486 kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt", 1487 KSTAT_DATA_ULONG); 1488 kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt", 1489 KSTAT_DATA_ULONG); 1490 kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt", 1491 KSTAT_DATA_ULONG); 1492 kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt", 1493 KSTAT_DATA_ULONG); 1494 kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt", 1495 KSTAT_DATA_ULONG); 1496 kstat_named_init(&nxgekp->rx_broadcast_cnt, "rxmac_broadcast_cnt", 1497 KSTAT_DATA_ULONG); 1498 kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt", 1499 KSTAT_DATA_ULONG); 1500 kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt", 1501 KSTAT_DATA_ULONG); 1502 kstat_named_init(&nxgekp->rx_linkfault_err_cnt, "rxmac_linkfault_errs", 1503 KSTAT_DATA_ULONG); 1504 kstat_named_init(&nxgekp->rx_remote_fault_err_cnt, 1505 "rxmac_remote_faults", 1506 KSTAT_DATA_ULONG); 1507 kstat_named_init(&nxgekp->rx_local_fault_err_cnt, "rxmac_local_faults", 1508 KSTAT_DATA_ULONG); 1509 1510 /* XPCS statistics */ 1511 1512 kstat_named_init(&nxgekp->xpcs_deskew_err_cnt, "xpcs_deskew_err_cnt", 1513 KSTAT_DATA_ULONG); 1514 #ifdef NXGE_DEBUG_SYMBOL_ERR 1515 kstat_named_init(&nxgekp->xpcs_ln0_symbol_err_cnt, 1516 "xpcs_ln0_symbol_err_cnt", 1517 KSTAT_DATA_ULONG); 1518 kstat_named_init(&nxgekp->xpcs_ln1_symbol_err_cnt, 1519 "xpcs_ln1_symbol_err_cnt", 1520 KSTAT_DATA_ULONG); 1521 kstat_named_init(&nxgekp->xpcs_ln2_symbol_err_cnt, 1522 "xpcs_ln2_symbol_err_cnt", 1523 KSTAT_DATA_ULONG); 1524 kstat_named_init(&nxgekp->xpcs_ln3_symbol_err_cnt, 1525 "xpcs_ln3_symbol_err_cnt", 1526 KSTAT_DATA_ULONG); 1527 #endif 1528 } 1529 1530 /* ARGSUSED */ 1531 void 1532 nxge_bmac_init_kstats(struct kstat *ksp) 1533 { 1534 p_nxge_bmac_kstat_t nxgekp; 1535 1536 nxgekp = (p_nxge_bmac_kstat_t)ksp->ks_data; 1537 1538 /* 1539 * Transmit MAC statistics. 1540 */ 1541 kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt", 1542 KSTAT_DATA_ULONG); 1543 kstat_named_init(&nxgekp->tx_underrun_err, "txmac_underflow_err", 1544 KSTAT_DATA_ULONG); 1545 kstat_named_init(&nxgekp->tx_max_pkt_err, "txmac_maxpktsize_err", 1546 KSTAT_DATA_ULONG); 1547 kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt", 1548 KSTAT_DATA_ULONG); 1549 1550 /* Receive MAC statistics */ 1551 kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err", 1552 KSTAT_DATA_ULONG); 1553 kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err", 1554 KSTAT_DATA_ULONG); 1555 kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err", 1556 KSTAT_DATA_ULONG); 1557 kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations", 1558 KSTAT_DATA_ULONG); 1559 kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt", 1560 KSTAT_DATA_ULONG); 1561 kstat_named_init(&nxgekp->rx_align_err_cnt, "rxmac_alignment_err", 1562 KSTAT_DATA_ULONG); 1563 kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt", 1564 KSTAT_DATA_ULONG); 1565 } 1566 1567 /* ARGSUSED */ 1568 void 1569 nxge_mac_init_kstats(p_nxge_t nxgep, struct kstat *ksp) 1570 { 1571 p_nxge_mac_kstat_t nxgekp; 1572 1573 nxgekp = (p_nxge_mac_kstat_t)ksp->ks_data; 1574 1575 /* 1576 * Transmit MAC statistics. 1577 */ 1578 kstat_named_init(&nxgekp->tx_frame_cnt, "txmac_frame_cnt", 1579 KSTAT_DATA_ULONG); 1580 kstat_named_init(&nxgekp->tx_underflow_err, "txmac_underflow_err", 1581 KSTAT_DATA_ULONG); 1582 kstat_named_init(&nxgekp->tx_overflow_err, "txmac_overflow_err", 1583 KSTAT_DATA_ULONG); 1584 kstat_named_init(&nxgekp->tx_maxpktsize_err, "txmac_maxpktsize_err", 1585 KSTAT_DATA_ULONG); 1586 kstat_named_init(&nxgekp->tx_fifo_xfr_err, "txmac_fifo_xfr_err", 1587 KSTAT_DATA_ULONG); 1588 kstat_named_init(&nxgekp->tx_byte_cnt, "txmac_byte_cnt", 1589 KSTAT_DATA_ULONG); 1590 1591 /* 1592 * Receive MAC statistics 1593 */ 1594 kstat_named_init(&nxgekp->rx_overflow_err, "rxmac_overflow_err", 1595 KSTAT_DATA_ULONG); 1596 kstat_named_init(&nxgekp->rx_underflow_err, "rxmac_underflow_err", 1597 KSTAT_DATA_ULONG); 1598 kstat_named_init(&nxgekp->rx_crc_err_cnt, "rxmac_crc_err", 1599 KSTAT_DATA_ULONG); 1600 kstat_named_init(&nxgekp->rx_len_err_cnt, "rxmac_length_err", 1601 KSTAT_DATA_ULONG); 1602 kstat_named_init(&nxgekp->rx_viol_err_cnt, "rxmac_code_violations", 1603 KSTAT_DATA_ULONG); 1604 kstat_named_init(&nxgekp->rx_byte_cnt, "rxmac_byte_cnt", 1605 KSTAT_DATA_ULONG); 1606 kstat_named_init(&nxgekp->rx_frame_align_err_cnt, 1607 "rxmac_alignment_err", 1608 KSTAT_DATA_ULONG); 1609 if (nxgep->mac.porttype == PORT_TYPE_XMAC) { 1610 kstat_named_init(&nxgekp->rx_hist1_cnt, "rxmac_64_cnt", 1611 KSTAT_DATA_ULONG); 1612 kstat_named_init(&nxgekp->rx_hist2_cnt, "rxmac_65_127_cnt", 1613 KSTAT_DATA_ULONG); 1614 kstat_named_init(&nxgekp->rx_hist3_cnt, "rxmac_128_255_cnt", 1615 KSTAT_DATA_ULONG); 1616 kstat_named_init(&nxgekp->rx_hist4_cnt, "rxmac_256_511_cnt", 1617 KSTAT_DATA_ULONG); 1618 kstat_named_init(&nxgekp->rx_hist5_cnt, "rxmac_512_1023_cnt", 1619 KSTAT_DATA_ULONG); 1620 kstat_named_init(&nxgekp->rx_hist6_cnt, "rxmac_1024_1522_cnt", 1621 KSTAT_DATA_ULONG); 1622 kstat_named_init(&nxgekp->rx_broadcast_cnt, 1623 "rxmac_broadcast_cnt", 1624 KSTAT_DATA_ULONG); 1625 kstat_named_init(&nxgekp->rx_mult_cnt, "rxmac_multicast_cnt", 1626 KSTAT_DATA_ULONG); 1627 kstat_named_init(&nxgekp->rx_frag_cnt, "rxmac_fragment_cnt", 1628 KSTAT_DATA_ULONG); 1629 kstat_named_init(&nxgekp->rx_linkfault_err_cnt, 1630 "rxmac_linkfault_errs", 1631 KSTAT_DATA_ULONG); 1632 kstat_named_init(&nxgekp->rx_remote_fault_err_cnt, 1633 "rxmac_remote_faults", 1634 KSTAT_DATA_ULONG); 1635 kstat_named_init(&nxgekp->rx_local_fault_err_cnt, 1636 "rxmac_local_faults", 1637 KSTAT_DATA_ULONG); 1638 } else if (nxgep->mac.porttype == PORT_TYPE_BMAC) { 1639 kstat_named_init(&nxgekp->rx_frame_cnt, "rxmac_frame_cnt", 1640 KSTAT_DATA_ULONG); 1641 } 1642 } 1643 1644 /* ARGSUSED */ 1645 void 1646 nxge_destroy_kstats(p_nxge_t nxgep) 1647 { 1648 int channel; 1649 p_nxge_dma_pt_cfg_t p_dma_cfgp; 1650 p_nxge_hw_pt_cfg_t p_cfgp; 1651 1652 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_destroy_kstats")); 1653 1654 if (nxgep->statsp == NULL) 1655 return; 1656 if (nxgep->statsp->ksp) 1657 kstat_delete(nxgep->statsp->ksp); 1658 1659 p_dma_cfgp = (p_nxge_dma_pt_cfg_t)&nxgep->pt_config; 1660 p_cfgp = (p_nxge_hw_pt_cfg_t)&p_dma_cfgp->hw_config; 1661 1662 for (channel = 0; channel < p_cfgp->max_rdcs; channel++) { 1663 if (nxgep->statsp->rdc_ksp[channel]) 1664 kstat_delete(nxgep->statsp->rdc_ksp[channel]); 1665 } 1666 1667 for (channel = 0; channel < p_cfgp->max_tdcs; channel++) { 1668 if (nxgep->statsp->tdc_ksp[channel]) 1669 kstat_delete(nxgep->statsp->tdc_ksp[channel]); 1670 } 1671 1672 if (nxgep->statsp->rdc_sys_ksp) 1673 kstat_delete(nxgep->statsp->rdc_sys_ksp); 1674 if (nxgep->statsp->fflp_ksp[0]) 1675 kstat_delete(nxgep->statsp->fflp_ksp[0]); 1676 if (nxgep->statsp->ipp_ksp) 1677 kstat_delete(nxgep->statsp->ipp_ksp); 1678 if (nxgep->statsp->txc_ksp) 1679 kstat_delete(nxgep->statsp->txc_ksp); 1680 if (nxgep->statsp->mac_ksp) 1681 kstat_delete(nxgep->statsp->mac_ksp); 1682 if (nxgep->statsp->zcp_ksp) 1683 kstat_delete(nxgep->statsp->zcp_ksp); 1684 if (nxgep->statsp->port_ksp) 1685 kstat_delete(nxgep->statsp->port_ksp); 1686 if (nxgep->statsp->mmac_ksp) 1687 kstat_delete(nxgep->statsp->mmac_ksp); 1688 if (nxgep->statsp) 1689 KMEM_FREE(nxgep->statsp, nxgep->statsp->stats_size); 1690 1691 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_destroy_kstats")); 1692 } 1693 1694 /* ARGSUSED */ 1695 int 1696 nxge_port_kstat_update(kstat_t *ksp, int rw) 1697 { 1698 p_nxge_t nxgep; 1699 p_nxge_stats_t statsp; 1700 p_nxge_port_kstat_t nxgekp; 1701 1702 nxgep = (p_nxge_t)ksp->ks_private; 1703 if (nxgep == NULL) 1704 return (-1); 1705 1706 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_port_kstat_update")); 1707 statsp = (p_nxge_stats_t)nxgep->statsp; 1708 nxgekp = (p_nxge_port_kstat_t)ksp->ks_data; 1709 nxge_save_cntrs(nxgep); 1710 1711 if (rw == KSTAT_WRITE) { 1712 /* 1713 * transceiver state informations. 1714 */ 1715 statsp->mac_stats.xcvr_inits = nxgekp->xcvr_inits.value.ul; 1716 1717 /* 1718 * Tx Statistics. 1719 */ 1720 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2 1721 statsp->port_stats.mdt_reqs = nxgekp->mdt_reqs.value.ul; 1722 statsp->port_stats.mdt_hdr_bufs = nxgekp->mdt_hdr_bufs.value.ul; 1723 statsp->port_stats.mdt_pld_bufs = nxgekp->mdt_pld_bufs.value.ul; 1724 statsp->port_stats.mdt_pkts = nxgekp->mdt_pkts.value.ul; 1725 statsp->port_stats.mdt_hdrs = nxgekp->mdt_hdrs.value.ul; 1726 statsp->port_stats.mdt_plds = nxgekp->mdt_plds.value.ul; 1727 statsp->port_stats.mdt_hdr_bind_fail = 1728 nxgekp->mdt_hdr_bind_fail.value.ul; 1729 statsp->port_stats.mdt_pld_bind_fail = 1730 nxgekp->mdt_pld_bind_fail.value.ul; 1731 #endif 1732 #ifdef ACCEPT_JUMBO 1733 statsp->port_stats.tx_jumbo_pkts = 1734 nxgekp->tx_jumbo_pkts.value.ul; 1735 #endif 1736 /* 1737 * Rx Statistics. 1738 */ 1739 #ifdef ACNXGEPT_JUMBO 1740 statsp->port_stats.rx_jumbo_pkts = 1741 nxgekp->rx_jumbo_pkts.value.ul; 1742 #endif 1743 (void) nxge_xmac_stat_update(ksp, KSTAT_WRITE); 1744 return (0); 1745 } else { 1746 if (nxgep->filter.all_phys_cnt) 1747 (void) strcpy(nxgekp->promisc.value.c, "phys"); 1748 else if (nxgep->filter.all_multicast_cnt) 1749 (void) strcpy(nxgekp->promisc.value.c, "multi"); 1750 else 1751 (void) strcpy(nxgekp->promisc.value.c, "off"); 1752 nxgekp->ifspeed.value.ul = 1753 statsp->mac_stats.link_speed * 1000000ULL; 1754 nxgekp->rev_id.value.ul = statsp->mac_stats.rev_id; 1755 1756 /* 1757 * transceiver state informations. 1758 */ 1759 nxgekp->xcvr_inits.value.ul = statsp->mac_stats.xcvr_inits; 1760 nxgekp->xcvr_inuse.value.ul = statsp->mac_stats.xcvr_inuse; 1761 nxgekp->xcvr_addr.value.ul = statsp->mac_stats.xcvr_portn; 1762 nxgekp->xcvr_id.value.ul = statsp->mac_stats.xcvr_id; 1763 nxgekp->cap_autoneg.value.ul = statsp->mac_stats.cap_autoneg; 1764 nxgekp->cap_10gfdx.value.ul = statsp->mac_stats.cap_10gfdx; 1765 nxgekp->cap_10ghdx.value.ul = statsp->mac_stats.cap_10ghdx; 1766 nxgekp->cap_1000fdx.value.ul = statsp->mac_stats.cap_1000fdx; 1767 nxgekp->cap_1000hdx.value.ul = statsp->mac_stats.cap_1000hdx; 1768 nxgekp->cap_100T4.value.ul = statsp->mac_stats.cap_100T4; 1769 nxgekp->cap_100fdx.value.ul = statsp->mac_stats.cap_100fdx; 1770 nxgekp->cap_100hdx.value.ul = statsp->mac_stats.cap_100hdx; 1771 nxgekp->cap_10fdx.value.ul = statsp->mac_stats.cap_10fdx; 1772 nxgekp->cap_10hdx.value.ul = statsp->mac_stats.cap_10hdx; 1773 nxgekp->cap_asmpause.value.ul = 1774 statsp->mac_stats.cap_asmpause; 1775 nxgekp->cap_pause.value.ul = statsp->mac_stats.cap_pause; 1776 1777 /* 1778 * Link partner capabilities. 1779 */ 1780 nxgekp->lp_cap_autoneg.value.ul = 1781 statsp->mac_stats.lp_cap_autoneg; 1782 nxgekp->lp_cap_10gfdx.value.ul = 1783 statsp->mac_stats.lp_cap_10gfdx; 1784 nxgekp->lp_cap_10ghdx.value.ul = 1785 statsp->mac_stats.lp_cap_10ghdx; 1786 nxgekp->lp_cap_1000fdx.value.ul = 1787 statsp->mac_stats.lp_cap_1000fdx; 1788 nxgekp->lp_cap_1000hdx.value.ul = 1789 statsp->mac_stats.lp_cap_1000hdx; 1790 nxgekp->lp_cap_100T4.value.ul = 1791 statsp->mac_stats.lp_cap_100T4; 1792 nxgekp->lp_cap_100fdx.value.ul = 1793 statsp->mac_stats.lp_cap_100fdx; 1794 nxgekp->lp_cap_100hdx.value.ul = 1795 statsp->mac_stats.lp_cap_100hdx; 1796 nxgekp->lp_cap_10fdx.value.ul = 1797 statsp->mac_stats.lp_cap_10fdx; 1798 nxgekp->lp_cap_10hdx.value.ul = 1799 statsp->mac_stats.lp_cap_10hdx; 1800 nxgekp->lp_cap_asmpause.value.ul = 1801 statsp->mac_stats.lp_cap_asmpause; 1802 nxgekp->lp_cap_pause.value.ul = 1803 statsp->mac_stats.lp_cap_pause; 1804 1805 /* 1806 * Physical link statistics. 1807 */ 1808 nxgekp->link_T4.value.ul = statsp->mac_stats.link_T4; 1809 nxgekp->link_speed.value.ul = statsp->mac_stats.link_speed; 1810 if (statsp->mac_stats.link_duplex == 2) 1811 (void) strcpy(nxgekp->link_duplex.value.c, "full"); 1812 else if (statsp->mac_stats.link_duplex == 1) 1813 (void) strcpy(nxgekp->link_duplex.value.c, "half"); 1814 else 1815 (void) strcpy(nxgekp->link_duplex.value.c, "unknown"); 1816 nxgekp->link_asmpause.value.ul = 1817 statsp->mac_stats.link_asmpause; 1818 nxgekp->link_pause.value.ul = statsp->mac_stats.link_pause; 1819 nxgekp->link_up.value.ul = statsp->mac_stats.link_up; 1820 1821 /* 1822 * Lets the user know the MTU currently in use by the physical 1823 * MAC port. 1824 */ 1825 nxgekp->mac_mtu.value.ul = statsp->mac_stats.mac_mtu; 1826 1827 /* 1828 * Loopback statistics. 1829 */ 1830 nxgekp->lb_mode.value.ul = statsp->port_stats.lb_mode; 1831 1832 /* 1833 * This tells the user whether the driver is in QOS mode or 1834 * not. 1835 */ 1836 nxgekp->qos_mode.value.ul = statsp->port_stats.qos_mode; 1837 1838 /* 1839 * This tells whether the instance is trunked or not 1840 */ 1841 nxgekp->trunk_mode.value.ul = statsp->port_stats.trunk_mode; 1842 1843 #if defined MULTI_DATA_TX || defined MULTI_DATA_TXV2 1844 nxgekp->mdt_reqs.value.ul = statsp->port_stats.mdt_reqs; 1845 nxgekp->mdt_hdr_bufs.value.ul = 1846 statsp->port_stats.mdt_hdr_bufs; 1847 nxgekp->mdt_pld_bufs.value.ul = 1848 statsp->port_stats.mdt_pld_bufs; 1849 nxgekp->mdt_pkts.value.ul = statsp->port_stats.mdt_pkts; 1850 nxgekp->mdt_hdrs.value.ul = statsp->port_stats.mdt_hdrs; 1851 nxgekp->mdt_plds.value.ul = statsp->port_stats.mdt_plds; 1852 nxgekp->mdt_hdr_bind_fail.value.ul = 1853 statsp->port_stats.mdt_hdr_bind_fail; 1854 nxgekp->mdt_pld_bind_fail.value.ul = 1855 statsp->port_stats.mdt_pld_bind_fail; 1856 #endif 1857 #ifdef ACCEPT_JUMBO 1858 nxgekp->tx_jumbo_pkts.value.ul = 1859 statsp->port_stats.tx_jumbo_pkts; 1860 #endif 1861 #ifdef TX_MBLK_DEST 1862 nxgekp->tx_1_desc.value.ul = statsp->port_stats.tx_1_desc; 1863 nxgekp->tx_2_desc.value.ul = statsp->port_stats.tx_2_desc; 1864 nxgekp->tx_3_desc.value.ul = statsp->port_stats.tx_3_desc; 1865 nxgekp->tx_4_desc.value.ul = statsp->port_stats.tx_4_desc; 1866 nxgekp->tx_5_desc.value.ul = statsp->port_stats.tx_5_desc; 1867 nxgekp->tx_6_desc.value.ul = statsp->port_stats.tx_6_desc; 1868 nxgekp->tx_7_desc.value.ul = statsp->port_stats.tx_7_desc; 1869 nxgekp->tx_8_desc.value.ul = statsp->port_stats.tx_8_desc; 1870 nxgekp->tx_max_desc.value.ul = 1871 statsp->port_stats.tx_max_desc; 1872 #endif 1873 /* 1874 * Rx Statistics. 1875 */ 1876 #ifdef ACCEPT_JUMBO 1877 nxgekp->rx_jumbo_pkts.value.ul = 1878 statsp->port_stats.rx_jumbo_pkts; 1879 #endif 1880 (void) nxge_xmac_stat_update(ksp, KSTAT_READ); 1881 } 1882 1883 NXGE_DEBUG_MSG((nxgep, KST_CTL, "<== nxge_port_kstat_update")); 1884 return (0); 1885 } 1886 1887 /* 1888 * if this is the first init do not bother to save the 1889 * counters. 1890 */ 1891 /* ARGSUSED */ 1892 void 1893 nxge_save_cntrs(p_nxge_t nxgep) 1894 { 1895 p_nxge_stats_t statsp; 1896 uint64_t val; 1897 npi_handle_t handle; 1898 uint8_t portn; 1899 uint8_t cnt8; 1900 uint16_t cnt16; 1901 uint32_t cnt32; 1902 1903 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "==> nxge_save_cntrs")); 1904 1905 statsp = (p_nxge_stats_t)nxgep->statsp; 1906 handle = nxgep->npi_handle; 1907 portn = nxgep->mac.portnum; 1908 1909 MUTEX_ENTER(&nxgep->ouraddr_lock); 1910 1911 if (nxgep->mac.porttype == PORT_TYPE_XMAC) { 1912 /* 1913 * Transmit MAC statistics. 1914 */ 1915 XMAC_REG_RD(handle, portn, XTXMAC_FRM_CNT_REG, &val); 1916 statsp->xmac_stats.tx_frame_cnt += (val & XTXMAC_FRM_CNT_MASK); 1917 XMAC_REG_RD(handle, portn, XTXMAC_BYTE_CNT_REG, &val); 1918 statsp->xmac_stats.tx_byte_cnt += (val & XTXMAC_BYTE_CNT_MASK); 1919 /* 1920 * Receive XMAC statistics. 1921 */ 1922 XMAC_REG_RD(handle, portn, XRXMAC_CRC_ER_CNT_REG, &val); 1923 statsp->xmac_stats.rx_crc_err_cnt += 1924 (val & XRXMAC_CRC_ER_CNT_MASK); 1925 XMAC_REG_RD(handle, portn, XRXMAC_MPSZER_CNT_REG, &val); 1926 statsp->xmac_stats.rx_len_err_cnt += 1927 (val & XRXMAC_MPSZER_CNT_MASK); 1928 XMAC_REG_RD(handle, portn, XRXMAC_CD_VIO_CNT_REG, &val); 1929 statsp->xmac_stats.rx_viol_err_cnt += 1930 (val & XRXMAC_CD_VIO_CNT_MASK); 1931 XMAC_REG_RD(handle, portn, XRXMAC_BT_CNT_REG, &val); 1932 statsp->xmac_stats.rx_byte_cnt += (val & XRXMAC_BT_CNT_MASK); 1933 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT1_REG, &val); 1934 statsp->xmac_stats.rx_hist1_cnt += 1935 (val & XRXMAC_HIST_CNT1_MASK); 1936 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT2_REG, &val); 1937 statsp->xmac_stats.rx_hist2_cnt += 1938 (val & XRXMAC_HIST_CNT2_MASK); 1939 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT3_REG, &val); 1940 statsp->xmac_stats.rx_hist3_cnt += 1941 (val & XRXMAC_HIST_CNT3_MASK); 1942 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT4_REG, &val); 1943 statsp->xmac_stats.rx_hist4_cnt += 1944 (val & XRXMAC_HIST_CNT4_MASK); 1945 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT5_REG, &val); 1946 statsp->xmac_stats.rx_hist5_cnt += 1947 (val & XRXMAC_HIST_CNT5_MASK); 1948 XMAC_REG_RD(handle, portn, XRXMAC_HIST_CNT6_REG, &val); 1949 statsp->xmac_stats.rx_hist6_cnt += 1950 (val & XRXMAC_HIST_CNT6_MASK); 1951 XMAC_REG_RD(handle, portn, XRXMAC_BC_FRM_CNT_REG, &val); 1952 statsp->xmac_stats.rx_broadcast_cnt += 1953 (val & XRXMAC_BC_FRM_CNT_MASK); 1954 XMAC_REG_RD(handle, portn, XRXMAC_MC_FRM_CNT_REG, &val); 1955 statsp->xmac_stats.rx_mult_cnt += 1956 (val & XRXMAC_MC_FRM_CNT_MASK); 1957 XMAC_REG_RD(handle, portn, XRXMAC_FRAG_CNT_REG, &val); 1958 statsp->xmac_stats.rx_frag_cnt += (val & XRXMAC_FRAG_CNT_MASK); 1959 XMAC_REG_RD(handle, portn, XRXMAC_AL_ER_CNT_REG, &val); 1960 statsp->xmac_stats.rx_frame_align_err_cnt += 1961 (val & XRXMAC_AL_ER_CNT_MASK); 1962 XMAC_REG_RD(handle, portn, XMAC_LINK_FLT_CNT_REG, &val); 1963 statsp->xmac_stats.rx_linkfault_err_cnt += 1964 (val & XMAC_LINK_FLT_CNT_MASK); 1965 (void) npi_xmac_xpcs_read(handle, portn, 1966 XPCS_REG_DESCWERR_COUNTER, &cnt32); 1967 statsp->xmac_stats.xpcs_deskew_err_cnt += 1968 (val & XMAC_XPCS_DESKEW_ERR_CNT_MASK); 1969 #ifdef NXGE_DEBUG_SYMBOL_ERR 1970 (void) npi_xmac_xpcs_read(handle, portn, 1971 XPCS_REG_SYMBOL_ERR_L0_1_COUNTER, &cnt32); 1972 statsp->xmac_stats.xpcs_ln0_symbol_err_cnt += 1973 (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L0_MASK); 1974 statsp->xmac_stats.xpcs_ln1_symbol_err_cnt += 1975 ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L1_MASK) >> 1976 XMAC_XPCS_SYM_ERR_CNT_L1_SHIFT); 1977 (void) npi_xmac_xpcs_read(handle, portn, 1978 XPCS_REG_SYMBOL_ERR_L2_3_COUNTER, &cnt32); 1979 statsp->xmac_stats.xpcs_ln2_symbol_err_cnt += 1980 (cnt32 & XMAC_XPCS_SYM_ERR_CNT_L2_MASK); 1981 statsp->xmac_stats.xpcs_ln3_symbol_err_cnt += 1982 ((cnt32 & XMAC_XPCS_SYM_ERR_CNT_L3_MASK) >> 1983 XMAC_XPCS_SYM_ERR_CNT_L3_SHIFT); 1984 #endif 1985 } else if (nxgep->mac.porttype == PORT_TYPE_BMAC) { 1986 /* 1987 * Transmit MAC statistics. 1988 */ 1989 BMAC_REG_RD(handle, portn, BTXMAC_FRM_CNT_REG, &val); 1990 statsp->bmac_stats.tx_frame_cnt += (val & BTXMAC_FRM_CNT_MASK); 1991 XMAC_REG_RD(handle, portn, BTXMAC_BYTE_CNT_REG, &val); 1992 statsp->bmac_stats.tx_byte_cnt += (val & BTXMAC_BYTE_CNT_MASK); 1993 1994 /* 1995 * Receive MAC statistics. 1996 */ 1997 XMAC_REG_RD(handle, portn, RXMAC_FRM_CNT_REG, &val); 1998 statsp->bmac_stats.rx_frame_cnt += (val & RXMAC_FRM_CNT_MASK); 1999 XMAC_REG_RD(handle, portn, BRXMAC_BYTE_CNT_REG, &val); 2000 statsp->bmac_stats.rx_byte_cnt += (val & BRXMAC_BYTE_CNT_MASK); 2001 XMAC_REG_RD(handle, portn, BMAC_AL_ER_CNT_REG, &val); 2002 statsp->bmac_stats.rx_align_err_cnt += 2003 (val & BMAC_AL_ER_CNT_MASK); 2004 XMAC_REG_RD(handle, portn, MAC_LEN_ER_CNT_REG, &val); 2005 statsp->bmac_stats.rx_len_err_cnt += 2006 (val & MAC_LEN_ER_CNT_MASK); 2007 XMAC_REG_RD(handle, portn, BMAC_CRC_ER_CNT_REG, &val); 2008 statsp->bmac_stats.rx_crc_err_cnt += 2009 (val & BMAC_CRC_ER_CNT_MASK); 2010 XMAC_REG_RD(handle, portn, BMAC_CD_VIO_CNT_REG, &val); 2011 statsp->bmac_stats.rx_viol_err_cnt += 2012 (val & BMAC_CD_VIO_CNT_MASK); 2013 } 2014 /* Update IPP counters */ 2015 (void) npi_ipp_get_ecc_err_count(handle, portn, &cnt8); 2016 statsp->ipp_stats.ecc_err_cnt += cnt8; 2017 (void) npi_ipp_get_pkt_dis_count(handle, portn, &cnt16); 2018 statsp->ipp_stats.pkt_dis_cnt += cnt16; 2019 (void) npi_ipp_get_cs_err_count(handle, portn, &cnt16); 2020 statsp->ipp_stats.bad_cs_cnt += cnt16; 2021 2022 MUTEX_EXIT(&nxgep->ouraddr_lock); 2023 2024 nxge_save_cntrs_exit: 2025 NXGE_DEBUG_MSG((nxgep, DDI_CTL, "<== nxge_save_cntrs")); 2026 } 2027 2028 /* ARGSUSED */ 2029 int 2030 nxge_m_stat(void *arg, uint_t stat, uint64_t *value) 2031 { 2032 p_nxge_t nxgep = (p_nxge_t)arg; 2033 p_nxge_stats_t statsp; 2034 uint64_t val = 0; 2035 int channel; 2036 2037 NXGE_DEBUG_MSG((nxgep, KST_CTL, "==> nxge_m_stat")); 2038 statsp = (p_nxge_stats_t)nxgep->statsp; 2039 2040 switch (stat) { 2041 case MAC_STAT_IFSPEED: 2042 val = statsp->mac_stats.link_speed * 1000000ull; 2043 break; 2044 2045 case MAC_STAT_MULTIRCV: 2046 val = statsp->port_stats.multircv; 2047 break; 2048 2049 case MAC_STAT_BRDCSTRCV: 2050 val = statsp->port_stats.brdcstrcv; 2051 break; 2052 2053 case MAC_STAT_MULTIXMT: 2054 val = statsp->port_stats.multixmt; 2055 break; 2056 2057 case MAC_STAT_BRDCSTXMT: 2058 val = statsp->port_stats.brdcstxmt; 2059 break; 2060 2061 case MAC_STAT_NORCVBUF: 2062 val = statsp->port_stats.norcvbuf; 2063 break; 2064 2065 case MAC_STAT_IERRORS: 2066 case ETHER_STAT_MACRCV_ERRORS: 2067 val = 0; 2068 for (channel = 0; channel < nxgep->nrdc; channel++) { 2069 val += statsp->rdc_stats[channel].ierrors; 2070 } 2071 break; 2072 2073 case MAC_STAT_NOXMTBUF: 2074 val = statsp->port_stats.noxmtbuf; 2075 break; 2076 2077 case MAC_STAT_OERRORS: 2078 for (channel = 0; channel < nxgep->ntdc; channel++) { 2079 val += statsp->tdc_stats[channel].oerrors; 2080 } 2081 2082 break; 2083 2084 case MAC_STAT_COLLISIONS: 2085 val = 0; 2086 break; 2087 2088 case MAC_STAT_RBYTES: 2089 for (channel = 0; channel < nxgep->nrdc; channel++) { 2090 val += statsp->rdc_stats[channel].ibytes; 2091 } 2092 break; 2093 2094 case MAC_STAT_IPACKETS: 2095 for (channel = 0; channel < nxgep->nrdc; channel++) { 2096 val += statsp->rdc_stats[channel].ipackets; 2097 } 2098 break; 2099 2100 case MAC_STAT_OBYTES: 2101 for (channel = 0; channel < nxgep->ntdc; channel++) { 2102 val += statsp->tdc_stats[channel].obytes; 2103 } 2104 break; 2105 2106 case MAC_STAT_OPACKETS: 2107 for (channel = 0; channel < nxgep->ntdc; channel++) { 2108 val += statsp->tdc_stats[channel].opackets; 2109 } 2110 break; 2111 case MAC_STAT_LINK_STATE: 2112 val = statsp->mac_stats.link_duplex; 2113 break; 2114 case MAC_STAT_LINK_UP: 2115 val = statsp->mac_stats.link_up; 2116 break; 2117 case MAC_STAT_PROMISC: 2118 val = statsp->mac_stats.promisc; 2119 break; 2120 case ETHER_STAT_SQE_ERRORS: 2121 val = 0; 2122 break; 2123 2124 case ETHER_STAT_ALIGN_ERRORS: 2125 if (nxgep->mac.porttype == PORT_TYPE_XMAC) 2126 val = statsp->xmac_stats.rx_frame_align_err_cnt; 2127 else if (nxgep->mac.porttype == PORT_TYPE_BMAC) 2128 val = statsp->bmac_stats.rx_align_err_cnt; 2129 else 2130 val = 0; 2131 break; 2132 2133 case ETHER_STAT_FCS_ERRORS: 2134 if (nxgep->mac.porttype == PORT_TYPE_XMAC) 2135 val = statsp->xmac_stats.rx_crc_err_cnt; 2136 else if (nxgep->mac.porttype == PORT_TYPE_BMAC) 2137 val = statsp->bmac_stats.rx_crc_err_cnt; 2138 else 2139 val = 0; 2140 break; 2141 2142 case ETHER_STAT_FIRST_COLLISIONS: 2143 val = 0; 2144 break; 2145 2146 case ETHER_STAT_MULTI_COLLISIONS: 2147 val = 0; 2148 break; 2149 2150 case ETHER_STAT_TX_LATE_COLLISIONS: 2151 val = 0; 2152 break; 2153 2154 case ETHER_STAT_EX_COLLISIONS: 2155 val = 0; 2156 break; 2157 2158 case ETHER_STAT_DEFER_XMTS: 2159 val = 0; 2160 break; 2161 2162 case ETHER_STAT_MACXMT_ERRORS: 2163 if (nxgep->mac.porttype == PORT_TYPE_XMAC) { 2164 val = statsp->xmac_stats.tx_underflow_err + 2165 statsp->xmac_stats.tx_maxpktsize_err + 2166 statsp->xmac_stats.tx_overflow_err + 2167 statsp->xmac_stats.tx_fifo_xfr_err; 2168 } else { 2169 val = statsp->bmac_stats.tx_underrun_err + 2170 statsp->bmac_stats.tx_max_pkt_err; 2171 } 2172 break; 2173 2174 case ETHER_STAT_CARRIER_ERRORS: 2175 if (nxgep->mac.porttype == PORT_TYPE_XMAC) { 2176 val = statsp->xmac_stats.rx_linkfault_err_cnt; 2177 } else { 2178 val = statsp->mac_stats.xcvr_inits + 2179 statsp->mac_stats.serdes_inits; 2180 } 2181 break; 2182 2183 case ETHER_STAT_TOOLONG_ERRORS: 2184 if (nxgep->mac.porttype == PORT_TYPE_XMAC) { 2185 val = statsp->xmac_stats.tx_maxpktsize_err + 2186 statsp->xmac_stats.rx_len_err_cnt; 2187 2188 } else { 2189 val = statsp->bmac_stats.rx_len_err_cnt + 2190 statsp->bmac_stats.tx_max_pkt_err; 2191 } 2192 break; 2193 2194 2195 case ETHER_STAT_XCVR_ADDR: 2196 val = statsp->mac_stats.xcvr_portn; 2197 break; 2198 case ETHER_STAT_XCVR_ID: 2199 val = statsp->mac_stats.xcvr_id; 2200 break; 2201 2202 case ETHER_STAT_XCVR_INUSE: 2203 val = statsp->mac_stats.xcvr_inuse; 2204 break; 2205 2206 case ETHER_STAT_CAP_1000FDX: 2207 val = statsp->mac_stats.cap_1000fdx; 2208 break; 2209 2210 case ETHER_STAT_CAP_1000HDX: 2211 val = statsp->mac_stats.cap_1000hdx; 2212 break; 2213 2214 case ETHER_STAT_CAP_100FDX: 2215 val = statsp->mac_stats.cap_100fdx; 2216 break; 2217 2218 case ETHER_STAT_CAP_100HDX: 2219 val = statsp->mac_stats.cap_100hdx; 2220 break; 2221 2222 case ETHER_STAT_CAP_10FDX: 2223 val = statsp->mac_stats.cap_10fdx; 2224 break; 2225 2226 case ETHER_STAT_CAP_10HDX: 2227 val = statsp->mac_stats.cap_10hdx; 2228 break; 2229 2230 case ETHER_STAT_CAP_ASMPAUSE: 2231 val = statsp->mac_stats.cap_asmpause; 2232 val = 1; 2233 break; 2234 2235 case ETHER_STAT_CAP_PAUSE: 2236 val = statsp->mac_stats.cap_pause; 2237 break; 2238 2239 case ETHER_STAT_CAP_AUTONEG: 2240 val = statsp->mac_stats.cap_autoneg; 2241 break; 2242 2243 case ETHER_STAT_ADV_CAP_1000FDX: 2244 val = statsp->mac_stats.adv_cap_1000fdx; 2245 break; 2246 2247 case ETHER_STAT_ADV_CAP_1000HDX: 2248 val = statsp->mac_stats.adv_cap_1000hdx; 2249 break; 2250 2251 case ETHER_STAT_ADV_CAP_100FDX: 2252 val = statsp->mac_stats.adv_cap_100fdx; 2253 break; 2254 2255 case ETHER_STAT_ADV_CAP_100HDX: 2256 val = statsp->mac_stats.adv_cap_100hdx; 2257 break; 2258 2259 case ETHER_STAT_ADV_CAP_10FDX: 2260 val = statsp->mac_stats.adv_cap_10fdx; 2261 break; 2262 2263 case ETHER_STAT_ADV_CAP_10HDX: 2264 val = statsp->mac_stats.adv_cap_10hdx; 2265 break; 2266 2267 case ETHER_STAT_ADV_CAP_ASMPAUSE: 2268 val = statsp->mac_stats.adv_cap_asmpause; 2269 break; 2270 2271 case ETHER_STAT_ADV_CAP_PAUSE: 2272 val = statsp->mac_stats.adv_cap_pause; 2273 break; 2274 2275 case ETHER_STAT_ADV_CAP_AUTONEG: 2276 val = statsp->mac_stats.adv_cap_autoneg; 2277 break; 2278 2279 case ETHER_STAT_LP_CAP_1000FDX: 2280 val = statsp->mac_stats.lp_cap_1000fdx; 2281 break; 2282 2283 case ETHER_STAT_LP_CAP_1000HDX: 2284 val = statsp->mac_stats.lp_cap_1000hdx; 2285 break; 2286 2287 case ETHER_STAT_LP_CAP_100FDX: 2288 val = statsp->mac_stats.lp_cap_100fdx; 2289 break; 2290 2291 case ETHER_STAT_LP_CAP_100HDX: 2292 val = statsp->mac_stats.lp_cap_100hdx; 2293 break; 2294 2295 case ETHER_STAT_LP_CAP_10FDX: 2296 val = statsp->mac_stats.lp_cap_10fdx; 2297 break; 2298 2299 case ETHER_STAT_LP_CAP_10HDX: 2300 val = statsp->mac_stats.lp_cap_10hdx; 2301 break; 2302 2303 case ETHER_STAT_LP_CAP_ASMPAUSE: 2304 val = statsp->mac_stats.lp_cap_asmpause; 2305 break; 2306 2307 case ETHER_STAT_LP_CAP_PAUSE: 2308 val = statsp->mac_stats.lp_cap_pause; 2309 break; 2310 2311 case ETHER_STAT_LP_CAP_AUTONEG: 2312 val = statsp->mac_stats.lp_cap_autoneg; 2313 break; 2314 2315 case ETHER_STAT_LINK_ASMPAUSE: 2316 val = statsp->mac_stats.link_asmpause; 2317 break; 2318 2319 case ETHER_STAT_LINK_PAUSE: 2320 val = statsp->mac_stats.link_pause; 2321 break; 2322 2323 case ETHER_STAT_LINK_AUTONEG: 2324 val = statsp->mac_stats.cap_autoneg; 2325 break; 2326 2327 case ETHER_STAT_LINK_DUPLEX: 2328 val = statsp->mac_stats.link_duplex; 2329 break; 2330 2331 default: 2332 /* 2333 * Shouldn't reach here... 2334 */ 2335 #ifdef NXGE_DEBUG 2336 NXGE_ERROR_MSG((nxgep, KST_CTL, 2337 "nxge_m_stat: unrecognized parameter value = 0x%x", 2338 stat)); 2339 #endif 2340 2341 return (ENOTSUP); 2342 } 2343 *value = val; 2344 return (0); 2345 } 2346