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

📄 zl5011xdebugfuncs.c

📁 Zalink50114----TDMoIP芯片驱动源码
💻 C
📖 第 1 页 / 共 5 页
字号:
}

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

 Function:
    zl5011xDebugResetPkcStats

 Description:
   This function is used to reset all of the PKC counters to 0.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugResetPkcStats(zl5011xParamsS *zl5011xParams)
{
   Uint32T loop;
   zlStatusE status = ZL5011X_OK;

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

      zl5011xPrintErr(status);
      return(status);
   }

   for (loop = 0; loop < ZL5011X_PKC_NUM_PROTOCOL_ENTRIES; loop++)
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      status = zl5011xWrite(zl5011xParams,
            ZL5011X_PKC_PROTOCOL_COUNT + (loop * 2 * sizeof(Uint32T)),
            0);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xWrite(zl5011xParams, ZL5011X_PKC_PROTOCOL_NO_MATCH_COUNT, 0);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xWrite(zl5011xParams, ZL5011X_PKC_CLASSIFY_NO_MATCH_COUNT, 0);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xWrite(zl5011xParams, ZL5011X_PKC_VERIFY_FAIL_COUNT, 0);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xWrite(zl5011xParams, ZL5011X_PKC_IPV4_CHECKSUM_COUNT, 0);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugPkiStats

 Description:
   This function is used to display raw packet statistics for the given Lan port.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   portNum           Port number to operate on

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugPkiStats(zl5011xParamsS *zl5011xParams, Uint32T portNum)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T address, loop, readValue;

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

      zl5011xPrintErr(status);
      return(status);
   }

   address = ZL5011X_PKI_RAM_BASE + (portNum * ZL5011X_PKI_MAC_STATS_SIZE * sizeof(Uint32T));

   for (loop = 0; loop < ZL5011X_PKI_MAC_STATS_SIZE; loop++)
   {
      if (loop == _ZL5011X_PKI_STATS_RESERVED) /* This PKI stats register is unused so don't display it */
      {
         continue;
      }
      if ((pkiStatsStr[loop] == 0) || (status != ZL5011X_OK))
      {  /* End of the list of statistics */
         break;
      }

      status = zl5011xRead(zl5011xParams, address + (loop * sizeof(Uint32T)), &readValue);

      if (status == ZL5011X_OK)
      {
         printf("%s = %10lu\n", pkiStatsStr[loop], readValue);
      }
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugResetPkiStats

 Description:
   This function is used to reset all of the PKI counters to 0 for the given
   port.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   portNum           Port number to operate on

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugResetPkiStats(zl5011xParamsS *zl5011xParams, Uint32T portNum)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T address, loop;

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

      zl5011xPrintErr(status);
      return(status);
   }

   address = ZL5011X_PKI_RAM_BASE + (portNum * ZL5011X_PKI_MAC_STATS_SIZE * sizeof(Uint32T));

   for (loop = 0; loop < ZL5011X_PKI_MAC_STATS_SIZE; loop++)
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      status = zl5011xWrite(zl5011xParams, address  + (loop * sizeof(Uint32T)), 0);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugPkcRates

 Description:
   This function provides information on the arrival rate of packets and their
   classification over a 1 second period.
   The number of packets for each of the protocols is displayed, along with the
   number of unmatched packets.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugPkcRates(zl5011xParamsS *zl5011xParams)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xPkcStatsS prevPktStats;
   zl5011xPkcStatsS pktStats;
   Uint32T loop;

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

      zl5011xPrintErr(status);
      return(status);
   }

   OS_TICK_DELAY(1);

   status = zl5011xPkcGetStats(zl5011xParams, &prevPktStats);

   if (status == ZL5011X_OK)
   {
      OS_TICK_DELAY(60);

      status = zl5011xPkcGetStats(zl5011xParams, &pktStats);
   }

   if (status == ZL5011X_OK)
   {
      for (loop = 0; loop < ZL5011X_PKC_NUM_PROTOCOL_ENTRIES; loop++)
      {
         printf("Packet protocol %ld = %8ld\n", loop, pktStats.protocolCount[loop] - prevPktStats.protocolCount[loop]);
      }

      printf("Protocol no match = %8lu\n", pktStats.protocolNoMatchCount - prevPktStats.protocolNoMatchCount);
      printf("Classify no match = %8lu\n", pktStats.classifyNoMatchCount - prevPktStats.classifyNoMatchCount);
      printf("Verify fail       = %8lu\n", pktStats.verifyFailCount - prevPktStats.verifyFailCount);
      printf("IPv4 checksum     = %8lu\n", pktStats.ipv4ChecksumFailCount - prevPktStats.ipv4ChecksumFailCount);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugPkiRates

 Description:
   This function is used to display packet statistics for the given Lan port over
   a period of 1 second.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   portNum           Port number to operate on

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugPkiRates(zl5011xParamsS *zl5011xParams, Uint32T portNum)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T address, loop;
   Uint32T prevValues[ZL5011X_PKI_MAC_STATS_SIZE] = {0}, currValues[ZL5011X_PKI_MAC_STATS_SIZE] = {0};

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

      zl5011xPrintErr(status);
      return(status);
   }

   address = ZL5011X_PKI_RAM_BASE + (portNum * ZL5011X_PKI_MAC_STATS_SIZE * sizeof(Uint32T));

   OS_TICK_DELAY(1);

   for (loop = 0; loop < ZL5011X_PKI_MAC_STATS_SIZE; loop++)
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      status = zl5011xRead(zl5011xParams, address + (loop * sizeof(Uint32T)), &(prevValues[loop]));
   }

   if (status == ZL5011X_OK)
   {
      OS_TICK_DELAY(60);
   }

   for (loop = 0; loop < ZL5011X_PKI_MAC_STATS_SIZE; loop++)
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      status = zl5011xRead(zl5011xParams, address + (loop * sizeof(Uint32T)), &(currValues[loop]));
   }

   for (loop = 0; loop < ZL5011X_PKI_MAC_STATS_SIZE; loop++)
   {
      if (loop == _ZL5011X_PKI_STATS_RESERVED) /* This PKI stats register is unused so don't display it */
      {
         continue;
      }
      if ((pkiStatsStr[loop] == 0) || (status != ZL5011X_OK))
      {  /* End of the list of statistics */
         break;
      }

      printf("%s = %10lu\n", pkiStatsStr[loop], currValues[loop] - prevValues[loop]);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
   zl5011xDebugRtpStats

 Description:
   Print the statistics from the RTP.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   context           context number to print stats for.

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:

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

zlStatusE zl5011xDebugRtpStats(zl5011xParamsS *zl5011xParams, Uint32T context)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xLanGetRtpStatsS rtpStats;

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

      zl5011xPrintErr(status);
      return(status);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xLanGetRtpStatsStructInit(zl5011xParams, &rtpStats);

      if (status == ZL5011X_OK)
      {
         rtpStats.context = context;
         status = zl5011xLanGetRtpStats(zl5011xParams, &rtpStats);
      }
   }

   if (status == ZL5011X_OK)
   {
      printf("Inter-arrival jitter = %10lu\n", rtpStats.rtpStats.interArrivalJitter);
      printf("Rx packet count      = %10lu\n", rtpStats.rtpStats.rxPacketCount);
      printf("Rx first seq num     = %10lu\n", rtpStats.rtpStats.rxFirstSequenceNumber);
      printf("Rx seq num           = %10lu\n", rtpStats.rtpStats.rxSequenceNumber);
      printf("Tx byte count        = %10lu\n", rtpStats.rtpStats.txByteCount);
      printf("Tx packet count      = %10lu\n", rtpStats.rtpStats.txPacketCount);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
   zl5011xDebugPwStats

 Description:
   Print the PW statistics for a context

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance
   context           context number to print stats for.

 Outputs:
   None

 Returns:
   zlStatusE

 Remarks:

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

zlStatusE zl5011xDebugPwStats(zl5011xParamsS *zl5011xParams, Uint32T context)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xLanGetPwStatsS stats;

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

   if (status == ZL5011X_OK)
   {
      status = zl5011xLanGetPwStatsStructInit(zl5011xParams, &stats);

      if (status == ZL5011X_OK)
      {
         stats.context = context;
         status = zl5011xLanGetPwStats(zl5011xParams, &stats);
      }
   }

   if (status == ZL5011X_OK)
   {
      printf("%3ld: L count    = %6lu\n", context, stats.lCount);
      printf("     L time(ms) = %6lu\n", stats.lTimeMs);
      printf("     R count    = %6lu\n", stats.rCount);
      printf("     R time(ms) = %6lu\n", stats.rTimeMs);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
   zl5011xDebugPkcConfig

⌨️ 快捷键说明

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