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