aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/main.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c320
1 files changed, 61 insertions, 259 deletions
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index facff102dd0e..1447b55a8d0a 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -73,7 +73,7 @@ static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc,
73 73
74 chan_idx = curchan->hw_value; 74 chan_idx = curchan->hw_value;
75 channel = &sc->sc_ah->channels[chan_idx]; 75 channel = &sc->sc_ah->channels[chan_idx];
76 ath9k_update_ichannel(sc, hw, channel); 76 ath9k_cmn_update_ichannel(channel, curchan, hw->conf.channel_type);
77 return channel; 77 return channel;
78} 78}
79 79
@@ -215,7 +215,6 @@ static void ath_update_survey_stats(struct ath_softc *sc)
215int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, 215int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
216 struct ath9k_channel *hchan) 216 struct ath9k_channel *hchan)
217{ 217{
218 struct ath_wiphy *aphy = hw->priv;
219 struct ath_hw *ah = sc->sc_ah; 218 struct ath_hw *ah = sc->sc_ah;
220 struct ath_common *common = ath9k_hw_common(ah); 219 struct ath_common *common = ath9k_hw_common(ah);
221 struct ieee80211_conf *conf = &common->hw->conf; 220 struct ieee80211_conf *conf = &common->hw->conf;
@@ -231,6 +230,7 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
231 cancel_work_sync(&sc->paprd_work); 230 cancel_work_sync(&sc->paprd_work);
232 cancel_work_sync(&sc->hw_check_work); 231 cancel_work_sync(&sc->hw_check_work);
233 cancel_delayed_work_sync(&sc->tx_complete_work); 232 cancel_delayed_work_sync(&sc->tx_complete_work);
233 cancel_delayed_work_sync(&sc->hw_pll_work);
234 234
235 ath9k_ps_wakeup(sc); 235 ath9k_ps_wakeup(sc);
236 236
@@ -262,7 +262,7 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
262 fastcc = false; 262 fastcc = false;
263 263
264 if (!(sc->sc_flags & SC_OP_OFFCHANNEL)) 264 if (!(sc->sc_flags & SC_OP_OFFCHANNEL))
265 caldata = &aphy->caldata; 265 caldata = &sc->caldata;
266 266
267 ath_dbg(common, ATH_DBG_CONFIG, 267 ath_dbg(common, ATH_DBG_CONFIG,
268 "(%u MHz) -> (%u MHz), conf_is_ht40: %d fastcc: %d\n", 268 "(%u MHz) -> (%u MHz), conf_is_ht40: %d fastcc: %d\n",
@@ -291,10 +291,13 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
291 if (sc->sc_flags & SC_OP_BEACONS) 291 if (sc->sc_flags & SC_OP_BEACONS)
292 ath_beacon_config(sc, NULL); 292 ath_beacon_config(sc, NULL);
293 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); 293 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
294 ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/2);
294 ath_start_ani(common); 295 ath_start_ani(common);
295 } 296 }
296 297
297 ps_restore: 298 ps_restore:
299 ieee80211_wake_queues(hw);
300
298 spin_unlock_bh(&sc->sc_pcu_lock); 301 spin_unlock_bh(&sc->sc_pcu_lock);
299 302
300 ath9k_ps_restore(sc); 303 ath9k_ps_restore(sc);
@@ -328,6 +331,8 @@ static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int
328{ 331{
329 struct ieee80211_hw *hw = sc->hw; 332 struct ieee80211_hw *hw = sc->hw;
330 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 333 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
334 struct ath_hw *ah = sc->sc_ah;
335 struct ath_common *common = ath9k_hw_common(ah);
331 struct ath_tx_control txctl; 336 struct ath_tx_control txctl;
332 int time_left; 337 int time_left;
333 338
@@ -345,8 +350,12 @@ static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int
345 init_completion(&sc->paprd_complete); 350 init_completion(&sc->paprd_complete);
346 sc->paprd_pending = true; 351 sc->paprd_pending = true;
347 txctl.paprd = BIT(chain); 352 txctl.paprd = BIT(chain);
348 if (ath_tx_start(hw, skb, &txctl) != 0) 353
354 if (ath_tx_start(hw, skb, &txctl) != 0) {
355 ath_dbg(common, ATH_DBG_XMIT, "PAPRD TX failed\n");
356 dev_kfree_skb_any(skb);
349 return false; 357 return false;
358 }
350 359
351 time_left = wait_for_completion_timeout(&sc->paprd_complete, 360 time_left = wait_for_completion_timeout(&sc->paprd_complete,
352 msecs_to_jiffies(ATH_PAPRD_TIMEOUT)); 361 msecs_to_jiffies(ATH_PAPRD_TIMEOUT));
@@ -803,54 +812,11 @@ chip_reset:
803#undef SCHED_INTR 812#undef SCHED_INTR
804} 813}
805 814
806static u32 ath_get_extchanmode(struct ath_softc *sc,
807 struct ieee80211_channel *chan,
808 enum nl80211_channel_type channel_type)
809{
810 u32 chanmode = 0;
811
812 switch (chan->band) {
813 case IEEE80211_BAND_2GHZ:
814 switch(channel_type) {
815 case NL80211_CHAN_NO_HT:
816 case NL80211_CHAN_HT20:
817 chanmode = CHANNEL_G_HT20;
818 break;
819 case NL80211_CHAN_HT40PLUS:
820 chanmode = CHANNEL_G_HT40PLUS;
821 break;
822 case NL80211_CHAN_HT40MINUS:
823 chanmode = CHANNEL_G_HT40MINUS;
824 break;
825 }
826 break;
827 case IEEE80211_BAND_5GHZ:
828 switch(channel_type) {
829 case NL80211_CHAN_NO_HT:
830 case NL80211_CHAN_HT20:
831 chanmode = CHANNEL_A_HT20;
832 break;
833 case NL80211_CHAN_HT40PLUS:
834 chanmode = CHANNEL_A_HT40PLUS;
835 break;
836 case NL80211_CHAN_HT40MINUS:
837 chanmode = CHANNEL_A_HT40MINUS;
838 break;
839 }
840 break;
841 default:
842 break;
843 }
844
845 return chanmode;
846}
847
848static void ath9k_bss_assoc_info(struct ath_softc *sc, 815static void ath9k_bss_assoc_info(struct ath_softc *sc,
849 struct ieee80211_hw *hw, 816 struct ieee80211_hw *hw,
850 struct ieee80211_vif *vif, 817 struct ieee80211_vif *vif,
851 struct ieee80211_bss_conf *bss_conf) 818 struct ieee80211_bss_conf *bss_conf)
852{ 819{
853 struct ath_wiphy *aphy = hw->priv;
854 struct ath_hw *ah = sc->sc_ah; 820 struct ath_hw *ah = sc->sc_ah;
855 struct ath_common *common = ath9k_hw_common(ah); 821 struct ath_common *common = ath9k_hw_common(ah);
856 822
@@ -874,7 +840,7 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
874 ath_beacon_config(sc, vif); 840 ath_beacon_config(sc, vif);
875 841
876 /* Reset rssi stats */ 842 /* Reset rssi stats */
877 aphy->last_rssi = ATH_RSSI_DUMMY_MARKER; 843 sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
878 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER; 844 sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
879 845
880 sc->sc_flags |= SC_OP_ANI_RUN; 846 sc->sc_flags |= SC_OP_ANI_RUN;
@@ -977,8 +943,6 @@ void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
977 943
978 spin_unlock_bh(&sc->sc_pcu_lock); 944 spin_unlock_bh(&sc->sc_pcu_lock);
979 ath9k_ps_restore(sc); 945 ath9k_ps_restore(sc);
980
981 ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
982} 946}
983 947
984int ath_reset(struct ath_softc *sc, bool retry_tx) 948int ath_reset(struct ath_softc *sc, bool retry_tx)
@@ -1043,38 +1007,13 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
1043 return r; 1007 return r;
1044} 1008}
1045 1009
1046/* XXX: Remove me once we don't depend on ath9k_channel for all
1047 * this redundant data */
1048void ath9k_update_ichannel(struct ath_softc *sc, struct ieee80211_hw *hw,
1049 struct ath9k_channel *ichan)
1050{
1051 struct ieee80211_channel *chan = hw->conf.channel;
1052 struct ieee80211_conf *conf = &hw->conf;
1053
1054 ichan->channel = chan->center_freq;
1055 ichan->chan = chan;
1056
1057 if (chan->band == IEEE80211_BAND_2GHZ) {
1058 ichan->chanmode = CHANNEL_G;
1059 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM | CHANNEL_G;
1060 } else {
1061 ichan->chanmode = CHANNEL_A;
1062 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
1063 }
1064
1065 if (conf_is_ht(conf))
1066 ichan->chanmode = ath_get_extchanmode(sc, chan,
1067 conf->channel_type);
1068}
1069
1070/**********************/ 1010/**********************/
1071/* mac80211 callbacks */ 1011/* mac80211 callbacks */
1072/**********************/ 1012/**********************/
1073 1013
1074static int ath9k_start(struct ieee80211_hw *hw) 1014static int ath9k_start(struct ieee80211_hw *hw)
1075{ 1015{
1076 struct ath_wiphy *aphy = hw->priv; 1016 struct ath_softc *sc = hw->priv;
1077 struct ath_softc *sc = aphy->sc;
1078 struct ath_hw *ah = sc->sc_ah; 1017 struct ath_hw *ah = sc->sc_ah;
1079 struct ath_common *common = ath9k_hw_common(ah); 1018 struct ath_common *common = ath9k_hw_common(ah);
1080 struct ieee80211_channel *curchan = hw->conf.channel; 1019 struct ieee80211_channel *curchan = hw->conf.channel;
@@ -1087,29 +1026,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
1087 1026
1088 mutex_lock(&sc->mutex); 1027 mutex_lock(&sc->mutex);
1089 1028
1090 if (ath9k_wiphy_started(sc)) {
1091 if (sc->chan_idx == curchan->hw_value) {
1092 /*
1093 * Already on the operational channel, the new wiphy
1094 * can be marked active.
1095 */
1096 aphy->state = ATH_WIPHY_ACTIVE;
1097 ieee80211_wake_queues(hw);
1098 } else {
1099 /*
1100 * Another wiphy is on another channel, start the new
1101 * wiphy in paused state.
1102 */
1103 aphy->state = ATH_WIPHY_PAUSED;
1104 ieee80211_stop_queues(hw);
1105 }
1106 mutex_unlock(&sc->mutex);
1107 return 0;
1108 }
1109 aphy->state = ATH_WIPHY_ACTIVE;
1110
1111 /* setup initial channel */ 1029 /* setup initial channel */
1112
1113 sc->chan_idx = curchan->hw_value; 1030 sc->chan_idx = curchan->hw_value;
1114 1031
1115 init_channel = ath_get_curchannel(sc, hw); 1032 init_channel = ath_get_curchannel(sc, hw);
@@ -1213,19 +1130,11 @@ mutex_unlock:
1213static int ath9k_tx(struct ieee80211_hw *hw, 1130static int ath9k_tx(struct ieee80211_hw *hw,
1214 struct sk_buff *skb) 1131 struct sk_buff *skb)
1215{ 1132{
1216 struct ath_wiphy *aphy = hw->priv; 1133 struct ath_softc *sc = hw->priv;
1217 struct ath_softc *sc = aphy->sc;
1218 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1134 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1219 struct ath_tx_control txctl; 1135 struct ath_tx_control txctl;
1220 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1136 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1221 1137
1222 if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
1223 ath_dbg(common, ATH_DBG_XMIT,
1224 "ath9k: %s: TX in unexpected wiphy state %d\n",
1225 wiphy_name(hw->wiphy), aphy->state);
1226 goto exit;
1227 }
1228
1229 if (sc->ps_enabled) { 1138 if (sc->ps_enabled) {
1230 /* 1139 /*
1231 * mac80211 does not set PM field for normal data frames, so we 1140 * mac80211 does not set PM field for normal data frames, so we
@@ -1284,44 +1193,26 @@ exit:
1284 1193
1285static void ath9k_stop(struct ieee80211_hw *hw) 1194static void ath9k_stop(struct ieee80211_hw *hw)
1286{ 1195{
1287 struct ath_wiphy *aphy = hw->priv; 1196 struct ath_softc *sc = hw->priv;
1288 struct ath_softc *sc = aphy->sc;
1289 struct ath_hw *ah = sc->sc_ah; 1197 struct ath_hw *ah = sc->sc_ah;
1290 struct ath_common *common = ath9k_hw_common(ah); 1198 struct ath_common *common = ath9k_hw_common(ah);
1291 int i;
1292 1199
1293 mutex_lock(&sc->mutex); 1200 mutex_lock(&sc->mutex);
1294 1201
1295 aphy->state = ATH_WIPHY_INACTIVE;
1296
1297 if (led_blink) 1202 if (led_blink)
1298 cancel_delayed_work_sync(&sc->ath_led_blink_work); 1203 cancel_delayed_work_sync(&sc->ath_led_blink_work);
1299 1204
1300 cancel_delayed_work_sync(&sc->tx_complete_work); 1205 cancel_delayed_work_sync(&sc->tx_complete_work);
1206 cancel_delayed_work_sync(&sc->hw_pll_work);
1301 cancel_work_sync(&sc->paprd_work); 1207 cancel_work_sync(&sc->paprd_work);
1302 cancel_work_sync(&sc->hw_check_work); 1208 cancel_work_sync(&sc->hw_check_work);
1303 1209
1304 for (i = 0; i < sc->num_sec_wiphy; i++) {
1305 if (sc->sec_wiphy[i])
1306 break;
1307 }
1308
1309 if (i == sc->num_sec_wiphy) {
1310 cancel_delayed_work_sync(&sc->wiphy_work);
1311 cancel_work_sync(&sc->chan_work);
1312 }
1313
1314 if (sc->sc_flags & SC_OP_INVALID) { 1210 if (sc->sc_flags & SC_OP_INVALID) {
1315 ath_dbg(common, ATH_DBG_ANY, "Device not present\n"); 1211 ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
1316 mutex_unlock(&sc->mutex); 1212 mutex_unlock(&sc->mutex);
1317 return; 1213 return;
1318 } 1214 }
1319 1215
1320 if (ath9k_wiphy_started(sc)) {
1321 mutex_unlock(&sc->mutex);
1322 return; /* another wiphy still in use */
1323 }
1324
1325 /* Ensure HW is awake when we try to shut it down. */ 1216 /* Ensure HW is awake when we try to shut it down. */
1326 ath9k_ps_wakeup(sc); 1217 ath9k_ps_wakeup(sc);
1327 1218
@@ -1333,6 +1224,9 @@ static void ath9k_stop(struct ieee80211_hw *hw)
1333 1224
1334 spin_lock_bh(&sc->sc_pcu_lock); 1225 spin_lock_bh(&sc->sc_pcu_lock);
1335 1226
1227 /* prevent tasklets to enable interrupts once we disable them */
1228 ah->imask &= ~ATH9K_INT_GLOBAL;
1229
1336 /* make sure h/w will not generate any interrupt 1230 /* make sure h/w will not generate any interrupt
1337 * before setting the invalid flag. */ 1231 * before setting the invalid flag. */
1338 ath9k_hw_disable_interrupts(ah); 1232 ath9k_hw_disable_interrupts(ah);
@@ -1344,16 +1238,26 @@ static void ath9k_stop(struct ieee80211_hw *hw)
1344 } else 1238 } else
1345 sc->rx.rxlink = NULL; 1239 sc->rx.rxlink = NULL;
1346 1240
1241 if (sc->rx.frag) {
1242 dev_kfree_skb_any(sc->rx.frag);
1243 sc->rx.frag = NULL;
1244 }
1245
1347 /* disable HAL and put h/w to sleep */ 1246 /* disable HAL and put h/w to sleep */
1348 ath9k_hw_disable(ah); 1247 ath9k_hw_disable(ah);
1349 ath9k_hw_configpcipowersave(ah, 1, 1); 1248 ath9k_hw_configpcipowersave(ah, 1, 1);
1350 1249
1351 spin_unlock_bh(&sc->sc_pcu_lock); 1250 spin_unlock_bh(&sc->sc_pcu_lock);
1352 1251
1252 /* we can now sync irq and kill any running tasklets, since we already
1253 * disabled interrupts and not holding a spin lock */
1254 synchronize_irq(sc->irq);
1255 tasklet_kill(&sc->intr_tq);
1256 tasklet_kill(&sc->bcon_tasklet);
1257
1353 ath9k_ps_restore(sc); 1258 ath9k_ps_restore(sc);
1354 1259
1355 sc->ps_idle = true; 1260 sc->ps_idle = true;
1356 ath9k_set_wiphy_idle(aphy, true);
1357 ath_radio_disable(sc, hw); 1261 ath_radio_disable(sc, hw);
1358 1262
1359 sc->sc_flags |= SC_OP_INVALID; 1263 sc->sc_flags |= SC_OP_INVALID;
@@ -1439,11 +1343,9 @@ void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
1439 struct ieee80211_vif *vif, 1343 struct ieee80211_vif *vif,
1440 struct ath9k_vif_iter_data *iter_data) 1344 struct ath9k_vif_iter_data *iter_data)
1441{ 1345{
1442 struct ath_wiphy *aphy = hw->priv; 1346 struct ath_softc *sc = hw->priv;
1443 struct ath_softc *sc = aphy->sc;
1444 struct ath_hw *ah = sc->sc_ah; 1347 struct ath_hw *ah = sc->sc_ah;
1445 struct ath_common *common = ath9k_hw_common(ah); 1348 struct ath_common *common = ath9k_hw_common(ah);
1446 int i;
1447 1349
1448 /* 1350 /*
1449 * Use the hardware MAC address as reference, the hardware uses it 1351 * Use the hardware MAC address as reference, the hardware uses it
@@ -1457,24 +1359,15 @@ void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
1457 ath9k_vif_iter(iter_data, vif->addr, vif); 1359 ath9k_vif_iter(iter_data, vif->addr, vif);
1458 1360
1459 /* Get list of all active MAC addresses */ 1361 /* Get list of all active MAC addresses */
1460 spin_lock_bh(&sc->wiphy_lock);
1461 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath9k_vif_iter, 1362 ieee80211_iterate_active_interfaces_atomic(sc->hw, ath9k_vif_iter,
1462 iter_data); 1363 iter_data);
1463 for (i = 0; i < sc->num_sec_wiphy; i++) {
1464 if (sc->sec_wiphy[i] == NULL)
1465 continue;
1466 ieee80211_iterate_active_interfaces_atomic(
1467 sc->sec_wiphy[i]->hw, ath9k_vif_iter, iter_data);
1468 }
1469 spin_unlock_bh(&sc->wiphy_lock);
1470} 1364}
1471 1365
1472/* Called with sc->mutex held. */ 1366/* Called with sc->mutex held. */
1473static void ath9k_calculate_summary_state(struct ieee80211_hw *hw, 1367static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
1474 struct ieee80211_vif *vif) 1368 struct ieee80211_vif *vif)
1475{ 1369{
1476 struct ath_wiphy *aphy = hw->priv; 1370 struct ath_softc *sc = hw->priv;
1477 struct ath_softc *sc = aphy->sc;
1478 struct ath_hw *ah = sc->sc_ah; 1371 struct ath_hw *ah = sc->sc_ah;
1479 struct ath_common *common = ath9k_hw_common(ah); 1372 struct ath_common *common = ath9k_hw_common(ah);
1480 struct ath9k_vif_iter_data iter_data; 1373 struct ath9k_vif_iter_data iter_data;
@@ -1530,8 +1423,7 @@ static void ath9k_calculate_summary_state(struct ieee80211_hw *hw,
1530static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw, 1423static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw,
1531 struct ieee80211_vif *vif) 1424 struct ieee80211_vif *vif)
1532{ 1425{
1533 struct ath_wiphy *aphy = hw->priv; 1426 struct ath_softc *sc = hw->priv;
1534 struct ath_softc *sc = aphy->sc;
1535 1427
1536 ath9k_calculate_summary_state(hw, vif); 1428 ath9k_calculate_summary_state(hw, vif);
1537 1429
@@ -1544,7 +1436,7 @@ static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw,
1544 * in the info_changed method and set up beacons properly 1436 * in the info_changed method and set up beacons properly
1545 * there. 1437 * there.
1546 */ 1438 */
1547 error = ath_beacon_alloc(aphy, vif); 1439 error = ath_beacon_alloc(sc, vif);
1548 if (error) 1440 if (error)
1549 ath9k_reclaim_beacon(sc, vif); 1441 ath9k_reclaim_beacon(sc, vif);
1550 else 1442 else
@@ -1556,8 +1448,7 @@ static void ath9k_do_vif_add_setup(struct ieee80211_hw *hw,
1556static int ath9k_add_interface(struct ieee80211_hw *hw, 1448static int ath9k_add_interface(struct ieee80211_hw *hw,
1557 struct ieee80211_vif *vif) 1449 struct ieee80211_vif *vif)
1558{ 1450{
1559 struct ath_wiphy *aphy = hw->priv; 1451 struct ath_softc *sc = hw->priv;
1560 struct ath_softc *sc = aphy->sc;
1561 struct ath_hw *ah = sc->sc_ah; 1452 struct ath_hw *ah = sc->sc_ah;
1562 struct ath_common *common = ath9k_hw_common(ah); 1453 struct ath_common *common = ath9k_hw_common(ah);
1563 struct ath_vif *avp = (void *)vif->drv_priv; 1454 struct ath_vif *avp = (void *)vif->drv_priv;
@@ -1617,8 +1508,7 @@ static int ath9k_change_interface(struct ieee80211_hw *hw,
1617 enum nl80211_iftype new_type, 1508 enum nl80211_iftype new_type,
1618 bool p2p) 1509 bool p2p)
1619{ 1510{
1620 struct ath_wiphy *aphy = hw->priv; 1511 struct ath_softc *sc = hw->priv;
1621 struct ath_softc *sc = aphy->sc;
1622 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1512 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1623 int ret = 0; 1513 int ret = 0;
1624 1514
@@ -1660,8 +1550,7 @@ out:
1660static void ath9k_remove_interface(struct ieee80211_hw *hw, 1550static void ath9k_remove_interface(struct ieee80211_hw *hw,
1661 struct ieee80211_vif *vif) 1551 struct ieee80211_vif *vif)
1662{ 1552{
1663 struct ath_wiphy *aphy = hw->priv; 1553 struct ath_softc *sc = hw->priv;
1664 struct ath_softc *sc = aphy->sc;
1665 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1554 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1666 1555
1667 ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n"); 1556 ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface\n");
@@ -1715,12 +1604,11 @@ static void ath9k_disable_ps(struct ath_softc *sc)
1715 1604
1716static int ath9k_config(struct ieee80211_hw *hw, u32 changed) 1605static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1717{ 1606{
1718 struct ath_wiphy *aphy = hw->priv; 1607 struct ath_softc *sc = hw->priv;
1719 struct ath_softc *sc = aphy->sc;
1720 struct ath_hw *ah = sc->sc_ah; 1608 struct ath_hw *ah = sc->sc_ah;
1721 struct ath_common *common = ath9k_hw_common(ah); 1609 struct ath_common *common = ath9k_hw_common(ah);
1722 struct ieee80211_conf *conf = &hw->conf; 1610 struct ieee80211_conf *conf = &hw->conf;
1723 bool disable_radio; 1611 bool disable_radio = false;
1724 1612
1725 mutex_lock(&sc->mutex); 1613 mutex_lock(&sc->mutex);
1726 1614
@@ -1731,29 +1619,13 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1731 * the end. 1619 * the end.
1732 */ 1620 */
1733 if (changed & IEEE80211_CONF_CHANGE_IDLE) { 1621 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
1734 bool enable_radio; 1622 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1735 bool all_wiphys_idle; 1623 if (!sc->ps_idle) {
1736 bool idle = !!(conf->flags & IEEE80211_CONF_IDLE);
1737
1738 spin_lock_bh(&sc->wiphy_lock);
1739 all_wiphys_idle = ath9k_all_wiphys_idle(sc);
1740 ath9k_set_wiphy_idle(aphy, idle);
1741
1742 enable_radio = (!idle && all_wiphys_idle);
1743
1744 /*
1745 * After we unlock here its possible another wiphy
1746 * can be re-renabled so to account for that we will
1747 * only disable the radio toward the end of this routine
1748 * if by then all wiphys are still idle.
1749 */
1750 spin_unlock_bh(&sc->wiphy_lock);
1751
1752 if (enable_radio) {
1753 sc->ps_idle = false;
1754 ath_radio_enable(sc, hw); 1624 ath_radio_enable(sc, hw);
1755 ath_dbg(common, ATH_DBG_CONFIG, 1625 ath_dbg(common, ATH_DBG_CONFIG,
1756 "not-idle: enabling radio\n"); 1626 "not-idle: enabling radio\n");
1627 } else {
1628 disable_radio = true;
1757 } 1629 }
1758 } 1630 }
1759 1631
@@ -1794,29 +1666,16 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1794 if (ah->curchan) 1666 if (ah->curchan)
1795 old_pos = ah->curchan - &ah->channels[0]; 1667 old_pos = ah->curchan - &ah->channels[0];
1796 1668
1797 aphy->chan_idx = pos;
1798 aphy->chan_is_ht = conf_is_ht(conf);
1799 if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) 1669 if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
1800 sc->sc_flags |= SC_OP_OFFCHANNEL; 1670 sc->sc_flags |= SC_OP_OFFCHANNEL;
1801 else 1671 else
1802 sc->sc_flags &= ~SC_OP_OFFCHANNEL; 1672 sc->sc_flags &= ~SC_OP_OFFCHANNEL;
1803 1673
1804 if (aphy->state == ATH_WIPHY_SCAN ||
1805 aphy->state == ATH_WIPHY_ACTIVE)
1806 ath9k_wiphy_pause_all_forced(sc, aphy);
1807 else {
1808 /*
1809 * Do not change operational channel based on a paused
1810 * wiphy changes.
1811 */
1812 goto skip_chan_change;
1813 }
1814
1815 ath_dbg(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n", 1674 ath_dbg(common, ATH_DBG_CONFIG, "Set channel: %d MHz\n",
1816 curchan->center_freq); 1675 curchan->center_freq);
1817 1676
1818 /* XXX: remove me eventualy */ 1677 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
1819 ath9k_update_ichannel(sc, hw, &sc->sc_ah->channels[pos]); 1678 curchan, conf->channel_type);
1820 1679
1821 /* update survey stats for the old channel before switching */ 1680 /* update survey stats for the old channel before switching */
1822 spin_lock_irqsave(&common->cc_lock, flags); 1681 spin_lock_irqsave(&common->cc_lock, flags);
@@ -1858,7 +1717,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1858 ath_update_survey_nf(sc, old_pos); 1717 ath_update_survey_nf(sc, old_pos);
1859 } 1718 }
1860 1719
1861skip_chan_change:
1862 if (changed & IEEE80211_CONF_CHANGE_POWER) { 1720 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1863 sc->config.txpowlimit = 2 * conf->power_level; 1721 sc->config.txpowlimit = 2 * conf->power_level;
1864 ath9k_ps_wakeup(sc); 1722 ath9k_ps_wakeup(sc);
@@ -1866,13 +1724,8 @@ skip_chan_change:
1866 ath9k_ps_restore(sc); 1724 ath9k_ps_restore(sc);
1867 } 1725 }
1868 1726
1869 spin_lock_bh(&sc->wiphy_lock);
1870 disable_radio = ath9k_all_wiphys_idle(sc);
1871 spin_unlock_bh(&sc->wiphy_lock);
1872
1873 if (disable_radio) { 1727 if (disable_radio) {
1874 ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n"); 1728 ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
1875 sc->ps_idle = true;
1876 ath_radio_disable(sc, hw); 1729 ath_radio_disable(sc, hw);
1877 } 1730 }
1878 1731
@@ -1897,8 +1750,7 @@ static void ath9k_configure_filter(struct ieee80211_hw *hw,
1897 unsigned int *total_flags, 1750 unsigned int *total_flags,
1898 u64 multicast) 1751 u64 multicast)
1899{ 1752{
1900 struct ath_wiphy *aphy = hw->priv; 1753 struct ath_softc *sc = hw->priv;
1901 struct ath_softc *sc = aphy->sc;
1902 u32 rfilt; 1754 u32 rfilt;
1903 1755
1904 changed_flags &= SUPPORTED_FILTERS; 1756 changed_flags &= SUPPORTED_FILTERS;
@@ -1918,8 +1770,7 @@ static int ath9k_sta_add(struct ieee80211_hw *hw,
1918 struct ieee80211_vif *vif, 1770 struct ieee80211_vif *vif,
1919 struct ieee80211_sta *sta) 1771 struct ieee80211_sta *sta)
1920{ 1772{
1921 struct ath_wiphy *aphy = hw->priv; 1773 struct ath_softc *sc = hw->priv;
1922 struct ath_softc *sc = aphy->sc;
1923 1774
1924 ath_node_attach(sc, sta); 1775 ath_node_attach(sc, sta);
1925 1776
@@ -1930,8 +1781,7 @@ static int ath9k_sta_remove(struct ieee80211_hw *hw,
1930 struct ieee80211_vif *vif, 1781 struct ieee80211_vif *vif,
1931 struct ieee80211_sta *sta) 1782 struct ieee80211_sta *sta)
1932{ 1783{
1933 struct ath_wiphy *aphy = hw->priv; 1784 struct ath_softc *sc = hw->priv;
1934 struct ath_softc *sc = aphy->sc;
1935 1785
1936 ath_node_detach(sc, sta); 1786 ath_node_detach(sc, sta);
1937 1787
@@ -1941,8 +1791,7 @@ static int ath9k_sta_remove(struct ieee80211_hw *hw,
1941static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue, 1791static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
1942 const struct ieee80211_tx_queue_params *params) 1792 const struct ieee80211_tx_queue_params *params)
1943{ 1793{
1944 struct ath_wiphy *aphy = hw->priv; 1794 struct ath_softc *sc = hw->priv;
1945 struct ath_softc *sc = aphy->sc;
1946 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1795 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1947 struct ath_txq *txq; 1796 struct ath_txq *txq;
1948 struct ath9k_tx_queue_info qi; 1797 struct ath9k_tx_queue_info qi;
@@ -1986,8 +1835,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
1986 struct ieee80211_sta *sta, 1835 struct ieee80211_sta *sta,
1987 struct ieee80211_key_conf *key) 1836 struct ieee80211_key_conf *key)
1988{ 1837{
1989 struct ath_wiphy *aphy = hw->priv; 1838 struct ath_softc *sc = hw->priv;
1990 struct ath_softc *sc = aphy->sc;
1991 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 1839 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1992 int ret = 0; 1840 int ret = 0;
1993 1841
@@ -2031,8 +1879,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
2031 struct ieee80211_bss_conf *bss_conf, 1879 struct ieee80211_bss_conf *bss_conf,
2032 u32 changed) 1880 u32 changed)
2033{ 1881{
2034 struct ath_wiphy *aphy = hw->priv; 1882 struct ath_softc *sc = hw->priv;
2035 struct ath_softc *sc = aphy->sc;
2036 struct ath_hw *ah = sc->sc_ah; 1883 struct ath_hw *ah = sc->sc_ah;
2037 struct ath_common *common = ath9k_hw_common(ah); 1884 struct ath_common *common = ath9k_hw_common(ah);
2038 struct ath_vif *avp = (void *)vif->drv_priv; 1885 struct ath_vif *avp = (void *)vif->drv_priv;
@@ -2062,7 +1909,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
2062 if ((changed & BSS_CHANGED_BEACON) || 1909 if ((changed & BSS_CHANGED_BEACON) ||
2063 ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon)) { 1910 ((changed & BSS_CHANGED_BEACON_ENABLED) && bss_conf->enable_beacon)) {
2064 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); 1911 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
2065 error = ath_beacon_alloc(aphy, vif); 1912 error = ath_beacon_alloc(sc, vif);
2066 if (!error) 1913 if (!error)
2067 ath_beacon_config(sc, vif); 1914 ath_beacon_config(sc, vif);
2068 } 1915 }
@@ -2099,7 +1946,7 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
2099 if (vif->type == NL80211_IFTYPE_AP) { 1946 if (vif->type == NL80211_IFTYPE_AP) {
2100 sc->sc_flags |= SC_OP_TSF_RESET; 1947 sc->sc_flags |= SC_OP_TSF_RESET;
2101 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq); 1948 ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
2102 error = ath_beacon_alloc(aphy, vif); 1949 error = ath_beacon_alloc(sc, vif);
2103 if (!error) 1950 if (!error)
2104 ath_beacon_config(sc, vif); 1951 ath_beacon_config(sc, vif);
2105 } else { 1952 } else {
@@ -2137,9 +1984,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
2137 1984
2138static u64 ath9k_get_tsf(struct ieee80211_hw *hw) 1985static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
2139{ 1986{
1987 struct ath_softc *sc = hw->priv;
2140 u64 tsf; 1988 u64 tsf;
2141 struct ath_wiphy *aphy = hw->priv;
2142 struct ath_softc *sc = aphy->sc;
2143 1989
2144 mutex_lock(&sc->mutex); 1990 mutex_lock(&sc->mutex);
2145 ath9k_ps_wakeup(sc); 1991 ath9k_ps_wakeup(sc);
@@ -2152,8 +1998,7 @@ static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
2152 1998
2153static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf) 1999static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
2154{ 2000{
2155 struct ath_wiphy *aphy = hw->priv; 2001 struct ath_softc *sc = hw->priv;
2156 struct ath_softc *sc = aphy->sc;
2157 2002
2158 mutex_lock(&sc->mutex); 2003 mutex_lock(&sc->mutex);
2159 ath9k_ps_wakeup(sc); 2004 ath9k_ps_wakeup(sc);
@@ -2164,8 +2009,7 @@ static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
2164 2009
2165static void ath9k_reset_tsf(struct ieee80211_hw *hw) 2010static void ath9k_reset_tsf(struct ieee80211_hw *hw)
2166{ 2011{
2167 struct ath_wiphy *aphy = hw->priv; 2012 struct ath_softc *sc = hw->priv;
2168 struct ath_softc *sc = aphy->sc;
2169 2013
2170 mutex_lock(&sc->mutex); 2014 mutex_lock(&sc->mutex);
2171 2015
@@ -2182,8 +2026,7 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
2182 struct ieee80211_sta *sta, 2026 struct ieee80211_sta *sta,
2183 u16 tid, u16 *ssn, u8 buf_size) 2027 u16 tid, u16 *ssn, u8 buf_size)
2184{ 2028{
2185 struct ath_wiphy *aphy = hw->priv; 2029 struct ath_softc *sc = hw->priv;
2186 struct ath_softc *sc = aphy->sc;
2187 int ret = 0; 2030 int ret = 0;
2188 2031
2189 local_bh_disable(); 2032 local_bh_disable();
@@ -2228,8 +2071,7 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
2228static int ath9k_get_survey(struct ieee80211_hw *hw, int idx, 2071static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
2229 struct survey_info *survey) 2072 struct survey_info *survey)
2230{ 2073{
2231 struct ath_wiphy *aphy = hw->priv; 2074 struct ath_softc *sc = hw->priv;
2232 struct ath_softc *sc = aphy->sc;
2233 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 2075 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2234 struct ieee80211_supported_band *sband; 2076 struct ieee80211_supported_band *sband;
2235 struct ieee80211_channel *chan; 2077 struct ieee80211_channel *chan;
@@ -2263,47 +2105,9 @@ static int ath9k_get_survey(struct ieee80211_hw *hw, int idx,
2263 return 0; 2105 return 0;
2264} 2106}
2265 2107
2266static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
2267{
2268 struct ath_wiphy *aphy = hw->priv;
2269 struct ath_softc *sc = aphy->sc;
2270
2271 mutex_lock(&sc->mutex);
2272 if (ath9k_wiphy_scanning(sc)) {
2273 /*
2274 * There is a race here in mac80211 but fixing it requires
2275 * we revisit how we handle the scan complete callback.
2276 * After mac80211 fixes we will not have configured hardware
2277 * to the home channel nor would we have configured the RX
2278 * filter yet.
2279 */
2280 mutex_unlock(&sc->mutex);
2281 return;
2282 }
2283
2284 aphy->state = ATH_WIPHY_SCAN;
2285 ath9k_wiphy_pause_all_forced(sc, aphy);
2286 mutex_unlock(&sc->mutex);
2287}
2288
2289/*
2290 * XXX: this requires a revisit after the driver
2291 * scan_complete gets moved to another place/removed in mac80211.
2292 */
2293static void ath9k_sw_scan_complete(struct ieee80211_hw *hw)
2294{
2295 struct ath_wiphy *aphy = hw->priv;
2296 struct ath_softc *sc = aphy->sc;
2297
2298 mutex_lock(&sc->mutex);
2299 aphy->state = ATH_WIPHY_ACTIVE;
2300 mutex_unlock(&sc->mutex);
2301}
2302
2303static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class) 2108static void ath9k_set_coverage_class(struct ieee80211_hw *hw, u8 coverage_class)
2304{ 2109{
2305 struct ath_wiphy *aphy = hw->priv; 2110 struct ath_softc *sc = hw->priv;
2306 struct ath_softc *sc = aphy->sc;
2307 struct ath_hw *ah = sc->sc_ah; 2111 struct ath_hw *ah = sc->sc_ah;
2308 2112
2309 mutex_lock(&sc->mutex); 2113 mutex_lock(&sc->mutex);
@@ -2331,8 +2135,6 @@ struct ieee80211_ops ath9k_ops = {
2331 .reset_tsf = ath9k_reset_tsf, 2135 .reset_tsf = ath9k_reset_tsf,
2332 .ampdu_action = ath9k_ampdu_action, 2136 .ampdu_action = ath9k_ampdu_action,
2333 .get_survey = ath9k_get_survey, 2137 .get_survey = ath9k_get_survey,
2334 .sw_scan_start = ath9k_sw_scan_start,
2335 .sw_scan_complete = ath9k_sw_scan_complete,
2336 .rfkill_poll = ath9k_rfkill_poll_state, 2138 .rfkill_poll = ath9k_rfkill_poll_state,
2337 .set_coverage_class = ath9k_set_coverage_class, 2139 .set_coverage_class = ath9k_set_coverage_class,
2338}; 2140};