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 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include "sys/bge_impl2.h" 30 31 #define BGE_DBG BGE_DBG_STATS /* debug flag for this code */ 32 33 /* 34 * Type of transceiver currently in use. The IEEE 802.3 std aPhyType 35 * enumerates the following set 36 */ 37 enum xcvr_type { 38 XCVR_TYPE_UNDEFINED = 0, /* 0 = undefined, or not yet known */ 39 XCVR_TYPE_NONE, /* 1= MII present & nothing connected */ 40 XCVR_TYPE_10BASE_T, /* 2 = 10 Mbps copper */ 41 XCVR_TYPE_100BASE_T4, /* 3 = 10 Mbps copper */ 42 XCVR_TYPE_100BASE_X, /* 4 = 100 Mbps copper */ 43 XCVR_TYPE_100BASE_T2, /* 5 = 100 Mbps copper */ 44 XCVR_TYPE_1000BASE_X, /* 6 = 1000 Mbps SerDes */ 45 XCVR_TYPE_1000BASE_T /* 7 = 1000 Mbps copper */ 46 }; 47 48 /* 49 * Local datatype for defining tables of (Offset, Name) pairs 50 */ 51 typedef struct { 52 offset_t index; 53 char *name; 54 } bge_ksindex_t; 55 56 57 /* 58 * Table of Hardware-defined Statistics Block Offsets and Names 59 */ 60 #define KS_NAME(s) { KS_ ## s, #s } 61 62 static const bge_ksindex_t bge_statistics[] = { 63 KS_NAME(ifHCInOctets), 64 KS_NAME(etherStatsFragments), 65 KS_NAME(ifHCInUcastPkts), 66 KS_NAME(ifHCInMulticastPkts), 67 KS_NAME(ifHCInBroadcastPkts), 68 KS_NAME(dot3StatsFCSErrors), 69 KS_NAME(dot3StatsAlignmentErrors), 70 KS_NAME(xonPauseFramesReceived), 71 KS_NAME(xoffPauseFramesReceived), 72 KS_NAME(macControlFramesReceived), 73 KS_NAME(xoffStateEntered), 74 KS_NAME(dot3StatsFrameTooLongs), 75 KS_NAME(etherStatsJabbers), 76 KS_NAME(etherStatsUndersizePkts), 77 KS_NAME(inRangeLengthError), 78 KS_NAME(outRangeLengthError), 79 KS_NAME(etherStatsPkts64Octets), 80 KS_NAME(etherStatsPkts65to127Octets), 81 KS_NAME(etherStatsPkts128to255Octets), 82 KS_NAME(etherStatsPkts256to511Octets), 83 KS_NAME(etherStatsPkts512to1023Octets), 84 KS_NAME(etherStatsPkts1024to1518Octets), 85 KS_NAME(etherStatsPkts1519to2047Octets), 86 KS_NAME(etherStatsPkts2048to4095Octets), 87 KS_NAME(etherStatsPkts4096to8191Octets), 88 KS_NAME(etherStatsPkts8192to9022Octets), 89 90 KS_NAME(ifHCOutOctets), 91 KS_NAME(etherStatsCollisions), 92 KS_NAME(outXonSent), 93 KS_NAME(outXoffSent), 94 KS_NAME(flowControlDone), 95 KS_NAME(dot3StatsInternalMacTransmitErrors), 96 KS_NAME(dot3StatsSingleCollisionFrames), 97 KS_NAME(dot3StatsMultipleCollisionFrames), 98 KS_NAME(dot3StatsDeferredTransmissions), 99 KS_NAME(dot3StatsExcessiveCollisions), 100 KS_NAME(dot3StatsLateCollisions), 101 KS_NAME(dot3Collided2Times), 102 KS_NAME(dot3Collided3Times), 103 KS_NAME(dot3Collided4Times), 104 KS_NAME(dot3Collided5Times), 105 KS_NAME(dot3Collided6Times), 106 KS_NAME(dot3Collided7Times), 107 KS_NAME(dot3Collided8Times), 108 KS_NAME(dot3Collided9Times), 109 KS_NAME(dot3Collided10Times), 110 KS_NAME(dot3Collided11Times), 111 KS_NAME(dot3Collided12Times), 112 KS_NAME(dot3Collided13Times), 113 KS_NAME(dot3Collided14Times), 114 KS_NAME(dot3Collided15Times), 115 KS_NAME(ifHCOutUcastPkts), 116 KS_NAME(ifHCOutMulticastPkts), 117 KS_NAME(ifHCOutBroadcastPkts), 118 KS_NAME(dot3StatsCarrierSenseErrors), 119 KS_NAME(ifOutDiscards), 120 KS_NAME(ifOutErrors), 121 122 KS_NAME(COSIfHCInPkts_1), 123 KS_NAME(COSIfHCInPkts_2), 124 KS_NAME(COSIfHCInPkts_3), 125 KS_NAME(COSIfHCInPkts_4), 126 KS_NAME(COSIfHCInPkts_5), 127 KS_NAME(COSIfHCInPkts_6), 128 KS_NAME(COSIfHCInPkts_7), 129 KS_NAME(COSIfHCInPkts_8), 130 KS_NAME(COSIfHCInPkts_9), 131 KS_NAME(COSIfHCInPkts_10), 132 KS_NAME(COSIfHCInPkts_11), 133 KS_NAME(COSIfHCInPkts_12), 134 KS_NAME(COSIfHCInPkts_13), 135 KS_NAME(COSIfHCInPkts_14), 136 KS_NAME(COSIfHCInPkts_15), 137 KS_NAME(COSIfHCInPkts_16), 138 KS_NAME(COSFramesDroppedDueToFilters), 139 KS_NAME(nicDmaWriteQueueFull), 140 KS_NAME(nicDmaWriteHighPriQueueFull), 141 KS_NAME(nicNoMoreRxBDs), 142 KS_NAME(ifInDiscards), 143 KS_NAME(ifInErrors), 144 KS_NAME(nicRecvThresholdHit), 145 146 KS_NAME(COSIfHCOutPkts_1), 147 KS_NAME(COSIfHCOutPkts_2), 148 KS_NAME(COSIfHCOutPkts_3), 149 KS_NAME(COSIfHCOutPkts_4), 150 KS_NAME(COSIfHCOutPkts_5), 151 KS_NAME(COSIfHCOutPkts_6), 152 KS_NAME(COSIfHCOutPkts_7), 153 KS_NAME(COSIfHCOutPkts_8), 154 KS_NAME(COSIfHCOutPkts_9), 155 KS_NAME(COSIfHCOutPkts_10), 156 KS_NAME(COSIfHCOutPkts_11), 157 KS_NAME(COSIfHCOutPkts_12), 158 KS_NAME(COSIfHCOutPkts_13), 159 KS_NAME(COSIfHCOutPkts_14), 160 KS_NAME(COSIfHCOutPkts_15), 161 KS_NAME(COSIfHCOutPkts_16), 162 KS_NAME(nicDmaReadQueueFull), 163 KS_NAME(nicDmaReadHighPriQueueFull), 164 KS_NAME(nicSendDataCompQueueFull), 165 KS_NAME(nicRingSetSendProdIndex), 166 KS_NAME(nicRingStatusUpdate), 167 KS_NAME(nicInterrupts), 168 KS_NAME(nicAvoidedInterrupts), 169 KS_NAME(nicSendThresholdHit), 170 171 { KS_STATS_SIZE, NULL } 172 }; 173 174 static const bge_ksindex_t bge_stat_val[] = { 175 KS_NAME(ifHCOutOctets), 176 KS_NAME(etherStatsCollisions), 177 KS_NAME(outXonSent), 178 KS_NAME(outXoffSent), 179 KS_NAME(dot3StatsInternalMacTransmitErrors), 180 KS_NAME(dot3StatsSingleCollisionFrames), 181 KS_NAME(dot3StatsMultipleCollisionFrames), 182 KS_NAME(dot3StatsDeferredTransmissions), 183 KS_NAME(dot3StatsExcessiveCollisions), 184 KS_NAME(dot3StatsLateCollisions), 185 KS_NAME(ifHCOutUcastPkts), 186 KS_NAME(ifHCOutMulticastPkts), 187 KS_NAME(ifHCOutBroadcastPkts), 188 KS_NAME(ifHCInOctets), 189 KS_NAME(etherStatsFragments), 190 KS_NAME(ifHCInUcastPkts), 191 KS_NAME(ifHCInMulticastPkts), 192 KS_NAME(ifHCInBroadcastPkts), 193 KS_NAME(dot3StatsFCSErrors), 194 KS_NAME(dot3StatsAlignmentErrors), 195 KS_NAME(xonPauseFramesReceived), 196 KS_NAME(xoffPauseFramesReceived), 197 KS_NAME(macControlFramesReceived), 198 KS_NAME(xoffStateEntered), 199 KS_NAME(dot3StatsFrameTooLongs), 200 KS_NAME(etherStatsJabbers), 201 KS_NAME(etherStatsUndersizePkts), 202 203 { KS_STAT_REG_SIZE, NULL } 204 }; 205 206 static int 207 bge_statistics_update(kstat_t *ksp, int flag) 208 { 209 bge_t *bgep; 210 bge_statistics_t *bstp; 211 kstat_named_t *knp; 212 const bge_ksindex_t *ksip; 213 214 if (flag != KSTAT_READ) 215 return (EACCES); 216 217 bgep = ksp->ks_private; 218 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 219 bstp = DMA_VPTR(bgep->statistics); 220 221 knp = ksp->ks_data; 222 223 /* 224 * Transfer the statistics values from the copy that the 225 * chip updates via DMA to the named-kstat structure. 226 * 227 * As above, we don't bother to sync or stop updates to the 228 * statistics, 'cos it doesn't really matter if they're a few 229 * microsends out of date or less than 100% consistent ... 230 */ 231 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 232 for (ksip = bge_statistics; ksip->name != NULL; ++knp, ++ksip) 233 knp->value.ui64 = bstp->a[ksip->index]; 234 else { 235 (knp++)->value.ui64 = 236 (uint64_t)(bgep->stat_val.ifHCOutOctets); 237 (knp++)->value.ui64 = 238 (uint64_t)(bgep->stat_val.etherStatsCollisions); 239 (knp++)->value.ui64 = 240 (uint64_t)(bgep->stat_val.outXonSent); 241 (knp++)->value.ui64 = 242 (uint64_t)(bgep->stat_val.outXoffSent); 243 (knp++)->value.ui64 = 244 (uint64_t)(bgep-> 245 stat_val.dot3StatsInternalMacTransmitErrors); 246 (knp++)->value.ui64 = 247 (uint64_t)(bgep-> 248 stat_val.dot3StatsSingleCollisionFrames); 249 (knp++)->value.ui64 = 250 (uint64_t)(bgep-> 251 stat_val.dot3StatsMultipleCollisionFrames); 252 (knp++)->value.ui64 = 253 (uint64_t)(bgep-> 254 stat_val.dot3StatsDeferredTransmissions); 255 (knp++)->value.ui64 = 256 (uint64_t)(bgep->stat_val.dot3StatsExcessiveCollisions); 257 (knp++)->value.ui64 = 258 (uint64_t)(bgep->stat_val.dot3StatsLateCollisions); 259 (knp++)->value.ui64 = 260 (uint64_t)(bgep->stat_val.ifHCOutUcastPkts); 261 (knp++)->value.ui64 = 262 (uint64_t)(bgep->stat_val.ifHCOutMulticastPkts); 263 (knp++)->value.ui64 = 264 (uint64_t)(bgep->stat_val.ifHCOutBroadcastPkts); 265 (knp++)->value.ui64 = 266 (uint64_t)(bgep->stat_val.ifHCInOctets); 267 (knp++)->value.ui64 = 268 (uint64_t)(bgep->stat_val.etherStatsFragments); 269 (knp++)->value.ui64 = 270 (uint64_t)(bgep->stat_val.ifHCInUcastPkts); 271 (knp++)->value.ui64 = 272 (uint64_t)(bgep->stat_val.ifHCInMulticastPkts); 273 (knp++)->value.ui64 = 274 (uint64_t)(bgep->stat_val.ifHCInBroadcastPkts); 275 (knp++)->value.ui64 = 276 (uint64_t)(bgep->stat_val.dot3StatsFCSErrors); 277 (knp++)->value.ui64 = 278 (uint64_t)(bgep->stat_val.dot3StatsAlignmentErrors); 279 (knp++)->value.ui64 = 280 (uint64_t)(bgep->stat_val.xonPauseFramesReceived); 281 (knp++)->value.ui64 = 282 (uint64_t)(bgep->stat_val.xoffPauseFramesReceived); 283 (knp++)->value.ui64 = 284 (uint64_t)(bgep->stat_val.macControlFramesReceived); 285 (knp++)->value.ui64 = 286 (uint64_t)(bgep->stat_val.xoffStateEntered); 287 (knp++)->value.ui64 = 288 (uint64_t)(bgep->stat_val.dot3StatsFrameTooLongs); 289 (knp++)->value.ui64 = 290 (uint64_t)(bgep->stat_val.etherStatsJabbers); 291 (knp++)->value.ui64 = 292 (uint64_t)(bgep->stat_val.etherStatsUndersizePkts); 293 } 294 295 return (0); 296 } 297 298 static int 299 bge_params_update(kstat_t *ksp, int flag) 300 { 301 bge_t *bgep; 302 kstat_named_t *knp; 303 int i; 304 305 if (flag != KSTAT_READ) 306 return (EACCES); 307 308 bgep = ksp->ks_private; 309 for (knp = ksp->ks_data, i = 0; i < PARAM_COUNT; ++knp, ++i) 310 knp->value.ui64 = bgep->nd_params[i].ndp_val; 311 312 return (0); 313 } 314 315 static const bge_ksindex_t bge_chipid[] = { 316 { 0, "asic_rev" }, 317 { 1, "businfo" }, 318 { 2, "command" }, 319 320 { 3, "vendor_id" }, 321 { 4, "device_id" }, 322 { 5, "subsystem_vendor_id" }, 323 { 6, "subsystem_device_id" }, 324 { 7, "revision_id" }, 325 { 8, "cache_line_size" }, 326 { 9, "latency_timer" }, 327 328 { 10, "flags" }, 329 { 11, "chip_type" }, 330 { 12, "mbuf_base" }, 331 { 13, "mbuf_count" }, 332 { 14, "hw_mac_addr" }, 333 334 { 15, "&bus_type" }, 335 { 16, "&bus_speed" }, 336 { 17, "&bus_size" }, 337 { 18, "&supported" }, 338 { 19, "&interface" }, 339 340 { -1, NULL } 341 }; 342 343 static void 344 bge_set_char_kstat(kstat_named_t *knp, const char *s) 345 { 346 (void) strncpy(knp->value.c, s, sizeof (knp->value.c)); 347 } 348 349 static int 350 bge_chipid_update(kstat_t *ksp, int flag) 351 { 352 bge_t *bgep; 353 kstat_named_t *knp; 354 uint64_t tmp; 355 356 if (flag != KSTAT_READ) 357 return (EACCES); 358 359 bgep = ksp->ks_private; 360 knp = ksp->ks_data; 361 362 (knp++)->value.ui64 = bgep->chipid.asic_rev; 363 (knp++)->value.ui64 = bgep->chipid.businfo; 364 (knp++)->value.ui64 = bgep->chipid.command; 365 366 (knp++)->value.ui64 = bgep->chipid.vendor; 367 (knp++)->value.ui64 = bgep->chipid.device; 368 (knp++)->value.ui64 = bgep->chipid.subven; 369 (knp++)->value.ui64 = bgep->chipid.subdev; 370 (knp++)->value.ui64 = bgep->chipid.revision; 371 (knp++)->value.ui64 = bgep->chipid.clsize; 372 (knp++)->value.ui64 = bgep->chipid.latency; 373 374 (knp++)->value.ui64 = bgep->chipid.flags; 375 (knp++)->value.ui64 = bgep->chipid.chip_label; 376 (knp++)->value.ui64 = bgep->chipid.mbuf_base; 377 (knp++)->value.ui64 = bgep->chipid.mbuf_length; 378 (knp++)->value.ui64 = bgep->chipid.hw_mac_addr; 379 380 /* 381 * Now we interpret some of the above into readable strings 382 */ 383 tmp = bgep->chipid.businfo; 384 bge_set_char_kstat(knp++, 385 tmp & PCISTATE_BUS_IS_PCI ? "PCI" : "PCI-X"); 386 bge_set_char_kstat(knp++, 387 tmp & PCISTATE_BUS_IS_FAST ? "fast" : "normal"); 388 bge_set_char_kstat(knp++, 389 tmp & PCISTATE_BUS_IS_32_BIT ? "32 bit" : "64 bit"); 390 391 tmp = bgep->chipid.flags; 392 bge_set_char_kstat(knp++, 393 tmp & CHIP_FLAG_SUPPORTED ? "yes" : "no"); 394 bge_set_char_kstat(knp++, 395 tmp & CHIP_FLAG_SERDES ? "serdes" : "copper"); 396 397 return (0); 398 } 399 400 static const bge_ksindex_t bge_driverinfo[] = { 401 { 0, "rx_buff_addr" }, 402 { 1, "tx_buff_addr" }, 403 { 2, "rx_desc_addr" }, 404 { 3, "tx_desc_addr" }, 405 406 { 4, "tx_desc_free" }, 407 { 5, "resched_needed" }, 408 { 6, "watchdog" }, 409 { 7, "chip_resets" }, 410 { 8, "dma_misses" }, 411 412 { 9, "misc_host_config" }, 413 { 10, "dma_rw_control" }, 414 { 11, "pci_bus_info" }, 415 416 { 12, "buff_mgr_status" }, 417 { 13, "rcv_init_status" }, 418 419 { -1, NULL } 420 }; 421 422 static int 423 bge_driverinfo_update(kstat_t *ksp, int flag) 424 { 425 bge_t *bgep; 426 kstat_named_t *knp; 427 ddi_acc_handle_t handle; 428 429 if (flag != KSTAT_READ) 430 return (EACCES); 431 432 bgep = ksp->ks_private; 433 knp = ksp->ks_data; 434 435 (knp++)->value.ui64 = bgep->rx_buff[0].cookie.dmac_laddress; 436 (knp++)->value.ui64 = bgep->tx_buff[0].cookie.dmac_laddress; 437 (knp++)->value.ui64 = bgep->rx_desc[0].cookie.dmac_laddress; 438 (knp++)->value.ui64 = bgep->tx_desc.cookie.dmac_laddress; 439 440 (knp++)->value.ui64 = bgep->send[0].tx_free; 441 (knp++)->value.ui64 = bgep->resched_needed; 442 (knp++)->value.ui64 = bgep->watchdog; 443 (knp++)->value.ui64 = bgep->chip_resets; 444 (knp++)->value.ui64 = bgep->missed_dmas; 445 446 /* 447 * Hold the mutex while accessing the chip registers 448 * just in case the factotum is trying to reset it! 449 */ 450 handle = bgep->cfg_handle; 451 mutex_enter(bgep->genlock); 452 (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_MHCR); 453 (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_PDRWCR); 454 (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_PCISTATE); 455 456 (knp++)->value.ui64 = bge_reg_get32(bgep, BUFFER_MANAGER_STATUS_REG); 457 (knp++)->value.ui64 = bge_reg_get32(bgep, RCV_INITIATOR_STATUS_REG); 458 mutex_exit(bgep->genlock); 459 460 return (0); 461 } 462 463 static const bge_ksindex_t bge_mii_kstats[] = { 464 { 0, "%xcvr_addr" }, 465 { 1, "%xcvr_id" }, 466 { 2, "%xcvr_inuse" }, 467 468 { 3, "%cap_1000fdx" }, 469 { 4, "%cap_1000hdx" }, 470 { 5, "%cap_100fdx" }, 471 { 6, "%cap_100hdx" }, 472 { 7, "%cap_10fdx" }, 473 { 8, "%cap_10hdx" }, 474 { 9, "%cap_asmpause" }, 475 { 10, "%cap_pause" }, 476 { 11, "%cap_rem_fault" }, 477 { 12, "%cap_autoneg" }, 478 479 { 13, "%adv_cap_1000fdx" }, 480 { 14, "%adv_cap_1000hdx" }, 481 { 15, "%adv_cap_100fdx" }, 482 { 16, "%adv_cap_100hdx" }, 483 { 17, "%adv_cap_10fdx" }, 484 { 18, "%adv_cap_10hdx" }, 485 { 19, "%adv_cap_asmpause" }, 486 { 20, "%adv_cap_pause" }, 487 { 21, "%adv_rem_fault" }, 488 { 22, "%adv_cap_autoneg" }, 489 490 { 23, "%lp_cap_1000fdx" }, 491 { 24, "%lp_cap_1000hdx" }, 492 { 25, "%lp_cap_100fdx" }, 493 { 26, "%lp_cap_100hdx" }, 494 { 27, "%lp_cap_10fdx" }, 495 { 28, "%lp_cap_10hdx" }, 496 { 29, "%lp_cap_asmpause" }, 497 { 30, "%lp_cap_pause" }, 498 { 31, "%lp_rem_fault" }, 499 { 32, "%lp_cap_autoneg" }, 500 501 { 33, "%link_asmpause" }, 502 { 34, "%link_pause" }, 503 { 35, "%link_duplex" }, 504 { 36, "%link_up" }, 505 506 { -1, NULL } 507 }; 508 509 /* 510 * Derive and publish the standard "mii" kstats. 511 * 512 * The information required is somewhat scattered: some is already held 513 * in driver softstate, some is available in the MII registers, and some 514 * has to be computed from combinations of both ... 515 */ 516 static int 517 bge_mii_update(kstat_t *ksp, int flag) 518 { 519 bge_t *bgep; 520 kstat_named_t *knp; 521 uint16_t anlpar; 522 uint16_t anar; 523 uint32_t xcvr_id; 524 uint32_t xcvr_inuse; 525 boolean_t asym_pause; 526 527 if (flag != KSTAT_READ) 528 return (EACCES); 529 530 bgep = ksp->ks_private; 531 knp = ksp->ks_data; 532 533 /* 534 * Read all the relevant PHY registers 535 */ 536 mutex_enter(bgep->genlock); 537 anlpar = bge_mii_get16(bgep, MII_AN_LPABLE); 538 anar = bge_mii_get16(bgep, MII_AN_ADVERT); 539 540 /* 541 * Derive PHY characterisation parameters 542 */ 543 xcvr_id = bge_mii_get16(bgep, MII_PHYIDH); 544 xcvr_id <<= 16; 545 xcvr_id |= bge_mii_get16(bgep, MII_PHYIDL); 546 mutex_exit(bgep->genlock); 547 548 switch (bgep->param_link_speed) { 549 case 1000: 550 if (bgep->chipid.flags & CHIP_FLAG_SERDES) 551 xcvr_inuse = XCVR_TYPE_1000BASE_X; 552 else 553 xcvr_inuse = XCVR_TYPE_1000BASE_T; 554 break; 555 556 case 100: 557 xcvr_inuse = XCVR_TYPE_100BASE_X; 558 break; 559 560 case 10: 561 xcvr_inuse = XCVR_TYPE_10BASE_T; 562 break; 563 564 default: 565 xcvr_inuse = XCVR_TYPE_UNDEFINED; 566 break; 567 } 568 569 /* 570 * Other miscellaneous transformations ... 571 */ 572 asym_pause = bgep->param_link_rx_pause != bgep->param_link_tx_pause; 573 574 /* 575 * All required values are now available; assign them to the 576 * actual kstats, in the sequence defined by the table above. 577 */ 578 (knp++)->value.ui32 = bgep->phy_mii_addr; 579 (knp++)->value.ui32 = xcvr_id; 580 (knp++)->value.ui32 = xcvr_inuse; 581 582 /* 583 * Our capabilities 584 */ 585 (knp++)->value.ui32 = bgep->nd_params[PARAM_1000FDX_CAP].ndp_val; 586 (knp++)->value.ui32 = bgep->nd_params[PARAM_1000HDX_CAP].ndp_val; 587 (knp++)->value.ui32 = bgep->nd_params[PARAM_100FDX_CAP].ndp_val; 588 (knp++)->value.ui32 = bgep->nd_params[PARAM_100HDX_CAP].ndp_val; 589 (knp++)->value.ui32 = bgep->nd_params[PARAM_10FDX_CAP].ndp_val; 590 (knp++)->value.ui32 = bgep->nd_params[PARAM_10HDX_CAP].ndp_val; 591 (knp++)->value.ui32 = bgep->nd_params[PARAM_ASYM_PAUSE_CAP].ndp_val; 592 (knp++)->value.ui32 = bgep->nd_params[PARAM_PAUSE_CAP].ndp_val; 593 (knp++)->value.ui32 = B_TRUE; 594 (knp++)->value.ui32 = bgep->nd_params[PARAM_AUTONEG_CAP].ndp_val; 595 596 /* 597 * Our *advertised* capabilities 598 */ 599 (knp++)->value.ui32 = bgep->param_adv_1000fdx; 600 (knp++)->value.ui32 = bgep->param_adv_1000hdx; 601 (knp++)->value.ui32 = bgep->param_adv_100fdx; 602 (knp++)->value.ui32 = bgep->param_adv_100hdx; 603 (knp++)->value.ui32 = bgep->param_adv_10fdx; 604 (knp++)->value.ui32 = bgep->param_adv_10hdx; 605 (knp++)->value.ui32 = bgep->param_adv_asym_pause; 606 (knp++)->value.ui32 = bgep->param_adv_pause; 607 (knp++)->value.ui32 = (anar & MII_AN_ADVERT_REMFAULT) ? 1 : 0; 608 (knp++)->value.ui32 = bgep->param_adv_autoneg; 609 610 /* 611 * Link Partner's advertised capabilities 612 */ 613 (knp++)->value.ui32 = bgep->param_lp_1000fdx; 614 (knp++)->value.ui32 = bgep->param_lp_1000hdx; 615 (knp++)->value.ui32 = bgep->param_lp_100fdx; 616 (knp++)->value.ui32 = bgep->param_lp_100hdx; 617 (knp++)->value.ui32 = bgep->param_lp_10fdx; 618 (knp++)->value.ui32 = bgep->param_lp_10hdx; 619 (knp++)->value.ui32 = bgep->param_lp_asym_pause; 620 (knp++)->value.ui32 = bgep->param_lp_pause; 621 (knp++)->value.ui32 = (anlpar & MII_AN_ADVERT_REMFAULT) ? 1 : 0; 622 (knp++)->value.ui32 = bgep->param_lp_autoneg; 623 624 /* 625 * Current operating modes 626 */ 627 (knp++)->value.ui32 = asym_pause; 628 (knp++)->value.ui32 = bgep->param_link_rx_pause; 629 (knp++)->value.ui32 = bgep->param_link_duplex; 630 (knp++)->value.ui32 = bgep->param_link_up; 631 632 return (0); 633 } 634 635 static const bge_ksindex_t bge_serdes[] = { 636 { 0, "serdes_status" }, 637 { 1, "serdes_advert" }, 638 { 2, "serdes_lpadv" }, 639 640 { -1, NULL } 641 }; 642 643 static int 644 bge_serdes_update(kstat_t *ksp, int flag) 645 { 646 bge_t *bgep; 647 kstat_named_t *knp; 648 649 if (flag != KSTAT_READ) 650 return (EACCES); 651 652 bgep = ksp->ks_private; 653 knp = ksp->ks_data; 654 655 (knp++)->value.ui64 = bgep->serdes_status; 656 (knp++)->value.ui64 = bgep->serdes_advert; 657 (knp++)->value.ui64 = bgep->serdes_lpadv; 658 659 return (0); 660 } 661 662 static const bge_ksindex_t bge_phydata[] = { 663 { MII_CONTROL, "mii_control" }, 664 { MII_STATUS, "mii_status" }, 665 { MII_PHYIDH, "phy_identifier" }, 666 { MII_AN_ADVERT, "an_advert" }, 667 { MII_AN_LPABLE, "an_lp_ability" }, 668 { MII_AN_EXPANSION, "an_expansion" }, 669 { MII_AN_LPNXTPG, "an_lp_nextpage" }, 670 { MII_1000BASE_T_CONTROL, "gbit_control" }, 671 { MII_1000BASE_T_STATUS, "gbit_status" }, 672 { MII_IEEE_EXT_STATUS, "ieee_ext_status" }, 673 { MII_EXT_CONTROL, "phy_ext_control" }, 674 { MII_EXT_STATUS, "phy_ext_status" }, 675 { MII_RCV_ERR_COUNT, "receive_error_count" }, 676 { MII_FALSE_CARR_COUNT, "false_carrier_count" }, 677 { MII_RCV_NOT_OK_COUNT, "receiver_not_ok_count" }, 678 { MII_AUX_CONTROL, "aux_control" }, 679 { MII_AUX_STATUS, "aux_status" }, 680 { MII_INTR_STATUS, "intr_status" }, 681 { MII_INTR_MASK, "intr_mask" }, 682 { MII_HCD_STATUS, "hcd_status" }, 683 684 { -1, NULL } 685 }; 686 687 static int 688 bge_phydata_update(kstat_t *ksp, int flag) 689 { 690 bge_t *bgep; 691 kstat_named_t *knp; 692 const bge_ksindex_t *ksip; 693 694 if (flag != KSTAT_READ) 695 return (EACCES); 696 697 bgep = ksp->ks_private; 698 knp = ksp->ks_data; 699 700 /* 701 * Read the PHY registers & update the kstats ... 702 * 703 * We need to hold the mutex while performing MII reads, but 704 * we don't want to hold it across the entire sequence of reads. 705 * So we grab and release it on each iteration, 'cos it doesn't 706 * really matter if the kstats are less than 100% consistent ... 707 */ 708 for (ksip = bge_phydata; ksip->name != NULL; ++knp, ++ksip) { 709 mutex_enter(bgep->genlock); 710 switch (ksip->index) { 711 case MII_STATUS: 712 knp->value.ui64 = bgep->phy_gen_status; 713 break; 714 715 case MII_PHYIDH: 716 knp->value.ui64 = bge_mii_get16(bgep, MII_PHYIDH); 717 knp->value.ui64 <<= 16; 718 knp->value.ui64 |= bge_mii_get16(bgep, MII_PHYIDL); 719 break; 720 721 default: 722 knp->value.ui64 = bge_mii_get16(bgep, ksip->index); 723 break; 724 } 725 mutex_exit(bgep->genlock); 726 } 727 728 return (0); 729 } 730 731 static kstat_t * 732 bge_setup_named_kstat(bge_t *bgep, int instance, char *name, 733 const bge_ksindex_t *ksip, size_t size, int (*update)(kstat_t *, int)) 734 { 735 kstat_t *ksp; 736 kstat_named_t *knp; 737 char *np; 738 int type; 739 740 size /= sizeof (bge_ksindex_t); 741 ksp = kstat_create(BGE_DRIVER_NAME, instance, name, "net", 742 KSTAT_TYPE_NAMED, size-1, KSTAT_FLAG_PERSISTENT); 743 if (ksp == NULL) 744 return (NULL); 745 746 ksp->ks_private = bgep; 747 ksp->ks_update = update; 748 for (knp = ksp->ks_data; (np = ksip->name) != NULL; ++knp, ++ksip) { 749 switch (*np) { 750 default: 751 type = KSTAT_DATA_UINT64; 752 break; 753 case '%': 754 np += 1; 755 type = KSTAT_DATA_UINT32; 756 break; 757 case '$': 758 np += 1; 759 type = KSTAT_DATA_STRING; 760 break; 761 case '&': 762 np += 1; 763 type = KSTAT_DATA_CHAR; 764 break; 765 } 766 kstat_named_init(knp, np, type); 767 } 768 kstat_install(ksp); 769 770 return (ksp); 771 } 772 773 /* 774 * Create kstats corresponding to NDD parameters 775 */ 776 static kstat_t * 777 bge_setup_params_kstat(bge_t *bgep, int instance, char *name, 778 int (*update)(kstat_t *, int)) 779 { 780 kstat_t *ksp; 781 kstat_named_t *knp; 782 int i; 783 784 ksp = kstat_create(BGE_DRIVER_NAME, instance, name, "net", 785 KSTAT_TYPE_NAMED, PARAM_COUNT, KSTAT_FLAG_PERSISTENT); 786 if (ksp != NULL) { 787 ksp->ks_private = bgep; 788 ksp->ks_update = update; 789 for (knp = ksp->ks_data, i = 0; i < PARAM_COUNT; ++knp, ++i) 790 kstat_named_init(knp, bgep->nd_params[i].ndp_name+1, 791 KSTAT_DATA_UINT64); 792 kstat_install(ksp); 793 } 794 795 return (ksp); 796 } 797 798 void 799 bge_init_kstats(bge_t *bgep, int instance) 800 { 801 kstat_t *ksp; 802 803 BGE_TRACE(("bge_init_kstats($%p, %d)", (void *)bgep, instance)); 804 805 if (bgep->chipid.statistic_type == BGE_STAT_BLK) { 806 DMA_ZERO(bgep->statistics); 807 bgep->bge_kstats[BGE_KSTAT_RAW] = ksp = 808 kstat_create(BGE_DRIVER_NAME, instance, 809 "raw_statistics", "net", KSTAT_TYPE_RAW, 810 sizeof (bge_statistics_t), KSTAT_FLAG_VIRTUAL); 811 if (ksp != NULL) { 812 ksp->ks_data = DMA_VPTR(bgep->statistics); 813 kstat_install(ksp); 814 } 815 816 bgep->bge_kstats[BGE_KSTAT_STATS] = bge_setup_named_kstat(bgep, 817 instance, "statistics", bge_statistics, 818 sizeof (bge_statistics), bge_statistics_update); 819 } else { 820 bgep->bge_kstats[BGE_KSTAT_STATS] = bge_setup_named_kstat(bgep, 821 instance, "statistics", bge_stat_val, 822 sizeof (bge_stat_val), bge_statistics_update); 823 } 824 825 bgep->bge_kstats[BGE_KSTAT_CHIPID] = bge_setup_named_kstat(bgep, 826 instance, "chipid", bge_chipid, 827 sizeof (bge_chipid), bge_chipid_update); 828 829 bgep->bge_kstats[BGE_KSTAT_DRIVER] = bge_setup_named_kstat(bgep, 830 instance, "driverinfo", bge_driverinfo, 831 sizeof (bge_driverinfo), bge_driverinfo_update); 832 833 bgep->bge_kstats[BGE_KSTAT_MII] = bge_setup_named_kstat(bgep, 834 instance, "mii", bge_mii_kstats, 835 sizeof (bge_mii_kstats), bge_mii_update); 836 837 if (bgep->chipid.flags & CHIP_FLAG_SERDES) 838 bgep->bge_kstats[BGE_KSTAT_PHYS] = bge_setup_named_kstat(bgep, 839 instance, "serdes", bge_serdes, 840 sizeof (bge_serdes), bge_serdes_update); 841 else 842 bgep->bge_kstats[BGE_KSTAT_PHYS] = bge_setup_named_kstat(bgep, 843 instance, "phydata", bge_phydata, 844 sizeof (bge_phydata), bge_phydata_update); 845 846 bgep->bge_kstats[BGE_KSTAT_PARAMS] = bge_setup_params_kstat(bgep, 847 instance, "parameters", bge_params_update); 848 } 849 850 void 851 bge_fini_kstats(bge_t *bgep) 852 { 853 int i; 854 855 BGE_TRACE(("bge_fini_kstats($%p)", (void *)bgep)); 856 857 for (i = BGE_KSTAT_COUNT; --i >= 0; ) 858 if (bgep->bge_kstats[i] != NULL) 859 kstat_delete(bgep->bge_kstats[i]); 860 } 861 862 uint64_t 863 bge_m_stat(void *arg, enum mac_stat stat) 864 { 865 bge_t *bgep = arg; 866 bge_statistics_t *bstp; 867 uint64_t val; 868 869 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 870 bstp = DMA_VPTR(bgep->statistics); 871 else { 872 873 bgep->stat_val.ifHCOutOctets += 874 bge_reg_get32(bgep, STAT_IFHCOUT_OCTETS_REG); 875 bgep->stat_val.etherStatsCollisions += 876 bge_reg_get32(bgep, STAT_ETHER_COLLIS_REG); 877 bgep->stat_val.outXonSent += 878 bge_reg_get32(bgep, STAT_OUTXON_SENT_REG); 879 bgep->stat_val.outXoffSent += 880 bge_reg_get32(bgep, STAT_OUTXOFF_SENT_REG); 881 bgep->stat_val.dot3StatsInternalMacTransmitErrors += 882 bge_reg_get32(bgep, STAT_DOT3_INTMACTX_ERR_REG); 883 bgep->stat_val.dot3StatsSingleCollisionFrames += 884 bge_reg_get32(bgep, STAT_DOT3_SCOLLI_FRAME_REG); 885 bgep->stat_val.dot3StatsMultipleCollisionFrames += 886 bge_reg_get32(bgep, STAT_DOT3_MCOLLI_FRAME_REG); 887 bgep->stat_val.dot3StatsDeferredTransmissions += 888 bge_reg_get32(bgep, STAT_DOT3_DEFERED_TX_REG); 889 bgep->stat_val.dot3StatsExcessiveCollisions += 890 bge_reg_get32(bgep, STAT_DOT3_EXCE_COLLI_REG); 891 bgep->stat_val.dot3StatsLateCollisions += 892 bge_reg_get32(bgep, STAT_DOT3_LATE_COLLI_REG); 893 bgep->stat_val.ifHCOutUcastPkts += 894 bge_reg_get32(bgep, STAT_IFHCOUT_UPKGS_REG); 895 bgep->stat_val.ifHCOutMulticastPkts += 896 bge_reg_get32(bgep, STAT_IFHCOUT_MPKGS_REG); 897 bgep->stat_val.ifHCOutBroadcastPkts += 898 bge_reg_get32(bgep, STAT_IFHCOUT_BPKGS_REG); 899 bgep->stat_val.ifHCInOctets += 900 bge_reg_get32(bgep, STAT_IFHCIN_OCTETS_REG); 901 bgep->stat_val.etherStatsFragments += 902 bge_reg_get32(bgep, STAT_ETHER_FRAGMENT_REG); 903 bgep->stat_val.ifHCInUcastPkts += 904 bge_reg_get32(bgep, STAT_IFHCIN_UPKGS_REG); 905 bgep->stat_val.ifHCInMulticastPkts += 906 bge_reg_get32(bgep, STAT_IFHCIN_MPKGS_REG); 907 bgep->stat_val.ifHCInBroadcastPkts += 908 bge_reg_get32(bgep, STAT_IFHCIN_BPKGS_REG); 909 bgep->stat_val.dot3StatsFCSErrors += 910 bge_reg_get32(bgep, STAT_DOT3_FCS_ERR_REG); 911 bgep->stat_val.dot3StatsAlignmentErrors += 912 bge_reg_get32(bgep, STAT_DOT3_ALIGN_ERR_REG); 913 bgep->stat_val.xonPauseFramesReceived += 914 bge_reg_get32(bgep, STAT_XON_PAUSE_RX_REG); 915 bgep->stat_val.xoffPauseFramesReceived += 916 bge_reg_get32(bgep, STAT_XOFF_PAUSE_RX_REG); 917 bgep->stat_val.macControlFramesReceived += 918 bge_reg_get32(bgep, STAT_MAC_CTRL_RX_REG); 919 bgep->stat_val.xoffStateEntered += 920 bge_reg_get32(bgep, STAT_XOFF_STATE_ENTER_REG); 921 bgep->stat_val.dot3StatsFrameTooLongs += 922 bge_reg_get32(bgep, STAT_DOT3_FRAME_TOOLONG_REG); 923 bgep->stat_val.etherStatsJabbers += 924 bge_reg_get32(bgep, STAT_ETHER_JABBERS_REG); 925 bgep->stat_val.etherStatsUndersizePkts += 926 bge_reg_get32(bgep, STAT_ETHER_UNDERSIZE_REG); 927 } 928 929 switch (stat) { 930 case MAC_STAT_IFSPEED: 931 val = bgep->param_link_speed * 1000000ull; 932 break; 933 934 case MAC_STAT_MULTIRCV: 935 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 936 val = bstp->s.ifHCInMulticastPkts; 937 else 938 val = bgep->stat_val.ifHCInMulticastPkts; 939 break; 940 941 case MAC_STAT_BRDCSTRCV: 942 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 943 val = bstp->s.ifHCInBroadcastPkts; 944 else 945 val = bgep->stat_val.ifHCInBroadcastPkts; 946 break; 947 948 case MAC_STAT_MULTIXMT: 949 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 950 val = bstp->s.ifHCOutMulticastPkts; 951 else 952 val = bgep->stat_val.ifHCOutMulticastPkts; 953 break; 954 955 case MAC_STAT_BRDCSTXMT: 956 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 957 val = bstp->s.ifHCOutBroadcastPkts; 958 else 959 val = bgep->stat_val.ifHCOutBroadcastPkts; 960 break; 961 962 case MAC_STAT_NORCVBUF: 963 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 964 val = bstp->s.ifInDiscards; 965 else 966 val = 0; 967 break; 968 969 case MAC_STAT_IERRORS: 970 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 971 val = bstp->s.dot3StatsFCSErrors + 972 bstp->s.dot3StatsAlignmentErrors + 973 bstp->s.dot3StatsFrameTooLongs + 974 bstp->s.etherStatsUndersizePkts + 975 bstp->s.etherStatsJabbers; 976 else 977 val = bgep->stat_val.dot3StatsFCSErrors + 978 bgep->stat_val.dot3StatsAlignmentErrors + 979 bgep->stat_val.dot3StatsFrameTooLongs + 980 bgep->stat_val.etherStatsUndersizePkts + 981 bgep->stat_val.etherStatsJabbers; 982 break; 983 984 case MAC_STAT_NOXMTBUF: 985 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 986 val = bstp->s.ifOutDiscards; 987 else 988 val = 0; 989 break; 990 991 case MAC_STAT_OERRORS: 992 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 993 val = bstp->s.ifOutDiscards; 994 else 995 val = 0; 996 break; 997 998 case MAC_STAT_COLLISIONS: 999 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1000 val = bstp->s.etherStatsCollisions; 1001 else 1002 val = bgep->stat_val.etherStatsCollisions; 1003 break; 1004 1005 case MAC_STAT_RBYTES: 1006 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1007 val = bstp->s.ifHCInOctets; 1008 else 1009 val = bgep->stat_val.ifHCInOctets; 1010 break; 1011 1012 case MAC_STAT_IPACKETS: 1013 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1014 val = bstp->s.ifHCInUcastPkts + 1015 bstp->s.ifHCInMulticastPkts + 1016 bstp->s.ifHCInBroadcastPkts; 1017 else 1018 val = bgep->stat_val.ifHCInUcastPkts + 1019 bgep->stat_val.ifHCInMulticastPkts + 1020 bgep->stat_val.ifHCInBroadcastPkts; 1021 break; 1022 1023 case MAC_STAT_OBYTES: 1024 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1025 val = bstp->s.ifHCOutOctets; 1026 else 1027 val = bgep->stat_val.ifHCOutOctets; 1028 break; 1029 1030 case MAC_STAT_OPACKETS: 1031 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1032 val = bstp->s.ifHCOutUcastPkts + 1033 bstp->s.ifHCOutMulticastPkts + 1034 bstp->s.ifHCOutBroadcastPkts; 1035 else 1036 val = bgep->stat_val.ifHCOutUcastPkts + 1037 bgep->stat_val.ifHCOutMulticastPkts + 1038 bgep->stat_val.ifHCOutBroadcastPkts; 1039 break; 1040 1041 case MAC_STAT_ALIGN_ERRORS: 1042 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1043 val = bstp->s.dot3StatsAlignmentErrors; 1044 else 1045 val = bgep->stat_val.dot3StatsAlignmentErrors; 1046 break; 1047 1048 case MAC_STAT_FCS_ERRORS: 1049 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1050 val = bstp->s.dot3StatsFCSErrors; 1051 else 1052 val = bgep->stat_val.dot3StatsFCSErrors; 1053 break; 1054 1055 case MAC_STAT_FIRST_COLLISIONS: 1056 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1057 val = bstp->s.dot3StatsSingleCollisionFrames; 1058 else 1059 val = bgep->stat_val.dot3StatsSingleCollisionFrames; 1060 break; 1061 1062 case MAC_STAT_MULTI_COLLISIONS: 1063 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1064 val = bstp->s.dot3StatsMultipleCollisionFrames; 1065 else 1066 val = bgep->stat_val.dot3StatsMultipleCollisionFrames; 1067 break; 1068 1069 case MAC_STAT_DEFER_XMTS: 1070 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1071 val = bstp->s.dot3StatsDeferredTransmissions; 1072 else 1073 val = bgep->stat_val.dot3StatsDeferredTransmissions; 1074 break; 1075 1076 case MAC_STAT_TX_LATE_COLLISIONS: 1077 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1078 val = bstp->s.dot3StatsLateCollisions; 1079 else 1080 val = bgep->stat_val.dot3StatsLateCollisions; 1081 break; 1082 1083 case MAC_STAT_EX_COLLISIONS: 1084 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1085 val = bstp->s.dot3StatsExcessiveCollisions; 1086 else 1087 val = bgep->stat_val.dot3StatsExcessiveCollisions; 1088 break; 1089 1090 case MAC_STAT_MACXMT_ERRORS: 1091 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1092 val = bstp->s.dot3StatsInternalMacTransmitErrors; 1093 else 1094 val = bgep->stat_val.dot3StatsInternalMacTransmitErrors; 1095 break; 1096 1097 case MAC_STAT_CARRIER_ERRORS: 1098 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1099 val = bstp->s.dot3StatsCarrierSenseErrors; 1100 else 1101 val = 0; 1102 break; 1103 1104 case MAC_STAT_TOOLONG_ERRORS: 1105 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 1106 val = bstp->s.dot3StatsFrameTooLongs; 1107 else 1108 val = bgep->stat_val.dot3StatsFrameTooLongs; 1109 break; 1110 1111 case MAC_STAT_XCVR_ADDR: 1112 val = bgep->phy_mii_addr; 1113 break; 1114 1115 case MAC_STAT_XCVR_ID: 1116 mutex_enter(bgep->genlock); 1117 val = bge_mii_get16(bgep, MII_PHYIDH); 1118 val <<= 16; 1119 val |= bge_mii_get16(bgep, MII_PHYIDL); 1120 mutex_exit(bgep->genlock); 1121 break; 1122 1123 case MAC_STAT_XCVR_INUSE: 1124 val = XCVR_1000T; 1125 break; 1126 1127 case MAC_STAT_CAP_1000FDX: 1128 val = 1; 1129 break; 1130 1131 case MAC_STAT_CAP_1000HDX: 1132 val = 1; 1133 break; 1134 1135 case MAC_STAT_CAP_100FDX: 1136 val = 1; 1137 break; 1138 1139 case MAC_STAT_CAP_100HDX: 1140 val = 1; 1141 break; 1142 1143 case MAC_STAT_CAP_10FDX: 1144 val = 1; 1145 break; 1146 1147 case MAC_STAT_CAP_10HDX: 1148 val = 1; 1149 break; 1150 1151 case MAC_STAT_CAP_ASMPAUSE: 1152 val = 1; 1153 break; 1154 1155 case MAC_STAT_CAP_PAUSE: 1156 val = 1; 1157 break; 1158 1159 case MAC_STAT_CAP_AUTONEG: 1160 val = 1; 1161 break; 1162 1163 case MAC_STAT_ADV_CAP_1000FDX: 1164 val = bgep->param_adv_1000fdx; 1165 break; 1166 1167 case MAC_STAT_ADV_CAP_1000HDX: 1168 val = bgep->param_adv_1000hdx; 1169 break; 1170 1171 case MAC_STAT_ADV_CAP_100FDX: 1172 val = bgep->param_adv_100fdx; 1173 break; 1174 1175 case MAC_STAT_ADV_CAP_100HDX: 1176 val = bgep->param_adv_100hdx; 1177 break; 1178 1179 case MAC_STAT_ADV_CAP_10FDX: 1180 val = bgep->param_adv_10fdx; 1181 break; 1182 1183 case MAC_STAT_ADV_CAP_10HDX: 1184 val = bgep->param_adv_10hdx; 1185 break; 1186 1187 case MAC_STAT_ADV_CAP_ASMPAUSE: 1188 val = bgep->param_adv_asym_pause; 1189 break; 1190 1191 case MAC_STAT_ADV_CAP_PAUSE: 1192 val = bgep->param_adv_pause; 1193 break; 1194 1195 case MAC_STAT_ADV_CAP_AUTONEG: 1196 val = bgep->param_adv_autoneg; 1197 break; 1198 1199 case MAC_STAT_LP_CAP_1000FDX: 1200 val = bgep->param_lp_1000fdx; 1201 break; 1202 1203 case MAC_STAT_LP_CAP_1000HDX: 1204 val = bgep->param_lp_1000hdx; 1205 break; 1206 1207 case MAC_STAT_LP_CAP_100FDX: 1208 val = bgep->param_lp_100fdx; 1209 break; 1210 1211 case MAC_STAT_LP_CAP_100HDX: 1212 val = bgep->param_lp_100hdx; 1213 break; 1214 1215 case MAC_STAT_LP_CAP_10FDX: 1216 val = bgep->param_lp_10fdx; 1217 break; 1218 1219 case MAC_STAT_LP_CAP_10HDX: 1220 val = bgep->param_lp_10hdx; 1221 break; 1222 1223 case MAC_STAT_LP_CAP_ASMPAUSE: 1224 val = bgep->param_lp_asym_pause; 1225 break; 1226 1227 case MAC_STAT_LP_CAP_PAUSE: 1228 val = bgep->param_lp_pause; 1229 break; 1230 1231 case MAC_STAT_LP_CAP_AUTONEG: 1232 val = bgep->param_lp_autoneg; 1233 break; 1234 1235 case MAC_STAT_LINK_ASMPAUSE: 1236 val = bgep->param_adv_asym_pause && 1237 bgep->param_lp_asym_pause && 1238 bgep->param_adv_pause != bgep->param_lp_pause; 1239 break; 1240 1241 case MAC_STAT_LINK_PAUSE: 1242 val = bgep->param_link_rx_pause; 1243 break; 1244 1245 case MAC_STAT_LINK_AUTONEG: 1246 val = bgep->param_link_autoneg; 1247 break; 1248 1249 case MAC_STAT_LINK_DUPLEX: 1250 val = bgep->param_link_duplex; 1251 break; 1252 1253 #ifdef DEBUG 1254 default: 1255 /* 1256 * Shouldn't reach here... 1257 */ 1258 cmn_err(CE_PANIC, 1259 "bge_m_stat: unrecognized parameter value = %d", 1260 stat); 1261 #endif 1262 } 1263 1264 return (val); 1265 } 1266