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