📄 diag.c
字号:
printf("ETH%d: RBD:%08X, RB:%08X\n", pDrvCtrl2->unit, (UINT32)pRbd, (UINT32)pRbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl2->err1Rx++;
errRx++;
}
seconds = (tickGet() - tickStart) / sysClkRateGet();
/* Advance to next RBD. */
pDrvCtrl2->rbdIndex++;
if (pDrvCtrl2->rbdIndex == NUM_RBD_ETH)
{
pDrvCtrl2->rbdIndex = 0;
}
}
if (((tickGet() - tickStart) / sysClkRateGet()) > 5)
{
break;
}
}
#ifdef DIAG_TASK
taskDelay(0);
#endif /* DIAG_TASK */
return OK;
}
#endif
/* temp */
STATUS diagEthRateTest1(ETH_DRV_CTRL *pDrvCtrl1, ETH_DRV_CTRL *pDrvCtrl2, int repeat)
{
int seqRx;
int seqTx;
UINT32 seconds;
UINT32 busyTx;
UINT32 okRx;
UINT32 okTx;
int errRx;
int errTx;
PETHRBD pRbd;
PETHTBD pTbd;
UINT32 tickStart;
ULONG length;
printf("\nETH%d: Estimate Data Transfer Rate (two copy)\n", pDrvCtrl1->unit);
do
{
printf("ETH%d: Wait for 30 seconds...\n", pDrvCtrl1->unit);
seqRx = 0;
seqTx = 0;
seconds = 0;
busyTx = 0;
okRx = 0;
okTx = 0;
errRx = 0;
errTx = 0;
tickStart = tickGet();
while (seconds < 30)
{
pTbd = ETH_DRV_TBD_GET(pDrvCtrl1);
if (pTbd)
{
seqTx++;
if (pTbd->status != 0)
{
if (ETH_DRV_TBD_CHECK(pDrvCtrl1, pTbd) != OK)
{
#ifndef DIAG_QUIET
printf("ETH%d: Tx error, sequence %d, length %u, status 0x%04X\n", pDrvCtrl1->unit, seqTx, (UINT)pTbd->length, pTbd->status);
printf("ETH%d: TBD:%08X, TB:%08X\n", pDrvCtrl1->unit, (UINT32)pTbd, (UINT32)pTbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl1->err1Tx++;
errTx++;
}
else
{
pDrvCtrl1->ok1Tx++;
okTx++;
}
}
/* temp
{
int i;
for (i=0; i<lengthFrame; i++)
{
buffer[i] = (UCHAR)(okTx + i + i / 256);
}
}
*/
diagEthMakeHeader(pDrvCtrl1, pTbd);
bcopy(buffer, (char *)(pTbd->pBuf + SIZE_ETH_WA + SIZE_ETH_HDR), lengthFrame);
ETH_DRV_TBD_START(pDrvCtrl1, pTbd, lengthFrame + SIZE_ETH_HDR);
}
else
{
busyTx++;
}
while ((pRbd = ETH_DRV_RBD_GET(pDrvCtrl2)) != NULL)
{
seqRx++;
length = ETH_DRV_RBD_CHECK(pDrvCtrl2, pRbd);
if (length == (lengthFrame + SIZE_ETH_HDR))
{
bcopy((char *)(pRbd->pBuf + SIZE_ETH_WA + SIZE_ETH_HDR), buffer, lengthFrame);
pDrvCtrl2->ok1Rx++;
okRx++;
}
else
{
#ifndef DIAG_QUIET
printf("ETH%d: Rx error, sequence %d, length %u, status 0x%04X\n", pDrvCtrl2->unit, seqRx, (UINT)pRbd->length, pRbd->status);
printf("ETH%d: RBD:%08X, RB:%08X\n", pDrvCtrl2->unit, (UINT32)pRbd, (UINT32)pRbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl2->err1Rx++;
errRx++;
}
ETH_DRV_RBD_FREE(pDrvCtrl2, pRbd);
}
seconds = (tickGet() - tickStart) / sysClkRateGet();
if ((okRx == 0) && (errRx == 0) && (seconds > 5))
{
printf("ETH%d: no receive indication during 5 seconds\n", pDrvCtrl2->unit);
pDrvCtrl2->err1Rx++;
errRx++;
return ERROR;
}
}
while ((okRx + errRx) != seqTx)
{
while ((pRbd = ETH_DRV_RBD_GET(pDrvCtrl2)) != NULL)
{
seqRx++;
length = ETH_DRV_RBD_CHECK(pDrvCtrl2, pRbd);
if (length == (lengthFrame + SIZE_ETH_HDR))
{
bcopy((char *)(pRbd->pBuf + SIZE_ETH_WA + SIZE_ETH_HDR), buffer, lengthFrame);
pDrvCtrl2->ok1Rx++;
okRx++;
}
else
{
#ifndef DIAG_QUIET
printf("ETH%d: Rx error, sequence %d, length %u, status 0x%04X\n", pDrvCtrl2->unit, seqRx, (UINT)pRbd->length, pRbd->status);
printf("ETH%d: RBD:%08X, RB:%08X\n", pDrvCtrl2->unit, (UINT32)pRbd, (UINT32)pRbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl2->err1Rx++;
errRx++;
}
ETH_DRV_RBD_FREE(pDrvCtrl2, pRbd);
seconds = (tickGet() - tickStart) / sysClkRateGet();
}
if (((tickGet() - tickStart) / sysClkRateGet()) > 35)
{
break;
}
}
printf("ETH%d: Elapsed Time : %d seconds\n", pDrvCtrl1->unit, seconds);
printf("ETH%d: Rx OKs : %u, %f MB\n", pDrvCtrl2->unit, (UINT)okRx, (float)okRx / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Tx OKs : %u, %f MB\n", pDrvCtrl1->unit, (UINT)okTx, (float)okTx / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Rx dropped : %u\n", pDrvCtrl2->unit, (UINT)(okTx - okRx));
printf("ETH%d: Tx dropped : %u\n", pDrvCtrl1->unit, (UINT)busyTx);
printf("ETH%d: Rx Rate : %f Mbps\n", pDrvCtrl2->unit, (float)okRx * 8 / seconds / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Tx Rate : %f Mbps\n", pDrvCtrl1->unit, (float)okTx * 8 / seconds / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Rx ERRs : %u\n", pDrvCtrl2->unit, errRx);
printf("ETH%d: Tx ERRs : %u\n", pDrvCtrl1->unit, errTx);
printf("ETH%d: Rx total ERRs : %u\n", pDrvCtrl2->unit, pDrvCtrl2->err1Rx);
printf("ETH%d: Tx total ERRs : %u\n", pDrvCtrl1->unit, pDrvCtrl1->err1Tx);
} while ((repeat == 0) || (--repeat != 0));
#ifdef DIAG_TASK
taskDelay(0);
#endif /* DIAG_TASK */
return OK;
}
STATUS diagEthRateTest2(ETH_DRV_CTRL *pDrvCtrl1, ETH_DRV_CTRL *pDrvCtrl2, int repeat)
{
int seqRx;
int seqTx;
UINT32 seconds;
UINT32 busyTx;
UINT32 okRx;
UINT32 okTx;
int errRx;
int errTx;
PETHRBD pRbd;
PETHTBD pTbd;
UINT32 tickStart;
ULONG length;
printf("\nETH%d: Estimate Data Transfer Rate (one copy)\n", pDrvCtrl1->unit);
do
{
printf("ETH%d: Wait for 30 seconds...\n", pDrvCtrl1->unit);
seqRx = 0;
seqTx = 0;
seconds = 0;
busyTx = 0;
okRx = 0;
okTx = 0;
errRx = 0;
errTx = 0;
tickStart = tickGet();
while (seconds < 30)
{
pTbd = ETH_DRV_TBD_GET(pDrvCtrl1);
if (pTbd)
{
seqTx++;
if (pTbd->status != 0)
{
if (ETH_DRV_TBD_CHECK(pDrvCtrl1, pTbd) != OK)
{
#ifndef DIAG_QUIET
printf("ETH%d: Tx error, sequence %d, length %u, status 0x%04X\n", pDrvCtrl1->unit, seqTx, (UINT)pTbd->length, pTbd->status);
printf("ETH%d: TBD:%08X, TB:%08X\n", pDrvCtrl1->unit, (UINT32)pTbd, (UINT32)pTbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl1->err2Tx++;
errTx++;
}
else
{
pDrvCtrl1->ok2Tx++;
okTx++;
}
}
/* temp
{
int i;
for (i=0; i<lengthFrame; i++)
{
buffer[i] = (UCHAR)(okTx + i + i / 256);
}
}
*/
diagEthMakeHeader(pDrvCtrl1, pTbd);
bcopy(buffer, (char *)(pTbd->pBuf + SIZE_ETH_WA + SIZE_ETH_HDR), lengthFrame);
ETH_DRV_TBD_START(pDrvCtrl1, pTbd, lengthFrame + SIZE_ETH_HDR);
}
else
{
busyTx++;
}
while ((pRbd = ETH_DRV_RBD_GET(pDrvCtrl2)) != NULL)
{
seqRx++;
length = ETH_DRV_RBD_CHECK(pDrvCtrl2, pRbd);
if (length == (lengthFrame + SIZE_ETH_HDR))
{
pDrvCtrl2->ok2Rx++;
okRx++;
}
else
{
#ifndef DIAG_QUIET
printf("ETH%d: Rx error, sequence %d, length %u, status 0x%04X\n", pDrvCtrl2->unit, seqRx, (UINT)pRbd->length, pRbd->status);
printf("ETH%d: RBD:%08X, RB:%08X\n", pDrvCtrl2->unit, (UINT32)pRbd, (UINT32)pRbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl2->err2Rx++;
errRx++;
}
ETH_DRV_RBD_FREE(pDrvCtrl2, pRbd);
}
seconds = (tickGet() - tickStart) / sysClkRateGet();
if ((okRx == 0) && (errRx == 0) && (seconds > 5))
{
printf("ETH%d: no receive indication during 5 seconds\n", pDrvCtrl2->unit);
pDrvCtrl2->err2Rx++;
errRx++;
return ERROR;
}
}
while ((okRx + errRx) != seqTx)
{
while ((pRbd = ETH_DRV_RBD_GET(pDrvCtrl2)) != NULL)
{
seqRx++;
length = ETH_DRV_RBD_CHECK(pDrvCtrl2, pRbd);
if (length == (lengthFrame + SIZE_ETH_HDR))
{
pDrvCtrl2->ok2Rx++;
okRx++;
}
else
{
#ifndef DIAG_QUIET
printf("ETH%d: Rx error, sequence %d, length %u, status 0x%04X\n", pDrvCtrl2->unit, seqRx, (UINT)pRbd->length, pRbd->status);
printf("ETH%d: RBD:%08X, RB:%08X\n", pDrvCtrl2->unit, (UINT32)pRbd, (UINT32)pRbd->pBuf);
#endif /* DIAG_QUIET */
pDrvCtrl2->err2Rx++;
errRx++;
}
ETH_DRV_RBD_FREE(pDrvCtrl2, pRbd);
seconds = (tickGet() - tickStart) / sysClkRateGet();
}
if (((tickGet() - tickStart) / sysClkRateGet()) > 35)
{
break;
}
}
printf("ETH%d: Elapsed Time : %d seconds\n", pDrvCtrl1->unit, seconds);
printf("ETH%d: Rx OKs : %u, %f MB\n", pDrvCtrl2->unit, (UINT)okRx, (float)okRx / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Tx OKs : %u, %f MB\n", pDrvCtrl1->unit, (UINT)okTx, (float)okTx / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Rx dropped : %u\n", pDrvCtrl2->unit, (UINT)(okTx - okRx));
printf("ETH%d: Tx dropped : %u\n", pDrvCtrl1->unit, (UINT)busyTx);
printf("ETH%d: Rx Rate : %f Mbps\n", pDrvCtrl2->unit, (float)okRx * 8 / seconds / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Tx Rate : %f Mbps\n", pDrvCtrl1->unit, (float)okTx * 8 / seconds / 1024 * (lengthFrame + SIZE_ETH_HDR + SIZE_ETH_CRC) / 1024);
printf("ETH%d: Rx ERRs : %u\n", pDrvCtrl2->unit, errRx);
printf("ETH%d: Tx ERRs : %u\n", pDrvCtrl1->unit, errTx);
printf("ETH%d: Rx total ERRs : %u\n", pDrvCtrl2->unit, pDrvCtrl2->err2Rx);
printf("ETH%d: Tx total ERRs : %u\n", pDrvCtrl1->unit, pDrvCtrl1->err2Tx);
} while ((repeat == 0) || (--repeat != 0));
#ifdef DIAG_TASK
taskDelay(0);
#endif /* DIAG_TASK */
return OK;
}
STATUS diagEthRateTest3(ETH_DRV_CTRL *pDrvCtrl1, ETH_DRV_CTRL *pDrvCtrl2, int repeat)
{
int seqRx;
int seqTx;
UINT32 seconds;
UINT32 busyTx;
UINT32 okRx;
UINT32 okTx;
int errRx;
int errTx;
PETHRBD pRbd;
PETHTBD pTbd;
UINT32 tickStart;
ULONG length;
printf("\nETH%d: Estimate Data Transfer Rate (zero copy)\n", pDrvCtrl1->unit);
do
{
printf("ETH%d: Wait for 30 seconds...\n", pDrvCtrl1->unit);
seqRx = 0;
seqTx = 0;
seconds = 0;
busyTx = 0;
okRx = 0;
okTx = 0;
errRx = 0;
errTx = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -