71a2d6bec190ecab16eebf41678cac7a660defdf
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath10k/mac.c
2 +++ b/drivers/net/wireless/ath/ath10k/mac.c
3 @@ -1351,12 +1351,12 @@ static int ath10k_update_channel_list(st
4 ch->allow_vht = true;
5
6 ch->allow_ibss =
7 - !(channel->flags & IEEE80211_CHAN_NO_IBSS);
8 + !(channel->flags & IEEE80211_CHAN_NO_IR);
9
10 ch->ht40plus =
11 !(channel->flags & IEEE80211_CHAN_NO_HT40PLUS);
12
13 - passive = channel->flags & IEEE80211_CHAN_PASSIVE_SCAN;
14 + passive = channel->flags & IEEE80211_CHAN_NO_IR;
15 ch->passive = passive;
16
17 ch->freq = channel->center_freq;
18 --- a/drivers/net/wireless/ath/ath9k/Kconfig
19 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
20 @@ -90,7 +90,7 @@ config ATH9K_DFS_CERTIFIED
21
22 config ATH9K_TX99
23 bool "Atheros ath9k TX99 testing support"
24 - depends on CFG80211_CERTIFICATION_ONUS
25 + depends on ATH9K_DEBUGFS && CFG80211_CERTIFICATION_ONUS
26 default n
27 ---help---
28 Say N. This should only be enabled on systems undergoing
29 @@ -108,6 +108,14 @@ config ATH9K_TX99
30 be evaluated to meet the RF exposure limits set forth in the
31 governmental SAR regulations.
32
33 +config ATH9K_WOW
34 + bool "Wake on Wireless LAN support (EXPERIMENTAL)"
35 + depends on ATH9K && PM
36 + default n
37 + ---help---
38 + This option enables Wake on Wireless LAN support for certain cards.
39 + Currently, AR9462 is supported.
40 +
41 config ATH9K_LEGACY_RATE_CONTROL
42 bool "Atheros ath9k rate control"
43 depends on ATH9K
44 --- a/drivers/net/wireless/ath/ath9k/Makefile
45 +++ b/drivers/net/wireless/ath/ath9k/Makefile
46 @@ -13,9 +13,9 @@ ath9k-$(CPTCFG_ATH9K_PCI) += pci.o
47 ath9k-$(CPTCFG_ATH9K_AHB) += ahb.o
48 ath9k-$(CPTCFG_ATH9K_DEBUGFS) += debug.o
49 ath9k-$(CPTCFG_ATH9K_DFS_DEBUGFS) += dfs_debug.o
50 -ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += \
51 - dfs.o
52 -ath9k-$(CONFIG_PM_SLEEP) += wow.o
53 +ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += dfs.o
54 +ath9k-$(CPTCFG_ATH9K_TX99) += tx99.o
55 +ath9k-$(CPTCFG_ATH9K_WOW) += wow.o
56
57 obj-$(CPTCFG_ATH9K) += ath9k.o
58
59 @@ -41,6 +41,8 @@ ath9k_hw-y:= \
60 ar9003_eeprom.o \
61 ar9003_paprd.o
62
63 +ath9k_hw-$(CPTCFG_ATH9K_WOW) += ar9003_wow.o
64 +
65 ath9k_hw-$(CPTCFG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \
66 ar9003_mci.o
67 obj-$(CPTCFG_ATH9K_HW) += ath9k_hw.o
68 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
69 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
70 @@ -581,6 +581,13 @@ static void ar9003_tx_gain_table_mode6(s
71 ar9580_1p0_type6_tx_gain_table);
72 }
73
74 +static void ar9003_tx_gain_table_mode7(struct ath_hw *ah)
75 +{
76 + if (AR_SREV_9340(ah))
77 + INIT_INI_ARRAY(&ah->iniModesTxGain,
78 + ar9340_cus227_tx_gain_table_1p0);
79 +}
80 +
81 typedef void (*ath_txgain_tab)(struct ath_hw *ah);
82
83 static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
84 @@ -593,6 +600,7 @@ static void ar9003_tx_gain_table_apply(s
85 ar9003_tx_gain_table_mode4,
86 ar9003_tx_gain_table_mode5,
87 ar9003_tx_gain_table_mode6,
88 + ar9003_tx_gain_table_mode7,
89 };
90 int idx = ar9003_hw_get_tx_gain_idx(ah);
91
92 @@ -750,6 +758,9 @@ static void ar9003_hw_init_mode_gain_reg
93 static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
94 bool power_off)
95 {
96 + unsigned int i;
97 + struct ar5416IniArray *array;
98 +
99 /*
100 * Increase L1 Entry Latency. Some WB222 boards don't have
101 * this change in eeprom/OTP.
102 @@ -775,18 +786,13 @@ static void ar9003_hw_configpcipowersave
103 * Configire PCIE after Ini init. SERDES values now come from ini file
104 * This enables PCIe low power mode.
105 */
106 - if (ah->config.pcieSerDesWrite) {
107 - unsigned int i;
108 - struct ar5416IniArray *array;
109 -
110 - array = power_off ? &ah->iniPcieSerdes :
111 - &ah->iniPcieSerdesLowPower;
112 -
113 - for (i = 0; i < array->ia_rows; i++) {
114 - REG_WRITE(ah,
115 - INI_RA(array, i, 0),
116 - INI_RA(array, i, 1));
117 - }
118 + array = power_off ? &ah->iniPcieSerdes :
119 + &ah->iniPcieSerdesLowPower;
120 +
121 + for (i = 0; i < array->ia_rows; i++) {
122 + REG_WRITE(ah,
123 + INI_RA(array, i, 0),
124 + INI_RA(array, i, 1));
125 }
126 }
127
128 --- a/drivers/net/wireless/ath/ath9k/ar9340_initvals.h
129 +++ b/drivers/net/wireless/ath/ath9k/ar9340_initvals.h
130 @@ -1447,4 +1447,106 @@ static const u32 ar9340_1p0_soc_preamble
131 {0x00007038, 0x000004c2},
132 };
133
134 +static const u32 ar9340_cus227_tx_gain_table_1p0[][5] = {
135 + /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
136 + {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
137 + {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
138 + {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
139 + {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
140 + {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
141 + {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
142 + {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
143 + {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
144 + {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
145 + {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
146 + {0x0000a514, 0x1c000223, 0x1c000223, 0x11000400, 0x11000400},
147 + {0x0000a518, 0x21002220, 0x21002220, 0x15000402, 0x15000402},
148 + {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
149 + {0x0000a520, 0x2c022220, 0x2c022220, 0x1b000603, 0x1b000603},
150 + {0x0000a524, 0x30022222, 0x30022222, 0x1f000a02, 0x1f000a02},
151 + {0x0000a528, 0x35022225, 0x35022225, 0x23000a04, 0x23000a04},
152 + {0x0000a52c, 0x3b02222a, 0x3b02222a, 0x26000a20, 0x26000a20},
153 + {0x0000a530, 0x3f02222c, 0x3f02222c, 0x2a000e20, 0x2a000e20},
154 + {0x0000a534, 0x4202242a, 0x4202242a, 0x2e000e22, 0x2e000e22},
155 + {0x0000a538, 0x4702244a, 0x4702244a, 0x31000e24, 0x31000e24},
156 + {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x34001640, 0x34001640},
157 + {0x0000a540, 0x4e02246c, 0x4e02246c, 0x38001660, 0x38001660},
158 + {0x0000a544, 0x5302266c, 0x5302266c, 0x3b001861, 0x3b001861},
159 + {0x0000a548, 0x5702286c, 0x5702286c, 0x3e001a81, 0x3e001a81},
160 + {0x0000a54c, 0x5c02486b, 0x5c02486b, 0x42001a83, 0x42001a83},
161 + {0x0000a550, 0x61024a6c, 0x61024a6c, 0x44001c84, 0x44001c84},
162 + {0x0000a554, 0x66026a6c, 0x66026a6c, 0x48001ce3, 0x48001ce3},
163 + {0x0000a558, 0x6b026e6c, 0x6b026e6c, 0x4c001ce5, 0x4c001ce5},
164 + {0x0000a55c, 0x7002708c, 0x7002708c, 0x50001ce9, 0x50001ce9},
165 + {0x0000a560, 0x7302b08a, 0x7302b08a, 0x54001ceb, 0x54001ceb},
166 + {0x0000a564, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
167 + {0x0000a568, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
168 + {0x0000a56c, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
169 + {0x0000a570, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
170 + {0x0000a574, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
171 + {0x0000a578, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
172 + {0x0000a57c, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
173 + {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
174 + {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
175 + {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
176 + {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
177 + {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
178 + {0x0000a594, 0x1c800223, 0x1c800223, 0x11800400, 0x11800400},
179 + {0x0000a598, 0x21820220, 0x21820220, 0x15800402, 0x15800402},
180 + {0x0000a59c, 0x27820223, 0x27820223, 0x19800404, 0x19800404},
181 + {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1b800603, 0x1b800603},
182 + {0x0000a5a4, 0x2f822222, 0x2f822222, 0x1f800a02, 0x1f800a02},
183 + {0x0000a5a8, 0x34822225, 0x34822225, 0x23800a04, 0x23800a04},
184 + {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x26800a20, 0x26800a20},
185 + {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2a800e20, 0x2a800e20},
186 + {0x0000a5b4, 0x4282242a, 0x4282242a, 0x2e800e22, 0x2e800e22},
187 + {0x0000a5b8, 0x4782244a, 0x4782244a, 0x31800e24, 0x31800e24},
188 + {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x34801640, 0x34801640},
189 + {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x38801660, 0x38801660},
190 + {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3b801861, 0x3b801861},
191 + {0x0000a5c8, 0x5782286c, 0x5782286c, 0x3e801a81, 0x3e801a81},
192 + {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x42801a83, 0x42801a83},
193 + {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x44801c84, 0x44801c84},
194 + {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x48801ce3, 0x48801ce3},
195 + {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x4c801ce5, 0x4c801ce5},
196 + {0x0000a5dc, 0x7086308c, 0x7086308c, 0x50801ce9, 0x50801ce9},
197 + {0x0000a5e0, 0x738a308a, 0x738a308a, 0x54801ceb, 0x54801ceb},
198 + {0x0000a5e4, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
199 + {0x0000a5e8, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
200 + {0x0000a5ec, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
201 + {0x0000a5f0, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
202 + {0x0000a5f4, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
203 + {0x0000a5f8, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
204 + {0x0000a5fc, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
205 + {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
206 + {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
207 + {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
208 + {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
209 + {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
210 + {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000},
211 + {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501},
212 + {0x0000a61c, 0x02008802, 0x02008802, 0x02008501, 0x02008501},
213 + {0x0000a620, 0x0300cc03, 0x0300cc03, 0x0280ca03, 0x0280ca03},
214 + {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04},
215 + {0x0000a628, 0x0300cc03, 0x0300cc03, 0x04014c04, 0x04014c04},
216 + {0x0000a62c, 0x03810c03, 0x03810c03, 0x04015005, 0x04015005},
217 + {0x0000a630, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
218 + {0x0000a634, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
219 + {0x0000a638, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
220 + {0x0000a63c, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
221 + {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
222 + {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
223 + {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
224 + {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
225 + {0x00016044, 0x056db2db, 0x056db2db, 0x03b6d2e4, 0x03b6d2e4},
226 + {0x00016048, 0x24925666, 0x24925666, 0x8e481266, 0x8e481266},
227 + {0x00016280, 0x01000015, 0x01000015, 0x01001015, 0x01001015},
228 + {0x00016288, 0x30318000, 0x30318000, 0x00318000, 0x00318000},
229 + {0x00016444, 0x056db2db, 0x056db2db, 0x03b6d2e4, 0x03b6d2e4},
230 + {0x00016448, 0x24925666, 0x24925666, 0x8e481266, 0x8e481266},
231 + {0x0000a3a4, 0x00000011, 0x00000011, 0x00000011, 0x00000011},
232 + {0x0000a3a8, 0x3c3c3c3c, 0x3c3c3c3c, 0x3c3c3c3c, 0x3c3c3c3c},
233 + {0x0000a3ac, 0x30303030, 0x30303030, 0x30303030, 0x30303030},
234 +};
235 +
236 #endif /* INITVALS_9340_H */
237 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
238 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
239 @@ -459,6 +459,7 @@ void ath_check_ani(struct ath_softc *sc)
240 int ath_update_survey_stats(struct ath_softc *sc);
241 void ath_update_survey_nf(struct ath_softc *sc, int channel);
242 void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type);
243 +void ath_ps_full_sleep(unsigned long data);
244
245 /**********/
246 /* BTCOEX */
247 @@ -570,6 +571,34 @@ static inline void ath_fill_led_pin(stru
248 }
249 #endif
250
251 +/************************/
252 +/* Wake on Wireless LAN */
253 +/************************/
254 +
255 +#ifdef CONFIG_ATH9K_WOW
256 +void ath9k_init_wow(struct ieee80211_hw *hw);
257 +int ath9k_suspend(struct ieee80211_hw *hw,
258 + struct cfg80211_wowlan *wowlan);
259 +int ath9k_resume(struct ieee80211_hw *hw);
260 +void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled);
261 +#else
262 +static inline void ath9k_init_wow(struct ieee80211_hw *hw)
263 +{
264 +}
265 +static inline int ath9k_suspend(struct ieee80211_hw *hw,
266 + struct cfg80211_wowlan *wowlan)
267 +{
268 + return 0;
269 +}
270 +static inline int ath9k_resume(struct ieee80211_hw *hw)
271 +{
272 + return 0;
273 +}
274 +static inline void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
275 +{
276 +}
277 +#endif /* CONFIG_ATH9K_WOW */
278 +
279 /*******************************/
280 /* Antenna diversity/combining */
281 /*******************************/
282 @@ -723,6 +752,7 @@ struct ath_softc {
283 struct work_struct hw_check_work;
284 struct work_struct hw_reset_work;
285 struct completion paprd_complete;
286 + wait_queue_head_t tx_wait;
287
288 unsigned int hw_busy_count;
289 unsigned long sc_flags;
290 @@ -759,6 +789,7 @@ struct ath_softc {
291 struct delayed_work tx_complete_work;
292 struct delayed_work hw_pll_work;
293 struct timer_list rx_poll_timer;
294 + struct timer_list sleep_timer;
295
296 #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
297 struct ath_btcoex btcoex;
298 @@ -783,7 +814,7 @@ struct ath_softc {
299 bool tx99_state;
300 s16 tx99_power;
301
302 -#ifdef CONFIG_PM_SLEEP
303 +#ifdef CONFIG_ATH9K_WOW
304 atomic_t wow_got_bmiss_intr;
305 atomic_t wow_sleep_proc_intr; /* in the middle of WoW sleep ? */
306 u32 wow_intr_before_sleep;
307 @@ -946,10 +977,25 @@ struct fft_sample_ht20_40 {
308 u8 data[SPECTRAL_HT20_40_NUM_BINS];
309 } __packed;
310
311 -int ath9k_tx99_init(struct ath_softc *sc);
312 -void ath9k_tx99_deinit(struct ath_softc *sc);
313 +/********/
314 +/* TX99 */
315 +/********/
316 +
317 +#ifdef CONFIG_ATH9K_TX99
318 +void ath9k_tx99_init_debug(struct ath_softc *sc);
319 int ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb,
320 struct ath_tx_control *txctl);
321 +#else
322 +static inline void ath9k_tx99_init_debug(struct ath_softc *sc)
323 +{
324 +}
325 +static inline int ath9k_tx99_send(struct ath_softc *sc,
326 + struct sk_buff *skb,
327 + struct ath_tx_control *txctl)
328 +{
329 + return 0;
330 +}
331 +#endif /* CONFIG_ATH9K_TX99 */
332
333 void ath9k_tasklet(unsigned long data);
334 int ath_cabq_update(struct ath_softc *);
335 @@ -966,6 +1012,9 @@ extern bool is_ath9k_unloaded;
336
337 u8 ath9k_parse_mpdudensity(u8 mpdudensity);
338 irqreturn_t ath_isr(int irq, void *dev);
339 +int ath_reset(struct ath_softc *sc);
340 +void ath_cancel_work(struct ath_softc *sc);
341 +void ath_restart_work(struct ath_softc *sc);
342 int ath9k_init_device(u16 devid, struct ath_softc *sc,
343 const struct ath_bus_ops *bus_ops);
344 void ath9k_deinit_device(struct ath_softc *sc);
345 --- a/drivers/net/wireless/ath/ath9k/debug.c
346 +++ b/drivers/net/wireless/ath/ath9k/debug.c
347 @@ -1782,111 +1782,6 @@ void ath9k_deinit_debug(struct ath_softc
348 }
349 }
350
351 -static ssize_t read_file_tx99(struct file *file, char __user *user_buf,
352 - size_t count, loff_t *ppos)
353 -{
354 - struct ath_softc *sc = file->private_data;
355 - char buf[3];
356 - unsigned int len;
357 -
358 - len = sprintf(buf, "%d\n", sc->tx99_state);
359 - return simple_read_from_buffer(user_buf, count, ppos, buf, len);
360 -}
361 -
362 -static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
363 - size_t count, loff_t *ppos)
364 -{
365 - struct ath_softc *sc = file->private_data;
366 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
367 - char buf[32];
368 - bool start;
369 - ssize_t len;
370 - int r;
371 -
372 - if (sc->nvifs > 1)
373 - return -EOPNOTSUPP;
374 -
375 - len = min(count, sizeof(buf) - 1);
376 - if (copy_from_user(buf, user_buf, len))
377 - return -EFAULT;
378 -
379 - if (strtobool(buf, &start))
380 - return -EINVAL;
381 -
382 - if (start == sc->tx99_state) {
383 - if (!start)
384 - return count;
385 - ath_dbg(common, XMIT, "Resetting TX99\n");
386 - ath9k_tx99_deinit(sc);
387 - }
388 -
389 - if (!start) {
390 - ath9k_tx99_deinit(sc);
391 - return count;
392 - }
393 -
394 - r = ath9k_tx99_init(sc);
395 - if (r)
396 - return r;
397 -
398 - return count;
399 -}
400 -
401 -static const struct file_operations fops_tx99 = {
402 - .read = read_file_tx99,
403 - .write = write_file_tx99,
404 - .open = simple_open,
405 - .owner = THIS_MODULE,
406 - .llseek = default_llseek,
407 -};
408 -
409 -static ssize_t read_file_tx99_power(struct file *file,
410 - char __user *user_buf,
411 - size_t count, loff_t *ppos)
412 -{
413 - struct ath_softc *sc = file->private_data;
414 - char buf[32];
415 - unsigned int len;
416 -
417 - len = sprintf(buf, "%d (%d dBm)\n",
418 - sc->tx99_power,
419 - sc->tx99_power / 2);
420 -
421 - return simple_read_from_buffer(user_buf, count, ppos, buf, len);
422 -}
423 -
424 -static ssize_t write_file_tx99_power(struct file *file,
425 - const char __user *user_buf,
426 - size_t count, loff_t *ppos)
427 -{
428 - struct ath_softc *sc = file->private_data;
429 - int r;
430 - u8 tx_power;
431 -
432 - r = kstrtou8_from_user(user_buf, count, 0, &tx_power);
433 - if (r)
434 - return r;
435 -
436 - if (tx_power > MAX_RATE_POWER)
437 - return -EINVAL;
438 -
439 - sc->tx99_power = tx_power;
440 -
441 - ath9k_ps_wakeup(sc);
442 - ath9k_hw_tx99_set_txpower(sc->sc_ah, sc->tx99_power);
443 - ath9k_ps_restore(sc);
444 -
445 - return count;
446 -}
447 -
448 -static const struct file_operations fops_tx99_power = {
449 - .read = read_file_tx99_power,
450 - .write = write_file_tx99_power,
451 - .open = simple_open,
452 - .owner = THIS_MODULE,
453 - .llseek = default_llseek,
454 -};
455 -
456 int ath9k_init_debug(struct ath_hw *ah)
457 {
458 struct ath_common *common = ath9k_hw_common(ah);
459 @@ -1903,6 +1798,7 @@ int ath9k_init_debug(struct ath_hw *ah)
460 #endif
461
462 ath9k_dfs_init_debug(sc);
463 + ath9k_tx99_init_debug(sc);
464
465 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
466 &fops_dma);
467 @@ -1978,15 +1874,6 @@ int ath9k_init_debug(struct ath_hw *ah)
468 debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
469 &fops_btcoex);
470 #endif
471 - if (config_enabled(CPTCFG_ATH9K_TX99) &&
472 - AR_SREV_9300_20_OR_LATER(ah)) {
473 - debugfs_create_file("tx99", S_IRUSR | S_IWUSR,
474 - sc->debug.debugfs_phy, sc,
475 - &fops_tx99);
476 - debugfs_create_file("tx99_power", S_IRUSR | S_IWUSR,
477 - sc->debug.debugfs_phy, sc,
478 - &fops_tx99_power);
479 - }
480
481 return 0;
482 }
483 --- a/drivers/net/wireless/ath/ath9k/hw.c
484 +++ b/drivers/net/wireless/ath/ath9k/hw.c
485 @@ -454,7 +454,6 @@ static void ath9k_hw_init_config(struct
486 }
487
488 ah->config.rx_intr_mitigation = true;
489 - ah->config.pcieSerDesWrite = true;
490
491 /*
492 * We need this for PCI devices only (Cardbus, PCI, miniPCI)
493 --- a/drivers/net/wireless/ath/ath9k/hw.h
494 +++ b/drivers/net/wireless/ath/ath9k/hw.h
495 @@ -283,7 +283,6 @@ struct ath9k_ops_config {
496 int additional_swba_backoff;
497 int ack_6mb;
498 u32 cwm_ignore_extcca;
499 - bool pcieSerDesWrite;
500 u8 pcie_clock_req;
501 u32 pcie_waen;
502 u8 analog_shiftreg;
503 @@ -920,7 +919,7 @@ struct ath_hw {
504 /* Enterprise mode cap */
505 u32 ent_mode;
506
507 -#ifdef CONFIG_PM_SLEEP
508 +#ifdef CONFIG_ATH9K_WOW
509 u32 wow_event_mask;
510 #endif
511 bool is_clk_25mhz;
512 @@ -1126,7 +1125,7 @@ ath9k_hw_get_btcoex_scheme(struct ath_hw
513 #endif /* CPTCFG_ATH9K_BTCOEX_SUPPORT */
514
515
516 -#ifdef CONFIG_PM_SLEEP
517 +#ifdef CONFIG_ATH9K_WOW
518 const char *ath9k_hw_wow_event_to_string(u32 wow_event);
519 void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
520 u8 *user_mask, int pattern_count,
521 --- a/drivers/net/wireless/ath/ath9k/init.c
522 +++ b/drivers/net/wireless/ath/ath9k/init.c
523 @@ -683,6 +683,7 @@ static int ath9k_init_softc(u16 devid, s
524 common = ath9k_hw_common(ah);
525 sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
526 sc->tx99_power = MAX_RATE_POWER + 1;
527 + init_waitqueue_head(&sc->tx_wait);
528
529 if (!pdata) {
530 ah->ah_flags |= AH_USE_EEPROM;
531 @@ -730,6 +731,7 @@ static int ath9k_init_softc(u16 devid, s
532 tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
533 (unsigned long)sc);
534
535 + setup_timer(&sc->sleep_timer, ath_ps_full_sleep, (unsigned long)sc);
536 INIT_WORK(&sc->hw_reset_work, ath_reset_work);
537 INIT_WORK(&sc->hw_check_work, ath_hw_check);
538 INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
539 @@ -862,20 +864,11 @@ static const struct ieee80211_iface_comb
540 .max_interfaces = 1,
541 .num_different_channels = 1,
542 .beacon_int_infra_match = true,
543 - .radar_detect_widths = BIT(NL80211_CHAN_NO_HT) |
544 - BIT(NL80211_CHAN_HT20),
545 + .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
546 + BIT(NL80211_CHAN_WIDTH_20),
547 }
548 };
549
550 -#ifdef CONFIG_PM
551 -static const struct wiphy_wowlan_support ath9k_wowlan_support = {
552 - .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
553 - .n_patterns = MAX_NUM_USER_PATTERN,
554 - .pattern_min_len = 1,
555 - .pattern_max_len = MAX_PATTERN_SIZE,
556 -};
557 -#endif
558 -
559 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
560 {
561 struct ath_hw *ah = sc->sc_ah;
562 @@ -925,16 +918,6 @@ void ath9k_set_hw_capab(struct ath_softc
563 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ;
564 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
565
566 -#ifdef CONFIG_PM_SLEEP
567 - if ((ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) &&
568 - (sc->driver_data & ATH9K_PCI_WOW) &&
569 - device_can_wakeup(sc->dev))
570 - hw->wiphy->wowlan = &ath9k_wowlan_support;
571 -
572 - atomic_set(&sc->wow_sleep_proc_intr, -1);
573 - atomic_set(&sc->wow_got_bmiss_intr, -1);
574 -#endif
575 -
576 hw->queues = 4;
577 hw->max_rates = 4;
578 hw->channel_change_time = 5000;
579 @@ -960,6 +943,7 @@ void ath9k_set_hw_capab(struct ath_softc
580 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
581 &sc->sbands[IEEE80211_BAND_5GHZ];
582
583 + ath9k_init_wow(hw);
584 ath9k_reload_chainmask_settings(sc);
585
586 SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
587 @@ -1058,6 +1042,7 @@ static void ath9k_deinit_softc(struct at
588 if (ATH_TXQ_SETUP(sc, i))
589 ath_tx_cleanupq(sc, &sc->tx.txq[i]);
590
591 + del_timer_sync(&sc->sleep_timer);
592 ath9k_hw_deinit(sc->sc_ah);
593 if (sc->dfs_detector != NULL)
594 sc->dfs_detector->exit(sc->dfs_detector);
595 --- a/drivers/net/wireless/ath/ath9k/main.c
596 +++ b/drivers/net/wireless/ath/ath9k/main.c
597 @@ -82,6 +82,22 @@ static bool ath9k_setpower(struct ath_so
598 return ret;
599 }
600
601 +void ath_ps_full_sleep(unsigned long data)
602 +{
603 + struct ath_softc *sc = (struct ath_softc *) data;
604 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
605 + bool reset;
606 +
607 + spin_lock(&common->cc_lock);
608 + ath_hw_cycle_counters_update(common);
609 + spin_unlock(&common->cc_lock);
610 +
611 + ath9k_hw_setrxabort(sc->sc_ah, 1);
612 + ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
613 +
614 + ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
615 +}
616 +
617 void ath9k_ps_wakeup(struct ath_softc *sc)
618 {
619 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
620 @@ -92,6 +108,7 @@ void ath9k_ps_wakeup(struct ath_softc *s
621 if (++sc->ps_usecount != 1)
622 goto unlock;
623
624 + del_timer_sync(&sc->sleep_timer);
625 power_mode = sc->sc_ah->power_mode;
626 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
627
628 @@ -117,17 +134,17 @@ void ath9k_ps_restore(struct ath_softc *
629 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
630 enum ath9k_power_mode mode;
631 unsigned long flags;
632 - bool reset;
633
634 spin_lock_irqsave(&sc->sc_pm_lock, flags);
635 if (--sc->ps_usecount != 0)
636 goto unlock;
637
638 if (sc->ps_idle) {
639 - ath9k_hw_setrxabort(sc->sc_ah, 1);
640 - ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
641 - mode = ATH9K_PM_FULL_SLEEP;
642 - } else if (sc->ps_enabled &&
643 + mod_timer(&sc->sleep_timer, jiffies + HZ / 10);
644 + goto unlock;
645 + }
646 +
647 + if (sc->ps_enabled &&
648 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
649 PS_WAIT_FOR_CAB |
650 PS_WAIT_FOR_PSPOLL_DATA |
651 @@ -163,13 +180,13 @@ static void __ath_cancel_work(struct ath
652 #endif
653 }
654
655 -static void ath_cancel_work(struct ath_softc *sc)
656 +void ath_cancel_work(struct ath_softc *sc)
657 {
658 __ath_cancel_work(sc);
659 cancel_work_sync(&sc->hw_reset_work);
660 }
661
662 -static void ath_restart_work(struct ath_softc *sc)
663 +void ath_restart_work(struct ath_softc *sc)
664 {
665 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
666
667 @@ -487,6 +504,8 @@ void ath9k_tasklet(unsigned long data)
668 ath_tx_edma_tasklet(sc);
669 else
670 ath_tx_tasklet(sc);
671 +
672 + wake_up(&sc->tx_wait);
673 }
674
675 ath9k_btcoex_handle_interrupt(sc, status);
676 @@ -579,7 +598,8 @@ irqreturn_t ath_isr(int irq, void *dev)
677
678 goto chip_reset;
679 }
680 -#ifdef CONFIG_PM_SLEEP
681 +
682 +#ifdef CONFIG_ATH9K_WOW
683 if (status & ATH9K_INT_BMISS) {
684 if (atomic_read(&sc->wow_sleep_proc_intr) == 0) {
685 ath_dbg(common, ANY, "during WoW we got a BMISS\n");
686 @@ -588,6 +608,8 @@ irqreturn_t ath_isr(int irq, void *dev)
687 }
688 }
689 #endif
690 +
691 +
692 if (status & ATH9K_INT_SWBA)
693 tasklet_schedule(&sc->bcon_tasklet);
694
695 @@ -627,7 +649,7 @@ chip_reset:
696 #undef SCHED_INTR
697 }
698
699 -static int ath_reset(struct ath_softc *sc)
700 +int ath_reset(struct ath_softc *sc)
701 {
702 int r;
703
704 @@ -1817,13 +1839,31 @@ static void ath9k_set_coverage_class(str
705 mutex_unlock(&sc->mutex);
706 }
707
708 +static bool ath9k_has_tx_pending(struct ath_softc *sc)
709 +{
710 + int i, npend;
711 +
712 + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
713 + if (!ATH_TXQ_SETUP(sc, i))
714 + continue;
715 +
716 + if (!sc->tx.txq[i].axq_depth)
717 + continue;
718 +
719 + npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
720 + if (npend)
721 + break;
722 + }
723 +
724 + return !!npend;
725 +}
726 +
727 static void ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
728 {
729 struct ath_softc *sc = hw->priv;
730 struct ath_hw *ah = sc->sc_ah;
731 struct ath_common *common = ath9k_hw_common(ah);
732 - int timeout = 200; /* ms */
733 - int i, j;
734 + int timeout = HZ / 5; /* 200 ms */
735 bool drain_txq;
736
737 mutex_lock(&sc->mutex);
738 @@ -1841,25 +1881,9 @@ static void ath9k_flush(struct ieee80211
739 return;
740 }
741
742 - for (j = 0; j < timeout; j++) {
743 - bool npend = false;
744 -
745 - if (j)
746 - usleep_range(1000, 2000);
747 -
748 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
749 - if (!ATH_TXQ_SETUP(sc, i))
750 - continue;
751 -
752 - npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
753 -
754 - if (npend)
755 - break;
756 - }
757 -
758 - if (!npend)
759 - break;
760 - }
761 + if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc),
762 + timeout) > 0)
763 + drop = false;
764
765 if (drop) {
766 ath9k_ps_wakeup(sc);
767 @@ -2021,333 +2045,6 @@ static int ath9k_get_antenna(struct ieee
768 return 0;
769 }
770
771 -#ifdef CONFIG_PM_SLEEP
772 -
773 -static void ath9k_wow_map_triggers(struct ath_softc *sc,
774 - struct cfg80211_wowlan *wowlan,
775 - u32 *wow_triggers)
776 -{
777 - if (wowlan->disconnect)
778 - *wow_triggers |= AH_WOW_LINK_CHANGE |
779 - AH_WOW_BEACON_MISS;
780 - if (wowlan->magic_pkt)
781 - *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
782 -
783 - if (wowlan->n_patterns)
784 - *wow_triggers |= AH_WOW_USER_PATTERN_EN;
785 -
786 - sc->wow_enabled = *wow_triggers;
787 -
788 -}
789 -
790 -static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
791 -{
792 - struct ath_hw *ah = sc->sc_ah;
793 - struct ath_common *common = ath9k_hw_common(ah);
794 - int pattern_count = 0;
795 - int i, byte_cnt;
796 - u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
797 - u8 dis_deauth_mask[MAX_PATTERN_SIZE];
798 -
799 - memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
800 - memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
801 -
802 - /*
803 - * Create Dissassociate / Deauthenticate packet filter
804 - *
805 - * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes
806 - * +--------------+----------+---------+--------+--------+----
807 - * + Frame Control+ Duration + DA + SA + BSSID +
808 - * +--------------+----------+---------+--------+--------+----
809 - *
810 - * The above is the management frame format for disassociate/
811 - * deauthenticate pattern, from this we need to match the first byte
812 - * of 'Frame Control' and DA, SA, and BSSID fields
813 - * (skipping 2nd byte of FC and Duration feild.
814 - *
815 - * Disassociate pattern
816 - * --------------------
817 - * Frame control = 00 00 1010
818 - * DA, SA, BSSID = x:x:x:x:x:x
819 - * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
820 - * | x:x:x:x:x:x -- 22 bytes
821 - *
822 - * Deauthenticate pattern
823 - * ----------------------
824 - * Frame control = 00 00 1100
825 - * DA, SA, BSSID = x:x:x:x:x:x
826 - * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
827 - * | x:x:x:x:x:x -- 22 bytes
828 - */
829 -
830 - /* Create Disassociate Pattern first */
831 -
832 - byte_cnt = 0;
833 -
834 - /* Fill out the mask with all FF's */
835 -
836 - for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
837 - dis_deauth_mask[i] = 0xff;
838 -
839 - /* copy the first byte of frame control field */
840 - dis_deauth_pattern[byte_cnt] = 0xa0;
841 - byte_cnt++;
842 -
843 - /* skip 2nd byte of frame control and Duration field */
844 - byte_cnt += 3;
845 -
846 - /*
847 - * need not match the destination mac address, it can be a broadcast
848 - * mac address or an unicast to this station
849 - */
850 - byte_cnt += 6;
851 -
852 - /* copy the source mac address */
853 - memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
854 -
855 - byte_cnt += 6;
856 -
857 - /* copy the bssid, its same as the source mac address */
858 -
859 - memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
860 -
861 - /* Create Disassociate pattern mask */
862 -
863 - dis_deauth_mask[0] = 0xfe;
864 - dis_deauth_mask[1] = 0x03;
865 - dis_deauth_mask[2] = 0xc0;
866 -
867 - ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
868 -
869 - ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
870 - pattern_count, byte_cnt);
871 -
872 - pattern_count++;
873 - /*
874 - * for de-authenticate pattern, only the first byte of the frame
875 - * control field gets changed from 0xA0 to 0xC0
876 - */
877 - dis_deauth_pattern[0] = 0xC0;
878 -
879 - ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
880 - pattern_count, byte_cnt);
881 -
882 -}
883 -
884 -static void ath9k_wow_add_pattern(struct ath_softc *sc,
885 - struct cfg80211_wowlan *wowlan)
886 -{
887 - struct ath_hw *ah = sc->sc_ah;
888 - struct ath9k_wow_pattern *wow_pattern = NULL;
889 - struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
890 - int mask_len;
891 - s8 i = 0;
892 -
893 - if (!wowlan->n_patterns)
894 - return;
895 -
896 - /*
897 - * Add the new user configured patterns
898 - */
899 - for (i = 0; i < wowlan->n_patterns; i++) {
900 -
901 - wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
902 -
903 - if (!wow_pattern)
904 - return;
905 -
906 - /*
907 - * TODO: convert the generic user space pattern to
908 - * appropriate chip specific/802.11 pattern.
909 - */
910 -
911 - mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
912 - memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
913 - memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
914 - memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
915 - patterns[i].pattern_len);
916 - memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
917 - wow_pattern->pattern_len = patterns[i].pattern_len;
918 -
919 - /*
920 - * just need to take care of deauth and disssoc pattern,
921 - * make sure we don't overwrite them.
922 - */
923 -
924 - ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
925 - wow_pattern->mask_bytes,
926 - i + 2,
927 - wow_pattern->pattern_len);
928 - kfree(wow_pattern);
929 -
930 - }
931 -
932 -}
933 -
934 -static int ath9k_suspend(struct ieee80211_hw *hw,
935 - struct cfg80211_wowlan *wowlan)
936 -{
937 - struct ath_softc *sc = hw->priv;
938 - struct ath_hw *ah = sc->sc_ah;
939 - struct ath_common *common = ath9k_hw_common(ah);
940 - u32 wow_triggers_enabled = 0;
941 - int ret = 0;
942 -
943 - mutex_lock(&sc->mutex);
944 -
945 - ath_cancel_work(sc);
946 - ath_stop_ani(sc);
947 - del_timer_sync(&sc->rx_poll_timer);
948 -
949 - if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
950 - ath_dbg(common, ANY, "Device not present\n");
951 - ret = -EINVAL;
952 - goto fail_wow;
953 - }
954 -
955 - if (WARN_ON(!wowlan)) {
956 - ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
957 - ret = -EINVAL;
958 - goto fail_wow;
959 - }
960 -
961 - if (!device_can_wakeup(sc->dev)) {
962 - ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
963 - ret = 1;
964 - goto fail_wow;
965 - }
966 -
967 - /*
968 - * none of the sta vifs are associated
969 - * and we are not currently handling multivif
970 - * cases, for instance we have to seperately
971 - * configure 'keep alive frame' for each
972 - * STA.
973 - */
974 -
975 - if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
976 - ath_dbg(common, WOW, "None of the STA vifs are associated\n");
977 - ret = 1;
978 - goto fail_wow;
979 - }
980 -
981 - if (sc->nvifs > 1) {
982 - ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
983 - ret = 1;
984 - goto fail_wow;
985 - }
986 -
987 - ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
988 -
989 - ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
990 - wow_triggers_enabled);
991 -
992 - ath9k_ps_wakeup(sc);
993 -
994 - ath9k_stop_btcoex(sc);
995 -
996 - /*
997 - * Enable wake up on recieving disassoc/deauth
998 - * frame by default.
999 - */
1000 - ath9k_wow_add_disassoc_deauth_pattern(sc);
1001 -
1002 - if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
1003 - ath9k_wow_add_pattern(sc, wowlan);
1004 -
1005 - spin_lock_bh(&sc->sc_pcu_lock);
1006 - /*
1007 - * To avoid false wake, we enable beacon miss interrupt only
1008 - * when we go to sleep. We save the current interrupt mask
1009 - * so we can restore it after the system wakes up
1010 - */
1011 - sc->wow_intr_before_sleep = ah->imask;
1012 - ah->imask &= ~ATH9K_INT_GLOBAL;
1013 - ath9k_hw_disable_interrupts(ah);
1014 - ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
1015 - ath9k_hw_set_interrupts(ah);
1016 - ath9k_hw_enable_interrupts(ah);
1017 -
1018 - spin_unlock_bh(&sc->sc_pcu_lock);
1019 -
1020 - /*
1021 - * we can now sync irq and kill any running tasklets, since we already
1022 - * disabled interrupts and not holding a spin lock
1023 - */
1024 - synchronize_irq(sc->irq);
1025 - tasklet_kill(&sc->intr_tq);
1026 -
1027 - ath9k_hw_wow_enable(ah, wow_triggers_enabled);
1028 -
1029 - ath9k_ps_restore(sc);
1030 - ath_dbg(common, ANY, "WoW enabled in ath9k\n");
1031 - atomic_inc(&sc->wow_sleep_proc_intr);
1032 -
1033 -fail_wow:
1034 - mutex_unlock(&sc->mutex);
1035 - return ret;
1036 -}
1037 -
1038 -static int ath9k_resume(struct ieee80211_hw *hw)
1039 -{
1040 - struct ath_softc *sc = hw->priv;
1041 - struct ath_hw *ah = sc->sc_ah;
1042 - struct ath_common *common = ath9k_hw_common(ah);
1043 - u32 wow_status;
1044 -
1045 - mutex_lock(&sc->mutex);
1046 -
1047 - ath9k_ps_wakeup(sc);
1048 -
1049 - spin_lock_bh(&sc->sc_pcu_lock);
1050 -
1051 - ath9k_hw_disable_interrupts(ah);
1052 - ah->imask = sc->wow_intr_before_sleep;
1053 - ath9k_hw_set_interrupts(ah);
1054 - ath9k_hw_enable_interrupts(ah);
1055 -
1056 - spin_unlock_bh(&sc->sc_pcu_lock);
1057 -
1058 - wow_status = ath9k_hw_wow_wakeup(ah);
1059 -
1060 - if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
1061 - /*
1062 - * some devices may not pick beacon miss
1063 - * as the reason they woke up so we add
1064 - * that here for that shortcoming.
1065 - */
1066 - wow_status |= AH_WOW_BEACON_MISS;
1067 - atomic_dec(&sc->wow_got_bmiss_intr);
1068 - ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
1069 - }
1070 -
1071 - atomic_dec(&sc->wow_sleep_proc_intr);
1072 -
1073 - if (wow_status) {
1074 - ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
1075 - ath9k_hw_wow_event_to_string(wow_status), wow_status);
1076 - }
1077 -
1078 - ath_restart_work(sc);
1079 - ath9k_start_btcoex(sc);
1080 -
1081 - ath9k_ps_restore(sc);
1082 - mutex_unlock(&sc->mutex);
1083 -
1084 - return 0;
1085 -}
1086 -
1087 -static void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1088 -{
1089 - struct ath_softc *sc = hw->priv;
1090 -
1091 - mutex_lock(&sc->mutex);
1092 - device_init_wakeup(sc->dev, 1);
1093 - device_set_wakeup_enable(sc->dev, enabled);
1094 - mutex_unlock(&sc->mutex);
1095 -}
1096 -
1097 -#endif
1098 static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
1099 {
1100 struct ath_softc *sc = hw->priv;
1101 @@ -2373,134 +2070,6 @@ static void ath9k_channel_switch_beacon(
1102 sc->csa_vif = vif;
1103 }
1104
1105 -static void ath9k_tx99_stop(struct ath_softc *sc)
1106 -{
1107 - struct ath_hw *ah = sc->sc_ah;
1108 - struct ath_common *common = ath9k_hw_common(ah);
1109 -
1110 - ath_drain_all_txq(sc);
1111 - ath_startrecv(sc);
1112 -
1113 - ath9k_hw_set_interrupts(ah);
1114 - ath9k_hw_enable_interrupts(ah);
1115 -
1116 - ieee80211_wake_queues(sc->hw);
1117 -
1118 - kfree_skb(sc->tx99_skb);
1119 - sc->tx99_skb = NULL;
1120 - sc->tx99_state = false;
1121 -
1122 - ath9k_hw_tx99_stop(sc->sc_ah);
1123 - ath_dbg(common, XMIT, "TX99 stopped\n");
1124 -}
1125 -
1126 -static struct sk_buff *ath9k_build_tx99_skb(struct ath_softc *sc)
1127 -{
1128 - static u8 PN9Data[] = {0xff, 0x87, 0xb8, 0x59, 0xb7, 0xa1, 0xcc, 0x24,
1129 - 0x57, 0x5e, 0x4b, 0x9c, 0x0e, 0xe9, 0xea, 0x50,
1130 - 0x2a, 0xbe, 0xb4, 0x1b, 0xb6, 0xb0, 0x5d, 0xf1,
1131 - 0xe6, 0x9a, 0xe3, 0x45, 0xfd, 0x2c, 0x53, 0x18,
1132 - 0x0c, 0xca, 0xc9, 0xfb, 0x49, 0x37, 0xe5, 0xa8,
1133 - 0x51, 0x3b, 0x2f, 0x61, 0xaa, 0x72, 0x18, 0x84,
1134 - 0x02, 0x23, 0x23, 0xab, 0x63, 0x89, 0x51, 0xb3,
1135 - 0xe7, 0x8b, 0x72, 0x90, 0x4c, 0xe8, 0xfb, 0xc0};
1136 - u32 len = 1200;
1137 - struct ieee80211_hw *hw = sc->hw;
1138 - struct ieee80211_hdr *hdr;
1139 - struct ieee80211_tx_info *tx_info;
1140 - struct sk_buff *skb;
1141 -
1142 - skb = alloc_skb(len, GFP_KERNEL);
1143 - if (!skb)
1144 - return NULL;
1145 -
1146 - skb_put(skb, len);
1147 -
1148 - memset(skb->data, 0, len);
1149 -
1150 - hdr = (struct ieee80211_hdr *)skb->data;
1151 - hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA);
1152 - hdr->duration_id = 0;
1153 -
1154 - memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
1155 - memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
1156 - memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
1157 -
1158 - hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
1159 -
1160 - tx_info = IEEE80211_SKB_CB(skb);
1161 - memset(tx_info, 0, sizeof(*tx_info));
1162 - tx_info->band = hw->conf.chandef.chan->band;
1163 - tx_info->flags = IEEE80211_TX_CTL_NO_ACK;
1164 - tx_info->control.vif = sc->tx99_vif;
1165 -
1166 - memcpy(skb->data + sizeof(*hdr), PN9Data, sizeof(PN9Data));
1167 -
1168 - return skb;
1169 -}
1170 -
1171 -void ath9k_tx99_deinit(struct ath_softc *sc)
1172 -{
1173 - ath_reset(sc);
1174 -
1175 - ath9k_ps_wakeup(sc);
1176 - ath9k_tx99_stop(sc);
1177 - ath9k_ps_restore(sc);
1178 -}
1179 -
1180 -int ath9k_tx99_init(struct ath_softc *sc)
1181 -{
1182 - struct ieee80211_hw *hw = sc->hw;
1183 - struct ath_hw *ah = sc->sc_ah;
1184 - struct ath_common *common = ath9k_hw_common(ah);
1185 - struct ath_tx_control txctl;
1186 - int r;
1187 -
1188 - if (sc->sc_flags & SC_OP_INVALID) {
1189 - ath_err(common,
1190 - "driver is in invalid state unable to use TX99");
1191 - return -EINVAL;
1192 - }
1193 -
1194 - sc->tx99_skb = ath9k_build_tx99_skb(sc);
1195 - if (!sc->tx99_skb)
1196 - return -ENOMEM;
1197 -
1198 - memset(&txctl, 0, sizeof(txctl));
1199 - txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
1200 -
1201 - ath_reset(sc);
1202 -
1203 - ath9k_ps_wakeup(sc);
1204 -
1205 - ath9k_hw_disable_interrupts(ah);
1206 - atomic_set(&ah->intr_ref_cnt, -1);
1207 - ath_drain_all_txq(sc);
1208 - ath_stoprecv(sc);
1209 -
1210 - sc->tx99_state = true;
1211 -
1212 - ieee80211_stop_queues(hw);
1213 -
1214 - if (sc->tx99_power == MAX_RATE_POWER + 1)
1215 - sc->tx99_power = MAX_RATE_POWER;
1216 -
1217 - ath9k_hw_tx99_set_txpower(ah, sc->tx99_power);
1218 - r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
1219 - if (r) {
1220 - ath_dbg(common, XMIT, "Failed to xmit TX99 skb\n");
1221 - return r;
1222 - }
1223 -
1224 - ath_dbg(common, XMIT, "TX99 xmit started using %d ( %ddBm)\n",
1225 - sc->tx99_power,
1226 - sc->tx99_power / 2);
1227 -
1228 - /* We leave the harware awake as it will be chugging on */
1229 -
1230 - return 0;
1231 -}
1232 -
1233 struct ieee80211_ops ath9k_ops = {
1234 .tx = ath9k_tx,
1235 .start = ath9k_start,
1236 @@ -2531,7 +2100,7 @@ struct ieee80211_ops ath9k_ops = {
1237 .set_antenna = ath9k_set_antenna,
1238 .get_antenna = ath9k_get_antenna,
1239
1240 -#ifdef CONFIG_PM_SLEEP
1241 +#ifdef CONFIG_ATH9K_WOW
1242 .suspend = ath9k_suspend,
1243 .resume = ath9k_resume,
1244 .set_wakeup = ath9k_set_wakeup,
1245 --- a/drivers/net/wireless/ath/ath9k/wow.c
1246 +++ b/drivers/net/wireless/ath/ath9k/wow.c
1247 @@ -1,5 +1,5 @@
1248 /*
1249 - * Copyright (c) 2012 Qualcomm Atheros, Inc.
1250 + * Copyright (c) 2013 Qualcomm Atheros, Inc.
1251 *
1252 * Permission to use, copy, modify, and/or distribute this software for any
1253 * purpose with or without fee is hereby granted, provided that the above
1254 @@ -14,409 +14,348 @@
1255 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1256 */
1257
1258 -#include <linux/export.h>
1259 #include "ath9k.h"
1260 -#include "reg.h"
1261 -#include "hw-ops.h"
1262
1263 -const char *ath9k_hw_wow_event_to_string(u32 wow_event)
1264 +static const struct wiphy_wowlan_support ath9k_wowlan_support = {
1265 + .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
1266 + .n_patterns = MAX_NUM_USER_PATTERN,
1267 + .pattern_min_len = 1,
1268 + .pattern_max_len = MAX_PATTERN_SIZE,
1269 +};
1270 +
1271 +static void ath9k_wow_map_triggers(struct ath_softc *sc,
1272 + struct cfg80211_wowlan *wowlan,
1273 + u32 *wow_triggers)
1274 {
1275 - if (wow_event & AH_WOW_MAGIC_PATTERN_EN)
1276 - return "Magic pattern";
1277 - if (wow_event & AH_WOW_USER_PATTERN_EN)
1278 - return "User pattern";
1279 - if (wow_event & AH_WOW_LINK_CHANGE)
1280 - return "Link change";
1281 - if (wow_event & AH_WOW_BEACON_MISS)
1282 - return "Beacon miss";
1283 + if (wowlan->disconnect)
1284 + *wow_triggers |= AH_WOW_LINK_CHANGE |
1285 + AH_WOW_BEACON_MISS;
1286 + if (wowlan->magic_pkt)
1287 + *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
1288 +
1289 + if (wowlan->n_patterns)
1290 + *wow_triggers |= AH_WOW_USER_PATTERN_EN;
1291 +
1292 + sc->wow_enabled = *wow_triggers;
1293
1294 - return "unknown reason";
1295 }
1296 -EXPORT_SYMBOL(ath9k_hw_wow_event_to_string);
1297
1298 -static void ath9k_hw_set_powermode_wow_sleep(struct ath_hw *ah)
1299 +static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
1300 {
1301 + struct ath_hw *ah = sc->sc_ah;
1302 struct ath_common *common = ath9k_hw_common(ah);
1303 + int pattern_count = 0;
1304 + int i, byte_cnt;
1305 + u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
1306 + u8 dis_deauth_mask[MAX_PATTERN_SIZE];
1307
1308 - REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
1309 + memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
1310 + memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
1311
1312 - /* set rx disable bit */
1313 - REG_WRITE(ah, AR_CR, AR_CR_RXD);
1314 + /*
1315 + * Create Dissassociate / Deauthenticate packet filter
1316 + *
1317 + * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes
1318 + * +--------------+----------+---------+--------+--------+----
1319 + * + Frame Control+ Duration + DA + SA + BSSID +
1320 + * +--------------+----------+---------+--------+--------+----
1321 + *
1322 + * The above is the management frame format for disassociate/
1323 + * deauthenticate pattern, from this we need to match the first byte
1324 + * of 'Frame Control' and DA, SA, and BSSID fields
1325 + * (skipping 2nd byte of FC and Duration feild.
1326 + *
1327 + * Disassociate pattern
1328 + * --------------------
1329 + * Frame control = 00 00 1010
1330 + * DA, SA, BSSID = x:x:x:x:x:x
1331 + * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
1332 + * | x:x:x:x:x:x -- 22 bytes
1333 + *
1334 + * Deauthenticate pattern
1335 + * ----------------------
1336 + * Frame control = 00 00 1100
1337 + * DA, SA, BSSID = x:x:x:x:x:x
1338 + * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
1339 + * | x:x:x:x:x:x -- 22 bytes
1340 + */
1341
1342 - if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0, AH_WAIT_TIMEOUT)) {
1343 - ath_err(common, "Failed to stop Rx DMA in 10ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
1344 - REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
1345 - return;
1346 - }
1347 + /* Create Disassociate Pattern first */
1348
1349 - REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_ON_INT);
1350 -}
1351 + byte_cnt = 0;
1352
1353 -static void ath9k_wow_create_keep_alive_pattern(struct ath_hw *ah)
1354 -{
1355 - struct ath_common *common = ath9k_hw_common(ah);
1356 - u8 sta_mac_addr[ETH_ALEN], ap_mac_addr[ETH_ALEN];
1357 - u32 ctl[13] = {0};
1358 - u32 data_word[KAL_NUM_DATA_WORDS];
1359 - u8 i;
1360 - u32 wow_ka_data_word0;
1361 -
1362 - memcpy(sta_mac_addr, common->macaddr, ETH_ALEN);
1363 - memcpy(ap_mac_addr, common->curbssid, ETH_ALEN);
1364 -
1365 - /* set the transmit buffer */
1366 - ctl[0] = (KAL_FRAME_LEN | (MAX_RATE_POWER << 16));
1367 - ctl[1] = 0;
1368 - ctl[3] = 0xb; /* OFDM_6M hardware value for this rate */
1369 - ctl[4] = 0;
1370 - ctl[7] = (ah->txchainmask) << 2;
1371 - ctl[2] = 0xf << 16; /* tx_tries 0 */
1372 -
1373 - for (i = 0; i < KAL_NUM_DESC_WORDS; i++)
1374 - REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
1375 -
1376 - REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
1377 -
1378 - data_word[0] = (KAL_FRAME_TYPE << 2) | (KAL_FRAME_SUB_TYPE << 4) |
1379 - (KAL_TO_DS << 8) | (KAL_DURATION_ID << 16);
1380 - data_word[1] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
1381 - (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
1382 - data_word[2] = (sta_mac_addr[1] << 24) | (sta_mac_addr[0] << 16) |
1383 - (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
1384 - data_word[3] = (sta_mac_addr[5] << 24) | (sta_mac_addr[4] << 16) |
1385 - (sta_mac_addr[3] << 8) | (sta_mac_addr[2]);
1386 - data_word[4] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
1387 - (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
1388 - data_word[5] = (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
1389 -
1390 - if (AR_SREV_9462_20(ah)) {
1391 - /* AR9462 2.0 has an extra descriptor word (time based
1392 - * discard) compared to other chips */
1393 - REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + (12 * 4)), 0);
1394 - wow_ka_data_word0 = AR_WOW_TXBUF(13);
1395 - } else {
1396 - wow_ka_data_word0 = AR_WOW_TXBUF(12);
1397 - }
1398 + /* Fill out the mask with all FF's */
1399
1400 - for (i = 0; i < KAL_NUM_DATA_WORDS; i++)
1401 - REG_WRITE(ah, (wow_ka_data_word0 + i*4), data_word[i]);
1402 + for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
1403 + dis_deauth_mask[i] = 0xff;
1404
1405 -}
1406 + /* copy the first byte of frame control field */
1407 + dis_deauth_pattern[byte_cnt] = 0xa0;
1408 + byte_cnt++;
1409
1410 -void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
1411 - u8 *user_mask, int pattern_count,
1412 - int pattern_len)
1413 -{
1414 - int i;
1415 - u32 pattern_val, mask_val;
1416 - u32 set, clr;
1417 + /* skip 2nd byte of frame control and Duration field */
1418 + byte_cnt += 3;
1419
1420 - /* FIXME: should check count by querying the hardware capability */
1421 - if (pattern_count >= MAX_NUM_PATTERN)
1422 - return;
1423 + /*
1424 + * need not match the destination mac address, it can be a broadcast
1425 + * mac address or an unicast to this station
1426 + */
1427 + byte_cnt += 6;
1428
1429 - REG_SET_BIT(ah, AR_WOW_PATTERN, BIT(pattern_count));
1430 + /* copy the source mac address */
1431 + memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
1432
1433 - /* set the registers for pattern */
1434 - for (i = 0; i < MAX_PATTERN_SIZE; i += 4) {
1435 - memcpy(&pattern_val, user_pattern, 4);
1436 - REG_WRITE(ah, (AR_WOW_TB_PATTERN(pattern_count) + i),
1437 - pattern_val);
1438 - user_pattern += 4;
1439 - }
1440 + byte_cnt += 6;
1441
1442 - /* set the registers for mask */
1443 - for (i = 0; i < MAX_PATTERN_MASK_SIZE; i += 4) {
1444 - memcpy(&mask_val, user_mask, 4);
1445 - REG_WRITE(ah, (AR_WOW_TB_MASK(pattern_count) + i), mask_val);
1446 - user_mask += 4;
1447 - }
1448 + /* copy the bssid, its same as the source mac address */
1449
1450 - /* set the pattern length to be matched
1451 - *
1452 - * AR_WOW_LENGTH1_REG1
1453 - * bit 31:24 pattern 0 length
1454 - * bit 23:16 pattern 1 length
1455 - * bit 15:8 pattern 2 length
1456 - * bit 7:0 pattern 3 length
1457 - *
1458 - * AR_WOW_LENGTH1_REG2
1459 - * bit 31:24 pattern 4 length
1460 - * bit 23:16 pattern 5 length
1461 - * bit 15:8 pattern 6 length
1462 - * bit 7:0 pattern 7 length
1463 - *
1464 - * the below logic writes out the new
1465 - * pattern length for the corresponding
1466 - * pattern_count, while masking out the
1467 - * other fields
1468 - */
1469 + memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
1470
1471 - ah->wow_event_mask |= BIT(pattern_count + AR_WOW_PAT_FOUND_SHIFT);
1472 + /* Create Disassociate pattern mask */
1473
1474 - if (pattern_count < 4) {
1475 - /* Pattern 0-3 uses AR_WOW_LENGTH1 register */
1476 - set = (pattern_len & AR_WOW_LENGTH_MAX) <<
1477 - AR_WOW_LEN1_SHIFT(pattern_count);
1478 - clr = AR_WOW_LENGTH1_MASK(pattern_count);
1479 - REG_RMW(ah, AR_WOW_LENGTH1, set, clr);
1480 - } else {
1481 - /* Pattern 4-7 uses AR_WOW_LENGTH2 register */
1482 - set = (pattern_len & AR_WOW_LENGTH_MAX) <<
1483 - AR_WOW_LEN2_SHIFT(pattern_count);
1484 - clr = AR_WOW_LENGTH2_MASK(pattern_count);
1485 - REG_RMW(ah, AR_WOW_LENGTH2, set, clr);
1486 - }
1487 + dis_deauth_mask[0] = 0xfe;
1488 + dis_deauth_mask[1] = 0x03;
1489 + dis_deauth_mask[2] = 0xc0;
1490
1491 -}
1492 -EXPORT_SYMBOL(ath9k_hw_wow_apply_pattern);
1493 + ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
1494
1495 -u32 ath9k_hw_wow_wakeup(struct ath_hw *ah)
1496 -{
1497 - u32 wow_status = 0;
1498 - u32 val = 0, rval;
1499 + ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
1500 + pattern_count, byte_cnt);
1501
1502 + pattern_count++;
1503 /*
1504 - * read the WoW status register to know
1505 - * the wakeup reason
1506 + * for de-authenticate pattern, only the first byte of the frame
1507 + * control field gets changed from 0xA0 to 0xC0
1508 */
1509 - rval = REG_READ(ah, AR_WOW_PATTERN);
1510 - val = AR_WOW_STATUS(rval);
1511 + dis_deauth_pattern[0] = 0xC0;
1512
1513 - /*
1514 - * mask only the WoW events that we have enabled. Sometimes
1515 - * we have spurious WoW events from the AR_WOW_PATTERN
1516 - * register. This mask will clean it up.
1517 - */
1518 + ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
1519 + pattern_count, byte_cnt);
1520
1521 - val &= ah->wow_event_mask;
1522 +}
1523
1524 - if (val) {
1525 - if (val & AR_WOW_MAGIC_PAT_FOUND)
1526 - wow_status |= AH_WOW_MAGIC_PATTERN_EN;
1527 - if (AR_WOW_PATTERN_FOUND(val))
1528 - wow_status |= AH_WOW_USER_PATTERN_EN;
1529 - if (val & AR_WOW_KEEP_ALIVE_FAIL)
1530 - wow_status |= AH_WOW_LINK_CHANGE;
1531 - if (val & AR_WOW_BEACON_FAIL)
1532 - wow_status |= AH_WOW_BEACON_MISS;
1533 - }
1534 +static void ath9k_wow_add_pattern(struct ath_softc *sc,
1535 + struct cfg80211_wowlan *wowlan)
1536 +{
1537 + struct ath_hw *ah = sc->sc_ah;
1538 + struct ath9k_wow_pattern *wow_pattern = NULL;
1539 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1540 + int mask_len;
1541 + s8 i = 0;
1542 +
1543 + if (!wowlan->n_patterns)
1544 + return;
1545
1546 /*
1547 - * set and clear WOW_PME_CLEAR registers for the chip to
1548 - * generate next wow signal.
1549 - * disable D3 before accessing other registers ?
1550 + * Add the new user configured patterns
1551 */
1552 + for (i = 0; i < wowlan->n_patterns; i++) {
1553
1554 - /* do we need to check the bit value 0x01000000 (7-10) ?? */
1555 - REG_RMW(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_WOW_PME_CLR,
1556 - AR_PMCTRL_PWR_STATE_D1D3);
1557 + wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
1558
1559 - /*
1560 - * clear all events
1561 - */
1562 - REG_WRITE(ah, AR_WOW_PATTERN,
1563 - AR_WOW_CLEAR_EVENTS(REG_READ(ah, AR_WOW_PATTERN)));
1564 + if (!wow_pattern)
1565 + return;
1566
1567 - /*
1568 - * restore the beacon threshold to init value
1569 - */
1570 - REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
1571 + /*
1572 + * TODO: convert the generic user space pattern to
1573 + * appropriate chip specific/802.11 pattern.
1574 + */
1575
1576 - /*
1577 - * Restore the way the PCI-E reset, Power-On-Reset, external
1578 - * PCIE_POR_SHORT pins are tied to its original value.
1579 - * Previously just before WoW sleep, we untie the PCI-E
1580 - * reset to our Chip's Power On Reset so that any PCI-E
1581 - * reset from the bus will not reset our chip
1582 - */
1583 - if (ah->is_pciexpress)
1584 - ath9k_hw_configpcipowersave(ah, false);
1585 + mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
1586 + memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
1587 + memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
1588 + memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
1589 + patterns[i].pattern_len);
1590 + memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
1591 + wow_pattern->pattern_len = patterns[i].pattern_len;
1592 +
1593 + /*
1594 + * just need to take care of deauth and disssoc pattern,
1595 + * make sure we don't overwrite them.
1596 + */
1597 +
1598 + ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
1599 + wow_pattern->mask_bytes,
1600 + i + 2,
1601 + wow_pattern->pattern_len);
1602 + kfree(wow_pattern);
1603
1604 - ah->wow_event_mask = 0;
1605 + }
1606
1607 - return wow_status;
1608 }
1609 -EXPORT_SYMBOL(ath9k_hw_wow_wakeup);
1610
1611 -void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable)
1612 +int ath9k_suspend(struct ieee80211_hw *hw,
1613 + struct cfg80211_wowlan *wowlan)
1614 {
1615 - u32 wow_event_mask;
1616 - u32 set, clr;
1617 + struct ath_softc *sc = hw->priv;
1618 + struct ath_hw *ah = sc->sc_ah;
1619 + struct ath_common *common = ath9k_hw_common(ah);
1620 + u32 wow_triggers_enabled = 0;
1621 + int ret = 0;
1622
1623 - /*
1624 - * wow_event_mask is a mask to the AR_WOW_PATTERN register to
1625 - * indicate which WoW events we have enabled. The WoW events
1626 - * are from the 'pattern_enable' in this function and
1627 - * 'pattern_count' of ath9k_hw_wow_apply_pattern()
1628 - */
1629 - wow_event_mask = ah->wow_event_mask;
1630 + mutex_lock(&sc->mutex);
1631
1632 - /*
1633 - * Untie Power-on-Reset from the PCI-E-Reset. When we are in
1634 - * WOW sleep, we do want the Reset from the PCI-E to disturb
1635 - * our hw state
1636 - */
1637 - if (ah->is_pciexpress) {
1638 - /*
1639 - * we need to untie the internal POR (power-on-reset)
1640 - * to the external PCI-E reset. We also need to tie
1641 - * the PCI-E Phy reset to the PCI-E reset.
1642 - */
1643 - set = AR_WA_RESET_EN | AR_WA_POR_SHORT;
1644 - clr = AR_WA_UNTIE_RESET_EN | AR_WA_D3_L1_DISABLE;
1645 - REG_RMW(ah, AR_WA, set, clr);
1646 + ath_cancel_work(sc);
1647 + ath_stop_ani(sc);
1648 + del_timer_sync(&sc->rx_poll_timer);
1649 +
1650 + if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
1651 + ath_dbg(common, ANY, "Device not present\n");
1652 + ret = -EINVAL;
1653 + goto fail_wow;
1654 }
1655
1656 - /*
1657 - * set the power states appropriately and enable PME
1658 - */
1659 - set = AR_PMCTRL_HOST_PME_EN | AR_PMCTRL_PWR_PM_CTRL_ENA |
1660 - AR_PMCTRL_AUX_PWR_DET | AR_PMCTRL_WOW_PME_CLR;
1661 + if (WARN_ON(!wowlan)) {
1662 + ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
1663 + ret = -EINVAL;
1664 + goto fail_wow;
1665 + }
1666
1667 - /*
1668 - * set and clear WOW_PME_CLEAR registers for the chip
1669 - * to generate next wow signal.
1670 - */
1671 - REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
1672 - clr = AR_PMCTRL_WOW_PME_CLR;
1673 - REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
1674 + if (!device_can_wakeup(sc->dev)) {
1675 + ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
1676 + ret = 1;
1677 + goto fail_wow;
1678 + }
1679
1680 /*
1681 - * Setup for:
1682 - * - beacon misses
1683 - * - magic pattern
1684 - * - keep alive timeout
1685 - * - pattern matching
1686 + * none of the sta vifs are associated
1687 + * and we are not currently handling multivif
1688 + * cases, for instance we have to seperately
1689 + * configure 'keep alive frame' for each
1690 + * STA.
1691 */
1692
1693 - /*
1694 - * Program default values for pattern backoff, aifs/slot/KAL count,
1695 - * beacon miss timeout, KAL timeout, etc.
1696 - */
1697 - set = AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF);
1698 - REG_SET_BIT(ah, AR_WOW_PATTERN, set);
1699 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1700 + ath_dbg(common, WOW, "None of the STA vifs are associated\n");
1701 + ret = 1;
1702 + goto fail_wow;
1703 + }
1704 +
1705 + if (sc->nvifs > 1) {
1706 + ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
1707 + ret = 1;
1708 + goto fail_wow;
1709 + }
1710
1711 - set = AR_WOW_AIFS_CNT(AR_WOW_CNT_AIFS_CNT) |
1712 - AR_WOW_SLOT_CNT(AR_WOW_CNT_SLOT_CNT) |
1713 - AR_WOW_KEEP_ALIVE_CNT(AR_WOW_CNT_KA_CNT);
1714 - REG_SET_BIT(ah, AR_WOW_COUNT, set);
1715 -
1716 - if (pattern_enable & AH_WOW_BEACON_MISS)
1717 - set = AR_WOW_BEACON_TIMO;
1718 - /* We are not using beacon miss, program a large value */
1719 - else
1720 - set = AR_WOW_BEACON_TIMO_MAX;
1721 + ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
1722
1723 - REG_WRITE(ah, AR_WOW_BCN_TIMO, set);
1724 + ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
1725 + wow_triggers_enabled);
1726
1727 - /*
1728 - * Keep alive timo in ms except AR9280
1729 - */
1730 - if (!pattern_enable)
1731 - set = AR_WOW_KEEP_ALIVE_NEVER;
1732 - else
1733 - set = KAL_TIMEOUT * 32;
1734 + ath9k_ps_wakeup(sc);
1735
1736 - REG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, set);
1737 + ath9k_stop_btcoex(sc);
1738
1739 /*
1740 - * Keep alive delay in us. based on 'power on clock',
1741 - * therefore in usec
1742 + * Enable wake up on recieving disassoc/deauth
1743 + * frame by default.
1744 */
1745 - set = KAL_DELAY * 1000;
1746 - REG_WRITE(ah, AR_WOW_KEEP_ALIVE_DELAY, set);
1747 + ath9k_wow_add_disassoc_deauth_pattern(sc);
1748
1749 - /*
1750 - * Create keep alive pattern to respond to beacons
1751 - */
1752 - ath9k_wow_create_keep_alive_pattern(ah);
1753 + if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
1754 + ath9k_wow_add_pattern(sc, wowlan);
1755
1756 + spin_lock_bh(&sc->sc_pcu_lock);
1757 /*
1758 - * Configure MAC WoW Registers
1759 + * To avoid false wake, we enable beacon miss interrupt only
1760 + * when we go to sleep. We save the current interrupt mask
1761 + * so we can restore it after the system wakes up
1762 */
1763 - set = 0;
1764 - /* Send keep alive timeouts anyway */
1765 - clr = AR_WOW_KEEP_ALIVE_AUTO_DIS;
1766 -
1767 - if (pattern_enable & AH_WOW_LINK_CHANGE)
1768 - wow_event_mask |= AR_WOW_KEEP_ALIVE_FAIL;
1769 - else
1770 - set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
1771 + sc->wow_intr_before_sleep = ah->imask;
1772 + ah->imask &= ~ATH9K_INT_GLOBAL;
1773 + ath9k_hw_disable_interrupts(ah);
1774 + ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
1775 + ath9k_hw_set_interrupts(ah);
1776 + ath9k_hw_enable_interrupts(ah);
1777
1778 - set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
1779 - REG_RMW(ah, AR_WOW_KEEP_ALIVE, set, clr);
1780 + spin_unlock_bh(&sc->sc_pcu_lock);
1781
1782 /*
1783 - * we are relying on a bmiss failure. ensure we have
1784 - * enough threshold to prevent false positives
1785 + * we can now sync irq and kill any running tasklets, since we already
1786 + * disabled interrupts and not holding a spin lock
1787 */
1788 - REG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR,
1789 - AR_WOW_BMISSTHRESHOLD);
1790 + synchronize_irq(sc->irq);
1791 + tasklet_kill(&sc->intr_tq);
1792 +
1793 + ath9k_hw_wow_enable(ah, wow_triggers_enabled);
1794
1795 - set = 0;
1796 - clr = 0;
1797 + ath9k_ps_restore(sc);
1798 + ath_dbg(common, ANY, "WoW enabled in ath9k\n");
1799 + atomic_inc(&sc->wow_sleep_proc_intr);
1800
1801 - if (pattern_enable & AH_WOW_BEACON_MISS) {
1802 - set = AR_WOW_BEACON_FAIL_EN;
1803 - wow_event_mask |= AR_WOW_BEACON_FAIL;
1804 - } else {
1805 - clr = AR_WOW_BEACON_FAIL_EN;
1806 +fail_wow:
1807 + mutex_unlock(&sc->mutex);
1808 + return ret;
1809 +}
1810 +
1811 +int ath9k_resume(struct ieee80211_hw *hw)
1812 +{
1813 + struct ath_softc *sc = hw->priv;
1814 + struct ath_hw *ah = sc->sc_ah;
1815 + struct ath_common *common = ath9k_hw_common(ah);
1816 + u32 wow_status;
1817 +
1818 + mutex_lock(&sc->mutex);
1819 +
1820 + ath9k_ps_wakeup(sc);
1821 +
1822 + spin_lock_bh(&sc->sc_pcu_lock);
1823 +
1824 + ath9k_hw_disable_interrupts(ah);
1825 + ah->imask = sc->wow_intr_before_sleep;
1826 + ath9k_hw_set_interrupts(ah);
1827 + ath9k_hw_enable_interrupts(ah);
1828 +
1829 + spin_unlock_bh(&sc->sc_pcu_lock);
1830 +
1831 + wow_status = ath9k_hw_wow_wakeup(ah);
1832 +
1833 + if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
1834 + /*
1835 + * some devices may not pick beacon miss
1836 + * as the reason they woke up so we add
1837 + * that here for that shortcoming.
1838 + */
1839 + wow_status |= AH_WOW_BEACON_MISS;
1840 + atomic_dec(&sc->wow_got_bmiss_intr);
1841 + ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
1842 }
1843
1844 - REG_RMW(ah, AR_WOW_BCN_EN, set, clr);
1845 + atomic_dec(&sc->wow_sleep_proc_intr);
1846
1847 - set = 0;
1848 - clr = 0;
1849 - /*
1850 - * Enable the magic packet registers
1851 - */
1852 - if (pattern_enable & AH_WOW_MAGIC_PATTERN_EN) {
1853 - set = AR_WOW_MAGIC_EN;
1854 - wow_event_mask |= AR_WOW_MAGIC_PAT_FOUND;
1855 - } else {
1856 - clr = AR_WOW_MAGIC_EN;
1857 + if (wow_status) {
1858 + ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
1859 + ath9k_hw_wow_event_to_string(wow_status), wow_status);
1860 }
1861 - set |= AR_WOW_MAC_INTR_EN;
1862 - REG_RMW(ah, AR_WOW_PATTERN, set, clr);
1863
1864 - REG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B,
1865 - AR_WOW_PATTERN_SUPPORTED);
1866 + ath_restart_work(sc);
1867 + ath9k_start_btcoex(sc);
1868
1869 - /*
1870 - * Set the power states appropriately and enable PME
1871 - */
1872 - clr = 0;
1873 - set = AR_PMCTRL_PWR_STATE_D1D3 | AR_PMCTRL_HOST_PME_EN |
1874 - AR_PMCTRL_PWR_PM_CTRL_ENA;
1875 + ath9k_ps_restore(sc);
1876 + mutex_unlock(&sc->mutex);
1877
1878 - clr = AR_PCIE_PM_CTRL_ENA;
1879 - REG_RMW(ah, AR_PCIE_PM_CTRL, set, clr);
1880 + return 0;
1881 +}
1882
1883 - /*
1884 - * this is needed to prevent the chip waking up
1885 - * the host within 3-4 seconds with certain
1886 - * platform/BIOS. The fix is to enable
1887 - * D1 & D3 to match original definition and
1888 - * also match the OTP value. Anyway this
1889 - * is more related to SW WOW.
1890 - */
1891 - clr = AR_PMCTRL_PWR_STATE_D1D3;
1892 - REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
1893 +void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1894 +{
1895 + struct ath_softc *sc = hw->priv;
1896
1897 - set = AR_PMCTRL_PWR_STATE_D1D3_REAL;
1898 - REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
1899 + mutex_lock(&sc->mutex);
1900 + device_init_wakeup(sc->dev, 1);
1901 + device_set_wakeup_enable(sc->dev, enabled);
1902 + mutex_unlock(&sc->mutex);
1903 +}
1904
1905 - REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
1906 +void ath9k_init_wow(struct ieee80211_hw *hw)
1907 +{
1908 + struct ath_softc *sc = hw->priv;
1909
1910 - /* to bring down WOW power low margin */
1911 - set = BIT(13);
1912 - REG_SET_BIT(ah, AR_PCIE_PHY_REG3, set);
1913 - /* HW WoW */
1914 - clr = BIT(5);
1915 - REG_CLR_BIT(ah, AR_PCU_MISC_MODE3, clr);
1916 + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) &&
1917 + (sc->driver_data & ATH9K_PCI_WOW) &&
1918 + device_can_wakeup(sc->dev))
1919 + hw->wiphy->wowlan = &ath9k_wowlan_support;
1920
1921 - ath9k_hw_set_powermode_wow_sleep(ah);
1922 - ah->wow_event_mask = wow_event_mask;
1923 + atomic_set(&sc->wow_sleep_proc_intr, -1);
1924 + atomic_set(&sc->wow_got_bmiss_intr, -1);
1925 }
1926 -EXPORT_SYMBOL(ath9k_hw_wow_enable);
1927 --- a/drivers/net/wireless/ath/ath9k/xmit.c
1928 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
1929 @@ -1786,6 +1786,9 @@ bool ath_drain_all_txq(struct ath_softc
1930 if (!ATH_TXQ_SETUP(sc, i))
1931 continue;
1932
1933 + if (!sc->tx.txq[i].axq_depth)
1934 + continue;
1935 +
1936 if (ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum))
1937 npend |= BIT(i);
1938 }
1939 @@ -2749,6 +2752,8 @@ void ath_tx_node_cleanup(struct ath_soft
1940 }
1941 }
1942
1943 +#ifdef CONFIG_ATH9K_TX99
1944 +
1945 int ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb,
1946 struct ath_tx_control *txctl)
1947 {
1948 @@ -2791,3 +2796,5 @@ int ath9k_tx99_send(struct ath_softc *sc
1949
1950 return 0;
1951 }
1952 +
1953 +#endif /* CONFIG_ATH9K_TX99 */
1954 --- a/drivers/net/wireless/ath/regd.c
1955 +++ b/drivers/net/wireless/ath/regd.c
1956 @@ -37,17 +37,17 @@ static int __ath_regd_init(struct ath_re
1957
1958 /* We enable active scan on these a case by case basis by regulatory domain */
1959 #define ATH9K_2GHZ_CH12_13 REG_RULE(2467-10, 2472+10, 40, 0, 20,\
1960 - NL80211_RRF_PASSIVE_SCAN)
1961 + NL80211_RRF_NO_IR)
1962 #define ATH9K_2GHZ_CH14 REG_RULE(2484-10, 2484+10, 40, 0, 20,\
1963 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
1964 + NL80211_RRF_NO_IR | NL80211_RRF_NO_OFDM)
1965
1966 /* We allow IBSS on these on a case by case basis by regulatory domain */
1967 #define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 80, 0, 30,\
1968 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
1969 + NL80211_RRF_NO_IR)
1970 #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 80, 0, 30,\
1971 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
1972 + NL80211_RRF_NO_IR)
1973 #define ATH9K_5GHZ_5725_5850 REG_RULE(5725-10, 5850+10, 80, 0, 30,\
1974 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
1975 + NL80211_RRF_NO_IR)
1976
1977 #define ATH9K_2GHZ_ALL ATH9K_2GHZ_CH01_11, \
1978 ATH9K_2GHZ_CH12_13, \
1979 @@ -224,17 +224,16 @@ ath_reg_apply_beaconing_flags(struct wip
1980 * regulatory_hint().
1981 */
1982 if (!(reg_rule->flags &
1983 - NL80211_RRF_NO_IBSS))
1984 + NL80211_RRF_NO_IR))
1985 ch->flags &=
1986 - ~IEEE80211_CHAN_NO_IBSS;
1987 + ~IEEE80211_CHAN_NO_IR;
1988 if (!(reg_rule->flags &
1989 - NL80211_RRF_PASSIVE_SCAN))
1990 + NL80211_RRF_NO_IR))
1991 ch->flags &=
1992 - ~IEEE80211_CHAN_PASSIVE_SCAN;
1993 + ~IEEE80211_CHAN_NO_IR;
1994 } else {
1995 if (ch->beacon_found)
1996 - ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
1997 - IEEE80211_CHAN_PASSIVE_SCAN);
1998 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
1999 }
2000 }
2001 }
2002 @@ -260,11 +259,11 @@ ath_reg_apply_active_scan_flags(struct w
2003 */
2004 if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2005 ch = &sband->channels[11]; /* CH 12 */
2006 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2007 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2008 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2009 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2010 ch = &sband->channels[12]; /* CH 13 */
2011 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2012 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2013 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2014 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2015 return;
2016 }
2017
2018 @@ -278,17 +277,17 @@ ath_reg_apply_active_scan_flags(struct w
2019 ch = &sband->channels[11]; /* CH 12 */
2020 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2021 if (!IS_ERR(reg_rule)) {
2022 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2023 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2024 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2025 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2026 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2027 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2028 }
2029
2030 ch = &sband->channels[12]; /* CH 13 */
2031 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2032 if (!IS_ERR(reg_rule)) {
2033 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2034 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2035 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2036 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2037 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2038 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2039 }
2040 }
2041
2042 @@ -320,8 +319,8 @@ static void ath_reg_apply_radar_flags(st
2043 */
2044 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2045 ch->flags |= IEEE80211_CHAN_RADAR |
2046 - IEEE80211_CHAN_NO_IBSS |
2047 - IEEE80211_CHAN_PASSIVE_SCAN;
2048 + IEEE80211_CHAN_NO_IR |
2049 + IEEE80211_CHAN_NO_IR;
2050 }
2051 }
2052
2053 --- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
2054 +++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
2055 @@ -812,7 +812,7 @@ static s32 brcmf_p2p_run_escan(struct br
2056 struct ieee80211_channel *chan = request->channels[i];
2057
2058 if (chan->flags & (IEEE80211_CHAN_RADAR |
2059 - IEEE80211_CHAN_PASSIVE_SCAN))
2060 + IEEE80211_CHAN_NO_IR))
2061 continue;
2062
2063 chanspecs[i] = channel_to_chanspec(&p2p->cfg->d11inf,
2064 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2065 +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2066 @@ -202,9 +202,9 @@ static struct ieee80211_supported_band _
2067
2068 /* This is to override regulatory domains defined in cfg80211 module (reg.c)
2069 * By default world regulatory domain defined in reg.c puts the flags
2070 - * NL80211_RRF_PASSIVE_SCAN and NL80211_RRF_NO_IBSS for 5GHz channels (for
2071 - * 36..48 and 149..165). With respect to these flags, wpa_supplicant doesn't
2072 - * start p2p operations on 5GHz channels. All the changes in world regulatory
2073 + * NL80211_RRF_NO_IR for 5GHz channels (for * 36..48 and 149..165).
2074 + * With respect to these flags, wpa_supplicant doesn't * start p2p
2075 + * operations on 5GHz channels. All the changes in world regulatory
2076 * domain are to be done here.
2077 */
2078 static const struct ieee80211_regdomain brcmf_regdom = {
2079 @@ -5197,10 +5197,10 @@ static s32 brcmf_construct_reginfo(struc
2080 if (channel & WL_CHAN_RADAR)
2081 band_chan_arr[index].flags |=
2082 (IEEE80211_CHAN_RADAR |
2083 - IEEE80211_CHAN_NO_IBSS);
2084 + IEEE80211_CHAN_NO_IR);
2085 if (channel & WL_CHAN_PASSIVE)
2086 band_chan_arr[index].flags |=
2087 - IEEE80211_CHAN_PASSIVE_SCAN;
2088 + IEEE80211_CHAN_NO_IR;
2089 }
2090 }
2091 if (!update)
2092 --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
2093 +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
2094 @@ -59,23 +59,20 @@
2095
2096 #define BRCM_2GHZ_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 19, 0)
2097 #define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, \
2098 - NL80211_RRF_PASSIVE_SCAN | \
2099 - NL80211_RRF_NO_IBSS)
2100 + NL80211_RRF_NO_IR)
2101
2102 #define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, \
2103 - NL80211_RRF_PASSIVE_SCAN | \
2104 - NL80211_RRF_NO_IBSS)
2105 + NL80211_RRF_NO_IR)
2106 #define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, \
2107 - NL80211_RRF_PASSIVE_SCAN | \
2108 + NL80211_RRF_NO_IR | \
2109 NL80211_RRF_DFS | \
2110 - NL80211_RRF_NO_IBSS)
2111 + NL80211_RRF_NO_IR)
2112 #define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, \
2113 - NL80211_RRF_PASSIVE_SCAN | \
2114 + NL80211_RRF_NO_IR | \
2115 NL80211_RRF_DFS | \
2116 - NL80211_RRF_NO_IBSS)
2117 + NL80211_RRF_NO_IR)
2118 #define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, \
2119 - NL80211_RRF_PASSIVE_SCAN | \
2120 - NL80211_RRF_NO_IBSS)
2121 + NL80211_RRF_NO_IR)
2122
2123 static const struct ieee80211_regdomain brcms_regdom_x2 = {
2124 .n_reg_rules = 6,
2125 @@ -395,7 +392,7 @@ brcms_c_channel_set_chanspec(struct brcm
2126 brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false);
2127
2128 brcms_b_set_chanspec(wlc->hw, chanspec,
2129 - !!(ch->flags & IEEE80211_CHAN_PASSIVE_SCAN),
2130 + !!(ch->flags & IEEE80211_CHAN_NO_IR),
2131 &txpwr);
2132 }
2133
2134 @@ -657,8 +654,8 @@ static void brcms_reg_apply_radar_flags(
2135 */
2136 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2137 ch->flags |= IEEE80211_CHAN_RADAR |
2138 - IEEE80211_CHAN_NO_IBSS |
2139 - IEEE80211_CHAN_PASSIVE_SCAN;
2140 + IEEE80211_CHAN_NO_IR |
2141 + IEEE80211_CHAN_NO_IR;
2142 }
2143 }
2144
2145 @@ -688,14 +685,13 @@ brcms_reg_apply_beaconing_flags(struct w
2146 if (IS_ERR(rule))
2147 continue;
2148
2149 - if (!(rule->flags & NL80211_RRF_NO_IBSS))
2150 - ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
2151 - if (!(rule->flags & NL80211_RRF_PASSIVE_SCAN))
2152 + if (!(rule->flags & NL80211_RRF_NO_IR))
2153 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2154 + if (!(rule->flags & NL80211_RRF_NO_IR))
2155 ch->flags &=
2156 - ~IEEE80211_CHAN_PASSIVE_SCAN;
2157 + ~IEEE80211_CHAN_NO_IR;
2158 } else if (ch->beacon_found) {
2159 - ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
2160 - IEEE80211_CHAN_PASSIVE_SCAN);
2161 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2162 }
2163 }
2164 }
2165 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
2166 +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
2167 @@ -125,13 +125,13 @@ static struct ieee80211_channel brcms_2g
2168 CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS),
2169 CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS),
2170 CHAN2GHZ(12, 2467,
2171 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
2172 + IEEE80211_CHAN_NO_IR |
2173 IEEE80211_CHAN_NO_HT40PLUS),
2174 CHAN2GHZ(13, 2472,
2175 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
2176 + IEEE80211_CHAN_NO_IR |
2177 IEEE80211_CHAN_NO_HT40PLUS),
2178 CHAN2GHZ(14, 2484,
2179 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
2180 + IEEE80211_CHAN_NO_IR |
2181 IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS |
2182 IEEE80211_CHAN_NO_OFDM)
2183 };
2184 @@ -144,51 +144,51 @@ static struct ieee80211_channel brcms_5g
2185 CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS),
2186 /* UNII-2 */
2187 CHAN5GHZ(52,
2188 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2189 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2190 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2191 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2192 CHAN5GHZ(56,
2193 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2194 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2195 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2196 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2197 CHAN5GHZ(60,
2198 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2199 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2200 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2201 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2202 CHAN5GHZ(64,
2203 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2204 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2205 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2206 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2207 /* MID */
2208 CHAN5GHZ(100,
2209 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2210 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2211 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2212 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2213 CHAN5GHZ(104,
2214 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2215 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2216 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2217 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2218 CHAN5GHZ(108,
2219 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2220 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2221 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2222 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2223 CHAN5GHZ(112,
2224 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2225 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2226 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2227 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2228 CHAN5GHZ(116,
2229 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2230 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2231 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2232 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2233 CHAN5GHZ(120,
2234 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2235 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2236 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2237 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2238 CHAN5GHZ(124,
2239 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2240 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2241 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2242 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2243 CHAN5GHZ(128,
2244 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2245 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2246 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2247 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2248 CHAN5GHZ(132,
2249 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2250 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2251 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2252 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2253 CHAN5GHZ(136,
2254 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2255 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2256 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2257 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2258 CHAN5GHZ(140,
2259 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2260 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS |
2261 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2262 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS |
2263 IEEE80211_CHAN_NO_HT40MINUS),
2264 /* UNII-3 */
2265 CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS),
2266 --- a/drivers/net/wireless/cw1200/scan.c
2267 +++ b/drivers/net/wireless/cw1200/scan.c
2268 @@ -197,9 +197,9 @@ void cw1200_scan_work(struct work_struct
2269 if ((*it)->band != first->band)
2270 break;
2271 if (((*it)->flags ^ first->flags) &
2272 - IEEE80211_CHAN_PASSIVE_SCAN)
2273 + IEEE80211_CHAN_NO_IR)
2274 break;
2275 - if (!(first->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
2276 + if (!(first->flags & IEEE80211_CHAN_NO_IR) &&
2277 (*it)->max_power != first->max_power)
2278 break;
2279 }
2280 @@ -210,7 +210,7 @@ void cw1200_scan_work(struct work_struct
2281 else
2282 scan.max_tx_rate = WSM_TRANSMIT_RATE_1;
2283 scan.num_probes =
2284 - (first->flags & IEEE80211_CHAN_PASSIVE_SCAN) ? 0 : 2;
2285 + (first->flags & IEEE80211_CHAN_NO_IR) ? 0 : 2;
2286 scan.num_ssids = priv->scan.n_ssids;
2287 scan.ssids = &priv->scan.ssids[0];
2288 scan.num_channels = it - priv->scan.curr;
2289 @@ -233,7 +233,7 @@ void cw1200_scan_work(struct work_struct
2290 }
2291 for (i = 0; i < scan.num_channels; ++i) {
2292 scan.ch[i].number = priv->scan.curr[i]->hw_value;
2293 - if (priv->scan.curr[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN) {
2294 + if (priv->scan.curr[i]->flags & IEEE80211_CHAN_NO_IR) {
2295 scan.ch[i].min_chan_time = 50;
2296 scan.ch[i].max_chan_time = 100;
2297 } else {
2298 @@ -241,7 +241,7 @@ void cw1200_scan_work(struct work_struct
2299 scan.ch[i].max_chan_time = 25;
2300 }
2301 }
2302 - if (!(first->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
2303 + if (!(first->flags & IEEE80211_CHAN_NO_IR) &&
2304 priv->scan.output_power != first->max_power) {
2305 priv->scan.output_power = first->max_power;
2306 wsm_set_output_power(priv,
2307 --- a/drivers/net/wireless/ipw2x00/ipw2100.c
2308 +++ b/drivers/net/wireless/ipw2x00/ipw2100.c
2309 @@ -1934,10 +1934,10 @@ static int ipw2100_wdev_init(struct net_
2310 bg_band->channels[i].max_power = geo->bg[i].max_power;
2311 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
2312 bg_band->channels[i].flags |=
2313 - IEEE80211_CHAN_PASSIVE_SCAN;
2314 + IEEE80211_CHAN_NO_IR;
2315 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
2316 bg_band->channels[i].flags |=
2317 - IEEE80211_CHAN_NO_IBSS;
2318 + IEEE80211_CHAN_NO_IR;
2319 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
2320 bg_band->channels[i].flags |=
2321 IEEE80211_CHAN_RADAR;
2322 --- a/drivers/net/wireless/ipw2x00/ipw2200.c
2323 +++ b/drivers/net/wireless/ipw2x00/ipw2200.c
2324 @@ -11472,10 +11472,10 @@ static int ipw_wdev_init(struct net_devi
2325 bg_band->channels[i].max_power = geo->bg[i].max_power;
2326 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
2327 bg_band->channels[i].flags |=
2328 - IEEE80211_CHAN_PASSIVE_SCAN;
2329 + IEEE80211_CHAN_NO_IR;
2330 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
2331 bg_band->channels[i].flags |=
2332 - IEEE80211_CHAN_NO_IBSS;
2333 + IEEE80211_CHAN_NO_IR;
2334 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
2335 bg_band->channels[i].flags |=
2336 IEEE80211_CHAN_RADAR;
2337 @@ -11511,10 +11511,10 @@ static int ipw_wdev_init(struct net_devi
2338 a_band->channels[i].max_power = geo->a[i].max_power;
2339 if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY)
2340 a_band->channels[i].flags |=
2341 - IEEE80211_CHAN_PASSIVE_SCAN;
2342 + IEEE80211_CHAN_NO_IR;
2343 if (geo->a[i].flags & LIBIPW_CH_NO_IBSS)
2344 a_band->channels[i].flags |=
2345 - IEEE80211_CHAN_NO_IBSS;
2346 + IEEE80211_CHAN_NO_IR;
2347 if (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT)
2348 a_band->channels[i].flags |=
2349 IEEE80211_CHAN_RADAR;
2350 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
2351 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
2352 @@ -1595,7 +1595,7 @@ il3945_get_channels_for_scan(struct il_p
2353 * and use long active_dwell time.
2354 */
2355 if (!is_active || il_is_channel_passive(ch_info) ||
2356 - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
2357 + (chan->flags & IEEE80211_CHAN_NO_IR)) {
2358 scan_ch->type = 0; /* passive */
2359 if (IL_UCODE_API(il->ucode_ver) == 1)
2360 scan_ch->active_dwell =
2361 --- a/drivers/net/wireless/iwlegacy/4965-mac.c
2362 +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
2363 @@ -805,7 +805,7 @@ il4965_get_channels_for_scan(struct il_p
2364 }
2365
2366 if (!is_active || il_is_channel_passive(ch_info) ||
2367 - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
2368 + (chan->flags & IEEE80211_CHAN_NO_IR))
2369 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
2370 else
2371 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
2372 --- a/drivers/net/wireless/iwlegacy/common.c
2373 +++ b/drivers/net/wireless/iwlegacy/common.c
2374 @@ -3447,10 +3447,10 @@ il_init_geos(struct il_priv *il)
2375
2376 if (il_is_channel_valid(ch)) {
2377 if (!(ch->flags & EEPROM_CHANNEL_IBSS))
2378 - geo_ch->flags |= IEEE80211_CHAN_NO_IBSS;
2379 + geo_ch->flags |= IEEE80211_CHAN_NO_IR;
2380
2381 if (!(ch->flags & EEPROM_CHANNEL_ACTIVE))
2382 - geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2383 + geo_ch->flags |= IEEE80211_CHAN_NO_IR;
2384
2385 if (ch->flags & EEPROM_CHANNEL_RADAR)
2386 geo_ch->flags |= IEEE80211_CHAN_RADAR;
2387 --- a/drivers/net/wireless/iwlegacy/debug.c
2388 +++ b/drivers/net/wireless/iwlegacy/debug.c
2389 @@ -567,12 +567,12 @@ il_dbgfs_channels_read(struct file *file
2390 flags & IEEE80211_CHAN_RADAR ?
2391 " (IEEE 802.11h required)" : "",
2392 ((channels[i].
2393 - flags & IEEE80211_CHAN_NO_IBSS) ||
2394 + flags & IEEE80211_CHAN_NO_IR) ||
2395 (channels[i].
2396 flags & IEEE80211_CHAN_RADAR)) ? "" :
2397 ", IBSS",
2398 channels[i].
2399 - flags & IEEE80211_CHAN_PASSIVE_SCAN ?
2400 + flags & IEEE80211_CHAN_NO_IR ?
2401 "passive only" : "active/passive");
2402 }
2403 supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ);
2404 @@ -594,12 +594,12 @@ il_dbgfs_channels_read(struct file *file
2405 flags & IEEE80211_CHAN_RADAR ?
2406 " (IEEE 802.11h required)" : "",
2407 ((channels[i].
2408 - flags & IEEE80211_CHAN_NO_IBSS) ||
2409 + flags & IEEE80211_CHAN_NO_IR) ||
2410 (channels[i].
2411 flags & IEEE80211_CHAN_RADAR)) ? "" :
2412 ", IBSS",
2413 channels[i].
2414 - flags & IEEE80211_CHAN_PASSIVE_SCAN ?
2415 + flags & IEEE80211_CHAN_NO_IR ?
2416 "passive only" : "active/passive");
2417 }
2418 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2419 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
2420 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
2421 @@ -352,12 +352,12 @@ static ssize_t iwl_dbgfs_channels_read(s
2422 channels[i].max_power,
2423 channels[i].flags & IEEE80211_CHAN_RADAR ?
2424 " (IEEE 802.11h required)" : "",
2425 - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
2426 + ((channels[i].flags & IEEE80211_CHAN_NO_IR)
2427 || (channels[i].flags &
2428 IEEE80211_CHAN_RADAR)) ? "" :
2429 ", IBSS",
2430 channels[i].flags &
2431 - IEEE80211_CHAN_PASSIVE_SCAN ?
2432 + IEEE80211_CHAN_NO_IR ?
2433 "passive only" : "active/passive");
2434 }
2435 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
2436 @@ -375,12 +375,12 @@ static ssize_t iwl_dbgfs_channels_read(s
2437 channels[i].max_power,
2438 channels[i].flags & IEEE80211_CHAN_RADAR ?
2439 " (IEEE 802.11h required)" : "",
2440 - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
2441 + ((channels[i].flags & IEEE80211_CHAN_NO_IR)
2442 || (channels[i].flags &
2443 IEEE80211_CHAN_RADAR)) ? "" :
2444 ", IBSS",
2445 channels[i].flags &
2446 - IEEE80211_CHAN_PASSIVE_SCAN ?
2447 + IEEE80211_CHAN_NO_IR ?
2448 "passive only" : "active/passive");
2449 }
2450 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2451 --- a/drivers/net/wireless/iwlwifi/dvm/scan.c
2452 +++ b/drivers/net/wireless/iwlwifi/dvm/scan.c
2453 @@ -544,7 +544,7 @@ static int iwl_get_channels_for_scan(str
2454 channel = chan->hw_value;
2455 scan_ch->channel = cpu_to_le16(channel);
2456
2457 - if (!is_active || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
2458 + if (!is_active || (chan->flags & IEEE80211_CHAN_NO_IR))
2459 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
2460 else
2461 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
2462 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
2463 +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
2464 @@ -614,10 +614,10 @@ static int iwl_init_channel_map(struct d
2465 channel->flags = IEEE80211_CHAN_NO_HT40;
2466
2467 if (!(eeprom_ch->flags & EEPROM_CHANNEL_IBSS))
2468 - channel->flags |= IEEE80211_CHAN_NO_IBSS;
2469 + channel->flags |= IEEE80211_CHAN_NO_IR;
2470
2471 if (!(eeprom_ch->flags & EEPROM_CHANNEL_ACTIVE))
2472 - channel->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2473 + channel->flags |= IEEE80211_CHAN_NO_IR;
2474
2475 if (eeprom_ch->flags & EEPROM_CHANNEL_RADAR)
2476 channel->flags |= IEEE80211_CHAN_RADAR;
2477 --- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
2478 +++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
2479 @@ -223,10 +223,10 @@ static int iwl_init_channel_map(struct d
2480 channel->flags |= IEEE80211_CHAN_NO_160MHZ;
2481
2482 if (!(ch_flags & NVM_CHANNEL_IBSS))
2483 - channel->flags |= IEEE80211_CHAN_NO_IBSS;
2484 + channel->flags |= IEEE80211_CHAN_NO_IR;
2485
2486 if (!(ch_flags & NVM_CHANNEL_ACTIVE))
2487 - channel->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2488 + channel->flags |= IEEE80211_CHAN_NO_IR;
2489
2490 if (ch_flags & NVM_CHANNEL_RADAR)
2491 channel->flags |= IEEE80211_CHAN_RADAR;
2492 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
2493 +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
2494 @@ -192,7 +192,7 @@ static void iwl_mvm_scan_fill_channels(s
2495 for (i = 0; i < cmd->channel_count; i++) {
2496 chan->channel = cpu_to_le16(req->channels[i]->hw_value);
2497 chan->type = cpu_to_le32(type);
2498 - if (req->channels[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2499 + if (req->channels[i]->flags & IEEE80211_CHAN_NO_IR)
2500 chan->type &= cpu_to_le32(~SCAN_CHANNEL_TYPE_ACTIVE);
2501 chan->active_dwell = cpu_to_le16(active_dwell);
2502 chan->passive_dwell = cpu_to_le16(passive_dwell);
2503 @@ -642,7 +642,7 @@ static void iwl_build_channel_cfg(struct
2504 channels->iter_count[index] = cpu_to_le16(1);
2505 channels->iter_interval[index] = 0;
2506
2507 - if (!(s_band->channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
2508 + if (!(s_band->channels[i].flags & IEEE80211_CHAN_NO_IR))
2509 channels->type[index] |=
2510 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE);
2511
2512 --- a/drivers/net/wireless/mac80211_hwsim.c
2513 +++ b/drivers/net/wireless/mac80211_hwsim.c
2514 @@ -159,7 +159,7 @@ static const struct ieee80211_regdomain
2515 .reg_rules = {
2516 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
2517 REG_RULE(5725-10, 5850+10, 40, 0, 30,
2518 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2519 + NL80211_RRF_NO_IR),
2520 }
2521 };
2522
2523 @@ -1485,7 +1485,7 @@ static void hw_scan_work(struct work_str
2524 req->channels[hwsim->scan_chan_idx]->center_freq);
2525
2526 hwsim->tmp_chan = req->channels[hwsim->scan_chan_idx];
2527 - if (hwsim->tmp_chan->flags & IEEE80211_CHAN_PASSIVE_SCAN ||
2528 + if (hwsim->tmp_chan->flags & IEEE80211_CHAN_NO_IR ||
2529 !req->n_ssids) {
2530 dwell = 120;
2531 } else {
2532 --- a/drivers/net/wireless/mwifiex/cfg80211.c
2533 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
2534 @@ -50,24 +50,24 @@ static const struct ieee80211_regdomain
2535 REG_RULE(2412-10, 2462+10, 40, 3, 20, 0),
2536 /* Channel 12 - 13 */
2537 REG_RULE(2467-10, 2472+10, 20, 3, 20,
2538 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2539 + NL80211_RRF_NO_IR),
2540 /* Channel 14 */
2541 REG_RULE(2484-10, 2484+10, 20, 3, 20,
2542 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
2543 + NL80211_RRF_NO_IR |
2544 NL80211_RRF_NO_OFDM),
2545 /* Channel 36 - 48 */
2546 REG_RULE(5180-10, 5240+10, 40, 3, 20,
2547 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2548 + NL80211_RRF_NO_IR),
2549 /* Channel 149 - 165 */
2550 REG_RULE(5745-10, 5825+10, 40, 3, 20,
2551 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2552 + NL80211_RRF_NO_IR),
2553 /* Channel 52 - 64 */
2554 REG_RULE(5260-10, 5320+10, 40, 3, 30,
2555 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
2556 + NL80211_RRF_NO_IR |
2557 NL80211_RRF_DFS),
2558 /* Channel 100 - 140 */
2559 REG_RULE(5500-10, 5700+10, 40, 3, 30,
2560 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
2561 + NL80211_RRF_NO_IR |
2562 NL80211_RRF_DFS),
2563 }
2564 };
2565 @@ -1968,7 +1968,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiph
2566 user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
2567 user_scan_cfg->chan_list[i].radio_type = chan->band;
2568
2569 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2570 + if (chan->flags & IEEE80211_CHAN_NO_IR)
2571 user_scan_cfg->chan_list[i].scan_type =
2572 MWIFIEX_SCAN_TYPE_PASSIVE;
2573 else
2574 --- a/drivers/net/wireless/mwifiex/scan.c
2575 +++ b/drivers/net/wireless/mwifiex/scan.c
2576 @@ -515,14 +515,14 @@ mwifiex_scan_create_channel_list(struct
2577 scan_chan_list[chan_idx].max_scan_time =
2578 cpu_to_le16((u16) user_scan_in->
2579 chan_list[0].scan_time);
2580 - else if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2581 + else if (ch->flags & IEEE80211_CHAN_NO_IR)
2582 scan_chan_list[chan_idx].max_scan_time =
2583 cpu_to_le16(adapter->passive_scan_time);
2584 else
2585 scan_chan_list[chan_idx].max_scan_time =
2586 cpu_to_le16(adapter->active_scan_time);
2587
2588 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2589 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2590 scan_chan_list[chan_idx].chan_scan_mode_bitmap
2591 |= MWIFIEX_PASSIVE_SCAN;
2592 else
2593 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h
2594 +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
2595 @@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_
2596 * @local: frame is not from mac80211
2597 */
2598 int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
2599 - bool local);
2600 + struct ieee80211_sta *sta, bool local);
2601
2602 /**
2603 * rt2x00queue_update_beacon - Send new beacon from mac80211
2604 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
2605 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
2606 @@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct r
2607 frag_skb->data, data_length, tx_info,
2608 (struct ieee80211_rts *)(skb->data));
2609
2610 - retval = rt2x00queue_write_tx_frame(queue, skb, true);
2611 + retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
2612 if (retval) {
2613 dev_kfree_skb_any(skb);
2614 rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
2615 @@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *h
2616 goto exit_fail;
2617 }
2618
2619 - if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
2620 + if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
2621 goto exit_fail;
2622
2623 /*
2624 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
2625 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
2626 @@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct
2627 }
2628
2629 int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
2630 - bool local)
2631 + struct ieee80211_sta *sta, bool local)
2632 {
2633 struct ieee80211_tx_info *tx_info;
2634 struct queue_entry *entry;
2635 @@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct da
2636 * after that we are free to use the skb->cb array
2637 * for our information.
2638 */
2639 - rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
2640 + rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
2641
2642 /*
2643 * All information is retrieved from the skb->cb array,
2644 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c
2645 +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c
2646 @@ -416,7 +416,7 @@ static int rtl8187_init_urbs(struct ieee
2647 struct rtl8187_rx_info *info;
2648 int ret = 0;
2649
2650 - while (skb_queue_len(&priv->rx_queue) < 16) {
2651 + while (skb_queue_len(&priv->rx_queue) < 32) {
2652 skb = __dev_alloc_skb(RTL8187_MAX_RX, GFP_KERNEL);
2653 if (!skb) {
2654 ret = -ENOMEM;
2655 --- a/drivers/net/wireless/rtlwifi/base.c
2656 +++ b/drivers/net/wireless/rtlwifi/base.c
2657 @@ -1078,8 +1078,8 @@ u8 rtl_is_special_data(struct ieee80211_
2658
2659 ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len +
2660 SNAP_SIZE + PROTOC_TYPE_SIZE);
2661 - ether_type = *(u16 *) ((u8 *) skb->data + mac_hdr_len + SNAP_SIZE);
2662 - /* ether_type = ntohs(ether_type); */
2663 + ether_type = be16_to_cpu(*(__be16 *)((u8 *)skb->data + mac_hdr_len +
2664 + SNAP_SIZE));
2665
2666 if (ETH_P_IP == ether_type) {
2667 if (IPPROTO_UDP == ip->protocol) {
2668 --- a/drivers/net/wireless/rtlwifi/regd.c
2669 +++ b/drivers/net/wireless/rtlwifi/regd.c
2670 @@ -59,30 +59,27 @@ static struct country_code_to_enum_rd al
2671 */
2672 #define RTL819x_2GHZ_CH12_13 \
2673 REG_RULE(2467-10, 2472+10, 40, 0, 20,\
2674 - NL80211_RRF_PASSIVE_SCAN)
2675 + NL80211_RRF_NO_IR)
2676
2677 #define RTL819x_2GHZ_CH14 \
2678 REG_RULE(2484-10, 2484+10, 40, 0, 20, \
2679 - NL80211_RRF_PASSIVE_SCAN | \
2680 + NL80211_RRF_NO_IR | \
2681 NL80211_RRF_NO_OFDM)
2682
2683 /* 5G chan 36 - chan 64*/
2684 #define RTL819x_5GHZ_5150_5350 \
2685 REG_RULE(5150-10, 5350+10, 40, 0, 30, \
2686 - NL80211_RRF_PASSIVE_SCAN | \
2687 - NL80211_RRF_NO_IBSS)
2688 + NL80211_RRF_NO_IR)
2689
2690 /* 5G chan 100 - chan 165*/
2691 #define RTL819x_5GHZ_5470_5850 \
2692 REG_RULE(5470-10, 5850+10, 40, 0, 30, \
2693 - NL80211_RRF_PASSIVE_SCAN | \
2694 - NL80211_RRF_NO_IBSS)
2695 + NL80211_RRF_NO_IR)
2696
2697 /* 5G chan 149 - chan 165*/
2698 #define RTL819x_5GHZ_5725_5850 \
2699 REG_RULE(5725-10, 5850+10, 40, 0, 30, \
2700 - NL80211_RRF_PASSIVE_SCAN | \
2701 - NL80211_RRF_NO_IBSS)
2702 + NL80211_RRF_NO_IR)
2703
2704 #define RTL819x_5GHZ_ALL \
2705 (RTL819x_5GHZ_5150_5350, RTL819x_5GHZ_5470_5850)
2706 @@ -185,16 +182,15 @@ static void _rtl_reg_apply_beaconing_fla
2707 *regulatory_hint().
2708 */
2709
2710 - if (!(reg_rule->flags & NL80211_RRF_NO_IBSS))
2711 - ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
2712 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2713 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2714 if (!(reg_rule->
2715 - flags & NL80211_RRF_PASSIVE_SCAN))
2716 + flags & NL80211_RRF_NO_IR))
2717 ch->flags &=
2718 - ~IEEE80211_CHAN_PASSIVE_SCAN;
2719 + ~IEEE80211_CHAN_NO_IR;
2720 } else {
2721 if (ch->beacon_found)
2722 - ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
2723 - IEEE80211_CHAN_PASSIVE_SCAN);
2724 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2725 }
2726 }
2727 }
2728 @@ -219,11 +215,11 @@ static void _rtl_reg_apply_active_scan_f
2729 */
2730 if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2731 ch = &sband->channels[11]; /* CH 12 */
2732 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2733 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2734 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2735 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2736 ch = &sband->channels[12]; /* CH 13 */
2737 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2738 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2739 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2740 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2741 return;
2742 }
2743
2744 @@ -237,17 +233,17 @@ static void _rtl_reg_apply_active_scan_f
2745 ch = &sband->channels[11]; /* CH 12 */
2746 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2747 if (!IS_ERR(reg_rule)) {
2748 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2749 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2750 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2751 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2752 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2753 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2754 }
2755
2756 ch = &sband->channels[12]; /* CH 13 */
2757 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2758 if (!IS_ERR(reg_rule)) {
2759 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2760 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2761 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2762 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2763 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2764 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2765 }
2766 }
2767
2768 @@ -284,8 +280,8 @@ static void _rtl_reg_apply_radar_flags(s
2769 */
2770 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2771 ch->flags |= IEEE80211_CHAN_RADAR |
2772 - IEEE80211_CHAN_NO_IBSS |
2773 - IEEE80211_CHAN_PASSIVE_SCAN;
2774 + IEEE80211_CHAN_NO_IR |
2775 + IEEE80211_CHAN_NO_IR;
2776 }
2777 }
2778
2779 --- a/drivers/net/wireless/ti/wl12xx/scan.c
2780 +++ b/drivers/net/wireless/ti/wl12xx/scan.c
2781 @@ -47,7 +47,7 @@ static int wl1271_get_scan_channels(stru
2782 * In active scans, we only scan channels not
2783 * marked as passive.
2784 */
2785 - (passive || !(flags & IEEE80211_CHAN_PASSIVE_SCAN))) {
2786 + (passive || !(flags & IEEE80211_CHAN_NO_IR))) {
2787 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
2788 req->channels[i]->band,
2789 req->channels[i]->center_freq);
2790 --- a/drivers/net/wireless/ti/wlcore/cmd.c
2791 +++ b/drivers/net/wireless/ti/wlcore/cmd.c
2792 @@ -1688,7 +1688,7 @@ int wlcore_cmd_regdomain_config_locked(s
2793
2794 if (channel->flags & (IEEE80211_CHAN_DISABLED |
2795 IEEE80211_CHAN_RADAR |
2796 - IEEE80211_CHAN_PASSIVE_SCAN))
2797 + IEEE80211_CHAN_NO_IR))
2798 continue;
2799
2800 ch_bit_idx = wlcore_get_reg_conf_ch_idx(b, ch);
2801 --- a/drivers/net/wireless/ti/wlcore/main.c
2802 +++ b/drivers/net/wireless/ti/wlcore/main.c
2803 @@ -91,8 +91,7 @@ static void wl1271_reg_notify(struct wip
2804 continue;
2805
2806 if (ch->flags & IEEE80211_CHAN_RADAR)
2807 - ch->flags |= IEEE80211_CHAN_NO_IBSS |
2808 - IEEE80211_CHAN_PASSIVE_SCAN;
2809 + ch->flags |= IEEE80211_CHAN_NO_IR;
2810
2811 }
2812
2813 --- a/drivers/net/wireless/ti/wlcore/scan.c
2814 +++ b/drivers/net/wireless/ti/wlcore/scan.c
2815 @@ -189,14 +189,14 @@ wlcore_scan_get_channels(struct wl1271 *
2816 flags = req_channels[i]->flags;
2817
2818 if (force_passive)
2819 - flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2820 + flags |= IEEE80211_CHAN_NO_IR;
2821
2822 if ((req_channels[i]->band == band) &&
2823 !(flags & IEEE80211_CHAN_DISABLED) &&
2824 (!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
2825 /* if radar is set, we ignore the passive flag */
2826 (radar ||
2827 - !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
2828 + !!(flags & IEEE80211_CHAN_NO_IR) == passive)) {
2829
2830
2831 if (flags & IEEE80211_CHAN_RADAR) {
2832 @@ -221,7 +221,7 @@ wlcore_scan_get_channels(struct wl1271 *
2833 (band == IEEE80211_BAND_2GHZ) &&
2834 (channels[j].channel >= 12) &&
2835 (channels[j].channel <= 14) &&
2836 - (flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
2837 + (flags & IEEE80211_CHAN_NO_IR) &&
2838 !force_passive) {
2839 /* pactive channels treated as DFS */
2840 channels[j].flags = SCAN_CHANNEL_FLAGS_DFS;
2841 @@ -244,7 +244,7 @@ wlcore_scan_get_channels(struct wl1271 *
2842 max_dwell_time_active,
2843 flags & IEEE80211_CHAN_RADAR ?
2844 ", DFS" : "",
2845 - flags & IEEE80211_CHAN_PASSIVE_SCAN ?
2846 + flags & IEEE80211_CHAN_NO_IR ?
2847 ", PASSIVE" : "");
2848 j++;
2849 }
2850 --- a/include/net/cfg80211.h
2851 +++ b/include/net/cfg80211.h
2852 @@ -91,9 +91,8 @@ enum ieee80211_band {
2853 * Channel flags set by the regulatory control code.
2854 *
2855 * @IEEE80211_CHAN_DISABLED: This channel is disabled.
2856 - * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
2857 - * on this channel.
2858 - * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
2859 + * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
2860 + * sending probe requests or beaconing.
2861 * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
2862 * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
2863 * is not permitted.
2864 @@ -113,8 +112,8 @@ enum ieee80211_band {
2865 */
2866 enum ieee80211_channel_flags {
2867 IEEE80211_CHAN_DISABLED = 1<<0,
2868 - IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
2869 - IEEE80211_CHAN_NO_IBSS = 1<<2,
2870 + IEEE80211_CHAN_NO_IR = 1<<1,
2871 + /* hole at 1<<2 */
2872 IEEE80211_CHAN_RADAR = 1<<3,
2873 IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
2874 IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
2875 @@ -4149,6 +4148,7 @@ void cfg80211_radar_event(struct wiphy *
2876 /**
2877 * cfg80211_cac_event - Channel availability check (CAC) event
2878 * @netdev: network device
2879 + * @chandef: chandef for the current channel
2880 * @event: type of event
2881 * @gfp: context flags
2882 *
2883 @@ -4157,6 +4157,7 @@ void cfg80211_radar_event(struct wiphy *
2884 * also by full-MAC drivers.
2885 */
2886 void cfg80211_cac_event(struct net_device *netdev,
2887 + const struct cfg80211_chan_def *chandef,
2888 enum nl80211_radar_event event, gfp_t gfp);
2889
2890
2891 --- a/include/uapi/linux/nl80211.h
2892 +++ b/include/uapi/linux/nl80211.h
2893 @@ -1508,6 +1508,9 @@ enum nl80211_commands {
2894 * to react to radar events, e.g. initiate a channel switch or leave the
2895 * IBSS network.
2896 *
2897 + * @NL80211_ATTR_SUPPORT_5_10_MHZ: A flag indicating that the device supports
2898 + * 5 MHz and 10 MHz channel bandwidth.
2899 + *
2900 * @NL80211_ATTR_MAX: highest attribute number currently defined
2901 * @__NL80211_ATTR_AFTER_LAST: internal use
2902 */
2903 @@ -1824,6 +1827,8 @@ enum nl80211_attrs {
2904
2905 NL80211_ATTR_HANDLE_DFS,
2906
2907 + NL80211_ATTR_SUPPORT_5_10_MHZ,
2908 +
2909 /* add attributes here, update the policy in nl80211.c */
2910
2911 __NL80211_ATTR_AFTER_LAST,
2912 @@ -2224,10 +2229,9 @@ enum nl80211_band_attr {
2913 * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
2914 * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
2915 * regulatory domain.
2916 - * @NL80211_FREQUENCY_ATTR_PASSIVE_SCAN: Only passive scanning is
2917 - * permitted on this channel in current regulatory domain.
2918 - * @NL80211_FREQUENCY_ATTR_NO_IBSS: IBSS networks are not permitted
2919 - * on this channel in current regulatory domain.
2920 + * @NL80211_FREQUENCY_ATTR_NO_IR: no mechanisms that initiate radiation
2921 + * are permitted on this channel, this includes sending probe
2922 + * requests, or modes of operation that require beaconing.
2923 * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
2924 * on this channel in current regulatory domain.
2925 * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
2926 @@ -2254,8 +2258,8 @@ enum nl80211_frequency_attr {
2927 __NL80211_FREQUENCY_ATTR_INVALID,
2928 NL80211_FREQUENCY_ATTR_FREQ,
2929 NL80211_FREQUENCY_ATTR_DISABLED,
2930 - NL80211_FREQUENCY_ATTR_PASSIVE_SCAN,
2931 - NL80211_FREQUENCY_ATTR_NO_IBSS,
2932 + NL80211_FREQUENCY_ATTR_NO_IR,
2933 + __NL80211_FREQUENCY_ATTR_NO_IBSS,
2934 NL80211_FREQUENCY_ATTR_RADAR,
2935 NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
2936 NL80211_FREQUENCY_ATTR_DFS_STATE,
2937 @@ -2271,6 +2275,9 @@ enum nl80211_frequency_attr {
2938 };
2939
2940 #define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
2941 +#define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR
2942 +#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
2943 +#define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
2944
2945 /**
2946 * enum nl80211_bitrate_attr - bitrate attributes
2947 @@ -2413,8 +2420,9 @@ enum nl80211_sched_scan_match_attr {
2948 * @NL80211_RRF_DFS: DFS support is required to be used
2949 * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
2950 * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
2951 - * @NL80211_RRF_PASSIVE_SCAN: passive scan is required
2952 - * @NL80211_RRF_NO_IBSS: no IBSS is allowed
2953 + * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed,
2954 + * this includes probe requests or modes of operation that require
2955 + * beaconing.
2956 */
2957 enum nl80211_reg_rule_flags {
2958 NL80211_RRF_NO_OFDM = 1<<0,
2959 @@ -2424,10 +2432,17 @@ enum nl80211_reg_rule_flags {
2960 NL80211_RRF_DFS = 1<<4,
2961 NL80211_RRF_PTP_ONLY = 1<<5,
2962 NL80211_RRF_PTMP_ONLY = 1<<6,
2963 - NL80211_RRF_PASSIVE_SCAN = 1<<7,
2964 - NL80211_RRF_NO_IBSS = 1<<8,
2965 + NL80211_RRF_NO_IR = 1<<7,
2966 + __NL80211_RRF_NO_IBSS = 1<<8,
2967 };
2968
2969 +#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
2970 +#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
2971 +#define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
2972 +
2973 +/* For backport compatibility with older userspace */
2974 +#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
2975 +
2976 /**
2977 * enum nl80211_dfs_regions - regulatory DFS regions
2978 *
2979 --- a/net/mac80211/cfg.c
2980 +++ b/net/mac80211/cfg.c
2981 @@ -1050,6 +1050,7 @@ static int ieee80211_stop_ap(struct wiph
2982 struct ieee80211_local *local = sdata->local;
2983 struct beacon_data *old_beacon;
2984 struct probe_resp *old_probe_resp;
2985 + struct cfg80211_chan_def chandef;
2986
2987 old_beacon = rtnl_dereference(sdata->u.ap.beacon);
2988 if (!old_beacon)
2989 @@ -1091,8 +1092,10 @@ static int ieee80211_stop_ap(struct wiph
2990 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
2991
2992 if (sdata->wdev.cac_started) {
2993 + chandef = sdata->vif.bss_conf.chandef;
2994 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
2995 - cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
2996 + cfg80211_cac_event(sdata->dev, &chandef,
2997 + NL80211_RADAR_CAC_ABORTED,
2998 GFP_KERNEL);
2999 }
3000
3001 --- a/net/mac80211/iface.c
3002 +++ b/net/mac80211/iface.c
3003 @@ -749,6 +749,7 @@ static void ieee80211_do_stop(struct iee
3004 u32 hw_reconf_flags = 0;
3005 int i, flushed;
3006 struct ps_data *ps;
3007 + struct cfg80211_chan_def chandef;
3008
3009 clear_bit(SDATA_STATE_RUNNING, &sdata->state);
3010
3011 @@ -828,11 +829,13 @@ static void ieee80211_do_stop(struct iee
3012 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
3013
3014 if (sdata->wdev.cac_started) {
3015 + chandef = sdata->vif.bss_conf.chandef;
3016 WARN_ON(local->suspended);
3017 mutex_lock(&local->iflist_mtx);
3018 ieee80211_vif_release_channel(sdata);
3019 mutex_unlock(&local->iflist_mtx);
3020 - cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
3021 + cfg80211_cac_event(sdata->dev, &chandef,
3022 + NL80211_RADAR_CAC_ABORTED,
3023 GFP_KERNEL);
3024 }
3025
3026 @@ -1340,7 +1343,6 @@ static void ieee80211_setup_sdata(struct
3027 sdata->vif.bss_conf.bssid = NULL;
3028 break;
3029 case NL80211_IFTYPE_AP_VLAN:
3030 - break;
3031 case NL80211_IFTYPE_P2P_DEVICE:
3032 sdata->vif.bss_conf.bssid = sdata->vif.addr;
3033 break;
3034 --- a/net/mac80211/mlme.c
3035 +++ b/net/mac80211/mlme.c
3036 @@ -1398,10 +1398,12 @@ void ieee80211_dfs_cac_timer_work(struct
3037 struct ieee80211_sub_if_data *sdata =
3038 container_of(delayed_work, struct ieee80211_sub_if_data,
3039 dfs_cac_timer_work);
3040 + struct cfg80211_chan_def chandef = sdata->vif.bss_conf.chandef;
3041
3042 ieee80211_vif_release_channel(sdata);
3043 -
3044 - cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_FINISHED, GFP_KERNEL);
3045 + cfg80211_cac_event(sdata->dev, &chandef,
3046 + NL80211_RADAR_CAC_FINISHED,
3047 + GFP_KERNEL);
3048 }
3049
3050 /* MLME */
3051 --- a/net/mac80211/rx.c
3052 +++ b/net/mac80211/rx.c
3053 @@ -729,9 +729,7 @@ static void ieee80211_release_reorder_fr
3054 lockdep_assert_held(&tid_agg_rx->reorder_lock);
3055
3056 while (ieee80211_sn_less(tid_agg_rx->head_seq_num, head_seq_num)) {
3057 - index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3058 - tid_agg_rx->ssn) %
3059 - tid_agg_rx->buf_size;
3060 + index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3061 ieee80211_release_reorder_frame(sdata, tid_agg_rx, index,
3062 frames);
3063 }
3064 @@ -757,8 +755,7 @@ static void ieee80211_sta_reorder_releas
3065 lockdep_assert_held(&tid_agg_rx->reorder_lock);
3066
3067 /* release the buffer until next missing frame */
3068 - index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3069 - tid_agg_rx->ssn) % tid_agg_rx->buf_size;
3070 + index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3071 if (!tid_agg_rx->reorder_buf[index] &&
3072 tid_agg_rx->stored_mpdu_num) {
3073 /*
3074 @@ -793,15 +790,11 @@ static void ieee80211_sta_reorder_releas
3075 } else while (tid_agg_rx->reorder_buf[index]) {
3076 ieee80211_release_reorder_frame(sdata, tid_agg_rx, index,
3077 frames);
3078 - index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3079 - tid_agg_rx->ssn) %
3080 - tid_agg_rx->buf_size;
3081 + index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3082 }
3083
3084 if (tid_agg_rx->stored_mpdu_num) {
3085 - j = index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3086 - tid_agg_rx->ssn) %
3087 - tid_agg_rx->buf_size;
3088 + j = index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3089
3090 for (; j != (index - 1) % tid_agg_rx->buf_size;
3091 j = (j + 1) % tid_agg_rx->buf_size) {
3092 @@ -861,8 +854,7 @@ static bool ieee80211_sta_manage_reorder
3093
3094 /* Now the new frame is always in the range of the reordering buffer */
3095
3096 - index = ieee80211_sn_sub(mpdu_seq_num,
3097 - tid_agg_rx->ssn) % tid_agg_rx->buf_size;
3098 + index = mpdu_seq_num % tid_agg_rx->buf_size;
3099
3100 /* check if we already stored this frame */
3101 if (tid_agg_rx->reorder_buf[index]) {
3102 --- a/net/mac80211/scan.c
3103 +++ b/net/mac80211/scan.c
3104 @@ -526,7 +526,7 @@ static int __ieee80211_start_scan(struct
3105 ieee80211_hw_config(local, 0);
3106
3107 if ((req->channels[0]->flags &
3108 - IEEE80211_CHAN_PASSIVE_SCAN) ||
3109 + IEEE80211_CHAN_NO_IR) ||
3110 !local->scan_req->n_ssids) {
3111 next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
3112 } else {
3113 @@ -572,7 +572,7 @@ ieee80211_scan_get_channel_time(struct i
3114 * TODO: channel switching also consumes quite some time,
3115 * add that delay as well to get a better estimation
3116 */
3117 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
3118 + if (chan->flags & IEEE80211_CHAN_NO_IR)
3119 return IEEE80211_PASSIVE_CHANNEL_TIME;
3120 return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
3121 }
3122 @@ -696,7 +696,7 @@ static void ieee80211_scan_state_set_cha
3123 *
3124 * In any case, it is not necessary for a passive scan.
3125 */
3126 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN ||
3127 + if (chan->flags & IEEE80211_CHAN_NO_IR ||
3128 !local->scan_req->n_ssids) {
3129 *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
3130 local->next_scan_state = SCAN_DECISION;
3131 @@ -881,7 +881,7 @@ int ieee80211_request_ibss_scan(struct i
3132 struct ieee80211_channel *tmp_ch =
3133 &local->hw.wiphy->bands[band]->channels[i];
3134
3135 - if (tmp_ch->flags & (IEEE80211_CHAN_NO_IBSS |
3136 + if (tmp_ch->flags & (IEEE80211_CHAN_NO_IR |
3137 IEEE80211_CHAN_DISABLED))
3138 continue;
3139
3140 @@ -895,7 +895,7 @@ int ieee80211_request_ibss_scan(struct i
3141
3142 local->int_scan_req->n_channels = n_ch;
3143 } else {
3144 - if (WARN_ON_ONCE(chan->flags & (IEEE80211_CHAN_NO_IBSS |
3145 + if (WARN_ON_ONCE(chan->flags & (IEEE80211_CHAN_NO_IR |
3146 IEEE80211_CHAN_DISABLED)))
3147 goto unlock;
3148
3149 --- a/net/mac80211/tx.c
3150 +++ b/net/mac80211/tx.c
3151 @@ -1728,8 +1728,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
3152 * radar detection by itself. We can do that later by adding a
3153 * monitor flag interfaces used for AP support.
3154 */
3155 - if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
3156 - IEEE80211_CHAN_PASSIVE_SCAN)))
3157 + if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)))
3158 goto fail_rcu;
3159
3160 ieee80211_xmit(sdata, skb, chan->band);
3161 --- a/net/mac80211/util.c
3162 +++ b/net/mac80211/util.c
3163 @@ -2259,14 +2259,17 @@ u64 ieee80211_calculate_rx_timestamp(str
3164 void ieee80211_dfs_cac_cancel(struct ieee80211_local *local)
3165 {
3166 struct ieee80211_sub_if_data *sdata;
3167 + struct cfg80211_chan_def chandef;
3168
3169 mutex_lock(&local->iflist_mtx);
3170 list_for_each_entry(sdata, &local->interfaces, list) {
3171 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
3172
3173 if (sdata->wdev.cac_started) {
3174 + chandef = sdata->vif.bss_conf.chandef;
3175 ieee80211_vif_release_channel(sdata);
3176 cfg80211_cac_event(sdata->dev,
3177 + &chandef,
3178 NL80211_RADAR_CAC_ABORTED,
3179 GFP_KERNEL);
3180 }
3181 --- a/net/wireless/chan.c
3182 +++ b/net/wireless/chan.c
3183 @@ -277,6 +277,32 @@ void cfg80211_set_dfs_state(struct wiphy
3184 width, dfs_state);
3185 }
3186
3187 +static u32 cfg80211_get_start_freq(u32 center_freq,
3188 + u32 bandwidth)
3189 +{
3190 + u32 start_freq;
3191 +
3192 + if (bandwidth <= 20)
3193 + start_freq = center_freq;
3194 + else
3195 + start_freq = center_freq - bandwidth/2 + 10;
3196 +
3197 + return start_freq;
3198 +}
3199 +
3200 +static u32 cfg80211_get_end_freq(u32 center_freq,
3201 + u32 bandwidth)
3202 +{
3203 + u32 end_freq;
3204 +
3205 + if (bandwidth <= 20)
3206 + end_freq = center_freq;
3207 + else
3208 + end_freq = center_freq + bandwidth/2 - 10;
3209 +
3210 + return end_freq;
3211 +}
3212 +
3213 static int cfg80211_get_chans_dfs_required(struct wiphy *wiphy,
3214 u32 center_freq,
3215 u32 bandwidth)
3216 @@ -284,13 +310,8 @@ static int cfg80211_get_chans_dfs_requir
3217 struct ieee80211_channel *c;
3218 u32 freq, start_freq, end_freq;
3219
3220 - if (bandwidth <= 20) {
3221 - start_freq = center_freq;
3222 - end_freq = center_freq;
3223 - } else {
3224 - start_freq = center_freq - bandwidth/2 + 10;
3225 - end_freq = center_freq + bandwidth/2 - 10;
3226 - }
3227 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3228 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3229
3230 for (freq = start_freq; freq <= end_freq; freq += 20) {
3231 c = ieee80211_get_channel(wiphy, freq);
3232 @@ -330,33 +351,159 @@ int cfg80211_chandef_dfs_required(struct
3233 }
3234 EXPORT_SYMBOL(cfg80211_chandef_dfs_required);
3235
3236 -static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
3237 - u32 center_freq, u32 bandwidth,
3238 - u32 prohibited_flags)
3239 +static int cfg80211_get_chans_dfs_usable(struct wiphy *wiphy,
3240 + u32 center_freq,
3241 + u32 bandwidth)
3242 {
3243 struct ieee80211_channel *c;
3244 u32 freq, start_freq, end_freq;
3245 + int count = 0;
3246
3247 - if (bandwidth <= 20) {
3248 - start_freq = center_freq;
3249 - end_freq = center_freq;
3250 - } else {
3251 - start_freq = center_freq - bandwidth/2 + 10;
3252 - end_freq = center_freq + bandwidth/2 - 10;
3253 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3254 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3255 +
3256 + /*
3257 + * Check entire range of channels for the bandwidth.
3258 + * Check all channels are DFS channels (DFS_USABLE or
3259 + * DFS_AVAILABLE). Return number of usable channels
3260 + * (require CAC). Allow DFS and non-DFS channel mix.
3261 + */
3262 + for (freq = start_freq; freq <= end_freq; freq += 20) {
3263 + c = ieee80211_get_channel(wiphy, freq);
3264 + if (!c)
3265 + return -EINVAL;
3266 +
3267 + if (c->flags & IEEE80211_CHAN_DISABLED)
3268 + return -EINVAL;
3269 +
3270 + if (c->flags & IEEE80211_CHAN_RADAR) {
3271 + if (c->dfs_state == NL80211_DFS_UNAVAILABLE)
3272 + return -EINVAL;
3273 +
3274 + if (c->dfs_state == NL80211_DFS_USABLE)
3275 + count++;
3276 + }
3277 + }
3278 +
3279 + return count;
3280 +}
3281 +
3282 +bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
3283 + const struct cfg80211_chan_def *chandef)
3284 +{
3285 + int width;
3286 + int r1, r2 = 0;
3287 +
3288 + if (WARN_ON(!cfg80211_chandef_valid(chandef)))
3289 + return false;
3290 +
3291 + width = cfg80211_chandef_get_width(chandef);
3292 + if (width < 0)
3293 + return false;
3294 +
3295 + r1 = cfg80211_get_chans_dfs_usable(wiphy, chandef->center_freq1,
3296 + width);
3297 +
3298 + if (r1 < 0)
3299 + return false;
3300 +
3301 + switch (chandef->width) {
3302 + case NL80211_CHAN_WIDTH_80P80:
3303 + WARN_ON(!chandef->center_freq2);
3304 + r2 = cfg80211_get_chans_dfs_usable(wiphy,
3305 + chandef->center_freq2,
3306 + width);
3307 + if (r2 < 0)
3308 + return false;
3309 + break;
3310 + default:
3311 + WARN_ON(chandef->center_freq2);
3312 + break;
3313 }
3314
3315 + return (r1 + r2 > 0);
3316 +}
3317 +
3318 +
3319 +static bool cfg80211_get_chans_dfs_available(struct wiphy *wiphy,
3320 + u32 center_freq,
3321 + u32 bandwidth)
3322 +{
3323 + struct ieee80211_channel *c;
3324 + u32 freq, start_freq, end_freq;
3325 +
3326 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3327 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3328 +
3329 + /*
3330 + * Check entire range of channels for the bandwidth.
3331 + * If any channel in between is disabled or has not
3332 + * had gone through CAC return false
3333 + */
3334 for (freq = start_freq; freq <= end_freq; freq += 20) {
3335 c = ieee80211_get_channel(wiphy, freq);
3336 if (!c)
3337 return false;
3338
3339 - /* check for radar flags */
3340 - if ((prohibited_flags & c->flags & IEEE80211_CHAN_RADAR) &&
3341 + if (c->flags & IEEE80211_CHAN_DISABLED)
3342 + return false;
3343 +
3344 + if ((c->flags & IEEE80211_CHAN_RADAR) &&
3345 (c->dfs_state != NL80211_DFS_AVAILABLE))
3346 return false;
3347 + }
3348 +
3349 + return true;
3350 +}
3351 +
3352 +static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy,
3353 + const struct cfg80211_chan_def *chandef)
3354 +{
3355 + int width;
3356 + int r;
3357 +
3358 + if (WARN_ON(!cfg80211_chandef_valid(chandef)))
3359 + return false;
3360
3361 - /* check for the other flags */
3362 - if (c->flags & prohibited_flags & ~IEEE80211_CHAN_RADAR)
3363 + width = cfg80211_chandef_get_width(chandef);
3364 + if (width < 0)
3365 + return false;
3366 +
3367 + r = cfg80211_get_chans_dfs_available(wiphy, chandef->center_freq1,
3368 + width);
3369 +
3370 + /* If any of channels unavailable for cf1 just return */
3371 + if (!r)
3372 + return r;
3373 +
3374 + switch (chandef->width) {
3375 + case NL80211_CHAN_WIDTH_80P80:
3376 + WARN_ON(!chandef->center_freq2);
3377 + r = cfg80211_get_chans_dfs_available(wiphy,
3378 + chandef->center_freq2,
3379 + width);
3380 + default:
3381 + WARN_ON(chandef->center_freq2);
3382 + break;
3383 + }
3384 +
3385 + return r;
3386 +}
3387 +
3388 +
3389 +static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
3390 + u32 center_freq, u32 bandwidth,
3391 + u32 prohibited_flags)
3392 +{
3393 + struct ieee80211_channel *c;
3394 + u32 freq, start_freq, end_freq;
3395 +
3396 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3397 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3398 +
3399 + for (freq = start_freq; freq <= end_freq; freq += 20) {
3400 + c = ieee80211_get_channel(wiphy, freq);
3401 + if (!c || c->flags & prohibited_flags)
3402 return false;
3403 }
3404
3405 @@ -462,14 +609,19 @@ bool cfg80211_reg_can_beacon(struct wiph
3406 struct cfg80211_chan_def *chandef)
3407 {
3408 bool res;
3409 + u32 prohibited_flags = IEEE80211_CHAN_DISABLED |
3410 + IEEE80211_CHAN_NO_IR |
3411 + IEEE80211_CHAN_RADAR;
3412
3413 trace_cfg80211_reg_can_beacon(wiphy, chandef);
3414
3415 - res = cfg80211_chandef_usable(wiphy, chandef,
3416 - IEEE80211_CHAN_DISABLED |
3417 - IEEE80211_CHAN_PASSIVE_SCAN |
3418 - IEEE80211_CHAN_NO_IBSS |
3419 - IEEE80211_CHAN_RADAR);
3420 + if (cfg80211_chandef_dfs_required(wiphy, chandef) > 0 &&
3421 + cfg80211_chandef_dfs_available(wiphy, chandef)) {
3422 + /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */
3423 + prohibited_flags = IEEE80211_CHAN_DISABLED;
3424 + }
3425 +
3426 + res = cfg80211_chandef_usable(wiphy, chandef, prohibited_flags);
3427
3428 trace_cfg80211_return_bool(res);
3429 return res;
3430 --- a/net/wireless/core.h
3431 +++ b/net/wireless/core.h
3432 @@ -382,6 +382,19 @@ int cfg80211_can_use_iftype_chan(struct
3433 enum cfg80211_chan_mode chanmode,
3434 u8 radar_detect);
3435
3436 +/**
3437 + * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable
3438 + * @wiphy: the wiphy to validate against
3439 + * @chandef: the channel definition to check
3440 + *
3441 + * Checks if chandef is usable and we can/need start CAC on such channel.
3442 + *
3443 + * Return: Return true if all channels available and at least
3444 + * one channel require CAC (NL80211_DFS_USABLE)
3445 + */
3446 +bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
3447 + const struct cfg80211_chan_def *chandef);
3448 +
3449 void cfg80211_set_dfs_state(struct wiphy *wiphy,
3450 const struct cfg80211_chan_def *chandef,
3451 enum nl80211_dfs_state dfs_state);
3452 --- a/net/wireless/genregdb.awk
3453 +++ b/net/wireless/genregdb.awk
3454 @@ -107,10 +107,13 @@ active && /^[ \t]*\(/ {
3455 } else if (flagarray[arg] == "PTMP-ONLY") {
3456 flags = flags "\n\t\t\tNL80211_RRF_PTMP_ONLY | "
3457 } else if (flagarray[arg] == "PASSIVE-SCAN") {
3458 - flags = flags "\n\t\t\tNL80211_RRF_PASSIVE_SCAN | "
3459 + flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
3460 } else if (flagarray[arg] == "NO-IBSS") {
3461 - flags = flags "\n\t\t\tNL80211_RRF_NO_IBSS | "
3462 + flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
3463 + } else if (flagarray[arg] == "NO-IR") {
3464 + flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
3465 }
3466 +
3467 }
3468 flags = flags "0"
3469 printf "\t\tREG_RULE(%d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, flags
3470 --- a/net/wireless/ibss.c
3471 +++ b/net/wireless/ibss.c
3472 @@ -274,7 +274,7 @@ int cfg80211_ibss_wext_join(struct cfg80
3473
3474 for (i = 0; i < sband->n_channels; i++) {
3475 chan = &sband->channels[i];
3476 - if (chan->flags & IEEE80211_CHAN_NO_IBSS)
3477 + if (chan->flags & IEEE80211_CHAN_NO_IR)
3478 continue;
3479 if (chan->flags & IEEE80211_CHAN_DISABLED)
3480 continue;
3481 @@ -345,7 +345,7 @@ int cfg80211_ibss_wext_siwfreq(struct ne
3482 chan = ieee80211_get_channel(wdev->wiphy, freq);
3483 if (!chan)
3484 return -EINVAL;
3485 - if (chan->flags & IEEE80211_CHAN_NO_IBSS ||
3486 + if (chan->flags & IEEE80211_CHAN_NO_IR ||
3487 chan->flags & IEEE80211_CHAN_DISABLED)
3488 return -EINVAL;
3489 }
3490 --- a/net/wireless/mesh.c
3491 +++ b/net/wireless/mesh.c
3492 @@ -141,8 +141,7 @@ int __cfg80211_join_mesh(struct cfg80211
3493
3494 for (i = 0; i < sband->n_channels; i++) {
3495 chan = &sband->channels[i];
3496 - if (chan->flags & (IEEE80211_CHAN_NO_IBSS |
3497 - IEEE80211_CHAN_PASSIVE_SCAN |
3498 + if (chan->flags & (IEEE80211_CHAN_NO_IR |
3499 IEEE80211_CHAN_DISABLED |
3500 IEEE80211_CHAN_RADAR))
3501 continue;
3502 --- a/net/wireless/mlme.c
3503 +++ b/net/wireless/mlme.c
3504 @@ -763,12 +763,12 @@ void cfg80211_radar_event(struct wiphy *
3505 EXPORT_SYMBOL(cfg80211_radar_event);
3506
3507 void cfg80211_cac_event(struct net_device *netdev,
3508 + const struct cfg80211_chan_def *chandef,
3509 enum nl80211_radar_event event, gfp_t gfp)
3510 {
3511 struct wireless_dev *wdev = netdev->ieee80211_ptr;
3512 struct wiphy *wiphy = wdev->wiphy;
3513 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
3514 - struct cfg80211_chan_def chandef;
3515 unsigned long timeout;
3516
3517 trace_cfg80211_cac_event(netdev, event);
3518 @@ -779,14 +779,12 @@ void cfg80211_cac_event(struct net_devic
3519 if (WARN_ON(!wdev->channel))
3520 return;
3521
3522 - cfg80211_chandef_create(&chandef, wdev->channel, NL80211_CHAN_NO_HT);
3523 -
3524 switch (event) {
3525 case NL80211_RADAR_CAC_FINISHED:
3526 timeout = wdev->cac_start_time +
3527 msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
3528 WARN_ON(!time_after_eq(jiffies, timeout));
3529 - cfg80211_set_dfs_state(wiphy, &chandef, NL80211_DFS_AVAILABLE);
3530 + cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE);
3531 break;
3532 case NL80211_RADAR_CAC_ABORTED:
3533 break;
3534 @@ -796,6 +794,6 @@ void cfg80211_cac_event(struct net_devic
3535 }
3536 wdev->cac_started = false;
3537
3538 - nl80211_radar_notify(rdev, &chandef, event, netdev, gfp);
3539 + nl80211_radar_notify(rdev, chandef, event, netdev, gfp);
3540 }
3541 EXPORT_SYMBOL(cfg80211_cac_event);
3542 --- a/net/wireless/nl80211.c
3543 +++ b/net/wireless/nl80211.c
3544 @@ -545,12 +545,12 @@ static int nl80211_msg_put_channel(struc
3545 if ((chan->flags & IEEE80211_CHAN_DISABLED) &&
3546 nla_put_flag(msg, NL80211_FREQUENCY_ATTR_DISABLED))
3547 goto nla_put_failure;
3548 - if ((chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
3549 - nla_put_flag(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN))
3550 - goto nla_put_failure;
3551 - if ((chan->flags & IEEE80211_CHAN_NO_IBSS) &&
3552 - nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IBSS))
3553 - goto nla_put_failure;
3554 + if (chan->flags & IEEE80211_CHAN_NO_IR) {
3555 + if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_IR))
3556 + goto nla_put_failure;
3557 + if (nla_put_flag(msg, __NL80211_FREQUENCY_ATTR_NO_IBSS))
3558 + goto nla_put_failure;
3559 + }
3560 if (chan->flags & IEEE80211_CHAN_RADAR) {
3561 if (nla_put_flag(msg, NL80211_FREQUENCY_ATTR_RADAR))
3562 goto nla_put_failure;
3563 @@ -1229,7 +1229,7 @@ static int nl80211_send_wiphy(struct cfg
3564 nla_put_flag(msg, NL80211_ATTR_TDLS_EXTERNAL_SETUP))
3565 goto nla_put_failure;
3566 if ((dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_5_10_MHZ) &&
3567 - nla_put_flag(msg, WIPHY_FLAG_SUPPORTS_5_10_MHZ))
3568 + nla_put_flag(msg, NL80211_ATTR_SUPPORT_5_10_MHZ))
3569 goto nla_put_failure;
3570
3571 state->split_start++;
3572 @@ -2170,7 +2170,7 @@ static inline u64 wdev_id(struct wireles
3573 }
3574
3575 static int nl80211_send_chandef(struct sk_buff *msg,
3576 - struct cfg80211_chan_def *chandef)
3577 + const struct cfg80211_chan_def *chandef)
3578 {
3579 WARN_ON(!cfg80211_chandef_valid(chandef));
3580
3581 @@ -5653,7 +5653,7 @@ static int nl80211_start_radar_detection
3582 if (err == 0)
3583 return -EINVAL;
3584
3585 - if (chandef.chan->dfs_state != NL80211_DFS_USABLE)
3586 + if (!cfg80211_chandef_dfs_usable(wdev->wiphy, &chandef))
3587 return -EINVAL;
3588
3589 if (!rdev->ops->start_radar_detection)
3590 @@ -10882,7 +10882,7 @@ EXPORT_SYMBOL(cfg80211_cqm_txe_notify);
3591
3592 void
3593 nl80211_radar_notify(struct cfg80211_registered_device *rdev,
3594 - struct cfg80211_chan_def *chandef,
3595 + const struct cfg80211_chan_def *chandef,
3596 enum nl80211_radar_event event,
3597 struct net_device *netdev, gfp_t gfp)
3598 {
3599 --- a/net/wireless/nl80211.h
3600 +++ b/net/wireless/nl80211.h
3601 @@ -70,7 +70,7 @@ int nl80211_send_mgmt(struct cfg80211_re
3602
3603 void
3604 nl80211_radar_notify(struct cfg80211_registered_device *rdev,
3605 - struct cfg80211_chan_def *chandef,
3606 + const struct cfg80211_chan_def *chandef,
3607 enum nl80211_radar_event event,
3608 struct net_device *netdev, gfp_t gfp);
3609
3610 --- a/net/wireless/reg.c
3611 +++ b/net/wireless/reg.c
3612 @@ -163,35 +163,29 @@ static const struct ieee80211_regdomain
3613 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
3614 /* IEEE 802.11b/g, channels 12..13. */
3615 REG_RULE(2467-10, 2472+10, 40, 6, 20,
3616 - NL80211_RRF_PASSIVE_SCAN |
3617 - NL80211_RRF_NO_IBSS),
3618 + NL80211_RRF_NO_IR),
3619 /* IEEE 802.11 channel 14 - Only JP enables
3620 * this and for 802.11b only */
3621 REG_RULE(2484-10, 2484+10, 20, 6, 20,
3622 - NL80211_RRF_PASSIVE_SCAN |
3623 - NL80211_RRF_NO_IBSS |
3624 + NL80211_RRF_NO_IR |
3625 NL80211_RRF_NO_OFDM),
3626 /* IEEE 802.11a, channel 36..48 */
3627 REG_RULE(5180-10, 5240+10, 160, 6, 20,
3628 - NL80211_RRF_PASSIVE_SCAN |
3629 - NL80211_RRF_NO_IBSS),
3630 + NL80211_RRF_NO_IR),
3631
3632 /* IEEE 802.11a, channel 52..64 - DFS required */
3633 REG_RULE(5260-10, 5320+10, 160, 6, 20,
3634 - NL80211_RRF_PASSIVE_SCAN |
3635 - NL80211_RRF_NO_IBSS |
3636 + NL80211_RRF_NO_IR |
3637 NL80211_RRF_DFS),
3638
3639 /* IEEE 802.11a, channel 100..144 - DFS required */
3640 REG_RULE(5500-10, 5720+10, 160, 6, 20,
3641 - NL80211_RRF_PASSIVE_SCAN |
3642 - NL80211_RRF_NO_IBSS |
3643 + NL80211_RRF_NO_IR |
3644 NL80211_RRF_DFS),
3645
3646 /* IEEE 802.11a, channel 149..165 */
3647 REG_RULE(5745-10, 5825+10, 80, 6, 20,
3648 - NL80211_RRF_PASSIVE_SCAN |
3649 - NL80211_RRF_NO_IBSS),
3650 + NL80211_RRF_NO_IR),
3651
3652 /* IEEE 802.11ad (60gHz), channels 1..3 */
3653 REG_RULE(56160+2160*1-1080, 56160+2160*3+1080, 2160, 0, 0, 0),
3654 @@ -698,10 +692,8 @@ regdom_intersect(const struct ieee80211_
3655 static u32 map_regdom_flags(u32 rd_flags)
3656 {
3657 u32 channel_flags = 0;
3658 - if (rd_flags & NL80211_RRF_PASSIVE_SCAN)
3659 - channel_flags |= IEEE80211_CHAN_PASSIVE_SCAN;
3660 - if (rd_flags & NL80211_RRF_NO_IBSS)
3661 - channel_flags |= IEEE80211_CHAN_NO_IBSS;
3662 + if (rd_flags & NL80211_RRF_NO_IR_ALL)
3663 + channel_flags |= IEEE80211_CHAN_NO_IR;
3664 if (rd_flags & NL80211_RRF_DFS)
3665 channel_flags |= IEEE80211_CHAN_RADAR;
3666 if (rd_flags & NL80211_RRF_NO_OFDM)
3667 @@ -1066,13 +1058,8 @@ static void handle_reg_beacon(struct wip
3668 chan_before.center_freq = chan->center_freq;
3669 chan_before.flags = chan->flags;
3670
3671 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) {
3672 - chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
3673 - channel_changed = true;
3674 - }
3675 -
3676 - if (chan->flags & IEEE80211_CHAN_NO_IBSS) {
3677 - chan->flags &= ~IEEE80211_CHAN_NO_IBSS;
3678 + if (chan->flags & IEEE80211_CHAN_NO_IR) {
3679 + chan->flags &= ~IEEE80211_CHAN_NO_IR;
3680 channel_changed = true;
3681 }
3682
3683 --- /dev/null
3684 +++ b/drivers/net/wireless/ath/ath9k/ar9003_wow.c
3685 @@ -0,0 +1,422 @@
3686 +/*
3687 + * Copyright (c) 2012 Qualcomm Atheros, Inc.
3688 + *
3689 + * Permission to use, copy, modify, and/or distribute this software for any
3690 + * purpose with or without fee is hereby granted, provided that the above
3691 + * copyright notice and this permission notice appear in all copies.
3692 + *
3693 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3694 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3695 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3696 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3697 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3698 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3699 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3700 + */
3701 +
3702 +#include <linux/export.h>
3703 +#include "ath9k.h"
3704 +#include "reg.h"
3705 +#include "hw-ops.h"
3706 +
3707 +const char *ath9k_hw_wow_event_to_string(u32 wow_event)
3708 +{
3709 + if (wow_event & AH_WOW_MAGIC_PATTERN_EN)
3710 + return "Magic pattern";
3711 + if (wow_event & AH_WOW_USER_PATTERN_EN)
3712 + return "User pattern";
3713 + if (wow_event & AH_WOW_LINK_CHANGE)
3714 + return "Link change";
3715 + if (wow_event & AH_WOW_BEACON_MISS)
3716 + return "Beacon miss";
3717 +
3718 + return "unknown reason";
3719 +}
3720 +EXPORT_SYMBOL(ath9k_hw_wow_event_to_string);
3721 +
3722 +static void ath9k_hw_set_powermode_wow_sleep(struct ath_hw *ah)
3723 +{
3724 + struct ath_common *common = ath9k_hw_common(ah);
3725 +
3726 + REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
3727 +
3728 + /* set rx disable bit */
3729 + REG_WRITE(ah, AR_CR, AR_CR_RXD);
3730 +
3731 + if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0, AH_WAIT_TIMEOUT)) {
3732 + ath_err(common, "Failed to stop Rx DMA in 10ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
3733 + REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
3734 + return;
3735 + }
3736 +
3737 + REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_ON_INT);
3738 +}
3739 +
3740 +static void ath9k_wow_create_keep_alive_pattern(struct ath_hw *ah)
3741 +{
3742 + struct ath_common *common = ath9k_hw_common(ah);
3743 + u8 sta_mac_addr[ETH_ALEN], ap_mac_addr[ETH_ALEN];
3744 + u32 ctl[13] = {0};
3745 + u32 data_word[KAL_NUM_DATA_WORDS];
3746 + u8 i;
3747 + u32 wow_ka_data_word0;
3748 +
3749 + memcpy(sta_mac_addr, common->macaddr, ETH_ALEN);
3750 + memcpy(ap_mac_addr, common->curbssid, ETH_ALEN);
3751 +
3752 + /* set the transmit buffer */
3753 + ctl[0] = (KAL_FRAME_LEN | (MAX_RATE_POWER << 16));
3754 + ctl[1] = 0;
3755 + ctl[3] = 0xb; /* OFDM_6M hardware value for this rate */
3756 + ctl[4] = 0;
3757 + ctl[7] = (ah->txchainmask) << 2;
3758 + ctl[2] = 0xf << 16; /* tx_tries 0 */
3759 +
3760 + for (i = 0; i < KAL_NUM_DESC_WORDS; i++)
3761 + REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
3762 +
3763 + REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
3764 +
3765 + data_word[0] = (KAL_FRAME_TYPE << 2) | (KAL_FRAME_SUB_TYPE << 4) |
3766 + (KAL_TO_DS << 8) | (KAL_DURATION_ID << 16);
3767 + data_word[1] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
3768 + (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
3769 + data_word[2] = (sta_mac_addr[1] << 24) | (sta_mac_addr[0] << 16) |
3770 + (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
3771 + data_word[3] = (sta_mac_addr[5] << 24) | (sta_mac_addr[4] << 16) |
3772 + (sta_mac_addr[3] << 8) | (sta_mac_addr[2]);
3773 + data_word[4] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
3774 + (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
3775 + data_word[5] = (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
3776 +
3777 + if (AR_SREV_9462_20(ah)) {
3778 + /* AR9462 2.0 has an extra descriptor word (time based
3779 + * discard) compared to other chips */
3780 + REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + (12 * 4)), 0);
3781 + wow_ka_data_word0 = AR_WOW_TXBUF(13);
3782 + } else {
3783 + wow_ka_data_word0 = AR_WOW_TXBUF(12);
3784 + }
3785 +
3786 + for (i = 0; i < KAL_NUM_DATA_WORDS; i++)
3787 + REG_WRITE(ah, (wow_ka_data_word0 + i*4), data_word[i]);
3788 +
3789 +}
3790 +
3791 +void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
3792 + u8 *user_mask, int pattern_count,
3793 + int pattern_len)
3794 +{
3795 + int i;
3796 + u32 pattern_val, mask_val;
3797 + u32 set, clr;
3798 +
3799 + /* FIXME: should check count by querying the hardware capability */
3800 + if (pattern_count >= MAX_NUM_PATTERN)
3801 + return;
3802 +
3803 + REG_SET_BIT(ah, AR_WOW_PATTERN, BIT(pattern_count));
3804 +
3805 + /* set the registers for pattern */
3806 + for (i = 0; i < MAX_PATTERN_SIZE; i += 4) {
3807 + memcpy(&pattern_val, user_pattern, 4);
3808 + REG_WRITE(ah, (AR_WOW_TB_PATTERN(pattern_count) + i),
3809 + pattern_val);
3810 + user_pattern += 4;
3811 + }
3812 +
3813 + /* set the registers for mask */
3814 + for (i = 0; i < MAX_PATTERN_MASK_SIZE; i += 4) {
3815 + memcpy(&mask_val, user_mask, 4);
3816 + REG_WRITE(ah, (AR_WOW_TB_MASK(pattern_count) + i), mask_val);
3817 + user_mask += 4;
3818 + }
3819 +
3820 + /* set the pattern length to be matched
3821 + *
3822 + * AR_WOW_LENGTH1_REG1
3823 + * bit 31:24 pattern 0 length
3824 + * bit 23:16 pattern 1 length
3825 + * bit 15:8 pattern 2 length
3826 + * bit 7:0 pattern 3 length
3827 + *
3828 + * AR_WOW_LENGTH1_REG2
3829 + * bit 31:24 pattern 4 length
3830 + * bit 23:16 pattern 5 length
3831 + * bit 15:8 pattern 6 length
3832 + * bit 7:0 pattern 7 length
3833 + *
3834 + * the below logic writes out the new
3835 + * pattern length for the corresponding
3836 + * pattern_count, while masking out the
3837 + * other fields
3838 + */
3839 +
3840 + ah->wow_event_mask |= BIT(pattern_count + AR_WOW_PAT_FOUND_SHIFT);
3841 +
3842 + if (pattern_count < 4) {
3843 + /* Pattern 0-3 uses AR_WOW_LENGTH1 register */
3844 + set = (pattern_len & AR_WOW_LENGTH_MAX) <<
3845 + AR_WOW_LEN1_SHIFT(pattern_count);
3846 + clr = AR_WOW_LENGTH1_MASK(pattern_count);
3847 + REG_RMW(ah, AR_WOW_LENGTH1, set, clr);
3848 + } else {
3849 + /* Pattern 4-7 uses AR_WOW_LENGTH2 register */
3850 + set = (pattern_len & AR_WOW_LENGTH_MAX) <<
3851 + AR_WOW_LEN2_SHIFT(pattern_count);
3852 + clr = AR_WOW_LENGTH2_MASK(pattern_count);
3853 + REG_RMW(ah, AR_WOW_LENGTH2, set, clr);
3854 + }
3855 +
3856 +}
3857 +EXPORT_SYMBOL(ath9k_hw_wow_apply_pattern);
3858 +
3859 +u32 ath9k_hw_wow_wakeup(struct ath_hw *ah)
3860 +{
3861 + u32 wow_status = 0;
3862 + u32 val = 0, rval;
3863 +
3864 + /*
3865 + * read the WoW status register to know
3866 + * the wakeup reason
3867 + */
3868 + rval = REG_READ(ah, AR_WOW_PATTERN);
3869 + val = AR_WOW_STATUS(rval);
3870 +
3871 + /*
3872 + * mask only the WoW events that we have enabled. Sometimes
3873 + * we have spurious WoW events from the AR_WOW_PATTERN
3874 + * register. This mask will clean it up.
3875 + */
3876 +
3877 + val &= ah->wow_event_mask;
3878 +
3879 + if (val) {
3880 + if (val & AR_WOW_MAGIC_PAT_FOUND)
3881 + wow_status |= AH_WOW_MAGIC_PATTERN_EN;
3882 + if (AR_WOW_PATTERN_FOUND(val))
3883 + wow_status |= AH_WOW_USER_PATTERN_EN;
3884 + if (val & AR_WOW_KEEP_ALIVE_FAIL)
3885 + wow_status |= AH_WOW_LINK_CHANGE;
3886 + if (val & AR_WOW_BEACON_FAIL)
3887 + wow_status |= AH_WOW_BEACON_MISS;
3888 + }
3889 +
3890 + /*
3891 + * set and clear WOW_PME_CLEAR registers for the chip to
3892 + * generate next wow signal.
3893 + * disable D3 before accessing other registers ?
3894 + */
3895 +
3896 + /* do we need to check the bit value 0x01000000 (7-10) ?? */
3897 + REG_RMW(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_WOW_PME_CLR,
3898 + AR_PMCTRL_PWR_STATE_D1D3);
3899 +
3900 + /*
3901 + * clear all events
3902 + */
3903 + REG_WRITE(ah, AR_WOW_PATTERN,
3904 + AR_WOW_CLEAR_EVENTS(REG_READ(ah, AR_WOW_PATTERN)));
3905 +
3906 + /*
3907 + * restore the beacon threshold to init value
3908 + */
3909 + REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
3910 +
3911 + /*
3912 + * Restore the way the PCI-E reset, Power-On-Reset, external
3913 + * PCIE_POR_SHORT pins are tied to its original value.
3914 + * Previously just before WoW sleep, we untie the PCI-E
3915 + * reset to our Chip's Power On Reset so that any PCI-E
3916 + * reset from the bus will not reset our chip
3917 + */
3918 + if (ah->is_pciexpress)
3919 + ath9k_hw_configpcipowersave(ah, false);
3920 +
3921 + ah->wow_event_mask = 0;
3922 +
3923 + return wow_status;
3924 +}
3925 +EXPORT_SYMBOL(ath9k_hw_wow_wakeup);
3926 +
3927 +void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable)
3928 +{
3929 + u32 wow_event_mask;
3930 + u32 set, clr;
3931 +
3932 + /*
3933 + * wow_event_mask is a mask to the AR_WOW_PATTERN register to
3934 + * indicate which WoW events we have enabled. The WoW events
3935 + * are from the 'pattern_enable' in this function and
3936 + * 'pattern_count' of ath9k_hw_wow_apply_pattern()
3937 + */
3938 + wow_event_mask = ah->wow_event_mask;
3939 +
3940 + /*
3941 + * Untie Power-on-Reset from the PCI-E-Reset. When we are in
3942 + * WOW sleep, we do want the Reset from the PCI-E to disturb
3943 + * our hw state
3944 + */
3945 + if (ah->is_pciexpress) {
3946 + /*
3947 + * we need to untie the internal POR (power-on-reset)
3948 + * to the external PCI-E reset. We also need to tie
3949 + * the PCI-E Phy reset to the PCI-E reset.
3950 + */
3951 + set = AR_WA_RESET_EN | AR_WA_POR_SHORT;
3952 + clr = AR_WA_UNTIE_RESET_EN | AR_WA_D3_L1_DISABLE;
3953 + REG_RMW(ah, AR_WA, set, clr);
3954 + }
3955 +
3956 + /*
3957 + * set the power states appropriately and enable PME
3958 + */
3959 + set = AR_PMCTRL_HOST_PME_EN | AR_PMCTRL_PWR_PM_CTRL_ENA |
3960 + AR_PMCTRL_AUX_PWR_DET | AR_PMCTRL_WOW_PME_CLR;
3961 +
3962 + /*
3963 + * set and clear WOW_PME_CLEAR registers for the chip
3964 + * to generate next wow signal.
3965 + */
3966 + REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
3967 + clr = AR_PMCTRL_WOW_PME_CLR;
3968 + REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
3969 +
3970 + /*
3971 + * Setup for:
3972 + * - beacon misses
3973 + * - magic pattern
3974 + * - keep alive timeout
3975 + * - pattern matching
3976 + */
3977 +
3978 + /*
3979 + * Program default values for pattern backoff, aifs/slot/KAL count,
3980 + * beacon miss timeout, KAL timeout, etc.
3981 + */
3982 + set = AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF);
3983 + REG_SET_BIT(ah, AR_WOW_PATTERN, set);
3984 +
3985 + set = AR_WOW_AIFS_CNT(AR_WOW_CNT_AIFS_CNT) |
3986 + AR_WOW_SLOT_CNT(AR_WOW_CNT_SLOT_CNT) |
3987 + AR_WOW_KEEP_ALIVE_CNT(AR_WOW_CNT_KA_CNT);
3988 + REG_SET_BIT(ah, AR_WOW_COUNT, set);
3989 +
3990 + if (pattern_enable & AH_WOW_BEACON_MISS)
3991 + set = AR_WOW_BEACON_TIMO;
3992 + /* We are not using beacon miss, program a large value */
3993 + else
3994 + set = AR_WOW_BEACON_TIMO_MAX;
3995 +
3996 + REG_WRITE(ah, AR_WOW_BCN_TIMO, set);
3997 +
3998 + /*
3999 + * Keep alive timo in ms except AR9280
4000 + */
4001 + if (!pattern_enable)
4002 + set = AR_WOW_KEEP_ALIVE_NEVER;
4003 + else
4004 + set = KAL_TIMEOUT * 32;
4005 +
4006 + REG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, set);
4007 +
4008 + /*
4009 + * Keep alive delay in us. based on 'power on clock',
4010 + * therefore in usec
4011 + */
4012 + set = KAL_DELAY * 1000;
4013 + REG_WRITE(ah, AR_WOW_KEEP_ALIVE_DELAY, set);
4014 +
4015 + /*
4016 + * Create keep alive pattern to respond to beacons
4017 + */
4018 + ath9k_wow_create_keep_alive_pattern(ah);
4019 +
4020 + /*
4021 + * Configure MAC WoW Registers
4022 + */
4023 + set = 0;
4024 + /* Send keep alive timeouts anyway */
4025 + clr = AR_WOW_KEEP_ALIVE_AUTO_DIS;
4026 +
4027 + if (pattern_enable & AH_WOW_LINK_CHANGE)
4028 + wow_event_mask |= AR_WOW_KEEP_ALIVE_FAIL;
4029 + else
4030 + set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
4031 +
4032 + set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
4033 + REG_RMW(ah, AR_WOW_KEEP_ALIVE, set, clr);
4034 +
4035 + /*
4036 + * we are relying on a bmiss failure. ensure we have
4037 + * enough threshold to prevent false positives
4038 + */
4039 + REG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR,
4040 + AR_WOW_BMISSTHRESHOLD);
4041 +
4042 + set = 0;
4043 + clr = 0;
4044 +
4045 + if (pattern_enable & AH_WOW_BEACON_MISS) {
4046 + set = AR_WOW_BEACON_FAIL_EN;
4047 + wow_event_mask |= AR_WOW_BEACON_FAIL;
4048 + } else {
4049 + clr = AR_WOW_BEACON_FAIL_EN;
4050 + }
4051 +
4052 + REG_RMW(ah, AR_WOW_BCN_EN, set, clr);
4053 +
4054 + set = 0;
4055 + clr = 0;
4056 + /*
4057 + * Enable the magic packet registers
4058 + */
4059 + if (pattern_enable & AH_WOW_MAGIC_PATTERN_EN) {
4060 + set = AR_WOW_MAGIC_EN;
4061 + wow_event_mask |= AR_WOW_MAGIC_PAT_FOUND;
4062 + } else {
4063 + clr = AR_WOW_MAGIC_EN;
4064 + }
4065 + set |= AR_WOW_MAC_INTR_EN;
4066 + REG_RMW(ah, AR_WOW_PATTERN, set, clr);
4067 +
4068 + REG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B,
4069 + AR_WOW_PATTERN_SUPPORTED);
4070 +
4071 + /*
4072 + * Set the power states appropriately and enable PME
4073 + */
4074 + clr = 0;
4075 + set = AR_PMCTRL_PWR_STATE_D1D3 | AR_PMCTRL_HOST_PME_EN |
4076 + AR_PMCTRL_PWR_PM_CTRL_ENA;
4077 +
4078 + clr = AR_PCIE_PM_CTRL_ENA;
4079 + REG_RMW(ah, AR_PCIE_PM_CTRL, set, clr);
4080 +
4081 + /*
4082 + * this is needed to prevent the chip waking up
4083 + * the host within 3-4 seconds with certain
4084 + * platform/BIOS. The fix is to enable
4085 + * D1 & D3 to match original definition and
4086 + * also match the OTP value. Anyway this
4087 + * is more related to SW WOW.
4088 + */
4089 + clr = AR_PMCTRL_PWR_STATE_D1D3;
4090 + REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
4091 +
4092 + set = AR_PMCTRL_PWR_STATE_D1D3_REAL;
4093 + REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
4094 +
4095 + REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
4096 +
4097 + /* to bring down WOW power low margin */
4098 + set = BIT(13);
4099 + REG_SET_BIT(ah, AR_PCIE_PHY_REG3, set);
4100 + /* HW WoW */
4101 + clr = BIT(5);
4102 + REG_CLR_BIT(ah, AR_PCU_MISC_MODE3, clr);
4103 +
4104 + ath9k_hw_set_powermode_wow_sleep(ah);
4105 + ah->wow_event_mask = wow_event_mask;
4106 +}
4107 +EXPORT_SYMBOL(ath9k_hw_wow_enable);
4108 --- /dev/null
4109 +++ b/drivers/net/wireless/ath/ath9k/tx99.c
4110 @@ -0,0 +1,263 @@
4111 +/*
4112 + * Copyright (c) 2013 Qualcomm Atheros, Inc.
4113 + *
4114 + * Permission to use, copy, modify, and/or distribute this software for any
4115 + * purpose with or without fee is hereby granted, provided that the above
4116 + * copyright notice and this permission notice appear in all copies.
4117 + *
4118 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
4119 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
4120 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
4121 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
4122 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
4123 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
4124 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4125 + */
4126 +
4127 +#include "ath9k.h"
4128 +
4129 +static void ath9k_tx99_stop(struct ath_softc *sc)
4130 +{
4131 + struct ath_hw *ah = sc->sc_ah;
4132 + struct ath_common *common = ath9k_hw_common(ah);
4133 +
4134 + ath_drain_all_txq(sc);
4135 + ath_startrecv(sc);
4136 +
4137 + ath9k_hw_set_interrupts(ah);
4138 + ath9k_hw_enable_interrupts(ah);
4139 +
4140 + ieee80211_wake_queues(sc->hw);
4141 +
4142 + kfree_skb(sc->tx99_skb);
4143 + sc->tx99_skb = NULL;
4144 + sc->tx99_state = false;
4145 +
4146 + ath9k_hw_tx99_stop(sc->sc_ah);
4147 + ath_dbg(common, XMIT, "TX99 stopped\n");
4148 +}
4149 +
4150 +static struct sk_buff *ath9k_build_tx99_skb(struct ath_softc *sc)
4151 +{
4152 + static u8 PN9Data[] = {0xff, 0x87, 0xb8, 0x59, 0xb7, 0xa1, 0xcc, 0x24,
4153 + 0x57, 0x5e, 0x4b, 0x9c, 0x0e, 0xe9, 0xea, 0x50,
4154 + 0x2a, 0xbe, 0xb4, 0x1b, 0xb6, 0xb0, 0x5d, 0xf1,
4155 + 0xe6, 0x9a, 0xe3, 0x45, 0xfd, 0x2c, 0x53, 0x18,
4156 + 0x0c, 0xca, 0xc9, 0xfb, 0x49, 0x37, 0xe5, 0xa8,
4157 + 0x51, 0x3b, 0x2f, 0x61, 0xaa, 0x72, 0x18, 0x84,
4158 + 0x02, 0x23, 0x23, 0xab, 0x63, 0x89, 0x51, 0xb3,
4159 + 0xe7, 0x8b, 0x72, 0x90, 0x4c, 0xe8, 0xfb, 0xc0};
4160 + u32 len = 1200;
4161 + struct ieee80211_hw *hw = sc->hw;
4162 + struct ieee80211_hdr *hdr;
4163 + struct ieee80211_tx_info *tx_info;
4164 + struct sk_buff *skb;
4165 +
4166 + skb = alloc_skb(len, GFP_KERNEL);
4167 + if (!skb)
4168 + return NULL;
4169 +
4170 + skb_put(skb, len);
4171 +
4172 + memset(skb->data, 0, len);
4173 +
4174 + hdr = (struct ieee80211_hdr *)skb->data;
4175 + hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA);
4176 + hdr->duration_id = 0;
4177 +
4178 + memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
4179 + memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
4180 + memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
4181 +
4182 + hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
4183 +
4184 + tx_info = IEEE80211_SKB_CB(skb);
4185 + memset(tx_info, 0, sizeof(*tx_info));
4186 + tx_info->band = hw->conf.chandef.chan->band;
4187 + tx_info->flags = IEEE80211_TX_CTL_NO_ACK;
4188 + tx_info->control.vif = sc->tx99_vif;
4189 +
4190 + memcpy(skb->data + sizeof(*hdr), PN9Data, sizeof(PN9Data));
4191 +
4192 + return skb;
4193 +}
4194 +
4195 +static void ath9k_tx99_deinit(struct ath_softc *sc)
4196 +{
4197 + ath_reset(sc);
4198 +
4199 + ath9k_ps_wakeup(sc);
4200 + ath9k_tx99_stop(sc);
4201 + ath9k_ps_restore(sc);
4202 +}
4203 +
4204 +static int ath9k_tx99_init(struct ath_softc *sc)
4205 +{
4206 + struct ieee80211_hw *hw = sc->hw;
4207 + struct ath_hw *ah = sc->sc_ah;
4208 + struct ath_common *common = ath9k_hw_common(ah);
4209 + struct ath_tx_control txctl;
4210 + int r;
4211 +
4212 + if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
4213 + ath_err(common,
4214 + "driver is in invalid state unable to use TX99");
4215 + return -EINVAL;
4216 + }
4217 +
4218 + sc->tx99_skb = ath9k_build_tx99_skb(sc);
4219 + if (!sc->tx99_skb)
4220 + return -ENOMEM;
4221 +
4222 + memset(&txctl, 0, sizeof(txctl));
4223 + txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
4224 +
4225 + ath_reset(sc);
4226 +
4227 + ath9k_ps_wakeup(sc);
4228 +
4229 + ath9k_hw_disable_interrupts(ah);
4230 + atomic_set(&ah->intr_ref_cnt, -1);
4231 + ath_drain_all_txq(sc);
4232 + ath_stoprecv(sc);
4233 +
4234 + sc->tx99_state = true;
4235 +
4236 + ieee80211_stop_queues(hw);
4237 +
4238 + if (sc->tx99_power == MAX_RATE_POWER + 1)
4239 + sc->tx99_power = MAX_RATE_POWER;
4240 +
4241 + ath9k_hw_tx99_set_txpower(ah, sc->tx99_power);
4242 + r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
4243 + if (r) {
4244 + ath_dbg(common, XMIT, "Failed to xmit TX99 skb\n");
4245 + return r;
4246 + }
4247 +
4248 + ath_dbg(common, XMIT, "TX99 xmit started using %d ( %ddBm)\n",
4249 + sc->tx99_power,
4250 + sc->tx99_power / 2);
4251 +
4252 + /* We leave the harware awake as it will be chugging on */
4253 +
4254 + return 0;
4255 +}
4256 +
4257 +static ssize_t read_file_tx99(struct file *file, char __user *user_buf,
4258 + size_t count, loff_t *ppos)
4259 +{
4260 + struct ath_softc *sc = file->private_data;
4261 + char buf[3];
4262 + unsigned int len;
4263 +
4264 + len = sprintf(buf, "%d\n", sc->tx99_state);
4265 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
4266 +}
4267 +
4268 +static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
4269 + size_t count, loff_t *ppos)
4270 +{
4271 + struct ath_softc *sc = file->private_data;
4272 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
4273 + char buf[32];
4274 + bool start;
4275 + ssize_t len;
4276 + int r;
4277 +
4278 + if (sc->nvifs > 1)
4279 + return -EOPNOTSUPP;
4280 +
4281 + len = min(count, sizeof(buf) - 1);
4282 + if (copy_from_user(buf, user_buf, len))
4283 + return -EFAULT;
4284 +
4285 + if (strtobool(buf, &start))
4286 + return -EINVAL;
4287 +
4288 + if (start == sc->tx99_state) {
4289 + if (!start)
4290 + return count;
4291 + ath_dbg(common, XMIT, "Resetting TX99\n");
4292 + ath9k_tx99_deinit(sc);
4293 + }
4294 +
4295 + if (!start) {
4296 + ath9k_tx99_deinit(sc);
4297 + return count;
4298 + }
4299 +
4300 + r = ath9k_tx99_init(sc);
4301 + if (r)
4302 + return r;
4303 +
4304 + return count;
4305 +}
4306 +
4307 +static const struct file_operations fops_tx99 = {
4308 + .read = read_file_tx99,
4309 + .write = write_file_tx99,
4310 + .open = simple_open,
4311 + .owner = THIS_MODULE,
4312 + .llseek = default_llseek,
4313 +};
4314 +
4315 +static ssize_t read_file_tx99_power(struct file *file,
4316 + char __user *user_buf,
4317 + size_t count, loff_t *ppos)
4318 +{
4319 + struct ath_softc *sc = file->private_data;
4320 + char buf[32];
4321 + unsigned int len;
4322 +
4323 + len = sprintf(buf, "%d (%d dBm)\n",
4324 + sc->tx99_power,
4325 + sc->tx99_power / 2);
4326 +
4327 + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
4328 +}
4329 +
4330 +static ssize_t write_file_tx99_power(struct file *file,
4331 + const char __user *user_buf,
4332 + size_t count, loff_t *ppos)
4333 +{
4334 + struct ath_softc *sc = file->private_data;
4335 + int r;
4336 + u8 tx_power;
4337 +
4338 + r = kstrtou8_from_user(user_buf, count, 0, &tx_power);
4339 + if (r)
4340 + return r;
4341 +
4342 + if (tx_power > MAX_RATE_POWER)
4343 + return -EINVAL;
4344 +
4345 + sc->tx99_power = tx_power;
4346 +
4347 + ath9k_ps_wakeup(sc);
4348 + ath9k_hw_tx99_set_txpower(sc->sc_ah, sc->tx99_power);
4349 + ath9k_ps_restore(sc);
4350 +
4351 + return count;
4352 +}
4353 +
4354 +static const struct file_operations fops_tx99_power = {
4355 + .read = read_file_tx99_power,
4356 + .write = write_file_tx99_power,
4357 + .open = simple_open,
4358 + .owner = THIS_MODULE,
4359 + .llseek = default_llseek,
4360 +};
4361 +
4362 +void ath9k_tx99_init_debug(struct ath_softc *sc)
4363 +{
4364 + if (!AR_SREV_9300_20_OR_LATER(sc->sc_ah))
4365 + return;
4366 +
4367 + debugfs_create_file("tx99", S_IRUSR | S_IWUSR,
4368 + sc->debug.debugfs_phy, sc,
4369 + &fops_tx99);
4370 + debugfs_create_file("tx99_power", S_IRUSR | S_IWUSR,
4371 + sc->debug.debugfs_phy, sc,
4372 + &fops_tx99_power);
4373 +}