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

📄 zl5011xdebugfuncs.c

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

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugContextTxRates

 Description:
    This function provides information on the operation of a Wan Tx queue for
    a duration of 1 second.
    Shows the number of packets that have been requested by the TDM formatter
    block, and a count of rejected packets (information depends on queue mode).

 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 zl5011xDebugContextTxRates(zl5011xParamsS *zl5011xParams, Uint32T start, Uint32T end)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xDebugTfqInfoS *prevTfqInfo;
   zl5011xDebugTfqInfoS *tfqInfo;
   Uint32T loop, readValue;

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

      zl5011xPrintErr(status);
      return(status);
   }

   prevTfqInfo = OS_MALLOC(sizeof(zl5011xDebugTfqInfoS));

   if (prevTfqInfo == NULL)
   {
      printf("Failed to allocate memory\n");

      status = ZL5011X_RTOS_MEMORY_FAIL;

      zl5011xPrintErr(status);
      return(status);
   }

   tfqInfo = OS_MALLOC(sizeof(zl5011xDebugTfqInfoS));

   if (tfqInfo == NULL)
   {
      printf("Failed to allocate memory\n");
      OS_FREE(prevTfqInfo);

      status = ZL5011X_RTOS_MEMORY_FAIL;

      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;
      }
   }

   loop = start;

   OS_TICK_DELAY(1);

   do
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      status = zl5011xTfqGetUnderrunCount(zl5011xParams, loop, &(prevTfqInfo->underrun[loop]));

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetLatePackets(zl5011xParams, loop, &(prevTfqInfo->late[loop]));
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetEarlyPackets(zl5011xParams, loop, &(prevTfqInfo->early[loop]));
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetReadPointer(zl5011xParams, loop, &(prevTfqInfo->readPointer[loop]));
      }

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

   OS_TICK_DELAY(60);

   loop = start;

   do
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetUnderrunCount(zl5011xParams, loop, &(tfqInfo->underrun[loop]));
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetLatePackets(zl5011xParams, loop, &(tfqInfo->late[loop]));
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetEarlyPackets(zl5011xParams, loop, &(tfqInfo->early[loop]));
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetReadPointer(zl5011xParams, loop, &(tfqInfo->readPointer[loop]));
      }

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

   loop = start;

   do
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      if (status == ZL5011X_OK)
      {
         status = zl5011xTfqGetAvgLength(zl5011xParams, loop, &readValue);
      }

      if (status == ZL5011X_OK)
      {
         Uint32T avgHi,avgLo;
         zl5011xTfqFormatAvgLength(readValue, _ZL5011X_DEBUG_AVG_PRECISION, &avgHi, &avgLo);

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

         if (zl5011xParams->wanIf.txQueue[loop].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 */
            printf("Full = %4ld,", tfqInfo->early[loop] - prevTfqInfo->early[loop]);
            printf("Pkts = %4ld\n", tfqInfo->readPointer[loop] - prevTfqInfo->readPointer[loop]);
         }
         else
         {
            printf("Underruns = %4ld, ", tfqInfo->underrun[loop] - prevTfqInfo->underrun[loop]);
            printf("Discards = %4ld, ", (tfqInfo->early[loop] - prevTfqInfo->early[loop]) +
                  (tfqInfo->late[loop] - prevTfqInfo->late[loop]));
            printf("Early = %4ld,  Late = %4ld, ", tfqInfo->early[loop] - prevTfqInfo->early[loop],
                  tfqInfo->late[loop] - prevTfqInfo->late[loop]);
            printf("Pkts = %4ld\n", tfqInfo->readPointer[loop] - prevTfqInfo->readPointer[loop]);
         }
      }

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

   OS_FREE(tfqInfo);
   OS_FREE(prevTfqInfo);

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugContextTxQueue

 Description:
    This function provides information on the TDM queue length.

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

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugContextTxQueue(zl5011xParamsS *zl5011xParams, Uint32T context)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xWanTxGetQueueStatsS stats;

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

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

   if (status == ZL5011X_OK)
   {
      stats.context = context;
      stats.minMaxReset = ZL5011X_TRUE;
      stats.minMaxEnable = ZL5011X_TRUE;

      status = zl5011xWanTxGetQueueStats(zl5011xParams, &stats);
   }

   if ((status == ZL5011X_OK) && (stats.lengthValid == ZL5011X_TRUE))
   {
      Uint32T avgHi,avgLo;
      zl5011xTfqFormatAvgLength(stats.avgQueueLength, _ZL5011X_DEBUG_AVG_PRECISION, &avgHi, &avgLo);

      printf("avg length = %4ld.%0*ld\n", avgHi, _ZL5011X_DEBUG_AVG_PRECISION, avgLo); /* Note:
                  '*' format allows _ZL5011X_DEBUG_AVG_PRECISION to specify the width of the field */
      printf("max length = %3ld\n", stats.maxQueueLength);
      printf("min length = %3ld\n", stats.minQueueLength);
   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugTxClockSource

 Description:
    This function provides information on the clock used for unstructured Wan
    Tx streams.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

zlStatusE zl5011xDebugTxClockSource(zl5011xParamsS *zl5011xParams)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T loop;
   zl5011xWanStreamClockConfigS wanStreamClockConfig;

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

      zl5011xPrintErr(status);
      return(status);
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xWanStreamClockConfigStructInit(zl5011xParams, &wanStreamClockConfig);
   }

   for (loop = 0; loop < zl5011xParams->wanIf.wanNumStreams; loop++)
   {
      if (status != ZL5011X_OK)
      {
         break;
      }

      wanStreamClockConfig.stream = (Uint8T)loop;
      status = zl5011xWanGetStreamClockConfig(zl5011xParams, &wanStreamClockConfig);

      if (status == ZL5011X_OK)
      {
         printf("%3ld: %s\n", loop, zl5011xDebugClockModeStr[wanStreamClockConfig.clockMode]);
      }

   }

   zl5011xPrintErr(status);
   return(status);
}

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

 Function:
    zl5011xDebugDpllStatus

 Description:
    This function provides status information for the PLL.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

char *dpllModeStr[] =
{
   "ZL5011X_DPLL_AUTOMATIC_OPERATION",
   "ZL5011X_DPLL_NORMAL_OPERATION",
   "ZL5011X_DPLL_HOLDOVER_OPERATION",
   "ZL5011X_DPLL_FREERUN_OPERATION"
};

zlStatusE zl5011xDebugDpllStatus(zl5011xParamsS *zl5011xParams)
{
   zlStatusE status = ZL5011X_OK;
   zl5011xDpllStatusS dpllStatus;

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

      zl5011xPrintErr(status);
      return(status);
   }

   if (zl5011xParams->wanIf.clock.sync.dpllConfig != ZL5011X_DPLL_MASTER_CONNECTION)
   {
      printf("DPLL not enabled\n");
      status = ZL5011X_ERROR;
   }

   if (status == ZL5011X_OK)
   {
      status = zl5011xPacDpllGetStatus(zl5011xParams, &dpllStatus);
   }

   if (status == ZL5011X_OK)
   {
      printf("DPLL mode    : %s\n", dpllModeStr[dpllStatus.dpllMode]);
      printf("     ref src : %s\n", (dpllStatus.primaryRefInUse == ZL5011X_TRUE) ? "Primary" : "Secondary");
      printf("     lock    : %d\n", dpllStatus.locked);
   }

   zl5011xPrintErr(status);
   return(status);
}


/******************************************************************************/
/* the following functions provided information for the Lan connection */
/******************************************************************************/

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

 Function:
    zl5011xDebugPkcStats

 Description:
   This function provides information on the packet classification process.
   Displaying the number of packets received for each of the protocols along
   with the number of unmatched packets.

 Inputs:
   zl5011xParams      Pointer to the structure for this device instance

 Outputs:
    None

 Returns:
   zlStatusE

 Remarks:
    None

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

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

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

      zl5011xPrintErr(status);
      return(status);
   }

   status = zl5011xPkcGetStats(zl5011xParams, &pktStats);

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

      printf("Protocol cnt %3ld  = %8lu\n", loop, pktStats.protocolCount[loop]);
   }

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

   zl5011xPrintErr(status);
   return(status);

⌨️ 快捷键说明

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