From d13142b3daba5e76646cd36f718a1ff5ae9e25d4 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 28 Dec 2017 01:24:38 +0100 Subject: etheriwl, etherwpi: limit transmit queue buffer bloat to 48k (at 22Mbit ≅ 20ms) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sys/src/9/pc/etheriwl.c | 22 +++++++++++++++------- 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<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<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; } -- cgit v1.2.3