📄 crc_diag.c
字号:
{
// Read the DRAM for the longword that was received
temp = GET32(dram_addr + ctr);
if (temp != pl_sys_lb_data[(ctr / 4)])
{
mailbox_value = ERROR_PATTERN;
eprintf("Packet:%d Longword:%d Expected:0x%X Received:0x%X\n", (rx_count + 1), (ctr / 4), pl_sys_lb_data[(ctr / 4)], temp);
flag = ERROR; // Set flag as error
rxflag[rx_port_num] = ERROR;
break;
}
if (ctr == 0)
{
if (((temp >>24) & 0xFF)== CHECK64)
Count64[rx_port_num]++;
if (((temp >>24) & 0xFF)== CHECK96)
Count138[rx_port_num]++;
if (((temp >>24) & 0xFF) == CHECK138)
Count96[rx_port_num]++;
}
}
if (flag == ERROR)
{
break;
}
hal_delay_us(800);
}
if (flag == ERROR)
{
if ((test_param == '4') || (test_param == 'd'))
;
else
{
break;
}
}
}
if (flag == ERROR)
{
if ((test_param == '4') || (test_param == 'd'))
;
else
{
break;
}
}
loop_count++;
if (forever && KEYPRESS)
{
break;
}
}
while ((loop_count != loop) || forever);
if (loop == 0)
{
expected_num_pkts = loop_count * 9;
counter = loop_count;
}
else
{
expected_num_pkts = loop * 9;
counter = loop;
}
MSG("\nexpected_num_pkts = %d\n",expected_num_pkts,0,0);
switch(ports)
{
case 0:
case 1:
case 2:
case 3: if (!cflag)
{
if ((pass_port[ports] != expected_num_pkts) || (pass_port[ports] == 0))
{
//eprintf("\nDid not Receive expected number of packets on port %d\n", ports);
eprintf("Packets Received = %d\n",pass_port[ports]);
flag = ERROR;
rxflag[ports] = ERROR;
}
else
{
eprintf("\nReceived on Port %d : %d\n",ports,pass_port[ports]);
flag = OK;
}
}
else
{
if ((pass_port[rxport[ports]] != expected_num_pkts) || (pass_port[rxport[ports]] == 0))
{
//eprintf("\nDid not Receive expected number of packets on port %d\n", rxport[ports]);
eprintf("Packets Received on port %d = %d\n",rxport[ports],pass_port[rxport[ports]]);
flag = ERROR;
rxflag[ports] = ERROR;
}
else
{
eprintf("\nReceived on Port %d : %d\n",rxport[ports],pass_port[rxport[ports]]);
flag = OK;
}
}
break;
case 4: eprintf("\n");
if (!cflag)
{
for (ctr=0; ctr<4; ctr++)
{
if ((pass_port[ctr] != expected_num_pkts) || (pass_port[ports] == 0))
{
//eprintf("\nDid not Receive expected number of packets on port %d\n", ctr);
eprintf("Packets Received = %d\n",pass_port[ctr]);
rxflag[ctr] = ERROR;
flag = ERROR;
}
if (pass_port[ctr] == expected_num_pkts)
{
eprintf("Received %d packets on Port %d\n",pass_port[ctr],ctr);
//flag = OK;
}
}
}
else
{
for (ctr=0; ctr<2; ctr++)
{
if ((pass_port[ctr*2+1] != expected_num_pkts) || (pass_port[ports] == 0))
{
//eprintf("\nDid not Receive expected number of packets on port %d\n", ctr*2+1);
eprintf("Packets Received = %d\n",pass_port[ctr*2+1]);
rxflag[ctr*2+1] = ERROR;
flag = ERROR;
}
if (pass_port[ctr*2+1] == expected_num_pkts)
{
eprintf("Received %d packets on Port %d\n",pass_port[ctr*2+1],ctr*2+1);
}
}
}
break;
default: eprintf("This is bad value for port number \n");
return INVALID_PARAMETERS;
}
}
eprintf("\n");
if(dcache_status != 0) // if dcache was originally ON
{
dcache_on();
}
if (loop == 0)
loop = loop_count;
if (get_crctest_stats(cflag) && !crcError)
{
switch(test_param)
{
case 'a':
case 'd':
eprintf("\nCRC test PASSED !\n");
break;
case '4':
eprintf("\nRMON: FCSError/CRCError stat. Reg. test PASSED !\n");
break;
}
Set_LED("PASS");
slowport_code[0] = SP_XSC;
slowport_code[1] = SP_PASS;
dump_slowport(slowport_code, 2, SP_NON_FATAL);
}
else
{
if (mailbox_value == INIT_ERROR)
{
eprintf("The slave NPU did not succeed in loading the microcode to its microengines\n");
}
else if (mailbox_value == NOT_RECEIVED)
{
eprintf("There was no sign that the expected packet was received\n");
}
else if (mailbox_value == ERROR_PATTERN)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("The packet received was not the same as the packet transmitted.\n");
}
else if (mailbox_value == INCORRECT_SIZE)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("The packet received was not the same size as the packet transmitted.\n");
}
if (mailbox_value == ILLEGAL_CRC_APPEND)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("\nCRC appended, when append disabled.\n");
}
if (mailbox_value == ILLEGAL_CRC_STRIP)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("\nCRC stripped, when CRC strip disabled.\n");
}
if (mailbox_value == CRC_STRIP_FAILED)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("\nCRC stripping failed..\n");
}
if (mailbox_value == CRC_APPEND_FAILED)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("\nCRC append failed.\n");
}
// prepare structure for dumping
syslog.type = TYPE_ERROR;
syslog.source_comp = MASTER_DIAG; // Determine master/slave
switch(test_param)
{
case 'a':
case 'd':
strcpy(syslog.desc, "CRC test FAILED!");
eprintf("CRC test FAILED!\n");
break;
case '4':
strcpy(syslog.desc, "RMON: FCSError/CRCError stat. Reg. test FAILED !");
eprintf("RMON: FCSError/CRCError stat. Reg. test FAILED !\n");
break;
}
// write to syslog
syslog_dump(&syslog, sizeof(SYSLOG_DATA));
Set_LED("FAIL");
slowport_code[0] = SP_XSC;
slowport_code[1] = SP_FAIL;
dump_slowport(slowport_code, 2, SP_NON_FATAL);
acL->Err = ERROR;
}
Clear_All_ME();
Msf_OutOfReset();
}
else
{
eprintf("\nThis test cannot be run directly on the Slave console\n");
return DONE; // To indicate that the slave does not do this.
}
return DONE;
}
int get_crctest_stats(short cflag)
{
int port=0,ctr=0,port_ctr=0,test_passed=1;
UINT32 rx64pkts[4], rx96pkts[4], rx138pkts[4];
UINT32 tx64pkts[4], tx96pkts[4], tx138pkts[4];
UINT32 RxfcsErrors[4],TxcrcErrors[4];
short rxok=0,txok=0;
spConfig();
for(port=0; port<4;port++)
{
if (cflag)
port=rxport[port];
/* Reading the total packets received */
rx64pkts[port]=reg_read(((port*PORTSZ)+RX_PKTS_64));
rx96pkts[port]=reg_read(((port*PORTSZ)+RX_PKTS_65_127));
rx138pkts[port]=reg_read(((port*PORTSZ)+RX_PKTS_128_255));
RxfcsErrors[port] = reg_read(((port*PORTSZ)+RX_FCS_ERR));
if (cflag)
port=rxport[port];
tx64pkts[port]=reg_read(((port*PORTSZ)+TX_PKTS_64));
tx96pkts[port]=reg_read(((port*PORTSZ)+TX_PKTS_65_127));
tx138pkts[port]=reg_read(((port*PORTSZ)+TX_PKTS_128_255));
TxcrcErrors[port] = reg_read(((port*PORTSZ)+TX_CRC_ERR));
}
spRestore();
if (ports == 4)
if (!cflag)
ctr = 4;
else
ctr = 2;
else
ctr = 1;
for(port_ctr=0; port_ctr<ctr;port_ctr++)
{
if ((!cflag) && (ports == 4))
port = port_ctr;
if ((cflag) && (ports == 4))
{
port = port_ctr*2;
port = rxport[port];
}
if ((!cflag) && (ports != 4))
port = ports;
if ((cflag) && (ports != 4))
port = rxport[ports];
eprintf("PORT = %d\n",port);
eprintf("Port %d: 64 byte packets received=0x%x\n",port,rx64pkts[port]);
eprintf("Port %d: 96 byte packets received=0x%x\n",port,rx96pkts[port]);
eprintf("Port %d: 138 byte packets received=0x%x\n",port,rx138pkts[port]);
eprintf("Port %d: Packets received with FCS Errors = 0x%x\n",port,RxfcsErrors[port]);
if (cflag)
port=rxport[port];
eprintf("\nPort %d: 64 byte packets transmitted=0x%x\n",port,tx64pkts[port]);
eprintf("Port %d: 96 byte packets transmitted=0x%x\n",port,tx96pkts[port]);
eprintf("Port %d: 138 byte packets transmitted=0x%x\n",port,tx138pkts[port]);
eprintf("Port %d: Packets transmitted with CRC Errors = 0x%x\n",port,TxcrcErrors[port]);
if (cflag)
port=rxport[port];
switch(test_param)
{
case 'a':
eprintf("port = %d\n",port);
if ((Count64[port] != (loop*LEN64_PKTS)) ||
(Count96[port] != (loop*LEN96_PKTS)) ||
(Count138[port] != (loop*LEN138_PKTS)))
{
eprintf("All packets are not received.\n");
test_passed = 0;
}
if (cflag)
port=rxport[port];
if (RxfcsErrors[port] != (loop *EXP_BAD_PKTS))
{
eprintf("Received frames with CRC Errors on port %d\n",port);
test_passed = 0;
}
if (test_passed)
rxok |= 1<<port_ctr;
if (cflag)
port=rxport[port];
if (TxcrcErrors[port] != (loop *EXP_BAD_PKTS))
{
eprintf("Transmitted frames with CRC Errors on port %d\n",port);
test_passed = 0;
}
else
txok |= 1<<port_ctr;
break;
case 'd':
case '4':
if (cflag)
port=rxport[port];
if (RxfcsErrors[port] == (loop *6))
{
eprintf("Received frames with CRC Errors on port %d\n",port);
rxok |= 1<<port_ctr;
}
if (cflag)
port=rxport[port];
if (TxcrcErrors[port] == (loop *9))
{
eprintf("Transmitted rames with CRC Errors on port %d\n",port);
txok |= 1<<port_ctr;
}
break;
}
}
if((rxok == 0xF) && (txok == 0xF) && (ports == 0x4) && (!cflag))
test_passed = 1;
else
if((rxok == 0x3) && (txok == 0x3) && (ports == 0x4) && cflag)
test_passed = 1;
else
if((rxok == 0x1) && (txok == 0x1) && (ports != 0x4))
test_passed = 1;
else
test_passed = 0;
return test_passed;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -