ath9k_htc: fix decryption errors
[openwrt/staging/chunkeey.git] / package / kernel / mac80211 / patches / 300-pending_work.patch
1 commit fb77a822cc68745186b38db7d105ad97e0622152
2 Author: Johannes Stezenbach <js@sig21.net>
3 Date: Fri Sep 12 22:36:51 2014 +0200
4
5 ath9k_htc: fix random decryption failure
6
7 In v3.15 the driver stopped to accept network packets after successful
8 authentification, which could be worked around by passing the
9 nohwcrypt=1 module parameter. This was not reproducible by
10 everyone, and showed random behaviour in some tests.
11 It was caused by an uninitialized variable introduced
12 in 4ed1a8d4a257 ("ath9k_htc: use ath9k_cmn_rx_accept") and
13 used in 341b29b9cd2f ("ath9k_htc: use ath9k_cmn_rx_skb_postprocess").
14
15 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=78581
16 Fixes: 341b29b9cd2f ("ath9k_htc: use ath9k_cmn_rx_skb_postprocess")
17 Signed-off-by: Johannes Stezenbach <js@sig21.net>
18
19 commit 11f17631d9bf2a9e910dac7d09ba4581f5693831
20 Author: Felix Fietkau <nbd@openwrt.org>
21 Date: Tue Sep 9 09:48:30 2014 +0200
22
23 ath9k_hw: fix PLL clock initialization for newer SoC
24
25 On AR934x and newer SoC devices, the layout of the AR_RTC_PLL_CONTROL
26 register changed. This currently breaks at least 5/10 MHz operation.
27 AR933x uses the old layout.
28
29 It might also have been causing other stability issues because of the
30 different location of the PLL_BYPASS bit which needs to be set during
31 PLL clock initialization.
32
33 This patch also removes more instances of hardcoded register values in
34 favor of properly computed ones with the PLL_BYPASS bit added.
35
36 Reported-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
37 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
38
39 commit 0fecedddd4a0945873db1bd230ec6a168b3cc4fe
40 Author: Felix Fietkau <nbd@openwrt.org>
41 Date: Mon Sep 8 18:35:08 2014 +0200
42
43 ath9k_hw: reduce ANI spur immunity setting on HT40 extension channel
44
45 The cycpwr_thr1 value needs to be lower on the extension channel than on
46 the control channel, similar to how the register settings are programmed
47 in the initvals.
48
49 Also drop the unnecessary check for HT40 - this register can always be
50 written. This patch has been reported to improve HT40 stability and
51 throughput in some environments.
52
53 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
54
55 commit 30d7434ccb853b96de698a040888fa4dacd0cc19
56 Author: Felix Fietkau <nbd@openwrt.org>
57 Date: Mon Sep 8 18:31:26 2014 +0200
58
59 Revert "ath9k_hw: reduce ANI firstep range for older chips"
60
61 This reverts commit 09efc56345be4146ab9fc87a55c837ed5d6ea1ab
62
63 I've received reports that this change is decreasing throughput in some
64 rare conditions on an AR9280 based device
65
66 Cc: stable@vger.kernel.org
67 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
68
69 commit 15ed54948f508ad1baad79c30050e2d29a21696d
70 Author: Felix Fietkau <nbd@openwrt.org>
71 Date: Fri Jul 25 16:18:03 2014 +0200
72
73 mac80211: fix smps mode check for AP_VLAN
74
75 In ieee80211_sta_ps_deliver_wakeup, sdata->smps_mode is checked. This is
76 initialized only for the base AP interface, not the individual VLANs.
77
78 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
79
80 commit bc74ad816bba291359ae46301173ea744bdda9d2
81 Author: Felix Fietkau <nbd@openwrt.org>
82 Date: Fri Jul 25 16:15:44 2014 +0200
83
84 mac80211: ignore AP_VLAN in ieee80211_recalc_chanctx_chantype
85
86 When bringing down the AP, a WARN_ON is hit because the bss config chandef
87 is empty here.
88 Since AP_VLAN channel settings do not matter for anything chanctx related
89 (always inherits the settings from the AP interface), let's just ignore
90 it here.
91
92 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
93
94 commit ff354dbdd743e5fe186df8cd17982db19f78231a
95 Author: Felix Fietkau <nbd@openwrt.org>
96 Date: Wed Jul 23 15:33:26 2014 +0200
97
98 ath9k: fix aggregation session lockup
99
100 If an aggregation session fails, frames still end up in the driver queue
101 with IEEE80211_TX_CTL_AMPDU set.
102 This causes tx for the affected station/tid to stall, since
103 ath_tx_get_tid_subframe returning packets to send.
104
105 Fix this by clearing IEEE80211_TX_CTL_AMPDU as long as no aggregation
106 session is running.
107
108 Cc: stable@vger.kernel.org
109 Reported-by: Antonio Quartulli <antonio@open-mesh.com>
110 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
111
112 commit 38695a6e5a940e6a524523b88a33916b016fb2a1
113 Author: Felix Fietkau <nbd@openwrt.org>
114 Date: Fri Jul 11 12:06:18 2014 +0200
115
116 mac80211: fix crash on getting sta info with uninitialized rate control
117
118 If the expected throughput is queried before rate control has been
119 initialized, the minstrel op for it will crash while trying to access
120 the rate table.
121 Check for WLAN_STA_RATE_CONTROL before attempting to use the rate
122 control op.
123
124 Reported-by: Jean-Pierre Tosoni <jp.tosoni@acksys.fr>
125 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
126
127 commit c0ee7fa4c0da824ccccc172bf175fb1f86540921
128 Author: Felix Fietkau <nbd@openwrt.org>
129 Date: Wed Jul 16 18:00:31 2014 +0200
130
131 ath9k: fix pending tx frames accounting
132
133 Packets originally buffered for the regular hardware tx queues can end
134 up being transmitted through the U-APSD queue (via PS-Poll or U-APSD).
135 When packets are dropped due to retransmit failures, the pending frames
136 counter is not always updated properly.
137 Fix this by keeping track of the queue that a frame was accounted for in
138 the ath_frame_info struct, and using that on completion to decide
139 whether the counter should be updated.
140 This fixes some spurious transmit queue hangs.
141
142 Cc: stable@vger.kernel.org
143 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
144
145 commit edcdf0989410a05a6a4b8438df4010447eaa7d9a
146 Author: Felix Fietkau <nbd@openwrt.org>
147 Date: Sun Jun 22 13:36:20 2014 +0200
148
149 Revert "cfg80211: Use 5MHz bandwidth by default when checking usable channels"
150
151 It enables channels that are not supposed to be enabled according to the
152 regulatory rules.
153
154 This reverts commit 8eca1fb692cc9557f386eddce75c300a3855d11a.
155
156 commit 6e7341074823d2a45b81f2742cbf75f1da790031
157 Author: Rafał Miłecki <zajec5@gmail.com>
158 Date: Sat May 31 19:40:45 2014 +0200
159
160 b43: disable 5 GHz on G-PHY
161
162 This fixes regression introduced by adding some G-PHY devices to the
163 list of dual band devices. There is simply no support for 5 GHz on
164 G-PHY devices in b43. It results in:
165 WARNING: CPU: 0 PID: 79 at drivers/net/wireless/b43/phy_g.c:75 b43_gphy_channel_switch+0x125/0x130 [b43]()
166 b43-phy1 ERROR: PHY init: Channel switch to default failed
167
168 Regression was introduced by the following commit:
169
170 commit 773cfc508f4d64c14547ff8751b5cbd473124364
171 Author: Rafał Miłecki <zajec5@gmail.com>
172 Date: Mon May 19 23:18:55 2014 +0200
173
174 b43: add more devices to the bands database
175
176 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
177 Signed-off-by: John W. Linville <linville@tuxdriver.com>
178
179 commit 1186edbef91f15722e5bdf56326ce0abc2935ce7
180 Author: Stanislaw Gruszka <sgruszka@redhat.com>
181 Date: Tue Jun 10 12:51:06 2014 +0200
182
183 rt2x00: disable TKIP on USB
184
185 On USB we can not get atomically TKIP key. We have to disable support
186 for TKIP acceleration on USB hardware to avoid bug as showed bellow.
187
188 [ 860.827243] BUG: scheduling while atomic: hostapd/3397/0x00000002
189 <snip>
190 [ 860.827280] Call Trace:
191 [ 860.827282] [<ffffffff81682ea6>] dump_stack+0x4d/0x66
192 [ 860.827284] [<ffffffff8167eb9b>] __schedule_bug+0x47/0x55
193 [ 860.827285] [<ffffffff81685bb3>] __schedule+0x733/0x7b0
194 [ 860.827287] [<ffffffff81685c59>] schedule+0x29/0x70
195 [ 860.827289] [<ffffffff81684f8a>] schedule_timeout+0x15a/0x2b0
196 [ 860.827291] [<ffffffff8105ac50>] ? ftrace_raw_event_tick_stop+0xc0/0xc0
197 [ 860.827294] [<ffffffff810c13c2>] ? __module_text_address+0x12/0x70
198 [ 860.827296] [<ffffffff81686823>] wait_for_completion_timeout+0xb3/0x140
199 [ 860.827298] [<ffffffff81080fc0>] ? wake_up_state+0x20/0x20
200 [ 860.827301] [<ffffffff814d5b3d>] usb_start_wait_urb+0x7d/0x150
201 [ 860.827303] [<ffffffff814d5cd5>] usb_control_msg+0xc5/0x110
202 [ 860.827305] [<ffffffffa02fb0c6>] rt2x00usb_vendor_request+0xc6/0x160 [rt2x00usb]
203 [ 860.827307] [<ffffffffa02fb215>] rt2x00usb_vendor_req_buff_lock+0x75/0x150 [rt2x00usb]
204 [ 860.827309] [<ffffffffa02fb393>] rt2x00usb_vendor_request_buff+0xa3/0xe0 [rt2x00usb]
205 [ 860.827311] [<ffffffffa023d1a3>] rt2x00usb_register_multiread+0x33/0x40 [rt2800usb]
206 [ 860.827314] [<ffffffffa05805f9>] rt2800_get_tkip_seq+0x39/0x50 [rt2800lib]
207 [ 860.827321] [<ffffffffa0480f88>] ieee80211_get_key+0x218/0x2a0 [mac80211]
208 [ 860.827322] [<ffffffff815cc68c>] ? __nlmsg_put+0x6c/0x80
209 [ 860.827329] [<ffffffffa051b02e>] nl80211_get_key+0x22e/0x360 [cfg80211]
210
211 Cc: stable@vger.kernel.org
212 Reported-and-tested-by: Peter Wu <lekensteyn@gmail.com>
213 Reported-and-tested-by: Pontus Fuchs <pontus.fuchs@gmail.com>
214 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
215 Signed-off-by: John W. Linville <linville@tuxdriver.com>
216
217 commit 5f313a15da92dda80ac4c9a137bc42d7d0b49adf
218 Author: Rafał Miłecki <zajec5@gmail.com>
219 Date: Thu Jun 12 09:28:38 2014 +0200
220
221 b43: fix frequency reported on G-PHY with /new/ firmware
222
223 commit d3a58df87a2e4c2301ac843604202d290a48440b
224 Author: Avraham Stern <avraham.stern@intel.com>
225 Date: Thu May 22 12:17:47 2014 +0300
226
227 mac80211: set new interfaces as idle upon init
228
229 Mark new interfaces as idle to allow operations that require that
230 interfaces are idle to take place. Interface types that are always
231 not idle (like AP interfaces) will be set as not idle when they are
232 assigned a channel context.
233
234 Signed-off-by: Avraham Stern <avraham.stern@intel.com>
235 Signed-off-by: Emmanuel Grumbach<emmanuel.grumbach@intel.com>
236 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
237
238 commit 923eaf367206e01f22c97aee22300e332d071916
239 Author: Arik Nemtsov <arik@wizery.com>
240 Date: Mon May 26 14:40:51 2014 +0300
241
242 mac80211: don't check netdev state for debugfs read/write
243
244 Doing so will lead to an oops for a p2p-dev interface, since it has
245 no netdev.
246
247 Cc: stable@vger.kernel.org
248 Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
249 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
250 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
251
252 commit a9fb54169b197f31aff24c8d6270dd1e56cde395
253 Author: chaitanya.mgit@gmail.com <chaitanya.mgit@gmail.com>
254 Date: Mon May 26 18:01:44 2014 +0530
255
256 regdb: Generalize the mW to dBm power conversion
257
258 Generalize the power conversion from mW to dBm
259 using log. This should fix the below compilation
260 error for country NO which adds a new power value
261 2000mW which is not handled earlier.
262
263 CC [M] net/wireless/wext-sme.o
264 CC [M] net/wireless/regdb.o
265 net/wireless/regdb.c:1130:1: error: Unknown undeclared here (not in
266 a function)
267 net/wireless/regdb.c:1130:9: error: expected } before power
268 make[2]: *** [net/wireless/regdb.o] Error 1
269 make[1]: *** [net/wireless] Error 2
270 make: *** [net] Error 2
271
272 Reported-By: John Walker <john@x109.net>
273 Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
274 Acked-by: John W. Linville <linville@tuxdriver.com>
275 [remove unneeded parentheses, fix rounding by using %.0f]
276 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
277
278 commit c7d37a66e345df2fdf1aa7b2c9a6d3d53846ca5b
279 Author: Krzysztof Hałasa <khalasa@piap.pl>
280 Date: Mon May 26 14:14:46 2014 +0200
281
282 mac80211: fix IBSS join by initializing last_scan_completed
283
284 Without this fix, freshly rebooted Linux creates a new IBSS
285 instead of joining an existing one. Only when jiffies counter
286 overflows after 5 minutes the IBSS can be successfully joined.
287
288 Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
289 [edit commit message slightly]
290 Cc: stable@vger.kernel.org
291 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
292
293 commit 34171dc0d623be2c1032416bf7d3819f388ed70d
294 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
295 Date: Sun May 25 15:35:41 2014 +0300
296
297 mac80211: fix virtual monitor interface addition
298
299 Since the commit below, cfg80211_chandef_dfs_required()
300 will warn if it gets a an NL80211_IFTYPE_UNSPECIFIED iftype
301 as explicitely written in the commit log.
302 When an virtual monitor interface is added, its type is set
303 in ieee80211_sub_if_data.vif.type, but not in
304 ieee80211_sub_if_data.wdev.iftype which is passed to
305 cfg80211_chandef_dfs_required() hence resulting in the
306 following warning:
307
308 WARNING: CPU: 1 PID: 21265 at net/wireless/chan.c:376 cfg80211_chandef_dfs_required+0xbc/0x130 [cfg80211]()
309 Modules linked in: [...]
310 CPU: 1 PID: 21265 Comm: ifconfig Tainted: G W O 3.13.11+ #12
311 Hardware name: Dell Inc. Latitude E6410/0667CC, BIOS A01 03/05/2010
312 0000000000000009 ffff88008f5fdb08 ffffffff817d4219 ffff88008f5fdb50
313 ffff88008f5fdb40 ffffffff8106f57d 0000000000000000 0000000000000000
314 ffff880081062fb8 ffff8800810604e0 0000000000000001 ffff88008f5fdba0
315 Call Trace:
316 [<ffffffff817d4219>] dump_stack+0x4d/0x66
317 [<ffffffff8106f57d>] warn_slowpath_common+0x7d/0xa0
318 [<ffffffff8106f5ec>] warn_slowpath_fmt+0x4c/0x50
319 [<ffffffffa04ea4ec>] cfg80211_chandef_dfs_required+0xbc/0x130 [cfg80211]
320 [<ffffffffa06b1024>] ieee80211_vif_use_channel+0x94/0x500 [mac80211]
321 [<ffffffffa0684e6b>] ieee80211_add_virtual_monitor+0x1ab/0x5c0 [mac80211]
322 [<ffffffffa0686ae5>] ieee80211_do_open+0xe75/0x1580 [mac80211]
323 [<ffffffffa0687259>] ieee80211_open+0x69/0x70 [mac80211]
324 [snip]
325
326 Fixes: 00ec75fc5a64 ("cfg80211: pass the actual iftype when calling cfg80211_chandef_dfs_required()")
327 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
328 Acked-by: Luciano Coelho <luciano.coelho@intel.com>
329 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
330
331 commit d93cc72b37b4e2c314e1c499e80e8801907c2fea
332 Author: Michal Kazior <michal.kazior@tieto.com>
333 Date: Thu Jun 5 14:21:37 2014 +0200
334
335 mac80211: use csa counter offsets instead of csa_active
336
337 vif->csa_active is protected by mutexes only. This
338 means it is unreliable to depend on it on codeflow
339 in non-sleepable beacon and CSA code. There was no
340 guarantee to have vif->csa_active update be
341 visible before beacons are updated on SMP systems.
342
343 Using csa counter offsets which are embedded in
344 beacon struct (and thus are protected with single
345 RCU assignment) is much safer.
346
347 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
348 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
349
350 commit d2746694fcdef24e0a7a1947d8c70082cde81a26
351 Author: Michal Kazior <michal.kazior@tieto.com>
352 Date: Thu Jun 5 14:21:36 2014 +0200
353
354 mac80211: move csa counters from sdata to beacon/presp
355
356 Having csa counters part of beacon and probe_resp
357 structures makes it easier to get rid of possible
358 races between setting a beacon and updating
359 counters on SMP systems by guaranteeing counters
360 are always consistent against given beacon struct.
361
362 While at it relax WARN_ON into WARN_ON_ONCE to
363 prevent spamming logs and racing.
364
365 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
366 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
367
368 commit 5dcb54f3a1a8cd7e0331e773487574f9743615db
369 Author: Janusz Dziedzic <janusz.dziedzic@tieto.com>
370 Date: Thu Jun 5 08:12:57 2014 +0200
371
372 mac80211: allow tx via monitor iface when DFS
373
374 Allow send frames using monitor interface
375 when DFS chandef and we pass CAC (beaconing
376 allowed).
377
378 This fix problem when old kernel and new backports used,
379 in such case hostapd create/use also monitor interface.
380 Before this patch all frames hostapd send using monitor
381 iface were dropped when AP was configured on DFS channel.
382
383 Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
384 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
385
386 commit 6f09a1beb0d2007572248c986780562219bd206f
387 Author: Johannes Berg <johannes.berg@intel.com>
388 Date: Wed Jun 4 17:31:56 2014 +0200
389
390 cfg80211: make ethtool the driver's responsibility
391
392 Currently, cfg80211 tries to implement ethtool, but that doesn't
393 really scale well, with all the different operations. Make the
394 lower-level driver responsible for it, which currently only has
395 an effect on mac80211. It will similarly not scale well at that
396 level though, since mac80211 also has many drivers.
397
398 To cleanly implement this in mac80211, introduce a new file and
399 move some code to appropriate places.
400
401 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
402
403 commit 6b0c6f133de8f90caeb1c4a902e6140567c5bf96
404 Author: Johannes Berg <johannes.berg@intel.com>
405 Date: Wed Jun 4 17:06:23 2014 +0200
406
407 mac80211: remove weak WEP IV accounting
408
409 Since WEP is practically dead, there seems very little
410 point in keeping WEP weak IV accounting.
411
412 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
413
414 commit aecdc89fb4664c76baa4bbd46008f220532309ff
415 Author: Luciano Coelho <luciano.coelho@intel.com>
416 Date: Fri May 23 11:04:50 2014 +0300
417
418 ath9k/ath10k: remove unnecessary channel_switch_beacon callbacks
419
420 The channel_switch_beacon callback is optional, so it doesn't have to
421 be defined if it's not going to do anything useful with it. Both
422 ath9k and ath10k define the callback and just returns. This commit
423 removes them.
424
425 Cc: Michal Kazior <michal.kazior@tieto.com>
426 Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
427 Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
428
429 commit 60ccc107c9b9fb732fdee1f76bb2dad44f0e1798
430 Author: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
431 Date: Tue May 27 16:58:02 2014 +0530
432
433 ath9k: Fix deadlock while updating p2p beacon timer
434
435 pm_lock is taken twice while syncing HW TSF of p2p vif.
436 Fix this by taking the lock at caller side.
437
438 Cc: Felix Fietkau <nbd@openwrt.org>
439 Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
440 Signed-off-by: John W. Linville <linville@tuxdriver.com>
441
442 commit f3831a4e3903dbc1a57d5df56deb6a143fd001bc
443 Author: Stanislaw Gruszka <sgruszka@redhat.com>
444 Date: Thu Jun 5 13:52:27 2014 +0200
445
446 rt2x00: do not initialize BCN_OFFSET registers
447
448 We setup BCN_OFFSET{0,1} registers dynamically, don't have to
449 initialize them.
450
451 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
452
453 commit e5c58ca7a48d4c82f282749a978052c47fd95998
454 Author: Stanislaw Gruszka <sgruszka@redhat.com>
455 Date: Thu Jun 5 13:52:26 2014 +0200
456
457 rt2x00: change order when stop beaconing
458
459 When no beaconing is needed, first stop beacon queue (disable beaconing
460 globally) to avoid possible sending of not prepared beacon on short
461 period after clearing beacon and before stop of BCN queue.
462
463 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
464
465 commit 382c1b9e03f52d0cd741ef1d942cad0f649f0744
466 Author: Stanislaw Gruszka <sgruszka@redhat.com>
467 Date: Thu Jun 5 13:52:25 2014 +0200
468
469 rt2x00: change default MAC_BSSID_DW1_BSS_BCN_NUM
470
471 We setup MAC_BSSID_DW1_BSS_BCN_NUM dynamically when numbers of active
472 beacons increase. Change default to 0 to tell hardware that we want to
473 send only one beacon as default.
474
475 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
476
477 commit 3b400571dd033e46fa7e76c5bb92a3ce8198afa9
478 Author: Stanislaw Gruszka <sgruszka@redhat.com>
479 Date: Thu Jun 5 13:52:24 2014 +0200
480
481 rt2x00: change beaconing setup on RT2800
482
483 As reported by Matthias, on 5572 chip, even if we clear up TXWI
484 of corresponding beacon, hardware still try to send it or do other
485 action that increase power consumption peak up to 1A.
486
487 To avoid the issue, setup beaconing dynamically by configuring offsets
488 of currently active beacons and MAC_BSSID_DW1_BSS_BCN_NUM variable,
489 which limit number of beacons that hardware will try to send.
490
491 Reported-by: Matthias Fend <Matthias.Fend@wolfvision.net>
492 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
493
494 commit 916e591b2cc41f7e572992175ca56d866d7bc958
495 Author: Stanislaw Gruszka <sgruszka@redhat.com>
496 Date: Thu Jun 5 13:52:23 2014 +0200
497
498 rt2x00: change beaconing locking
499
500 This patch is needed for further changes to keep global variables
501 consistent when changing beaconing on diffrent vif's.
502
503 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
504
505 commit 930b0dffd1731f3f418f9132faea720a23b7af61
506 Author: Johannes Berg <johannes.berg@intel.com>
507 Date: Tue Jun 3 11:18:47 2014 +0200
508
509 mac80211: fix station/driver powersave race
510
511 It is currently possible to have a race due to the station PS
512 unblock work like this:
513 * station goes to sleep with frames buffered in the driver
514 * driver blocks wakeup
515 * station wakes up again
516 * driver flushes/returns frames, and unblocks, which schedules
517 the unblock work
518 * unblock work starts to run, and checks that the station is
519 awake (i.e. that the WLAN_STA_PS_STA flag isn't set)
520 * we process a received frame with PM=1, setting the flag again
521 * ieee80211_sta_ps_deliver_wakeup() runs, delivering all frames
522 to the driver, and then clearing the WLAN_STA_PS_DRIVER and
523 WLAN_STA_PS_STA flags
524
525 In this scenario, mac80211 will think that the station is awake,
526 while it really is asleep, and any TX'ed frames should be filtered
527 by the device (it will know that the station is sleeping) but then
528 passed to mac80211 again, which will not buffer it either as it
529 thinks the station is awake, and eventually the packets will be
530 dropped.
531
532 Fix this by moving the clearing of the flags to exactly where we
533 learn about the situation. This creates a problem of reordering,
534 so introduce another flag indicating that delivery is being done,
535 this new flag also queues frames and is cleared only while the
536 spinlock is held (which the queuing code also holds) so that any
537 concurrent delivery/TX is handled correctly.
538
539 Reported-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
540 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
541
542 commit 6df35206bc6c1c6aad1d8077df5786b4a7f77873
543 Author: Felix Fietkau <nbd@openwrt.org>
544 Date: Fri May 23 19:58:14 2014 +0200
545
546 mac80211: reduce packet loss notifications under load
547
548 During strong signal fluctuations under high throughput, few consecutive
549 failed A-MPDU transmissions can easily trigger packet loss notification,
550 and thus (in AP mode) client disconnection.
551
552 Reduce the number of false positives by checking the A-MPDU status flag
553 and treating a failed A-MPDU as a single packet.
554
555 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
556
557 commit 7b7843a36fbcc568834404c7430ff895d8502131
558 Author: Felix Fietkau <nbd@openwrt.org>
559 Date: Fri May 23 19:26:32 2014 +0200
560
561 mac80211: fix a memory leak on sta rate selection table
562
563 Cc: stable@vger.kernel.org
564 Reported-by: Christophe Prévotaux <cprevotaux@nltinc.com>
565 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
566
567 commit 96892d6aa0a153423070addf3070bc79578b3897
568 Author: Felix Fietkau <nbd@openwrt.org>
569 Date: Mon May 19 21:20:49 2014 +0200
570
571 ath9k: avoid passing buffers to the hardware during flush
572
573 The commit "ath9k: fix possible hang on flush" changed the receive code
574 to always link rx descriptors of processed frames, even when flushing.
575 In some cases, this leads to flushed rx buffers being passed to the
576 hardware while rx is already stopped.
577
578 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
579
580 --- a/drivers/net/wireless/ath/ath9k/recv.c
581 +++ b/drivers/net/wireless/ath/ath9k/recv.c
582 @@ -34,7 +34,8 @@ static inline bool ath9k_check_auto_slee
583 * buffer (or rx fifo). This can incorrectly acknowledge packets
584 * to a sender if last desc is self-linked.
585 */
586 -static void ath_rx_buf_link(struct ath_softc *sc, struct ath_rxbuf *bf)
587 +static void ath_rx_buf_link(struct ath_softc *sc, struct ath_rxbuf *bf,
588 + bool flush)
589 {
590 struct ath_hw *ah = sc->sc_ah;
591 struct ath_common *common = ath9k_hw_common(ah);
592 @@ -59,18 +60,19 @@ static void ath_rx_buf_link(struct ath_s
593 common->rx_bufsize,
594 0);
595
596 - if (sc->rx.rxlink == NULL)
597 - ath9k_hw_putrxbuf(ah, bf->bf_daddr);
598 - else
599 + if (sc->rx.rxlink)
600 *sc->rx.rxlink = bf->bf_daddr;
601 + else if (!flush)
602 + ath9k_hw_putrxbuf(ah, bf->bf_daddr);
603
604 sc->rx.rxlink = &ds->ds_link;
605 }
606
607 -static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_rxbuf *bf)
608 +static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_rxbuf *bf,
609 + bool flush)
610 {
611 if (sc->rx.buf_hold)
612 - ath_rx_buf_link(sc, sc->rx.buf_hold);
613 + ath_rx_buf_link(sc, sc->rx.buf_hold, flush);
614
615 sc->rx.buf_hold = bf;
616 }
617 @@ -442,7 +444,7 @@ int ath_startrecv(struct ath_softc *sc)
618 sc->rx.buf_hold = NULL;
619 sc->rx.rxlink = NULL;
620 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) {
621 - ath_rx_buf_link(sc, bf);
622 + ath_rx_buf_link(sc, bf, false);
623 }
624
625 /* We could have deleted elements so the list may be empty now */
626 @@ -1118,12 +1120,12 @@ requeue_drop_frag:
627 requeue:
628 list_add_tail(&bf->list, &sc->rx.rxbuf);
629
630 - if (edma) {
631 - ath_rx_edma_buf_link(sc, qtype);
632 - } else {
633 - ath_rx_buf_relink(sc, bf);
634 + if (!edma) {
635 + ath_rx_buf_relink(sc, bf, flush);
636 if (!flush)
637 ath9k_hw_rxena(ah);
638 + } else if (!flush) {
639 + ath_rx_edma_buf_link(sc, qtype);
640 }
641
642 if (!budget--)
643 --- a/net/mac80211/sta_info.c
644 +++ b/net/mac80211/sta_info.c
645 @@ -100,7 +100,8 @@ static void __cleanup_single_sta(struct
646 struct ps_data *ps;
647
648 if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
649 - test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
650 + test_sta_flag(sta, WLAN_STA_PS_DRIVER) ||
651 + test_sta_flag(sta, WLAN_STA_PS_DELIVER)) {
652 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
653 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
654 ps = &sdata->bss->ps;
655 @@ -111,6 +112,7 @@ static void __cleanup_single_sta(struct
656
657 clear_sta_flag(sta, WLAN_STA_PS_STA);
658 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
659 + clear_sta_flag(sta, WLAN_STA_PS_DELIVER);
660
661 atomic_dec(&ps->num_sta_ps);
662 sta_info_recalc_tim(sta);
663 @@ -125,7 +127,7 @@ static void __cleanup_single_sta(struct
664 if (ieee80211_vif_is_mesh(&sdata->vif))
665 mesh_sta_cleanup(sta);
666
667 - cancel_work_sync(&sta->drv_unblock_wk);
668 + cancel_work_sync(&sta->drv_deliver_wk);
669
670 /*
671 * Destroy aggregation state here. It would be nice to wait for the
672 @@ -227,6 +229,7 @@ struct sta_info *sta_info_get_by_idx(str
673 */
674 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
675 {
676 + struct ieee80211_sta_rates *rates;
677 int i;
678
679 if (sta->rate_ctrl)
680 @@ -238,6 +241,10 @@ void sta_info_free(struct ieee80211_loca
681 kfree(sta->tx_lat);
682 }
683
684 + rates = rcu_dereference_protected(sta->sta.rates, true);
685 + if (rates)
686 + kfree(rates);
687 +
688 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr);
689
690 kfree(sta);
691 @@ -252,33 +259,23 @@ static void sta_info_hash_add(struct iee
692 rcu_assign_pointer(local->sta_hash[STA_HASH(sta->sta.addr)], sta);
693 }
694
695 -static void sta_unblock(struct work_struct *wk)
696 +static void sta_deliver_ps_frames(struct work_struct *wk)
697 {
698 struct sta_info *sta;
699
700 - sta = container_of(wk, struct sta_info, drv_unblock_wk);
701 + sta = container_of(wk, struct sta_info, drv_deliver_wk);
702
703 if (sta->dead)
704 return;
705
706 - if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
707 - local_bh_disable();
708 + local_bh_disable();
709 + if (!test_sta_flag(sta, WLAN_STA_PS_STA))
710 ieee80211_sta_ps_deliver_wakeup(sta);
711 - local_bh_enable();
712 - } else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) {
713 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
714 -
715 - local_bh_disable();
716 + else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL))
717 ieee80211_sta_ps_deliver_poll_response(sta);
718 - local_bh_enable();
719 - } else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD)) {
720 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
721 -
722 - local_bh_disable();
723 + else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD))
724 ieee80211_sta_ps_deliver_uapsd(sta);
725 - local_bh_enable();
726 - } else
727 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
728 + local_bh_enable();
729 }
730
731 static int sta_prepare_rate_control(struct ieee80211_local *local,
732 @@ -340,7 +337,7 @@ struct sta_info *sta_info_alloc(struct i
733
734 spin_lock_init(&sta->lock);
735 spin_lock_init(&sta->ps_lock);
736 - INIT_WORK(&sta->drv_unblock_wk, sta_unblock);
737 + INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames);
738 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
739 mutex_init(&sta->ampdu_mlme.mtx);
740 #ifdef CPTCFG_MAC80211_MESH
741 @@ -1101,8 +1098,11 @@ void ieee80211_sta_ps_deliver_wakeup(str
742 unsigned long flags;
743 struct ps_data *ps;
744
745 - if (sdata->vif.type == NL80211_IFTYPE_AP ||
746 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
747 + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
748 + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
749 + u.ap);
750 +
751 + if (sdata->vif.type == NL80211_IFTYPE_AP)
752 ps = &sdata->bss->ps;
753 else if (ieee80211_vif_is_mesh(&sdata->vif))
754 ps = &sdata->u.mesh.ps;
755 @@ -1140,8 +1140,15 @@ void ieee80211_sta_ps_deliver_wakeup(str
756 }
757
758 ieee80211_add_pending_skbs(local, &pending);
759 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
760 - clear_sta_flag(sta, WLAN_STA_PS_STA);
761 +
762 + /* now we're no longer in the deliver code */
763 + clear_sta_flag(sta, WLAN_STA_PS_DELIVER);
764 +
765 + /* The station might have polled and then woken up before we responded,
766 + * so clear these flags now to avoid them sticking around.
767 + */
768 + clear_sta_flag(sta, WLAN_STA_PSPOLL);
769 + clear_sta_flag(sta, WLAN_STA_UAPSD);
770 spin_unlock(&sta->ps_lock);
771
772 atomic_dec(&ps->num_sta_ps);
773 @@ -1542,10 +1549,26 @@ void ieee80211_sta_block_awake(struct ie
774
775 trace_api_sta_block_awake(sta->local, pubsta, block);
776
777 - if (block)
778 + if (block) {
779 set_sta_flag(sta, WLAN_STA_PS_DRIVER);
780 - else if (test_sta_flag(sta, WLAN_STA_PS_DRIVER))
781 - ieee80211_queue_work(hw, &sta->drv_unblock_wk);
782 + return;
783 + }
784 +
785 + if (!test_sta_flag(sta, WLAN_STA_PS_DRIVER))
786 + return;
787 +
788 + if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
789 + set_sta_flag(sta, WLAN_STA_PS_DELIVER);
790 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
791 + ieee80211_queue_work(hw, &sta->drv_deliver_wk);
792 + } else if (test_sta_flag(sta, WLAN_STA_PSPOLL) ||
793 + test_sta_flag(sta, WLAN_STA_UAPSD)) {
794 + /* must be asleep in this case */
795 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
796 + ieee80211_queue_work(hw, &sta->drv_deliver_wk);
797 + } else {
798 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
799 + }
800 }
801 EXPORT_SYMBOL(ieee80211_sta_block_awake);
802
803 @@ -1703,3 +1726,140 @@ u8 sta_info_tx_streams(struct sta_info *
804 return ((ht_cap->mcs.tx_params & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
805 >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT) + 1;
806 }
807 +
808 +void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
809 +{
810 + struct ieee80211_sub_if_data *sdata = sta->sdata;
811 + struct ieee80211_local *local = sdata->local;
812 + struct rate_control_ref *ref = NULL;
813 + struct timespec uptime;
814 + u64 packets = 0;
815 + u32 thr = 0;
816 + int i, ac;
817 +
818 + if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
819 + ref = local->rate_ctrl;
820 +
821 + sinfo->generation = sdata->local->sta_generation;
822 +
823 + sinfo->filled = STATION_INFO_INACTIVE_TIME |
824 + STATION_INFO_RX_BYTES64 |
825 + STATION_INFO_TX_BYTES64 |
826 + STATION_INFO_RX_PACKETS |
827 + STATION_INFO_TX_PACKETS |
828 + STATION_INFO_TX_RETRIES |
829 + STATION_INFO_TX_FAILED |
830 + STATION_INFO_TX_BITRATE |
831 + STATION_INFO_RX_BITRATE |
832 + STATION_INFO_RX_DROP_MISC |
833 + STATION_INFO_BSS_PARAM |
834 + STATION_INFO_CONNECTED_TIME |
835 + STATION_INFO_STA_FLAGS |
836 + STATION_INFO_BEACON_LOSS_COUNT;
837 +
838 + do_posix_clock_monotonic_gettime(&uptime);
839 + sinfo->connected_time = uptime.tv_sec - sta->last_connected;
840 +
841 + sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
842 + sinfo->tx_bytes = 0;
843 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
844 + sinfo->tx_bytes += sta->tx_bytes[ac];
845 + packets += sta->tx_packets[ac];
846 + }
847 + sinfo->tx_packets = packets;
848 + sinfo->rx_bytes = sta->rx_bytes;
849 + sinfo->rx_packets = sta->rx_packets;
850 + sinfo->tx_retries = sta->tx_retry_count;
851 + sinfo->tx_failed = sta->tx_retry_failed;
852 + sinfo->rx_dropped_misc = sta->rx_dropped;
853 + sinfo->beacon_loss_count = sta->beacon_loss_count;
854 +
855 + if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
856 + (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
857 + sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
858 + if (!local->ops->get_rssi ||
859 + drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal))
860 + sinfo->signal = (s8)sta->last_signal;
861 + sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
862 + }
863 + if (sta->chains) {
864 + sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
865 + STATION_INFO_CHAIN_SIGNAL_AVG;
866 +
867 + sinfo->chains = sta->chains;
868 + for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
869 + sinfo->chain_signal[i] = sta->chain_signal_last[i];
870 + sinfo->chain_signal_avg[i] =
871 + (s8) -ewma_read(&sta->chain_signal_avg[i]);
872 + }
873 + }
874 +
875 + sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
876 + sta_set_rate_info_rx(sta, &sinfo->rxrate);
877 +
878 + if (ieee80211_vif_is_mesh(&sdata->vif)) {
879 +#ifdef CPTCFG_MAC80211_MESH
880 + sinfo->filled |= STATION_INFO_LLID |
881 + STATION_INFO_PLID |
882 + STATION_INFO_PLINK_STATE |
883 + STATION_INFO_LOCAL_PM |
884 + STATION_INFO_PEER_PM |
885 + STATION_INFO_NONPEER_PM;
886 +
887 + sinfo->llid = sta->llid;
888 + sinfo->plid = sta->plid;
889 + sinfo->plink_state = sta->plink_state;
890 + if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
891 + sinfo->filled |= STATION_INFO_T_OFFSET;
892 + sinfo->t_offset = sta->t_offset;
893 + }
894 + sinfo->local_pm = sta->local_pm;
895 + sinfo->peer_pm = sta->peer_pm;
896 + sinfo->nonpeer_pm = sta->nonpeer_pm;
897 +#endif
898 + }
899 +
900 + sinfo->bss_param.flags = 0;
901 + if (sdata->vif.bss_conf.use_cts_prot)
902 + sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
903 + if (sdata->vif.bss_conf.use_short_preamble)
904 + sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
905 + if (sdata->vif.bss_conf.use_short_slot)
906 + sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
907 + sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
908 + sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
909 +
910 + sinfo->sta_flags.set = 0;
911 + sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
912 + BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
913 + BIT(NL80211_STA_FLAG_WME) |
914 + BIT(NL80211_STA_FLAG_MFP) |
915 + BIT(NL80211_STA_FLAG_AUTHENTICATED) |
916 + BIT(NL80211_STA_FLAG_ASSOCIATED) |
917 + BIT(NL80211_STA_FLAG_TDLS_PEER);
918 + if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
919 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
920 + if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
921 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
922 + if (test_sta_flag(sta, WLAN_STA_WME))
923 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
924 + if (test_sta_flag(sta, WLAN_STA_MFP))
925 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
926 + if (test_sta_flag(sta, WLAN_STA_AUTH))
927 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
928 + if (test_sta_flag(sta, WLAN_STA_ASSOC))
929 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
930 + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
931 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
932 +
933 + /* check if the driver has a SW RC implementation */
934 + if (ref && ref->ops->get_expected_throughput)
935 + thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv);
936 + else
937 + thr = drv_get_expected_throughput(local, &sta->sta);
938 +
939 + if (thr != 0) {
940 + sinfo->filled |= STATION_INFO_EXPECTED_THROUGHPUT;
941 + sinfo->expected_throughput = thr;
942 + }
943 +}
944 --- a/net/mac80211/status.c
945 +++ b/net/mac80211/status.c
946 @@ -541,6 +541,23 @@ static void ieee80211_tx_latency_end_msr
947 */
948 #define STA_LOST_PKT_THRESHOLD 50
949
950 +static void ieee80211_lost_packet(struct sta_info *sta, struct sk_buff *skb)
951 +{
952 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
953 +
954 + /* This packet was aggregated but doesn't carry status info */
955 + if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
956 + !(info->flags & IEEE80211_TX_STAT_AMPDU))
957 + return;
958 +
959 + if (++sta->lost_packets < STA_LOST_PKT_THRESHOLD)
960 + return;
961 +
962 + cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
963 + sta->lost_packets, GFP_ATOMIC);
964 + sta->lost_packets = 0;
965 +}
966 +
967 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
968 {
969 struct sk_buff *skb2;
970 @@ -680,12 +697,8 @@ void ieee80211_tx_status(struct ieee8021
971 if (info->flags & IEEE80211_TX_STAT_ACK) {
972 if (sta->lost_packets)
973 sta->lost_packets = 0;
974 - } else if (++sta->lost_packets >= STA_LOST_PKT_THRESHOLD) {
975 - cfg80211_cqm_pktloss_notify(sta->sdata->dev,
976 - sta->sta.addr,
977 - sta->lost_packets,
978 - GFP_ATOMIC);
979 - sta->lost_packets = 0;
980 + } else {
981 + ieee80211_lost_packet(sta, skb);
982 }
983 }
984
985 --- a/net/mac80211/rx.c
986 +++ b/net/mac80211/rx.c
987 @@ -1107,6 +1107,8 @@ static void sta_ps_end(struct sta_info *
988 return;
989 }
990
991 + set_sta_flag(sta, WLAN_STA_PS_DELIVER);
992 + clear_sta_flag(sta, WLAN_STA_PS_STA);
993 ieee80211_sta_ps_deliver_wakeup(sta);
994 }
995
996 --- a/net/mac80211/sta_info.h
997 +++ b/net/mac80211/sta_info.h
998 @@ -82,6 +82,7 @@ enum ieee80211_sta_info_flags {
999 WLAN_STA_TOFFSET_KNOWN,
1000 WLAN_STA_MPSP_OWNER,
1001 WLAN_STA_MPSP_RECIPIENT,
1002 + WLAN_STA_PS_DELIVER,
1003 };
1004
1005 #define ADDBA_RESP_INTERVAL HZ
1006 @@ -265,7 +266,7 @@ struct ieee80211_tx_latency_stat {
1007 * @last_rx_rate_vht_nss: rx status nss of last data packet
1008 * @lock: used for locking all fields that require locking, see comments
1009 * in the header file.
1010 - * @drv_unblock_wk: used for driver PS unblocking
1011 + * @drv_deliver_wk: used for delivering frames after driver PS unblocking
1012 * @listen_interval: listen interval of this station, when we're acting as AP
1013 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
1014 * @ps_lock: used for powersave (when mac80211 is the AP) related locking
1015 @@ -278,7 +279,6 @@ struct ieee80211_tx_latency_stat {
1016 * @driver_buffered_tids: bitmap of TIDs the driver has data buffered on
1017 * @rx_packets: Number of MSDUs received from this STA
1018 * @rx_bytes: Number of bytes received from this STA
1019 - * @wep_weak_iv_count: number of weak WEP IVs received from this station
1020 * @last_rx: time (in jiffies) when last frame was received from this STA
1021 * @last_connected: time (in seconds) when a station got connected
1022 * @num_duplicates: number of duplicate frames received from this STA
1023 @@ -345,7 +345,7 @@ struct sta_info {
1024 void *rate_ctrl_priv;
1025 spinlock_t lock;
1026
1027 - struct work_struct drv_unblock_wk;
1028 + struct work_struct drv_deliver_wk;
1029
1030 u16 listen_interval;
1031
1032 @@ -367,7 +367,6 @@ struct sta_info {
1033 /* Updated from RX path only, no locking requirements */
1034 unsigned long rx_packets;
1035 u64 rx_bytes;
1036 - unsigned long wep_weak_iv_count;
1037 unsigned long last_rx;
1038 long last_connected;
1039 unsigned long num_duplicates;
1040 @@ -628,6 +627,8 @@ void sta_set_rate_info_tx(struct sta_inf
1041 struct rate_info *rinfo);
1042 void sta_set_rate_info_rx(struct sta_info *sta,
1043 struct rate_info *rinfo);
1044 +void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo);
1045 +
1046 void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
1047 unsigned long exp_time);
1048 u8 sta_info_tx_streams(struct sta_info *sta);
1049 --- a/net/mac80211/tx.c
1050 +++ b/net/mac80211/tx.c
1051 @@ -469,7 +469,8 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1052 return TX_CONTINUE;
1053
1054 if (unlikely((test_sta_flag(sta, WLAN_STA_PS_STA) ||
1055 - test_sta_flag(sta, WLAN_STA_PS_DRIVER)) &&
1056 + test_sta_flag(sta, WLAN_STA_PS_DRIVER) ||
1057 + test_sta_flag(sta, WLAN_STA_PS_DELIVER)) &&
1058 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {
1059 int ac = skb_get_queue_mapping(tx->skb);
1060
1061 @@ -486,7 +487,8 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1062 * ahead and Tx the packet.
1063 */
1064 if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
1065 - !test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1066 + !test_sta_flag(sta, WLAN_STA_PS_DRIVER) &&
1067 + !test_sta_flag(sta, WLAN_STA_PS_DELIVER)) {
1068 spin_unlock(&sta->ps_lock);
1069 return TX_CONTINUE;
1070 }
1071 @@ -1618,12 +1620,12 @@ netdev_tx_t ieee80211_monitor_start_xmit
1072 {
1073 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1074 struct ieee80211_chanctx_conf *chanctx_conf;
1075 - struct ieee80211_channel *chan;
1076 struct ieee80211_radiotap_header *prthdr =
1077 (struct ieee80211_radiotap_header *)skb->data;
1078 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1079 struct ieee80211_hdr *hdr;
1080 struct ieee80211_sub_if_data *tmp_sdata, *sdata;
1081 + struct cfg80211_chan_def *chandef;
1082 u16 len_rthdr;
1083 int hdrlen;
1084
1085 @@ -1721,9 +1723,9 @@ netdev_tx_t ieee80211_monitor_start_xmit
1086 }
1087
1088 if (chanctx_conf)
1089 - chan = chanctx_conf->def.chan;
1090 + chandef = &chanctx_conf->def;
1091 else if (!local->use_chanctx)
1092 - chan = local->_oper_chandef.chan;
1093 + chandef = &local->_oper_chandef;
1094 else
1095 goto fail_rcu;
1096
1097 @@ -1743,10 +1745,11 @@ netdev_tx_t ieee80211_monitor_start_xmit
1098 * radar detection by itself. We can do that later by adding a
1099 * monitor flag interfaces used for AP support.
1100 */
1101 - if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)))
1102 + if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef,
1103 + sdata->vif.type))
1104 goto fail_rcu;
1105
1106 - ieee80211_xmit(sdata, skb, chan->band);
1107 + ieee80211_xmit(sdata, skb, chandef->chan->band);
1108 rcu_read_unlock();
1109
1110 return NETDEV_TX_OK;
1111 @@ -2425,7 +2428,7 @@ static void ieee80211_set_csa(struct iee
1112 u8 *beacon_data;
1113 size_t beacon_data_len;
1114 int i;
1115 - u8 count = sdata->csa_current_counter;
1116 + u8 count = beacon->csa_current_counter;
1117
1118 switch (sdata->vif.type) {
1119 case NL80211_IFTYPE_AP:
1120 @@ -2444,46 +2447,54 @@ static void ieee80211_set_csa(struct iee
1121 return;
1122 }
1123
1124 + rcu_read_lock();
1125 for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; ++i) {
1126 - u16 counter_offset_beacon =
1127 - sdata->csa_counter_offset_beacon[i];
1128 - u16 counter_offset_presp = sdata->csa_counter_offset_presp[i];
1129 -
1130 - if (counter_offset_beacon) {
1131 - if (WARN_ON(counter_offset_beacon >= beacon_data_len))
1132 - return;
1133 -
1134 - beacon_data[counter_offset_beacon] = count;
1135 - }
1136 -
1137 - if (sdata->vif.type == NL80211_IFTYPE_AP &&
1138 - counter_offset_presp) {
1139 - rcu_read_lock();
1140 - resp = rcu_dereference(sdata->u.ap.probe_resp);
1141 + resp = rcu_dereference(sdata->u.ap.probe_resp);
1142
1143 - /* If nl80211 accepted the offset, this should
1144 - * not happen.
1145 - */
1146 - if (WARN_ON(!resp)) {
1147 + if (beacon->csa_counter_offsets[i]) {
1148 + if (WARN_ON_ONCE(beacon->csa_counter_offsets[i] >=
1149 + beacon_data_len)) {
1150 rcu_read_unlock();
1151 return;
1152 }
1153 - resp->data[counter_offset_presp] = count;
1154 - rcu_read_unlock();
1155 +
1156 + beacon_data[beacon->csa_counter_offsets[i]] = count;
1157 }
1158 +
1159 + if (sdata->vif.type == NL80211_IFTYPE_AP && resp &&
1160 + resp->csa_counter_offsets)
1161 + resp->data[resp->csa_counter_offsets[i]] = count;
1162 }
1163 + rcu_read_unlock();
1164 }
1165
1166 u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
1167 {
1168 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
1169 + struct beacon_data *beacon = NULL;
1170 + u8 count = 0;
1171 +
1172 + rcu_read_lock();
1173 +
1174 + if (sdata->vif.type == NL80211_IFTYPE_AP)
1175 + beacon = rcu_dereference(sdata->u.ap.beacon);
1176 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1177 + beacon = rcu_dereference(sdata->u.ibss.presp);
1178 + else if (ieee80211_vif_is_mesh(&sdata->vif))
1179 + beacon = rcu_dereference(sdata->u.mesh.beacon);
1180 +
1181 + if (!beacon)
1182 + goto unlock;
1183
1184 - sdata->csa_current_counter--;
1185 + beacon->csa_current_counter--;
1186
1187 /* the counter should never reach 0 */
1188 - WARN_ON(!sdata->csa_current_counter);
1189 + WARN_ON_ONCE(!beacon->csa_current_counter);
1190 + count = beacon->csa_current_counter;
1191
1192 - return sdata->csa_current_counter;
1193 +unlock:
1194 + rcu_read_unlock();
1195 + return count;
1196 }
1197 EXPORT_SYMBOL(ieee80211_csa_update_counter);
1198
1199 @@ -2493,7 +2504,6 @@ bool ieee80211_csa_is_complete(struct ie
1200 struct beacon_data *beacon = NULL;
1201 u8 *beacon_data;
1202 size_t beacon_data_len;
1203 - int counter_beacon = sdata->csa_counter_offset_beacon[0];
1204 int ret = false;
1205
1206 if (!ieee80211_sdata_running(sdata))
1207 @@ -2531,10 +2541,13 @@ bool ieee80211_csa_is_complete(struct ie
1208 goto out;
1209 }
1210
1211 - if (WARN_ON(counter_beacon > beacon_data_len))
1212 + if (!beacon->csa_counter_offsets[0])
1213 + goto out;
1214 +
1215 + if (WARN_ON_ONCE(beacon->csa_counter_offsets[0] > beacon_data_len))
1216 goto out;
1217
1218 - if (beacon_data[counter_beacon] == 1)
1219 + if (beacon_data[beacon->csa_counter_offsets[0]] == 1)
1220 ret = true;
1221 out:
1222 rcu_read_unlock();
1223 @@ -2550,6 +2563,7 @@ __ieee80211_beacon_get(struct ieee80211_
1224 bool is_template)
1225 {
1226 struct ieee80211_local *local = hw_to_local(hw);
1227 + struct beacon_data *beacon = NULL;
1228 struct sk_buff *skb = NULL;
1229 struct ieee80211_tx_info *info;
1230 struct ieee80211_sub_if_data *sdata = NULL;
1231 @@ -2571,10 +2585,10 @@ __ieee80211_beacon_get(struct ieee80211_
1232
1233 if (sdata->vif.type == NL80211_IFTYPE_AP) {
1234 struct ieee80211_if_ap *ap = &sdata->u.ap;
1235 - struct beacon_data *beacon = rcu_dereference(ap->beacon);
1236
1237 + beacon = rcu_dereference(ap->beacon);
1238 if (beacon) {
1239 - if (sdata->vif.csa_active) {
1240 + if (beacon->csa_counter_offsets[0]) {
1241 if (!is_template)
1242 ieee80211_csa_update_counter(vif);
1243
1244 @@ -2615,37 +2629,37 @@ __ieee80211_beacon_get(struct ieee80211_
1245 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
1246 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
1247 struct ieee80211_hdr *hdr;
1248 - struct beacon_data *presp = rcu_dereference(ifibss->presp);
1249
1250 - if (!presp)
1251 + beacon = rcu_dereference(ifibss->presp);
1252 + if (!beacon)
1253 goto out;
1254
1255 - if (sdata->vif.csa_active) {
1256 + if (beacon->csa_counter_offsets[0]) {
1257 if (!is_template)
1258 ieee80211_csa_update_counter(vif);
1259
1260 - ieee80211_set_csa(sdata, presp);
1261 + ieee80211_set_csa(sdata, beacon);
1262 }
1263
1264 - skb = dev_alloc_skb(local->tx_headroom + presp->head_len +
1265 + skb = dev_alloc_skb(local->tx_headroom + beacon->head_len +
1266 local->hw.extra_beacon_tailroom);
1267 if (!skb)
1268 goto out;
1269 skb_reserve(skb, local->tx_headroom);
1270 - memcpy(skb_put(skb, presp->head_len), presp->head,
1271 - presp->head_len);
1272 + memcpy(skb_put(skb, beacon->head_len), beacon->head,
1273 + beacon->head_len);
1274
1275 hdr = (struct ieee80211_hdr *) skb->data;
1276 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1277 IEEE80211_STYPE_BEACON);
1278 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
1279 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1280 - struct beacon_data *bcn = rcu_dereference(ifmsh->beacon);
1281
1282 - if (!bcn)
1283 + beacon = rcu_dereference(ifmsh->beacon);
1284 + if (!beacon)
1285 goto out;
1286
1287 - if (sdata->vif.csa_active) {
1288 + if (beacon->csa_counter_offsets[0]) {
1289 if (!is_template)
1290 /* TODO: For mesh csa_counter is in TU, so
1291 * decrementing it by one isn't correct, but
1292 @@ -2654,40 +2668,42 @@ __ieee80211_beacon_get(struct ieee80211_
1293 */
1294 ieee80211_csa_update_counter(vif);
1295
1296 - ieee80211_set_csa(sdata, bcn);
1297 + ieee80211_set_csa(sdata, beacon);
1298 }
1299
1300 if (ifmsh->sync_ops)
1301 - ifmsh->sync_ops->adjust_tbtt(sdata, bcn);
1302 + ifmsh->sync_ops->adjust_tbtt(sdata, beacon);
1303
1304 skb = dev_alloc_skb(local->tx_headroom +
1305 - bcn->head_len +
1306 + beacon->head_len +
1307 256 + /* TIM IE */
1308 - bcn->tail_len +
1309 + beacon->tail_len +
1310 local->hw.extra_beacon_tailroom);
1311 if (!skb)
1312 goto out;
1313 skb_reserve(skb, local->tx_headroom);
1314 - memcpy(skb_put(skb, bcn->head_len), bcn->head, bcn->head_len);
1315 + memcpy(skb_put(skb, beacon->head_len), beacon->head,
1316 + beacon->head_len);
1317 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template);
1318
1319 if (offs) {
1320 - offs->tim_offset = bcn->head_len;
1321 - offs->tim_length = skb->len - bcn->head_len;
1322 + offs->tim_offset = beacon->head_len;
1323 + offs->tim_length = skb->len - beacon->head_len;
1324 }
1325
1326 - memcpy(skb_put(skb, bcn->tail_len), bcn->tail, bcn->tail_len);
1327 + memcpy(skb_put(skb, beacon->tail_len), beacon->tail,
1328 + beacon->tail_len);
1329 } else {
1330 WARN_ON(1);
1331 goto out;
1332 }
1333
1334 /* CSA offsets */
1335 - if (offs) {
1336 + if (offs && beacon) {
1337 int i;
1338
1339 for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; i++) {
1340 - u16 csa_off = sdata->csa_counter_offset_beacon[i];
1341 + u16 csa_off = beacon->csa_counter_offsets[i];
1342
1343 if (!csa_off)
1344 continue;
1345 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
1346 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1347 @@ -947,6 +947,40 @@ static inline u8 rt2800_get_beacon_offse
1348 return BEACON_BASE_TO_OFFSET(rt2800_hw_beacon_base(rt2x00dev, index));
1349 }
1350
1351 +static void rt2800_update_beacons_setup(struct rt2x00_dev *rt2x00dev)
1352 +{
1353 + struct data_queue *queue = rt2x00dev->bcn;
1354 + struct queue_entry *entry;
1355 + int i, bcn_num = 0;
1356 + u64 off, reg = 0;
1357 + u32 bssid_dw1;
1358 +
1359 + /*
1360 + * Setup offsets of all active beacons in BCN_OFFSET{0,1} registers.
1361 + */
1362 + for (i = 0; i < queue->limit; i++) {
1363 + entry = &queue->entries[i];
1364 + if (!test_bit(ENTRY_BCN_ENABLED, &entry->flags))
1365 + continue;
1366 + off = rt2800_get_beacon_offset(rt2x00dev, entry->entry_idx);
1367 + reg |= off << (8 * bcn_num);
1368 + bcn_num++;
1369 + }
1370 +
1371 + WARN_ON_ONCE(bcn_num != rt2x00dev->intf_beaconing);
1372 +
1373 + rt2800_register_write(rt2x00dev, BCN_OFFSET0, (u32) reg);
1374 + rt2800_register_write(rt2x00dev, BCN_OFFSET1, (u32) (reg >> 32));
1375 +
1376 + /*
1377 + * H/W sends up to MAC_BSSID_DW1_BSS_BCN_NUM + 1 consecutive beacons.
1378 + */
1379 + rt2800_register_read(rt2x00dev, MAC_BSSID_DW1, &bssid_dw1);
1380 + rt2x00_set_field32(&bssid_dw1, MAC_BSSID_DW1_BSS_BCN_NUM,
1381 + bcn_num > 0 ? bcn_num - 1 : 0);
1382 + rt2800_register_write(rt2x00dev, MAC_BSSID_DW1, bssid_dw1);
1383 +}
1384 +
1385 void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
1386 {
1387 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1388 @@ -1003,6 +1037,12 @@ void rt2800_write_beacon(struct queue_en
1389
1390 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
1391 entry->skb->len + padding_len);
1392 + __set_bit(ENTRY_BCN_ENABLED, &entry->flags);
1393 +
1394 + /*
1395 + * Change global beacons settings.
1396 + */
1397 + rt2800_update_beacons_setup(rt2x00dev);
1398
1399 /*
1400 * Restore beaconing state.
1401 @@ -1053,8 +1093,13 @@ void rt2800_clear_beacon(struct queue_en
1402 * Clear beacon.
1403 */
1404 rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx);
1405 + __clear_bit(ENTRY_BCN_ENABLED, &entry->flags);
1406
1407 /*
1408 + * Change global beacons settings.
1409 + */
1410 + rt2800_update_beacons_setup(rt2x00dev);
1411 + /*
1412 * Restore beaconing state.
1413 */
1414 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, orig_reg);
1415 @@ -1556,7 +1601,7 @@ void rt2800_config_intf(struct rt2x00_de
1416 if (!is_zero_ether_addr((const u8 *)conf->bssid)) {
1417 reg = le32_to_cpu(conf->bssid[1]);
1418 rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_ID_MASK, 3);
1419 - rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_BCN_NUM, 7);
1420 + rt2x00_set_field32(&reg, MAC_BSSID_DW1_BSS_BCN_NUM, 0);
1421 conf->bssid[1] = cpu_to_le32(reg);
1422 }
1423
1424 @@ -4517,28 +4562,6 @@ static int rt2800_init_registers(struct
1425 if (ret)
1426 return ret;
1427
1428 - rt2800_register_read(rt2x00dev, BCN_OFFSET0, &reg);
1429 - rt2x00_set_field32(&reg, BCN_OFFSET0_BCN0,
1430 - rt2800_get_beacon_offset(rt2x00dev, 0));
1431 - rt2x00_set_field32(&reg, BCN_OFFSET0_BCN1,
1432 - rt2800_get_beacon_offset(rt2x00dev, 1));
1433 - rt2x00_set_field32(&reg, BCN_OFFSET0_BCN2,
1434 - rt2800_get_beacon_offset(rt2x00dev, 2));
1435 - rt2x00_set_field32(&reg, BCN_OFFSET0_BCN3,
1436 - rt2800_get_beacon_offset(rt2x00dev, 3));
1437 - rt2800_register_write(rt2x00dev, BCN_OFFSET0, reg);
1438 -
1439 - rt2800_register_read(rt2x00dev, BCN_OFFSET1, &reg);
1440 - rt2x00_set_field32(&reg, BCN_OFFSET1_BCN4,
1441 - rt2800_get_beacon_offset(rt2x00dev, 4));
1442 - rt2x00_set_field32(&reg, BCN_OFFSET1_BCN5,
1443 - rt2800_get_beacon_offset(rt2x00dev, 5));
1444 - rt2x00_set_field32(&reg, BCN_OFFSET1_BCN6,
1445 - rt2800_get_beacon_offset(rt2x00dev, 6));
1446 - rt2x00_set_field32(&reg, BCN_OFFSET1_BCN7,
1447 - rt2800_get_beacon_offset(rt2x00dev, 7));
1448 - rt2800_register_write(rt2x00dev, BCN_OFFSET1, reg);
1449 -
1450 rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f);
1451 rt2800_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
1452
1453 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
1454 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
1455 @@ -141,8 +141,11 @@ static void rt2x00lib_intf_scheduled_ite
1456 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
1457 return;
1458
1459 - if (test_and_clear_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags))
1460 + if (test_and_clear_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags)) {
1461 + mutex_lock(&intf->beacon_skb_mutex);
1462 rt2x00queue_update_beacon(rt2x00dev, vif);
1463 + mutex_unlock(&intf->beacon_skb_mutex);
1464 + }
1465 }
1466
1467 static void rt2x00lib_intf_scheduled(struct work_struct *work)
1468 @@ -216,7 +219,7 @@ static void rt2x00lib_beaconupdate_iter(
1469 * never be called for USB devices.
1470 */
1471 WARN_ON(rt2x00_is_usb(rt2x00dev));
1472 - rt2x00queue_update_beacon_locked(rt2x00dev, vif);
1473 + rt2x00queue_update_beacon(rt2x00dev, vif);
1474 }
1475
1476 void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev)
1477 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
1478 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
1479 @@ -487,6 +487,8 @@ int rt2x00mac_set_key(struct ieee80211_h
1480 crypto.cipher = rt2x00crypto_key_to_cipher(key);
1481 if (crypto.cipher == CIPHER_NONE)
1482 return -EOPNOTSUPP;
1483 + if (crypto.cipher == CIPHER_TKIP && rt2x00_is_usb(rt2x00dev))
1484 + return -EOPNOTSUPP;
1485
1486 crypto.cmd = cmd;
1487
1488 @@ -624,25 +626,24 @@ void rt2x00mac_bss_info_changed(struct i
1489 * Start/stop beaconing.
1490 */
1491 if (changes & BSS_CHANGED_BEACON_ENABLED) {
1492 + mutex_lock(&intf->beacon_skb_mutex);
1493 if (!bss_conf->enable_beacon && intf->enable_beacon) {
1494 rt2x00dev->intf_beaconing--;
1495 intf->enable_beacon = false;
1496 - /*
1497 - * Clear beacon in the H/W for this vif. This is needed
1498 - * to disable beaconing on this particular interface
1499 - * and keep it running on other interfaces.
1500 - */
1501 - rt2x00queue_clear_beacon(rt2x00dev, vif);
1502
1503 if (rt2x00dev->intf_beaconing == 0) {
1504 /*
1505 * Last beaconing interface disabled
1506 * -> stop beacon queue.
1507 */
1508 - mutex_lock(&intf->beacon_skb_mutex);
1509 rt2x00queue_stop_queue(rt2x00dev->bcn);
1510 - mutex_unlock(&intf->beacon_skb_mutex);
1511 }
1512 + /*
1513 + * Clear beacon in the H/W for this vif. This is needed
1514 + * to disable beaconing on this particular interface
1515 + * and keep it running on other interfaces.
1516 + */
1517 + rt2x00queue_clear_beacon(rt2x00dev, vif);
1518 } else if (bss_conf->enable_beacon && !intf->enable_beacon) {
1519 rt2x00dev->intf_beaconing++;
1520 intf->enable_beacon = true;
1521 @@ -658,11 +659,10 @@ void rt2x00mac_bss_info_changed(struct i
1522 * First beaconing interface enabled
1523 * -> start beacon queue.
1524 */
1525 - mutex_lock(&intf->beacon_skb_mutex);
1526 rt2x00queue_start_queue(rt2x00dev->bcn);
1527 - mutex_unlock(&intf->beacon_skb_mutex);
1528 }
1529 }
1530 + mutex_unlock(&intf->beacon_skb_mutex);
1531 }
1532
1533 /*
1534 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
1535 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
1536 @@ -754,8 +754,6 @@ int rt2x00queue_clear_beacon(struct rt2x
1537 if (unlikely(!intf->beacon))
1538 return -ENOBUFS;
1539
1540 - mutex_lock(&intf->beacon_skb_mutex);
1541 -
1542 /*
1543 * Clean up the beacon skb.
1544 */
1545 @@ -768,13 +766,11 @@ int rt2x00queue_clear_beacon(struct rt2x
1546 if (rt2x00dev->ops->lib->clear_beacon)
1547 rt2x00dev->ops->lib->clear_beacon(intf->beacon);
1548
1549 - mutex_unlock(&intf->beacon_skb_mutex);
1550 -
1551 return 0;
1552 }
1553
1554 -int rt2x00queue_update_beacon_locked(struct rt2x00_dev *rt2x00dev,
1555 - struct ieee80211_vif *vif)
1556 +int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
1557 + struct ieee80211_vif *vif)
1558 {
1559 struct rt2x00_intf *intf = vif_to_intf(vif);
1560 struct skb_frame_desc *skbdesc;
1561 @@ -815,19 +811,6 @@ int rt2x00queue_update_beacon_locked(str
1562
1563 }
1564
1565 -int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
1566 - struct ieee80211_vif *vif)
1567 -{
1568 - struct rt2x00_intf *intf = vif_to_intf(vif);
1569 - int ret;
1570 -
1571 - mutex_lock(&intf->beacon_skb_mutex);
1572 - ret = rt2x00queue_update_beacon_locked(rt2x00dev, vif);
1573 - mutex_unlock(&intf->beacon_skb_mutex);
1574 -
1575 - return ret;
1576 -}
1577 -
1578 bool rt2x00queue_for_each_entry(struct data_queue *queue,
1579 enum queue_index start,
1580 enum queue_index end,
1581 --- a/drivers/net/wireless/rt2x00/rt2x00queue.h
1582 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
1583 @@ -353,6 +353,7 @@ struct txentry_desc {
1584 */
1585 enum queue_entry_flags {
1586 ENTRY_BCN_ASSIGNED,
1587 + ENTRY_BCN_ENABLED,
1588 ENTRY_OWNER_DEVICE_DATA,
1589 ENTRY_DATA_PENDING,
1590 ENTRY_DATA_IO_FAILED,
1591 --- a/drivers/net/wireless/ath/ath9k/main.c
1592 +++ b/drivers/net/wireless/ath/ath9k/main.c
1593 @@ -1757,7 +1757,6 @@ out:
1594 void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
1595 {
1596 struct ath_vif *avp = (void *)vif->drv_priv;
1597 - unsigned long flags;
1598 u32 tsf;
1599
1600 if (!sc->p2p_ps_timer)
1601 @@ -1767,14 +1766,9 @@ void ath9k_update_p2p_ps(struct ath_soft
1602 return;
1603
1604 sc->p2p_ps_vif = avp;
1605 -
1606 - spin_lock_irqsave(&sc->sc_pm_lock, flags);
1607 - if (!(sc->ps_flags & PS_BEACON_SYNC)) {
1608 - tsf = ath9k_hw_gettsf32(sc->sc_ah);
1609 - ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
1610 - ath9k_update_p2p_ps_timer(sc, avp);
1611 - }
1612 - spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1613 + tsf = ath9k_hw_gettsf32(sc->sc_ah);
1614 + ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
1615 + ath9k_update_p2p_ps_timer(sc, avp);
1616 }
1617
1618 static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1619 @@ -1791,6 +1785,7 @@ static void ath9k_bss_info_changed(struc
1620 struct ath_hw *ah = sc->sc_ah;
1621 struct ath_common *common = ath9k_hw_common(ah);
1622 struct ath_vif *avp = (void *)vif->drv_priv;
1623 + unsigned long flags;
1624 int slottime;
1625
1626 ath9k_ps_wakeup(sc);
1627 @@ -1853,7 +1848,10 @@ static void ath9k_bss_info_changed(struc
1628
1629 if (changed & BSS_CHANGED_P2P_PS) {
1630 spin_lock_bh(&sc->sc_pcu_lock);
1631 - ath9k_update_p2p_ps(sc, vif);
1632 + spin_lock_irqsave(&sc->sc_pm_lock, flags);
1633 + if (!(sc->ps_flags & PS_BEACON_SYNC))
1634 + ath9k_update_p2p_ps(sc, vif);
1635 + spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1636 spin_unlock_bh(&sc->sc_pcu_lock);
1637 }
1638
1639 @@ -2232,14 +2230,6 @@ static void ath9k_sw_scan_complete(struc
1640 clear_bit(ATH_OP_SCANNING, &common->op_flags);
1641 }
1642
1643 -static void ath9k_channel_switch_beacon(struct ieee80211_hw *hw,
1644 - struct ieee80211_vif *vif,
1645 - struct cfg80211_chan_def *chandef)
1646 -{
1647 - /* depend on vif->csa_active only */
1648 - return;
1649 -}
1650 -
1651 struct ieee80211_ops ath9k_ops = {
1652 .tx = ath9k_tx,
1653 .start = ath9k_start,
1654 @@ -2287,5 +2277,4 @@ struct ieee80211_ops ath9k_ops = {
1655 #endif
1656 .sw_scan_start = ath9k_sw_scan_start,
1657 .sw_scan_complete = ath9k_sw_scan_complete,
1658 - .channel_switch_beacon = ath9k_channel_switch_beacon,
1659 };
1660 --- a/drivers/net/wireless/ath/ath10k/mac.c
1661 +++ b/drivers/net/wireless/ath/ath10k/mac.c
1662 @@ -4142,14 +4142,6 @@ static int ath10k_set_bitrate_mask(struc
1663 fixed_nss, force_sgi);
1664 }
1665
1666 -static void ath10k_channel_switch_beacon(struct ieee80211_hw *hw,
1667 - struct ieee80211_vif *vif,
1668 - struct cfg80211_chan_def *chandef)
1669 -{
1670 - /* there's no need to do anything here. vif->csa_active is enough */
1671 - return;
1672 -}
1673 -
1674 static void ath10k_sta_rc_update(struct ieee80211_hw *hw,
1675 struct ieee80211_vif *vif,
1676 struct ieee80211_sta *sta,
1677 @@ -4256,7 +4248,6 @@ static const struct ieee80211_ops ath10k
1678 .restart_complete = ath10k_restart_complete,
1679 .get_survey = ath10k_get_survey,
1680 .set_bitrate_mask = ath10k_set_bitrate_mask,
1681 - .channel_switch_beacon = ath10k_channel_switch_beacon,
1682 .sta_rc_update = ath10k_sta_rc_update,
1683 .get_tsf = ath10k_get_tsf,
1684 #ifdef CONFIG_PM
1685 --- a/net/mac80211/cfg.c
1686 +++ b/net/mac80211/cfg.c
1687 @@ -468,327 +468,6 @@ void sta_set_rate_info_rx(struct sta_inf
1688 rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH;
1689 }
1690
1691 -static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1692 -{
1693 - struct ieee80211_sub_if_data *sdata = sta->sdata;
1694 - struct ieee80211_local *local = sdata->local;
1695 - struct rate_control_ref *ref = local->rate_ctrl;
1696 - struct timespec uptime;
1697 - u64 packets = 0;
1698 - u32 thr = 0;
1699 - int i, ac;
1700 -
1701 - sinfo->generation = sdata->local->sta_generation;
1702 -
1703 - sinfo->filled = STATION_INFO_INACTIVE_TIME |
1704 - STATION_INFO_RX_BYTES64 |
1705 - STATION_INFO_TX_BYTES64 |
1706 - STATION_INFO_RX_PACKETS |
1707 - STATION_INFO_TX_PACKETS |
1708 - STATION_INFO_TX_RETRIES |
1709 - STATION_INFO_TX_FAILED |
1710 - STATION_INFO_TX_BITRATE |
1711 - STATION_INFO_RX_BITRATE |
1712 - STATION_INFO_RX_DROP_MISC |
1713 - STATION_INFO_BSS_PARAM |
1714 - STATION_INFO_CONNECTED_TIME |
1715 - STATION_INFO_STA_FLAGS |
1716 - STATION_INFO_BEACON_LOSS_COUNT;
1717 -
1718 - do_posix_clock_monotonic_gettime(&uptime);
1719 - sinfo->connected_time = uptime.tv_sec - sta->last_connected;
1720 -
1721 - sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
1722 - sinfo->tx_bytes = 0;
1723 - for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1724 - sinfo->tx_bytes += sta->tx_bytes[ac];
1725 - packets += sta->tx_packets[ac];
1726 - }
1727 - sinfo->tx_packets = packets;
1728 - sinfo->rx_bytes = sta->rx_bytes;
1729 - sinfo->rx_packets = sta->rx_packets;
1730 - sinfo->tx_retries = sta->tx_retry_count;
1731 - sinfo->tx_failed = sta->tx_retry_failed;
1732 - sinfo->rx_dropped_misc = sta->rx_dropped;
1733 - sinfo->beacon_loss_count = sta->beacon_loss_count;
1734 -
1735 - if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
1736 - (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
1737 - sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
1738 - if (!local->ops->get_rssi ||
1739 - drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal))
1740 - sinfo->signal = (s8)sta->last_signal;
1741 - sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
1742 - }
1743 - if (sta->chains) {
1744 - sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
1745 - STATION_INFO_CHAIN_SIGNAL_AVG;
1746 -
1747 - sinfo->chains = sta->chains;
1748 - for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
1749 - sinfo->chain_signal[i] = sta->chain_signal_last[i];
1750 - sinfo->chain_signal_avg[i] =
1751 - (s8) -ewma_read(&sta->chain_signal_avg[i]);
1752 - }
1753 - }
1754 -
1755 - sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
1756 - sta_set_rate_info_rx(sta, &sinfo->rxrate);
1757 -
1758 - if (ieee80211_vif_is_mesh(&sdata->vif)) {
1759 -#ifdef CPTCFG_MAC80211_MESH
1760 - sinfo->filled |= STATION_INFO_LLID |
1761 - STATION_INFO_PLID |
1762 - STATION_INFO_PLINK_STATE |
1763 - STATION_INFO_LOCAL_PM |
1764 - STATION_INFO_PEER_PM |
1765 - STATION_INFO_NONPEER_PM;
1766 -
1767 - sinfo->llid = sta->llid;
1768 - sinfo->plid = sta->plid;
1769 - sinfo->plink_state = sta->plink_state;
1770 - if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
1771 - sinfo->filled |= STATION_INFO_T_OFFSET;
1772 - sinfo->t_offset = sta->t_offset;
1773 - }
1774 - sinfo->local_pm = sta->local_pm;
1775 - sinfo->peer_pm = sta->peer_pm;
1776 - sinfo->nonpeer_pm = sta->nonpeer_pm;
1777 -#endif
1778 - }
1779 -
1780 - sinfo->bss_param.flags = 0;
1781 - if (sdata->vif.bss_conf.use_cts_prot)
1782 - sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
1783 - if (sdata->vif.bss_conf.use_short_preamble)
1784 - sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
1785 - if (sdata->vif.bss_conf.use_short_slot)
1786 - sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
1787 - sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
1788 - sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
1789 -
1790 - sinfo->sta_flags.set = 0;
1791 - sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
1792 - BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
1793 - BIT(NL80211_STA_FLAG_WME) |
1794 - BIT(NL80211_STA_FLAG_MFP) |
1795 - BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1796 - BIT(NL80211_STA_FLAG_ASSOCIATED) |
1797 - BIT(NL80211_STA_FLAG_TDLS_PEER);
1798 - if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1799 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
1800 - if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
1801 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
1802 - if (test_sta_flag(sta, WLAN_STA_WME))
1803 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
1804 - if (test_sta_flag(sta, WLAN_STA_MFP))
1805 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
1806 - if (test_sta_flag(sta, WLAN_STA_AUTH))
1807 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
1808 - if (test_sta_flag(sta, WLAN_STA_ASSOC))
1809 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1810 - if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1811 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
1812 -
1813 - /* check if the driver has a SW RC implementation */
1814 - if (ref && ref->ops->get_expected_throughput)
1815 - thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv);
1816 - else
1817 - thr = drv_get_expected_throughput(local, &sta->sta);
1818 -
1819 - if (thr != 0) {
1820 - sinfo->filled |= STATION_INFO_EXPECTED_THROUGHPUT;
1821 - sinfo->expected_throughput = thr;
1822 - }
1823 -}
1824 -
1825 -static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
1826 - "rx_packets", "rx_bytes", "wep_weak_iv_count",
1827 - "rx_duplicates", "rx_fragments", "rx_dropped",
1828 - "tx_packets", "tx_bytes", "tx_fragments",
1829 - "tx_filtered", "tx_retry_failed", "tx_retries",
1830 - "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
1831 - "channel", "noise", "ch_time", "ch_time_busy",
1832 - "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
1833 -};
1834 -#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
1835 -
1836 -static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
1837 - struct net_device *dev,
1838 - int sset)
1839 -{
1840 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1841 - int rv = 0;
1842 -
1843 - if (sset == ETH_SS_STATS)
1844 - rv += STA_STATS_LEN;
1845 -
1846 - rv += drv_get_et_sset_count(sdata, sset);
1847 -
1848 - if (rv == 0)
1849 - return -EOPNOTSUPP;
1850 - return rv;
1851 -}
1852 -
1853 -static void ieee80211_get_et_stats(struct wiphy *wiphy,
1854 - struct net_device *dev,
1855 - struct ethtool_stats *stats,
1856 - u64 *data)
1857 -{
1858 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1859 - struct ieee80211_chanctx_conf *chanctx_conf;
1860 - struct ieee80211_channel *channel;
1861 - struct sta_info *sta;
1862 - struct ieee80211_local *local = sdata->local;
1863 - struct station_info sinfo;
1864 - struct survey_info survey;
1865 - int i, q;
1866 -#define STA_STATS_SURVEY_LEN 7
1867 -
1868 - memset(data, 0, sizeof(u64) * STA_STATS_LEN);
1869 -
1870 -#define ADD_STA_STATS(sta) \
1871 - do { \
1872 - data[i++] += sta->rx_packets; \
1873 - data[i++] += sta->rx_bytes; \
1874 - data[i++] += sta->wep_weak_iv_count; \
1875 - data[i++] += sta->num_duplicates; \
1876 - data[i++] += sta->rx_fragments; \
1877 - data[i++] += sta->rx_dropped; \
1878 - \
1879 - data[i++] += sinfo.tx_packets; \
1880 - data[i++] += sinfo.tx_bytes; \
1881 - data[i++] += sta->tx_fragments; \
1882 - data[i++] += sta->tx_filtered_count; \
1883 - data[i++] += sta->tx_retry_failed; \
1884 - data[i++] += sta->tx_retry_count; \
1885 - data[i++] += sta->beacon_loss_count; \
1886 - } while (0)
1887 -
1888 - /* For Managed stations, find the single station based on BSSID
1889 - * and use that. For interface types, iterate through all available
1890 - * stations and add stats for any station that is assigned to this
1891 - * network device.
1892 - */
1893 -
1894 - mutex_lock(&local->sta_mtx);
1895 -
1896 - if (sdata->vif.type == NL80211_IFTYPE_STATION) {
1897 - sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
1898 -
1899 - if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
1900 - goto do_survey;
1901 -
1902 - sinfo.filled = 0;
1903 - sta_set_sinfo(sta, &sinfo);
1904 -
1905 - i = 0;
1906 - ADD_STA_STATS(sta);
1907 -
1908 - data[i++] = sta->sta_state;
1909 -
1910 -
1911 - if (sinfo.filled & STATION_INFO_TX_BITRATE)
1912 - data[i] = 100000 *
1913 - cfg80211_calculate_bitrate(&sinfo.txrate);
1914 - i++;
1915 - if (sinfo.filled & STATION_INFO_RX_BITRATE)
1916 - data[i] = 100000 *
1917 - cfg80211_calculate_bitrate(&sinfo.rxrate);
1918 - i++;
1919 -
1920 - if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
1921 - data[i] = (u8)sinfo.signal_avg;
1922 - i++;
1923 - } else {
1924 - list_for_each_entry(sta, &local->sta_list, list) {
1925 - /* Make sure this station belongs to the proper dev */
1926 - if (sta->sdata->dev != dev)
1927 - continue;
1928 -
1929 - sinfo.filled = 0;
1930 - sta_set_sinfo(sta, &sinfo);
1931 - i = 0;
1932 - ADD_STA_STATS(sta);
1933 - }
1934 - }
1935 -
1936 -do_survey:
1937 - i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
1938 - /* Get survey stats for current channel */
1939 - survey.filled = 0;
1940 -
1941 - rcu_read_lock();
1942 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1943 - if (chanctx_conf)
1944 - channel = chanctx_conf->def.chan;
1945 - else
1946 - channel = NULL;
1947 - rcu_read_unlock();
1948 -
1949 - if (channel) {
1950 - q = 0;
1951 - do {
1952 - survey.filled = 0;
1953 - if (drv_get_survey(local, q, &survey) != 0) {
1954 - survey.filled = 0;
1955 - break;
1956 - }
1957 - q++;
1958 - } while (channel != survey.channel);
1959 - }
1960 -
1961 - if (survey.filled)
1962 - data[i++] = survey.channel->center_freq;
1963 - else
1964 - data[i++] = 0;
1965 - if (survey.filled & SURVEY_INFO_NOISE_DBM)
1966 - data[i++] = (u8)survey.noise;
1967 - else
1968 - data[i++] = -1LL;
1969 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
1970 - data[i++] = survey.channel_time;
1971 - else
1972 - data[i++] = -1LL;
1973 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
1974 - data[i++] = survey.channel_time_busy;
1975 - else
1976 - data[i++] = -1LL;
1977 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
1978 - data[i++] = survey.channel_time_ext_busy;
1979 - else
1980 - data[i++] = -1LL;
1981 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
1982 - data[i++] = survey.channel_time_rx;
1983 - else
1984 - data[i++] = -1LL;
1985 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
1986 - data[i++] = survey.channel_time_tx;
1987 - else
1988 - data[i++] = -1LL;
1989 -
1990 - mutex_unlock(&local->sta_mtx);
1991 -
1992 - if (WARN_ON(i != STA_STATS_LEN))
1993 - return;
1994 -
1995 - drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
1996 -}
1997 -
1998 -static void ieee80211_get_et_strings(struct wiphy *wiphy,
1999 - struct net_device *dev,
2000 - u32 sset, u8 *data)
2001 -{
2002 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2003 - int sz_sta_stats = 0;
2004 -
2005 - if (sset == ETH_SS_STATS) {
2006 - sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
2007 - memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
2008 - }
2009 - drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
2010 -}
2011 -
2012 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
2013 int idx, u8 *mac, struct station_info *sinfo)
2014 {
2015 @@ -875,7 +554,8 @@ static int ieee80211_set_monitor_channel
2016 }
2017
2018 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
2019 - const u8 *resp, size_t resp_len)
2020 + const u8 *resp, size_t resp_len,
2021 + const struct ieee80211_csa_settings *csa)
2022 {
2023 struct probe_resp *new, *old;
2024
2025 @@ -891,6 +571,11 @@ static int ieee80211_set_probe_resp(stru
2026 new->len = resp_len;
2027 memcpy(new->data, resp, resp_len);
2028
2029 + if (csa)
2030 + memcpy(new->csa_counter_offsets, csa->counter_offsets_presp,
2031 + csa->n_counter_offsets_presp *
2032 + sizeof(new->csa_counter_offsets[0]));
2033 +
2034 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
2035 if (old)
2036 kfree_rcu(old, rcu_head);
2037 @@ -899,7 +584,8 @@ static int ieee80211_set_probe_resp(stru
2038 }
2039
2040 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
2041 - struct cfg80211_beacon_data *params)
2042 + struct cfg80211_beacon_data *params,
2043 + const struct ieee80211_csa_settings *csa)
2044 {
2045 struct beacon_data *new, *old;
2046 int new_head_len, new_tail_len;
2047 @@ -943,6 +629,13 @@ static int ieee80211_assign_beacon(struc
2048 new->head_len = new_head_len;
2049 new->tail_len = new_tail_len;
2050
2051 + if (csa) {
2052 + new->csa_current_counter = csa->count;
2053 + memcpy(new->csa_counter_offsets, csa->counter_offsets_beacon,
2054 + csa->n_counter_offsets_beacon *
2055 + sizeof(new->csa_counter_offsets[0]));
2056 + }
2057 +
2058 /* copy in head */
2059 if (params->head)
2060 memcpy(new->head, params->head, new_head_len);
2061 @@ -957,7 +650,7 @@ static int ieee80211_assign_beacon(struc
2062 memcpy(new->tail, old->tail, new_tail_len);
2063
2064 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
2065 - params->probe_resp_len);
2066 + params->probe_resp_len, csa);
2067 if (err < 0)
2068 return err;
2069 if (err == 0)
2070 @@ -1042,7 +735,7 @@ static int ieee80211_start_ap(struct wip
2071 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2072 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2073
2074 - err = ieee80211_assign_beacon(sdata, &params->beacon);
2075 + err = ieee80211_assign_beacon(sdata, &params->beacon, NULL);
2076 if (err < 0) {
2077 ieee80211_vif_release_channel(sdata);
2078 return err;
2079 @@ -1090,7 +783,7 @@ static int ieee80211_change_beacon(struc
2080 if (!old)
2081 return -ENOENT;
2082
2083 - err = ieee80211_assign_beacon(sdata, params);
2084 + err = ieee80211_assign_beacon(sdata, params, NULL);
2085 if (err < 0)
2086 return err;
2087 ieee80211_bss_info_change_notify(sdata, err);
2088 @@ -3073,7 +2766,8 @@ static int ieee80211_set_after_csa_beaco
2089
2090 switch (sdata->vif.type) {
2091 case NL80211_IFTYPE_AP:
2092 - err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
2093 + err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
2094 + NULL);
2095 kfree(sdata->u.ap.next_beacon);
2096 sdata->u.ap.next_beacon = NULL;
2097
2098 @@ -3176,6 +2870,7 @@ static int ieee80211_set_csa_beacon(stru
2099 struct cfg80211_csa_settings *params,
2100 u32 *changed)
2101 {
2102 + struct ieee80211_csa_settings csa = {};
2103 int err;
2104
2105 switch (sdata->vif.type) {
2106 @@ -3210,20 +2905,13 @@ static int ieee80211_set_csa_beacon(stru
2107 IEEE80211_MAX_CSA_COUNTERS_NUM))
2108 return -EINVAL;
2109
2110 - /* make sure we don't have garbage in other counters */
2111 - memset(sdata->csa_counter_offset_beacon, 0,
2112 - sizeof(sdata->csa_counter_offset_beacon));
2113 - memset(sdata->csa_counter_offset_presp, 0,
2114 - sizeof(sdata->csa_counter_offset_presp));
2115 -
2116 - memcpy(sdata->csa_counter_offset_beacon,
2117 - params->counter_offsets_beacon,
2118 - params->n_counter_offsets_beacon * sizeof(u16));
2119 - memcpy(sdata->csa_counter_offset_presp,
2120 - params->counter_offsets_presp,
2121 - params->n_counter_offsets_presp * sizeof(u16));
2122 + csa.counter_offsets_beacon = params->counter_offsets_beacon;
2123 + csa.counter_offsets_presp = params->counter_offsets_presp;
2124 + csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
2125 + csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
2126 + csa.count = params->count;
2127
2128 - err = ieee80211_assign_beacon(sdata, &params->beacon_csa);
2129 + err = ieee80211_assign_beacon(sdata, &params->beacon_csa, &csa);
2130 if (err < 0) {
2131 kfree(sdata->u.ap.next_beacon);
2132 return err;
2133 @@ -3367,7 +3055,6 @@ __ieee80211_channel_switch(struct wiphy
2134 sdata->csa_radar_required = params->radar_required;
2135 sdata->csa_chandef = params->chandef;
2136 sdata->csa_block_tx = params->block_tx;
2137 - sdata->csa_current_counter = params->count;
2138 sdata->vif.csa_active = true;
2139
2140 if (sdata->csa_block_tx)
2141 @@ -3515,10 +3202,23 @@ static int ieee80211_mgmt_tx(struct wiph
2142 sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
2143 params->n_csa_offsets) {
2144 int i;
2145 - u8 c = sdata->csa_current_counter;
2146 + struct beacon_data *beacon = NULL;
2147 +
2148 + rcu_read_lock();
2149
2150 - for (i = 0; i < params->n_csa_offsets; i++)
2151 - data[params->csa_offsets[i]] = c;
2152 + if (sdata->vif.type == NL80211_IFTYPE_AP)
2153 + beacon = rcu_dereference(sdata->u.ap.beacon);
2154 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
2155 + beacon = rcu_dereference(sdata->u.ibss.presp);
2156 + else if (ieee80211_vif_is_mesh(&sdata->vif))
2157 + beacon = rcu_dereference(sdata->u.mesh.beacon);
2158 +
2159 + if (beacon)
2160 + for (i = 0; i < params->n_csa_offsets; i++)
2161 + data[params->csa_offsets[i]] =
2162 + beacon->csa_current_counter;
2163 +
2164 + rcu_read_unlock();
2165 }
2166
2167 IEEE80211_SKB_CB(skb)->flags = flags;
2168 @@ -3598,21 +3298,6 @@ static int ieee80211_get_antenna(struct
2169 return drv_get_antenna(local, tx_ant, rx_ant);
2170 }
2171
2172 -static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2173 -{
2174 - struct ieee80211_local *local = wiphy_priv(wiphy);
2175 -
2176 - return drv_set_ringparam(local, tx, rx);
2177 -}
2178 -
2179 -static void ieee80211_get_ringparam(struct wiphy *wiphy,
2180 - u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2181 -{
2182 - struct ieee80211_local *local = wiphy_priv(wiphy);
2183 -
2184 - drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2185 -}
2186 -
2187 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2188 struct net_device *dev,
2189 struct cfg80211_gtk_rekey_data *data)
2190 @@ -3844,8 +3529,6 @@ const struct cfg80211_ops mac80211_confi
2191 .mgmt_frame_register = ieee80211_mgmt_frame_register,
2192 .set_antenna = ieee80211_set_antenna,
2193 .get_antenna = ieee80211_get_antenna,
2194 - .set_ringparam = ieee80211_set_ringparam,
2195 - .get_ringparam = ieee80211_get_ringparam,
2196 .set_rekey_data = ieee80211_set_rekey_data,
2197 .tdls_oper = ieee80211_tdls_oper,
2198 .tdls_mgmt = ieee80211_tdls_mgmt,
2199 @@ -3854,9 +3537,6 @@ const struct cfg80211_ops mac80211_confi
2200 #ifdef CONFIG_PM
2201 .set_wakeup = ieee80211_set_wakeup,
2202 #endif
2203 - .get_et_sset_count = ieee80211_get_et_sset_count,
2204 - .get_et_stats = ieee80211_get_et_stats,
2205 - .get_et_strings = ieee80211_get_et_strings,
2206 .get_channel = ieee80211_cfg_get_channel,
2207 .start_radar_detection = ieee80211_start_radar_detection,
2208 .channel_switch = ieee80211_channel_switch,
2209 --- a/net/mac80211/debugfs_sta.c
2210 +++ b/net/mac80211/debugfs_sta.c
2211 @@ -587,7 +587,6 @@ void ieee80211_sta_debugfs_add(struct st
2212 DEBUGFS_ADD_COUNTER(tx_filtered, tx_filtered_count);
2213 DEBUGFS_ADD_COUNTER(tx_retry_failed, tx_retry_failed);
2214 DEBUGFS_ADD_COUNTER(tx_retry_count, tx_retry_count);
2215 - DEBUGFS_ADD_COUNTER(wep_weak_iv_count, wep_weak_iv_count);
2216
2217 if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
2218 debugfs_create_x32("driver_buffered_tids", 0400,
2219 --- a/net/mac80211/wep.c
2220 +++ b/net/mac80211/wep.c
2221 @@ -271,22 +271,6 @@ static int ieee80211_wep_decrypt(struct
2222 return ret;
2223 }
2224
2225 -
2226 -static bool ieee80211_wep_is_weak_iv(struct sk_buff *skb,
2227 - struct ieee80211_key *key)
2228 -{
2229 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2230 - unsigned int hdrlen;
2231 - u8 *ivpos;
2232 - u32 iv;
2233 -
2234 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
2235 - ivpos = skb->data + hdrlen;
2236 - iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
2237 -
2238 - return ieee80211_wep_weak_iv(iv, key->conf.keylen);
2239 -}
2240 -
2241 ieee80211_rx_result
2242 ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx)
2243 {
2244 @@ -301,16 +285,12 @@ ieee80211_crypto_wep_decrypt(struct ieee
2245 if (!(status->flag & RX_FLAG_DECRYPTED)) {
2246 if (skb_linearize(rx->skb))
2247 return RX_DROP_UNUSABLE;
2248 - if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key))
2249 - rx->sta->wep_weak_iv_count++;
2250 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key))
2251 return RX_DROP_UNUSABLE;
2252 } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) {
2253 if (!pskb_may_pull(rx->skb, ieee80211_hdrlen(fc) +
2254 IEEE80211_WEP_IV_LEN))
2255 return RX_DROP_UNUSABLE;
2256 - if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key))
2257 - rx->sta->wep_weak_iv_count++;
2258 ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key);
2259 /* remove ICV */
2260 if (pskb_trim(rx->skb, rx->skb->len - IEEE80211_WEP_ICV_LEN))
2261 --- a/include/net/cfg80211.h
2262 +++ b/include/net/cfg80211.h
2263 @@ -2278,16 +2278,6 @@ struct cfg80211_qos_map {
2264 *
2265 * @set_noack_map: Set the NoAck Map for the TIDs.
2266 *
2267 - * @get_et_sset_count: Ethtool API to get string-set count.
2268 - * See @ethtool_ops.get_sset_count
2269 - *
2270 - * @get_et_stats: Ethtool API to get a set of u64 stats.
2271 - * See @ethtool_ops.get_ethtool_stats
2272 - *
2273 - * @get_et_strings: Ethtool API to get a set of strings to describe stats
2274 - * and perhaps other supported types of ethtool data-sets.
2275 - * See @ethtool_ops.get_strings
2276 - *
2277 * @get_channel: Get the current operating channel for the virtual interface.
2278 * For monitor interfaces, it should return %NULL unless there's a single
2279 * current monitoring channel.
2280 @@ -2529,13 +2519,6 @@ struct cfg80211_ops {
2281 struct net_device *dev,
2282 u16 noack_map);
2283
2284 - int (*get_et_sset_count)(struct wiphy *wiphy,
2285 - struct net_device *dev, int sset);
2286 - void (*get_et_stats)(struct wiphy *wiphy, struct net_device *dev,
2287 - struct ethtool_stats *stats, u64 *data);
2288 - void (*get_et_strings)(struct wiphy *wiphy, struct net_device *dev,
2289 - u32 sset, u8 *data);
2290 -
2291 int (*get_channel)(struct wiphy *wiphy,
2292 struct wireless_dev *wdev,
2293 struct cfg80211_chan_def *chandef);
2294 @@ -4846,6 +4829,10 @@ void cfg80211_stop_iface(struct wiphy *w
2295 */
2296 void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
2297
2298 +
2299 +/* ethtool helper */
2300 +void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
2301 +
2302 /* Logging, debugging and troubleshooting/diagnostic helpers. */
2303
2304 /* wiphy_printk helpers, similar to dev_printk */
2305 --- a/net/mac80211/Makefile
2306 +++ b/net/mac80211/Makefile
2307 @@ -17,6 +17,7 @@ mac80211-y := \
2308 aes_ccm.o \
2309 aes_cmac.o \
2310 cfg.o \
2311 + ethtool.o \
2312 rx.o \
2313 spectmgmt.o \
2314 tx.o \
2315 --- a/net/mac80211/ieee80211_i.h
2316 +++ b/net/mac80211/ieee80211_i.h
2317 @@ -229,16 +229,29 @@ struct ieee80211_rx_data {
2318 u16 tkip_iv16;
2319 };
2320
2321 +struct ieee80211_csa_settings {
2322 + const u16 *counter_offsets_beacon;
2323 + const u16 *counter_offsets_presp;
2324 +
2325 + int n_counter_offsets_beacon;
2326 + int n_counter_offsets_presp;
2327 +
2328 + u8 count;
2329 +};
2330 +
2331 struct beacon_data {
2332 u8 *head, *tail;
2333 int head_len, tail_len;
2334 struct ieee80211_meshconf_ie *meshconf;
2335 + u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
2336 + u8 csa_current_counter;
2337 struct rcu_head rcu_head;
2338 };
2339
2340 struct probe_resp {
2341 struct rcu_head rcu_head;
2342 int len;
2343 + u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
2344 u8 data[0];
2345 };
2346
2347 @@ -754,8 +767,6 @@ struct ieee80211_sub_if_data {
2348 struct mac80211_qos_map __rcu *qos_map;
2349
2350 struct work_struct csa_finalize_work;
2351 - u16 csa_counter_offset_beacon[IEEE80211_MAX_CSA_COUNTERS_NUM];
2352 - u16 csa_counter_offset_presp[IEEE80211_MAX_CSA_COUNTERS_NUM];
2353 bool csa_radar_required;
2354 bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
2355 struct cfg80211_chan_def csa_chandef;
2356 @@ -767,7 +778,6 @@ struct ieee80211_sub_if_data {
2357 struct ieee80211_chanctx *reserved_chanctx;
2358 struct cfg80211_chan_def reserved_chandef;
2359 bool reserved_radar_required;
2360 - u8 csa_current_counter;
2361
2362 /* used to reconfigure hardware SM PS */
2363 struct work_struct recalc_smps;
2364 @@ -1850,6 +1860,8 @@ int ieee80211_tdls_oper(struct wiphy *wi
2365 const u8 *peer, enum nl80211_tdls_operation oper);
2366
2367
2368 +extern const struct ethtool_ops ieee80211_ethtool_ops;
2369 +
2370 #ifdef CPTCFG_MAC80211_NOINLINE
2371 #define debug_noinline noinline
2372 #else
2373 --- a/net/mac80211/iface.c
2374 +++ b/net/mac80211/iface.c
2375 @@ -399,6 +399,7 @@ int ieee80211_add_virtual_monitor(struct
2376 sdata->vif.type = NL80211_IFTYPE_MONITOR;
2377 snprintf(sdata->name, IFNAMSIZ, "%s-monitor",
2378 wiphy_name(local->hw.wiphy));
2379 + sdata->wdev.iftype = NL80211_IFTYPE_MONITOR;
2380
2381 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
2382
2383 @@ -1303,6 +1304,7 @@ static void ieee80211_setup_sdata(struct
2384 sdata->control_port_protocol = cpu_to_be16(ETH_P_PAE);
2385 sdata->control_port_no_encrypt = false;
2386 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
2387 + sdata->vif.bss_conf.idle = true;
2388
2389 sdata->noack_map = 0;
2390
2391 @@ -1721,6 +1723,8 @@ int ieee80211_if_add(struct ieee80211_lo
2392
2393 ndev->features |= local->hw.netdev_features;
2394
2395 + netdev_set_default_ethtool_ops(ndev, &ieee80211_ethtool_ops);
2396 +
2397 ret = register_netdevice(ndev);
2398 if (ret) {
2399 free_netdev(ndev);
2400 --- a/net/wireless/core.c
2401 +++ b/net/wireless/core.c
2402 @@ -25,7 +25,6 @@
2403 #include "sysfs.h"
2404 #include "debugfs.h"
2405 #include "wext-compat.h"
2406 -#include "ethtool.h"
2407 #include "rdev-ops.h"
2408
2409 /* name for sysfs, %d is appended */
2410 @@ -940,8 +939,6 @@ static int cfg80211_netdev_notifier_call
2411 /* allow mac80211 to determine the timeout */
2412 wdev->ps_timeout = -1;
2413
2414 - netdev_set_default_ethtool_ops(dev, &cfg80211_ethtool_ops);
2415 -
2416 if ((wdev->iftype == NL80211_IFTYPE_STATION ||
2417 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
2418 wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
2419 --- a/net/wireless/ethtool.c
2420 +++ b/net/wireless/ethtool.c
2421 @@ -1,11 +1,9 @@
2422 #include <linux/utsname.h>
2423 #include <net/cfg80211.h>
2424 #include "core.h"
2425 -#include "ethtool.h"
2426 #include "rdev-ops.h"
2427
2428 -static void cfg80211_get_drvinfo(struct net_device *dev,
2429 - struct ethtool_drvinfo *info)
2430 +void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2431 {
2432 struct wireless_dev *wdev = dev->ieee80211_ptr;
2433
2434 @@ -23,84 +21,4 @@ static void cfg80211_get_drvinfo(struct
2435 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
2436 sizeof(info->bus_info));
2437 }
2438 -
2439 -static int cfg80211_get_regs_len(struct net_device *dev)
2440 -{
2441 - /* For now, return 0... */
2442 - return 0;
2443 -}
2444 -
2445 -static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
2446 - void *data)
2447 -{
2448 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2449 -
2450 - regs->version = wdev->wiphy->hw_version;
2451 - regs->len = 0;
2452 -}
2453 -
2454 -static void cfg80211_get_ringparam(struct net_device *dev,
2455 - struct ethtool_ringparam *rp)
2456 -{
2457 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2458 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2459 -
2460 - memset(rp, 0, sizeof(*rp));
2461 -
2462 - if (rdev->ops->get_ringparam)
2463 - rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending,
2464 - &rp->rx_pending, &rp->rx_max_pending);
2465 -}
2466 -
2467 -static int cfg80211_set_ringparam(struct net_device *dev,
2468 - struct ethtool_ringparam *rp)
2469 -{
2470 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2471 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2472 -
2473 - if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
2474 - return -EINVAL;
2475 -
2476 - if (rdev->ops->set_ringparam)
2477 - return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending);
2478 -
2479 - return -ENOTSUPP;
2480 -}
2481 -
2482 -static int cfg80211_get_sset_count(struct net_device *dev, int sset)
2483 -{
2484 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2485 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2486 - if (rdev->ops->get_et_sset_count)
2487 - return rdev_get_et_sset_count(rdev, dev, sset);
2488 - return -EOPNOTSUPP;
2489 -}
2490 -
2491 -static void cfg80211_get_stats(struct net_device *dev,
2492 - struct ethtool_stats *stats, u64 *data)
2493 -{
2494 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2495 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2496 - if (rdev->ops->get_et_stats)
2497 - rdev_get_et_stats(rdev, dev, stats, data);
2498 -}
2499 -
2500 -static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
2501 -{
2502 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2503 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2504 - if (rdev->ops->get_et_strings)
2505 - rdev_get_et_strings(rdev, dev, sset, data);
2506 -}
2507 -
2508 -const struct ethtool_ops cfg80211_ethtool_ops = {
2509 - .get_drvinfo = cfg80211_get_drvinfo,
2510 - .get_regs_len = cfg80211_get_regs_len,
2511 - .get_regs = cfg80211_get_regs,
2512 - .get_link = ethtool_op_get_link,
2513 - .get_ringparam = cfg80211_get_ringparam,
2514 - .set_ringparam = cfg80211_set_ringparam,
2515 - .get_strings = cfg80211_get_strings,
2516 - .get_ethtool_stats = cfg80211_get_stats,
2517 - .get_sset_count = cfg80211_get_sset_count,
2518 -};
2519 +EXPORT_SYMBOL(cfg80211_get_drvinfo);
2520 --- a/net/wireless/ethtool.h
2521 +++ /dev/null
2522 @@ -1,6 +0,0 @@
2523 -#ifndef __CFG80211_ETHTOOL__
2524 -#define __CFG80211_ETHTOOL__
2525 -
2526 -extern const struct ethtool_ops cfg80211_ethtool_ops;
2527 -
2528 -#endif /* __CFG80211_ETHTOOL__ */
2529 --- a/net/wireless/rdev-ops.h
2530 +++ b/net/wireless/rdev-ops.h
2531 @@ -714,25 +714,6 @@ static inline int rdev_get_antenna(struc
2532 return ret;
2533 }
2534
2535 -static inline int rdev_set_ringparam(struct cfg80211_registered_device *rdev,
2536 - u32 tx, u32 rx)
2537 -{
2538 - int ret;
2539 - trace_rdev_set_ringparam(&rdev->wiphy, tx, rx);
2540 - ret = rdev->ops->set_ringparam(&rdev->wiphy, tx, rx);
2541 - trace_rdev_return_int(&rdev->wiphy, ret);
2542 - return ret;
2543 -}
2544 -
2545 -static inline void rdev_get_ringparam(struct cfg80211_registered_device *rdev,
2546 - u32 *tx, u32 *tx_max, u32 *rx,
2547 - u32 *rx_max)
2548 -{
2549 - trace_rdev_get_ringparam(&rdev->wiphy);
2550 - rdev->ops->get_ringparam(&rdev->wiphy, tx, tx_max, rx, rx_max);
2551 - trace_rdev_return_void_tx_rx(&rdev->wiphy, *tx, *tx_max, *rx, *rx_max);
2552 -}
2553 -
2554 static inline int
2555 rdev_sched_scan_start(struct cfg80211_registered_device *rdev,
2556 struct net_device *dev,
2557 @@ -816,35 +797,6 @@ static inline int rdev_set_noack_map(str
2558 }
2559
2560 static inline int
2561 -rdev_get_et_sset_count(struct cfg80211_registered_device *rdev,
2562 - struct net_device *dev, int sset)
2563 -{
2564 - int ret;
2565 - trace_rdev_get_et_sset_count(&rdev->wiphy, dev, sset);
2566 - ret = rdev->ops->get_et_sset_count(&rdev->wiphy, dev, sset);
2567 - trace_rdev_return_int(&rdev->wiphy, ret);
2568 - return ret;
2569 -}
2570 -
2571 -static inline void rdev_get_et_stats(struct cfg80211_registered_device *rdev,
2572 - struct net_device *dev,
2573 - struct ethtool_stats *stats, u64 *data)
2574 -{
2575 - trace_rdev_get_et_stats(&rdev->wiphy, dev);
2576 - rdev->ops->get_et_stats(&rdev->wiphy, dev, stats, data);
2577 - trace_rdev_return_void(&rdev->wiphy);
2578 -}
2579 -
2580 -static inline void rdev_get_et_strings(struct cfg80211_registered_device *rdev,
2581 - struct net_device *dev, u32 sset,
2582 - u8 *data)
2583 -{
2584 - trace_rdev_get_et_strings(&rdev->wiphy, dev, sset);
2585 - rdev->ops->get_et_strings(&rdev->wiphy, dev, sset, data);
2586 - trace_rdev_return_void(&rdev->wiphy);
2587 -}
2588 -
2589 -static inline int
2590 rdev_get_channel(struct cfg80211_registered_device *rdev,
2591 struct wireless_dev *wdev,
2592 struct cfg80211_chan_def *chandef)
2593 --- a/net/wireless/trace.h
2594 +++ b/net/wireless/trace.h
2595 @@ -298,11 +298,6 @@ DEFINE_EVENT(wiphy_only_evt, rdev_return
2596 TP_ARGS(wiphy)
2597 );
2598
2599 -DEFINE_EVENT(wiphy_only_evt, rdev_get_ringparam,
2600 - TP_PROTO(struct wiphy *wiphy),
2601 - TP_ARGS(wiphy)
2602 -);
2603 -
2604 DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna,
2605 TP_PROTO(struct wiphy *wiphy),
2606 TP_ARGS(wiphy)
2607 @@ -580,11 +575,6 @@ DEFINE_EVENT(wiphy_netdev_evt, rdev_stop
2608 TP_ARGS(wiphy, netdev)
2609 );
2610
2611 -DEFINE_EVENT(wiphy_netdev_evt, rdev_get_et_stats,
2612 - TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
2613 - TP_ARGS(wiphy, netdev)
2614 -);
2615 -
2616 DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop,
2617 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
2618 TP_ARGS(wiphy, netdev)
2619 @@ -1439,11 +1429,6 @@ DECLARE_EVENT_CLASS(tx_rx_evt,
2620 WIPHY_PR_ARG, __entry->tx, __entry->rx)
2621 );
2622
2623 -DEFINE_EVENT(tx_rx_evt, rdev_set_ringparam,
2624 - TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
2625 - TP_ARGS(wiphy, rx, tx)
2626 -);
2627 -
2628 DEFINE_EVENT(tx_rx_evt, rdev_set_antenna,
2629 TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
2630 TP_ARGS(wiphy, rx, tx)
2631 @@ -1725,40 +1710,6 @@ TRACE_EVENT(rdev_set_noack_map,
2632 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map)
2633 );
2634
2635 -TRACE_EVENT(rdev_get_et_sset_count,
2636 - TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int sset),
2637 - TP_ARGS(wiphy, netdev, sset),
2638 - TP_STRUCT__entry(
2639 - WIPHY_ENTRY
2640 - NETDEV_ENTRY
2641 - __field(int, sset)
2642 - ),
2643 - TP_fast_assign(
2644 - WIPHY_ASSIGN;
2645 - NETDEV_ASSIGN;
2646 - __entry->sset = sset;
2647 - ),
2648 - TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %d",
2649 - WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset)
2650 -);
2651 -
2652 -TRACE_EVENT(rdev_get_et_strings,
2653 - TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 sset),
2654 - TP_ARGS(wiphy, netdev, sset),
2655 - TP_STRUCT__entry(
2656 - WIPHY_ENTRY
2657 - NETDEV_ENTRY
2658 - __field(u32, sset)
2659 - ),
2660 - TP_fast_assign(
2661 - WIPHY_ASSIGN;
2662 - NETDEV_ASSIGN;
2663 - __entry->sset = sset;
2664 - ),
2665 - TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %u",
2666 - WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset)
2667 -);
2668 -
2669 DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel,
2670 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
2671 TP_ARGS(wiphy, wdev)
2672 --- /dev/null
2673 +++ b/net/mac80211/ethtool.c
2674 @@ -0,0 +1,244 @@
2675 +/*
2676 + * mac80211 ethtool hooks for cfg80211
2677 + *
2678 + * Copied from cfg.c - originally
2679 + * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
2680 + * Copyright 2014 Intel Corporation (Author: Johannes Berg)
2681 + *
2682 + * This file is GPLv2 as found in COPYING.
2683 + */
2684 +#include <linux/types.h>
2685 +#include <net/cfg80211.h>
2686 +#include "ieee80211_i.h"
2687 +#include "sta_info.h"
2688 +#include "driver-ops.h"
2689 +
2690 +static int ieee80211_set_ringparam(struct net_device *dev,
2691 + struct ethtool_ringparam *rp)
2692 +{
2693 + struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
2694 +
2695 + if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
2696 + return -EINVAL;
2697 +
2698 + return drv_set_ringparam(local, rp->tx_pending, rp->rx_pending);
2699 +}
2700 +
2701 +static void ieee80211_get_ringparam(struct net_device *dev,
2702 + struct ethtool_ringparam *rp)
2703 +{
2704 + struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
2705 +
2706 + memset(rp, 0, sizeof(*rp));
2707 +
2708 + drv_get_ringparam(local, &rp->tx_pending, &rp->tx_max_pending,
2709 + &rp->rx_pending, &rp->rx_max_pending);
2710 +}
2711 +
2712 +static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
2713 + "rx_packets", "rx_bytes",
2714 + "rx_duplicates", "rx_fragments", "rx_dropped",
2715 + "tx_packets", "tx_bytes", "tx_fragments",
2716 + "tx_filtered", "tx_retry_failed", "tx_retries",
2717 + "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
2718 + "channel", "noise", "ch_time", "ch_time_busy",
2719 + "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
2720 +};
2721 +#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
2722 +
2723 +static int ieee80211_get_sset_count(struct net_device *dev, int sset)
2724 +{
2725 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2726 + int rv = 0;
2727 +
2728 + if (sset == ETH_SS_STATS)
2729 + rv += STA_STATS_LEN;
2730 +
2731 + rv += drv_get_et_sset_count(sdata, sset);
2732 +
2733 + if (rv == 0)
2734 + return -EOPNOTSUPP;
2735 + return rv;
2736 +}
2737 +
2738 +static void ieee80211_get_stats(struct net_device *dev,
2739 + struct ethtool_stats *stats,
2740 + u64 *data)
2741 +{
2742 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2743 + struct ieee80211_chanctx_conf *chanctx_conf;
2744 + struct ieee80211_channel *channel;
2745 + struct sta_info *sta;
2746 + struct ieee80211_local *local = sdata->local;
2747 + struct station_info sinfo;
2748 + struct survey_info survey;
2749 + int i, q;
2750 +#define STA_STATS_SURVEY_LEN 7
2751 +
2752 + memset(data, 0, sizeof(u64) * STA_STATS_LEN);
2753 +
2754 +#define ADD_STA_STATS(sta) \
2755 + do { \
2756 + data[i++] += sta->rx_packets; \
2757 + data[i++] += sta->rx_bytes; \
2758 + data[i++] += sta->num_duplicates; \
2759 + data[i++] += sta->rx_fragments; \
2760 + data[i++] += sta->rx_dropped; \
2761 + \
2762 + data[i++] += sinfo.tx_packets; \
2763 + data[i++] += sinfo.tx_bytes; \
2764 + data[i++] += sta->tx_fragments; \
2765 + data[i++] += sta->tx_filtered_count; \
2766 + data[i++] += sta->tx_retry_failed; \
2767 + data[i++] += sta->tx_retry_count; \
2768 + data[i++] += sta->beacon_loss_count; \
2769 + } while (0)
2770 +
2771 + /* For Managed stations, find the single station based on BSSID
2772 + * and use that. For interface types, iterate through all available
2773 + * stations and add stats for any station that is assigned to this
2774 + * network device.
2775 + */
2776 +
2777 + mutex_lock(&local->sta_mtx);
2778 +
2779 + if (sdata->vif.type == NL80211_IFTYPE_STATION) {
2780 + sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
2781 +
2782 + if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
2783 + goto do_survey;
2784 +
2785 + sinfo.filled = 0;
2786 + sta_set_sinfo(sta, &sinfo);
2787 +
2788 + i = 0;
2789 + ADD_STA_STATS(sta);
2790 +
2791 + data[i++] = sta->sta_state;
2792 +
2793 +
2794 + if (sinfo.filled & STATION_INFO_TX_BITRATE)
2795 + data[i] = 100000 *
2796 + cfg80211_calculate_bitrate(&sinfo.txrate);
2797 + i++;
2798 + if (sinfo.filled & STATION_INFO_RX_BITRATE)
2799 + data[i] = 100000 *
2800 + cfg80211_calculate_bitrate(&sinfo.rxrate);
2801 + i++;
2802 +
2803 + if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
2804 + data[i] = (u8)sinfo.signal_avg;
2805 + i++;
2806 + } else {
2807 + list_for_each_entry(sta, &local->sta_list, list) {
2808 + /* Make sure this station belongs to the proper dev */
2809 + if (sta->sdata->dev != dev)
2810 + continue;
2811 +
2812 + sinfo.filled = 0;
2813 + sta_set_sinfo(sta, &sinfo);
2814 + i = 0;
2815 + ADD_STA_STATS(sta);
2816 + }
2817 + }
2818 +
2819 +do_survey:
2820 + i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
2821 + /* Get survey stats for current channel */
2822 + survey.filled = 0;
2823 +
2824 + rcu_read_lock();
2825 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2826 + if (chanctx_conf)
2827 + channel = chanctx_conf->def.chan;
2828 + else
2829 + channel = NULL;
2830 + rcu_read_unlock();
2831 +
2832 + if (channel) {
2833 + q = 0;
2834 + do {
2835 + survey.filled = 0;
2836 + if (drv_get_survey(local, q, &survey) != 0) {
2837 + survey.filled = 0;
2838 + break;
2839 + }
2840 + q++;
2841 + } while (channel != survey.channel);
2842 + }
2843 +
2844 + if (survey.filled)
2845 + data[i++] = survey.channel->center_freq;
2846 + else
2847 + data[i++] = 0;
2848 + if (survey.filled & SURVEY_INFO_NOISE_DBM)
2849 + data[i++] = (u8)survey.noise;
2850 + else
2851 + data[i++] = -1LL;
2852 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
2853 + data[i++] = survey.channel_time;
2854 + else
2855 + data[i++] = -1LL;
2856 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
2857 + data[i++] = survey.channel_time_busy;
2858 + else
2859 + data[i++] = -1LL;
2860 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
2861 + data[i++] = survey.channel_time_ext_busy;
2862 + else
2863 + data[i++] = -1LL;
2864 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
2865 + data[i++] = survey.channel_time_rx;
2866 + else
2867 + data[i++] = -1LL;
2868 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
2869 + data[i++] = survey.channel_time_tx;
2870 + else
2871 + data[i++] = -1LL;
2872 +
2873 + mutex_unlock(&local->sta_mtx);
2874 +
2875 + if (WARN_ON(i != STA_STATS_LEN))
2876 + return;
2877 +
2878 + drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
2879 +}
2880 +
2881 +static void ieee80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
2882 +{
2883 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2884 + int sz_sta_stats = 0;
2885 +
2886 + if (sset == ETH_SS_STATS) {
2887 + sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
2888 + memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
2889 + }
2890 + drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
2891 +}
2892 +
2893 +static int ieee80211_get_regs_len(struct net_device *dev)
2894 +{
2895 + return 0;
2896 +}
2897 +
2898 +static void ieee80211_get_regs(struct net_device *dev,
2899 + struct ethtool_regs *regs,
2900 + void *data)
2901 +{
2902 + struct wireless_dev *wdev = dev->ieee80211_ptr;
2903 +
2904 + regs->version = wdev->wiphy->hw_version;
2905 + regs->len = 0;
2906 +}
2907 +
2908 +const struct ethtool_ops ieee80211_ethtool_ops = {
2909 + .get_drvinfo = cfg80211_get_drvinfo,
2910 + .get_regs_len = ieee80211_get_regs_len,
2911 + .get_regs = ieee80211_get_regs,
2912 + .get_link = ethtool_op_get_link,
2913 + .get_ringparam = ieee80211_get_ringparam,
2914 + .set_ringparam = ieee80211_set_ringparam,
2915 + .get_strings = ieee80211_get_strings,
2916 + .get_ethtool_stats = ieee80211_get_stats,
2917 + .get_sset_count = ieee80211_get_sset_count,
2918 +};
2919 --- a/net/mac80211/ibss.c
2920 +++ b/net/mac80211/ibss.c
2921 @@ -143,7 +143,7 @@ ieee80211_ibss_build_presp(struct ieee80
2922 *pos++ = csa_settings->block_tx ? 1 : 0;
2923 *pos++ = ieee80211_frequency_to_channel(
2924 csa_settings->chandef.chan->center_freq);
2925 - sdata->csa_counter_offset_beacon[0] = (pos - presp->head);
2926 + presp->csa_counter_offsets[0] = (pos - presp->head);
2927 *pos++ = csa_settings->count;
2928 }
2929
2930 @@ -1677,6 +1677,7 @@ int ieee80211_ibss_join(struct ieee80211
2931 sdata->u.ibss.control_port = params->control_port;
2932 sdata->u.ibss.userspace_handles_dfs = params->userspace_handles_dfs;
2933 sdata->u.ibss.basic_rates = params->basic_rates;
2934 + sdata->u.ibss.last_scan_completed = jiffies;
2935
2936 /* fix basic_rates if channel does not support these rates */
2937 rate_flags = ieee80211_chandef_rate_flags(&params->chandef);
2938 --- a/net/mac80211/mesh.c
2939 +++ b/net/mac80211/mesh.c
2940 @@ -679,7 +679,7 @@ ieee80211_mesh_build_beacon(struct ieee8
2941 *pos++ = 0x0;
2942 *pos++ = ieee80211_frequency_to_channel(
2943 csa->settings.chandef.chan->center_freq);
2944 - sdata->csa_counter_offset_beacon[0] = hdr_len + 6;
2945 + bcn->csa_counter_offsets[0] = hdr_len + 6;
2946 *pos++ = csa->settings.count;
2947 *pos++ = WLAN_EID_CHAN_SWITCH_PARAM;
2948 *pos++ = 6;
2949 --- a/net/wireless/genregdb.awk
2950 +++ b/net/wireless/genregdb.awk
2951 @@ -65,17 +65,7 @@ function parse_reg_rule()
2952 sub(/,/, "", units)
2953 dfs_cac = $9
2954 if (units == "mW") {
2955 - if (power == 100) {
2956 - power = 20
2957 - } else if (power == 200) {
2958 - power = 23
2959 - } else if (power == 500) {
2960 - power = 27
2961 - } else if (power == 1000) {
2962 - power = 30
2963 - } else {
2964 - print "Unknown power value in database!"
2965 - }
2966 + power = 10 * log(power)/log(10)
2967 } else {
2968 dfs_cac = $8
2969 }
2970 @@ -114,7 +104,7 @@ function parse_reg_rule()
2971
2972 }
2973 flags = flags "0"
2974 - printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
2975 + printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %.0f, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
2976 rules++
2977 }
2978
2979 --- a/net/mac80211/debugfs_netdev.c
2980 +++ b/net/mac80211/debugfs_netdev.c
2981 @@ -34,8 +34,7 @@ static ssize_t ieee80211_if_read(
2982 ssize_t ret = -EINVAL;
2983
2984 read_lock(&dev_base_lock);
2985 - if (sdata->dev->reg_state == NETREG_REGISTERED)
2986 - ret = (*format)(sdata, buf, sizeof(buf));
2987 + ret = (*format)(sdata, buf, sizeof(buf));
2988 read_unlock(&dev_base_lock);
2989
2990 if (ret >= 0)
2991 @@ -62,8 +61,7 @@ static ssize_t ieee80211_if_write(
2992
2993 ret = -ENODEV;
2994 rtnl_lock();
2995 - if (sdata->dev->reg_state == NETREG_REGISTERED)
2996 - ret = (*write)(sdata, buf, count);
2997 + ret = (*write)(sdata, buf, count);
2998 rtnl_unlock();
2999
3000 return ret;
3001 --- a/drivers/net/wireless/b43/xmit.c
3002 +++ b/drivers/net/wireless/b43/xmit.c
3003 @@ -811,9 +811,13 @@ void b43_rx(struct b43_wldev *dev, struc
3004 break;
3005 case B43_PHYTYPE_G:
3006 status.band = IEEE80211_BAND_2GHZ;
3007 - /* chanid is the radio channel cookie value as used
3008 - * to tune the radio. */
3009 - status.freq = chanid + 2400;
3010 + /* Somewhere between 478.104 and 508.1084 firmware for G-PHY
3011 + * has been modified to be compatible with N-PHY and others.
3012 + */
3013 + if (dev->fw.rev >= 508)
3014 + status.freq = ieee80211_channel_to_frequency(chanid, status.band);
3015 + else
3016 + status.freq = chanid + 2400;
3017 break;
3018 case B43_PHYTYPE_N:
3019 case B43_PHYTYPE_LP:
3020 --- a/drivers/net/wireless/b43/main.c
3021 +++ b/drivers/net/wireless/b43/main.c
3022 @@ -5216,6 +5216,7 @@ static int b43_wireless_core_attach(stru
3023 /* We don't support 5 GHz on some PHYs yet */
3024 switch (dev->phy.type) {
3025 case B43_PHYTYPE_A:
3026 + case B43_PHYTYPE_G:
3027 case B43_PHYTYPE_N:
3028 case B43_PHYTYPE_LP:
3029 case B43_PHYTYPE_HT:
3030 --- a/net/wireless/reg.c
3031 +++ b/net/wireless/reg.c
3032 @@ -935,7 +935,7 @@ freq_reg_info_regd(struct wiphy *wiphy,
3033 if (!band_rule_found)
3034 band_rule_found = freq_in_rule_band(fr, center_freq);
3035
3036 - bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(5));
3037 + bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20));
3038
3039 if (band_rule_found && bw_fits)
3040 return rr;
3041 @@ -1019,10 +1019,10 @@ static void chan_reg_rule_print_dbg(cons
3042 }
3043 #endif
3044
3045 -/* Find an ieee80211_reg_rule such that a 5MHz channel with frequency
3046 - * chan->center_freq fits there.
3047 - * If there is no such reg_rule, disable the channel, otherwise set the
3048 - * flags corresponding to the bandwidths allowed in the particular reg_rule
3049 +/*
3050 + * Note that right now we assume the desired channel bandwidth
3051 + * is always 20 MHz for each individual channel (HT40 uses 20 MHz
3052 + * per channel, the primary and the extension channel).
3053 */
3054 static void handle_channel(struct wiphy *wiphy,
3055 enum nl80211_reg_initiator initiator,
3056 @@ -1083,12 +1083,8 @@ static void handle_channel(struct wiphy
3057 if (reg_rule->flags & NL80211_RRF_AUTO_BW)
3058 max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
3059
3060 - if (max_bandwidth_khz < MHZ_TO_KHZ(10))
3061 - bw_flags = IEEE80211_CHAN_NO_10MHZ;
3062 - if (max_bandwidth_khz < MHZ_TO_KHZ(20))
3063 - bw_flags |= IEEE80211_CHAN_NO_20MHZ;
3064 if (max_bandwidth_khz < MHZ_TO_KHZ(40))
3065 - bw_flags |= IEEE80211_CHAN_NO_HT40;
3066 + bw_flags = IEEE80211_CHAN_NO_HT40;
3067 if (max_bandwidth_khz < MHZ_TO_KHZ(80))
3068 bw_flags |= IEEE80211_CHAN_NO_80MHZ;
3069 if (max_bandwidth_khz < MHZ_TO_KHZ(160))
3070 @@ -1522,12 +1518,8 @@ static void handle_channel_custom(struct
3071 if (reg_rule->flags & NL80211_RRF_AUTO_BW)
3072 max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
3073
3074 - if (max_bandwidth_khz < MHZ_TO_KHZ(10))
3075 - bw_flags = IEEE80211_CHAN_NO_10MHZ;
3076 - if (max_bandwidth_khz < MHZ_TO_KHZ(20))
3077 - bw_flags |= IEEE80211_CHAN_NO_20MHZ;
3078 if (max_bandwidth_khz < MHZ_TO_KHZ(40))
3079 - bw_flags |= IEEE80211_CHAN_NO_HT40;
3080 + bw_flags = IEEE80211_CHAN_NO_HT40;
3081 if (max_bandwidth_khz < MHZ_TO_KHZ(80))
3082 bw_flags |= IEEE80211_CHAN_NO_80MHZ;
3083 if (max_bandwidth_khz < MHZ_TO_KHZ(160))
3084 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
3085 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3086 @@ -185,7 +185,8 @@ struct ath_atx_ac {
3087
3088 struct ath_frame_info {
3089 struct ath_buf *bf;
3090 - int framelen;
3091 + u16 framelen;
3092 + s8 txq;
3093 enum ath9k_key_type keytype;
3094 u8 keyix;
3095 u8 rtscts_rate;
3096 --- a/drivers/net/wireless/ath/ath9k/xmit.c
3097 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3098 @@ -147,15 +147,13 @@ static void ath_set_rates(struct ieee802
3099 static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
3100 struct sk_buff *skb)
3101 {
3102 - int q;
3103 -
3104 - q = skb_get_queue_mapping(skb);
3105 - if (txq == sc->tx.uapsdq)
3106 - txq = sc->tx.txq_map[q];
3107 + struct ath_frame_info *fi = get_frame_info(skb);
3108 + int q = fi->txq;
3109
3110 - if (txq != sc->tx.txq_map[q])
3111 + if (q < 0)
3112 return;
3113
3114 + txq = sc->tx.txq_map[q];
3115 if (WARN_ON(--txq->pending_frames < 0))
3116 txq->pending_frames = 0;
3117
3118 @@ -887,6 +885,15 @@ ath_tx_get_tid_subframe(struct ath_softc
3119
3120 tx_info = IEEE80211_SKB_CB(skb);
3121 tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
3122 +
3123 + /*
3124 + * No aggregation session is running, but there may be frames
3125 + * from a previous session or a failed attempt in the queue.
3126 + * Send them out as normal data frames
3127 + */
3128 + if (!tid->active)
3129 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
3130 +
3131 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
3132 bf->bf_state.bf_type = 0;
3133 return bf;
3134 @@ -1999,6 +2006,7 @@ static void setup_frame_info(struct ieee
3135 an = (struct ath_node *) sta->drv_priv;
3136
3137 memset(fi, 0, sizeof(*fi));
3138 + fi->txq = -1;
3139 if (hw_key)
3140 fi->keyix = hw_key->hw_key_idx;
3141 else if (an && ieee80211_is_data(hdr->frame_control) && an->ps_key > 0)
3142 @@ -2150,6 +2158,7 @@ int ath_tx_start(struct ieee80211_hw *hw
3143 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3144 struct ieee80211_sta *sta = txctl->sta;
3145 struct ieee80211_vif *vif = info->control.vif;
3146 + struct ath_frame_info *fi = get_frame_info(skb);
3147 struct ath_softc *sc = hw->priv;
3148 struct ath_txq *txq = txctl->txq;
3149 struct ath_atx_tid *tid = NULL;
3150 @@ -2170,11 +2179,13 @@ int ath_tx_start(struct ieee80211_hw *hw
3151 q = skb_get_queue_mapping(skb);
3152
3153 ath_txq_lock(sc, txq);
3154 - if (txq == sc->tx.txq_map[q] &&
3155 - ++txq->pending_frames > sc->tx.txq_max_pending[q] &&
3156 - !txq->stopped) {
3157 - ieee80211_stop_queue(sc->hw, q);
3158 - txq->stopped = true;
3159 + if (txq == sc->tx.txq_map[q]) {
3160 + fi->txq = q;
3161 + if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
3162 + !txq->stopped) {
3163 + ieee80211_stop_queue(sc->hw, q);
3164 + txq->stopped = true;
3165 + }
3166 }
3167
3168 if (txctl->an && ieee80211_is_data_present(hdr->frame_control))
3169 --- a/net/mac80211/chan.c
3170 +++ b/net/mac80211/chan.c
3171 @@ -521,6 +521,8 @@ static void ieee80211_recalc_chanctx_cha
3172 continue;
3173 if (rcu_access_pointer(sdata->vif.chanctx_conf) != conf)
3174 continue;
3175 + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
3176 + continue;
3177
3178 if (!compat)
3179 compat = &sdata->vif.bss_conf.chandef;
3180 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
3181 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
3182 @@ -1004,9 +1004,11 @@ static bool ar5008_hw_ani_control_new(st
3183 case ATH9K_ANI_FIRSTEP_LEVEL:{
3184 u32 level = param;
3185
3186 - value = level;
3187 + value = level * 2;
3188 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
3189 AR_PHY_FIND_SIG_FIRSTEP, value);
3190 + REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW,
3191 + AR_PHY_FIND_SIG_FIRSTEP_LOW, value);
3192
3193 if (level != aniState->firstepLevel) {
3194 ath_dbg(common, ANI,
3195 @@ -1040,9 +1042,8 @@ static bool ar5008_hw_ani_control_new(st
3196 REG_RMW_FIELD(ah, AR_PHY_TIMING5,
3197 AR_PHY_TIMING5_CYCPWR_THR1, value);
3198
3199 - if (IS_CHAN_HT40(ah->curchan))
3200 - REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
3201 - AR_PHY_EXT_TIMING5_CYCPWR_THR1, value);
3202 + REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
3203 + AR_PHY_EXT_TIMING5_CYCPWR_THR1, value - 1);
3204
3205 if (level != aniState->spurImmunityLevel) {
3206 ath_dbg(common, ANI,
3207 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3208 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3209 @@ -517,6 +517,23 @@ static void ar9003_hw_spur_mitigate(stru
3210 ar9003_hw_spur_mitigate_ofdm(ah, chan);
3211 }
3212
3213 +static u32 ar9003_hw_compute_pll_control_soc(struct ath_hw *ah,
3214 + struct ath9k_channel *chan)
3215 +{
3216 + u32 pll;
3217 +
3218 + pll = SM(0x5, AR_RTC_9300_SOC_PLL_REFDIV);
3219 +
3220 + if (chan && IS_CHAN_HALF_RATE(chan))
3221 + pll |= SM(0x1, AR_RTC_9300_SOC_PLL_CLKSEL);
3222 + else if (chan && IS_CHAN_QUARTER_RATE(chan))
3223 + pll |= SM(0x2, AR_RTC_9300_SOC_PLL_CLKSEL);
3224 +
3225 + pll |= SM(0x2c, AR_RTC_9300_SOC_PLL_DIV_INT);
3226 +
3227 + return pll;
3228 +}
3229 +
3230 static u32 ar9003_hw_compute_pll_control(struct ath_hw *ah,
3231 struct ath9k_channel *chan)
3232 {
3233 @@ -1779,7 +1796,12 @@ void ar9003_hw_attach_phy_ops(struct ath
3234
3235 priv_ops->rf_set_freq = ar9003_hw_set_channel;
3236 priv_ops->spur_mitigate_freq = ar9003_hw_spur_mitigate;
3237 - priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
3238 +
3239 + if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah))
3240 + priv_ops->compute_pll_control = ar9003_hw_compute_pll_control_soc;
3241 + else
3242 + priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
3243 +
3244 priv_ops->set_channel_regs = ar9003_hw_set_channel_regs;
3245 priv_ops->init_bb = ar9003_hw_init_bb;
3246 priv_ops->process_ini = ar9003_hw_process_ini;
3247 --- a/drivers/net/wireless/ath/ath9k/hw.c
3248 +++ b/drivers/net/wireless/ath/ath9k/hw.c
3249 @@ -702,6 +702,8 @@ static void ath9k_hw_init_pll(struct ath
3250 {
3251 u32 pll;
3252
3253 + pll = ath9k_hw_compute_pll_control(ah, chan);
3254 +
3255 if (AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
3256 /* program BB PLL ki and kd value, ki=0x4, kd=0x40 */
3257 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
3258 @@ -752,7 +754,8 @@ static void ath9k_hw_init_pll(struct ath
3259 REG_RMW_FIELD(ah, AR_CH0_DDR_DPLL3,
3260 AR_CH0_DPLL3_PHASE_SHIFT, 0x1);
3261
3262 - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
3263 + REG_WRITE(ah, AR_RTC_PLL_CONTROL,
3264 + pll | AR_RTC_9300_PLL_BYPASS);
3265 udelay(1000);
3266
3267 /* program refdiv, nint, frac to RTC register */
3268 @@ -768,7 +771,8 @@ static void ath9k_hw_init_pll(struct ath
3269 } else if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah)) {
3270 u32 regval, pll2_divint, pll2_divfrac, refdiv;
3271
3272 - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
3273 + REG_WRITE(ah, AR_RTC_PLL_CONTROL,
3274 + pll | AR_RTC_9300_SOC_PLL_BYPASS);
3275 udelay(1000);
3276
3277 REG_SET_BIT(ah, AR_PHY_PLL_MODE, 0x1 << 16);
3278 @@ -840,7 +844,6 @@ static void ath9k_hw_init_pll(struct ath
3279 udelay(1000);
3280 }
3281
3282 - pll = ath9k_hw_compute_pll_control(ah, chan);
3283 if (AR_SREV_9565(ah))
3284 pll |= 0x40000;
3285 REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll);
3286 --- a/drivers/net/wireless/ath/ath9k/reg.h
3287 +++ b/drivers/net/wireless/ath/ath9k/reg.h
3288 @@ -1236,12 +1236,23 @@ enum {
3289 #define AR_CH0_DPLL3_PHASE_SHIFT_S 23
3290 #define AR_PHY_CCA_NOM_VAL_2GHZ -118
3291
3292 +#define AR_RTC_9300_SOC_PLL_DIV_INT 0x0000003f
3293 +#define AR_RTC_9300_SOC_PLL_DIV_INT_S 0
3294 +#define AR_RTC_9300_SOC_PLL_DIV_FRAC 0x000fffc0
3295 +#define AR_RTC_9300_SOC_PLL_DIV_FRAC_S 6
3296 +#define AR_RTC_9300_SOC_PLL_REFDIV 0x01f00000
3297 +#define AR_RTC_9300_SOC_PLL_REFDIV_S 20
3298 +#define AR_RTC_9300_SOC_PLL_CLKSEL 0x06000000
3299 +#define AR_RTC_9300_SOC_PLL_CLKSEL_S 25
3300 +#define AR_RTC_9300_SOC_PLL_BYPASS 0x08000000
3301 +
3302 #define AR_RTC_9300_PLL_DIV 0x000003ff
3303 #define AR_RTC_9300_PLL_DIV_S 0
3304 #define AR_RTC_9300_PLL_REFDIV 0x00003C00
3305 #define AR_RTC_9300_PLL_REFDIV_S 10
3306 #define AR_RTC_9300_PLL_CLKSEL 0x0000C000
3307 #define AR_RTC_9300_PLL_CLKSEL_S 14
3308 +#define AR_RTC_9300_PLL_BYPASS 0x00010000
3309
3310 #define AR_RTC_9160_PLL_DIV 0x000003ff
3311 #define AR_RTC_9160_PLL_DIV_S 0
3312 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
3313 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
3314 @@ -978,7 +978,7 @@ static bool ath9k_rx_prepare(struct ath9
3315 struct ath_hw *ah = common->ah;
3316 struct ath_htc_rx_status *rxstatus;
3317 struct ath_rx_status rx_stats;
3318 - bool decrypt_error;
3319 + bool decrypt_error = false;
3320
3321 if (skb->len < HTC_RX_FRAME_HEADER_SIZE) {
3322 ath_err(common, "Corrupted RX frame, dropping (len: %d)\n",