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