Commit 2a7a2689 authored by 's avatar

Combo6x: reporting received and dropped packets in mapi_stats.


git-svn-id: file:///home/svn/mapi/trunk@1538 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent e7f928f3
......@@ -333,4 +333,70 @@ __attribute__ ((destructor))
printf ("Combo6 driver unloaded\n");
}
void pktdrop(combo6_instance_t *i) {
char buf[BUFSIZ];
FILE *pipe;
unsigned int hfe_x0_clas = 0;
unsigned int hfe_x1_clas = 0;
unsigned int crossbar2_trim_unit = 0;
unsigned int failed = 0;
if(pipe = popen("csbus 018C0008", "r")) {
if(fgets(buf, BUFSIZ, pipe) != NULL) {
if(!sscanf(buf, "%x", &hfe_x0_clas)) failed = 1;
}
else failed = 1;
pclose(pipe);
}
else failed = 1;
if(pipe = popen("csbus 018C000C", "r")) {
if(fgets(buf, BUFSIZ, pipe) != NULL) {
if(!sscanf(buf, "%x", &hfe_x1_clas)) failed = 1;;
}
else failed = 1;
pclose(pipe);
}
else failed = 1;
if(pipe = popen("csbus 018C8014", "r")) {
if(fgets(buf, BUFSIZ, pipe) != NULL) {
if(!sscanf(buf, "%x", &crossbar2_trim_unit)) failed = 1;
}
else failed = 1;
pclose(pipe);
}
else failed = 1;
if(!failed) {
i->hwinfo.pkts = hfe_x0_clas + hfe_x1_clas;
i->hwinfo.pkt_drop = hfe_x0_clas + hfe_x1_clas - crossbar2_trim_unit;
}
else {
DEBUG_CMD(Debug_Message("combo6drv: pktdrop failed"));;
}
}
int
mapidrv_stats (int devid, char **devtype, struct mapi_stat *stats)
{
DEBUG_CMD(Debug_Message("combo6drv: mapidrv_stats"));
combo6_instance_t *i=flist_get(devlist,devid);
*devtype=MAPI_DEVICE_SCAMPI;
if (i!=NULL)
{
pktdrop(i);
stats->ps_recv=i->hwinfo.pkts + i->hwinfo.pkt_drop;
stats->ps_drop=i->hwinfo.pkt_drop;
stats->ps_ifdrop=0;
return 0;
}
return MAPI_STATS_ERROR;
}
/* vim: set shiftwidth=2 tabstop=2 smarttab expandtab : */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment