diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-10 09:04:05 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-10 09:04:05 +0200 |
commit | b5655b7247a657bd4b590218a68ed99bbab318f6 (patch) | |
tree | c1abbf0fb9b06ca100f857581d1254be5493d237 /sys/src/9/pc/wifi.c | |
parent | 4ec93f94c92eec46433a962eb0f86b6f27909e6c (diff) |
wifi: adjust transmit rate on error (for etheriwl), small mkfile changes
Wnode gets two new counters: txcount and txerror
and actrate pointer that will be between minrate
and maxrate.
driver should use actrate instead of maxrate for
transmission when it can provide error feedback.
when a driver detects a transmission failed, it calls
wifitxfail() with the original packet. wifitxfail() then
reduces wn->actrate.
every 256th packet, we optimistically increase wn->actrate
before transmitting.
Diffstat (limited to 'sys/src/9/pc/wifi.c')
-rw-r--r-- | sys/src/9/pc/wifi.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/sys/src/9/pc/wifi.c b/sys/src/9/pc/wifi.c index 4b9b3639d..77d2deb96 100644 --- a/sys/src/9/pc/wifi.c +++ b/sys/src/9/pc/wifi.c @@ -156,11 +156,18 @@ wifitx(Wifi *wifi, Wnode *wn, Block *b) w->seq[0] = seq; w->seq[1] = seq>>8; - if((w->fc[0] & 0x0c) != 0x00) + if((w->fc[0] & 0x0c) != 0x00){ b = wifiencrypt(wifi, wn, b); + if(b == nil) + return; + } + + if((wn->txcount++ & 255) == 255){ + if(wn->actrate != nil && wn->actrate < wn->maxrate) + wn->actrate++; + } - if(b != nil) - (*wifi->transmit)(wifi, wn, b); + (*wifi->transmit)(wifi, wn, b); } static Wnode* @@ -196,6 +203,23 @@ nodelookup(Wifi *wifi, uchar *bssid, int new) return nn; } +void +wifitxfail(Wifi *wifi, Block *b) +{ + Wifipkt *w; + Wnode *wn; + + if(b == nil) + return; + w = (Wifipkt*)b->rp; + wn = nodelookup(wifi, w->a1, 0); + if(wn == nil) + return; + wn->txerror++; + if(wn->actrate != nil && wn->actrate > wn->minrate) + wn->actrate--; +} + static uchar* putrates(uchar *p, uchar *rates) { @@ -417,6 +441,7 @@ recvbeacon(Wifi *wifi, Wnode *wn, uchar *d, int len) break; } } + wn->actrate = wn->maxrate; } break; case 3: /* DSPARAMS */ |