?? diag.c
字號:
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->err3Tx++;
errTx++;
}
else
{
pDrvCtrl1->ok3Tx++;
okTx++;
}
}
diagEthMakeHeader(pDrvCtrl1, pTbd);
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->ok3Rx++;
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->err3Rx++;
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->err3Rx++;
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->ok3Rx++;
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->err3Rx++;
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->err3Rx);
printf("ETH%d: Tx total ERRs : %u\n", pDrvCtrl1->unit, pDrvCtrl1->err3Tx);
} while ((repeat == 0) || (--repeat != 0));
#ifdef DIAG_TASK
taskDelay(0);
#endif /* DIAG_TASK */
return OK;
}
void taskDiagEth(int unit, int repeat)
{
ETH_DRV_CTRL drvCtrl;
bzero((char *)&drvCtrl, sizeof(ETH_DRV_CTRL));
drvCtrl.unit = unit;
do
{
printf("\n-------- MAC Loopback Mode\n");
memset((void *)USER_BASE_ADRS, 0, USER_SIZE);
if (ETH_DRV_INIT(&drvCtrl) == ERROR)
{
break;
}
ETH_DRV_START(&drvCtrl);
ETH_DRV_POLL_START(&drvCtrl);
ETH_DRV_LOOP_SET(&drvCtrl, LOOP_L2);
/* temp */
#if 0
diagEthRateTest(&drvCtrl, &drvCtrl, 1);
ETH_DRV_POLL_STOP(&drvCtrl);
break;
#endif
/* temp */
if (diagEthLoopTest(&drvCtrl, &drvCtrl, 1) == ERROR)
{
break;
}
diagEthRateTest1(&drvCtrl, &drvCtrl, 1);
diagEthRateTest2(&drvCtrl, &drvCtrl, 1);
diagEthRateTest3(&drvCtrl, &drvCtrl, 1);
ETH_DRV_POLL_STOP(&drvCtrl);
ETH_DRV_STOP(&drvCtrl);
printf("\n-------- PHY Loopback Mode\n");
if (ETH_DRV_INIT(&drvCtrl) == ERROR)
{
break;
}
ETH_DRV_START(&drvCtrl);
ETH_DRV_POLL_START(&drvCtrl);
ETH_DRV_LOOP_SET(&drvCtrl, LOOP_L1);
if (diagEthLoopTest(&drvCtrl, &drvCtrl, 1) == ERROR)
{
break;
}
diagEthRateTest1(&drvCtrl, &drvCtrl, 1);
diagEthRateTest2(&drvCtrl, &drvCtrl, 1);
diagEthRateTest3(&drvCtrl, &drvCtrl, 1);
ETH_DRV_POLL_STOP(&drvCtrl);
ETH_DRV_STOP(&drvCtrl);
#if 0
printf("\n-------- LINE Loopback Mode\n");
if (ETH_DRV_INIT(&drvCtrl) == ERROR)
{
break;
}
ETH_DRV_START(&drvCtrl);
ETH_DRV_POLL_START(&drvCtrl);
ETH_DRV_LOOP_SET(&drvCtrl, LOOP_NONE);
if (diagEthLoopTest(&drvCtrl, &drvCtrl, 1) == ERROR)
{
break;
}
diagEthRateTest1(&drvCtrl, &drvCtrl, 1);
diagEthRateTest2(&drvCtrl, &drvCtrl, 1);
diagEthRateTest3(&drvCtrl, &drvCtrl, 1);
ETH_DRV_POLL_STOP(&drvCtrl);
ETH_DRV_STOP(&drvCtrl);
#endif
} while ((repeat == 0) || (--repeat != 0));
}
void taskDiagEth2(int unit1, int unit2, int repeat)
{
ETH_DRV_CTRL drvCtrl1;
ETH_DRV_CTRL drvCtrl2;
bzero((char *)&drvCtrl1, sizeof(ETH_DRV_CTRL));
bzero((char *)&drvCtrl2, sizeof(ETH_DRV_CTRL));
drvCtrl1.unit = unit1;
drvCtrl2.unit = unit2;
do
{
printf("\n-------- MAC Cross Mode\n");
if (ETH_DRV_INIT(&drvCtrl1) == ERROR)
{
break;
}
ETH_DRV_START(&drvCtrl1);
ETH_DRV_POLL_START(&drvCtrl1);
if (ETH_DRV_INIT(&drvCtrl2) == ERROR)
{
break;
}
ETH_DRV_START(&drvCtrl2);
ETH_DRV_POLL_START(&drvCtrl2);
if (diagEthLoopTest(&drvCtrl1, &drvCtrl2, 1) == ERROR)
{
break;
}
/*
diagEthRateTest1(&drvCtrl1, &drvCtrl2, 1);
diagEthRateTest2(&drvCtrl1, &drvCtrl2, 1);
diagEthRateTest3(&drvCtrl1, &drvCtrl2, 1);
*/
ETH_DRV_POLL_STOP(&drvCtrl1);
ETH_DRV_STOP(&drvCtrl1);
ETH_DRV_POLL_STOP(&drvCtrl2);
ETH_DRV_STOP(&drvCtrl2);
} while ((repeat == 0) || (--repeat != 0));
}
STATUS s3c2510DiagEthMem(void)
{
printf("Ethernet Memory Diagnostic Test\n");
/* Test 1 */
printf(" 1) Ethernet 0 BD R/W Test (Address = 0x%08X, Length = 0x%08X)\n", BD_BASE_ETH, BD_SIZE_ETH);
if (diagMem((UINT8 *)BD_BASE_ETH, BD_SIZE_ETH) != OK)
{
return ERROR;
}
/* Test 2 */
printf(" 2) Ethernet 0 FB R/W Test (Address = 0x%08X, Length = 0x%08X)\n", FB_BASE_ETH, FB_SIZE_ETH);
if (diagMem((UINT8 *)FB_BASE_ETH, FB_SIZE_ETH ) != OK)
{
return ERROR;
}
#if (ETH_MAX_UNITS == 2)
/* Test 3 */
printf(" 3) Ethernet 1 BD R/W Test (Address = 0x%08X, Length = 0x%08X)\n", BD_BASE_ETH + BD_SIZE_ETH, BD_SIZE_ETH);
if (diagMem((UINT8 *)BD_BASE_ETH + BD_SIZE_ETH, BD_SIZE_ETH) != OK)
{
return ERROR;
}
/* Test 4 */
printf(" 4) Ethernet 1 FB R/W Test (Address = 0x%08X, Length = 0x%08X)\n", FB_BASE_ETH + FB_SIZE_ETH, FB_SIZE_ETH);
if (diagMem((UINT8 *)FB_BASE_ETH + FB_SIZE_ETH, FB_SIZE_ETH) != OK)
{
return ERROR;
}
#endif /* (ETH_MAX_UNITS == 2) */
return OK;
}
#define SYS_MEM_SIZE 0x400000
STATUS s3c2510DiagSysMem(int loop)
{
UINT8 *ptr;
printf("System Memory Diagnostic Test\n");
ptr = (UINT8 *)memalign(4, SYS_MEM_SIZE);
if (!ptr)
{
printf("Failed to allocate memory\n");
return ERROR;
}
while (loop)
{
if (diagMem(ptr, SYS_MEM_SIZE) != OK)
{
free(ptr);
return ERROR;
}
loop--;
}
free(ptr);
return OK;
}
STATUS s3c2510DiagEth(int unit, int length, int repeat)
{
#ifdef DIAG_TASK
char name[256];
if ((length >= 46) && (length <= 2048))
{
lengthFrame = length;
}
sprintf(name, "tDiagEth%d", unit);
taskSpawn(
name, /* name */
60, /* priority */
0, /* options */
65536, /* stack size */
(FUNCPTR)taskDiagEth, /* entry */
unit, /* unit number */
repeat, /* repeat count */
0, 0, 0, 0, 0, 0, 0, 0 /* params, unused */
);
#else /* DIAG_TASK */
if ((length >= 46) && (length <= 2048))
{
lengthFrame = length;
}
taskDiagEth(unit, repeat);
#endif /* DIAG_TASK */
return OK;
}
STATUS s3c2510DiagEth2(int unit1, int unit2, int length, int repeat)
{
#ifdef DIAG_TASK
char name[256];
if ((length >= 46) && (length <= 2048))
{
lengthFrame = length;
}
sprintf(name, "tDiagEth%d%d", unit1, unit2);
taskSpawn(
name, /* name */
60, /* priority */
0, /* options */
65536, /* stack size */
(FUNCPTR)taskDiagEth2, /* entry */
unit1, /* #1 unit number */
unit2, /* #2 unit number */
repeat, /* repeat count */
0, 0, 0, 0, 0, 0, 0 /* params, unused */
);
#else /* DIAG_TASK */
if ((length >= 46) && (length <= 2048))
{
lengthFrame = length;
}
taskDiagEth2(unit1, unit2, repeat);
#endif /* DIAG_TASK */
return OK;
}
STATUS s3c2510DiagMemFind(UINT32 var)
{
UINT32 ptr;
for (ptr=LOCAL_MEM_LOCAL_ADRS; ptr<(LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE); ptr+=4)
{
if (*(UINT32 *)ptr == var)
{
printf("0x%08X\n", ptr);
}
}
return OK;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -