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