/*
Copyright (C) 2008, 2009  GE Intelligent Platforms, Inc
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/* rhAsicDrv - RedHawk ASIC device driver */

/*
DESCRIPTION:

    This module provides the interface to RedHawk ASIC.
    Displays the statistics of individual modules in RedHawk.

INCLUDES:
    regif.h redHawkReg.h rhAsciLib.h

SEE ALSO:
    registerLib

*/

#include <common.h>
#include <config.h>
#include <command.h>

#ifndef CONFIG_OCTEON_AT5810
#include "systypes.h"
#endif

#include "rhOsif.h"
#include "rhRegif.h"
#include "rhAsicLib.h"
#include "rhAsicReg.h"

static void stShow (char *str, unsigned int data)
{
    osPrintf("    %-40s : %u\n", str, data);
}

/******************************************************************
* shadowregs_stats - Display RedHawk Shadow Statistics
*
* The routine displays the RedHawk Shadow statistics
*
* RETURNS: None
*/
void shadowregs_stats (
        int port              /* port number */
        )
{
	shadowRegsStats stat;

	rhAsicShadowRegsStats(redHawkRegs, port , &stat);

	osPrintf("RedHawk Shadow Register Statistics for Port %d\n", port);

	stShow("Total Frms Rcvd", stat.ToalFrmsReceived);
	stShow("Total Frms Txd", stat.ToalFrmsTransmitted);
	stShow("Total Good Frms Rcvd", stat.GoodFrmsReceived);
	stShow("Total Good Frms Txd", stat.GoodFrmsTransmitted);
	stShow("Total CRC Err Frms Rcvd", stat.CrcErrsReceived);
	stShow("Total CRC Err Frms Txd", stat.CrcErrsTransmitted);
	stShow("RED Drops", stat.FrmsDropedByRed);
	stShow("UCast Drops", stat.UCastFrmsDroped);
	stShow("MCast Drops", stat.MCastFrmsDroped);
	stShow("BCast Drops", stat.BCastFrmsDroped);
	stShow("MPLS Drops", stat.MPLSFrmsDroped);
	stShow("EthType Drops", stat.EthTypeMatchFrmsDroped);
	stShow("MAC Filter Drops", stat.MacFilterFrmsDroped);
	stShow("Ctrl Block Drops", stat.IngFilterFrmsDroped);
	stShow("Excess Latency Drops", stat.DeqExcessLatencyFrmsDroped);
	stShow("EnqMemFull Drops", stat.EnqMemFullFrmsDroped);
}

/******************************************************************
* rxmac_stats - Display RedHawk receive MAC Statistics
*
* The routine displays the receive MAC statistics of the RedHawk.
*
* RETURNS: None
*/
void rxmac_stats (
        int port              /* port number */
        )
{
	rxMacStats stat;

	rhAsicRxMacStats (redHawkRegs, port , &stat);

	osPrintf("RedHawk RxMAC Statistics for Port %d\n", port);

	stShow("VLAN Tags", stat.RxVLANTagRcvd);
	stShow("PAUSE Time", stat.RxPauseTime);

	stShow("Errored Frms", stat.RxNumOfBadFrms);
	stShow("Good Frms", stat.RxFRcvdOK);
	stShow("CRC Errored Frms", stat.RxNumOfCRCErrors);
	stShow("BCast Frms", stat.RxNumOfBcastFrms);
	stShow("MCast Frms", stat.RxNumOfMcastFrms);
	stShow("64B Frms", stat.RxFrmsOf64Octets);
	stShow("65To127B Frms", stat.RxFrmsOf65to127Octets);
	stShow("128To255B Frms", stat.RxFrmsOf128to255Octets);
	stShow("256To511B Frms", stat.RxFrmsOf256to511Octets);
	stShow("512To1023B Frms", stat.RxFrmsOf512to1023Octets);
	stShow("1024To1518B Frms", stat.RxFrmsOf1024to1518Octets);
	stShow("Jumbo Frms", stat.RxJumboFrms);
	stShow("Oversize Frms", stat.RxOversizeFrms);
	stShow("Undersize Frms", stat.RxUndersizeFrms);
	stShow("Fragments", stat.RxNumOfFragments);
	stShow("Jabbers", stat.RxNumOfJabbers);
	stShow("Too Long Jabbers", stat.RxNumOfTooLongJabbers);
	stShow("OutOfRange Len", stat.RxOutOfRangeLenField);
	stShow("Too Long Errors", stat.RxFTooLongErrors);
	stShow("MAC Ctrl Frms", stat.RxMACCtrlFRcvd);
	stShow("Unsupp Opcode", stat.RxUnsuppOpcodeRcvd);
	stShow("Good VLANs", stat.RxGoodVLANFRcvd);
	stShow("SA Errored Frms", stat.RxBadSAFRcvd);
	stShow("Data Errored Frms", stat.RxDataError);
	stShow("MCast Drops", stat.RxMcastDrop);
	stShow("BCast Drops", stat.RxBcastDrop);
	stShow("Filter Drops", stat.RxFilDrop);
	stShow("MAC Interrupt", stat.RxMACInterrupt);
	stShow("MAC Interrupt Mask", stat.RxMACInterruptMask);
	stShow("MAC Diag", stat.RxMACDiag);
	stShow("Frms with IPG 5B", stat.RxIPG5);
	stShow("Frms with IPG 6B", stat.RxIPG6);
	stShow("Frms with IPG 7B", stat.RxIPG7);
	stShow("Frms with IPG 8B", stat.RxIPG8);
	stShow("Frms with IPG 9B", stat.RxIPG9);
	stShow("Frms with IPG 10B", stat.RxIPG10);
	stShow("Frms with IPG 11B", stat.RxIPG11);
}

/******************************************************************
* rxdropcontrol_stats - Displays RedHawk Drop Control Statistics
*
* The routine displays the RedHawk Drop Control statistics
*
* RETURNS: None
*/
void rxdropcontrol_stats (
        int port              /* port number */
        )
{
	rxDropControlStats stat;

	rhAsicRxDropControlStats (redHawkRegs, port, &stat);

	osPrintf("Rx Drop Control Stats for port %d\n", port);

	stShow("Tail Dropped Pkts", stat.TailDropCount);
	stShow("Def Dropped Pkts", stat.RxDefaultDroppedFrms);
	stShow("BCast Dropped Frms", stat.RxDroppedBCastFrms);
	stShow("MCast Dropped Frms", stat.RxDroppedMCastFrms);
	stShow("MPLS Type Frms", stat.RxMPLSTypeMatchFrms);
	stShow("MPLS Def Match Frms", stat.RxMPLSDefaultMatchFrms);
	stShow("MPLS LLSP Match Frms", stat.RxMPLSLLSPMatchFrms);
	stShow("MPLS DLLSP Match Frms", stat.RxMPLSDLLSPMatchFrms);
	stShow("MPLS Dropped Frms", stat.RxMPLSDroppedFrms);
	stShow("VLAN EtherType Frms", stat.RxVLANEthertypeFrms);
	stShow("SVLAN EtherType Frms", stat.RxSVLANEthertypeFrms);
	stShow("VLAN SVLAN Ether Drop Frms", stat.RxVLANSVLANEtherDropFrms);
	stShow("Std Primary Map Frms", stat.RxStdPriMapFrms);
	stShow("Extd Primary Map Frms", stat.RxExtdPriMapFrms);
	stShow("No VLAN Tag Frms", stat.RxNoVLANTagFrms);
	stShow("Single VLAN Tag Frms", stat.RxSingleVLANTagFrms);
	stShow("Double VLAN Tag Frms", stat.RxDoubleVLANTagFrms);
	stShow("More VLAN Tagged Frms", stat.RxMT2VLANTagFrms);
	stShow("VLAN Ctrl Dropped Frms", stat.RxVLANControlDropFrms);
	stShow("Extd VLAN Tagged Frms", stat.RxExtdVLANTagFrms);
	stShow("VLAN Tag Operation Frms", stat.RxVLANTagOpFrms);
	stShow("VLAN Priority Ovwr Frms", stat.RxVLANPrioOvrwrFrms);
	stShow("DA Match Frms", stat.RxDAMatchFrms);
	stShow("Hash Fltr Frms", stat.RxMultiHashFrms);
	stShow("Type Fltr Frms", stat.RxTypeFrms);
	stShow("Other Type Fltr Frms", stat.RxOtherTypeFrms);
	stShow("LLC/SNAP Fltr Frms", stat.RxLLCSNAPFrms);
	stShow("Unknown LLC/SNAP Fltr Frms", stat.RxUnknownLLCSNAPFrms);
	stShow("MAC Drop Frms", stat.RxMACDropFrms);
	stShow("DSCP Mismatch Frms", stat.RxDSCPIPVerMismatchFrms);
	stShow("DSCP Fltr Frms", stat.RxDSCPAssignFrms);
	stShow("IP Fltr Frms", stat.RxIPAssignFrms);
	stShow("Def IP Fltr Frms", stat.RxDIPAssignFrms);
	stShow("DSCP IP Drop Frms", stat.RxDSCPIPDropFrms);
	stShow("DropCtrl EOF's", stat.RxDropControlEOFs);
	stShow("Outer VLAN Ctrl Table Data", stat.OVLANCtrlRdData);
	stShow("Inner VLAN Ctrl Table Data", stat.IVLANCtrlRdData);
	stShow("VLAN ID Table Data", stat.VLANIDRdData);
	stShow("Hash Ctrl Read Data", stat.HashRdData);
	stShow("DSCP Assign Table Data", stat.DSCPAssignData);
	stShow("Illegal Length Frms", stat.RxIllegalTypeLenFrms);
	stShow("VLAN Tag RAM Data", stat.RdDataRxVlanTagRam);
	stShow("InRange Length Err Frms", stat.RxInRangeLengthErrs);
	stShow("OutOfRange Length Err Frms", stat.RxOutofRangeLengthErrs);
	stShow("Queue0 Frms", stat.RxQueue0Frms);
	stShow("Queue1 Frms", stat.RxQueue1Frms);
	stShow("Queue2 Frms", stat.RxQueue2Frms);
	stShow("Queue3 Frms", stat.RxQueue3Frms);
	stShow("Queue4 Frms", stat.RxQueue4Frms);
	stShow("Queue5 Frms", stat.RxQueue5Frms);
	stShow("Queue6 Frms", stat.RxQueue6Frms);
	stShow("Queue7 Frms", stat.RxQueue7Frms);
}

/******************************************************************
* rxdropcontrolwred_stats - Display RedHawk Drop Control WRED Statistics
*
* The routine displays the RedHawk Drop Control WRED statistics
*
* RETURNS: None
*/
void rxdropcontrolwred_stats (
        int port              /* port number */
        )
{
	rxDropControlWredStats stat;

	rhAsicRxDropControlWredStats (redHawkRegs, port, &stat);

	osPrintf("Rx Drop Control WRED Statistics for port %d\n", port);

	stShow("WRED Drop Propability", stat.WREDDropProbability);
	stShow("WRED Drop[0] Frms", stat.WREDDrop_0);
	stShow("WRED Drop[1] Frms", stat.WREDDrop_1);
	stShow("WRED Drop[2] Frms", stat.WREDDrop_2);
	stShow("WRED Drop[3] Frms", stat.WREDDrop_3);
	stShow("WRED Drop[4] Frms", stat.WREDDrop_4);
	stShow("WRED Drop[5] Frms", stat.WREDDrop_5);
	stShow("WRED Drop[6] Frms", stat.WREDDrop_6);
	stShow("WRED Drop[7] Frms", stat.WREDDrop_7);

	stShow("BPDU Drop[0] Frms", stat.BPDUDrop_0);
	stShow("BPDU Drop[1] Frms", stat.BPDUDrop_1);
	stShow("BPDU Drop[2] Frms", stat.BPDUDrop_2);
	stShow("BPDU Drop[3] Frms", stat.BPDUDrop_3);
	stShow("BPDU Drop[4] Frms", stat.BPDUDrop_4);
	stShow("BPDU Drop[5] Frms", stat.BPDUDrop_5);
	stShow("BPDU Drop[6] Frms", stat.BPDUDrop_6);
	stShow("BPDU Drop[7] Frms", stat.BPDUDrop_7);

	stShow("Tail Drop[0] Frms", stat.TailDrop_0);
	stShow("Tail Drop[1] Frms", stat.TailDrop_1);
	stShow("Tail Drop[2] Frms", stat.TailDrop_2);
	stShow("Tail Drop[3] Frms", stat.TailDrop_3);
	stShow("Tail Drop[4] Frms", stat.TailDrop_4);
	stShow("Tail Drop[5] Frms", stat.TailDrop_5);
	stShow("Tail Drop[6] Frms", stat.TailDrop_6);
	stShow("Tail Drop[7] Frms", stat.TailDrop_7);

	stShow("Green Color Mark[0] Frms", stat.GreenColorMark_0);
	stShow("Green Color Mark[1] Frms", stat.GreenColorMark_1);
	stShow("Green Color Mark[2] Frms", stat.GreenColorMark_2);
	stShow("Green Color Mark[3] Frms", stat.GreenColorMark_3);
	stShow("Green Color Mark[4] Frms", stat.GreenColorMark_4);
	stShow("Green Color Mark[5] Frms", stat.GreenColorMark_5);
	stShow("Green Color Mark[6] Frms", stat.GreenColorMark_6);
	stShow("Green Color Mark[7] Frms", stat.GreenColorMark_7);

	stShow("Yellow Color Mark[0] Frms", stat.YelloColorMark_0);
	stShow("Yellow Color Mark[1] Frms", stat.YelloColorMark_1);
	stShow("Yellow Color Mark[2] Frms", stat.YelloColorMark_2);
	stShow("Yellow Color Mark[3] Frms", stat.YelloColorMark_3);
	stShow("Yellow Color Mark[4] Frms", stat.YelloColorMark_4);
	stShow("Yellow Color Mark[5] Frms", stat.YelloColorMark_5);
	stShow("Yellow Color Mark[6] Frms", stat.YelloColorMark_6);
	stShow("Yellow Color Mark[7] Frms", stat.YelloColorMark_7);

	stShow("Orange Color Mark[0] Frms", stat.OrangeColorMark_0);
	stShow("Orange Color Mark[1] Frms", stat.OrangeColorMark_1);
	stShow("Orange Color Mark[2] Frms", stat.OrangeColorMark_2);
	stShow("Orange Color Mark[3] Frms", stat.OrangeColorMark_3);
	stShow("Orange Color Mark[4] Frms", stat.OrangeColorMark_4);
	stShow("Orange Color Mark[5] Frms", stat.OrangeColorMark_5);
	stShow("Orange Color Mark[6] Frms", stat.OrangeColorMark_6);
	stShow("Orange Color Mark[7] Frms", stat.OrangeColorMark_7);

	stShow("Red Color Mark[0] Frms", stat.ColorRedMark_0);
	stShow("Red Color Mark[1] Frms", stat.ColorRedMark_1);
	stShow("Red Color Mark[2] Frms", stat.ColorRedMark_2);
	stShow("Red Color Mark[3] Frms", stat.ColorRedMark_3);
	stShow("Red Color Mark[4] Frms", stat.ColorRedMark_4);
	stShow("Red Color Mark[5] Frms", stat.ColorRedMark_5);
	stShow("Red Color Mark[6] Frms", stat.ColorRedMark_6);
	stShow("Red Color Mark[7] Frms", stat.ColorRedMark_7);

	stShow("Exss Congestion Mark[0] Frms", stat.ExCongMark_0);
	stShow("Exss Congestion Mark[1] Frms", stat.ExCongMark_1);
	stShow("Exss Congestion Mark[2] Frms", stat.ExCongMark_2);
	stShow("Exss Congestion Mark[3] Frms", stat.ExCongMark_3);
	stShow("Exss Congestion Mark[4] Frms", stat.ExCongMark_4);
	stShow("Exss Congestion Mark[5] Frms", stat.ExCongMark_5);
	stShow("Exss Congestion Mark[6] Frms", stat.ExCongMark_6);
	stShow("Exss Congestion Mark[7] Frms", stat.ExCongMark_7);

	stShow("EOP Count", stat.EopCount);
}

/******************************************************************
* rxlinetocpu_stats - Display RedHawk Line To CPU Statistics
*
* The routine displays the RedHawk Line To CPU statistics
*
* RETURNS: None
*/
void rxlinetocpu_stats (
        int port              /* port number */
        )
{
	rxLineToCpuStats stat;

	rhAsicRxLineToCpuStats (redHawkRegs, port, &stat);

	osPrintf("RxLineToCPU Statistics for port %d\n", port);

	stShow("Line To CPU Data0", stat.DataReg0);
	stShow("Line To CPU Data1", stat.DataReg1);
	stShow("Line To CPU Data2", stat.DataReg2);
	stShow("Line To CPU Data3", stat.DataReg3);
	stShow("Line To CPU Data4", stat.DataReg4);
	stShow("Line To CPU Data5", stat.DataReg5);
	stShow("Line To CPU Data6", stat.DataReg6);
	stShow("Line To CPU Data7", stat.DataReg7);
	stShow("Line To CPU Data8", stat.DataReg8);
	stShow("Line To CPU Data9", stat.DataReg9);
	stShow("Line To CPU Data10", stat.DataReg10);
	stShow("Line To CPU Data11", stat.DataReg11);
	stShow("Line To CPU Data12", stat.DataReg12);
	stShow("Line To CPU WrPtr", stat.WritePointer);
	stShow("Line To CPU RdPtr", stat.ReadPointer);
	stShow("Commit Pointer", stat.CommitPointer);
	stShow("Drop Pkt Cnt", stat.DropPktCnt);
}

/******************************************************************
* enqueuer_stats - Display RedHawk Enqueuer Statistics
*
* The routine displays the RedHawk Enqueuer statistics
*
* RETURNS: None
*/
void enqueuer_stats (
        int port              /* port number */
        )
{
	enqueuerStats stat;

	rhAsicEnqueuerStats (redHawkRegs, port, &stat);

	osPrintf("Enqueuer Statistics for port %d\n", port);

	stShow("Intrl RAM Data[0]", stat.IntMemData_0);
	stShow("Intrl RAM Data[0]", stat.IntMemData_1);
	stShow("Intrl RAM Data[0]", stat.IntMemData_2);
	stShow("Intrl RAM Data[0]", stat.IntMemData_3);
	stShow("Intrl RAM Data[0]", stat.IntMemData_4);
	stShow("Intrl RAM Data[0]", stat.IntMemData_5);
	stShow("Intrl RAM Data[0]", stat.IntMemData_6);
	stShow("Intrl RAM Data[0]", stat.IntMemData_7);
	stShow("Intrl Mem Cur Read Add", stat.IntMemCurrentRdAddress);
	stShow("Intrl Mem Cur Write Add", stat.IntMemCurrentWrAddress);
	stShow("Enqueuer Ingress Pkt Cnt", stat.EnqIgrPktCnt);
	stShow("Enqueuer Egress Pkt Cnt", stat.EnqEgrPktCnt);
	stShow("Enqueuer Drop Pkt Cnt", stat.EnqDropPktCnt);
	stShow("Queue #0 Drop Cnt", stat.EnqDropPktCntQNum0);
	stShow("Queue #1 Drop Cnt", stat.EnqDropPktCntQNum1);
	stShow("Queue #2 Drop Cnt", stat.EnqDropPktCntQNum2);
	stShow("Queue #3 Drop Cnt", stat.EnqDropPktCntQNum3);
	stShow("Queue #4 Drop Cnt", stat.EnqDropPktCntQNum4);
	stShow("Queue #5 Drop Cnt", stat.EnqDropPktCntQNum5);
	stShow("Queue #6 Drop Cnt", stat.EnqDropPktCntQNum6);
	stShow("Queue #7 Drop Cnt", stat.EnqDropPktCntQNum7);
}

/******************************************************************
* dualmemctrl_stats - Display RedHawk Dual Memory Control Statistics
*
* The routine displays the RedHawk Dual Memory Control statistics
*
* RETURNS: None
*/
void dualmemctl_stats (
        int port              /* port number */
        )
{
	dualMemCtlStats stat;

	rhAsicDualMemCtlStats (redHawkRegs, port, &stat);

	osPrintf("Dual Memory Control Statistics for port %d\n", port);

	stShow("FCRAM Data[0]", stat.ExtMemData_0);
	stShow("FCRAM Data[1]", stat.ExtMemData_1);
	stShow("FCRAM Data[2]", stat.ExtMemData_2);
	stShow("FCRAM Data[3]", stat.ExtMemData_3);
	stShow("FCRAM Data[4]", stat.ExtMemData_4);
	stShow("FCRAM Data[5]", stat.ExtMemData_5);
	stShow("FCRAM Data[6]", stat.ExtMemData_6);
	stShow("FCRAM Data[7]", stat.ExtMemData_7);
	stShow("FCRAM Cur Rd Add", stat.ExtMemCurrentRdAddress);
	stShow("FCRAM Cur Wr Add", stat.ExtMemCurrentWrAddress);
	stShow("Init FCRAM", stat.InitFCRAM);
}

/******************************************************************
* queuemanager_stats - Display RedHawk Queue Manager Statistics
*
* The routine displays the RedHawk Queue Manager statistics
*
* RETURNS: None
*/
void queuemanager_stats (
        int port              /* port number */
        )
{
	queueManagerStats stat;

	rhAsicQueueManagerStats (redHawkRegs, port, &stat);

	osPrintf("Queue Manager Statistics for port %d\n", port);

	stShow("Num Max Pages", stat.MaxPageCountRd);
	stShow("Num Reserve Pages", stat.RsvdPageCountRd);
	stShow("Rsvd Pool Page Ptr", stat.RsvdPoolPagePntr);
	stShow("Free Pool Page Ptr", stat.FreePoolPagePntr);
	stShow("Mem Full Cnt", stat.MemoryFullCount);
}

/******************************************************************
* dequeuer_stats - Display RedHawk Dequeuer Statistics
*
* The routine displays the RedHawk Dequeuer statistics
*
* RETURNS: None
*/
void dequeuer_stats (
        int port              /* port number */
        )
{
	DequeuerStats stat;

	rhAsicDequeuerStats (redHawkRegs, port, &stat);

	stShow("Tail Drop Cnt", stat.TailDropCount);
	stShow("Dequeuer EOF Cnt", stat.EOFCount);
	stShow("Num Loopback Pkts", stat.LpbkEOFCount);
	stShow("Queue #0 Pkt Cnt", stat.PktCountQ0);
	stShow("Queue #1 Pkt Cnt", stat.PktCountQ1);
	stShow("Queue #2 Pkt Cnt", stat.PktCountQ2);
	stShow("Queue #3 Pkt Cnt", stat.PktCountQ3);
	stShow("Queue #4 Pkt Cnt", stat.PktCountQ4);
	stShow("Queue #5 Pkt Cnt", stat.PktCountQ5);
	stShow("Queue #6 Pkt Cnt", stat.PktCountQ6);
	stShow("Queue #7 Pkt Cnt", stat.PktCountQ7);
	stShow("Queue #0 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ0);
	stShow("Queue #1 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ1);
	stShow("Queue #2 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ2);
	stShow("Queue #3 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ3);
	stShow("Queue #4 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ4);
	stShow("Queue #5 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ5);
	stShow("Queue #6 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ6);
	stShow("Queue #7 Excess Ltcny Drp Cnt", stat.ExcessLatencyDropCountQ7);
}

/******************************************************************
* rxpspi_stats - Display RedHawk receive Primary SPI Statistics
*
* The routine displays the RedHawk receive Primary SPI statistics
*
* RETURNS: None
*/
void rxpspi_stats ()
{
	rxpSpiStats stat;
	int i;

	rhAsicRxpSpiStats (redHawkRegs, &stat);

	osPrintf("RxPSPI Statistics\n");

	stShow("PLL Lock Detect", stat.RpSpiPLLLockDet);
	stShow("FIFO EOP Cnt", stat.RxpSpiInFifoEopCnt);

	/* These registers have more than 2 instances */
	for (i=0; i<5; i++) {
		osPrintf("Printing Instance #%d values\n", i);
		stShow("SOP Cnt", stat.RxpSpiSopCount[i]);
		stShow("EOP1 Cnt", stat.RxpSpiEop1Count[i]);
		stShow("EOP2 Cnt", stat.RxpSpiEop2Count[i]);
		stShow("EOPA Cnt", stat.RxpSpiEopACount[i]);
		stShow("Mdrr Credit Cnt", stat.RxpSpiMdrrCreditCntr[i]);
		stShow("Port Burst Cntr", stat.RxpSpiPortBurstCntr[i]);
	}

	stShow("Training Cnt", stat.RxpSpiTrainingCount);
	stShow("Fetch FIFO UFlow", stat.RxpSpiPerFetchFifoUFlow);
	stShow("SPI Diag", stat.RxpSpiDiag);
}

/******************************************************************
* rxsspi_stats - Display RedHawk receive Secondary SPI Statistics
*
* The routine displays the RedHawk receive Secondary SPI statistics
*
* RETURNS: None
*/
void rxsspi_stats (
        int port              /* port number */
        )
{
	rxSSpiStats stat;

	rhAsicRxSSpiStats (redHawkRegs, port, &stat);

	osPrintf("RxSSPI Statistics for port %d\n", port);

	stShow("PLL Lock Detect", stat.RsSpiPLLLockDet);
	stShow("FIFO EOP Cnt", stat.RxsSpiInFifoEopCnt);
	stShow("SOP Cnt", stat.RxsSpiSopCount);
	stShow("EOP1 Cnt", stat.RxsSpiEop1Count);
	stShow("EOP2 Cnt", stat.RxsSpiEop2Count);
	stShow("EOPA Cnt", stat.RxsSpiEopACount);
	stShow("Training Cnt", stat.RxsSpiTrainingCount);
	stShow("Mdrr Credit Cnt", stat.RxsSpiMdrrCreditCntr);
	stShow("Port Burst Cntr", stat.RxsSpiPortBurstCntr);
	stShow("SPI Diag", stat.RxsSpiDiag);
	stShow("Fetch FIFO UFlow", stat.RxsSpiPerFetchFifoUFlow);
	stShow("DIP2 Err Cnt", stat.RxsSpiDip2ErrCount);
}

/******************************************************************
* rxxauixmac_stats - Display RedHawk receive XAUI XMAC Statistics
*
* The routine displays the RedHawk receive XAUI XMAC statistics
*
* RETURNS: None
*/
void rxxauixmac_stats (
        int port              /* port number */
        )
{
	rxXauiXMacStats stat;

	rhAsicRxXauiXMacStats (redHawkRegs, port, &stat);

	osPrintf("RxXAUI MAC Statistics for port %d\n", port);

	stShow("SOP's Rcvd", stat.RxXauiXmacSopInCnt);
	stShow("EOP'd Rcvd", stat.RxXauiXmacEopInCnt);
	stShow("SOP's Txd", stat.RxXauiXmacSopOutCnt);
	stShow("EOP's Txd", stat.RxXauiXmacEopOutCnt);
	stShow("Frms Txd", stat.RxXauiXmacFrames);
	stShow("Err Frms Txd", stat.RxXauiXmacErroredFrames);
}

/******************************************************************
* txmac_stats - Display RedHawk transmit MAC Statistics
*
* The routine displays the RedHawk transmit MAC statistics
*
* RETURNS: None
*/
void txmac_stats (
        int port              /* port number */
        )
{
	txMacStats stat;

	rhAsicTxMacStats (redHawkRegs, port, &stat);

	osPrintf("Tx MAC Statistics for Port %d\n", port);

	stShow("Good Frms", stat.GoodFrames);
	stShow("BCast Frms", stat.BCASTFrames);
	stShow("MCast Frms", stat.MCASTFrames);
	stShow("Cntrl Frms", stat.ControlFrames);
	stShow("VLAN Frms", stat.VLANFrames);
	stShow("PAUSE Frms", stat.PauseFrames);
	stShow("64B Frms", stat.Frames64B);
	stShow("65BTo127B Frms", stat.Frames65to127B);
	stShow("128BTo255B Frms", stat.Frames128to255B);
	stShow("256To511B Frms", stat.Frames256to511B);
	stShow("512BTo1023B Frms", stat.Frames512to1023B);
	stShow("1024BTo1518B Frms", stat.Frames1024to1518B);
	stShow("Over 1518B Frms", stat.Over1518BFrames);
	stShow("Errored Frms", stat.ErroredFrames);
	stShow("Filter Drop Frms", stat.FilterDropFrames);
	stShow("MCast Filter Drops", stat.McastFilterDrop);
	stShow("BCast Filter Drops", stat.BcastFilterDrop);
	stShow("Too Long Frms", stat.TooLongFrames);
	stShow("Frms Dropped", stat.DroppedFrames);
	stShow("Jumbo Frms", stat.JumboFrames);
	stShow("FCS Errored Frms", stat.FCSError);
	stShow("MAC Diag", stat.DiagPort);
}

/******************************************************************
* txvlanctrl_stats - Display RedHawk transmit VLAN Control Statistics
*
* The routine displays the RedHawk transmit VLAN Control statistics
*
* RETURNS: None
*/
void txvlanctrl_stats (
        int port              /* port number */
        )
{
	txVlanCtrlStats stat;

	rhAsicTxVlanCtrlStats (redHawkRegs, port, &stat);

	osPrintf("Tx VLAN Ctrl Statistics for port %d\n", port);

	stShow("VLAN Ctrl Table RAM", stat.RdDataTxVlanCtrlTblRamReg);
	stShow("VLAN Tag RAM", stat.RdDataVlanTagRamReg);
	stShow("SOP's Rcvd", stat.TxVlanCtrlSopInCnt);
	stShow("EOP's Rcvd", stat.TxVlanCtrlEopInCnt);
	stShow("SOP's Txd", stat.TxVlanCtrlSopOutCnt);
	stShow("EOP's Txd", stat.TxVlanCtrlEopOutCnt);
	stShow("MPLS UCast Frm Cnt", stat.MPLSUnicastFrameCount);
	stShow("MPLS MCast Frm Cnt", stat.MPLSMulticastFrameCount);
	stShow("MPLS Bytes Egressed", stat.MPLSFrameOctetsEgressed);
	stShow("Frms with no VLAN", stat.NoVLANTagFrameCount);
	stShow("Frms with Single VLAN", stat.SingleVLANTagFrameCount);
	stShow("Frms with Double VLAN", stat.DoubleVLANTagFrameCount);
	stShow("VLAN Ctrl Tbl Frm Cnt", stat.VLANControlTableFrameCount);
	stShow("Def VLAN Ctrl Tbl Frm Cnt", stat.DefaultVLANControlTableFrameCount);
	stShow("VLAN Ctrl Tbl Tag Operation Frm Cnt", stat.VLANControlTableTagOperationFrameCount);
	stShow("Efh Operation Frm Cnt", stat.EfhTagOperationFrameCount);
	stShow("Prsvd Frm Cnt", stat.PreservedFrameCount);
}

/******************************************************************
* txmemmanager_stats - Display RedHawk transmit Memory Manager Statistics
*
* The routine displays the RedHawk transmit Memory Manager statistics
*
* RETURNS: None
*/
void txmemmanager_stats (
        int port              /* port number */
        )
{
	txMemManagerStats stat;

	rhAsicTxMemManagerStats (redHawkRegs, port, &stat);

	osPrintf("Tx Memory Manager Statistics for port %d\n", port);

	stShow("Egress Pkt Cnt", stat.MemMgrEgrPktCnt);
	stShow("Drop Pkt Cnt", stat.MemMgrDropPktCnt);
	stShow("VLAN Ctrl Pkt CRC Err Cnt", stat.VlanCtrlPktCrcErrCnt);
	stShow("Egress SPI Err Drop Cnt", stat.EgressSpiErrDropCnt);
	stShow("One Line Pkts Dropped Cnt", stat.MemMgrOneLinePktsDropedCnt);
	stShow("VLAN Efh FCS Err Cnt", stat.VlanCtrlEfhFcsErrCnt);
	stShow("ID Mismatch Pkts", stat.RedHawkIdMisMatchCnt);
}

/******************************************************************
* txmemcommon_stats - Display RedHawk transmit Memory Common Statistics
*
* The routine displays the RedHawk transmit Memory Common statistics
*
* RETURNS: None
*/
void txmemcommon_stats ()
{
	txMemCommonStats stat;

	rhAsicTxMemCommonStats (redHawkRegs, &stat);

	osPrintf("Tx Memory Common Statistics\n");

	stShow("SOP EOP Same Line Drop Cnt 0", stat.WidConSopEopSameLineDropCntP0);
	stShow("SOP EOP Same Line Drop Cnt 1", stat.WidConSopEopSameLineDropCntP1);
	stShow("Max Size Pkts Filtered P0", stat.TxMemMgrSPIMaxSzPktDrpCntPrt0);
	stShow("Max Size Pkts Filtered P1", stat.TxMemMgrSPIMaxSzPktDrpCntPrt1);
	stShow("Min Size Pkts Filtered P0", stat.TxMemMgrSPIMinSzPktDrpCntPrt0);
	stShow("Min Size Pkts Filtered P1", stat.TxMemMgrSPIMinSzPktDrpCntPrt1);
}

/******************************************************************
* txcputoline_stats - Display RedHawk transmit CPU To Line Statistics
*
* The routine displays the RedHawk transmit CPU To Line statistics
*
* RETURNS: None
*/
void txcputoline_stats (
        int port              /* port number */
        )
{
	txCpuToLineStats stat;

	rhAsicTxCpuToLineStats (redHawkRegs, port, &stat);

	osPrintf("Tx CPU To Line Statistics for port %d\n", port);

	stShow("Drop Pkt Cnt", stat.DropPktCnt);
	stShow("Write Pointer", stat.WritePointer);
	stShow("Read Pointer", stat.ReadPointer);
	stShow("Commit Pointer", stat.CommitPointer);
}

/******************************************************************
* txpspi_stats - Display RedHawk transmit Primary SPI Statistics
*
* The routine displays the RedHawk transmit Primary SPI statistics
*
* RETURNS: None
*/
void txpspi_stats ()
{
	txpSpiStats stat;

	rhAsicTxpSpiStats (redHawkRegs, &stat);

	osPrintf("Txp SPI Statistics\n");

	stShow("Training Count", stat.TSpiTrainingCount);
	stShow("SOP Count", stat.TSpiSopCount);
	stShow("EOP Count", stat.TSpiEopCount);
	stShow("External EOPA Count", stat.TSpiExtEopACount);
	stShow("Internal EOPA Count", stat.TSpiIntEopACount);
	stShow("DIP4 Err Cnt", stat.TSpiDip4ErrCount);
	stShow("Protocol Violation Cnt", stat.TSpiProtViolCount);
	stShow("FIFO Overflow Cnt", stat.TSpiFifoOverFlow);
	stShow("Diag", stat.TSpiDiag);
	stShow("DPG Status", stat.PSpiDPGStatus);
	stShow("DPV	Bit Cnt", stat.PSpiDPVBitCnt);
	stShow("DPV Err Cnt", stat.PSpiDPVErrorCnt);
	stShow("DPV CRC Err Cnt ", stat.PSpiDPVCRCErrorCnt);
	stShow("DPV Good Pkt Cnt", stat.PSpiDPVGoodPktCnt);
	stShow("DPV Sync On Cnt ", stat.PSpiDPVSyncOnCnt);
	stShow("DPV EOP Cnt", stat.PSpiDPVEopCnt);
	stShow("Ch0 Drop Cnt", stat.PSpiCh0DropCount);
	stShow("Ch1 Drop Cnt", stat.PSpiCh1DropCount);
	stShow("Loopback Pkt Drop Cnt ", stat.PSpiLpbkPktDropCount);
	stShow("XAUI Pkt Drop Cnt", stat.PSpiXauiPktDropCount);
	stShow("Ch0 EOP Cnt", stat.PSpiEopCountCh0);
	stShow("Ch1 EOP Cnt", stat.PSpiEopCountCh1);
	stShow("Ch2 EOP Cnt", stat.PSpiEopCountCh2);
	stShow("Ch2 EOP Cnt", stat.PSpiEopCountCh3);
}

/******************************************************************
* txsspi_stats - Display RedHawk transmit Secondary SPI Statistics
*
* The routine displays the RedHawk Shadow statistics
*
* RETURNS: None
*/
void txsspi_stats ()
{
	txsSpiStats stat;

	rhAsicTxsSpiStats (redHawkRegs, &stat);

	osPrintf("Txs SPI Statistics\n");

	stShow("Training Count", stat.SSpiTrainingCount);
	stShow("SOP Count", stat.SSpiSopCount);
	stShow("EOP Count", stat.SSpiEopCount);
	stShow("External EOPA Count", stat.SSpiExtEopACount);
	stShow("Internal EOPA Count", stat.SSpiIntEopACount);
	stShow("DIP4 Err Cnt", stat.SSpiDip4ErrCount);
	stShow("Protocol Violation Cnt", stat.SSpiProtViolCount);
	stShow("FIFO Overflow Cnt", stat.SSpiFifoOverFlow);
	stShow("Diag", stat.SSpiDiag);
	stShow("DPG Status", stat.SSpiDPGStatus);
	stShow("DPV	Bit Cnt", stat.SSpiDPVBitCnt);
	stShow("DPV Err Cnt", stat.SSpiDPVErrorCnt);
	stShow("DPV CRC Err Cnt", stat.SSpiDPVCRCErrorCnt);
	stShow("DPV Good Pkt Cnt", stat.SSpiDPVGoodPktCnt);
	stShow("DPV Sync On Cnt ", stat.SSpiDPVSyncOnCnt);
	stShow("DPV EOP Cnt", stat.SSpiDPVEopCnt);
	stShow("Ch0 Drop Cnt", stat.SSpiCh0PktDropCount);
	stShow("Ch1 Drop Cnt", stat.SSpiCh1PktDropCount);
	stShow("Loopback Pkt Drop Cnt ", stat.SSpiLpbkPktDropCount);
	stShow("Ch0 EOP Cnt", stat.SSpiEopCountCh0);
	stShow("Ch1 EOP Cnt", stat.SSpiEopCountCh1);
	stShow("Ch2 EOP Cnt", stat.SSpiEopCountCh2);
}

/******************************************************************
* txxauixmac_stats - Display RedHawk transmit XAUI XMAC Statistics
*
* The routine displays the RedHawk transmit XAUI XMAC statistics
*
* RETURNS: None
*/
void txxauixmac_stats (
        int port              /* port number */
        )
{
	txXauiXMacStats stat;

	rhAsicTxXauiXMacStats (redHawkRegs, port, &stat);

	osPrintf("Tx XAUI XMAC Statistics for port %d\n", port);

	stShow("SOP In Cnt", stat.XauiXmacSopInCnt);
	stShow("EOP In Cnt", stat.XauiXmacEopInCnt);
	stShow("SOP Out Cnt", stat.XauiXmacSopOutCnt);
	stShow("EOP Out Cnt", stat.XauiXmacEopOutCnt);
	stShow("Frms", stat.XauiXmacFrames);
	stShow("Errored Frms", stat.XauiXmacErroredFrames);
}

/******************************************************************
* txsspimtuaccess_stats - Display RedHawk transmit Secondary SPI MTU Access Statistics
*
* The routine displays the RedHawk transmit Secondary SPI MTU Access statistics
*
* RETURNS: None
*/
void txsspimtuaccess_stats ()
{
	txsSpiMtuAccessStats stat;

	rhAsicTxsSpiMtuAccessStats (redHawkRegs, &stat);

	osPrintf("Txs SPI MTU Access Statistics\n");
	stShow("Tail Drop Count 1", stat.TailDropCount1);
}

