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