📄 ge_eventstatistic.c
字号:
{
GE_EventReport( 4, 0,REPORT_LINE_STATE,NET_PORT_UP);
netIf[0].adminStatus=NET_PORT_UP;
}
if(netIf[1].adminStatus==NET_PORT_DOWN)
{
GE_EventReport( 4, 1,REPORT_LINE_STATE,NET_PORT_UP);
netIf[1].adminStatus=NET_PORT_UP;
}
}
break;
case SYS_PORT_STAT_REQUEST:
GE_PortStatRead();
if(GE_PortStatReport()==ERROR)
{
break;
}
break;
default:
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_EventStatistic:recive msg type %d invalid!\n",EventStatisticMsg.type);
break;
}
}
}
return OK;
}
/*******************************************************************************************/
STATUS GE_UnitStatRead(unsigned char unit)
{
infpgaWrite(0x18,0x40+GE_swiport);
switch(unit)
{
case 0:
StatUMsg[0].RX_OCT.low32 = PM3386Read(0x51C)+ (PM3386Read(0x51D)<<16);
StatUMsg[0].RX_OCT.high32 = PM3386Read(0x51e);
StatUMsg[0].RX_UNI_CNT= (PM3386Read(0x521)<<16)+PM3386Read(0x520);
StatUMsg[0].RX_MUI_CNT= (PM3386Read(0x525)<<16)+PM3386Read(0x524);
StatUMsg[0].RX_BRO_CNT= (PM3386Read(0x529)<<16)+PM3386Read(0x528);
StatUMsg[0].RX_ERR_CNT= (PM3386Read(0x519)<<16)+PM3386Read(0x518)- ((PM3386Read(0x511)<<16)+PM3386Read(0x510));
StatUMsg[0].RX_UREC_CNT= infpgaRead(0x3)/2;
StatUMsg[0].TX_OCT.low32 = (PM3386Read(0x599)<<16)+PM3386Read(0x598);
StatUMsg[0].TX_OCT.high32 = PM3386Read(0x59a);
StatUMsg[0].TX_UNI_CNT= (PM3386Read(0x5a5)<<16)+PM3386Read(0x5a4);
StatUMsg[0].TX_MUI_CNT = PM3386Read(0x5ac)+ (PM3386Read(0x5ad)<<16);
StatUMsg[0].TX_BRO_CNT = PM3386Read(0x5b4)+ (PM3386Read(0x5b5)<<16);
StatUMsg[0].TX_ERR_CNT = (PM3386Read(0x599)<<16)+PM3386Read(0x598)- ((PM3386Read(0x595)<<16)+PM3386Read(0x594));
StatUMsg[0].FCS_ERR_CNT =(PM3386Read(0x539)<<16)+PM3386Read(0x538);
StatUMsg[0].TOO_LONG_CNT = PM3386Read(0x54c)+ (PM3386Read(0x54d)<<16);
StatUMsg[0].SYM_ERR_CNT = (PM3386Read(0x541)<<16)+PM3386Read(0x540);
bcopy((char*)&arpInfo[0],(char*)&StatUMsg + 40 ,20);
break;
case 1:
StatUMsg[0].RX_OCT.low32 = PM3386Read(0x61C)+ (PM3386Read(0x61D)<<16);
StatUMsg[1].RX_OCT.high32 = PM3386Read(0x61e);
StatUMsg[1].RX_UNI_CNT= (PM3386Read(0x621)<<16)+PM3386Read(0x620);
StatUMsg[1].RX_MUI_CNT= (PM3386Read(0x625)<<16)+PM3386Read(0x624);
StatUMsg[1].RX_BRO_CNT= (PM3386Read(0x629)<<16)+PM3386Read(0x628);
StatUMsg[1].RX_ERR_CNT= (PM3386Read(0x619)<<16)+PM3386Read(0x618)- ((PM3386Read(0x611)<<16)+PM3386Read(0x610));
StatUMsg[1].RX_UREC_CNT= infpgaRead(0x3)/2;
StatUMsg[1].TX_OCT.low32 = (PM3386Read(0x699)<<16)+PM3386Read(0x698);
StatUMsg[1].TX_OCT.high32 = PM3386Read(0x69a);
StatUMsg[1].TX_UNI_CNT = (PM3386Read(0x6a5)<<16)+PM3386Read(0x6a4);
StatUMsg[1].TX_MUI_CNT= PM3386Read(0x6ac)+ (PM3386Read(0x6ad)<<16);
StatUMsg[1].TX_BRO_CNT= PM3386Read(0x6b4)+ (PM3386Read(0x6b5)<<16);
StatUMsg[1].TX_ERR_CNT = (PM3386Read(0x699)<<16)+PM3386Read(0x698)- ((PM3386Read(0x695)<<16)+PM3386Read(0x694));
StatUMsg[1].FCS_ERR_CNT =(PM3386Read(0x639)<<16)+PM3386Read(0x638);
StatUMsg[1].TOO_LONG_CNT = PM3386Read(0x64c)+ (PM3386Read(0x64d)<<16);
StatUMsg[1].SYM_ERR_CNT = (PM3386Read(0x641)<<16)+PM3386Read(0x640);
bcopy((char*)&arpInfo[1],(char*)&StatUMsg + 40,20);
break;
}
return OK;
}
/*******************************************************************************************/
STATUS GE_PortStatRead ()
{
if(GE_STAT_DEBUG)
GE_printf(GE_EVENT,"GE_StatisticRead : is reading hardware statistics data...\n");
infpgaWrite(0x18,0x40+GE_swiport);
StatPMsg.if_in_packet_num=infpgaRead(0x01);
StatPMsg.if_in_Oceets=infpgaRead(0x02)*4;
StatPMsg.if_in_unRec_discard_num=infpgaRead(0x03);
StatPMsg.if_in_ip_packet_num=infpgaRead(0x04);
StatPMsg.if_in_arp_packet_num=infpgaRead(0x05);
StatPMsg.if_in_mpls_packet_num=infpgaRead(0x06);
StatPMsg.if_to_pro_packet_num = infpgaRead(0x7);
StatPMsg.if_to_pro_oceets = infpgaRead(0x8)*4;
StatPMsg.if_to_pro_full_discard_num = infpgaRead(0x09);
StatPMsg.if_to_B_packet_num=infpgaRead(0x0A);
StatPMsg.if_to_B_oceets=infpgaRead(0x0B)*8;
StatPMsg.if_to_B_full_discard_num=infpgaRead(0x0C);
if(GE_STAT_DEBUG)
{
GE_printf(GE_DATA,"\n**********************infpga statistic data***************************\n");
GE_printf(GE_DATA,"if_in_Oceets %lx\n",StatPMsg.if_in_Oceets);
GE_printf(GE_DATA,"if_in_packet_num %lx\n",StatPMsg.if_in_packet_num);
GE_printf(GE_DATA,"if_in_ip_packet_num %lx\n",StatPMsg.if_in_ip_packet_num);
GE_printf(GE_DATA,"if_in_mpls_packet_num %lx\n",StatPMsg.if_in_mpls_packet_num);
GE_printf(GE_DATA,"if_in_arp_packet_num %lx\n",StatPMsg.if_in_arp_packet_num);
GE_printf(GE_DATA,"if_in_unRec_discard_num %lx\n",StatPMsg.if_in_unRec_discard_num);
GE_printf(GE_DATA,"if_to_B_packet_num %lx\n",StatPMsg.if_to_B_packet_num);
GE_printf(GE_DATA,"if_to_B_oceets %lx\n",StatPMsg.if_to_B_oceets);
GE_printf(GE_DATA,"if_to_B_full_discard_num %lx\n",StatPMsg.if_to_B_full_discard_num);
GE_printf(GE_DATA,"if_to_pro_packet_num %lx\n",StatPMsg.if_to_pro_packet_num);
GE_printf(GE_DATA,"if_to_pro_oceets %lx\n",StatPMsg.if_to_pro_oceets);
GE_printf(GE_DATA,"if_to_pro_full_discard_num %lx\n",StatPMsg.if_to_pro_full_discard_num);
}
outfpgaWrite(0x14,0x0);
StatPMsg.of_E_in_packet_num=outfpgaRead(0x20);
StatPMsg.of_E_in_oceets=outfpgaRead(0x21)*8;
StatPMsg.of_E_in_IP_packet_num=outfpgaRead(0x22);
StatPMsg.of_E_in_MPLS_packet_num=outfpgaRead(0x23);
StatPMsg.of_in_proFIFO_packet_num=outfpgaRead(0x24);
StatPMsg.of_in_reqFIFO_packet_num=outfpgaRead(0x25);
StatPMsg.of_to_PM3386_packet_num=outfpgaRead(0x26);
StatPMsg.of_to_PM3386_occeets=outfpgaRead(0x27)*4;
StatPMsg.of_PM3386_full_discard_num=outfpgaRead(0x28) + outfpgaRead(0x29);
if(GE_STAT_DEBUG)
{
GE_printf(GE_DATA,"\n**********************outfpga statistic data***************************\n");
GE_printf(GE_DATA,"of_E_in_packet_num %lx\n",StatPMsg.of_E_in_packet_num);
GE_printf(GE_DATA,"of_E_in_oceets %lx\n",StatPMsg.of_E_in_oceets);
GE_printf(GE_DATA,"of_E_in_IP_packet_num %lx\n",StatPMsg.of_E_in_IP_packet_num);
GE_printf(GE_DATA,"of_E_in_MPLS_packet_num %lx\n",StatPMsg.of_E_in_MPLS_packet_num);
GE_printf(GE_DATA,"of_in_proFIFO_packet_num %lx\n",StatPMsg.of_in_proFIFO_packet_num);
GE_printf(GE_DATA,"of_in_reqFIFO_packet_num %lx\n",StatPMsg.of_in_reqFIFO_packet_num);
GE_printf(GE_DATA,"of_to_PM3386_packet_num %lx\n",StatPMsg.of_to_PM3386_packet_num);
GE_printf(GE_DATA,"of_to_PM3386_occeets %lx\n",StatPMsg.of_to_PM3386_occeets);
GE_printf(GE_DATA,"of_PM3386_full_discard_num %lx\n",StatPMsg.of_PM3386_full_discard_num);
}
return OK;
}
/*report statistic data */
STATUS GE_PortStatReport()
{
MSG_STRUCTURE *pReport;
char *pBuf;
pBuf=(char*)malloc(12+9+sizeof(GE_PORT_STAT_STRUCTURE));
if (pBuf==NULL)
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_PortStatReport: memory alloc failed!\n");
return ERROR;
}
pReport=(MSG_STRUCTURE*)pBuf;
memset(pReport->blank,0,12);
pReport->type = SYS_PORT_STAT_REPLY;
pReport->length = 1+sizeof(GE_PORT_STAT_STRUCTURE);
pReport->data[0] = GE_swiport;
bcopy((char*)&StatPMsg,(char*)(&pReport->data[1]),sizeof(GE_PORT_STAT_STRUCTURE));
if(BDCOM_UpReceive( BDCOM_STREAM,
NO_WAIT,
MSG_PRI_NORMAL,
12 +9+sizeof(GE_PORT_STAT_STRUCTURE),
(UCHAR *) pReport,
12,
9+sizeof(GE_PORT_STAT_STRUCTURE) ) == ERROR )
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_PortStatReport:report the statistic data failed!\n");
free((void*)pBuf);
return ERROR;
}
else
{
if(GE_STAT_DEBUG)
GE_printf(GE_EVENT,"GE_PortStatReport:report the statistic data succeed!\n");
}
return OK;
}
STATUS GE_UnitStatReport(unsigned char unit)
{
MSG_STRUCTURE *pBuf;
pBuf=(MSG_STRUCTURE*)malloc(12+10+sizeof(GE_UNIT_STAT_STRUCTURE));
if (pBuf==NULL)
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_PortStatReport: memory alloc failed!\n");
return ERROR;
}
memset(pBuf->blank,0,12);
pBuf->type = SYS_STAT;
pBuf->length = 2+sizeof(GE_UNIT_STAT_STRUCTURE);
pBuf->data[0] = GE_swiport;
pBuf->data[1] = unit;
bcopy((char*)&StatUMsg,(char*)(&pBuf->data[2]),sizeof(GE_UNIT_STAT_STRUCTURE));
if(BDCOM_UpReceive( BDCOM_STREAM,
NO_WAIT,
MSG_PRI_NORMAL,
12 + 10+sizeof(GE_UNIT_STAT_STRUCTURE),
(UCHAR *) pBuf,
12,
10+sizeof(GE_UNIT_STAT_STRUCTURE)) == ERROR )
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_PortStatReport:report the statistic data failed!\n");
free((void*)pBuf);
return ERROR;
}
else
{
if(GE_STAT_DEBUG)
GE_printf(GE_EVENT,"GE_PortStatReport:report the statistic data succeed!\n");
}
return OK;
}
/*************************************************************************************************/
STATUS GE_EventReport( unsigned int len,
unsigned char lnPort,
unsigned char subType,
unsigned char result)
{
MSG_STRUCTURE* pEventMsg;
unsigned char *pBuf;
int taskId;
taskId=taskIdSelf();
pBuf=(char*)malloc(12+8+4);
if ( pBuf==NULL )
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_EventReport:memory allocation failed!\n");
return ERROR;
}
pEventMsg=(MSG_STRUCTURE*)pBuf;
memset(pEventMsg->blank,0,12);
pEventMsg->type = SYS_EVENT_REPORT;
pEventMsg->length =len;
pEventMsg->data[0] = subType;
pEventMsg->data[1] = GE_swiport;
pEventMsg->data[2] = lnPort;
pEventMsg->data[3] = result;
if (BDCOM_UpReceive ( BDCOM_STREAM,
NO_WAIT,
MSG_PRI_NORMAL,
12+4+8,
(UCHAR *) pEventMsg,
12,
12 ) ==ERROR)
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_EventReport: sending SYS_EVENT_REPORT to BDCOM failed!\n");
free((void*)pBuf);
return ERROR;
}
else
{
if(GE_STAT_DEBUG)
GE_printf(GE_EVENT,"GE_EventReport:task id is 0x%.8x send SYS_EVENT_REPORT-%d to BDCOM succeed!\n",taskId,subType);
}
return OK;
}
/*clear statistic result*/
void GE_StatisticZero ()
{
memset(&StatUMsg,0,sizeof(GE_PORT_STAT_STRUCTURE));
PM3386Write(0x500,0x2);
PM3386Write(0x600,0x2);
return;
}
/******************************************************************************************
*/
STATUS GE_SuspendEventStatistic()
{
if(taskSuspend((SBSL_TaskIdGet(GE_EVENTSTATIC_TASK_CODE)))==ERROR)
{
return ERROR;
}
if(SBSL_TaskStop(GE_EVENTSTATIC_TASK_CODE)==ERROR)
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_SuspendEventStatistic:suspendTask failed!\n");
return ERROR;
}
return OK;
}
STATUS GE_ResumeEventStatistic()
{
if(taskResume((SBSL_TaskIdGet(GE_EVENTSTATIC_TASK_CODE)))==ERROR)
{
return ERROR;
}
if(SBSL_TaskStart(GE_EVENTSTATIC_TASK_CODE,SBSL_TaskIdGet(GE_EVENTSTATIC_TASK_CODE))==ERROR)
{
if(GE_STAT_DEBUG)
GE_printf(GE_ALARM,"GE_ResumeEventStatistic:resumTask failed!\n");
return ERROR;
}
return OK;
}
/* end of file GE_EventStatistic.c */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -