Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6

+303 -296
+69 -68
Documentation/rfkill.txt
··· 3 3 4 4 1. Introduction 5 5 2. Implementation details 6 - 3. Kernel driver guidelines 7 - 4. Kernel API 8 - 5. Userspace support 6 + 3. Kernel API 7 + 4. Userspace support 9 8 10 9 11 10 1. Introduction ··· 18 19 situations where transmitters need to be turned off, for example on 19 20 aircraft. 20 21 22 + The rfkill subsystem has a concept of "hard" and "soft" block, which 23 + differ little in their meaning (block == transmitters off) but rather in 24 + whether they can be changed or not: 25 + - hard block: read-only radio block that cannot be overriden by software 26 + - soft block: writable radio block (need not be readable) that is set by 27 + the system software. 21 28 22 29 23 30 2. Implementation details 24 31 25 - The rfkill subsystem is composed of various components: the rfkill class, the 26 - rfkill-input module (an input layer handler), and some specific input layer 27 - events. 32 + The rfkill subsystem is composed of three main components: 33 + * the rfkill core, 34 + * the deprecated rfkill-input module (an input layer handler, being 35 + replaced by userspace policy code) and 36 + * the rfkill drivers. 28 37 29 - The rfkill class is provided for kernel drivers to register their radio 30 - transmitter with the kernel, provide methods for turning it on and off and, 31 - optionally, letting the system know about hardware-disabled states that may 32 - be implemented on the device. This code is enabled with the CONFIG_RFKILL 33 - Kconfig option, which drivers can "select". 38 + The rfkill core provides API for kernel drivers to register their radio 39 + transmitter with the kernel, methods for turning it on and off and, letting 40 + the system know about hardware-disabled states that may be implemented on 41 + the device. 34 42 35 - The rfkill class code also notifies userspace of state changes, this is 36 - achieved via uevents. It also provides some sysfs files for userspace to 37 - check the status of radio transmitters. See the "Userspace support" section 38 - below. 39 - 40 - 41 - The rfkill-input code implements a basic response to rfkill buttons -- it 42 - implements turning on/off all devices of a certain class (or all). 43 + The rfkill core code also notifies userspace of state changes, and provides 44 + ways for userspace to query the current states. See the "Userspace support" 45 + section below. 43 46 44 47 When the device is hard-blocked (either by a call to rfkill_set_hw_state() 45 - or from query_hw_block) set_block() will be invoked but drivers can well 46 - ignore the method call since they can use the return value of the function 47 - rfkill_set_hw_state() to sync the software state instead of keeping track 48 - of calls to set_block(). 48 + or from query_hw_block) set_block() will be invoked for additional software 49 + block, but drivers can ignore the method call since they can use the return 50 + value of the function rfkill_set_hw_state() to sync the software state 51 + instead of keeping track of calls to set_block(). In fact, drivers should 52 + use the return value of rfkill_set_hw_state() unless the hardware actually 53 + keeps track of soft and hard block separately. 49 54 50 55 51 - The entire functionality is spread over more than one subsystem: 52 - 53 - * The kernel input layer generates KEY_WWAN, KEY_WLAN etc. and 54 - SW_RFKILL_ALL -- when the user presses a button. Drivers for radio 55 - transmitters generally do not register to the input layer, unless the 56 - device really provides an input device (i.e. a button that has no 57 - effect other than generating a button press event) 58 - 59 - * The rfkill-input code hooks up to these events and switches the soft-block 60 - of the various radio transmitters, depending on the button type. 61 - 62 - * The rfkill drivers turn off/on their transmitters as requested. 63 - 64 - * The rfkill class will generate userspace notifications (uevents) to tell 65 - userspace what the current state is. 56 + 3. Kernel API 66 57 67 58 68 - 69 - 3. Kernel driver guidelines 70 - 71 - 72 - Drivers for radio transmitters normally implement only the rfkill class. 73 - These drivers may not unblock the transmitter based on own decisions, they 74 - should act on information provided by the rfkill class only. 59 + Drivers for radio transmitters normally implement an rfkill driver. 75 60 76 61 Platform drivers might implement input devices if the rfkill button is just 77 62 that, a button. If that button influences the hardware then you need to 78 - implement an rfkill class instead. This also applies if the platform provides 63 + implement an rfkill driver instead. This also applies if the platform provides 79 64 a way to turn on/off the transmitter(s). 80 65 81 - During suspend/hibernation, transmitters should only be left enabled when 82 - wake-on wlan or similar functionality requires it and the device wasn't 83 - blocked before suspend/hibernate. Note that it may be necessary to update 84 - the rfkill subsystem's idea of what the current state is at resume time if 85 - the state may have changed over suspend. 66 + For some platforms, it is possible that the hardware state changes during 67 + suspend/hibernation, in which case it will be necessary to update the rfkill 68 + core with the current state is at resume time. 86 69 70 + To create an rfkill driver, driver's Kconfig needs to have 87 71 72 + depends on RFKILL || !RFKILL 88 73 89 - 4. Kernel API 90 - 91 - To build a driver with rfkill subsystem support, the driver should depend on 92 - (or select) the Kconfig symbol RFKILL. 93 - 94 - The hardware the driver talks to may be write-only (where the current state 95 - of the hardware is unknown), or read-write (where the hardware can be queried 96 - about its current state). 74 + to ensure the driver cannot be built-in when rfkill is modular. The !RFKILL 75 + case allows the driver to be built when rfkill is not configured, which which 76 + case all rfkill API can still be used but will be provided by static inlines 77 + which compile to almost nothing. 97 78 98 79 Calling rfkill_set_hw_state() when a state change happens is required from 99 80 rfkill drivers that control devices that can be hard-blocked unless they also ··· 84 105 85 106 5. Userspace support 86 107 87 - The following sysfs entries exist for every rfkill device: 108 + The recommended userspace interface to use is /dev/rfkill, which is a misc 109 + character device that allows userspace to obtain and set the state of rfkill 110 + devices and sets of devices. It also notifies userspace about device addition 111 + and removal. The API is a simple read/write API that is defined in 112 + linux/rfkill.h, with one ioctl that allows turning off the deprecated input 113 + handler in the kernel for the transition period. 114 + 115 + Except for the one ioctl, communication with the kernel is done via read() 116 + and write() of instances of 'struct rfkill_event'. In this structure, the 117 + soft and hard block are properly separated (unlike sysfs, see below) and 118 + userspace is able to get a consistent snapshot of all rfkill devices in the 119 + system. Also, it is possible to switch all rfkill drivers (or all drivers of 120 + a specified type) into a state which also updates the default state for 121 + hotplugged devices. 122 + 123 + After an application opens /dev/rfkill, it can read the current state of 124 + all devices, and afterwards can poll the descriptor for hotplug or state 125 + change events. 126 + 127 + Applications must ignore operations (the "op" field) they do not handle, 128 + this allows the API to be extended in the future. 129 + 130 + Additionally, each rfkill device is registered in sysfs and there has the 131 + following attributes: 88 132 89 133 name: Name assigned by driver to this key (interface or driver name). 90 - type: Name of the key type ("wlan", "bluetooth", etc). 134 + type: Driver type string ("wlan", "bluetooth", etc). 91 135 state: Current state of the transmitter 92 136 0: RFKILL_STATE_SOFT_BLOCKED 93 137 transmitter is turned off by software ··· 119 117 2: RFKILL_STATE_HARD_BLOCKED 120 118 transmitter is forced off by something outside of 121 119 the driver's control. 122 - claim: 0: Kernel handles events (currently always reads that value) 120 + This file is deprecated because it can only properly show 121 + three of the four possible states, soft-and-hard-blocked is 122 + missing. 123 + claim: 0: Kernel handles events 124 + This file is deprecated because there no longer is a way to 125 + claim just control over a single rfkill instance. 123 126 124 127 rfkill devices also issue uevents (with an action of "change"), with the 125 128 following environment variables set: ··· 135 128 136 129 The contents of these variables corresponds to the "name", "state" and 137 130 "type" sysfs files explained above. 138 - 139 - An alternative userspace interface exists as a misc device /dev/rfkill, 140 - which allows userspace to obtain and set the state of rfkill devices and 141 - sets of devices. It also notifies userspace about device addition and 142 - removal. The API is a simple read/write API that is defined in 143 - linux/rfkill.h.
+3 -2
drivers/net/wireless/ath/ath5k/pcu.c
··· 733 733 /* 734 734 * Set the beacon register and enable all timers. 735 735 */ 736 - /* When in AP mode zero timer0 to start TSF */ 737 - if (ah->ah_op_mode == NL80211_IFTYPE_AP) 736 + /* When in AP or Mesh Point mode zero timer0 to start TSF */ 737 + if (ah->ah_op_mode == NL80211_IFTYPE_AP || 738 + ah->ah_op_mode == NL80211_IFTYPE_MESH_POINT) 738 739 ath5k_hw_reg_write(ah, 0, AR5K_TIMER0); 739 740 740 741 ath5k_hw_reg_write(ah, next_beacon, AR5K_TIMER0);
-1
drivers/net/wireless/ath/ath9k/Kconfig
··· 1 1 config ATH9K 2 2 tristate "Atheros 802.11n wireless cards support" 3 3 depends on PCI && MAC80211 && WLAN_80211 4 - depends on RFKILL || RFKILL=n 5 4 select ATH_COMMON 6 5 select MAC80211_LEDS 7 6 select LEDS_CLASS
+1 -9
drivers/net/wireless/ath/ath9k/ath9k.h
··· 21 21 #include <linux/device.h> 22 22 #include <net/mac80211.h> 23 23 #include <linux/leds.h> 24 - #include <linux/rfkill.h> 25 24 26 25 #include "hw.h" 27 26 #include "rc.h" ··· 459 460 bool registered; 460 461 }; 461 462 462 - struct ath_rfkill { 463 - struct rfkill *rfkill; 464 - struct rfkill_ops ops; 465 - char rfkill_name[32]; 466 - }; 467 - 468 463 /********************/ 469 464 /* Main driver core */ 470 465 /********************/ ··· 498 505 #define SC_OP_PROTECT_ENABLE BIT(6) 499 506 #define SC_OP_RXFLUSH BIT(7) 500 507 #define SC_OP_LED_ASSOCIATED BIT(8) 501 - #define SC_OP_RFKILL_REGISTERED BIT(9) 502 508 #define SC_OP_WAIT_FOR_BEACON BIT(12) 503 509 #define SC_OP_LED_ON BIT(13) 504 510 #define SC_OP_SCANNING BIT(14) ··· 583 591 584 592 int beacon_interval; 585 593 586 - struct ath_rfkill rf_kill; 587 594 struct ath_ani ani; 588 595 struct ath9k_node_stats nodestats; 589 596 #ifdef CONFIG_ATH9K_DEBUG ··· 668 677 if (atomic_dec_and_test(&sc->ps_usecount)) 669 678 if ((sc->hw->conf.flags & IEEE80211_CONF_PS) && 670 679 !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON | 680 + SC_OP_WAIT_FOR_CAB | 671 681 SC_OP_WAIT_FOR_PSPOLL_DATA | 672 682 SC_OP_WAIT_FOR_TX_ACK))) 673 683 ath9k_hw_setpower(sc->sc_ah,
+13 -16
drivers/net/wireless/ath/ath9k/hw.c
··· 2186 2186 REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask); 2187 2187 } 2188 2188 2189 + static void ath9k_enable_rfkill(struct ath_hw *ah) 2190 + { 2191 + REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, 2192 + AR_GPIO_INPUT_EN_VAL_RFSILENT_BB); 2193 + 2194 + REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2, 2195 + AR_GPIO_INPUT_MUX2_RFSILENT); 2196 + 2197 + ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio); 2198 + REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB); 2199 + } 2200 + 2189 2201 int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, 2190 2202 bool bChannelChange) 2191 2203 { ··· 2325 2313 ath9k_hw_init_interrupt_masks(ah, ah->opmode); 2326 2314 ath9k_hw_init_qos(ah); 2327 2315 2328 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 2329 2316 if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) 2330 2317 ath9k_enable_rfkill(ah); 2331 - #endif 2318 + 2332 2319 ath9k_hw_init_user_settings(ah); 2333 2320 2334 2321 REG_WRITE(ah, AR_STA_ID1, ··· 3623 3612 REG_RMW(ah, AR_GPIO_IN_OUT, ((val & 1) << gpio), 3624 3613 AR_GPIO_BIT(gpio)); 3625 3614 } 3626 - 3627 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 3628 - void ath9k_enable_rfkill(struct ath_hw *ah) 3629 - { 3630 - REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, 3631 - AR_GPIO_INPUT_EN_VAL_RFSILENT_BB); 3632 - 3633 - REG_CLR_BIT(ah, AR_GPIO_INPUT_MUX2, 3634 - AR_GPIO_INPUT_MUX2_RFSILENT); 3635 - 3636 - ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio); 3637 - REG_SET_BIT(ah, AR_PHY_TEST, RFSILENT_BB); 3638 - } 3639 - #endif 3640 3615 3641 3616 u32 ath9k_hw_getdefantenna(struct ath_hw *ah) 3642 3617 {
-3
drivers/net/wireless/ath/ath9k/hw.h
··· 565 565 void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, 566 566 u32 ah_signal_type); 567 567 void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); 568 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 569 - void ath9k_enable_rfkill(struct ath_hw *ah); 570 - #endif 571 568 u32 ath9k_hw_getdefantenna(struct ath_hw *ah); 572 569 void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); 573 570 bool ath9k_hw_setantennaswitch(struct ath_hw *ah,
+41 -89
drivers/net/wireless/ath/ath9k/main.c
··· 231 231 } 232 232 } 233 233 234 + static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc, 235 + struct ieee80211_hw *hw) 236 + { 237 + struct ieee80211_channel *curchan = hw->conf.channel; 238 + struct ath9k_channel *channel; 239 + u8 chan_idx; 240 + 241 + chan_idx = curchan->hw_value; 242 + channel = &sc->sc_ah->channels[chan_idx]; 243 + ath9k_update_ichannel(sc, hw, channel); 244 + return channel; 245 + } 246 + 234 247 /* 235 248 * Set/change channels. If the channel is really being changed, it's done 236 249 * by reseting the chip. To accomplish this we must first cleanup any pending ··· 296 283 "reset status %d\n", 297 284 channel->center_freq, r); 298 285 spin_unlock_bh(&sc->sc_resetlock); 299 - return r; 286 + goto ps_restore; 300 287 } 301 288 spin_unlock_bh(&sc->sc_resetlock); 302 289 ··· 305 292 if (ath_startrecv(sc) != 0) { 306 293 DPRINTF(sc, ATH_DBG_FATAL, 307 294 "Unable to restart recv logic\n"); 308 - return -EIO; 295 + r = -EIO; 296 + goto ps_restore; 309 297 } 310 298 311 299 ath_cache_conf_rate(sc, &hw->conf); 312 300 ath_update_txpow(sc); 313 301 ath9k_hw_set_interrupts(ah, sc->imask); 302 + 303 + ps_restore: 314 304 ath9k_ps_restore(sc); 315 - return 0; 305 + return r; 316 306 } 317 307 318 308 /* ··· 1126 1110 ath9k_ps_wakeup(sc); 1127 1111 ath9k_hw_configpcipowersave(ah, 0); 1128 1112 1113 + if (!ah->curchan) 1114 + ah->curchan = ath_get_curchannel(sc, sc->hw); 1115 + 1129 1116 spin_lock_bh(&sc->sc_resetlock); 1130 1117 r = ath9k_hw_reset(ah, ah->curchan, false); 1131 1118 if (r) { ··· 1181 1162 ath_stoprecv(sc); /* turn off frame recv */ 1182 1163 ath_flushrecv(sc); /* flush recv queue */ 1183 1164 1165 + if (!ah->curchan) 1166 + ah->curchan = ath_get_curchannel(sc, sc->hw); 1167 + 1184 1168 spin_lock_bh(&sc->sc_resetlock); 1185 1169 r = ath9k_hw_reset(ah, ah->curchan, false); 1186 1170 if (r) { ··· 1200 1178 ath9k_ps_restore(sc); 1201 1179 } 1202 1180 1203 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 1204 - 1205 1181 /*******************/ 1206 1182 /* Rfkill */ 1207 1183 /*******************/ ··· 1212 1192 ah->rfkill_polarity; 1213 1193 } 1214 1194 1215 - /* s/w rfkill handlers */ 1216 - static int ath_rfkill_set_block(void *data, bool blocked) 1195 + static void ath9k_rfkill_poll_state(struct ieee80211_hw *hw) 1217 1196 { 1218 - struct ath_softc *sc = data; 1197 + struct ath_wiphy *aphy = hw->priv; 1198 + struct ath_softc *sc = aphy->sc; 1199 + bool blocked = !!ath_is_rfkill_set(sc); 1200 + 1201 + wiphy_rfkill_set_hw_state(hw->wiphy, blocked); 1219 1202 1220 1203 if (blocked) 1221 1204 ath_radio_disable(sc); 1222 1205 else 1223 1206 ath_radio_enable(sc); 1224 - 1225 - return 0; 1226 1207 } 1227 1208 1228 - static void ath_rfkill_poll_state(struct rfkill *rfkill, void *data) 1209 + static void ath_start_rfkill_poll(struct ath_softc *sc) 1229 1210 { 1230 - struct ath_softc *sc = data; 1231 - bool blocked = !!ath_is_rfkill_set(sc); 1211 + struct ath_hw *ah = sc->sc_ah; 1232 1212 1233 - if (rfkill_set_hw_state(rfkill, blocked)) 1234 - ath_radio_disable(sc); 1235 - else 1236 - ath_radio_enable(sc); 1213 + if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) 1214 + wiphy_rfkill_start_polling(sc->hw->wiphy); 1237 1215 } 1238 - 1239 - /* Init s/w rfkill */ 1240 - static int ath_init_sw_rfkill(struct ath_softc *sc) 1241 - { 1242 - sc->rf_kill.ops.set_block = ath_rfkill_set_block; 1243 - if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) 1244 - sc->rf_kill.ops.poll = ath_rfkill_poll_state; 1245 - 1246 - snprintf(sc->rf_kill.rfkill_name, sizeof(sc->rf_kill.rfkill_name), 1247 - "ath9k-%s::rfkill", wiphy_name(sc->hw->wiphy)); 1248 - 1249 - sc->rf_kill.rfkill = rfkill_alloc(sc->rf_kill.rfkill_name, 1250 - wiphy_dev(sc->hw->wiphy), 1251 - RFKILL_TYPE_WLAN, 1252 - &sc->rf_kill.ops, sc); 1253 - if (!sc->rf_kill.rfkill) { 1254 - DPRINTF(sc, ATH_DBG_FATAL, "Failed to allocate rfkill\n"); 1255 - return -ENOMEM; 1256 - } 1257 - 1258 - return 0; 1259 - } 1260 - 1261 - /* Deinitialize rfkill */ 1262 - static void ath_deinit_rfkill(struct ath_softc *sc) 1263 - { 1264 - if (sc->sc_flags & SC_OP_RFKILL_REGISTERED) { 1265 - rfkill_unregister(sc->rf_kill.rfkill); 1266 - rfkill_destroy(sc->rf_kill.rfkill); 1267 - sc->sc_flags &= ~SC_OP_RFKILL_REGISTERED; 1268 - } 1269 - } 1270 - 1271 - static int ath_start_rfkill_poll(struct ath_softc *sc) 1272 - { 1273 - if (!(sc->sc_flags & SC_OP_RFKILL_REGISTERED)) { 1274 - if (rfkill_register(sc->rf_kill.rfkill)) { 1275 - DPRINTF(sc, ATH_DBG_FATAL, 1276 - "Unable to register rfkill\n"); 1277 - rfkill_destroy(sc->rf_kill.rfkill); 1278 - 1279 - /* Deinitialize the device */ 1280 - ath_cleanup(sc); 1281 - return -EIO; 1282 - } else { 1283 - sc->sc_flags |= SC_OP_RFKILL_REGISTERED; 1284 - } 1285 - } 1286 - 1287 - return 0; 1288 - } 1289 - #endif /* CONFIG_RFKILL */ 1290 1216 1291 1217 void ath_cleanup(struct ath_softc *sc) 1292 1218 { ··· 1252 1286 1253 1287 DPRINTF(sc, ATH_DBG_CONFIG, "Detach ATH hw\n"); 1254 1288 1255 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 1256 - ath_deinit_rfkill(sc); 1257 - #endif 1258 1289 ath_deinit_leds(sc); 1259 1290 cancel_work_sync(&sc->chan_work); 1260 1291 cancel_delayed_work_sync(&sc->wiphy_work); ··· 1589 1626 if (error != 0) 1590 1627 goto error_attach; 1591 1628 1592 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 1593 - /* Initialize s/w rfkill */ 1594 - error = ath_init_sw_rfkill(sc); 1595 - if (error) 1596 - goto error_attach; 1597 - #endif 1598 - 1599 1629 INIT_WORK(&sc->chan_work, ath9k_wiphy_chan_work); 1600 1630 INIT_DELAYED_WORK(&sc->wiphy_work, ath9k_wiphy_work); 1601 1631 sc->wiphy_scheduler_int = msecs_to_jiffies(500); ··· 1604 1648 /* Initialize LED control */ 1605 1649 ath_init_leds(sc); 1606 1650 1651 + ath_start_rfkill_poll(sc); 1607 1652 1608 1653 return 0; 1609 1654 ··· 1877 1920 struct ath_softc *sc = aphy->sc; 1878 1921 struct ieee80211_channel *curchan = hw->conf.channel; 1879 1922 struct ath9k_channel *init_channel; 1880 - int r, pos; 1923 + int r; 1881 1924 1882 1925 DPRINTF(sc, ATH_DBG_CONFIG, "Starting driver with " 1883 1926 "initial channel: %d MHz\n", curchan->center_freq); ··· 1907 1950 1908 1951 /* setup initial channel */ 1909 1952 1910 - pos = curchan->hw_value; 1953 + sc->chan_idx = curchan->hw_value; 1911 1954 1912 - sc->chan_idx = pos; 1913 - init_channel = &sc->sc_ah->channels[pos]; 1914 - ath9k_update_ichannel(sc, hw, init_channel); 1955 + init_channel = ath_get_curchannel(sc, hw); 1915 1956 1916 1957 /* Reset SERDES registers */ 1917 1958 ath9k_hw_configpcipowersave(sc->sc_ah, 0); ··· 1972 2017 ath9k_hw_set_interrupts(sc->sc_ah, sc->imask); 1973 2018 1974 2019 ieee80211_wake_queues(hw); 1975 - 1976 - #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 1977 - r = ath_start_rfkill_poll(sc); 1978 - #endif 1979 2020 1980 2021 mutex_unlock: 1981 2022 mutex_unlock(&sc->mutex); ··· 2110 2159 } else 2111 2160 sc->rx.rxlink = NULL; 2112 2161 2113 - rfkill_pause_polling(sc->rf_kill.rfkill); 2162 + wiphy_rfkill_stop_polling(sc->hw->wiphy); 2114 2163 2115 2164 /* disable HAL and put h/w to sleep */ 2116 2165 ath9k_hw_disable(sc->sc_ah); ··· 2716 2765 .ampdu_action = ath9k_ampdu_action, 2717 2766 .sw_scan_start = ath9k_sw_scan_start, 2718 2767 .sw_scan_complete = ath9k_sw_scan_complete, 2768 + .rfkill_poll = ath9k_rfkill_poll_state, 2719 2769 }; 2720 2770 2721 2771 static struct {
+1
drivers/net/wireless/ath/ath9k/recv.c
··· 817 817 } 818 818 819 819 if (unlikely(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON | 820 + SC_OP_WAIT_FOR_CAB | 820 821 SC_OP_WAIT_FOR_PSPOLL_DATA))) 821 822 ath_rx_ps(sc, skb); 822 823
-1
drivers/net/wireless/iwlwifi/iwl-agn.c
··· 2152 2152 /* we should be verifying the device is ready to be opened */ 2153 2153 mutex_lock(&priv->mutex); 2154 2154 2155 - memset(&priv->staging_rxon, 0, sizeof(struct iwl_rxon_cmd)); 2156 2155 /* fetch ucode file from disk, alloc and copy to bus-master buffers ... 2157 2156 * ucode filename and max sizes are card-specific. */ 2158 2157
+85 -54
drivers/net/wireless/iwlwifi/iwl-core.c
··· 629 629 if (!sta_ht_inf->ht_supported) 630 630 return 0; 631 631 } 632 - 633 - if (iwl_ht_conf->ht_protection & IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) 634 - return 1; 635 - else 636 - return iwl_is_channel_extension(priv, priv->band, 637 - le16_to_cpu(priv->staging_rxon.channel), 638 - iwl_ht_conf->extension_chan_offset); 632 + return iwl_is_channel_extension(priv, priv->band, 633 + le16_to_cpu(priv->staging_rxon.channel), 634 + iwl_ht_conf->extension_chan_offset); 639 635 } 640 636 EXPORT_SYMBOL(iwl_is_fat_tx_allowed); 641 637 ··· 822 826 RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); 823 827 if (iwl_is_fat_tx_allowed(priv, NULL)) { 824 828 /* pure 40 fat */ 825 - if (rxon->flags & RXON_FLG_FAT_PROT_MSK) 829 + if (ht_info->ht_protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { 826 830 rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; 827 - else { 831 + /* Note: control channel is opposite of extension channel */ 832 + switch (ht_info->extension_chan_offset) { 833 + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 834 + rxon->flags &= ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; 835 + break; 836 + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: 837 + rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; 838 + break; 839 + } 840 + } else { 828 841 /* Note: control channel is opposite of extension channel */ 829 842 switch (ht_info->extension_chan_offset) { 830 843 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: ··· 2395 2390 priv->ibss_beacon = ieee80211_beacon_get(hw, vif); 2396 2391 } 2397 2392 2398 - if ((changes & BSS_CHANGED_BSSID) && !iwl_is_rfkill(priv)) { 2399 - /* If there is currently a HW scan going on in the background 2400 - * then we need to cancel it else the RXON below will fail. */ 2393 + if (changes & BSS_CHANGED_BEACON_INT) { 2394 + priv->beacon_int = bss_conf->beacon_int; 2395 + /* TODO: in AP mode, do something to make this take effect */ 2396 + } 2397 + 2398 + if (changes & BSS_CHANGED_BSSID) { 2399 + IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); 2400 + 2401 + /* 2402 + * If there is currently a HW scan going on in the 2403 + * background then we need to cancel it else the RXON 2404 + * below/in post_associate will fail. 2405 + */ 2401 2406 if (iwl_scan_cancel_timeout(priv, 100)) { 2402 - IWL_WARN(priv, "Aborted scan still in progress " 2403 - "after 100ms\n"); 2407 + IWL_WARN(priv, "Aborted scan still in progress after 100ms\n"); 2404 2408 IWL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n"); 2405 2409 mutex_unlock(&priv->mutex); 2406 2410 return; 2407 2411 } 2408 - memcpy(priv->staging_rxon.bssid_addr, 2409 - bss_conf->bssid, ETH_ALEN); 2410 2412 2411 - /* TODO: Audit driver for usage of these members and see 2412 - * if mac80211 deprecates them (priv->bssid looks like it 2413 - * shouldn't be there, but I haven't scanned the IBSS code 2414 - * to verify) - jpk */ 2415 - memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); 2413 + /* mac80211 only sets assoc when in STATION mode */ 2414 + if (priv->iw_mode == NL80211_IFTYPE_ADHOC || 2415 + bss_conf->assoc) { 2416 + memcpy(priv->staging_rxon.bssid_addr, 2417 + bss_conf->bssid, ETH_ALEN); 2416 2418 2417 - if (priv->iw_mode == NL80211_IFTYPE_AP) 2418 - iwlcore_config_ap(priv); 2419 - else { 2420 - int rc = iwlcore_commit_rxon(priv); 2421 - if ((priv->iw_mode == NL80211_IFTYPE_STATION) && rc) 2422 - iwl_rxon_add_station( 2423 - priv, priv->active_rxon.bssid_addr, 1); 2419 + /* currently needed in a few places */ 2420 + memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); 2421 + } else { 2422 + priv->staging_rxon.filter_flags &= 2423 + ~RXON_FILTER_ASSOC_MSK; 2424 2424 } 2425 - } else if (!iwl_is_rfkill(priv)) { 2426 - iwl_scan_cancel_timeout(priv, 100); 2427 - priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2428 - iwlcore_commit_rxon(priv); 2425 + 2429 2426 } 2430 2427 2428 + /* 2429 + * This needs to be after setting the BSSID in case 2430 + * mac80211 decides to do both changes at once because 2431 + * it will invoke post_associate. 2432 + */ 2431 2433 if (priv->iw_mode == NL80211_IFTYPE_ADHOC && 2432 2434 changes & BSS_CHANGED_BEACON) { 2433 2435 struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); ··· 2442 2430 if (beacon) 2443 2431 iwl_mac_beacon_update(hw, beacon); 2444 2432 } 2445 - 2446 - mutex_unlock(&priv->mutex); 2447 2433 2448 2434 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 2449 2435 IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", ··· 2460 2450 priv->staging_rxon.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 2461 2451 } 2462 2452 2453 + if (changes & BSS_CHANGED_BASIC_RATES) { 2454 + /* XXX use this information 2455 + * 2456 + * To do that, remove code from iwl_set_rate() and put something 2457 + * like this here: 2458 + * 2459 + if (A-band) 2460 + priv->staging_rxon.ofdm_basic_rates = 2461 + bss_conf->basic_rates; 2462 + else 2463 + priv->staging_rxon.ofdm_basic_rates = 2464 + bss_conf->basic_rates >> 4; 2465 + priv->staging_rxon.cck_basic_rates = 2466 + bss_conf->basic_rates & 0xF; 2467 + */ 2468 + } 2469 + 2463 2470 if (changes & BSS_CHANGED_HT) { 2464 2471 iwl_ht_conf(priv, bss_conf); 2465 2472 ··· 2486 2459 2487 2460 if (changes & BSS_CHANGED_ASSOC) { 2488 2461 IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); 2489 - /* This should never happen as this function should 2490 - * never be called from interrupt context. */ 2491 - if (WARN_ON_ONCE(in_interrupt())) 2492 - return; 2493 2462 if (bss_conf->assoc) { 2494 2463 priv->assoc_id = bss_conf->aid; 2495 2464 priv->beacon_int = bss_conf->beacon_int; ··· 2493 2470 priv->timestamp = bss_conf->timestamp; 2494 2471 priv->assoc_capability = bss_conf->assoc_capability; 2495 2472 2496 - /* we have just associated, don't start scan too early 2497 - * leave time for EAPOL exchange to complete 2473 + /* 2474 + * We have just associated, don't start scan too early 2475 + * leave time for EAPOL exchange to complete. 2476 + * 2477 + * XXX: do this in mac80211 2498 2478 */ 2499 2479 priv->next_scan_jiffies = jiffies + 2500 2480 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC; 2501 - mutex_lock(&priv->mutex); 2502 - priv->cfg->ops->lib->post_associate(priv); 2503 - mutex_unlock(&priv->mutex); 2504 - } else { 2481 + if (!iwl_is_rfkill(priv)) 2482 + priv->cfg->ops->lib->post_associate(priv); 2483 + } else 2505 2484 priv->assoc_id = 0; 2506 - IWL_DEBUG_MAC80211(priv, "DISASSOC %d\n", bss_conf->assoc); 2507 - } 2508 - } else if (changes && iwl_is_associated(priv) && priv->assoc_id) { 2509 - IWL_DEBUG_MAC80211(priv, "Associated Changes %d\n", changes); 2510 - ret = iwl_send_rxon_assoc(priv); 2511 - if (!ret) 2512 - /* Sync active_rxon with latest change. */ 2513 - memcpy((void *)&priv->active_rxon, 2514 - &priv->staging_rxon, 2515 - sizeof(struct iwl_rxon_cmd)); 2485 + 2516 2486 } 2487 + 2488 + if (changes && iwl_is_associated(priv) && priv->assoc_id) { 2489 + IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", 2490 + changes); 2491 + ret = iwl_send_rxon_assoc(priv); 2492 + if (!ret) { 2493 + /* Sync active_rxon with latest change. */ 2494 + memcpy((void *)&priv->active_rxon, 2495 + &priv->staging_rxon, 2496 + sizeof(struct iwl_rxon_cmd)); 2497 + } 2498 + } 2499 + 2500 + mutex_unlock(&priv->mutex); 2501 + 2517 2502 IWL_DEBUG_MAC80211(priv, "leave\n"); 2518 2503 } 2519 2504 EXPORT_SYMBOL(iwl_bss_info_changed);
+1 -3
drivers/net/wireless/iwlwifi/iwl3945-base.c
··· 2498 2498 struct iwl3945_rxon_cmd *active_rxon = 2499 2499 (struct iwl3945_rxon_cmd *)(&priv->active_rxon); 2500 2500 2501 - memcpy(&priv->staging_rxon, &priv->active_rxon, 2502 - sizeof(priv->staging_rxon)); 2501 + priv->staging_rxon.filter_flags |= RXON_FILTER_ASSOC_MSK; 2503 2502 active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; 2504 2503 } else { 2505 2504 /* Initialize our rx_config data */ ··· 3146 3147 /* we should be verifying the device is ready to be opened */ 3147 3148 mutex_lock(&priv->mutex); 3148 3149 3149 - memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon)); 3150 3150 /* fetch ucode file from disk, alloc and copy to bus-master buffers ... 3151 3151 * ucode filename and max sizes are card-specific. */ 3152 3152
+6 -5
drivers/net/wireless/libertas/if_spi.c
··· 812 812 static void if_spi_e2h(struct if_spi_card *card) 813 813 { 814 814 int err = 0; 815 - unsigned long flags; 816 815 u32 cause; 817 816 struct lbs_private *priv = card->priv; 818 817 ··· 826 827 /* generate a card interrupt */ 827 828 spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG, IF_SPI_CIC_HOST_EVENT); 828 829 829 - spin_lock_irqsave(&priv->driver_lock, flags); 830 830 lbs_queue_event(priv, cause & 0xff); 831 - spin_unlock_irqrestore(&priv->driver_lock, flags); 832 - 833 831 out: 834 832 if (err) 835 833 lbs_pr_err("%s: error %d\n", __func__, err); ··· 871 875 err = if_spi_c2h_data(card); 872 876 if (err) 873 877 goto err; 874 - if (hiStatus & IF_SPI_HIST_CMD_DOWNLOAD_RDY) { 878 + 879 + /* workaround: in PS mode, the card does not set the Command 880 + * Download Ready bit, but it sets TX Download Ready. */ 881 + if (hiStatus & IF_SPI_HIST_CMD_DOWNLOAD_RDY || 882 + (card->priv->psstate != PS_STATE_FULL_POWER && 883 + (hiStatus & IF_SPI_HIST_TX_DOWNLOAD_RDY))) { 875 884 /* This means two things. First of all, 876 885 * if there was a previous command sent, the card has 877 886 * successfully received it.
+1 -1
drivers/platform/x86/dell-laptop.c
··· 177 177 static int dell_rfkill_set(void *data, bool blocked) 178 178 { 179 179 struct calling_interface_buffer buffer; 180 - int disable = blocked ? 0 : 1; 180 + int disable = blocked ? 1 : 0; 181 181 unsigned long radio = (unsigned long)data; 182 182 183 183 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
+3 -2
drivers/platform/x86/sony-laptop.c
··· 1133 1133 continue; 1134 1134 1135 1135 if (hwblock) { 1136 - if (rfkill_set_hw_state(sony_rfkill_devices[i], true)) 1137 - sony_nc_rfkill_set((void *)i, true); 1136 + if (rfkill_set_hw_state(sony_rfkill_devices[i], true)) { 1137 + /* we already know we're blocked */ 1138 + } 1138 1139 continue; 1139 1140 } 1140 1141
+25
net/mac80211/debugfs.c
··· 163 163 .open = mac80211_open_file_generic 164 164 }; 165 165 166 + static ssize_t queues_read(struct file *file, char __user *user_buf, 167 + size_t count, loff_t *ppos) 168 + { 169 + struct ieee80211_local *local = file->private_data; 170 + unsigned long flags; 171 + char buf[IEEE80211_MAX_QUEUES * 20]; 172 + int q, res = 0; 173 + 174 + spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 175 + for (q = 0; q < local->hw.queues; q++) 176 + res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q, 177 + local->queue_stop_reasons[q], 178 + __netif_subqueue_stopped(local->mdev, q)); 179 + spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 180 + 181 + return simple_read_from_buffer(user_buf, count, ppos, buf, res); 182 + } 183 + 184 + static const struct file_operations queues_ops = { 185 + .read = queues_read, 186 + .open = mac80211_open_file_generic 187 + }; 188 + 166 189 /* statistics stuff */ 167 190 168 191 #define DEBUGFS_STATS_FILE(name, buflen, fmt, value...) \ ··· 321 298 DEBUGFS_ADD(total_ps_buffered); 322 299 DEBUGFS_ADD(wep_iv); 323 300 DEBUGFS_ADD(tsf); 301 + DEBUGFS_ADD(queues); 324 302 DEBUGFS_ADD_MODE(reset, 0200); 325 303 DEBUGFS_ADD(noack); 326 304 ··· 374 350 DEBUGFS_DEL(total_ps_buffered); 375 351 DEBUGFS_DEL(wep_iv); 376 352 DEBUGFS_DEL(tsf); 353 + DEBUGFS_DEL(queues); 377 354 DEBUGFS_DEL(reset); 378 355 DEBUGFS_DEL(noack); 379 356
+1 -1
net/mac80211/ieee80211_i.h
··· 783 783 struct dentry *total_ps_buffered; 784 784 struct dentry *wep_iv; 785 785 struct dentry *tsf; 786 + struct dentry *queues; 786 787 struct dentry *reset; 787 788 struct dentry *noack; 788 789 struct dentry *statistics; ··· 1101 1100 u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, 1102 1101 struct ieee802_11_elems *elems, 1103 1102 u64 filter, u32 crc); 1104 - int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq); 1105 1103 u32 ieee80211_mandatory_rates(struct ieee80211_local *local, 1106 1104 enum ieee80211_band band); 1107 1105
+26 -12
net/mac80211/mlme.c
··· 1102 1102 struct sta_info *sta; 1103 1103 u32 changed = 0, config_changed = 0; 1104 1104 1105 - rcu_read_lock(); 1106 - 1107 - sta = sta_info_get(local, ifmgd->bssid); 1108 - if (!sta) { 1109 - rcu_read_unlock(); 1110 - return; 1111 - } 1112 - 1113 1105 if (deauth) { 1114 1106 ifmgd->direct_probe_tries = 0; 1115 1107 ifmgd->auth_tries = 0; ··· 1112 1120 netif_tx_stop_all_queues(sdata->dev); 1113 1121 netif_carrier_off(sdata->dev); 1114 1122 1115 - ieee80211_sta_tear_down_BA_sessions(sta); 1123 + rcu_read_lock(); 1124 + sta = sta_info_get(local, ifmgd->bssid); 1125 + if (sta) 1126 + ieee80211_sta_tear_down_BA_sessions(sta); 1127 + rcu_read_unlock(); 1116 1128 1117 1129 bss = ieee80211_rx_bss_get(local, ifmgd->bssid, 1118 1130 conf->channel->center_freq, ··· 1151 1155 sdata->local->hw.conf.channel->center_freq, 1152 1156 ifmgd->ssid, ifmgd->ssid_len); 1153 1157 } 1154 - 1155 - rcu_read_unlock(); 1156 1158 1157 1159 ieee80211_set_wmm_default(sdata); 1158 1160 ··· 2217 2223 capa_mask, capa_val); 2218 2224 2219 2225 if (bss) { 2220 - ieee80211_set_freq(sdata, bss->cbss.channel->center_freq); 2226 + local->oper_channel = bss->cbss.channel; 2227 + local->oper_channel_type = NL80211_CHAN_NO_HT; 2228 + ieee80211_hw_config(local, 0); 2229 + 2221 2230 if (!(ifmgd->flags & IEEE80211_STA_SSID_SET)) 2222 2231 ieee80211_sta_set_ssid(sdata, bss->ssid, 2223 2232 bss->ssid_len); ··· 2442 2445 ieee80211_set_disassoc(sdata, true, true, 2443 2446 WLAN_REASON_DEAUTH_LEAVING); 2444 2447 2448 + if (ifmgd->ssid_len == 0) { 2449 + /* 2450 + * Only allow association to be started if a valid SSID 2451 + * is configured. 2452 + */ 2453 + return; 2454 + } 2455 + 2445 2456 if (!(ifmgd->flags & IEEE80211_STA_EXT_SME) || 2446 2457 ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE) 2447 2458 set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); ··· 2481 2476 ifmgd = &sdata->u.mgd; 2482 2477 2483 2478 if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) { 2479 + if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) 2480 + ieee80211_set_disassoc(sdata, true, true, 2481 + WLAN_REASON_DEAUTH_LEAVING); 2482 + 2484 2483 /* 2485 2484 * Do not use reassociation if SSID is changed (different ESS). 2486 2485 */ ··· 2508 2499 int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) 2509 2500 { 2510 2501 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2502 + 2503 + if (compare_ether_addr(bssid, ifmgd->bssid) != 0 && 2504 + ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) 2505 + ieee80211_set_disassoc(sdata, true, true, 2506 + WLAN_REASON_DEAUTH_LEAVING); 2511 2507 2512 2508 if (is_valid_ether_addr(bssid)) { 2513 2509 memcpy(ifmgd->bssid, bssid, ETH_ALEN);
-25
net/mac80211/util.c
··· 774 774 dev_queue_xmit(skb); 775 775 } 776 776 777 - int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freqMHz) 778 - { 779 - int ret = -EINVAL; 780 - struct ieee80211_channel *chan; 781 - struct ieee80211_local *local = sdata->local; 782 - 783 - chan = ieee80211_get_channel(local->hw.wiphy, freqMHz); 784 - 785 - if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) { 786 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC && 787 - chan->flags & IEEE80211_CHAN_NO_IBSS) 788 - return ret; 789 - local->oper_channel = chan; 790 - local->oper_channel_type = NL80211_CHAN_NO_HT; 791 - 792 - if (local->sw_scanning || local->hw_scanning) 793 - ret = 0; 794 - else 795 - ret = ieee80211_hw_config( 796 - local, IEEE80211_CONF_CHANGE_CHANNEL); 797 - } 798 - 799 - return ret; 800 - } 801 - 802 777 u32 ieee80211_mandatory_rates(struct ieee80211_local *local, 803 778 enum ieee80211_band band) 804 779 {
+27 -4
net/mac80211/wext.c
··· 55 55 struct iw_freq *freq, char *extra) 56 56 { 57 57 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 58 + struct ieee80211_local *local = sdata->local; 59 + struct ieee80211_channel *chan; 58 60 59 61 if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 60 62 return cfg80211_ibss_wext_siwfreq(dev, info, freq, extra); ··· 71 69 IEEE80211_STA_AUTO_CHANNEL_SEL; 72 70 return 0; 73 71 } else 74 - return ieee80211_set_freq(sdata, 72 + chan = ieee80211_get_channel(local->hw.wiphy, 75 73 ieee80211_channel_to_frequency(freq->m)); 76 74 } else { 77 75 int i, div = 1000000; 78 76 for (i = 0; i < freq->e; i++) 79 77 div /= 10; 80 - if (div > 0) 81 - return ieee80211_set_freq(sdata, freq->m / div); 82 - else 78 + if (div <= 0) 83 79 return -EINVAL; 80 + chan = ieee80211_get_channel(local->hw.wiphy, freq->m / div); 84 81 } 82 + 83 + if (!chan) 84 + return -EINVAL; 85 + 86 + if (chan->flags & IEEE80211_CHAN_DISABLED) 87 + return -EINVAL; 88 + 89 + /* 90 + * no change except maybe auto -> fixed, ignore the HT 91 + * setting so you can fix a channel you're on already 92 + */ 93 + if (local->oper_channel == chan) 94 + return 0; 95 + 96 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 97 + ieee80211_sta_req_auth(sdata); 98 + 99 + local->oper_channel = chan; 100 + local->oper_channel_type = NL80211_CHAN_NO_HT; 101 + ieee80211_hw_config(local, 0); 102 + 103 + return 0; 85 104 } 86 105 87 106