ieee80211_superg.c revision 190450
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 190450 2009-03-26 19:07:56Z sam $"); 28190391Ssam 29190391Ssam#include "opt_wlan.h" 30190391Ssam 31190391Ssam#include <sys/param.h> 32190391Ssam#include <sys/systm.h> 33190391Ssam#include <sys/mbuf.h> 34190391Ssam#include <sys/kernel.h> 35190391Ssam#include <sys/endian.h> 36190391Ssam 37190391Ssam#include <sys/socket.h> 38190391Ssam 39190391Ssam#include <net/bpf.h> 40190391Ssam#include <net/ethernet.h> 41190391Ssam#include <net/if.h> 42190391Ssam#include <net/if_llc.h> 43190391Ssam#include <net/if_media.h> 44190391Ssam 45190391Ssam#include <net80211/ieee80211_var.h> 46190391Ssam#include <net80211/ieee80211_input.h> 47190391Ssam#include <net80211/ieee80211_phy.h> 48190391Ssam#include <net80211/ieee80211_superg.h> 49190391Ssam 50190391Ssam#define ETHER_HEADER_COPY(dst, src) \ 51190391Ssam memcpy(dst, src, sizeof(struct ether_header)) 52190391Ssam 53190391Ssamvoid 54190391Ssamieee80211_superg_attach(struct ieee80211com *ic) 55190391Ssam{ 56190391Ssam} 57190391Ssam 58190391Ssamvoid 59190391Ssamieee80211_superg_detach(struct ieee80211com *ic) 60190391Ssam{ 61190391Ssam} 62190391Ssam 63190391Ssamvoid 64190391Ssamieee80211_superg_vattach(struct ieee80211vap *vap) 65190391Ssam{ 66190391Ssam if (vap->iv_caps & IEEE80211_C_FF) 67190391Ssam vap->iv_flags |= IEEE80211_F_FF; 68190450Ssam /* NB: we only implement sta mode */ 69190450Ssam if (vap->iv_opmode == IEEE80211_M_STA && 70190450Ssam (vap->iv_caps & IEEE80211_C_TURBOP)) 71190391Ssam vap->iv_flags |= IEEE80211_F_TURBOP; 72190391Ssam} 73190391Ssam 74190391Ssamvoid 75190391Ssamieee80211_superg_vdetach(struct ieee80211vap *vap) 76190391Ssam{ 77190391Ssam} 78190391Ssam 79190391Ssam#define ATH_OUI_BYTES 0x00, 0x03, 0x7f 80190391Ssam/* 81190391Ssam * Add a WME information element to a frame. 82190391Ssam */ 83190391Ssamuint8_t * 84190391Ssamieee80211_add_ath(uint8_t *frm, uint8_t caps, uint16_t defkeyix) 85190391Ssam{ 86190391Ssam static const struct ieee80211_ath_ie info = { 87190391Ssam .ath_id = IEEE80211_ELEMID_VENDOR, 88190391Ssam .ath_len = sizeof(struct ieee80211_ath_ie) - 2, 89190391Ssam .ath_oui = { ATH_OUI_BYTES }, 90190391Ssam .ath_oui_type = ATH_OUI_TYPE, 91190391Ssam .ath_oui_subtype= ATH_OUI_SUBTYPE, 92190391Ssam .ath_version = ATH_OUI_VERSION, 93190391Ssam }; 94190391Ssam struct ieee80211_ath_ie *ath = (struct ieee80211_ath_ie *) frm; 95190391Ssam 96190391Ssam memcpy(frm, &info, sizeof(info)); 97190391Ssam ath->ath_capability = caps; 98190391Ssam ath->ath_defkeyix[0] = (defkeyix & 0xff); 99190391Ssam ath->ath_defkeyix[1] = ((defkeyix >> 8) & 0xff); 100190391Ssam return frm + sizeof(info); 101190391Ssam} 102190391Ssam#undef ATH_OUI_BYTES 103190391Ssam 104190391Ssamvoid 105190391Ssamieee80211_parse_ath(struct ieee80211_node *ni, uint8_t *ie) 106190391Ssam{ 107190391Ssam const struct ieee80211_ath_ie *ath = 108190391Ssam (const struct ieee80211_ath_ie *) ie; 109190391Ssam 110190391Ssam ni->ni_ath_flags = ath->ath_capability; 111190391Ssam ni->ni_ath_defkeyix = LE_READ_2(&ath->ath_defkeyix); 112190391Ssam} 113190391Ssam 114190391Ssamint 115190391Ssamieee80211_parse_athparams(struct ieee80211_node *ni, uint8_t *frm, 116190391Ssam const struct ieee80211_frame *wh) 117190391Ssam{ 118190391Ssam struct ieee80211vap *vap = ni->ni_vap; 119190391Ssam const struct ieee80211_ath_ie *ath; 120190391Ssam u_int len = frm[1]; 121190391Ssam int capschanged; 122190391Ssam uint16_t defkeyix; 123190391Ssam 124190391Ssam if (len < sizeof(struct ieee80211_ath_ie)-2) { 125190391Ssam IEEE80211_DISCARD_IE(vap, 126190391Ssam IEEE80211_MSG_ELEMID | IEEE80211_MSG_SUPERG, 127190391Ssam wh, "Atheros", "too short, len %u", len); 128190391Ssam return -1; 129190391Ssam } 130190391Ssam ath = (const struct ieee80211_ath_ie *)frm; 131190391Ssam capschanged = (ni->ni_ath_flags != ath->ath_capability); 132190391Ssam defkeyix = LE_READ_2(ath->ath_defkeyix); 133190391Ssam if (capschanged || defkeyix != ni->ni_ath_defkeyix) { 134190391Ssam ni->ni_ath_flags = ath->ath_capability; 135190391Ssam ni->ni_ath_defkeyix = defkeyix; 136190391Ssam IEEE80211_NOTE(vap, IEEE80211_MSG_SUPERG, ni, 137190391Ssam "ath ie change: new caps 0x%x defkeyix 0x%x", 138190391Ssam ni->ni_ath_flags, ni->ni_ath_defkeyix); 139190391Ssam } 140190391Ssam if (IEEE80211_ATH_CAP(vap, ni, ATHEROS_CAP_TURBO_PRIME)) { 141190391Ssam uint16_t curflags, newflags; 142190391Ssam 143190391Ssam /* 144190391Ssam * Check for turbo mode switch. Calculate flags 145190391Ssam * for the new mode and effect the switch. 146190391Ssam */ 147190391Ssam newflags = curflags = vap->iv_ic->ic_bsschan->ic_flags; 148190391Ssam /* NB: BOOST is not in ic_flags, so get it from the ie */ 149190391Ssam if (ath->ath_capability & ATHEROS_CAP_BOOST) 150190391Ssam newflags |= IEEE80211_CHAN_TURBO; 151190391Ssam else 152190391Ssam newflags &= ~IEEE80211_CHAN_TURBO; 153190391Ssam if (newflags != curflags) 154190391Ssam ieee80211_dturbo_switch(vap, newflags); 155190391Ssam } 156190391Ssam return capschanged; 157190391Ssam} 158190391Ssam 159190391Ssam/* 160190391Ssam * Decap the encapsulated frame pair and dispatch the first 161190391Ssam * for delivery. The second frame is returned for delivery 162190391Ssam * via the normal path. 163190391Ssam */ 164190391Ssamstruct mbuf * 165190391Ssamieee80211_ff_decap(struct ieee80211_node *ni, struct mbuf *m) 166190391Ssam{ 167190391Ssam#define FF_LLC_SIZE (sizeof(struct ether_header) + sizeof(struct llc)) 168190391Ssam#define MS(x,f) (((x) & f) >> f##_S) 169190391Ssam struct ieee80211vap *vap = ni->ni_vap; 170190391Ssam struct llc *llc; 171190391Ssam uint32_t ath; 172190391Ssam struct mbuf *n; 173190391Ssam int framelen; 174190391Ssam 175190391Ssam /* NB: we assume caller does this check for us */ 176190391Ssam KASSERT(IEEE80211_ATH_CAP(vap, ni, IEEE80211_NODE_FF), 177190391Ssam ("ff not negotiated")); 178190391Ssam /* 179190391Ssam * Check for fast-frame tunnel encapsulation. 180190391Ssam */ 181190391Ssam if (m->m_pkthdr.len < 3*FF_LLC_SIZE) 182190391Ssam return m; 183190391Ssam if (m->m_len < FF_LLC_SIZE && 184190391Ssam (m = m_pullup(m, FF_LLC_SIZE)) == NULL) { 185190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 186190391Ssam ni->ni_macaddr, "fast-frame", 187190391Ssam "%s", "m_pullup(llc) failed"); 188190391Ssam vap->iv_stats.is_rx_tooshort++; 189190391Ssam return NULL; 190190391Ssam } 191190391Ssam llc = (struct llc *)(mtod(m, uint8_t *) + 192190391Ssam sizeof(struct ether_header)); 193190391Ssam if (llc->llc_snap.ether_type != htons(ATH_FF_ETH_TYPE)) 194190391Ssam return m; 195190391Ssam m_adj(m, FF_LLC_SIZE); 196190391Ssam m_copydata(m, 0, sizeof(uint32_t), (caddr_t) &ath); 197190391Ssam if (MS(ath, ATH_FF_PROTO) != ATH_FF_PROTO_L2TUNNEL) { 198190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 199190391Ssam ni->ni_macaddr, "fast-frame", 200190391Ssam "unsupport tunnel protocol, header 0x%x", ath); 201190391Ssam vap->iv_stats.is_ff_badhdr++; 202190391Ssam m_freem(m); 203190391Ssam return NULL; 204190391Ssam } 205190391Ssam /* NB: skip header and alignment padding */ 206190391Ssam m_adj(m, roundup(sizeof(uint32_t) - 2, 4) + 2); 207190391Ssam 208190391Ssam vap->iv_stats.is_ff_decap++; 209190391Ssam 210190391Ssam /* 211190391Ssam * Decap the first frame, bust it apart from the 212190391Ssam * second and deliver; then decap the second frame 213190391Ssam * and return it to the caller for normal delivery. 214190391Ssam */ 215190391Ssam m = ieee80211_decap1(m, &framelen); 216190391Ssam if (m == NULL) { 217190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 218190391Ssam ni->ni_macaddr, "fast-frame", "%s", "first decap failed"); 219190391Ssam vap->iv_stats.is_ff_tooshort++; 220190391Ssam return NULL; 221190391Ssam } 222190391Ssam n = m_split(m, framelen, M_NOWAIT); 223190391Ssam if (n == NULL) { 224190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 225190391Ssam ni->ni_macaddr, "fast-frame", 226190391Ssam "%s", "unable to split encapsulated frames"); 227190391Ssam vap->iv_stats.is_ff_split++; 228190391Ssam m_freem(m); /* NB: must reclaim */ 229190391Ssam return NULL; 230190391Ssam } 231190391Ssam /* XXX not right for WDS */ 232190391Ssam vap->iv_deliver_data(vap, ni, m); /* 1st of pair */ 233190391Ssam 234190391Ssam /* 235190391Ssam * Decap second frame. 236190391Ssam */ 237190391Ssam m_adj(n, roundup2(framelen, 4) - framelen); /* padding */ 238190391Ssam n = ieee80211_decap1(n, &framelen); 239190391Ssam if (n == NULL) { 240190391Ssam IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ANY, 241190391Ssam ni->ni_macaddr, "fast-frame", "%s", "second decap failed"); 242190391Ssam vap->iv_stats.is_ff_tooshort++; 243190391Ssam } 244190391Ssam /* XXX verify framelen against mbuf contents */ 245190391Ssam return n; /* 2nd delivered by caller */ 246190391Ssam#undef MS 247190391Ssam#undef FF_LLC_SIZE 248190391Ssam} 249190391Ssam 250190391Ssam/* 251190391Ssam * Do Ethernet-LLC encapsulation for each payload in a fast frame 252190391Ssam * tunnel encapsulation. The frame is assumed to have an Ethernet 253190391Ssam * header at the front that must be stripped before prepending the 254190391Ssam * LLC followed by the Ethernet header passed in (with an Ethernet 255190391Ssam * type that specifies the payload size). 256190391Ssam */ 257190391Ssamstatic struct mbuf * 258190391Ssamff_encap1(struct ieee80211vap *vap, struct mbuf *m, 259190391Ssam const struct ether_header *eh) 260190391Ssam{ 261190391Ssam struct llc *llc; 262190391Ssam uint16_t payload; 263190391Ssam 264190391Ssam /* XXX optimize by combining m_adj+M_PREPEND */ 265190391Ssam m_adj(m, sizeof(struct ether_header) - sizeof(struct llc)); 266190391Ssam llc = mtod(m, struct llc *); 267190391Ssam llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; 268190391Ssam llc->llc_control = LLC_UI; 269190391Ssam llc->llc_snap.org_code[0] = 0; 270190391Ssam llc->llc_snap.org_code[1] = 0; 271190391Ssam llc->llc_snap.org_code[2] = 0; 272190391Ssam llc->llc_snap.ether_type = eh->ether_type; 273190391Ssam payload = m->m_pkthdr.len; /* NB: w/o Ethernet header */ 274190391Ssam 275190391Ssam M_PREPEND(m, sizeof(struct ether_header), M_DONTWAIT); 276190391Ssam if (m == NULL) { /* XXX cannot happen */ 277190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 278190391Ssam "%s: no space for ether_header\n", __func__); 279190391Ssam vap->iv_stats.is_tx_nobuf++; 280190391Ssam return NULL; 281190391Ssam } 282190391Ssam ETHER_HEADER_COPY(mtod(m, void *), eh); 283190391Ssam mtod(m, struct ether_header *)->ether_type = htons(payload); 284190391Ssam return m; 285190391Ssam} 286190391Ssam 287190391Ssam/* 288190391Ssam * Fast frame encapsulation. There must be two packets 289190391Ssam * chained with m_nextpkt. We do header adjustment for 290190391Ssam * each, add the tunnel encapsulation, and then concatenate 291190391Ssam * the mbuf chains to form a single frame for transmission. 292190391Ssam */ 293190391Ssamstruct mbuf * 294190391Ssamieee80211_ff_encap(struct ieee80211vap *vap, struct mbuf *m1, int hdrspace, 295190391Ssam struct ieee80211_key *key) 296190391Ssam{ 297190391Ssam struct mbuf *m2; 298190391Ssam struct ether_header eh1, eh2; 299190391Ssam struct llc *llc; 300190391Ssam struct mbuf *m; 301190391Ssam int pad; 302190391Ssam 303190391Ssam m2 = m1->m_nextpkt; 304190391Ssam if (m2 == NULL) { 305190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 306190391Ssam "%s: only one frame\n", __func__); 307190391Ssam goto bad; 308190391Ssam } 309190391Ssam m1->m_nextpkt = NULL; 310190391Ssam /* 311190391Ssam * Include fast frame headers in adjusting header 312190391Ssam * layout; this allocates space according to what 313190391Ssam * ff_encap will do. 314190391Ssam */ 315190391Ssam m1 = ieee80211_mbuf_adjust(vap, 316190391Ssam hdrspace + sizeof(struct llc) + sizeof(uint32_t) + 2 + 317190391Ssam sizeof(struct ether_header), 318190391Ssam key, m1); 319190391Ssam if (m1 == NULL) { 320190391Ssam /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ 321190391Ssam m_freem(m2); 322190391Ssam goto bad; 323190391Ssam } 324190391Ssam 325190391Ssam /* 326190391Ssam * Copy second frame's Ethernet header out of line 327190391Ssam * and adjust for encapsulation headers. Note that 328190391Ssam * we make room for padding in case there isn't room 329190391Ssam * at the end of first frame. 330190391Ssam */ 331190391Ssam KASSERT(m2->m_len >= sizeof(eh2), ("no ethernet header!")); 332190391Ssam ETHER_HEADER_COPY(&eh2, mtod(m2, caddr_t)); 333190391Ssam m2 = ieee80211_mbuf_adjust(vap, 334190391Ssam ATH_FF_MAX_HDR_PAD + sizeof(struct ether_header), 335190391Ssam NULL, m2); 336190391Ssam if (m2 == NULL) { 337190391Ssam /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ 338190391Ssam goto bad; 339190391Ssam } 340190391Ssam 341190391Ssam /* 342190391Ssam * Now do tunnel encapsulation. First, each 343190391Ssam * frame gets a standard encapsulation. 344190391Ssam */ 345190391Ssam m1 = ff_encap1(vap, m1, &eh1); 346190391Ssam if (m1 == NULL) 347190391Ssam goto bad; 348190391Ssam m2 = ff_encap1(vap, m2, &eh2); 349190391Ssam if (m2 == NULL) 350190391Ssam goto bad; 351190391Ssam 352190391Ssam /* 353190391Ssam * Pad leading frame to a 4-byte boundary. If there 354190391Ssam * is space at the end of the first frame, put it 355190391Ssam * there; otherwise prepend to the front of the second 356190391Ssam * frame. We know doing the second will always work 357190391Ssam * because we reserve space above. We prefer appending 358190391Ssam * as this typically has better DMA alignment properties. 359190391Ssam */ 360190391Ssam for (m = m1; m->m_next != NULL; m = m->m_next) 361190391Ssam ; 362190391Ssam pad = roundup2(m1->m_pkthdr.len, 4) - m1->m_pkthdr.len; 363190391Ssam if (pad) { 364190391Ssam if (M_TRAILINGSPACE(m) < pad) { /* prepend to second */ 365190391Ssam m2->m_data -= pad; 366190391Ssam m2->m_len += pad; 367190391Ssam m2->m_pkthdr.len += pad; 368190391Ssam } else { /* append to first */ 369190391Ssam m->m_len += pad; 370190391Ssam m1->m_pkthdr.len += pad; 371190391Ssam } 372190391Ssam } 373190391Ssam 374190391Ssam /* 375190391Ssam * Now, stick 'em together and prepend the tunnel headers; 376190391Ssam * first the Atheros tunnel header (all zero for now) and 377190391Ssam * then a special fast frame LLC. 378190391Ssam * 379190391Ssam * XXX optimize by prepending together 380190391Ssam */ 381190391Ssam m->m_next = m2; /* NB: last mbuf from above */ 382190391Ssam m1->m_pkthdr.len += m2->m_pkthdr.len; 383190391Ssam M_PREPEND(m1, sizeof(uint32_t)+2, M_DONTWAIT); 384190391Ssam if (m1 == NULL) { /* XXX cannot happen */ 385190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 386190391Ssam "%s: no space for tunnel header\n", __func__); 387190391Ssam vap->iv_stats.is_tx_nobuf++; 388190391Ssam return NULL; 389190391Ssam } 390190391Ssam memset(mtod(m1, void *), 0, sizeof(uint32_t)+2); 391190391Ssam 392190391Ssam M_PREPEND(m1, sizeof(struct llc), M_DONTWAIT); 393190391Ssam if (m1 == NULL) { /* XXX cannot happen */ 394190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 395190391Ssam "%s: no space for llc header\n", __func__); 396190391Ssam vap->iv_stats.is_tx_nobuf++; 397190391Ssam return NULL; 398190391Ssam } 399190391Ssam llc = mtod(m1, struct llc *); 400190391Ssam llc->llc_dsap = llc->llc_ssap = LLC_SNAP_LSAP; 401190391Ssam llc->llc_control = LLC_UI; 402190391Ssam llc->llc_snap.org_code[0] = ATH_FF_SNAP_ORGCODE_0; 403190391Ssam llc->llc_snap.org_code[1] = ATH_FF_SNAP_ORGCODE_1; 404190391Ssam llc->llc_snap.org_code[2] = ATH_FF_SNAP_ORGCODE_2; 405190391Ssam llc->llc_snap.ether_type = htons(ATH_FF_ETH_TYPE); 406190391Ssam 407190391Ssam vap->iv_stats.is_ff_encap++; 408190391Ssam 409190391Ssam return m1; 410190391Ssambad: 411190391Ssam if (m1 != NULL) 412190391Ssam m_freem(m1); 413190391Ssam if (m2 != NULL) 414190391Ssam m_freem(m2); 415190391Ssam return NULL; 416190391Ssam} 417190391Ssam 418190391Ssam/* 419190391Ssam * Switch between turbo and non-turbo operating modes. 420190391Ssam * Use the specified channel flags to locate the new 421190391Ssam * channel, update 802.11 state, and then call back into 422190391Ssam * the driver to effect the change. 423190391Ssam */ 424190391Ssamvoid 425190391Ssamieee80211_dturbo_switch(struct ieee80211vap *vap, int newflags) 426190391Ssam{ 427190391Ssam struct ieee80211com *ic = vap->iv_ic; 428190391Ssam struct ieee80211_channel *chan; 429190391Ssam 430190391Ssam chan = ieee80211_find_channel(ic, ic->ic_bsschan->ic_freq, newflags); 431190391Ssam if (chan == NULL) { /* XXX should not happen */ 432190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 433190391Ssam "%s: no channel with freq %u flags 0x%x\n", 434190391Ssam __func__, ic->ic_bsschan->ic_freq, newflags); 435190391Ssam return; 436190391Ssam } 437190391Ssam 438190391Ssam IEEE80211_DPRINTF(vap, IEEE80211_MSG_SUPERG, 439190391Ssam "%s: %s -> %s (freq %u flags 0x%x)\n", __func__, 440190391Ssam ieee80211_phymode_name[ieee80211_chan2mode(ic->ic_bsschan)], 441190391Ssam ieee80211_phymode_name[ieee80211_chan2mode(chan)], 442190391Ssam chan->ic_freq, chan->ic_flags); 443190391Ssam 444190391Ssam ic->ic_bsschan = chan; 445190391Ssam ic->ic_prevchan = ic->ic_curchan; 446190391Ssam ic->ic_curchan = chan; 447190391Ssam ic->ic_set_channel(ic); 448190391Ssam /* NB: do not need to reset ERP state 'cuz we're in sta mode */ 449190391Ssam} 450190391Ssam 451190391Ssam/* 452190391Ssam * Return the current ``state'' of an Atheros capbility. 453190391Ssam * If associated in station mode report the negotiated 454190391Ssam * setting. Otherwise report the current setting. 455190391Ssam */ 456190391Ssamstatic int 457190391Ssamgetathcap(struct ieee80211vap *vap, int cap) 458190391Ssam{ 459190391Ssam if (vap->iv_opmode == IEEE80211_M_STA && 460190391Ssam vap->iv_state == IEEE80211_S_RUN) 461190391Ssam return IEEE80211_ATH_CAP(vap, vap->iv_bss, cap) != 0; 462190391Ssam else 463190391Ssam return (vap->iv_flags & cap) != 0; 464190391Ssam} 465190391Ssam 466190391Ssamstatic int 467190391Ssamsuperg_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) 468190391Ssam{ 469190391Ssam switch (ireq->i_type) { 470190391Ssam case IEEE80211_IOC_FF: 471190391Ssam ireq->i_val = getathcap(vap, IEEE80211_F_FF); 472190391Ssam break; 473190391Ssam case IEEE80211_IOC_TURBOP: 474190391Ssam ireq->i_val = getathcap(vap, IEEE80211_F_TURBOP); 475190391Ssam break; 476190391Ssam default: 477190391Ssam return ENOSYS; 478190391Ssam } 479190391Ssam return 0; 480190391Ssam} 481190391SsamIEEE80211_IOCTL_GET(superg, superg_ioctl_get80211); 482190391Ssam 483190391Ssamstatic int 484190391Ssamsuperg_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) 485190391Ssam{ 486190391Ssam switch (ireq->i_type) { 487190391Ssam case IEEE80211_IOC_FF: 488190391Ssam if (ireq->i_val) { 489190391Ssam if ((vap->iv_caps & IEEE80211_C_FF) == 0) 490190391Ssam return EOPNOTSUPP; 491190391Ssam vap->iv_flags |= IEEE80211_F_FF; 492190391Ssam } else 493190391Ssam vap->iv_flags &= ~IEEE80211_F_FF; 494190391Ssam return ERESTART; 495190391Ssam case IEEE80211_IOC_TURBOP: 496190391Ssam if (ireq->i_val) { 497190391Ssam if ((vap->iv_caps & IEEE80211_C_TURBOP) == 0) 498190391Ssam return EOPNOTSUPP; 499190391Ssam vap->iv_flags |= IEEE80211_F_TURBOP; 500190391Ssam } else 501190391Ssam vap->iv_flags &= ~IEEE80211_F_TURBOP; 502190391Ssam return ENETRESET; 503190391Ssam default: 504190391Ssam return ENOSYS; 505190391Ssam } 506190391Ssam return 0; 507190391Ssam} 508190391SsamIEEE80211_IOCTL_SET(superg, superg_ioctl_set80211); 509