📄 frsize_diag.c
字号:
hal_delay_us(100);
ctr++;
}
while (mailbox_value == 0);
}
if(dcache_status != 0) // if dcache was originally ON
{
dcache_on();
}
switch(test_param)
{
case 'j':
if (verify_stats(cflag))
test_passed = 1;
else
{
strcpy(syslog.desc, "\nRMON Big packets stat. test FAILED\n!");
eprintf("\nRMON Big packets stat. test FAILED\n!");
test_passed = 0;
}
break;
case 'l':
if (verify_error(cflag))
test_passed = 1;
else
{
strcpy(syslog.desc, "\nRMON LongError Register test FAILED\n!");
eprintf("\nRMON LongError Register test FAILED\n!");
test_passed = 0;
}
break;
case 'b':
if (verify_error(cflag))
test_passed = 1;
else
{
strcpy(syslog.desc, "\nRMON JabberError Register test FAILED\n!");
eprintf("\nRMON BLongError Register test FAILED\n!");
test_passed = 0;
}
break;
case 'c':
if (mailbox_value == TEST_COMPLETE)
{
test_passed = 1;
eprintf("Frame Size test...PASSED\n");
}
else
{
eprintf("\nFrame Size test...FAILED\n");
strcpy(syslog.desc, "Frame Size test FAIL!");
}
break;
default: eprintf("Invalid test parameter\n");
return ABORT;
}
if (!test_passed)
{
if (mailbox_value == SLAVE_MAILBOX0_NO_SIG)
{
eprintf("No signal was received from slave NPU to indicate completion\n");
}
else if (mailbox_value == ERROR_PATTERN)
{
eprintf("The packet received was not the same as the packet transmitted\n");
}
else if (mailbox_value == INCORRECT_SIZE)
{
eprintf("The packet received was not the same size as the packet transmitted\n");
}
else if (mailbox_value == SLAVE_MAILBOX1_NO_SIG)
{
eprintf("Slave NPU did not indicate that it received a packet\n");
}
else if (mailbox_value == NOT_SENT)
{
eprintf("Master NPU did not manage to transmit a packet\n");
}
else if (mailbox_value == NOT_RECEIVED)
{
eprintf("Slave NPU did not receive a packet\n");
}
else if (mailbox_value == RECEIVE_ERROR)
{
eprintf("Slave NPU receive a packet with an error\n");
}
else if (mailbox_value == INIT_ERROR)
{
eprintf("Slave NPU could not load its microcode and init\n");
}
// 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("LbkF");
slowport_code[0] = SP_XSC;
slowport_code[1] = SP_FAIL;
dump_slowport(slowport_code, 2, SP_NON_FATAL);
acL->Err = ERROR;
}
else
{
Set_LED("PASS");
slowport_code[0] = SP_XSC;
slowport_code[1] = SP_PASS;
dump_slowport(slowport_code, 2, SP_NON_FATAL);
}
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;
}
// ******************************************************************************
// Function: void PL_Media_Loopback_Slave(void)
//
// This function will be called by the PCI Doorbell Interrupt handler after the
// Master NPU initiates a PCI Doorbell Interrupt on the Slave NPU
// ******************************************************************************
void PL_Media_Loopback_Slave(void)
{
UINT32 ctr, port_ctr, flag, status, loop_count, forever, packet_num = 0, error=0, rx_port_num=0;
UINT32 dram_addr, lw1;
UINT32 packet_len, mailbox_value=0;
UINT32 get_ring_addr=0;
UINT dcache_status;
UINT32 *media_lb_data=0;
UINT32 pass_port[4],ports=0;
UINT32 mailbox2_val = 0,data=0;
UINT32 rxflag[4], temp =0,exp_pkt_sz=0;
UINT32 iteration = 0,port_num=0, per_port_pkts = 0,freebuffer = 0;
/***************************************************************************
** The rxport is to be indexed by the txport and the value is the corresponding rxport.
** Tx port Rxport
** 0 1
** 1 0
** 2 3
** 3 2
*********************************************************************************/
UINT32 rxport[4] = {1, 0, 3, 2};
UINT32 msg,orig_data_size=0,pnum=0, *pktptr=0;
short cflag = 0,combination=0;
flag = OK;
get_ring_addr = SCR_RING_INSTR_ADDR + (0 << 2);
Msf_OutOfReset();
status = Msf_PLL();
if (status == ERROR)
{
return;
}
dcache_status = get_CP15() & DCACHE_BIT;
if(dcache_status != 0) // if dcache ON
{
dcache_off();
}
/* initialize port array to 0 */
for (ctr = 0;ctr<4;ctr++)
{
pass_port[ctr] = 0;
rxflag[ctr] = ERROR;
}
msg = GET32(PCI_LOCAL_CSR_BASE + MAILBOX_2_OFF);
ports = msg & 0xFF;
cflag = msg >> 31;
loop_count = (msg >> 16) & 0x7FFF;
if (loop_count == 0)
{
forever = 1;
}
else
{
forever = 0;
}
flag = DownLoadUcode(PTLONE_MEDIA_LOOPBACK_RX_ME, sizeof(pl_media_lpbk_jumboFrame_rx), (UINT32 *)(pl_media_lpbk_jumboFrame_rx));
if (flag != OK)
eprintf("Error downloading microcode on slave on ME 0!\n");
hal_delay_us(1000);
makePkt(256);
makePkt(512);
makePkt(1024);
makePkt(1520);
makePkt(5*1024);
//makePkt(10*1024);
makePkt(11*1024);
iteration=get_pkt_seq(&pktptr, &pnum,cflag,ports);
while ((9*loop_count != per_port_pkts) || forever)
{
for (combination = 0; combination < pnum; combination++)
{
//for (port_num = 0; port_num < 4; port_num++)
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;
mailbox_value = 0;
do // Poll for completion of receive by ME
{
if (ctr == 50000) // After 3 seconds
{
eprintf("\nTimed out...packet not received on port %d\n",port_num);
mailbox_value = NOT_RECEIVED;
flag = ERROR;
rxflag[port_num] = ERROR;
break;
}
mailbox_value = GET32(get_ring_addr);
hal_delay_us(100);
ctr++;
}
while (mailbox_value == 0);
if (flag == ERROR)
{
break;
}
/* mailbox value = sram descriptor */
freebuffer = mailbox_value << 2;
data = GET32(freebuffer+CHANNEL1_BASE_ADDRESS);
rx_port_num = data >> 24;
packet_len = data & 0xFFFF;
//eprintf("Rx port = %d, packet length = 0x%x\n",rx_port_num,packet_len);
pass_port[rx_port_num] = 1;
rxflag[rx_port_num] = OK;
packet_num++;
//error = (mailbox_value >> 16) & 0xFF;
//packet_len = mailbox_value & MASK_16BIT;
if (error > 0)
{
if (error & 1)
{
eprintf("\nBit 10 (ABORT ERROR) of Receive Status Word set\n");
}
else if ((error >> 1) & 1)
{
eprintf("\nBit 11 (LENGTH ERROR) of Receive Status Word set\n");
}
else if ((error >> 2) & 1)
{
eprintf("\nBit 12 (PARITY ERROR) of Receive Status Word set\n");
}
mailbox_value = RECEIVE_ERROR;
flag = ERROR;
rxflag[rx_port_num] = ERROR;
break;
}
if (ports == 4)
{
exp_pkt_sz = fs_tx_data_pl[((combination * 4) + port_num)] & 0xFFFF;
}
else
{
exp_pkt_sz = pktptr[combination] & 0xFFFF;
}
dram_addr = ((freebuffer - SRAM_DESC_BASE) << 12) + DRAM_BASE_OFFSET;
if (packet_len != exp_pkt_sz)
{
eprintf("Received packet length = 0x%x\n",packet_len);
eprintf("Expected packet length = 0x%x\n",exp_pkt_sz);
mailbox_value = INCORRECT_SIZE;
flag = ERROR;
rxflag[rx_port_num] = ERROR;
break;
}
/* In this test, the same packet is used on all the 4 ports.
Hence a chack on cflag is not required. */
if ((packet_len == (RING_DATA_96_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_96_SZ;
media_lb_data = (UINT32 *)data96_0;
}
else if ((packet_len == (RING_DATA_64_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_64_SZ;
media_lb_data = (UINT32 *)data64_0;
}
else if ((packet_len == (RING_DATA_138_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_138_SZ;
media_lb_data = (UINT32 *)data138_0;
}
else if ((packet_len == (RING_DATA_256_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_256_SZ;
media_lb_data = (UINT32 *)data256_0;
}
else if ((packet_len == (RING_DATA_512_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_512_SZ;
media_lb_data = (UINT32 *)data512_0;
}
else if ((packet_len == (RING_DATA_1024_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_1024_SZ;
media_lb_data = (UINT32 *)data1024_0;
}
else if ((packet_len == (RING_DATA_1520_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_1520_SZ;
media_lb_data = (UINT32 *)data1520_0;
}
else if ((packet_len == (RING_DATA_5K_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_5K_SZ;
media_lb_data = (UINT32 *)data5K_0;
}
else if ((packet_len == (RING_DATA_10K_0 & MASK_16BIT)) && ((rx_port_num == 0) || (rx_port_num == 1)||(rx_port_num == 2)||(rx_port_num == 3)))
{
orig_data_size = PKT_10K_SZ;
media_lb_data = (UINT32 *)data10K_0;
}
else
{
eprintf("pkt size mismatch !! port = %d, packet len = 0x%x\n",rx_port_num,packet_len);
mailbox_value = NOT_COMPLETE;
flag = ERROR; // Set flag as error
rxflag[rx_port_num] = ERROR;
break;
}
for (ctr = 0; ctr < packet_len; ctr+=4)
{
lw1 = GET32(dram_addr + ctr);
//eprintf("2. dram_addr = 0x%08X val = 0x%08X\n",dram_addr, *((unsigned int *)(dram_addr)));
if (lw1 != media_lb_data[(ctr / 4)])
{
eprintf("ERROR: ctr=%d Orig=0x%08X Received=0x%08X\n", ctr, media_lb_data[(ctr / 4)], lw1);
eprintf("packet len = 0x%x\n",packet_len);
mailbox_value = ERROR_PATTERN;
flag = ERROR;
rxflag[rx_port_num] = ERROR;
break;
}
}
if(mailbox_value == ERROR_PATTERN)
{
eprintf("Port %d received a packet with pattern errors\n", rx_port_num);
break;
}
} // end of per port processing
if (flag == ERROR)
break;
} // combinations
switch(ports)
{
case 0:
case 1:
case 2:
case 3:
if (!cflag)
{
if (pass_port[ports] == 0)
{
eprintf("Did not Receive packet on port %d\n", ports);
flag = ERROR;
rxflag[ports] = ERROR;
}
}
else
{
if (pass_port[rx_port_num] == 0)
{
eprintf("Did not Receive packet on port %d\n", rx_port_num);
flag = ERROR;
rxflag[rxport[ports]] = ERROR;
}
}
break;
case 4:
if (!cflag)
{
for (ctr=0; ctr<4; ctr++)
{
if (pass_port[ctr] == 0)
{
eprintf("Did not Receive packet on port %d\n", ctr);
rxflag[ctr] = ERROR;
}
}
}
else
{
for (ctr=0; ctr<2; ctr++)
{
if (pass_port[ctr*2+1] == 0)
{
eprintf("Did not Receive packet on port %d\n", ctr*2+1);
rxflag[ctr*2+1] = ERROR;
}
}
}
break;
default: eprintf("This is bad value for port number \n");
break;
}
if (flag == ERROR)
break;
for (ctr =0;ctr <4; ctr ++)
{
if (rxflag[ctr] == OK)
temp ++;
}
if ((ports >=0) && (ports <=3))
{
if (!cflag)
{
if (rxflag[ports] == OK)
{
flag = OK;
}
else
{
flag = ERROR;
}
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -