ref: 45d01d9c99a423248687fc330ca028f2be4afae1
parent: 7d4a1e3643caa658ee40271edb0dc9a48fd50b58
author: cinap_lenrek <[email protected]>
date: Mon Feb 13 17:26:38 EST 2017
wifi: handle short preamble and short time slot capabilities - drivers enable short preamble and sort timeslot depending on the ap beacon capinfo field (bss->cap) - wifi sets short preamble bit in capinfo on association request - wifi sets short timeslot bit when ap advertized it in beacon
--- a/sys/src/9/pc/etheriwl.c
+++ b/sys/src/9/pc/etheriwl.c
@@ -1845,7 +1845,12 @@
ctlr->channel = bss->channel;
bss = nil;
}
+ flags = RFlagTSF | RFlagCTSToSelf | RFlag24Ghz | RFlagAuto;
if(bss != nil){
+ if(bss->cap & (1<<5))
+ flags |= RFlagShPreamble;
+ if(bss->cap & (1<<10))
+ flags |= RFlagShSlot;
ctlr->channel = bss->channel;
memmove(ctlr->bssid, bss->bssid, Eaddrlen);
ctlr->aid = bss->aid;
@@ -1861,7 +1866,6 @@
ctlr->bcastnodeid = -1;
ctlr->bssnodeid = -1;
}
- flags = RFlagTSF | RFlagCTSToSelf | RFlag24Ghz | RFlagAuto;
if(ctlr->aid != 0)
setled(ctlr, 2, 0, 1); /* on when associated */
--- a/sys/src/9/pc/etherrt2860.c
+++ b/sys/src/9/pc/etherrt2860.c
@@ -1318,10 +1318,12 @@
{
u32int tmp;
Ctlr *ctlr;
+ int cap;
ctlr = edev->ctlr;
if(bss != nil){
+ cap = bss->cap;
ctlr->channel = bss->channel;
memmove(ctlr->bssid, bss->bssid, Eaddrlen);
ctlr->aid = bss->aid;
@@ -1332,6 +1334,7 @@
}else
ctlr->bcastnodeid = -1;
}else{
+ cap = 0;
memmove(ctlr->bssid, edev->bcast, Eaddrlen);
ctlr->aid = 0;
ctlr->bcastnodeid = -1;
@@ -1377,14 +1380,13 @@
/* update slot */
tmp = csr32r(ctlr, BkoffSlotCfg);
tmp &= ~0xff;
- tmp |= /* (ic->ic_flags & IEEE80211_F_SHSLOT) ? 9 : */ 20;
+ tmp |= (cap & (1<<10)) ? 9 : 20;
csr32w(ctlr, BkoffSlotCfg, tmp);
/* set TX preamble */
tmp = csr32r(ctlr, AutoRspCfg);
tmp &= ~CckShortEn;
-/* if(sc->sc_ic.ic_flags & IEEE80211_F_SHPREAMBLE)
- tmp |= CckShortEn; */
+ if(cap & (1<<5)) tmp |= CckShortEn;
csr32w(ctlr, AutoRspCfg, tmp);
/* set basic rates */
--- a/sys/src/9/pc/etherwpi.c
+++ b/sys/src/9/pc/etherwpi.c
@@ -1304,7 +1304,12 @@
ctlr->channel = bss->channel;
bss = nil;
}
+ flags = RFlagTSF | RFlag24Ghz | RFlagAuto;
if(bss != nil){
+ if(bss->cap & (1<<5))
+ flags |= RFlagShPreamble;
+ if(bss->cap & (1<<10))
+ flags |= RFlagShSlot;
ctlr->channel = bss->channel;
memmove(ctlr->bssid, bss->bssid, Eaddrlen);
ctlr->aid = bss->aid;
@@ -1319,7 +1324,6 @@
ctlr->bcastnodeid = -1;
ctlr->bssnodeid = -1;
}
- flags = RFlagTSF | RFlag24Ghz | RFlagAuto;
if(ctlr->aid != 0)
setled(ctlr, 2, 0, 1); /* on when associated */
--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -320,7 +320,7 @@
Wifipkt *w;
Block *b;
uchar *p;
- int n;
+ int cap, n;
b = allocb(WIFIHDRSIZE + 512);
w = (Wifipkt*)b->wp;
@@ -331,9 +331,16 @@
memmove(w->a3, bss->bssid, Eaddrlen);
b->wp += WIFIHDRSIZE;
p = b->wp;
- *p++ = 1; /* capinfo */
- *p++ = 0;
- *p++ = 16; /* interval */
+
+ /* capinfo */
+ cap = 1; // ESS
+ cap |= (1<<5); // Short Preamble
+ cap |= (1<<10) & bss->cap; // Short Slot Time
+ *p++ = cap;
+ *p++ = cap>>8;
+
+ /* interval */
+ *p++ = 16;
*p++ = 16>>8;
n = strlen(bss->ssid);