ath: add module information
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / mac80211 / pm.c
CommitLineData
665af4fc
BC
1#include <net/mac80211.h>
2#include <net/rtnetlink.h>
3
4#include "ieee80211_i.h"
5#include "led.h"
6
7int __ieee80211_suspend(struct ieee80211_hw *hw)
8{
9 struct ieee80211_local *local = hw_to_local(hw);
10 struct ieee80211_sub_if_data *sdata;
11 struct ieee80211_if_init_conf conf;
12 struct sta_info *sta;
7f0216a4 13 unsigned long flags;
665af4fc 14
25420604
JB
15 ieee80211_stop_queues_by_reason(hw,
16 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
17
665af4fc
BC
18 flush_workqueue(local->hw.workqueue);
19
20 /* disable keys */
21 list_for_each_entry(sdata, &local->interfaces, list)
22 ieee80211_disable_keys(sdata);
23
722f069a
S
24 /* Tear down aggregation sessions */
25
26 rcu_read_lock();
27
28 if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
29 list_for_each_entry_rcu(sta, &local->sta_list, list) {
30 set_sta_flags(sta, WLAN_STA_SUSPEND);
31 ieee80211_sta_tear_down_BA_sessions(sta);
32 }
33 }
34
35 rcu_read_unlock();
36
665af4fc 37 /* remove STAs */
7f0216a4
JB
38 if (local->ops->sta_notify) {
39 spin_lock_irqsave(&local->sta_lock, flags);
40 list_for_each_entry(sta, &local->sta_list, list) {
665af4fc
BC
41 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
42 sdata = container_of(sdata->bss,
43 struct ieee80211_sub_if_data,
44 u.ap);
45
46 local->ops->sta_notify(hw, &sdata->vif,
47 STA_NOTIFY_REMOVE, &sta->sta);
48 }
7f0216a4 49 spin_unlock_irqrestore(&local->sta_lock, flags);
665af4fc
BC
50 }
51
52 /* remove all interfaces */
53 list_for_each_entry(sdata, &local->interfaces, list) {
665af4fc
BC
54 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
55 sdata->vif.type != NL80211_IFTYPE_MONITOR &&
56 netif_running(sdata->dev)) {
57 conf.vif = &sdata->vif;
58 conf.type = sdata->vif.type;
59 conf.mac_addr = sdata->dev->dev_addr;
60 local->ops->remove_interface(hw, &conf);
61 }
62 }
63
e874e658
BC
64 /* flush again, in case driver queued work */
65 flush_workqueue(local->hw.workqueue);
66
665af4fc
BC
67 /* stop hardware */
68 if (local->open_count) {
69 ieee80211_led_radio(local, false);
70 local->ops->stop(hw);
71 }
72 return 0;
73}
74
75int __ieee80211_resume(struct ieee80211_hw *hw)
76{
77 struct ieee80211_local *local = hw_to_local(hw);
78 struct ieee80211_sub_if_data *sdata;
79 struct ieee80211_if_init_conf conf;
80 struct sta_info *sta;
7f0216a4 81 unsigned long flags;
665af4fc
BC
82 int res;
83
84 /* restart hardware */
85 if (local->open_count) {
86 res = local->ops->start(hw);
87
88 ieee80211_led_radio(local, hw->conf.radio_enabled);
89 }
90
91 /* add interfaces */
92 list_for_each_entry(sdata, &local->interfaces, list) {
665af4fc
BC
93 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
94 sdata->vif.type != NL80211_IFTYPE_MONITOR &&
95 netif_running(sdata->dev)) {
96 conf.vif = &sdata->vif;
97 conf.type = sdata->vif.type;
98 conf.mac_addr = sdata->dev->dev_addr;
99 res = local->ops->add_interface(hw, &conf);
100 }
101 }
102
103 /* add STAs back */
7f0216a4
JB
104 if (local->ops->sta_notify) {
105 spin_lock_irqsave(&local->sta_lock, flags);
106 list_for_each_entry(sta, &local->sta_list, list) {
665af4fc
BC
107 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
108 sdata = container_of(sdata->bss,
109 struct ieee80211_sub_if_data,
110 u.ap);
111
112 local->ops->sta_notify(hw, &sdata->vif,
113 STA_NOTIFY_ADD, &sta->sta);
114 }
7f0216a4 115 spin_unlock_irqrestore(&local->sta_lock, flags);
665af4fc
BC
116 }
117
722f069a
S
118 /* Clear Suspend state so that ADDBA requests can be processed */
119
120 rcu_read_lock();
121
122 if (hw->flags & IEEE80211_HW_AMPDU_AGGREGATION) {
123 list_for_each_entry_rcu(sta, &local->sta_list, list) {
124 clear_sta_flags(sta, WLAN_STA_SUSPEND);
125 }
126 }
127
128 rcu_read_unlock();
129
665af4fc
BC
130 /* setup RTS threshold */
131 if (local->ops->set_rts_threshold)
132 local->ops->set_rts_threshold(hw, local->rts_threshold);
133
134 /* reconfigure hardware */
135 ieee80211_hw_config(local, ~0);
136
137 netif_addr_lock_bh(local->mdev);
138 ieee80211_configure_filter(local);
139 netif_addr_unlock_bh(local->mdev);
140
827b1fb4
JB
141 /* Finally also reconfigure all the BSS information */
142 list_for_each_entry(sdata, &local->interfaces, list) {
143 u32 changed = ~0;
144 if (!netif_running(sdata->dev))
145 continue;
146 switch (sdata->vif.type) {
147 case NL80211_IFTYPE_STATION:
148 /* disable beacon change bits */
149 changed &= ~IEEE80211_IFCC_BEACON;
150 /* fall through */
151 case NL80211_IFTYPE_ADHOC:
152 case NL80211_IFTYPE_AP:
153 case NL80211_IFTYPE_MESH_POINT:
154 WARN_ON(ieee80211_if_config(sdata, changed));
155 ieee80211_bss_info_change_notify(sdata, ~0);
156 break;
157 case NL80211_IFTYPE_WDS:
158 break;
159 case NL80211_IFTYPE_AP_VLAN:
160 case NL80211_IFTYPE_MONITOR:
161 /* ignore virtual */
162 break;
163 case NL80211_IFTYPE_UNSPECIFIED:
164 case __NL80211_IFTYPE_AFTER_LAST:
165 WARN_ON(1);
166 break;
167 }
168 }
169
4499b239
JB
170 /* add back keys */
171 list_for_each_entry(sdata, &local->interfaces, list)
172 if (netif_running(sdata->dev))
173 ieee80211_enable_keys(sdata);
174
25420604
JB
175 ieee80211_wake_queues_by_reason(hw,
176 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
177
665af4fc
BC
178 return 0;
179}