ath9k: merge an aggregation related fix
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 300-pending_work.patch
1 commit 584d297fd29fb39c76af25ae74ff9d5fe74c8a14
2 Author: Helmut Schaa <helmut.schaa@googlemail.com>
3 Date: Wed Mar 12 10:37:55 2014 +0100
4
5 ath9k: Fix sequence number assignment for non-data frames
6
7 Since commit 558ff225de80ac95b132d3a115ddadcd64498b4f (ath9k: fix
8 ps-poll responses under a-mpdu sessions) non-data frames would have
9 gotten a sequence number from a TIDs sequence counter instead of
10 using the global sequence counter.
11
12 This can lead to instable connections.
13
14 To fix this only select the correct TID if we are processing a
15 data frame. Furthermore, prevent non-data frames to get a sequence
16 number from a TID sequence counter by adding a check to
17 ath_tx_setup_buffer.
18
19 Cc: Felix Fietkau <nbd@openwrt.org>
20 Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
21
22 commit 3a0f984b1cdcd6a9f8c441635ef3b05d58547f4e
23 Author: Felix Fietkau <nbd@openwrt.org>
24 Date: Tue Mar 11 14:03:32 2014 +0100
25
26 ath9k_hw: set ANI firstep as absolute values instead of relative
27
28 On older chips, the INI value differ in similar ways as cycpwr_thr1, so
29 convert it to absolute values as well.
30
31 Since the ANI algorithm is different here compared to the old
32 implementation (fewer steps, controlled at a different point in time),
33 it makes sense to use values similar to what would be applied for newer
34 chips, just without relying on INI defaults.
35
36 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
37
38 commit 91d70d40400c569b49605b78fd7c43e9405694f4
39 Author: Felix Fietkau <nbd@openwrt.org>
40 Date: Tue Mar 11 14:00:37 2014 +0100
41
42 ath9k_hw: set ANI cycpwr_thr1 as absolute values instead of relative
43
44 The table was copied from the ANI implementation of AR9300. It assumes
45 that the INI values contain a baseline value that is usable as reference
46 from which to increase/decrease based on the noise immunity value.
47
48 On older chips, the differences are bigger and especially AR5008/AR9001
49 are configured to much more sensitive values than what is useful.
50
51 Improve ANI behavior by reverting to the absolute values used in the
52 previous implementation (expressed as a simple formula instead of the
53 old table).
54
55 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
56
57 commit c977493766310a825f406836636ffd66e1447783
58 Author: Felix Fietkau <nbd@openwrt.org>
59 Date: Mon Mar 10 19:52:56 2014 +0100
60
61 ath9k_hw: remove ANI function restrictions for AP mode
62
63 The primary purpose of this piece of code was to selectively disable
64 OFDM weak signal detection. The checks for this are elsewhere, and an
65 earlier commit relaxed the restrictions for older chips, which are more
66 sensitive to interference.
67
68 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
69
70 commit 8d804f1af11e4e058b1e8453327777d73a585cb8
71 Author: Felix Fietkau <nbd@openwrt.org>
72 Date: Sun Mar 9 11:25:43 2014 +0100
73
74 ath9k: clean up and enhance ANI debugfs file
75
76 Unify scnprintf calls and include the current OFDM/CCK immunity level.
77
78 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
79
80 commit 22e298b5a3a8a49e33805d4e351965123dede35b
81 Author: Felix Fietkau <nbd@openwrt.org>
82 Date: Sun Mar 9 10:58:47 2014 +0100
83
84 ath9k: fix ready time of the multicast buffer queue
85
86 qi->tqi_readyTime is written directly to registers that expect
87 microseconds as unit instead of TU.
88 When setting the CABQ ready time, cur_conf->beacon_interval is in TU, so
89 convert it to microseconds before passing it to ath9k_hw.
90
91 This should hopefully fix some Tx DMA issues with buffered multicast
92 frames in AP mode.
93
94 Cc: stable@vger.kernel.org
95 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
96
97 commit fcb064fdd5a27bec8d24099bc0172468f34c97cb
98 Author: Felix Fietkau <nbd@openwrt.org>
99 Date: Sun Mar 9 09:43:09 2014 +0100
100
101 ath9k_hw: fix unreachable code in baseband hang detection code
102
103 The commit "ath9k: reduce baseband hang detection false positive rate"
104 added a delay in the loop checking the baseband state, however it was
105 unreachable due to previous 'continue' statements.
106
107 Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
108 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
109
110 commit 31959d8df39319e32c6d5ba9c135727be90cfad7
111 Author: Michal Kazior <michal.kazior@tieto.com>
112 Date: Fri Mar 7 08:09:38 2014 +0100
113
114 mac80211: fix possible NULL dereference
115
116 If chanctx is missing on a given vif then the band
117 is assumed to be 2GHz. However if hw doesn't
118 support 2GHz band then mac80211 ended up with a
119 NULL dereference.
120
121 This fixes a splat:
122
123 [ 4605.207223] BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
124 [ 4605.210789] IP: [<ffffffffa07b5635>] ieee80211_parse_bitrates+0x65/0x110 [mac80211]
125
126 The splat was preceeded by WARN_ON(!chanctx_conf)
127 in ieee80211_get_sdata_band().
128
129 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
130
131 commit 6c5a3ffa0a2d22c091a2717f427259bacf77ac5e
132 Author: Michael Braun <michael-dev@fami-braun.de>
133 Date: Thu Mar 6 15:08:43 2014 +0100
134
135 mac80211: fix WPA with VLAN on AP side with ps-sta again
136
137 commit de74a1d9032f4d37ea453ad2a647e1aff4cd2591
138 "mac80211: fix WPA with VLAN on AP side with ps-sta"
139 fixed an issue where queued multicast packets would
140 be sent out encrypted with the key of an other bss.
141
142 commit "7cbf9d017dbb5e3276de7d527925d42d4c11e732"
143 "mac80211: fix oops on mesh PS broadcast forwarding"
144 essentially reverted it, because vif.type cannot be AP_VLAN
145 due to the check to vif.type in ieee80211_get_buffered_bc before.
146
147 As the later commit intended to fix the MESH case, fix it
148 by checking for IFTYPE_AP instead of IFTYPE_AP_VLAN.
149
150 Fixes: 7cbf9d017dbb
151 Cc: <stable@vger.kernel.org> # 3.10.x
152 Cc: <stable@vger.kernel.org> # 3.11.x
153 Cc: <stable@vger.kernel.org> # 3.12.x
154 Cc: <stable@vger.kernel.org> # 3.13.x
155 Cc: <linux-wireless@vger.kernel.org>
156 Cc: <projekt-wlan@fem.tu-ilmenau.de>
157 Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
158
159 commit 9d6ab9bdb9b368a6cf9519f0f92509b5b2c297ec
160 Author: Johannes Berg <johannes.berg@intel.com>
161 Date: Mon Mar 3 14:19:08 2014 +0100
162
163 cfg80211: remove racy beacon_interval assignment
164
165 In case of AP mode, the beacon interval is already reset to
166 zero inside cfg80211_stop_ap(), and in the other modes it
167 isn't relevant. Remove the assignment to remove a potential
168 race since the assignment isn't properly locked.
169
170 Reported-by: Michal Kazior <michal.kazior@tieto.com>
171 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
172
173 commit 1abdeca3c6fb9cf1f84f85e78ed8d1c33bd69db0
174 Author: Felix Fietkau <nbd@openwrt.org>
175 Date: Fri Feb 28 18:52:56 2014 +0100
176
177 ath9k_hw: tweak noise immunity thresholds for older chipsets
178
179 Older chipsets are more sensitive to high PHY error counts, and the
180 current noise immunity thresholds were based on tests run at QCA with
181 newer chipsets.
182
183 This patch brings back the values from the old ANI implementation for
184 old chipsets, and it also disables weak signal detection on an earlier
185 noise immunity level, to improve overall radio stability on affected
186 devices.
187
188 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
189
190 commit 431e506da5953adc3b65af25f4b90873d528c115
191 Author: Felix Fietkau <nbd@openwrt.org>
192 Date: Fri Feb 28 18:44:13 2014 +0100
193
194 ath9k_hw: toggle weak signal detection in AP mode on older chipsets
195
196 The commit 80b4205b "ath9k: Fix OFDM weak signal detection for AP mode"
197 prevented weak signal detection changes from taking effect in AP mode on
198 all chipsets, claiming it is "not allowed".
199
200 The main reason for not disabling weak signal detection in AP mode is
201 that typically beacon RSSI is used to track whether it is needed to
202 boost range, and this is unavailable in AP mode for obvious reasons.
203
204 The problem with not disabling weak signal detection is that older
205 chipsets are very sensitive to high PHY error counts. When faced with
206 heavy noise, this can lead to an excessive amount of "Failed to stop
207 TX DMA" errors in the field.
208
209 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
210
211 commit 98d1a6c5b14688ed030e81b889f607be308e0df9
212 Author: Felix Fietkau <nbd@openwrt.org>
213 Date: Mon Feb 24 22:20:32 2014 +0100
214
215 ath9k: fix invalid descriptor discarding
216
217 Only set sc->rx.discard_next to rx_stats->rs_more when actually
218 discarding the current descriptor.
219
220 Also, fix a detection of broken descriptors:
221 First the code checks if the current descriptor is not done.
222 Then it checks if the next descriptor is done.
223 Add a check that afterwards checks the first descriptor again, because
224 it might have been completed in the mean time.
225
226 This fixes a regression introduced in
227 commit 723e711356b5a8a95728a890e254e8b0d47b55cf
228 "ath9k: fix handling of broken descriptors"
229
230 Cc: stable@vger.kernel.org
231 Reported-by: Marco André Dinis <marcoandredinis@gmail.com>
232 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
233
234 commit 52a46300e782fe6994466523eb2b0b59091ea59f
235 Author: Felix Fietkau <nbd@openwrt.org>
236 Date: Mon Feb 24 11:43:50 2014 +0100
237
238 ath9k: reduce baseband hang detection false positive rate
239
240 Check if the baseband state remains stable, and add a small delay
241 between register reads.
242
243 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
244
245 commit 118945bb12082e9d4edddc868d88143164e0f440
246 Author: Felix Fietkau <nbd@openwrt.org>
247 Date: Sat Feb 22 14:55:23 2014 +0100
248
249 ath5k: set SURVEY_INFO_IN_USE on get_survey
250
251 Only one channel is returned - the one currently being used.
252
253 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
254
255 commit ee41f72476e1ea44283dfe1cbf75b9543a1e15c8
256 Author: Felix Fietkau <nbd@openwrt.org>
257 Date: Sat Feb 22 14:44:52 2014 +0100
258
259 ath9k: make some hardware reset log messages debug-only
260
261 On some chips, baseband watchdog hangs are more common than others, and
262 the driver has support for handling them.
263 Interrupts even after a watchdog hang are also quite common, so there's
264 not much point in spamming the user's logfiles.
265
266 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
267
268 commit b14fbb554fc65a2e0b5c41a319269b0350f187e7
269 Author: Felix Fietkau <nbd@openwrt.org>
270 Date: Sat Feb 22 14:35:25 2014 +0100
271
272 ath9k: do not set half/quarter channel flags in AR_PHY_MODE
273
274 5/10 MHz channel bandwidth is configured via the PLL clock, instead of
275 the AR_PHY_MODE register. Using that register is AR93xx specific, and
276 makes the mode incompatible with earlier chipsets.
277
278 In some early versions, these flags were apparently applied at the wrong
279 point in time and thus did not cause connectivity issues, however now
280 they are causing problems, as pointed out in this OpenWrt ticket:
281
282 https://dev.openwrt.org/ticket/14916
283
284 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
285
286 commit 0f1cb7be2551b30b02cd54c897e0e29e483cfda5
287 Author: Felix Fietkau <nbd@openwrt.org>
288 Date: Sat Feb 22 13:43:29 2014 +0100
289
290 ath9k: fix ps-poll responses under a-mpdu sessions
291
292 When passing tx frames to the U-APSD queue for powersave poll responses,
293 the ath_atx_tid pointer needs to be passed to ath_tx_setup_buffer for
294 proper sequence number accounting.
295
296 This fixes high latency and connection stability issues with ath9k
297 running as AP and a few kinds of mobile phones as client, when PS-Poll
298 is heavily used
299
300 Cc: stable@vger.kernel.org
301 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
302
303 commit d5d87a37bbd6066b2c3c5d0bd0fe2a6e2ea45cc5
304 Author: Felix Fietkau <nbd@openwrt.org>
305 Date: Fri Feb 21 11:39:59 2014 +0100
306
307 ath9k: list more reset causes in debugfs
308
309 Number of MAC hangs and stuck beacons were missing
310
311 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
312
313 commit d84856012e0f10fe598a5ad3b7b869397a089e07
314 Author: Johannes Berg <johannes.berg@intel.com>
315 Date: Thu Feb 20 11:19:58 2014 +0100
316
317 mac80211: fix station wakeup powersave race
318
319 Consider the following (relatively unlikely) scenario:
320 1) station goes to sleep while frames are buffered in driver
321 2) driver blocks wakeup (until no more frames are buffered)
322 3) station wakes up again
323 4) driver unblocks wakeup
324
325 In this case, the current mac80211 code will do the following:
326 1) WLAN_STA_PS_STA set
327 2) WLAN_STA_PS_DRIVER set
328 3) - nothing -
329 4) WLAN_STA_PS_DRIVER cleared
330
331 As a result, no frames will be delivered to the client, even
332 though it is awake, until it sends another frame to us that
333 triggers ieee80211_sta_ps_deliver_wakeup() in sta_ps_end().
334
335 Since we now take the PS spinlock, we can fix this while at
336 the same time removing the complexity with the pending skb
337 queue function. This was broken since my commit 50a9432daeec
338 ("mac80211: fix powersaving clients races") due to removing
339 the clearing of WLAN_STA_PS_STA in the RX path.
340
341 While at it, fix a cleanup path issue when a station is
342 removed while the driver is still blocking its wakeup.
343
344 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
345
346 commit 798f2786602cbe93e6b928299614aa36ebf50692
347 Author: Johannes Berg <johannes.berg@intel.com>
348 Date: Mon Feb 17 20:49:03 2014 +0100
349
350 mac80211: insert stations before adding to driver
351
352 There's a race condition in mac80211 because we add stations
353 to the internal lists after adding them to the driver, which
354 means that (for example) the following can happen:
355 1. a station connects and is added
356 2. first, it is added to the driver
357 3. then, it is added to the mac80211 lists
358
359 If the station goes to sleep between steps 2 and 3, and the
360 firmware/hardware records it as being asleep, mac80211 will
361 never instruct the driver to wake it up again as it never
362 realized it went to sleep since the RX path discarded the
363 frame as a "spurious class 3 frame", no station entry was
364 present yet.
365
366 Fix this by adding the station in software first, and only
367 then adding it to the driver. That way, any state that the
368 driver changes will be reflected properly in mac80211's
369 station state. The problematic part is the roll-back if the
370 driver fails to add the station, in that case a bit more is
371 needed. To not make that overly complex prevent starting BA
372 sessions in the meantime.
373
374 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
375
376 commit b9ba6a520cb07ab3aa7aaaf9ce4a0bc7a6bc06fe
377 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
378 Date: Thu Feb 20 09:22:11 2014 +0200
379
380 mac80211: fix AP powersave TX vs. wakeup race
381
382 There is a race between the TX path and the STA wakeup: while
383 a station is sleeping, mac80211 buffers frames until it wakes
384 up, then the frames are transmitted. However, the RX and TX
385 path are concurrent, so the packet indicating wakeup can be
386 processed while a packet is being transmitted.
387
388 This can lead to a situation where the buffered frames list
389 is emptied on the one side, while a frame is being added on
390 the other side, as the station is still seen as sleeping in
391 the TX path.
392
393 As a result, the newly added frame will not be send anytime
394 soon. It might be sent much later (and out of order) when the
395 station goes to sleep and wakes up the next time.
396
397 Additionally, it can lead to the crash below.
398
399 Fix all this by synchronising both paths with a new lock.
400 Both path are not fastpath since they handle PS situations.
401
402 In a later patch we'll remove the extra skb queue locks to
403 reduce locking overhead.
404
405 BUG: unable to handle kernel
406 NULL pointer dereference at 000000b0
407 IP: [<ff6f1791>] ieee80211_report_used_skb+0x11/0x3e0 [mac80211]
408 *pde = 00000000
409 Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
410 EIP: 0060:[<ff6f1791>] EFLAGS: 00210282 CPU: 1
411 EIP is at ieee80211_report_used_skb+0x11/0x3e0 [mac80211]
412 EAX: e5900da0 EBX: 00000000 ECX: 00000001 EDX: 00000000
413 ESI: e41d00c0 EDI: e5900da0 EBP: ebe458e4 ESP: ebe458b0
414 DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
415 CR0: 8005003b CR2: 000000b0 CR3: 25a78000 CR4: 000407d0
416 DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
417 DR6: ffff0ff0 DR7: 00000400
418 Process iperf (pid: 3934, ti=ebe44000 task=e757c0b0 task.ti=ebe44000)
419 iwlwifi 0000:02:00.0: I iwl_pcie_enqueue_hcmd Sending command LQ_CMD (#4e), seq: 0x0903, 92 bytes at 3[3]:9
420 Stack:
421 e403b32c ebe458c4 00200002 00200286 e403b338 ebe458cc c10960bb e5900da0
422 ff76a6ec ebe458d8 00000000 e41d00c0 e5900da0 ebe458f0 ff6f1b75 e403b210
423 ebe4598c ff723dc1 00000000 ff76a6ec e597c978 e403b758 00000002 00000002
424 Call Trace:
425 [<ff6f1b75>] ieee80211_free_txskb+0x15/0x20 [mac80211]
426 [<ff723dc1>] invoke_tx_handlers+0x1661/0x1780 [mac80211]
427 [<ff7248a5>] ieee80211_tx+0x75/0x100 [mac80211]
428 [<ff7249bf>] ieee80211_xmit+0x8f/0xc0 [mac80211]
429 [<ff72550e>] ieee80211_subif_start_xmit+0x4fe/0xe20 [mac80211]
430 [<c149ef70>] dev_hard_start_xmit+0x450/0x950
431 [<c14b9aa9>] sch_direct_xmit+0xa9/0x250
432 [<c14b9c9b>] __qdisc_run+0x4b/0x150
433 [<c149f732>] dev_queue_xmit+0x2c2/0xca0
434
435 Cc: stable@vger.kernel.org
436 Reported-by: Yaara Rozenblum <yaara.rozenblum@intel.com>
437 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
438 Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
439 [reword commit log, use a separate lock]
440 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
441
442 commit 80e419de0dff38436b30d363311c625766193f86
443 Author: Inbal Hacohen <Inbal.Hacohen@intel.com>
444 Date: Wed Feb 12 09:32:27 2014 +0200
445
446 cfg80211: bugfix in regulatory user hint process
447
448 After processing hint_user, we would want to schedule the
449 timeout work only if we are actually waiting to CRDA. This happens
450 when the status is not "IGNORE" nor "ALREADY_SET".
451
452 Signed-off-by: Inbal Hacohen <Inbal.Hacohen@intel.com>
453 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
454
455 commit 6514c93afede55284e2cb63359aadedb85884c80
456 Author: Jouni Malinen <jouni@qca.qualcomm.com>
457 Date: Tue Feb 18 20:41:08 2014 +0200
458
459 ath9k: Enable U-APSD AP mode support
460
461 mac80211 handles the actual operations, so ath9k can just indicate
462 support for this. Based on initial tests, this combination seems to
463 work fine.
464
465 Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
466
467 commit a63caf0a357ad5c1f08d6b7827dc76c451445017
468 Author: Stanislaw Gruszka <sgruszka@redhat.com>
469 Date: Wed Feb 19 13:15:17 2014 +0100
470
471 ath9k: protect tid->sched check
472
473 We check tid->sched without a lock taken on ath_tx_aggr_sleep(). That
474 is race condition which can result of doing list_del(&tid->list) twice
475 (second time with poisoned list node) and cause crash like shown below:
476
477 [424271.637220] BUG: unable to handle kernel paging request at 00100104
478 [424271.637328] IP: [<f90fc072>] ath_tx_aggr_sleep+0x62/0xe0 [ath9k]
479 ...
480 [424271.639953] Call Trace:
481 [424271.639998] [<f90f6900>] ? ath9k_get_survey+0x110/0x110 [ath9k]
482 [424271.640083] [<f90f6942>] ath9k_sta_notify+0x42/0x50 [ath9k]
483 [424271.640177] [<f809cfef>] sta_ps_start+0x8f/0x1c0 [mac80211]
484 [424271.640258] [<c10f730e>] ? free_compound_page+0x2e/0x40
485 [424271.640346] [<f809e915>] ieee80211_rx_handlers+0x9d5/0x2340 [mac80211]
486 [424271.640437] [<c112f048>] ? kmem_cache_free+0x1d8/0x1f0
487 [424271.640510] [<c1345a84>] ? kfree_skbmem+0x34/0x90
488 [424271.640578] [<c10fc23c>] ? put_page+0x2c/0x40
489 [424271.640640] [<c1345a84>] ? kfree_skbmem+0x34/0x90
490 [424271.640706] [<c1345a84>] ? kfree_skbmem+0x34/0x90
491 [424271.640787] [<f809dde3>] ? ieee80211_rx_handlers_result+0x73/0x1d0 [mac80211]
492 [424271.640897] [<f80a07a0>] ieee80211_prepare_and_rx_handle+0x520/0xad0 [mac80211]
493 [424271.641009] [<f809e22d>] ? ieee80211_rx_handlers+0x2ed/0x2340 [mac80211]
494 [424271.641104] [<c13846ce>] ? ip_output+0x7e/0xd0
495 [424271.641182] [<f80a1057>] ieee80211_rx+0x307/0x7c0 [mac80211]
496 [424271.641266] [<f90fa6ee>] ath_rx_tasklet+0x88e/0xf70 [ath9k]
497 [424271.641358] [<f80a0f2c>] ? ieee80211_rx+0x1dc/0x7c0 [mac80211]
498 [424271.641445] [<f90f82db>] ath9k_tasklet+0xcb/0x130 [ath9k]
499
500 Bug report:
501 https://bugzilla.kernel.org/show_bug.cgi?id=70551
502
503 Reported-and-tested-by: Max Sydorenko <maxim.stargazer@gmail.com>
504 Cc: stable@vger.kernel.org
505 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
506
507 commit 82ed9e3ccc02797df2ffe4b78127c4cd5f799a41
508 Author: Felix Fietkau <nbd@openwrt.org>
509 Date: Tue Feb 11 15:54:13 2014 +0100
510
511 mac80211: send control port protocol frames to the VO queue
512
513 Improves reliability of wifi connections with WPA, since authentication
514 frames are prioritized over normal traffic and also typically exempt
515 from aggregation.
516
517 Cc: stable@vger.kernel.org
518 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
519
520 commit d4426800f71e972feaa33e04c5801fc730627bdd
521 Author: Stanislaw Gruszka <stf_xl@wp.pl>
522 Date: Mon Feb 10 22:38:28 2014 +0100
523
524 rtl8187: fix regression on MIPS without coherent DMA
525
526 This patch fixes regression caused by commit a16dad77634 "MIPS: Fix
527 potencial corruption". That commit fixes one corruption scenario in
528 cost of adding another one, which actually start to cause crashes
529 on Yeeloong laptop when rtl8187 driver is used.
530
531 For correct DMA read operation on machines without DMA coherence, kernel
532 have to invalidate cache, such it will refill later with new data that
533 device wrote to memory, when that data is needed to process. We can only
534 invalidate full cache line. Hence when cache line includes both dma
535 buffer and some other data (written in cache, but not yet in main
536 memory), the other data can not hit memory due to invalidation. That
537 happen on rtl8187 where struct rtl8187_priv fields are located just
538 before and after small buffers that are passed to USB layer and DMA
539 is performed on them.
540
541 To fix the problem we align buffers and reserve space after them to make
542 them match cache line.
543
544 This patch does not resolve all possible MIPS problems entirely, for
545 that we have to assure that we always map cache aligned buffers for DMA,
546 what can be complex or even not possible. But patch fixes visible and
547 reproducible regression and seems other possible corruptions do not
548 happen in practice, since Yeeloong laptop works stable without rtl8187
549 driver.
550
551 Bug report:
552 https://bugzilla.kernel.org/show_bug.cgi?id=54391
553
554 Reported-by: Petr Pisar <petr.pisar@atlas.cz>
555 Bisected-by: Tom Li <biergaizi2009@gmail.com>
556 Reported-and-tested-by: Tom Li <biergaizi2009@gmail.com>
557 Cc: stable@vger.kernel.org
558 Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
559
560 commit e2f141d67ad1e7fe10aaab61811e8a409dfb2442
561 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
562 Date: Fri Feb 7 10:29:55 2014 +0530
563
564 ath9k: Calculate IQ-CAL median
565
566 This patch adds a routine to calculate the median IQ correction
567 values for AR955x, which is used for outlier detection.
568 The normal method which is used for all other chips is
569 bypassed for AR955x.
570
571 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
572
573 commit c52a6fce0820c8d0687443ab86058ae03b478c8f
574 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
575 Date: Fri Feb 7 10:29:54 2014 +0530
576
577 ath9k: Expand the IQ coefficient array
578
579 This will be used for storing data for mutiple
580 IQ calibration runs, for AR955x.
581
582 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
583
584 commit 034969ff5c2b6431d10e07c1938f0b916da85cc3
585 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
586 Date: Fri Feb 7 10:29:53 2014 +0530
587
588 ath9k: Modify IQ calibration for AR955x
589
590 IQ calibration post-processing for AR955x is different
591 from other chips - instead of just doing it as part
592 of AGC calibration once, it is triggered 3 times and
593 a median is determined. This patch adds initial support
594 for changing the calibration behavior for AR955x.
595
596 Also, to simplify things, a helper routine to issue/poll
597 AGC calibration is used.
598
599 For non-AR955x chips, the iqcal_idx (which will be used
600 in subsequent patches) is set to zero.
601
602 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
603
604 commit 9b1ed6454e6f3511f24266be99b4e403f243f6a8
605 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
606 Date: Fri Feb 7 10:29:52 2014 +0530
607
608 ath9k: Fix magnitude/phase calculation
609
610 Incorrect values are programmed in the registers
611 containing the IQ correction coefficients by the IQ-CAL
612 post-processing code. Fix this.
613
614 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
615
616 commit 36f93484f96f79171dcecb67c5ef0c3de22531a6
617 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
618 Date: Fri Feb 7 10:29:51 2014 +0530
619
620 ath9k: Rename ar9003_hw_tx_iqcal_load_avg_2_passes
621
622 Use ar9003_hw_tx_iq_cal_outlier_detection instead.
623
624 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
625
626 commit 3af09a7f5d21dd5fd15b973ce6a91a575da30417
627 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
628 Date: Fri Feb 7 10:29:50 2014 +0530
629
630 ath9k: Check explicitly for IQ calibration
631
632 In chips like AR955x, the initvals contain the information
633 whether IQ calibration is to be done in the HW when an
634 AGC calibration is triggered. Check if IQ-CAL is enabled
635 in the initvals before flagging 'txiqcal_done' as true.
636
637 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
638
639 commit cb4969634b93c4643a32cc3fbd27d2b288b25771
640 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
641 Date: Fri Feb 7 10:29:49 2014 +0530
642
643 ath9k: Fix IQ cal post processing for SoC
644
645 Calibration data is not reused for SoC chips, so
646 call ar9003_hw_tx_iq_cal_post_proc() with the correct
647 argument. The 'is_reusable' flag is currently used
648 only for PC-OEM chips, but it makes things clearer to
649 specify it explicity.
650
651 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
652
653 commit e138e0ef9560c46ce93dbb22a728a57888e94d1c
654 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
655 Date: Mon Feb 3 13:31:37 2014 +0530
656
657 ath9k: Fix TX power calculation
658
659 The commit, "ath9k_hw: Fix incorrect Tx control power in AR9003 template"
660 fixed the incorrect values in the eeprom templates, but if
661 boards have already been calibrated with incorrect values,
662 they would still be using the wrong TX power. Fix this by assigning
663 a default value in such cases.
664
665 Cc: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
666 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
667
668 commit b9f268b5b01331c3c82179abca551429450e9417
669 Author: Michal Kazior <michal.kazior@tieto.com>
670 Date: Wed Jan 29 14:22:27 2014 +0100
671
672 cfg80211: consider existing DFS interfaces
673
674 It was possible to break interface combinations in
675 the following way:
676
677 combo 1: iftype = AP, num_ifaces = 2, num_chans = 2,
678 combo 2: iftype = AP, num_ifaces = 1, num_chans = 1, radar = HT20
679
680 With the above interface combinations it was
681 possible to:
682
683 step 1. start AP on DFS channel by matching combo 2
684 step 2. start AP on non-DFS channel by matching combo 1
685
686 This was possible beacuse (step 2) did not consider
687 if other interfaces require radar detection.
688
689 The patch changes how cfg80211 tracks channels -
690 instead of channel itself now a complete chandef
691 is stored.
692
693 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
694 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
695
696 commit bc9c62f5f511cc395c62dbf4cdd437f23db53b28
697 Author: Antonio Quartulli <antonio@open-mesh.com>
698 Date: Wed Jan 29 17:53:43 2014 +0100
699
700 cfg80211: fix channel configuration in IBSS join
701
702 When receiving an IBSS_JOINED event select the BSS object
703 based on the {bssid, channel} couple rather than the bssid
704 only.
705 With the current approach if another cell having the same
706 BSSID (but using a different channel) exists then cfg80211
707 picks up the wrong BSS object.
708 The result is a mismatching channel configuration between
709 cfg80211 and the driver, that can lead to any sort of
710 problem.
711
712 The issue can be triggered by having an IBSS sitting on
713 given channel and then asking the driver to create a new
714 cell using the same BSSID but with a different frequency.
715 By passing the channel to cfg80211_get_bss() we can solve
716 this ambiguity and retrieve/create the correct BSS object.
717 All the users of cfg80211_ibss_joined() have been changed
718 accordingly.
719
720 Moreover WARN when cfg80211_ibss_joined() gets a NULL
721 channel as argument and remove a bogus call of the same
722 function in ath6kl (it does not make sense to call
723 cfg80211_ibss_joined() with a zero BSSID on ibss-leave).
724
725 Cc: Kalle Valo <kvalo@qca.qualcomm.com>
726 Cc: Arend van Spriel <arend@broadcom.com>
727 Cc: Bing Zhao <bzhao@marvell.com>
728 Cc: Jussi Kivilinna <jussi.kivilinna@iki.fi>
729 Cc: libertas-dev@lists.infradead.org
730 Acked-by: Kalle Valo <kvalo@qca.qualcomm.com>
731 Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
732 [minor code cleanup in ath6kl]
733 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
734
735 commit 7e0c41cb41f215aba2c39b1c237bb4d42ec49a85
736 Author: Johannes Berg <johannes.berg@intel.com>
737 Date: Fri Jan 24 14:41:44 2014 +0100
738
739 mac80211: fix bufferable MMPDU RX handling
740
741 Action, disassoc and deauth frames are bufferable, and as such don't
742 have the PM bit in the frame control field reserved which means we
743 need to react to the bit when receiving in such a frame.
744
745 Fix this by introducing a new helper ieee80211_is_bufferable_mmpdu()
746 and using it for the RX path that currently ignores the PM bit in
747 any non-data frames for doze->wake transitions, but listens to it in
748 all frames for wake->doze transitions, both of which are wrong.
749
750 Also use the new helper in the TX path to clean up the code.
751
752 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
753
754 commit fc0df6d2343636e3f48a069330d5b972e3d8659d
755 Author: Janusz Dziedzic <janusz.dziedzic@tieto.com>
756 Date: Fri Jan 24 14:29:21 2014 +0100
757
758 cfg80211: set preset_chandef after channel switch
759
760 Set preset_chandef in channel switch notification.
761 In other case we will have old preset_chandef.
762
763 Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
764 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
765
766 commit cdec895e2344987ff171cece96e25d7407a3ebf6
767 Author: Simon Wunderlich <simon@open-mesh.com>
768 Date: Fri Jan 24 23:48:29 2014 +0100
769
770 mac80211: send ibss probe responses with noack flag
771
772 Responding to probe requests for scanning clients will often create
773 excessive retries, as it happens quite often that the scanning client
774 already left the channel. Therefore do it like hostapd and send probe
775 responses for wildcard SSID only once by using the noack flag.
776
777 Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
778 [fix typo & 'wildcard SSID' in commit log]
779 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
780
781 commit 0b865d1e6b9c05052adae9315df7cb195dc60c3b
782 Author: Luciano Coelho <luciano.coelho@intel.com>
783 Date: Tue Jan 28 17:09:08 2014 +0200
784
785 mac80211: ibss: remove unnecessary call to release channel
786
787 The ieee80211_vif_use_channel() function calls
788 ieee80211_vif_release_channel(), so there's no need to call it
789 explicitly in __ieee80211_sta_join_ibss().
790
791 Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
792 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
793
794 commit e1b6c17e971f0a51ff86c2dac2584c63cd999cd7
795 Author: Michal Kazior <michal.kazior@tieto.com>
796 Date: Wed Jan 29 07:56:21 2014 +0100
797
798 mac80211: add missing CSA locking
799
800 The patch adds a missing sdata lock and adds a few
801 lockdeps for easier maintenance.
802
803 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
804 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
805
806 commit ad17ba7d14d225b109b73c177cd446afb8050598
807 Author: Michal Kazior <michal.kazior@tieto.com>
808 Date: Wed Jan 29 07:56:20 2014 +0100
809
810 mac80211: fix sdata->radar_required locking
811
812 radar_required setting wasn't protected by
813 local->mtx in some places. This should prevent
814 from scanning/radar detection/roc colliding.
815
816 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
817 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
818
819 commit 5fcd5f1808813a3d9e502fd756e01bee8a79c85d
820 Author: Michal Kazior <michal.kazior@tieto.com>
821 Date: Wed Jan 29 07:56:19 2014 +0100
822
823 mac80211: move csa_active setting in STA CSA
824
825 The sdata->vif.csa_active could be left set after,
826 e.g. channel context constraints check fail in STA
827 mode leaving the interface in a strange state for
828 a brief period of time until it is disconnected.
829 This was harmless but ugly.
830
831 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
832 Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
833 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
834
835 commit e486da4b7eed71821c6b4c1bb9ac62ffd3ab13e9
836 Author: Michal Kazior <michal.kazior@tieto.com>
837 Date: Wed Jan 29 07:56:18 2014 +0100
838
839 mac80211: fix possible memory leak on AP CSA failure
840
841 If CSA for AP interface failed and the interface
842 was not stopped afterwards another CSA request
843 would leak sdata->u.ap.next_beacon.
844
845 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
846 Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
847 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
848
849 commit 3a77ba08940682bf3d52cf14f980337324af9d4a
850 Author: Johannes Berg <johannes.berg@intel.com>
851 Date: Sat Feb 1 00:33:29 2014 +0100
852
853 mac80211: fix fragmentation code, particularly for encryption
854
855 The "new" fragmentation code (since my rewrite almost 5 years ago)
856 erroneously sets skb->len rather than using skb_trim() to adjust
857 the length of the first fragment after copying out all the others.
858 This leaves the skb tail pointer pointing to after where the data
859 originally ended, and thus causes the encryption MIC to be written
860 at that point, rather than where it belongs: immediately after the
861 data.
862
863 The impact of this is that if software encryption is done, then
864 a) encryption doesn't work for the first fragment, the connection
865 becomes unusable as the first fragment will never be properly
866 verified at the receiver, the MIC is practically guaranteed to
867 be wrong
868 b) we leak up to 8 bytes of plaintext (!) of the packet out into
869 the air
870
871 This is only mitigated by the fact that many devices are capable
872 of doing encryption in hardware, in which case this can't happen
873 as the tail pointer is irrelevant in that case. Additionally,
874 fragmentation is not used very frequently and would normally have
875 to be configured manually.
876
877 Fix this by using skb_trim() properly.
878
879 Cc: stable@vger.kernel.org
880 Fixes: 2de8e0d999b8 ("mac80211: rewrite fragmentation")
881 Reported-by: Jouni Malinen <j@w1.fi>
882 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
883
884 commit de5f242e0c10e841017e37eb8c38974a642dbca8
885 Author: Sujith Manoharan <c_manoha@qca.qualcomm.com>
886 Date: Tue Jan 28 06:21:59 2014 +0530
887
888 ath9k: Fix build error on ARM
889
890 Use mdelay instead of udelay to fix this error:
891
892 ERROR: "__bad_udelay" [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!
893 make[1]: *** [__modpost] Error 1
894 make: *** [modules] Error 2
895
896 Reported-by: Josh Boyer <jwboyer@fedoraproject.org>
897 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
898
899 commit 8e3ea7a51dfc61810fcefd947f6edcf61125252a
900 Author: Geert Uytterhoeven <geert@linux-m68k.org>
901 Date: Sun Jan 26 11:53:21 2014 +0100
902
903 ath9k: Fix uninitialized variable in ath9k_has_tx_pending()
904
905 drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_has_tx_pending’:
906 drivers/net/wireless/ath/ath9k/main.c:1869: warning: ‘npend’ may be used uninitialized in this function
907
908 Introduced by commit 10e2318103f5941aa70c318afe34bc41f1b98529 ("ath9k:
909 optimize ath9k_flush").
910
911 Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
912
913 commit a4a634a6937ebdd827fa58e8fcdb8ca49a3769f6
914 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
915 Date: Mon Jan 27 11:07:42 2014 +0200
916
917 mac80211: release the channel in error path in start_ap
918
919 When the driver cannot start the AP or when the assignement
920 of the beacon goes wrong, we need to unassign the vif.
921
922 Cc: stable@vger.kernel.org
923 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
924 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
925
926 commit dfb6889a75c601aedb7450b7e606668e77da6679
927 Author: Johannes Berg <johannes.berg@intel.com>
928 Date: Wed Jan 22 11:14:19 2014 +0200
929
930 cfg80211: send scan results from work queue
931
932 Due to the previous commit, when a scan finishes, it is in theory
933 possible to hit the following sequence:
934 1. interface starts being removed
935 2. scan is cancelled by driver and cfg80211 is notified
936 3. scan done work is scheduled
937 4. interface is removed completely, rdev->scan_req is freed,
938 event sent to userspace but scan done work remains pending
939 5. new scan is requested on another virtual interface
940 6. scan done work runs, freeing the still-running scan
941
942 To fix this situation, hang on to the scan done message and block
943 new scans while that is the case, and only send the message from
944 the work function, regardless of whether the scan_req is already
945 freed from interface removal. This makes step 5 above impossible
946 and changes step 6 to be
947 5. scan done work runs, sending the scan done message
948
949 As this can't work for wext, so we send the message immediately,
950 but this shouldn't be an issue since we still return -EBUSY.
951
952 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
953
954 commit 45b7ab41fc08627d9a8428cb413d5d84662a9707
955 Author: Johannes Berg <johannes.berg@intel.com>
956 Date: Wed Jan 22 11:14:18 2014 +0200
957
958 cfg80211: fix scan done race
959
960 When an interface/wdev is removed, any ongoing scan should be
961 cancelled by the driver. This will make it call cfg80211, which
962 only queues a work struct. If interface/wdev removal is quick
963 enough, this can leave the scan request pending and processed
964 only after the interface is gone, causing a use-after-free.
965
966 Fix this by making sure the scan request is not pending after
967 the interface is destroyed. We can't flush or cancel the work
968 item due to locking concerns, but when it'll run it shouldn't
969 find anything to do. This leaves a potential issue, if a new
970 scan gets requested before the work runs, it prematurely stops
971 the running scan, potentially causing another crash. I'll fix
972 that in the next patch.
973
974 This was particularly observed with P2P_DEVICE wdevs, likely
975 because freeing them is quicker than freeing netdevs.
976
977 Reported-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
978 Fixes: 4a58e7c38443 ("cfg80211: don't "leak" uncompleted scans")
979 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
980
981 commit ae04fa489ab31b5a10d3cc8399f52761175d4321
982 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
983 Date: Thu Jan 23 14:28:16 2014 +0200
984
985 mac80211: avoid deadlock revealed by lockdep
986
987 sdata->u.ap.request_smps_work can’t be flushed synchronously
988 under wdev_lock(wdev) since ieee80211_request_smps_ap_work
989 itself locks the same lock.
990 While at it, reset the driver_smps_mode when the ap is
991 stopped to its default: OFF.
992
993 This solves:
994
995 ======================================================
996 [ INFO: possible circular locking dependency detected ]
997 3.12.0-ipeer+ #2 Tainted: G O
998 -------------------------------------------------------
999 rmmod/2867 is trying to acquire lock:
1000 ((&sdata->u.ap.request_smps_work)){+.+...}, at: [<c105b8d0>] flush_work+0x0/0x90
1001
1002 but task is already holding lock:
1003 (&wdev->mtx){+.+.+.}, at: [<f9b32626>] cfg80211_stop_ap+0x26/0x230 [cfg80211]
1004
1005 which lock already depends on the new lock.
1006
1007 the existing dependency chain (in reverse order) is:
1008
1009 -> #1 (&wdev->mtx){+.+.+.}:
1010 [<c10aefa9>] lock_acquire+0x79/0xe0
1011 [<c1607a1a>] mutex_lock_nested+0x4a/0x360
1012 [<fb06288b>] ieee80211_request_smps_ap_work+0x2b/0x50 [mac80211]
1013 [<c105cdd8>] process_one_work+0x198/0x450
1014 [<c105d469>] worker_thread+0xf9/0x320
1015 [<c10669ff>] kthread+0x9f/0xb0
1016 [<c1613397>] ret_from_kernel_thread+0x1b/0x28
1017
1018 -> #0 ((&sdata->u.ap.request_smps_work)){+.+...}:
1019 [<c10ae9df>] __lock_acquire+0x183f/0x1910
1020 [<c10aefa9>] lock_acquire+0x79/0xe0
1021 [<c105b917>] flush_work+0x47/0x90
1022 [<c105d867>] __cancel_work_timer+0x67/0xe0
1023 [<c105d90f>] cancel_work_sync+0xf/0x20
1024 [<fb0765cc>] ieee80211_stop_ap+0x8c/0x340 [mac80211]
1025 [<f9b3268c>] cfg80211_stop_ap+0x8c/0x230 [cfg80211]
1026 [<f9b0d8f9>] cfg80211_leave+0x79/0x100 [cfg80211]
1027 [<f9b0da72>] cfg80211_netdev_notifier_call+0xf2/0x4f0 [cfg80211]
1028 [<c160f2c9>] notifier_call_chain+0x59/0x130
1029 [<c106c6de>] __raw_notifier_call_chain+0x1e/0x30
1030 [<c106c70f>] raw_notifier_call_chain+0x1f/0x30
1031 [<c14f8213>] call_netdevice_notifiers_info+0x33/0x70
1032 [<c14f8263>] call_netdevice_notifiers+0x13/0x20
1033 [<c14f82a4>] __dev_close_many+0x34/0xb0
1034 [<c14f83fe>] dev_close_many+0x6e/0xc0
1035 [<c14f9c77>] rollback_registered_many+0xa7/0x1f0
1036 [<c14f9dd4>] unregister_netdevice_many+0x14/0x60
1037 [<fb06f4d9>] ieee80211_remove_interfaces+0xe9/0x170 [mac80211]
1038 [<fb055116>] ieee80211_unregister_hw+0x56/0x110 [mac80211]
1039 [<fa3e9396>] iwl_op_mode_mvm_stop+0x26/0xe0 [iwlmvm]
1040 [<f9b9d8ca>] _iwl_op_mode_stop+0x3a/0x70 [iwlwifi]
1041 [<f9b9d96f>] iwl_opmode_deregister+0x6f/0x90 [iwlwifi]
1042 [<fa405179>] __exit_compat+0xd/0x19 [iwlmvm]
1043 [<c10b8bf9>] SyS_delete_module+0x179/0x2b0
1044 [<c1613421>] sysenter_do_call+0x12/0x32
1045
1046 Fixes: 687da132234f ("mac80211: implement SMPS for AP")
1047 Cc: <stable@vger.kernel.org> [3.13]
1048 Reported-by: Ilan Peer <ilan.peer@intel.com>
1049 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
1050 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1051
1052 commit 178b205e96217164fd7c30113464250d0b6f5eca
1053 Author: Johannes Berg <johannes.berg@intel.com>
1054 Date: Thu Jan 23 16:32:29 2014 +0100
1055
1056 cfg80211: re-enable 5/10 MHz support
1057
1058 Unfortunately I forgot this during the merge window, but the
1059 patch seems small enough to go in as a fix. The userspace API
1060 bug that was the reason for disabling it has long been fixed.
1061
1062 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1063
1064 commit 110a1c79acda14edc83b7c8dc5af9c7ddd23eb61
1065 Author: Pontus Fuchs <pontus.fuchs@gmail.com>
1066 Date: Thu Jan 16 15:00:40 2014 +0100
1067
1068 nl80211: Reset split_start when netlink skb is exhausted
1069
1070 When the netlink skb is exhausted split_start is left set. In the
1071 subsequent retry, with a larger buffer, the dump is continued from the
1072 failing point instead of from the beginning.
1073
1074 This was causing my rt28xx based USB dongle to now show up when
1075 running "iw list" with an old iw version without split dump support.
1076
1077 Cc: stable@vger.kernel.org
1078 Fixes: 3713b4e364ef ("nl80211: allow splitting wiphy information in dumps")
1079 Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
1080 [avoid the entire workaround when state->split is set]
1081 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1082
1083 commit b4c31b45ffc7ef110fa9ecc34d7878fe7c5b9da4
1084 Author: Eliad Peller <eliad@wizery.com>
1085 Date: Sun Jan 12 11:06:37 2014 +0200
1086
1087 mac80211: move roc cookie assignment earlier
1088
1089 ieee80211_start_roc_work() might add a new roc
1090 to existing roc, and tell cfg80211 it has already
1091 started.
1092
1093 However, this might happen before the roc cookie
1094 was set, resulting in REMAIN_ON_CHANNEL (started)
1095 event with null cookie. Consequently, it can make
1096 wpa_supplicant go out of sync.
1097
1098 Fix it by setting the roc cookie earlier.
1099
1100 Cc: stable@vger.kernel.org
1101 Signed-off-by: Eliad Peller <eliad@wizery.com>
1102 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1103
1104 commit cfdc9157bfd7bcf88ab4dae08873a9907eba984c
1105 Author: Johannes Berg <johannes.berg@intel.com>
1106 Date: Fri Jan 24 14:06:29 2014 +0100
1107
1108 nl80211: send event when AP operation is stopped
1109
1110 There are a few cases, e.g. suspend, where an AP interface is
1111 stopped by the kernel rather than by userspace request, most
1112 commonly when suspending. To let userspace know about this,
1113 send the NL80211_CMD_STOP_AP command as an event every time
1114 an AP interface is stopped. This also happens when userspace
1115 did in fact request the AP stop, but that's not a problem.
1116
1117 For full-MAC drivers this may need to be extended to also
1118 cover cases where the device stopped the AP operation for
1119 some reason, this a bit more complicated because then all
1120 cfg80211 state also needs to be reset; such API is not part
1121 of this patch.
1122
1123 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1124
1125 commit d5d567eda7704f190379ca852a8f9a4112e3eee3
1126 Author: Johannes Berg <johannes.berg@intel.com>
1127 Date: Thu Jan 23 16:20:29 2014 +0100
1128
1129 mac80211: add length check in ieee80211_is_robust_mgmt_frame()
1130
1131 A few places weren't checking that the frame passed to the
1132 function actually has enough data even though the function
1133 clearly documents it must have a payload byte. Make this
1134 safer by changing the function to take an skb and checking
1135 the length inside. The old version is preserved for now as
1136 the rtl* drivers use it and don't have a correct skb.
1137
1138 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1139
1140 commit f8f6d212a047fc65c7d3442dfc038f65517236fc
1141 Author: Johannes Berg <johannes.berg@intel.com>
1142 Date: Fri Jan 24 10:53:53 2014 +0100
1143
1144 nl80211: fix scheduled scan RSSI matchset attribute confusion
1145
1146 The scheduled scan matchsets were intended to be a list of filters,
1147 with the found BSS having to pass at least one of them to be passed
1148 to the host. When the RSSI attribute was added, however, this was
1149 broken and currently wpa_supplicant adds that attribute in its own
1150 matchset; however, it doesn't intend that to mean that anything
1151 that passes the RSSI filter should be passed to the host, instead
1152 it wants it to mean that everything needs to also have higher RSSI.
1153
1154 This is semantically problematic because we have a list of filters
1155 like [ SSID1, SSID2, SSID3, RSSI ] with no real indication which
1156 one should be OR'ed and which one AND'ed.
1157
1158 To fix this, move the RSSI filter attribute into each matchset. As
1159 we need to stay backward compatible, treat a matchset with only the
1160 RSSI attribute as a "default RSSI filter" for all other matchsets,
1161 but only if there are other matchsets (an RSSI-only matchset by
1162 itself is still desirable.)
1163
1164 To make driver implementation easier, keep a global min_rssi_thold
1165 for the entire request as well. The only affected driver is ath6kl.
1166
1167 I found this when I looked into the code after Raja Mani submitted
1168 a patch fixing the n_match_sets calculation to disregard the RSSI,
1169 but that patch didn't address the semantic issue.
1170
1171 Reported-by: Raja Mani <rmani@qti.qualcomm.com>
1172 Acked-by: Luciano Coelho <luciano.coelho@intel.com>
1173 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1174
1175 commit de553e8545e65a6dc4e45f43df7e1443d4291922
1176 Author: Johannes Berg <johannes.berg@intel.com>
1177 Date: Fri Jan 24 10:17:47 2014 +0100
1178
1179 nl80211: check nla_parse() return values
1180
1181 If there's a policy, then nla_parse() return values must be
1182 checked, otherwise the policy is useless and there's nothing
1183 that ensures the attributes are actually what we expect them
1184 to be.
1185
1186 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1187
1188 commit 652204a0733e9e1c54661d6f9d36e2e1e3b22bb1
1189 Author: Karl Beldan <karl.beldan@rivierawaves.com>
1190 Date: Thu Jan 23 20:06:34 2014 +0100
1191
1192 mac80211: send {ADD,DEL}BA on AC_VO like other mgmt frames, as per spec
1193
1194 ATM, {ADD,DEL}BA and BAR frames are sent on the AC matching the TID of
1195 the BA parameters. In the discussion [1] about this patch, Johannes
1196 recalled that it fixed some races with the DELBA and indeed this
1197 behavior was introduced in [2].
1198 While [2] is right for the BARs, the part queueing the {ADD,DEL}BAs on
1199 their BA params TID AC violates the spec and is more a workaround for
1200 some drivers. Helmut expressed some concerns wrt such drivers, in
1201 particular DELBAs in rt2x00.
1202
1203 ATM, DELBAs are sent after a driver has called (hence "purposely")
1204 ieee80211_start_tx_ba_cb_irqsafe and Johannes and Emmanuel gave some
1205 details wrt intentions behind the split of the IEEE80211_AMPDU_TX_STOP_*
1206 given to the driver ampdu_action supposed to call this function, which
1207 could prove handy to people trying to do the right thing in faulty
1208 drivers (if their fw/hw don't get in their way).
1209
1210 [1] http://mid.gmane.org/1390391564-18481-1-git-send-email-karl.beldan@gmail.com
1211 [2] Commit: cf6bb79ad828 ("mac80211: Use appropriate TID for sending BAR, ADDBA and DELBA frames")
1212
1213 Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
1214 Cc: Helmut Schaa <helmut.schaa@googlemail.com>
1215 Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
1216 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1217 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
1218 +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
1219 @@ -790,7 +790,7 @@ void ath6kl_cfg80211_connect_event(struc
1220 if (nw_type & ADHOC_NETWORK) {
1221 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "ad-hoc %s selected\n",
1222 nw_type & ADHOC_CREATOR ? "creator" : "joiner");
1223 - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
1224 + cfg80211_ibss_joined(vif->ndev, bssid, chan, GFP_KERNEL);
1225 cfg80211_put_bss(ar->wiphy, bss);
1226 return;
1227 }
1228 @@ -861,13 +861,9 @@ void ath6kl_cfg80211_disconnect_event(st
1229 }
1230
1231 if (vif->nw_type & ADHOC_NETWORK) {
1232 - if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC) {
1233 + if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC)
1234 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
1235 "%s: ath6k not in ibss mode\n", __func__);
1236 - return;
1237 - }
1238 - memset(bssid, 0, ETH_ALEN);
1239 - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
1240 return;
1241 }
1242
1243 @@ -3256,6 +3252,15 @@ static int ath6kl_cfg80211_sscan_start(s
1244 struct ath6kl_vif *vif = netdev_priv(dev);
1245 u16 interval;
1246 int ret, rssi_thold;
1247 + int n_match_sets = request->n_match_sets;
1248 +
1249 + /*
1250 + * If there's a matchset w/o an SSID, then assume it's just for
1251 + * the RSSI (nothing else is currently supported) and ignore it.
1252 + * The device only supports a global RSSI filter that we set below.
1253 + */
1254 + if (n_match_sets == 1 && !request->match_sets[0].ssid.ssid_len)
1255 + n_match_sets = 0;
1256
1257 if (ar->state != ATH6KL_STATE_ON)
1258 return -EIO;
1259 @@ -3268,11 +3273,11 @@ static int ath6kl_cfg80211_sscan_start(s
1260 ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
1261 request->n_ssids,
1262 request->match_sets,
1263 - request->n_match_sets);
1264 + n_match_sets);
1265 if (ret < 0)
1266 return ret;
1267
1268 - if (!request->n_match_sets) {
1269 + if (!n_match_sets) {
1270 ret = ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
1271 ALL_BSS_FILTER, 0);
1272 if (ret < 0)
1273 @@ -3286,12 +3291,12 @@ static int ath6kl_cfg80211_sscan_start(s
1274
1275 if (test_bit(ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD,
1276 ar->fw_capabilities)) {
1277 - if (request->rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
1278 + if (request->min_rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
1279 rssi_thold = 0;
1280 - else if (request->rssi_thold < -127)
1281 + else if (request->min_rssi_thold < -127)
1282 rssi_thold = -127;
1283 else
1284 - rssi_thold = request->rssi_thold;
1285 + rssi_thold = request->min_rssi_thold;
1286
1287 ret = ath6kl_wmi_set_rssi_filter_cmd(ar->wmi, vif->fw_vif_idx,
1288 rssi_thold);
1289 --- a/drivers/net/wireless/ath/ath9k/hw.c
1290 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1291 @@ -1316,7 +1316,7 @@ static bool ath9k_hw_set_reset(struct at
1292 if (AR_SREV_9300_20_OR_LATER(ah))
1293 udelay(50);
1294 else if (AR_SREV_9100(ah))
1295 - udelay(10000);
1296 + mdelay(10);
1297 else
1298 udelay(100);
1299
1300 @@ -1534,7 +1534,7 @@ EXPORT_SYMBOL(ath9k_hw_check_nav);
1301 bool ath9k_hw_check_alive(struct ath_hw *ah)
1302 {
1303 int count = 50;
1304 - u32 reg;
1305 + u32 reg, last_val;
1306
1307 if (AR_SREV_9300(ah))
1308 return !ath9k_hw_detect_mac_hang(ah);
1309 @@ -1542,9 +1542,14 @@ bool ath9k_hw_check_alive(struct ath_hw
1310 if (AR_SREV_9285_12_OR_LATER(ah))
1311 return true;
1312
1313 + last_val = REG_READ(ah, AR_OBS_BUS_1);
1314 do {
1315 reg = REG_READ(ah, AR_OBS_BUS_1);
1316 + if (reg != last_val)
1317 + return true;
1318
1319 + udelay(1);
1320 + last_val = reg;
1321 if ((reg & 0x7E7FFFEF) == 0x00702400)
1322 continue;
1323
1324 @@ -2051,9 +2056,8 @@ static bool ath9k_hw_set_power_awake(str
1325
1326 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
1327 AR_RTC_FORCE_WAKE_EN);
1328 -
1329 if (AR_SREV_9100(ah))
1330 - udelay(10000);
1331 + mdelay(10);
1332 else
1333 udelay(50);
1334
1335 --- a/drivers/net/wireless/ath/ath9k/main.c
1336 +++ b/drivers/net/wireless/ath/ath9k/main.c
1337 @@ -451,7 +451,7 @@ void ath9k_tasklet(unsigned long data)
1338 * interrupts are enabled in the reset routine.
1339 */
1340 atomic_inc(&ah->intr_ref_cnt);
1341 - ath_dbg(common, ANY, "FATAL: Skipping interrupts\n");
1342 + ath_dbg(common, RESET, "FATAL: Skipping interrupts\n");
1343 goto out;
1344 }
1345
1346 @@ -471,7 +471,7 @@ void ath9k_tasklet(unsigned long data)
1347 * interrupts are enabled in the reset routine.
1348 */
1349 atomic_inc(&ah->intr_ref_cnt);
1350 - ath_dbg(common, ANY,
1351 + ath_dbg(common, RESET,
1352 "BB_WATCHDOG: Skipping interrupts\n");
1353 goto out;
1354 }
1355 @@ -484,7 +484,7 @@ void ath9k_tasklet(unsigned long data)
1356 type = RESET_TYPE_TX_GTT;
1357 ath9k_queue_reset(sc, type);
1358 atomic_inc(&ah->intr_ref_cnt);
1359 - ath_dbg(common, ANY,
1360 + ath_dbg(common, RESET,
1361 "GTT: Skipping interrupts\n");
1362 goto out;
1363 }
1364 @@ -1866,7 +1866,7 @@ static void ath9k_set_coverage_class(str
1365
1366 static bool ath9k_has_tx_pending(struct ath_softc *sc)
1367 {
1368 - int i, npend;
1369 + int i, npend = 0;
1370
1371 for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1372 if (!ATH_TXQ_SETUP(sc, i))
1373 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
1374 +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
1375 @@ -595,6 +595,9 @@ static void iwl_scan_offload_build_ssid(
1376 * config match list.
1377 */
1378 for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) {
1379 + /* skip empty SSID matchsets */
1380 + if (!req->match_sets[i].ssid.ssid_len)
1381 + continue;
1382 scan->direct_scan[i].id = WLAN_EID_SSID;
1383 scan->direct_scan[i].len = req->match_sets[i].ssid.ssid_len;
1384 memcpy(scan->direct_scan[i].ssid, req->match_sets[i].ssid.ssid,
1385 --- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
1386 +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
1387 @@ -452,7 +452,7 @@ bool rtl88ee_rx_query_desc(struct ieee80
1388 /* During testing, hdr was NULL */
1389 return false;
1390 }
1391 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
1392 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
1393 (ieee80211_has_protected(hdr->frame_control)))
1394 rx_status->flag &= ~RX_FLAG_DECRYPTED;
1395 else
1396 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
1397 +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
1398 @@ -393,7 +393,7 @@ bool rtl92ce_rx_query_desc(struct ieee80
1399 /* In testing, hdr was NULL here */
1400 return false;
1401 }
1402 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
1403 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
1404 (ieee80211_has_protected(hdr->frame_control)))
1405 rx_status->flag &= ~RX_FLAG_DECRYPTED;
1406 else
1407 --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
1408 +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
1409 @@ -310,7 +310,7 @@ bool rtl92se_rx_query_desc(struct ieee80
1410 /* during testing, hdr was NULL here */
1411 return false;
1412 }
1413 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
1414 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
1415 (ieee80211_has_protected(hdr->frame_control)))
1416 rx_status->flag &= ~RX_FLAG_DECRYPTED;
1417 else
1418 --- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
1419 +++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
1420 @@ -334,7 +334,7 @@ bool rtl8723ae_rx_query_desc(struct ieee
1421 /* during testing, hdr could be NULL here */
1422 return false;
1423 }
1424 - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
1425 + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
1426 (ieee80211_has_protected(hdr->frame_control)))
1427 rx_status->flag &= ~RX_FLAG_DECRYPTED;
1428 else
1429 --- a/include/linux/ieee80211.h
1430 +++ b/include/linux/ieee80211.h
1431 @@ -597,6 +597,20 @@ static inline int ieee80211_is_qos_nullf
1432 }
1433
1434 /**
1435 + * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
1436 + * @fc: frame control field in little-endian byteorder
1437 + */
1438 +static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
1439 +{
1440 + /* IEEE 802.11-2012, definition of "bufferable management frame";
1441 + * note that this ignores the IBSS special case. */
1442 + return ieee80211_is_mgmt(fc) &&
1443 + (ieee80211_is_action(fc) ||
1444 + ieee80211_is_disassoc(fc) ||
1445 + ieee80211_is_deauth(fc));
1446 +}
1447 +
1448 +/**
1449 * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
1450 * @seq_ctrl: frame sequence control bytes in little-endian byteorder
1451 */
1452 @@ -2192,10 +2206,10 @@ static inline u8 *ieee80211_get_DA(struc
1453 }
1454
1455 /**
1456 - * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
1457 + * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
1458 * @hdr: the frame (buffer must include at least the first octet of payload)
1459 */
1460 -static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1461 +static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
1462 {
1463 if (ieee80211_is_disassoc(hdr->frame_control) ||
1464 ieee80211_is_deauth(hdr->frame_control))
1465 @@ -2224,6 +2238,17 @@ static inline bool ieee80211_is_robust_m
1466 }
1467
1468 /**
1469 + * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
1470 + * @skb: the skb containing the frame, length will be checked
1471 + */
1472 +static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
1473 +{
1474 + if (skb->len < 25)
1475 + return false;
1476 + return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
1477 +}
1478 +
1479 +/**
1480 * ieee80211_is_public_action - check if frame is a public action frame
1481 * @hdr: the frame
1482 * @len: length of the frame
1483 --- a/include/net/cfg80211.h
1484 +++ b/include/net/cfg80211.h
1485 @@ -1395,9 +1395,11 @@ struct cfg80211_scan_request {
1486 * struct cfg80211_match_set - sets of attributes to match
1487 *
1488 * @ssid: SSID to be matched
1489 + * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
1490 */
1491 struct cfg80211_match_set {
1492 struct cfg80211_ssid ssid;
1493 + s32 rssi_thold;
1494 };
1495
1496 /**
1497 @@ -1420,7 +1422,8 @@ struct cfg80211_match_set {
1498 * @dev: the interface
1499 * @scan_start: start time of the scheduled scan
1500 * @channels: channels to scan
1501 - * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
1502 + * @min_rssi_thold: for drivers only supporting a single threshold, this
1503 + * contains the minimum over all matchsets
1504 */
1505 struct cfg80211_sched_scan_request {
1506 struct cfg80211_ssid *ssids;
1507 @@ -1433,7 +1436,7 @@ struct cfg80211_sched_scan_request {
1508 u32 flags;
1509 struct cfg80211_match_set *match_sets;
1510 int n_match_sets;
1511 - s32 rssi_thold;
1512 + s32 min_rssi_thold;
1513
1514 /* internal */
1515 struct wiphy *wiphy;
1516 @@ -3130,8 +3133,8 @@ struct cfg80211_cached_keys;
1517 * @identifier: (private) Identifier used in nl80211 to identify this
1518 * wireless device if it has no netdev
1519 * @current_bss: (private) Used by the internal configuration code
1520 - * @channel: (private) Used by the internal configuration code to track
1521 - * the user-set AP, monitor and WDS channel
1522 + * @chandef: (private) Used by the internal configuration code to track
1523 + * the user-set channel definition.
1524 * @preset_chandef: (private) Used by the internal configuration code to
1525 * track the channel to be used for AP later
1526 * @bssid: (private) Used by the internal configuration code
1527 @@ -3195,9 +3198,7 @@ struct wireless_dev {
1528
1529 struct cfg80211_internal_bss *current_bss; /* associated / joined */
1530 struct cfg80211_chan_def preset_chandef;
1531 -
1532 - /* for AP and mesh channel tracking */
1533 - struct ieee80211_channel *channel;
1534 + struct cfg80211_chan_def chandef;
1535
1536 bool ibss_fixed;
1537 bool ibss_dfs_possible;
1538 @@ -3879,6 +3880,7 @@ void cfg80211_michael_mic_failure(struct
1539 *
1540 * @dev: network device
1541 * @bssid: the BSSID of the IBSS joined
1542 + * @channel: the channel of the IBSS joined
1543 * @gfp: allocation flags
1544 *
1545 * This function notifies cfg80211 that the device joined an IBSS or
1546 @@ -3888,7 +3890,8 @@ void cfg80211_michael_mic_failure(struct
1547 * with the locally generated beacon -- this guarantees that there is
1548 * always a scan result for this IBSS. cfg80211 will handle the rest.
1549 */
1550 -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
1551 +void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
1552 + struct ieee80211_channel *channel, gfp_t gfp);
1553
1554 /**
1555 * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
1556 --- a/include/uapi/linux/nl80211.h
1557 +++ b/include/uapi/linux/nl80211.h
1558 @@ -2442,9 +2442,15 @@ enum nl80211_reg_rule_attr {
1559 * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
1560 * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
1561 * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
1562 - * only report BSS with matching SSID.
1563 + * only report BSS with matching SSID.
1564 * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
1565 - * BSS in scan results. Filtering is turned off if not specified.
1566 + * BSS in scan results. Filtering is turned off if not specified. Note that
1567 + * if this attribute is in a match set of its own, then it is treated as
1568 + * the default value for all matchsets with an SSID, rather than being a
1569 + * matchset of its own without an RSSI filter. This is due to problems with
1570 + * how this API was implemented in the past. Also, due to the same problem,
1571 + * the only way to create a matchset with only an RSSI filter (with this
1572 + * attribute) is if there's only a single matchset with the RSSI attribute.
1573 * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
1574 * attribute number currently defined
1575 * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
1576 --- a/net/mac80211/agg-tx.c
1577 +++ b/net/mac80211/agg-tx.c
1578 @@ -107,7 +107,7 @@ static void ieee80211_send_addba_request
1579 mgmt->u.action.u.addba_req.start_seq_num =
1580 cpu_to_le16(start_seq_num << 4);
1581
1582 - ieee80211_tx_skb_tid(sdata, skb, tid);
1583 + ieee80211_tx_skb(sdata, skb);
1584 }
1585
1586 void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn)
1587 --- a/net/mac80211/cfg.c
1588 +++ b/net/mac80211/cfg.c
1589 @@ -970,9 +970,9 @@ static int ieee80211_start_ap(struct wip
1590 /* TODO: make hostapd tell us what it wants */
1591 sdata->smps_mode = IEEE80211_SMPS_OFF;
1592 sdata->needed_rx_chains = sdata->local->rx_chains;
1593 - sdata->radar_required = params->radar_required;
1594
1595 mutex_lock(&local->mtx);
1596 + sdata->radar_required = params->radar_required;
1597 err = ieee80211_vif_use_channel(sdata, &params->chandef,
1598 IEEE80211_CHANCTX_SHARED);
1599 mutex_unlock(&local->mtx);
1600 @@ -1021,8 +1021,10 @@ static int ieee80211_start_ap(struct wip
1601 IEEE80211_P2P_OPPPS_ENABLE_BIT;
1602
1603 err = ieee80211_assign_beacon(sdata, &params->beacon);
1604 - if (err < 0)
1605 + if (err < 0) {
1606 + ieee80211_vif_release_channel(sdata);
1607 return err;
1608 + }
1609 changed |= err;
1610
1611 err = drv_start_ap(sdata->local, sdata);
1612 @@ -1032,6 +1034,7 @@ static int ieee80211_start_ap(struct wip
1613 if (old)
1614 kfree_rcu(old, rcu_head);
1615 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
1616 + ieee80211_vif_release_channel(sdata);
1617 return err;
1618 }
1619
1620 @@ -1053,6 +1056,7 @@ static int ieee80211_change_beacon(struc
1621 int err;
1622
1623 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1624 + sdata_assert_lock(sdata);
1625
1626 /* don't allow changing the beacon while CSA is in place - offset
1627 * of channel switch counter may change
1628 @@ -1080,6 +1084,8 @@ static int ieee80211_stop_ap(struct wiph
1629 struct probe_resp *old_probe_resp;
1630 struct cfg80211_chan_def chandef;
1631
1632 + sdata_assert_lock(sdata);
1633 +
1634 old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
1635 if (!old_beacon)
1636 return -ENOENT;
1637 @@ -1090,8 +1096,6 @@ static int ieee80211_stop_ap(struct wiph
1638 kfree(sdata->u.ap.next_beacon);
1639 sdata->u.ap.next_beacon = NULL;
1640
1641 - cancel_work_sync(&sdata->u.ap.request_smps_work);
1642 -
1643 /* turn off carrier for this interface and dependent VLANs */
1644 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
1645 netif_carrier_off(vlan->dev);
1646 @@ -1103,6 +1107,7 @@ static int ieee80211_stop_ap(struct wiph
1647 kfree_rcu(old_beacon, rcu_head);
1648 if (old_probe_resp)
1649 kfree_rcu(old_probe_resp, rcu_head);
1650 + sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
1651
1652 __sta_info_flush(sdata, true);
1653 ieee80211_free_keys(sdata, true);
1654 @@ -1988,6 +1993,9 @@ static int ieee80211_change_bss(struct w
1655
1656 band = ieee80211_get_sdata_band(sdata);
1657
1658 + if (WARN_ON(!wiphy->bands[band]))
1659 + return -EINVAL;
1660 +
1661 if (params->use_cts_prot >= 0) {
1662 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
1663 changed |= BSS_CHANGED_ERP_CTS_PROT;
1664 @@ -2638,6 +2646,24 @@ static int ieee80211_start_roc_work(stru
1665 INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
1666 INIT_LIST_HEAD(&roc->dependents);
1667
1668 + /*
1669 + * cookie is either the roc cookie (for normal roc)
1670 + * or the SKB (for mgmt TX)
1671 + */
1672 + if (!txskb) {
1673 + /* local->mtx protects this */
1674 + local->roc_cookie_counter++;
1675 + roc->cookie = local->roc_cookie_counter;
1676 + /* wow, you wrapped 64 bits ... more likely a bug */
1677 + if (WARN_ON(roc->cookie == 0)) {
1678 + roc->cookie = 1;
1679 + local->roc_cookie_counter++;
1680 + }
1681 + *cookie = roc->cookie;
1682 + } else {
1683 + *cookie = (unsigned long)txskb;
1684 + }
1685 +
1686 /* if there's one pending or we're scanning, queue this one */
1687 if (!list_empty(&local->roc_list) ||
1688 local->scanning || local->radar_detect_enabled)
1689 @@ -2772,24 +2798,6 @@ static int ieee80211_start_roc_work(stru
1690 if (!queued)
1691 list_add_tail(&roc->list, &local->roc_list);
1692
1693 - /*
1694 - * cookie is either the roc cookie (for normal roc)
1695 - * or the SKB (for mgmt TX)
1696 - */
1697 - if (!txskb) {
1698 - /* local->mtx protects this */
1699 - local->roc_cookie_counter++;
1700 - roc->cookie = local->roc_cookie_counter;
1701 - /* wow, you wrapped 64 bits ... more likely a bug */
1702 - if (WARN_ON(roc->cookie == 0)) {
1703 - roc->cookie = 1;
1704 - local->roc_cookie_counter++;
1705 - }
1706 - *cookie = roc->cookie;
1707 - } else {
1708 - *cookie = (unsigned long)txskb;
1709 - }
1710 -
1711 return 0;
1712 }
1713
1714 @@ -3004,8 +3012,10 @@ void ieee80211_csa_finalize_work(struct
1715 if (!ieee80211_sdata_running(sdata))
1716 goto unlock;
1717
1718 - sdata->radar_required = sdata->csa_radar_required;
1719 + sdata_assert_lock(sdata);
1720 +
1721 mutex_lock(&local->mtx);
1722 + sdata->radar_required = sdata->csa_radar_required;
1723 err = ieee80211_vif_change_channel(sdata, &changed);
1724 mutex_unlock(&local->mtx);
1725 if (WARN_ON(err < 0))
1726 @@ -3022,13 +3032,13 @@ void ieee80211_csa_finalize_work(struct
1727 switch (sdata->vif.type) {
1728 case NL80211_IFTYPE_AP:
1729 err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
1730 + kfree(sdata->u.ap.next_beacon);
1731 + sdata->u.ap.next_beacon = NULL;
1732 +
1733 if (err < 0)
1734 goto unlock;
1735
1736 changed |= err;
1737 - kfree(sdata->u.ap.next_beacon);
1738 - sdata->u.ap.next_beacon = NULL;
1739 -
1740 ieee80211_bss_info_change_notify(sdata, err);
1741 break;
1742 case NL80211_IFTYPE_ADHOC:
1743 @@ -3066,7 +3076,7 @@ int ieee80211_channel_switch(struct wiph
1744 struct ieee80211_if_mesh __maybe_unused *ifmsh;
1745 int err, num_chanctx;
1746
1747 - lockdep_assert_held(&sdata->wdev.mtx);
1748 + sdata_assert_lock(sdata);
1749
1750 if (!list_empty(&local->roc_list) || local->scanning)
1751 return -EBUSY;
1752 --- a/net/mac80211/ht.c
1753 +++ b/net/mac80211/ht.c
1754 @@ -375,7 +375,7 @@ void ieee80211_send_delba(struct ieee802
1755 mgmt->u.action.u.delba.params = cpu_to_le16(params);
1756 mgmt->u.action.u.delba.reason_code = cpu_to_le16(reason_code);
1757
1758 - ieee80211_tx_skb_tid(sdata, skb, tid);
1759 + ieee80211_tx_skb(sdata, skb);
1760 }
1761
1762 void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
1763 @@ -466,7 +466,9 @@ void ieee80211_request_smps_ap_work(stru
1764 u.ap.request_smps_work);
1765
1766 sdata_lock(sdata);
1767 - __ieee80211_request_smps_ap(sdata, sdata->u.ap.driver_smps_mode);
1768 + if (sdata_dereference(sdata->u.ap.beacon, sdata))
1769 + __ieee80211_request_smps_ap(sdata,
1770 + sdata->u.ap.driver_smps_mode);
1771 sdata_unlock(sdata);
1772 }
1773
1774 --- a/net/mac80211/iface.c
1775 +++ b/net/mac80211/iface.c
1776 @@ -770,12 +770,19 @@ static void ieee80211_do_stop(struct iee
1777
1778 ieee80211_roc_purge(local, sdata);
1779
1780 - if (sdata->vif.type == NL80211_IFTYPE_STATION)
1781 + switch (sdata->vif.type) {
1782 + case NL80211_IFTYPE_STATION:
1783 ieee80211_mgd_stop(sdata);
1784 -
1785 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1786 + break;
1787 + case NL80211_IFTYPE_ADHOC:
1788 ieee80211_ibss_stop(sdata);
1789 -
1790 + break;
1791 + case NL80211_IFTYPE_AP:
1792 + cancel_work_sync(&sdata->u.ap.request_smps_work);
1793 + break;
1794 + default:
1795 + break;
1796 + }
1797
1798 /*
1799 * Remove all stations associated with this interface.
1800 @@ -827,7 +834,9 @@ static void ieee80211_do_stop(struct iee
1801 cancel_work_sync(&local->dynamic_ps_enable_work);
1802
1803 cancel_work_sync(&sdata->recalc_smps);
1804 + sdata_lock(sdata);
1805 sdata->vif.csa_active = false;
1806 + sdata_unlock(sdata);
1807 cancel_work_sync(&sdata->csa_finalize_work);
1808
1809 cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
1810 --- a/net/mac80211/rx.c
1811 +++ b/net/mac80211/rx.c
1812 @@ -599,10 +599,10 @@ static int ieee80211_is_unicast_robust_m
1813 {
1814 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1815
1816 - if (skb->len < 24 || is_multicast_ether_addr(hdr->addr1))
1817 + if (is_multicast_ether_addr(hdr->addr1))
1818 return 0;
1819
1820 - return ieee80211_is_robust_mgmt_frame(hdr);
1821 + return ieee80211_is_robust_mgmt_frame(skb);
1822 }
1823
1824
1825 @@ -610,10 +610,10 @@ static int ieee80211_is_multicast_robust
1826 {
1827 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1828
1829 - if (skb->len < 24 || !is_multicast_ether_addr(hdr->addr1))
1830 + if (!is_multicast_ether_addr(hdr->addr1))
1831 return 0;
1832
1833 - return ieee80211_is_robust_mgmt_frame(hdr);
1834 + return ieee80211_is_robust_mgmt_frame(skb);
1835 }
1836
1837
1838 @@ -626,7 +626,7 @@ static int ieee80211_get_mmie_keyidx(str
1839 if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da))
1840 return -1;
1841
1842 - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr))
1843 + if (!ieee80211_is_robust_mgmt_frame(skb))
1844 return -1; /* not a robust management frame */
1845
1846 mmie = (struct ieee80211_mmie *)
1847 @@ -1128,6 +1128,13 @@ static void sta_ps_end(struct sta_info *
1848 sta->sta.addr, sta->sta.aid);
1849
1850 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1851 + /*
1852 + * Clear the flag only if the other one is still set
1853 + * so that the TX path won't start TX'ing new frames
1854 + * directly ... In the case that the driver flag isn't
1855 + * set ieee80211_sta_ps_deliver_wakeup() will clear it.
1856 + */
1857 + clear_sta_flag(sta, WLAN_STA_PS_STA);
1858 ps_dbg(sta->sdata, "STA %pM aid %d driver-ps-blocked\n",
1859 sta->sta.addr, sta->sta.aid);
1860 return;
1861 @@ -1311,18 +1318,15 @@ ieee80211_rx_h_sta_process(struct ieee80
1862 !ieee80211_has_morefrags(hdr->frame_control) &&
1863 !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
1864 (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
1865 - rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
1866 + rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
1867 + /* PM bit is only checked in frames where it isn't reserved,
1868 + * in AP mode it's reserved in non-bufferable management frames
1869 + * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field)
1870 + */
1871 + (!ieee80211_is_mgmt(hdr->frame_control) ||
1872 + ieee80211_is_bufferable_mmpdu(hdr->frame_control))) {
1873 if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
1874 - /*
1875 - * Ignore doze->wake transitions that are
1876 - * indicated by non-data frames, the standard
1877 - * is unclear here, but for example going to
1878 - * PS mode and then scanning would cause a
1879 - * doze->wake transition for the probe request,
1880 - * and that is clearly undesirable.
1881 - */
1882 - if (ieee80211_is_data(hdr->frame_control) &&
1883 - !ieee80211_has_pm(hdr->frame_control))
1884 + if (!ieee80211_has_pm(hdr->frame_control))
1885 sta_ps_end(sta);
1886 } else {
1887 if (ieee80211_has_pm(hdr->frame_control))
1888 @@ -1845,8 +1849,7 @@ static int ieee80211_drop_unencrypted_mg
1889 * having configured keys.
1890 */
1891 if (unlikely(ieee80211_is_action(fc) && !rx->key &&
1892 - ieee80211_is_robust_mgmt_frame(
1893 - (struct ieee80211_hdr *) rx->skb->data)))
1894 + ieee80211_is_robust_mgmt_frame(rx->skb)))
1895 return -EACCES;
1896 }
1897
1898 --- a/net/mac80211/tx.c
1899 +++ b/net/mac80211/tx.c
1900 @@ -452,8 +452,7 @@ static int ieee80211_use_mfp(__le16 fc,
1901 if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP))
1902 return 0;
1903
1904 - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *)
1905 - skb->data))
1906 + if (!ieee80211_is_robust_mgmt_frame(skb))
1907 return 0;
1908
1909 return 1;
1910 @@ -478,6 +477,20 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1911 sta->sta.addr, sta->sta.aid, ac);
1912 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
1913 purge_old_ps_buffers(tx->local);
1914 +
1915 + /* sync with ieee80211_sta_ps_deliver_wakeup */
1916 + spin_lock(&sta->ps_lock);
1917 + /*
1918 + * STA woke up the meantime and all the frames on ps_tx_buf have
1919 + * been queued to pending queue. No reordering can happen, go
1920 + * ahead and Tx the packet.
1921 + */
1922 + if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
1923 + !test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1924 + spin_unlock(&sta->ps_lock);
1925 + return TX_CONTINUE;
1926 + }
1927 +
1928 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) {
1929 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]);
1930 ps_dbg(tx->sdata,
1931 @@ -492,6 +505,7 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1932 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
1933 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
1934 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb);
1935 + spin_unlock(&sta->ps_lock);
1936
1937 if (!timer_pending(&local->sta_cleanup))
1938 mod_timer(&local->sta_cleanup,
1939 @@ -525,9 +539,7 @@ ieee80211_tx_h_ps_buf(struct ieee80211_t
1940
1941 /* only deauth, disassoc and action are bufferable MMPDUs */
1942 if (ieee80211_is_mgmt(hdr->frame_control) &&
1943 - !ieee80211_is_deauth(hdr->frame_control) &&
1944 - !ieee80211_is_disassoc(hdr->frame_control) &&
1945 - !ieee80211_is_action(hdr->frame_control)) {
1946 + !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {
1947 if (tx->flags & IEEE80211_TX_UNICAST)
1948 info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
1949 return TX_CONTINUE;
1950 @@ -567,7 +579,7 @@ ieee80211_tx_h_select_key(struct ieee802
1951 tx->key = key;
1952 else if (ieee80211_is_mgmt(hdr->frame_control) &&
1953 is_multicast_ether_addr(hdr->addr1) &&
1954 - ieee80211_is_robust_mgmt_frame(hdr) &&
1955 + ieee80211_is_robust_mgmt_frame(tx->skb) &&
1956 (key = rcu_dereference(tx->sdata->default_mgmt_key)))
1957 tx->key = key;
1958 else if (is_multicast_ether_addr(hdr->addr1) &&
1959 @@ -582,12 +594,12 @@ ieee80211_tx_h_select_key(struct ieee802
1960 tx->key = NULL;
1961 else if (tx->skb->protocol == tx->sdata->control_port_protocol)
1962 tx->key = NULL;
1963 - else if (ieee80211_is_robust_mgmt_frame(hdr) &&
1964 + else if (ieee80211_is_robust_mgmt_frame(tx->skb) &&
1965 !(ieee80211_is_action(hdr->frame_control) &&
1966 tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))
1967 tx->key = NULL;
1968 else if (ieee80211_is_mgmt(hdr->frame_control) &&
1969 - !ieee80211_is_robust_mgmt_frame(hdr))
1970 + !ieee80211_is_robust_mgmt_frame(tx->skb))
1971 tx->key = NULL;
1972 else {
1973 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
1974 @@ -878,7 +890,7 @@ static int ieee80211_fragment(struct iee
1975 }
1976
1977 /* adjust first fragment's length */
1978 - skb->len = hdrlen + per_fragm;
1979 + skb_trim(skb, hdrlen + per_fragm);
1980 return 0;
1981 }
1982
1983 @@ -2900,7 +2912,7 @@ ieee80211_get_buffered_bc(struct ieee802
1984 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
1985 }
1986
1987 - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
1988 + if (sdata->vif.type == NL80211_IFTYPE_AP)
1989 sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev);
1990 if (!ieee80211_tx_prepare(sdata, &tx, skb))
1991 break;
1992 --- a/net/mac80211/wpa.c
1993 +++ b/net/mac80211/wpa.c
1994 @@ -499,7 +499,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
1995 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1996
1997 if (!ieee80211_is_data(hdr->frame_control) &&
1998 - !ieee80211_is_robust_mgmt_frame(hdr))
1999 + !ieee80211_is_robust_mgmt_frame(skb))
2000 return RX_CONTINUE;
2001
2002 data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN -
2003 --- a/net/wireless/ap.c
2004 +++ b/net/wireless/ap.c
2005 @@ -27,9 +27,10 @@ static int __cfg80211_stop_ap(struct cfg
2006 err = rdev_stop_ap(rdev, dev);
2007 if (!err) {
2008 wdev->beacon_interval = 0;
2009 - wdev->channel = NULL;
2010 + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
2011 wdev->ssid_len = 0;
2012 rdev_set_qos_map(rdev, dev, NULL);
2013 + nl80211_send_ap_stopped(wdev);
2014 }
2015
2016 return err;
2017 --- a/net/wireless/core.c
2018 +++ b/net/wireless/core.c
2019 @@ -203,8 +203,11 @@ void cfg80211_stop_p2p_device(struct cfg
2020
2021 rdev->opencount--;
2022
2023 - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
2024 - !rdev->scan_req->notified);
2025 + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
2026 + if (WARN_ON(!rdev->scan_req->notified))
2027 + rdev->scan_req->aborted = true;
2028 + ___cfg80211_scan_done(rdev, false);
2029 + }
2030 }
2031
2032 static int cfg80211_rfkill_set_block(void *data, bool blocked)
2033 @@ -447,9 +450,6 @@ int wiphy_register(struct wiphy *wiphy)
2034 int i;
2035 u16 ifmodes = wiphy->interface_modes;
2036
2037 - /* support for 5/10 MHz is broken due to nl80211 API mess - disable */
2038 - wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_5_10_MHZ;
2039 -
2040 /*
2041 * There are major locking problems in nl80211/mac80211 for CSA,
2042 * disable for all drivers until this has been reworked.
2043 @@ -795,8 +795,6 @@ void cfg80211_leave(struct cfg80211_regi
2044 default:
2045 break;
2046 }
2047 -
2048 - wdev->beacon_interval = 0;
2049 }
2050
2051 static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
2052 @@ -875,8 +873,11 @@ static int cfg80211_netdev_notifier_call
2053 break;
2054 case NETDEV_DOWN:
2055 cfg80211_update_iface_num(rdev, wdev->iftype, -1);
2056 - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
2057 - !rdev->scan_req->notified);
2058 + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
2059 + if (WARN_ON(!rdev->scan_req->notified))
2060 + rdev->scan_req->aborted = true;
2061 + ___cfg80211_scan_done(rdev, false);
2062 + }
2063
2064 if (WARN_ON(rdev->sched_scan_req &&
2065 rdev->sched_scan_req->dev == wdev->netdev)) {
2066 --- a/net/wireless/core.h
2067 +++ b/net/wireless/core.h
2068 @@ -62,6 +62,7 @@ struct cfg80211_registered_device {
2069 struct rb_root bss_tree;
2070 u32 bss_generation;
2071 struct cfg80211_scan_request *scan_req; /* protected by RTNL */
2072 + struct sk_buff *scan_msg;
2073 struct cfg80211_sched_scan_request *sched_scan_req;
2074 unsigned long suspend_at;
2075 struct work_struct scan_done_wk;
2076 @@ -210,6 +211,7 @@ struct cfg80211_event {
2077 } dc;
2078 struct {
2079 u8 bssid[ETH_ALEN];
2080 + struct ieee80211_channel *channel;
2081 } ij;
2082 };
2083 };
2084 @@ -257,7 +259,8 @@ int __cfg80211_leave_ibss(struct cfg8021
2085 struct net_device *dev, bool nowext);
2086 int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
2087 struct net_device *dev, bool nowext);
2088 -void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid);
2089 +void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
2090 + struct ieee80211_channel *channel);
2091 int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
2092 struct wireless_dev *wdev);
2093
2094 @@ -361,7 +364,8 @@ int cfg80211_validate_key_settings(struc
2095 struct key_params *params, int key_idx,
2096 bool pairwise, const u8 *mac_addr);
2097 void __cfg80211_scan_done(struct work_struct *wk);
2098 -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev);
2099 +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
2100 + bool send_message);
2101 void __cfg80211_sched_scan_results(struct work_struct *wk);
2102 int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
2103 bool driver_initiated);
2104 @@ -441,7 +445,8 @@ static inline unsigned int elapsed_jiffi
2105 void
2106 cfg80211_get_chan_state(struct wireless_dev *wdev,
2107 struct ieee80211_channel **chan,
2108 - enum cfg80211_chan_mode *chanmode);
2109 + enum cfg80211_chan_mode *chanmode,
2110 + u8 *radar_detect);
2111
2112 int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
2113 struct cfg80211_chan_def *chandef);
2114 --- a/net/wireless/nl80211.c
2115 +++ b/net/wireless/nl80211.c
2116 @@ -1723,9 +1723,10 @@ static int nl80211_dump_wiphy(struct sk_
2117 * We can then retry with the larger buffer.
2118 */
2119 if ((ret == -ENOBUFS || ret == -EMSGSIZE) &&
2120 - !skb->len &&
2121 + !skb->len && !state->split &&
2122 cb->min_dump_alloc < 4096) {
2123 cb->min_dump_alloc = 4096;
2124 + state->split_start = 0;
2125 rtnl_unlock();
2126 return 1;
2127 }
2128 @@ -2047,10 +2048,12 @@ static int nl80211_set_wiphy(struct sk_b
2129 nla_for_each_nested(nl_txq_params,
2130 info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
2131 rem_txq_params) {
2132 - nla_parse(tb, NL80211_TXQ_ATTR_MAX,
2133 - nla_data(nl_txq_params),
2134 - nla_len(nl_txq_params),
2135 - txq_params_policy);
2136 + result = nla_parse(tb, NL80211_TXQ_ATTR_MAX,
2137 + nla_data(nl_txq_params),
2138 + nla_len(nl_txq_params),
2139 + txq_params_policy);
2140 + if (result)
2141 + goto bad_res;
2142 result = parse_txq_params(tb, &txq_params);
2143 if (result)
2144 goto bad_res;
2145 @@ -3289,7 +3292,7 @@ static int nl80211_start_ap(struct sk_bu
2146 if (!err) {
2147 wdev->preset_chandef = params.chandef;
2148 wdev->beacon_interval = params.beacon_interval;
2149 - wdev->channel = params.chandef.chan;
2150 + wdev->chandef = params.chandef;
2151 wdev->ssid_len = params.ssid_len;
2152 memcpy(wdev->ssid, params.ssid, wdev->ssid_len);
2153 }
2154 @@ -5210,9 +5213,11 @@ static int nl80211_set_reg(struct sk_buf
2155
2156 nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
2157 rem_reg_rules) {
2158 - nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
2159 - nla_data(nl_reg_rule), nla_len(nl_reg_rule),
2160 - reg_rule_policy);
2161 + r = nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
2162 + nla_data(nl_reg_rule), nla_len(nl_reg_rule),
2163 + reg_rule_policy);
2164 + if (r)
2165 + goto bad_reg;
2166 r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
2167 if (r)
2168 goto bad_reg;
2169 @@ -5277,7 +5282,7 @@ static int nl80211_trigger_scan(struct s
2170 if (!rdev->ops->scan)
2171 return -EOPNOTSUPP;
2172
2173 - if (rdev->scan_req) {
2174 + if (rdev->scan_req || rdev->scan_msg) {
2175 err = -EBUSY;
2176 goto unlock;
2177 }
2178 @@ -5475,6 +5480,7 @@ static int nl80211_start_sched_scan(stru
2179 enum ieee80211_band band;
2180 size_t ie_len;
2181 struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
2182 + s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
2183
2184 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
2185 !rdev->ops->sched_scan_start)
2186 @@ -5509,11 +5515,40 @@ static int nl80211_start_sched_scan(stru
2187 if (n_ssids > wiphy->max_sched_scan_ssids)
2188 return -EINVAL;
2189
2190 - if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH])
2191 + /*
2192 + * First, count the number of 'real' matchsets. Due to an issue with
2193 + * the old implementation, matchsets containing only the RSSI attribute
2194 + * (NL80211_SCHED_SCAN_MATCH_ATTR_RSSI) are considered as the 'default'
2195 + * RSSI for all matchsets, rather than their own matchset for reporting
2196 + * all APs with a strong RSSI. This is needed to be compatible with
2197 + * older userspace that treated a matchset with only the RSSI as the
2198 + * global RSSI for all other matchsets - if there are other matchsets.
2199 + */
2200 + if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
2201 nla_for_each_nested(attr,
2202 info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
2203 - tmp)
2204 - n_match_sets++;
2205 + tmp) {
2206 + struct nlattr *rssi;
2207 +
2208 + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
2209 + nla_data(attr), nla_len(attr),
2210 + nl80211_match_policy);
2211 + if (err)
2212 + return err;
2213 + /* add other standalone attributes here */
2214 + if (tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]) {
2215 + n_match_sets++;
2216 + continue;
2217 + }
2218 + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
2219 + if (rssi)
2220 + default_match_rssi = nla_get_s32(rssi);
2221 + }
2222 + }
2223 +
2224 + /* However, if there's no other matchset, add the RSSI one */
2225 + if (!n_match_sets && default_match_rssi != NL80211_SCAN_RSSI_THOLD_OFF)
2226 + n_match_sets = 1;
2227
2228 if (n_match_sets > wiphy->max_match_sets)
2229 return -EINVAL;
2230 @@ -5634,11 +5669,22 @@ static int nl80211_start_sched_scan(stru
2231 tmp) {
2232 struct nlattr *ssid, *rssi;
2233
2234 - nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
2235 - nla_data(attr), nla_len(attr),
2236 - nl80211_match_policy);
2237 + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
2238 + nla_data(attr), nla_len(attr),
2239 + nl80211_match_policy);
2240 + if (err)
2241 + goto out_free;
2242 ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
2243 if (ssid) {
2244 + if (WARN_ON(i >= n_match_sets)) {
2245 + /* this indicates a programming error,
2246 + * the loop above should have verified
2247 + * things properly
2248 + */
2249 + err = -EINVAL;
2250 + goto out_free;
2251 + }
2252 +
2253 if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) {
2254 err = -EINVAL;
2255 goto out_free;
2256 @@ -5647,15 +5693,28 @@ static int nl80211_start_sched_scan(stru
2257 nla_data(ssid), nla_len(ssid));
2258 request->match_sets[i].ssid.ssid_len =
2259 nla_len(ssid);
2260 + /* special attribute - old implemenation w/a */
2261 + request->match_sets[i].rssi_thold =
2262 + default_match_rssi;
2263 + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
2264 + if (rssi)
2265 + request->match_sets[i].rssi_thold =
2266 + nla_get_s32(rssi);
2267 }
2268 - rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
2269 - if (rssi)
2270 - request->rssi_thold = nla_get_u32(rssi);
2271 - else
2272 - request->rssi_thold =
2273 - NL80211_SCAN_RSSI_THOLD_OFF;
2274 i++;
2275 }
2276 +
2277 + /* there was no other matchset, so the RSSI one is alone */
2278 + if (i == 0)
2279 + request->match_sets[0].rssi_thold = default_match_rssi;
2280 +
2281 + request->min_rssi_thold = INT_MAX;
2282 + for (i = 0; i < n_match_sets; i++)
2283 + request->min_rssi_thold =
2284 + min(request->match_sets[i].rssi_thold,
2285 + request->min_rssi_thold);
2286 + } else {
2287 + request->min_rssi_thold = NL80211_SCAN_RSSI_THOLD_OFF;
2288 }
2289
2290 if (info->attrs[NL80211_ATTR_IE]) {
2291 @@ -5751,7 +5810,7 @@ static int nl80211_start_radar_detection
2292
2293 err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef);
2294 if (!err) {
2295 - wdev->channel = chandef.chan;
2296 + wdev->chandef = chandef;
2297 wdev->cac_started = true;
2298 wdev->cac_start_time = jiffies;
2299 }
2300 @@ -7502,16 +7561,19 @@ static int nl80211_set_tx_bitrate_mask(s
2301 * directly to the enum ieee80211_band values used in cfg80211.
2302 */
2303 BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
2304 - nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
2305 - {
2306 + nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) {
2307 enum ieee80211_band band = nla_type(tx_rates);
2308 + int err;
2309 +
2310 if (band < 0 || band >= IEEE80211_NUM_BANDS)
2311 return -EINVAL;
2312 sband = rdev->wiphy.bands[band];
2313 if (sband == NULL)
2314 return -EINVAL;
2315 - nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
2316 - nla_len(tx_rates), nl80211_txattr_policy);
2317 + err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
2318 + nla_len(tx_rates), nl80211_txattr_policy);
2319 + if (err)
2320 + return err;
2321 if (tb[NL80211_TXRATE_LEGACY]) {
2322 mask.control[band].legacy = rateset_to_mask(
2323 sband,
2324 @@ -10054,40 +10116,31 @@ void nl80211_send_scan_start(struct cfg8
2325 NL80211_MCGRP_SCAN, GFP_KERNEL);
2326 }
2327
2328 -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
2329 - struct wireless_dev *wdev)
2330 +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
2331 + struct wireless_dev *wdev, bool aborted)
2332 {
2333 struct sk_buff *msg;
2334
2335 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2336 if (!msg)
2337 - return;
2338 + return NULL;
2339
2340 if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
2341 - NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
2342 + aborted ? NL80211_CMD_SCAN_ABORTED :
2343 + NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
2344 nlmsg_free(msg);
2345 - return;
2346 + return NULL;
2347 }
2348
2349 - genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
2350 - NL80211_MCGRP_SCAN, GFP_KERNEL);
2351 + return msg;
2352 }
2353
2354 -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
2355 - struct wireless_dev *wdev)
2356 +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
2357 + struct sk_buff *msg)
2358 {
2359 - struct sk_buff *msg;
2360 -
2361 - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2362 if (!msg)
2363 return;
2364
2365 - if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
2366 - NL80211_CMD_SCAN_ABORTED) < 0) {
2367 - nlmsg_free(msg);
2368 - return;
2369 - }
2370 -
2371 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
2372 NL80211_MCGRP_SCAN, GFP_KERNEL);
2373 }
2374 @@ -11158,7 +11211,8 @@ void cfg80211_ch_switch_notify(struct ne
2375 wdev->iftype != NL80211_IFTYPE_MESH_POINT))
2376 return;
2377
2378 - wdev->channel = chandef->chan;
2379 + wdev->chandef = *chandef;
2380 + wdev->preset_chandef = *chandef;
2381 nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL);
2382 }
2383 EXPORT_SYMBOL(cfg80211_ch_switch_notify);
2384 @@ -11673,6 +11727,35 @@ void cfg80211_crit_proto_stopped(struct
2385 }
2386 EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
2387
2388 +void nl80211_send_ap_stopped(struct wireless_dev *wdev)
2389 +{
2390 + struct wiphy *wiphy = wdev->wiphy;
2391 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
2392 + struct sk_buff *msg;
2393 + void *hdr;
2394 +
2395 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
2396 + if (!msg)
2397 + return;
2398 +
2399 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_STOP_AP);
2400 + if (!hdr)
2401 + goto out;
2402 +
2403 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
2404 + nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) ||
2405 + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
2406 + goto out;
2407 +
2408 + genlmsg_end(msg, hdr);
2409 +
2410 + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(wiphy), msg, 0,
2411 + NL80211_MCGRP_MLME, GFP_KERNEL);
2412 + return;
2413 + out:
2414 + nlmsg_free(msg);
2415 +}
2416 +
2417 /* initialisation/exit functions */
2418
2419 int nl80211_init(void)
2420 --- a/net/wireless/nl80211.h
2421 +++ b/net/wireless/nl80211.h
2422 @@ -8,10 +8,10 @@ void nl80211_exit(void);
2423 void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
2424 void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
2425 struct wireless_dev *wdev);
2426 -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
2427 - struct wireless_dev *wdev);
2428 -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
2429 - struct wireless_dev *wdev);
2430 +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
2431 + struct wireless_dev *wdev, bool aborted);
2432 +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
2433 + struct sk_buff *msg);
2434 void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
2435 struct net_device *netdev, u32 cmd);
2436 void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
2437 @@ -74,6 +74,8 @@ nl80211_radar_notify(struct cfg80211_reg
2438 enum nl80211_radar_event event,
2439 struct net_device *netdev, gfp_t gfp);
2440
2441 +void nl80211_send_ap_stopped(struct wireless_dev *wdev);
2442 +
2443 void cfg80211_rdev_free_coalesce(struct cfg80211_registered_device *rdev);
2444
2445 #endif /* __NET_WIRELESS_NL80211_H */
2446 --- a/net/wireless/scan.c
2447 +++ b/net/wireless/scan.c
2448 @@ -161,18 +161,25 @@ static void __cfg80211_bss_expire(struct
2449 dev->bss_generation++;
2450 }
2451
2452 -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev)
2453 +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
2454 + bool send_message)
2455 {
2456 struct cfg80211_scan_request *request;
2457 struct wireless_dev *wdev;
2458 + struct sk_buff *msg;
2459 #ifdef CPTCFG_CFG80211_WEXT
2460 union iwreq_data wrqu;
2461 #endif
2462
2463 ASSERT_RTNL();
2464
2465 - request = rdev->scan_req;
2466 + if (rdev->scan_msg) {
2467 + nl80211_send_scan_result(rdev, rdev->scan_msg);
2468 + rdev->scan_msg = NULL;
2469 + return;
2470 + }
2471
2472 + request = rdev->scan_req;
2473 if (!request)
2474 return;
2475
2476 @@ -186,18 +193,16 @@ void ___cfg80211_scan_done(struct cfg802
2477 if (wdev->netdev)
2478 cfg80211_sme_scan_done(wdev->netdev);
2479
2480 - if (request->aborted) {
2481 - nl80211_send_scan_aborted(rdev, wdev);
2482 - } else {
2483 - if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
2484 - /* flush entries from previous scans */
2485 - spin_lock_bh(&rdev->bss_lock);
2486 - __cfg80211_bss_expire(rdev, request->scan_start);
2487 - spin_unlock_bh(&rdev->bss_lock);
2488 - }
2489 - nl80211_send_scan_done(rdev, wdev);
2490 + if (!request->aborted &&
2491 + request->flags & NL80211_SCAN_FLAG_FLUSH) {
2492 + /* flush entries from previous scans */
2493 + spin_lock_bh(&rdev->bss_lock);
2494 + __cfg80211_bss_expire(rdev, request->scan_start);
2495 + spin_unlock_bh(&rdev->bss_lock);
2496 }
2497
2498 + msg = nl80211_build_scan_msg(rdev, wdev, request->aborted);
2499 +
2500 #ifdef CPTCFG_CFG80211_WEXT
2501 if (wdev->netdev && !request->aborted) {
2502 memset(&wrqu, 0, sizeof(wrqu));
2503 @@ -211,6 +216,11 @@ void ___cfg80211_scan_done(struct cfg802
2504
2505 rdev->scan_req = NULL;
2506 kfree(request);
2507 +
2508 + if (!send_message)
2509 + rdev->scan_msg = msg;
2510 + else
2511 + nl80211_send_scan_result(rdev, msg);
2512 }
2513
2514 void __cfg80211_scan_done(struct work_struct *wk)
2515 @@ -221,7 +231,7 @@ void __cfg80211_scan_done(struct work_st
2516 scan_done_wk);
2517
2518 rtnl_lock();
2519 - ___cfg80211_scan_done(rdev);
2520 + ___cfg80211_scan_done(rdev, true);
2521 rtnl_unlock();
2522 }
2523
2524 @@ -1079,7 +1089,7 @@ int cfg80211_wext_siwscan(struct net_dev
2525 if (IS_ERR(rdev))
2526 return PTR_ERR(rdev);
2527
2528 - if (rdev->scan_req) {
2529 + if (rdev->scan_req || rdev->scan_msg) {
2530 err = -EBUSY;
2531 goto out;
2532 }
2533 @@ -1481,7 +1491,7 @@ int cfg80211_wext_giwscan(struct net_dev
2534 if (IS_ERR(rdev))
2535 return PTR_ERR(rdev);
2536
2537 - if (rdev->scan_req)
2538 + if (rdev->scan_req || rdev->scan_msg)
2539 return -EAGAIN;
2540
2541 res = ieee80211_scan_results(rdev, info, extra, data->length);
2542 --- a/net/wireless/sme.c
2543 +++ b/net/wireless/sme.c
2544 @@ -67,7 +67,7 @@ static int cfg80211_conn_scan(struct wir
2545 ASSERT_RDEV_LOCK(rdev);
2546 ASSERT_WDEV_LOCK(wdev);
2547
2548 - if (rdev->scan_req)
2549 + if (rdev->scan_req || rdev->scan_msg)
2550 return -EBUSY;
2551
2552 if (wdev->conn->params.channel)
2553 --- a/net/mac80211/mlme.c
2554 +++ b/net/mac80211/mlme.c
2555 @@ -1001,7 +1001,6 @@ ieee80211_sta_process_chanswitch(struct
2556 }
2557
2558 ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
2559 - sdata->vif.csa_active = true;
2560
2561 mutex_lock(&local->chanctx_mtx);
2562 if (local->use_chanctx) {
2563 @@ -1039,6 +1038,7 @@ ieee80211_sta_process_chanswitch(struct
2564 mutex_unlock(&local->chanctx_mtx);
2565
2566 sdata->csa_chandef = csa_ie.chandef;
2567 + sdata->vif.csa_active = true;
2568
2569 if (csa_ie.mode)
2570 ieee80211_stop_queues_by_reason(&local->hw,
2571 --- a/net/mac80211/chan.c
2572 +++ b/net/mac80211/chan.c
2573 @@ -196,6 +196,8 @@ static bool ieee80211_is_radar_required(
2574 {
2575 struct ieee80211_sub_if_data *sdata;
2576
2577 + lockdep_assert_held(&local->mtx);
2578 +
2579 rcu_read_lock();
2580 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
2581 if (sdata->radar_required) {
2582 --- a/net/mac80211/ibss.c
2583 +++ b/net/mac80211/ibss.c
2584 @@ -294,7 +294,6 @@ static void __ieee80211_sta_join_ibss(st
2585 }
2586
2587 mutex_lock(&local->mtx);
2588 - ieee80211_vif_release_channel(sdata);
2589 if (ieee80211_vif_use_channel(sdata, &chandef,
2590 ifibss->fixed_channel ?
2591 IEEE80211_CHANCTX_SHARED :
2592 @@ -303,6 +302,7 @@ static void __ieee80211_sta_join_ibss(st
2593 mutex_unlock(&local->mtx);
2594 return;
2595 }
2596 + sdata->radar_required = radar_required;
2597 mutex_unlock(&local->mtx);
2598
2599 memcpy(ifibss->bssid, bssid, ETH_ALEN);
2600 @@ -318,7 +318,6 @@ static void __ieee80211_sta_join_ibss(st
2601 rcu_assign_pointer(ifibss->presp, presp);
2602 mgmt = (void *)presp->head;
2603
2604 - sdata->radar_required = radar_required;
2605 sdata->vif.bss_conf.enable_beacon = true;
2606 sdata->vif.bss_conf.beacon_int = beacon_int;
2607 sdata->vif.bss_conf.basic_rates = basic_rates;
2608 @@ -386,7 +385,7 @@ static void __ieee80211_sta_join_ibss(st
2609 presp->head_len, 0, GFP_KERNEL);
2610 cfg80211_put_bss(local->hw.wiphy, bss);
2611 netif_carrier_on(sdata->dev);
2612 - cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL);
2613 + cfg80211_ibss_joined(sdata->dev, ifibss->bssid, chan, GFP_KERNEL);
2614 }
2615
2616 static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
2617 @@ -802,6 +801,8 @@ ieee80211_ibss_process_chanswitch(struct
2618 int err;
2619 u32 sta_flags;
2620
2621 + sdata_assert_lock(sdata);
2622 +
2623 sta_flags = IEEE80211_STA_DISABLE_VHT;
2624 switch (ifibss->chandef.width) {
2625 case NL80211_CHAN_WIDTH_5:
2626 @@ -1471,6 +1472,11 @@ static void ieee80211_rx_mgmt_probe_req(
2627 memcpy(((struct ieee80211_mgmt *) skb->data)->da, mgmt->sa, ETH_ALEN);
2628 ibss_dbg(sdata, "Sending ProbeResp to %pM\n", mgmt->sa);
2629 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
2630 +
2631 + /* avoid excessive retries for probe request to wildcard SSIDs */
2632 + if (pos[1] == 0)
2633 + IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_NO_ACK;
2634 +
2635 ieee80211_tx_skb(sdata, skb);
2636 }
2637
2638 --- a/net/mac80211/mesh.c
2639 +++ b/net/mac80211/mesh.c
2640 @@ -872,6 +872,8 @@ ieee80211_mesh_process_chnswitch(struct
2641 if (!ifmsh->mesh_id)
2642 return false;
2643
2644 + sdata_assert_lock(sdata);
2645 +
2646 sta_flags = IEEE80211_STA_DISABLE_VHT;
2647 switch (sdata->vif.bss_conf.chandef.width) {
2648 case NL80211_CHAN_WIDTH_20_NOHT:
2649 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2650 +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2651 @@ -4658,6 +4658,7 @@ brcmf_notify_connect_status(struct brcmf
2652 struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
2653 struct net_device *ndev = ifp->ndev;
2654 struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
2655 + struct ieee80211_channel *chan;
2656 s32 err = 0;
2657
2658 if (ifp->vif->mode == WL_MODE_AP) {
2659 @@ -4665,9 +4666,10 @@ brcmf_notify_connect_status(struct brcmf
2660 } else if (brcmf_is_linkup(e)) {
2661 brcmf_dbg(CONN, "Linkup\n");
2662 if (brcmf_is_ibssmode(ifp->vif)) {
2663 + chan = ieee80211_get_channel(cfg->wiphy, cfg->channel);
2664 memcpy(profile->bssid, e->addr, ETH_ALEN);
2665 wl_inform_ibss(cfg, ndev, e->addr);
2666 - cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL);
2667 + cfg80211_ibss_joined(ndev, e->addr, chan, GFP_KERNEL);
2668 clear_bit(BRCMF_VIF_STATUS_CONNECTING,
2669 &ifp->vif->sme_state);
2670 set_bit(BRCMF_VIF_STATUS_CONNECTED,
2671 --- a/drivers/net/wireless/libertas/cfg.c
2672 +++ b/drivers/net/wireless/libertas/cfg.c
2673 @@ -1766,7 +1766,8 @@ static void lbs_join_post(struct lbs_pri
2674 memcpy(priv->wdev->ssid, params->ssid, params->ssid_len);
2675 priv->wdev->ssid_len = params->ssid_len;
2676
2677 - cfg80211_ibss_joined(priv->dev, bssid, GFP_KERNEL);
2678 + cfg80211_ibss_joined(priv->dev, bssid, params->chandef.chan,
2679 + GFP_KERNEL);
2680
2681 /* TODO: consider doing this at MACREG_INT_CODE_LINK_SENSED time */
2682 priv->connect_status = LBS_CONNECTED;
2683 --- a/drivers/net/wireless/mwifiex/cfg80211.c
2684 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
2685 @@ -1881,7 +1881,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy
2686 params->privacy);
2687 done:
2688 if (!ret) {
2689 - cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL);
2690 + cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid,
2691 + params->chandef.chan, GFP_KERNEL);
2692 dev_dbg(priv->adapter->dev,
2693 "info: joined/created adhoc network with bssid"
2694 " %pM successfully\n", priv->cfg_bssid);
2695 --- a/drivers/net/wireless/rndis_wlan.c
2696 +++ b/drivers/net/wireless/rndis_wlan.c
2697 @@ -2835,7 +2835,9 @@ static void rndis_wlan_do_link_up_work(s
2698 bssid, req_ie, req_ie_len,
2699 resp_ie, resp_ie_len, GFP_KERNEL);
2700 } else if (priv->infra_mode == NDIS_80211_INFRA_ADHOC)
2701 - cfg80211_ibss_joined(usbdev->net, bssid, GFP_KERNEL);
2702 + cfg80211_ibss_joined(usbdev->net, bssid,
2703 + get_current_channel(usbdev, NULL),
2704 + GFP_KERNEL);
2705
2706 kfree(info);
2707
2708 --- a/net/wireless/ibss.c
2709 +++ b/net/wireless/ibss.c
2710 @@ -14,7 +14,8 @@
2711 #include "rdev-ops.h"
2712
2713
2714 -void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid)
2715 +void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
2716 + struct ieee80211_channel *channel)
2717 {
2718 struct wireless_dev *wdev = dev->ieee80211_ptr;
2719 struct cfg80211_bss *bss;
2720 @@ -28,8 +29,7 @@ void __cfg80211_ibss_joined(struct net_d
2721 if (!wdev->ssid_len)
2722 return;
2723
2724 - bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
2725 - wdev->ssid, wdev->ssid_len,
2726 + bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, NULL, 0,
2727 WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS);
2728
2729 if (WARN_ON(!bss))
2730 @@ -54,21 +54,26 @@ void __cfg80211_ibss_joined(struct net_d
2731 #endif
2732 }
2733
2734 -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
2735 +void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
2736 + struct ieee80211_channel *channel, gfp_t gfp)
2737 {
2738 struct wireless_dev *wdev = dev->ieee80211_ptr;
2739 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
2740 struct cfg80211_event *ev;
2741 unsigned long flags;
2742
2743 - trace_cfg80211_ibss_joined(dev, bssid);
2744 + trace_cfg80211_ibss_joined(dev, bssid, channel);
2745 +
2746 + if (WARN_ON(!channel))
2747 + return;
2748
2749 ev = kzalloc(sizeof(*ev), gfp);
2750 if (!ev)
2751 return;
2752
2753 ev->type = EVENT_IBSS_JOINED;
2754 - memcpy(ev->cr.bssid, bssid, ETH_ALEN);
2755 + memcpy(ev->ij.bssid, bssid, ETH_ALEN);
2756 + ev->ij.channel = channel;
2757
2758 spin_lock_irqsave(&wdev->event_lock, flags);
2759 list_add_tail(&ev->list, &wdev->event_list);
2760 @@ -117,6 +122,7 @@ int __cfg80211_join_ibss(struct cfg80211
2761
2762 wdev->ibss_fixed = params->channel_fixed;
2763 wdev->ibss_dfs_possible = params->userspace_handles_dfs;
2764 + wdev->chandef = params->chandef;
2765 #ifdef CPTCFG_CFG80211_WEXT
2766 wdev->wext.ibss.chandef = params->chandef;
2767 #endif
2768 @@ -200,6 +206,7 @@ static void __cfg80211_clear_ibss(struct
2769
2770 wdev->current_bss = NULL;
2771 wdev->ssid_len = 0;
2772 + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
2773 #ifdef CPTCFG_CFG80211_WEXT
2774 if (!nowext)
2775 wdev->wext.ibss.ssid_len = 0;
2776 --- a/net/wireless/trace.h
2777 +++ b/net/wireless/trace.h
2778 @@ -2278,11 +2278,6 @@ DECLARE_EVENT_CLASS(cfg80211_rx_evt,
2779 TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT, NETDEV_PR_ARG, MAC_PR_ARG(addr))
2780 );
2781
2782 -DEFINE_EVENT(cfg80211_rx_evt, cfg80211_ibss_joined,
2783 - TP_PROTO(struct net_device *netdev, const u8 *addr),
2784 - TP_ARGS(netdev, addr)
2785 -);
2786 -
2787 DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_spurious_frame,
2788 TP_PROTO(struct net_device *netdev, const u8 *addr),
2789 TP_ARGS(netdev, addr)
2790 @@ -2293,6 +2288,24 @@ DEFINE_EVENT(cfg80211_rx_evt, cfg80211_r
2791 TP_ARGS(netdev, addr)
2792 );
2793
2794 +TRACE_EVENT(cfg80211_ibss_joined,
2795 + TP_PROTO(struct net_device *netdev, const u8 *bssid,
2796 + struct ieee80211_channel *channel),
2797 + TP_ARGS(netdev, bssid, channel),
2798 + TP_STRUCT__entry(
2799 + NETDEV_ENTRY
2800 + MAC_ENTRY(bssid)
2801 + CHAN_ENTRY
2802 + ),
2803 + TP_fast_assign(
2804 + NETDEV_ASSIGN;
2805 + MAC_ASSIGN(bssid, bssid);
2806 + CHAN_ASSIGN(channel);
2807 + ),
2808 + TP_printk(NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", " CHAN_PR_FMT,
2809 + NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG)
2810 +);
2811 +
2812 TRACE_EVENT(cfg80211_probe_status,
2813 TP_PROTO(struct net_device *netdev, const u8 *addr, u64 cookie,
2814 bool acked),
2815 --- a/net/wireless/util.c
2816 +++ b/net/wireless/util.c
2817 @@ -820,7 +820,8 @@ void cfg80211_process_wdev_events(struct
2818 ev->dc.reason, true);
2819 break;
2820 case EVENT_IBSS_JOINED:
2821 - __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
2822 + __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid,
2823 + ev->ij.channel);
2824 break;
2825 }
2826 wdev_unlock(wdev);
2827 @@ -1356,7 +1357,7 @@ int cfg80211_can_use_iftype_chan(struct
2828 */
2829 mutex_lock_nested(&wdev_iter->mtx, 1);
2830 __acquire(wdev_iter->mtx);
2831 - cfg80211_get_chan_state(wdev_iter, &ch, &chmode);
2832 + cfg80211_get_chan_state(wdev_iter, &ch, &chmode, &radar_detect);
2833 wdev_unlock(wdev_iter);
2834
2835 switch (chmode) {
2836 --- a/net/wireless/chan.c
2837 +++ b/net/wireless/chan.c
2838 @@ -642,7 +642,8 @@ int cfg80211_set_monitor_channel(struct
2839 void
2840 cfg80211_get_chan_state(struct wireless_dev *wdev,
2841 struct ieee80211_channel **chan,
2842 - enum cfg80211_chan_mode *chanmode)
2843 + enum cfg80211_chan_mode *chanmode,
2844 + u8 *radar_detect)
2845 {
2846 *chan = NULL;
2847 *chanmode = CHAN_MODE_UNDEFINED;
2848 @@ -660,6 +661,11 @@ cfg80211_get_chan_state(struct wireless_
2849 !wdev->ibss_dfs_possible)
2850 ? CHAN_MODE_SHARED
2851 : CHAN_MODE_EXCLUSIVE;
2852 +
2853 + /* consider worst-case - IBSS can try to return to the
2854 + * original user-specified channel as creator */
2855 + if (wdev->ibss_dfs_possible)
2856 + *radar_detect |= BIT(wdev->chandef.width);
2857 return;
2858 }
2859 break;
2860 @@ -674,17 +680,26 @@ cfg80211_get_chan_state(struct wireless_
2861 case NL80211_IFTYPE_AP:
2862 case NL80211_IFTYPE_P2P_GO:
2863 if (wdev->cac_started) {
2864 - *chan = wdev->channel;
2865 + *chan = wdev->chandef.chan;
2866 *chanmode = CHAN_MODE_SHARED;
2867 + *radar_detect |= BIT(wdev->chandef.width);
2868 } else if (wdev->beacon_interval) {
2869 - *chan = wdev->channel;
2870 + *chan = wdev->chandef.chan;
2871 *chanmode = CHAN_MODE_SHARED;
2872 +
2873 + if (cfg80211_chandef_dfs_required(wdev->wiphy,
2874 + &wdev->chandef))
2875 + *radar_detect |= BIT(wdev->chandef.width);
2876 }
2877 return;
2878 case NL80211_IFTYPE_MESH_POINT:
2879 if (wdev->mesh_id_len) {
2880 - *chan = wdev->channel;
2881 + *chan = wdev->chandef.chan;
2882 *chanmode = CHAN_MODE_SHARED;
2883 +
2884 + if (cfg80211_chandef_dfs_required(wdev->wiphy,
2885 + &wdev->chandef))
2886 + *radar_detect |= BIT(wdev->chandef.width);
2887 }
2888 return;
2889 case NL80211_IFTYPE_MONITOR:
2890 --- a/net/wireless/mesh.c
2891 +++ b/net/wireless/mesh.c
2892 @@ -195,7 +195,7 @@ int __cfg80211_join_mesh(struct cfg80211
2893 if (!err) {
2894 memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
2895 wdev->mesh_id_len = setup->mesh_id_len;
2896 - wdev->channel = setup->chandef.chan;
2897 + wdev->chandef = setup->chandef;
2898 }
2899
2900 return err;
2901 @@ -244,7 +244,7 @@ int cfg80211_set_mesh_channel(struct cfg
2902 err = rdev_libertas_set_mesh_channel(rdev, wdev->netdev,
2903 chandef->chan);
2904 if (!err)
2905 - wdev->channel = chandef->chan;
2906 + wdev->chandef = *chandef;
2907
2908 return err;
2909 }
2910 @@ -276,7 +276,7 @@ static int __cfg80211_leave_mesh(struct
2911 err = rdev_leave_mesh(rdev, dev);
2912 if (!err) {
2913 wdev->mesh_id_len = 0;
2914 - wdev->channel = NULL;
2915 + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
2916 rdev_set_qos_map(rdev, dev, NULL);
2917 }
2918
2919 --- a/net/wireless/mlme.c
2920 +++ b/net/wireless/mlme.c
2921 @@ -772,7 +772,7 @@ void cfg80211_cac_event(struct net_devic
2922 if (WARN_ON(!wdev->cac_started))
2923 return;
2924
2925 - if (WARN_ON(!wdev->channel))
2926 + if (WARN_ON(!wdev->chandef.chan))
2927 return;
2928
2929 switch (event) {
2930 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2931 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
2932 @@ -5065,6 +5065,10 @@ static u16 ar9003_hw_get_max_edge_power(
2933 break;
2934 }
2935 }
2936 +
2937 + if (is2GHz && !twiceMaxEdgePower)
2938 + twiceMaxEdgePower = 60;
2939 +
2940 return twiceMaxEdgePower;
2941 }
2942
2943 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
2944 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
2945 @@ -23,10 +23,11 @@
2946 #define MAX_MEASUREMENT MAX_IQCAL_MEASUREMENT
2947 #define MAX_MAG_DELTA 11
2948 #define MAX_PHS_DELTA 10
2949 +#define MAXIQCAL 3
2950
2951 struct coeff {
2952 - int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
2953 - int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
2954 + int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
2955 + int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
2956 int iqc_coeff[2];
2957 };
2958
2959 @@ -800,7 +801,7 @@ static bool ar9003_hw_calc_iq_corr(struc
2960 if (q_q_coff > 63)
2961 q_q_coff = 63;
2962
2963 - iqc_coeff[0] = (q_q_coff * 128) + q_i_coff;
2964 + iqc_coeff[0] = (q_q_coff * 128) + (0x7f & q_i_coff);
2965
2966 ath_dbg(common, CALIBRATE, "tx chain %d: iq corr coeff=%x\n",
2967 chain_idx, iqc_coeff[0]);
2968 @@ -831,7 +832,7 @@ static bool ar9003_hw_calc_iq_corr(struc
2969 if (q_q_coff > 63)
2970 q_q_coff = 63;
2971
2972 - iqc_coeff[1] = (q_q_coff * 128) + q_i_coff;
2973 + iqc_coeff[1] = (q_q_coff * 128) + (0x7f & q_i_coff);
2974
2975 ath_dbg(common, CALIBRATE, "rx chain %d: iq corr coeff=%x\n",
2976 chain_idx, iqc_coeff[1]);
2977 @@ -839,7 +840,8 @@ static bool ar9003_hw_calc_iq_corr(struc
2978 return true;
2979 }
2980
2981 -static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
2982 +static void ar9003_hw_detect_outlier(int mp_coeff[][MAXIQCAL],
2983 + int nmeasurement,
2984 int max_delta)
2985 {
2986 int mp_max = -64, max_idx = 0;
2987 @@ -848,20 +850,20 @@ static void ar9003_hw_detect_outlier(int
2988
2989 /* find min/max mismatch across all calibrated gains */
2990 for (i = 0; i < nmeasurement; i++) {
2991 - if (mp_coeff[i] > mp_max) {
2992 - mp_max = mp_coeff[i];
2993 + if (mp_coeff[i][0] > mp_max) {
2994 + mp_max = mp_coeff[i][0];
2995 max_idx = i;
2996 - } else if (mp_coeff[i] < mp_min) {
2997 - mp_min = mp_coeff[i];
2998 + } else if (mp_coeff[i][0] < mp_min) {
2999 + mp_min = mp_coeff[i][0];
3000 min_idx = i;
3001 }
3002 }
3003
3004 /* find average (exclude max abs value) */
3005 for (i = 0; i < nmeasurement; i++) {
3006 - if ((abs(mp_coeff[i]) < abs(mp_max)) ||
3007 - (abs(mp_coeff[i]) < abs(mp_min))) {
3008 - mp_avg += mp_coeff[i];
3009 + if ((abs(mp_coeff[i][0]) < abs(mp_max)) ||
3010 + (abs(mp_coeff[i][0]) < abs(mp_min))) {
3011 + mp_avg += mp_coeff[i][0];
3012 mp_count++;
3013 }
3014 }
3015 @@ -873,7 +875,7 @@ static void ar9003_hw_detect_outlier(int
3016 if (mp_count)
3017 mp_avg /= mp_count;
3018 else
3019 - mp_avg = mp_coeff[nmeasurement - 1];
3020 + mp_avg = mp_coeff[nmeasurement - 1][0];
3021
3022 /* detect outlier */
3023 if (abs(mp_max - mp_min) > max_delta) {
3024 @@ -882,15 +884,16 @@ static void ar9003_hw_detect_outlier(int
3025 else
3026 outlier_idx = min_idx;
3027
3028 - mp_coeff[outlier_idx] = mp_avg;
3029 + mp_coeff[outlier_idx][0] = mp_avg;
3030 }
3031 }
3032
3033 -static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
3034 - struct coeff *coeff,
3035 - bool is_reusable)
3036 +static void ar9003_hw_tx_iq_cal_outlier_detection(struct ath_hw *ah,
3037 + struct coeff *coeff,
3038 + bool is_reusable)
3039 {
3040 int i, im, nmeasurement;
3041 + int magnitude, phase;
3042 u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
3043 struct ath9k_hw_cal_data *caldata = ah->caldata;
3044
3045 @@ -920,21 +923,30 @@ static void ar9003_hw_tx_iqcal_load_avg_
3046 if (nmeasurement > MAX_MEASUREMENT)
3047 nmeasurement = MAX_MEASUREMENT;
3048
3049 - /* detect outlier only if nmeasurement > 1 */
3050 - if (nmeasurement > 1) {
3051 - /* Detect magnitude outlier */
3052 - ar9003_hw_detect_outlier(coeff->mag_coeff[i],
3053 - nmeasurement, MAX_MAG_DELTA);
3054 -
3055 - /* Detect phase outlier */
3056 - ar9003_hw_detect_outlier(coeff->phs_coeff[i],
3057 - nmeasurement, MAX_PHS_DELTA);
3058 + /*
3059 + * Skip normal outlier detection for AR9550.
3060 + */
3061 + if (!AR_SREV_9550(ah)) {
3062 + /* detect outlier only if nmeasurement > 1 */
3063 + if (nmeasurement > 1) {
3064 + /* Detect magnitude outlier */
3065 + ar9003_hw_detect_outlier(coeff->mag_coeff[i],
3066 + nmeasurement,
3067 + MAX_MAG_DELTA);
3068 +
3069 + /* Detect phase outlier */
3070 + ar9003_hw_detect_outlier(coeff->phs_coeff[i],
3071 + nmeasurement,
3072 + MAX_PHS_DELTA);
3073 + }
3074 }
3075
3076 for (im = 0; im < nmeasurement; im++) {
3077 + magnitude = coeff->mag_coeff[i][im][0];
3078 + phase = coeff->phs_coeff[i][im][0];
3079
3080 - coeff->iqc_coeff[0] = (coeff->mag_coeff[i][im] & 0x7f) |
3081 - ((coeff->phs_coeff[i][im] & 0x7f) << 7);
3082 + coeff->iqc_coeff[0] =
3083 + (phase & 0x7f) | ((magnitude & 0x7f) << 7);
3084
3085 if ((im % 2) == 0)
3086 REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
3087 @@ -991,7 +1003,63 @@ static bool ar9003_hw_tx_iq_cal_run(stru
3088 return true;
3089 }
3090
3091 -static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah, bool is_reusable)
3092 +static void __ar955x_tx_iq_cal_sort(struct ath_hw *ah,
3093 + struct coeff *coeff,
3094 + int i, int nmeasurement)
3095 +{
3096 + struct ath_common *common = ath9k_hw_common(ah);
3097 + int im, ix, iy, temp;
3098 +
3099 + for (im = 0; im < nmeasurement; im++) {
3100 + for (ix = 0; ix < MAXIQCAL - 1; ix++) {
3101 + for (iy = ix + 1; iy <= MAXIQCAL - 1; iy++) {
3102 + if (coeff->mag_coeff[i][im][iy] <
3103 + coeff->mag_coeff[i][im][ix]) {
3104 + temp = coeff->mag_coeff[i][im][ix];
3105 + coeff->mag_coeff[i][im][ix] =
3106 + coeff->mag_coeff[i][im][iy];
3107 + coeff->mag_coeff[i][im][iy] = temp;
3108 + }
3109 + if (coeff->phs_coeff[i][im][iy] <
3110 + coeff->phs_coeff[i][im][ix]) {
3111 + temp = coeff->phs_coeff[i][im][ix];
3112 + coeff->phs_coeff[i][im][ix] =
3113 + coeff->phs_coeff[i][im][iy];
3114 + coeff->phs_coeff[i][im][iy] = temp;
3115 + }
3116 + }
3117 + }
3118 + coeff->mag_coeff[i][im][0] = coeff->mag_coeff[i][im][MAXIQCAL / 2];
3119 + coeff->phs_coeff[i][im][0] = coeff->phs_coeff[i][im][MAXIQCAL / 2];
3120 +
3121 + ath_dbg(common, CALIBRATE,
3122 + "IQCAL: Median [ch%d][gain%d]: mag = %d phase = %d\n",
3123 + i, im,
3124 + coeff->mag_coeff[i][im][0],
3125 + coeff->phs_coeff[i][im][0]);
3126 + }
3127 +}
3128 +
3129 +static bool ar955x_tx_iq_cal_median(struct ath_hw *ah,
3130 + struct coeff *coeff,
3131 + int iqcal_idx,
3132 + int nmeasurement)
3133 +{
3134 + int i;
3135 +
3136 + if ((iqcal_idx + 1) != MAXIQCAL)
3137 + return false;
3138 +
3139 + for (i = 0; i < AR9300_MAX_CHAINS; i++) {
3140 + __ar955x_tx_iq_cal_sort(ah, coeff, i, nmeasurement);
3141 + }
3142 +
3143 + return true;
3144 +}
3145 +
3146 +static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah,
3147 + int iqcal_idx,
3148 + bool is_reusable)
3149 {
3150 struct ath_common *common = ath9k_hw_common(ah);
3151 const u32 txiqcal_status[AR9300_MAX_CHAINS] = {
3152 @@ -1004,10 +1072,11 @@ static void ar9003_hw_tx_iq_cal_post_pro
3153 AR_PHY_CHAN_INFO_TAB_1,
3154 AR_PHY_CHAN_INFO_TAB_2,
3155 };
3156 - struct coeff coeff;
3157 + static struct coeff coeff;
3158 s32 iq_res[6];
3159 int i, im, j;
3160 - int nmeasurement;
3161 + int nmeasurement = 0;
3162 + bool outlier_detect = true;
3163
3164 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
3165 if (!(ah->txchainmask & (1 << i)))
3166 @@ -1065,17 +1134,23 @@ static void ar9003_hw_tx_iq_cal_post_pro
3167 goto tx_iqcal_fail;
3168 }
3169
3170 - coeff.mag_coeff[i][im] = coeff.iqc_coeff[0] & 0x7f;
3171 - coeff.phs_coeff[i][im] =
3172 + coeff.phs_coeff[i][im][iqcal_idx] =
3173 + coeff.iqc_coeff[0] & 0x7f;
3174 + coeff.mag_coeff[i][im][iqcal_idx] =
3175 (coeff.iqc_coeff[0] >> 7) & 0x7f;
3176
3177 - if (coeff.mag_coeff[i][im] > 63)
3178 - coeff.mag_coeff[i][im] -= 128;
3179 - if (coeff.phs_coeff[i][im] > 63)
3180 - coeff.phs_coeff[i][im] -= 128;
3181 + if (coeff.mag_coeff[i][im][iqcal_idx] > 63)
3182 + coeff.mag_coeff[i][im][iqcal_idx] -= 128;
3183 + if (coeff.phs_coeff[i][im][iqcal_idx] > 63)
3184 + coeff.phs_coeff[i][im][iqcal_idx] -= 128;
3185 }
3186 }
3187 - ar9003_hw_tx_iqcal_load_avg_2_passes(ah, &coeff, is_reusable);
3188 +
3189 + if (AR_SREV_9550(ah))
3190 + outlier_detect = ar955x_tx_iq_cal_median(ah, &coeff,
3191 + iqcal_idx, nmeasurement);
3192 + if (outlier_detect)
3193 + ar9003_hw_tx_iq_cal_outlier_detection(ah, &coeff, is_reusable);
3194
3195 return;
3196
3197 @@ -1409,7 +1484,7 @@ skip_tx_iqcal:
3198 }
3199
3200 if (txiqcal_done)
3201 - ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
3202 + ar9003_hw_tx_iq_cal_post_proc(ah, 0, is_reusable);
3203 else if (caldata && test_bit(TXIQCAL_DONE, &caldata->cal_flags))
3204 ar9003_hw_tx_iq_cal_reload(ah);
3205
3206 @@ -1455,14 +1530,38 @@ skip_tx_iqcal:
3207 return true;
3208 }
3209
3210 +static bool do_ar9003_agc_cal(struct ath_hw *ah)
3211 +{
3212 + struct ath_common *common = ath9k_hw_common(ah);
3213 + bool status;
3214 +
3215 + REG_WRITE(ah, AR_PHY_AGC_CONTROL,
3216 + REG_READ(ah, AR_PHY_AGC_CONTROL) |
3217 + AR_PHY_AGC_CONTROL_CAL);
3218 +
3219 + status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
3220 + AR_PHY_AGC_CONTROL_CAL,
3221 + 0, AH_WAIT_TIMEOUT);
3222 + if (!status) {
3223 + ath_dbg(common, CALIBRATE,
3224 + "offset calibration failed to complete in %d ms,"
3225 + "noisy environment?\n",
3226 + AH_WAIT_TIMEOUT / 1000);
3227 + return false;
3228 + }
3229 +
3230 + return true;
3231 +}
3232 +
3233 static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
3234 struct ath9k_channel *chan)
3235 {
3236 struct ath_common *common = ath9k_hw_common(ah);
3237 struct ath9k_hw_cal_data *caldata = ah->caldata;
3238 bool txiqcal_done = false;
3239 - bool is_reusable = true, status = true;
3240 + bool status = true;
3241 bool run_agc_cal = false, sep_iq_cal = false;
3242 + int i = 0;
3243
3244 /* Use chip chainmask only for calibration */
3245 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
3246 @@ -1485,7 +1584,12 @@ static bool ar9003_hw_init_cal_soc(struc
3247 * AGC calibration. Specifically, AR9550 in SoC chips.
3248 */
3249 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) {
3250 - txiqcal_done = true;
3251 + if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
3252 + AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL)) {
3253 + txiqcal_done = true;
3254 + } else {
3255 + txiqcal_done = false;
3256 + }
3257 run_agc_cal = true;
3258 } else {
3259 sep_iq_cal = true;
3260 @@ -1512,27 +1616,37 @@ skip_tx_iqcal:
3261 if (AR_SREV_9330_11(ah))
3262 ar9003_hw_manual_peak_cal(ah, 0, IS_CHAN_2GHZ(chan));
3263
3264 - /* Calibrate the AGC */
3265 - REG_WRITE(ah, AR_PHY_AGC_CONTROL,
3266 - REG_READ(ah, AR_PHY_AGC_CONTROL) |
3267 - AR_PHY_AGC_CONTROL_CAL);
3268 -
3269 - /* Poll for offset calibration complete */
3270 - status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
3271 - AR_PHY_AGC_CONTROL_CAL,
3272 - 0, AH_WAIT_TIMEOUT);
3273 - }
3274 + /*
3275 + * For non-AR9550 chips, we just trigger AGC calibration
3276 + * in the HW, poll for completion and then process
3277 + * the results.
3278 + *
3279 + * For AR955x, we run it multiple times and use
3280 + * median IQ correction.
3281 + */
3282 + if (!AR_SREV_9550(ah)) {
3283 + status = do_ar9003_agc_cal(ah);
3284 + if (!status)
3285 + return false;
3286
3287 - if (!status) {
3288 - ath_dbg(common, CALIBRATE,
3289 - "offset calibration failed to complete in %d ms; noisy environment?\n",
3290 - AH_WAIT_TIMEOUT / 1000);
3291 - return false;
3292 + if (txiqcal_done)
3293 + ar9003_hw_tx_iq_cal_post_proc(ah, 0, false);
3294 + } else {
3295 + if (!txiqcal_done) {
3296 + status = do_ar9003_agc_cal(ah);
3297 + if (!status)
3298 + return false;
3299 + } else {
3300 + for (i = 0; i < MAXIQCAL; i++) {
3301 + status = do_ar9003_agc_cal(ah);
3302 + if (!status)
3303 + return false;
3304 + ar9003_hw_tx_iq_cal_post_proc(ah, i, false);
3305 + }
3306 + }
3307 + }
3308 }
3309
3310 - if (txiqcal_done)
3311 - ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
3312 -
3313 /* Revert chainmask to runtime parameters */
3314 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
3315
3316 --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
3317 +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
3318 @@ -15,6 +15,8 @@
3319 #ifndef RTL8187_H
3320 #define RTL8187_H
3321
3322 +#include <linux/cache.h>
3323 +
3324 #include "rtl818x.h"
3325 #include "leds.h"
3326
3327 @@ -139,7 +141,10 @@ struct rtl8187_priv {
3328 u8 aifsn[4];
3329 u8 rfkill_mask;
3330 struct {
3331 - __le64 buf;
3332 + union {
3333 + __le64 buf;
3334 + u8 dummy1[L1_CACHE_BYTES];
3335 + } ____cacheline_aligned;
3336 struct sk_buff_head queue;
3337 } b_tx_status; /* This queue is used by both -b and non-b devices */
3338 struct mutex io_mutex;
3339 @@ -147,7 +152,8 @@ struct rtl8187_priv {
3340 u8 bits8;
3341 __le16 bits16;
3342 __le32 bits32;
3343 - } *io_dmabuf;
3344 + u8 dummy2[L1_CACHE_BYTES];
3345 + } *io_dmabuf ____cacheline_aligned;
3346 bool rfkill_off;
3347 u16 seqno;
3348 };
3349 --- a/net/mac80211/wme.c
3350 +++ b/net/mac80211/wme.c
3351 @@ -154,6 +154,11 @@ u16 ieee80211_select_queue(struct ieee80
3352 return IEEE80211_AC_BE;
3353 }
3354
3355 + if (skb->protocol == sdata->control_port_protocol) {
3356 + skb->priority = 7;
3357 + return ieee80211_downgrade_queue(sdata, skb);
3358 + }
3359 +
3360 /* use the data classifier to determine what 802.1d tag the
3361 * data frame has */
3362 rcu_read_lock();
3363 --- a/drivers/net/wireless/ath/ath9k/xmit.c
3364 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3365 @@ -1444,14 +1444,16 @@ void ath_tx_aggr_sleep(struct ieee80211_
3366 for (tidno = 0, tid = &an->tid[tidno];
3367 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
3368
3369 - if (!tid->sched)
3370 - continue;
3371 -
3372 ac = tid->ac;
3373 txq = ac->txq;
3374
3375 ath_txq_lock(sc, txq);
3376
3377 + if (!tid->sched) {
3378 + ath_txq_unlock(sc, txq);
3379 + continue;
3380 + }
3381 +
3382 buffered = ath_tid_has_buffered(tid);
3383
3384 tid->sched = false;
3385 @@ -1696,7 +1698,7 @@ int ath_cabq_update(struct ath_softc *sc
3386
3387 ath9k_hw_get_txq_props(sc->sc_ah, qnum, &qi);
3388
3389 - qi.tqi_readyTime = (cur_conf->beacon_interval *
3390 + qi.tqi_readyTime = (TU_TO_USEC(cur_conf->beacon_interval) *
3391 ATH_CABQ_READY_TIME) / 100;
3392 ath_txq_update(sc, qnum, &qi);
3393
3394 @@ -2061,7 +2063,7 @@ static struct ath_buf *ath_tx_setup_buff
3395
3396 ATH_TXBUF_RESET(bf);
3397
3398 - if (tid) {
3399 + if (tid && ieee80211_is_data_present(hdr->frame_control)) {
3400 fragno = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
3401 seqno = tid->seq_next;
3402 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
3403 @@ -2184,14 +2186,15 @@ int ath_tx_start(struct ieee80211_hw *hw
3404 txq->stopped = true;
3405 }
3406
3407 + if (txctl->an && ieee80211_is_data_present(hdr->frame_control))
3408 + tid = ath_get_skb_tid(sc, txctl->an, skb);
3409 +
3410 if (info->flags & IEEE80211_TX_CTL_PS_RESPONSE) {
3411 ath_txq_unlock(sc, txq);
3412 txq = sc->tx.uapsdq;
3413 ath_txq_lock(sc, txq);
3414 } else if (txctl->an &&
3415 ieee80211_is_data_present(hdr->frame_control)) {
3416 - tid = ath_get_skb_tid(sc, txctl->an, skb);
3417 -
3418 WARN_ON(tid->ac->txq != txctl->txq);
3419
3420 if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
3421 --- a/drivers/net/wireless/ath/ath9k/init.c
3422 +++ b/drivers/net/wireless/ath/ath9k/init.c
3423 @@ -943,6 +943,7 @@ static void ath9k_set_hw_capab(struct at
3424 hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
3425 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ;
3426 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
3427 + hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
3428
3429 hw->queues = 4;
3430 hw->max_rates = 4;
3431 --- a/net/mac80211/ieee80211_i.h
3432 +++ b/net/mac80211/ieee80211_i.h
3433 @@ -1700,14 +1700,8 @@ void ieee80211_stop_queue_by_reason(stru
3434 void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
3435 void ieee80211_add_pending_skb(struct ieee80211_local *local,
3436 struct sk_buff *skb);
3437 -void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
3438 - struct sk_buff_head *skbs,
3439 - void (*fn)(void *data), void *data);
3440 -static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,
3441 - struct sk_buff_head *skbs)
3442 -{
3443 - ieee80211_add_pending_skbs_fn(local, skbs, NULL, NULL);
3444 -}
3445 +void ieee80211_add_pending_skbs(struct ieee80211_local *local,
3446 + struct sk_buff_head *skbs);
3447 void ieee80211_flush_queues(struct ieee80211_local *local,
3448 struct ieee80211_sub_if_data *sdata);
3449
3450 --- a/net/mac80211/sta_info.c
3451 +++ b/net/mac80211/sta_info.c
3452 @@ -91,7 +91,7 @@ static int sta_info_hash_del(struct ieee
3453 return -ENOENT;
3454 }
3455
3456 -static void cleanup_single_sta(struct sta_info *sta)
3457 +static void __cleanup_single_sta(struct sta_info *sta)
3458 {
3459 int ac, i;
3460 struct tid_ampdu_tx *tid_tx;
3461 @@ -99,7 +99,8 @@ static void cleanup_single_sta(struct st
3462 struct ieee80211_local *local = sdata->local;
3463 struct ps_data *ps;
3464
3465 - if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
3466 + if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
3467 + test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
3468 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
3469 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
3470 ps = &sdata->bss->ps;
3471 @@ -109,6 +110,7 @@ static void cleanup_single_sta(struct st
3472 return;
3473
3474 clear_sta_flag(sta, WLAN_STA_PS_STA);
3475 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
3476
3477 atomic_dec(&ps->num_sta_ps);
3478 sta_info_recalc_tim(sta);
3479 @@ -139,7 +141,14 @@ static void cleanup_single_sta(struct st
3480 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending);
3481 kfree(tid_tx);
3482 }
3483 +}
3484
3485 +static void cleanup_single_sta(struct sta_info *sta)
3486 +{
3487 + struct ieee80211_sub_if_data *sdata = sta->sdata;
3488 + struct ieee80211_local *local = sdata->local;
3489 +
3490 + __cleanup_single_sta(sta);
3491 sta_info_free(local, sta);
3492 }
3493
3494 @@ -330,6 +339,7 @@ struct sta_info *sta_info_alloc(struct i
3495 rcu_read_unlock();
3496
3497 spin_lock_init(&sta->lock);
3498 + spin_lock_init(&sta->ps_lock);
3499 INIT_WORK(&sta->drv_unblock_wk, sta_unblock);
3500 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
3501 mutex_init(&sta->ampdu_mlme.mtx);
3502 @@ -487,21 +497,26 @@ static int sta_info_insert_finish(struct
3503 goto out_err;
3504 }
3505
3506 - /* notify driver */
3507 - err = sta_info_insert_drv_state(local, sdata, sta);
3508 - if (err)
3509 - goto out_err;
3510 -
3511 local->num_sta++;
3512 local->sta_generation++;
3513 smp_mb();
3514
3515 + /* simplify things and don't accept BA sessions yet */
3516 + set_sta_flag(sta, WLAN_STA_BLOCK_BA);
3517 +
3518 /* make the station visible */
3519 sta_info_hash_add(local, sta);
3520
3521 list_add_rcu(&sta->list, &local->sta_list);
3522
3523 + /* notify driver */
3524 + err = sta_info_insert_drv_state(local, sdata, sta);
3525 + if (err)
3526 + goto out_remove;
3527 +
3528 set_sta_flag(sta, WLAN_STA_INSERTED);
3529 + /* accept BA sessions now */
3530 + clear_sta_flag(sta, WLAN_STA_BLOCK_BA);
3531
3532 ieee80211_recalc_min_chandef(sdata);
3533 ieee80211_sta_debugfs_add(sta);
3534 @@ -522,6 +537,12 @@ static int sta_info_insert_finish(struct
3535 mesh_accept_plinks_update(sdata);
3536
3537 return 0;
3538 + out_remove:
3539 + sta_info_hash_del(local, sta);
3540 + list_del_rcu(&sta->list);
3541 + local->num_sta--;
3542 + synchronize_net();
3543 + __cleanup_single_sta(sta);
3544 out_err:
3545 mutex_unlock(&local->sta_mtx);
3546 rcu_read_lock();
3547 @@ -1071,10 +1092,14 @@ struct ieee80211_sta *ieee80211_find_sta
3548 }
3549 EXPORT_SYMBOL(ieee80211_find_sta);
3550
3551 -static void clear_sta_ps_flags(void *_sta)
3552 +/* powersave support code */
3553 +void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
3554 {
3555 - struct sta_info *sta = _sta;
3556 struct ieee80211_sub_if_data *sdata = sta->sdata;
3557 + struct ieee80211_local *local = sdata->local;
3558 + struct sk_buff_head pending;
3559 + int filtered = 0, buffered = 0, ac;
3560 + unsigned long flags;
3561 struct ps_data *ps;
3562
3563 if (sdata->vif.type == NL80211_IFTYPE_AP ||
3564 @@ -1085,20 +1110,6 @@ static void clear_sta_ps_flags(void *_st
3565 else
3566 return;
3567
3568 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
3569 - if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA))
3570 - atomic_dec(&ps->num_sta_ps);
3571 -}
3572 -
3573 -/* powersave support code */
3574 -void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
3575 -{
3576 - struct ieee80211_sub_if_data *sdata = sta->sdata;
3577 - struct ieee80211_local *local = sdata->local;
3578 - struct sk_buff_head pending;
3579 - int filtered = 0, buffered = 0, ac;
3580 - unsigned long flags;
3581 -
3582 clear_sta_flag(sta, WLAN_STA_SP);
3583
3584 BUILD_BUG_ON(BITS_TO_LONGS(IEEE80211_NUM_TIDS) > 1);
3585 @@ -1109,6 +1120,8 @@ void ieee80211_sta_ps_deliver_wakeup(str
3586
3587 skb_queue_head_init(&pending);
3588
3589 + /* sync with ieee80211_tx_h_unicast_ps_buf */
3590 + spin_lock(&sta->ps_lock);
3591 /* Send all buffered frames to the station */
3592 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
3593 int count = skb_queue_len(&pending), tmp;
3594 @@ -1127,7 +1140,12 @@ void ieee80211_sta_ps_deliver_wakeup(str
3595 buffered += tmp - count;
3596 }
3597
3598 - ieee80211_add_pending_skbs_fn(local, &pending, clear_sta_ps_flags, sta);
3599 + ieee80211_add_pending_skbs(local, &pending);
3600 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
3601 + clear_sta_flag(sta, WLAN_STA_PS_STA);
3602 + spin_unlock(&sta->ps_lock);
3603 +
3604 + atomic_dec(&ps->num_sta_ps);
3605
3606 /* This station just woke up and isn't aware of our SMPS state */
3607 if (!ieee80211_smps_is_restrictive(sta->known_smps_mode,
3608 --- a/net/mac80211/sta_info.h
3609 +++ b/net/mac80211/sta_info.h
3610 @@ -267,6 +267,7 @@ struct ieee80211_tx_latency_stat {
3611 * @drv_unblock_wk: used for driver PS unblocking
3612 * @listen_interval: listen interval of this station, when we're acting as AP
3613 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
3614 + * @ps_lock: used for powersave (when mac80211 is the AP) related locking
3615 * @ps_tx_buf: buffers (per AC) of frames to transmit to this station
3616 * when it leaves power saving state or polls
3617 * @tx_filtered: buffers (per AC) of frames we already tried to
3618 @@ -356,10 +357,8 @@ struct sta_info {
3619 /* use the accessors defined below */
3620 unsigned long _flags;
3621
3622 - /*
3623 - * STA powersave frame queues, no more than the internal
3624 - * locking required.
3625 - */
3626 + /* STA powersave lock and frame queues */
3627 + spinlock_t ps_lock;
3628 struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
3629 struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
3630 unsigned long driver_buffered_tids;
3631 --- a/net/mac80211/util.c
3632 +++ b/net/mac80211/util.c
3633 @@ -435,9 +435,8 @@ void ieee80211_add_pending_skb(struct ie
3634 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
3635 }
3636
3637 -void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
3638 - struct sk_buff_head *skbs,
3639 - void (*fn)(void *data), void *data)
3640 +void ieee80211_add_pending_skbs(struct ieee80211_local *local,
3641 + struct sk_buff_head *skbs)
3642 {
3643 struct ieee80211_hw *hw = &local->hw;
3644 struct sk_buff *skb;
3645 @@ -461,9 +460,6 @@ void ieee80211_add_pending_skbs_fn(struc
3646 __skb_queue_tail(&local->pending[queue], skb);
3647 }
3648
3649 - if (fn)
3650 - fn(data);
3651 -
3652 for (i = 0; i < hw->queues; i++)
3653 __ieee80211_wake_queue(hw, i,
3654 IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
3655 --- a/net/wireless/reg.c
3656 +++ b/net/wireless/reg.c
3657 @@ -1700,7 +1700,7 @@ static void reg_process_hint(struct regu
3658 return;
3659 case NL80211_REGDOM_SET_BY_USER:
3660 treatment = reg_process_hint_user(reg_request);
3661 - if (treatment == REG_REQ_OK ||
3662 + if (treatment == REG_REQ_IGNORE ||
3663 treatment == REG_REQ_ALREADY_SET)
3664 return;
3665 schedule_delayed_work(&reg_timeout, msecs_to_jiffies(3142));
3666 --- a/drivers/net/wireless/ath/ath9k/debug.c
3667 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3668 @@ -138,43 +138,41 @@ static ssize_t read_file_ani(struct file
3669 unsigned int len = 0, size = 1024;
3670 ssize_t retval = 0;
3671 char *buf;
3672 + int i;
3673 + struct {
3674 + const char *name;
3675 + unsigned int val;
3676 + } ani_info[] = {
3677 + { "ANI RESET", ah->stats.ast_ani_reset },
3678 + { "OFDM LEVEL", ah->ani.ofdmNoiseImmunityLevel },
3679 + { "CCK LEVEL", ah->ani.cckNoiseImmunityLevel },
3680 + { "SPUR UP", ah->stats.ast_ani_spurup },
3681 + { "SPUR DOWN", ah->stats.ast_ani_spurup },
3682 + { "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon },
3683 + { "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff },
3684 + { "MRC-CCK ON", ah->stats.ast_ani_ccklow },
3685 + { "MRC-CCK OFF", ah->stats.ast_ani_cckhigh },
3686 + { "FIR-STEP UP", ah->stats.ast_ani_stepup },
3687 + { "FIR-STEP DOWN", ah->stats.ast_ani_stepdown },
3688 + { "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero },
3689 + { "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs },
3690 + { "CCK ERRORS", ah->stats.ast_ani_cckerrs },
3691 + };
3692
3693 buf = kzalloc(size, GFP_KERNEL);
3694 if (buf == NULL)
3695 return -ENOMEM;
3696
3697 - if (common->disable_ani) {
3698 - len += scnprintf(buf + len, size - len, "%s: %s\n",
3699 - "ANI", "DISABLED");
3700 + len += scnprintf(buf + len, size - len, "%15s: %s\n", "ANI",
3701 + common->disable_ani ? "DISABLED" : "ENABLED");
3702 +
3703 + if (common->disable_ani)
3704 goto exit;
3705 - }
3706
3707 - len += scnprintf(buf + len, size - len, "%15s: %s\n",
3708 - "ANI", "ENABLED");
3709 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3710 - "ANI RESET", ah->stats.ast_ani_reset);
3711 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3712 - "SPUR UP", ah->stats.ast_ani_spurup);
3713 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3714 - "SPUR DOWN", ah->stats.ast_ani_spurup);
3715 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3716 - "OFDM WS-DET ON", ah->stats.ast_ani_ofdmon);
3717 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3718 - "OFDM WS-DET OFF", ah->stats.ast_ani_ofdmoff);
3719 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3720 - "MRC-CCK ON", ah->stats.ast_ani_ccklow);
3721 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3722 - "MRC-CCK OFF", ah->stats.ast_ani_cckhigh);
3723 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3724 - "FIR-STEP UP", ah->stats.ast_ani_stepup);
3725 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3726 - "FIR-STEP DOWN", ah->stats.ast_ani_stepdown);
3727 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3728 - "INV LISTENTIME", ah->stats.ast_ani_lneg_or_lzero);
3729 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3730 - "OFDM ERRORS", ah->stats.ast_ani_ofdmerrs);
3731 - len += scnprintf(buf + len, size - len, "%15s: %u\n",
3732 - "CCK ERRORS", ah->stats.ast_ani_cckerrs);
3733 + for (i = 0; i < ARRAY_SIZE(ani_info); i++)
3734 + len += scnprintf(buf + len, size - len, "%15s: %u\n",
3735 + ani_info[i].name, ani_info[i].val);
3736 +
3737 exit:
3738 if (len > size)
3739 len = size;
3740 @@ -866,6 +864,12 @@ static ssize_t read_file_reset(struct fi
3741 "%17s: %2d\n", "PLL RX Hang",
3742 sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
3743 len += scnprintf(buf + len, sizeof(buf) - len,
3744 + "%17s: %2d\n", "MAC Hang",
3745 + sc->debug.stats.reset[RESET_TYPE_MAC_HANG]);
3746 + len += scnprintf(buf + len, sizeof(buf) - len,
3747 + "%17s: %2d\n", "Stuck Beacon",
3748 + sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]);
3749 + len += scnprintf(buf + len, sizeof(buf) - len,
3750 "%17s: %2d\n", "MCI Reset",
3751 sc->debug.stats.reset[RESET_TYPE_MCI]);
3752
3753 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3754 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3755 @@ -868,10 +868,6 @@ static void ar9003_hw_set_rfmode(struct
3756
3757 if (IS_CHAN_A_FAST_CLOCK(ah, chan))
3758 rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
3759 - if (IS_CHAN_QUARTER_RATE(chan))
3760 - rfMode |= AR_PHY_MODE_QUARTER;
3761 - if (IS_CHAN_HALF_RATE(chan))
3762 - rfMode |= AR_PHY_MODE_HALF;
3763
3764 if (rfMode & (AR_PHY_MODE_QUARTER | AR_PHY_MODE_HALF))
3765 REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL,
3766 --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
3767 +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
3768 @@ -706,6 +706,7 @@ ath5k_get_survey(struct ieee80211_hw *hw
3769 survey->channel = conf->chandef.chan;
3770 survey->noise = ah->ah_noise_floor;
3771 survey->filled = SURVEY_INFO_NOISE_DBM |
3772 + SURVEY_INFO_IN_USE |
3773 SURVEY_INFO_CHANNEL_TIME |
3774 SURVEY_INFO_CHANNEL_TIME_BUSY |
3775 SURVEY_INFO_CHANNEL_TIME_RX |
3776 --- a/drivers/net/wireless/ath/ath9k/recv.c
3777 +++ b/drivers/net/wireless/ath/ath9k/recv.c
3778 @@ -732,11 +732,18 @@ static struct ath_rxbuf *ath_get_next_rx
3779 return NULL;
3780
3781 /*
3782 - * mark descriptor as zero-length and set the 'more'
3783 - * flag to ensure that both buffers get discarded
3784 + * Re-check previous descriptor, in case it has been filled
3785 + * in the mean time.
3786 */
3787 - rs->rs_datalen = 0;
3788 - rs->rs_more = true;
3789 + ret = ath9k_hw_rxprocdesc(ah, ds, rs);
3790 + if (ret == -EINPROGRESS) {
3791 + /*
3792 + * mark descriptor as zero-length and set the 'more'
3793 + * flag to ensure that both buffers get discarded
3794 + */
3795 + rs->rs_datalen = 0;
3796 + rs->rs_more = true;
3797 + }
3798 }
3799
3800 list_del(&bf->list);
3801 @@ -985,32 +992,32 @@ static int ath9k_rx_skb_preprocess(struc
3802 struct ath_common *common = ath9k_hw_common(ah);
3803 struct ieee80211_hdr *hdr;
3804 bool discard_current = sc->rx.discard_next;
3805 - int ret = 0;
3806
3807 /*
3808 * Discard corrupt descriptors which are marked in
3809 * ath_get_next_rx_buf().
3810 */
3811 - sc->rx.discard_next = rx_stats->rs_more;
3812 if (discard_current)
3813 - return -EINVAL;
3814 + goto corrupt;
3815 +
3816 + sc->rx.discard_next = false;
3817
3818 /*
3819 * Discard zero-length packets.
3820 */
3821 if (!rx_stats->rs_datalen) {
3822 RX_STAT_INC(rx_len_err);
3823 - return -EINVAL;
3824 + goto corrupt;
3825 }
3826
3827 - /*
3828 - * rs_status follows rs_datalen so if rs_datalen is too large
3829 - * we can take a hint that hardware corrupted it, so ignore
3830 - * those frames.
3831 - */
3832 + /*
3833 + * rs_status follows rs_datalen so if rs_datalen is too large
3834 + * we can take a hint that hardware corrupted it, so ignore
3835 + * those frames.
3836 + */
3837 if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) {
3838 RX_STAT_INC(rx_len_err);
3839 - return -EINVAL;
3840 + goto corrupt;
3841 }
3842
3843 /* Only use status info from the last fragment */
3844 @@ -1024,10 +1031,8 @@ static int ath9k_rx_skb_preprocess(struc
3845 * This is different from the other corrupt descriptor
3846 * condition handled above.
3847 */
3848 - if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC) {
3849 - ret = -EINVAL;
3850 - goto exit;
3851 - }
3852 + if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC)
3853 + goto corrupt;
3854
3855 hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len);
3856
3857 @@ -1043,18 +1048,15 @@ static int ath9k_rx_skb_preprocess(struc
3858 if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime))
3859 RX_STAT_INC(rx_spectral);
3860
3861 - ret = -EINVAL;
3862 - goto exit;
3863 + return -EINVAL;
3864 }
3865
3866 /*
3867 * everything but the rate is checked here, the rate check is done
3868 * separately to avoid doing two lookups for a rate for each frame.
3869 */
3870 - if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) {
3871 - ret = -EINVAL;
3872 - goto exit;
3873 - }
3874 + if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error))
3875 + return -EINVAL;
3876
3877 if (ath_is_mybeacon(common, hdr)) {
3878 RX_STAT_INC(rx_beacons);
3879 @@ -1064,15 +1066,11 @@ static int ath9k_rx_skb_preprocess(struc
3880 /*
3881 * This shouldn't happen, but have a safety check anyway.
3882 */
3883 - if (WARN_ON(!ah->curchan)) {
3884 - ret = -EINVAL;
3885 - goto exit;
3886 - }
3887 + if (WARN_ON(!ah->curchan))
3888 + return -EINVAL;
3889
3890 - if (ath9k_process_rate(common, hw, rx_stats, rx_status)) {
3891 - ret =-EINVAL;
3892 - goto exit;
3893 - }
3894 + if (ath9k_process_rate(common, hw, rx_stats, rx_status))
3895 + return -EINVAL;
3896
3897 ath9k_process_rssi(common, hw, rx_stats, rx_status);
3898
3899 @@ -1087,9 +1085,11 @@ static int ath9k_rx_skb_preprocess(struc
3900 sc->rx.num_pkts++;
3901 #endif
3902
3903 -exit:
3904 - sc->rx.discard_next = false;
3905 - return ret;
3906 + return 0;
3907 +
3908 +corrupt:
3909 + sc->rx.discard_next = rx_stats->rs_more;
3910 + return -EINVAL;
3911 }
3912
3913 static void ath9k_rx_skb_postprocess(struct ath_common *common,
3914 --- a/drivers/net/wireless/ath/ath9k/ani.c
3915 +++ b/drivers/net/wireless/ath/ath9k/ani.c
3916 @@ -176,16 +176,26 @@ static void ath9k_hw_set_ofdm_nil(struct
3917 if (ah->opmode == NL80211_IFTYPE_STATION &&
3918 BEACON_RSSI(ah) <= ATH9K_ANI_RSSI_THR_HIGH)
3919 weak_sig = true;
3920 -
3921 /*
3922 - * OFDM Weak signal detection is always enabled for AP mode.
3923 + * Newer chipsets are better at dealing with high PHY error counts -
3924 + * keep weak signal detection enabled when no RSSI threshold is
3925 + * available to determine if it is needed (mode != STA)
3926 */
3927 - if (ah->opmode != NL80211_IFTYPE_AP &&
3928 - aniState->ofdmWeakSigDetect != weak_sig) {
3929 - ath9k_hw_ani_control(ah,
3930 - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
3931 - entry_ofdm->ofdm_weak_signal_on);
3932 - }
3933 + else if (AR_SREV_9300_20_OR_LATER(ah) &&
3934 + ah->opmode != NL80211_IFTYPE_STATION)
3935 + weak_sig = true;
3936 +
3937 + /* Older chipsets are more sensitive to high PHY error counts */
3938 + else if (!AR_SREV_9300_20_OR_LATER(ah) &&
3939 + aniState->ofdmNoiseImmunityLevel >= 8)
3940 + weak_sig = false;
3941 +
3942 + if (aniState->ofdmWeakSigDetect != weak_sig)
3943 + ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
3944 + weak_sig);
3945 +
3946 + if (!AR_SREV_9300_20_OR_LATER(ah))
3947 + return;
3948
3949 if (aniState->ofdmNoiseImmunityLevel >= ATH9K_ANI_OFDM_DEF_LEVEL) {
3950 ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
3951 @@ -308,17 +318,6 @@ void ath9k_ani_reset(struct ath_hw *ah,
3952 BUG_ON(aniState == NULL);
3953 ah->stats.ast_ani_reset++;
3954
3955 - /* only allow a subset of functions in AP mode */
3956 - if (ah->opmode == NL80211_IFTYPE_AP) {
3957 - if (IS_CHAN_2GHZ(chan)) {
3958 - ah->ani_function = (ATH9K_ANI_SPUR_IMMUNITY_LEVEL |
3959 - ATH9K_ANI_FIRSTEP_LEVEL);
3960 - if (AR_SREV_9300_20_OR_LATER(ah))
3961 - ah->ani_function |= ATH9K_ANI_MRC_CCK;
3962 - } else
3963 - ah->ani_function = 0;
3964 - }
3965 -
3966 ofdm_nil = max_t(int, ATH9K_ANI_OFDM_DEF_LEVEL,
3967 aniState->ofdmNoiseImmunityLevel);
3968 cck_nil = max_t(int, ATH9K_ANI_CCK_DEF_LEVEL,
3969 @@ -483,10 +482,17 @@ void ath9k_hw_ani_init(struct ath_hw *ah
3970
3971 ath_dbg(common, ANI, "Initialize ANI\n");
3972
3973 - ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
3974 - ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
3975 - ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH;
3976 - ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW;
3977 + if (AR_SREV_9300_20_OR_LATER(ah)) {
3978 + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
3979 + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
3980 + ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH;
3981 + ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW;
3982 + } else {
3983 + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_OLD;
3984 + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW_OLD;
3985 + ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH_OLD;
3986 + ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW_OLD;
3987 + }
3988
3989 ani->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
3990 ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
3991 --- a/drivers/net/wireless/ath/ath9k/ani.h
3992 +++ b/drivers/net/wireless/ath/ath9k/ani.h
3993 @@ -22,12 +22,16 @@
3994 /* units are errors per second */
3995 #define ATH9K_ANI_OFDM_TRIG_HIGH 3500
3996 #define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
3997 +#define ATH9K_ANI_OFDM_TRIG_HIGH_OLD 500
3998
3999 #define ATH9K_ANI_OFDM_TRIG_LOW 400
4000 #define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
4001 +#define ATH9K_ANI_OFDM_TRIG_LOW_OLD 200
4002
4003 #define ATH9K_ANI_CCK_TRIG_HIGH 600
4004 +#define ATH9K_ANI_CCK_TRIG_HIGH_OLD 200
4005 #define ATH9K_ANI_CCK_TRIG_LOW 300
4006 +#define ATH9K_ANI_CCK_TRIG_LOW_OLD 100
4007
4008 #define ATH9K_ANI_SPUR_IMMUNE_LVL 3
4009 #define ATH9K_ANI_FIRSTEP_LVL 2
4010 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
4011 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
4012 @@ -26,10 +26,6 @@ static const int firstep_table[] =
4013 /* level: 0 1 2 3 4 5 6 7 8 */
4014 { -4, -2, 0, 2, 4, 6, 8, 10, 12 }; /* lvl 0-8, default 2 */
4015
4016 -static const int cycpwrThr1_table[] =
4017 -/* level: 0 1 2 3 4 5 6 7 8 */
4018 - { -6, -4, -2, 0, 2, 4, 6, 8 }; /* lvl 0-7, default 3 */
4019 -
4020 /*
4021 * register values to turn OFDM weak signal detection OFF
4022 */
4023 @@ -921,7 +917,7 @@ static bool ar5008_hw_ani_control_new(st
4024 struct ath_common *common = ath9k_hw_common(ah);
4025 struct ath9k_channel *chan = ah->curchan;
4026 struct ar5416AniState *aniState = &ah->ani;
4027 - s32 value, value2;
4028 + s32 value;
4029
4030 switch (cmd & ah->ani_function) {
4031 case ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION:{
4032 @@ -1008,42 +1004,11 @@ static bool ar5008_hw_ani_control_new(st
4033 case ATH9K_ANI_FIRSTEP_LEVEL:{
4034 u32 level = param;
4035
4036 - if (level >= ARRAY_SIZE(firstep_table)) {
4037 - ath_dbg(common, ANI,
4038 - "ATH9K_ANI_FIRSTEP_LEVEL: level out of range (%u > %zu)\n",
4039 - level, ARRAY_SIZE(firstep_table));
4040 - return false;
4041 - }
4042 -
4043 - /*
4044 - * make register setting relative to default
4045 - * from INI file & cap value
4046 - */
4047 - value = firstep_table[level] -
4048 - firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
4049 - aniState->iniDef.firstep;
4050 - if (value < ATH9K_SIG_FIRSTEP_SETTING_MIN)
4051 - value = ATH9K_SIG_FIRSTEP_SETTING_MIN;
4052 - if (value > ATH9K_SIG_FIRSTEP_SETTING_MAX)
4053 - value = ATH9K_SIG_FIRSTEP_SETTING_MAX;
4054 + value = level * 2;
4055 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
4056 - AR_PHY_FIND_SIG_FIRSTEP,
4057 - value);
4058 - /*
4059 - * we need to set first step low register too
4060 - * make register setting relative to default
4061 - * from INI file & cap value
4062 - */
4063 - value2 = firstep_table[level] -
4064 - firstep_table[ATH9K_ANI_FIRSTEP_LVL] +
4065 - aniState->iniDef.firstepLow;
4066 - if (value2 < ATH9K_SIG_FIRSTEP_SETTING_MIN)
4067 - value2 = ATH9K_SIG_FIRSTEP_SETTING_MIN;
4068 - if (value2 > ATH9K_SIG_FIRSTEP_SETTING_MAX)
4069 - value2 = ATH9K_SIG_FIRSTEP_SETTING_MAX;
4070 -
4071 + AR_PHY_FIND_SIG_FIRSTEP, value);
4072 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW,
4073 - AR_PHY_FIND_SIG_FIRSTEP_LOW, value2);
4074 + AR_PHY_FIND_SIG_FIRSTEP_LOW, value);
4075
4076 if (level != aniState->firstepLevel) {
4077 ath_dbg(common, ANI,
4078 @@ -1060,7 +1025,7 @@ static bool ar5008_hw_ani_control_new(st
4079 aniState->firstepLevel,
4080 level,
4081 ATH9K_ANI_FIRSTEP_LVL,
4082 - value2,
4083 + value,
4084 aniState->iniDef.firstepLow);
4085 if (level > aniState->firstepLevel)
4086 ah->stats.ast_ani_stepup++;
4087 @@ -1073,41 +1038,13 @@ static bool ar5008_hw_ani_control_new(st
4088 case ATH9K_ANI_SPUR_IMMUNITY_LEVEL:{
4089 u32 level = param;
4090
4091 - if (level >= ARRAY_SIZE(cycpwrThr1_table)) {
4092 - ath_dbg(common, ANI,
4093 - "ATH9K_ANI_SPUR_IMMUNITY_LEVEL: level out of range (%u > %zu)\n",
4094 - level, ARRAY_SIZE(cycpwrThr1_table));
4095 - return false;
4096 - }
4097 - /*
4098 - * make register setting relative to default
4099 - * from INI file & cap value
4100 - */
4101 - value = cycpwrThr1_table[level] -
4102 - cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL] +
4103 - aniState->iniDef.cycpwrThr1;
4104 - if (value < ATH9K_SIG_SPUR_IMM_SETTING_MIN)
4105 - value = ATH9K_SIG_SPUR_IMM_SETTING_MIN;
4106 - if (value > ATH9K_SIG_SPUR_IMM_SETTING_MAX)
4107 - value = ATH9K_SIG_SPUR_IMM_SETTING_MAX;
4108 + value = (level + 1) * 2;
4109 REG_RMW_FIELD(ah, AR_PHY_TIMING5,
4110 - AR_PHY_TIMING5_CYCPWR_THR1,
4111 - value);
4112 + AR_PHY_TIMING5_CYCPWR_THR1, value);
4113
4114 - /*
4115 - * set AR_PHY_EXT_CCA for extension channel
4116 - * make register setting relative to default
4117 - * from INI file & cap value
4118 - */
4119 - value2 = cycpwrThr1_table[level] -
4120 - cycpwrThr1_table[ATH9K_ANI_SPUR_IMMUNE_LVL] +
4121 - aniState->iniDef.cycpwrThr1Ext;
4122 - if (value2 < ATH9K_SIG_SPUR_IMM_SETTING_MIN)
4123 - value2 = ATH9K_SIG_SPUR_IMM_SETTING_MIN;
4124 - if (value2 > ATH9K_SIG_SPUR_IMM_SETTING_MAX)
4125 - value2 = ATH9K_SIG_SPUR_IMM_SETTING_MAX;
4126 - REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
4127 - AR_PHY_EXT_TIMING5_CYCPWR_THR1, value2);
4128 + if (IS_CHAN_HT40(ah->curchan))
4129 + REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
4130 + AR_PHY_EXT_TIMING5_CYCPWR_THR1, value);
4131
4132 if (level != aniState->spurImmunityLevel) {
4133 ath_dbg(common, ANI,
4134 @@ -1124,7 +1061,7 @@ static bool ar5008_hw_ani_control_new(st
4135 aniState->spurImmunityLevel,
4136 level,
4137 ATH9K_ANI_SPUR_IMMUNE_LVL,
4138 - value2,
4139 + value,
4140 aniState->iniDef.cycpwrThr1Ext);
4141 if (level > aniState->spurImmunityLevel)
4142 ah->stats.ast_ani_spurup++;