📄 reset_diag.c
字号:
ctr++;
}
while (temp == 0);
if (flag == OK) // If slave completed microcode loading successfully
{
// Load Master's NPU with ucode and init
// DownLoadUcode(PL_SYS_LOOPBACK_EG_TX_ME, Sz_pl_sys_loopback_eg_tx, (UINT32 *)pl_sys_loopback_eg_tx);
// DownLoadUcode(PL_SYS_LOOPBACK_EG_RX_ME, Sz_pl_sys_loopback_eg_rx, (UINT32 *)pl_sys_loopback_eg_rx);
DownLoadUcode(PL_SYS_LOOPBACK_EG_TX_ME, Sz_mphy_loopback_eg_tx, (UINT32 *)mphy_loopback_eg_tx);
DownLoadUcode(PL_SYS_LOOPBACK_EG_RX_ME, Sz_mphy_loopback_eg_rx, (UINT32 *)mphy_loopback_eg_rx);
hal_delay_us(10000);
// eprintf("DEBUG: (sizeof(tx_data_pl) / sizeof(UINT32)) / 4 = %d\n", ((sizeof(tx_data_pl) / sizeof(UINT32)) / 4));
do
{
//for (combination = 0; combination < ((sizeof(tx_data_pl) / sizeof(UINT32)) / 4); combination++)
for (combination = 0; combination < pnum; combination++)
{
for (port_ctr = 0; port_ctr < iteration; port_ctr++)
{
if (ports != 4)
{
port_num = ports;
PUT32((SCR_RING_INSTR_ADDR + (port_num << 2)), pktptr[combination]);
}
else
{
if (cflag)
port_num = port_ctr*2;
else
port_num = port_ctr;
PUT32((SCR_RING_INSTR_ADDR + (port_num << 2)), tx_data_pl[((combination * 4) + port_num)]);
}
}
}
//for (combination = 0; combination < ((sizeof(tx_data_pl) / sizeof(UINT32)) / 4); combination++)
for (combination = 0; combination < pnum; combination++)
{
flag = OK;
for (port_ctr = 0; port_ctr < iteration; port_ctr++)
{
if (ports != 4)
port_num = ports;
else
{
if (cflag)
port_num = port_ctr*2;
else
port_num = port_ctr;
}
ctr = 0;
do // Do while waiting for all the packets to be transmitted
{
if (ctr == 1000) // After 1 second
{
eprintf("\nTimed out...No indication from scratch ring that all packets were transmitted\n");
mailbox_value = NOT_SENT;
flag = ERROR;
break;
}
// Poll on scratch ring to check if the packets have been transmitted
if ((scratch_read_value = GET32(scratch_ring_tx_count)) == 0)
{
hal_delay_us(1);
ctr++;
}
else
{
switch(ports)
{
case 0 :
case 1 :
case 2 :
case 3 :
eprintf("Transmitted on port %d: %d\r", ports,(scratch_read_value));
break;
case 4 : // all ports
if (!cflag)
{
eprintf("Transmitted on ports 0-3 : %d\r", (scratch_read_value)/4);
iteration = 4;
}
else
{
eprintf("Transmitted on ports 0 and 2 : %d\r", (scratch_read_value)/2);
iteration = 2;
}
break;
}
tx_count++;
}
}
while (scratch_read_value == 0);
PUT32(scratch_ring_tx_count, 0);
tx_count = scratch_read_value;
if (flag == ERROR)
{
if (test_param == 'r')
break;
else
continue;
}
}
if (flag == ERROR)
{
if (test_param == 'r')
break;
else
continue;
}
}
//if (flag == ERROR)
//{
// break;
//}
for (combination = 0; combination < pnum; combination++)
{
for (port_ctr = 0; port_ctr < iteration; port_ctr++)
{
if (!cflag)
{
if (ports != 4)
port_num = ports;
else
port_num = port_ctr;
}
else
{
if (ports != 4)
port_num = rxport[ports];
else
port_num = port_ctr*2 + 1;
}
ctr = 0;
do // Do while waiting for a signal that a packet has been received
{
if (ctr == 300) // After 1 second
{
//eprintf("Timed out...No indication from scratch ring that packets were received\n");
mailbox_value = NOT_RECEIVED;
flag = ERROR;
rxerr=1;
break;
}
// Poll on scratch ring to check if packets have been received
if ((scratch_read_value = GET32(scratch_ring_rx)) == 0)
{
hal_delay_us(10);
ctr++;
}
}
while (scratch_read_value == 0);
if (flag == ERROR)
{
//break;
continue;
}
rx_count++;
pkt_size = scratch_read_value & MASK_8BIT;
rx_port_num = (scratch_read_value >> 8) & MASK_8BIT;
dram_addr = DRAM_BASE_DEST + ((scratch_read_value >> 16) << 8);
// set the port on which packet was received.
pass_port[rx_port_num]++;
rxflag[rx_port_num] = OK;
if (ports == 4)
{
exp_pkt_sz = tx_data_pl[((combination * 4) + port_num)] & 0xFFFF;
//eprintf("pkt size from pktptr: %d\n",exp_pkt_sz);
}
else
{
exp_pkt_sz = pktptr[combination] & 0xFFFF;
}
}
}
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;
}
switch(test_param)
{
case 'r':
case 't': expected_num_pkts = counter * 0;
break;
default: expected_num_pkts = counter * 9;
break;
}
switch(ports)
{
case 0:
case 1:
case 2:
case 3: if (!cflag)
{
if (pass_port[ports] != expected_num_pkts)
{
//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;
//eprintf("70. FLAG == ERROR");
}
else
{
eprintf("\nReceived on Port %d : %d\n",ports,pass_port[ports]);
flag = OK;
}
}
else
{
if (pass_port[rxport[ports]] != expected_num_pkts) {
//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;
//eprintf("70. FLAG == ERROR");
}
else
{
eprintf("\nReceived on Port %d : %d\n",rxport[ports],pass_port[rxport[ports]]);
flag = OK;
}
}
break;
case 4: //eprintf("4 ports : %d\n",ports);
eprintf("\n");
if (!cflag)
{
for (ctr=0; ctr<4; ctr++)
{
if (pass_port[ctr] != expected_num_pkts)
{
eprintf("Packets Received = %d on port %d\n",pass_port[ctr],ctr);
rxflag[ctr] = ERROR;
//flag = ERROR;
if ((exp_port_num ==4) || (test_param == 't'))
act_port_num |= 1 << ctr;
else
act_port_num = ctr;
}
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 (exp_port_num==4)
act_port_num |= 1<<ctr;
else
act_port_num = ctr*2+1;
}
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);
flag = OK;
}
}
}
break;
default: eprintf("This is bad value for port number \n");
break;
}
}
eprintf("\n");
if(dcache_status != 0) // if dcache was originally ON
{
dcache_on();
}
if (loop == 0)
loop = loop_count;
if (test_param == 'r')
{
if ((act_port_num == exp_port_num ) && (flag == ERROR))
{
flag = OK;
}
if ((exp_port_num == 4) && (act_port_num == 0xF) && (flag == ERROR))
{
flag = OK;
}
if (cflag && (ports == 4) && (act_port_num == 0x3) )
{
flag = OK;
}
}
if (test_param == 't')
{
if ((!cflag && (act_port_num == 0xF)) || (cflag && ((act_port_num == 0x1) || (act_port_num == 0x3))))
flag = OK;
}
if (flag == OK)
{
switch(test_param)
{
case 't':
eprintf("Tx FIFO Reset test...PASSED\n");
break;
case 'r':
eprintf("Rx FIFO Reset test...PASSED\n");
break;
default:
eprintf("Invalid parameters. \n");
return INVALID_PARAMETERS;
}
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");
}
/* get statistics from Vallejo */
//get_stats();
switch(test_param)
{
case 't':
eprintf("Tx FIFO Reset test...FAILED\n");
strcpy(syslog.desc, "Tx FIFO Reset FAILED!");
break;
case 'r':
eprintf("Rx FIFO Reset test...FAILED\n");
strcpy(syslog.desc, "Rx FIFO Reset FAILED!");
break;
default:
eprintf("Invalid parameters. \n");
return INVALID_PARAMETERS;
}
// prepare structure for dumping
syslog.type = TYPE_ERROR;
syslog.source_comp = MASTER_DIAG; // Determine master/slave
// 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();
}
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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -