mac80211: small rate control fix
[openwrt/openwrt.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 @@ -17,6 +17,7 @@
486 #include <linux/io.h>
487 #include <linux/slab.h>
488 #include <linux/module.h>
489 +#include <linux/time.h>
490 #include <asm/unaligned.h>
491
492 #include "hw.h"
493 @@ -454,7 +455,6 @@ static void ath9k_hw_init_config(struct
494 }
495
496 ah->config.rx_intr_mitigation = true;
497 - ah->config.pcieSerDesWrite = true;
498
499 /*
500 * We need this for PCI devices only (Cardbus, PCI, miniPCI)
501 @@ -1502,8 +1502,9 @@ static bool ath9k_hw_channel_change(stru
502 int r;
503
504 if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
505 - band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan);
506 - mode_diff = (chan->channelFlags != ah->curchan->channelFlags);
507 + u32 flags_diff = chan->channelFlags ^ ah->curchan->channelFlags;
508 + band_switch = !!(flags_diff & CHANNEL_5GHZ);
509 + mode_diff = !!(flags_diff & ~CHANNEL_HT);
510 }
511
512 for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
513 @@ -1815,7 +1816,7 @@ static int ath9k_hw_do_fastcc(struct ath
514 * If cross-band fcc is not supoprted, bail out if channelFlags differ.
515 */
516 if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) &&
517 - chan->channelFlags != ah->curchan->channelFlags)
518 + ((chan->channelFlags ^ ah->curchan->channelFlags) & ~CHANNEL_HT))
519 goto fail;
520
521 if (!ath9k_hw_check_alive(ah))
522 @@ -1856,10 +1857,12 @@ int ath9k_hw_reset(struct ath_hw *ah, st
523 struct ath9k_hw_cal_data *caldata, bool fastcc)
524 {
525 struct ath_common *common = ath9k_hw_common(ah);
526 + struct timespec ts;
527 u32 saveLedState;
528 u32 saveDefAntenna;
529 u32 macStaId1;
530 u64 tsf = 0;
531 + s64 usec = 0;
532 int r;
533 bool start_mci_reset = false;
534 bool save_fullsleep = ah->chip_fullsleep;
535 @@ -1902,10 +1905,10 @@ int ath9k_hw_reset(struct ath_hw *ah, st
536
537 macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
538
539 - /* For chips on which RTC reset is done, save TSF before it gets cleared */
540 - if (AR_SREV_9100(ah) ||
541 - (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)))
542 - tsf = ath9k_hw_gettsf64(ah);
543 + /* Save TSF before chip reset, a cold reset clears it */
544 + tsf = ath9k_hw_gettsf64(ah);
545 + getrawmonotonic(&ts);
546 + usec = ts.tv_sec * 1000 + ts.tv_nsec / 1000;
547
548 saveLedState = REG_READ(ah, AR_CFG_LED) &
549 (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
550 @@ -1938,8 +1941,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
551 }
552
553 /* Restore TSF */
554 - if (tsf)
555 - ath9k_hw_settsf64(ah, tsf);
556 + getrawmonotonic(&ts);
557 + usec = ts.tv_sec * 1000 + ts.tv_nsec / 1000 - usec;
558 + ath9k_hw_settsf64(ah, tsf + usec);
559
560 if (AR_SREV_9280_20_OR_LATER(ah))
561 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
562 --- a/drivers/net/wireless/ath/ath9k/hw.h
563 +++ b/drivers/net/wireless/ath/ath9k/hw.h
564 @@ -283,7 +283,6 @@ struct ath9k_ops_config {
565 int additional_swba_backoff;
566 int ack_6mb;
567 u32 cwm_ignore_extcca;
568 - bool pcieSerDesWrite;
569 u8 pcie_clock_req;
570 u32 pcie_waen;
571 u8 analog_shiftreg;
572 @@ -920,7 +919,7 @@ struct ath_hw {
573 /* Enterprise mode cap */
574 u32 ent_mode;
575
576 -#ifdef CONFIG_PM_SLEEP
577 +#ifdef CONFIG_ATH9K_WOW
578 u32 wow_event_mask;
579 #endif
580 bool is_clk_25mhz;
581 @@ -1126,7 +1125,7 @@ ath9k_hw_get_btcoex_scheme(struct ath_hw
582 #endif /* CPTCFG_ATH9K_BTCOEX_SUPPORT */
583
584
585 -#ifdef CONFIG_PM_SLEEP
586 +#ifdef CONFIG_ATH9K_WOW
587 const char *ath9k_hw_wow_event_to_string(u32 wow_event);
588 void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
589 u8 *user_mask, int pattern_count,
590 --- a/drivers/net/wireless/ath/ath9k/init.c
591 +++ b/drivers/net/wireless/ath/ath9k/init.c
592 @@ -683,6 +683,7 @@ static int ath9k_init_softc(u16 devid, s
593 common = ath9k_hw_common(ah);
594 sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
595 sc->tx99_power = MAX_RATE_POWER + 1;
596 + init_waitqueue_head(&sc->tx_wait);
597
598 if (!pdata) {
599 ah->ah_flags |= AH_USE_EEPROM;
600 @@ -730,6 +731,7 @@ static int ath9k_init_softc(u16 devid, s
601 tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
602 (unsigned long)sc);
603
604 + setup_timer(&sc->sleep_timer, ath_ps_full_sleep, (unsigned long)sc);
605 INIT_WORK(&sc->hw_reset_work, ath_reset_work);
606 INIT_WORK(&sc->hw_check_work, ath_hw_check);
607 INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
608 @@ -845,7 +847,8 @@ static const struct ieee80211_iface_limi
609 };
610
611 static const struct ieee80211_iface_limit if_dfs_limits[] = {
612 - { .max = 1, .types = BIT(NL80211_IFTYPE_AP) },
613 + { .max = 1, .types = BIT(NL80211_IFTYPE_AP) |
614 + BIT(NL80211_IFTYPE_ADHOC) },
615 };
616
617 static const struct ieee80211_iface_combination if_comb[] = {
618 @@ -862,20 +865,11 @@ static const struct ieee80211_iface_comb
619 .max_interfaces = 1,
620 .num_different_channels = 1,
621 .beacon_int_infra_match = true,
622 - .radar_detect_widths = BIT(NL80211_CHAN_NO_HT) |
623 - BIT(NL80211_CHAN_HT20),
624 + .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
625 + BIT(NL80211_CHAN_WIDTH_20),
626 }
627 };
628
629 -#ifdef CONFIG_PM
630 -static const struct wiphy_wowlan_support ath9k_wowlan_support = {
631 - .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
632 - .n_patterns = MAX_NUM_USER_PATTERN,
633 - .pattern_min_len = 1,
634 - .pattern_max_len = MAX_PATTERN_SIZE,
635 -};
636 -#endif
637 -
638 void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
639 {
640 struct ath_hw *ah = sc->sc_ah;
641 @@ -925,16 +919,6 @@ void ath9k_set_hw_capab(struct ath_softc
642 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ;
643 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
644
645 -#ifdef CONFIG_PM_SLEEP
646 - if ((ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) &&
647 - (sc->driver_data & ATH9K_PCI_WOW) &&
648 - device_can_wakeup(sc->dev))
649 - hw->wiphy->wowlan = &ath9k_wowlan_support;
650 -
651 - atomic_set(&sc->wow_sleep_proc_intr, -1);
652 - atomic_set(&sc->wow_got_bmiss_intr, -1);
653 -#endif
654 -
655 hw->queues = 4;
656 hw->max_rates = 4;
657 hw->channel_change_time = 5000;
658 @@ -960,6 +944,7 @@ void ath9k_set_hw_capab(struct ath_softc
659 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
660 &sc->sbands[IEEE80211_BAND_5GHZ];
661
662 + ath9k_init_wow(hw);
663 ath9k_reload_chainmask_settings(sc);
664
665 SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
666 @@ -1058,6 +1043,7 @@ static void ath9k_deinit_softc(struct at
667 if (ATH_TXQ_SETUP(sc, i))
668 ath_tx_cleanupq(sc, &sc->tx.txq[i]);
669
670 + del_timer_sync(&sc->sleep_timer);
671 ath9k_hw_deinit(sc->sc_ah);
672 if (sc->dfs_detector != NULL)
673 sc->dfs_detector->exit(sc->dfs_detector);
674 --- a/drivers/net/wireless/ath/ath9k/main.c
675 +++ b/drivers/net/wireless/ath/ath9k/main.c
676 @@ -82,6 +82,22 @@ static bool ath9k_setpower(struct ath_so
677 return ret;
678 }
679
680 +void ath_ps_full_sleep(unsigned long data)
681 +{
682 + struct ath_softc *sc = (struct ath_softc *) data;
683 + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
684 + bool reset;
685 +
686 + spin_lock(&common->cc_lock);
687 + ath_hw_cycle_counters_update(common);
688 + spin_unlock(&common->cc_lock);
689 +
690 + ath9k_hw_setrxabort(sc->sc_ah, 1);
691 + ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
692 +
693 + ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
694 +}
695 +
696 void ath9k_ps_wakeup(struct ath_softc *sc)
697 {
698 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
699 @@ -92,6 +108,7 @@ void ath9k_ps_wakeup(struct ath_softc *s
700 if (++sc->ps_usecount != 1)
701 goto unlock;
702
703 + del_timer_sync(&sc->sleep_timer);
704 power_mode = sc->sc_ah->power_mode;
705 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
706
707 @@ -117,17 +134,17 @@ void ath9k_ps_restore(struct ath_softc *
708 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
709 enum ath9k_power_mode mode;
710 unsigned long flags;
711 - bool reset;
712
713 spin_lock_irqsave(&sc->sc_pm_lock, flags);
714 if (--sc->ps_usecount != 0)
715 goto unlock;
716
717 if (sc->ps_idle) {
718 - ath9k_hw_setrxabort(sc->sc_ah, 1);
719 - ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
720 - mode = ATH9K_PM_FULL_SLEEP;
721 - } else if (sc->ps_enabled &&
722 + mod_timer(&sc->sleep_timer, jiffies + HZ / 10);
723 + goto unlock;
724 + }
725 +
726 + if (sc->ps_enabled &&
727 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
728 PS_WAIT_FOR_CAB |
729 PS_WAIT_FOR_PSPOLL_DATA |
730 @@ -163,13 +180,13 @@ static void __ath_cancel_work(struct ath
731 #endif
732 }
733
734 -static void ath_cancel_work(struct ath_softc *sc)
735 +void ath_cancel_work(struct ath_softc *sc)
736 {
737 __ath_cancel_work(sc);
738 cancel_work_sync(&sc->hw_reset_work);
739 }
740
741 -static void ath_restart_work(struct ath_softc *sc)
742 +void ath_restart_work(struct ath_softc *sc)
743 {
744 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
745
746 @@ -487,6 +504,8 @@ void ath9k_tasklet(unsigned long data)
747 ath_tx_edma_tasklet(sc);
748 else
749 ath_tx_tasklet(sc);
750 +
751 + wake_up(&sc->tx_wait);
752 }
753
754 ath9k_btcoex_handle_interrupt(sc, status);
755 @@ -579,7 +598,8 @@ irqreturn_t ath_isr(int irq, void *dev)
756
757 goto chip_reset;
758 }
759 -#ifdef CONFIG_PM_SLEEP
760 +
761 +#ifdef CONFIG_ATH9K_WOW
762 if (status & ATH9K_INT_BMISS) {
763 if (atomic_read(&sc->wow_sleep_proc_intr) == 0) {
764 ath_dbg(common, ANY, "during WoW we got a BMISS\n");
765 @@ -588,6 +608,8 @@ irqreturn_t ath_isr(int irq, void *dev)
766 }
767 }
768 #endif
769 +
770 +
771 if (status & ATH9K_INT_SWBA)
772 tasklet_schedule(&sc->bcon_tasklet);
773
774 @@ -627,7 +649,7 @@ chip_reset:
775 #undef SCHED_INTR
776 }
777
778 -static int ath_reset(struct ath_softc *sc)
779 +int ath_reset(struct ath_softc *sc)
780 {
781 int r;
782
783 @@ -1817,13 +1839,31 @@ static void ath9k_set_coverage_class(str
784 mutex_unlock(&sc->mutex);
785 }
786
787 +static bool ath9k_has_tx_pending(struct ath_softc *sc)
788 +{
789 + int i, npend;
790 +
791 + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
792 + if (!ATH_TXQ_SETUP(sc, i))
793 + continue;
794 +
795 + if (!sc->tx.txq[i].axq_depth)
796 + continue;
797 +
798 + npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
799 + if (npend)
800 + break;
801 + }
802 +
803 + return !!npend;
804 +}
805 +
806 static void ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
807 {
808 struct ath_softc *sc = hw->priv;
809 struct ath_hw *ah = sc->sc_ah;
810 struct ath_common *common = ath9k_hw_common(ah);
811 - int timeout = 200; /* ms */
812 - int i, j;
813 + int timeout = HZ / 5; /* 200 ms */
814 bool drain_txq;
815
816 mutex_lock(&sc->mutex);
817 @@ -1841,25 +1881,9 @@ static void ath9k_flush(struct ieee80211
818 return;
819 }
820
821 - for (j = 0; j < timeout; j++) {
822 - bool npend = false;
823 -
824 - if (j)
825 - usleep_range(1000, 2000);
826 -
827 - for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
828 - if (!ATH_TXQ_SETUP(sc, i))
829 - continue;
830 -
831 - npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
832 -
833 - if (npend)
834 - break;
835 - }
836 -
837 - if (!npend)
838 - break;
839 - }
840 + if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc),
841 + timeout) > 0)
842 + drop = false;
843
844 if (drop) {
845 ath9k_ps_wakeup(sc);
846 @@ -2021,333 +2045,6 @@ static int ath9k_get_antenna(struct ieee
847 return 0;
848 }
849
850 -#ifdef CONFIG_PM_SLEEP
851 -
852 -static void ath9k_wow_map_triggers(struct ath_softc *sc,
853 - struct cfg80211_wowlan *wowlan,
854 - u32 *wow_triggers)
855 -{
856 - if (wowlan->disconnect)
857 - *wow_triggers |= AH_WOW_LINK_CHANGE |
858 - AH_WOW_BEACON_MISS;
859 - if (wowlan->magic_pkt)
860 - *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
861 -
862 - if (wowlan->n_patterns)
863 - *wow_triggers |= AH_WOW_USER_PATTERN_EN;
864 -
865 - sc->wow_enabled = *wow_triggers;
866 -
867 -}
868 -
869 -static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
870 -{
871 - struct ath_hw *ah = sc->sc_ah;
872 - struct ath_common *common = ath9k_hw_common(ah);
873 - int pattern_count = 0;
874 - int i, byte_cnt;
875 - u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
876 - u8 dis_deauth_mask[MAX_PATTERN_SIZE];
877 -
878 - memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
879 - memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
880 -
881 - /*
882 - * Create Dissassociate / Deauthenticate packet filter
883 - *
884 - * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes
885 - * +--------------+----------+---------+--------+--------+----
886 - * + Frame Control+ Duration + DA + SA + BSSID +
887 - * +--------------+----------+---------+--------+--------+----
888 - *
889 - * The above is the management frame format for disassociate/
890 - * deauthenticate pattern, from this we need to match the first byte
891 - * of 'Frame Control' and DA, SA, and BSSID fields
892 - * (skipping 2nd byte of FC and Duration feild.
893 - *
894 - * Disassociate pattern
895 - * --------------------
896 - * Frame control = 00 00 1010
897 - * DA, SA, BSSID = x:x:x:x:x:x
898 - * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
899 - * | x:x:x:x:x:x -- 22 bytes
900 - *
901 - * Deauthenticate pattern
902 - * ----------------------
903 - * Frame control = 00 00 1100
904 - * DA, SA, BSSID = x:x:x:x:x:x
905 - * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
906 - * | x:x:x:x:x:x -- 22 bytes
907 - */
908 -
909 - /* Create Disassociate Pattern first */
910 -
911 - byte_cnt = 0;
912 -
913 - /* Fill out the mask with all FF's */
914 -
915 - for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
916 - dis_deauth_mask[i] = 0xff;
917 -
918 - /* copy the first byte of frame control field */
919 - dis_deauth_pattern[byte_cnt] = 0xa0;
920 - byte_cnt++;
921 -
922 - /* skip 2nd byte of frame control and Duration field */
923 - byte_cnt += 3;
924 -
925 - /*
926 - * need not match the destination mac address, it can be a broadcast
927 - * mac address or an unicast to this station
928 - */
929 - byte_cnt += 6;
930 -
931 - /* copy the source mac address */
932 - memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
933 -
934 - byte_cnt += 6;
935 -
936 - /* copy the bssid, its same as the source mac address */
937 -
938 - memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
939 -
940 - /* Create Disassociate pattern mask */
941 -
942 - dis_deauth_mask[0] = 0xfe;
943 - dis_deauth_mask[1] = 0x03;
944 - dis_deauth_mask[2] = 0xc0;
945 -
946 - ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
947 -
948 - ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
949 - pattern_count, byte_cnt);
950 -
951 - pattern_count++;
952 - /*
953 - * for de-authenticate pattern, only the first byte of the frame
954 - * control field gets changed from 0xA0 to 0xC0
955 - */
956 - dis_deauth_pattern[0] = 0xC0;
957 -
958 - ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
959 - pattern_count, byte_cnt);
960 -
961 -}
962 -
963 -static void ath9k_wow_add_pattern(struct ath_softc *sc,
964 - struct cfg80211_wowlan *wowlan)
965 -{
966 - struct ath_hw *ah = sc->sc_ah;
967 - struct ath9k_wow_pattern *wow_pattern = NULL;
968 - struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
969 - int mask_len;
970 - s8 i = 0;
971 -
972 - if (!wowlan->n_patterns)
973 - return;
974 -
975 - /*
976 - * Add the new user configured patterns
977 - */
978 - for (i = 0; i < wowlan->n_patterns; i++) {
979 -
980 - wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
981 -
982 - if (!wow_pattern)
983 - return;
984 -
985 - /*
986 - * TODO: convert the generic user space pattern to
987 - * appropriate chip specific/802.11 pattern.
988 - */
989 -
990 - mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
991 - memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
992 - memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
993 - memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
994 - patterns[i].pattern_len);
995 - memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
996 - wow_pattern->pattern_len = patterns[i].pattern_len;
997 -
998 - /*
999 - * just need to take care of deauth and disssoc pattern,
1000 - * make sure we don't overwrite them.
1001 - */
1002 -
1003 - ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
1004 - wow_pattern->mask_bytes,
1005 - i + 2,
1006 - wow_pattern->pattern_len);
1007 - kfree(wow_pattern);
1008 -
1009 - }
1010 -
1011 -}
1012 -
1013 -static int ath9k_suspend(struct ieee80211_hw *hw,
1014 - struct cfg80211_wowlan *wowlan)
1015 -{
1016 - struct ath_softc *sc = hw->priv;
1017 - struct ath_hw *ah = sc->sc_ah;
1018 - struct ath_common *common = ath9k_hw_common(ah);
1019 - u32 wow_triggers_enabled = 0;
1020 - int ret = 0;
1021 -
1022 - mutex_lock(&sc->mutex);
1023 -
1024 - ath_cancel_work(sc);
1025 - ath_stop_ani(sc);
1026 - del_timer_sync(&sc->rx_poll_timer);
1027 -
1028 - if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
1029 - ath_dbg(common, ANY, "Device not present\n");
1030 - ret = -EINVAL;
1031 - goto fail_wow;
1032 - }
1033 -
1034 - if (WARN_ON(!wowlan)) {
1035 - ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
1036 - ret = -EINVAL;
1037 - goto fail_wow;
1038 - }
1039 -
1040 - if (!device_can_wakeup(sc->dev)) {
1041 - ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
1042 - ret = 1;
1043 - goto fail_wow;
1044 - }
1045 -
1046 - /*
1047 - * none of the sta vifs are associated
1048 - * and we are not currently handling multivif
1049 - * cases, for instance we have to seperately
1050 - * configure 'keep alive frame' for each
1051 - * STA.
1052 - */
1053 -
1054 - if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1055 - ath_dbg(common, WOW, "None of the STA vifs are associated\n");
1056 - ret = 1;
1057 - goto fail_wow;
1058 - }
1059 -
1060 - if (sc->nvifs > 1) {
1061 - ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
1062 - ret = 1;
1063 - goto fail_wow;
1064 - }
1065 -
1066 - ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
1067 -
1068 - ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
1069 - wow_triggers_enabled);
1070 -
1071 - ath9k_ps_wakeup(sc);
1072 -
1073 - ath9k_stop_btcoex(sc);
1074 -
1075 - /*
1076 - * Enable wake up on recieving disassoc/deauth
1077 - * frame by default.
1078 - */
1079 - ath9k_wow_add_disassoc_deauth_pattern(sc);
1080 -
1081 - if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
1082 - ath9k_wow_add_pattern(sc, wowlan);
1083 -
1084 - spin_lock_bh(&sc->sc_pcu_lock);
1085 - /*
1086 - * To avoid false wake, we enable beacon miss interrupt only
1087 - * when we go to sleep. We save the current interrupt mask
1088 - * so we can restore it after the system wakes up
1089 - */
1090 - sc->wow_intr_before_sleep = ah->imask;
1091 - ah->imask &= ~ATH9K_INT_GLOBAL;
1092 - ath9k_hw_disable_interrupts(ah);
1093 - ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
1094 - ath9k_hw_set_interrupts(ah);
1095 - ath9k_hw_enable_interrupts(ah);
1096 -
1097 - spin_unlock_bh(&sc->sc_pcu_lock);
1098 -
1099 - /*
1100 - * we can now sync irq and kill any running tasklets, since we already
1101 - * disabled interrupts and not holding a spin lock
1102 - */
1103 - synchronize_irq(sc->irq);
1104 - tasklet_kill(&sc->intr_tq);
1105 -
1106 - ath9k_hw_wow_enable(ah, wow_triggers_enabled);
1107 -
1108 - ath9k_ps_restore(sc);
1109 - ath_dbg(common, ANY, "WoW enabled in ath9k\n");
1110 - atomic_inc(&sc->wow_sleep_proc_intr);
1111 -
1112 -fail_wow:
1113 - mutex_unlock(&sc->mutex);
1114 - return ret;
1115 -}
1116 -
1117 -static int ath9k_resume(struct ieee80211_hw *hw)
1118 -{
1119 - struct ath_softc *sc = hw->priv;
1120 - struct ath_hw *ah = sc->sc_ah;
1121 - struct ath_common *common = ath9k_hw_common(ah);
1122 - u32 wow_status;
1123 -
1124 - mutex_lock(&sc->mutex);
1125 -
1126 - ath9k_ps_wakeup(sc);
1127 -
1128 - spin_lock_bh(&sc->sc_pcu_lock);
1129 -
1130 - ath9k_hw_disable_interrupts(ah);
1131 - ah->imask = sc->wow_intr_before_sleep;
1132 - ath9k_hw_set_interrupts(ah);
1133 - ath9k_hw_enable_interrupts(ah);
1134 -
1135 - spin_unlock_bh(&sc->sc_pcu_lock);
1136 -
1137 - wow_status = ath9k_hw_wow_wakeup(ah);
1138 -
1139 - if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
1140 - /*
1141 - * some devices may not pick beacon miss
1142 - * as the reason they woke up so we add
1143 - * that here for that shortcoming.
1144 - */
1145 - wow_status |= AH_WOW_BEACON_MISS;
1146 - atomic_dec(&sc->wow_got_bmiss_intr);
1147 - ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
1148 - }
1149 -
1150 - atomic_dec(&sc->wow_sleep_proc_intr);
1151 -
1152 - if (wow_status) {
1153 - ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
1154 - ath9k_hw_wow_event_to_string(wow_status), wow_status);
1155 - }
1156 -
1157 - ath_restart_work(sc);
1158 - ath9k_start_btcoex(sc);
1159 -
1160 - ath9k_ps_restore(sc);
1161 - mutex_unlock(&sc->mutex);
1162 -
1163 - return 0;
1164 -}
1165 -
1166 -static void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1167 -{
1168 - struct ath_softc *sc = hw->priv;
1169 -
1170 - mutex_lock(&sc->mutex);
1171 - device_init_wakeup(sc->dev, 1);
1172 - device_set_wakeup_enable(sc->dev, enabled);
1173 - mutex_unlock(&sc->mutex);
1174 -}
1175 -
1176 -#endif
1177 static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
1178 {
1179 struct ath_softc *sc = hw->priv;
1180 @@ -2373,134 +2070,6 @@ static void ath9k_channel_switch_beacon(
1181 sc->csa_vif = vif;
1182 }
1183
1184 -static void ath9k_tx99_stop(struct ath_softc *sc)
1185 -{
1186 - struct ath_hw *ah = sc->sc_ah;
1187 - struct ath_common *common = ath9k_hw_common(ah);
1188 -
1189 - ath_drain_all_txq(sc);
1190 - ath_startrecv(sc);
1191 -
1192 - ath9k_hw_set_interrupts(ah);
1193 - ath9k_hw_enable_interrupts(ah);
1194 -
1195 - ieee80211_wake_queues(sc->hw);
1196 -
1197 - kfree_skb(sc->tx99_skb);
1198 - sc->tx99_skb = NULL;
1199 - sc->tx99_state = false;
1200 -
1201 - ath9k_hw_tx99_stop(sc->sc_ah);
1202 - ath_dbg(common, XMIT, "TX99 stopped\n");
1203 -}
1204 -
1205 -static struct sk_buff *ath9k_build_tx99_skb(struct ath_softc *sc)
1206 -{
1207 - static u8 PN9Data[] = {0xff, 0x87, 0xb8, 0x59, 0xb7, 0xa1, 0xcc, 0x24,
1208 - 0x57, 0x5e, 0x4b, 0x9c, 0x0e, 0xe9, 0xea, 0x50,
1209 - 0x2a, 0xbe, 0xb4, 0x1b, 0xb6, 0xb0, 0x5d, 0xf1,
1210 - 0xe6, 0x9a, 0xe3, 0x45, 0xfd, 0x2c, 0x53, 0x18,
1211 - 0x0c, 0xca, 0xc9, 0xfb, 0x49, 0x37, 0xe5, 0xa8,
1212 - 0x51, 0x3b, 0x2f, 0x61, 0xaa, 0x72, 0x18, 0x84,
1213 - 0x02, 0x23, 0x23, 0xab, 0x63, 0x89, 0x51, 0xb3,
1214 - 0xe7, 0x8b, 0x72, 0x90, 0x4c, 0xe8, 0xfb, 0xc0};
1215 - u32 len = 1200;
1216 - struct ieee80211_hw *hw = sc->hw;
1217 - struct ieee80211_hdr *hdr;
1218 - struct ieee80211_tx_info *tx_info;
1219 - struct sk_buff *skb;
1220 -
1221 - skb = alloc_skb(len, GFP_KERNEL);
1222 - if (!skb)
1223 - return NULL;
1224 -
1225 - skb_put(skb, len);
1226 -
1227 - memset(skb->data, 0, len);
1228 -
1229 - hdr = (struct ieee80211_hdr *)skb->data;
1230 - hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA);
1231 - hdr->duration_id = 0;
1232 -
1233 - memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
1234 - memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
1235 - memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
1236 -
1237 - hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
1238 -
1239 - tx_info = IEEE80211_SKB_CB(skb);
1240 - memset(tx_info, 0, sizeof(*tx_info));
1241 - tx_info->band = hw->conf.chandef.chan->band;
1242 - tx_info->flags = IEEE80211_TX_CTL_NO_ACK;
1243 - tx_info->control.vif = sc->tx99_vif;
1244 -
1245 - memcpy(skb->data + sizeof(*hdr), PN9Data, sizeof(PN9Data));
1246 -
1247 - return skb;
1248 -}
1249 -
1250 -void ath9k_tx99_deinit(struct ath_softc *sc)
1251 -{
1252 - ath_reset(sc);
1253 -
1254 - ath9k_ps_wakeup(sc);
1255 - ath9k_tx99_stop(sc);
1256 - ath9k_ps_restore(sc);
1257 -}
1258 -
1259 -int ath9k_tx99_init(struct ath_softc *sc)
1260 -{
1261 - struct ieee80211_hw *hw = sc->hw;
1262 - struct ath_hw *ah = sc->sc_ah;
1263 - struct ath_common *common = ath9k_hw_common(ah);
1264 - struct ath_tx_control txctl;
1265 - int r;
1266 -
1267 - if (sc->sc_flags & SC_OP_INVALID) {
1268 - ath_err(common,
1269 - "driver is in invalid state unable to use TX99");
1270 - return -EINVAL;
1271 - }
1272 -
1273 - sc->tx99_skb = ath9k_build_tx99_skb(sc);
1274 - if (!sc->tx99_skb)
1275 - return -ENOMEM;
1276 -
1277 - memset(&txctl, 0, sizeof(txctl));
1278 - txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
1279 -
1280 - ath_reset(sc);
1281 -
1282 - ath9k_ps_wakeup(sc);
1283 -
1284 - ath9k_hw_disable_interrupts(ah);
1285 - atomic_set(&ah->intr_ref_cnt, -1);
1286 - ath_drain_all_txq(sc);
1287 - ath_stoprecv(sc);
1288 -
1289 - sc->tx99_state = true;
1290 -
1291 - ieee80211_stop_queues(hw);
1292 -
1293 - if (sc->tx99_power == MAX_RATE_POWER + 1)
1294 - sc->tx99_power = MAX_RATE_POWER;
1295 -
1296 - ath9k_hw_tx99_set_txpower(ah, sc->tx99_power);
1297 - r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
1298 - if (r) {
1299 - ath_dbg(common, XMIT, "Failed to xmit TX99 skb\n");
1300 - return r;
1301 - }
1302 -
1303 - ath_dbg(common, XMIT, "TX99 xmit started using %d ( %ddBm)\n",
1304 - sc->tx99_power,
1305 - sc->tx99_power / 2);
1306 -
1307 - /* We leave the harware awake as it will be chugging on */
1308 -
1309 - return 0;
1310 -}
1311 -
1312 struct ieee80211_ops ath9k_ops = {
1313 .tx = ath9k_tx,
1314 .start = ath9k_start,
1315 @@ -2531,7 +2100,7 @@ struct ieee80211_ops ath9k_ops = {
1316 .set_antenna = ath9k_set_antenna,
1317 .get_antenna = ath9k_get_antenna,
1318
1319 -#ifdef CONFIG_PM_SLEEP
1320 +#ifdef CONFIG_ATH9K_WOW
1321 .suspend = ath9k_suspend,
1322 .resume = ath9k_resume,
1323 .set_wakeup = ath9k_set_wakeup,
1324 --- a/drivers/net/wireless/ath/ath9k/wow.c
1325 +++ b/drivers/net/wireless/ath/ath9k/wow.c
1326 @@ -1,5 +1,5 @@
1327 /*
1328 - * Copyright (c) 2012 Qualcomm Atheros, Inc.
1329 + * Copyright (c) 2013 Qualcomm Atheros, Inc.
1330 *
1331 * Permission to use, copy, modify, and/or distribute this software for any
1332 * purpose with or without fee is hereby granted, provided that the above
1333 @@ -14,409 +14,348 @@
1334 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1335 */
1336
1337 -#include <linux/export.h>
1338 #include "ath9k.h"
1339 -#include "reg.h"
1340 -#include "hw-ops.h"
1341
1342 -const char *ath9k_hw_wow_event_to_string(u32 wow_event)
1343 +static const struct wiphy_wowlan_support ath9k_wowlan_support = {
1344 + .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
1345 + .n_patterns = MAX_NUM_USER_PATTERN,
1346 + .pattern_min_len = 1,
1347 + .pattern_max_len = MAX_PATTERN_SIZE,
1348 +};
1349 +
1350 +static void ath9k_wow_map_triggers(struct ath_softc *sc,
1351 + struct cfg80211_wowlan *wowlan,
1352 + u32 *wow_triggers)
1353 {
1354 - if (wow_event & AH_WOW_MAGIC_PATTERN_EN)
1355 - return "Magic pattern";
1356 - if (wow_event & AH_WOW_USER_PATTERN_EN)
1357 - return "User pattern";
1358 - if (wow_event & AH_WOW_LINK_CHANGE)
1359 - return "Link change";
1360 - if (wow_event & AH_WOW_BEACON_MISS)
1361 - return "Beacon miss";
1362 + if (wowlan->disconnect)
1363 + *wow_triggers |= AH_WOW_LINK_CHANGE |
1364 + AH_WOW_BEACON_MISS;
1365 + if (wowlan->magic_pkt)
1366 + *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
1367 +
1368 + if (wowlan->n_patterns)
1369 + *wow_triggers |= AH_WOW_USER_PATTERN_EN;
1370 +
1371 + sc->wow_enabled = *wow_triggers;
1372
1373 - return "unknown reason";
1374 }
1375 -EXPORT_SYMBOL(ath9k_hw_wow_event_to_string);
1376
1377 -static void ath9k_hw_set_powermode_wow_sleep(struct ath_hw *ah)
1378 +static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
1379 {
1380 + struct ath_hw *ah = sc->sc_ah;
1381 struct ath_common *common = ath9k_hw_common(ah);
1382 + int pattern_count = 0;
1383 + int i, byte_cnt;
1384 + u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
1385 + u8 dis_deauth_mask[MAX_PATTERN_SIZE];
1386
1387 - REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
1388 + memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
1389 + memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
1390
1391 - /* set rx disable bit */
1392 - REG_WRITE(ah, AR_CR, AR_CR_RXD);
1393 + /*
1394 + * Create Dissassociate / Deauthenticate packet filter
1395 + *
1396 + * 2 bytes 2 byte 6 bytes 6 bytes 6 bytes
1397 + * +--------------+----------+---------+--------+--------+----
1398 + * + Frame Control+ Duration + DA + SA + BSSID +
1399 + * +--------------+----------+---------+--------+--------+----
1400 + *
1401 + * The above is the management frame format for disassociate/
1402 + * deauthenticate pattern, from this we need to match the first byte
1403 + * of 'Frame Control' and DA, SA, and BSSID fields
1404 + * (skipping 2nd byte of FC and Duration feild.
1405 + *
1406 + * Disassociate pattern
1407 + * --------------------
1408 + * Frame control = 00 00 1010
1409 + * DA, SA, BSSID = x:x:x:x:x:x
1410 + * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
1411 + * | x:x:x:x:x:x -- 22 bytes
1412 + *
1413 + * Deauthenticate pattern
1414 + * ----------------------
1415 + * Frame control = 00 00 1100
1416 + * DA, SA, BSSID = x:x:x:x:x:x
1417 + * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
1418 + * | x:x:x:x:x:x -- 22 bytes
1419 + */
1420
1421 - if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0, AH_WAIT_TIMEOUT)) {
1422 - ath_err(common, "Failed to stop Rx DMA in 10ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
1423 - REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
1424 - return;
1425 - }
1426 + /* Create Disassociate Pattern first */
1427
1428 - REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_ON_INT);
1429 -}
1430 + byte_cnt = 0;
1431
1432 -static void ath9k_wow_create_keep_alive_pattern(struct ath_hw *ah)
1433 -{
1434 - struct ath_common *common = ath9k_hw_common(ah);
1435 - u8 sta_mac_addr[ETH_ALEN], ap_mac_addr[ETH_ALEN];
1436 - u32 ctl[13] = {0};
1437 - u32 data_word[KAL_NUM_DATA_WORDS];
1438 - u8 i;
1439 - u32 wow_ka_data_word0;
1440 -
1441 - memcpy(sta_mac_addr, common->macaddr, ETH_ALEN);
1442 - memcpy(ap_mac_addr, common->curbssid, ETH_ALEN);
1443 -
1444 - /* set the transmit buffer */
1445 - ctl[0] = (KAL_FRAME_LEN | (MAX_RATE_POWER << 16));
1446 - ctl[1] = 0;
1447 - ctl[3] = 0xb; /* OFDM_6M hardware value for this rate */
1448 - ctl[4] = 0;
1449 - ctl[7] = (ah->txchainmask) << 2;
1450 - ctl[2] = 0xf << 16; /* tx_tries 0 */
1451 -
1452 - for (i = 0; i < KAL_NUM_DESC_WORDS; i++)
1453 - REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
1454 -
1455 - REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
1456 -
1457 - data_word[0] = (KAL_FRAME_TYPE << 2) | (KAL_FRAME_SUB_TYPE << 4) |
1458 - (KAL_TO_DS << 8) | (KAL_DURATION_ID << 16);
1459 - data_word[1] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
1460 - (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
1461 - data_word[2] = (sta_mac_addr[1] << 24) | (sta_mac_addr[0] << 16) |
1462 - (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
1463 - data_word[3] = (sta_mac_addr[5] << 24) | (sta_mac_addr[4] << 16) |
1464 - (sta_mac_addr[3] << 8) | (sta_mac_addr[2]);
1465 - data_word[4] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
1466 - (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
1467 - data_word[5] = (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
1468 -
1469 - if (AR_SREV_9462_20(ah)) {
1470 - /* AR9462 2.0 has an extra descriptor word (time based
1471 - * discard) compared to other chips */
1472 - REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + (12 * 4)), 0);
1473 - wow_ka_data_word0 = AR_WOW_TXBUF(13);
1474 - } else {
1475 - wow_ka_data_word0 = AR_WOW_TXBUF(12);
1476 - }
1477 + /* Fill out the mask with all FF's */
1478
1479 - for (i = 0; i < KAL_NUM_DATA_WORDS; i++)
1480 - REG_WRITE(ah, (wow_ka_data_word0 + i*4), data_word[i]);
1481 + for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
1482 + dis_deauth_mask[i] = 0xff;
1483
1484 -}
1485 + /* copy the first byte of frame control field */
1486 + dis_deauth_pattern[byte_cnt] = 0xa0;
1487 + byte_cnt++;
1488
1489 -void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
1490 - u8 *user_mask, int pattern_count,
1491 - int pattern_len)
1492 -{
1493 - int i;
1494 - u32 pattern_val, mask_val;
1495 - u32 set, clr;
1496 + /* skip 2nd byte of frame control and Duration field */
1497 + byte_cnt += 3;
1498
1499 - /* FIXME: should check count by querying the hardware capability */
1500 - if (pattern_count >= MAX_NUM_PATTERN)
1501 - return;
1502 + /*
1503 + * need not match the destination mac address, it can be a broadcast
1504 + * mac address or an unicast to this station
1505 + */
1506 + byte_cnt += 6;
1507
1508 - REG_SET_BIT(ah, AR_WOW_PATTERN, BIT(pattern_count));
1509 + /* copy the source mac address */
1510 + memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
1511
1512 - /* set the registers for pattern */
1513 - for (i = 0; i < MAX_PATTERN_SIZE; i += 4) {
1514 - memcpy(&pattern_val, user_pattern, 4);
1515 - REG_WRITE(ah, (AR_WOW_TB_PATTERN(pattern_count) + i),
1516 - pattern_val);
1517 - user_pattern += 4;
1518 - }
1519 + byte_cnt += 6;
1520
1521 - /* set the registers for mask */
1522 - for (i = 0; i < MAX_PATTERN_MASK_SIZE; i += 4) {
1523 - memcpy(&mask_val, user_mask, 4);
1524 - REG_WRITE(ah, (AR_WOW_TB_MASK(pattern_count) + i), mask_val);
1525 - user_mask += 4;
1526 - }
1527 + /* copy the bssid, its same as the source mac address */
1528
1529 - /* set the pattern length to be matched
1530 - *
1531 - * AR_WOW_LENGTH1_REG1
1532 - * bit 31:24 pattern 0 length
1533 - * bit 23:16 pattern 1 length
1534 - * bit 15:8 pattern 2 length
1535 - * bit 7:0 pattern 3 length
1536 - *
1537 - * AR_WOW_LENGTH1_REG2
1538 - * bit 31:24 pattern 4 length
1539 - * bit 23:16 pattern 5 length
1540 - * bit 15:8 pattern 6 length
1541 - * bit 7:0 pattern 7 length
1542 - *
1543 - * the below logic writes out the new
1544 - * pattern length for the corresponding
1545 - * pattern_count, while masking out the
1546 - * other fields
1547 - */
1548 + memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
1549
1550 - ah->wow_event_mask |= BIT(pattern_count + AR_WOW_PAT_FOUND_SHIFT);
1551 + /* Create Disassociate pattern mask */
1552
1553 - if (pattern_count < 4) {
1554 - /* Pattern 0-3 uses AR_WOW_LENGTH1 register */
1555 - set = (pattern_len & AR_WOW_LENGTH_MAX) <<
1556 - AR_WOW_LEN1_SHIFT(pattern_count);
1557 - clr = AR_WOW_LENGTH1_MASK(pattern_count);
1558 - REG_RMW(ah, AR_WOW_LENGTH1, set, clr);
1559 - } else {
1560 - /* Pattern 4-7 uses AR_WOW_LENGTH2 register */
1561 - set = (pattern_len & AR_WOW_LENGTH_MAX) <<
1562 - AR_WOW_LEN2_SHIFT(pattern_count);
1563 - clr = AR_WOW_LENGTH2_MASK(pattern_count);
1564 - REG_RMW(ah, AR_WOW_LENGTH2, set, clr);
1565 - }
1566 + dis_deauth_mask[0] = 0xfe;
1567 + dis_deauth_mask[1] = 0x03;
1568 + dis_deauth_mask[2] = 0xc0;
1569
1570 -}
1571 -EXPORT_SYMBOL(ath9k_hw_wow_apply_pattern);
1572 + ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
1573
1574 -u32 ath9k_hw_wow_wakeup(struct ath_hw *ah)
1575 -{
1576 - u32 wow_status = 0;
1577 - u32 val = 0, rval;
1578 + ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
1579 + pattern_count, byte_cnt);
1580
1581 + pattern_count++;
1582 /*
1583 - * read the WoW status register to know
1584 - * the wakeup reason
1585 + * for de-authenticate pattern, only the first byte of the frame
1586 + * control field gets changed from 0xA0 to 0xC0
1587 */
1588 - rval = REG_READ(ah, AR_WOW_PATTERN);
1589 - val = AR_WOW_STATUS(rval);
1590 + dis_deauth_pattern[0] = 0xC0;
1591
1592 - /*
1593 - * mask only the WoW events that we have enabled. Sometimes
1594 - * we have spurious WoW events from the AR_WOW_PATTERN
1595 - * register. This mask will clean it up.
1596 - */
1597 + ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
1598 + pattern_count, byte_cnt);
1599
1600 - val &= ah->wow_event_mask;
1601 +}
1602
1603 - if (val) {
1604 - if (val & AR_WOW_MAGIC_PAT_FOUND)
1605 - wow_status |= AH_WOW_MAGIC_PATTERN_EN;
1606 - if (AR_WOW_PATTERN_FOUND(val))
1607 - wow_status |= AH_WOW_USER_PATTERN_EN;
1608 - if (val & AR_WOW_KEEP_ALIVE_FAIL)
1609 - wow_status |= AH_WOW_LINK_CHANGE;
1610 - if (val & AR_WOW_BEACON_FAIL)
1611 - wow_status |= AH_WOW_BEACON_MISS;
1612 - }
1613 +static void ath9k_wow_add_pattern(struct ath_softc *sc,
1614 + struct cfg80211_wowlan *wowlan)
1615 +{
1616 + struct ath_hw *ah = sc->sc_ah;
1617 + struct ath9k_wow_pattern *wow_pattern = NULL;
1618 + struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1619 + int mask_len;
1620 + s8 i = 0;
1621 +
1622 + if (!wowlan->n_patterns)
1623 + return;
1624
1625 /*
1626 - * set and clear WOW_PME_CLEAR registers for the chip to
1627 - * generate next wow signal.
1628 - * disable D3 before accessing other registers ?
1629 + * Add the new user configured patterns
1630 */
1631 + for (i = 0; i < wowlan->n_patterns; i++) {
1632
1633 - /* do we need to check the bit value 0x01000000 (7-10) ?? */
1634 - REG_RMW(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_WOW_PME_CLR,
1635 - AR_PMCTRL_PWR_STATE_D1D3);
1636 + wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
1637
1638 - /*
1639 - * clear all events
1640 - */
1641 - REG_WRITE(ah, AR_WOW_PATTERN,
1642 - AR_WOW_CLEAR_EVENTS(REG_READ(ah, AR_WOW_PATTERN)));
1643 + if (!wow_pattern)
1644 + return;
1645
1646 - /*
1647 - * restore the beacon threshold to init value
1648 - */
1649 - REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
1650 + /*
1651 + * TODO: convert the generic user space pattern to
1652 + * appropriate chip specific/802.11 pattern.
1653 + */
1654
1655 - /*
1656 - * Restore the way the PCI-E reset, Power-On-Reset, external
1657 - * PCIE_POR_SHORT pins are tied to its original value.
1658 - * Previously just before WoW sleep, we untie the PCI-E
1659 - * reset to our Chip's Power On Reset so that any PCI-E
1660 - * reset from the bus will not reset our chip
1661 - */
1662 - if (ah->is_pciexpress)
1663 - ath9k_hw_configpcipowersave(ah, false);
1664 + mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
1665 + memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
1666 + memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
1667 + memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
1668 + patterns[i].pattern_len);
1669 + memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
1670 + wow_pattern->pattern_len = patterns[i].pattern_len;
1671 +
1672 + /*
1673 + * just need to take care of deauth and disssoc pattern,
1674 + * make sure we don't overwrite them.
1675 + */
1676 +
1677 + ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
1678 + wow_pattern->mask_bytes,
1679 + i + 2,
1680 + wow_pattern->pattern_len);
1681 + kfree(wow_pattern);
1682
1683 - ah->wow_event_mask = 0;
1684 + }
1685
1686 - return wow_status;
1687 }
1688 -EXPORT_SYMBOL(ath9k_hw_wow_wakeup);
1689
1690 -void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable)
1691 +int ath9k_suspend(struct ieee80211_hw *hw,
1692 + struct cfg80211_wowlan *wowlan)
1693 {
1694 - u32 wow_event_mask;
1695 - u32 set, clr;
1696 + struct ath_softc *sc = hw->priv;
1697 + struct ath_hw *ah = sc->sc_ah;
1698 + struct ath_common *common = ath9k_hw_common(ah);
1699 + u32 wow_triggers_enabled = 0;
1700 + int ret = 0;
1701
1702 - /*
1703 - * wow_event_mask is a mask to the AR_WOW_PATTERN register to
1704 - * indicate which WoW events we have enabled. The WoW events
1705 - * are from the 'pattern_enable' in this function and
1706 - * 'pattern_count' of ath9k_hw_wow_apply_pattern()
1707 - */
1708 - wow_event_mask = ah->wow_event_mask;
1709 + mutex_lock(&sc->mutex);
1710
1711 - /*
1712 - * Untie Power-on-Reset from the PCI-E-Reset. When we are in
1713 - * WOW sleep, we do want the Reset from the PCI-E to disturb
1714 - * our hw state
1715 - */
1716 - if (ah->is_pciexpress) {
1717 - /*
1718 - * we need to untie the internal POR (power-on-reset)
1719 - * to the external PCI-E reset. We also need to tie
1720 - * the PCI-E Phy reset to the PCI-E reset.
1721 - */
1722 - set = AR_WA_RESET_EN | AR_WA_POR_SHORT;
1723 - clr = AR_WA_UNTIE_RESET_EN | AR_WA_D3_L1_DISABLE;
1724 - REG_RMW(ah, AR_WA, set, clr);
1725 + ath_cancel_work(sc);
1726 + ath_stop_ani(sc);
1727 + del_timer_sync(&sc->rx_poll_timer);
1728 +
1729 + if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
1730 + ath_dbg(common, ANY, "Device not present\n");
1731 + ret = -EINVAL;
1732 + goto fail_wow;
1733 }
1734
1735 - /*
1736 - * set the power states appropriately and enable PME
1737 - */
1738 - set = AR_PMCTRL_HOST_PME_EN | AR_PMCTRL_PWR_PM_CTRL_ENA |
1739 - AR_PMCTRL_AUX_PWR_DET | AR_PMCTRL_WOW_PME_CLR;
1740 + if (WARN_ON(!wowlan)) {
1741 + ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
1742 + ret = -EINVAL;
1743 + goto fail_wow;
1744 + }
1745
1746 - /*
1747 - * set and clear WOW_PME_CLEAR registers for the chip
1748 - * to generate next wow signal.
1749 - */
1750 - REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
1751 - clr = AR_PMCTRL_WOW_PME_CLR;
1752 - REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
1753 + if (!device_can_wakeup(sc->dev)) {
1754 + ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
1755 + ret = 1;
1756 + goto fail_wow;
1757 + }
1758
1759 /*
1760 - * Setup for:
1761 - * - beacon misses
1762 - * - magic pattern
1763 - * - keep alive timeout
1764 - * - pattern matching
1765 + * none of the sta vifs are associated
1766 + * and we are not currently handling multivif
1767 + * cases, for instance we have to seperately
1768 + * configure 'keep alive frame' for each
1769 + * STA.
1770 */
1771
1772 - /*
1773 - * Program default values for pattern backoff, aifs/slot/KAL count,
1774 - * beacon miss timeout, KAL timeout, etc.
1775 - */
1776 - set = AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF);
1777 - REG_SET_BIT(ah, AR_WOW_PATTERN, set);
1778 + if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1779 + ath_dbg(common, WOW, "None of the STA vifs are associated\n");
1780 + ret = 1;
1781 + goto fail_wow;
1782 + }
1783 +
1784 + if (sc->nvifs > 1) {
1785 + ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
1786 + ret = 1;
1787 + goto fail_wow;
1788 + }
1789
1790 - set = AR_WOW_AIFS_CNT(AR_WOW_CNT_AIFS_CNT) |
1791 - AR_WOW_SLOT_CNT(AR_WOW_CNT_SLOT_CNT) |
1792 - AR_WOW_KEEP_ALIVE_CNT(AR_WOW_CNT_KA_CNT);
1793 - REG_SET_BIT(ah, AR_WOW_COUNT, set);
1794 -
1795 - if (pattern_enable & AH_WOW_BEACON_MISS)
1796 - set = AR_WOW_BEACON_TIMO;
1797 - /* We are not using beacon miss, program a large value */
1798 - else
1799 - set = AR_WOW_BEACON_TIMO_MAX;
1800 + ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
1801
1802 - REG_WRITE(ah, AR_WOW_BCN_TIMO, set);
1803 + ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
1804 + wow_triggers_enabled);
1805
1806 - /*
1807 - * Keep alive timo in ms except AR9280
1808 - */
1809 - if (!pattern_enable)
1810 - set = AR_WOW_KEEP_ALIVE_NEVER;
1811 - else
1812 - set = KAL_TIMEOUT * 32;
1813 + ath9k_ps_wakeup(sc);
1814
1815 - REG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, set);
1816 + ath9k_stop_btcoex(sc);
1817
1818 /*
1819 - * Keep alive delay in us. based on 'power on clock',
1820 - * therefore in usec
1821 + * Enable wake up on recieving disassoc/deauth
1822 + * frame by default.
1823 */
1824 - set = KAL_DELAY * 1000;
1825 - REG_WRITE(ah, AR_WOW_KEEP_ALIVE_DELAY, set);
1826 + ath9k_wow_add_disassoc_deauth_pattern(sc);
1827
1828 - /*
1829 - * Create keep alive pattern to respond to beacons
1830 - */
1831 - ath9k_wow_create_keep_alive_pattern(ah);
1832 + if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
1833 + ath9k_wow_add_pattern(sc, wowlan);
1834
1835 + spin_lock_bh(&sc->sc_pcu_lock);
1836 /*
1837 - * Configure MAC WoW Registers
1838 + * To avoid false wake, we enable beacon miss interrupt only
1839 + * when we go to sleep. We save the current interrupt mask
1840 + * so we can restore it after the system wakes up
1841 */
1842 - set = 0;
1843 - /* Send keep alive timeouts anyway */
1844 - clr = AR_WOW_KEEP_ALIVE_AUTO_DIS;
1845 -
1846 - if (pattern_enable & AH_WOW_LINK_CHANGE)
1847 - wow_event_mask |= AR_WOW_KEEP_ALIVE_FAIL;
1848 - else
1849 - set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
1850 + sc->wow_intr_before_sleep = ah->imask;
1851 + ah->imask &= ~ATH9K_INT_GLOBAL;
1852 + ath9k_hw_disable_interrupts(ah);
1853 + ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
1854 + ath9k_hw_set_interrupts(ah);
1855 + ath9k_hw_enable_interrupts(ah);
1856
1857 - set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
1858 - REG_RMW(ah, AR_WOW_KEEP_ALIVE, set, clr);
1859 + spin_unlock_bh(&sc->sc_pcu_lock);
1860
1861 /*
1862 - * we are relying on a bmiss failure. ensure we have
1863 - * enough threshold to prevent false positives
1864 + * we can now sync irq and kill any running tasklets, since we already
1865 + * disabled interrupts and not holding a spin lock
1866 */
1867 - REG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR,
1868 - AR_WOW_BMISSTHRESHOLD);
1869 + synchronize_irq(sc->irq);
1870 + tasklet_kill(&sc->intr_tq);
1871 +
1872 + ath9k_hw_wow_enable(ah, wow_triggers_enabled);
1873
1874 - set = 0;
1875 - clr = 0;
1876 + ath9k_ps_restore(sc);
1877 + ath_dbg(common, ANY, "WoW enabled in ath9k\n");
1878 + atomic_inc(&sc->wow_sleep_proc_intr);
1879
1880 - if (pattern_enable & AH_WOW_BEACON_MISS) {
1881 - set = AR_WOW_BEACON_FAIL_EN;
1882 - wow_event_mask |= AR_WOW_BEACON_FAIL;
1883 - } else {
1884 - clr = AR_WOW_BEACON_FAIL_EN;
1885 +fail_wow:
1886 + mutex_unlock(&sc->mutex);
1887 + return ret;
1888 +}
1889 +
1890 +int ath9k_resume(struct ieee80211_hw *hw)
1891 +{
1892 + struct ath_softc *sc = hw->priv;
1893 + struct ath_hw *ah = sc->sc_ah;
1894 + struct ath_common *common = ath9k_hw_common(ah);
1895 + u32 wow_status;
1896 +
1897 + mutex_lock(&sc->mutex);
1898 +
1899 + ath9k_ps_wakeup(sc);
1900 +
1901 + spin_lock_bh(&sc->sc_pcu_lock);
1902 +
1903 + ath9k_hw_disable_interrupts(ah);
1904 + ah->imask = sc->wow_intr_before_sleep;
1905 + ath9k_hw_set_interrupts(ah);
1906 + ath9k_hw_enable_interrupts(ah);
1907 +
1908 + spin_unlock_bh(&sc->sc_pcu_lock);
1909 +
1910 + wow_status = ath9k_hw_wow_wakeup(ah);
1911 +
1912 + if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
1913 + /*
1914 + * some devices may not pick beacon miss
1915 + * as the reason they woke up so we add
1916 + * that here for that shortcoming.
1917 + */
1918 + wow_status |= AH_WOW_BEACON_MISS;
1919 + atomic_dec(&sc->wow_got_bmiss_intr);
1920 + ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
1921 }
1922
1923 - REG_RMW(ah, AR_WOW_BCN_EN, set, clr);
1924 + atomic_dec(&sc->wow_sleep_proc_intr);
1925
1926 - set = 0;
1927 - clr = 0;
1928 - /*
1929 - * Enable the magic packet registers
1930 - */
1931 - if (pattern_enable & AH_WOW_MAGIC_PATTERN_EN) {
1932 - set = AR_WOW_MAGIC_EN;
1933 - wow_event_mask |= AR_WOW_MAGIC_PAT_FOUND;
1934 - } else {
1935 - clr = AR_WOW_MAGIC_EN;
1936 + if (wow_status) {
1937 + ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
1938 + ath9k_hw_wow_event_to_string(wow_status), wow_status);
1939 }
1940 - set |= AR_WOW_MAC_INTR_EN;
1941 - REG_RMW(ah, AR_WOW_PATTERN, set, clr);
1942
1943 - REG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B,
1944 - AR_WOW_PATTERN_SUPPORTED);
1945 + ath_restart_work(sc);
1946 + ath9k_start_btcoex(sc);
1947
1948 - /*
1949 - * Set the power states appropriately and enable PME
1950 - */
1951 - clr = 0;
1952 - set = AR_PMCTRL_PWR_STATE_D1D3 | AR_PMCTRL_HOST_PME_EN |
1953 - AR_PMCTRL_PWR_PM_CTRL_ENA;
1954 + ath9k_ps_restore(sc);
1955 + mutex_unlock(&sc->mutex);
1956
1957 - clr = AR_PCIE_PM_CTRL_ENA;
1958 - REG_RMW(ah, AR_PCIE_PM_CTRL, set, clr);
1959 + return 0;
1960 +}
1961
1962 - /*
1963 - * this is needed to prevent the chip waking up
1964 - * the host within 3-4 seconds with certain
1965 - * platform/BIOS. The fix is to enable
1966 - * D1 & D3 to match original definition and
1967 - * also match the OTP value. Anyway this
1968 - * is more related to SW WOW.
1969 - */
1970 - clr = AR_PMCTRL_PWR_STATE_D1D3;
1971 - REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
1972 +void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1973 +{
1974 + struct ath_softc *sc = hw->priv;
1975
1976 - set = AR_PMCTRL_PWR_STATE_D1D3_REAL;
1977 - REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
1978 + mutex_lock(&sc->mutex);
1979 + device_init_wakeup(sc->dev, 1);
1980 + device_set_wakeup_enable(sc->dev, enabled);
1981 + mutex_unlock(&sc->mutex);
1982 +}
1983
1984 - REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
1985 +void ath9k_init_wow(struct ieee80211_hw *hw)
1986 +{
1987 + struct ath_softc *sc = hw->priv;
1988
1989 - /* to bring down WOW power low margin */
1990 - set = BIT(13);
1991 - REG_SET_BIT(ah, AR_PCIE_PHY_REG3, set);
1992 - /* HW WoW */
1993 - clr = BIT(5);
1994 - REG_CLR_BIT(ah, AR_PCU_MISC_MODE3, clr);
1995 + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) &&
1996 + (sc->driver_data & ATH9K_PCI_WOW) &&
1997 + device_can_wakeup(sc->dev))
1998 + hw->wiphy->wowlan = &ath9k_wowlan_support;
1999
2000 - ath9k_hw_set_powermode_wow_sleep(ah);
2001 - ah->wow_event_mask = wow_event_mask;
2002 + atomic_set(&sc->wow_sleep_proc_intr, -1);
2003 + atomic_set(&sc->wow_got_bmiss_intr, -1);
2004 }
2005 -EXPORT_SYMBOL(ath9k_hw_wow_enable);
2006 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2007 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
2008 @@ -1786,6 +1786,9 @@ bool ath_drain_all_txq(struct ath_softc
2009 if (!ATH_TXQ_SETUP(sc, i))
2010 continue;
2011
2012 + if (!sc->tx.txq[i].axq_depth)
2013 + continue;
2014 +
2015 if (ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum))
2016 npend |= BIT(i);
2017 }
2018 @@ -2749,6 +2752,8 @@ void ath_tx_node_cleanup(struct ath_soft
2019 }
2020 }
2021
2022 +#ifdef CONFIG_ATH9K_TX99
2023 +
2024 int ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb,
2025 struct ath_tx_control *txctl)
2026 {
2027 @@ -2791,3 +2796,5 @@ int ath9k_tx99_send(struct ath_softc *sc
2028
2029 return 0;
2030 }
2031 +
2032 +#endif /* CONFIG_ATH9K_TX99 */
2033 --- a/drivers/net/wireless/ath/regd.c
2034 +++ b/drivers/net/wireless/ath/regd.c
2035 @@ -37,17 +37,17 @@ static int __ath_regd_init(struct ath_re
2036
2037 /* We enable active scan on these a case by case basis by regulatory domain */
2038 #define ATH9K_2GHZ_CH12_13 REG_RULE(2467-10, 2472+10, 40, 0, 20,\
2039 - NL80211_RRF_PASSIVE_SCAN)
2040 + NL80211_RRF_NO_IR)
2041 #define ATH9K_2GHZ_CH14 REG_RULE(2484-10, 2484+10, 40, 0, 20,\
2042 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
2043 + NL80211_RRF_NO_IR | NL80211_RRF_NO_OFDM)
2044
2045 /* We allow IBSS on these on a case by case basis by regulatory domain */
2046 #define ATH9K_5GHZ_5150_5350 REG_RULE(5150-10, 5350+10, 80, 0, 30,\
2047 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
2048 + NL80211_RRF_NO_IR)
2049 #define ATH9K_5GHZ_5470_5850 REG_RULE(5470-10, 5850+10, 80, 0, 30,\
2050 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
2051 + NL80211_RRF_NO_IR)
2052 #define ATH9K_5GHZ_5725_5850 REG_RULE(5725-10, 5850+10, 80, 0, 30,\
2053 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
2054 + NL80211_RRF_NO_IR)
2055
2056 #define ATH9K_2GHZ_ALL ATH9K_2GHZ_CH01_11, \
2057 ATH9K_2GHZ_CH12_13, \
2058 @@ -224,17 +224,16 @@ ath_reg_apply_beaconing_flags(struct wip
2059 * regulatory_hint().
2060 */
2061 if (!(reg_rule->flags &
2062 - NL80211_RRF_NO_IBSS))
2063 + NL80211_RRF_NO_IR))
2064 ch->flags &=
2065 - ~IEEE80211_CHAN_NO_IBSS;
2066 + ~IEEE80211_CHAN_NO_IR;
2067 if (!(reg_rule->flags &
2068 - NL80211_RRF_PASSIVE_SCAN))
2069 + NL80211_RRF_NO_IR))
2070 ch->flags &=
2071 - ~IEEE80211_CHAN_PASSIVE_SCAN;
2072 + ~IEEE80211_CHAN_NO_IR;
2073 } else {
2074 if (ch->beacon_found)
2075 - ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
2076 - IEEE80211_CHAN_PASSIVE_SCAN);
2077 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2078 }
2079 }
2080 }
2081 @@ -260,11 +259,11 @@ ath_reg_apply_active_scan_flags(struct w
2082 */
2083 if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2084 ch = &sband->channels[11]; /* CH 12 */
2085 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2086 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2087 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2088 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2089 ch = &sband->channels[12]; /* CH 13 */
2090 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2091 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2092 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2093 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2094 return;
2095 }
2096
2097 @@ -278,17 +277,17 @@ ath_reg_apply_active_scan_flags(struct w
2098 ch = &sband->channels[11]; /* CH 12 */
2099 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2100 if (!IS_ERR(reg_rule)) {
2101 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2102 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2103 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2104 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2105 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2106 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2107 }
2108
2109 ch = &sband->channels[12]; /* CH 13 */
2110 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2111 if (!IS_ERR(reg_rule)) {
2112 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2113 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2114 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2115 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2116 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2117 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2118 }
2119 }
2120
2121 @@ -320,8 +319,8 @@ static void ath_reg_apply_radar_flags(st
2122 */
2123 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2124 ch->flags |= IEEE80211_CHAN_RADAR |
2125 - IEEE80211_CHAN_NO_IBSS |
2126 - IEEE80211_CHAN_PASSIVE_SCAN;
2127 + IEEE80211_CHAN_NO_IR |
2128 + IEEE80211_CHAN_NO_IR;
2129 }
2130 }
2131
2132 --- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
2133 +++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
2134 @@ -812,7 +812,7 @@ static s32 brcmf_p2p_run_escan(struct br
2135 struct ieee80211_channel *chan = request->channels[i];
2136
2137 if (chan->flags & (IEEE80211_CHAN_RADAR |
2138 - IEEE80211_CHAN_PASSIVE_SCAN))
2139 + IEEE80211_CHAN_NO_IR))
2140 continue;
2141
2142 chanspecs[i] = channel_to_chanspec(&p2p->cfg->d11inf,
2143 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2144 +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2145 @@ -202,9 +202,9 @@ static struct ieee80211_supported_band _
2146
2147 /* This is to override regulatory domains defined in cfg80211 module (reg.c)
2148 * By default world regulatory domain defined in reg.c puts the flags
2149 - * NL80211_RRF_PASSIVE_SCAN and NL80211_RRF_NO_IBSS for 5GHz channels (for
2150 - * 36..48 and 149..165). With respect to these flags, wpa_supplicant doesn't
2151 - * start p2p operations on 5GHz channels. All the changes in world regulatory
2152 + * NL80211_RRF_NO_IR for 5GHz channels (for * 36..48 and 149..165).
2153 + * With respect to these flags, wpa_supplicant doesn't * start p2p
2154 + * operations on 5GHz channels. All the changes in world regulatory
2155 * domain are to be done here.
2156 */
2157 static const struct ieee80211_regdomain brcmf_regdom = {
2158 @@ -5197,10 +5197,10 @@ static s32 brcmf_construct_reginfo(struc
2159 if (channel & WL_CHAN_RADAR)
2160 band_chan_arr[index].flags |=
2161 (IEEE80211_CHAN_RADAR |
2162 - IEEE80211_CHAN_NO_IBSS);
2163 + IEEE80211_CHAN_NO_IR);
2164 if (channel & WL_CHAN_PASSIVE)
2165 band_chan_arr[index].flags |=
2166 - IEEE80211_CHAN_PASSIVE_SCAN;
2167 + IEEE80211_CHAN_NO_IR;
2168 }
2169 }
2170 if (!update)
2171 --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
2172 +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
2173 @@ -59,23 +59,20 @@
2174
2175 #define BRCM_2GHZ_2412_2462 REG_RULE(2412-10, 2462+10, 40, 0, 19, 0)
2176 #define BRCM_2GHZ_2467_2472 REG_RULE(2467-10, 2472+10, 20, 0, 19, \
2177 - NL80211_RRF_PASSIVE_SCAN | \
2178 - NL80211_RRF_NO_IBSS)
2179 + NL80211_RRF_NO_IR)
2180
2181 #define BRCM_5GHZ_5180_5240 REG_RULE(5180-10, 5240+10, 40, 0, 21, \
2182 - NL80211_RRF_PASSIVE_SCAN | \
2183 - NL80211_RRF_NO_IBSS)
2184 + NL80211_RRF_NO_IR)
2185 #define BRCM_5GHZ_5260_5320 REG_RULE(5260-10, 5320+10, 40, 0, 21, \
2186 - NL80211_RRF_PASSIVE_SCAN | \
2187 + NL80211_RRF_NO_IR | \
2188 NL80211_RRF_DFS | \
2189 - NL80211_RRF_NO_IBSS)
2190 + NL80211_RRF_NO_IR)
2191 #define BRCM_5GHZ_5500_5700 REG_RULE(5500-10, 5700+10, 40, 0, 21, \
2192 - NL80211_RRF_PASSIVE_SCAN | \
2193 + NL80211_RRF_NO_IR | \
2194 NL80211_RRF_DFS | \
2195 - NL80211_RRF_NO_IBSS)
2196 + NL80211_RRF_NO_IR)
2197 #define BRCM_5GHZ_5745_5825 REG_RULE(5745-10, 5825+10, 40, 0, 21, \
2198 - NL80211_RRF_PASSIVE_SCAN | \
2199 - NL80211_RRF_NO_IBSS)
2200 + NL80211_RRF_NO_IR)
2201
2202 static const struct ieee80211_regdomain brcms_regdom_x2 = {
2203 .n_reg_rules = 6,
2204 @@ -395,7 +392,7 @@ brcms_c_channel_set_chanspec(struct brcm
2205 brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false);
2206
2207 brcms_b_set_chanspec(wlc->hw, chanspec,
2208 - !!(ch->flags & IEEE80211_CHAN_PASSIVE_SCAN),
2209 + !!(ch->flags & IEEE80211_CHAN_NO_IR),
2210 &txpwr);
2211 }
2212
2213 @@ -657,8 +654,8 @@ static void brcms_reg_apply_radar_flags(
2214 */
2215 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2216 ch->flags |= IEEE80211_CHAN_RADAR |
2217 - IEEE80211_CHAN_NO_IBSS |
2218 - IEEE80211_CHAN_PASSIVE_SCAN;
2219 + IEEE80211_CHAN_NO_IR |
2220 + IEEE80211_CHAN_NO_IR;
2221 }
2222 }
2223
2224 @@ -688,14 +685,13 @@ brcms_reg_apply_beaconing_flags(struct w
2225 if (IS_ERR(rule))
2226 continue;
2227
2228 - if (!(rule->flags & NL80211_RRF_NO_IBSS))
2229 - ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
2230 - if (!(rule->flags & NL80211_RRF_PASSIVE_SCAN))
2231 + if (!(rule->flags & NL80211_RRF_NO_IR))
2232 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2233 + if (!(rule->flags & NL80211_RRF_NO_IR))
2234 ch->flags &=
2235 - ~IEEE80211_CHAN_PASSIVE_SCAN;
2236 + ~IEEE80211_CHAN_NO_IR;
2237 } else if (ch->beacon_found) {
2238 - ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
2239 - IEEE80211_CHAN_PASSIVE_SCAN);
2240 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2241 }
2242 }
2243 }
2244 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
2245 +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
2246 @@ -125,13 +125,13 @@ static struct ieee80211_channel brcms_2g
2247 CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS),
2248 CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS),
2249 CHAN2GHZ(12, 2467,
2250 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
2251 + IEEE80211_CHAN_NO_IR |
2252 IEEE80211_CHAN_NO_HT40PLUS),
2253 CHAN2GHZ(13, 2472,
2254 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
2255 + IEEE80211_CHAN_NO_IR |
2256 IEEE80211_CHAN_NO_HT40PLUS),
2257 CHAN2GHZ(14, 2484,
2258 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
2259 + IEEE80211_CHAN_NO_IR |
2260 IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS |
2261 IEEE80211_CHAN_NO_OFDM)
2262 };
2263 @@ -144,51 +144,51 @@ static struct ieee80211_channel brcms_5g
2264 CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS),
2265 /* UNII-2 */
2266 CHAN5GHZ(52,
2267 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2268 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2269 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2270 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2271 CHAN5GHZ(56,
2272 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2273 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2274 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2275 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2276 CHAN5GHZ(60,
2277 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2278 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2279 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2280 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2281 CHAN5GHZ(64,
2282 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2283 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2284 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2285 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2286 /* MID */
2287 CHAN5GHZ(100,
2288 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2289 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2290 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2291 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2292 CHAN5GHZ(104,
2293 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2294 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2295 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2296 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2297 CHAN5GHZ(108,
2298 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2299 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2300 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2301 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2302 CHAN5GHZ(112,
2303 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2304 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2305 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2306 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2307 CHAN5GHZ(116,
2308 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2309 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2310 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2311 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2312 CHAN5GHZ(120,
2313 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2314 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2315 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2316 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2317 CHAN5GHZ(124,
2318 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2319 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2320 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2321 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2322 CHAN5GHZ(128,
2323 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2324 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2325 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2326 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2327 CHAN5GHZ(132,
2328 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2329 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
2330 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2331 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
2332 CHAN5GHZ(136,
2333 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2334 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
2335 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2336 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
2337 CHAN5GHZ(140,
2338 - IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
2339 - IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS |
2340 + IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
2341 + IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS |
2342 IEEE80211_CHAN_NO_HT40MINUS),
2343 /* UNII-3 */
2344 CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS),
2345 --- a/drivers/net/wireless/cw1200/scan.c
2346 +++ b/drivers/net/wireless/cw1200/scan.c
2347 @@ -197,9 +197,9 @@ void cw1200_scan_work(struct work_struct
2348 if ((*it)->band != first->band)
2349 break;
2350 if (((*it)->flags ^ first->flags) &
2351 - IEEE80211_CHAN_PASSIVE_SCAN)
2352 + IEEE80211_CHAN_NO_IR)
2353 break;
2354 - if (!(first->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
2355 + if (!(first->flags & IEEE80211_CHAN_NO_IR) &&
2356 (*it)->max_power != first->max_power)
2357 break;
2358 }
2359 @@ -210,7 +210,7 @@ void cw1200_scan_work(struct work_struct
2360 else
2361 scan.max_tx_rate = WSM_TRANSMIT_RATE_1;
2362 scan.num_probes =
2363 - (first->flags & IEEE80211_CHAN_PASSIVE_SCAN) ? 0 : 2;
2364 + (first->flags & IEEE80211_CHAN_NO_IR) ? 0 : 2;
2365 scan.num_ssids = priv->scan.n_ssids;
2366 scan.ssids = &priv->scan.ssids[0];
2367 scan.num_channels = it - priv->scan.curr;
2368 @@ -233,7 +233,7 @@ void cw1200_scan_work(struct work_struct
2369 }
2370 for (i = 0; i < scan.num_channels; ++i) {
2371 scan.ch[i].number = priv->scan.curr[i]->hw_value;
2372 - if (priv->scan.curr[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN) {
2373 + if (priv->scan.curr[i]->flags & IEEE80211_CHAN_NO_IR) {
2374 scan.ch[i].min_chan_time = 50;
2375 scan.ch[i].max_chan_time = 100;
2376 } else {
2377 @@ -241,7 +241,7 @@ void cw1200_scan_work(struct work_struct
2378 scan.ch[i].max_chan_time = 25;
2379 }
2380 }
2381 - if (!(first->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
2382 + if (!(first->flags & IEEE80211_CHAN_NO_IR) &&
2383 priv->scan.output_power != first->max_power) {
2384 priv->scan.output_power = first->max_power;
2385 wsm_set_output_power(priv,
2386 --- a/drivers/net/wireless/ipw2x00/ipw2100.c
2387 +++ b/drivers/net/wireless/ipw2x00/ipw2100.c
2388 @@ -1934,10 +1934,10 @@ static int ipw2100_wdev_init(struct net_
2389 bg_band->channels[i].max_power = geo->bg[i].max_power;
2390 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
2391 bg_band->channels[i].flags |=
2392 - IEEE80211_CHAN_PASSIVE_SCAN;
2393 + IEEE80211_CHAN_NO_IR;
2394 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
2395 bg_band->channels[i].flags |=
2396 - IEEE80211_CHAN_NO_IBSS;
2397 + IEEE80211_CHAN_NO_IR;
2398 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
2399 bg_band->channels[i].flags |=
2400 IEEE80211_CHAN_RADAR;
2401 --- a/drivers/net/wireless/ipw2x00/ipw2200.c
2402 +++ b/drivers/net/wireless/ipw2x00/ipw2200.c
2403 @@ -11472,10 +11472,10 @@ static int ipw_wdev_init(struct net_devi
2404 bg_band->channels[i].max_power = geo->bg[i].max_power;
2405 if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
2406 bg_band->channels[i].flags |=
2407 - IEEE80211_CHAN_PASSIVE_SCAN;
2408 + IEEE80211_CHAN_NO_IR;
2409 if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
2410 bg_band->channels[i].flags |=
2411 - IEEE80211_CHAN_NO_IBSS;
2412 + IEEE80211_CHAN_NO_IR;
2413 if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
2414 bg_band->channels[i].flags |=
2415 IEEE80211_CHAN_RADAR;
2416 @@ -11511,10 +11511,10 @@ static int ipw_wdev_init(struct net_devi
2417 a_band->channels[i].max_power = geo->a[i].max_power;
2418 if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY)
2419 a_band->channels[i].flags |=
2420 - IEEE80211_CHAN_PASSIVE_SCAN;
2421 + IEEE80211_CHAN_NO_IR;
2422 if (geo->a[i].flags & LIBIPW_CH_NO_IBSS)
2423 a_band->channels[i].flags |=
2424 - IEEE80211_CHAN_NO_IBSS;
2425 + IEEE80211_CHAN_NO_IR;
2426 if (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT)
2427 a_band->channels[i].flags |=
2428 IEEE80211_CHAN_RADAR;
2429 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
2430 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
2431 @@ -1595,7 +1595,7 @@ il3945_get_channels_for_scan(struct il_p
2432 * and use long active_dwell time.
2433 */
2434 if (!is_active || il_is_channel_passive(ch_info) ||
2435 - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
2436 + (chan->flags & IEEE80211_CHAN_NO_IR)) {
2437 scan_ch->type = 0; /* passive */
2438 if (IL_UCODE_API(il->ucode_ver) == 1)
2439 scan_ch->active_dwell =
2440 --- a/drivers/net/wireless/iwlegacy/4965-mac.c
2441 +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
2442 @@ -805,7 +805,7 @@ il4965_get_channels_for_scan(struct il_p
2443 }
2444
2445 if (!is_active || il_is_channel_passive(ch_info) ||
2446 - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
2447 + (chan->flags & IEEE80211_CHAN_NO_IR))
2448 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
2449 else
2450 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
2451 --- a/drivers/net/wireless/iwlegacy/common.c
2452 +++ b/drivers/net/wireless/iwlegacy/common.c
2453 @@ -3447,10 +3447,10 @@ il_init_geos(struct il_priv *il)
2454
2455 if (il_is_channel_valid(ch)) {
2456 if (!(ch->flags & EEPROM_CHANNEL_IBSS))
2457 - geo_ch->flags |= IEEE80211_CHAN_NO_IBSS;
2458 + geo_ch->flags |= IEEE80211_CHAN_NO_IR;
2459
2460 if (!(ch->flags & EEPROM_CHANNEL_ACTIVE))
2461 - geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2462 + geo_ch->flags |= IEEE80211_CHAN_NO_IR;
2463
2464 if (ch->flags & EEPROM_CHANNEL_RADAR)
2465 geo_ch->flags |= IEEE80211_CHAN_RADAR;
2466 --- a/drivers/net/wireless/iwlegacy/debug.c
2467 +++ b/drivers/net/wireless/iwlegacy/debug.c
2468 @@ -567,12 +567,12 @@ il_dbgfs_channels_read(struct file *file
2469 flags & IEEE80211_CHAN_RADAR ?
2470 " (IEEE 802.11h required)" : "",
2471 ((channels[i].
2472 - flags & IEEE80211_CHAN_NO_IBSS) ||
2473 + flags & IEEE80211_CHAN_NO_IR) ||
2474 (channels[i].
2475 flags & IEEE80211_CHAN_RADAR)) ? "" :
2476 ", IBSS",
2477 channels[i].
2478 - flags & IEEE80211_CHAN_PASSIVE_SCAN ?
2479 + flags & IEEE80211_CHAN_NO_IR ?
2480 "passive only" : "active/passive");
2481 }
2482 supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ);
2483 @@ -594,12 +594,12 @@ il_dbgfs_channels_read(struct file *file
2484 flags & IEEE80211_CHAN_RADAR ?
2485 " (IEEE 802.11h required)" : "",
2486 ((channels[i].
2487 - flags & IEEE80211_CHAN_NO_IBSS) ||
2488 + flags & IEEE80211_CHAN_NO_IR) ||
2489 (channels[i].
2490 flags & IEEE80211_CHAN_RADAR)) ? "" :
2491 ", IBSS",
2492 channels[i].
2493 - flags & IEEE80211_CHAN_PASSIVE_SCAN ?
2494 + flags & IEEE80211_CHAN_NO_IR ?
2495 "passive only" : "active/passive");
2496 }
2497 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2498 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
2499 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
2500 @@ -352,12 +352,12 @@ static ssize_t iwl_dbgfs_channels_read(s
2501 channels[i].max_power,
2502 channels[i].flags & IEEE80211_CHAN_RADAR ?
2503 " (IEEE 802.11h required)" : "",
2504 - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
2505 + ((channels[i].flags & IEEE80211_CHAN_NO_IR)
2506 || (channels[i].flags &
2507 IEEE80211_CHAN_RADAR)) ? "" :
2508 ", IBSS",
2509 channels[i].flags &
2510 - IEEE80211_CHAN_PASSIVE_SCAN ?
2511 + IEEE80211_CHAN_NO_IR ?
2512 "passive only" : "active/passive");
2513 }
2514 supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
2515 @@ -375,12 +375,12 @@ static ssize_t iwl_dbgfs_channels_read(s
2516 channels[i].max_power,
2517 channels[i].flags & IEEE80211_CHAN_RADAR ?
2518 " (IEEE 802.11h required)" : "",
2519 - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
2520 + ((channels[i].flags & IEEE80211_CHAN_NO_IR)
2521 || (channels[i].flags &
2522 IEEE80211_CHAN_RADAR)) ? "" :
2523 ", IBSS",
2524 channels[i].flags &
2525 - IEEE80211_CHAN_PASSIVE_SCAN ?
2526 + IEEE80211_CHAN_NO_IR ?
2527 "passive only" : "active/passive");
2528 }
2529 ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
2530 --- a/drivers/net/wireless/iwlwifi/dvm/scan.c
2531 +++ b/drivers/net/wireless/iwlwifi/dvm/scan.c
2532 @@ -544,7 +544,7 @@ static int iwl_get_channels_for_scan(str
2533 channel = chan->hw_value;
2534 scan_ch->channel = cpu_to_le16(channel);
2535
2536 - if (!is_active || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
2537 + if (!is_active || (chan->flags & IEEE80211_CHAN_NO_IR))
2538 scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
2539 else
2540 scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
2541 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
2542 +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
2543 @@ -614,10 +614,10 @@ static int iwl_init_channel_map(struct d
2544 channel->flags = IEEE80211_CHAN_NO_HT40;
2545
2546 if (!(eeprom_ch->flags & EEPROM_CHANNEL_IBSS))
2547 - channel->flags |= IEEE80211_CHAN_NO_IBSS;
2548 + channel->flags |= IEEE80211_CHAN_NO_IR;
2549
2550 if (!(eeprom_ch->flags & EEPROM_CHANNEL_ACTIVE))
2551 - channel->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2552 + channel->flags |= IEEE80211_CHAN_NO_IR;
2553
2554 if (eeprom_ch->flags & EEPROM_CHANNEL_RADAR)
2555 channel->flags |= IEEE80211_CHAN_RADAR;
2556 --- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
2557 +++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
2558 @@ -223,10 +223,10 @@ static int iwl_init_channel_map(struct d
2559 channel->flags |= IEEE80211_CHAN_NO_160MHZ;
2560
2561 if (!(ch_flags & NVM_CHANNEL_IBSS))
2562 - channel->flags |= IEEE80211_CHAN_NO_IBSS;
2563 + channel->flags |= IEEE80211_CHAN_NO_IR;
2564
2565 if (!(ch_flags & NVM_CHANNEL_ACTIVE))
2566 - channel->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2567 + channel->flags |= IEEE80211_CHAN_NO_IR;
2568
2569 if (ch_flags & NVM_CHANNEL_RADAR)
2570 channel->flags |= IEEE80211_CHAN_RADAR;
2571 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
2572 +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
2573 @@ -192,7 +192,7 @@ static void iwl_mvm_scan_fill_channels(s
2574 for (i = 0; i < cmd->channel_count; i++) {
2575 chan->channel = cpu_to_le16(req->channels[i]->hw_value);
2576 chan->type = cpu_to_le32(type);
2577 - if (req->channels[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2578 + if (req->channels[i]->flags & IEEE80211_CHAN_NO_IR)
2579 chan->type &= cpu_to_le32(~SCAN_CHANNEL_TYPE_ACTIVE);
2580 chan->active_dwell = cpu_to_le16(active_dwell);
2581 chan->passive_dwell = cpu_to_le16(passive_dwell);
2582 @@ -642,7 +642,7 @@ static void iwl_build_channel_cfg(struct
2583 channels->iter_count[index] = cpu_to_le16(1);
2584 channels->iter_interval[index] = 0;
2585
2586 - if (!(s_band->channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
2587 + if (!(s_band->channels[i].flags & IEEE80211_CHAN_NO_IR))
2588 channels->type[index] |=
2589 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE);
2590
2591 --- a/drivers/net/wireless/mac80211_hwsim.c
2592 +++ b/drivers/net/wireless/mac80211_hwsim.c
2593 @@ -159,7 +159,7 @@ static const struct ieee80211_regdomain
2594 .reg_rules = {
2595 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
2596 REG_RULE(5725-10, 5850+10, 40, 0, 30,
2597 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2598 + NL80211_RRF_NO_IR),
2599 }
2600 };
2601
2602 @@ -1485,7 +1485,7 @@ static void hw_scan_work(struct work_str
2603 req->channels[hwsim->scan_chan_idx]->center_freq);
2604
2605 hwsim->tmp_chan = req->channels[hwsim->scan_chan_idx];
2606 - if (hwsim->tmp_chan->flags & IEEE80211_CHAN_PASSIVE_SCAN ||
2607 + if (hwsim->tmp_chan->flags & IEEE80211_CHAN_NO_IR ||
2608 !req->n_ssids) {
2609 dwell = 120;
2610 } else {
2611 --- a/drivers/net/wireless/mwifiex/cfg80211.c
2612 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
2613 @@ -50,24 +50,24 @@ static const struct ieee80211_regdomain
2614 REG_RULE(2412-10, 2462+10, 40, 3, 20, 0),
2615 /* Channel 12 - 13 */
2616 REG_RULE(2467-10, 2472+10, 20, 3, 20,
2617 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2618 + NL80211_RRF_NO_IR),
2619 /* Channel 14 */
2620 REG_RULE(2484-10, 2484+10, 20, 3, 20,
2621 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
2622 + NL80211_RRF_NO_IR |
2623 NL80211_RRF_NO_OFDM),
2624 /* Channel 36 - 48 */
2625 REG_RULE(5180-10, 5240+10, 40, 3, 20,
2626 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2627 + NL80211_RRF_NO_IR),
2628 /* Channel 149 - 165 */
2629 REG_RULE(5745-10, 5825+10, 40, 3, 20,
2630 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
2631 + NL80211_RRF_NO_IR),
2632 /* Channel 52 - 64 */
2633 REG_RULE(5260-10, 5320+10, 40, 3, 30,
2634 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
2635 + NL80211_RRF_NO_IR |
2636 NL80211_RRF_DFS),
2637 /* Channel 100 - 140 */
2638 REG_RULE(5500-10, 5700+10, 40, 3, 30,
2639 - NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
2640 + NL80211_RRF_NO_IR |
2641 NL80211_RRF_DFS),
2642 }
2643 };
2644 @@ -1968,7 +1968,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiph
2645 user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
2646 user_scan_cfg->chan_list[i].radio_type = chan->band;
2647
2648 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2649 + if (chan->flags & IEEE80211_CHAN_NO_IR)
2650 user_scan_cfg->chan_list[i].scan_type =
2651 MWIFIEX_SCAN_TYPE_PASSIVE;
2652 else
2653 --- a/drivers/net/wireless/mwifiex/scan.c
2654 +++ b/drivers/net/wireless/mwifiex/scan.c
2655 @@ -515,14 +515,14 @@ mwifiex_scan_create_channel_list(struct
2656 scan_chan_list[chan_idx].max_scan_time =
2657 cpu_to_le16((u16) user_scan_in->
2658 chan_list[0].scan_time);
2659 - else if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2660 + else if (ch->flags & IEEE80211_CHAN_NO_IR)
2661 scan_chan_list[chan_idx].max_scan_time =
2662 cpu_to_le16(adapter->passive_scan_time);
2663 else
2664 scan_chan_list[chan_idx].max_scan_time =
2665 cpu_to_le16(adapter->active_scan_time);
2666
2667 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2668 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2669 scan_chan_list[chan_idx].chan_scan_mode_bitmap
2670 |= MWIFIEX_PASSIVE_SCAN;
2671 else
2672 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h
2673 +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
2674 @@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_
2675 * @local: frame is not from mac80211
2676 */
2677 int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
2678 - bool local);
2679 + struct ieee80211_sta *sta, bool local);
2680
2681 /**
2682 * rt2x00queue_update_beacon - Send new beacon from mac80211
2683 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
2684 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
2685 @@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct r
2686 frag_skb->data, data_length, tx_info,
2687 (struct ieee80211_rts *)(skb->data));
2688
2689 - retval = rt2x00queue_write_tx_frame(queue, skb, true);
2690 + retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
2691 if (retval) {
2692 dev_kfree_skb_any(skb);
2693 rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
2694 @@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *h
2695 goto exit_fail;
2696 }
2697
2698 - if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
2699 + if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
2700 goto exit_fail;
2701
2702 /*
2703 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
2704 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
2705 @@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct
2706 }
2707
2708 int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
2709 - bool local)
2710 + struct ieee80211_sta *sta, bool local)
2711 {
2712 struct ieee80211_tx_info *tx_info;
2713 struct queue_entry *entry;
2714 @@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct da
2715 * after that we are free to use the skb->cb array
2716 * for our information.
2717 */
2718 - rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
2719 + rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
2720
2721 /*
2722 * All information is retrieved from the skb->cb array,
2723 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c
2724 +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c
2725 @@ -416,7 +416,7 @@ static int rtl8187_init_urbs(struct ieee
2726 struct rtl8187_rx_info *info;
2727 int ret = 0;
2728
2729 - while (skb_queue_len(&priv->rx_queue) < 16) {
2730 + while (skb_queue_len(&priv->rx_queue) < 32) {
2731 skb = __dev_alloc_skb(RTL8187_MAX_RX, GFP_KERNEL);
2732 if (!skb) {
2733 ret = -ENOMEM;
2734 --- a/drivers/net/wireless/rtlwifi/base.c
2735 +++ b/drivers/net/wireless/rtlwifi/base.c
2736 @@ -1078,8 +1078,8 @@ u8 rtl_is_special_data(struct ieee80211_
2737
2738 ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len +
2739 SNAP_SIZE + PROTOC_TYPE_SIZE);
2740 - ether_type = *(u16 *) ((u8 *) skb->data + mac_hdr_len + SNAP_SIZE);
2741 - /* ether_type = ntohs(ether_type); */
2742 + ether_type = be16_to_cpu(*(__be16 *)((u8 *)skb->data + mac_hdr_len +
2743 + SNAP_SIZE));
2744
2745 if (ETH_P_IP == ether_type) {
2746 if (IPPROTO_UDP == ip->protocol) {
2747 --- a/drivers/net/wireless/rtlwifi/regd.c
2748 +++ b/drivers/net/wireless/rtlwifi/regd.c
2749 @@ -59,30 +59,27 @@ static struct country_code_to_enum_rd al
2750 */
2751 #define RTL819x_2GHZ_CH12_13 \
2752 REG_RULE(2467-10, 2472+10, 40, 0, 20,\
2753 - NL80211_RRF_PASSIVE_SCAN)
2754 + NL80211_RRF_NO_IR)
2755
2756 #define RTL819x_2GHZ_CH14 \
2757 REG_RULE(2484-10, 2484+10, 40, 0, 20, \
2758 - NL80211_RRF_PASSIVE_SCAN | \
2759 + NL80211_RRF_NO_IR | \
2760 NL80211_RRF_NO_OFDM)
2761
2762 /* 5G chan 36 - chan 64*/
2763 #define RTL819x_5GHZ_5150_5350 \
2764 REG_RULE(5150-10, 5350+10, 40, 0, 30, \
2765 - NL80211_RRF_PASSIVE_SCAN | \
2766 - NL80211_RRF_NO_IBSS)
2767 + NL80211_RRF_NO_IR)
2768
2769 /* 5G chan 100 - chan 165*/
2770 #define RTL819x_5GHZ_5470_5850 \
2771 REG_RULE(5470-10, 5850+10, 40, 0, 30, \
2772 - NL80211_RRF_PASSIVE_SCAN | \
2773 - NL80211_RRF_NO_IBSS)
2774 + NL80211_RRF_NO_IR)
2775
2776 /* 5G chan 149 - chan 165*/
2777 #define RTL819x_5GHZ_5725_5850 \
2778 REG_RULE(5725-10, 5850+10, 40, 0, 30, \
2779 - NL80211_RRF_PASSIVE_SCAN | \
2780 - NL80211_RRF_NO_IBSS)
2781 + NL80211_RRF_NO_IR)
2782
2783 #define RTL819x_5GHZ_ALL \
2784 (RTL819x_5GHZ_5150_5350, RTL819x_5GHZ_5470_5850)
2785 @@ -185,16 +182,15 @@ static void _rtl_reg_apply_beaconing_fla
2786 *regulatory_hint().
2787 */
2788
2789 - if (!(reg_rule->flags & NL80211_RRF_NO_IBSS))
2790 - ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
2791 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2792 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2793 if (!(reg_rule->
2794 - flags & NL80211_RRF_PASSIVE_SCAN))
2795 + flags & NL80211_RRF_NO_IR))
2796 ch->flags &=
2797 - ~IEEE80211_CHAN_PASSIVE_SCAN;
2798 + ~IEEE80211_CHAN_NO_IR;
2799 } else {
2800 if (ch->beacon_found)
2801 - ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
2802 - IEEE80211_CHAN_PASSIVE_SCAN);
2803 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2804 }
2805 }
2806 }
2807 @@ -219,11 +215,11 @@ static void _rtl_reg_apply_active_scan_f
2808 */
2809 if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2810 ch = &sband->channels[11]; /* CH 12 */
2811 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2812 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2813 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2814 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2815 ch = &sband->channels[12]; /* CH 13 */
2816 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2817 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2818 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2819 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2820 return;
2821 }
2822
2823 @@ -237,17 +233,17 @@ static void _rtl_reg_apply_active_scan_f
2824 ch = &sband->channels[11]; /* CH 12 */
2825 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2826 if (!IS_ERR(reg_rule)) {
2827 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2828 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2829 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2830 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2831 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2832 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2833 }
2834
2835 ch = &sband->channels[12]; /* CH 13 */
2836 reg_rule = freq_reg_info(wiphy, ch->center_freq);
2837 if (!IS_ERR(reg_rule)) {
2838 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2839 - if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2840 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2841 + if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2842 + if (ch->flags & IEEE80211_CHAN_NO_IR)
2843 + ch->flags &= ~IEEE80211_CHAN_NO_IR;
2844 }
2845 }
2846
2847 @@ -284,8 +280,8 @@ static void _rtl_reg_apply_radar_flags(s
2848 */
2849 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2850 ch->flags |= IEEE80211_CHAN_RADAR |
2851 - IEEE80211_CHAN_NO_IBSS |
2852 - IEEE80211_CHAN_PASSIVE_SCAN;
2853 + IEEE80211_CHAN_NO_IR |
2854 + IEEE80211_CHAN_NO_IR;
2855 }
2856 }
2857
2858 --- a/drivers/net/wireless/ti/wl12xx/scan.c
2859 +++ b/drivers/net/wireless/ti/wl12xx/scan.c
2860 @@ -47,7 +47,7 @@ static int wl1271_get_scan_channels(stru
2861 * In active scans, we only scan channels not
2862 * marked as passive.
2863 */
2864 - (passive || !(flags & IEEE80211_CHAN_PASSIVE_SCAN))) {
2865 + (passive || !(flags & IEEE80211_CHAN_NO_IR))) {
2866 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
2867 req->channels[i]->band,
2868 req->channels[i]->center_freq);
2869 --- a/drivers/net/wireless/ti/wlcore/cmd.c
2870 +++ b/drivers/net/wireless/ti/wlcore/cmd.c
2871 @@ -1688,7 +1688,7 @@ int wlcore_cmd_regdomain_config_locked(s
2872
2873 if (channel->flags & (IEEE80211_CHAN_DISABLED |
2874 IEEE80211_CHAN_RADAR |
2875 - IEEE80211_CHAN_PASSIVE_SCAN))
2876 + IEEE80211_CHAN_NO_IR))
2877 continue;
2878
2879 ch_bit_idx = wlcore_get_reg_conf_ch_idx(b, ch);
2880 --- a/drivers/net/wireless/ti/wlcore/main.c
2881 +++ b/drivers/net/wireless/ti/wlcore/main.c
2882 @@ -91,8 +91,7 @@ static void wl1271_reg_notify(struct wip
2883 continue;
2884
2885 if (ch->flags & IEEE80211_CHAN_RADAR)
2886 - ch->flags |= IEEE80211_CHAN_NO_IBSS |
2887 - IEEE80211_CHAN_PASSIVE_SCAN;
2888 + ch->flags |= IEEE80211_CHAN_NO_IR;
2889
2890 }
2891
2892 --- a/drivers/net/wireless/ti/wlcore/scan.c
2893 +++ b/drivers/net/wireless/ti/wlcore/scan.c
2894 @@ -189,14 +189,14 @@ wlcore_scan_get_channels(struct wl1271 *
2895 flags = req_channels[i]->flags;
2896
2897 if (force_passive)
2898 - flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2899 + flags |= IEEE80211_CHAN_NO_IR;
2900
2901 if ((req_channels[i]->band == band) &&
2902 !(flags & IEEE80211_CHAN_DISABLED) &&
2903 (!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
2904 /* if radar is set, we ignore the passive flag */
2905 (radar ||
2906 - !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
2907 + !!(flags & IEEE80211_CHAN_NO_IR) == passive)) {
2908
2909
2910 if (flags & IEEE80211_CHAN_RADAR) {
2911 @@ -221,7 +221,7 @@ wlcore_scan_get_channels(struct wl1271 *
2912 (band == IEEE80211_BAND_2GHZ) &&
2913 (channels[j].channel >= 12) &&
2914 (channels[j].channel <= 14) &&
2915 - (flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
2916 + (flags & IEEE80211_CHAN_NO_IR) &&
2917 !force_passive) {
2918 /* pactive channels treated as DFS */
2919 channels[j].flags = SCAN_CHANNEL_FLAGS_DFS;
2920 @@ -244,7 +244,7 @@ wlcore_scan_get_channels(struct wl1271 *
2921 max_dwell_time_active,
2922 flags & IEEE80211_CHAN_RADAR ?
2923 ", DFS" : "",
2924 - flags & IEEE80211_CHAN_PASSIVE_SCAN ?
2925 + flags & IEEE80211_CHAN_NO_IR ?
2926 ", PASSIVE" : "");
2927 j++;
2928 }
2929 --- a/include/net/cfg80211.h
2930 +++ b/include/net/cfg80211.h
2931 @@ -91,9 +91,8 @@ enum ieee80211_band {
2932 * Channel flags set by the regulatory control code.
2933 *
2934 * @IEEE80211_CHAN_DISABLED: This channel is disabled.
2935 - * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
2936 - * on this channel.
2937 - * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
2938 + * @IEEE80211_CHAN_NO_IR: do not initiate radiation, this includes
2939 + * sending probe requests or beaconing.
2940 * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
2941 * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel
2942 * is not permitted.
2943 @@ -113,8 +112,8 @@ enum ieee80211_band {
2944 */
2945 enum ieee80211_channel_flags {
2946 IEEE80211_CHAN_DISABLED = 1<<0,
2947 - IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
2948 - IEEE80211_CHAN_NO_IBSS = 1<<2,
2949 + IEEE80211_CHAN_NO_IR = 1<<1,
2950 + /* hole at 1<<2 */
2951 IEEE80211_CHAN_RADAR = 1<<3,
2952 IEEE80211_CHAN_NO_HT40PLUS = 1<<4,
2953 IEEE80211_CHAN_NO_HT40MINUS = 1<<5,
2954 @@ -4149,6 +4148,7 @@ void cfg80211_radar_event(struct wiphy *
2955 /**
2956 * cfg80211_cac_event - Channel availability check (CAC) event
2957 * @netdev: network device
2958 + * @chandef: chandef for the current channel
2959 * @event: type of event
2960 * @gfp: context flags
2961 *
2962 @@ -4157,6 +4157,7 @@ void cfg80211_radar_event(struct wiphy *
2963 * also by full-MAC drivers.
2964 */
2965 void cfg80211_cac_event(struct net_device *netdev,
2966 + const struct cfg80211_chan_def *chandef,
2967 enum nl80211_radar_event event, gfp_t gfp);
2968
2969
2970 --- a/include/uapi/linux/nl80211.h
2971 +++ b/include/uapi/linux/nl80211.h
2972 @@ -1508,6 +1508,9 @@ enum nl80211_commands {
2973 * to react to radar events, e.g. initiate a channel switch or leave the
2974 * IBSS network.
2975 *
2976 + * @NL80211_ATTR_SUPPORT_5_10_MHZ: A flag indicating that the device supports
2977 + * 5 MHz and 10 MHz channel bandwidth.
2978 + *
2979 * @NL80211_ATTR_MAX: highest attribute number currently defined
2980 * @__NL80211_ATTR_AFTER_LAST: internal use
2981 */
2982 @@ -1824,6 +1827,8 @@ enum nl80211_attrs {
2983
2984 NL80211_ATTR_HANDLE_DFS,
2985
2986 + NL80211_ATTR_SUPPORT_5_10_MHZ,
2987 +
2988 /* add attributes here, update the policy in nl80211.c */
2989
2990 __NL80211_ATTR_AFTER_LAST,
2991 @@ -2224,10 +2229,9 @@ enum nl80211_band_attr {
2992 * @NL80211_FREQUENCY_ATTR_FREQ: Frequency in MHz
2993 * @NL80211_FREQUENCY_ATTR_DISABLED: Channel is disabled in current
2994 * regulatory domain.
2995 - * @NL80211_FREQUENCY_ATTR_PASSIVE_SCAN: Only passive scanning is
2996 - * permitted on this channel in current regulatory domain.
2997 - * @NL80211_FREQUENCY_ATTR_NO_IBSS: IBSS networks are not permitted
2998 - * on this channel in current regulatory domain.
2999 + * @NL80211_FREQUENCY_ATTR_NO_IR: no mechanisms that initiate radiation
3000 + * are permitted on this channel, this includes sending probe
3001 + * requests, or modes of operation that require beaconing.
3002 * @NL80211_FREQUENCY_ATTR_RADAR: Radar detection is mandatory
3003 * on this channel in current regulatory domain.
3004 * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
3005 @@ -2254,8 +2258,8 @@ enum nl80211_frequency_attr {
3006 __NL80211_FREQUENCY_ATTR_INVALID,
3007 NL80211_FREQUENCY_ATTR_FREQ,
3008 NL80211_FREQUENCY_ATTR_DISABLED,
3009 - NL80211_FREQUENCY_ATTR_PASSIVE_SCAN,
3010 - NL80211_FREQUENCY_ATTR_NO_IBSS,
3011 + NL80211_FREQUENCY_ATTR_NO_IR,
3012 + __NL80211_FREQUENCY_ATTR_NO_IBSS,
3013 NL80211_FREQUENCY_ATTR_RADAR,
3014 NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
3015 NL80211_FREQUENCY_ATTR_DFS_STATE,
3016 @@ -2271,6 +2275,9 @@ enum nl80211_frequency_attr {
3017 };
3018
3019 #define NL80211_FREQUENCY_ATTR_MAX_TX_POWER NL80211_FREQUENCY_ATTR_MAX_TX_POWER
3020 +#define NL80211_FREQUENCY_ATTR_PASSIVE_SCAN NL80211_FREQUENCY_ATTR_NO_IR
3021 +#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
3022 +#define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
3023
3024 /**
3025 * enum nl80211_bitrate_attr - bitrate attributes
3026 @@ -2413,8 +2420,9 @@ enum nl80211_sched_scan_match_attr {
3027 * @NL80211_RRF_DFS: DFS support is required to be used
3028 * @NL80211_RRF_PTP_ONLY: this is only for Point To Point links
3029 * @NL80211_RRF_PTMP_ONLY: this is only for Point To Multi Point links
3030 - * @NL80211_RRF_PASSIVE_SCAN: passive scan is required
3031 - * @NL80211_RRF_NO_IBSS: no IBSS is allowed
3032 + * @NL80211_RRF_NO_IR: no mechanisms that initiate radiation are allowed,
3033 + * this includes probe requests or modes of operation that require
3034 + * beaconing.
3035 */
3036 enum nl80211_reg_rule_flags {
3037 NL80211_RRF_NO_OFDM = 1<<0,
3038 @@ -2424,10 +2432,17 @@ enum nl80211_reg_rule_flags {
3039 NL80211_RRF_DFS = 1<<4,
3040 NL80211_RRF_PTP_ONLY = 1<<5,
3041 NL80211_RRF_PTMP_ONLY = 1<<6,
3042 - NL80211_RRF_PASSIVE_SCAN = 1<<7,
3043 - NL80211_RRF_NO_IBSS = 1<<8,
3044 + NL80211_RRF_NO_IR = 1<<7,
3045 + __NL80211_RRF_NO_IBSS = 1<<8,
3046 };
3047
3048 +#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
3049 +#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
3050 +#define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
3051 +
3052 +/* For backport compatibility with older userspace */
3053 +#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
3054 +
3055 /**
3056 * enum nl80211_dfs_regions - regulatory DFS regions
3057 *
3058 --- a/net/mac80211/cfg.c
3059 +++ b/net/mac80211/cfg.c
3060 @@ -1050,6 +1050,7 @@ static int ieee80211_stop_ap(struct wiph
3061 struct ieee80211_local *local = sdata->local;
3062 struct beacon_data *old_beacon;
3063 struct probe_resp *old_probe_resp;
3064 + struct cfg80211_chan_def chandef;
3065
3066 old_beacon = rtnl_dereference(sdata->u.ap.beacon);
3067 if (!old_beacon)
3068 @@ -1091,8 +1092,10 @@ static int ieee80211_stop_ap(struct wiph
3069 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
3070
3071 if (sdata->wdev.cac_started) {
3072 + chandef = sdata->vif.bss_conf.chandef;
3073 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
3074 - cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
3075 + cfg80211_cac_event(sdata->dev, &chandef,
3076 + NL80211_RADAR_CAC_ABORTED,
3077 GFP_KERNEL);
3078 }
3079
3080 --- a/net/mac80211/iface.c
3081 +++ b/net/mac80211/iface.c
3082 @@ -749,6 +749,7 @@ static void ieee80211_do_stop(struct iee
3083 u32 hw_reconf_flags = 0;
3084 int i, flushed;
3085 struct ps_data *ps;
3086 + struct cfg80211_chan_def chandef;
3087
3088 clear_bit(SDATA_STATE_RUNNING, &sdata->state);
3089
3090 @@ -828,11 +829,13 @@ static void ieee80211_do_stop(struct iee
3091 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
3092
3093 if (sdata->wdev.cac_started) {
3094 + chandef = sdata->vif.bss_conf.chandef;
3095 WARN_ON(local->suspended);
3096 mutex_lock(&local->iflist_mtx);
3097 ieee80211_vif_release_channel(sdata);
3098 mutex_unlock(&local->iflist_mtx);
3099 - cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
3100 + cfg80211_cac_event(sdata->dev, &chandef,
3101 + NL80211_RADAR_CAC_ABORTED,
3102 GFP_KERNEL);
3103 }
3104
3105 @@ -1340,7 +1343,6 @@ static void ieee80211_setup_sdata(struct
3106 sdata->vif.bss_conf.bssid = NULL;
3107 break;
3108 case NL80211_IFTYPE_AP_VLAN:
3109 - break;
3110 case NL80211_IFTYPE_P2P_DEVICE:
3111 sdata->vif.bss_conf.bssid = sdata->vif.addr;
3112 break;
3113 --- a/net/mac80211/mlme.c
3114 +++ b/net/mac80211/mlme.c
3115 @@ -1398,10 +1398,12 @@ void ieee80211_dfs_cac_timer_work(struct
3116 struct ieee80211_sub_if_data *sdata =
3117 container_of(delayed_work, struct ieee80211_sub_if_data,
3118 dfs_cac_timer_work);
3119 + struct cfg80211_chan_def chandef = sdata->vif.bss_conf.chandef;
3120
3121 ieee80211_vif_release_channel(sdata);
3122 -
3123 - cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_FINISHED, GFP_KERNEL);
3124 + cfg80211_cac_event(sdata->dev, &chandef,
3125 + NL80211_RADAR_CAC_FINISHED,
3126 + GFP_KERNEL);
3127 }
3128
3129 /* MLME */
3130 --- a/net/mac80211/rx.c
3131 +++ b/net/mac80211/rx.c
3132 @@ -729,9 +729,7 @@ static void ieee80211_release_reorder_fr
3133 lockdep_assert_held(&tid_agg_rx->reorder_lock);
3134
3135 while (ieee80211_sn_less(tid_agg_rx->head_seq_num, head_seq_num)) {
3136 - index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3137 - tid_agg_rx->ssn) %
3138 - tid_agg_rx->buf_size;
3139 + index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3140 ieee80211_release_reorder_frame(sdata, tid_agg_rx, index,
3141 frames);
3142 }
3143 @@ -757,8 +755,7 @@ static void ieee80211_sta_reorder_releas
3144 lockdep_assert_held(&tid_agg_rx->reorder_lock);
3145
3146 /* release the buffer until next missing frame */
3147 - index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3148 - tid_agg_rx->ssn) % tid_agg_rx->buf_size;
3149 + index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3150 if (!tid_agg_rx->reorder_buf[index] &&
3151 tid_agg_rx->stored_mpdu_num) {
3152 /*
3153 @@ -793,15 +790,11 @@ static void ieee80211_sta_reorder_releas
3154 } else while (tid_agg_rx->reorder_buf[index]) {
3155 ieee80211_release_reorder_frame(sdata, tid_agg_rx, index,
3156 frames);
3157 - index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3158 - tid_agg_rx->ssn) %
3159 - tid_agg_rx->buf_size;
3160 + index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3161 }
3162
3163 if (tid_agg_rx->stored_mpdu_num) {
3164 - j = index = ieee80211_sn_sub(tid_agg_rx->head_seq_num,
3165 - tid_agg_rx->ssn) %
3166 - tid_agg_rx->buf_size;
3167 + j = index = tid_agg_rx->head_seq_num % tid_agg_rx->buf_size;
3168
3169 for (; j != (index - 1) % tid_agg_rx->buf_size;
3170 j = (j + 1) % tid_agg_rx->buf_size) {
3171 @@ -861,8 +854,7 @@ static bool ieee80211_sta_manage_reorder
3172
3173 /* Now the new frame is always in the range of the reordering buffer */
3174
3175 - index = ieee80211_sn_sub(mpdu_seq_num,
3176 - tid_agg_rx->ssn) % tid_agg_rx->buf_size;
3177 + index = mpdu_seq_num % tid_agg_rx->buf_size;
3178
3179 /* check if we already stored this frame */
3180 if (tid_agg_rx->reorder_buf[index]) {
3181 --- a/net/mac80211/scan.c
3182 +++ b/net/mac80211/scan.c
3183 @@ -526,7 +526,7 @@ static int __ieee80211_start_scan(struct
3184 ieee80211_hw_config(local, 0);
3185
3186 if ((req->channels[0]->flags &
3187 - IEEE80211_CHAN_PASSIVE_SCAN) ||
3188 + IEEE80211_CHAN_NO_IR) ||
3189 !local->scan_req->n_ssids) {
3190 next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
3191 } else {
3192 @@ -572,7 +572,7 @@ ieee80211_scan_get_channel_time(struct i
3193 * TODO: channel switching also consumes quite some time,
3194 * add that delay as well to get a better estimation
3195 */
3196 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
3197 + if (chan->flags & IEEE80211_CHAN_NO_IR)
3198 return IEEE80211_PASSIVE_CHANNEL_TIME;
3199 return IEEE80211_PROBE_DELAY + IEEE80211_CHANNEL_TIME;
3200 }
3201 @@ -696,7 +696,7 @@ static void ieee80211_scan_state_set_cha
3202 *
3203 * In any case, it is not necessary for a passive scan.
3204 */
3205 - if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN ||
3206 + if (chan->flags & IEEE80211_CHAN_NO_IR ||
3207 !local->scan_req->n_ssids) {
3208 *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
3209 local->next_scan_state = SCAN_DECISION;
3210 @@ -881,7 +881,7 @@ int ieee80211_request_ibss_scan(struct i
3211 struct ieee80211_channel *tmp_ch =
3212 &local->hw.wiphy->bands[band]->channels[i];
3213
3214 - if (tmp_ch->flags & (IEEE80211_CHAN_NO_IBSS |
3215 + if (tmp_ch->flags & (IEEE80211_CHAN_NO_IR |
3216 IEEE80211_CHAN_DISABLED))
3217 continue;
3218
3219 @@ -895,7 +895,7 @@ int ieee80211_request_ibss_scan(struct i
3220
3221 local->int_scan_req->n_channels = n_ch;
3222 } else {
3223 - if (WARN_ON_ONCE(chan->flags & (IEEE80211_CHAN_NO_IBSS |
3224 + if (WARN_ON_ONCE(chan->flags & (IEEE80211_CHAN_NO_IR |
3225 IEEE80211_CHAN_DISABLED)))
3226 goto unlock;
3227
3228 --- a/net/mac80211/tx.c
3229 +++ b/net/mac80211/tx.c
3230 @@ -1728,8 +1728,7 @@ netdev_tx_t ieee80211_monitor_start_xmit
3231 * radar detection by itself. We can do that later by adding a
3232 * monitor flag interfaces used for AP support.
3233 */
3234 - if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR |
3235 - IEEE80211_CHAN_PASSIVE_SCAN)))
3236 + if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)))
3237 goto fail_rcu;
3238
3239 ieee80211_xmit(sdata, skb, chan->band);
3240 --- a/net/mac80211/util.c
3241 +++ b/net/mac80211/util.c
3242 @@ -2259,14 +2259,17 @@ u64 ieee80211_calculate_rx_timestamp(str
3243 void ieee80211_dfs_cac_cancel(struct ieee80211_local *local)
3244 {
3245 struct ieee80211_sub_if_data *sdata;
3246 + struct cfg80211_chan_def chandef;
3247
3248 mutex_lock(&local->iflist_mtx);
3249 list_for_each_entry(sdata, &local->interfaces, list) {
3250 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
3251
3252 if (sdata->wdev.cac_started) {
3253 + chandef = sdata->vif.bss_conf.chandef;
3254 ieee80211_vif_release_channel(sdata);
3255 cfg80211_cac_event(sdata->dev,
3256 + &chandef,
3257 NL80211_RADAR_CAC_ABORTED,
3258 GFP_KERNEL);
3259 }
3260 --- a/net/wireless/chan.c
3261 +++ b/net/wireless/chan.c
3262 @@ -277,6 +277,32 @@ void cfg80211_set_dfs_state(struct wiphy
3263 width, dfs_state);
3264 }
3265
3266 +static u32 cfg80211_get_start_freq(u32 center_freq,
3267 + u32 bandwidth)
3268 +{
3269 + u32 start_freq;
3270 +
3271 + if (bandwidth <= 20)
3272 + start_freq = center_freq;
3273 + else
3274 + start_freq = center_freq - bandwidth/2 + 10;
3275 +
3276 + return start_freq;
3277 +}
3278 +
3279 +static u32 cfg80211_get_end_freq(u32 center_freq,
3280 + u32 bandwidth)
3281 +{
3282 + u32 end_freq;
3283 +
3284 + if (bandwidth <= 20)
3285 + end_freq = center_freq;
3286 + else
3287 + end_freq = center_freq + bandwidth/2 - 10;
3288 +
3289 + return end_freq;
3290 +}
3291 +
3292 static int cfg80211_get_chans_dfs_required(struct wiphy *wiphy,
3293 u32 center_freq,
3294 u32 bandwidth)
3295 @@ -284,13 +310,8 @@ static int cfg80211_get_chans_dfs_requir
3296 struct ieee80211_channel *c;
3297 u32 freq, start_freq, end_freq;
3298
3299 - if (bandwidth <= 20) {
3300 - start_freq = center_freq;
3301 - end_freq = center_freq;
3302 - } else {
3303 - start_freq = center_freq - bandwidth/2 + 10;
3304 - end_freq = center_freq + bandwidth/2 - 10;
3305 - }
3306 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3307 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3308
3309 for (freq = start_freq; freq <= end_freq; freq += 20) {
3310 c = ieee80211_get_channel(wiphy, freq);
3311 @@ -330,33 +351,159 @@ int cfg80211_chandef_dfs_required(struct
3312 }
3313 EXPORT_SYMBOL(cfg80211_chandef_dfs_required);
3314
3315 -static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
3316 - u32 center_freq, u32 bandwidth,
3317 - u32 prohibited_flags)
3318 +static int cfg80211_get_chans_dfs_usable(struct wiphy *wiphy,
3319 + u32 center_freq,
3320 + u32 bandwidth)
3321 {
3322 struct ieee80211_channel *c;
3323 u32 freq, start_freq, end_freq;
3324 + int count = 0;
3325
3326 - if (bandwidth <= 20) {
3327 - start_freq = center_freq;
3328 - end_freq = center_freq;
3329 - } else {
3330 - start_freq = center_freq - bandwidth/2 + 10;
3331 - end_freq = center_freq + bandwidth/2 - 10;
3332 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3333 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3334 +
3335 + /*
3336 + * Check entire range of channels for the bandwidth.
3337 + * Check all channels are DFS channels (DFS_USABLE or
3338 + * DFS_AVAILABLE). Return number of usable channels
3339 + * (require CAC). Allow DFS and non-DFS channel mix.
3340 + */
3341 + for (freq = start_freq; freq <= end_freq; freq += 20) {
3342 + c = ieee80211_get_channel(wiphy, freq);
3343 + if (!c)
3344 + return -EINVAL;
3345 +
3346 + if (c->flags & IEEE80211_CHAN_DISABLED)
3347 + return -EINVAL;
3348 +
3349 + if (c->flags & IEEE80211_CHAN_RADAR) {
3350 + if (c->dfs_state == NL80211_DFS_UNAVAILABLE)
3351 + return -EINVAL;
3352 +
3353 + if (c->dfs_state == NL80211_DFS_USABLE)
3354 + count++;
3355 + }
3356 + }
3357 +
3358 + return count;
3359 +}
3360 +
3361 +bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
3362 + const struct cfg80211_chan_def *chandef)
3363 +{
3364 + int width;
3365 + int r1, r2 = 0;
3366 +
3367 + if (WARN_ON(!cfg80211_chandef_valid(chandef)))
3368 + return false;
3369 +
3370 + width = cfg80211_chandef_get_width(chandef);
3371 + if (width < 0)
3372 + return false;
3373 +
3374 + r1 = cfg80211_get_chans_dfs_usable(wiphy, chandef->center_freq1,
3375 + width);
3376 +
3377 + if (r1 < 0)
3378 + return false;
3379 +
3380 + switch (chandef->width) {
3381 + case NL80211_CHAN_WIDTH_80P80:
3382 + WARN_ON(!chandef->center_freq2);
3383 + r2 = cfg80211_get_chans_dfs_usable(wiphy,
3384 + chandef->center_freq2,
3385 + width);
3386 + if (r2 < 0)
3387 + return false;
3388 + break;
3389 + default:
3390 + WARN_ON(chandef->center_freq2);
3391 + break;
3392 }
3393
3394 + return (r1 + r2 > 0);
3395 +}
3396 +
3397 +
3398 +static bool cfg80211_get_chans_dfs_available(struct wiphy *wiphy,
3399 + u32 center_freq,
3400 + u32 bandwidth)
3401 +{
3402 + struct ieee80211_channel *c;
3403 + u32 freq, start_freq, end_freq;
3404 +
3405 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3406 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3407 +
3408 + /*
3409 + * Check entire range of channels for the bandwidth.
3410 + * If any channel in between is disabled or has not
3411 + * had gone through CAC return false
3412 + */
3413 for (freq = start_freq; freq <= end_freq; freq += 20) {
3414 c = ieee80211_get_channel(wiphy, freq);
3415 if (!c)
3416 return false;
3417
3418 - /* check for radar flags */
3419 - if ((prohibited_flags & c->flags & IEEE80211_CHAN_RADAR) &&
3420 + if (c->flags & IEEE80211_CHAN_DISABLED)
3421 + return false;
3422 +
3423 + if ((c->flags & IEEE80211_CHAN_RADAR) &&
3424 (c->dfs_state != NL80211_DFS_AVAILABLE))
3425 return false;
3426 + }
3427 +
3428 + return true;
3429 +}
3430 +
3431 +static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy,
3432 + const struct cfg80211_chan_def *chandef)
3433 +{
3434 + int width;
3435 + int r;
3436 +
3437 + if (WARN_ON(!cfg80211_chandef_valid(chandef)))
3438 + return false;
3439
3440 - /* check for the other flags */
3441 - if (c->flags & prohibited_flags & ~IEEE80211_CHAN_RADAR)
3442 + width = cfg80211_chandef_get_width(chandef);
3443 + if (width < 0)
3444 + return false;
3445 +
3446 + r = cfg80211_get_chans_dfs_available(wiphy, chandef->center_freq1,
3447 + width);
3448 +
3449 + /* If any of channels unavailable for cf1 just return */
3450 + if (!r)
3451 + return r;
3452 +
3453 + switch (chandef->width) {
3454 + case NL80211_CHAN_WIDTH_80P80:
3455 + WARN_ON(!chandef->center_freq2);
3456 + r = cfg80211_get_chans_dfs_available(wiphy,
3457 + chandef->center_freq2,
3458 + width);
3459 + default:
3460 + WARN_ON(chandef->center_freq2);
3461 + break;
3462 + }
3463 +
3464 + return r;
3465 +}
3466 +
3467 +
3468 +static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
3469 + u32 center_freq, u32 bandwidth,
3470 + u32 prohibited_flags)
3471 +{
3472 + struct ieee80211_channel *c;
3473 + u32 freq, start_freq, end_freq;
3474 +
3475 + start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
3476 + end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
3477 +
3478 + for (freq = start_freq; freq <= end_freq; freq += 20) {
3479 + c = ieee80211_get_channel(wiphy, freq);
3480 + if (!c || c->flags & prohibited_flags)
3481 return false;
3482 }
3483
3484 @@ -462,14 +609,19 @@ bool cfg80211_reg_can_beacon(struct wiph
3485 struct cfg80211_chan_def *chandef)
3486 {
3487 bool res;
3488 + u32 prohibited_flags = IEEE80211_CHAN_DISABLED |
3489 + IEEE80211_CHAN_NO_IR |
3490 + IEEE80211_CHAN_RADAR;
3491
3492 trace_cfg80211_reg_can_beacon(wiphy, chandef);
3493
3494 - res = cfg80211_chandef_usable(wiphy, chandef,
3495 - IEEE80211_CHAN_DISABLED |
3496 - IEEE80211_CHAN_PASSIVE_SCAN |
3497 - IEEE80211_CHAN_NO_IBSS |
3498 - IEEE80211_CHAN_RADAR);
3499 + if (cfg80211_chandef_dfs_required(wiphy, chandef) > 0 &&
3500 + cfg80211_chandef_dfs_available(wiphy, chandef)) {
3501 + /* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */
3502 + prohibited_flags = IEEE80211_CHAN_DISABLED;
3503 + }
3504 +
3505 + res = cfg80211_chandef_usable(wiphy, chandef, prohibited_flags);
3506
3507 trace_cfg80211_return_bool(res);
3508 return res;
3509 --- a/net/wireless/core.h
3510 +++ b/net/wireless/core.h
3511 @@ -382,6 +382,19 @@ int cfg80211_can_use_iftype_chan(struct
3512 enum cfg80211_chan_mode chanmode,
3513 u8 radar_detect);
3514
3515 +/**
3516 + * cfg80211_chandef_dfs_usable - checks if chandef is DFS usable
3517 + * @wiphy: the wiphy to validate against
3518 + * @chandef: the channel definition to check
3519 + *
3520 + * Checks if chandef is usable and we can/need start CAC on such channel.
3521 + *
3522 + * Return: Return true if all channels available and at least
3523 + * one channel require CAC (NL80211_DFS_USABLE)
3524 + */
3525 +bool cfg80211_chandef_dfs_usable(struct wiphy *wiphy,
3526 + const struct cfg80211_chan_def *chandef);
3527 +
3528 void cfg80211_set_dfs_state(struct wiphy *wiphy,
3529 const struct cfg80211_chan_def *chandef,
3530 enum nl80211_dfs_state dfs_state);
3531 --- a/net/wireless/genregdb.awk
3532 +++ b/net/wireless/genregdb.awk
3533 @@ -107,10 +107,13 @@ active && /^[ \t]*\(/ {
3534 } else if (flagarray[arg] == "PTMP-ONLY") {
3535 flags = flags "\n\t\t\tNL80211_RRF_PTMP_ONLY | "
3536 } else if (flagarray[arg] == "PASSIVE-SCAN") {
3537 - flags = flags "\n\t\t\tNL80211_RRF_PASSIVE_SCAN | "
3538 + flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
3539 } else if (flagarray[arg] == "NO-IBSS") {
3540 - flags = flags "\n\t\t\tNL80211_RRF_NO_IBSS | "
3541 + flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
3542 + } else if (flagarray[arg] == "NO-IR") {
3543 + flags = flags "\n\t\t\tNL80211_RRF_NO_IR | "
3544 }
3545 +
3546 }
3547 flags = flags "0"
3548 printf "\t\tREG_RULE(%d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, flags
3549 --- a/net/wireless/ibss.c
3550 +++ b/net/wireless/ibss.c
3551 @@ -274,7 +274,7 @@ int cfg80211_ibss_wext_join(struct cfg80
3552
3553 for (i = 0; i < sband->n_channels; i++) {
3554 chan = &sband->channels[i];
3555 - if (chan->flags & IEEE80211_CHAN_NO_IBSS)
3556 + if (chan->flags & IEEE80211_CHAN_NO_IR)
3557 continue;
3558 if (chan->flags & IEEE80211_CHAN_DISABLED)
3559 continue;
3560 @@ -345,7 +345,7 @@ int cfg80211_ibss_wext_siwfreq(struct ne
3561 chan = ieee80211_get_channel(wdev->wiphy, freq);
3562 if (!chan)
3563 return -EINVAL;
3564 - if (chan->flags & IEEE80211_CHAN_NO_IBSS ||
3565 + if (chan->flags & IEEE80211_CHAN_NO_IR ||
3566 chan->flags & IEEE80211_CHAN_DISABLED)
3567 return -EINVAL;
3568 }
3569 --- a/net/wireless/mesh.c
3570 +++ b/net/wireless/mesh.c
3571 @@ -141,8 +141,7 @@ int __cfg80211_join_mesh(struct cfg80211
3572
3573 for (i = 0; i < sband->n_channels; i++) {
3574 chan = &sband->channels[i];
3575 - if (chan->flags & (IEEE80211_CHAN_NO_IBSS |
3576 - IEEE80211_CHAN_PASSIVE_SCAN |
3577 + if (chan->flags & (IEEE80211_CHAN_NO_IR |
3578 IEEE80211_CHAN_DISABLED |
3579 IEEE80211_CHAN_RADAR))
3580 continue;
3581 --- a/net/wireless/mlme.c
3582 +++ b/net/wireless/mlme.c
3583 @@ -763,12 +763,12 @@ void cfg80211_radar_event(struct wiphy *
3584 EXPORT_SYMBOL(cfg80211_radar_event);
3585
3586 void cfg80211_cac_event(struct net_device *netdev,
3587 + const struct cfg80211_chan_def *chandef,
3588 enum nl80211_radar_event event, gfp_t gfp)
3589 {
3590 struct wireless_dev *wdev = netdev->ieee80211_ptr;
3591 struct wiphy *wiphy = wdev->wiphy;
3592 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
3593 - struct cfg80211_chan_def chandef;