10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51369Sdduvall * Common Development and Distribution License (the "License").
61369Sdduvall * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
211369Sdduvall
220Sstevel@tonic-gate /*
23*11878SVenu.Iyer@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
272675Szh199473 #include "bge_impl.h"
280Sstevel@tonic-gate
290Sstevel@tonic-gate #define BGE_DBG BGE_DBG_STATS /* debug flag for this code */
300Sstevel@tonic-gate
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate * Local datatype for defining tables of (Offset, Name) pairs
330Sstevel@tonic-gate */
340Sstevel@tonic-gate typedef struct {
350Sstevel@tonic-gate offset_t index;
360Sstevel@tonic-gate char *name;
370Sstevel@tonic-gate } bge_ksindex_t;
380Sstevel@tonic-gate
390Sstevel@tonic-gate
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate * Table of Hardware-defined Statistics Block Offsets and Names
420Sstevel@tonic-gate */
430Sstevel@tonic-gate #define KS_NAME(s) { KS_ ## s, #s }
440Sstevel@tonic-gate
450Sstevel@tonic-gate static const bge_ksindex_t bge_statistics[] = {
460Sstevel@tonic-gate KS_NAME(ifHCInOctets),
470Sstevel@tonic-gate KS_NAME(etherStatsFragments),
480Sstevel@tonic-gate KS_NAME(ifHCInUcastPkts),
490Sstevel@tonic-gate KS_NAME(ifHCInMulticastPkts),
500Sstevel@tonic-gate KS_NAME(ifHCInBroadcastPkts),
510Sstevel@tonic-gate KS_NAME(dot3StatsFCSErrors),
520Sstevel@tonic-gate KS_NAME(dot3StatsAlignmentErrors),
530Sstevel@tonic-gate KS_NAME(xonPauseFramesReceived),
540Sstevel@tonic-gate KS_NAME(xoffPauseFramesReceived),
550Sstevel@tonic-gate KS_NAME(macControlFramesReceived),
560Sstevel@tonic-gate KS_NAME(xoffStateEntered),
570Sstevel@tonic-gate KS_NAME(dot3StatsFrameTooLongs),
580Sstevel@tonic-gate KS_NAME(etherStatsJabbers),
590Sstevel@tonic-gate KS_NAME(etherStatsUndersizePkts),
600Sstevel@tonic-gate KS_NAME(inRangeLengthError),
610Sstevel@tonic-gate KS_NAME(outRangeLengthError),
620Sstevel@tonic-gate KS_NAME(etherStatsPkts64Octets),
630Sstevel@tonic-gate KS_NAME(etherStatsPkts65to127Octets),
640Sstevel@tonic-gate KS_NAME(etherStatsPkts128to255Octets),
650Sstevel@tonic-gate KS_NAME(etherStatsPkts256to511Octets),
660Sstevel@tonic-gate KS_NAME(etherStatsPkts512to1023Octets),
670Sstevel@tonic-gate KS_NAME(etherStatsPkts1024to1518Octets),
680Sstevel@tonic-gate KS_NAME(etherStatsPkts1519to2047Octets),
690Sstevel@tonic-gate KS_NAME(etherStatsPkts2048to4095Octets),
700Sstevel@tonic-gate KS_NAME(etherStatsPkts4096to8191Octets),
710Sstevel@tonic-gate KS_NAME(etherStatsPkts8192to9022Octets),
720Sstevel@tonic-gate
730Sstevel@tonic-gate KS_NAME(ifHCOutOctets),
740Sstevel@tonic-gate KS_NAME(etherStatsCollisions),
750Sstevel@tonic-gate KS_NAME(outXonSent),
760Sstevel@tonic-gate KS_NAME(outXoffSent),
770Sstevel@tonic-gate KS_NAME(flowControlDone),
780Sstevel@tonic-gate KS_NAME(dot3StatsInternalMacTransmitErrors),
790Sstevel@tonic-gate KS_NAME(dot3StatsSingleCollisionFrames),
800Sstevel@tonic-gate KS_NAME(dot3StatsMultipleCollisionFrames),
810Sstevel@tonic-gate KS_NAME(dot3StatsDeferredTransmissions),
820Sstevel@tonic-gate KS_NAME(dot3StatsExcessiveCollisions),
830Sstevel@tonic-gate KS_NAME(dot3StatsLateCollisions),
840Sstevel@tonic-gate KS_NAME(dot3Collided2Times),
850Sstevel@tonic-gate KS_NAME(dot3Collided3Times),
860Sstevel@tonic-gate KS_NAME(dot3Collided4Times),
870Sstevel@tonic-gate KS_NAME(dot3Collided5Times),
880Sstevel@tonic-gate KS_NAME(dot3Collided6Times),
890Sstevel@tonic-gate KS_NAME(dot3Collided7Times),
900Sstevel@tonic-gate KS_NAME(dot3Collided8Times),
910Sstevel@tonic-gate KS_NAME(dot3Collided9Times),
920Sstevel@tonic-gate KS_NAME(dot3Collided10Times),
930Sstevel@tonic-gate KS_NAME(dot3Collided11Times),
940Sstevel@tonic-gate KS_NAME(dot3Collided12Times),
950Sstevel@tonic-gate KS_NAME(dot3Collided13Times),
960Sstevel@tonic-gate KS_NAME(dot3Collided14Times),
970Sstevel@tonic-gate KS_NAME(dot3Collided15Times),
980Sstevel@tonic-gate KS_NAME(ifHCOutUcastPkts),
990Sstevel@tonic-gate KS_NAME(ifHCOutMulticastPkts),
1000Sstevel@tonic-gate KS_NAME(ifHCOutBroadcastPkts),
1010Sstevel@tonic-gate KS_NAME(dot3StatsCarrierSenseErrors),
1020Sstevel@tonic-gate KS_NAME(ifOutDiscards),
1030Sstevel@tonic-gate KS_NAME(ifOutErrors),
1040Sstevel@tonic-gate
1050Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_1),
1060Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_2),
1070Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_3),
1080Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_4),
1090Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_5),
1100Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_6),
1110Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_7),
1120Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_8),
1130Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_9),
1140Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_10),
1150Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_11),
1160Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_12),
1170Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_13),
1180Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_14),
1190Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_15),
1200Sstevel@tonic-gate KS_NAME(COSIfHCInPkts_16),
1210Sstevel@tonic-gate KS_NAME(COSFramesDroppedDueToFilters),
1220Sstevel@tonic-gate KS_NAME(nicDmaWriteQueueFull),
1230Sstevel@tonic-gate KS_NAME(nicDmaWriteHighPriQueueFull),
1240Sstevel@tonic-gate KS_NAME(nicNoMoreRxBDs),
1250Sstevel@tonic-gate KS_NAME(ifInDiscards),
1260Sstevel@tonic-gate KS_NAME(ifInErrors),
1270Sstevel@tonic-gate KS_NAME(nicRecvThresholdHit),
1280Sstevel@tonic-gate
1290Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_1),
1300Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_2),
1310Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_3),
1320Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_4),
1330Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_5),
1340Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_6),
1350Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_7),
1360Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_8),
1370Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_9),
1380Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_10),
1390Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_11),
1400Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_12),
1410Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_13),
1420Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_14),
1430Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_15),
1440Sstevel@tonic-gate KS_NAME(COSIfHCOutPkts_16),
1450Sstevel@tonic-gate KS_NAME(nicDmaReadQueueFull),
1460Sstevel@tonic-gate KS_NAME(nicDmaReadHighPriQueueFull),
1470Sstevel@tonic-gate KS_NAME(nicSendDataCompQueueFull),
1480Sstevel@tonic-gate KS_NAME(nicRingSetSendProdIndex),
1490Sstevel@tonic-gate KS_NAME(nicRingStatusUpdate),
1500Sstevel@tonic-gate KS_NAME(nicInterrupts),
1510Sstevel@tonic-gate KS_NAME(nicAvoidedInterrupts),
1520Sstevel@tonic-gate KS_NAME(nicSendThresholdHit),
1530Sstevel@tonic-gate
1540Sstevel@tonic-gate { KS_STATS_SIZE, NULL }
1550Sstevel@tonic-gate };
1560Sstevel@tonic-gate
1571102Sly149593 static const bge_ksindex_t bge_stat_val[] = {
1581102Sly149593 KS_NAME(ifHCOutOctets),
1591102Sly149593 KS_NAME(etherStatsCollisions),
1601102Sly149593 KS_NAME(outXonSent),
1611102Sly149593 KS_NAME(outXoffSent),
1621102Sly149593 KS_NAME(dot3StatsInternalMacTransmitErrors),
1631102Sly149593 KS_NAME(dot3StatsSingleCollisionFrames),
1641102Sly149593 KS_NAME(dot3StatsMultipleCollisionFrames),
1651102Sly149593 KS_NAME(dot3StatsDeferredTransmissions),
1661102Sly149593 KS_NAME(dot3StatsExcessiveCollisions),
1671102Sly149593 KS_NAME(dot3StatsLateCollisions),
1681102Sly149593 KS_NAME(ifHCOutUcastPkts),
1691102Sly149593 KS_NAME(ifHCOutMulticastPkts),
1701102Sly149593 KS_NAME(ifHCOutBroadcastPkts),
1711102Sly149593 KS_NAME(ifHCInOctets),
1721102Sly149593 KS_NAME(etherStatsFragments),
1731102Sly149593 KS_NAME(ifHCInUcastPkts),
1741102Sly149593 KS_NAME(ifHCInMulticastPkts),
1751102Sly149593 KS_NAME(ifHCInBroadcastPkts),
1761102Sly149593 KS_NAME(dot3StatsFCSErrors),
1771102Sly149593 KS_NAME(dot3StatsAlignmentErrors),
1781102Sly149593 KS_NAME(xonPauseFramesReceived),
1791102Sly149593 KS_NAME(xoffPauseFramesReceived),
1801102Sly149593 KS_NAME(macControlFramesReceived),
1811102Sly149593 KS_NAME(xoffStateEntered),
1821102Sly149593 KS_NAME(dot3StatsFrameTooLongs),
1831102Sly149593 KS_NAME(etherStatsJabbers),
1841102Sly149593 KS_NAME(etherStatsUndersizePkts),
1851102Sly149593
1861102Sly149593 { KS_STAT_REG_SIZE, NULL }
1871102Sly149593 };
1881102Sly149593
1890Sstevel@tonic-gate static int
bge_statistics_update(kstat_t * ksp,int flag)1900Sstevel@tonic-gate bge_statistics_update(kstat_t *ksp, int flag)
1910Sstevel@tonic-gate {
1920Sstevel@tonic-gate bge_t *bgep;
1930Sstevel@tonic-gate bge_statistics_t *bstp;
1943334Sgs150176 bge_statistics_reg_t *pstats;
1950Sstevel@tonic-gate kstat_named_t *knp;
1960Sstevel@tonic-gate const bge_ksindex_t *ksip;
1970Sstevel@tonic-gate
1980Sstevel@tonic-gate if (flag != KSTAT_READ)
1990Sstevel@tonic-gate return (EACCES);
2000Sstevel@tonic-gate
2010Sstevel@tonic-gate bgep = ksp->ks_private;
2021102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
2031102Sly149593 bstp = DMA_VPTR(bgep->statistics);
2041102Sly149593
2050Sstevel@tonic-gate knp = ksp->ks_data;
2060Sstevel@tonic-gate
2070Sstevel@tonic-gate /*
2080Sstevel@tonic-gate * Transfer the statistics values from the copy that the
2090Sstevel@tonic-gate * chip updates via DMA to the named-kstat structure.
2100Sstevel@tonic-gate *
2110Sstevel@tonic-gate * As above, we don't bother to sync or stop updates to the
2120Sstevel@tonic-gate * statistics, 'cos it doesn't really matter if they're a few
2132135Szh199473 * microseconds out of date or less than 100% consistent ...
2140Sstevel@tonic-gate */
2151102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
2161102Sly149593 for (ksip = bge_statistics; ksip->name != NULL; ++knp, ++ksip)
2171102Sly149593 knp->value.ui64 = bstp->a[ksip->index];
2181102Sly149593 else {
2193334Sgs150176 pstats = bgep->pstats;
2203334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCOutOctets);
2213334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->etherStatsCollisions);
2223334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->outXonSent);
2233334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->outXoffSent);
2241102Sly149593 (knp++)->value.ui64 =
2253334Sgs150176 (uint64_t)(pstats->dot3StatsInternalMacTransmitErrors);
2261102Sly149593 (knp++)->value.ui64 =
2273334Sgs150176 (uint64_t)(pstats->dot3StatsSingleCollisionFrames);
2281102Sly149593 (knp++)->value.ui64 =
2293334Sgs150176 (uint64_t)(pstats->dot3StatsMultipleCollisionFrames);
2301102Sly149593 (knp++)->value.ui64 =
2313334Sgs150176 (uint64_t)(pstats->dot3StatsDeferredTransmissions);
2321102Sly149593 (knp++)->value.ui64 =
2333334Sgs150176 (uint64_t)(pstats->dot3StatsExcessiveCollisions);
2341102Sly149593 (knp++)->value.ui64 =
2353334Sgs150176 (uint64_t)(pstats->dot3StatsLateCollisions);
2363334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCOutUcastPkts);
2373334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCOutMulticastPkts);
2383334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCOutBroadcastPkts);
2393334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCInOctets);
2403334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->etherStatsFragments);
2413334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCInUcastPkts);
2423334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCInMulticastPkts);
2433334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->ifHCInBroadcastPkts);
2443334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->dot3StatsFCSErrors);
2451102Sly149593 (knp++)->value.ui64 =
2463334Sgs150176 (uint64_t)(pstats->dot3StatsAlignmentErrors);
2471102Sly149593 (knp++)->value.ui64 =
2483334Sgs150176 (uint64_t)(pstats->xonPauseFramesReceived);
2491102Sly149593 (knp++)->value.ui64 =
2503334Sgs150176 (uint64_t)(pstats->xoffPauseFramesReceived);
2511102Sly149593 (knp++)->value.ui64 =
2523334Sgs150176 (uint64_t)(pstats->macControlFramesReceived);
2533334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->xoffStateEntered);
2541102Sly149593 (knp++)->value.ui64 =
2553334Sgs150176 (uint64_t)(pstats->dot3StatsFrameTooLongs);
2563334Sgs150176 (knp++)->value.ui64 = (uint64_t)(pstats->etherStatsJabbers);
2571102Sly149593 (knp++)->value.ui64 =
2583334Sgs150176 (uint64_t)(pstats->etherStatsUndersizePkts);
2591102Sly149593 }
2600Sstevel@tonic-gate
2610Sstevel@tonic-gate return (0);
2620Sstevel@tonic-gate }
2630Sstevel@tonic-gate
2640Sstevel@tonic-gate static const bge_ksindex_t bge_chipid[] = {
2650Sstevel@tonic-gate { 0, "asic_rev" },
2660Sstevel@tonic-gate { 1, "businfo" },
2670Sstevel@tonic-gate { 2, "command" },
2680Sstevel@tonic-gate
2690Sstevel@tonic-gate { 3, "vendor_id" },
2700Sstevel@tonic-gate { 4, "device_id" },
2710Sstevel@tonic-gate { 5, "subsystem_vendor_id" },
2720Sstevel@tonic-gate { 6, "subsystem_device_id" },
2730Sstevel@tonic-gate { 7, "revision_id" },
2740Sstevel@tonic-gate { 8, "cache_line_size" },
2750Sstevel@tonic-gate { 9, "latency_timer" },
2760Sstevel@tonic-gate
2770Sstevel@tonic-gate { 10, "flags" },
2780Sstevel@tonic-gate { 11, "chip_type" },
2790Sstevel@tonic-gate { 12, "mbuf_base" },
2800Sstevel@tonic-gate { 13, "mbuf_count" },
2810Sstevel@tonic-gate { 14, "hw_mac_addr" },
2820Sstevel@tonic-gate
2830Sstevel@tonic-gate { 15, "&bus_type" },
2840Sstevel@tonic-gate { 16, "&bus_speed" },
2850Sstevel@tonic-gate { 17, "&bus_size" },
2860Sstevel@tonic-gate { 18, "&supported" },
2870Sstevel@tonic-gate { 19, "&interface" },
2880Sstevel@tonic-gate
2890Sstevel@tonic-gate { -1, NULL }
2900Sstevel@tonic-gate };
2910Sstevel@tonic-gate
2920Sstevel@tonic-gate static void
bge_set_char_kstat(kstat_named_t * knp,const char * s)2930Sstevel@tonic-gate bge_set_char_kstat(kstat_named_t *knp, const char *s)
2940Sstevel@tonic-gate {
2950Sstevel@tonic-gate (void) strncpy(knp->value.c, s, sizeof (knp->value.c));
2960Sstevel@tonic-gate }
2970Sstevel@tonic-gate
2980Sstevel@tonic-gate static int
bge_chipid_update(kstat_t * ksp,int flag)2990Sstevel@tonic-gate bge_chipid_update(kstat_t *ksp, int flag)
3000Sstevel@tonic-gate {
3010Sstevel@tonic-gate bge_t *bgep;
3020Sstevel@tonic-gate kstat_named_t *knp;
3030Sstevel@tonic-gate uint64_t tmp;
3040Sstevel@tonic-gate
3050Sstevel@tonic-gate if (flag != KSTAT_READ)
3060Sstevel@tonic-gate return (EACCES);
3070Sstevel@tonic-gate
3080Sstevel@tonic-gate bgep = ksp->ks_private;
3090Sstevel@tonic-gate knp = ksp->ks_data;
3100Sstevel@tonic-gate
3110Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.asic_rev;
3120Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.businfo;
3130Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.command;
3140Sstevel@tonic-gate
3150Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.vendor;
3160Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.device;
3170Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.subven;
3180Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.subdev;
3190Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.revision;
3200Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.clsize;
3210Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.latency;
3220Sstevel@tonic-gate
3230Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.flags;
3240Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.chip_label;
3250Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.mbuf_base;
3260Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.mbuf_length;
3270Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chipid.hw_mac_addr;
3280Sstevel@tonic-gate
3290Sstevel@tonic-gate /*
3300Sstevel@tonic-gate * Now we interpret some of the above into readable strings
3310Sstevel@tonic-gate */
3320Sstevel@tonic-gate tmp = bgep->chipid.businfo;
3330Sstevel@tonic-gate bge_set_char_kstat(knp++,
3344711Sml149210 tmp & PCISTATE_BUS_IS_PCI ? "PCI" : "PCI-X");
3350Sstevel@tonic-gate bge_set_char_kstat(knp++,
3364711Sml149210 tmp & PCISTATE_BUS_IS_FAST ? "fast" : "normal");
3370Sstevel@tonic-gate bge_set_char_kstat(knp++,
3384711Sml149210 tmp & PCISTATE_BUS_IS_32_BIT ? "32 bit" : "64 bit");
3390Sstevel@tonic-gate
3400Sstevel@tonic-gate tmp = bgep->chipid.flags;
3410Sstevel@tonic-gate bge_set_char_kstat(knp++,
3424711Sml149210 tmp & CHIP_FLAG_SUPPORTED ? "yes" : "no");
3430Sstevel@tonic-gate bge_set_char_kstat(knp++,
3444711Sml149210 tmp & CHIP_FLAG_SERDES ? "serdes" : "copper");
3450Sstevel@tonic-gate
3460Sstevel@tonic-gate return (0);
3470Sstevel@tonic-gate }
3480Sstevel@tonic-gate
3490Sstevel@tonic-gate static const bge_ksindex_t bge_driverinfo[] = {
3500Sstevel@tonic-gate { 0, "rx_buff_addr" },
3510Sstevel@tonic-gate { 1, "tx_buff_addr" },
3520Sstevel@tonic-gate { 2, "rx_desc_addr" },
3530Sstevel@tonic-gate { 3, "tx_desc_addr" },
3540Sstevel@tonic-gate
3550Sstevel@tonic-gate { 4, "tx_desc_free" },
3563334Sgs150176 { 5, "tx_array" },
3573334Sgs150176 { 6, "tc_next" },
3583334Sgs150176 { 7, "tx_next" },
3593334Sgs150176 { 8, "txfill_next" },
3603334Sgs150176 { 9, "txpkt_next" },
3613334Sgs150176 { 10, "tx_bufs" },
3623334Sgs150176 { 11, "tx_flow" },
3633334Sgs150176 { 12, "tx_resched_needed" },
3643334Sgs150176 { 13, "tx_resched" },
3653334Sgs150176 { 14, "tx_nobuf" },
3663334Sgs150176 { 15, "tx_nobd" },
3673334Sgs150176 { 16, "tx_block" },
3683334Sgs150176 { 17, "tx_alloc_fail" },
3690Sstevel@tonic-gate
3703334Sgs150176 { 18, "watchdog" },
3713334Sgs150176 { 19, "chip_resets" },
3723334Sgs150176 { 20, "dma_misses" },
3733907Szh199473 { 21, "update_misses" },
3740Sstevel@tonic-gate
3753907Szh199473 { 22, "misc_host_config" },
3763907Szh199473 { 23, "dma_rw_control" },
3773907Szh199473 { 24, "pci_bus_info" },
3783334Sgs150176
3793907Szh199473 { 25, "buff_mgr_status" },
3803907Szh199473 { 26, "rcv_init_status" },
3810Sstevel@tonic-gate
3820Sstevel@tonic-gate { -1, NULL }
3830Sstevel@tonic-gate };
3840Sstevel@tonic-gate
3850Sstevel@tonic-gate static int
bge_driverinfo_update(kstat_t * ksp,int flag)3860Sstevel@tonic-gate bge_driverinfo_update(kstat_t *ksp, int flag)
3870Sstevel@tonic-gate {
3880Sstevel@tonic-gate bge_t *bgep;
3890Sstevel@tonic-gate kstat_named_t *knp;
3900Sstevel@tonic-gate ddi_acc_handle_t handle;
3910Sstevel@tonic-gate
3920Sstevel@tonic-gate if (flag != KSTAT_READ)
3930Sstevel@tonic-gate return (EACCES);
3940Sstevel@tonic-gate
3950Sstevel@tonic-gate bgep = ksp->ks_private;
3961865Sdilpreet if (bgep->bge_chip_state == BGE_CHIP_FAULT)
3971865Sdilpreet return (EIO);
3981865Sdilpreet
3990Sstevel@tonic-gate knp = ksp->ks_data;
4000Sstevel@tonic-gate
4010Sstevel@tonic-gate (knp++)->value.ui64 = bgep->rx_buff[0].cookie.dmac_laddress;
4020Sstevel@tonic-gate (knp++)->value.ui64 = bgep->tx_buff[0].cookie.dmac_laddress;
4030Sstevel@tonic-gate (knp++)->value.ui64 = bgep->rx_desc[0].cookie.dmac_laddress;
4040Sstevel@tonic-gate (knp++)->value.ui64 = bgep->tx_desc.cookie.dmac_laddress;
4050Sstevel@tonic-gate
4060Sstevel@tonic-gate (knp++)->value.ui64 = bgep->send[0].tx_free;
4073334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_array;
4083334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tc_next;
4093334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_next;
4103334Sgs150176 (knp++)->value.ui64 = bgep->send[0].txfill_next;
4113334Sgs150176 (knp++)->value.ui64 = bgep->send[0].txpkt_next;
4123334Sgs150176 (knp++)->value.ui64 = bgep->send[0].txbuf_pop_queue->count +
4133334Sgs150176 bgep->send[0].txbuf_push_queue->count;
4143334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_flow;
4153334Sgs150176 (knp++)->value.ui64 = bgep->tx_resched_needed;
4163334Sgs150176 (knp++)->value.ui64 = bgep->tx_resched;
4173334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_nobuf;
4183334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_nobd;
4193334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_block;
4203334Sgs150176 (knp++)->value.ui64 = bgep->send[0].tx_alloc_fail;
4213334Sgs150176
4220Sstevel@tonic-gate (knp++)->value.ui64 = bgep->watchdog;
4230Sstevel@tonic-gate (knp++)->value.ui64 = bgep->chip_resets;
4240Sstevel@tonic-gate (knp++)->value.ui64 = bgep->missed_dmas;
4253907Szh199473 (knp++)->value.ui64 = bgep->missed_updates;
4260Sstevel@tonic-gate
4270Sstevel@tonic-gate /*
4280Sstevel@tonic-gate * Hold the mutex while accessing the chip registers
4290Sstevel@tonic-gate * just in case the factotum is trying to reset it!
4300Sstevel@tonic-gate */
4310Sstevel@tonic-gate handle = bgep->cfg_handle;
4320Sstevel@tonic-gate mutex_enter(bgep->genlock);
4330Sstevel@tonic-gate (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_MHCR);
4340Sstevel@tonic-gate (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_PDRWCR);
4350Sstevel@tonic-gate (knp++)->value.ui64 = pci_config_get32(handle, PCI_CONF_BGE_PCISTATE);
4361865Sdilpreet if (bge_check_acc_handle(bgep, bgep->cfg_handle) != DDI_FM_OK) {
4371865Sdilpreet ddi_fm_service_impact(bgep->devinfo, DDI_SERVICE_DEGRADED);
4381865Sdilpreet mutex_exit(bgep->genlock);
4391865Sdilpreet return (EIO);
4401865Sdilpreet }
4410Sstevel@tonic-gate
4420Sstevel@tonic-gate (knp++)->value.ui64 = bge_reg_get32(bgep, BUFFER_MANAGER_STATUS_REG);
4430Sstevel@tonic-gate (knp++)->value.ui64 = bge_reg_get32(bgep, RCV_INITIATOR_STATUS_REG);
4441865Sdilpreet if (bge_check_acc_handle(bgep, bgep->io_handle) != DDI_FM_OK) {
4451865Sdilpreet ddi_fm_service_impact(bgep->devinfo, DDI_SERVICE_DEGRADED);
4461865Sdilpreet mutex_exit(bgep->genlock);
4471865Sdilpreet return (EIO);
4481865Sdilpreet }
4490Sstevel@tonic-gate mutex_exit(bgep->genlock);
4500Sstevel@tonic-gate
4510Sstevel@tonic-gate return (0);
4520Sstevel@tonic-gate }
4530Sstevel@tonic-gate
4540Sstevel@tonic-gate static const bge_ksindex_t bge_serdes[] = {
4550Sstevel@tonic-gate { 0, "serdes_status" },
4560Sstevel@tonic-gate { 1, "serdes_advert" },
4570Sstevel@tonic-gate { 2, "serdes_lpadv" },
4580Sstevel@tonic-gate
4590Sstevel@tonic-gate { -1, NULL }
4600Sstevel@tonic-gate };
4610Sstevel@tonic-gate
4620Sstevel@tonic-gate static int
bge_serdes_update(kstat_t * ksp,int flag)4630Sstevel@tonic-gate bge_serdes_update(kstat_t *ksp, int flag)
4640Sstevel@tonic-gate {
4650Sstevel@tonic-gate bge_t *bgep;
4660Sstevel@tonic-gate kstat_named_t *knp;
4670Sstevel@tonic-gate
4680Sstevel@tonic-gate if (flag != KSTAT_READ)
4690Sstevel@tonic-gate return (EACCES);
4700Sstevel@tonic-gate
4710Sstevel@tonic-gate bgep = ksp->ks_private;
4720Sstevel@tonic-gate knp = ksp->ks_data;
4730Sstevel@tonic-gate
4740Sstevel@tonic-gate (knp++)->value.ui64 = bgep->serdes_status;
4750Sstevel@tonic-gate (knp++)->value.ui64 = bgep->serdes_advert;
4760Sstevel@tonic-gate (knp++)->value.ui64 = bgep->serdes_lpadv;
4770Sstevel@tonic-gate
4780Sstevel@tonic-gate return (0);
4790Sstevel@tonic-gate }
4800Sstevel@tonic-gate
4810Sstevel@tonic-gate static const bge_ksindex_t bge_phydata[] = {
4820Sstevel@tonic-gate { MII_CONTROL, "mii_control" },
4830Sstevel@tonic-gate { MII_STATUS, "mii_status" },
4840Sstevel@tonic-gate { MII_PHYIDH, "phy_identifier" },
4850Sstevel@tonic-gate { MII_AN_ADVERT, "an_advert" },
4860Sstevel@tonic-gate { MII_AN_LPABLE, "an_lp_ability" },
4870Sstevel@tonic-gate { MII_AN_EXPANSION, "an_expansion" },
4889860Sgdamore@opensolaris.org { MII_AN_NXTPGLP, "an_lp_nextpage" },
4899860Sgdamore@opensolaris.org { MII_MSCONTROL, "gbit_control" },
4909860Sgdamore@opensolaris.org { MII_MSSTATUS, "gbit_status" },
4919860Sgdamore@opensolaris.org { MII_EXTSTATUS, "ieee_ext_status" },
4920Sstevel@tonic-gate { MII_EXT_CONTROL, "phy_ext_control" },
4930Sstevel@tonic-gate { MII_EXT_STATUS, "phy_ext_status" },
4940Sstevel@tonic-gate { MII_RCV_ERR_COUNT, "receive_error_count" },
4950Sstevel@tonic-gate { MII_FALSE_CARR_COUNT, "false_carrier_count" },
4960Sstevel@tonic-gate { MII_RCV_NOT_OK_COUNT, "receiver_not_ok_count" },
4970Sstevel@tonic-gate { MII_AUX_CONTROL, "aux_control" },
4980Sstevel@tonic-gate { MII_AUX_STATUS, "aux_status" },
4990Sstevel@tonic-gate { MII_INTR_STATUS, "intr_status" },
5000Sstevel@tonic-gate { MII_INTR_MASK, "intr_mask" },
5010Sstevel@tonic-gate { MII_HCD_STATUS, "hcd_status" },
5020Sstevel@tonic-gate
5030Sstevel@tonic-gate { -1, NULL }
5040Sstevel@tonic-gate };
5050Sstevel@tonic-gate
5060Sstevel@tonic-gate static int
bge_phydata_update(kstat_t * ksp,int flag)5070Sstevel@tonic-gate bge_phydata_update(kstat_t *ksp, int flag)
5080Sstevel@tonic-gate {
5090Sstevel@tonic-gate bge_t *bgep;
5100Sstevel@tonic-gate kstat_named_t *knp;
5110Sstevel@tonic-gate const bge_ksindex_t *ksip;
5120Sstevel@tonic-gate
5130Sstevel@tonic-gate if (flag != KSTAT_READ)
5140Sstevel@tonic-gate return (EACCES);
5150Sstevel@tonic-gate
5160Sstevel@tonic-gate bgep = ksp->ks_private;
5171865Sdilpreet if (bgep->bge_chip_state == BGE_CHIP_FAULT)
5181865Sdilpreet return (EIO);
5191865Sdilpreet
5200Sstevel@tonic-gate knp = ksp->ks_data;
5210Sstevel@tonic-gate
5220Sstevel@tonic-gate /*
5230Sstevel@tonic-gate * Read the PHY registers & update the kstats ...
5240Sstevel@tonic-gate *
5250Sstevel@tonic-gate * We need to hold the mutex while performing MII reads, but
5260Sstevel@tonic-gate * we don't want to hold it across the entire sequence of reads.
5270Sstevel@tonic-gate * So we grab and release it on each iteration, 'cos it doesn't
5280Sstevel@tonic-gate * really matter if the kstats are less than 100% consistent ...
5290Sstevel@tonic-gate */
5300Sstevel@tonic-gate for (ksip = bge_phydata; ksip->name != NULL; ++knp, ++ksip) {
5310Sstevel@tonic-gate mutex_enter(bgep->genlock);
5320Sstevel@tonic-gate switch (ksip->index) {
5330Sstevel@tonic-gate case MII_STATUS:
5340Sstevel@tonic-gate knp->value.ui64 = bgep->phy_gen_status;
5350Sstevel@tonic-gate break;
5360Sstevel@tonic-gate
5370Sstevel@tonic-gate case MII_PHYIDH:
5380Sstevel@tonic-gate knp->value.ui64 = bge_mii_get16(bgep, MII_PHYIDH);
5390Sstevel@tonic-gate knp->value.ui64 <<= 16;
5400Sstevel@tonic-gate knp->value.ui64 |= bge_mii_get16(bgep, MII_PHYIDL);
5410Sstevel@tonic-gate break;
5420Sstevel@tonic-gate
5430Sstevel@tonic-gate default:
5440Sstevel@tonic-gate knp->value.ui64 = bge_mii_get16(bgep, ksip->index);
5450Sstevel@tonic-gate break;
5460Sstevel@tonic-gate }
5471865Sdilpreet if (bge_check_acc_handle(bgep, bgep->io_handle) != DDI_FM_OK) {
5481865Sdilpreet ddi_fm_service_impact(bgep->devinfo,
5491865Sdilpreet DDI_SERVICE_DEGRADED);
5501865Sdilpreet mutex_exit(bgep->genlock);
5511865Sdilpreet return (EIO);
5521865Sdilpreet }
5530Sstevel@tonic-gate mutex_exit(bgep->genlock);
5540Sstevel@tonic-gate }
5550Sstevel@tonic-gate
5560Sstevel@tonic-gate return (0);
5570Sstevel@tonic-gate }
5580Sstevel@tonic-gate
5590Sstevel@tonic-gate static kstat_t *
bge_setup_named_kstat(bge_t * bgep,int instance,char * name,const bge_ksindex_t * ksip,size_t size,int (* update)(kstat_t *,int))5600Sstevel@tonic-gate bge_setup_named_kstat(bge_t *bgep, int instance, char *name,
5610Sstevel@tonic-gate const bge_ksindex_t *ksip, size_t size, int (*update)(kstat_t *, int))
5620Sstevel@tonic-gate {
5630Sstevel@tonic-gate kstat_t *ksp;
5640Sstevel@tonic-gate kstat_named_t *knp;
5650Sstevel@tonic-gate char *np;
5660Sstevel@tonic-gate int type;
5670Sstevel@tonic-gate
5680Sstevel@tonic-gate size /= sizeof (bge_ksindex_t);
5690Sstevel@tonic-gate ksp = kstat_create(BGE_DRIVER_NAME, instance, name, "net",
5704711Sml149210 KSTAT_TYPE_NAMED, size-1, KSTAT_FLAG_PERSISTENT);
5710Sstevel@tonic-gate if (ksp == NULL)
5720Sstevel@tonic-gate return (NULL);
5730Sstevel@tonic-gate
5740Sstevel@tonic-gate ksp->ks_private = bgep;
5750Sstevel@tonic-gate ksp->ks_update = update;
5760Sstevel@tonic-gate for (knp = ksp->ks_data; (np = ksip->name) != NULL; ++knp, ++ksip) {
5770Sstevel@tonic-gate switch (*np) {
5780Sstevel@tonic-gate default:
5790Sstevel@tonic-gate type = KSTAT_DATA_UINT64;
5800Sstevel@tonic-gate break;
5810Sstevel@tonic-gate case '%':
5820Sstevel@tonic-gate np += 1;
5830Sstevel@tonic-gate type = KSTAT_DATA_UINT32;
5840Sstevel@tonic-gate break;
5850Sstevel@tonic-gate case '$':
5860Sstevel@tonic-gate np += 1;
5870Sstevel@tonic-gate type = KSTAT_DATA_STRING;
5880Sstevel@tonic-gate break;
5890Sstevel@tonic-gate case '&':
5900Sstevel@tonic-gate np += 1;
5910Sstevel@tonic-gate type = KSTAT_DATA_CHAR;
5920Sstevel@tonic-gate break;
5930Sstevel@tonic-gate }
5940Sstevel@tonic-gate kstat_named_init(knp, np, type);
5950Sstevel@tonic-gate }
5960Sstevel@tonic-gate kstat_install(ksp);
5970Sstevel@tonic-gate
5980Sstevel@tonic-gate return (ksp);
5990Sstevel@tonic-gate }
6000Sstevel@tonic-gate
6010Sstevel@tonic-gate void
bge_init_kstats(bge_t * bgep,int instance)6020Sstevel@tonic-gate bge_init_kstats(bge_t *bgep, int instance)
6030Sstevel@tonic-gate {
6040Sstevel@tonic-gate kstat_t *ksp;
6050Sstevel@tonic-gate
6060Sstevel@tonic-gate BGE_TRACE(("bge_init_kstats($%p, %d)", (void *)bgep, instance));
6070Sstevel@tonic-gate
6081102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK) {
6091102Sly149593 DMA_ZERO(bgep->statistics);
6101102Sly149593 bgep->bge_kstats[BGE_KSTAT_RAW] = ksp =
6114711Sml149210 kstat_create(BGE_DRIVER_NAME, instance,
6124711Sml149210 "raw_statistics", "net", KSTAT_TYPE_RAW,
6134711Sml149210 sizeof (bge_statistics_t), KSTAT_FLAG_VIRTUAL);
6141102Sly149593 if (ksp != NULL) {
6151102Sly149593 ksp->ks_data = DMA_VPTR(bgep->statistics);
6161102Sly149593 kstat_install(ksp);
6171102Sly149593 }
6181102Sly149593
6191102Sly149593 bgep->bge_kstats[BGE_KSTAT_STATS] = bge_setup_named_kstat(bgep,
6204711Sml149210 instance, "statistics", bge_statistics,
6214711Sml149210 sizeof (bge_statistics), bge_statistics_update);
6221102Sly149593 } else {
6231102Sly149593 bgep->bge_kstats[BGE_KSTAT_STATS] = bge_setup_named_kstat(bgep,
6244711Sml149210 instance, "statistics", bge_stat_val,
6254711Sml149210 sizeof (bge_stat_val), bge_statistics_update);
6260Sstevel@tonic-gate }
6270Sstevel@tonic-gate
6280Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_CHIPID] = bge_setup_named_kstat(bgep,
6294711Sml149210 instance, "chipid", bge_chipid,
6304711Sml149210 sizeof (bge_chipid), bge_chipid_update);
6310Sstevel@tonic-gate
6320Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_DRIVER] = bge_setup_named_kstat(bgep,
6334711Sml149210 instance, "driverinfo", bge_driverinfo,
6344711Sml149210 sizeof (bge_driverinfo), bge_driverinfo_update);
6350Sstevel@tonic-gate
6360Sstevel@tonic-gate if (bgep->chipid.flags & CHIP_FLAG_SERDES)
6370Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_PHYS] = bge_setup_named_kstat(bgep,
6384711Sml149210 instance, "serdes", bge_serdes,
6394711Sml149210 sizeof (bge_serdes), bge_serdes_update);
6400Sstevel@tonic-gate else
6410Sstevel@tonic-gate bgep->bge_kstats[BGE_KSTAT_PHYS] = bge_setup_named_kstat(bgep,
6424711Sml149210 instance, "phydata", bge_phydata,
6434711Sml149210 sizeof (bge_phydata), bge_phydata_update);
6440Sstevel@tonic-gate
6450Sstevel@tonic-gate }
6460Sstevel@tonic-gate
6470Sstevel@tonic-gate void
bge_fini_kstats(bge_t * bgep)6480Sstevel@tonic-gate bge_fini_kstats(bge_t *bgep)
6490Sstevel@tonic-gate {
6500Sstevel@tonic-gate int i;
6510Sstevel@tonic-gate
6520Sstevel@tonic-gate BGE_TRACE(("bge_fini_kstats($%p)", (void *)bgep));
6530Sstevel@tonic-gate
6540Sstevel@tonic-gate for (i = BGE_KSTAT_COUNT; --i >= 0; )
6550Sstevel@tonic-gate if (bgep->bge_kstats[i] != NULL)
6560Sstevel@tonic-gate kstat_delete(bgep->bge_kstats[i]);
6570Sstevel@tonic-gate }
6580Sstevel@tonic-gate
6592311Sseb int
bge_m_stat(void * arg,uint_t stat,uint64_t * val)6602311Sseb bge_m_stat(void *arg, uint_t stat, uint64_t *val)
6610Sstevel@tonic-gate {
6620Sstevel@tonic-gate bge_t *bgep = arg;
6631102Sly149593 bge_statistics_t *bstp;
6643334Sgs150176 bge_statistics_reg_t *pstats;
6650Sstevel@tonic-gate
6661865Sdilpreet if (bgep->bge_chip_state == BGE_CHIP_FAULT) {
6672311Sseb return (EINVAL);
6682311Sseb }
6692311Sseb
6701102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
6711102Sly149593 bstp = DMA_VPTR(bgep->statistics);
6721102Sly149593 else {
6733334Sgs150176 pstats = bgep->pstats;
6743334Sgs150176 pstats->ifHCOutOctets +=
6753334Sgs150176 bge_reg_get32(bgep, STAT_IFHCOUT_OCTETS_REG);
6763334Sgs150176 pstats->etherStatsCollisions +=
6773334Sgs150176 bge_reg_get32(bgep, STAT_ETHER_COLLIS_REG);
6783334Sgs150176 pstats->outXonSent +=
6793334Sgs150176 bge_reg_get32(bgep, STAT_OUTXON_SENT_REG);
6803334Sgs150176 pstats->outXoffSent +=
6813334Sgs150176 bge_reg_get32(bgep, STAT_OUTXOFF_SENT_REG);
6823334Sgs150176 pstats->dot3StatsInternalMacTransmitErrors +=
6833334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_INTMACTX_ERR_REG);
6843334Sgs150176 pstats->dot3StatsSingleCollisionFrames +=
6853334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_SCOLLI_FRAME_REG);
6863334Sgs150176 pstats->dot3StatsMultipleCollisionFrames +=
6873334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_MCOLLI_FRAME_REG);
6883334Sgs150176 pstats->dot3StatsDeferredTransmissions +=
6893334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_DEFERED_TX_REG);
6903334Sgs150176 pstats->dot3StatsExcessiveCollisions +=
6913334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_EXCE_COLLI_REG);
6923334Sgs150176 pstats->dot3StatsLateCollisions +=
6933334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_LATE_COLLI_REG);
6943334Sgs150176 pstats->ifHCOutUcastPkts +=
6953334Sgs150176 bge_reg_get32(bgep, STAT_IFHCOUT_UPKGS_REG);
6963334Sgs150176 pstats->ifHCOutMulticastPkts +=
6973334Sgs150176 bge_reg_get32(bgep, STAT_IFHCOUT_MPKGS_REG);
6983334Sgs150176 pstats->ifHCOutBroadcastPkts +=
6993334Sgs150176 bge_reg_get32(bgep, STAT_IFHCOUT_BPKGS_REG);
7003334Sgs150176 pstats->ifHCInOctets +=
7013334Sgs150176 bge_reg_get32(bgep, STAT_IFHCIN_OCTETS_REG);
7023334Sgs150176 pstats->etherStatsFragments +=
7033334Sgs150176 bge_reg_get32(bgep, STAT_ETHER_FRAGMENT_REG);
7043334Sgs150176 pstats->ifHCInUcastPkts +=
7053334Sgs150176 bge_reg_get32(bgep, STAT_IFHCIN_UPKGS_REG);
7063334Sgs150176 pstats->ifHCInMulticastPkts +=
7073334Sgs150176 bge_reg_get32(bgep, STAT_IFHCIN_MPKGS_REG);
7083334Sgs150176 pstats->ifHCInBroadcastPkts +=
7093334Sgs150176 bge_reg_get32(bgep, STAT_IFHCIN_BPKGS_REG);
7103334Sgs150176 pstats->dot3StatsFCSErrors +=
7113334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_FCS_ERR_REG);
7123334Sgs150176 pstats->dot3StatsAlignmentErrors +=
7133334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_ALIGN_ERR_REG);
7143334Sgs150176 pstats->xonPauseFramesReceived +=
7153334Sgs150176 bge_reg_get32(bgep, STAT_XON_PAUSE_RX_REG);
7163334Sgs150176 pstats->xoffPauseFramesReceived +=
7173334Sgs150176 bge_reg_get32(bgep, STAT_XOFF_PAUSE_RX_REG);
7183334Sgs150176 pstats->macControlFramesReceived +=
7193334Sgs150176 bge_reg_get32(bgep, STAT_MAC_CTRL_RX_REG);
7203334Sgs150176 pstats->xoffStateEntered +=
7213334Sgs150176 bge_reg_get32(bgep, STAT_XOFF_STATE_ENTER_REG);
7223334Sgs150176 pstats->dot3StatsFrameTooLongs +=
7233334Sgs150176 bge_reg_get32(bgep, STAT_DOT3_FRAME_TOOLONG_REG);
7243334Sgs150176 pstats->etherStatsJabbers +=
7253334Sgs150176 bge_reg_get32(bgep, STAT_ETHER_JABBERS_REG);
7263334Sgs150176 pstats->etherStatsUndersizePkts +=
7273334Sgs150176 bge_reg_get32(bgep, STAT_ETHER_UNDERSIZE_REG);
7282675Szh199473 mutex_enter(bgep->genlock);
7291865Sdilpreet if (bge_check_acc_handle(bgep, bgep->io_handle) != DDI_FM_OK) {
7301865Sdilpreet ddi_fm_service_impact(bgep->devinfo,
7311865Sdilpreet DDI_SERVICE_UNAFFECTED);
7321102Sly149593 }
7332675Szh199473 mutex_exit(bgep->genlock);
7341865Sdilpreet }
7351102Sly149593
7360Sstevel@tonic-gate switch (stat) {
7370Sstevel@tonic-gate case MAC_STAT_IFSPEED:
7382311Sseb *val = bgep->param_link_speed * 1000000ull;
7390Sstevel@tonic-gate break;
7400Sstevel@tonic-gate
7410Sstevel@tonic-gate case MAC_STAT_MULTIRCV:
7421102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
7432311Sseb *val = bstp->s.ifHCInMulticastPkts;
7441102Sly149593 else
7453334Sgs150176 *val = pstats->ifHCInMulticastPkts;
7460Sstevel@tonic-gate break;
7470Sstevel@tonic-gate
7480Sstevel@tonic-gate case MAC_STAT_BRDCSTRCV:
7491102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
7502311Sseb *val = bstp->s.ifHCInBroadcastPkts;
7511102Sly149593 else
7523334Sgs150176 *val = pstats->ifHCInBroadcastPkts;
7530Sstevel@tonic-gate break;
7540Sstevel@tonic-gate
7550Sstevel@tonic-gate case MAC_STAT_MULTIXMT:
7561102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
7572311Sseb *val = bstp->s.ifHCOutMulticastPkts;
7581102Sly149593 else
7593334Sgs150176 *val = pstats->ifHCOutMulticastPkts;
7600Sstevel@tonic-gate break;
7610Sstevel@tonic-gate
7620Sstevel@tonic-gate case MAC_STAT_BRDCSTXMT:
7631102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
7642311Sseb *val = bstp->s.ifHCOutBroadcastPkts;
7651102Sly149593 else
7663334Sgs150176 *val = pstats->ifHCOutBroadcastPkts;
7670Sstevel@tonic-gate break;
7680Sstevel@tonic-gate
7690Sstevel@tonic-gate case MAC_STAT_NORCVBUF:
7701102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
7712311Sseb *val = bstp->s.ifInDiscards;
7721102Sly149593 else
7732311Sseb *val = 0;
7740Sstevel@tonic-gate break;
7750Sstevel@tonic-gate
7760Sstevel@tonic-gate case MAC_STAT_IERRORS:
7772311Sseb if (bgep->chipid.statistic_type == BGE_STAT_BLK) {
7782311Sseb *val = bstp->s.dot3StatsFCSErrors +
7793334Sgs150176 bstp->s.dot3StatsAlignmentErrors +
7803334Sgs150176 bstp->s.dot3StatsFrameTooLongs +
7813334Sgs150176 bstp->s.etherStatsUndersizePkts +
7823334Sgs150176 bstp->s.etherStatsJabbers;
7832311Sseb } else {
7843334Sgs150176 *val = pstats->dot3StatsFCSErrors +
7853334Sgs150176 pstats->dot3StatsAlignmentErrors +
7863334Sgs150176 pstats->dot3StatsFrameTooLongs +
7873334Sgs150176 pstats->etherStatsUndersizePkts +
7883334Sgs150176 pstats->etherStatsJabbers;
7892311Sseb }
7900Sstevel@tonic-gate break;
7910Sstevel@tonic-gate
7920Sstevel@tonic-gate case MAC_STAT_NOXMTBUF:
7931102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
7942311Sseb *val = bstp->s.ifOutDiscards;
7951102Sly149593 else
7962311Sseb *val = 0;
7970Sstevel@tonic-gate break;
7980Sstevel@tonic-gate
7990Sstevel@tonic-gate case MAC_STAT_OERRORS:
8001102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8012311Sseb *val = bstp->s.ifOutDiscards;
8021102Sly149593 else
8032311Sseb *val = 0;
8040Sstevel@tonic-gate break;
8050Sstevel@tonic-gate
8060Sstevel@tonic-gate case MAC_STAT_COLLISIONS:
8071102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8082311Sseb *val = bstp->s.etherStatsCollisions;
8091102Sly149593 else
8103334Sgs150176 *val = pstats->etherStatsCollisions;
8110Sstevel@tonic-gate break;
8120Sstevel@tonic-gate
8130Sstevel@tonic-gate case MAC_STAT_RBYTES:
8141102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8152311Sseb *val = bstp->s.ifHCInOctets;
8161102Sly149593 else
8173334Sgs150176 *val = pstats->ifHCInOctets;
8180Sstevel@tonic-gate break;
8190Sstevel@tonic-gate
8200Sstevel@tonic-gate case MAC_STAT_IPACKETS:
8211102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8222311Sseb *val = bstp->s.ifHCInUcastPkts +
8232311Sseb bstp->s.ifHCInMulticastPkts +
8242311Sseb bstp->s.ifHCInBroadcastPkts;
8251102Sly149593 else
8263334Sgs150176 *val = pstats->ifHCInUcastPkts +
8273334Sgs150176 pstats->ifHCInMulticastPkts +
8283334Sgs150176 pstats->ifHCInBroadcastPkts;
8290Sstevel@tonic-gate break;
8300Sstevel@tonic-gate
8310Sstevel@tonic-gate case MAC_STAT_OBYTES:
8321102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8332311Sseb *val = bstp->s.ifHCOutOctets;
8341102Sly149593 else
8353334Sgs150176 *val = pstats->ifHCOutOctets;
8360Sstevel@tonic-gate break;
8370Sstevel@tonic-gate
8380Sstevel@tonic-gate case MAC_STAT_OPACKETS:
8391102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8402311Sseb *val = bstp->s.ifHCOutUcastPkts +
8412311Sseb bstp->s.ifHCOutMulticastPkts +
8422311Sseb bstp->s.ifHCOutBroadcastPkts;
8431102Sly149593 else
8443334Sgs150176 *val = pstats->ifHCOutUcastPkts +
8453334Sgs150176 pstats->ifHCOutMulticastPkts +
8463334Sgs150176 pstats->ifHCOutBroadcastPkts;
8470Sstevel@tonic-gate break;
8480Sstevel@tonic-gate
8492311Sseb case ETHER_STAT_ALIGN_ERRORS:
8501102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8512311Sseb *val = bstp->s.dot3StatsAlignmentErrors;
8521102Sly149593 else
8533334Sgs150176 *val = pstats->dot3StatsAlignmentErrors;
8540Sstevel@tonic-gate break;
8550Sstevel@tonic-gate
8562311Sseb case ETHER_STAT_FCS_ERRORS:
8571102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8582311Sseb *val = bstp->s.dot3StatsFCSErrors;
8591102Sly149593 else
8603334Sgs150176 *val = pstats->dot3StatsFCSErrors;
8610Sstevel@tonic-gate break;
8620Sstevel@tonic-gate
8632311Sseb case ETHER_STAT_FIRST_COLLISIONS:
8641102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8652311Sseb *val = bstp->s.dot3StatsSingleCollisionFrames;
8661102Sly149593 else
8673334Sgs150176 *val = pstats->dot3StatsSingleCollisionFrames;
8680Sstevel@tonic-gate break;
8690Sstevel@tonic-gate
8702311Sseb case ETHER_STAT_MULTI_COLLISIONS:
8711102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8722311Sseb *val = bstp->s.dot3StatsMultipleCollisionFrames;
8731102Sly149593 else
8743334Sgs150176 *val = pstats->dot3StatsMultipleCollisionFrames;
8750Sstevel@tonic-gate break;
8760Sstevel@tonic-gate
8772311Sseb case ETHER_STAT_DEFER_XMTS:
8781102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8792311Sseb *val = bstp->s.dot3StatsDeferredTransmissions;
8801102Sly149593 else
8813334Sgs150176 *val = pstats->dot3StatsDeferredTransmissions;
8820Sstevel@tonic-gate break;
8830Sstevel@tonic-gate
8842311Sseb case ETHER_STAT_TX_LATE_COLLISIONS:
8851102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8862311Sseb *val = bstp->s.dot3StatsLateCollisions;
8871102Sly149593 else
8883334Sgs150176 *val = pstats->dot3StatsLateCollisions;
8890Sstevel@tonic-gate break;
8900Sstevel@tonic-gate
8912311Sseb case ETHER_STAT_EX_COLLISIONS:
8921102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
8932311Sseb *val = bstp->s.dot3StatsExcessiveCollisions;
8941102Sly149593 else
8953334Sgs150176 *val = pstats->dot3StatsExcessiveCollisions;
8960Sstevel@tonic-gate break;
8970Sstevel@tonic-gate
8982311Sseb case ETHER_STAT_MACXMT_ERRORS:
8991102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
9002311Sseb *val = bstp->s.dot3StatsInternalMacTransmitErrors;
9011102Sly149593 else
9023334Sgs150176 *val = bgep->pstats->dot3StatsInternalMacTransmitErrors;
9030Sstevel@tonic-gate break;
9040Sstevel@tonic-gate
9052311Sseb case ETHER_STAT_CARRIER_ERRORS:
9061102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
9072311Sseb *val = bstp->s.dot3StatsCarrierSenseErrors;
9081102Sly149593 else
9092311Sseb *val = 0;
9100Sstevel@tonic-gate break;
9110Sstevel@tonic-gate
9122311Sseb case ETHER_STAT_TOOLONG_ERRORS:
9131102Sly149593 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
9142311Sseb *val = bstp->s.dot3StatsFrameTooLongs;
9151102Sly149593 else
9163334Sgs150176 *val = pstats->dot3StatsFrameTooLongs;
9170Sstevel@tonic-gate break;
9180Sstevel@tonic-gate
9194089Sgd78059 case ETHER_STAT_TOOSHORT_ERRORS:
9204089Sgd78059 if (bgep->chipid.statistic_type == BGE_STAT_BLK)
9214089Sgd78059 *val = bstp->s.etherStatsUndersizePkts;
9224089Sgd78059 else
9234089Sgd78059 *val = pstats->etherStatsUndersizePkts;
9244089Sgd78059 break;
9254089Sgd78059
9262311Sseb case ETHER_STAT_XCVR_ADDR:
9272311Sseb *val = bgep->phy_mii_addr;
9280Sstevel@tonic-gate break;
9290Sstevel@tonic-gate
9302311Sseb case ETHER_STAT_XCVR_ID:
9312675Szh199473 mutex_enter(bgep->genlock);
9322311Sseb *val = bge_mii_get16(bgep, MII_PHYIDH);
9332311Sseb *val <<= 16;
9342311Sseb *val |= bge_mii_get16(bgep, MII_PHYIDL);
9351865Sdilpreet if (bge_check_acc_handle(bgep, bgep->io_handle) != DDI_FM_OK) {
9361865Sdilpreet ddi_fm_service_impact(bgep->devinfo,
9371865Sdilpreet DDI_SERVICE_UNAFFECTED);
9381865Sdilpreet }
9392675Szh199473 mutex_exit(bgep->genlock);
9400Sstevel@tonic-gate break;
9410Sstevel@tonic-gate
9422311Sseb case ETHER_STAT_XCVR_INUSE:
9436546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
9446546Sgh162552 *val = XCVR_1000X;
9456546Sgh162552 else
9466546Sgh162552 *val = XCVR_1000T;
9470Sstevel@tonic-gate break;
9480Sstevel@tonic-gate
9492311Sseb case ETHER_STAT_CAP_1000FDX:
9502311Sseb *val = 1;
9510Sstevel@tonic-gate break;
9520Sstevel@tonic-gate
9532311Sseb case ETHER_STAT_CAP_1000HDX:
9542311Sseb *val = 1;
9550Sstevel@tonic-gate break;
9560Sstevel@tonic-gate
9572311Sseb case ETHER_STAT_CAP_100FDX:
9586546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
9596546Sgh162552 *val = 0;
9606546Sgh162552 else
9616546Sgh162552 *val = 1;
9620Sstevel@tonic-gate break;
9630Sstevel@tonic-gate
9642311Sseb case ETHER_STAT_CAP_100HDX:
9656546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
9666546Sgh162552 *val = 0;
9676546Sgh162552 else
9686546Sgh162552 *val = 1;
9690Sstevel@tonic-gate break;
9700Sstevel@tonic-gate
9712311Sseb case ETHER_STAT_CAP_10FDX:
9726546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
9736546Sgh162552 *val = 0;
9746546Sgh162552 else
9756546Sgh162552 *val = 1;
9760Sstevel@tonic-gate break;
9770Sstevel@tonic-gate
9782311Sseb case ETHER_STAT_CAP_10HDX:
9796546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
9806546Sgh162552 *val = 0;
9816546Sgh162552 else
9826546Sgh162552 *val = 1;
9830Sstevel@tonic-gate break;
9840Sstevel@tonic-gate
9852311Sseb case ETHER_STAT_CAP_ASMPAUSE:
9862311Sseb *val = 1;
9870Sstevel@tonic-gate break;
9880Sstevel@tonic-gate
9892311Sseb case ETHER_STAT_CAP_PAUSE:
9902311Sseb *val = 1;
9910Sstevel@tonic-gate break;
9920Sstevel@tonic-gate
9932311Sseb case ETHER_STAT_CAP_AUTONEG:
9942311Sseb *val = 1;
9950Sstevel@tonic-gate break;
9960Sstevel@tonic-gate
9974089Sgd78059 case ETHER_STAT_CAP_REMFAULT:
9984089Sgd78059 *val = 1;
9994089Sgd78059 break;
10004089Sgd78059
10012311Sseb case ETHER_STAT_ADV_CAP_1000FDX:
10022311Sseb *val = bgep->param_adv_1000fdx;
10030Sstevel@tonic-gate break;
10040Sstevel@tonic-gate
10052311Sseb case ETHER_STAT_ADV_CAP_1000HDX:
10062311Sseb *val = bgep->param_adv_1000hdx;
10070Sstevel@tonic-gate break;
10080Sstevel@tonic-gate
10092311Sseb case ETHER_STAT_ADV_CAP_100FDX:
10102311Sseb *val = bgep->param_adv_100fdx;
10110Sstevel@tonic-gate break;
10120Sstevel@tonic-gate
10132311Sseb case ETHER_STAT_ADV_CAP_100HDX:
10142311Sseb *val = bgep->param_adv_100hdx;
10150Sstevel@tonic-gate break;
10160Sstevel@tonic-gate
10172311Sseb case ETHER_STAT_ADV_CAP_10FDX:
10182311Sseb *val = bgep->param_adv_10fdx;
10190Sstevel@tonic-gate break;
10200Sstevel@tonic-gate
10212311Sseb case ETHER_STAT_ADV_CAP_10HDX:
10222311Sseb *val = bgep->param_adv_10hdx;
10230Sstevel@tonic-gate break;
10240Sstevel@tonic-gate
10252311Sseb case ETHER_STAT_ADV_CAP_ASMPAUSE:
10262311Sseb *val = bgep->param_adv_asym_pause;
10270Sstevel@tonic-gate break;
10280Sstevel@tonic-gate
10292311Sseb case ETHER_STAT_ADV_CAP_PAUSE:
10302311Sseb *val = bgep->param_adv_pause;
10310Sstevel@tonic-gate break;
10320Sstevel@tonic-gate
10332311Sseb case ETHER_STAT_ADV_CAP_AUTONEG:
10342311Sseb *val = bgep->param_adv_autoneg;
10350Sstevel@tonic-gate break;
10360Sstevel@tonic-gate
10374089Sgd78059 case ETHER_STAT_ADV_REMFAULT:
10386546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
10396546Sgh162552 *val = 0;
10406546Sgh162552 else {
10416546Sgh162552 mutex_enter(bgep->genlock);
10426546Sgh162552 *val = bge_mii_get16(bgep, MII_AN_ADVERT) &
10436546Sgh162552 MII_AN_ADVERT_REMFAULT ? 1 : 0;
10446546Sgh162552 if (bge_check_acc_handle(bgep, bgep->io_handle) !=
10456546Sgh162552 DDI_FM_OK) {
10466546Sgh162552 ddi_fm_service_impact(bgep->devinfo,
10476546Sgh162552 DDI_SERVICE_UNAFFECTED);
10486546Sgh162552 }
10496546Sgh162552 mutex_exit(bgep->genlock);
10504089Sgd78059 }
10514089Sgd78059 break;
10524089Sgd78059
10532311Sseb case ETHER_STAT_LP_CAP_1000FDX:
10542311Sseb *val = bgep->param_lp_1000fdx;
10550Sstevel@tonic-gate break;
10560Sstevel@tonic-gate
10572311Sseb case ETHER_STAT_LP_CAP_1000HDX:
10582311Sseb *val = bgep->param_lp_1000hdx;
10590Sstevel@tonic-gate break;
10600Sstevel@tonic-gate
10612311Sseb case ETHER_STAT_LP_CAP_100FDX:
10622311Sseb *val = bgep->param_lp_100fdx;
10630Sstevel@tonic-gate break;
10640Sstevel@tonic-gate
10652311Sseb case ETHER_STAT_LP_CAP_100HDX:
10662311Sseb *val = bgep->param_lp_100hdx;
10670Sstevel@tonic-gate break;
10680Sstevel@tonic-gate
10692311Sseb case ETHER_STAT_LP_CAP_10FDX:
10702311Sseb *val = bgep->param_lp_10fdx;
10710Sstevel@tonic-gate break;
10720Sstevel@tonic-gate
10732311Sseb case ETHER_STAT_LP_CAP_10HDX:
10742311Sseb *val = bgep->param_lp_10hdx;
10750Sstevel@tonic-gate break;
10760Sstevel@tonic-gate
10772311Sseb case ETHER_STAT_LP_CAP_ASMPAUSE:
10782311Sseb *val = bgep->param_lp_asym_pause;
10790Sstevel@tonic-gate break;
10800Sstevel@tonic-gate
10812311Sseb case ETHER_STAT_LP_CAP_PAUSE:
10822311Sseb *val = bgep->param_lp_pause;
10832311Sseb break;
10842311Sseb
10852311Sseb case ETHER_STAT_LP_CAP_AUTONEG:
10862311Sseb *val = bgep->param_lp_autoneg;
10870Sstevel@tonic-gate break;
10880Sstevel@tonic-gate
10894089Sgd78059 case ETHER_STAT_LP_REMFAULT:
10906546Sgh162552 if (bgep->chipid.flags & CHIP_FLAG_SERDES)
10916546Sgh162552 *val = 0;
10926546Sgh162552 else {
10936546Sgh162552 mutex_enter(bgep->genlock);
10946546Sgh162552 *val = bge_mii_get16(bgep, MII_AN_LPABLE) &
10956546Sgh162552 MII_AN_ADVERT_REMFAULT ? 1 : 0;
10966546Sgh162552 if (bge_check_acc_handle(bgep, bgep->io_handle) !=
10976546Sgh162552 DDI_FM_OK) {
10986546Sgh162552 ddi_fm_service_impact(bgep->devinfo,
10996546Sgh162552 DDI_SERVICE_UNAFFECTED);
11006546Sgh162552 }
11016546Sgh162552 mutex_exit(bgep->genlock);
11024089Sgd78059 }
11034089Sgd78059 break;
11044089Sgd78059
11052311Sseb case ETHER_STAT_LINK_ASMPAUSE:
11062311Sseb *val = bgep->param_adv_asym_pause &&
11072311Sseb bgep->param_lp_asym_pause &&
11082311Sseb bgep->param_adv_pause != bgep->param_lp_pause;
11092675Szh199473 break;
11100Sstevel@tonic-gate
11112311Sseb case ETHER_STAT_LINK_PAUSE:
11122311Sseb *val = bgep->param_link_rx_pause;
11130Sstevel@tonic-gate break;
11140Sstevel@tonic-gate
11152311Sseb case ETHER_STAT_LINK_AUTONEG:
11162311Sseb *val = bgep->param_link_autoneg;
11172311Sseb break;
11182311Sseb
11192311Sseb case ETHER_STAT_LINK_DUPLEX:
11202311Sseb *val = bgep->param_link_duplex;
11212311Sseb break;
11222311Sseb
11230Sstevel@tonic-gate default:
11242311Sseb return (ENOTSUP);
11250Sstevel@tonic-gate }
11260Sstevel@tonic-gate
11272311Sseb return (0);
11280Sstevel@tonic-gate }
1129*11878SVenu.Iyer@Sun.COM
1130*11878SVenu.Iyer@Sun.COM /*
1131*11878SVenu.Iyer@Sun.COM * Retrieve a value for one of the statistics for a particular rx ring
1132*11878SVenu.Iyer@Sun.COM */
1133*11878SVenu.Iyer@Sun.COM int
bge_rx_ring_stat(mac_ring_driver_t rh,uint_t stat,uint64_t * val)1134*11878SVenu.Iyer@Sun.COM bge_rx_ring_stat(mac_ring_driver_t rh, uint_t stat, uint64_t *val)
1135*11878SVenu.Iyer@Sun.COM {
1136*11878SVenu.Iyer@Sun.COM recv_ring_t *rx_ring = (recv_ring_t *)rh;
1137*11878SVenu.Iyer@Sun.COM
1138*11878SVenu.Iyer@Sun.COM switch (stat) {
1139*11878SVenu.Iyer@Sun.COM case MAC_STAT_RBYTES:
1140*11878SVenu.Iyer@Sun.COM *val = rx_ring->rx_bytes;
1141*11878SVenu.Iyer@Sun.COM break;
1142*11878SVenu.Iyer@Sun.COM
1143*11878SVenu.Iyer@Sun.COM case MAC_STAT_IPACKETS:
1144*11878SVenu.Iyer@Sun.COM *val = rx_ring->rx_pkts;
1145*11878SVenu.Iyer@Sun.COM break;
1146*11878SVenu.Iyer@Sun.COM
1147*11878SVenu.Iyer@Sun.COM default:
1148*11878SVenu.Iyer@Sun.COM *val = 0;
1149*11878SVenu.Iyer@Sun.COM return (ENOTSUP);
1150*11878SVenu.Iyer@Sun.COM }
1151*11878SVenu.Iyer@Sun.COM
1152*11878SVenu.Iyer@Sun.COM return (0);
1153*11878SVenu.Iyer@Sun.COM }
1154