openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

stat_xe.c (33803B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  */
      7 
      8 #include <soc/drv.h>
      9 #include <soc/counter.h>
     10 #include <soc/debug.h>
     11 #include <shared/bsl.h>
     12 #include <bcm/stat.h>
     13 #include <bcm/error.h>
     14 
     15 #include <bcm_int/esw/stat.h>
     16 
     17 #include <bcm_int/esw_dispatch.h>
     18 
     19 /*
     20  * Function:
     21  *      _bcm_stat_xe_get
     22  * Description:
     23  *      Get the specified statistic for an XE port on the StrataSwitch family
     24  *      of devices.
     25  * Parameters:
     26  *      unit - StrataSwitch PCI device unit number (driver internal).
     27  *      port - zero-based port number
     28  *      sync_mode - if 1 read hw counter else sw accumualated counter
     29  *      type - SNMP statistics type (see stat.h)
     30  *      val  - (OUT) 64 bit statistic counter value
     31  * Returns:
     32  *      BCM_E_NONE - Success.
     33  *      BCM_E_PARAM - Illegal parameter.
     34  *      BCM_E_INTERNAL - Chip access failure.
     35  */
     36 int
     37 _bcm_stat_xe_get_set(int unit, bcm_port_t port, 
     38                      int sync_mode, int stat_op,
     39                      bcm_stat_val_t type, uint64 *val)
     40 {
     41     uint64 count, count1;
     42     int reg_op = (stat_op == _BCM_STAT_GET)? _BCM_STAT_REG_ADD: 
     43                                              _BCM_STAT_REG_CLEAR;
     44     int reg_sub_op = (stat_op == _BCM_STAT_GET)? _BCM_STAT_REG_SUB: 
     45                                              _BCM_STAT_REG_CLEAR;
     46 
     47     COMPILER_REFERENCE(&count);  /* Work around PPC compiler bug */
     48     COMPILER_64_ZERO(count);
     49 
     50     switch (type) {
     51         /* *** RFC 1213 *** */
     52 
     53     case snmpIfInOctets:
     54         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRBYTr, &count);
     55         break;
     56     case snmpIfInUcastPkts:
     57         if (soc_feature(unit, soc_feature_hw_stats_calc)) {
     58             if (SOC_REG_IS_VALID(unit, IRUCAr)) {
     59                 BCM_STAT_REG_OPER(unit, port, sync_mode, 
     60                                   reg_op, IRUCAr, &count);
     61             } else if (SOC_REG_IS_VALID(unit, IRUCr)) {
     62                 BCM_STAT_REG_OPER(unit, port, sync_mode, 
     63                                   reg_op, IRUCr, &count);
     64             } else {
     65                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
     66                                   RUCr, &count);  /* unicast pkts rcvd */
     67             }
     68         } else {
     69             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRPKTr, &count);
     70             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
     71                               IRMCAr, &count); /* - multicast */
     72             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
     73                               IRBCAr, &count); /* - broadcast */
     74             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
     75                               IRFCSr, &count); /* - bad FCS */
     76             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
     77                               IRXCFr, &count); /* - good FCS, all MAC ctrl */
     78             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
     79                               IRXPFr, &count); /* - not included in IRXCFr */
     80             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
     81                               IRJBRr, &count); /* - oversize, bad FCS */
     82             if (COUNT_OVR_ERRORS(unit)) {
     83                 if (SOC_REG_IS_VALID(unit, CLMIB_ROVRr)) {
     84                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
     85                                   CLMIB_ROVRr, &count);
     86                 } else {
     87                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
     88                                   IROVRr, &count); /* - oversize, good FCS */
     89                 }
     90             }
     91         }
     92         break;
     93     case snmpIfInNUcastPkts:    /* Multicast frames plus broadcast frames */
     94         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
     95                           IRMCAr, &count); /* + multicast */
     96         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
     97                           IRBCAr, &count); /* + broadcast */
     98         break;
     99     case snmpIfInBroadcastPkts:  /* broadcast frames */
    100         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    101                           IRBCAr, &count); /* + broadcast */
    102         break;
    103     case snmpIfInMulticastPkts:  /* Multicast frames */
    104         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    105                           IRMCAr, &count); /* + multicast */
    106         break;
    107     case snmpIfInDiscards:    /* Dropped packets including aborted */
    108         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    109                           RDBGC0r, &count); /* Ingress drop conditions */
    110         BCM_IF_ERROR_RETURN
    111             (_bcm_stat_counter_non_dma_extra_get(
    112                 unit,
    113                 SOC_COUNTER_NON_DMA_PORT_DROP_PKT_ING,
    114                 port, &count1));
    115         COMPILER_64_ADD_64(count, count1);
    116         break;
    117     case snmpIfInErrors: /* RX Errors or Receive packets - non-error frames */
    118         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRFCSr, &count);
    119         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRJBRr, &count);
    120         if (COUNT_OVR_ERRORS(unit)) {
    121             if (SOC_REG_IS_VALID(unit, CLMIB_ROVRr)) {
    122                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op,
    123                               CLMIB_ROVRr, &count);
    124             } else {
    125                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op,
    126                               IROVRr, &count);
    127             }
    128         }
    129 		if (soc_feature(unit, soc_feature_stat_jumbo_adj)) { 
    130 			BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMEGr, &count); 
    131 			BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMEBr, &count); 
    132 		} 
    133         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRUNDr, &count);
    134         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRFRGr, &count);
    135         break;
    136     case snmpIfInUnknownProtos:
    137         break;
    138     case snmpIfOutOctets:    /* TX bytes */
    139         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITBYTr, &count);
    140         break;
    141     case snmpIfOutUcastPkts:    /* ALL - mcast - bcast */
    142 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_TRX_SUPPORT)
    143         if (soc_feature(unit, soc_feature_hw_stats_calc)) {
    144             /* This register has a different name on some devices.
    145              * Only one value is added here. */
    146             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    147                               ITUCr, &count);  /* unicast pkts sent */
    148             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    149                               ITUCAr, &count);  /* unicast pkts sent */
    150         } else 
    151 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */
    152         {
    153             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITPKTr, &count);
    154             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    155                               ITMCAr, &count); /* - multicast */
    156             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    157                               ITBCAr, &count); /* - broadcast */
    158         }
    159         break;
    160     case snmpIfOutNUcastPkts:    /* broadcast frames plus multicast frames */
    161         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    162                           ITMCAr, &count); /* + multicast */
    163         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    164                           ITBCAr, &count); /* + broadcast */
    165         break;
    166     case snmpIfOutBroadcastPkts:    /* broadcast frames */
    167         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    168                           ITBCAr, &count); /* + broadcast */
    169         break;
    170     case snmpIfOutMulticastPkts:    /* multicast frames */
    171         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op,
    172                           ITMCAr, &count); /* + multicast */
    173         break;
    174     case snmpIfOutDiscards:    /* Aged packet counter */
    175         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    176             if (SOC_REG_IS_VALID(unit, HOLDr)) {
    177                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    178                                   HOLDr, &count);  /* L2 MTU drops */
    179             } else if (SOC_REG_IS_VALID(unit, HOL_DROPr)) {
    180                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    181                                   HOL_DROPr, &count);
    182             }
    183             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC3r, &count);
    184             BCM_IF_ERROR_RETURN
    185                 (_bcm_stat_counter_extra_get(unit, EGRDROPPKTCOUNTr,
    186                                              port, &count1));
    187             COMPILER_64_ADD_64(count, count1);
    188             BCM_IF_ERROR_RETURN
    189                 (bcm_esw_cosq_stat_get(unit, port, BCM_COS_INVALID, 
    190                                    bcmCosqStatDroppedPackets, &count1));
    191             COMPILER_64_ADD_64(count, count1);
    192         }
    193         break;
    194     case snmpIfOutErrors:   /* Error packets could not be xmitted */
    195         
    196         break;
    197     case snmpIfOutQLen: {
    198         uint32  qcount;
    199         if (bcm_esw_port_queued_count_get(unit, port, &qcount) >= 0) {
    200             COMPILER_64_ADD_32(count, qcount);
    201         }
    202     }
    203     break;
    204     case snmpIpInReceives:
    205         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPC4r, &count);
    206         break;
    207     case snmpIpInHdrErrors:
    208         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4r, &count);
    209         break;
    210     case snmpIpForwDatagrams:
    211         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    212             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC4r, &count);
    213         }
    214         break;
    215     case snmpIpInDiscards:
    216         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE4r, &count);
    217         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4r, &count);
    218         break;
    219 
    220         /* *** RFC 1493 *** */
    221 
    222     case snmpDot1dBasePortDelayExceededDiscards:
    223         break;
    224     case snmpDot1dBasePortMtuExceededDiscards:
    225         if (soc_feature(unit, soc_feature_stat_jumbo_adj)) {
    226             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMEGr, &count);
    227             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMEBr, &count);
    228         } else {
    229             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRJBRr, &count);
    230         }
    231         break;
    232     case snmpDot1dTpPortInFrames:
    233         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRPKTr, &count);
    234         break;
    235     case snmpDot1dTpPortOutFrames:
    236         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITPKTr, &count);
    237         break;
    238     case snmpDot1dPortInDiscards:
    239         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDISCr, &count);
    240         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD4r, &count);
    241         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6r, &count);
    242         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RPORTDr, &count);
    243         break;
    244 
    245         /* *** RFC 1757 *** */
    246 
    247     case snmpEtherStatsDropEvents:
    248         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDISCr, &count);
    249         break;
    250     case snmpEtherStatsOctets:
    251         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRBYTr, &count);
    252         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITBYTr, &count);
    253         break;
    254     case snmpEtherStatsPkts:
    255         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRPKTr, &count);
    256         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITPKTr, &count);
    257         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    258                           IRUNDr, &count); /* Runts */
    259         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    260                           IRFRGr, &count); /* Fragments */
    261         break;
    262     case snmpEtherStatsBroadcastPkts:
    263         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRBCAr, &count);
    264         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITBCAr, &count);
    265         break;
    266     case snmpEtherStatsMulticastPkts:
    267         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMCAr, &count);
    268         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITMCAr, &count);
    269         break;
    270     case snmpEtherStatsCRCAlignErrors:
    271         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRFCSr, &count);
    272         break;
    273     case snmpEtherStatsUndersizePkts:  /* Undersize frames */
    274         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRUNDr, &count);
    275         break;
    276     case snmpEtherStatsOversizePkts:
    277             if (SOC_REG_IS_VALID(unit, CLMIB_ROVRr)) {
    278                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, CLMIB_ROVRr, &count);
    279                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, CLMIB_TOVRr, &count);
    280             } else {
    281                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IROVRr, &count);
    282                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITOVRr, &count);
    283             }
    284         break;
    285     case snmpEtherRxOversizePkts:
    286             if (SOC_REG_IS_VALID(unit, CLMIB_ROVRr)) {
    287                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, CLMIB_ROVRr, &count);
    288             } else {
    289                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IROVRr, &count);
    290             }
    291         break;
    292     case snmpEtherTxOversizePkts:
    293             if (SOC_REG_IS_VALID(unit, CLMIB_TOVRr)) {
    294                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, CLMIB_TOVRr, &count);
    295             } else {
    296                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITOVRr, &count);
    297             }
    298         break;
    299     case snmpEtherStatsFragments:
    300         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRFRGr, &count);
    301         if (SOC_REG_IS_VALID(unit, ITFRGr)) {
    302            BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITFRGr, &count);
    303         }
    304         break;
    305     case snmpEtherStatsJabbers:
    306         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRJBRr, &count);
    307         break;
    308     case snmpEtherStatsCollisions:
    309         break;
    310     case snmpEtherStatsPkts64Octets:
    311         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT64r, &count);
    312         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR64r, &count);
    313         break;
    314     case snmpEtherStatsPkts65to127Octets:
    315         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT127r, &count);
    316         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR127r, &count);
    317         break;
    318     case snmpEtherStatsPkts128to255Octets:
    319         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT255r, &count);
    320         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR255r, &count);
    321         break;
    322     case snmpEtherStatsPkts256to511Octets:
    323         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT511r, &count);
    324         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR511r, &count);
    325         break;
    326     case snmpEtherStatsPkts512to1023Octets:
    327         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT1023r, &count);
    328         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR1023r, &count);
    329         break;
    330     case snmpEtherStatsPkts1024to1518Octets:
    331         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    332             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT1518r, &count);
    333             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR1518r, &count);
    334         } else {
    335             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT2047r, &count);
    336             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR2047r, &count);
    337         }
    338         break;
    339 
    340         /* *** not actually in rfc1757 *** */
    341 
    342     case snmpBcmEtherStatsPkts1519to1522Octets:
    343         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT2047r, &count);
    344         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR2047r, &count);
    345         break;
    346     case snmpBcmEtherStatsPkts1522to2047Octets:
    347         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT2047r, &count);
    348         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR2047r, &count);
    349         break;
    350     case snmpBcmEtherStatsPkts2048to4095Octets:
    351         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT4095r, &count);
    352         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR4095r, &count);
    353         break;
    354     case snmpBcmEtherStatsPkts4095to9216Octets:
    355         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR9216r, &count);
    356         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT9216r, &count);
    357         break;
    358 
    359     case snmpBcmReceivedPkts64Octets:
    360         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR64r, &count);
    361         break;
    362     case snmpBcmReceivedPkts65to127Octets:
    363         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR127r, &count);
    364         break;
    365     case snmpBcmReceivedPkts128to255Octets:
    366         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR255r, &count);
    367         break;
    368     case snmpBcmReceivedPkts256to511Octets:
    369         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR511r, &count);
    370         break;
    371     case snmpBcmReceivedPkts512to1023Octets:
    372         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR1023r, &count);
    373         break;
    374     case snmpBcmReceivedPkts1024to1518Octets:
    375         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR1518r, &count);
    376         break;
    377     case snmpBcmReceivedPkts1519to2047Octets:
    378         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR2047r, &count);
    379         break;
    380     case snmpBcmReceivedPkts2048to4095Octets:
    381         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR4095r, &count);
    382         break;
    383     case snmpBcmReceivedPkts4095to9216Octets:
    384         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR9216r, &count);
    385         break;
    386     case snmpBcmReceivedPkts9217to16383Octets:
    387         if (SOC_REG_IS_VALID(unit, IR16383r)) {
    388             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IR16383r, &count);
    389         } else {
    390             return BCM_E_UNAVAIL;
    391         }
    392         break;
    393     case snmpBcmTransmittedPkts64Octets:
    394         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT64r, &count);
    395         break;
    396     case snmpBcmTransmittedPkts65to127Octets:
    397         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT127r, &count);
    398         break;
    399     case snmpBcmTransmittedPkts128to255Octets:
    400         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT255r, &count);
    401         break;
    402     case snmpBcmTransmittedPkts256to511Octets:
    403         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT511r, &count);
    404         break;
    405     case snmpBcmTransmittedPkts512to1023Octets:
    406         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT1023r, &count);
    407         break;
    408     case snmpBcmTransmittedPkts1024to1518Octets:
    409         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT1518r, &count);
    410         break;
    411     case snmpBcmTransmittedPkts1519to2047Octets:
    412         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT2047r, &count);
    413         break;
    414     case snmpBcmTransmittedPkts2048to4095Octets:
    415         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT4095r, &count);
    416         break;
    417     case snmpBcmTransmittedPkts4095to9216Octets:
    418         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT9216r, &count);
    419         break;
    420     case snmpBcmTransmittedPkts9217to16383Octets:
    421         if (SOC_REG_IS_VALID(unit, IT16383r)) {
    422             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IT16383r, &count);
    423         } else {
    424             return BCM_E_UNAVAIL;
    425         }
    426         break;
    427     case snmpEtherStatsTXNoErrors:
    428 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_TRX_SUPPORT)
    429         if (soc_feature(unit, soc_feature_hw_stats_calc)) {
    430             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    431                               ITPOKr, &count); /* All good packets */
    432         } else 
    433 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */
    434         {
    435             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITPKTr, &count);
    436             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    437                               ITFRGr, &count);
    438             if (COUNT_OVR_ERRORS(unit)) {
    439                 if (SOC_REG_IS_VALID(unit, CLMIB_TOVRr)) {
    440                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
    441                                   CLMIB_TOVRr, &count);
    442                 } else {
    443                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
    444                                   ITOVRr, &count);
    445                 }
    446             }
    447             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    448                               ITUFLr, &count);
    449             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    450                               ITERRr, &count);
    451         }
    452         break;
    453     case snmpEtherStatsRXNoErrors:
    454 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_TRX_SUPPORT)
    455         if (soc_feature(unit, soc_feature_hw_stats_calc)) {
    456             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRPOKr, &count);
    457         } else 
    458 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */
    459         {
    460             /*
    461              * IRPKT - (IRFCS + IRJBR + IROVR + IRUND + IRFLR +
    462              *           IRFRG + IRERPKT)
    463              */
    464             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRPKTr, &count);
    465             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    466                               IRFCSr, &count);
    467             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    468                               IRJBRr, &count);
    469             if (COUNT_OVR_ERRORS(unit)) {
    470                 if (SOC_REG_IS_VALID(unit, CLMIB_ROVRr)) {
    471                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op,
    472                               CLMIB_ROVRr, &count);
    473                 } else {
    474                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
    475                                   IROVRr, &count);
    476                 }
    477             }
    478             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    479                               IRUNDr, &count);
    480             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    481                               IRFRGr, &count);
    482             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    483                               IRERPKTr, &count);
    484         }
    485         break;
    486 
    487         /* *** RFC 2665 *** */
    488 
    489     case snmpDot3StatsAlignmentErrors:
    490         break;
    491     case snmpDot3StatsFCSErrors:
    492         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRFCSr, &count);
    493         break;
    494     case snmpDot3StatsSingleCollisionFrames:
    495         break;
    496     case snmpDot3StatsMultipleCollisionFrames:
    497         break;
    498     case snmpDot3StatsSQETTestErrors:
    499         break;
    500     case snmpDot3StatsDeferredTransmissions:
    501         break;
    502     case snmpDot3StatsLateCollisions:
    503         break;
    504     case snmpDot3StatsExcessiveCollisions:
    505         break;
    506     case snmpDot3StatsInternalMacTransmitErrors:
    507         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITUFLr, &count);
    508         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITERRr, &count);
    509         break;
    510     case snmpDot3StatsCarrierSenseErrors:
    511         break;
    512     case snmpDot3StatsFrameTooLongs:
    513         if ((soc_feature(unit, soc_feature_stat_jumbo_adj)) &&
    514             (!SOC_IS_TRIUMPH(unit)) ) {
    515             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMEGr, &count);
    516             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMEBr, &count);
    517         } else {
    518             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRJBRr, &count);
    519         }
    520         break;
    521     case snmpDot3StatsInternalMacReceiveErrors:
    522         break;
    523     case snmpDot3StatsSymbolErrors:
    524         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRERBYTr, &count);
    525         break;
    526     case snmpDot3ControlInUnknownOpcodes:
    527         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRXUOr, &count);
    528         break;
    529     case snmpDot3InPauseFrames:
    530         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRXPFr, &count);
    531         break;
    532     case snmpDot3OutPauseFrames:
    533         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITXPFr, &count);
    534         break;
    535 
    536         /* *** RFC 2233 high capacity versions of RFC1213 objects *** */
    537 
    538     case snmpIfHCInOctets:
    539         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRBYTr, &count);
    540         break;
    541     case snmpIfHCInUcastPkts:
    542         if (soc_feature(unit, soc_feature_hw_stats_calc)) {
    543             if (SOC_REG_IS_VALID(unit, IRUCAr)) {
    544                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    545                                   IRUCAr, &count);
    546             } else if (SOC_REG_IS_VALID(unit, IRUCr)) {
    547                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRUCr, &count);
    548             } else {
    549                 BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RUCr, &count);  /* unicast pkts rcvd */
    550             }
    551         } else {
    552             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRPKTr, &count);
    553             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    554                               IRMCAr, &count);
    555             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    556                               IRBCAr, &count);
    557             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    558                               IRFCSr, &count); /* - bad FCS */
    559             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    560                               IRXCFr, &count); /* - good FCS, all MAC ctrl */
    561             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    562                               IRXPFr, &count); /* - not included in IRXCFr */
    563             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    564                               IRJBRr, &count); /* - oversize, bad FCS */
    565             if (COUNT_OVR_ERRORS(unit)) {
    566                 if (SOC_REG_IS_VALID(unit, CLMIB_ROVRr)) {
    567                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
    568                                   CLMIB_ROVRr, &count);
    569                 } else {
    570                     BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op,
    571                                   IROVRr, &count); /* - oversize, good FCS */
    572                 }
    573             }
    574         }
    575         break;
    576     case snmpIfHCInMulticastPkts:
    577         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRMCAr, &count);
    578         break;
    579     case snmpIfHCInBroadcastPkts:
    580         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRBCAr, &count);
    581         break;
    582     case snmpIfHCOutOctets:
    583         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITBYTr, &count);
    584         break;
    585     case snmpIfHCOutUcastPkts:
    586 #if defined(BCM_FIREBOLT2_SUPPORT) || defined(BCM_TRX_SUPPORT)
    587         if (soc_feature(unit, soc_feature_hw_stats_calc)) {
    588             /* This register has a different name on some devices.
    589              * Only one value is added here. */
    590             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    591                               ITUCr, &count); /* All good packets */
    592             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    593                               ITUCAr, &count);  /* unicast pkts sent */
    594         } else 
    595 #endif /* BCM_FIREBOLT2_SUPPORT || BCM_TRX_SUPPORT */
    596         {
    597             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITPKTr, &count);
    598             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    599                               ITMCAr, &count);
    600             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_sub_op, 
    601                               ITBCAr, &count);
    602         }
    603         break;
    604     case snmpIfHCOutMulticastPkts:
    605         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITMCAr, &count);
    606         break;
    607     case snmpIfHCOutBroadcastPckts:
    608         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITBCAr, &count);
    609         break;
    610 
    611         /* *** RFC 2465 *** */
    612 
    613     case snmpIpv6IfStatsInReceives:
    614         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    615             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPC6r, &count);
    616             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6r, &count);
    617         }
    618         break;
    619     case snmpIpv6IfStatsInHdrErrors:
    620         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    621             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6r, &count);
    622         }
    623         break;
    624     case snmpIpv6IfStatsInAddrErrors:
    625         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    626             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE6r, &count);
    627         }
    628         break;
    629     case snmpIpv6IfStatsInDiscards:
    630         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    631             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPHE6r, &count);
    632             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RIPD6r, &count);
    633         }
    634         break;
    635     case snmpIpv6IfStatsOutForwDatagrams:
    636         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    637             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC0r, &count);
    638         }
    639         break;
    640     case snmpIpv6IfStatsOutDiscards:
    641         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    642             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC1r, &count);
    643         }
    644         break;
    645     case snmpIpv6IfStatsInMcastPkts:
    646         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    647              BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6r, &count);
    648         }
    649         break;
    650     case snmpIpv6IfStatsOutMcastPkts:
    651         if (soc_feature(unit, soc_feature_stat_xgs3)) {
    652             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC2r, &count);
    653         }
    654         break;
    655 
    656         /* *** IEEE 802.1bb *** */
    657     case snmpIeee8021PfcRequests:
    658         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, ITXPPr, &count);
    659         break;
    660     case snmpIeee8021PfcIndications:
    661         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IRXPPr, &count);
    662         break;
    663 
    664         /* *** RFC 1284 - unsupported in XGS *** */
    665     case snmpDot3StatsInRangeLengthError:
    666         break;
    667 
    668         /* *** RFC 4837 - unsupported in XGS *** */
    669     case snmpDot3OmpEmulationCRC8Errors:
    670     case snmpDot3MpcpRxGate:
    671     case snmpDot3MpcpRxRegister:
    672     case snmpDot3MpcpTxRegRequest:
    673     case snmpDot3MpcpTxRegAck:
    674     case snmpDot3MpcpTxReport:
    675     case snmpDot3EponFecCorrectedBlocks:
    676     case snmpDot3EponFecUncorrectableBlocks:
    677         break;
    678 
    679         /* IPMC counters (broadcom specific) */
    680 
    681     case snmpBcmIPMCBridgedPckts:
    682         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC1r, &count);
    683         break;
    684     case snmpBcmIPMCRoutedPckts:
    685         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP4r, &count);
    686         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, IMRP6r, &count);
    687         break;
    688     case snmpBcmIPMCInDroppedPckts:
    689         BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC2r, &count);
    690         break;
    691     case snmpBcmIPMCOutDroppedPckts:
    692         if (soc_feature(unit, soc_feature_stat_xgs3)) { 
    693             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC5r, &count);
    694         }
    695         break;
    696 
    697         /* EA (broadcom specific) - unsupported in XGS */
    698     case snmpBcmPonInDroppedOctets:
    699     case snmpBcmPonOutDroppedOctets:
    700     case snmpBcmPonInDelayedOctets:
    701     case snmpBcmPonOutDelayedOctets:
    702     case snmpBcmPonInDelayedHundredUs:
    703     case snmpBcmPonOutDelayedHundredUs:
    704     case snmpBcmPonInFrameErrors:
    705     case snmpBcmPonInOamFrames:
    706     case snmpBcmPonOutOamFrames:
    707     case snmpBcmPonOutUnusedOctets:
    708         break;
    709 
    710     case snmpFcmPortClass3RxFrames:
    711         if (soc_feature(unit, soc_feature_fcoe)) {
    712             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC3r, &count);
    713         } else {
    714             return BCM_E_UNAVAIL;
    715         }
    716         break;
    717 
    718     case snmpFcmPortClass3TxFrames:
    719         if (soc_feature(unit, soc_feature_fcoe)) {
    720             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC6r, &count);
    721         } else {
    722             return BCM_E_UNAVAIL;
    723         }
    724         break;
    725 
    726     case snmpFcmPortClass3Discards:
    727         if (soc_feature(unit, soc_feature_fcoe)) {
    728             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC4r, &count);
    729         } else {
    730             return BCM_E_UNAVAIL;
    731         }
    732         break;
    733 
    734     case snmpFcmPortClass2RxFrames:
    735         if (soc_feature(unit, soc_feature_fcoe)) {
    736             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC5r, &count);
    737         } else {
    738             return BCM_E_UNAVAIL;
    739         }
    740         break;
    741 
    742     case snmpFcmPortClass2TxFrames:
    743         if (soc_feature(unit, soc_feature_fcoe)) {
    744             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, TDBGC7r, &count);
    745         } else {
    746             return BCM_E_UNAVAIL;
    747         }
    748         break;
    749 
    750     case snmpFcmPortClass2Discards:
    751         if (soc_feature(unit, soc_feature_fcoe)) {
    752             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, RDBGC6r, &count);
    753         } else {
    754             return BCM_E_UNAVAIL;
    755         }
    756         break;
    757 
    758     case snmpFcmPortInvalidCRCs:
    759         if (soc_feature(unit, soc_feature_fcoe)) {
    760             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    761                               EGR_FCOE_INVALID_CRC_FRAMESr, &count);
    762         } else {
    763             return BCM_E_UNAVAIL;
    764         }
    765         break;
    766 
    767     case snmpFcmPortDelimiterErrors:
    768         if (soc_feature(unit, soc_feature_fcoe)) {
    769             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, 
    770                               EGR_FCOE_DELIMITER_ERROR_FRAMESr, 
    771                     &count);
    772         } else {
    773             return BCM_E_UNAVAIL;
    774         }
    775         break;
    776 
    777     case snmpBcmTxE2ECCControlFrames:
    778         if (SOC_REG_IS_VALID(unit, XTHOLr)) {
    779             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op, XTHOLr,
    780                               &count);
    781         }
    782         break;
    783 
    784     case snmpBcmRxDot3LengthMismatches:
    785         if (SOC_REG_IS_VALID(unit, IRFLRr)) {
    786             BCM_STAT_REG_OPER(unit, port, sync_mode, reg_op,
    787                               IRFLRr, &count); /* Good FCS, bad length */
    788         } else {
    789             return BCM_E_UNAVAIL;
    790         }
    791         break;
    792 
    793     default:
    794         if (type < snmpValCount) {
    795             return BCM_E_UNAVAIL;
    796         }
    797         LOG_VERBOSE(BSL_LS_SOC_COMMON,
    798                     (BSL_META_U(unit,
    799                                 "_bcm_stat_xe_get: Statistic not supported: %d\n"), type));
    800         return BCM_E_PARAM;
    801     }
    802 
    803     if (stat_op == _BCM_STAT_GET) {
    804         *val = count;
    805     }
    806 
    807     return BCM_E_NONE;
    808 }