CustomSTAT

Enable/disable counter collection

CustomSTAT

Shortest form: cstat.

Show and configure the programmable debug counters: RDBGC on receive and TDBGC on transmit. Each counter counts the packets that match a set of triggers, mostly drop reasons. Usually typed as cstat. The command’s one-line description in help, “Enable/disable counter collection”, is wrong. It is copied from counter.

The first word selects the mode: ls, info, set, get or raw. Any other word is taken as the port bitmap for the counter table. Then comes rx or tx; in the table form, a word starting with z includes zero counters instead. Last comes the counter: a decimal index, or all. All keywords must be typed in full. The built-in help speaks of names such as RDBGC0, but the shell accepts only the index (0).

SONiC drop counters (show dropcounters) may use these same debug counters, so cstat set can change what a configured SONiC drop counter reports.

Safety on a running switch

Form

Effect

cstat <pbmp> [z], ls, info, get, raw

Read-only.

set

Reprograms a debug counter’s triggers behind SONiC’s back.

Hardware-validated — Non-zero debug counters and their triggers on all front-panel ports

drivshell> cstat xe

+------------------Programmable Statistics Counters[Port  xe3]------------------+
| Type | No. |       Value       |                Enabled For                   |
+-------------------------------------------------------------------------------+
|      | 2(R)|               7035| RIMDR                                        |
+-------------------------------------------------------------------------------+

The table form prints one box per port, and only for ports that have a non-zero counter; ports with nothing to show are skipped silently. No. is the counter index, with (R) marking a receive (RDBGC) counter, and Enabled For lists the counter’s triggers. In the example only xe3 had counted anything: 7035 packets on receive counter 2 (RIMDR).

With no argument at all, the table is shown for logical port 0, which on Trident 3 is the CPU port. SONiC’s show techsupport collects cstat (scripts/generate_dump (show techsupport collector)), and the SDK’s own techsupport basic runs cstat get all.

Unvalidated — Include counters that are zero

drivshell> cstat xe0 z
CustomSTAT ls [rx | tx]

List the available trigger names for both directions, or for one. Read-only.

Hardware-validated

drivshell> cstat ls rx
Custom stat
 Available Rx trigger flags :
  RIPD4              RIPC4              RIPHE4             IMRP4
  RIPD6              RIPC6              RIPHE6             IMRP6
  RUC                RPORTD             PDISC              IMBP
  RFILDR             RIMDR              RDROP              IRPSE
  IRHOL              IRIBP              DSL3HE             IUNKHDR
  DSL4HE             IMIRROR            MTUERR             RTUN
  RHGUC              RHGMC              HGHDRE             MCIDXE
  LAGLUP             LAGLUPD            PARITYD            VFPDR
  URPF               CLASSBASEDMOVEDROP MACLMT_NODROP      MACSAEQUALMACDA
  MACLMT_DROP        FcmPortClass3RxFrames FcmPortClass3RxDiscards FcmPortClass2RxFrames
  FcmPortClass2RxDiscards NonHGoE            HGoE               RxHigigLoopbackDrop
  RxHigigUnknownOpcodeDrop RxIpInIpDrop       RxMimDrop          RxTunnelInterfaceError
  RxMplsControlWordInvalid RxMplsGalNotBosDrop RxMplsPayloadInvalid RxMplsEntropyDrop
  RxMplsLabelLookupMiss RxMplsActionInvalid RxTunnelTtlError   RxTunnelShimError
  RxTunnelObjectValidationFail RxVlanMismatch     RxVlanMemberMismatch RxTpidMismatch
  RxPrivateVlanMismatch RxMacIpBindError   RxVlanTranslate2LookupMiss RxL3TunnelLookupMiss
  RxMplsLookupMiss   RxVlanTranslate1LookupMiss RxFcoeVftDrop      RxFcoeSrcBindError
  RxFcoeSrcFpmaError RxVfiP2pDrop       RxStgDrop          RxCompositeError
  RxBpduDrop         RxProtocolDrop     RxUnknownMacSaDrop RxSrcRouteDrop
  RxL2SrcDiscardDrop RxL2SrcStaticMoveDrop RxL2DstDiscardDrop RxL3DisableDrop
  RxMacSaEqual0Drop  RxVlanCrossConnectOrNonUnicastDrop RxTimeSyncDrop     RxIpmcDrop
  RxMyStationDrop    RxPrivateVlanVpFilterDrop RxL3DstDiscardDrop RxTunnelDecapEcnError
  RxL3SrcDiscardDrop RxFcoeZoneLookupMiss RxL3TtlError       RxL3HeaderError
  RxL2HeaderError    RxL3DstLookupDrop  RxL2TtlError       RxL2RpfError
  RxTagUntagDiscardDrop RxStormControlDrop RxFcoeZoneError    RxFieldChangeL2NoRedirectDrop
  RxNextHopDrop      RxNatDrop          IngressProtectionDataDrop RxSrcKnockoutDrop
  RxMplsSeqNumberError RxBlockMaskDrop    RxDlbRhResolutionError
CustomSTAT info [rx | tx]

Like ls, with a short description of each trigger. Read-only.

Hardware-validated

drivshell> cstat info tx
Custom stat
 Available Tx trigger flags :
  TGIP4         Tx Good IPv4 L3 UC packets
  TIPD4         Tx IPv4 L3 UC Aged and Drop packets
  TGIPMC4       Tx Good IPv4 IPMC packets
  TIPMCD4       Tx IPv4 IPMC Aged and Drop packets
  TGIP6         Tx Good IPv6 L3 UC packets
  TIPD6         Tx IPv6 L3 UC Aged and Drop Packets
  TGIPMC6       Tx Good IPv6 IPMC packets
  TIPMCD6       Tx IPv6 IPMC Aged and Drop packets
  TTNL          Tx Tunnel packets
  TTNLE         Tx Tunnel error packets
  TTTLD         Pkts dropped due to TTL threshold counter
  TCFID         Pkts dropped when CFI set & pkt is untagged or L3 switched for IPMC
  TVLAN         Tx VLAN tagged packets
  TVXLTMD       Pkts dropped due to miss in VXLT table counter
  TSTGD         Pkts dropped due to Spanning Tree State not in forwarding state
  TAGED         Pkts dropped due to packet aged counter
  TL2MCD        L2 MC packet drop counter
  TPKTD         Pkts dropped due to any condition
  TMIRR         mirroring flag
  TSIPL         SIP Link Local Drop flag
  THGUC         Higig Lookedup L3UC Pkts
  THGMC         Higig Lookedup L3MC Pkts
  THIGIG2       Unknown HiGig2 Drop
  THGI          Unknown HiGig drop
  TL2_MTU       L2 MTU fail drop
  TPARITY_ERR   Parity Error drop
  TIP_LEN_FAIL  IP Length check fail drop
  TSLLD         ESIP_LINK_LOCAL
...
CustomSTAT get <pbmp> [rx | tx] [<counter> | all]

Show the triggers enabled on one counter, or on all of them. Read-only. The triggers are the same on every port (the output says [Triggers are common for all ports]), so the port bitmap only has to be valid. Receive counters are listed as snmpBcmCustomReceive<n>, each with its triggers; unconfigured counters are left out. On a SONiC switch receive counters 0–6 are configured.

Hardware-validated

drivshell> cstat get xe0 rx all
Custom Receive stats are enabled for following triggers
[Triggers are common for all ports]

  snmpBcmCustomReceive0-
          RIPD4 RIPD6 RPORTD PDISC RDROP
          RxVlanMismatch RxVlanMemberMismatch RxTpidMismatch RxPrivateVlanMismatch RxSrcKnockoutDrop

  snmpBcmCustomReceive1-
          IMBP
  snmpBcmCustomReceive2-
          RIMDR
  snmpBcmCustomReceive3-
          RxVlanMismatch RxVlanMemberMismatch RxTpidMismatch RxPrivateVlanMismatch
  snmpBcmCustomReceive4-
          RIPC4 IMRP4
  snmpBcmCustomReceive5-
          IMRP4
  snmpBcmCustomReceive6-
          RIPC6
CustomSTAT raw <pbmp> [rx | tx] [<counter> | all]

Show a debug counter’s current value in raw form. Read-only. A counter that has nothing to report prints only the RX Custom Statistics : (or TX) heading.

Hardware-validated

drivshell> cstat raw xe0 rx 0
RX Custom Statistics :
CustomSTAT set <pbmp> <rx | tx> <counter> <trigger> [<trigger> ...]

Set the triggers of one debug counter on the given ports. Take the trigger names from CustomSTAT ls. If a part is missing, it prints Error: No input type[rx|tx], Error: No input counter or Error: No input triggers. This changes switch state behind SONiC’s back.

Unvalidated — Replace <trigger> with a name from “cstat ls rx”

drivshell> cstat set xe0 rx 5 <trigger>

Built-in help

Usages:
      cstat <pbmp> [z]
            - Display all non-zero custom counters and their triggers
                z  - include counters that are zero
      cstat raw <pbmp> [rx|tx] <counter>
            - Display value of counter in raw mode
      cstat set <pbmp> [rx|tx] <counter> <triggers>
            - Set triggers for given counter
      cstat get <pbmp> [rx|tx] <counter>
            - Get currently enabled triggers of counter
      cstat ls [rx|tx]
            - List available triggers
      cstat info [rx|tx]
            - List available triggers with short description
            Note: To specify all counters use 'all'
    Displays and configures programmable statistic counters
    RDBGC0,TDBGC0 etc.

Further reading

SDK-6.5.20 HSDK Getting Started Guide (GS-SDK6520-R), plus SDK-6.5.20/21/22 Release Notes (RN-SDK65xx-R), BCM_SDK命令.