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