📄 pad_diag.c
字号:
{
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_count ==0)
loop = loop_count;
if (verify_padding(cflag))
{
if (test_param == 'e')
eprintf("\nPadding test PASSED !\n");
else if (test_param == 'p')
eprintf("\nPre-pending test PASSED !\n");
else if (test_param == '5')
eprintf("\nRMON: Rx Runt stat. reg test PASSED !\n");
else if (test_param == '6')
eprintf("\nRMON: Rx Short stat. reg test PASSED !\n");
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 == SHORT_PKT_NOT_PADDED)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("Short packet was not padded to 64 byte length.\n");
}
else if (mailbox_value == PADDED_64_PKT)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("Error. 64 byte packet was padded.\n");
}
else if (mailbox_value == PADDED_138_PKT)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("Error. 138 byte packet was padded.\n");
}
else if (mailbox_value == PREPEND_FAILED)
{
eprintf("mailbox = 0x%x\n",mailbox_value);
eprintf("Error. 2 byte prepend failed.\n");
}
// prepare structure for dumping
syslog.type = TYPE_ERROR;
syslog.source_comp = MASTER_DIAG; // Determine master/slave
switch(test_param)
{
case 'e':
strcpy(syslog.desc, "\nPAD test FAILED!");
eprintf("PAD test FAILED!\n");
break;
case 'p':
strcpy(syslog.desc, "\nPrepending test FAILED!");
eprintf("Prepending test FAILED!");
break;
case '5':
strcpy(syslog.desc, "\nRMON: Rx Runt stat. reg test FAILED!");
eprintf("\nRMON: Rx Runt stat. reg test FAILED!");
break;
case '6':
strcpy(syslog.desc, "\nRMON: Rx Short stat. reg test FAILED!");
eprintf("\nRMON: Rx Short stat. reg test FAILED!");
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 verify_padding(short cflag)
{
int port=0,ctr=0,port_ctr=0,test_passed=1;
UINT32 rx64pkts[4], rx138pkts[4];
UINT32 tx64pkts[4], tx138pkts[4];
UINT32 Rxrunt[4],TxBad[4], RxShort[4];
short res=0, rxok=0,txok=0;
spConfig();
for(port=0; port<4;port++)
{
/* Reading the total packets received */
rx64pkts[port]=reg_read(((port*PORTSZ)+RX_PKTS_64));
rx138pkts[port]=reg_read(((port*PORTSZ)+RX_PKTS_128_255));
Rxrunt[port] = reg_read(((port*PORTSZ)+RUNT_ERR));
RxShort[port] = reg_read(((port*PORTSZ)+SHORT_ERR));
tx64pkts[port]=reg_read(((port*PORTSZ)+TX_PKTS_64));
tx138pkts[port]=reg_read(((port*PORTSZ)+TX_PKTS_128_255));
TxBad[port] = reg_read(((port*PORTSZ)+TX_OCTETS_BAD));
}
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: 64 byte packets received=0x%x\n",port,rx64pkts[port]);
eprintf("Port %d: 138 byte packets received=0x%x\n",port,rx138pkts[port]);
eprintf("Port %d: Runt Packets received 0x%x\n",port,Rxrunt[port]);
eprintf("Port %d: Short Packets received 0x%x\n",port,RxShort[port]);
if (cflag)
port = rxport[port];
eprintf("Port %d: 64 byte packets transmitted=0x%x\n",port,tx64pkts[port]);
eprintf("Port %d: 138 byte packets transmitted=0x%x\n",port,tx138pkts[port]);
eprintf("Port %d: Octets transmitted with Errors = 0x%x\n",port,TxBad[port]);
switch(test_param)
{
case 'e':
case 'p':
if (cflag)
port = rxport[port];
if ((rx64pkts[port] != (loop*PKTS_64)) ||
(rx138pkts[port] != (loop*PKTS_138)) ||
(Rxrunt[port] != (loop *EXP_BAD_PKTS)))
{
eprintf("Received frames with Padding Errors on port %d\n",port);
rxok = 0;
}
else
{
if ((rx64pkts[port] == 0) ||
(rx138pkts[port] == 0))
{
rxok = 0;
}
else
rxok = 1;
}
if (cflag)
port = rxport[port];
if ((tx64pkts[port] != (loop*PKTS_64)) ||
(tx138pkts[port] != (loop*PKTS_138)) ||
(TxBad[port] != (loop *EXP_BAD_PKTS)))
{
eprintf("Transmitted frames with Padding Errors on port %d\n",port);
txok = 0;
}
else
{
if ((tx64pkts[port] == 0) ||
(tx138pkts[port] == 0))
{
txok = 0;
}
else txok = 1;
}
if(rxok && txok)
res|= 1<<port_ctr;
break;
case '5':
if (cflag)
port = rxport[port];
if ((Rxrunt[port] == 3*loop) && (RxShort[port] == 0))
{
res|= 1<<port_ctr;
eprintf("RMON Runt frame stat. counter OK, port %d\n",port);
}
else
{
eprintf("RMON Runt frame stat. counter BAD, port %d\n",port);
res|= 0<<port_ctr;
}
break;
case '6':
if (cflag)
port = rxport[port];
if ((Rxrunt[port] == 0) && (RxShort[port] == 3*loop) && (RxShort[port] != 0))
{
res|= 1<<port_ctr;
eprintf("RMON Short frame stat. counter OK, port %d\n",port);
}
else
{
eprintf("RMON Short frame stat. counter BAD, port %d\n",port);
res|= 0<<port_ctr;
}
break;
}
}
if ((res == 0xF) && (ports == 0x4) && (!cflag))
test_passed = 1;
else
if ((res == 0x3) && (ports == 0x4) && cflag)
test_passed = 1;
else
if ((res == 0x1) && (ports != 0x4))
test_passed = 1;
else
test_passed = 0;
return test_passed;
}
void get_packets_for_pad_test(void)
{
pl_sys_lb_data64_0 = data64_0;
pl_sys_lb_data64_1 = data64_1;
pl_sys_lb_data64_2 = data64_2;
pl_sys_lb_data64_3 = data64_3;
if (test_param == '6') /* Rx Short reg. test */
{
/* use the same 48 byte frame for all ports */
pl_sys_lb_data96_0 = data4_0;
pl_sys_lb_data96_1 = data4_0;
pl_sys_lb_data96_2 = data4_0;
pl_sys_lb_data96_3 = data4_0;
}
else
{
/* use the same 48 byte frame for all ports */
pl_sys_lb_data96_0 = data48_0;
pl_sys_lb_data96_1 = data48_0;
pl_sys_lb_data96_2 = data48_0;
pl_sys_lb_data96_3 = data48_0;
}
pl_sys_lb_data138_0 = data138_0;
pl_sys_lb_data138_1 = data138_1;
pl_sys_lb_data138_2 = data138_2;
pl_sys_lb_data138_3 = data138_3;
}
void get_exp_pkt_sz(UINT32 * exp_sz)
{
UINT32 pkt_sz = *exp_sz;
switch (test_param)
{
case 'e': /* padding enabled */
if (pkt_sz == 0x2C)
pkt_sz = 0x3C;
break;
case 'p': /*pre-pending and padding enabled */
if ((pkt_sz == 0x2C) || (pkt_sz == 0x3C))
pkt_sz = 0x3C + 2;
if (pkt_sz == 0x84)
pkt_sz = 0x84 + 2;
break;
case '5': /* RMON runt/short stat reg */
/* Vallejo workaround for bacCRC append */
if (pkt_sz == 0x2C)
pkt_sz=0x30;
//if (pkt_sz == 0x3C)
// pkt_sz=0x84;
case '6': /* RMON runt/short stat reg */
/* Vallejo workaround for bacCRC append */
if (pkt_sz == 0x8)
pkt_sz=4;
}
*exp_sz = pkt_sz;
}
void get_error(UINT32 pkt_size, UINT32 exp_pkt_sz, UINT32 *mailbox_value)
{
switch (test_param)
{
case 'e':
if ((pkt_size == 0x2C) && (exp_pkt_sz == 0x3C))
*mailbox_value = SHORT_PKT_NOT_PADDED;
if ((pkt_size > 0x3C) && (pkt_size < 0x84) && (exp_pkt_sz == 0x3C))
*mailbox_value = PADDED_64_PKT;
if ((pkt_size > 0x84) && (exp_pkt_sz == 0x84))
*mailbox_value = PADDED_138_PKT;
break;
case 'p':
if ( (((pkt_size == 0x2C) || (pkt_size == 0x3C)) && (exp_pkt_sz == 0x3E))
|| ((pkt_size == 0x84) && (exp_pkt_sz == 0x86)) )
*mailbox_value = PREPEND_FAILED;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -