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