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