ref: 4b8d6b808552c5e1c5a832aab06d14fddbe5032e
parent: f585c54bf108dac970f5ca891e21d03479f7a9f5
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sun Sep 30 12:16:20 EDT 2012
ether82557: timeout for ifstats DumpSC command
--- a/sys/src/9/pc/ether82557.c
+++ b/sys/src/9/pc/ether82557.c
@@ -409,6 +409,10 @@
ctlr = ether->ctlr;
lock(&ctlr->dlock);
+ if(waserror()){+ unlock(&ctlr->dlock);
+ nexterror();
+ }
/*
* Start the command then
@@ -417,22 +421,24 @@
*/
ctlr->dump[16] = 0;
command(ctlr, DumpSC, 0);
- while(ctlr->dump[16] == 0)
- ;
+ for(i = 0; i < 1000 && ctlr->dump[16] == 0; i++)
+ microdelay(100);
+ if(i == 1000)
+ error("command timeout");- ether->oerrs = ctlr->dump[1]+ctlr->dump[2]+ctlr->dump[3];
- ether->crcs = ctlr->dump[10];
- ether->frames = ctlr->dump[11];
- ether->buffs = ctlr->dump[12]+ctlr->dump[15];
- ether->overflows = ctlr->dump[13];
+ memmove(dump, ctlr->dump, sizeof(dump));
- if(n == 0){- unlock(&ctlr->dlock);
- return 0;
- }
+ ether->oerrs = dump[1]+dump[2]+dump[3];
+ ether->crcs = dump[10];
+ ether->frames = dump[11];
+ ether->buffs = dump[12]+dump[15];
+ ether->overflows = dump[13];
- memmove(dump, ctlr->dump, sizeof(dump));
+ poperror();
unlock(&ctlr->dlock);
+
+ if(n == 0)
+ return 0;
p = smalloc(READSTR);
len = snprint(p, READSTR, "transmit good frames: %lud\n", dump[0]);
--
⑨