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