aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_main.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c393
1 files changed, 258 insertions, 135 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 776cd7c4114..48a4b9961ae 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -124,28 +124,28 @@ static struct conf_drv_settings default_conf = {
124 }, 124 },
125 .ac_conf_count = 4, 125 .ac_conf_count = 4,
126 .ac_conf = { 126 .ac_conf = {
127 [0] = { 127 [CONF_TX_AC_BE] = {
128 .ac = CONF_TX_AC_BE, 128 .ac = CONF_TX_AC_BE,
129 .cw_min = 15, 129 .cw_min = 15,
130 .cw_max = 63, 130 .cw_max = 63,
131 .aifsn = 3, 131 .aifsn = 3,
132 .tx_op_limit = 0, 132 .tx_op_limit = 0,
133 }, 133 },
134 [1] = { 134 [CONF_TX_AC_BK] = {
135 .ac = CONF_TX_AC_BK, 135 .ac = CONF_TX_AC_BK,
136 .cw_min = 15, 136 .cw_min = 15,
137 .cw_max = 63, 137 .cw_max = 63,
138 .aifsn = 7, 138 .aifsn = 7,
139 .tx_op_limit = 0, 139 .tx_op_limit = 0,
140 }, 140 },
141 [2] = { 141 [CONF_TX_AC_VI] = {
142 .ac = CONF_TX_AC_VI, 142 .ac = CONF_TX_AC_VI,
143 .cw_min = 15, 143 .cw_min = 15,
144 .cw_max = 63, 144 .cw_max = 63,
145 .aifsn = CONF_TX_AIFS_PIFS, 145 .aifsn = CONF_TX_AIFS_PIFS,
146 .tx_op_limit = 3008, 146 .tx_op_limit = 3008,
147 }, 147 },
148 [3] = { 148 [CONF_TX_AC_VO] = {
149 .ac = CONF_TX_AC_VO, 149 .ac = CONF_TX_AC_VO,
150 .cw_min = 15, 150 .cw_min = 15,
151 .cw_max = 63, 151 .cw_max = 63,
@@ -153,64 +153,40 @@ static struct conf_drv_settings default_conf = {
153 .tx_op_limit = 1504, 153 .tx_op_limit = 1504,
154 }, 154 },
155 }, 155 },
156 .tid_conf_count = 7, 156 .tid_conf_count = 4,
157 .tid_conf = { 157 .tid_conf = {
158 [0] = { 158 [CONF_TX_AC_BE] = {
159 .queue_id = 0, 159 .queue_id = CONF_TX_AC_BE,
160 .channel_type = CONF_CHANNEL_TYPE_DCF, 160 .channel_type = CONF_CHANNEL_TYPE_EDCF,
161 .tsid = CONF_TX_AC_BE,
162 .ps_scheme = CONF_PS_SCHEME_LEGACY,
163 .ack_policy = CONF_ACK_POLICY_LEGACY,
164 .apsd_conf = {0, 0},
165 },
166 [1] = {
167 .queue_id = 1,
168 .channel_type = CONF_CHANNEL_TYPE_DCF,
169 .tsid = CONF_TX_AC_BE, 161 .tsid = CONF_TX_AC_BE,
170 .ps_scheme = CONF_PS_SCHEME_LEGACY, 162 .ps_scheme = CONF_PS_SCHEME_LEGACY,
171 .ack_policy = CONF_ACK_POLICY_LEGACY, 163 .ack_policy = CONF_ACK_POLICY_LEGACY,
172 .apsd_conf = {0, 0}, 164 .apsd_conf = {0, 0},
173 }, 165 },
174 [2] = { 166 [CONF_TX_AC_BK] = {
175 .queue_id = 2, 167 .queue_id = CONF_TX_AC_BK,
176 .channel_type = CONF_CHANNEL_TYPE_DCF, 168 .channel_type = CONF_CHANNEL_TYPE_EDCF,
177 .tsid = CONF_TX_AC_BE, 169 .tsid = CONF_TX_AC_BK,
178 .ps_scheme = CONF_PS_SCHEME_LEGACY, 170 .ps_scheme = CONF_PS_SCHEME_LEGACY,
179 .ack_policy = CONF_ACK_POLICY_LEGACY, 171 .ack_policy = CONF_ACK_POLICY_LEGACY,
180 .apsd_conf = {0, 0}, 172 .apsd_conf = {0, 0},
181 }, 173 },
182 [3] = { 174 [CONF_TX_AC_VI] = {
183 .queue_id = 3, 175 .queue_id = CONF_TX_AC_VI,
184 .channel_type = CONF_CHANNEL_TYPE_DCF, 176 .channel_type = CONF_CHANNEL_TYPE_EDCF,
185 .tsid = CONF_TX_AC_BE, 177 .tsid = CONF_TX_AC_VI,
186 .ps_scheme = CONF_PS_SCHEME_LEGACY,
187 .ack_policy = CONF_ACK_POLICY_LEGACY,
188 .apsd_conf = {0, 0},
189 },
190 [4] = {
191 .queue_id = 4,
192 .channel_type = CONF_CHANNEL_TYPE_DCF,
193 .tsid = CONF_TX_AC_BE,
194 .ps_scheme = CONF_PS_SCHEME_LEGACY, 178 .ps_scheme = CONF_PS_SCHEME_LEGACY,
195 .ack_policy = CONF_ACK_POLICY_LEGACY, 179 .ack_policy = CONF_ACK_POLICY_LEGACY,
196 .apsd_conf = {0, 0}, 180 .apsd_conf = {0, 0},
197 }, 181 },
198 [5] = { 182 [CONF_TX_AC_VO] = {
199 .queue_id = 5, 183 .queue_id = CONF_TX_AC_VO,
200 .channel_type = CONF_CHANNEL_TYPE_DCF, 184 .channel_type = CONF_CHANNEL_TYPE_EDCF,
201 .tsid = CONF_TX_AC_BE, 185 .tsid = CONF_TX_AC_VO,
202 .ps_scheme = CONF_PS_SCHEME_LEGACY, 186 .ps_scheme = CONF_PS_SCHEME_LEGACY,
203 .ack_policy = CONF_ACK_POLICY_LEGACY, 187 .ack_policy = CONF_ACK_POLICY_LEGACY,
204 .apsd_conf = {0, 0}, 188 .apsd_conf = {0, 0},
205 }, 189 },
206 [6] = {
207 .queue_id = 6,
208 .channel_type = CONF_CHANNEL_TYPE_DCF,
209 .tsid = CONF_TX_AC_BE,
210 .ps_scheme = CONF_PS_SCHEME_LEGACY,
211 .ack_policy = CONF_ACK_POLICY_LEGACY,
212 .apsd_conf = {0, 0},
213 }
214 }, 190 },
215 .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD, 191 .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
216 .tx_compl_timeout = 700, 192 .tx_compl_timeout = 700,
@@ -238,7 +214,9 @@ static struct conf_drv_settings default_conf = {
238 .ps_poll_recovery_period = 700, 214 .ps_poll_recovery_period = 700,
239 .bet_enable = CONF_BET_MODE_ENABLE, 215 .bet_enable = CONF_BET_MODE_ENABLE,
240 .bet_max_consecutive = 10, 216 .bet_max_consecutive = 10,
241 .psm_entry_retries = 3, 217 .psm_entry_retries = 5,
218 .psm_entry_nullfunc_retries = 3,
219 .psm_entry_hangover_period = 1,
242 .keep_alive_interval = 55000, 220 .keep_alive_interval = 55000,
243 .max_listen_interval = 20, 221 .max_listen_interval = 20,
244 }, 222 },
@@ -251,15 +229,34 @@ static struct conf_drv_settings default_conf = {
251 .host_fast_wakeup_support = false 229 .host_fast_wakeup_support = false
252 }, 230 },
253 .roam_trigger = { 231 .roam_trigger = {
254 /* FIXME: due to firmware bug, must use value 1 for now */
255 .trigger_pacing = 1, 232 .trigger_pacing = 1,
256 .avg_weight_rssi_beacon = 20, 233 .avg_weight_rssi_beacon = 20,
257 .avg_weight_rssi_data = 10, 234 .avg_weight_rssi_data = 10,
258 .avg_weight_snr_beacon = 20, 235 .avg_weight_snr_beacon = 20,
259 .avg_weight_snr_data = 10 236 .avg_weight_snr_data = 10
260 } 237 },
238 .scan = {
239 .min_dwell_time_active = 7500,
240 .max_dwell_time_active = 30000,
241 .min_dwell_time_passive = 30000,
242 .max_dwell_time_passive = 60000,
243 .num_probe_reqs = 2,
244 },
245 .rf = {
246 .tx_per_channel_power_compensation_2 = {
247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
248 },
249 .tx_per_channel_power_compensation_5 = {
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
253 },
254 },
261}; 255};
262 256
257static void __wl1271_op_remove_interface(struct wl1271 *wl);
258
259
263static void wl1271_device_release(struct device *dev) 260static void wl1271_device_release(struct device *dev)
264{ 261{
265 262
@@ -277,6 +274,67 @@ static struct platform_device wl1271_device = {
277 274
278static LIST_HEAD(wl_list); 275static LIST_HEAD(wl_list);
279 276
277static int wl1271_dev_notify(struct notifier_block *me, unsigned long what,
278 void *arg)
279{
280 struct net_device *dev = arg;
281 struct wireless_dev *wdev;
282 struct wiphy *wiphy;
283 struct ieee80211_hw *hw;
284 struct wl1271 *wl;
285 struct wl1271 *wl_temp;
286 int ret = 0;
287
288 /* Check that this notification is for us. */
289 if (what != NETDEV_CHANGE)
290 return NOTIFY_DONE;
291
292 wdev = dev->ieee80211_ptr;
293 if (wdev == NULL)
294 return NOTIFY_DONE;
295
296 wiphy = wdev->wiphy;
297 if (wiphy == NULL)
298 return NOTIFY_DONE;
299
300 hw = wiphy_priv(wiphy);
301 if (hw == NULL)
302 return NOTIFY_DONE;
303
304 wl_temp = hw->priv;
305 list_for_each_entry(wl, &wl_list, list) {
306 if (wl == wl_temp)
307 break;
308 }
309 if (wl != wl_temp)
310 return NOTIFY_DONE;
311
312 mutex_lock(&wl->mutex);
313
314 if (wl->state == WL1271_STATE_OFF)
315 goto out;
316
317 if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
318 goto out;
319
320 ret = wl1271_ps_elp_wakeup(wl, false);
321 if (ret < 0)
322 goto out;
323
324 if ((dev->operstate == IF_OPER_UP) &&
325 !test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) {
326 wl1271_cmd_set_sta_state(wl);
327 wl1271_info("Association completed.");
328 }
329
330 wl1271_ps_elp_sleep(wl);
331
332out:
333 mutex_unlock(&wl->mutex);
334
335 return NOTIFY_OK;
336}
337
280static void wl1271_conf_init(struct wl1271 *wl) 338static void wl1271_conf_init(struct wl1271 *wl)
281{ 339{
282 340
@@ -309,6 +367,10 @@ static int wl1271_plt_init(struct wl1271 *wl)
309 if (ret < 0) 367 if (ret < 0)
310 return ret; 368 return ret;
311 369
370 ret = wl1271_cmd_ext_radio_parms(wl);
371 if (ret < 0)
372 return ret;
373
312 ret = wl1271_init_templates_config(wl); 374 ret = wl1271_init_templates_config(wl);
313 if (ret < 0) 375 if (ret < 0)
314 return ret; 376 return ret;
@@ -346,8 +408,16 @@ static int wl1271_plt_init(struct wl1271 *wl)
346 if (ret < 0) 408 if (ret < 0)
347 goto out_free_memmap; 409 goto out_free_memmap;
348 410
349 /* Default TID configuration */ 411 /* Default TID/AC configuration */
412 BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
350 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { 413 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
414 conf_ac = &wl->conf.tx.ac_conf[i];
415 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
416 conf_ac->cw_max, conf_ac->aifsn,
417 conf_ac->tx_op_limit);
418 if (ret < 0)
419 goto out_free_memmap;
420
351 conf_tid = &wl->conf.tx.tid_conf[i]; 421 conf_tid = &wl->conf.tx.tid_conf[i];
352 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id, 422 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
353 conf_tid->channel_type, 423 conf_tid->channel_type,
@@ -360,16 +430,6 @@ static int wl1271_plt_init(struct wl1271 *wl)
360 goto out_free_memmap; 430 goto out_free_memmap;
361 } 431 }
362 432
363 /* Default AC configuration */
364 for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
365 conf_ac = &wl->conf.tx.ac_conf[i];
366 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
367 conf_ac->cw_max, conf_ac->aifsn,
368 conf_ac->tx_op_limit);
369 if (ret < 0)
370 goto out_free_memmap;
371 }
372
373 /* Enable data path */ 433 /* Enable data path */
374 ret = wl1271_cmd_data_path(wl, 1); 434 ret = wl1271_cmd_data_path(wl, 1);
375 if (ret < 0) 435 if (ret < 0)
@@ -562,20 +622,6 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
562 return ret; 622 return ret;
563 } 623 }
564 624
565 /*
566 * FIXME: the LEGACY NVS image support (NVS's missing the 5GHz band
567 * configurations) can be removed when those NVS files stop floating
568 * around.
569 */
570 if (fw->size != sizeof(struct wl1271_nvs_file) &&
571 (fw->size != WL1271_INI_LEGACY_NVS_FILE_SIZE ||
572 wl1271_11a_enabled())) {
573 wl1271_error("nvs size is not as expected: %zu != %zu",
574 fw->size, sizeof(struct wl1271_nvs_file));
575 ret = -EILSEQ;
576 goto out;
577 }
578
579 wl->nvs = kmemdup(fw->data, sizeof(struct wl1271_nvs_file), GFP_KERNEL); 625 wl->nvs = kmemdup(fw->data, sizeof(struct wl1271_nvs_file), GFP_KERNEL);
580 626
581 if (!wl->nvs) { 627 if (!wl->nvs) {
@@ -584,12 +630,37 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
584 goto out; 630 goto out;
585 } 631 }
586 632
633 wl->nvs_len = fw->size;
634
587out: 635out:
588 release_firmware(fw); 636 release_firmware(fw);
589 637
590 return ret; 638 return ret;
591} 639}
592 640
641static void wl1271_recovery_work(struct work_struct *work)
642{
643 struct wl1271 *wl =
644 container_of(work, struct wl1271, recovery_work);
645
646 mutex_lock(&wl->mutex);
647
648 if (wl->state != WL1271_STATE_ON)
649 goto out;
650
651 wl1271_info("Hardware recovery in progress.");
652
653 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
654 ieee80211_connection_loss(wl->vif);
655
656 /* reboot the chipset */
657 __wl1271_op_remove_interface(wl);
658 ieee80211_restart_hw(wl->hw);
659
660out:
661 mutex_unlock(&wl->mutex);
662}
663
593static void wl1271_fw_wakeup(struct wl1271 *wl) 664static void wl1271_fw_wakeup(struct wl1271 *wl)
594{ 665{
595 u32 elp_reg; 666 u32 elp_reg;
@@ -610,8 +681,6 @@ static int wl1271_setup(struct wl1271 *wl)
610 return -ENOMEM; 681 return -ENOMEM;
611 } 682 }
612 683
613 INIT_WORK(&wl->irq_work, wl1271_irq_work);
614 INIT_WORK(&wl->tx_work, wl1271_tx_work);
615 return 0; 684 return 0;
616} 685}
617 686
@@ -768,10 +837,12 @@ int wl1271_plt_stop(struct wl1271 *wl)
768out: 837out:
769 mutex_unlock(&wl->mutex); 838 mutex_unlock(&wl->mutex);
770 839
840 cancel_work_sync(&wl->irq_work);
841 cancel_work_sync(&wl->recovery_work);
842
771 return ret; 843 return ret;
772} 844}
773 845
774
775static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 846static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
776{ 847{
777 struct wl1271 *wl = hw->priv; 848 struct wl1271 *wl = hw->priv;
@@ -814,6 +885,10 @@ static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
814 return NETDEV_TX_OK; 885 return NETDEV_TX_OK;
815} 886}
816 887
888static struct notifier_block wl1271_dev_notifier = {
889 .notifier_call = wl1271_dev_notify,
890};
891
817static int wl1271_op_start(struct ieee80211_hw *hw) 892static int wl1271_op_start(struct ieee80211_hw *hw)
818{ 893{
819 wl1271_debug(DEBUG_MAC80211, "mac80211 start"); 894 wl1271_debug(DEBUG_MAC80211, "mac80211 start");
@@ -930,13 +1005,10 @@ out:
930 return ret; 1005 return ret;
931} 1006}
932 1007
933static void wl1271_op_remove_interface(struct ieee80211_hw *hw, 1008static void __wl1271_op_remove_interface(struct wl1271 *wl)
934 struct ieee80211_vif *vif)
935{ 1009{
936 struct wl1271 *wl = hw->priv;
937 int i; 1010 int i;
938 1011
939 mutex_lock(&wl->mutex);
940 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); 1012 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
941 1013
942 wl1271_info("down"); 1014 wl1271_info("down");
@@ -950,10 +1022,10 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
950 ieee80211_enable_dyn_ps(wl->vif); 1022 ieee80211_enable_dyn_ps(wl->vif);
951 1023
952 if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { 1024 if (wl->scan.state != WL1271_SCAN_STATE_IDLE) {
953 ieee80211_scan_completed(wl->hw, true);
954 wl->scan.state = WL1271_SCAN_STATE_IDLE; 1025 wl->scan.state = WL1271_SCAN_STATE_IDLE;
955 kfree(wl->scan.scanned_ch); 1026 kfree(wl->scan.scanned_ch);
956 wl->scan.scanned_ch = NULL; 1027 wl->scan.scanned_ch = NULL;
1028 ieee80211_scan_completed(wl->hw, true);
957 } 1029 }
958 1030
959 wl->state = WL1271_STATE_OFF; 1031 wl->state = WL1271_STATE_OFF;
@@ -962,9 +1034,11 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
962 1034
963 mutex_unlock(&wl->mutex); 1035 mutex_unlock(&wl->mutex);
964 1036
1037 cancel_delayed_work_sync(&wl->scan_complete_work);
965 cancel_work_sync(&wl->irq_work); 1038 cancel_work_sync(&wl->irq_work);
966 cancel_work_sync(&wl->tx_work); 1039 cancel_work_sync(&wl->tx_work);
967 cancel_delayed_work_sync(&wl->pspoll_work); 1040 cancel_delayed_work_sync(&wl->pspoll_work);
1041 cancel_delayed_work_sync(&wl->elp_work);
968 1042
969 mutex_lock(&wl->mutex); 1043 mutex_lock(&wl->mutex);
970 1044
@@ -1006,8 +1080,19 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
1006 wl->tx_res_if = NULL; 1080 wl->tx_res_if = NULL;
1007 kfree(wl->target_mem_map); 1081 kfree(wl->target_mem_map);
1008 wl->target_mem_map = NULL; 1082 wl->target_mem_map = NULL;
1083}
1084
1085static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
1086 struct ieee80211_vif *vif)
1087{
1088 struct wl1271 *wl = hw->priv;
1009 1089
1090 mutex_lock(&wl->mutex);
1091 WARN_ON(wl->vif != vif);
1092 __wl1271_op_remove_interface(wl);
1010 mutex_unlock(&wl->mutex); 1093 mutex_unlock(&wl->mutex);
1094
1095 cancel_work_sync(&wl->recovery_work);
1011} 1096}
1012 1097
1013static void wl1271_configure_filters(struct wl1271 *wl, unsigned int filters) 1098static void wl1271_configure_filters(struct wl1271 *wl, unsigned int filters)
@@ -1289,7 +1374,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1289 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { 1374 if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) {
1290 wl1271_debug(DEBUG_PSM, "psm enabled"); 1375 wl1271_debug(DEBUG_PSM, "psm enabled");
1291 ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, 1376 ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE,
1292 true); 1377 wl->basic_rate, true);
1293 } 1378 }
1294 } else if (!(conf->flags & IEEE80211_CONF_PS) && 1379 } else if (!(conf->flags & IEEE80211_CONF_PS) &&
1295 test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { 1380 test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) {
@@ -1299,7 +1384,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1299 1384
1300 if (test_bit(WL1271_FLAG_PSM, &wl->flags)) 1385 if (test_bit(WL1271_FLAG_PSM, &wl->flags))
1301 ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, 1386 ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE,
1302 true); 1387 wl->basic_rate, true);
1303 } 1388 }
1304 1389
1305 if (conf->power_level != wl->power_level) { 1390 if (conf->power_level != wl->power_level) {
@@ -1476,6 +1561,11 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1476 tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); 1561 tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq);
1477 tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); 1562 tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq);
1478 break; 1563 break;
1564 case WL1271_CIPHER_SUITE_GEM:
1565 key_type = KEY_GEM;
1566 tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq);
1567 tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq);
1568 break;
1479 default: 1569 default:
1480 wl1271_error("Unknown key algo 0x%x", key_conf->cipher); 1570 wl1271_error("Unknown key algo 0x%x", key_conf->cipher);
1481 1571
@@ -1559,10 +1649,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw,
1559 if (ret < 0) 1649 if (ret < 0)
1560 goto out; 1650 goto out;
1561 1651
1562 if (wl1271_11a_enabled()) 1652 ret = wl1271_scan(hw->priv, ssid, len, req);
1563 ret = wl1271_scan(hw->priv, ssid, len, req);
1564 else
1565 ret = wl1271_scan(hw->priv, ssid, len, req);
1566 1653
1567 wl1271_ps_elp_sleep(wl); 1654 wl1271_ps_elp_sleep(wl);
1568 1655
@@ -1777,12 +1864,15 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
1777 if (test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags) && 1864 if (test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags) &&
1778 !test_bit(WL1271_FLAG_PSM, &wl->flags)) { 1865 !test_bit(WL1271_FLAG_PSM, &wl->flags)) {
1779 mode = STATION_POWER_SAVE_MODE; 1866 mode = STATION_POWER_SAVE_MODE;
1780 ret = wl1271_ps_set_mode(wl, mode, true); 1867 ret = wl1271_ps_set_mode(wl, mode,
1868 wl->basic_rate,
1869 true);
1781 if (ret < 0) 1870 if (ret < 0)
1782 goto out_sleep; 1871 goto out_sleep;
1783 } 1872 }
1784 } else { 1873 } else {
1785 /* use defaults when not associated */ 1874 /* use defaults when not associated */
1875 clear_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags);
1786 clear_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags); 1876 clear_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags);
1787 wl->aid = 0; 1877 wl->aid = 0;
1788 1878
@@ -1994,21 +2084,24 @@ static struct ieee80211_rate wl1271_rates[] = {
1994 .hw_value_short = CONF_HW_BIT_RATE_54MBPS, }, 2084 .hw_value_short = CONF_HW_BIT_RATE_54MBPS, },
1995}; 2085};
1996 2086
1997/* can't be const, mac80211 writes to this */ 2087/*
2088 * Can't be const, mac80211 writes to this. The order of the channels here
2089 * is designed to improve scanning.
2090 */
1998static struct ieee80211_channel wl1271_channels[] = { 2091static struct ieee80211_channel wl1271_channels[] = {
1999 { .hw_value = 1, .center_freq = 2412, .max_power = 25 }, 2092 { .hw_value = 1, .center_freq = 2412, .max_power = 25 },
2000 { .hw_value = 2, .center_freq = 2417, .max_power = 25 },
2001 { .hw_value = 3, .center_freq = 2422, .max_power = 25 },
2002 { .hw_value = 4, .center_freq = 2427, .max_power = 25 },
2003 { .hw_value = 5, .center_freq = 2432, .max_power = 25 }, 2093 { .hw_value = 5, .center_freq = 2432, .max_power = 25 },
2004 { .hw_value = 6, .center_freq = 2437, .max_power = 25 },
2005 { .hw_value = 7, .center_freq = 2442, .max_power = 25 },
2006 { .hw_value = 8, .center_freq = 2447, .max_power = 25 },
2007 { .hw_value = 9, .center_freq = 2452, .max_power = 25 }, 2094 { .hw_value = 9, .center_freq = 2452, .max_power = 25 },
2008 { .hw_value = 10, .center_freq = 2457, .max_power = 25 },
2009 { .hw_value = 11, .center_freq = 2462, .max_power = 25 },
2010 { .hw_value = 12, .center_freq = 2467, .max_power = 25 },
2011 { .hw_value = 13, .center_freq = 2472, .max_power = 25 }, 2095 { .hw_value = 13, .center_freq = 2472, .max_power = 25 },
2096 { .hw_value = 4, .center_freq = 2427, .max_power = 25 },
2097 { .hw_value = 8, .center_freq = 2447, .max_power = 25 },
2098 { .hw_value = 12, .center_freq = 2467, .max_power = 25 },
2099 { .hw_value = 3, .center_freq = 2422, .max_power = 25 },
2100 { .hw_value = 7, .center_freq = 2442, .max_power = 25 },
2101 { .hw_value = 11, .center_freq = 2462, .max_power = 25 },
2102 { .hw_value = 2, .center_freq = 2417, .max_power = 25 },
2103 { .hw_value = 6, .center_freq = 2437, .max_power = 25 },
2104 { .hw_value = 10, .center_freq = 2457, .max_power = 25 },
2012}; 2105};
2013 2106
2014/* mapping to indexes for wl1271_rates */ 2107/* mapping to indexes for wl1271_rates */
@@ -2077,49 +2170,52 @@ static struct ieee80211_rate wl1271_rates_5ghz[] = {
2077 .hw_value_short = CONF_HW_BIT_RATE_54MBPS, }, 2170 .hw_value_short = CONF_HW_BIT_RATE_54MBPS, },
2078}; 2171};
2079 2172
2080/* 5 GHz band channels for WL1273 */ 2173/*
2174 * 5 GHz band channels for WL1273 - can't be const, mac80211 writes to this.
2175 * The order of the channels here is designed to improve scanning.
2176 */
2081static struct ieee80211_channel wl1271_channels_5ghz[] = { 2177static struct ieee80211_channel wl1271_channels_5ghz[] = {
2082 { .hw_value = 183, .center_freq = 4915}, 2178 { .hw_value = 183, .center_freq = 4915},
2083 { .hw_value = 184, .center_freq = 4920},
2084 { .hw_value = 185, .center_freq = 4925},
2085 { .hw_value = 187, .center_freq = 4935},
2086 { .hw_value = 188, .center_freq = 4940}, 2179 { .hw_value = 188, .center_freq = 4940},
2087 { .hw_value = 189, .center_freq = 4945},
2088 { .hw_value = 192, .center_freq = 4960},
2089 { .hw_value = 196, .center_freq = 4980},
2090 { .hw_value = 7, .center_freq = 5035},
2091 { .hw_value = 8, .center_freq = 5040}, 2180 { .hw_value = 8, .center_freq = 5040},
2092 { .hw_value = 9, .center_freq = 5045},
2093 { .hw_value = 11, .center_freq = 5055},
2094 { .hw_value = 12, .center_freq = 5060},
2095 { .hw_value = 16, .center_freq = 5080},
2096 { .hw_value = 34, .center_freq = 5170}, 2181 { .hw_value = 34, .center_freq = 5170},
2097 { .hw_value = 36, .center_freq = 5180},
2098 { .hw_value = 38, .center_freq = 5190},
2099 { .hw_value = 40, .center_freq = 5200},
2100 { .hw_value = 42, .center_freq = 5210},
2101 { .hw_value = 44, .center_freq = 5220}, 2182 { .hw_value = 44, .center_freq = 5220},
2102 { .hw_value = 46, .center_freq = 5230},
2103 { .hw_value = 48, .center_freq = 5240},
2104 { .hw_value = 52, .center_freq = 5260},
2105 { .hw_value = 56, .center_freq = 5280},
2106 { .hw_value = 60, .center_freq = 5300}, 2183 { .hw_value = 60, .center_freq = 5300},
2107 { .hw_value = 64, .center_freq = 5320},
2108 { .hw_value = 100, .center_freq = 5500},
2109 { .hw_value = 104, .center_freq = 5520},
2110 { .hw_value = 108, .center_freq = 5540},
2111 { .hw_value = 112, .center_freq = 5560}, 2184 { .hw_value = 112, .center_freq = 5560},
2112 { .hw_value = 116, .center_freq = 5580},
2113 { .hw_value = 120, .center_freq = 5600},
2114 { .hw_value = 124, .center_freq = 5620},
2115 { .hw_value = 128, .center_freq = 5640},
2116 { .hw_value = 132, .center_freq = 5660}, 2185 { .hw_value = 132, .center_freq = 5660},
2186 { .hw_value = 157, .center_freq = 5785},
2187 { .hw_value = 184, .center_freq = 4920},
2188 { .hw_value = 189, .center_freq = 4945},
2189 { .hw_value = 9, .center_freq = 5045},
2190 { .hw_value = 36, .center_freq = 5180},
2191 { .hw_value = 46, .center_freq = 5230},
2192 { .hw_value = 64, .center_freq = 5320},
2193 { .hw_value = 116, .center_freq = 5580},
2117 { .hw_value = 136, .center_freq = 5680}, 2194 { .hw_value = 136, .center_freq = 5680},
2195 { .hw_value = 192, .center_freq = 4960},
2196 { .hw_value = 11, .center_freq = 5055},
2197 { .hw_value = 38, .center_freq = 5190},
2198 { .hw_value = 48, .center_freq = 5240},
2199 { .hw_value = 100, .center_freq = 5500},
2200 { .hw_value = 120, .center_freq = 5600},
2118 { .hw_value = 140, .center_freq = 5700}, 2201 { .hw_value = 140, .center_freq = 5700},
2202 { .hw_value = 185, .center_freq = 4925},
2203 { .hw_value = 196, .center_freq = 4980},
2204 { .hw_value = 12, .center_freq = 5060},
2205 { .hw_value = 40, .center_freq = 5200},
2206 { .hw_value = 52, .center_freq = 5260},
2207 { .hw_value = 104, .center_freq = 5520},
2208 { .hw_value = 124, .center_freq = 5620},
2119 { .hw_value = 149, .center_freq = 5745}, 2209 { .hw_value = 149, .center_freq = 5745},
2120 { .hw_value = 153, .center_freq = 5765},
2121 { .hw_value = 157, .center_freq = 5785},
2122 { .hw_value = 161, .center_freq = 5805}, 2210 { .hw_value = 161, .center_freq = 5805},
2211 { .hw_value = 187, .center_freq = 4935},
2212 { .hw_value = 7, .center_freq = 5035},
2213 { .hw_value = 16, .center_freq = 5080},
2214 { .hw_value = 42, .center_freq = 5210},
2215 { .hw_value = 56, .center_freq = 5280},
2216 { .hw_value = 108, .center_freq = 5540},
2217 { .hw_value = 128, .center_freq = 5640},
2218 { .hw_value = 153, .center_freq = 5765},
2123 { .hw_value = 165, .center_freq = 5825}, 2219 { .hw_value = 165, .center_freq = 5825},
2124}; 2220};
2125 2221
@@ -2212,8 +2308,7 @@ static ssize_t wl1271_sysfs_show_bt_coex_state(struct device *dev,
2212 struct wl1271 *wl = dev_get_drvdata(dev); 2308 struct wl1271 *wl = dev_get_drvdata(dev);
2213 ssize_t len; 2309 ssize_t len;
2214 2310
2215 /* FIXME: what's the maximum length of buf? page size?*/ 2311 len = PAGE_SIZE;
2216 len = 500;
2217 2312
2218 mutex_lock(&wl->mutex); 2313 mutex_lock(&wl->mutex);
2219 len = snprintf(buf, len, "%d\n\n0 - off\n1 - on\n", 2314 len = snprintf(buf, len, "%d\n\n0 - off\n1 - on\n",
@@ -2274,8 +2369,7 @@ static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev,
2274 struct wl1271 *wl = dev_get_drvdata(dev); 2369 struct wl1271 *wl = dev_get_drvdata(dev);
2275 ssize_t len; 2370 ssize_t len;
2276 2371
2277 /* FIXME: what's the maximum length of buf? page size?*/ 2372 len = PAGE_SIZE;
2278 len = 500;
2279 2373
2280 mutex_lock(&wl->mutex); 2374 mutex_lock(&wl->mutex);
2281 if (wl->hw_pg_ver >= 0) 2375 if (wl->hw_pg_ver >= 0)
@@ -2307,6 +2401,8 @@ int wl1271_register_hw(struct wl1271 *wl)
2307 2401
2308 wl->mac80211_registered = true; 2402 wl->mac80211_registered = true;
2309 2403
2404 register_netdevice_notifier(&wl1271_dev_notifier);
2405
2310 wl1271_notice("loaded"); 2406 wl1271_notice("loaded");
2311 2407
2312 return 0; 2408 return 0;
@@ -2315,6 +2411,7 @@ EXPORT_SYMBOL_GPL(wl1271_register_hw);
2315 2411
2316void wl1271_unregister_hw(struct wl1271 *wl) 2412void wl1271_unregister_hw(struct wl1271 *wl)
2317{ 2413{
2414 unregister_netdevice_notifier(&wl1271_dev_notifier);
2318 ieee80211_unregister_hw(wl->hw); 2415 ieee80211_unregister_hw(wl->hw);
2319 wl->mac80211_registered = false; 2416 wl->mac80211_registered = false;
2320 2417
@@ -2323,6 +2420,14 @@ EXPORT_SYMBOL_GPL(wl1271_unregister_hw);
2323 2420
2324int wl1271_init_ieee80211(struct wl1271 *wl) 2421int wl1271_init_ieee80211(struct wl1271 *wl)
2325{ 2422{
2423 static const u32 cipher_suites[] = {
2424 WLAN_CIPHER_SUITE_WEP40,
2425 WLAN_CIPHER_SUITE_WEP104,
2426 WLAN_CIPHER_SUITE_TKIP,
2427 WLAN_CIPHER_SUITE_CCMP,
2428 WL1271_CIPHER_SUITE_GEM,
2429 };
2430
2326 /* The tx descriptor buffer and the TKIP space. */ 2431 /* The tx descriptor buffer and the TKIP space. */
2327 wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE + 2432 wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE +
2328 sizeof(struct wl1271_tx_hw_descr); 2433 sizeof(struct wl1271_tx_hw_descr);
@@ -2340,13 +2445,14 @@ int wl1271_init_ieee80211(struct wl1271 *wl)
2340 IEEE80211_HW_CONNECTION_MONITOR | 2445 IEEE80211_HW_CONNECTION_MONITOR |
2341 IEEE80211_HW_SUPPORTS_CQM_RSSI; 2446 IEEE80211_HW_SUPPORTS_CQM_RSSI;
2342 2447
2448 wl->hw->wiphy->cipher_suites = cipher_suites;
2449 wl->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
2450
2343 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 2451 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
2344 BIT(NL80211_IFTYPE_ADHOC); 2452 BIT(NL80211_IFTYPE_ADHOC);
2345 wl->hw->wiphy->max_scan_ssids = 1; 2453 wl->hw->wiphy->max_scan_ssids = 1;
2346 wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1271_band_2ghz; 2454 wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1271_band_2ghz;
2347 2455 wl->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &wl1271_band_5ghz;
2348 if (wl1271_11a_enabled())
2349 wl->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &wl1271_band_5ghz;
2350 2456
2351 wl->hw->queues = 4; 2457 wl->hw->queues = 4;
2352 wl->hw->max_rates = 1; 2458 wl->hw->max_rates = 1;
@@ -2365,6 +2471,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
2365 struct platform_device *plat_dev = NULL; 2471 struct platform_device *plat_dev = NULL;
2366 struct wl1271 *wl; 2472 struct wl1271 *wl;
2367 int i, ret; 2473 int i, ret;
2474 unsigned int order;
2368 2475
2369 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); 2476 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);
2370 if (!hw) { 2477 if (!hw) {
@@ -2392,6 +2499,10 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
2392 2499
2393 INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work); 2500 INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work);
2394 INIT_DELAYED_WORK(&wl->pspoll_work, wl1271_pspoll_work); 2501 INIT_DELAYED_WORK(&wl->pspoll_work, wl1271_pspoll_work);
2502 INIT_WORK(&wl->irq_work, wl1271_irq_work);
2503 INIT_WORK(&wl->tx_work, wl1271_tx_work);
2504 INIT_WORK(&wl->recovery_work, wl1271_recovery_work);
2505 INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work);
2395 wl->channel = WL1271_DEFAULT_CHANNEL; 2506 wl->channel = WL1271_DEFAULT_CHANNEL;
2396 wl->beacon_int = WL1271_DEFAULT_BEACON_INT; 2507 wl->beacon_int = WL1271_DEFAULT_BEACON_INT;
2397 wl->default_key = 0; 2508 wl->default_key = 0;
@@ -2423,11 +2534,18 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
2423 2534
2424 wl1271_debugfs_init(wl); 2535 wl1271_debugfs_init(wl);
2425 2536
2537 order = get_order(WL1271_AGGR_BUFFER_SIZE);
2538 wl->aggr_buf = (u8 *)__get_free_pages(GFP_KERNEL, order);
2539 if (!wl->aggr_buf) {
2540 ret = -ENOMEM;
2541 goto err_hw;
2542 }
2543
2426 /* Register platform device */ 2544 /* Register platform device */
2427 ret = platform_device_register(wl->plat_dev); 2545 ret = platform_device_register(wl->plat_dev);
2428 if (ret) { 2546 if (ret) {
2429 wl1271_error("couldn't register platform device"); 2547 wl1271_error("couldn't register platform device");
2430 goto err_hw; 2548 goto err_aggr;
2431 } 2549 }
2432 dev_set_drvdata(&wl->plat_dev->dev, wl); 2550 dev_set_drvdata(&wl->plat_dev->dev, wl);
2433 2551
@@ -2453,6 +2571,9 @@ err_bt_coex_state:
2453err_platform: 2571err_platform:
2454 platform_device_unregister(wl->plat_dev); 2572 platform_device_unregister(wl->plat_dev);
2455 2573
2574err_aggr:
2575 free_pages((unsigned long)wl->aggr_buf, order);
2576
2456err_hw: 2577err_hw:
2457 wl1271_debugfs_exit(wl); 2578 wl1271_debugfs_exit(wl);
2458 kfree(plat_dev); 2579 kfree(plat_dev);
@@ -2469,6 +2590,8 @@ EXPORT_SYMBOL_GPL(wl1271_alloc_hw);
2469int wl1271_free_hw(struct wl1271 *wl) 2590int wl1271_free_hw(struct wl1271 *wl)
2470{ 2591{
2471 platform_device_unregister(wl->plat_dev); 2592 platform_device_unregister(wl->plat_dev);
2593 free_pages((unsigned long)wl->aggr_buf,
2594 get_order(WL1271_AGGR_BUFFER_SIZE));
2472 kfree(wl->plat_dev); 2595 kfree(wl->plat_dev);
2473 2596
2474 wl1271_debugfs_exit(wl); 2597 wl1271_debugfs_exit(wl);