ieee80211_superg.c revision 248069
1190391Ssam/*- 2190391Ssam * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 3190391Ssam * All rights reserved. 4190391Ssam * 5190391Ssam * Redistribution and use in source and binary forms, with or without 6190391Ssam * modification, are permitted provided that the following conditions 7190391Ssam * are met: 8190391Ssam * 1. Redistributions of source code must retain the above copyright 9190391Ssam * notice, this list of conditions and the following disclaimer. 10190391Ssam * 2. Redistributions in binary form must reproduce the above copyright 11190391Ssam * notice, this list of conditions and the following disclaimer in the 12190391Ssam * documentation and/or other materials provided with the distribution. 13190391Ssam * 14190391Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15190391Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16190391Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17190391Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18190391Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19190391Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20190391Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21190391Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22190391Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23190391Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24190391Ssam */ 25190391Ssam 26190391Ssam#include <sys/cdefs.h> 27190391Ssam__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_superg.c 248069 2013-03-08 20:23:55Z adrian $"); 28190391Ssam 29190391Ssam#include "opt_wlan.h" 30190391Ssam 31246226Sadrian#ifdef IEEE80211_SUPPORT_SUPERG 32246226Sadrian 33190391Ssam#include <sys/param.h> 34190391Ssam#include <sys/systm.h> 35190391Ssam#include <sys/mbuf.h> 36190391Ssam#include <sys/kernel.h> 37190391Ssam#include <sys/endian.h> 38190391Ssam 39190391Ssam#include <sys/socket.h> 40190391Ssam 41190391Ssam#include <net/bpf.h> 42190391Ssam#include <net/ethernet.h> 43190391Ssam#include <net/if.h> 44190391Ssam#include <net/if_llc.h> 45190391Ssam#include <net/if_media.h> 46190391Ssam 47190391Ssam#include <net80211/ieee80211_var.h> 48190391Ssam#include <net80211/ieee80211_input.h> 49190391Ssam#include <net80211/ieee80211_phy.h> 50190391Ssam#include <net80211/ieee80211_superg.h> 51190391Ssam 52190455Ssam/* 53190455Ssam * Atheros fast-frame encapsulation format. 54190455Ssam * FF max payload: 55190455Ssam * 802.2 + FFHDR + HPAD + 802.3 + 802.2 + 1500 + SPAD + 802.3 + 802.2 + 1500: 56190455Ssam * 8 + 4 + 4 + 14 + 8 + 1500 + 6 + 14 + 8 + 1500 57190455Ssam * = 3066 58190455Ssam */ 59190455Ssam/* fast frame header is 32-bits */ 60190455Ssam#define ATH_FF_PROTO 0x0000003f /* protocol */ 61190455Ssam#define ATH_FF_PROTO_S 0 62190455Ssam#define ATH_FF_FTYPE 0x000000c0 /* frame type */ 63190455Ssam#define ATH_FF_FTYPE_S 6 64190455Ssam#define ATH_FF_HLEN32 0x00000300 /* optional hdr length */ 65190455Ssam#define ATH_FF_HLEN32_S 8 66190455Ssam#define ATH_FF_SEQNUM 0x001ffc00 /* sequence number */ 67190455Ssam#define ATH_FF_SEQNUM_S 10 68190455Ssam#define ATH_FF_OFFSET 0xffe00000 /* offset to 2nd payload */ 69190455Ssam#define ATH_FF_OFFSET_S 21 70190455Ssam 71190455Ssam#define ATH_FF_MAX_HDR_PAD 4 72190455Ssam#define ATH_FF_MAX_SEP_PAD 6 73190455Ssam#define ATH_FF_MAX_HDR 30 74190455Ssam 75190455Ssam#define ATH_FF_PROTO_L2TUNNEL 0 /* L2 tunnel protocol */ 76190455Ssam#define ATH_FF_ETH_TYPE 0x88bd /* Ether type for encapsulated frames */ 77190455Ssam#define ATH_FF_SNAP_ORGCODE_0 0x00 78190455Ssam#define ATH_FF_SNAP_ORGCODE_1 0x03 79190455Ssam#define ATH_FF_SNAP_ORGCODE_2 0x7f 80190455Ssam 81190579Ssam#define ATH_FF_TXQMIN 2 /* min txq depth for staging */ 82190579Ssam#define ATH_FF_TXQMAX 50 /* maximum # of queued frames allowed */ 83190579Ssam#define ATH_FF_STAGEMAX 5 /* max waiting period for staged frame*/ 84190579Ssam 85190391Ssam#define ETHER_HEADER_COPY(dst, src) \ 86190391Ssam memcpy(dst, src, sizeof(struct ether_header)) 87190391Ssam 88193115Ssamstatic int ieee80211_ffppsmin = 2; /* pps threshold for ff aggregation */ 89193115SsamSYSCTL_INT(_net_wlan, OID_AUTO, ffppsmin, CTLTYPE_INT | CTLFLAG_RW, 90193115Ssam &ieee80211_ffppsmin, 0, "min packet rate before fast-frame staging"); 91193115Ssamstatic int ieee80211_ffagemax = -1; /* max time frames held on stage q */ 92193115SsamSYSCTL_PROC(_net_wlan, OID_AUTO, ffagemax, CTLTYPE_INT | CTLFLAG_RW, 93193115Ssam &ieee80211_ffagemax, 0, ieee80211_sysctl_msecs_ticks, "I", 94193115Ssam "max hold time for fast-frame staging (ms)"); 95190579Ssam 96190391Ssamvoid 97190391Ssamieee80211_superg_attach(struct ieee80211com *ic) 98190391Ssam{ 99191753Ssam struct ieee80211_superg *sg; 100191753Ssam 101191753Ssam if (ic->ic_caps & IEEE80211_C_FF) { 102191753Ssam sg = (struct ieee80211_superg *) malloc( 103191753Ssam sizeof(struct ieee80211_superg), M_80211_VAP, 104191753Ssam M_NOWAIT | M_ZERO); 105191753Ssam if (sg == NULL) { 106191753Ssam printf("%s: cannot allocate SuperG state block\n", 107191753Ssam __func__); 108191753Ssam return; 109191753Ssam } 110191753Ssam ic->ic_superg = sg; 111191753Ssam } 112190579Ssam ieee80211_ffagemax = msecs_to_ticks(150); 113190391Ssam} 114190391Ssam 115190391Ssamvoid 116190391Ssamieee80211_superg_detach(struct ieee80211com *ic) 117190391Ssam{ 118191753Ssam if (ic->ic_superg != NULL) { 119191753Ssam free(ic->ic_superg, M_80211_VAP); 120191753Ssam ic->ic_superg = NULL; 121191753Ssam } 122190391Ssam} 123190391Ssam 124190391Ssamvoid 125190391Ssamieee80211_superg_vattach(struct ieee80211vap *vap) 126190391Ssam{ 127191753Ssam struct ieee80211com *ic = vap->iv_ic; 128191753Ssam 129191753Ssam if (ic->ic_superg == NULL) /* NB: can't do fast-frames w/o state */ 130191753Ssam vap->iv_caps &= ~IEEE80211_C_FF; 131190391Ssam if (vap->iv_caps & IEEE80211_C_FF) 132190391Ssam vap->iv_flags |= IEEE80211_F_FF; 133190450Ssam /* NB: we only implement sta mode */ 134190450Ssam if (vap->iv_opmode == IEEE80211_M_STA && 135190450Ssam (vap->iv_caps & IEEE80211_C_TURBOP)) 136190391Ssam vap->iv_flags |= IEEE80211_F_TURBOP; 137190391Ssam} 138190391Ssam 139190391Ssamvoid 140190391Ssamieee80211_superg_vdetach(struct ieee80211vap *vap) 141190391Ssam{ 142190391Ssam} 143190391Ssam 144190391Ssam#define ATH_OUI_BYTES 0x00, 0x03, 0x7f 145190391Ssam/* 146190391Ssam * Add a WME information element to a frame. 147190391Ssam */ 148190391Ssamuint8_t * 149190451Ssamieee80211_add_ath(uint8_t *frm, uint8_t caps, ieee80211_keyix defkeyix) 150190391Ssam{ 151190391Ssam static const struct ieee80211_ath_ie info = { 152190391Ssam .ath_id = IEEE80211_ELEMID_VENDOR, 153190391Ssam .ath_len = sizeof(struct ieee80211_ath_ie) - 2, 154190391Ssam .ath_oui = { ATH_OUI_BYTES }, 155190391Ssam .ath_oui_type = ATH_OUI_TYPE, 156190391Ssam .ath_oui_subtype= ATH_OUI_SUBTYPE, 157190391Ssam .ath_version = ATH_OUI_VERSION, 158190391Ssam }; 159190391Ssam struct ieee80211_ath_ie *ath = (struct ieee80211_ath_ie *) frm; 160190391Ssam 161190391Ssam memcpy(frm, &info, sizeof(info)); 162190391Ssam ath->ath_capability = caps; 163190451Ssam if (defkeyix != IEEE80211_KEYIX_NONE) { 164190451Ssam ath->ath_defkeyix[0] = (defkeyix & 0xff); 165190451Ssam ath->ath_defkeyix[1] = ((defkeyix >> 8) & 0xff); 166190451Ssam } else { 167190451Ssam ath->ath_defkeyix[0] = 0xff; 168190451Ssam ath->ath_defkeyix[1] = 0x7f; 169190451Ssam } 170190391Ssam return frm + sizeof(info); 171190391Ssam} 172190391Ssam#undef ATH_OUI_BYTES 173190391Ssam 174190451Ssamuint8_t * 175190451Ssamieee80211_add_athcaps(uint8_t *frm, const struct ieee80211_node *bss) 176190451Ssam{ 177190451Ssam const struct ieee80211vap *vap = bss->ni_vap; 178190451Ssam 179190451Ssam return ieee80211_add_ath(frm, 180190451Ssam vap->iv_flags & IEEE80211_F_ATHEROS, 181190451Ssam ((vap->iv_flags & IEEE80211_F_WPA) == 0 && 182190451Ssam bss->ni_authmode != IEEE80211_AUTH_8021X) ? 183190451Ssam vap->iv_def_txkey : IEEE80211_KEYIX_NONE); 184190451Ssam} 185190451Ssam 186190391Ssamvoid 187190391Ssamieee80211_parse_ath(struct ieee80211_node *ni, uint8_t *ie) 188190391Ssam{ 189190391Ssam const struct ieee80211_ath_ie *ath = 190190391Ssam (const struct ieee80211_ath_ie *) ie; 191190391Ssam 192190391Ssam ni->ni_ath_flags = ath->ath_capability; 193190391Ssam ni->ni_ath_defkeyix = LE_READ_2(&ath->ath_defkeyix); 194190391Ssam} 195190391Ssam 196190391Ssamint 197190391Ssamieee80211_parse_athparams(struct ieee80211_node *ni, uint8_t *frm, 198190391Ssam const struct ieee80211_frame *wh) 199190391Ssam{ 200190391Ssam struct ieee80211vap *vap = ni->ni_vap; 201190391Ssam const struct ieee80211_ath_ie *ath; 202190391Ssam u_int len = frm[1]; 203190391Ssam int capschanged; 204190391Ssam uint16_t defkeyix; 205190391Ssam 206190391Ssam if (len < sizeof(struct ieee80211_ath_ie)-2) { 207190391Ssam IEEE80211_DISCARD_IE(vap, 208190391Ssam IEEE80211_MSG_ELEMID | IEEE80211_MSG_SUPERG, 209190391Ssam wh, "Atheros", "too short, len %u", len); 210190391Ssam return -1; 211190391Ssam } 212190391Ssam ath = (const struct ieee80211_ath_ie *)frm; 213190391Ssam capschanged = (ni->ni_ath_flags != ath->ath_capability); 214190391Ssam defkeyix = LE_READ_2(ath->ath_defkeyix); 215190391Ssam if (capschanged || defkeyix != ni->ni_ath_defkeyix) { 216190391Ssam ni->ni_ath_flags = ath->ath_capability; 217190391Ssam ni->ni_ath_defkeyix = defkeyix; 218190391Ssam IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, 219190391Ssam "ath ie change: new caps 0x%x defkeyix 0x%x", 220190391Ssam ni->ni_ath_flags, ni->ni_ath_defkeyix); 221190391Ssam } 222190391Ssam if (IEEE80211_ATH_CAP(vap, ni, ATHEROS_CAP_TURBO_PRIME)) { 223190391Ssam uint16_t curflags, newflags; 224190391Ssam 225190391Ssam /* 226190391Ssam * Check for turbo mode switch. Calculate flags 227190391Ssam * for the new mode and effect the switch. 228190391Ssam */ 229190391Ssam newflags = curflags = vap->iv_ic->ic_bsschan->ic_flags; 230190391Ssam /* NB: BOOST is not in ic_flags, so get it from the ie */ 231190391Ssam if (ath->ath_capability & ATHEROS_CAP_BOOST) 232190391Ssam newflags |= IEEE80211_CHAN_TURBO; 233190391Ssam else 234190391Ssam newflags &= ~IEEE80211_CHAN_TURBO; 235190391Ssam if (newflags != curflags) 236190391Ssam ieee80211_dturbo_switch(vap, newflags); 237190391Ssam } 238190391Ssam return capschanged; 239190391Ssam} 240190391Ssam 241190391Ssam/* 242190391Ssam * Decap the encapsulated frame pair and dispatch the first 243190391Ssam * for delivery. The second frame is returned for delivery 244190391Ssam * via the normal path. 245190391Ssam */ 246190391Ssamstruct mbuf * 247190391Ssamieee80211_ff_decap(struct ieee80211_node *ni, struct mbuf *m) 248190391Ssam{ 249190391Ssam#define FF_LLC_SIZE (sizeof(struct ether_header) + sizeof(struct llc)) 250190391Ssam#define MS(x,f) (((x) & f) >> f##_S) 251190391Ssam struct ieee80211vap *vap = ni->ni_vap; 252190391Ssam struct llc *llc; 253190391Ssam uint32_t ath; 254190391Ssam struct mbuf *n; 255190391Ssam int framelen; 256190391Ssam 257190391Ssam /* NB: we assume caller does this check for us */ 258190391Ssam KASSERT(IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF), 259190391Ssam ("ff not negotiated")); 260190391Ssam /* 261190391Ssam * Check for fast-frame tunnel encapsulation. 262190391Ssam */ 263190391Ssam if (m->m_pkthdr.len < 3*FF_LLC_SIZE) 264190391Ssam return m; 265190391Ssam if (m->m_len < FF_LLC_SIZE && 266190391Ssam (m = m_pullup(m, FF_LLC_SIZE)) == NULL) { 267190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 268190391Ssam ni->ni_macaddr, "fast-frame", 269190391Ssam "%s", "m_pullup(llc) failed"); 270190391Ssam vap->iv_stats.is_rx_tooshort++; 271190391Ssam return NULL; 272190391Ssam } 273190391Ssam llc = (struct llc *)(mtod(m, uint8_t *) + 274190391Ssam sizeof(struct ether_header)); 275190391Ssam if (llc->llc_snap.ether_type != htons(ATH_FF_ETH_TYPE)) 276190391Ssam return m; 277190391Ssam m_adj(m, FF_LLC_SIZE); 278190391Ssam m_copydata(m, 0, sizeof(uint32_t), (caddr_t) &ath); 279190391Ssam if (MS(ath, ATH_FF_PROTO) != ATH_FF_PROTO_L2TUNNEL) { 280190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 281190391Ssam ni->ni_macaddr, "fast-frame", 282190391Ssam "unsupport tunnel protocol, header 0x%x", ath); 283190391Ssam vap->iv_stats.is_ff_badhdr++; 284190391Ssam m_freem(m); 285190391Ssam return NULL; 286190391Ssam } 287190391Ssam /* NB: skip header and alignment padding */ 288190391Ssam m_adj(m, roundup(sizeof(uint32_t) - 2, 4) + 2); 289190391Ssam 290190391Ssam vap->iv_stats.is_ff_decap++; 291190391Ssam 292190391Ssam /* 293190391Ssam * Decap the first frame, bust it apart from the 294190391Ssam * second and deliver; then decap the second frame 295190391Ssam * and return it to the caller for normal delivery. 296190391Ssam */ 297190391Ssam m = ieee80211_decap1(m, &framelen); 298190391Ssam if (m == NULL) { 299190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 300190391Ssam ni->ni_macaddr, "fast-frame", "%s", "first decap failed"); 301190391Ssam vap->iv_stats.is_ff_tooshort++; 302190391Ssam return NULL; 303190391Ssam } 304190391Ssam n = m_split(m, framelen, M_NOWAIT); 305190391Ssam if (n == NULL) { 306190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 307190391Ssam ni->ni_macaddr, "fast-frame", 308190391Ssam "%s", "unable to split encapsulated frames"); 309190391Ssam vap->iv_stats.is_ff_split++; 310190391Ssam m_freem(m); /* NB: must reclaim */ 311190391Ssam return NULL; 312190391Ssam } 313190391Ssam /* XXX not right for WDS */ 314190391Ssam vap->iv_deliver_data(vap, ni, m); /* 1st of pair */ 315190391Ssam 316190391Ssam /* 317190391Ssam * Decap second frame. 318190391Ssam */ 319190391Ssam m_adj(n, roundup2(framelen, 4) - framelen); /* padding */ 320190391Ssam n = ieee80211_decap1(n, &framelen); 321190391Ssam if (n == NULL) { 322190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 323190391Ssam ni->ni_macaddr, "fast-frame", "%s", "second decap failed"); 324190391Ssam vap->iv_stats.is_ff_tooshort++; 325190391Ssam } 326190391Ssam /* XXX verify framelen against mbuf contents */ 327190391Ssam return n; /* 2nd delivered by caller */ 328190391Ssam#undef MS 329190391Ssam#undef FF_LLC_SIZE 330190391Ssam} 331190391Ssam 332190391Ssam/* 333190391Ssam * Do Ethernet-LLC encapsulation for each payload in a fast frame 334190391Ssam * tunnel encapsulation. The frame is assumed to have an Ethernet 335190391Ssam * header at the front that must be stripped before prepending the 336190391Ssam * LLC followed by the Ethernet header passed in (with an Ethernet 337190391Ssam * type that specifies the payload size). 338190391Ssam */ 339190391Ssamstatic struct mbuf * 340190391Ssamff_encap1(struct ieee80211vap *vap, struct mbuf *m, 341190391Ssam const struct ether_header *eh) 342190391Ssam{ 343190391Ssam struct llc *llc; 344190391Ssam uint16_t payload; 345190391Ssam 346190391Ssam /* XXX optimize by combining m_adj+M_PREPEND */ 347190391Ssam m_adj(m, sizeof(struct ether_header) - sizeof(struct llc)); 348190391Ssam llc = mtod(m, struct llc *); 349190391Ssam llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; 350190391Ssam llc->llc_control = LLC_UI; 351190391Ssam llc->llc_snap.org_code[0] = 0; 352190391Ssam llc->llc_snap.org_code[1] = 0; 353190391Ssam llc->llc_snap.org_code[2] = 0; 354190391Ssam llc->llc_snap.ether_type = eh->ether_type; 355190391Ssam payload = m->m_pkthdr.len; /* NB: w/o Ethernet header */ 356190391Ssam 357243882Sglebius M_PREPEND(m, sizeof(struct ether_header), M_NOWAIT); 358190391Ssam if (m == NULL) { /* XXX cannot happen */ 359190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 360190391Ssam "%s: no space for ether_header\n", __func__); 361190391Ssam vap->iv_stats.is_tx_nobuf++; 362190391Ssam return NULL; 363190391Ssam } 364190391Ssam ETHER_HEADER_COPY(mtod(m, void *), eh); 365190391Ssam mtod(m, struct ether_header *)->ether_type = htons(payload); 366190391Ssam return m; 367190391Ssam} 368190391Ssam 369190391Ssam/* 370190391Ssam * Fast frame encapsulation. There must be two packets 371190391Ssam * chained with m_nextpkt. We do header adjustment for 372190391Ssam * each, add the tunnel encapsulation, and then concatenate 373190391Ssam * the mbuf chains to form a single frame for transmission. 374190391Ssam */ 375190391Ssamstruct mbuf * 376190391Ssamieee80211_ff_encap(struct ieee80211vap *vap, struct mbuf *m1, int hdrspace, 377190391Ssam struct ieee80211_key *key) 378190391Ssam{ 379190391Ssam struct mbuf *m2; 380190391Ssam struct ether_header eh1, eh2; 381190391Ssam struct llc *llc; 382190391Ssam struct mbuf *m; 383190391Ssam int pad; 384190391Ssam 385190391Ssam m2 = m1->m_nextpkt; 386190391Ssam if (m2 == NULL) { 387190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 388190391Ssam "%s: only one frame\n", __func__); 389190391Ssam goto bad; 390190391Ssam } 391190391Ssam m1->m_nextpkt = NULL; 392190391Ssam /* 393190579Ssam * Include fast frame headers in adjusting header layout. 394190391Ssam */ 395190579Ssam KASSERT(m1->m_len >= sizeof(eh1), ("no ethernet header!")); 396190579Ssam ETHER_HEADER_COPY(&eh1, mtod(m1, caddr_t)); 397190391Ssam m1 = ieee80211_mbuf_adjust(vap, 398190391Ssam hdrspace + sizeof(struct llc) + sizeof(uint32_t) + 2 + 399190391Ssam sizeof(struct ether_header), 400190391Ssam key, m1); 401190391Ssam if (m1 == NULL) { 402190391Ssam /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ 403190391Ssam m_freem(m2); 404190391Ssam goto bad; 405190391Ssam } 406190391Ssam 407190391Ssam /* 408190391Ssam * Copy second frame's Ethernet header out of line 409190391Ssam * and adjust for encapsulation headers. Note that 410190391Ssam * we make room for padding in case there isn't room 411190391Ssam * at the end of first frame. 412190391Ssam */ 413190391Ssam KASSERT(m2->m_len >= sizeof(eh2), ("no ethernet header!")); 414190391Ssam ETHER_HEADER_COPY(&eh2, mtod(m2, caddr_t)); 415190391Ssam m2 = ieee80211_mbuf_adjust(vap, 416190391Ssam ATH_FF_MAX_HDR_PAD + sizeof(struct ether_header), 417190391Ssam NULL, m2); 418190391Ssam if (m2 == NULL) { 419190391Ssam /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ 420190391Ssam goto bad; 421190391Ssam } 422190391Ssam 423190391Ssam /* 424190391Ssam * Now do tunnel encapsulation. First, each 425190391Ssam * frame gets a standard encapsulation. 426190391Ssam */ 427190391Ssam m1 = ff_encap1(vap, m1, &eh1); 428190391Ssam if (m1 == NULL) 429190391Ssam goto bad; 430190391Ssam m2 = ff_encap1(vap, m2, &eh2); 431190391Ssam if (m2 == NULL) 432190391Ssam goto bad; 433190391Ssam 434190391Ssam /* 435190391Ssam * Pad leading frame to a 4-byte boundary. If there 436190391Ssam * is space at the end of the first frame, put it 437190391Ssam * there; otherwise prepend to the front of the second 438190391Ssam * frame. We know doing the second will always work 439190391Ssam * because we reserve space above. We prefer appending 440190391Ssam * as this typically has better DMA alignment properties. 441190391Ssam */ 442190391Ssam for (m = m1; m->m_next != NULL; m = m->m_next) 443190391Ssam ; 444190391Ssam pad = roundup2(m1->m_pkthdr.len, 4) - m1->m_pkthdr.len; 445190391Ssam if (pad) { 446190391Ssam if (M_TRAILINGSPACE(m) < pad) { /* prepend to second */ 447190391Ssam m2->m_data -= pad; 448190391Ssam m2->m_len += pad; 449190391Ssam m2->m_pkthdr.len += pad; 450190391Ssam } else { /* append to first */ 451190391Ssam m->m_len += pad; 452190391Ssam m1->m_pkthdr.len += pad; 453190391Ssam } 454190391Ssam } 455190391Ssam 456190391Ssam /* 457190391Ssam * Now, stick 'em together and prepend the tunnel headers; 458190391Ssam * first the Atheros tunnel header (all zero for now) and 459190391Ssam * then a special fast frame LLC. 460190391Ssam * 461190391Ssam * XXX optimize by prepending together 462190391Ssam */ 463190391Ssam m->m_next = m2; /* NB: last mbuf from above */ 464190391Ssam m1->m_pkthdr.len += m2->m_pkthdr.len; 465243882Sglebius M_PREPEND(m1, sizeof(uint32_t)+2, M_NOWAIT); 466190391Ssam if (m1 == NULL) { /* XXX cannot happen */ 467190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 468190391Ssam "%s: no space for tunnel header\n", __func__); 469190391Ssam vap->iv_stats.is_tx_nobuf++; 470190391Ssam return NULL; 471190391Ssam } 472190391Ssam memset(mtod(m1, void *), 0, sizeof(uint32_t)+2); 473190391Ssam 474243882Sglebius M_PREPEND(m1, sizeof(struct llc), M_NOWAIT); 475190391Ssam if (m1 == NULL) { /* XXX cannot happen */ 476190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 477190391Ssam "%s: no space for llc header\n", __func__); 478190391Ssam vap->iv_stats.is_tx_nobuf++; 479190391Ssam return NULL; 480190391Ssam } 481190391Ssam llc = mtod(m1, struct llc *); 482190391Ssam llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; 483190391Ssam llc->llc_control = LLC_UI; 484190391Ssam llc->llc_snap.org_code[0] = ATH_FF_SNAP_ORGCODE_0; 485190391Ssam llc->llc_snap.org_code[1] = ATH_FF_SNAP_ORGCODE_1; 486190391Ssam llc->llc_snap.org_code[2] = ATH_FF_SNAP_ORGCODE_2; 487190391Ssam llc->llc_snap.ether_type = htons(ATH_FF_ETH_TYPE); 488190391Ssam 489190391Ssam vap->iv_stats.is_ff_encap++; 490190391Ssam 491190391Ssam return m1; 492190391Ssambad: 493190391Ssam if (m1 != NULL) 494190391Ssam m_freem(m1); 495190391Ssam if (m2 != NULL) 496190391Ssam m_freem(m2); 497190391Ssam return NULL; 498190391Ssam} 499190391Ssam 500190579Ssamstatic void 501190579Ssamff_transmit(struct ieee80211_node *ni, struct mbuf *m) 502190579Ssam{ 503190579Ssam struct ieee80211vap *vap = ni->ni_vap; 504248069Sadrian struct ieee80211com *ic = ni->ni_ic; 505190579Ssam int error; 506190579Ssam 507248069Sadrian IEEE80211_TX_LOCK_ASSERT(vap->iv_ic); 508248069Sadrian 509190579Ssam /* encap and xmit */ 510190579Ssam m = ieee80211_encap(vap, ni, m); 511190579Ssam if (m != NULL) { 512190579Ssam struct ifnet *ifp = vap->iv_ifp; 513190579Ssam 514248069Sadrian error = ieee80211_parent_transmit(ic, m);; 515190579Ssam if (error != 0) { 516190579Ssam /* NB: IFQ_HANDOFF reclaims mbuf */ 517190579Ssam ieee80211_free_node(ni); 518190579Ssam } else { 519190579Ssam ifp->if_opackets++; 520190579Ssam } 521190579Ssam } else 522190579Ssam ieee80211_free_node(ni); 523190579Ssam} 524190579Ssam 525190391Ssam/* 526190579Ssam * Flush frames to device; note we re-use the linked list 527190579Ssam * the frames were stored on and use the sentinel (unchanged) 528190579Ssam * which may be non-NULL. 529190579Ssam */ 530190579Ssamstatic void 531190579Ssamff_flush(struct mbuf *head, struct mbuf *last) 532190579Ssam{ 533190579Ssam struct mbuf *m, *next; 534190579Ssam struct ieee80211_node *ni; 535190579Ssam struct ieee80211vap *vap; 536190579Ssam 537248069Sadrian IEEE80211_TX_LOCK_ASSERT(vap->iv_ic); 538248069Sadrian 539190579Ssam for (m = head; m != last; m = next) { 540190579Ssam next = m->m_nextpkt; 541190579Ssam m->m_nextpkt = NULL; 542190579Ssam 543190579Ssam ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; 544190579Ssam vap = ni->ni_vap; 545190579Ssam 546190579Ssam IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, 547190579Ssam "%s: flush frame, age %u", __func__, M_AGE_GET(m)); 548190579Ssam vap->iv_stats.is_ff_flush++; 549190579Ssam 550190579Ssam ff_transmit(ni, m); 551190579Ssam } 552190579Ssam} 553190579Ssam 554190579Ssam/* 555190579Ssam * Age frames on the staging queue. 556244044Sadrian * 557244044Sadrian * This is called without the comlock held, but it does all its work 558244044Sadrian * behind the comlock. Because of this, it's possible that the 559244044Sadrian * staging queue will be serviced between the function which called 560244044Sadrian * it and now; thus simply checking that the queue has work in it 561244044Sadrian * may fail. 562244044Sadrian * 563244044Sadrian * See PR kern/174283 for more details. 564190579Ssam */ 565190579Ssamvoid 566191753Ssamieee80211_ff_age(struct ieee80211com *ic, struct ieee80211_stageq *sq, 567191753Ssam int quanta) 568190579Ssam{ 569190579Ssam struct mbuf *m, *head; 570190579Ssam struct ieee80211_node *ni; 571190579Ssam struct ieee80211_tx_ampdu *tap; 572190579Ssam 573244044Sadrian#if 0 574190579Ssam KASSERT(sq->head != NULL, ("stageq empty")); 575244044Sadrian#endif 576190579Ssam 577190579Ssam IEEE80211_LOCK(ic); 578190579Ssam head = sq->head; 579190579Ssam while ((m = sq->head) != NULL && M_AGE_GET(m) < quanta) { 580234324Sadrian int tid = WME_AC_TO_TID(M_WME_GETAC(m)); 581234324Sadrian 582190579Ssam /* clear tap ref to frame */ 583190579Ssam ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; 584234324Sadrian tap = &ni->ni_tx_ampdu[tid]; 585190579Ssam KASSERT(tap->txa_private == m, ("staging queue empty")); 586190579Ssam tap->txa_private = NULL; 587190579Ssam 588190579Ssam sq->head = m->m_nextpkt; 589190579Ssam sq->depth--; 590190579Ssam } 591190579Ssam if (m == NULL) 592190579Ssam sq->tail = NULL; 593190579Ssam else 594190579Ssam M_AGE_SUB(m, quanta); 595190579Ssam IEEE80211_UNLOCK(ic); 596190579Ssam 597248069Sadrian IEEE80211_TX_LOCK(ic); 598190579Ssam ff_flush(head, m); 599248069Sadrian IEEE80211_TX_UNLOCK(ic); 600190579Ssam} 601190579Ssam 602190579Ssamstatic void 603244051Sadrianstageq_add(struct ieee80211com *ic, struct ieee80211_stageq *sq, struct mbuf *m) 604190579Ssam{ 605190579Ssam int age = ieee80211_ffagemax; 606244051Sadrian 607244051Sadrian IEEE80211_LOCK_ASSERT(ic); 608244051Sadrian 609190579Ssam if (sq->tail != NULL) { 610190579Ssam sq->tail->m_nextpkt = m; 611190579Ssam age -= M_AGE_GET(sq->head); 612190579Ssam } else 613190579Ssam sq->head = m; 614190579Ssam KASSERT(age >= 0, ("age %d", age)); 615190579Ssam M_AGE_SET(m, age); 616190579Ssam m->m_nextpkt = NULL; 617190579Ssam sq->tail = m; 618190579Ssam sq->depth++; 619190579Ssam} 620190579Ssam 621190579Ssamstatic void 622244051Sadrianstageq_remove(struct ieee80211com *ic, struct ieee80211_stageq *sq, struct mbuf *mstaged) 623190579Ssam{ 624190579Ssam struct mbuf *m, *mprev; 625190579Ssam 626244051Sadrian IEEE80211_LOCK_ASSERT(ic); 627244051Sadrian 628190579Ssam mprev = NULL; 629190579Ssam for (m = sq->head; m != NULL; m = m->m_nextpkt) { 630190579Ssam if (m == mstaged) { 631190579Ssam if (mprev == NULL) 632190579Ssam sq->head = m->m_nextpkt; 633190579Ssam else 634190579Ssam mprev->m_nextpkt = m->m_nextpkt; 635190579Ssam if (sq->tail == m) 636190579Ssam sq->tail = mprev; 637190579Ssam sq->depth--; 638190579Ssam return; 639190579Ssam } 640190579Ssam mprev = m; 641190579Ssam } 642190579Ssam printf("%s: packet not found\n", __func__); 643190579Ssam} 644190579Ssam 645190579Ssamstatic uint32_t 646190579Ssamff_approx_txtime(struct ieee80211_node *ni, 647190579Ssam const struct mbuf *m1, const struct mbuf *m2) 648190579Ssam{ 649190579Ssam struct ieee80211com *ic = ni->ni_ic; 650190579Ssam struct ieee80211vap *vap = ni->ni_vap; 651190579Ssam uint32_t framelen; 652190579Ssam 653190579Ssam /* 654190579Ssam * Approximate the frame length to be transmitted. A swag to add 655190579Ssam * the following maximal values to the skb payload: 656190579Ssam * - 32: 802.11 encap + CRC 657190579Ssam * - 24: encryption overhead (if wep bit) 658190579Ssam * - 4 + 6: fast-frame header and padding 659190579Ssam * - 16: 2 LLC FF tunnel headers 660190579Ssam * - 14: 1 802.3 FF tunnel header (mbuf already accounts for 2nd) 661190579Ssam */ 662190579Ssam framelen = m1->m_pkthdr.len + 32 + 663190579Ssam ATH_FF_MAX_HDR_PAD + ATH_FF_MAX_SEP_PAD + ATH_FF_MAX_HDR; 664190579Ssam if (vap->iv_flags & IEEE80211_F_PRIVACY) 665190579Ssam framelen += 24; 666190579Ssam if (m2 != NULL) 667190579Ssam framelen += m2->m_pkthdr.len; 668190579Ssam return ieee80211_compute_duration(ic->ic_rt, framelen, ni->ni_txrate, 0); 669190579Ssam} 670190579Ssam 671190579Ssam/* 672190579Ssam * Check if the supplied frame can be partnered with an existing 673190579Ssam * or pending frame. Return a reference to any frame that should be 674190579Ssam * sent on return; otherwise return NULL. 675190579Ssam */ 676190579Ssamstruct mbuf * 677190579Ssamieee80211_ff_check(struct ieee80211_node *ni, struct mbuf *m) 678190579Ssam{ 679190579Ssam struct ieee80211vap *vap = ni->ni_vap; 680190579Ssam struct ieee80211com *ic = ni->ni_ic; 681191753Ssam struct ieee80211_superg *sg = ic->ic_superg; 682190579Ssam const int pri = M_WME_GETAC(m); 683190579Ssam struct ieee80211_stageq *sq; 684190579Ssam struct ieee80211_tx_ampdu *tap; 685190579Ssam struct mbuf *mstaged; 686190579Ssam uint32_t txtime, limit; 687190579Ssam 688248069Sadrian IEEE80211_TX_UNLOCK_ASSERT(ic); 689248069Sadrian 690190579Ssam /* 691190579Ssam * Check if the supplied frame can be aggregated. 692190579Ssam * 693190579Ssam * NB: we allow EAPOL frames to be aggregated with other ucast traffic. 694190579Ssam * Do 802.1x EAPOL frames proceed in the clear? Then they couldn't 695190579Ssam * be aggregated with other types of frames when encryption is on? 696190579Ssam */ 697190579Ssam IEEE80211_LOCK(ic); 698234324Sadrian tap = &ni->ni_tx_ampdu[WME_AC_TO_TID(pri)]; 699190579Ssam mstaged = tap->txa_private; /* NB: we reuse AMPDU state */ 700190579Ssam ieee80211_txampdu_count_packet(tap); 701190579Ssam 702190579Ssam /* 703190579Ssam * When not in station mode never aggregate a multicast 704190579Ssam * frame; this insures, for example, that a combined frame 705190579Ssam * does not require multiple encryption keys. 706190579Ssam */ 707190579Ssam if (vap->iv_opmode != IEEE80211_M_STA && 708190579Ssam ETHER_IS_MULTICAST(mtod(m, struct ether_header *)->ether_dhost)) { 709190579Ssam /* XXX flush staged frame? */ 710190579Ssam IEEE80211_UNLOCK(ic); 711190579Ssam return m; 712190579Ssam } 713190579Ssam /* 714190579Ssam * If there is no frame to combine with and the pps is 715190579Ssam * too low; then do not attempt to aggregate this frame. 716190579Ssam */ 717190579Ssam if (mstaged == NULL && 718190579Ssam ieee80211_txampdu_getpps(tap) < ieee80211_ffppsmin) { 719190579Ssam IEEE80211_UNLOCK(ic); 720190579Ssam return m; 721190579Ssam } 722191753Ssam sq = &sg->ff_stageq[pri]; 723190579Ssam /* 724190579Ssam * Check the txop limit to insure the aggregate fits. 725190579Ssam */ 726190579Ssam limit = IEEE80211_TXOP_TO_US( 727190579Ssam ic->ic_wme.wme_chanParams.cap_wmeParams[pri].wmep_txopLimit); 728190579Ssam if (limit != 0 && 729190579Ssam (txtime = ff_approx_txtime(ni, m, mstaged)) > limit) { 730190579Ssam /* 731190579Ssam * Aggregate too long, return to the caller for direct 732190579Ssam * transmission. In addition, flush any pending frame 733190579Ssam * before sending this one. 734190579Ssam */ 735190579Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 736190579Ssam "%s: txtime %u exceeds txop limit %u\n", 737190579Ssam __func__, txtime, limit); 738190579Ssam 739190579Ssam tap->txa_private = NULL; 740190579Ssam if (mstaged != NULL) 741244051Sadrian stageq_remove(ic, sq, mstaged); 742190579Ssam IEEE80211_UNLOCK(ic); 743190579Ssam 744190579Ssam if (mstaged != NULL) { 745248069Sadrian IEEE80211_TX_LOCK(ic); 746190579Ssam IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, 747190579Ssam "%s: flush staged frame", __func__); 748190579Ssam /* encap and xmit */ 749190579Ssam ff_transmit(ni, mstaged); 750248069Sadrian IEEE80211_TX_UNLOCK(ic); 751190579Ssam } 752190579Ssam return m; /* NB: original frame */ 753190579Ssam } 754190579Ssam /* 755190579Ssam * An aggregation candidate. If there's a frame to partner 756190579Ssam * with then combine and return for processing. Otherwise 757190579Ssam * save this frame and wait for a partner to show up (or 758190579Ssam * the frame to be flushed). Note that staged frames also 759190579Ssam * hold their node reference. 760190579Ssam */ 761190579Ssam if (mstaged != NULL) { 762190579Ssam tap->txa_private = NULL; 763244051Sadrian stageq_remove(ic, sq, mstaged); 764190579Ssam IEEE80211_UNLOCK(ic); 765190579Ssam 766190579Ssam IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, 767190579Ssam "%s: aggregate fast-frame", __func__); 768190579Ssam /* 769190579Ssam * Release the node reference; we only need 770190579Ssam * the one already in mstaged. 771190579Ssam */ 772190579Ssam KASSERT(mstaged->m_pkthdr.rcvif == (void *)ni, 773190579Ssam ("rcvif %p ni %p", mstaged->m_pkthdr.rcvif, ni)); 774190579Ssam ieee80211_free_node(ni); 775190579Ssam 776190579Ssam m->m_nextpkt = NULL; 777190579Ssam mstaged->m_nextpkt = m; 778190579Ssam mstaged->m_flags |= M_FF; /* NB: mark for encap work */ 779190579Ssam } else { 780190579Ssam KASSERT(tap->txa_private == NULL, 781190579Ssam ("txa_private %p", tap->txa_private)); 782190579Ssam tap->txa_private = m; 783190579Ssam 784244051Sadrian stageq_add(ic, sq, m); 785190579Ssam IEEE80211_UNLOCK(ic); 786190579Ssam 787190579Ssam IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, 788190579Ssam "%s: stage frame, %u queued", __func__, sq->depth); 789190579Ssam /* NB: mstaged is NULL */ 790190579Ssam } 791190579Ssam return mstaged; 792190579Ssam} 793190579Ssam 794190579Ssamvoid 795190579Ssamieee80211_ff_node_init(struct ieee80211_node *ni) 796190579Ssam{ 797190579Ssam /* 798190579Ssam * Clean FF state on re-associate. This handles the case 799190579Ssam * where a station leaves w/o notifying us and then returns 800190579Ssam * before node is reaped for inactivity. 801190579Ssam */ 802190579Ssam ieee80211_ff_node_cleanup(ni); 803190579Ssam} 804190579Ssam 805190579Ssamvoid 806190579Ssamieee80211_ff_node_cleanup(struct ieee80211_node *ni) 807190579Ssam{ 808190579Ssam struct ieee80211com *ic = ni->ni_ic; 809191753Ssam struct ieee80211_superg *sg = ic->ic_superg; 810190579Ssam struct ieee80211_tx_ampdu *tap; 811244025Sadrian struct mbuf *m, *next_m, *head; 812234324Sadrian int tid; 813190579Ssam 814190579Ssam IEEE80211_LOCK(ic); 815190579Ssam head = NULL; 816234324Sadrian for (tid = 0; tid < WME_NUM_TID; tid++) { 817234324Sadrian int ac = TID_TO_WME_AC(tid); 818234324Sadrian 819234324Sadrian tap = &ni->ni_tx_ampdu[tid]; 820190579Ssam m = tap->txa_private; 821190579Ssam if (m != NULL) { 822190579Ssam tap->txa_private = NULL; 823244051Sadrian stageq_remove(ic, &sg->ff_stageq[ac], m); 824190579Ssam m->m_nextpkt = head; 825190579Ssam head = m; 826190579Ssam } 827190579Ssam } 828190579Ssam IEEE80211_UNLOCK(ic); 829190579Ssam 830244025Sadrian /* 831244025Sadrian * Free mbufs, taking care to not dereference the mbuf after 832244025Sadrian * we free it (hence grabbing m_nextpkt before we free it.) 833244025Sadrian */ 834244025Sadrian m = head; 835244025Sadrian while (m != NULL) { 836244025Sadrian next_m = m->m_nextpkt; 837190579Ssam m_freem(m); 838190579Ssam ieee80211_free_node(ni); 839244025Sadrian m = next_m; 840190579Ssam } 841190579Ssam} 842190579Ssam 843190579Ssam/* 844190391Ssam * Switch between turbo and non-turbo operating modes. 845190391Ssam * Use the specified channel flags to locate the new 846190391Ssam * channel, update 802.11 state, and then call back into 847190391Ssam * the driver to effect the change. 848190391Ssam */ 849190391Ssamvoid 850190391Ssamieee80211_dturbo_switch(struct ieee80211vap *vap, int newflags) 851190391Ssam{ 852190391Ssam struct ieee80211com *ic = vap->iv_ic; 853190391Ssam struct ieee80211_channel *chan; 854190391Ssam 855190391Ssam chan = ieee80211_find_channel(ic, ic->ic_bsschan->ic_freq, newflags); 856190391Ssam if (chan == NULL) { /* XXX should not happen */ 857190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 858190391Ssam "%s: no channel with freq %u flags 0x%x\n", 859190391Ssam __func__, ic->ic_bsschan->ic_freq, newflags); 860190391Ssam return; 861190391Ssam } 862190391Ssam 863190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 864190391Ssam "%s: %s -> %s (freq %u flags 0x%x)\n", __func__, 865190391Ssam ieee80211_phymode_name[ieee80211_chan2mode(ic->ic_bsschan)], 866190391Ssam ieee80211_phymode_name[ieee80211_chan2mode(chan)], 867190391Ssam chan->ic_freq, chan->ic_flags); 868190391Ssam 869190391Ssam ic->ic_bsschan = chan; 870190391Ssam ic->ic_prevchan = ic->ic_curchan; 871190391Ssam ic->ic_curchan = chan; 872190532Ssam ic->ic_rt = ieee80211_get_ratetable(chan); 873190391Ssam ic->ic_set_channel(ic); 874192468Ssam ieee80211_radiotap_chan_change(ic); 875190391Ssam /* NB: do not need to reset ERP state 'cuz we're in sta mode */ 876190391Ssam} 877190391Ssam 878190391Ssam/* 879190391Ssam * Return the current ``state'' of an Atheros capbility. 880190391Ssam * If associated in station mode report the negotiated 881190391Ssam * setting. Otherwise report the current setting. 882190391Ssam */ 883190391Ssamstatic int 884190391Ssamgetathcap(struct ieee80211vap *vap, int cap) 885190391Ssam{ 886190391Ssam if (vap->iv_opmode == IEEE80211_M_STA && 887190391Ssam vap->iv_state == IEEE80211_S_RUN) 888190391Ssam return IEEE80211_ATH_CAP(vap, vap->iv_bss, cap) != 0; 889190391Ssam else 890190391Ssam return (vap->iv_flags & cap) != 0; 891190391Ssam} 892190391Ssam 893190391Ssamstatic int 894190391Ssamsuperg_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) 895190391Ssam{ 896190391Ssam switch (ireq->i_type) { 897190391Ssam case IEEE80211_IOC_FF: 898190391Ssam ireq->i_val = getathcap(vap, IEEE80211_F_FF); 899190391Ssam break; 900190391Ssam case IEEE80211_IOC_TURBOP: 901190391Ssam ireq->i_val = getathcap(vap, IEEE80211_F_TURBOP); 902190391Ssam break; 903190391Ssam default: 904190391Ssam return ENOSYS; 905190391Ssam } 906190391Ssam return 0; 907190391Ssam} 908190391SsamIEEE80211_IOCTL_GET(superg, superg_ioctl_get80211); 909190391Ssam 910190391Ssamstatic int 911190391Ssamsuperg_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) 912190391Ssam{ 913190391Ssam switch (ireq->i_type) { 914190391Ssam case IEEE80211_IOC_FF: 915190391Ssam if (ireq->i_val) { 916190391Ssam if ((vap->iv_caps & IEEE80211_C_FF) == 0) 917190391Ssam return EOPNOTSUPP; 918190391Ssam vap->iv_flags |= IEEE80211_F_FF; 919190391Ssam } else 920190391Ssam vap->iv_flags &= ~IEEE80211_F_FF; 921190530Ssam return ENETRESET; 922190391Ssam case IEEE80211_IOC_TURBOP: 923190391Ssam if (ireq->i_val) { 924190391Ssam if ((vap->iv_caps & IEEE80211_C_TURBOP) == 0) 925190391Ssam return EOPNOTSUPP; 926190391Ssam vap->iv_flags |= IEEE80211_F_TURBOP; 927190391Ssam } else 928190391Ssam vap->iv_flags &= ~IEEE80211_F_TURBOP; 929190391Ssam return ENETRESET; 930190391Ssam default: 931190391Ssam return ENOSYS; 932190391Ssam } 933190391Ssam return 0; 934190391Ssam} 935190391SsamIEEE80211_IOCTL_SET(superg, superg_ioctl_set80211); 936246226Sadrian 937246226Sadrian#endif /* IEEE80211_SUPPORT_SUPERG */ 938