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