17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*62387023Sdduvall * Common Development and Distribution License (the "License"). 6*62387023Sdduvall * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*62387023Sdduvall 227c478bd9Sstevel@tonic-gate /* 23*62387023Sdduvall * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 29*62387023Sdduvall #include "sys/bge_impl2.h" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #define BGE_DBG BGE_DBG_STATS /* debug flag for this code */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * Type of transceiver currently in use. The IEEE 802.3 std aPhyType 357c478bd9Sstevel@tonic-gate * enumerates the following set 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate enum xcvr_type { 387c478bd9Sstevel@tonic-gate XCVR_TYPE_UNDEFINED = 0, /* 0 = undefined, or not yet known */ 397c478bd9Sstevel@tonic-gate XCVR_TYPE_NONE, /* 1= MII present & nothing connected */ 407c478bd9Sstevel@tonic-gate XCVR_TYPE_10BASE_T, /* 2 = 10 Mbps copper */ 417c478bd9Sstevel@tonic-gate XCVR_TYPE_100BASE_T4, /* 3 = 10 Mbps copper */ 427c478bd9Sstevel@tonic-gate XCVR_TYPE_100BASE_X, /* 4 = 100 Mbps copper */ 437c478bd9Sstevel@tonic-gate XCVR_TYPE_100BASE_T2, /* 5 = 100 Mbps copper */ 447c478bd9Sstevel@tonic-gate XCVR_TYPE_1000BASE_X, /* 6 = 1000 Mbps SerDes */ 457c478bd9Sstevel@tonic-gate XCVR_TYPE_1000BASE_T /* 7 = 1000 Mbps copper */ 467c478bd9Sstevel@tonic-gate }; 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Local datatype for defining tables of (Offset, Name) pairs 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate typedef struct { 527c478bd9Sstevel@tonic-gate offset_t index; 537c478bd9Sstevel@tonic-gate char *name; 547c478bd9Sstevel@tonic-gate } bge_ksindex_t; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * Table of Hardware-defined Statistics Block Offsets and Names 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate #define KS_NAME(s) { KS_ ## s, #s } 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate static const bge_ksindex_t bge_statistics[] = { 637c478bd9Sstevel@tonic-gate KS_NAME(ifHCInOctets), 647c478bd9Sstevel@tonic-gate KS_NAME(etherStatsFragments), 657c478bd9Sstevel@tonic-gate KS_NAME(ifHCInUcastPkts), 667c478bd9Sstevel@tonic-gate KS_NAME(ifHCInMulticastPkts), 677c478bd9Sstevel@tonic-gate KS_NAME(ifHCInBroadcastPkts), 687c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsFCSErrors), 697c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsAlignmentErrors), 707c478bd9Sstevel@tonic-gate KS_NAME(xonPauseFramesReceived), 717c478bd9Sstevel@tonic-gate KS_NAME(xoffPauseFramesReceived), 727c478bd9Sstevel@tonic-gate KS_NAME(macControlFramesReceived), 737c478bd9Sstevel@tonic-gate KS_NAME(xoffStateEntered), 747c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsFrameTooLongs), 757c478bd9Sstevel@tonic-gate KS_NAME(etherStatsJabbers), 767c478bd9Sstevel@tonic-gate KS_NAME(etherStatsUndersizePkts), 777c478bd9Sstevel@tonic-gate KS_NAME(inRangeLengthError), 787c478bd9Sstevel@tonic-gate KS_NAME(outRangeLengthError), 797c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts64Octets), 807c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts65to127Octets), 817c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts128to255Octets), 827c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts256to511Octets), 837c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts512to1023Octets), 847c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts1024to1518Octets), 857c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts1519to2047Octets), 867c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts2048to4095Octets), 877c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts4096to8191Octets), 887c478bd9Sstevel@tonic-gate KS_NAME(etherStatsPkts8192to9022Octets), 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate KS_NAME(ifHCOutOctets), 917c478bd9Sstevel@tonic-gate KS_NAME(etherStatsCollisions), 927c478bd9Sstevel@tonic-gate KS_NAME(outXonSent), 937c478bd9Sstevel@tonic-gate KS_NAME(outXoffSent), 947c478bd9Sstevel@tonic-gate KS_NAME(flowControlDone), 957c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsInternalMacTransmitErrors), 967c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsSingleCollisionFrames), 977c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsMultipleCollisionFrames), 987c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsDeferredTransmissions), 997c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsExcessiveCollisions), 1007c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsLateCollisions), 1017c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided2Times), 1027c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided3Times), 1037c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided4Times), 1047c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided5Times), 1057c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided6Times), 1067c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided7Times), 1077c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided8Times), 1087c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided9Times), 1097c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided10Times), 1107c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided11Times), 1117c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided12Times), 1127c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided13Times), 1137c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided14Times), 1147c478bd9Sstevel@tonic-gate KS_NAME(dot3Collided15Times), 1157c478bd9Sstevel@tonic-gate KS_NAME(ifHCOutUcastPkts), 1167c478bd9Sstevel@tonic-gate KS_NAME(ifHCOutMulticastPkts), 1177c478bd9Sstevel@tonic-gate KS_NAME(ifHCOutBroadcastPkts), 1187c478bd9Sstevel@tonic-gate KS_NAME(dot3StatsCarrierSenseErrors), 1197c478bd9Sstevel@tonic-gate KS_NAME(ifOutDiscards), 1207c478bd9Sstevel@tonic-gate KS_NAME(ifOutErrors), 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_1), 1237c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_2), 1247c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_3), 1257c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_4), 1267c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_5), 1277c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_6), 1287c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_7), 1297c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_8), 1307c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_9), 1317c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_10), 1327c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_11), 1337c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_12), 1347c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_13), 1357c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_14), 1367c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_15), 1377c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_16), 1387c478bd9Sstevel@tonic-gate KS_NAME(COSFramesDroppedDueToFilters), 1397c478bd9Sstevel@tonic-gate KS_NAME(nicDmaWriteQueueFull), 1407c478bd9Sstevel@tonic-gate KS_NAME(nicDmaWriteHighPriQueueFull), 1417c478bd9Sstevel@tonic-gate KS_NAME(nicNoMoreRxBDs), 1427c478bd9Sstevel@tonic-gate KS_NAME(ifInDiscards), 1437c478bd9Sstevel@tonic-gate KS_NAME(ifInErrors), 1447c478bd9Sstevel@tonic-gate KS_NAME(nicRecvThresholdHit), 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_1), 1477c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_2), 1487c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_3), 1497c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_4), 1507c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_5), 1517c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_6), 1527c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_7), 1537c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_8), 1547c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_9), 1557c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_10), 1567c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_11), 1577c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_12), 1587c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_13), 1597c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_14), 1607c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_15), 1617c478bd9Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_16), 1627c478bd9Sstevel@tonic-gate KS_NAME(nicDmaReadQueueFull), 1637c478bd9Sstevel@tonic-gate KS_NAME(nicDmaReadHighPriQueueFull), 1647c478bd9Sstevel@tonic-gate KS_NAME(nicSendDataCompQueueFull), 1657c478bd9Sstevel@tonic-gate KS_NAME(nicRingSetSendProdIndex), 1667c478bd9Sstevel@tonic-gate KS_NAME(nicRingStatusUpdate), 1677c478bd9Sstevel@tonic-gate KS_NAME(nicInterrupts), 1687c478bd9Sstevel@tonic-gate KS_NAME(nicAvoidedInterrupts), 1697c478bd9Sstevel@tonic-gate KS_NAME(nicSendThresholdHit), 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate { KS_STATS_SIZE, NULL } 1727c478bd9Sstevel@tonic-gate }; 1737c478bd9Sstevel@tonic-gate 1748eb6c4f9Sly149593 static const bge_ksindex_t bge_stat_val[] = { 1758eb6c4f9Sly149593 KS_NAME(ifHCOutOctets), 1768eb6c4f9Sly149593 KS_NAME(etherStatsCollisions), 1778eb6c4f9Sly149593 KS_NAME(outXonSent), 1788eb6c4f9Sly149593 KS_NAME(outXoffSent), 1798eb6c4f9Sly149593 KS_NAME(dot3StatsInternalMacTransmitErrors), 1808eb6c4f9Sly149593 KS_NAME(dot3StatsSingleCollisionFrames), 1818eb6c4f9Sly149593 KS_NAME(dot3StatsMultipleCollisionFrames), 1828eb6c4f9Sly149593 KS_NAME(dot3StatsDeferredTransmissions), 1838eb6c4f9Sly149593 KS_NAME(dot3StatsExcessiveCollisions), 1848eb6c4f9Sly149593 KS_NAME(dot3StatsLateCollisions), 1858eb6c4f9Sly149593 KS_NAME(ifHCOutUcastPkts), 1868eb6c4f9Sly149593 KS_NAME(ifHCOutMulticastPkts), 1878eb6c4f9Sly149593 KS_NAME(ifHCOutBroadcastPkts), 1888eb6c4f9Sly149593 KS_NAME(ifHCInOctets), 1898eb6c4f9Sly149593 KS_NAME(etherStatsFragments), 1908eb6c4f9Sly149593 KS_NAME(ifHCInUcastPkts), 1918eb6c4f9Sly149593 KS_NAME(ifHCInMulticastPkts), 1928eb6c4f9Sly149593 KS_NAME(ifHCInBroadcastPkts), 1938eb6c4f9Sly149593 KS_NAME(dot3StatsFCSErrors), 1948eb6c4f9Sly149593 KS_NAME(dot3StatsAlignmentErrors), 1958eb6c4f9Sly149593 KS_NAME(xonPauseFramesReceived), 1968eb6c4f9Sly149593 KS_NAME(xoffPauseFramesReceived), 1978eb6c4f9Sly149593 KS_NAME(macControlFramesReceived), 1988eb6c4f9Sly149593 KS_NAME(xoffStateEntered), 1998eb6c4f9Sly149593 KS_NAME(dot3StatsFrameTooLongs), 2008eb6c4f9Sly149593 KS_NAME(etherStatsJabbers), 2018eb6c4f9Sly149593 KS_NAME(etherStatsUndersizePkts), 2028eb6c4f9Sly149593 2038eb6c4f9Sly149593 { KS_STAT_REG_SIZE, NULL } 2048eb6c4f9Sly149593 }; 2058eb6c4f9Sly149593 2067c478bd9Sstevel@tonic-gate static int 2077c478bd9Sstevel@tonic-gate bge_statistics_update(kstat_t *ksp, int flag) 2087c478bd9Sstevel@tonic-gate { 2097c478bd9Sstevel@tonic-gate bge_t *bgep; 2107c478bd9Sstevel@tonic-gate bge_statistics_t *bstp; 2117c478bd9Sstevel@tonic-gate kstat_named_t *knp; 2127c478bd9Sstevel@tonic-gate const bge_ksindex_t *ksip; 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 2157c478bd9Sstevel@tonic-gate return (EACCES); 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 2188eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 2197c478bd9Sstevel@tonic-gate bstp = DMA_VPTR(bgep->statistics); 2208eb6c4f9Sly149593 2217c478bd9Sstevel@tonic-gate knp = ksp->ks_data; 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate /* 2247c478bd9Sstevel@tonic-gate * Transfer the statistics values from the copy that the 2257c478bd9Sstevel@tonic-gate * chip updates via DMA to the named-kstat structure. 2267c478bd9Sstevel@tonic-gate * 2277c478bd9Sstevel@tonic-gate * As above, we don't bother to sync or stop updates to the 2287c478bd9Sstevel@tonic-gate * statistics, 'cos it doesn't really matter if they're a few 2297c478bd9Sstevel@tonic-gate * microsends out of date or less than 100% consistent ... 2307c478bd9Sstevel@tonic-gate */ 2318eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 2327c478bd9Sstevel@tonic-gate for (ksip = bge_statistics; ksip->name != NULL; ++knp, ++ksip) 2337c478bd9Sstevel@tonic-gate knp->value.ui64 = bstp->a[ksip->index]; 2348eb6c4f9Sly149593 else { 2358eb6c4f9Sly149593 (knp++)->value.ui64 = 2368eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCOutOctets); 2378eb6c4f9Sly149593 (knp++)->value.ui64 = 2388eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.etherStatsCollisions); 2398eb6c4f9Sly149593 (knp++)->value.ui64 = 2408eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.outXonSent); 2418eb6c4f9Sly149593 (knp++)->value.ui64 = 2428eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.outXoffSent); 2438eb6c4f9Sly149593 (knp++)->value.ui64 = 2448eb6c4f9Sly149593 (uint64_t)(bgep-> 2458eb6c4f9Sly149593 stat_val.dot3StatsInternalMacTransmitErrors); 2468eb6c4f9Sly149593 (knp++)->value.ui64 = 2478eb6c4f9Sly149593 (uint64_t)(bgep-> 2488eb6c4f9Sly149593 stat_val.dot3StatsSingleCollisionFrames); 2498eb6c4f9Sly149593 (knp++)->value.ui64 = 2508eb6c4f9Sly149593 (uint64_t)(bgep-> 2518eb6c4f9Sly149593 stat_val.dot3StatsMultipleCollisionFrames); 2528eb6c4f9Sly149593 (knp++)->value.ui64 = 2538eb6c4f9Sly149593 (uint64_t)(bgep-> 2548eb6c4f9Sly149593 stat_val.dot3StatsDeferredTransmissions); 2558eb6c4f9Sly149593 (knp++)->value.ui64 = 2568eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.dot3StatsExcessiveCollisions); 2578eb6c4f9Sly149593 (knp++)->value.ui64 = 2588eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.dot3StatsLateCollisions); 2598eb6c4f9Sly149593 (knp++)->value.ui64 = 2608eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCOutUcastPkts); 2618eb6c4f9Sly149593 (knp++)->value.ui64 = 2628eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCOutMulticastPkts); 2638eb6c4f9Sly149593 (knp++)->value.ui64 = 2648eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCOutBroadcastPkts); 2658eb6c4f9Sly149593 (knp++)->value.ui64 = 2668eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCInOctets); 2678eb6c4f9Sly149593 (knp++)->value.ui64 = 2688eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.etherStatsFragments); 2698eb6c4f9Sly149593 (knp++)->value.ui64 = 2708eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCInUcastPkts); 2718eb6c4f9Sly149593 (knp++)->value.ui64 = 2728eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCInMulticastPkts); 2738eb6c4f9Sly149593 (knp++)->value.ui64 = 2748eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.ifHCInBroadcastPkts); 2758eb6c4f9Sly149593 (knp++)->value.ui64 = 2768eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.dot3StatsFCSErrors); 2778eb6c4f9Sly149593 (knp++)->value.ui64 = 2788eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.dot3StatsAlignmentErrors); 2798eb6c4f9Sly149593 (knp++)->value.ui64 = 2808eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.xonPauseFramesReceived); 2818eb6c4f9Sly149593 (knp++)->value.ui64 = 2828eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.xoffPauseFramesReceived); 2838eb6c4f9Sly149593 (knp++)->value.ui64 = 2848eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.macControlFramesReceived); 2858eb6c4f9Sly149593 (knp++)->value.ui64 = 2868eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.xoffStateEntered); 2878eb6c4f9Sly149593 (knp++)->value.ui64 = 2888eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.dot3StatsFrameTooLongs); 2898eb6c4f9Sly149593 (knp++)->value.ui64 = 2908eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.etherStatsJabbers); 2918eb6c4f9Sly149593 (knp++)->value.ui64 = 2928eb6c4f9Sly149593 (uint64_t)(bgep->stat_val.etherStatsUndersizePkts); 2938eb6c4f9Sly149593 } 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate return (0); 2967c478bd9Sstevel@tonic-gate } 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate static int 2997c478bd9Sstevel@tonic-gate bge_params_update(kstat_t *ksp, int flag) 3007c478bd9Sstevel@tonic-gate { 3017c478bd9Sstevel@tonic-gate bge_t *bgep; 3027c478bd9Sstevel@tonic-gate kstat_named_t *knp; 3037c478bd9Sstevel@tonic-gate int i; 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 3067c478bd9Sstevel@tonic-gate return (EACCES); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 3097c478bd9Sstevel@tonic-gate for (knp = ksp->ks_data, i = 0; i < PARAM_COUNT; ++knp, ++i) 3107c478bd9Sstevel@tonic-gate knp->value.ui64 = bgep->nd_params[i].ndp_val; 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate return (0); 3137c478bd9Sstevel@tonic-gate } 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate static const bge_ksindex_t bge_chipid[] = { 3167c478bd9Sstevel@tonic-gate { 0, "asic_rev" }, 3177c478bd9Sstevel@tonic-gate { 1, "businfo" }, 3187c478bd9Sstevel@tonic-gate { 2, "command" }, 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate { 3, "vendor_id" }, 3217c478bd9Sstevel@tonic-gate { 4, "device_id" }, 3227c478bd9Sstevel@tonic-gate { 5, "subsystem_vendor_id" }, 3237c478bd9Sstevel@tonic-gate { 6, "subsystem_device_id" }, 3247c478bd9Sstevel@tonic-gate { 7, "revision_id" }, 3257c478bd9Sstevel@tonic-gate { 8, "cache_line_size" }, 3267c478bd9Sstevel@tonic-gate { 9, "latency_timer" }, 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate { 10, "flags" }, 3297c478bd9Sstevel@tonic-gate { 11, "chip_type" }, 3307c478bd9Sstevel@tonic-gate { 12, "mbuf_base" }, 3317c478bd9Sstevel@tonic-gate { 13, "mbuf_count" }, 3327c478bd9Sstevel@tonic-gate { 14, "hw_mac_addr" }, 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate { 15, "&bus_type" }, 3357c478bd9Sstevel@tonic-gate { 16, "&bus_speed" }, 3367c478bd9Sstevel@tonic-gate { 17, "&bus_size" }, 3377c478bd9Sstevel@tonic-gate { 18, "&supported" }, 3387c478bd9Sstevel@tonic-gate { 19, "&interface" }, 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate { -1, NULL } 3417c478bd9Sstevel@tonic-gate }; 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate static void 3447c478bd9Sstevel@tonic-gate bge_set_char_kstat(kstat_named_t *knp, const char *s) 3457c478bd9Sstevel@tonic-gate { 3467c478bd9Sstevel@tonic-gate (void) strncpy(knp->value.c, s, sizeof (knp->value.c)); 3477c478bd9Sstevel@tonic-gate } 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate static int 3507c478bd9Sstevel@tonic-gate bge_chipid_update(kstat_t *ksp, int flag) 3517c478bd9Sstevel@tonic-gate { 3527c478bd9Sstevel@tonic-gate bge_t *bgep; 3537c478bd9Sstevel@tonic-gate kstat_named_t *knp; 3547c478bd9Sstevel@tonic-gate uint64_t tmp; 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 3577c478bd9Sstevel@tonic-gate return (EACCES); 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 3607c478bd9Sstevel@tonic-gate knp = ksp->ks_data; 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.asic_rev; 3637c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.businfo; 3647c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.command; 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.vendor; 3677c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.device; 3687c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.subven; 3697c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.subdev; 3707c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.revision; 3717c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.clsize; 3727c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.latency; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.flags; 3757c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.chip_label; 3767c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.mbuf_base; 3777c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.mbuf_length; 3787c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.hw_mac_addr; 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate /* 3817c478bd9Sstevel@tonic-gate * Now we interpret some of the above into readable strings 3827c478bd9Sstevel@tonic-gate */ 3837c478bd9Sstevel@tonic-gate tmp = bgep->chipid.businfo; 3847c478bd9Sstevel@tonic-gate bge_set_char_kstat(knp++, 3857c478bd9Sstevel@tonic-gate tmp & PCISTATE_BUS_IS_PCI ? "PCI" : "PCI-X"); 3867c478bd9Sstevel@tonic-gate bge_set_char_kstat(knp++, 3877c478bd9Sstevel@tonic-gate tmp & PCISTATE_BUS_IS_FAST ? "fast" : "normal"); 3887c478bd9Sstevel@tonic-gate bge_set_char_kstat(knp++, 3897c478bd9Sstevel@tonic-gate tmp & PCISTATE_BUS_IS_32_BIT ? "32 bit" : "64 bit"); 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate tmp = bgep->chipid.flags; 3927c478bd9Sstevel@tonic-gate bge_set_char_kstat(knp++, 3937c478bd9Sstevel@tonic-gate tmp & CHIP_FLAG_SUPPORTED ? "yes" : "no"); 3947c478bd9Sstevel@tonic-gate bge_set_char_kstat(knp++, 3957c478bd9Sstevel@tonic-gate tmp & CHIP_FLAG_SERDES ? "serdes" : "copper"); 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate return (0); 3987c478bd9Sstevel@tonic-gate } 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate static const bge_ksindex_t bge_driverinfo[] = { 4017c478bd9Sstevel@tonic-gate { 0, "rx_buff_addr" }, 4027c478bd9Sstevel@tonic-gate { 1, "tx_buff_addr" }, 4037c478bd9Sstevel@tonic-gate { 2, "rx_desc_addr" }, 4047c478bd9Sstevel@tonic-gate { 3, "tx_desc_addr" }, 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate { 4, "tx_desc_free" }, 4077c478bd9Sstevel@tonic-gate { 5, "resched_needed" }, 4087c478bd9Sstevel@tonic-gate { 6, "watchdog" }, 4097c478bd9Sstevel@tonic-gate { 7, "chip_resets" }, 4107c478bd9Sstevel@tonic-gate { 8, "dma_misses" }, 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate { 9, "misc_host_config" }, 4137c478bd9Sstevel@tonic-gate { 10, "dma_rw_control" }, 4147c478bd9Sstevel@tonic-gate { 11, "pci_bus_info" }, 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate { 12, "buff_mgr_status" }, 4177c478bd9Sstevel@tonic-gate { 13, "rcv_init_status" }, 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate { -1, NULL } 4207c478bd9Sstevel@tonic-gate }; 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate static int 4237c478bd9Sstevel@tonic-gate bge_driverinfo_update(kstat_t *ksp, int flag) 4247c478bd9Sstevel@tonic-gate { 4257c478bd9Sstevel@tonic-gate bge_t *bgep; 4267c478bd9Sstevel@tonic-gate kstat_named_t *knp; 4277c478bd9Sstevel@tonic-gate ddi_acc_handle_t handle; 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 4307c478bd9Sstevel@tonic-gate return (EACCES); 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 4337c478bd9Sstevel@tonic-gate knp = ksp->ks_data; 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->rx_buff[0].cookie.dmac_laddress; 4367c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->tx_buff[0].cookie.dmac_laddress; 4377c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->rx_desc[0].cookie.dmac_laddress; 4387c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->tx_desc.cookie.dmac_laddress; 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->send[0].tx_free; 4417c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->resched_needed; 4427c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->watchdog; 4437c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chip_resets; 4447c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->missed_dmas; 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate /* 4477c478bd9Sstevel@tonic-gate * Hold the mutex while accessing the chip registers 4487c478bd9Sstevel@tonic-gate * just in case the factotum is trying to reset it! 4497c478bd9Sstevel@tonic-gate */ 4507c478bd9Sstevel@tonic-gate handle = bgep->cfg_handle; 4517c478bd9Sstevel@tonic-gate mutex_enter(bgep->genlock); 4527c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_MHCR); 4537c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_PDRWCR); 4547c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_PCISTATE); 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bge_reg_get32(bgep, BUFFER_MANAGER_STATUS_REG); 4577c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bge_reg_get32(bgep, RCV_INITIATOR_STATUS_REG); 4587c478bd9Sstevel@tonic-gate mutex_exit(bgep->genlock); 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate return (0); 4617c478bd9Sstevel@tonic-gate } 4627c478bd9Sstevel@tonic-gate 4637c478bd9Sstevel@tonic-gate static const bge_ksindex_t bge_mii_kstats[] = { 4647c478bd9Sstevel@tonic-gate { 0, "%xcvr_addr" }, 4657c478bd9Sstevel@tonic-gate { 1, "%xcvr_id" }, 4667c478bd9Sstevel@tonic-gate { 2, "%xcvr_inuse" }, 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate { 3, "%cap_1000fdx" }, 4697c478bd9Sstevel@tonic-gate { 4, "%cap_1000hdx" }, 4707c478bd9Sstevel@tonic-gate { 5, "%cap_100fdx" }, 4717c478bd9Sstevel@tonic-gate { 6, "%cap_100hdx" }, 4727c478bd9Sstevel@tonic-gate { 7, "%cap_10fdx" }, 4737c478bd9Sstevel@tonic-gate { 8, "%cap_10hdx" }, 4747c478bd9Sstevel@tonic-gate { 9, "%cap_asmpause" }, 4757c478bd9Sstevel@tonic-gate { 10, "%cap_pause" }, 4767c478bd9Sstevel@tonic-gate { 11, "%cap_rem_fault" }, 4777c478bd9Sstevel@tonic-gate { 12, "%cap_autoneg" }, 4787c478bd9Sstevel@tonic-gate 4797c478bd9Sstevel@tonic-gate { 13, "%adv_cap_1000fdx" }, 4807c478bd9Sstevel@tonic-gate { 14, "%adv_cap_1000hdx" }, 4817c478bd9Sstevel@tonic-gate { 15, "%adv_cap_100fdx" }, 4827c478bd9Sstevel@tonic-gate { 16, "%adv_cap_100hdx" }, 4837c478bd9Sstevel@tonic-gate { 17, "%adv_cap_10fdx" }, 4847c478bd9Sstevel@tonic-gate { 18, "%adv_cap_10hdx" }, 4857c478bd9Sstevel@tonic-gate { 19, "%adv_cap_asmpause" }, 4867c478bd9Sstevel@tonic-gate { 20, "%adv_cap_pause" }, 4877c478bd9Sstevel@tonic-gate { 21, "%adv_rem_fault" }, 4887c478bd9Sstevel@tonic-gate { 22, "%adv_cap_autoneg" }, 4897c478bd9Sstevel@tonic-gate 4907c478bd9Sstevel@tonic-gate { 23, "%lp_cap_1000fdx" }, 4917c478bd9Sstevel@tonic-gate { 24, "%lp_cap_1000hdx" }, 4927c478bd9Sstevel@tonic-gate { 25, "%lp_cap_100fdx" }, 4937c478bd9Sstevel@tonic-gate { 26, "%lp_cap_100hdx" }, 4947c478bd9Sstevel@tonic-gate { 27, "%lp_cap_10fdx" }, 4957c478bd9Sstevel@tonic-gate { 28, "%lp_cap_10hdx" }, 4967c478bd9Sstevel@tonic-gate { 29, "%lp_cap_asmpause" }, 4977c478bd9Sstevel@tonic-gate { 30, "%lp_cap_pause" }, 4987c478bd9Sstevel@tonic-gate { 31, "%lp_rem_fault" }, 4997c478bd9Sstevel@tonic-gate { 32, "%lp_cap_autoneg" }, 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate { 33, "%link_asmpause" }, 5027c478bd9Sstevel@tonic-gate { 34, "%link_pause" }, 5037c478bd9Sstevel@tonic-gate { 35, "%link_duplex" }, 5047c478bd9Sstevel@tonic-gate { 36, "%link_up" }, 5057c478bd9Sstevel@tonic-gate 5067c478bd9Sstevel@tonic-gate { -1, NULL } 5077c478bd9Sstevel@tonic-gate }; 5087c478bd9Sstevel@tonic-gate 5097c478bd9Sstevel@tonic-gate /* 5107c478bd9Sstevel@tonic-gate * Derive and publish the standard "mii" kstats. 5117c478bd9Sstevel@tonic-gate * 5127c478bd9Sstevel@tonic-gate * The information required is somewhat scattered: some is already held 5137c478bd9Sstevel@tonic-gate * in driver softstate, some is available in the MII registers, and some 5147c478bd9Sstevel@tonic-gate * has to be computed from combinations of both ... 5157c478bd9Sstevel@tonic-gate */ 5167c478bd9Sstevel@tonic-gate static int 5177c478bd9Sstevel@tonic-gate bge_mii_update(kstat_t *ksp, int flag) 5187c478bd9Sstevel@tonic-gate { 5197c478bd9Sstevel@tonic-gate bge_t *bgep; 5207c478bd9Sstevel@tonic-gate kstat_named_t *knp; 5217c478bd9Sstevel@tonic-gate uint16_t anlpar; 5227c478bd9Sstevel@tonic-gate uint16_t anar; 5237c478bd9Sstevel@tonic-gate uint32_t xcvr_id; 5247c478bd9Sstevel@tonic-gate uint32_t xcvr_inuse; 5257c478bd9Sstevel@tonic-gate boolean_t asym_pause; 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 5287c478bd9Sstevel@tonic-gate return (EACCES); 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 5317c478bd9Sstevel@tonic-gate knp = ksp->ks_data; 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate /* 5347c478bd9Sstevel@tonic-gate * Read all the relevant PHY registers 5357c478bd9Sstevel@tonic-gate */ 5367c478bd9Sstevel@tonic-gate mutex_enter(bgep->genlock); 5377c478bd9Sstevel@tonic-gate anlpar = bge_mii_get16(bgep, MII_AN_LPABLE); 5387c478bd9Sstevel@tonic-gate anar = bge_mii_get16(bgep, MII_AN_ADVERT); 5397c478bd9Sstevel@tonic-gate 5407c478bd9Sstevel@tonic-gate /* 5417c478bd9Sstevel@tonic-gate * Derive PHY characterisation parameters 5427c478bd9Sstevel@tonic-gate */ 5437c478bd9Sstevel@tonic-gate xcvr_id = bge_mii_get16(bgep, MII_PHYIDH); 5447c478bd9Sstevel@tonic-gate xcvr_id <<= 16; 5457c478bd9Sstevel@tonic-gate xcvr_id |= bge_mii_get16(bgep, MII_PHYIDL); 5467c478bd9Sstevel@tonic-gate mutex_exit(bgep->genlock); 5477c478bd9Sstevel@tonic-gate 5487c478bd9Sstevel@tonic-gate switch (bgep->param_link_speed) { 5497c478bd9Sstevel@tonic-gate case 1000: 5507c478bd9Sstevel@tonic-gate if (bgep->chipid.flags & CHIP_FLAG_SERDES) 5517c478bd9Sstevel@tonic-gate xcvr_inuse = XCVR_TYPE_1000BASE_X; 5527c478bd9Sstevel@tonic-gate else 5537c478bd9Sstevel@tonic-gate xcvr_inuse = XCVR_TYPE_1000BASE_T; 5547c478bd9Sstevel@tonic-gate break; 5557c478bd9Sstevel@tonic-gate 5567c478bd9Sstevel@tonic-gate case 100: 5577c478bd9Sstevel@tonic-gate xcvr_inuse = XCVR_TYPE_100BASE_X; 5587c478bd9Sstevel@tonic-gate break; 5597c478bd9Sstevel@tonic-gate 5607c478bd9Sstevel@tonic-gate case 10: 5617c478bd9Sstevel@tonic-gate xcvr_inuse = XCVR_TYPE_10BASE_T; 5627c478bd9Sstevel@tonic-gate break; 5637c478bd9Sstevel@tonic-gate 5647c478bd9Sstevel@tonic-gate default: 5657c478bd9Sstevel@tonic-gate xcvr_inuse = XCVR_TYPE_UNDEFINED; 5667c478bd9Sstevel@tonic-gate break; 5677c478bd9Sstevel@tonic-gate } 5687c478bd9Sstevel@tonic-gate 5697c478bd9Sstevel@tonic-gate /* 5707c478bd9Sstevel@tonic-gate * Other miscellaneous transformations ... 5717c478bd9Sstevel@tonic-gate */ 5727c478bd9Sstevel@tonic-gate asym_pause = bgep->param_link_rx_pause != bgep->param_link_tx_pause; 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate /* 5757c478bd9Sstevel@tonic-gate * All required values are now available; assign them to the 5767c478bd9Sstevel@tonic-gate * actual kstats, in the sequence defined by the table above. 5777c478bd9Sstevel@tonic-gate */ 5787c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->phy_mii_addr; 5797c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = xcvr_id; 5807c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = xcvr_inuse; 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate /* 5837c478bd9Sstevel@tonic-gate * Our capabilities 5847c478bd9Sstevel@tonic-gate */ 5857c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_1000FDX_CAP].ndp_val; 5867c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_1000HDX_CAP].ndp_val; 5877c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_100FDX_CAP].ndp_val; 5887c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_100HDX_CAP].ndp_val; 5897c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_10FDX_CAP].ndp_val; 5907c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_10HDX_CAP].ndp_val; 5917c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_ASYM_PAUSE_CAP].ndp_val; 5927c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_PAUSE_CAP].ndp_val; 5937c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = B_TRUE; 5947c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->nd_params[PARAM_AUTONEG_CAP].ndp_val; 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate /* 5977c478bd9Sstevel@tonic-gate * Our *advertised* capabilities 5987c478bd9Sstevel@tonic-gate */ 5997c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_1000fdx; 6007c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_1000hdx; 6017c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_100fdx; 6027c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_100hdx; 6037c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_10fdx; 6047c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_10hdx; 6057c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_asym_pause; 6067c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_pause; 6077c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = (anar & MII_AN_ADVERT_REMFAULT) ? 1 : 0; 6087c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_adv_autoneg; 6097c478bd9Sstevel@tonic-gate 6107c478bd9Sstevel@tonic-gate /* 6117c478bd9Sstevel@tonic-gate * Link Partner's advertised capabilities 6127c478bd9Sstevel@tonic-gate */ 6137c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_1000fdx; 6147c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_1000hdx; 6157c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_100fdx; 6167c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_100hdx; 6177c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_10fdx; 6187c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_10hdx; 6197c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_asym_pause; 6207c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_pause; 6217c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = (anlpar & MII_AN_ADVERT_REMFAULT) ? 1 : 0; 6227c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_lp_autoneg; 6237c478bd9Sstevel@tonic-gate 6247c478bd9Sstevel@tonic-gate /* 6257c478bd9Sstevel@tonic-gate * Current operating modes 6267c478bd9Sstevel@tonic-gate */ 6277c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = asym_pause; 6287c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_link_rx_pause; 6297c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_link_duplex; 6307c478bd9Sstevel@tonic-gate (knp++)->value.ui32 = bgep->param_link_up; 6317c478bd9Sstevel@tonic-gate 6327c478bd9Sstevel@tonic-gate return (0); 6337c478bd9Sstevel@tonic-gate } 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate static const bge_ksindex_t bge_serdes[] = { 6367c478bd9Sstevel@tonic-gate { 0, "serdes_status" }, 6377c478bd9Sstevel@tonic-gate { 1, "serdes_advert" }, 6387c478bd9Sstevel@tonic-gate { 2, "serdes_lpadv" }, 6397c478bd9Sstevel@tonic-gate 6407c478bd9Sstevel@tonic-gate { -1, NULL } 6417c478bd9Sstevel@tonic-gate }; 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate static int 6447c478bd9Sstevel@tonic-gate bge_serdes_update(kstat_t *ksp, int flag) 6457c478bd9Sstevel@tonic-gate { 6467c478bd9Sstevel@tonic-gate bge_t *bgep; 6477c478bd9Sstevel@tonic-gate kstat_named_t *knp; 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 6507c478bd9Sstevel@tonic-gate return (EACCES); 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 6537c478bd9Sstevel@tonic-gate knp = ksp->ks_data; 6547c478bd9Sstevel@tonic-gate 6557c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->serdes_status; 6567c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->serdes_advert; 6577c478bd9Sstevel@tonic-gate (knp++)->value.ui64 = bgep->serdes_lpadv; 6587c478bd9Sstevel@tonic-gate 6597c478bd9Sstevel@tonic-gate return (0); 6607c478bd9Sstevel@tonic-gate } 6617c478bd9Sstevel@tonic-gate 6627c478bd9Sstevel@tonic-gate static const bge_ksindex_t bge_phydata[] = { 6637c478bd9Sstevel@tonic-gate { MII_CONTROL, "mii_control" }, 6647c478bd9Sstevel@tonic-gate { MII_STATUS, "mii_status" }, 6657c478bd9Sstevel@tonic-gate { MII_PHYIDH, "phy_identifier" }, 6667c478bd9Sstevel@tonic-gate { MII_AN_ADVERT, "an_advert" }, 6677c478bd9Sstevel@tonic-gate { MII_AN_LPABLE, "an_lp_ability" }, 6687c478bd9Sstevel@tonic-gate { MII_AN_EXPANSION, "an_expansion" }, 6697c478bd9Sstevel@tonic-gate { MII_AN_LPNXTPG, "an_lp_nextpage" }, 6707c478bd9Sstevel@tonic-gate { MII_1000BASE_T_CONTROL, "gbit_control" }, 6717c478bd9Sstevel@tonic-gate { MII_1000BASE_T_STATUS, "gbit_status" }, 6727c478bd9Sstevel@tonic-gate { MII_IEEE_EXT_STATUS, "ieee_ext_status" }, 6737c478bd9Sstevel@tonic-gate { MII_EXT_CONTROL, "phy_ext_control" }, 6747c478bd9Sstevel@tonic-gate { MII_EXT_STATUS, "phy_ext_status" }, 6757c478bd9Sstevel@tonic-gate { MII_RCV_ERR_COUNT, "receive_error_count" }, 6767c478bd9Sstevel@tonic-gate { MII_FALSE_CARR_COUNT, "false_carrier_count" }, 6777c478bd9Sstevel@tonic-gate { MII_RCV_NOT_OK_COUNT, "receiver_not_ok_count" }, 6787c478bd9Sstevel@tonic-gate { MII_AUX_CONTROL, "aux_control" }, 6797c478bd9Sstevel@tonic-gate { MII_AUX_STATUS, "aux_status" }, 6807c478bd9Sstevel@tonic-gate { MII_INTR_STATUS, "intr_status" }, 6817c478bd9Sstevel@tonic-gate { MII_INTR_MASK, "intr_mask" }, 6827c478bd9Sstevel@tonic-gate { MII_HCD_STATUS, "hcd_status" }, 6837c478bd9Sstevel@tonic-gate 6847c478bd9Sstevel@tonic-gate { -1, NULL } 6857c478bd9Sstevel@tonic-gate }; 6867c478bd9Sstevel@tonic-gate 6877c478bd9Sstevel@tonic-gate static int 6887c478bd9Sstevel@tonic-gate bge_phydata_update(kstat_t *ksp, int flag) 6897c478bd9Sstevel@tonic-gate { 6907c478bd9Sstevel@tonic-gate bge_t *bgep; 6917c478bd9Sstevel@tonic-gate kstat_named_t *knp; 6927c478bd9Sstevel@tonic-gate const bge_ksindex_t *ksip; 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate if (flag != KSTAT_READ) 6957c478bd9Sstevel@tonic-gate return (EACCES); 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate bgep = ksp->ks_private; 6987c478bd9Sstevel@tonic-gate knp = ksp->ks_data; 6997c478bd9Sstevel@tonic-gate 7007c478bd9Sstevel@tonic-gate /* 7017c478bd9Sstevel@tonic-gate * Read the PHY registers & update the kstats ... 7027c478bd9Sstevel@tonic-gate * 7037c478bd9Sstevel@tonic-gate * We need to hold the mutex while performing MII reads, but 7047c478bd9Sstevel@tonic-gate * we don't want to hold it across the entire sequence of reads. 7057c478bd9Sstevel@tonic-gate * So we grab and release it on each iteration, 'cos it doesn't 7067c478bd9Sstevel@tonic-gate * really matter if the kstats are less than 100% consistent ... 7077c478bd9Sstevel@tonic-gate */ 7087c478bd9Sstevel@tonic-gate for (ksip = bge_phydata; ksip->name != NULL; ++knp, ++ksip) { 7097c478bd9Sstevel@tonic-gate mutex_enter(bgep->genlock); 7107c478bd9Sstevel@tonic-gate switch (ksip->index) { 7117c478bd9Sstevel@tonic-gate case MII_STATUS: 7127c478bd9Sstevel@tonic-gate knp->value.ui64 = bgep->phy_gen_status; 7137c478bd9Sstevel@tonic-gate break; 7147c478bd9Sstevel@tonic-gate 7157c478bd9Sstevel@tonic-gate case MII_PHYIDH: 7167c478bd9Sstevel@tonic-gate knp->value.ui64 = bge_mii_get16(bgep, MII_PHYIDH); 7177c478bd9Sstevel@tonic-gate knp->value.ui64 <<= 16; 7187c478bd9Sstevel@tonic-gate knp->value.ui64 |= bge_mii_get16(bgep, MII_PHYIDL); 7197c478bd9Sstevel@tonic-gate break; 7207c478bd9Sstevel@tonic-gate 7217c478bd9Sstevel@tonic-gate default: 7227c478bd9Sstevel@tonic-gate knp->value.ui64 = bge_mii_get16(bgep, ksip->index); 7237c478bd9Sstevel@tonic-gate break; 7247c478bd9Sstevel@tonic-gate } 7257c478bd9Sstevel@tonic-gate mutex_exit(bgep->genlock); 7267c478bd9Sstevel@tonic-gate } 7277c478bd9Sstevel@tonic-gate 7287c478bd9Sstevel@tonic-gate return (0); 7297c478bd9Sstevel@tonic-gate } 7307c478bd9Sstevel@tonic-gate 7317c478bd9Sstevel@tonic-gate static kstat_t * 7327c478bd9Sstevel@tonic-gate bge_setup_named_kstat(bge_t *bgep, int instance, char *name, 7337c478bd9Sstevel@tonic-gate const bge_ksindex_t *ksip, size_t size, int (*update)(kstat_t *, int)) 7347c478bd9Sstevel@tonic-gate { 7357c478bd9Sstevel@tonic-gate kstat_t *ksp; 7367c478bd9Sstevel@tonic-gate kstat_named_t *knp; 7377c478bd9Sstevel@tonic-gate char *np; 7387c478bd9Sstevel@tonic-gate int type; 7397c478bd9Sstevel@tonic-gate 7407c478bd9Sstevel@tonic-gate size /= sizeof (bge_ksindex_t); 7417c478bd9Sstevel@tonic-gate ksp = kstat_create(BGE_DRIVER_NAME, instance, name, "net", 7427c478bd9Sstevel@tonic-gate KSTAT_TYPE_NAMED, size-1, KSTAT_FLAG_PERSISTENT); 7437c478bd9Sstevel@tonic-gate if (ksp == NULL) 7447c478bd9Sstevel@tonic-gate return (NULL); 7457c478bd9Sstevel@tonic-gate 7467c478bd9Sstevel@tonic-gate ksp->ks_private = bgep; 7477c478bd9Sstevel@tonic-gate ksp->ks_update = update; 7487c478bd9Sstevel@tonic-gate for (knp = ksp->ks_data; (np = ksip->name) != NULL; ++knp, ++ksip) { 7497c478bd9Sstevel@tonic-gate switch (*np) { 7507c478bd9Sstevel@tonic-gate default: 7517c478bd9Sstevel@tonic-gate type = KSTAT_DATA_UINT64; 7527c478bd9Sstevel@tonic-gate break; 7537c478bd9Sstevel@tonic-gate case '%': 7547c478bd9Sstevel@tonic-gate np += 1; 7557c478bd9Sstevel@tonic-gate type = KSTAT_DATA_UINT32; 7567c478bd9Sstevel@tonic-gate break; 7577c478bd9Sstevel@tonic-gate case '$': 7587c478bd9Sstevel@tonic-gate np += 1; 7597c478bd9Sstevel@tonic-gate type = KSTAT_DATA_STRING; 7607c478bd9Sstevel@tonic-gate break; 7617c478bd9Sstevel@tonic-gate case '&': 7627c478bd9Sstevel@tonic-gate np += 1; 7637c478bd9Sstevel@tonic-gate type = KSTAT_DATA_CHAR; 7647c478bd9Sstevel@tonic-gate break; 7657c478bd9Sstevel@tonic-gate } 7667c478bd9Sstevel@tonic-gate kstat_named_init(knp, np, type); 7677c478bd9Sstevel@tonic-gate } 7687c478bd9Sstevel@tonic-gate kstat_install(ksp); 7697c478bd9Sstevel@tonic-gate 7707c478bd9Sstevel@tonic-gate return (ksp); 7717c478bd9Sstevel@tonic-gate } 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate /* 7747c478bd9Sstevel@tonic-gate * Create kstats corresponding to NDD parameters 7757c478bd9Sstevel@tonic-gate */ 7767c478bd9Sstevel@tonic-gate static kstat_t * 7777c478bd9Sstevel@tonic-gate bge_setup_params_kstat(bge_t *bgep, int instance, char *name, 7787c478bd9Sstevel@tonic-gate int (*update)(kstat_t *, int)) 7797c478bd9Sstevel@tonic-gate { 7807c478bd9Sstevel@tonic-gate kstat_t *ksp; 7817c478bd9Sstevel@tonic-gate kstat_named_t *knp; 7827c478bd9Sstevel@tonic-gate int i; 7837c478bd9Sstevel@tonic-gate 7847c478bd9Sstevel@tonic-gate ksp = kstat_create(BGE_DRIVER_NAME, instance, name, "net", 7857c478bd9Sstevel@tonic-gate KSTAT_TYPE_NAMED, PARAM_COUNT, KSTAT_FLAG_PERSISTENT); 7867c478bd9Sstevel@tonic-gate if (ksp != NULL) { 7877c478bd9Sstevel@tonic-gate ksp->ks_private = bgep; 7887c478bd9Sstevel@tonic-gate ksp->ks_update = update; 7897c478bd9Sstevel@tonic-gate for (knp = ksp->ks_data, i = 0; i < PARAM_COUNT; ++knp, ++i) 7907c478bd9Sstevel@tonic-gate kstat_named_init(knp, bgep->nd_params[i].ndp_name+1, 7917c478bd9Sstevel@tonic-gate KSTAT_DATA_UINT64); 7927c478bd9Sstevel@tonic-gate kstat_install(ksp); 7937c478bd9Sstevel@tonic-gate } 7947c478bd9Sstevel@tonic-gate 7957c478bd9Sstevel@tonic-gate return (ksp); 7967c478bd9Sstevel@tonic-gate } 7977c478bd9Sstevel@tonic-gate 7987c478bd9Sstevel@tonic-gate void 7997c478bd9Sstevel@tonic-gate bge_init_kstats(bge_t *bgep, int instance) 8007c478bd9Sstevel@tonic-gate { 8017c478bd9Sstevel@tonic-gate kstat_t *ksp; 8027c478bd9Sstevel@tonic-gate 8037c478bd9Sstevel@tonic-gate BGE_TRACE(("bge_init_kstats($%p, %d)", (void *)bgep, instance)); 8047c478bd9Sstevel@tonic-gate 8058eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) { 8067c478bd9Sstevel@tonic-gate DMA_ZERO(bgep->statistics); 8078eb6c4f9Sly149593 bgep->bge_kstats[BGE_KSTAT_RAW] = ksp = 8088eb6c4f9Sly149593 kstat_create(BGE_DRIVER_NAME, instance, 8098eb6c4f9Sly149593 "raw_statistics", "net", KSTAT_TYPE_RAW, 8107c478bd9Sstevel@tonic-gate sizeof (bge_statistics_t), KSTAT_FLAG_VIRTUAL); 8117c478bd9Sstevel@tonic-gate if (ksp != NULL) { 8127c478bd9Sstevel@tonic-gate ksp->ks_data = DMA_VPTR(bgep->statistics); 8137c478bd9Sstevel@tonic-gate kstat_install(ksp); 8147c478bd9Sstevel@tonic-gate } 8157c478bd9Sstevel@tonic-gate 8167c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_STATS] = bge_setup_named_kstat(bgep, 8177c478bd9Sstevel@tonic-gate instance, "statistics", bge_statistics, 8187c478bd9Sstevel@tonic-gate sizeof (bge_statistics), bge_statistics_update); 8198eb6c4f9Sly149593 } else { 8208eb6c4f9Sly149593 bgep->bge_kstats[BGE_KSTAT_STATS] = bge_setup_named_kstat(bgep, 8218eb6c4f9Sly149593 instance, "statistics", bge_stat_val, 8228eb6c4f9Sly149593 sizeof (bge_stat_val), bge_statistics_update); 8238eb6c4f9Sly149593 } 8247c478bd9Sstevel@tonic-gate 8257c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_CHIPID] = bge_setup_named_kstat(bgep, 8267c478bd9Sstevel@tonic-gate instance, "chipid", bge_chipid, 8277c478bd9Sstevel@tonic-gate sizeof (bge_chipid), bge_chipid_update); 8287c478bd9Sstevel@tonic-gate 8297c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_DRIVER] = bge_setup_named_kstat(bgep, 8307c478bd9Sstevel@tonic-gate instance, "driverinfo", bge_driverinfo, 8317c478bd9Sstevel@tonic-gate sizeof (bge_driverinfo), bge_driverinfo_update); 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_MII] = bge_setup_named_kstat(bgep, 8347c478bd9Sstevel@tonic-gate instance, "mii", bge_mii_kstats, 8357c478bd9Sstevel@tonic-gate sizeof (bge_mii_kstats), bge_mii_update); 8367c478bd9Sstevel@tonic-gate 8377c478bd9Sstevel@tonic-gate if (bgep->chipid.flags & CHIP_FLAG_SERDES) 8387c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_PHYS] = bge_setup_named_kstat(bgep, 8397c478bd9Sstevel@tonic-gate instance, "serdes", bge_serdes, 8407c478bd9Sstevel@tonic-gate sizeof (bge_serdes), bge_serdes_update); 8417c478bd9Sstevel@tonic-gate else 8427c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_PHYS] = bge_setup_named_kstat(bgep, 8437c478bd9Sstevel@tonic-gate instance, "phydata", bge_phydata, 8447c478bd9Sstevel@tonic-gate sizeof (bge_phydata), bge_phydata_update); 8457c478bd9Sstevel@tonic-gate 8467c478bd9Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_PARAMS] = bge_setup_params_kstat(bgep, 8477c478bd9Sstevel@tonic-gate instance, "parameters", bge_params_update); 8487c478bd9Sstevel@tonic-gate } 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate void 8517c478bd9Sstevel@tonic-gate bge_fini_kstats(bge_t *bgep) 8527c478bd9Sstevel@tonic-gate { 8537c478bd9Sstevel@tonic-gate int i; 8547c478bd9Sstevel@tonic-gate 8557c478bd9Sstevel@tonic-gate BGE_TRACE(("bge_fini_kstats($%p)", (void *)bgep)); 8567c478bd9Sstevel@tonic-gate 8577c478bd9Sstevel@tonic-gate for (i = BGE_KSTAT_COUNT; --i >= 0; ) 8587c478bd9Sstevel@tonic-gate if (bgep->bge_kstats[i] != NULL) 8597c478bd9Sstevel@tonic-gate kstat_delete(bgep->bge_kstats[i]); 8607c478bd9Sstevel@tonic-gate } 8617c478bd9Sstevel@tonic-gate 8627c478bd9Sstevel@tonic-gate uint64_t 8637c478bd9Sstevel@tonic-gate bge_m_stat(void *arg, enum mac_stat stat) 8647c478bd9Sstevel@tonic-gate { 8657c478bd9Sstevel@tonic-gate bge_t *bgep = arg; 8668eb6c4f9Sly149593 bge_statistics_t *bstp; 8677c478bd9Sstevel@tonic-gate uint64_t val; 8687c478bd9Sstevel@tonic-gate 8698eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 8708eb6c4f9Sly149593 bstp = DMA_VPTR(bgep->statistics); 8718eb6c4f9Sly149593 else { 8728eb6c4f9Sly149593 8738eb6c4f9Sly149593 bgep->stat_val.ifHCOutOctets += 8748eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCOUT_OCTETS_REG); 8758eb6c4f9Sly149593 bgep->stat_val.etherStatsCollisions += 8768eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_ETHER_COLLIS_REG); 8778eb6c4f9Sly149593 bgep->stat_val.outXonSent += 8788eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_OUTXON_SENT_REG); 8798eb6c4f9Sly149593 bgep->stat_val.outXoffSent += 8808eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_OUTXOFF_SENT_REG); 8818eb6c4f9Sly149593 bgep->stat_val.dot3StatsInternalMacTransmitErrors += 8828eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_INTMACTX_ERR_REG); 8838eb6c4f9Sly149593 bgep->stat_val.dot3StatsSingleCollisionFrames += 8848eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_SCOLLI_FRAME_REG); 8858eb6c4f9Sly149593 bgep->stat_val.dot3StatsMultipleCollisionFrames += 8868eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_MCOLLI_FRAME_REG); 8878eb6c4f9Sly149593 bgep->stat_val.dot3StatsDeferredTransmissions += 8888eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_DEFERED_TX_REG); 8898eb6c4f9Sly149593 bgep->stat_val.dot3StatsExcessiveCollisions += 8908eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_EXCE_COLLI_REG); 8918eb6c4f9Sly149593 bgep->stat_val.dot3StatsLateCollisions += 8928eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_LATE_COLLI_REG); 8938eb6c4f9Sly149593 bgep->stat_val.ifHCOutUcastPkts += 8948eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCOUT_UPKGS_REG); 8958eb6c4f9Sly149593 bgep->stat_val.ifHCOutMulticastPkts += 8968eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCOUT_MPKGS_REG); 8978eb6c4f9Sly149593 bgep->stat_val.ifHCOutBroadcastPkts += 8988eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCOUT_BPKGS_REG); 8998eb6c4f9Sly149593 bgep->stat_val.ifHCInOctets += 9008eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCIN_OCTETS_REG); 9018eb6c4f9Sly149593 bgep->stat_val.etherStatsFragments += 9028eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_ETHER_FRAGMENT_REG); 9038eb6c4f9Sly149593 bgep->stat_val.ifHCInUcastPkts += 9048eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCIN_UPKGS_REG); 9058eb6c4f9Sly149593 bgep->stat_val.ifHCInMulticastPkts += 9068eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCIN_MPKGS_REG); 9078eb6c4f9Sly149593 bgep->stat_val.ifHCInBroadcastPkts += 9088eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_IFHCIN_BPKGS_REG); 9098eb6c4f9Sly149593 bgep->stat_val.dot3StatsFCSErrors += 9108eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_FCS_ERR_REG); 9118eb6c4f9Sly149593 bgep->stat_val.dot3StatsAlignmentErrors += 9128eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_ALIGN_ERR_REG); 9138eb6c4f9Sly149593 bgep->stat_val.xonPauseFramesReceived += 9148eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_XON_PAUSE_RX_REG); 9158eb6c4f9Sly149593 bgep->stat_val.xoffPauseFramesReceived += 9168eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_XOFF_PAUSE_RX_REG); 9178eb6c4f9Sly149593 bgep->stat_val.macControlFramesReceived += 9188eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_MAC_CTRL_RX_REG); 9198eb6c4f9Sly149593 bgep->stat_val.xoffStateEntered += 9208eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_XOFF_STATE_ENTER_REG); 9218eb6c4f9Sly149593 bgep->stat_val.dot3StatsFrameTooLongs += 9228eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_DOT3_FRAME_TOOLONG_REG); 9238eb6c4f9Sly149593 bgep->stat_val.etherStatsJabbers += 9248eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_ETHER_JABBERS_REG); 9258eb6c4f9Sly149593 bgep->stat_val.etherStatsUndersizePkts += 9268eb6c4f9Sly149593 bge_reg_get32(bgep, STAT_ETHER_UNDERSIZE_REG); 9278eb6c4f9Sly149593 } 9288eb6c4f9Sly149593 9297c478bd9Sstevel@tonic-gate switch (stat) { 9307c478bd9Sstevel@tonic-gate case MAC_STAT_IFSPEED: 9317c478bd9Sstevel@tonic-gate val = bgep->param_link_speed * 1000000ull; 9327c478bd9Sstevel@tonic-gate break; 9337c478bd9Sstevel@tonic-gate 9347c478bd9Sstevel@tonic-gate case MAC_STAT_MULTIRCV: 9358eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9367c478bd9Sstevel@tonic-gate val = bstp->s.ifHCInMulticastPkts; 9378eb6c4f9Sly149593 else 9388eb6c4f9Sly149593 val = bgep->stat_val.ifHCInMulticastPkts; 9397c478bd9Sstevel@tonic-gate break; 9407c478bd9Sstevel@tonic-gate 9417c478bd9Sstevel@tonic-gate case MAC_STAT_BRDCSTRCV: 9428eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9437c478bd9Sstevel@tonic-gate val = bstp->s.ifHCInBroadcastPkts; 9448eb6c4f9Sly149593 else 9458eb6c4f9Sly149593 val = bgep->stat_val.ifHCInBroadcastPkts; 9467c478bd9Sstevel@tonic-gate break; 9477c478bd9Sstevel@tonic-gate 9487c478bd9Sstevel@tonic-gate case MAC_STAT_MULTIXMT: 9498eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9507c478bd9Sstevel@tonic-gate val = bstp->s.ifHCOutMulticastPkts; 9518eb6c4f9Sly149593 else 9528eb6c4f9Sly149593 val = bgep->stat_val.ifHCOutMulticastPkts; 9537c478bd9Sstevel@tonic-gate break; 9547c478bd9Sstevel@tonic-gate 9557c478bd9Sstevel@tonic-gate case MAC_STAT_BRDCSTXMT: 9568eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9577c478bd9Sstevel@tonic-gate val = bstp->s.ifHCOutBroadcastPkts; 9588eb6c4f9Sly149593 else 9598eb6c4f9Sly149593 val = bgep->stat_val.ifHCOutBroadcastPkts; 9607c478bd9Sstevel@tonic-gate break; 9617c478bd9Sstevel@tonic-gate 9627c478bd9Sstevel@tonic-gate case MAC_STAT_NORCVBUF: 9638eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9647c478bd9Sstevel@tonic-gate val = bstp->s.ifInDiscards; 9658eb6c4f9Sly149593 else 9668eb6c4f9Sly149593 val = 0; 9677c478bd9Sstevel@tonic-gate break; 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate case MAC_STAT_IERRORS: 9708eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9717c478bd9Sstevel@tonic-gate val = bstp->s.ifInErrors; 9728eb6c4f9Sly149593 else 9738eb6c4f9Sly149593 val = 0; 9747c478bd9Sstevel@tonic-gate break; 9757c478bd9Sstevel@tonic-gate 9767c478bd9Sstevel@tonic-gate case MAC_STAT_NOXMTBUF: 9778eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9787c478bd9Sstevel@tonic-gate val = bstp->s.ifOutDiscards; 9798eb6c4f9Sly149593 else 9808eb6c4f9Sly149593 val = 0; 9817c478bd9Sstevel@tonic-gate break; 9827c478bd9Sstevel@tonic-gate 9837c478bd9Sstevel@tonic-gate case MAC_STAT_OERRORS: 9848eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9858eb6c4f9Sly149593 val = bstp->s.ifOutDiscards; 9868eb6c4f9Sly149593 else 9878eb6c4f9Sly149593 val = 0; 9887c478bd9Sstevel@tonic-gate break; 9897c478bd9Sstevel@tonic-gate 9907c478bd9Sstevel@tonic-gate case MAC_STAT_COLLISIONS: 9918eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9927c478bd9Sstevel@tonic-gate val = bstp->s.etherStatsCollisions; 9938eb6c4f9Sly149593 else 9948eb6c4f9Sly149593 val = bgep->stat_val.etherStatsCollisions; 9957c478bd9Sstevel@tonic-gate break; 9967c478bd9Sstevel@tonic-gate 9977c478bd9Sstevel@tonic-gate case MAC_STAT_RBYTES: 9988eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 9997c478bd9Sstevel@tonic-gate val = bstp->s.ifHCInOctets; 10008eb6c4f9Sly149593 else 10018eb6c4f9Sly149593 val = bgep->stat_val.ifHCInOctets; 10027c478bd9Sstevel@tonic-gate break; 10037c478bd9Sstevel@tonic-gate 10047c478bd9Sstevel@tonic-gate case MAC_STAT_IPACKETS: 10058eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10067c478bd9Sstevel@tonic-gate val = bstp->s.ifHCInUcastPkts + 10077c478bd9Sstevel@tonic-gate bstp->s.ifHCInMulticastPkts + 10087c478bd9Sstevel@tonic-gate bstp->s.ifHCInBroadcastPkts; 10098eb6c4f9Sly149593 else 10108eb6c4f9Sly149593 val = bgep->stat_val.ifHCInUcastPkts + 10118eb6c4f9Sly149593 bgep->stat_val.ifHCInMulticastPkts + 10128eb6c4f9Sly149593 bgep->stat_val.ifHCInBroadcastPkts; 10137c478bd9Sstevel@tonic-gate break; 10147c478bd9Sstevel@tonic-gate 10157c478bd9Sstevel@tonic-gate case MAC_STAT_OBYTES: 10168eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10177c478bd9Sstevel@tonic-gate val = bstp->s.ifHCOutOctets; 10188eb6c4f9Sly149593 else 10198eb6c4f9Sly149593 val = bgep->stat_val.ifHCOutOctets; 10207c478bd9Sstevel@tonic-gate break; 10217c478bd9Sstevel@tonic-gate 10227c478bd9Sstevel@tonic-gate case MAC_STAT_OPACKETS: 10238eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10247c478bd9Sstevel@tonic-gate val = bstp->s.ifHCOutUcastPkts + 10257c478bd9Sstevel@tonic-gate bstp->s.ifHCOutMulticastPkts + 10267c478bd9Sstevel@tonic-gate bstp->s.ifHCOutBroadcastPkts; 10278eb6c4f9Sly149593 else 10288eb6c4f9Sly149593 val = bgep->stat_val.ifHCOutUcastPkts + 10298eb6c4f9Sly149593 bgep->stat_val.ifHCOutMulticastPkts + 10308eb6c4f9Sly149593 bgep->stat_val.ifHCOutBroadcastPkts; 10317c478bd9Sstevel@tonic-gate break; 10327c478bd9Sstevel@tonic-gate 10337c478bd9Sstevel@tonic-gate case MAC_STAT_ALIGN_ERRORS: 10348eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10357c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsAlignmentErrors; 10368eb6c4f9Sly149593 else 10378eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsAlignmentErrors; 10387c478bd9Sstevel@tonic-gate break; 10397c478bd9Sstevel@tonic-gate 10407c478bd9Sstevel@tonic-gate case MAC_STAT_FCS_ERRORS: 10418eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10427c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsFCSErrors; 10438eb6c4f9Sly149593 else 10448eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsFCSErrors; 10457c478bd9Sstevel@tonic-gate break; 10467c478bd9Sstevel@tonic-gate 10477c478bd9Sstevel@tonic-gate case MAC_STAT_FIRST_COLLISIONS: 10488eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10497c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsSingleCollisionFrames; 10508eb6c4f9Sly149593 else 10518eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsSingleCollisionFrames; 10527c478bd9Sstevel@tonic-gate break; 10537c478bd9Sstevel@tonic-gate 10547c478bd9Sstevel@tonic-gate case MAC_STAT_MULTI_COLLISIONS: 10558eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10567c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsMultipleCollisionFrames; 10578eb6c4f9Sly149593 else 10588eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsMultipleCollisionFrames; 10597c478bd9Sstevel@tonic-gate break; 10607c478bd9Sstevel@tonic-gate 10617c478bd9Sstevel@tonic-gate case MAC_STAT_DEFER_XMTS: 10628eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10637c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsDeferredTransmissions; 10648eb6c4f9Sly149593 else 10658eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsDeferredTransmissions; 10667c478bd9Sstevel@tonic-gate break; 10677c478bd9Sstevel@tonic-gate 10687c478bd9Sstevel@tonic-gate case MAC_STAT_TX_LATE_COLLISIONS: 10698eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10707c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsLateCollisions; 10718eb6c4f9Sly149593 else 10728eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsLateCollisions; 10737c478bd9Sstevel@tonic-gate break; 10747c478bd9Sstevel@tonic-gate 10757c478bd9Sstevel@tonic-gate case MAC_STAT_EX_COLLISIONS: 10768eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10777c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsExcessiveCollisions; 10788eb6c4f9Sly149593 else 10798eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsExcessiveCollisions; 10807c478bd9Sstevel@tonic-gate break; 10817c478bd9Sstevel@tonic-gate 10827c478bd9Sstevel@tonic-gate case MAC_STAT_MACXMT_ERRORS: 10838eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10847c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsInternalMacTransmitErrors; 10858eb6c4f9Sly149593 else 10868eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsInternalMacTransmitErrors; 10877c478bd9Sstevel@tonic-gate break; 10887c478bd9Sstevel@tonic-gate 10897c478bd9Sstevel@tonic-gate case MAC_STAT_CARRIER_ERRORS: 10908eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10917c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsCarrierSenseErrors; 10928eb6c4f9Sly149593 else 10938eb6c4f9Sly149593 val = 0; 10947c478bd9Sstevel@tonic-gate break; 10957c478bd9Sstevel@tonic-gate 10967c478bd9Sstevel@tonic-gate case MAC_STAT_TOOLONG_ERRORS: 10978eb6c4f9Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) 10987c478bd9Sstevel@tonic-gate val = bstp->s.dot3StatsFrameTooLongs; 10998eb6c4f9Sly149593 else 11008eb6c4f9Sly149593 val = bgep->stat_val.dot3StatsFrameTooLongs; 11017c478bd9Sstevel@tonic-gate break; 11027c478bd9Sstevel@tonic-gate 11037c478bd9Sstevel@tonic-gate case MAC_STAT_XCVR_ADDR: 11047c478bd9Sstevel@tonic-gate val = bgep->phy_mii_addr; 11057c478bd9Sstevel@tonic-gate break; 11067c478bd9Sstevel@tonic-gate 11077c478bd9Sstevel@tonic-gate case MAC_STAT_XCVR_ID: 11087c478bd9Sstevel@tonic-gate mutex_enter(bgep->genlock); 11097c478bd9Sstevel@tonic-gate val = bge_mii_get16(bgep, MII_PHYIDH); 11107c478bd9Sstevel@tonic-gate val <<= 16; 11117c478bd9Sstevel@tonic-gate val |= bge_mii_get16(bgep, MII_PHYIDL); 11127c478bd9Sstevel@tonic-gate mutex_exit(bgep->genlock); 11137c478bd9Sstevel@tonic-gate break; 11147c478bd9Sstevel@tonic-gate 11157c478bd9Sstevel@tonic-gate case MAC_STAT_XCVR_INUSE: 11167c478bd9Sstevel@tonic-gate val = XCVR_1000T; 11177c478bd9Sstevel@tonic-gate break; 11187c478bd9Sstevel@tonic-gate 11197c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_1000FDX: 11207c478bd9Sstevel@tonic-gate val = 1; 11217c478bd9Sstevel@tonic-gate break; 11227c478bd9Sstevel@tonic-gate 11237c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_1000HDX: 11247c478bd9Sstevel@tonic-gate val = 1; 11257c478bd9Sstevel@tonic-gate break; 11267c478bd9Sstevel@tonic-gate 11277c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_100FDX: 11287c478bd9Sstevel@tonic-gate val = 1; 11297c478bd9Sstevel@tonic-gate break; 11307c478bd9Sstevel@tonic-gate 11317c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_100HDX: 11327c478bd9Sstevel@tonic-gate val = 1; 11337c478bd9Sstevel@tonic-gate break; 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_10FDX: 11367c478bd9Sstevel@tonic-gate val = 1; 11377c478bd9Sstevel@tonic-gate break; 11387c478bd9Sstevel@tonic-gate 11397c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_10HDX: 11407c478bd9Sstevel@tonic-gate val = 1; 11417c478bd9Sstevel@tonic-gate break; 11427c478bd9Sstevel@tonic-gate 11437c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_ASMPAUSE: 11447c478bd9Sstevel@tonic-gate val = 1; 11457c478bd9Sstevel@tonic-gate break; 11467c478bd9Sstevel@tonic-gate 11477c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_PAUSE: 11487c478bd9Sstevel@tonic-gate val = 1; 11497c478bd9Sstevel@tonic-gate break; 11507c478bd9Sstevel@tonic-gate 11517c478bd9Sstevel@tonic-gate case MAC_STAT_CAP_AUTONEG: 11527c478bd9Sstevel@tonic-gate val = 1; 11537c478bd9Sstevel@tonic-gate break; 11547c478bd9Sstevel@tonic-gate 11557c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_1000FDX: 11567c478bd9Sstevel@tonic-gate val = bgep->param_adv_1000fdx; 11577c478bd9Sstevel@tonic-gate break; 11587c478bd9Sstevel@tonic-gate 11597c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_1000HDX: 11607c478bd9Sstevel@tonic-gate val = bgep->param_adv_1000hdx; 11617c478bd9Sstevel@tonic-gate break; 11627c478bd9Sstevel@tonic-gate 11637c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_100FDX: 11647c478bd9Sstevel@tonic-gate val = bgep->param_adv_100fdx; 11657c478bd9Sstevel@tonic-gate break; 11667c478bd9Sstevel@tonic-gate 11677c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_100HDX: 11687c478bd9Sstevel@tonic-gate val = bgep->param_adv_100hdx; 11697c478bd9Sstevel@tonic-gate break; 11707c478bd9Sstevel@tonic-gate 11717c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_10FDX: 11727c478bd9Sstevel@tonic-gate val = bgep->param_adv_10fdx; 11737c478bd9Sstevel@tonic-gate break; 11747c478bd9Sstevel@tonic-gate 11757c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_10HDX: 11767c478bd9Sstevel@tonic-gate val = bgep->param_adv_10hdx; 11777c478bd9Sstevel@tonic-gate break; 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_ASMPAUSE: 11807c478bd9Sstevel@tonic-gate val = bgep->param_adv_asym_pause; 11817c478bd9Sstevel@tonic-gate break; 11827c478bd9Sstevel@tonic-gate 11837c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_PAUSE: 11847c478bd9Sstevel@tonic-gate val = bgep->param_adv_pause; 11857c478bd9Sstevel@tonic-gate break; 11867c478bd9Sstevel@tonic-gate 11877c478bd9Sstevel@tonic-gate case MAC_STAT_ADV_CAP_AUTONEG: 11887c478bd9Sstevel@tonic-gate val = bgep->param_adv_autoneg; 11897c478bd9Sstevel@tonic-gate break; 11907c478bd9Sstevel@tonic-gate 11917c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_1000FDX: 11927c478bd9Sstevel@tonic-gate val = bgep->param_lp_1000fdx; 11937c478bd9Sstevel@tonic-gate break; 11947c478bd9Sstevel@tonic-gate 11957c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_1000HDX: 11967c478bd9Sstevel@tonic-gate val = bgep->param_lp_1000hdx; 11977c478bd9Sstevel@tonic-gate break; 11987c478bd9Sstevel@tonic-gate 11997c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_100FDX: 12007c478bd9Sstevel@tonic-gate val = bgep->param_lp_100fdx; 12017c478bd9Sstevel@tonic-gate break; 12027c478bd9Sstevel@tonic-gate 12037c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_100HDX: 12047c478bd9Sstevel@tonic-gate val = bgep->param_lp_100hdx; 12057c478bd9Sstevel@tonic-gate break; 12067c478bd9Sstevel@tonic-gate 12077c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_10FDX: 12087c478bd9Sstevel@tonic-gate val = bgep->param_lp_10fdx; 12097c478bd9Sstevel@tonic-gate break; 12107c478bd9Sstevel@tonic-gate 12117c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_10HDX: 12127c478bd9Sstevel@tonic-gate val = bgep->param_lp_10hdx; 12137c478bd9Sstevel@tonic-gate break; 12147c478bd9Sstevel@tonic-gate 12157c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_ASMPAUSE: 12167c478bd9Sstevel@tonic-gate val = bgep->param_lp_asym_pause; 12177c478bd9Sstevel@tonic-gate break; 12187c478bd9Sstevel@tonic-gate 12197c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_PAUSE: 12207c478bd9Sstevel@tonic-gate val = bgep->param_lp_pause; 12217c478bd9Sstevel@tonic-gate break; 12227c478bd9Sstevel@tonic-gate 12237c478bd9Sstevel@tonic-gate case MAC_STAT_LP_CAP_AUTONEG: 12247c478bd9Sstevel@tonic-gate val = bgep->param_lp_autoneg; 12257c478bd9Sstevel@tonic-gate break; 12267c478bd9Sstevel@tonic-gate 12277c478bd9Sstevel@tonic-gate case MAC_STAT_LINK_ASMPAUSE: 12287c478bd9Sstevel@tonic-gate val = bgep->param_adv_asym_pause && 12297c478bd9Sstevel@tonic-gate bgep->param_lp_asym_pause && 12307c478bd9Sstevel@tonic-gate bgep->param_adv_pause != bgep->param_lp_pause; 12317c478bd9Sstevel@tonic-gate break; 12327c478bd9Sstevel@tonic-gate 12337c478bd9Sstevel@tonic-gate case MAC_STAT_LINK_PAUSE: 12347c478bd9Sstevel@tonic-gate val = bgep->param_link_rx_pause; 12357c478bd9Sstevel@tonic-gate break; 12367c478bd9Sstevel@tonic-gate 12377c478bd9Sstevel@tonic-gate case MAC_STAT_LINK_AUTONEG: 12387c478bd9Sstevel@tonic-gate val = bgep->param_link_autoneg; 12397c478bd9Sstevel@tonic-gate break; 12407c478bd9Sstevel@tonic-gate 12417c478bd9Sstevel@tonic-gate case MAC_STAT_LINK_DUPLEX: 12427c478bd9Sstevel@tonic-gate val = bgep->param_link_duplex; 12437c478bd9Sstevel@tonic-gate break; 12447c478bd9Sstevel@tonic-gate 12457c478bd9Sstevel@tonic-gate #ifdef DEBUG 12467c478bd9Sstevel@tonic-gate default: 12477c478bd9Sstevel@tonic-gate /* 12487c478bd9Sstevel@tonic-gate * Shouldn't reach here... 12497c478bd9Sstevel@tonic-gate */ 12507c478bd9Sstevel@tonic-gate cmn_err(CE_PANIC, 12517c478bd9Sstevel@tonic-gate "bge_m_stat: unrecognized parameter value = %d", 12527c478bd9Sstevel@tonic-gate stat); 12537c478bd9Sstevel@tonic-gate #endif 12547c478bd9Sstevel@tonic-gate } 12557c478bd9Sstevel@tonic-gate 12567c478bd9Sstevel@tonic-gate return (val); 12577c478bd9Sstevel@tonic-gate } 1258