1 commit d4426800f71e972feaa33e04c5801fc730627bdd
2 Author: Stanislaw Gruszka <stf_xl@wp.pl>
3 Date: Mon Feb 10 22:38:28 2014 +0100
5 rtl8187: fix regression on MIPS without coherent DMA
7 This patch fixes regression caused by commit a16dad77634 "MIPS: Fix
8 potencial corruption". That commit fixes one corruption scenario in
9 cost of adding another one, which actually start to cause crashes
10 on Yeeloong laptop when rtl8187 driver is used.
12 For correct DMA read operation on machines without DMA coherence, kernel
13 have to invalidate cache, such it will refill later with new data that
14 device wrote to memory, when that data is needed to process. We can only
15 invalidate full cache line. Hence when cache line includes both dma
16 buffer and some other data (written in cache, but not yet in main
17 memory), the other data can not hit memory due to invalidation. That
18 happen on rtl8187 where struct rtl8187_priv fields are located just
19 before and after small buffers that are passed to USB layer and DMA
22 To fix the problem we align buffers and reserve space after them to make
23 them match cache line.
25 This patch does not resolve all possible MIPS problems entirely, for
26 that we have to assure that we always map cache aligned buffers for DMA,
27 what can be complex or even not possible. But patch fixes visible and
28 reproducible regression and seems other possible corruptions do not
29 happen in practice, since Yeeloong laptop works stable without rtl8187
33 https://bugzilla.kernel.org/show_bug.cgi?id=54391
35 Reported-by: Petr Pisar <petr.pisar@atlas.cz>
36 Bisected-by: Tom Li <biergaizi2009@gmail.com>
37 Reported-and-tested-by: Tom Li <biergaizi2009@gmail.com>
38 Cc: stable@vger.kernel.org
39 Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
41 commit e2f141d67ad1e7fe10aaab61811e8a409dfb2442
42 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
43 Date: Fri Feb 7 10:29:55 2014 +0530
45 ath9k: Calculate IQ-CAL median
47 This patch adds a routine to calculate the median IQ correction
48 values for AR955x, which is used for outlier detection.
49 The normal method which is used for all other chips is
52 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
54 commit c52a6fce0820c8d0687443ab86058ae03b478c8f
55 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
56 Date: Fri Feb 7 10:29:54 2014 +0530
58 ath9k: Expand the IQ coefficient array
60 This will be used for storing data for mutiple
61 IQ calibration runs, for AR955x.
63 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
65 commit 034969ff5c2b6431d10e07c1938f0b916da85cc3
66 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
67 Date: Fri Feb 7 10:29:53 2014 +0530
69 ath9k: Modify IQ calibration for AR955x
71 IQ calibration post-processing for AR955x is different
72 from other chips - instead of just doing it as part
73 of AGC calibration once, it is triggered 3 times and
74 a median is determined. This patch adds initial support
75 for changing the calibration behavior for AR955x.
77 Also, to simplify things, a helper routine to issue/poll
78 AGC calibration is used.
80 For non-AR955x chips, the iqcal_idx (which will be used
81 in subsequent patches) is set to zero.
83 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
85 commit 9b1ed6454e6f3511f24266be99b4e403f243f6a8
86 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
87 Date: Fri Feb 7 10:29:52 2014 +0530
89 ath9k: Fix magnitude/phase calculation
91 Incorrect values are programmed in the registers
92 containing the IQ correction coefficients by the IQ-CAL
93 post-processing code. Fix this.
95 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
97 commit 36f93484f96f79171dcecb67c5ef0c3de22531a6
98 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
99 Date: Fri Feb 7 10:29:51 2014 +0530
101 ath9k: Rename ar9003_hw_tx_iqcal_load_avg_2_passes
103 Use ar9003_hw_tx_iq_cal_outlier_detection instead.
105 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
107 commit 3af09a7f5d21dd5fd15b973ce6a91a575da30417
108 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
109 Date: Fri Feb 7 10:29:50 2014 +0530
111 ath9k: Check explicitly for IQ calibration
113 In chips like AR955x, the initvals contain the information
114 whether IQ calibration is to be done in the HW when an
115 AGC calibration is triggered. Check if IQ-CAL is enabled
116 in the initvals before flagging 'txiqcal_done' as true.
118 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
120 commit cb4969634b93c4643a32cc3fbd27d2b288b25771
121 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
122 Date: Fri Feb 7 10:29:49 2014 +0530
124 ath9k: Fix IQ cal post processing for SoC
126 Calibration data is not reused for SoC chips, so
127 call ar9003_hw_tx_iq_cal_post_proc() with the correct
128 argument. The 'is_reusable' flag is currently used
129 only for PC-OEM chips, but it makes things clearer to
130 specify it explicity.
132 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
134 commit e138e0ef9560c46ce93dbb22a728a57888e94d1c
135 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
136 Date: Mon Feb 3 13:31:37 2014 +0530
138 ath9k: Fix TX power calculation
140 The commit, "ath9k_hw: Fix incorrect Tx control power in AR9003 template"
141 fixed the incorrect values in the eeprom templates, but if
142 boards have already been calibrated with incorrect values,
143 they would still be using the wrong TX power. Fix this by assigning
144 a default value in such cases.
146 Cc: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
147 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
149 commit b9f268b5b01331c3c82179abca551429450e9417
150 Author: Michal Kazior <michal.kazior@tieto.com>
151 Date: Wed Jan 29 14:22:27 2014 +0100
153 cfg80211: consider existing DFS interfaces
155 It was possible to break interface combinations in
158 combo 1: iftype = AP, num_ifaces = 2, num_chans = 2,
159 combo 2: iftype = AP, num_ifaces = 1, num_chans = 1, radar = HT20
161 With the above interface combinations it was
164 step 1. start AP on DFS channel by matching combo 2
165 step 2. start AP on non-DFS channel by matching combo 1
167 This was possible beacuse (step 2) did not consider
168 if other interfaces require radar detection.
170 The patch changes how cfg80211 tracks channels -
171 instead of channel itself now a complete chandef
174 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
175 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
177 commit bc9c62f5f511cc395c62dbf4cdd437f23db53b28
178 Author: Antonio Quartulli <antonio@open-mesh.com>
179 Date: Wed Jan 29 17:53:43 2014 +0100
181 cfg80211: fix channel configuration in IBSS join
183 When receiving an IBSS_JOINED event select the BSS object
184 based on the {bssid, channel} couple rather than the bssid
186 With the current approach if another cell having the same
187 BSSID (but using a different channel) exists then cfg80211
188 picks up the wrong BSS object.
189 The result is a mismatching channel configuration between
190 cfg80211 and the driver, that can lead to any sort of
193 The issue can be triggered by having an IBSS sitting on
194 given channel and then asking the driver to create a new
195 cell using the same BSSID but with a different frequency.
196 By passing the channel to cfg80211_get_bss() we can solve
197 this ambiguity and retrieve/create the correct BSS object.
198 All the users of cfg80211_ibss_joined() have been changed
201 Moreover WARN when cfg80211_ibss_joined() gets a NULL
202 channel as argument and remove a bogus call of the same
203 function in ath6kl (it does not make sense to call
204 cfg80211_ibss_joined() with a zero BSSID on ibss-leave).
206 Cc: Kalle Valo <kvalo@qca.qualcomm.com>
207 Cc: Arend van Spriel <arend@broadcom.com>
208 Cc: Bing Zhao <bzhao@marvell.com>
209 Cc: Jussi Kivilinna <jussi.kivilinna@iki.fi>
210 Cc: libertas-dev@lists.infradead.org
211 Acked-by: Kalle Valo <kvalo@qca.qualcomm.com>
212 Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
213 [minor code cleanup in ath6kl]
214 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
216 commit 7e0c41cb41f215aba2c39b1c237bb4d42ec49a85
217 Author: Johannes Berg <johannes.berg@intel.com>
218 Date: Fri Jan 24 14:41:44 2014 +0100
220 mac80211: fix bufferable MMPDU RX handling
222 Action, disassoc and deauth frames are bufferable, and as such don't
223 have the PM bit in the frame control field reserved which means we
224 need to react to the bit when receiving in such a frame.
226 Fix this by introducing a new helper ieee80211_is_bufferable_mmpdu()
227 and using it for the RX path that currently ignores the PM bit in
228 any non-data frames for doze->wake transitions, but listens to it in
229 all frames for wake->doze transitions, both of which are wrong.
231 Also use the new helper in the TX path to clean up the code.
233 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
235 commit fc0df6d2343636e3f48a069330d5b972e3d8659d
236 Author: Janusz Dziedzic <janusz.dziedzic@tieto.com>
237 Date: Fri Jan 24 14:29:21 2014 +0100
239 cfg80211: set preset_chandef after channel switch
241 Set preset_chandef in channel switch notification.
242 In other case we will have old preset_chandef.
244 Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
245 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
247 commit cdec895e2344987ff171cece96e25d7407a3ebf6
248 Author: Simon Wunderlich <simon@open-mesh.com>
249 Date: Fri Jan 24 23:48:29 2014 +0100
251 mac80211: send ibss probe responses with noack flag
253 Responding to probe requests for scanning clients will often create
254 excessive retries, as it happens quite often that the scanning client
255 already left the channel. Therefore do it like hostapd and send probe
256 responses for wildcard SSID only once by using the noack flag.
258 Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
259 [fix typo & 'wildcard SSID' in commit log]
260 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
262 commit 0b865d1e6b9c05052adae9315df7cb195dc60c3b
263 Author: Luciano Coelho <luciano.coelho@intel.com>
264 Date: Tue Jan 28 17:09:08 2014 +0200
266 mac80211: ibss: remove unnecessary call to release channel
268 The ieee80211_vif_use_channel() function calls
269 ieee80211_vif_release_channel(), so there's no need to call it
270 explicitly in __ieee80211_sta_join_ibss().
272 Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
273 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
275 commit e1b6c17e971f0a51ff86c2dac2584c63cd999cd7
276 Author: Michal Kazior <michal.kazior@tieto.com>
277 Date: Wed Jan 29 07:56:21 2014 +0100
279 mac80211: add missing CSA locking
281 The patch adds a missing sdata lock and adds a few
282 lockdeps for easier maintenance.
284 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
285 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
287 commit ad17ba7d14d225b109b73c177cd446afb8050598
288 Author: Michal Kazior <michal.kazior@tieto.com>
289 Date: Wed Jan 29 07:56:20 2014 +0100
291 mac80211: fix sdata->radar_required locking
293 radar_required setting wasn't protected by
294 local->mtx in some places. This should prevent
295 from scanning/radar detection/roc colliding.
297 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
298 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
300 commit 5fcd5f1808813a3d9e502fd756e01bee8a79c85d
301 Author: Michal Kazior <michal.kazior@tieto.com>
302 Date: Wed Jan 29 07:56:19 2014 +0100
304 mac80211: move csa_active setting in STA CSA
306 The sdata->vif.csa_active could be left set after,
307 e.g. channel context constraints check fail in STA
308 mode leaving the interface in a strange state for
309 a brief period of time until it is disconnected.
310 This was harmless but ugly.
312 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
313 Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
314 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
316 commit e486da4b7eed71821c6b4c1bb9ac62ffd3ab13e9
317 Author: Michal Kazior <michal.kazior@tieto.com>
318 Date: Wed Jan 29 07:56:18 2014 +0100
320 mac80211: fix possible memory leak on AP CSA failure
322 If CSA for AP interface failed and the interface
323 was not stopped afterwards another CSA request
324 would leak sdata->u.ap.next_beacon.
326 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
327 Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
328 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
330 commit 3a77ba08940682bf3d52cf14f980337324af9d4a
331 Author: Johannes Berg <johannes.berg@intel.com>
332 Date: Sat Feb 1 00:33:29 2014 +0100
334 mac80211: fix fragmentation code, particularly for encryption
336 The "new" fragmentation code (since my rewrite almost 5 years ago)
337 erroneously sets skb->len rather than using skb_trim() to adjust
338 the length of the first fragment after copying out all the others.
339 This leaves the skb tail pointer pointing to after where the data
340 originally ended, and thus causes the encryption MIC to be written
341 at that point, rather than where it belongs: immediately after the
344 The impact of this is that if software encryption is done, then
345 a) encryption doesn't work for the first fragment, the connection
346 becomes unusable as the first fragment will never be properly
347 verified at the receiver, the MIC is practically guaranteed to
349 b) we leak up to 8 bytes of plaintext (!) of the packet out into
352 This is only mitigated by the fact that many devices are capable
353 of doing encryption in hardware, in which case this can't happen
354 as the tail pointer is irrelevant in that case. Additionally,
355 fragmentation is not used very frequently and would normally have
356 to be configured manually.
358 Fix this by using skb_trim() properly.
360 Cc: stable@vger.kernel.org
361 Fixes: 2de8e0d999b8 ("mac80211: rewrite fragmentation")
362 Reported-by: Jouni Malinen <j@w1.fi>
363 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
365 commit de5f242e0c10e841017e37eb8c38974a642dbca8
366 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
367 Date: Tue Jan 28 06:21:59 2014 +0530
369 ath9k: Fix build error on ARM
371 Use mdelay instead of udelay to fix this error:
373 ERROR: "__bad_udelay" [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!
374 make[1]: *** [__modpost] Error 1
375 make: *** [modules] Error 2
377 Reported-by: Josh Boyer <jwboyer@fedoraproject.org>
378 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
380 commit 8e3ea7a51dfc61810fcefd947f6edcf61125252a
381 Author: Geert Uytterhoeven <geert@linux-m68k.org>
382 Date: Sun Jan 26 11:53:21 2014 +0100
384 ath9k: Fix uninitialized variable in ath9k_has_tx_pending()
386 drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_has_tx_pending’:
387 drivers/net/wireless/ath/ath9k/main.c:1869: warning: ‘npend’ may be used uninitialized in this function
389 Introduced by commit 10e2318103f5941aa70c318afe34bc41f1b98529 ("ath9k:
390 optimize ath9k_flush").
392 Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
394 commit a4a634a6937ebdd827fa58e8fcdb8ca49a3769f6
395 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
396 Date: Mon Jan 27 11:07:42 2014 +0200
398 mac80211: release the channel in error path in start_ap
400 When the driver cannot start the AP or when the assignement
401 of the beacon goes wrong, we need to unassign the vif.
403 Cc: stable@vger.kernel.org
404 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
405 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
407 commit dfb6889a75c601aedb7450b7e606668e77da6679
408 Author: Johannes Berg <johannes.berg@intel.com>
409 Date: Wed Jan 22 11:14:19 2014 +0200
411 cfg80211: send scan results from work queue
413 Due to the previous commit, when a scan finishes, it is in theory
414 possible to hit the following sequence:
415 1. interface starts being removed
416 2. scan is cancelled by driver and cfg80211 is notified
417 3. scan done work is scheduled
418 4. interface is removed completely, rdev->scan_req is freed,
419 event sent to userspace but scan done work remains pending
420 5. new scan is requested on another virtual interface
421 6. scan done work runs, freeing the still-running scan
423 To fix this situation, hang on to the scan done message and block
424 new scans while that is the case, and only send the message from
425 the work function, regardless of whether the scan_req is already
426 freed from interface removal. This makes step 5 above impossible
427 and changes step 6 to be
428 5. scan done work runs, sending the scan done message
430 As this can't work for wext, so we send the message immediately,
431 but this shouldn't be an issue since we still return -EBUSY.
433 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
435 commit 45b7ab41fc08627d9a8428cb413d5d84662a9707
436 Author: Johannes Berg <johannes.berg@intel.com>
437 Date: Wed Jan 22 11:14:18 2014 +0200
439 cfg80211: fix scan done race
441 When an interface/wdev is removed, any ongoing scan should be
442 cancelled by the driver. This will make it call cfg80211, which
443 only queues a work struct. If interface/wdev removal is quick
444 enough, this can leave the scan request pending and processed
445 only after the interface is gone, causing a use-after-free.
447 Fix this by making sure the scan request is not pending after
448 the interface is destroyed. We can't flush or cancel the work
449 item due to locking concerns, but when it'll run it shouldn't
450 find anything to do. This leaves a potential issue, if a new
451 scan gets requested before the work runs, it prematurely stops
452 the running scan, potentially causing another crash. I'll fix
453 that in the next patch.
455 This was particularly observed with P2P_DEVICE wdevs, likely
456 because freeing them is quicker than freeing netdevs.
458 Reported-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
459 Fixes: 4a58e7c38443 ("cfg80211: don't "leak" uncompleted scans")
460 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
462 commit ae04fa489ab31b5a10d3cc8399f52761175d4321
463 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
464 Date: Thu Jan 23 14:28:16 2014 +0200
466 mac80211: avoid deadlock revealed by lockdep
468 sdata->u.ap.request_smps_work can’t be flushed synchronously
469 under wdev_lock(wdev) since ieee80211_request_smps_ap_work
470 itself locks the same lock.
471 While at it, reset the driver_smps_mode when the ap is
472 stopped to its default: OFF.
476 ======================================================
477 [ INFO: possible circular locking dependency detected ]
478 3.12.0-ipeer+ #2 Tainted: G O
479 -------------------------------------------------------
480 rmmod/2867 is trying to acquire lock:
481 ((&sdata->u.ap.request_smps_work)){+.+...}, at: [<c105b8d0>] flush_work+0x0/0x90
483 but task is already holding lock:
484 (&wdev->mtx){+.+.+.}, at: [<f9b32626>] cfg80211_stop_ap+0x26/0x230 [cfg80211]
486 which lock already depends on the new lock.
488 the existing dependency chain (in reverse order) is:
490 -> #1 (&wdev->mtx){+.+.+.}:
491 [<c10aefa9>] lock_acquire+0x79/0xe0
492 [<c1607a1a>] mutex_lock_nested+0x4a/0x360
493 [<fb06288b>] ieee80211_request_smps_ap_work+0x2b/0x50 [mac80211]
494 [<c105cdd8>] process_one_work+0x198/0x450
495 [<c105d469>] worker_thread+0xf9/0x320
496 [<c10669ff>] kthread+0x9f/0xb0
497 [<c1613397>] ret_from_kernel_thread+0x1b/0x28
499 -> #0 ((&sdata->u.ap.request_smps_work)){+.+...}:
500 [<c10ae9df>] __lock_acquire+0x183f/0x1910
501 [<c10aefa9>] lock_acquire+0x79/0xe0
502 [<c105b917>] flush_work+0x47/0x90
503 [<c105d867>] __cancel_work_timer+0x67/0xe0
504 [<c105d90f>] cancel_work_sync+0xf/0x20
505 [<fb0765cc>] ieee80211_stop_ap+0x8c/0x340 [mac80211]
506 [<f9b3268c>] cfg80211_stop_ap+0x8c/0x230 [cfg80211]
507 [<f9b0d8f9>] cfg80211_leave+0x79/0x100 [cfg80211]
508 [<f9b0da72>] cfg80211_netdev_notifier_call+0xf2/0x4f0 [cfg80211]
509 [<c160f2c9>] notifier_call_chain+0x59/0x130
510 [<c106c6de>] __raw_notifier_call_chain+0x1e/0x30
511 [<c106c70f>] raw_notifier_call_chain+0x1f/0x30
512 [<c14f8213>] call_netdevice_notifiers_info+0x33/0x70
513 [<c14f8263>] call_netdevice_notifiers+0x13/0x20
514 [<c14f82a4>] __dev_close_many+0x34/0xb0
515 [<c14f83fe>] dev_close_many+0x6e/0xc0
516 [<c14f9c77>] rollback_registered_many+0xa7/0x1f0
517 [<c14f9dd4>] unregister_netdevice_many+0x14/0x60
518 [<fb06f4d9>] ieee80211_remove_interfaces+0xe9/0x170 [mac80211]
519 [<fb055116>] ieee80211_unregister_hw+0x56/0x110 [mac80211]
520 [<fa3e9396>] iwl_op_mode_mvm_stop+0x26/0xe0 [iwlmvm]
521 [<f9b9d8ca>] _iwl_op_mode_stop+0x3a/0x70 [iwlwifi]
522 [<f9b9d96f>] iwl_opmode_deregister+0x6f/0x90 [iwlwifi]
523 [<fa405179>] __exit_compat+0xd/0x19 [iwlmvm]
524 [<c10b8bf9>] SyS_delete_module+0x179/0x2b0
525 [<c1613421>] sysenter_do_call+0x12/0x32
527 Fixes: 687da132234f ("mac80211: implement SMPS for AP")
528 Cc: <stable@vger.kernel.org> [3.13]
529 Reported-by: Ilan Peer <ilan.peer@intel.com>
530 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
531 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
533 commit 178b205e96217164fd7c30113464250d0b6f5eca
534 Author: Johannes Berg <johannes.berg@intel.com>
535 Date: Thu Jan 23 16:32:29 2014 +0100
537 cfg80211: re-enable 5/10 MHz support
539 Unfortunately I forgot this during the merge window, but the
540 patch seems small enough to go in as a fix. The userspace API
541 bug that was the reason for disabling it has long been fixed.
543 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
545 commit 110a1c79acda14edc83b7c8dc5af9c7ddd23eb61
546 Author: Pontus Fuchs <pontus.fuchs@gmail.com>
547 Date: Thu Jan 16 15:00:40 2014 +0100
549 nl80211: Reset split_start when netlink skb is exhausted
551 When the netlink skb is exhausted split_start is left set. In the
552 subsequent retry, with a larger buffer, the dump is continued from the
553 failing point instead of from the beginning.
555 This was causing my rt28xx based USB dongle to now show up when
556 running "iw list" with an old iw version without split dump support.
558 Cc: stable@vger.kernel.org
559 Fixes: 3713b4e364ef ("nl80211: allow splitting wiphy information in dumps")
560 Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
561 [avoid the entire workaround when state->split is set]
562 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
564 commit b4c31b45ffc7ef110fa9ecc34d7878fe7c5b9da4
565 Author: Eliad Peller <eliad@wizery.com>
566 Date: Sun Jan 12 11:06:37 2014 +0200
568 mac80211: move roc cookie assignment earlier
570 ieee80211_start_roc_work() might add a new roc
571 to existing roc, and tell cfg80211 it has already
574 However, this might happen before the roc cookie
575 was set, resulting in REMAIN_ON_CHANNEL (started)
576 event with null cookie. Consequently, it can make
577 wpa_supplicant go out of sync.
579 Fix it by setting the roc cookie earlier.
581 Cc: stable@vger.kernel.org
582 Signed-off-by: Eliad Peller <eliad@wizery.com>
583 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
585 commit cfdc9157bfd7bcf88ab4dae08873a9907eba984c
586 Author: Johannes Berg <johannes.berg@intel.com>
587 Date: Fri Jan 24 14:06:29 2014 +0100
589 nl80211: send event when AP operation is stopped
591 There are a few cases, e.g. suspend, where an AP interface is
592 stopped by the kernel rather than by userspace request, most
593 commonly when suspending. To let userspace know about this,
594 send the NL80211_CMD_STOP_AP command as an event every time
595 an AP interface is stopped. This also happens when userspace
596 did in fact request the AP stop, but that's not a problem.
598 For full-MAC drivers this may need to be extended to also
599 cover cases where the device stopped the AP operation for
600 some reason, this a bit more complicated because then all
601 cfg80211 state also needs to be reset; such API is not part
604 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
606 commit d5d567eda7704f190379ca852a8f9a4112e3eee3
607 Author: Johannes Berg <johannes.berg@intel.com>
608 Date: Thu Jan 23 16:20:29 2014 +0100
610 mac80211: add length check in ieee80211_is_robust_mgmt_frame()
612 A few places weren't checking that the frame passed to the
613 function actually has enough data even though the function
614 clearly documents it must have a payload byte. Make this
615 safer by changing the function to take an skb and checking
616 the length inside. The old version is preserved for now as
617 the rtl* drivers use it and don't have a correct skb.
619 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
621 commit f8f6d212a047fc65c7d3442dfc038f65517236fc
622 Author: Johannes Berg <johannes.berg@intel.com>
623 Date: Fri Jan 24 10:53:53 2014 +0100
625 nl80211: fix scheduled scan RSSI matchset attribute confusion
627 The scheduled scan matchsets were intended to be a list of filters,
628 with the found BSS having to pass at least one of them to be passed
629 to the host. When the RSSI attribute was added, however, this was
630 broken and currently wpa_supplicant adds that attribute in its own
631 matchset; however, it doesn't intend that to mean that anything
632 that passes the RSSI filter should be passed to the host, instead
633 it wants it to mean that everything needs to also have higher RSSI.
635 This is semantically problematic because we have a list of filters
636 like [ SSID1, SSID2, SSID3, RSSI ] with no real indication which
637 one should be OR'ed and which one AND'ed.
639 To fix this, move the RSSI filter attribute into each matchset. As
640 we need to stay backward compatible, treat a matchset with only the
641 RSSI attribute as a "default RSSI filter" for all other matchsets,
642 but only if there are other matchsets (an RSSI-only matchset by
643 itself is still desirable.)
645 To make driver implementation easier, keep a global min_rssi_thold
646 for the entire request as well. The only affected driver is ath6kl.
648 I found this when I looked into the code after Raja Mani submitted
649 a patch fixing the n_match_sets calculation to disregard the RSSI,
650 but that patch didn't address the semantic issue.
652 Reported-by: Raja Mani <rmani@qti.qualcomm.com>
653 Acked-by: Luciano Coelho <luciano.coelho@intel.com>
654 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
656 commit de553e8545e65a6dc4e45f43df7e1443d4291922
657 Author: Johannes Berg <johannes.berg@intel.com>
658 Date: Fri Jan 24 10:17:47 2014 +0100
660 nl80211: check nla_parse() return values
662 If there's a policy, then nla_parse() return values must be
663 checked, otherwise the policy is useless and there's nothing
664 that ensures the attributes are actually what we expect them
667 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
669 commit 652204a0733e9e1c54661d6f9d36e2e1e3b22bb1
670 Author: Karl Beldan <karl.beldan@rivierawaves.com>
671 Date: Thu Jan 23 20:06:34 2014 +0100
673 mac80211: send {ADD,DEL}BA on AC_VO like other mgmt frames, as per spec
675 ATM, {ADD,DEL}BA and BAR frames are sent on the AC matching the TID of
676 the BA parameters. In the discussion [1] about this patch, Johannes
677 recalled that it fixed some races with the DELBA and indeed this
678 behavior was introduced in [2].
679 While [2] is right for the BARs, the part queueing the {ADD,DEL}BAs on
680 their BA params TID AC violates the spec and is more a workaround for
681 some drivers. Helmut expressed some concerns wrt such drivers, in
682 particular DELBAs in rt2x00.
684 ATM, DELBAs are sent after a driver has called (hence "purposely")
685 ieee80211_start_tx_ba_cb_irqsafe and Johannes and Emmanuel gave some
686 details wrt intentions behind the split of the IEEE80211_AMPDU_TX_STOP_*
687 given to the driver ampdu_action supposed to call this function, which
688 could prove handy to people trying to do the right thing in faulty
689 drivers (if their fw/hw don't get in their way).
691 [1] http://mid.gmane.org/1390391564-18481-1-git-send-email-karl.beldan@gmail.com
692 [2] Commit: cf6bb79ad828 ("mac80211: Use appropriate TID for sending BAR, ADDBA and DELBA frames")
694 Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
695 Cc: Helmut Schaa <helmut.schaa@googlemail.com>
696 Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
697 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
698 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
699 +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
700 @@ -790,7 +790,7 @@ void ath6kl_cfg80211_connect_event(struc
701 if (nw_type & ADHOC_NETWORK) {
702 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "ad-hoc %s selected\n",
703 nw_type & ADHOC_CREATOR ? "creator" : "joiner");
704 - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
705 + cfg80211_ibss_joined(vif->ndev, bssid, chan, GFP_KERNEL);
706 cfg80211_put_bss(ar->wiphy, bss);
709 @@ -861,13 +861,9 @@ void ath6kl_cfg80211_disconnect_event(st
712 if (vif->nw_type & ADHOC_NETWORK) {
713 - if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC) {
714 + if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC)
715 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
716 "%s: ath6k not in ibss mode\n", __func__);
719 - memset(bssid, 0, ETH_ALEN);
720 - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
724 @@ -3256,6 +3252,15 @@ static int ath6kl_cfg80211_sscan_start(s
725 struct ath6kl_vif *vif = netdev_priv(dev);
728 + int n_match_sets = request->n_match_sets;
731 + * If there's a matchset w/o an SSID, then assume it's just for
732 + * the RSSI (nothing else is currently supported) and ignore it.
733 + * The device only supports a global RSSI filter that we set below.
735 + if (n_match_sets == 1 && !request->match_sets[0].ssid.ssid_len)
738 if (ar->state != ATH6KL_STATE_ON)
740 @@ -3268,11 +3273,11 @@ static int ath6kl_cfg80211_sscan_start(s
741 ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
744 - request->n_match_sets);
749 - if (!request->n_match_sets) {
750 + if (!n_match_sets) {
751 ret = ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
754 @@ -3286,12 +3291,12 @@ static int ath6kl_cfg80211_sscan_start(s
756 if (test_bit(ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD,
757 ar->fw_capabilities)) {
758 - if (request->rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
759 + if (request->min_rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
761 - else if (request->rssi_thold < -127)
762 + else if (request->min_rssi_thold < -127)
765 - rssi_thold = request->rssi_thold;
766 + rssi_thold = request->min_rssi_thold;
768 ret = ath6kl_wmi_set_rssi_filter_cmd(ar->wmi, vif->fw_vif_idx,
770 --- a/drivers/net/wireless/ath/ath9k/hw.c
771 +++ b/drivers/net/wireless/ath/ath9k/hw.c
772 @@ -1316,7 +1316,7 @@ static bool ath9k_hw_set_reset(struct at
773 if (AR_SREV_9300_20_OR_LATER(ah))
775 else if (AR_SREV_9100(ah))
781 @@ -2051,9 +2051,8 @@ static bool ath9k_hw_set_power_awake(str
783 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
784 AR_RTC_FORCE_WAKE_EN);
786 if (AR_SREV_9100(ah))
792 --- a/drivers/net/wireless/ath/ath9k/main.c
793 +++ b/drivers/net/wireless/ath/ath9k/main.c
794 @@ -1866,7 +1866,7 @@ static void ath9k_set_coverage_class(str
796 static bool ath9k_has_tx_pending(struct ath_softc *sc)
801 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
802 if (!ATH_TXQ_SETUP(sc, i))
803 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
804 +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
805 @@ -595,6 +595,9 @@ static void iwl_scan_offload_build_ssid(
808 for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) {
809 + /* skip empty SSID matchsets */
810 + if (!req->match_sets[i].ssid.ssid_len)
812 scan->direct_scan[i].id = WLAN_EID_SSID;
813 scan->direct_scan[i].len = req->match_sets[i].ssid.ssid_len;
814 memcpy(scan->direct_scan[i].ssid, req->match_sets[i].ssid.ssid,
815 --- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
816 +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
817 @@ -452,7 +452,7 @@ bool rtl88ee_rx_query_desc(struct ieee80
818 /* During testing, hdr was NULL */
821 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
822 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
823 (ieee80211_has_protected(hdr->frame_control)))
824 rx_status->flag &= ~RX_FLAG_DECRYPTED;
826 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
827 +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
828 @@ -393,7 +393,7 @@ bool rtl92ce_rx_query_desc(struct ieee80
829 /* In testing, hdr was NULL here */
832 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
833 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
834 (ieee80211_has_protected(hdr->frame_control)))
835 rx_status->flag &= ~RX_FLAG_DECRYPTED;
837 --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
838 +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
839 @@ -310,7 +310,7 @@ bool rtl92se_rx_query_desc(struct ieee80
840 /* during testing, hdr was NULL here */
843 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
844 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
845 (ieee80211_has_protected(hdr->frame_control)))
846 rx_status->flag &= ~RX_FLAG_DECRYPTED;
848 --- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
849 +++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
850 @@ -334,7 +334,7 @@ bool rtl8723ae_rx_query_desc(struct ieee
851 /* during testing, hdr could be NULL here */
854 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
855 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
856 (ieee80211_has_protected(hdr->frame_control)))
857 rx_status->flag &= ~RX_FLAG_DECRYPTED;
859 --- a/include/linux/ieee80211.h
860 +++ b/include/linux/ieee80211.h
861 @@ -597,6 +597,20 @@ static inline int ieee80211_is_qos_nullf
865 + * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
866 + * @fc: frame control field in little-endian byteorder
868 +static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
870 + /* IEEE 802.11-2012, definition of "bufferable management frame";
871 + * note that this ignores the IBSS special case. */
872 + return ieee80211_is_mgmt(fc) &&
873 + (ieee80211_is_action(fc) ||
874 + ieee80211_is_disassoc(fc) ||
875 + ieee80211_is_deauth(fc));
879 * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
880 * @seq_ctrl: frame sequence control bytes in little-endian byteorder
882 @@ -2192,10 +2206,10 @@ static inline u8 *ieee80211_get_DA(struc
886 - * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
887 + * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
888 * @hdr: the frame (buffer must include at least the first octet of payload)
890 -static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
891 +static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
893 if (ieee80211_is_disassoc(hdr->frame_control) ||
894 ieee80211_is_deauth(hdr->frame_control))
895 @@ -2224,6 +2238,17 @@ static inline bool ieee80211_is_robust_m
899 + * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
900 + * @skb: the skb containing the frame, length will be checked
902 +static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
906 + return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
910 * ieee80211_is_public_action - check if frame is a public action frame
912 * @len: length of the frame
913 --- a/include/net/cfg80211.h
914 +++ b/include/net/cfg80211.h
915 @@ -1395,9 +1395,11 @@ struct cfg80211_scan_request {
916 * struct cfg80211_match_set - sets of attributes to match
918 * @ssid: SSID to be matched
919 + * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
921 struct cfg80211_match_set {
922 struct cfg80211_ssid ssid;
927 @@ -1420,7 +1422,8 @@ struct cfg80211_match_set {
928 * @dev: the interface
929 * @scan_start: start time of the scheduled scan
930 * @channels: channels to scan
931 - * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
932 + * @min_rssi_thold: for drivers only supporting a single threshold, this
933 + * contains the minimum over all matchsets
935 struct cfg80211_sched_scan_request {
936 struct cfg80211_ssid *ssids;
937 @@ -1433,7 +1436,7 @@ struct cfg80211_sched_scan_request {
939 struct cfg80211_match_set *match_sets;
942 + s32 min_rssi_thold;
946 @@ -3130,8 +3133,8 @@ struct cfg80211_cached_keys;
947 * @identifier: (private) Identifier used in nl80211 to identify this
948 * wireless device if it has no netdev
949 * @current_bss: (private) Used by the internal configuration code
950 - * @channel: (private) Used by the internal configuration code to track
951 - * the user-set AP, monitor and WDS channel
952 + * @chandef: (private) Used by the internal configuration code to track
953 + * the user-set channel definition.
954 * @preset_chandef: (private) Used by the internal configuration code to
955 * track the channel to be used for AP later
956 * @bssid: (private) Used by the internal configuration code
957 @@ -3195,9 +3198,7 @@ struct wireless_dev {
959 struct cfg80211_internal_bss *current_bss; /* associated / joined */
960 struct cfg80211_chan_def preset_chandef;
962 - /* for AP and mesh channel tracking */
963 - struct ieee80211_channel *channel;
964 + struct cfg80211_chan_def chandef;
967 bool ibss_dfs_possible;
968 @@ -3879,6 +3880,7 @@ void cfg80211_michael_mic_failure(struct
970 * @dev: network device
971 * @bssid: the BSSID of the IBSS joined
972 + * @channel: the channel of the IBSS joined
973 * @gfp: allocation flags
975 * This function notifies cfg80211 that the device joined an IBSS or
976 @@ -3888,7 +3890,8 @@ void cfg80211_michael_mic_failure(struct
977 * with the locally generated beacon -- this guarantees that there is
978 * always a scan result for this IBSS. cfg80211 will handle the rest.
980 -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
981 +void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
982 + struct ieee80211_channel *channel, gfp_t gfp);
985 * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
986 --- a/include/uapi/linux/nl80211.h
987 +++ b/include/uapi/linux/nl80211.h
988 @@ -2442,9 +2442,15 @@ enum nl80211_reg_rule_attr {
989 * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
990 * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
991 * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
992 - * only report BSS with matching SSID.
993 + * only report BSS with matching SSID.
994 * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
995 - * BSS in scan results. Filtering is turned off if not specified.
996 + * BSS in scan results. Filtering is turned off if not specified. Note that
997 + * if this attribute is in a match set of its own, then it is treated as
998 + * the default value for all matchsets with an SSID, rather than being a
999 + * matchset of its own without an RSSI filter. This is due to problems with
1000 + * how this API was implemented in the past. Also, due to the same problem,
1001 + * the only way to create a matchset with only an RSSI filter (with this
1002 + * attribute) is if there's only a single matchset with the RSSI attribute.
1003 * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
1004 * attribute number currently defined
1005 * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
1006 --- a/net/mac80211/agg-tx.c
1007 +++ b/net/mac80211/agg-tx.c
1008 @@ -107,7 +107,7 @@ static void ieee80211_send_addba_request
1009 mgmt->u.action.u.addba_req.start_seq_num =
1010 cpu_to_le16(start_seq_num << 4);
1012 - ieee80211_tx_skb_tid(sdata, skb, tid);
1013 + ieee80211_tx_skb(sdata, skb);
1016 void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn)
1017 --- a/net/mac80211/cfg.c
1018 +++ b/net/mac80211/cfg.c
1019 @@ -970,9 +970,9 @@ static int ieee80211_start_ap(struct wip
1020 /* TODO: make hostapd tell us what it wants */
1021 sdata->smps_mode = IEEE80211_SMPS_OFF;
1022 sdata->needed_rx_chains = sdata->local->rx_chains;
1023 - sdata->radar_required = params->radar_required;
1025 mutex_lock(&local->mtx);
1026 + sdata->radar_required = params->radar_required;
1027 err = ieee80211_vif_use_channel(sdata, ¶ms->chandef,
1028 IEEE80211_CHANCTX_SHARED);
1029 mutex_unlock(&local->mtx);
1030 @@ -1021,8 +1021,10 @@ static int ieee80211_start_ap(struct wip
1031 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1033 err = ieee80211_assign_beacon(sdata, ¶ms->beacon);
1036 + ieee80211_vif_release_channel(sdata);
1041 err = drv_start_ap(sdata->local, sdata);
1042 @@ -1032,6 +1034,7 @@ static int ieee80211_start_ap(struct wip
1044 kfree_rcu(old, rcu_head);
1045 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1046 + ieee80211_vif_release_channel(sdata);
1050 @@ -1053,6 +1056,7 @@ static int ieee80211_change_beacon(struc
1053 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1054 + sdata_assert_lock(sdata);
1056 /* don't allow changing the beacon while CSA is in place - offset
1057 * of channel switch counter may change
1058 @@ -1080,6 +1084,8 @@ static int ieee80211_stop_ap(struct wiph
1059 struct probe_resp *old_probe_resp;
1060 struct cfg80211_chan_def chandef;
1062 + sdata_assert_lock(sdata);
1064 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
1067 @@ -1090,8 +1096,6 @@ static int ieee80211_stop_ap(struct wiph
1068 kfree(sdata->u.ap.next_beacon);
1069 sdata->u.ap.next_beacon = NULL;
1071 - cancel_work_sync(&sdata->u.ap.request_smps_work);
1073 /* turn off carrier for this interface and dependent VLANs */
1074 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1075 netif_carrier_off(vlan->dev);
1076 @@ -1103,6 +1107,7 @@ static int ieee80211_stop_ap(struct wiph
1077 kfree_rcu(old_beacon, rcu_head);
1079 kfree_rcu(old_probe_resp, rcu_head);
1080 + sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
1082 __sta_info_flush(sdata, true);
1083 ieee80211_free_keys(sdata, true);
1084 @@ -2638,6 +2643,24 @@ static int ieee80211_start_roc_work(stru
1085 INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
1086 INIT_LIST_HEAD(&roc->dependents);
1089 + * cookie is either the roc cookie (for normal roc)
1090 + * or the SKB (for mgmt TX)
1093 + /* local->mtx protects this */
1094 + local->roc_cookie_counter++;
1095 + roc->cookie = local->roc_cookie_counter;
1096 + /* wow, you wrapped 64 bits ... more likely a bug */
1097 + if (WARN_ON(roc->cookie == 0)) {
1099 + local->roc_cookie_counter++;
1101 + *cookie = roc->cookie;
1103 + *cookie = (unsigned long)txskb;
1106 /* if there's one pending or we're scanning, queue this one */
1107 if (!list_empty(&local->roc_list) ||
1108 local->scanning || local->radar_detect_enabled)
1109 @@ -2772,24 +2795,6 @@ static int ieee80211_start_roc_work(stru
1111 list_add_tail(&roc->list, &local->roc_list);
1114 - * cookie is either the roc cookie (for normal roc)
1115 - * or the SKB (for mgmt TX)
1118 - /* local->mtx protects this */
1119 - local->roc_cookie_counter++;
1120 - roc->cookie = local->roc_cookie_counter;
1121 - /* wow, you wrapped 64 bits ... more likely a bug */
1122 - if (WARN_ON(roc->cookie == 0)) {
1124 - local->roc_cookie_counter++;
1126 - *cookie = roc->cookie;
1128 - *cookie = (unsigned long)txskb;
1134 @@ -3004,8 +3009,10 @@ void ieee80211_csa_finalize_work(struct
1135 if (!ieee80211_sdata_running(sdata))
1138 - sdata->radar_required = sdata->csa_radar_required;
1139 + sdata_assert_lock(sdata);
1141 mutex_lock(&local->mtx);
1142 + sdata->radar_required = sdata->csa_radar_required;
1143 err = ieee80211_vif_change_channel(sdata, &changed);
1144 mutex_unlock(&local->mtx);
1145 if (WARN_ON(err < 0))
1146 @@ -3022,13 +3029,13 @@ void ieee80211_csa_finalize_work(struct
1147 switch (sdata->vif.type) {
1148 case NL80211_IFTYPE_AP:
1149 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
1150 + kfree(sdata->u.ap.next_beacon);
1151 + sdata->u.ap.next_beacon = NULL;
1157 - kfree(sdata->u.ap.next_beacon);
1158 - sdata->u.ap.next_beacon = NULL;
1160 ieee80211_bss_info_change_notify(sdata, err);
1162 case NL80211_IFTYPE_ADHOC:
1163 @@ -3066,7 +3073,7 @@ int ieee80211_channel_switch(struct wiph
1164 struct ieee80211_if_mesh __maybe_unused *ifmsh;
1165 int err, num_chanctx;
1167 - lockdep_assert_held(&sdata->wdev.mtx);
1168 + sdata_assert_lock(sdata);
1170 if (!list_empty(&local->roc_list) || local->scanning)
1172 --- a/net/mac80211/ht.c
1173 +++ b/net/mac80211/ht.c
1174 @@ -375,7 +375,7 @@ void ieee80211_send_delba(struct ieee802
1175 mgmt->u.action.u.delba.params = cpu_to_le16(params);
1176 mgmt->u.action.u.delba.reason_code = cpu_to_le16(reason_code);
1178 - ieee80211_tx_skb_tid(sdata, skb, tid);
1179 + ieee80211_tx_skb(sdata, skb);
1182 void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1183 @@ -466,7 +466,9 @@ void ieee80211_request_smps_ap_work(stru
1184 u.ap.request_smps_work);
1187 - __ieee80211_request_smps_ap(sdata, sdata->u.ap.driver_smps_mode);
1188 + if (sdata_dereference(sdata->u.ap.beacon, sdata))
1189 + __ieee80211_request_smps_ap(sdata,
1190 + sdata->u.ap.driver_smps_mode);
1191 sdata_unlock(sdata);
1194 --- a/net/mac80211/iface.c
1195 +++ b/net/mac80211/iface.c
1196 @@ -770,12 +770,19 @@ static void ieee80211_do_stop(struct iee
1198 ieee80211_roc_purge(local, sdata);
1200 - if (sdata->vif.type == NL80211_IFTYPE_STATION)
1201 + switch (sdata->vif.type) {
1202 + case NL80211_IFTYPE_STATION:
1203 ieee80211_mgd_stop(sdata);
1205 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1207 + case NL80211_IFTYPE_ADHOC:
1208 ieee80211_ibss_stop(sdata);
1211 + case NL80211_IFTYPE_AP:
1212 + cancel_work_sync(&sdata->u.ap.request_smps_work);
1219 * Remove all stations associated with this interface.
1220 @@ -827,7 +834,9 @@ static void ieee80211_do_stop(struct iee
1221 cancel_work_sync(&local->dynamic_ps_enable_work);
1223 cancel_work_sync(&sdata->recalc_smps);
1224 + sdata_lock(sdata);
1225 sdata->vif.csa_active = false;
1226 + sdata_unlock(sdata);
1227 cancel_work_sync(&sdata->csa_finalize_work);
1229 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1230 --- a/net/mac80211/rx.c
1231 +++ b/net/mac80211/rx.c
1232 @@ -599,10 +599,10 @@ static int ieee80211_is_unicast_robust_m
1234 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1236 - if (skb->len < 24 || is_multicast_ether_addr(hdr->addr1))
1237 + if (is_multicast_ether_addr(hdr->addr1))
1240 - return ieee80211_is_robust_mgmt_frame(hdr);
1241 + return ieee80211_is_robust_mgmt_frame(skb);
1245 @@ -610,10 +610,10 @@ static int ieee80211_is_multicast_robust
1247 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1249 - if (skb->len < 24 || !is_multicast_ether_addr(hdr->addr1))
1250 + if (!is_multicast_ether_addr(hdr->addr1))
1253 - return ieee80211_is_robust_mgmt_frame(hdr);
1254 + return ieee80211_is_robust_mgmt_frame(skb);
1258 @@ -626,7 +626,7 @@ static int ieee80211_get_mmie_keyidx(str
1259 if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da))
1262 - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr))
1263 + if (!ieee80211_is_robust_mgmt_frame(skb))
1264 return -1; /* not a robust management frame */
1266 mmie = (struct ieee80211_mmie *)
1267 @@ -1311,18 +1311,15 @@ ieee80211_rx_h_sta_process(struct ieee80
1268 !ieee80211_has_morefrags(hdr->frame_control) &&
1269 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
1270 (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
1271 - rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
1272 + rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1273 + /* PM bit is only checked in frames where it isn't reserved,
1274 + * in AP mode it's reserved in non-bufferable management frames
1275 + * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field)
1277 + (!ieee80211_is_mgmt(hdr->frame_control) ||
1278 + ieee80211_is_bufferable_mmpdu(hdr->frame_control))) {
1279 if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
1281 - * Ignore doze->wake transitions that are
1282 - * indicated by non-data frames, the standard
1283 - * is unclear here, but for example going to
1284 - * PS mode and then scanning would cause a
1285 - * doze->wake transition for the probe request,
1286 - * and that is clearly undesirable.
1288 - if (ieee80211_is_data(hdr->frame_control) &&
1289 - !ieee80211_has_pm(hdr->frame_control))
1290 + if (!ieee80211_has_pm(hdr->frame_control))
1293 if (ieee80211_has_pm(hdr->frame_control))
1294 @@ -1845,8 +1842,7 @@ static int ieee80211_drop_unencrypted_mg
1295 * having configured keys.
1297 if (unlikely(ieee80211_is_action(fc) && !rx->key &&
1298 - ieee80211_is_robust_mgmt_frame(
1299 - (struct ieee80211_hdr *) rx->skb->data)))
1300 + ieee80211_is_robust_mgmt_frame(rx->skb)))
1304 --- a/net/mac80211/tx.c
1305 +++ b/net/mac80211/tx.c
1306 @@ -452,8 +452,7 @@ static int ieee80211_use_mfp(__le16 fc,
1307 if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP))
1310 - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *)
1312 + if (!ieee80211_is_robust_mgmt_frame(skb))
1316 @@ -525,9 +524,7 @@ ieee80211_tx_h_ps_buf(struct ieee80211_t
1318 /* only deauth, disassoc and action are bufferable MMPDUs */
1319 if (ieee80211_is_mgmt(hdr->frame_control) &&
1320 - !ieee80211_is_deauth(hdr->frame_control) &&
1321 - !ieee80211_is_disassoc(hdr->frame_control) &&
1322 - !ieee80211_is_action(hdr->frame_control)) {
1323 + !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {
1324 if (tx->flags & IEEE80211_TX_UNICAST)
1325 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
1327 @@ -567,7 +564,7 @@ ieee80211_tx_h_select_key(struct ieee802
1329 else if (ieee80211_is_mgmt(hdr->frame_control) &&
1330 is_multicast_ether_addr(hdr->addr1) &&
1331 - ieee80211_is_robust_mgmt_frame(hdr) &&
1332 + ieee80211_is_robust_mgmt_frame(tx->skb) &&
1333 (key = rcu_dereference(tx->sdata->default_mgmt_key)))
1335 else if (is_multicast_ether_addr(hdr->addr1) &&
1336 @@ -582,12 +579,12 @@ ieee80211_tx_h_select_key(struct ieee802
1338 else if (tx->skb->protocol == tx->sdata->control_port_protocol)
1340 - else if (ieee80211_is_robust_mgmt_frame(hdr) &&
1341 + else if (ieee80211_is_robust_mgmt_frame(tx->skb) &&
1342 !(ieee80211_is_action(hdr->frame_control) &&
1343 tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))
1345 else if (ieee80211_is_mgmt(hdr->frame_control) &&
1346 - !ieee80211_is_robust_mgmt_frame(hdr))
1347 + !ieee80211_is_robust_mgmt_frame(tx->skb))
1350 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
1351 @@ -878,7 +875,7 @@ static int ieee80211_fragment(struct iee
1354 /* adjust first fragment's length */
1355 - skb->len = hdrlen + per_fragm;
1356 + skb_trim(skb, hdrlen + per_fragm);
1360 --- a/net/mac80211/wpa.c
1361 +++ b/net/mac80211/wpa.c
1362 @@ -499,7 +499,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
1363 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1365 if (!ieee80211_is_data(hdr->frame_control) &&
1366 - !ieee80211_is_robust_mgmt_frame(hdr))
1367 + !ieee80211_is_robust_mgmt_frame(skb))
1370 data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN -
1371 --- a/net/wireless/ap.c
1372 +++ b/net/wireless/ap.c
1373 @@ -27,9 +27,10 @@ static int __cfg80211_stop_ap(struct cfg
1374 err = rdev_stop_ap(rdev, dev);
1376 wdev->beacon_interval = 0;
1377 - wdev->channel = NULL;
1378 + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
1380 rdev_set_qos_map(rdev, dev, NULL);
1381 + nl80211_send_ap_stopped(wdev);
1385 --- a/net/wireless/core.c
1386 +++ b/net/wireless/core.c
1387 @@ -203,8 +203,11 @@ void cfg80211_stop_p2p_device(struct cfg
1391 - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
1392 - !rdev->scan_req->notified);
1393 + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
1394 + if (WARN_ON(!rdev->scan_req->notified))
1395 + rdev->scan_req->aborted = true;
1396 + ___cfg80211_scan_done(rdev, false);
1400 static int cfg80211_rfkill_set_block(void *data, bool blocked)
1401 @@ -447,9 +450,6 @@ int wiphy_register(struct wiphy *wiphy)
1403 u16 ifmodes = wiphy->interface_modes;
1405 - /* support for 5/10 MHz is broken due to nl80211 API mess - disable */
1406 - wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_5_10_MHZ;
1409 * There are major locking problems in nl80211/mac80211 for CSA,
1410 * disable for all drivers until this has been reworked.
1411 @@ -875,8 +875,11 @@ static int cfg80211_netdev_notifier_call
1414 cfg80211_update_iface_num(rdev, wdev->iftype, -1);
1415 - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
1416 - !rdev->scan_req->notified);
1417 + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
1418 + if (WARN_ON(!rdev->scan_req->notified))
1419 + rdev->scan_req->aborted = true;
1420 + ___cfg80211_scan_done(rdev, false);
1423 if (WARN_ON(rdev->sched_scan_req &&
1424 rdev->sched_scan_req->dev == wdev->netdev)) {
1425 --- a/net/wireless/core.h
1426 +++ b/net/wireless/core.h
1427 @@ -62,6 +62,7 @@ struct cfg80211_registered_device {
1428 struct rb_root bss_tree;
1430 struct cfg80211_scan_request *scan_req; /* protected by RTNL */
1431 + struct sk_buff *scan_msg;
1432 struct cfg80211_sched_scan_request *sched_scan_req;
1433 unsigned long suspend_at;
1434 struct work_struct scan_done_wk;
1435 @@ -210,6 +211,7 @@ struct cfg80211_event {
1439 + struct ieee80211_channel *channel;
1443 @@ -257,7 +259,8 @@ int __cfg80211_leave_ibss(struct cfg8021
1444 struct net_device *dev, bool nowext);
1445 int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
1446 struct net_device *dev, bool nowext);
1447 -void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid);
1448 +void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
1449 + struct ieee80211_channel *channel);
1450 int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
1451 struct wireless_dev *wdev);
1453 @@ -361,7 +364,8 @@ int cfg80211_validate_key_settings(struc
1454 struct key_params *params, int key_idx,
1455 bool pairwise, const u8 *mac_addr);
1456 void __cfg80211_scan_done(struct work_struct *wk);
1457 -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev);
1458 +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
1459 + bool send_message);
1460 void __cfg80211_sched_scan_results(struct work_struct *wk);
1461 int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
1462 bool driver_initiated);
1463 @@ -441,7 +445,8 @@ static inline unsigned int elapsed_jiffi
1465 cfg80211_get_chan_state(struct wireless_dev *wdev,
1466 struct ieee80211_channel **chan,
1467 - enum cfg80211_chan_mode *chanmode);
1468 + enum cfg80211_chan_mode *chanmode,
1469 + u8 *radar_detect);
1471 int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
1472 struct cfg80211_chan_def *chandef);
1473 --- a/net/wireless/nl80211.c
1474 +++ b/net/wireless/nl80211.c
1475 @@ -1723,9 +1723,10 @@ static int nl80211_dump_wiphy(struct sk_
1476 * We can then retry with the larger buffer.
1478 if ((ret == -ENOBUFS || ret == -EMSGSIZE) &&
1480 + !skb->len && !state->split &&
1481 cb->min_dump_alloc < 4096) {
1482 cb->min_dump_alloc = 4096;
1483 + state->split_start = 0;
1487 @@ -2047,10 +2048,12 @@ static int nl80211_set_wiphy(struct sk_b
1488 nla_for_each_nested(nl_txq_params,
1489 info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
1491 - nla_parse(tb, NL80211_TXQ_ATTR_MAX,
1492 - nla_data(nl_txq_params),
1493 - nla_len(nl_txq_params),
1494 - txq_params_policy);
1495 + result = nla_parse(tb, NL80211_TXQ_ATTR_MAX,
1496 + nla_data(nl_txq_params),
1497 + nla_len(nl_txq_params),
1498 + txq_params_policy);
1501 result = parse_txq_params(tb, &txq_params);
1504 @@ -3289,7 +3292,7 @@ static int nl80211_start_ap(struct sk_bu
1506 wdev->preset_chandef = params.chandef;
1507 wdev->beacon_interval = params.beacon_interval;
1508 - wdev->channel = params.chandef.chan;
1509 + wdev->chandef = params.chandef;
1510 wdev->ssid_len = params.ssid_len;
1511 memcpy(wdev->ssid, params.ssid, wdev->ssid_len);
1513 @@ -5210,9 +5213,11 @@ static int nl80211_set_reg(struct sk_buf
1515 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
1517 - nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
1518 - nla_data(nl_reg_rule), nla_len(nl_reg_rule),
1520 + r = nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
1521 + nla_data(nl_reg_rule), nla_len(nl_reg_rule),
1525 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
1528 @@ -5277,7 +5282,7 @@ static int nl80211_trigger_scan(struct s
1529 if (!rdev->ops->scan)
1532 - if (rdev->scan_req) {
1533 + if (rdev->scan_req || rdev->scan_msg) {
1537 @@ -5475,6 +5480,7 @@ static int nl80211_start_sched_scan(stru
1538 enum ieee80211_band band;
1540 struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
1541 + s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
1543 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
1544 !rdev->ops->sched_scan_start)
1545 @@ -5509,11 +5515,40 @@ static int nl80211_start_sched_scan(stru
1546 if (n_ssids > wiphy->max_sched_scan_ssids)
1549 - if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH])
1551 + * First, count the number of 'real' matchsets. Due to an issue with
1552 + * the old implementation, matchsets containing only the RSSI attribute
1553 + * (NL80211_SCHED_SCAN_MATCH_ATTR_RSSI) are considered as the 'default'
1554 + * RSSI for all matchsets, rather than their own matchset for reporting
1555 + * all APs with a strong RSSI. This is needed to be compatible with
1556 + * older userspace that treated a matchset with only the RSSI as the
1557 + * global RSSI for all other matchsets - if there are other matchsets.
1559 + if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
1560 nla_for_each_nested(attr,
1561 info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
1565 + struct nlattr *rssi;
1567 + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
1568 + nla_data(attr), nla_len(attr),
1569 + nl80211_match_policy);
1572 + /* add other standalone attributes here */
1573 + if (tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]) {
1577 + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
1579 + default_match_rssi = nla_get_s32(rssi);
1583 + /* However, if there's no other matchset, add the RSSI one */
1584 + if (!n_match_sets && default_match_rssi != NL80211_SCAN_RSSI_THOLD_OFF)
1587 if (n_match_sets > wiphy->max_match_sets)
1589 @@ -5634,11 +5669,22 @@ static int nl80211_start_sched_scan(stru
1591 struct nlattr *ssid, *rssi;
1593 - nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
1594 - nla_data(attr), nla_len(attr),
1595 - nl80211_match_policy);
1596 + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
1597 + nla_data(attr), nla_len(attr),
1598 + nl80211_match_policy);
1601 ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
1603 + if (WARN_ON(i >= n_match_sets)) {
1604 + /* this indicates a programming error,
1605 + * the loop above should have verified
1612 if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) {
1615 @@ -5647,15 +5693,28 @@ static int nl80211_start_sched_scan(stru
1616 nla_data(ssid), nla_len(ssid));
1617 request->match_sets[i].ssid.ssid_len =
1619 + /* special attribute - old implemenation w/a */
1620 + request->match_sets[i].rssi_thold =
1621 + default_match_rssi;
1622 + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
1624 + request->match_sets[i].rssi_thold =
1625 + nla_get_s32(rssi);
1627 - rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
1629 - request->rssi_thold = nla_get_u32(rssi);
1631 - request->rssi_thold =
1632 - NL80211_SCAN_RSSI_THOLD_OFF;
1636 + /* there was no other matchset, so the RSSI one is alone */
1638 + request->match_sets[0].rssi_thold = default_match_rssi;
1640 + request->min_rssi_thold = INT_MAX;
1641 + for (i = 0; i < n_match_sets; i++)
1642 + request->min_rssi_thold =
1643 + min(request->match_sets[i].rssi_thold,
1644 + request->min_rssi_thold);
1646 + request->min_rssi_thold = NL80211_SCAN_RSSI_THOLD_OFF;
1649 if (info->attrs[NL80211_ATTR_IE]) {
1650 @@ -5751,7 +5810,7 @@ static int nl80211_start_radar_detection
1652 err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef);
1654 - wdev->channel = chandef.chan;
1655 + wdev->chandef = chandef;
1656 wdev->cac_started = true;
1657 wdev->cac_start_time = jiffies;
1659 @@ -7502,16 +7561,19 @@ static int nl80211_set_tx_bitrate_mask(s
1660 * directly to the enum ieee80211_band values used in cfg80211.
1662 BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
1663 - nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
1665 + nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) {
1666 enum ieee80211_band band = nla_type(tx_rates);
1669 if (band < 0 || band >= IEEE80211_NUM_BANDS)
1671 sband = rdev->wiphy.bands[band];
1674 - nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
1675 - nla_len(tx_rates), nl80211_txattr_policy);
1676 + err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
1677 + nla_len(tx_rates), nl80211_txattr_policy);
1680 if (tb[NL80211_TXRATE_LEGACY]) {
1681 mask.control[band].legacy = rateset_to_mask(
1683 @@ -10054,40 +10116,31 @@ void nl80211_send_scan_start(struct cfg8
1684 NL80211_MCGRP_SCAN, GFP_KERNEL);
1687 -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
1688 - struct wireless_dev *wdev)
1689 +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
1690 + struct wireless_dev *wdev, bool aborted)
1692 struct sk_buff *msg;
1694 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1699 if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
1700 - NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
1701 + aborted ? NL80211_CMD_SCAN_ABORTED :
1702 + NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
1708 - genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
1709 - NL80211_MCGRP_SCAN, GFP_KERNEL);
1713 -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
1714 - struct wireless_dev *wdev)
1715 +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
1716 + struct sk_buff *msg)
1718 - struct sk_buff *msg;
1720 - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1724 - if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
1725 - NL80211_CMD_SCAN_ABORTED) < 0) {
1730 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
1731 NL80211_MCGRP_SCAN, GFP_KERNEL);
1733 @@ -11158,7 +11211,8 @@ void cfg80211_ch_switch_notify(struct ne
1734 wdev->iftype != NL80211_IFTYPE_MESH_POINT))
1737 - wdev->channel = chandef->chan;
1738 + wdev->chandef = *chandef;
1739 + wdev->preset_chandef = *chandef;
1740 nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL);
1742 EXPORT_SYMBOL(cfg80211_ch_switch_notify);
1743 @@ -11673,6 +11727,35 @@ void cfg80211_crit_proto_stopped(struct
1745 EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
1747 +void nl80211_send_ap_stopped(struct wireless_dev *wdev)
1749 + struct wiphy *wiphy = wdev->wiphy;
1750 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
1751 + struct sk_buff *msg;
1754 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1758 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_STOP_AP);
1762 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
1763 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) ||
1764 + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
1767 + genlmsg_end(msg, hdr);
1769 + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(wiphy), msg, 0,
1770 + NL80211_MCGRP_MLME, GFP_KERNEL);
1776 /* initialisation/exit functions */
1778 int nl80211_init(void)
1779 --- a/net/wireless/nl80211.h
1780 +++ b/net/wireless/nl80211.h
1781 @@ -8,10 +8,10 @@ void nl80211_exit(void);
1782 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
1783 void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
1784 struct wireless_dev *wdev);
1785 -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
1786 - struct wireless_dev *wdev);
1787 -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
1788 - struct wireless_dev *wdev);
1789 +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
1790 + struct wireless_dev *wdev, bool aborted);
1791 +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
1792 + struct sk_buff *msg);
1793 void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
1794 struct net_device *netdev, u32 cmd);
1795 void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
1796 @@ -74,6 +74,8 @@ nl80211_radar_notify(struct cfg80211_reg
1797 enum nl80211_radar_event event,
1798 struct net_device *netdev, gfp_t gfp);
1800 +void nl80211_send_ap_stopped(struct wireless_dev *wdev);
1802 void cfg80211_rdev_free_coalesce(struct cfg80211_registered_device *rdev);
1804 #endif /* __NET_WIRELESS_NL80211_H */
1805 --- a/net/wireless/scan.c
1806 +++ b/net/wireless/scan.c
1807 @@ -161,18 +161,25 @@ static void __cfg80211_bss_expire(struct
1808 dev->bss_generation++;
1811 -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev)
1812 +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
1813 + bool send_message)
1815 struct cfg80211_scan_request *request;
1816 struct wireless_dev *wdev;
1817 + struct sk_buff *msg;
1818 #ifdef CPTCFG_CFG80211_WEXT
1819 union iwreq_data wrqu;
1824 - request = rdev->scan_req;
1825 + if (rdev->scan_msg) {
1826 + nl80211_send_scan_result(rdev, rdev->scan_msg);
1827 + rdev->scan_msg = NULL;
1831 + request = rdev->scan_req;
1835 @@ -186,18 +193,16 @@ void ___cfg80211_scan_done(struct cfg802
1837 cfg80211_sme_scan_done(wdev->netdev);
1839 - if (request->aborted) {
1840 - nl80211_send_scan_aborted(rdev, wdev);
1842 - if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
1843 - /* flush entries from previous scans */
1844 - spin_lock_bh(&rdev->bss_lock);
1845 - __cfg80211_bss_expire(rdev, request->scan_start);
1846 - spin_unlock_bh(&rdev->bss_lock);
1848 - nl80211_send_scan_done(rdev, wdev);
1849 + if (!request->aborted &&
1850 + request->flags & NL80211_SCAN_FLAG_FLUSH) {
1851 + /* flush entries from previous scans */
1852 + spin_lock_bh(&rdev->bss_lock);
1853 + __cfg80211_bss_expire(rdev, request->scan_start);
1854 + spin_unlock_bh(&rdev->bss_lock);
1857 + msg = nl80211_build_scan_msg(rdev, wdev, request->aborted);
1859 #ifdef CPTCFG_CFG80211_WEXT
1860 if (wdev->netdev && !request->aborted) {
1861 memset(&wrqu, 0, sizeof(wrqu));
1862 @@ -211,6 +216,11 @@ void ___cfg80211_scan_done(struct cfg802
1864 rdev->scan_req = NULL;
1867 + if (!send_message)
1868 + rdev->scan_msg = msg;
1870 + nl80211_send_scan_result(rdev, msg);
1873 void __cfg80211_scan_done(struct work_struct *wk)
1874 @@ -221,7 +231,7 @@ void __cfg80211_scan_done(struct work_st
1878 - ___cfg80211_scan_done(rdev);
1879 + ___cfg80211_scan_done(rdev, true);
1883 @@ -1079,7 +1089,7 @@ int cfg80211_wext_siwscan(struct net_dev
1885 return PTR_ERR(rdev);
1887 - if (rdev->scan_req) {
1888 + if (rdev->scan_req || rdev->scan_msg) {
1892 @@ -1481,7 +1491,7 @@ int cfg80211_wext_giwscan(struct net_dev
1894 return PTR_ERR(rdev);
1896 - if (rdev->scan_req)
1897 + if (rdev->scan_req || rdev->scan_msg)
1900 res = ieee80211_scan_results(rdev, info, extra, data->length);
1901 --- a/net/wireless/sme.c
1902 +++ b/net/wireless/sme.c
1903 @@ -67,7 +67,7 @@ static int cfg80211_conn_scan(struct wir
1904 ASSERT_RDEV_LOCK(rdev);
1905 ASSERT_WDEV_LOCK(wdev);
1907 - if (rdev->scan_req)
1908 + if (rdev->scan_req || rdev->scan_msg)
1911 if (wdev->conn->params.channel)
1912 --- a/net/mac80211/mlme.c
1913 +++ b/net/mac80211/mlme.c
1914 @@ -1001,7 +1001,6 @@ ieee80211_sta_process_chanswitch(struct
1917 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
1918 - sdata->vif.csa_active = true;
1920 mutex_lock(&local->chanctx_mtx);
1921 if (local->use_chanctx) {
1922 @@ -1039,6 +1038,7 @@ ieee80211_sta_process_chanswitch(struct
1923 mutex_unlock(&local->chanctx_mtx);
1925 sdata->csa_chandef = csa_ie.chandef;
1926 + sdata->vif.csa_active = true;
1929 ieee80211_stop_queues_by_reason(&local->hw,
1930 --- a/net/mac80211/chan.c
1931 +++ b/net/mac80211/chan.c
1932 @@ -196,6 +196,8 @@ static bool ieee80211_is_radar_required(
1934 struct ieee80211_sub_if_data *sdata;
1936 + lockdep_assert_held(&local->mtx);
1939 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
1940 if (sdata->radar_required) {
1941 --- a/net/mac80211/ibss.c
1942 +++ b/net/mac80211/ibss.c
1943 @@ -294,7 +294,6 @@ static void __ieee80211_sta_join_ibss(st
1946 mutex_lock(&local->mtx);
1947 - ieee80211_vif_release_channel(sdata);
1948 if (ieee80211_vif_use_channel(sdata, &chandef,
1949 ifibss->fixed_channel ?
1950 IEEE80211_CHANCTX_SHARED :
1951 @@ -303,6 +302,7 @@ static void __ieee80211_sta_join_ibss(st
1952 mutex_unlock(&local->mtx);
1955 + sdata->radar_required = radar_required;
1956 mutex_unlock(&local->mtx);
1958 memcpy(ifibss->bssid, bssid, ETH_ALEN);
1959 @@ -318,7 +318,6 @@ static void __ieee80211_sta_join_ibss(st
1960 rcu_assign_pointer(ifibss->presp, presp);
1961 mgmt = (void *)presp->head;
1963 - sdata->radar_required = radar_required;
1964 sdata->vif.bss_conf.enable_beacon = true;
1965 sdata->vif.bss_conf.beacon_int = beacon_int;
1966 sdata->vif.bss_conf.basic_rates = basic_rates;
1967 @@ -386,7 +385,7 @@ static void __ieee80211_sta_join_ibss(st
1968 presp->head_len, 0, GFP_KERNEL);
1969 cfg80211_put_bss(local->hw.wiphy, bss);
1970 netif_carrier_on(sdata->dev);
1971 - cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL);
1972 + cfg80211_ibss_joined(sdata->dev, ifibss->bssid, chan, GFP_KERNEL);
1975 static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
1976 @@ -802,6 +801,8 @@ ieee80211_ibss_process_chanswitch(struct
1980 + sdata_assert_lock(sdata);
1982 sta_flags = IEEE80211_STA_DISABLE_VHT;
1983 switch (ifibss->chandef.width) {
1984 case NL80211_CHAN_WIDTH_5:
1985 @@ -1471,6 +1472,11 @@ static void ieee80211_rx_mgmt_probe_req(
1986 memcpy(((struct ieee80211_mgmt *) skb->data)->da, mgmt->sa, ETH_ALEN);
1987 ibss_dbg(sdata, "Sending ProbeResp to %pM\n", mgmt->sa);
1988 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
1990 + /* avoid excessive retries for probe request to wildcard SSIDs */
1992 + IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_NO_ACK;
1994 ieee80211_tx_skb(sdata, skb);
1997 --- a/net/mac80211/mesh.c
1998 +++ b/net/mac80211/mesh.c
1999 @@ -872,6 +872,8 @@ ieee80211_mesh_process_chnswitch(struct
2000 if (!ifmsh->mesh_id)
2003 + sdata_assert_lock(sdata);
2005 sta_flags = IEEE80211_STA_DISABLE_VHT;
2006 switch (sdata->vif.bss_conf.chandef.width) {
2007 case NL80211_CHAN_WIDTH_20_NOHT:
2008 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2009 +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2010 @@ -4658,6 +4658,7 @@ brcmf_notify_connect_status(struct brcmf
2011 struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
2012 struct net_device *ndev = ifp->ndev;
2013 struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
2014 + struct ieee80211_channel *chan;
2017 if (ifp->vif->mode == WL_MODE_AP) {
2018 @@ -4665,9 +4666,10 @@ brcmf_notify_connect_status(struct brcmf
2019 } else if (brcmf_is_linkup(e)) {
2020 brcmf_dbg(CONN, "Linkup\n");
2021 if (brcmf_is_ibssmode(ifp->vif)) {
2022 + chan = ieee80211_get_channel(cfg->wiphy, cfg->channel);
2023 memcpy(profile->bssid, e->addr, ETH_ALEN);
2024 wl_inform_ibss(cfg, ndev, e->addr);
2025 - cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL);
2026 + cfg80211_ibss_joined(ndev, e->addr, chan, GFP_KERNEL);
2027 clear_bit(BRCMF_VIF_STATUS_CONNECTING,
2028 &ifp->vif->sme_state);
2029 set_bit(BRCMF_VIF_STATUS_CONNECTED,
2030 --- a/drivers/net/wireless/libertas/cfg.c
2031 +++ b/drivers/net/wireless/libertas/cfg.c
2032 @@ -1766,7 +1766,8 @@ static void lbs_join_post(struct lbs_pri
2033 memcpy(priv->wdev->ssid, params->ssid, params->ssid_len);
2034 priv->wdev->ssid_len = params->ssid_len;
2036 - cfg80211_ibss_joined(priv->dev, bssid, GFP_KERNEL);
2037 + cfg80211_ibss_joined(priv->dev, bssid, params->chandef.chan,
2040 /* TODO: consider doing this at MACREG_INT_CODE_LINK_SENSED time */
2041 priv->connect_status = LBS_CONNECTED;
2042 --- a/drivers/net/wireless/mwifiex/cfg80211.c
2043 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
2044 @@ -1881,7 +1881,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy
2048 - cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL);
2049 + cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid,
2050 + params->chandef.chan, GFP_KERNEL);
2051 dev_dbg(priv->adapter->dev,
2052 "info: joined/created adhoc network with bssid"
2053 " %pM successfully\n", priv->cfg_bssid);
2054 --- a/drivers/net/wireless/rndis_wlan.c
2055 +++ b/drivers/net/wireless/rndis_wlan.c
2056 @@ -2835,7 +2835,9 @@ static void rndis_wlan_do_link_up_work(s
2057 bssid, req_ie, req_ie_len,
2058 resp_ie, resp_ie_len, GFP_KERNEL);
2059 } else if (priv->infra_mode == NDIS_80211_INFRA_ADHOC)
2060 - cfg80211_ibss_joined(usbdev->net, bssid, GFP_KERNEL);
2061 + cfg80211_ibss_joined(usbdev->net, bssid,
2062 + get_current_channel(usbdev, NULL),
2067 --- a/net/wireless/ibss.c
2068 +++ b/net/wireless/ibss.c
2070 #include "rdev-ops.h"
2073 -void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid)
2074 +void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
2075 + struct ieee80211_channel *channel)
2077 struct wireless_dev *wdev = dev->ieee80211_ptr;
2078 struct cfg80211_bss *bss;
2079 @@ -28,8 +29,7 @@ void __cfg80211_ibss_joined(struct net_d
2080 if (!wdev->ssid_len)
2083 - bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
2084 - wdev->ssid, wdev->ssid_len,
2085 + bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, NULL, 0,
2086 WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS);
2089 @@ -54,21 +54,26 @@ void __cfg80211_ibss_joined(struct net_d
2093 -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
2094 +void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
2095 + struct ieee80211_channel *channel, gfp_t gfp)
2097 struct wireless_dev *wdev = dev->ieee80211_ptr;
2098 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2099 struct cfg80211_event *ev;
2100 unsigned long flags;
2102 - trace_cfg80211_ibss_joined(dev, bssid);
2103 + trace_cfg80211_ibss_joined(dev, bssid, channel);
2105 + if (WARN_ON(!channel))
2108 ev = kzalloc(sizeof(*ev), gfp);
2112 ev->type = EVENT_IBSS_JOINED;
2113 - memcpy(ev->cr.bssid, bssid, ETH_ALEN);
2114 + memcpy(ev->ij.bssid, bssid, ETH_ALEN);
2115 + ev->ij.channel = channel;
2117 spin_lock_irqsave(&wdev->event_lock, flags);
2118 list_add_tail(&ev->list, &wdev->event_list);
2119 @@ -117,6 +122,7 @@ int __cfg80211_join_ibss(struct cfg80211
2121 wdev->ibss_fixed = params->channel_fixed;
2122 wdev->ibss_dfs_possible = params->userspace_handles_dfs;
2123 + wdev->chandef = params->chandef;
2124 #ifdef CPTCFG_CFG80211_WEXT
2125 wdev->wext.ibss.chandef = params->chandef;
2127 @@ -200,6 +206,7 @@ static void __cfg80211_clear_ibss(struct
2129 wdev->current_bss = NULL;
2131 + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
2132 #ifdef CPTCFG_CFG80211_WEXT
2134 wdev->wext.ibss.ssid_len = 0;
2135 --- a/net/wireless/trace.h
2136 +++ b/net/wireless/trace.h
2137 @@ -2278,11 +2278,6 @@ DECLARE_EVENT_CLASS(cfg80211_rx_evt,
2138 TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT, NETDEV_PR_ARG, MAC_PR_ARG(addr))
2141 -DEFINE_EVENT(cfg80211_rx_evt, cfg80211_ibss_joined,
2142 - TP_PROTO(struct net_device *netdev, const u8 *addr),
2143 - TP_ARGS(netdev, addr)
2146 DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_spurious_frame,
2147 TP_PROTO(struct net_device *netdev, const u8 *addr),
2148 TP_ARGS(netdev, addr)
2149 @@ -2293,6 +2288,24 @@ DEFINE_EVENT(cfg80211_rx_evt, cfg80211_r
2150 TP_ARGS(netdev, addr)
2153 +TRACE_EVENT(cfg80211_ibss_joined,
2154 + TP_PROTO(struct net_device *netdev, const u8 *bssid,
2155 + struct ieee80211_channel *channel),
2156 + TP_ARGS(netdev, bssid, channel),
2164 + MAC_ASSIGN(bssid, bssid);
2165 + CHAN_ASSIGN(channel);
2167 + TP_printk(NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", " CHAN_PR_FMT,
2168 + NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG)
2171 TRACE_EVENT(cfg80211_probe_status,
2172 TP_PROTO(struct net_device *netdev, const u8 *addr, u64 cookie,
2174 --- a/net/wireless/util.c
2175 +++ b/net/wireless/util.c
2176 @@ -820,7 +820,8 @@ void cfg80211_process_wdev_events(struct
2177 ev->dc.reason, true);
2179 case EVENT_IBSS_JOINED:
2180 - __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
2181 + __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid,
2186 @@ -1356,7 +1357,7 @@ int cfg80211_can_use_iftype_chan(struct
2188 mutex_lock_nested(&wdev_iter->mtx, 1);
2189 __acquire(wdev_iter->mtx);
2190 - cfg80211_get_chan_state(wdev_iter, &ch, &chmode);
2191 + cfg80211_get_chan_state(wdev_iter, &ch, &chmode, &radar_detect);
2192 wdev_unlock(wdev_iter);
2195 --- a/net/wireless/chan.c
2196 +++ b/net/wireless/chan.c
2197 @@ -642,7 +642,8 @@ int cfg80211_set_monitor_channel(struct
2199 cfg80211_get_chan_state(struct wireless_dev *wdev,
2200 struct ieee80211_channel **chan,
2201 - enum cfg80211_chan_mode *chanmode)
2202 + enum cfg80211_chan_mode *chanmode,
2206 *chanmode = CHAN_MODE_UNDEFINED;
2207 @@ -660,6 +661,11 @@ cfg80211_get_chan_state(struct wireless_
2208 !wdev->ibss_dfs_possible)
2210 : CHAN_MODE_EXCLUSIVE;
2212 + /* consider worst-case - IBSS can try to return to the
2213 + * original user-specified channel as creator */
2214 + if (wdev->ibss_dfs_possible)
2215 + *radar_detect |= BIT(wdev->chandef.width);
2219 @@ -674,17 +680,26 @@ cfg80211_get_chan_state(struct wireless_
2220 case NL80211_IFTYPE_AP:
2221 case NL80211_IFTYPE_P2P_GO:
2222 if (wdev->cac_started) {
2223 - *chan = wdev->channel;
2224 + *chan = wdev->chandef.chan;
2225 *chanmode = CHAN_MODE_SHARED;
2226 + *radar_detect |= BIT(wdev->chandef.width);
2227 } else if (wdev->beacon_interval) {
2228 - *chan = wdev->channel;
2229 + *chan = wdev->chandef.chan;
2230 *chanmode = CHAN_MODE_SHARED;
2232 + if (cfg80211_chandef_dfs_required(wdev->wiphy,
2234 + *radar_detect |= BIT(wdev->chandef.width);
2237 case NL80211_IFTYPE_MESH_POINT:
2238 if (wdev->mesh_id_len) {
2239 - *chan = wdev->channel;
2240 + *chan = wdev->chandef.chan;
2241 *chanmode = CHAN_MODE_SHARED;
2243 + if (cfg80211_chandef_dfs_required(wdev->wiphy,
2245 + *radar_detect |= BIT(wdev->chandef.width);
2248 case NL80211_IFTYPE_MONITOR:
2249 --- a/net/wireless/mesh.c
2250 +++ b/net/wireless/mesh.c
2251 @@ -195,7 +195,7 @@ int __cfg80211_join_mesh(struct cfg80211
2253 memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
2254 wdev->mesh_id_len = setup->mesh_id_len;
2255 - wdev->channel = setup->chandef.chan;
2256 + wdev->chandef = setup->chandef;
2260 @@ -244,7 +244,7 @@ int cfg80211_set_mesh_channel(struct cfg
2261 err = rdev_libertas_set_mesh_channel(rdev, wdev->netdev,
2264 - wdev->channel = chandef->chan;
2265 + wdev->chandef = *chandef;
2269 @@ -276,7 +276,7 @@ static int __cfg80211_leave_mesh(struct
2270 err = rdev_leave_mesh(rdev, dev);
2272 wdev->mesh_id_len = 0;
2273 - wdev->channel = NULL;
2274 + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
2275 rdev_set_qos_map(rdev, dev, NULL);
2278 --- a/net/wireless/mlme.c
2279 +++ b/net/wireless/mlme.c
2280 @@ -772,7 +772,7 @@ void cfg80211_cac_event(struct net_devic
2281 if (WARN_ON(!wdev->cac_started))
2284 - if (WARN_ON(!wdev->channel))
2285 + if (WARN_ON(!wdev->chandef.chan))
2289 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2290 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2291 @@ -5065,6 +5065,10 @@ static u16 ar9003_hw_get_max_edge_power(
2296 + if (is2GHz && !twiceMaxEdgePower)
2297 + twiceMaxEdgePower = 60;
2299 return twiceMaxEdgePower;
2302 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
2303 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
2305 #define MAX_MEASUREMENT MAX_IQCAL_MEASUREMENT
2306 #define MAX_MAG_DELTA 11
2307 #define MAX_PHS_DELTA 10
2311 - int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
2312 - int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
2313 + int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
2314 + int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
2318 @@ -800,7 +801,7 @@ static bool ar9003_hw_calc_iq_corr(struc
2322 - iqc_coeff[0] = (q_q_coff * 128) + q_i_coff;
2323 + iqc_coeff[0] = (q_q_coff * 128) + (0x7f & q_i_coff);
2325 ath_dbg(common, CALIBRATE, "tx chain %d: iq corr coeff=%x\n",
2326 chain_idx, iqc_coeff[0]);
2327 @@ -831,7 +832,7 @@ static bool ar9003_hw_calc_iq_corr(struc
2331 - iqc_coeff[1] = (q_q_coff * 128) + q_i_coff;
2332 + iqc_coeff[1] = (q_q_coff * 128) + (0x7f & q_i_coff);
2334 ath_dbg(common, CALIBRATE, "rx chain %d: iq corr coeff=%x\n",
2335 chain_idx, iqc_coeff[1]);
2336 @@ -839,7 +840,8 @@ static bool ar9003_hw_calc_iq_corr(struc
2340 -static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
2341 +static void ar9003_hw_detect_outlier(int mp_coeff[][MAXIQCAL],
2345 int mp_max = -64, max_idx = 0;
2346 @@ -848,20 +850,20 @@ static void ar9003_hw_detect_outlier(int
2348 /* find min/max mismatch across all calibrated gains */
2349 for (i = 0; i < nmeasurement; i++) {
2350 - if (mp_coeff[i] > mp_max) {
2351 - mp_max = mp_coeff[i];
2352 + if (mp_coeff[i][0] > mp_max) {
2353 + mp_max = mp_coeff[i][0];
2355 - } else if (mp_coeff[i] < mp_min) {
2356 - mp_min = mp_coeff[i];
2357 + } else if (mp_coeff[i][0] < mp_min) {
2358 + mp_min = mp_coeff[i][0];
2363 /* find average (exclude max abs value) */
2364 for (i = 0; i < nmeasurement; i++) {
2365 - if ((abs(mp_coeff[i]) < abs(mp_max)) ||
2366 - (abs(mp_coeff[i]) < abs(mp_min))) {
2367 - mp_avg += mp_coeff[i];
2368 + if ((abs(mp_coeff[i][0]) < abs(mp_max)) ||
2369 + (abs(mp_coeff[i][0]) < abs(mp_min))) {
2370 + mp_avg += mp_coeff[i][0];
2374 @@ -873,7 +875,7 @@ static void ar9003_hw_detect_outlier(int
2378 - mp_avg = mp_coeff[nmeasurement - 1];
2379 + mp_avg = mp_coeff[nmeasurement - 1][0];
2381 /* detect outlier */
2382 if (abs(mp_max - mp_min) > max_delta) {
2383 @@ -882,15 +884,16 @@ static void ar9003_hw_detect_outlier(int
2385 outlier_idx = min_idx;
2387 - mp_coeff[outlier_idx] = mp_avg;
2388 + mp_coeff[outlier_idx][0] = mp_avg;
2392 -static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
2393 - struct coeff *coeff,
2395 +static void ar9003_hw_tx_iq_cal_outlier_detection(struct ath_hw *ah,
2396 + struct coeff *coeff,
2399 int i, im, nmeasurement;
2400 + int magnitude, phase;
2401 u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
2402 struct ath9k_hw_cal_data *caldata = ah->caldata;
2404 @@ -920,21 +923,30 @@ static void ar9003_hw_tx_iqcal_load_avg_
2405 if (nmeasurement > MAX_MEASUREMENT)
2406 nmeasurement = MAX_MEASUREMENT;
2408 - /* detect outlier only if nmeasurement > 1 */
2409 - if (nmeasurement > 1) {
2410 - /* Detect magnitude outlier */
2411 - ar9003_hw_detect_outlier(coeff->mag_coeff[i],
2412 - nmeasurement, MAX_MAG_DELTA);
2414 - /* Detect phase outlier */
2415 - ar9003_hw_detect_outlier(coeff->phs_coeff[i],
2416 - nmeasurement, MAX_PHS_DELTA);
2418 + * Skip normal outlier detection for AR9550.
2420 + if (!AR_SREV_9550(ah)) {
2421 + /* detect outlier only if nmeasurement > 1 */
2422 + if (nmeasurement > 1) {
2423 + /* Detect magnitude outlier */
2424 + ar9003_hw_detect_outlier(coeff->mag_coeff[i],
2428 + /* Detect phase outlier */
2429 + ar9003_hw_detect_outlier(coeff->phs_coeff[i],
2435 for (im = 0; im < nmeasurement; im++) {
2436 + magnitude = coeff->mag_coeff[i][im][0];
2437 + phase = coeff->phs_coeff[i][im][0];
2439 - coeff->iqc_coeff[0] = (coeff->mag_coeff[i][im] & 0x7f) |
2440 - ((coeff->phs_coeff[i][im] & 0x7f) << 7);
2441 + coeff->iqc_coeff[0] =
2442 + (phase & 0x7f) | ((magnitude & 0x7f) << 7);
2445 REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
2446 @@ -991,7 +1003,63 @@ static bool ar9003_hw_tx_iq_cal_run(stru
2450 -static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah, bool is_reusable)
2451 +static void __ar955x_tx_iq_cal_sort(struct ath_hw *ah,
2452 + struct coeff *coeff,
2453 + int i, int nmeasurement)
2455 + struct ath_common *common = ath9k_hw_common(ah);
2456 + int im, ix, iy, temp;
2458 + for (im = 0; im < nmeasurement; im++) {
2459 + for (ix = 0; ix < MAXIQCAL - 1; ix++) {
2460 + for (iy = ix + 1; iy <= MAXIQCAL - 1; iy++) {
2461 + if (coeff->mag_coeff[i][im][iy] <
2462 + coeff->mag_coeff[i][im][ix]) {
2463 + temp = coeff->mag_coeff[i][im][ix];
2464 + coeff->mag_coeff[i][im][ix] =
2465 + coeff->mag_coeff[i][im][iy];
2466 + coeff->mag_coeff[i][im][iy] = temp;
2468 + if (coeff->phs_coeff[i][im][iy] <
2469 + coeff->phs_coeff[i][im][ix]) {
2470 + temp = coeff->phs_coeff[i][im][ix];
2471 + coeff->phs_coeff[i][im][ix] =
2472 + coeff->phs_coeff[i][im][iy];
2473 + coeff->phs_coeff[i][im][iy] = temp;
2477 + coeff->mag_coeff[i][im][0] = coeff->mag_coeff[i][im][MAXIQCAL / 2];
2478 + coeff->phs_coeff[i][im][0] = coeff->phs_coeff[i][im][MAXIQCAL / 2];
2480 + ath_dbg(common, CALIBRATE,
2481 + "IQCAL: Median [ch%d][gain%d]: mag = %d phase = %d\n",
2483 + coeff->mag_coeff[i][im][0],
2484 + coeff->phs_coeff[i][im][0]);
2488 +static bool ar955x_tx_iq_cal_median(struct ath_hw *ah,
2489 + struct coeff *coeff,
2495 + if ((iqcal_idx + 1) != MAXIQCAL)
2498 + for (i = 0; i < AR9300_MAX_CHAINS; i++) {
2499 + __ar955x_tx_iq_cal_sort(ah, coeff, i, nmeasurement);
2505 +static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah,
2509 struct ath_common *common = ath9k_hw_common(ah);
2510 const u32 txiqcal_status[AR9300_MAX_CHAINS] = {
2511 @@ -1004,10 +1072,11 @@ static void ar9003_hw_tx_iq_cal_post_pro
2512 AR_PHY_CHAN_INFO_TAB_1,
2513 AR_PHY_CHAN_INFO_TAB_2,
2515 - struct coeff coeff;
2516 + static struct coeff coeff;
2520 + int nmeasurement = 0;
2521 + bool outlier_detect = true;
2523 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
2524 if (!(ah->txchainmask & (1 << i)))
2525 @@ -1065,17 +1134,23 @@ static void ar9003_hw_tx_iq_cal_post_pro
2529 - coeff.mag_coeff[i][im] = coeff.iqc_coeff[0] & 0x7f;
2530 - coeff.phs_coeff[i][im] =
2531 + coeff.phs_coeff[i][im][iqcal_idx] =
2532 + coeff.iqc_coeff[0] & 0x7f;
2533 + coeff.mag_coeff[i][im][iqcal_idx] =
2534 (coeff.iqc_coeff[0] >> 7) & 0x7f;
2536 - if (coeff.mag_coeff[i][im] > 63)
2537 - coeff.mag_coeff[i][im] -= 128;
2538 - if (coeff.phs_coeff[i][im] > 63)
2539 - coeff.phs_coeff[i][im] -= 128;
2540 + if (coeff.mag_coeff[i][im][iqcal_idx] > 63)
2541 + coeff.mag_coeff[i][im][iqcal_idx] -= 128;
2542 + if (coeff.phs_coeff[i][im][iqcal_idx] > 63)
2543 + coeff.phs_coeff[i][im][iqcal_idx] -= 128;
2546 - ar9003_hw_tx_iqcal_load_avg_2_passes(ah, &coeff, is_reusable);
2548 + if (AR_SREV_9550(ah))
2549 + outlier_detect = ar955x_tx_iq_cal_median(ah, &coeff,
2550 + iqcal_idx, nmeasurement);
2551 + if (outlier_detect)
2552 + ar9003_hw_tx_iq_cal_outlier_detection(ah, &coeff, is_reusable);
2556 @@ -1409,7 +1484,7 @@ skip_tx_iqcal:
2560 - ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
2561 + ar9003_hw_tx_iq_cal_post_proc(ah, 0, is_reusable);
2562 else if (caldata && test_bit(TXIQCAL_DONE, &caldata->cal_flags))
2563 ar9003_hw_tx_iq_cal_reload(ah);
2565 @@ -1455,14 +1530,38 @@ skip_tx_iqcal:
2569 +static bool do_ar9003_agc_cal(struct ath_hw *ah)
2571 + struct ath_common *common = ath9k_hw_common(ah);
2574 + REG_WRITE(ah, AR_PHY_AGC_CONTROL,
2575 + REG_READ(ah, AR_PHY_AGC_CONTROL) |
2576 + AR_PHY_AGC_CONTROL_CAL);
2578 + status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
2579 + AR_PHY_AGC_CONTROL_CAL,
2580 + 0, AH_WAIT_TIMEOUT);
2582 + ath_dbg(common, CALIBRATE,
2583 + "offset calibration failed to complete in %d ms,"
2584 + "noisy environment?\n",
2585 + AH_WAIT_TIMEOUT / 1000);
2592 static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
2593 struct ath9k_channel *chan)
2595 struct ath_common *common = ath9k_hw_common(ah);
2596 struct ath9k_hw_cal_data *caldata = ah->caldata;
2597 bool txiqcal_done = false;
2598 - bool is_reusable = true, status = true;
2599 + bool status = true;
2600 bool run_agc_cal = false, sep_iq_cal = false;
2603 /* Use chip chainmask only for calibration */
2604 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
2605 @@ -1485,7 +1584,12 @@ static bool ar9003_hw_init_cal_soc(struc
2606 * AGC calibration. Specifically, AR9550 in SoC chips.
2608 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) {
2609 - txiqcal_done = true;
2610 + if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
2611 + AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL)) {
2612 + txiqcal_done = true;
2614 + txiqcal_done = false;
2619 @@ -1512,27 +1616,37 @@ skip_tx_iqcal:
2620 if (AR_SREV_9330_11(ah))
2621 ar9003_hw_manual_peak_cal(ah, 0, IS_CHAN_2GHZ(chan));
2623 - /* Calibrate the AGC */
2624 - REG_WRITE(ah, AR_PHY_AGC_CONTROL,
2625 - REG_READ(ah, AR_PHY_AGC_CONTROL) |
2626 - AR_PHY_AGC_CONTROL_CAL);
2628 - /* Poll for offset calibration complete */
2629 - status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
2630 - AR_PHY_AGC_CONTROL_CAL,
2631 - 0, AH_WAIT_TIMEOUT);
2634 + * For non-AR9550 chips, we just trigger AGC calibration
2635 + * in the HW, poll for completion and then process
2638 + * For AR955x, we run it multiple times and use
2639 + * median IQ correction.
2641 + if (!AR_SREV_9550(ah)) {
2642 + status = do_ar9003_agc_cal(ah);
2647 - ath_dbg(common, CALIBRATE,
2648 - "offset calibration failed to complete in %d ms; noisy environment?\n",
2649 - AH_WAIT_TIMEOUT / 1000);
2652 + ar9003_hw_tx_iq_cal_post_proc(ah, 0, false);
2654 + if (!txiqcal_done) {
2655 + status = do_ar9003_agc_cal(ah);
2659 + for (i = 0; i < MAXIQCAL; i++) {
2660 + status = do_ar9003_agc_cal(ah);
2663 + ar9003_hw_tx_iq_cal_post_proc(ah, i, false);
2670 - ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
2672 /* Revert chainmask to runtime parameters */
2673 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
2675 --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
2676 +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
2681 +#include <linux/cache.h>
2683 #include "rtl818x.h"
2686 @@ -139,7 +141,10 @@ struct rtl8187_priv {
2693 + u8 dummy1[L1_CACHE_BYTES];
2694 + } ____cacheline_aligned;
2695 struct sk_buff_head queue;
2696 } b_tx_status; /* This queue is used by both -b and non-b devices */
2697 struct mutex io_mutex;
2698 @@ -147,7 +152,8 @@ struct rtl8187_priv {
2703 + u8 dummy2[L1_CACHE_BYTES];
2704 + } *io_dmabuf ____cacheline_aligned;