summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-09-30 16:16:20 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-09-30 16:16:20 +0200
commit2204bb732132fc98ad099da04e528968a91bfe87 (patch)
tree793add2704f014309058c9f06dc3cde760eaee97
parent5d64e428ebec115f9129a8f1de2f418e5418c8f4 (diff)
downloadplan9front-2204bb732132fc98ad099da04e528968a91bfe87.tar.xz
ether82557: timeout for ifstats DumpSC command
-rw-r--r--sys/src/9/pc/ether82557.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/sys/src/9/pc/ether82557.c b/sys/src/9/pc/ether82557.c
index b71909bbf..8a2bd9e4c 100644
--- a/sys/src/9/pc/ether82557.c
+++ b/sys/src/9/pc/ether82557.c
@@ -409,6 +409,10 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
ctlr = ether->ctlr;
lock(&ctlr->dlock);
+ if(waserror()){
+ unlock(&ctlr->dlock);
+ nexterror();
+ }
/*
* Start the command then
@@ -417,23 +421,25 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
*/
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]);
len += snprint(p+len, READSTR-len, "transmit maximum collisions errors: %lud\n", dump[1]);