⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zl5011xdebugfuncs.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************
*
*  File name:              zl5011xDebugFuncs.c
*
*  Version:                16
*
*  Author:                 MRC
*
*  Date created:           27/08/2003
*
*  Module Description:
*
*  This file contains various functions that can be used interactively to
*  help with debugging a running system
*
*  Revision History:
*
*  Rev:  Date:       Author:  Comments:
*  1     27/08/2003  MRC      Creation
*  2     09/09/2003  MRC      Added RTP statistics function
*  3     10/02/2004  APL      Corrected a comment
*  4     23/03/2004  APL      Corrected file version history
*  5     21/05/2004  MRC      Added tick delay before measurements
*  6     21/07/2004  MRC      Added Wan Tx clock source function
*  7     29/07/2004  MRC      Fixed some compiler warnings
*  8     04/08/2004  MRC      Added packet sniff'ing function for a context
*  9     25/08/2004  MRC      Added PW function
*  10    17/09/2004  MRC      Added TDM queue function
*  11    02/12/2004  APL      Made use of zl5011xTfqFormatAvgLength function
*  12    07/12/2004  APL      Fixed error introduced in previous version
*  13    18/03/2005  APL      Updated file header
*  14    07/07/2005  APL      Added more debug/status functions
*  15    08/07/2005  APL      Added debug function zl5011xDebugDisplayClockInfo
*  16    21/07/2005  MRC      Added DPLL status, PKC config and Packet Tx header fns
*
******************************************************************************/

/*****************   INCLUDE FILES                ****************************/

#include "zl5011xApi.h"
#include "zl5011xPkcMap.h"
#include "zl5011xPkiMap.h"
#include "zl5011xTfqMap.h"
#include "zl5011xTmMap.h"
#include "zl5011xTdm.h"
#include "zl5011xLan.h"
#include "zl5011xCet.h"
#include "zl5011xPrintError.h"

/*****************   DEFINES  *************************************************/
#define _ZL5011X_DEBUG_AVG_PRECISION 3   /* Display average queue length to 3 DPs */

#define _ZL5011X_PKI_STATS_RESERVED   28 /* Register 28 in the PKI stats is unused so
                                          we don't display it */

/*****************   DATA STRUCTURES   ****************************************/

typedef struct
{
   Uint32T early[128];
   Uint32T late[128];
   Uint32T underrun[128];
   Uint32T readPointer[128];
} zl5011xDebugTfqInfoS;

static char *stateStr[] =
{
   "not in use  ",
   "initialised ",
   "taken       ",
   "updating    ",
   "active      ",
   "tearing down"
};

static char *zl5011xDebugClockModeStr[] =
{
   "Loop timing - TDM_CLKo from TDM_CLKi (DCO Bypass)",
   "Master timing - TDM_CLKo from DCO"
};

static char *zl5011xDebugCetModeStr[] =
{
   "ZL5011X_CET_DISABLED",
   "ZL5011X_CET_DIFFERENTIAL_RX",
   "ZL5011X_CET_DIFFERENTIAL_TX",
   "ZL5011X_CET_DIFFERENTIAL_IN_BAND",
   "ZL5011X_CET_ADAPTIVE",
   "ZL5011X_CET_ADAPTIVE_ENHANCED",
   "ZL5011X_CET_DIFFERENTIAL_RX_TX",
};

static char *zl5011xDebugCetStatusStr[] =
{
   "FREERUN",
   "HOLDOVER",
   "ACQUIRING",
   "ACQUIRED"
};

static char *pkiStatsStr[ZL5011X_PKI_MAC_STATS_SIZE] =
{
   "BYTES TX      ",
   "UNICAST TX    ",
   "FRM TX FAIL   ",
   "FLOW CTRL TX  ",
   "NON UCAST TX  ",
   "BYTES RX      ",
   "FRM RX        ",
   "BYTES RX GOOD ",
   "FRAMES RX GOOD",
   "FLOW CTRL RX  ",
   "MULTICAST RX  ",
   "BROADCAST RX  ",
   "64            ",
   "JABBER        ",
   "65 TO 127     ",
   "OVERSIZE      ",
   "128 TO 255    ",
   "256 TO 511    ",
   "512 TO 1023   ",
   "1023 TO 1518  ",
   "FRAGMENT      ",
   "ALIGNERR      ",
   "UNDERSIZE     ",
   "CRC           ",
   "SHORT EVENT   ",
   "COLLISION     ",
   "DROP EVENT    ",
   "FILTER        ",
   "RESERVED      ",    /* Unused */
   "LATE COLLISION",
   0,                   /* Unused */
   0                    /* Unused */
};

/*****************   EXPORTED FUNCTION DEFINTIONS   ***************************/
/******************************************************************************/
/* the following functions provided information for the TDM contexts */
/******************************************************************************/

/*******************************************************************************

 Function:
    zl5011xDebugContextRx

 Description:
    This function provides information on the state of the Wan Rx context.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   start             first context to display (or -1 to display all)
   end               last context to display. Note this parameter can be omitted
                     (set to zero) if only one context is of interest.

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

*******************************************************************************/

zlStatusE zl5011xDebugContextRx(zl5011xParamsS *zl5011xParams, Uint32T start, Uint32T end)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T context;

   if (zl5011xParams == NULL)
   {
      status = ZL5011X_INVALID_POINTER;

      zl5011xPrintErr(status);
      return(status);
   }

   if (start == (Uint32T)-1)
   {
      start = 0;

      if (zl5011xParams->wanIf.wanConnectionMode == ZL5011X_WAN_CONNECTION_UNFRAMED)
      {
         end = zl5011xParams->wanIf.wanNumStreams - 1;
      }
      else
      {
         end = zl5011xParams->devLimits.numContexts - 1;
      }
   }

   context = start;
   do
   {
      if (zl5011xParams->wanIf.plaCurrent.context[context].state == ZL5011X_STATE_TEARING_DOWN)
      {
         status = zl5011xPlaCheckContextTeardown(zl5011xParams, context);
      }

      if (zl5011xParams->wanIf.plaCurrent.context[context].state == ZL5011X_STATE_UPDATING)
      {
         status = zl5011xPlaCheckContextUpdate(zl5011xParams, context);
      }

      printf("Context %3ld, Status = %s\n",
            context, stateStr[zl5011xParams->wanIf.plaCurrent.context[context].state]);

      context++;
   } while (context <= end);

   zl5011xPrintErr(status);
   return(status);
}

/*******************************************************************************

 Function:
    zl5011xDebugContextRxChans

 Description:
    This function provides information on the channels attached to a Wan Rx
    context. Primarily intended for structured (framed) operation, and shows
    whether a context has been added / removed since the last update was
    completed.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   context           set to context number

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

*******************************************************************************/

zlStatusE zl5011xDebugContextRxChans(zl5011xParamsS *zl5011xParams, Uint32T context)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T loop;

   if (zl5011xParams == NULL)
   {
      status = ZL5011X_INVALID_POINTER;

      zl5011xPrintErr(status);
      return(status);
   }

   for (loop = 0; loop < ZL5011X_MAX_NUMBER_CHANNELS; loop++)
   {
      if ((zl5011xParams->wanIf.plaCurrent.channel[loop].context == context) &&
         (zl5011xParams->wanIf.plaActive.channel[loop].context == context))
      {
         printf("Ch     %4ld\n", loop);
      }
      else
      {
         if ((zl5011xParams->wanIf.plaCurrent.channel[loop].context == context) &&
            (zl5011xParams->wanIf.plaActive.channel[loop].context != context))
         {
            printf("Ch new %4ld\n", loop);
         }
         else
         {
            if ((zl5011xParams->wanIf.plaCurrent.channel[loop].context != context) &&
               (zl5011xParams->wanIf.plaActive.channel[loop].context == context))
            {
               printf("Ch old %4ld\n", loop);
            }
         }
      }
   }

   zl5011xPrintErr(status);
   return(status);
}

/*******************************************************************************

 Function:
    zl5011xDebugContextTx

 Description:
    This function provides information on the state of the Wan Tx context.
    Active contexts will also display information on the queue state (this
    information varies for FIFO and resequencing queues)

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   start             first context to display (or -1 to display all)
   end               last context to display. Note this parameter can be omitted
                     (set to zero) if only one context is of interest.

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

*******************************************************************************/

zlStatusE zl5011xDebugContextTx(zl5011xParamsS *zl5011xParams, Uint32T start, Uint32T end)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T readValue;
   Uint32T context;

   if (zl5011xParams == NULL)
   {
      status = ZL5011X_INVALID_POINTER;

      zl5011xPrintErr(status);
      return(status);
   }

   if (start == (Uint32T)-1)
   {
      start = 0;

      if (zl5011xParams->wanIf.wanConnectionMode == ZL5011X_WAN_CONNECTION_UNFRAMED)
      {
         end = zl5011xParams->wanIf.wanNumStreams - 1;
      }
      else
      {
         end = zl5011xParams->devLimits.numContexts - 1;
      }
   }

   context = start;
   do
   {
      if (zl5011xParams->wanIf.tfmCurrent.context[context].state == ZL5011X_STATE_TEARING_DOWN)
      {
         status = zl5011xTfmCheckContextTeardown(zl5011xParams, context);
      }

      if (zl5011xParams->wanIf.tfmCurrent.context[context].state == ZL5011X_STATE_UPDATING)
      {
         status = zl5011xTfmCheckContextUpdate(zl5011xParams, context);
      }

      printf("Context %3ld, Status = %s",
            context, stateStr[zl5011xParams->wanIf.tfmCurrent.context[context].state]);

      if ((zl5011xParams->wanIf.tfmCurrent.context[context].state == ZL5011X_STATE_TAKEN) ||
         (zl5011xParams->wanIf.tfmCurrent.context[context].state == ZL5011X_STATE_UPDATING) ||
         (zl5011xParams->wanIf.tfmCurrent.context[context].state == ZL5011X_STATE_ACTIVE))
      {
         Uint32T avgHi,avgLo;

         status = zl5011xTfqGetAvgLength(zl5011xParams, context, &readValue);
         zl5011xTfqFormatAvgLength(readValue, _ZL5011X_DEBUG_AVG_PRECISION, &avgHi, &avgLo);

         printf(": Avg len = %4ld.%0*ld, ", avgHi, _ZL5011X_DEBUG_AVG_PRECISION, avgLo); /* Note:
                     '*' format allows _ZL5011X_DEBUG_AVG_PRECISION to specify the width of the field */

         if (zl5011xParams->wanIf.txQueue[context].queueMode == ZL5011X_WAN_TX_QUEUE_FIFO)
         {
            /* for FIFO queues, the early count is actually a count of the packets
               rejected because the queue is full */
            status = zl5011xTfqGetEarlyPackets(zl5011xParams, context, &readValue);
            printf("Full = %8ld\n", readValue);
         }
         else
         {
            status = zl5011xTfqGetUnderrunCount(zl5011xParams, context, &readValue);
            printf("Underruns = %8ld, ", readValue);

            status = zl5011xTfqGetLatePackets(zl5011xParams, context, &readValue);
            printf("Late = %8ld, ", readValue);

            status = zl5011xTfqGetEarlyPackets(zl5011xParams, context, &readValue);
            printf("Early = %8ld\n", readValue);
         }
      }
      else
      {
         printf("\n");
      }

      context++;
   } while (context <= end);

   zl5011xPrintErr(status);
   return(status);
}

/*******************************************************************************

 Function:
    zl5011xDebugContextTxChans

 Description:
    This function provides information on the channels attached to a Wan Tx
    context. Primarily intended for structured (framed) operation, and shows
    whether a context has been added / removed since the last update was
    completed.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   context           set to context number

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

*******************************************************************************/

zlStatusE zl5011xDebugContextTxChans(zl5011xParamsS *zl5011xParams, Uint32T context)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T loop;

   if (zl5011xParams == NULL)
   {
      status = ZL5011X_INVALID_POINTER;

      zl5011xPrintErr(status);
      return(status);
   }

   for (loop = 0; loop < ZL5011X_MAX_NUMBER_CHANNELS; loop++)
   {
      if ((zl5011xParams->wanIf.tfmCurrent.channel[loop].context == context) &&
         (zl5011xParams->wanIf.tfmActive.channel[loop].context == context))
      {
         printf("Ch     %4ld\n", loop);
      }
      else
      {
         if ((zl5011xParams->wanIf.tfmCurrent.channel[loop].context == context) &&
            (zl5011xParams->wanIf.tfmActive.channel[loop].context != context))
         {
            printf("Ch new %4ld\n", loop);
         }
         else
         {
            if ((zl5011xParams->wanIf.tfmCurrent.channel[loop].context != context) &&
               (zl5011xParams->wanIf.tfmActive.channel[loop].context == context))
            {
               printf("Ch old %4ld\n", loop);
            }
         }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -