diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-12-28 01:24:38 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-12-28 01:24:38 +0100 |
commit | d13142b3daba5e76646cd36f718a1ff5ae9e25d4 (patch) | |
tree | 8f4bdd5e633438ff1062a1b477e9f618960fd830 /sys/src/9 | |
parent | ce9cc8a358cad7be3561554a7ebfd06f7af5360f (diff) |
etheriwl, etherwpi: limit transmit queue buffer bloat to 48k (at 22Mbit ≅ 20ms)
Diffstat (limited to 'sys/src/9')
-rw-r--r-- | sys/src/9/pc/etheriwl.c | 22 | ||||
-rw-r--r-- | sys/src/9/pc/etherwpi.c | 37 |
2 files changed, 38 insertions, 21 deletions
diff --git a/sys/src/9/pc/etheriwl.c b/sys/src/9/pc/etheriwl.c index 8fa3078d8..34be54337 100644 --- a/sys/src/9/pc/etheriwl.c +++ b/sys/src/9/pc/etheriwl.c @@ -19,8 +19,12 @@ #include "wifi.h" enum { + MaxQueue = 24*1024, /* total buffer is 2*MaxQueue: 48k at 22Mbit ≅ 20ms */ + Ntxlog = 8, Ntx = 1<<Ntxlog, + Ntxqmax = MaxQueue/1500, + Nrxlog = 8, Nrx = 1<<Nrxlog, @@ -1666,7 +1670,7 @@ static int txqready(void *arg) { TXQ *q = arg; - return q->n < Ntx; + return q->n < Ntxqmax; } static char* @@ -1680,11 +1684,11 @@ qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block) ilock(ctlr); q = &ctlr->tx[qid]; - while(q->n >= Ntx && !ctlr->broken){ + while(q->n >= Ntxqmax && !ctlr->broken){ iunlock(ctlr); qlock(q); if(!waserror()){ - tsleep(q, txqready, q, 10); + tsleep(q, txqready, q, 5); poperror(); } qunlock(q); @@ -1929,6 +1933,7 @@ static struct ratetab { { 4, 20, RFlagCCK }, { 11, 55, RFlagCCK }, { 22, 110, RFlagCCK }, + { 12, 0xd, 0 }, { 18, 0xf, 0 }, { 24, 0x5, 0 }, @@ -1945,6 +1950,7 @@ static uchar iwlrates[] = { 0x80 | 4, 0x80 | 11, 0x80 | 22, + 0x80 | 12, 0x80 | 18, 0x80 | 24, @@ -2026,12 +2032,12 @@ transmit(Wifi *wifi, Wnode *wn, Block *b) flags |= TFlagFullTxOp; } } + if(p >= wifi->rates) + rate = p - wifi->rates; + else + rate = 0; qunlock(ctlr); - rate = 0; - if(p >= iwlrates && p < &iwlrates[nelem(ratetab)]) - rate = p - iwlrates; - /* select first available antenna */ ant = ctlr->rfcfg.txantmask & 7; ant |= (ant == 0); @@ -2192,6 +2198,8 @@ iwlattach(Ether *edev) error("wifi disabled by switch"); if(ctlr->wifi == nil){ + qsetlimit(edev->oq, MaxQueue); + ctlr->wifi = wifiattach(edev, transmit); /* tested with 2230, it has transmit issues using higher bit rates */ if(ctlr->type != Type2030) diff --git a/sys/src/9/pc/etherwpi.c b/sys/src/9/pc/etherwpi.c index 1663eb31b..b86a51c5f 100644 --- a/sys/src/9/pc/etherwpi.c +++ b/sys/src/9/pc/etherwpi.c @@ -11,15 +11,20 @@ #include "wifi.h" enum { - Nrxlog = 6, - Nrx = 1<<Nrxlog, - Ntx = 256, + MaxQueue = 24*1024, /* total buffer is 2*MaxQueue: 48k at 22Mbit ≅ 20ms */ - Rbufsize = 3*1024, - Rdscsize = 8, + Ntxlog = 8, + Ntx = 1<<Ntxlog, + Ntxqmax = MaxQueue/1500, - Tdscsize = 64, - Tcmdsize = 128, + Nrxlog = 6, + Nrx = 1<<Nrxlog, + + Rbufsize = 3*1024, + Rdscsize = 8, + + Tdscsize = 64, + Tcmdsize = 128, }; /* registers */ @@ -956,7 +961,7 @@ static int txqready(void *arg) { TXQ *q = arg; - return q->n < Ntx; + return q->n < Ntxqmax; } static char* @@ -971,11 +976,11 @@ qcmd(Ctlr *ctlr, uint qid, uint code, uchar *data, int size, Block *block) ilock(ctlr); q = &ctlr->tx[qid]; - while(q->n >= Ntx && !ctlr->broken){ + while(q->n >= Ntxqmax && !ctlr->broken){ iunlock(ctlr); qlock(q); if(!waserror()){ - tsleep(q, txqready, q, 10); + tsleep(q, txqready, q, 5); poperror(); } qunlock(q); @@ -1144,6 +1149,7 @@ static uchar wpirates[] = { 0x80 | 72, 0x80 | 96, 0x80 | 108, + 0x80 | 2, 0x80 | 4, 0x80 | 11, @@ -1164,6 +1170,7 @@ static struct { { 72, 0xb }, { 96, 0x1 }, { 108, 0x3 }, + { 2, 10 }, { 4, 20 }, { 11, 55 }, @@ -1436,12 +1443,12 @@ transmit(Wifi *wifi, Wnode *wn, Block *b) p = wn->actrate; } } + if(p >= wifi->rates) + rate = p - wifi->rates; + else + rate = 0; qunlock(ctlr); - rate = 0; - if(p >= wpirates && p < &wpirates[nelem(ratetab)]) - rate = p - wpirates; - memset(p = c, 0, sizeof(c)); put16(p, BLEN(b)), p += 2; put16(p, 0), p += 2; /* lnext */ @@ -1582,6 +1589,8 @@ wpiattach(Ether *edev) error("wifi disabled by switch"); if(ctlr->wifi == nil){ + qsetlimit(edev->oq, MaxQueue); + ctlr->wifi = wifiattach(edev, transmit); ctlr->wifi->rates = wpirates; } |