mac80211: pass queue bitmap to flush operation
[deliverable/linux.git] / net / mac80211 / pm.c
CommitLineData
665af4fc
BC
1#include <net/mac80211.h>
2#include <net/rtnetlink.h>
3
4#include "ieee80211_i.h"
5bb644a0 5#include "mesh.h"
24487981 6#include "driver-ops.h"
665af4fc
BC
7#include "led.h"
8
eecc4800 9int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
665af4fc
BC
10{
11 struct ieee80211_local *local = hw_to_local(hw);
12 struct ieee80211_sub_if_data *sdata;
665af4fc
BC
13 struct sta_info *sta;
14
94f9b97b
JB
15 if (!local->open_count)
16 goto suspend;
17
4136c422 18 ieee80211_scan_cancel(local);
5bb644a0 19
164eb02d
SW
20 ieee80211_dfs_cac_cancel(local);
21
ca45de77
JB
22 if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
23 mutex_lock(&local->sta_mtx);
24 list_for_each_entry(sta, &local->sta_list, list) {
c2c98fde 25 set_sta_flag(sta, WLAN_STA_BLOCK_BA);
c82c4a80
JB
26 ieee80211_sta_tear_down_BA_sessions(
27 sta, AGG_STOP_LOCAL_REQUEST);
ca45de77
JB
28 }
29 mutex_unlock(&local->sta_mtx);
30 }
31
25420604
JB
32 ieee80211_stop_queues_by_reason(hw,
33 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
34
5bb644a0
JB
35 /* flush out all packets */
36 synchronize_net();
37
39ecc01d 38 ieee80211_flush_queues(local, NULL);
ca45de77 39
5bb644a0
JB
40 local->quiescing = true;
41 /* make quiescing visible to timers everywhere */
42 mb();
43
42935eca 44 flush_workqueue(local->workqueue);
665af4fc 45
5bb644a0
JB
46 /* Don't try to run timers while suspended. */
47 del_timer_sync(&local->sta_cleanup);
48
49 /*
50 * Note that this particular timer doesn't need to be
51 * restarted at resume.
52 */
53 cancel_work_sync(&local->dynamic_ps_enable_work);
54 del_timer_sync(&local->dynamic_ps_timer);
55
eecc4800
JB
56 local->wowlan = wowlan && local->open_count;
57 if (local->wowlan) {
58 int err = drv_suspend(local, wowlan);
2b4562df 59 if (err < 0) {
eecc4800 60 local->quiescing = false;
3b08cf6b 61 local->wowlan = false;
9ea4fa15
ES
62 if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
63 mutex_lock(&local->sta_mtx);
64 list_for_each_entry(sta,
65 &local->sta_list, list) {
66 clear_sta_flag(sta, WLAN_STA_BLOCK_BA);
67 }
68 mutex_unlock(&local->sta_mtx);
69 }
70 ieee80211_wake_queues_by_reason(hw,
71 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
eecc4800 72 return err;
2b4562df
JB
73 } else if (err > 0) {
74 WARN_ON(err != 1);
81256969 75 return err;
2b4562df 76 } else {
2b4562df 77 goto suspend;
eecc4800 78 }
eecc4800
JB
79 }
80
2a419056
JB
81 /* tear down aggregation sessions and remove STAs */
82 mutex_lock(&local->sta_mtx);
83 list_for_each_entry(sta, &local->sta_list, list) {
f09603a2
JB
84 if (sta->uploaded) {
85 enum ieee80211_sta_state state;
86
f09603a2
JB
87 state = sta->sta_state;
88 for (; state > IEEE80211_STA_NOTEXIST; state--)
9d88c7f6 89 WARN_ON(drv_sta_state(local, sta->sdata, sta,
f09603a2
JB
90 state, state - 1));
91 }
665af4fc 92 }
34e89507 93 mutex_unlock(&local->sta_mtx);
665af4fc
BC
94
95 /* remove all interfaces */
96 list_for_each_entry(sdata, &local->interfaces, list) {
61e8a48c 97 if (!ieee80211_sdata_running(sdata))
5bb644a0 98 continue;
7b7eab6f 99 drv_remove_interface(local, sdata);
665af4fc 100 }
5bb644a0 101
4b6f1dd6 102 sdata = rtnl_dereference(local->monitor_sdata);
12e7f517 103 if (sdata)
4b6f1dd6 104 drv_remove_interface(local, sdata);
fe5f2559 105
12e7f517
SG
106 /*
107 * We disconnected on all interfaces before suspend, all channel
108 * contexts should be released.
109 */
110 WARN_ON(!list_empty(&local->chanctx_list));
4b6f1dd6 111
89c3a8ac 112 /* stop hardware - this must stop RX */
84f6a01c
JB
113 if (local->open_count)
114 ieee80211_stop_device(local);
89c3a8ac 115
eecc4800 116 suspend:
5bb644a0 117 local->suspended = true;
89c3a8ac
JB
118 /* need suspended to be visible before quiescing is false */
119 barrier();
5bb644a0
JB
120 local->quiescing = false;
121
665af4fc
BC
122 return 0;
123}
124
f2753ddb
JB
125/*
126 * __ieee80211_resume() is a static inline which just calls
127 * ieee80211_reconfig(), which is also needed for hardware
128 * hang/firmware failure/etc. recovery.
129 */
cd8f7cb4
JB
130
131void ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif,
132 struct cfg80211_wowlan_wakeup *wakeup,
133 gfp_t gfp)
134{
135 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
136
137 cfg80211_report_wowlan_wakeup(&sdata->wdev, wakeup, gfp);
138}
139EXPORT_SYMBOL(ieee80211_report_wowlan_wakeup);
This page took 0.259408 seconds and 5 git commands to generate.