diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00dev.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00dev.c | 409 |
1 files changed, 23 insertions, 386 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 87c0f2c83077..e1b40545a9be 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2004 - 2008 rt2x00 SourceForge Project | 2 | Copyright (C) 2004 - 2009 rt2x00 SourceForge Project |
3 | <http://rt2x00.serialmonkey.com> | 3 | <http://rt2x00.serialmonkey.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
@@ -30,60 +30,6 @@ | |||
30 | #include "rt2x00lib.h" | 30 | #include "rt2x00lib.h" |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Link tuning handlers | ||
34 | */ | ||
35 | void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev) | ||
36 | { | ||
37 | if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) | ||
38 | return; | ||
39 | |||
40 | /* | ||
41 | * Reset link information. | ||
42 | * Both the currently active vgc level as well as | ||
43 | * the link tuner counter should be reset. Resetting | ||
44 | * the counter is important for devices where the | ||
45 | * device should only perform link tuning during the | ||
46 | * first minute after being enabled. | ||
47 | */ | ||
48 | rt2x00dev->link.count = 0; | ||
49 | rt2x00dev->link.vgc_level = 0; | ||
50 | |||
51 | /* | ||
52 | * Reset the link tuner. | ||
53 | */ | ||
54 | rt2x00dev->ops->lib->reset_tuner(rt2x00dev); | ||
55 | } | ||
56 | |||
57 | static void rt2x00lib_start_link_tuner(struct rt2x00_dev *rt2x00dev) | ||
58 | { | ||
59 | /* | ||
60 | * Clear all (possibly) pre-existing quality statistics. | ||
61 | */ | ||
62 | memset(&rt2x00dev->link.qual, 0, sizeof(rt2x00dev->link.qual)); | ||
63 | |||
64 | /* | ||
65 | * The RX and TX percentage should start at 50% | ||
66 | * this will assure we will get at least get some | ||
67 | * decent value when the link tuner starts. | ||
68 | * The value will be dropped and overwritten with | ||
69 | * the correct (measured )value anyway during the | ||
70 | * first run of the link tuner. | ||
71 | */ | ||
72 | rt2x00dev->link.qual.rx_percentage = 50; | ||
73 | rt2x00dev->link.qual.tx_percentage = 50; | ||
74 | |||
75 | rt2x00lib_reset_link_tuner(rt2x00dev); | ||
76 | |||
77 | queue_delayed_work(rt2x00dev->hw->workqueue, | ||
78 | &rt2x00dev->link.work, LINK_TUNE_INTERVAL); | ||
79 | } | ||
80 | |||
81 | static void rt2x00lib_stop_link_tuner(struct rt2x00_dev *rt2x00dev) | ||
82 | { | ||
83 | cancel_delayed_work_sync(&rt2x00dev->link.work); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | * Radio control handlers. | 33 | * Radio control handlers. |
88 | */ | 34 | */ |
89 | int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev) | 35 | int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev) |
@@ -161,238 +107,15 @@ void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state) | |||
161 | * When we are disabling the RX, we should also stop the link tuner. | 107 | * When we are disabling the RX, we should also stop the link tuner. |
162 | */ | 108 | */ |
163 | if (state == STATE_RADIO_RX_OFF) | 109 | if (state == STATE_RADIO_RX_OFF) |
164 | rt2x00lib_stop_link_tuner(rt2x00dev); | 110 | rt2x00link_stop_tuner(rt2x00dev); |
165 | 111 | ||
166 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); | 112 | rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); |
167 | 113 | ||
168 | /* | 114 | /* |
169 | * When we are enabling the RX, we should also start the link tuner. | 115 | * When we are enabling the RX, we should also start the link tuner. |
170 | */ | 116 | */ |
171 | if (state == STATE_RADIO_RX_ON && | 117 | if (state == STATE_RADIO_RX_ON) |
172 | (rt2x00dev->intf_ap_count || rt2x00dev->intf_sta_count)) | 118 | rt2x00link_start_tuner(rt2x00dev); |
173 | rt2x00lib_start_link_tuner(rt2x00dev); | ||
174 | } | ||
175 | |||
176 | static void rt2x00lib_evaluate_antenna_sample(struct rt2x00_dev *rt2x00dev) | ||
177 | { | ||
178 | struct antenna_setup ant; | ||
179 | int sample_a = | ||
180 | rt2x00_get_link_ant_rssi_history(&rt2x00dev->link, ANTENNA_A); | ||
181 | int sample_b = | ||
182 | rt2x00_get_link_ant_rssi_history(&rt2x00dev->link, ANTENNA_B); | ||
183 | |||
184 | memcpy(&ant, &rt2x00dev->link.ant.active, sizeof(ant)); | ||
185 | |||
186 | /* | ||
187 | * We are done sampling. Now we should evaluate the results. | ||
188 | */ | ||
189 | rt2x00dev->link.ant.flags &= ~ANTENNA_MODE_SAMPLE; | ||
190 | |||
191 | /* | ||
192 | * During the last period we have sampled the RSSI | ||
193 | * from both antenna's. It now is time to determine | ||
194 | * which antenna demonstrated the best performance. | ||
195 | * When we are already on the antenna with the best | ||
196 | * performance, then there really is nothing for us | ||
197 | * left to do. | ||
198 | */ | ||
199 | if (sample_a == sample_b) | ||
200 | return; | ||
201 | |||
202 | if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) | ||
203 | ant.rx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B; | ||
204 | |||
205 | if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY) | ||
206 | ant.tx = (sample_a > sample_b) ? ANTENNA_A : ANTENNA_B; | ||
207 | |||
208 | rt2x00lib_config_antenna(rt2x00dev, &ant); | ||
209 | } | ||
210 | |||
211 | static void rt2x00lib_evaluate_antenna_eval(struct rt2x00_dev *rt2x00dev) | ||
212 | { | ||
213 | struct antenna_setup ant; | ||
214 | int rssi_curr = rt2x00_get_link_ant_rssi(&rt2x00dev->link); | ||
215 | int rssi_old = rt2x00_update_ant_rssi(&rt2x00dev->link, rssi_curr); | ||
216 | |||
217 | memcpy(&ant, &rt2x00dev->link.ant.active, sizeof(ant)); | ||
218 | |||
219 | /* | ||
220 | * Legacy driver indicates that we should swap antenna's | ||
221 | * when the difference in RSSI is greater that 5. This | ||
222 | * also should be done when the RSSI was actually better | ||
223 | * then the previous sample. | ||
224 | * When the difference exceeds the threshold we should | ||
225 | * sample the rssi from the other antenna to make a valid | ||
226 | * comparison between the 2 antennas. | ||
227 | */ | ||
228 | if (abs(rssi_curr - rssi_old) < 5) | ||
229 | return; | ||
230 | |||
231 | rt2x00dev->link.ant.flags |= ANTENNA_MODE_SAMPLE; | ||
232 | |||
233 | if (rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) | ||
234 | ant.rx = (ant.rx == ANTENNA_A) ? ANTENNA_B : ANTENNA_A; | ||
235 | |||
236 | if (rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY) | ||
237 | ant.tx = (ant.tx == ANTENNA_A) ? ANTENNA_B : ANTENNA_A; | ||
238 | |||
239 | rt2x00lib_config_antenna(rt2x00dev, &ant); | ||
240 | } | ||
241 | |||
242 | static void rt2x00lib_evaluate_antenna(struct rt2x00_dev *rt2x00dev) | ||
243 | { | ||
244 | /* | ||
245 | * Determine if software diversity is enabled for | ||
246 | * either the TX or RX antenna (or both). | ||
247 | * Always perform this check since within the link | ||
248 | * tuner interval the configuration might have changed. | ||
249 | */ | ||
250 | rt2x00dev->link.ant.flags &= ~ANTENNA_RX_DIVERSITY; | ||
251 | rt2x00dev->link.ant.flags &= ~ANTENNA_TX_DIVERSITY; | ||
252 | |||
253 | if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY) | ||
254 | rt2x00dev->link.ant.flags |= ANTENNA_RX_DIVERSITY; | ||
255 | if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY) | ||
256 | rt2x00dev->link.ant.flags |= ANTENNA_TX_DIVERSITY; | ||
257 | |||
258 | if (!(rt2x00dev->link.ant.flags & ANTENNA_RX_DIVERSITY) && | ||
259 | !(rt2x00dev->link.ant.flags & ANTENNA_TX_DIVERSITY)) { | ||
260 | rt2x00dev->link.ant.flags = 0; | ||
261 | return; | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * If we have only sampled the data over the last period | ||
266 | * we should now harvest the data. Otherwise just evaluate | ||
267 | * the data. The latter should only be performed once | ||
268 | * every 2 seconds. | ||
269 | */ | ||
270 | if (rt2x00dev->link.ant.flags & ANTENNA_MODE_SAMPLE) | ||
271 | rt2x00lib_evaluate_antenna_sample(rt2x00dev); | ||
272 | else if (rt2x00dev->link.count & 1) | ||
273 | rt2x00lib_evaluate_antenna_eval(rt2x00dev); | ||
274 | } | ||
275 | |||
276 | static void rt2x00lib_update_link_stats(struct link *link, int rssi) | ||
277 | { | ||
278 | int avg_rssi = rssi; | ||
279 | |||
280 | /* | ||
281 | * Update global RSSI | ||
282 | */ | ||
283 | if (link->qual.avg_rssi) | ||
284 | avg_rssi = MOVING_AVERAGE(link->qual.avg_rssi, rssi, 8); | ||
285 | link->qual.avg_rssi = avg_rssi; | ||
286 | |||
287 | /* | ||
288 | * Update antenna RSSI | ||
289 | */ | ||
290 | if (link->ant.rssi_ant) | ||
291 | rssi = MOVING_AVERAGE(link->ant.rssi_ant, rssi, 8); | ||
292 | link->ant.rssi_ant = rssi; | ||
293 | } | ||
294 | |||
295 | static void rt2x00lib_precalculate_link_signal(struct link_qual *qual) | ||
296 | { | ||
297 | if (qual->rx_failed || qual->rx_success) | ||
298 | qual->rx_percentage = | ||
299 | (qual->rx_success * 100) / | ||
300 | (qual->rx_failed + qual->rx_success); | ||
301 | else | ||
302 | qual->rx_percentage = 50; | ||
303 | |||
304 | if (qual->tx_failed || qual->tx_success) | ||
305 | qual->tx_percentage = | ||
306 | (qual->tx_success * 100) / | ||
307 | (qual->tx_failed + qual->tx_success); | ||
308 | else | ||
309 | qual->tx_percentage = 50; | ||
310 | |||
311 | qual->rx_success = 0; | ||
312 | qual->rx_failed = 0; | ||
313 | qual->tx_success = 0; | ||
314 | qual->tx_failed = 0; | ||
315 | } | ||
316 | |||
317 | static int rt2x00lib_calculate_link_signal(struct rt2x00_dev *rt2x00dev, | ||
318 | int rssi) | ||
319 | { | ||
320 | int rssi_percentage = 0; | ||
321 | int signal; | ||
322 | |||
323 | /* | ||
324 | * We need a positive value for the RSSI. | ||
325 | */ | ||
326 | if (rssi < 0) | ||
327 | rssi += rt2x00dev->rssi_offset; | ||
328 | |||
329 | /* | ||
330 | * Calculate the different percentages, | ||
331 | * which will be used for the signal. | ||
332 | */ | ||
333 | if (rt2x00dev->rssi_offset) | ||
334 | rssi_percentage = (rssi * 100) / rt2x00dev->rssi_offset; | ||
335 | |||
336 | /* | ||
337 | * Add the individual percentages and use the WEIGHT | ||
338 | * defines to calculate the current link signal. | ||
339 | */ | ||
340 | signal = ((WEIGHT_RSSI * rssi_percentage) + | ||
341 | (WEIGHT_TX * rt2x00dev->link.qual.tx_percentage) + | ||
342 | (WEIGHT_RX * rt2x00dev->link.qual.rx_percentage)) / 100; | ||
343 | |||
344 | return (signal > 100) ? 100 : signal; | ||
345 | } | ||
346 | |||
347 | static void rt2x00lib_link_tuner(struct work_struct *work) | ||
348 | { | ||
349 | struct rt2x00_dev *rt2x00dev = | ||
350 | container_of(work, struct rt2x00_dev, link.work.work); | ||
351 | |||
352 | /* | ||
353 | * When the radio is shutting down we should | ||
354 | * immediately cease all link tuning. | ||
355 | */ | ||
356 | if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) | ||
357 | return; | ||
358 | |||
359 | /* | ||
360 | * Update statistics. | ||
361 | */ | ||
362 | rt2x00dev->ops->lib->link_stats(rt2x00dev, &rt2x00dev->link.qual); | ||
363 | rt2x00dev->low_level_stats.dot11FCSErrorCount += | ||
364 | rt2x00dev->link.qual.rx_failed; | ||
365 | |||
366 | /* | ||
367 | * Only perform the link tuning when Link tuning | ||
368 | * has been enabled (This could have been disabled from the EEPROM). | ||
369 | */ | ||
370 | if (!test_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags)) | ||
371 | rt2x00dev->ops->lib->link_tuner(rt2x00dev); | ||
372 | |||
373 | /* | ||
374 | * Precalculate a portion of the link signal which is | ||
375 | * in based on the tx/rx success/failure counters. | ||
376 | */ | ||
377 | rt2x00lib_precalculate_link_signal(&rt2x00dev->link.qual); | ||
378 | |||
379 | /* | ||
380 | * Send a signal to the led to update the led signal strength. | ||
381 | */ | ||
382 | rt2x00leds_led_quality(rt2x00dev, rt2x00dev->link.qual.avg_rssi); | ||
383 | |||
384 | /* | ||
385 | * Evaluate antenna setup, make this the last step since this could | ||
386 | * possibly reset some statistics. | ||
387 | */ | ||
388 | rt2x00lib_evaluate_antenna(rt2x00dev); | ||
389 | |||
390 | /* | ||
391 | * Increase tuner counter, and reschedule the next link tuner run. | ||
392 | */ | ||
393 | rt2x00dev->link.count++; | ||
394 | queue_delayed_work(rt2x00dev->hw->workqueue, | ||
395 | &rt2x00dev->link.work, LINK_TUNE_INTERVAL); | ||
396 | } | 119 | } |
397 | 120 | ||
398 | static void rt2x00lib_packetfilter_scheduled(struct work_struct *work) | 121 | static void rt2x00lib_packetfilter_scheduled(struct work_struct *work) |
@@ -467,7 +190,9 @@ static void rt2x00lib_beacondone_iter(void *data, u8 *mac, | |||
467 | struct rt2x00_intf *intf = vif_to_intf(vif); | 190 | struct rt2x00_intf *intf = vif_to_intf(vif); |
468 | 191 | ||
469 | if (vif->type != NL80211_IFTYPE_AP && | 192 | if (vif->type != NL80211_IFTYPE_AP && |
470 | vif->type != NL80211_IFTYPE_ADHOC) | 193 | vif->type != NL80211_IFTYPE_ADHOC && |
194 | vif->type != NL80211_IFTYPE_MESH_POINT && | ||
195 | vif->type != NL80211_IFTYPE_WDS) | ||
471 | return; | 196 | return; |
472 | 197 | ||
473 | /* | 198 | /* |
@@ -597,7 +322,6 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev, | |||
597 | struct sk_buff *skb; | 322 | struct sk_buff *skb; |
598 | struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; | 323 | struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; |
599 | struct ieee80211_supported_band *sband; | 324 | struct ieee80211_supported_band *sband; |
600 | struct ieee80211_hdr *hdr; | ||
601 | const struct rt2x00_rate *rate; | 325 | const struct rt2x00_rate *rate; |
602 | unsigned int header_length; | 326 | unsigned int header_length; |
603 | unsigned int align; | 327 | unsigned int align; |
@@ -668,30 +392,22 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev, | |||
668 | 392 | ||
669 | if (idx < 0) { | 393 | if (idx < 0) { |
670 | WARNING(rt2x00dev, "Frame received with unrecognized signal," | 394 | WARNING(rt2x00dev, "Frame received with unrecognized signal," |
671 | "signal=0x%.2x, plcp=%d.\n", rxdesc.signal, | 395 | "signal=0x%.2x, type=%d.\n", rxdesc.signal, |
672 | !!(rxdesc.dev_flags & RXDONE_SIGNAL_PLCP)); | 396 | (rxdesc.dev_flags & RXDONE_SIGNAL_MASK)); |
673 | idx = 0; | 397 | idx = 0; |
674 | } | 398 | } |
675 | 399 | ||
676 | /* | 400 | /* |
677 | * Only update link status if this is a beacon frame carrying our bssid. | 401 | * Update extra components |
678 | */ | 402 | */ |
679 | hdr = (struct ieee80211_hdr *)entry->skb->data; | 403 | rt2x00link_update_stats(rt2x00dev, entry->skb, &rxdesc); |
680 | if (ieee80211_is_beacon(hdr->frame_control) && | 404 | rt2x00debug_update_crypto(rt2x00dev, &rxdesc); |
681 | (rxdesc.dev_flags & RXDONE_MY_BSS)) | ||
682 | rt2x00lib_update_link_stats(&rt2x00dev->link, rxdesc.rssi); | ||
683 | |||
684 | rt2x00debug_update_crypto(rt2x00dev, | ||
685 | rxdesc.cipher, | ||
686 | rxdesc.cipher_status); | ||
687 | |||
688 | rt2x00dev->link.qual.rx_success++; | ||
689 | 405 | ||
690 | rx_status->mactime = rxdesc.timestamp; | 406 | rx_status->mactime = rxdesc.timestamp; |
691 | rx_status->rate_idx = idx; | 407 | rx_status->rate_idx = idx; |
692 | rx_status->qual = | 408 | rx_status->qual = rt2x00link_calculate_signal(rt2x00dev, rxdesc.rssi); |
693 | rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc.rssi); | ||
694 | rx_status->signal = rxdesc.rssi; | 409 | rx_status->signal = rxdesc.rssi; |
410 | rx_status->noise = rxdesc.noise; | ||
695 | rx_status->flag = rxdesc.flags; | 411 | rx_status->flag = rxdesc.flags; |
696 | rx_status->antenna = rt2x00dev->link.ant.active.rx; | 412 | rx_status->antenna = rt2x00dev->link.ant.active.rx; |
697 | 413 | ||
@@ -1067,7 +783,9 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) | |||
1067 | if (rt2x00dev->ops->bcn->entry_num > 0) | 783 | if (rt2x00dev->ops->bcn->entry_num > 0) |
1068 | rt2x00dev->hw->wiphy->interface_modes |= | 784 | rt2x00dev->hw->wiphy->interface_modes |= |
1069 | BIT(NL80211_IFTYPE_ADHOC) | | 785 | BIT(NL80211_IFTYPE_ADHOC) | |
1070 | BIT(NL80211_IFTYPE_AP); | 786 | BIT(NL80211_IFTYPE_AP) | |
787 | BIT(NL80211_IFTYPE_MESH_POINT) | | ||
788 | BIT(NL80211_IFTYPE_WDS); | ||
1071 | 789 | ||
1072 | /* | 790 | /* |
1073 | * Let the driver probe the device to detect the capabilities. | 791 | * Let the driver probe the device to detect the capabilities. |
@@ -1083,7 +801,6 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) | |||
1083 | */ | 801 | */ |
1084 | INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); | 802 | INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); |
1085 | INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled); | 803 | INIT_WORK(&rt2x00dev->filter_work, rt2x00lib_packetfilter_scheduled); |
1086 | INIT_DELAYED_WORK(&rt2x00dev->link.work, rt2x00lib_link_tuner); | ||
1087 | 804 | ||
1088 | /* | 805 | /* |
1089 | * Allocate queue array. | 806 | * Allocate queue array. |
@@ -1104,6 +821,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) | |||
1104 | /* | 821 | /* |
1105 | * Register extra components. | 822 | * Register extra components. |
1106 | */ | 823 | */ |
824 | rt2x00link_register(rt2x00dev); | ||
1107 | rt2x00leds_register(rt2x00dev); | 825 | rt2x00leds_register(rt2x00dev); |
1108 | rt2x00rfkill_allocate(rt2x00dev); | 826 | rt2x00rfkill_allocate(rt2x00dev); |
1109 | rt2x00debug_register(rt2x00dev); | 827 | rt2x00debug_register(rt2x00dev); |
@@ -1163,23 +881,17 @@ EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); | |||
1163 | #ifdef CONFIG_PM | 881 | #ifdef CONFIG_PM |
1164 | int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state) | 882 | int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state) |
1165 | { | 883 | { |
1166 | int retval; | ||
1167 | |||
1168 | NOTICE(rt2x00dev, "Going to sleep.\n"); | 884 | NOTICE(rt2x00dev, "Going to sleep.\n"); |
1169 | 885 | ||
1170 | /* | 886 | /* |
1171 | * Only continue if mac80211 has open interfaces. | 887 | * Prevent mac80211 from accessing driver while suspended. |
1172 | */ | 888 | */ |
1173 | if (!test_and_clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) || | 889 | if (!test_and_clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) |
1174 | !test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags)) | 890 | return 0; |
1175 | goto exit; | ||
1176 | |||
1177 | set_bit(DEVICE_STATE_STARTED_SUSPEND, &rt2x00dev->flags); | ||
1178 | 891 | ||
1179 | /* | 892 | /* |
1180 | * Disable radio. | 893 | * Cleanup as much as possible. |
1181 | */ | 894 | */ |
1182 | rt2x00lib_stop(rt2x00dev); | ||
1183 | rt2x00lib_uninitialize(rt2x00dev); | 895 | rt2x00lib_uninitialize(rt2x00dev); |
1184 | 896 | ||
1185 | /* | 897 | /* |
@@ -1188,7 +900,6 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state) | |||
1188 | rt2x00leds_suspend(rt2x00dev); | 900 | rt2x00leds_suspend(rt2x00dev); |
1189 | rt2x00debug_deregister(rt2x00dev); | 901 | rt2x00debug_deregister(rt2x00dev); |
1190 | 902 | ||
1191 | exit: | ||
1192 | /* | 903 | /* |
1193 | * Set device mode to sleep for power management, | 904 | * Set device mode to sleep for power management, |
1194 | * on some hardware this call seems to consistently fail. | 905 | * on some hardware this call seems to consistently fail. |
@@ -1200,8 +911,7 @@ exit: | |||
1200 | * the radio and the other components already disabled the | 911 | * the radio and the other components already disabled the |
1201 | * device is as good as disabled. | 912 | * device is as good as disabled. |
1202 | */ | 913 | */ |
1203 | retval = rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP); | 914 | if (rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_SLEEP)) |
1204 | if (retval) | ||
1205 | WARNING(rt2x00dev, "Device failed to enter sleep state, " | 915 | WARNING(rt2x00dev, "Device failed to enter sleep state, " |
1206 | "continue suspending.\n"); | 916 | "continue suspending.\n"); |
1207 | 917 | ||
@@ -1209,32 +919,8 @@ exit: | |||
1209 | } | 919 | } |
1210 | EXPORT_SYMBOL_GPL(rt2x00lib_suspend); | 920 | EXPORT_SYMBOL_GPL(rt2x00lib_suspend); |
1211 | 921 | ||
1212 | static void rt2x00lib_resume_intf(void *data, u8 *mac, | ||
1213 | struct ieee80211_vif *vif) | ||
1214 | { | ||
1215 | struct rt2x00_dev *rt2x00dev = data; | ||
1216 | struct rt2x00_intf *intf = vif_to_intf(vif); | ||
1217 | |||
1218 | spin_lock(&intf->lock); | ||
1219 | |||
1220 | rt2x00lib_config_intf(rt2x00dev, intf, | ||
1221 | vif->type, intf->mac, intf->bssid); | ||
1222 | |||
1223 | |||
1224 | /* | ||
1225 | * Master or Ad-hoc mode require a new beacon update. | ||
1226 | */ | ||
1227 | if (vif->type == NL80211_IFTYPE_AP || | ||
1228 | vif->type == NL80211_IFTYPE_ADHOC) | ||
1229 | intf->delayed_flags |= DELAYED_UPDATE_BEACON; | ||
1230 | |||
1231 | spin_unlock(&intf->lock); | ||
1232 | } | ||
1233 | |||
1234 | int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) | 922 | int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) |
1235 | { | 923 | { |
1236 | int retval; | ||
1237 | |||
1238 | NOTICE(rt2x00dev, "Waking up.\n"); | 924 | NOTICE(rt2x00dev, "Waking up.\n"); |
1239 | 925 | ||
1240 | /* | 926 | /* |
@@ -1244,60 +930,11 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev) | |||
1244 | rt2x00leds_resume(rt2x00dev); | 930 | rt2x00leds_resume(rt2x00dev); |
1245 | 931 | ||
1246 | /* | 932 | /* |
1247 | * Only continue if mac80211 had open interfaces. | ||
1248 | */ | ||
1249 | if (!test_and_clear_bit(DEVICE_STATE_STARTED_SUSPEND, &rt2x00dev->flags)) | ||
1250 | return 0; | ||
1251 | |||
1252 | /* | ||
1253 | * Reinitialize device and all active interfaces. | ||
1254 | */ | ||
1255 | retval = rt2x00lib_start(rt2x00dev); | ||
1256 | if (retval) | ||
1257 | goto exit; | ||
1258 | |||
1259 | /* | ||
1260 | * Reconfigure device. | ||
1261 | */ | ||
1262 | retval = rt2x00mac_config(rt2x00dev->hw, ~0); | ||
1263 | if (retval) | ||
1264 | goto exit; | ||
1265 | |||
1266 | /* | ||
1267 | * Iterator over each active interface to | ||
1268 | * reconfigure the hardware. | ||
1269 | */ | ||
1270 | ieee80211_iterate_active_interfaces(rt2x00dev->hw, | ||
1271 | rt2x00lib_resume_intf, rt2x00dev); | ||
1272 | |||
1273 | /* | ||
1274 | * We are ready again to receive requests from mac80211. | 933 | * We are ready again to receive requests from mac80211. |
1275 | */ | 934 | */ |
1276 | set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); | 935 | set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); |
1277 | 936 | ||
1278 | /* | ||
1279 | * It is possible that during that mac80211 has attempted | ||
1280 | * to send frames while we were suspending or resuming. | ||
1281 | * In that case we have disabled the TX queue and should | ||
1282 | * now enable it again | ||
1283 | */ | ||
1284 | ieee80211_wake_queues(rt2x00dev->hw); | ||
1285 | |||
1286 | /* | ||
1287 | * During interface iteration we might have changed the | ||
1288 | * delayed_flags, time to handles the event by calling | ||
1289 | * the work handler directly. | ||
1290 | */ | ||
1291 | rt2x00lib_intf_scheduled(&rt2x00dev->intf_work); | ||
1292 | |||
1293 | return 0; | 937 | return 0; |
1294 | |||
1295 | exit: | ||
1296 | rt2x00lib_stop(rt2x00dev); | ||
1297 | rt2x00lib_uninitialize(rt2x00dev); | ||
1298 | rt2x00debug_deregister(rt2x00dev); | ||
1299 | |||
1300 | return retval; | ||
1301 | } | 938 | } |
1302 | EXPORT_SYMBOL_GPL(rt2x00lib_resume); | 939 | EXPORT_SYMBOL_GPL(rt2x00lib_resume); |
1303 | #endif /* CONFIG_PM */ | 940 | #endif /* CONFIG_PM */ |