?? zl5011xdebugfuncs.c
字號:
Description:
Displays information on the protocol matching and the classifier rules in use.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
*******************************************************************************/
zlStatusE zl5011xDebugPkcConfig(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
Uint32T loop;
if (zl5011xParams == NULL)
{
status = ZL5011X_INVALID_POINTER;
}
if (status == ZL5011X_OK)
{
printf("Protocol matching\n");
printf("=================\n");
for (loop = 0; loop < ZL5011X_PKC_NUM_PROTOCOL_ENTRIES; loop++)
{
if (zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolInUse == ZL5011X_FALSE)
{
/* not used so skip info */
continue;
}
printf("%ld: %2d bit seq = %2d, %2d, TS = %2d, %2d, %2d, %2d, PW = %2d\n", loop,
(zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.protocolTwoByteSeq == ZL5011X_TRUE) ? 16 : 8,
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractSequenceBytes[1],
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractSequenceBytes[0],
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractTimestampBytes[3],
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractTimestampBytes[2],
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractTimestampBytes[1],
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractTimestampBytes[0],
zl5011xParams->packetIf.packetRx.pkcProtocol[loop].protocolOutput.extractPwByte);
}
}
if (status == ZL5011X_OK)
{
printf("\nClassifier matching\n");
printf("===================\n");
for (loop = 0; loop < ZL5011X_PKC_NUM_CLASSIFY_ENTRIES; loop++)
{
if (zl5011xParams->packetIf.packetRx.pkcClassify[loop].classifyInUse == ZL5011X_FALSE)
{
/* not used so skip info */
continue;
}
printf("%3ld: prot = %d, context = %3ld, hdr off = %2d, flow = %2d\n", loop,
zl5011xParams->packetIf.packetRx.pkcClassify[loop].classifyMatch.protocolMatchNum,
zl5011xParams->packetIf.packetRx.pkcClassify[loop].classifyOutput.classifyMpid,
zl5011xParams->packetIf.packetRx.pkcClassify[loop].classifyOutput.classifyHeaderOffset,
zl5011xParams->packetIf.packetRx.pkcClassify[loop].classifyOutput.classifyFlow);
}
}
zl5011xPrintErr(status);
return(status);
}
/*******************************************************************************
Function:
zl5011xDebugPacketSniffCapture
Description:
Returns the first granule of data for a given context.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context number to print stats for.
Outputs:
buf buffer to hold packet data - assumed to be 64 bytes
length payload length in bytes
Returns:
zlStatusE
Remarks:
Sniffs the TDM queue - does not disable interrupts. Therefore may get
pre-empted since run from a low priority task, so allow the process to retry.
*******************************************************************************/
#define ZL5011X_DEBUG_MAX_SNIFF_RETRIES 10
zlStatusE zl5011xDebugPacketSniffCapture(zl5011xParamsS *zl5011xParams, Uint32T context, Uint32T *buf, Uint32T *length)
{
zlStatusE status = ZL5011X_OK;
Uint32T tfqWrite = 0, tfqQueue = 0, queueMask = 0;
Uint32T gran = 0, tfq1, tfq2;
Uint32T loop, readValue, retryCount;
zl5011xBooleanE failed;
if (zl5011xParams->wanIf.txQueue[context].queueBaseAddress == (Uint32T)ZL5011X_NOT_INITIALISED)
{
status = ZL5011X_ERROR;
}
else
{
/* queue has been set up so work out a mask based on it's size.
The sequence numbers in the packet get this mask applied in order to
put the packet into a slot in the queue, so this operation needs to be
repeated to find the data in the packet */
queueMask = (1 << zl5011xParams->wanIf.txQueue[context].queueSize) - 1;
/* get the address of the TFQ register that holds the write pointer */
tfqWrite = ZL5011X_TFQ_CTXT_STATUS + (ZL5011X_TFQ_CTXT_CONTROL_SIZE * context);
}
retryCount = 0;
/* allow the packet sniff to retry in the event of failing - most likely cause
is no packet Rx or concurrency (higher priority task or interrupt) */
while ((retryCount < ZL5011X_DEBUG_MAX_SNIFF_RETRIES) && (status == ZL5011X_OK))
{
failed = ZL5011X_FALSE;
retryCount++;
status = zl5011xRead(zl5011xParams, tfqWrite, &readValue);
/* work out the address for the last packet added to the queue.
Masking out any bits not related to the write pointer. */
tfqQueue = zl5011xParams->wanIf.txQueue[context].queueBaseAddress + ((readValue & queueMask) * 8);
if (status == ZL5011X_OK)
{
/* read the first word from the queue */
status = zl5011xRead(zl5011xParams, tfqQueue, &tfq1);
/* retrieve the granule pointer for the start of the packet */
gran = tfq1 & 0x3ffff;
}
if (status == ZL5011X_OK)
{
/* read the second word from the queue */
status = zl5011xRead(zl5011xParams, tfqQueue + sizeof(Uint32T), &tfq2);
/* check that there is data for this entry in the queue.
No entry in the queue probably means that there are no Rx packets */
if ((tfq2 & 0x80000000) == 0)
{
failed = ZL5011X_TRUE;
}
}
if (failed == ZL5011X_FALSE)
{
/* retrieve a granules worth of data for the context */
for (loop = 0; loop < (ZL5011X_GRANULE_DATA_SIZE / sizeof(Uint32T)); loop++)
{
if (status != ZL5011X_OK)
{
break;
}
status = zl5011xRead(zl5011xParams,
zl5011xParams->packetMemory.granBaseAddr + (gran * ZL5011X_GRANULE_DATA_SIZE) + (loop * sizeof(Uint32T)),
buf + loop);
}
/* check that the queue hasn't changed since we first read it. If it has then means
that we were delayed and the queue entry changed, so the data is most likely invalid. */
if (status == ZL5011X_OK)
{
status = zl5011xRead(zl5011xParams, tfqQueue, &readValue);
if (readValue != tfq1)
{
failed = ZL5011X_TRUE;
}
}
if (status == ZL5011X_OK)
{
status = zl5011xRead(zl5011xParams, tfqQueue + sizeof(Uint32T), &readValue);
if (readValue != tfq2)
{
failed = ZL5011X_TRUE;
}
}
}
if (failed == ZL5011X_FALSE)
{
/* collected a packet so break out of the loop */
break;
}
}
if (retryCount == ZL5011X_DEBUG_MAX_SNIFF_RETRIES)
{
status = ZL5011X_ERROR;
}
/* retrieve the payload length from the TFQ word */
*length = (tfq2 >> 10) & 0x7ff;
return(status);
}
/*******************************************************************************
Function:
zl5011xDebugPacketSniff
Description:
Displays the first granule of data for a packet sniffed from a TDM queue.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context context number to print stats for.
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xDebugPacketSniff(zl5011xParamsS *zl5011xParams, Uint32T context)
{
zlStatusE status = ZL5011X_OK;
Uint32T *buf = NULL;
Uint32T loop, payloadLength;
/* allocate some memory - only fetching one granule. Since the header will
almost always be contained in the first granule, there is no need to traverse
the chain */
buf = (Uint32T *)OS_MALLOC(ZL5011X_GRANULE_DATA_SIZE);
if (buf == NULL)
{
status = ZL5011X_ERROR;
}
if (status == ZL5011X_OK)
{
status = zl5011xDebugPacketSniffCapture(zl5011xParams, context, buf, &payloadLength);
}
/* display the packet information */
if (status == ZL5011X_OK)
{
printf("payload length = %ld\n", payloadLength);
for (loop = 0; loop < ZL5011X_GRANULE_DATA_SIZE / sizeof(Uint32T); loop++)
{
printf(" %02X %02X %02X %02X",
(Uint8T)(buf[loop] >> 0),
(Uint8T)(buf[loop] >> 8),
(Uint8T)(buf[loop] >> 16),
(Uint8T)(buf[loop] >> 24));
if (loop & 1)
{
printf("\n");
}
}
}
if (buf != NULL)
{
free(buf);
}
zl5011xPrintErr(status);
return(status);
}
/*******************************************************************************
Function:
zl5011xDebugPacketTxHeader
Description:
Displays the packet header programmed for given Wan Rx context
Inputs:
zl5011xParams Pointer to the structure for this device instance
context Wan Rx context to inspect
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xDebugPacketTxHeader(zl5011xParamsS *zl5011xParams, Uint32T context)
{
zlStatusE status = ZL5011X_OK;
Uint32T tempAddr;
Uint32T loop, temp, readValue;
zl5011xContextHeaderSwitchE currTxHeader;
temp = zl5011xParams->packetIf.packetTx.txHeader[context].lowHeader.txLowLength;
status = zl5011xPtxGetHeaderAddress(zl5011xParams, context, &tempAddr);
printf("Low header\n");
printf("==========\n ");
for (loop = 0; loop < temp; loop++)
{
if (status != ZL5011X_OK)
{
break;
}
if ((loop % sizeof(Uint32T)) == 0)
{
status = zl5011xRead(zl5011xParams, tempAddr + loop, &readValue);
}
printf("%02lX ", readValue >> (loop % sizeof(Uint32T) * 8) & 0xff);
if ((loop % 8) == 7)
{
printf("\n ");
}
}
printf("\n\nHigh header\n");
printf( "===========\n ");
if (status == ZL5011X_OK)
{
status = zl5011xPlaGetCurrentHeader(zl5011xParams,
context, &currTxHeader);
if (status == ZL5011X_OK)
{
temp = zl5011xParams->packetIf.packetTx.txHeader[context].highHeader[currTxHeader].txHighLength;
status = zl5011xRtpGetHeaderAddress(zl5011xParams, context,
currTxHeader, &tempAddr);
}
}
for (loop = 0; loop < temp; loop++)
{
if (status != ZL5011X_OK)
{
break;
}
if ((loop % sizeof(Uint32T)) == 0)
{
status = zl5011xRead(zl5011xParams, tempAddr + loop, &readValue);
}
printf("%02lX ", readValue >> (loop % sizeof(Uint32T) * 8) & 0xff);
if ((loop % 8) == 7)
{
printf("\n ");
}
}
printf("\n");
zl5011xPrintErr(status);
return status;
}
/******************************************************************************/
/* the following functions provided information on the task messages */
/******************************************************************************/
/*******************************************************************************
Function:
zl5011xDebugScanTmMsg
Description:
This function just scans through the task manager trace buffer and provides
a count of the number of messages found for each context. The number of
messages found can provide information on packet generation (Wan Rx contexts)
and packet reception (Wan Tx).
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xDebugScanTmMsg(zl5011xParamsS *zl5011xParams)
{
zlStatusE status = ZL5011X_OK;
zl5011xTmTraceMessageS msg;
Uint32T found[128];
Uint32T loop;
if (zl5011xParams == NULL)
{
status = ZL5011X_INVALID_POINTER;
zl5011xPrintErr(status);
return(status);
}
memset(found, 0, sizeof(found));
for (loop = 0; loop < ZL5011X_TM_TRACE_BUFFER_SIZE / zl5011xParams->taskManager.tmBufferSize; loop++)
{
if (status != ZL5011X_OK)
{
break;
}
status = zl5011xTmGetTraceMessage(zl5011xParams, loop, &msg);
found[msg.mpid & 0x7f]++;
}
for (loop = 0; loop < 128; loop++)
{
if (found[loop] != 0)
{
printf("context %3ld, found %3ld messages\n", loop, found[loop]);
}
}
zl5011xPrintErr(status);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -