1 commit c35074725eb19f353beb5f71266f9e985e46f583
2 Author: Felix Fietkau <nbd@openwrt.org>
3 Date: Wed Oct 22 18:16:14 2014 +0200
5 ath9k_common: always update value in ath9k_cmn_update_txpow
7 In some cases the limit may be the same as reg->power_limit, but the
8 actual value that the hardware uses is not up to date. In that case, a
9 wrong value for current tx power is tracked internally.
10 Fix this by unconditionally updating it.
12 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
14 commit 11f17631d9bf2a9e910dac7d09ba4581f5693831
15 Author: Felix Fietkau <nbd@openwrt.org>
16 Date: Tue Sep 9 09:48:30 2014 +0200
18 ath9k_hw: fix PLL clock initialization for newer SoC
20 On AR934x and newer SoC devices, the layout of the AR_RTC_PLL_CONTROL
21 register changed. This currently breaks at least 5/10 MHz operation.
22 AR933x uses the old layout.
24 It might also have been causing other stability issues because of the
25 different location of the PLL_BYPASS bit which needs to be set during
26 PLL clock initialization.
28 This patch also removes more instances of hardcoded register values in
29 favor of properly computed ones with the PLL_BYPASS bit added.
31 Reported-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
32 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
34 commit 0fecedddd4a0945873db1bd230ec6a168b3cc4fe
35 Author: Felix Fietkau <nbd@openwrt.org>
36 Date: Mon Sep 8 18:35:08 2014 +0200
38 ath9k_hw: reduce ANI spur immunity setting on HT40 extension channel
40 The cycpwr_thr1 value needs to be lower on the extension channel than on
41 the control channel, similar to how the register settings are programmed
44 Also drop the unnecessary check for HT40 - this register can always be
45 written. This patch has been reported to improve HT40 stability and
46 throughput in some environments.
48 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
50 commit 30d7434ccb853b96de698a040888fa4dacd0cc19
51 Author: Felix Fietkau <nbd@openwrt.org>
52 Date: Mon Sep 8 18:31:26 2014 +0200
54 Revert "ath9k_hw: reduce ANI firstep range for older chips"
56 This reverts commit 09efc56345be4146ab9fc87a55c837ed5d6ea1ab
58 I've received reports that this change is decreasing throughput in some
59 rare conditions on an AR9280 based device
61 Cc: stable@vger.kernel.org
62 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
64 commit 15ed54948f508ad1baad79c30050e2d29a21696d
65 Author: Felix Fietkau <nbd@openwrt.org>
66 Date: Fri Jul 25 16:18:03 2014 +0200
68 mac80211: fix smps mode check for AP_VLAN
70 In ieee80211_sta_ps_deliver_wakeup, sdata->smps_mode is checked. This is
71 initialized only for the base AP interface, not the individual VLANs.
73 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
75 commit bc74ad816bba291359ae46301173ea744bdda9d2
76 Author: Felix Fietkau <nbd@openwrt.org>
77 Date: Fri Jul 25 16:15:44 2014 +0200
79 mac80211: ignore AP_VLAN in ieee80211_recalc_chanctx_chantype
81 When bringing down the AP, a WARN_ON is hit because the bss config chandef
83 Since AP_VLAN channel settings do not matter for anything chanctx related
84 (always inherits the settings from the AP interface), let's just ignore
87 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
89 commit ff354dbdd743e5fe186df8cd17982db19f78231a
90 Author: Felix Fietkau <nbd@openwrt.org>
91 Date: Wed Jul 23 15:33:26 2014 +0200
93 ath9k: fix aggregation session lockup
95 If an aggregation session fails, frames still end up in the driver queue
96 with IEEE80211_TX_CTL_AMPDU set.
97 This causes tx for the affected station/tid to stall, since
98 ath_tx_get_tid_subframe returning packets to send.
100 Fix this by clearing IEEE80211_TX_CTL_AMPDU as long as no aggregation
103 Cc: stable@vger.kernel.org
104 Reported-by: Antonio Quartulli <antonio@open-mesh.com>
105 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
107 commit 38695a6e5a940e6a524523b88a33916b016fb2a1
108 Author: Felix Fietkau <nbd@openwrt.org>
109 Date: Fri Jul 11 12:06:18 2014 +0200
111 mac80211: fix crash on getting sta info with uninitialized rate control
113 If the expected throughput is queried before rate control has been
114 initialized, the minstrel op for it will crash while trying to access
116 Check for WLAN_STA_RATE_CONTROL before attempting to use the rate
119 Reported-by: Jean-Pierre Tosoni <jp.tosoni@acksys.fr>
120 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
122 commit c0ee7fa4c0da824ccccc172bf175fb1f86540921
123 Author: Felix Fietkau <nbd@openwrt.org>
124 Date: Wed Jul 16 18:00:31 2014 +0200
126 ath9k: fix pending tx frames accounting
128 Packets originally buffered for the regular hardware tx queues can end
129 up being transmitted through the U-APSD queue (via PS-Poll or U-APSD).
130 When packets are dropped due to retransmit failures, the pending frames
131 counter is not always updated properly.
132 Fix this by keeping track of the queue that a frame was accounted for in
133 the ath_frame_info struct, and using that on completion to decide
134 whether the counter should be updated.
135 This fixes some spurious transmit queue hangs.
137 Cc: stable@vger.kernel.org
138 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
140 commit edcdf0989410a05a6a4b8438df4010447eaa7d9a
141 Author: Felix Fietkau <nbd@openwrt.org>
142 Date: Sun Jun 22 13:36:20 2014 +0200
144 Revert "cfg80211: Use 5MHz bandwidth by default when checking usable channels"
146 It enables channels that are not supposed to be enabled according to the
149 This reverts commit 8eca1fb692cc9557f386eddce75c300a3855d11a.
151 commit 6e7341074823d2a45b81f2742cbf75f1da790031
152 Author: Rafał Miłecki <zajec5@gmail.com>
153 Date: Sat May 31 19:40:45 2014 +0200
155 b43: disable 5 GHz on G-PHY
157 This fixes regression introduced by adding some G-PHY devices to the
158 list of dual band devices. There is simply no support for 5 GHz on
159 G-PHY devices in b43. It results in:
160 WARNING: CPU: 0 PID: 79 at drivers/net/wireless/b43/phy_g.c:75 b43_gphy_channel_switch+0x125/0x130 [b43]()
161 b43-phy1 ERROR: PHY init: Channel switch to default failed
163 Regression was introduced by the following commit:
165 commit 773cfc508f4d64c14547ff8751b5cbd473124364
166 Author: Rafał Miłecki <zajec5@gmail.com>
167 Date: Mon May 19 23:18:55 2014 +0200
169 b43: add more devices to the bands database
171 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
172 Signed-off-by: John W. Linville <linville@tuxdriver.com>
174 commit 1186edbef91f15722e5bdf56326ce0abc2935ce7
175 Author: Stanislaw Gruszka <sgruszka@redhat.com>
176 Date: Tue Jun 10 12:51:06 2014 +0200
178 rt2x00: disable TKIP on USB
180 On USB we can not get atomically TKIP key. We have to disable support
181 for TKIP acceleration on USB hardware to avoid bug as showed bellow.
183 [ 860.827243] BUG: scheduling while atomic: hostapd/3397/0x00000002
185 [ 860.827280] Call Trace:
186 [ 860.827282] [<ffffffff81682ea6>] dump_stack+0x4d/0x66
187 [ 860.827284] [<ffffffff8167eb9b>] __schedule_bug+0x47/0x55
188 [ 860.827285] [<ffffffff81685bb3>] __schedule+0x733/0x7b0
189 [ 860.827287] [<ffffffff81685c59>] schedule+0x29/0x70
190 [ 860.827289] [<ffffffff81684f8a>] schedule_timeout+0x15a/0x2b0
191 [ 860.827291] [<ffffffff8105ac50>] ? ftrace_raw_event_tick_stop+0xc0/0xc0
192 [ 860.827294] [<ffffffff810c13c2>] ? __module_text_address+0x12/0x70
193 [ 860.827296] [<ffffffff81686823>] wait_for_completion_timeout+0xb3/0x140
194 [ 860.827298] [<ffffffff81080fc0>] ? wake_up_state+0x20/0x20
195 [ 860.827301] [<ffffffff814d5b3d>] usb_start_wait_urb+0x7d/0x150
196 [ 860.827303] [<ffffffff814d5cd5>] usb_control_msg+0xc5/0x110
197 [ 860.827305] [<ffffffffa02fb0c6>] rt2x00usb_vendor_request+0xc6/0x160 [rt2x00usb]
198 [ 860.827307] [<ffffffffa02fb215>] rt2x00usb_vendor_req_buff_lock+0x75/0x150 [rt2x00usb]
199 [ 860.827309] [<ffffffffa02fb393>] rt2x00usb_vendor_request_buff+0xa3/0xe0 [rt2x00usb]
200 [ 860.827311] [<ffffffffa023d1a3>] rt2x00usb_register_multiread+0x33/0x40 [rt2800usb]
201 [ 860.827314] [<ffffffffa05805f9>] rt2800_get_tkip_seq+0x39/0x50 [rt2800lib]
202 [ 860.827321] [<ffffffffa0480f88>] ieee80211_get_key+0x218/0x2a0 [mac80211]
203 [ 860.827322] [<ffffffff815cc68c>] ? __nlmsg_put+0x6c/0x80
204 [ 860.827329] [<ffffffffa051b02e>] nl80211_get_key+0x22e/0x360 [cfg80211]
206 Cc: stable@vger.kernel.org
207 Reported-and-tested-by: Peter Wu <lekensteyn@gmail.com>
208 Reported-and-tested-by: Pontus Fuchs <pontus.fuchs@gmail.com>
209 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
210 Signed-off-by: John W. Linville <linville@tuxdriver.com>
212 commit 5f313a15da92dda80ac4c9a137bc42d7d0b49adf
213 Author: Rafał Miłecki <zajec5@gmail.com>
214 Date: Thu Jun 12 09:28:38 2014 +0200
216 b43: fix frequency reported on G-PHY with /new/ firmware
218 commit d3a58df87a2e4c2301ac843604202d290a48440b
219 Author: Avraham Stern <avraham.stern@intel.com>
220 Date: Thu May 22 12:17:47 2014 +0300
222 mac80211: set new interfaces as idle upon init
224 Mark new interfaces as idle to allow operations that require that
225 interfaces are idle to take place. Interface types that are always
226 not idle (like AP interfaces) will be set as not idle when they are
227 assigned a channel context.
229 Signed-off-by: Avraham Stern <avraham.stern@intel.com>
230 Signed-off-by: Emmanuel Grumbach<emmanuel.grumbach@intel.com>
231 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
233 commit 923eaf367206e01f22c97aee22300e332d071916
234 Author: Arik Nemtsov <arik@wizery.com>
235 Date: Mon May 26 14:40:51 2014 +0300
237 mac80211: don't check netdev state for debugfs read/write
239 Doing so will lead to an oops for a p2p-dev interface, since it has
242 Cc: stable@vger.kernel.org
243 Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
244 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
245 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
247 commit a9fb54169b197f31aff24c8d6270dd1e56cde395
248 Author: chaitanya.mgit@gmail.com <chaitanya.mgit@gmail.com>
249 Date: Mon May 26 18:01:44 2014 +0530
251 regdb: Generalize the mW to dBm power conversion
253 Generalize the power conversion from mW to dBm
254 using log. This should fix the below compilation
255 error for country NO which adds a new power value
256 2000mW which is not handled earlier.
258 CC [M] net/wireless/wext-sme.o
259 CC [M] net/wireless/regdb.o
260 net/wireless/regdb.c:1130:1: error: Unknown undeclared here (not in
262 net/wireless/regdb.c:1130:9: error: expected } before power
263 make[2]: *** [net/wireless/regdb.o] Error 1
264 make[1]: *** [net/wireless] Error 2
265 make: *** [net] Error 2
267 Reported-By: John Walker <john@x109.net>
268 Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
269 Acked-by: John W. Linville <linville@tuxdriver.com>
270 [remove unneeded parentheses, fix rounding by using %.0f]
271 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
273 commit c7d37a66e345df2fdf1aa7b2c9a6d3d53846ca5b
274 Author: Krzysztof Hałasa <khalasa@piap.pl>
275 Date: Mon May 26 14:14:46 2014 +0200
277 mac80211: fix IBSS join by initializing last_scan_completed
279 Without this fix, freshly rebooted Linux creates a new IBSS
280 instead of joining an existing one. Only when jiffies counter
281 overflows after 5 minutes the IBSS can be successfully joined.
283 Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
284 [edit commit message slightly]
285 Cc: stable@vger.kernel.org
286 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
288 commit 34171dc0d623be2c1032416bf7d3819f388ed70d
289 Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
290 Date: Sun May 25 15:35:41 2014 +0300
292 mac80211: fix virtual monitor interface addition
294 Since the commit below, cfg80211_chandef_dfs_required()
295 will warn if it gets a an NL80211_IFTYPE_UNSPECIFIED iftype
296 as explicitely written in the commit log.
297 When an virtual monitor interface is added, its type is set
298 in ieee80211_sub_if_data.vif.type, but not in
299 ieee80211_sub_if_data.wdev.iftype which is passed to
300 cfg80211_chandef_dfs_required() hence resulting in the
303 WARNING: CPU: 1 PID: 21265 at net/wireless/chan.c:376 cfg80211_chandef_dfs_required+0xbc/0x130 [cfg80211]()
304 Modules linked in: [...]
305 CPU: 1 PID: 21265 Comm: ifconfig Tainted: G W O 3.13.11+ #12
306 Hardware name: Dell Inc. Latitude E6410/0667CC, BIOS A01 03/05/2010
307 0000000000000009 ffff88008f5fdb08 ffffffff817d4219 ffff88008f5fdb50
308 ffff88008f5fdb40 ffffffff8106f57d 0000000000000000 0000000000000000
309 ffff880081062fb8 ffff8800810604e0 0000000000000001 ffff88008f5fdba0
311 [<ffffffff817d4219>] dump_stack+0x4d/0x66
312 [<ffffffff8106f57d>] warn_slowpath_common+0x7d/0xa0
313 [<ffffffff8106f5ec>] warn_slowpath_fmt+0x4c/0x50
314 [<ffffffffa04ea4ec>] cfg80211_chandef_dfs_required+0xbc/0x130 [cfg80211]
315 [<ffffffffa06b1024>] ieee80211_vif_use_channel+0x94/0x500 [mac80211]
316 [<ffffffffa0684e6b>] ieee80211_add_virtual_monitor+0x1ab/0x5c0 [mac80211]
317 [<ffffffffa0686ae5>] ieee80211_do_open+0xe75/0x1580 [mac80211]
318 [<ffffffffa0687259>] ieee80211_open+0x69/0x70 [mac80211]
321 Fixes: 00ec75fc5a64 ("cfg80211: pass the actual iftype when calling cfg80211_chandef_dfs_required()")
322 Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
323 Acked-by: Luciano Coelho <luciano.coelho@intel.com>
324 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
326 commit d93cc72b37b4e2c314e1c499e80e8801907c2fea
327 Author: Michal Kazior <michal.kazior@tieto.com>
328 Date: Thu Jun 5 14:21:37 2014 +0200
330 mac80211: use csa counter offsets instead of csa_active
332 vif->csa_active is protected by mutexes only. This
333 means it is unreliable to depend on it on codeflow
334 in non-sleepable beacon and CSA code. There was no
335 guarantee to have vif->csa_active update be
336 visible before beacons are updated on SMP systems.
338 Using csa counter offsets which are embedded in
339 beacon struct (and thus are protected with single
340 RCU assignment) is much safer.
342 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
343 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
345 commit d2746694fcdef24e0a7a1947d8c70082cde81a26
346 Author: Michal Kazior <michal.kazior@tieto.com>
347 Date: Thu Jun 5 14:21:36 2014 +0200
349 mac80211: move csa counters from sdata to beacon/presp
351 Having csa counters part of beacon and probe_resp
352 structures makes it easier to get rid of possible
353 races between setting a beacon and updating
354 counters on SMP systems by guaranteeing counters
355 are always consistent against given beacon struct.
357 While at it relax WARN_ON into WARN_ON_ONCE to
358 prevent spamming logs and racing.
360 Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
361 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
363 commit 5dcb54f3a1a8cd7e0331e773487574f9743615db
364 Author: Janusz Dziedzic <janusz.dziedzic@tieto.com>
365 Date: Thu Jun 5 08:12:57 2014 +0200
367 mac80211: allow tx via monitor iface when DFS
369 Allow send frames using monitor interface
370 when DFS chandef and we pass CAC (beaconing
373 This fix problem when old kernel and new backports used,
374 in such case hostapd create/use also monitor interface.
375 Before this patch all frames hostapd send using monitor
376 iface were dropped when AP was configured on DFS channel.
378 Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
379 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
381 commit 6f09a1beb0d2007572248c986780562219bd206f
382 Author: Johannes Berg <johannes.berg@intel.com>
383 Date: Wed Jun 4 17:31:56 2014 +0200
385 cfg80211: make ethtool the driver's responsibility
387 Currently, cfg80211 tries to implement ethtool, but that doesn't
388 really scale well, with all the different operations. Make the
389 lower-level driver responsible for it, which currently only has
390 an effect on mac80211. It will similarly not scale well at that
391 level though, since mac80211 also has many drivers.
393 To cleanly implement this in mac80211, introduce a new file and
394 move some code to appropriate places.
396 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
398 commit 6b0c6f133de8f90caeb1c4a902e6140567c5bf96
399 Author: Johannes Berg <johannes.berg@intel.com>
400 Date: Wed Jun 4 17:06:23 2014 +0200
402 mac80211: remove weak WEP IV accounting
404 Since WEP is practically dead, there seems very little
405 point in keeping WEP weak IV accounting.
407 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
409 commit aecdc89fb4664c76baa4bbd46008f220532309ff
410 Author: Luciano Coelho <luciano.coelho@intel.com>
411 Date: Fri May 23 11:04:50 2014 +0300
413 ath9k/ath10k: remove unnecessary channel_switch_beacon callbacks
415 The channel_switch_beacon callback is optional, so it doesn't have to
416 be defined if it's not going to do anything useful with it. Both
417 ath9k and ath10k define the callback and just returns. This commit
420 Cc: Michal Kazior <michal.kazior@tieto.com>
421 Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
422 Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
424 commit 60ccc107c9b9fb732fdee1f76bb2dad44f0e1798
425 Author: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
426 Date: Tue May 27 16:58:02 2014 +0530
428 ath9k: Fix deadlock while updating p2p beacon timer
430 pm_lock is taken twice while syncing HW TSF of p2p vif.
431 Fix this by taking the lock at caller side.
433 Cc: Felix Fietkau <nbd@openwrt.org>
434 Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
435 Signed-off-by: John W. Linville <linville@tuxdriver.com>
437 commit f3831a4e3903dbc1a57d5df56deb6a143fd001bc
438 Author: Stanislaw Gruszka <sgruszka@redhat.com>
439 Date: Thu Jun 5 13:52:27 2014 +0200
441 rt2x00: do not initialize BCN_OFFSET registers
443 We setup BCN_OFFSET{0,1} registers dynamically, don't have to
446 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
448 commit e5c58ca7a48d4c82f282749a978052c47fd95998
449 Author: Stanislaw Gruszka <sgruszka@redhat.com>
450 Date: Thu Jun 5 13:52:26 2014 +0200
452 rt2x00: change order when stop beaconing
454 When no beaconing is needed, first stop beacon queue (disable beaconing
455 globally) to avoid possible sending of not prepared beacon on short
456 period after clearing beacon and before stop of BCN queue.
458 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
460 commit 382c1b9e03f52d0cd741ef1d942cad0f649f0744
461 Author: Stanislaw Gruszka <sgruszka@redhat.com>
462 Date: Thu Jun 5 13:52:25 2014 +0200
464 rt2x00: change default MAC_BSSID_DW1_BSS_BCN_NUM
466 We setup MAC_BSSID_DW1_BSS_BCN_NUM dynamically when numbers of active
467 beacons increase. Change default to 0 to tell hardware that we want to
468 send only one beacon as default.
470 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
472 commit 3b400571dd033e46fa7e76c5bb92a3ce8198afa9
473 Author: Stanislaw Gruszka <sgruszka@redhat.com>
474 Date: Thu Jun 5 13:52:24 2014 +0200
476 rt2x00: change beaconing setup on RT2800
478 As reported by Matthias, on 5572 chip, even if we clear up TXWI
479 of corresponding beacon, hardware still try to send it or do other
480 action that increase power consumption peak up to 1A.
482 To avoid the issue, setup beaconing dynamically by configuring offsets
483 of currently active beacons and MAC_BSSID_DW1_BSS_BCN_NUM variable,
484 which limit number of beacons that hardware will try to send.
486 Reported-by: Matthias Fend <Matthias.Fend@wolfvision.net>
487 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
489 commit 916e591b2cc41f7e572992175ca56d866d7bc958
490 Author: Stanislaw Gruszka <sgruszka@redhat.com>
491 Date: Thu Jun 5 13:52:23 2014 +0200
493 rt2x00: change beaconing locking
495 This patch is needed for further changes to keep global variables
496 consistent when changing beaconing on diffrent vif's.
498 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
500 commit 930b0dffd1731f3f418f9132faea720a23b7af61
501 Author: Johannes Berg <johannes.berg@intel.com>
502 Date: Tue Jun 3 11:18:47 2014 +0200
504 mac80211: fix station/driver powersave race
506 It is currently possible to have a race due to the station PS
507 unblock work like this:
508 * station goes to sleep with frames buffered in the driver
509 * driver blocks wakeup
510 * station wakes up again
511 * driver flushes/returns frames, and unblocks, which schedules
513 * unblock work starts to run, and checks that the station is
514 awake (i.e. that the WLAN_STA_PS_STA flag isn't set)
515 * we process a received frame with PM=1, setting the flag again
516 * ieee80211_sta_ps_deliver_wakeup() runs, delivering all frames
517 to the driver, and then clearing the WLAN_STA_PS_DRIVER and
518 WLAN_STA_PS_STA flags
520 In this scenario, mac80211 will think that the station is awake,
521 while it really is asleep, and any TX'ed frames should be filtered
522 by the device (it will know that the station is sleeping) but then
523 passed to mac80211 again, which will not buffer it either as it
524 thinks the station is awake, and eventually the packets will be
527 Fix this by moving the clearing of the flags to exactly where we
528 learn about the situation. This creates a problem of reordering,
529 so introduce another flag indicating that delivery is being done,
530 this new flag also queues frames and is cleared only while the
531 spinlock is held (which the queuing code also holds) so that any
532 concurrent delivery/TX is handled correctly.
534 Reported-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
535 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
537 commit 6df35206bc6c1c6aad1d8077df5786b4a7f77873
538 Author: Felix Fietkau <nbd@openwrt.org>
539 Date: Fri May 23 19:58:14 2014 +0200
541 mac80211: reduce packet loss notifications under load
543 During strong signal fluctuations under high throughput, few consecutive
544 failed A-MPDU transmissions can easily trigger packet loss notification,
545 and thus (in AP mode) client disconnection.
547 Reduce the number of false positives by checking the A-MPDU status flag
548 and treating a failed A-MPDU as a single packet.
550 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
552 commit 7b7843a36fbcc568834404c7430ff895d8502131
553 Author: Felix Fietkau <nbd@openwrt.org>
554 Date: Fri May 23 19:26:32 2014 +0200
556 mac80211: fix a memory leak on sta rate selection table
558 Cc: stable@vger.kernel.org
559 Reported-by: Christophe Prévotaux <cprevotaux@nltinc.com>
560 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
562 commit 96892d6aa0a153423070addf3070bc79578b3897
563 Author: Felix Fietkau <nbd@openwrt.org>
564 Date: Mon May 19 21:20:49 2014 +0200
566 ath9k: avoid passing buffers to the hardware during flush
568 The commit "ath9k: fix possible hang on flush" changed the receive code
569 to always link rx descriptors of processed frames, even when flushing.
570 In some cases, this leads to flushed rx buffers being passed to the
571 hardware while rx is already stopped.
573 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
575 --- a/drivers/net/wireless/ath/ath9k/recv.c
576 +++ b/drivers/net/wireless/ath/ath9k/recv.c
577 @@ -34,7 +34,8 @@ static inline bool ath9k_check_auto_slee
578 * buffer (or rx fifo). This can incorrectly acknowledge packets
579 * to a sender if last desc is self-linked.
581 -static void ath_rx_buf_link(struct ath_softc *sc, struct ath_rxbuf *bf)
582 +static void ath_rx_buf_link(struct ath_softc *sc, struct ath_rxbuf *bf,
585 struct ath_hw *ah = sc->sc_ah;
586 struct ath_common *common = ath9k_hw_common(ah);
587 @@ -59,18 +60,19 @@ static void ath_rx_buf_link(struct ath_s
591 - if (sc->rx.rxlink == NULL)
592 - ath9k_hw_putrxbuf(ah, bf->bf_daddr);
595 *sc->rx.rxlink = bf->bf_daddr;
597 + ath9k_hw_putrxbuf(ah, bf->bf_daddr);
599 sc->rx.rxlink = &ds->ds_link;
602 -static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_rxbuf *bf)
603 +static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_rxbuf *bf,
607 - ath_rx_buf_link(sc, sc->rx.buf_hold);
608 + ath_rx_buf_link(sc, sc->rx.buf_hold, flush);
610 sc->rx.buf_hold = bf;
612 @@ -442,7 +444,7 @@ int ath_startrecv(struct ath_softc *sc)
613 sc->rx.buf_hold = NULL;
614 sc->rx.rxlink = NULL;
615 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) {
616 - ath_rx_buf_link(sc, bf);
617 + ath_rx_buf_link(sc, bf, false);
620 /* We could have deleted elements so the list may be empty now */
621 @@ -1118,12 +1120,12 @@ requeue_drop_frag:
623 list_add_tail(&bf->list, &sc->rx.rxbuf);
626 - ath_rx_edma_buf_link(sc, qtype);
628 - ath_rx_buf_relink(sc, bf);
630 + ath_rx_buf_relink(sc, bf, flush);
633 + } else if (!flush) {
634 + ath_rx_edma_buf_link(sc, qtype);
638 --- a/net/mac80211/sta_info.c
639 +++ b/net/mac80211/sta_info.c
640 @@ -100,7 +100,8 @@ static void __cleanup_single_sta(struct
643 if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
644 - test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
645 + test_sta_flag(sta, WLAN_STA_PS_DRIVER) ||
646 + test_sta_flag(sta, WLAN_STA_PS_DELIVER)) {
647 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
648 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
649 ps = &sdata->bss->ps;
650 @@ -111,6 +112,7 @@ static void __cleanup_single_sta(struct
652 clear_sta_flag(sta, WLAN_STA_PS_STA);
653 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
654 + clear_sta_flag(sta, WLAN_STA_PS_DELIVER);
656 atomic_dec(&ps->num_sta_ps);
657 sta_info_recalc_tim(sta);
658 @@ -125,7 +127,7 @@ static void __cleanup_single_sta(struct
659 if (ieee80211_vif_is_mesh(&sdata->vif))
660 mesh_sta_cleanup(sta);
662 - cancel_work_sync(&sta->drv_unblock_wk);
663 + cancel_work_sync(&sta->drv_deliver_wk);
666 * Destroy aggregation state here. It would be nice to wait for the
667 @@ -227,6 +229,7 @@ struct sta_info *sta_info_get_by_idx(str
669 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
671 + struct ieee80211_sta_rates *rates;
675 @@ -238,6 +241,10 @@ void sta_info_free(struct ieee80211_loca
679 + rates = rcu_dereference_protected(sta->sta.rates, true);
683 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr);
686 @@ -252,33 +259,23 @@ static void sta_info_hash_add(struct iee
687 rcu_assign_pointer(local->sta_hash[STA_HASH(sta->sta.addr)], sta);
690 -static void sta_unblock(struct work_struct *wk)
691 +static void sta_deliver_ps_frames(struct work_struct *wk)
693 struct sta_info *sta;
695 - sta = container_of(wk, struct sta_info, drv_unblock_wk);
696 + sta = container_of(wk, struct sta_info, drv_deliver_wk);
701 - if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
702 - local_bh_disable();
703 + local_bh_disable();
704 + if (!test_sta_flag(sta, WLAN_STA_PS_STA))
705 ieee80211_sta_ps_deliver_wakeup(sta);
707 - } else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL)) {
708 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
710 - local_bh_disable();
711 + else if (test_and_clear_sta_flag(sta, WLAN_STA_PSPOLL))
712 ieee80211_sta_ps_deliver_poll_response(sta);
714 - } else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD)) {
715 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
717 - local_bh_disable();
718 + else if (test_and_clear_sta_flag(sta, WLAN_STA_UAPSD))
719 ieee80211_sta_ps_deliver_uapsd(sta);
722 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
726 static int sta_prepare_rate_control(struct ieee80211_local *local,
727 @@ -340,7 +337,7 @@ struct sta_info *sta_info_alloc(struct i
729 spin_lock_init(&sta->lock);
730 spin_lock_init(&sta->ps_lock);
731 - INIT_WORK(&sta->drv_unblock_wk, sta_unblock);
732 + INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames);
733 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
734 mutex_init(&sta->ampdu_mlme.mtx);
735 #ifdef CPTCFG_MAC80211_MESH
736 @@ -1101,8 +1098,11 @@ void ieee80211_sta_ps_deliver_wakeup(str
740 - if (sdata->vif.type == NL80211_IFTYPE_AP ||
741 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
742 + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
743 + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
746 + if (sdata->vif.type == NL80211_IFTYPE_AP)
747 ps = &sdata->bss->ps;
748 else if (ieee80211_vif_is_mesh(&sdata->vif))
749 ps = &sdata->u.mesh.ps;
750 @@ -1140,8 +1140,15 @@ void ieee80211_sta_ps_deliver_wakeup(str
753 ieee80211_add_pending_skbs(local, &pending);
754 - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
755 - clear_sta_flag(sta, WLAN_STA_PS_STA);
757 + /* now we're no longer in the deliver code */
758 + clear_sta_flag(sta, WLAN_STA_PS_DELIVER);
760 + /* The station might have polled and then woken up before we responded,
761 + * so clear these flags now to avoid them sticking around.
763 + clear_sta_flag(sta, WLAN_STA_PSPOLL);
764 + clear_sta_flag(sta, WLAN_STA_UAPSD);
765 spin_unlock(&sta->ps_lock);
767 atomic_dec(&ps->num_sta_ps);
768 @@ -1542,10 +1549,26 @@ void ieee80211_sta_block_awake(struct ie
770 trace_api_sta_block_awake(sta->local, pubsta, block);
774 set_sta_flag(sta, WLAN_STA_PS_DRIVER);
775 - else if (test_sta_flag(sta, WLAN_STA_PS_DRIVER))
776 - ieee80211_queue_work(hw, &sta->drv_unblock_wk);
780 + if (!test_sta_flag(sta, WLAN_STA_PS_DRIVER))
783 + if (!test_sta_flag(sta, WLAN_STA_PS_STA)) {
784 + set_sta_flag(sta, WLAN_STA_PS_DELIVER);
785 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
786 + ieee80211_queue_work(hw, &sta->drv_deliver_wk);
787 + } else if (test_sta_flag(sta, WLAN_STA_PSPOLL) ||
788 + test_sta_flag(sta, WLAN_STA_UAPSD)) {
789 + /* must be asleep in this case */
790 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
791 + ieee80211_queue_work(hw, &sta->drv_deliver_wk);
793 + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
796 EXPORT_SYMBOL(ieee80211_sta_block_awake);
798 @@ -1703,3 +1726,140 @@ u8 sta_info_tx_streams(struct sta_info *
799 return ((ht_cap->mcs.tx_params & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK)
800 >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT) + 1;
803 +void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
805 + struct ieee80211_sub_if_data *sdata = sta->sdata;
806 + struct ieee80211_local *local = sdata->local;
807 + struct rate_control_ref *ref = NULL;
808 + struct timespec uptime;
813 + if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
814 + ref = local->rate_ctrl;
816 + sinfo->generation = sdata->local->sta_generation;
818 + sinfo->filled = STATION_INFO_INACTIVE_TIME |
819 + STATION_INFO_RX_BYTES64 |
820 + STATION_INFO_TX_BYTES64 |
821 + STATION_INFO_RX_PACKETS |
822 + STATION_INFO_TX_PACKETS |
823 + STATION_INFO_TX_RETRIES |
824 + STATION_INFO_TX_FAILED |
825 + STATION_INFO_TX_BITRATE |
826 + STATION_INFO_RX_BITRATE |
827 + STATION_INFO_RX_DROP_MISC |
828 + STATION_INFO_BSS_PARAM |
829 + STATION_INFO_CONNECTED_TIME |
830 + STATION_INFO_STA_FLAGS |
831 + STATION_INFO_BEACON_LOSS_COUNT;
833 + do_posix_clock_monotonic_gettime(&uptime);
834 + sinfo->connected_time = uptime.tv_sec - sta->last_connected;
836 + sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
837 + sinfo->tx_bytes = 0;
838 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
839 + sinfo->tx_bytes += sta->tx_bytes[ac];
840 + packets += sta->tx_packets[ac];
842 + sinfo->tx_packets = packets;
843 + sinfo->rx_bytes = sta->rx_bytes;
844 + sinfo->rx_packets = sta->rx_packets;
845 + sinfo->tx_retries = sta->tx_retry_count;
846 + sinfo->tx_failed = sta->tx_retry_failed;
847 + sinfo->rx_dropped_misc = sta->rx_dropped;
848 + sinfo->beacon_loss_count = sta->beacon_loss_count;
850 + if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
851 + (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
852 + sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
853 + if (!local->ops->get_rssi ||
854 + drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal))
855 + sinfo->signal = (s8)sta->last_signal;
856 + sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
859 + sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
860 + STATION_INFO_CHAIN_SIGNAL_AVG;
862 + sinfo->chains = sta->chains;
863 + for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
864 + sinfo->chain_signal[i] = sta->chain_signal_last[i];
865 + sinfo->chain_signal_avg[i] =
866 + (s8) -ewma_read(&sta->chain_signal_avg[i]);
870 + sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
871 + sta_set_rate_info_rx(sta, &sinfo->rxrate);
873 + if (ieee80211_vif_is_mesh(&sdata->vif)) {
874 +#ifdef CPTCFG_MAC80211_MESH
875 + sinfo->filled |= STATION_INFO_LLID |
876 + STATION_INFO_PLID |
877 + STATION_INFO_PLINK_STATE |
878 + STATION_INFO_LOCAL_PM |
879 + STATION_INFO_PEER_PM |
880 + STATION_INFO_NONPEER_PM;
882 + sinfo->llid = sta->llid;
883 + sinfo->plid = sta->plid;
884 + sinfo->plink_state = sta->plink_state;
885 + if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
886 + sinfo->filled |= STATION_INFO_T_OFFSET;
887 + sinfo->t_offset = sta->t_offset;
889 + sinfo->local_pm = sta->local_pm;
890 + sinfo->peer_pm = sta->peer_pm;
891 + sinfo->nonpeer_pm = sta->nonpeer_pm;
895 + sinfo->bss_param.flags = 0;
896 + if (sdata->vif.bss_conf.use_cts_prot)
897 + sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
898 + if (sdata->vif.bss_conf.use_short_preamble)
899 + sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
900 + if (sdata->vif.bss_conf.use_short_slot)
901 + sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
902 + sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
903 + sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
905 + sinfo->sta_flags.set = 0;
906 + sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
907 + BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
908 + BIT(NL80211_STA_FLAG_WME) |
909 + BIT(NL80211_STA_FLAG_MFP) |
910 + BIT(NL80211_STA_FLAG_AUTHENTICATED) |
911 + BIT(NL80211_STA_FLAG_ASSOCIATED) |
912 + BIT(NL80211_STA_FLAG_TDLS_PEER);
913 + if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
914 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
915 + if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
916 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
917 + if (test_sta_flag(sta, WLAN_STA_WME))
918 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
919 + if (test_sta_flag(sta, WLAN_STA_MFP))
920 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
921 + if (test_sta_flag(sta, WLAN_STA_AUTH))
922 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
923 + if (test_sta_flag(sta, WLAN_STA_ASSOC))
924 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
925 + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
926 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
928 + /* check if the driver has a SW RC implementation */
929 + if (ref && ref->ops->get_expected_throughput)
930 + thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv);
932 + thr = drv_get_expected_throughput(local, &sta->sta);
935 + sinfo->filled |= STATION_INFO_EXPECTED_THROUGHPUT;
936 + sinfo->expected_throughput = thr;
939 --- a/net/mac80211/status.c
940 +++ b/net/mac80211/status.c
941 @@ -541,6 +541,23 @@ static void ieee80211_tx_latency_end_msr
943 #define STA_LOST_PKT_THRESHOLD 50
945 +static void ieee80211_lost_packet(struct sta_info *sta, struct sk_buff *skb)
947 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
949 + /* This packet was aggregated but doesn't carry status info */
950 + if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
951 + !(info->flags & IEEE80211_TX_STAT_AMPDU))
954 + if (++sta->lost_packets < STA_LOST_PKT_THRESHOLD)
957 + cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
958 + sta->lost_packets, GFP_ATOMIC);
959 + sta->lost_packets = 0;
962 void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
964 struct sk_buff *skb2;
965 @@ -680,12 +697,8 @@ void ieee80211_tx_status(struct ieee8021
966 if (info->flags & IEEE80211_TX_STAT_ACK) {
967 if (sta->lost_packets)
968 sta->lost_packets = 0;
969 - } else if (++sta->lost_packets >= STA_LOST_PKT_THRESHOLD) {
970 - cfg80211_cqm_pktloss_notify(sta->sdata->dev,
974 - sta->lost_packets = 0;
976 + ieee80211_lost_packet(sta, skb);
980 --- a/net/mac80211/rx.c
981 +++ b/net/mac80211/rx.c
982 @@ -1107,6 +1107,8 @@ static void sta_ps_end(struct sta_info *
986 + set_sta_flag(sta, WLAN_STA_PS_DELIVER);
987 + clear_sta_flag(sta, WLAN_STA_PS_STA);
988 ieee80211_sta_ps_deliver_wakeup(sta);
991 --- a/net/mac80211/sta_info.h
992 +++ b/net/mac80211/sta_info.h
993 @@ -82,6 +82,7 @@ enum ieee80211_sta_info_flags {
994 WLAN_STA_TOFFSET_KNOWN,
996 WLAN_STA_MPSP_RECIPIENT,
997 + WLAN_STA_PS_DELIVER,
1000 #define ADDBA_RESP_INTERVAL HZ
1001 @@ -265,7 +266,7 @@ struct ieee80211_tx_latency_stat {
1002 * @last_rx_rate_vht_nss: rx status nss of last data packet
1003 * @lock: used for locking all fields that require locking, see comments
1004 * in the header file.
1005 - * @drv_unblock_wk: used for driver PS unblocking
1006 + * @drv_deliver_wk: used for delivering frames after driver PS unblocking
1007 * @listen_interval: listen interval of this station, when we're acting as AP
1008 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
1009 * @ps_lock: used for powersave (when mac80211 is the AP) related locking
1010 @@ -278,7 +279,6 @@ struct ieee80211_tx_latency_stat {
1011 * @driver_buffered_tids: bitmap of TIDs the driver has data buffered on
1012 * @rx_packets: Number of MSDUs received from this STA
1013 * @rx_bytes: Number of bytes received from this STA
1014 - * @wep_weak_iv_count: number of weak WEP IVs received from this station
1015 * @last_rx: time (in jiffies) when last frame was received from this STA
1016 * @last_connected: time (in seconds) when a station got connected
1017 * @num_duplicates: number of duplicate frames received from this STA
1018 @@ -345,7 +345,7 @@ struct sta_info {
1019 void *rate_ctrl_priv;
1022 - struct work_struct drv_unblock_wk;
1023 + struct work_struct drv_deliver_wk;
1025 u16 listen_interval;
1027 @@ -367,7 +367,6 @@ struct sta_info {
1028 /* Updated from RX path only, no locking requirements */
1029 unsigned long rx_packets;
1031 - unsigned long wep_weak_iv_count;
1032 unsigned long last_rx;
1033 long last_connected;
1034 unsigned long num_duplicates;
1035 @@ -628,6 +627,8 @@ void sta_set_rate_info_tx(struct sta_inf
1036 struct rate_info *rinfo);
1037 void sta_set_rate_info_rx(struct sta_info *sta,
1038 struct rate_info *rinfo);
1039 +void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo);
1041 void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata,
1042 unsigned long exp_time);
1043 u8 sta_info_tx_streams(struct sta_info *sta);
1044 --- a/net/mac80211/tx.c
1045 +++ b/net/mac80211/tx.c
1046 @@ -469,7 +469,8 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1049 if (unlikely((test_sta_flag(sta, WLAN_STA_PS_STA) ||
1050 - test_sta_flag(sta, WLAN_STA_PS_DRIVER)) &&
1051 + test_sta_flag(sta, WLAN_STA_PS_DRIVER) ||
1052 + test_sta_flag(sta, WLAN_STA_PS_DELIVER)) &&
1053 !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) {
1054 int ac = skb_get_queue_mapping(tx->skb);
1056 @@ -486,7 +487,8 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
1057 * ahead and Tx the packet.
1059 if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
1060 - !test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1061 + !test_sta_flag(sta, WLAN_STA_PS_DRIVER) &&
1062 + !test_sta_flag(sta, WLAN_STA_PS_DELIVER)) {
1063 spin_unlock(&sta->ps_lock);
1066 @@ -1618,12 +1620,12 @@ netdev_tx_t ieee80211_monitor_start_xmit
1068 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
1069 struct ieee80211_chanctx_conf *chanctx_conf;
1070 - struct ieee80211_channel *chan;
1071 struct ieee80211_radiotap_header *prthdr =
1072 (struct ieee80211_radiotap_header *)skb->data;
1073 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1074 struct ieee80211_hdr *hdr;
1075 struct ieee80211_sub_if_data *tmp_sdata, *sdata;
1076 + struct cfg80211_chan_def *chandef;
1080 @@ -1721,9 +1723,9 @@ netdev_tx_t ieee80211_monitor_start_xmit
1084 - chan = chanctx_conf->def.chan;
1085 + chandef = &chanctx_conf->def;
1086 else if (!local->use_chanctx)
1087 - chan = local->_oper_chandef.chan;
1088 + chandef = &local->_oper_chandef;
1092 @@ -1743,10 +1745,11 @@ netdev_tx_t ieee80211_monitor_start_xmit
1093 * radar detection by itself. We can do that later by adding a
1094 * monitor flag interfaces used for AP support.
1096 - if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)))
1097 + if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef,
1101 - ieee80211_xmit(sdata, skb, chan->band);
1102 + ieee80211_xmit(sdata, skb, chandef->chan->band);
1105 return NETDEV_TX_OK;
1106 @@ -2425,7 +2428,7 @@ static void ieee80211_set_csa(struct iee
1108 size_t beacon_data_len;
1110 - u8 count = sdata->csa_current_counter;
1111 + u8 count = beacon->csa_current_counter;
1113 switch (sdata->vif.type) {
1114 case NL80211_IFTYPE_AP:
1115 @@ -2444,46 +2447,54 @@ static void ieee80211_set_csa(struct iee
1120 for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; ++i) {
1121 - u16 counter_offset_beacon =
1122 - sdata->csa_counter_offset_beacon[i];
1123 - u16 counter_offset_presp = sdata->csa_counter_offset_presp[i];
1125 - if (counter_offset_beacon) {
1126 - if (WARN_ON(counter_offset_beacon >= beacon_data_len))
1129 - beacon_data[counter_offset_beacon] = count;
1132 - if (sdata->vif.type == NL80211_IFTYPE_AP &&
1133 - counter_offset_presp) {
1135 - resp = rcu_dereference(sdata->u.ap.probe_resp);
1136 + resp = rcu_dereference(sdata->u.ap.probe_resp);
1138 - /* If nl80211 accepted the offset, this should
1141 - if (WARN_ON(!resp)) {
1142 + if (beacon->csa_counter_offsets[i]) {
1143 + if (WARN_ON_ONCE(beacon->csa_counter_offsets[i] >=
1144 + beacon_data_len)) {
1148 - resp->data[counter_offset_presp] = count;
1149 - rcu_read_unlock();
1151 + beacon_data[beacon->csa_counter_offsets[i]] = count;
1154 + if (sdata->vif.type == NL80211_IFTYPE_AP && resp &&
1155 + resp->csa_counter_offsets)
1156 + resp->data[resp->csa_counter_offsets[i]] = count;
1158 + rcu_read_unlock();
1161 u8 ieee80211_csa_update_counter(struct ieee80211_vif *vif)
1163 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
1164 + struct beacon_data *beacon = NULL;
1169 + if (sdata->vif.type == NL80211_IFTYPE_AP)
1170 + beacon = rcu_dereference(sdata->u.ap.beacon);
1171 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
1172 + beacon = rcu_dereference(sdata->u.ibss.presp);
1173 + else if (ieee80211_vif_is_mesh(&sdata->vif))
1174 + beacon = rcu_dereference(sdata->u.mesh.beacon);
1179 - sdata->csa_current_counter--;
1180 + beacon->csa_current_counter--;
1182 /* the counter should never reach 0 */
1183 - WARN_ON(!sdata->csa_current_counter);
1184 + WARN_ON_ONCE(!beacon->csa_current_counter);
1185 + count = beacon->csa_current_counter;
1187 - return sdata->csa_current_counter;
1189 + rcu_read_unlock();
1192 EXPORT_SYMBOL(ieee80211_csa_update_counter);
1194 @@ -2493,7 +2504,6 @@ bool ieee80211_csa_is_complete(struct ie
1195 struct beacon_data *beacon = NULL;
1197 size_t beacon_data_len;
1198 - int counter_beacon = sdata->csa_counter_offset_beacon[0];
1201 if (!ieee80211_sdata_running(sdata))
1202 @@ -2531,10 +2541,13 @@ bool ieee80211_csa_is_complete(struct ie
1206 - if (WARN_ON(counter_beacon > beacon_data_len))
1207 + if (!beacon->csa_counter_offsets[0])
1210 + if (WARN_ON_ONCE(beacon->csa_counter_offsets[0] > beacon_data_len))
1213 - if (beacon_data[counter_beacon] == 1)
1214 + if (beacon_data[beacon->csa_counter_offsets[0]] == 1)
1218 @@ -2550,6 +2563,7 @@ __ieee80211_beacon_get(struct ieee80211_
1221 struct ieee80211_local *local = hw_to_local(hw);
1222 + struct beacon_data *beacon = NULL;
1223 struct sk_buff *skb = NULL;
1224 struct ieee80211_tx_info *info;
1225 struct ieee80211_sub_if_data *sdata = NULL;
1226 @@ -2571,10 +2585,10 @@ __ieee80211_beacon_get(struct ieee80211_
1228 if (sdata->vif.type == NL80211_IFTYPE_AP) {
1229 struct ieee80211_if_ap *ap = &sdata->u.ap;
1230 - struct beacon_data *beacon = rcu_dereference(ap->beacon);
1232 + beacon = rcu_dereference(ap->beacon);
1234 - if (sdata->vif.csa_active) {
1235 + if (beacon->csa_counter_offsets[0]) {
1237 ieee80211_csa_update_counter(vif);
1239 @@ -2615,37 +2629,37 @@ __ieee80211_beacon_get(struct ieee80211_
1240 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
1241 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
1242 struct ieee80211_hdr *hdr;
1243 - struct beacon_data *presp = rcu_dereference(ifibss->presp);
1246 + beacon = rcu_dereference(ifibss->presp);
1250 - if (sdata->vif.csa_active) {
1251 + if (beacon->csa_counter_offsets[0]) {
1253 ieee80211_csa_update_counter(vif);
1255 - ieee80211_set_csa(sdata, presp);
1256 + ieee80211_set_csa(sdata, beacon);
1259 - skb = dev_alloc_skb(local->tx_headroom + presp->head_len +
1260 + skb = dev_alloc_skb(local->tx_headroom + beacon->head_len +
1261 local->hw.extra_beacon_tailroom);
1264 skb_reserve(skb, local->tx_headroom);
1265 - memcpy(skb_put(skb, presp->head_len), presp->head,
1267 + memcpy(skb_put(skb, beacon->head_len), beacon->head,
1268 + beacon->head_len);
1270 hdr = (struct ieee80211_hdr *) skb->data;
1271 hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1272 IEEE80211_STYPE_BEACON);
1273 } else if (ieee80211_vif_is_mesh(&sdata->vif)) {
1274 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1275 - struct beacon_data *bcn = rcu_dereference(ifmsh->beacon);
1278 + beacon = rcu_dereference(ifmsh->beacon);
1282 - if (sdata->vif.csa_active) {
1283 + if (beacon->csa_counter_offsets[0]) {
1285 /* TODO: For mesh csa_counter is in TU, so
1286 * decrementing it by one isn't correct, but
1287 @@ -2654,40 +2668,42 @@ __ieee80211_beacon_get(struct ieee80211_
1289 ieee80211_csa_update_counter(vif);
1291 - ieee80211_set_csa(sdata, bcn);
1292 + ieee80211_set_csa(sdata, beacon);
1295 if (ifmsh->sync_ops)
1296 - ifmsh->sync_ops->adjust_tbtt(sdata, bcn);
1297 + ifmsh->sync_ops->adjust_tbtt(sdata, beacon);
1299 skb = dev_alloc_skb(local->tx_headroom +
1301 + beacon->head_len +
1304 + beacon->tail_len +
1305 local->hw.extra_beacon_tailroom);
1308 skb_reserve(skb, local->tx_headroom);
1309 - memcpy(skb_put(skb, bcn->head_len), bcn->head, bcn->head_len);
1310 + memcpy(skb_put(skb, beacon->head_len), beacon->head,
1311 + beacon->head_len);
1312 ieee80211_beacon_add_tim(sdata, &ifmsh->ps, skb, is_template);
1315 - offs->tim_offset = bcn->head_len;
1316 - offs->tim_length = skb->len - bcn->head_len;
1317 + offs->tim_offset = beacon->head_len;
1318 + offs->tim_length = skb->len - beacon->head_len;
1321 - memcpy(skb_put(skb, bcn->tail_len), bcn->tail, bcn->tail_len);
1322 + memcpy(skb_put(skb, beacon->tail_len), beacon->tail,
1323 + beacon->tail_len);
1331 + if (offs && beacon) {
1334 for (i = 0; i < IEEE80211_MAX_CSA_COUNTERS_NUM; i++) {
1335 - u16 csa_off = sdata->csa_counter_offset_beacon[i];
1336 + u16 csa_off = beacon->csa_counter_offsets[i];
1340 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
1341 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1342 @@ -947,6 +947,40 @@ static inline u8 rt2800_get_beacon_offse
1343 return BEACON_BASE_TO_OFFSET(rt2800_hw_beacon_base(rt2x00dev, index));
1346 +static void rt2800_update_beacons_setup(struct rt2x00_dev *rt2x00dev)
1348 + struct data_queue *queue = rt2x00dev->bcn;
1349 + struct queue_entry *entry;
1350 + int i, bcn_num = 0;
1355 + * Setup offsets of all active beacons in BCN_OFFSET{0,1} registers.
1357 + for (i = 0; i < queue->limit; i++) {
1358 + entry = &queue->entries[i];
1359 + if (!test_bit(ENTRY_BCN_ENABLED, &entry->flags))
1361 + off = rt2800_get_beacon_offset(rt2x00dev, entry->entry_idx);
1362 + reg |= off << (8 * bcn_num);
1366 + WARN_ON_ONCE(bcn_num != rt2x00dev->intf_beaconing);
1368 + rt2800_register_write(rt2x00dev, BCN_OFFSET0, (u32) reg);
1369 + rt2800_register_write(rt2x00dev, BCN_OFFSET1, (u32) (reg >> 32));
1372 + * H/W sends up to MAC_BSSID_DW1_BSS_BCN_NUM + 1 consecutive beacons.
1374 + rt2800_register_read(rt2x00dev, MAC_BSSID_DW1, &bssid_dw1);
1375 + rt2x00_set_field32(&bssid_dw1, MAC_BSSID_DW1_BSS_BCN_NUM,
1376 + bcn_num > 0 ? bcn_num - 1 : 0);
1377 + rt2800_register_write(rt2x00dev, MAC_BSSID_DW1, bssid_dw1);
1380 void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
1382 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1383 @@ -1003,6 +1037,12 @@ void rt2800_write_beacon(struct queue_en
1385 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
1386 entry->skb->len + padding_len);
1387 + __set_bit(ENTRY_BCN_ENABLED, &entry->flags);
1390 + * Change global beacons settings.
1392 + rt2800_update_beacons_setup(rt2x00dev);
1395 * Restore beaconing state.
1396 @@ -1053,8 +1093,13 @@ void rt2800_clear_beacon(struct queue_en
1399 rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx);
1400 + __clear_bit(ENTRY_BCN_ENABLED, &entry->flags);
1403 + * Change global beacons settings.
1405 + rt2800_update_beacons_setup(rt2x00dev);
1407 * Restore beaconing state.
1409 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, orig_reg);
1410 @@ -1556,7 +1601,7 @@ void rt2800_config_intf(struct rt2x00_de
1411 if (!is_zero_ether_addr((const u8 *)conf->bssid)) {
1412 reg = le32_to_cpu(conf->bssid[1]);
1413 rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_ID_MASK, 3);
1414 - rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_BCN_NUM, 7);
1415 + rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_BCN_NUM, 0);
1416 conf->bssid[1] = cpu_to_le32(reg);
1419 @@ -4517,28 +4562,6 @@ static int rt2800_init_registers(struct
1423 - rt2800_register_read(rt2x00dev, BCN_OFFSET0, ®);
1424 - rt2x00_set_field32(®, BCN_OFFSET0_BCN0,
1425 - rt2800_get_beacon_offset(rt2x00dev, 0));
1426 - rt2x00_set_field32(®, BCN_OFFSET0_BCN1,
1427 - rt2800_get_beacon_offset(rt2x00dev, 1));
1428 - rt2x00_set_field32(®, BCN_OFFSET0_BCN2,
1429 - rt2800_get_beacon_offset(rt2x00dev, 2));
1430 - rt2x00_set_field32(®, BCN_OFFSET0_BCN3,
1431 - rt2800_get_beacon_offset(rt2x00dev, 3));
1432 - rt2800_register_write(rt2x00dev, BCN_OFFSET0, reg);
1434 - rt2800_register_read(rt2x00dev, BCN_OFFSET1, ®);
1435 - rt2x00_set_field32(®, BCN_OFFSET1_BCN4,
1436 - rt2800_get_beacon_offset(rt2x00dev, 4));
1437 - rt2x00_set_field32(®, BCN_OFFSET1_BCN5,
1438 - rt2800_get_beacon_offset(rt2x00dev, 5));
1439 - rt2x00_set_field32(®, BCN_OFFSET1_BCN6,
1440 - rt2800_get_beacon_offset(rt2x00dev, 6));
1441 - rt2x00_set_field32(®, BCN_OFFSET1_BCN7,
1442 - rt2800_get_beacon_offset(rt2x00dev, 7));
1443 - rt2800_register_write(rt2x00dev, BCN_OFFSET1, reg);
1445 rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f);
1446 rt2800_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
1448 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
1449 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
1450 @@ -141,8 +141,11 @@ static void rt2x00lib_intf_scheduled_ite
1451 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
1454 - if (test_and_clear_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags))
1455 + if (test_and_clear_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags)) {
1456 + mutex_lock(&intf->beacon_skb_mutex);
1457 rt2x00queue_update_beacon(rt2x00dev, vif);
1458 + mutex_unlock(&intf->beacon_skb_mutex);
1462 static void rt2x00lib_intf_scheduled(struct work_struct *work)
1463 @@ -216,7 +219,7 @@ static void rt2x00lib_beaconupdate_iter(
1464 * never be called for USB devices.
1466 WARN_ON(rt2x00_is_usb(rt2x00dev));
1467 - rt2x00queue_update_beacon_locked(rt2x00dev, vif);
1468 + rt2x00queue_update_beacon(rt2x00dev, vif);
1471 void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev)
1472 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
1473 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
1474 @@ -487,6 +487,8 @@ int rt2x00mac_set_key(struct ieee80211_h
1475 crypto.cipher = rt2x00crypto_key_to_cipher(key);
1476 if (crypto.cipher == CIPHER_NONE)
1478 + if (crypto.cipher == CIPHER_TKIP && rt2x00_is_usb(rt2x00dev))
1479 + return -EOPNOTSUPP;
1483 @@ -624,25 +626,24 @@ void rt2x00mac_bss_info_changed(struct i
1484 * Start/stop beaconing.
1486 if (changes & BSS_CHANGED_BEACON_ENABLED) {
1487 + mutex_lock(&intf->beacon_skb_mutex);
1488 if (!bss_conf->enable_beacon && intf->enable_beacon) {
1489 rt2x00dev->intf_beaconing--;
1490 intf->enable_beacon = false;
1492 - * Clear beacon in the H/W for this vif. This is needed
1493 - * to disable beaconing on this particular interface
1494 - * and keep it running on other interfaces.
1496 - rt2x00queue_clear_beacon(rt2x00dev, vif);
1498 if (rt2x00dev->intf_beaconing == 0) {
1500 * Last beaconing interface disabled
1501 * -> stop beacon queue.
1503 - mutex_lock(&intf->beacon_skb_mutex);
1504 rt2x00queue_stop_queue(rt2x00dev->bcn);
1505 - mutex_unlock(&intf->beacon_skb_mutex);
1508 + * Clear beacon in the H/W for this vif. This is needed
1509 + * to disable beaconing on this particular interface
1510 + * and keep it running on other interfaces.
1512 + rt2x00queue_clear_beacon(rt2x00dev, vif);
1513 } else if (bss_conf->enable_beacon && !intf->enable_beacon) {
1514 rt2x00dev->intf_beaconing++;
1515 intf->enable_beacon = true;
1516 @@ -658,11 +659,10 @@ void rt2x00mac_bss_info_changed(struct i
1517 * First beaconing interface enabled
1518 * -> start beacon queue.
1520 - mutex_lock(&intf->beacon_skb_mutex);
1521 rt2x00queue_start_queue(rt2x00dev->bcn);
1522 - mutex_unlock(&intf->beacon_skb_mutex);
1525 + mutex_unlock(&intf->beacon_skb_mutex);
1529 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
1530 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
1531 @@ -754,8 +754,6 @@ int rt2x00queue_clear_beacon(struct rt2x
1532 if (unlikely(!intf->beacon))
1535 - mutex_lock(&intf->beacon_skb_mutex);
1538 * Clean up the beacon skb.
1540 @@ -768,13 +766,11 @@ int rt2x00queue_clear_beacon(struct rt2x
1541 if (rt2x00dev->ops->lib->clear_beacon)
1542 rt2x00dev->ops->lib->clear_beacon(intf->beacon);
1544 - mutex_unlock(&intf->beacon_skb_mutex);
1549 -int rt2x00queue_update_beacon_locked(struct rt2x00_dev *rt2x00dev,
1550 - struct ieee80211_vif *vif)
1551 +int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
1552 + struct ieee80211_vif *vif)
1554 struct rt2x00_intf *intf = vif_to_intf(vif);
1555 struct skb_frame_desc *skbdesc;
1556 @@ -815,19 +811,6 @@ int rt2x00queue_update_beacon_locked(str
1560 -int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
1561 - struct ieee80211_vif *vif)
1563 - struct rt2x00_intf *intf = vif_to_intf(vif);
1566 - mutex_lock(&intf->beacon_skb_mutex);
1567 - ret = rt2x00queue_update_beacon_locked(rt2x00dev, vif);
1568 - mutex_unlock(&intf->beacon_skb_mutex);
1573 bool rt2x00queue_for_each_entry(struct data_queue *queue,
1574 enum queue_index start,
1575 enum queue_index end,
1576 --- a/drivers/net/wireless/rt2x00/rt2x00queue.h
1577 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.h
1578 @@ -353,6 +353,7 @@ struct txentry_desc {
1580 enum queue_entry_flags {
1582 + ENTRY_BCN_ENABLED,
1583 ENTRY_OWNER_DEVICE_DATA,
1585 ENTRY_DATA_IO_FAILED,
1586 --- a/drivers/net/wireless/ath/ath9k/main.c
1587 +++ b/drivers/net/wireless/ath/ath9k/main.c
1588 @@ -1757,7 +1757,6 @@ out:
1589 void ath9k_update_p2p_ps(struct ath_softc *sc, struct ieee80211_vif *vif)
1591 struct ath_vif *avp = (void *)vif->drv_priv;
1592 - unsigned long flags;
1595 if (!sc->p2p_ps_timer)
1596 @@ -1767,14 +1766,9 @@ void ath9k_update_p2p_ps(struct ath_soft
1599 sc->p2p_ps_vif = avp;
1601 - spin_lock_irqsave(&sc->sc_pm_lock, flags);
1602 - if (!(sc->ps_flags & PS_BEACON_SYNC)) {
1603 - tsf = ath9k_hw_gettsf32(sc->sc_ah);
1604 - ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
1605 - ath9k_update_p2p_ps_timer(sc, avp);
1607 - spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1608 + tsf = ath9k_hw_gettsf32(sc->sc_ah);
1609 + ieee80211_parse_p2p_noa(&vif->bss_conf.p2p_noa_attr, &avp->noa, tsf);
1610 + ath9k_update_p2p_ps_timer(sc, avp);
1613 static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
1614 @@ -1791,6 +1785,7 @@ static void ath9k_bss_info_changed(struc
1615 struct ath_hw *ah = sc->sc_ah;
1616 struct ath_common *common = ath9k_hw_common(ah);
1617 struct ath_vif *avp = (void *)vif->drv_priv;
1618 + unsigned long flags;
1621 ath9k_ps_wakeup(sc);
1622 @@ -1853,7 +1848,10 @@ static void ath9k_bss_info_changed(struc
1624 if (changed & BSS_CHANGED_P2P_PS) {
1625 spin_lock_bh(&sc->sc_pcu_lock);
1626 - ath9k_update_p2p_ps(sc, vif);
1627 + spin_lock_irqsave(&sc->sc_pm_lock, flags);
1628 + if (!(sc->ps_flags & PS_BEACON_SYNC))
1629 + ath9k_update_p2p_ps(sc, vif);
1630 + spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
1631 spin_unlock_bh(&sc->sc_pcu_lock);
1634 @@ -2232,14 +2230,6 @@ static void ath9k_sw_scan_complete(struc
1635 clear_bit(ATH_OP_SCANNING, &common->op_flags);
1638 -static void ath9k_channel_switch_beacon(struct ieee80211_hw *hw,
1639 - struct ieee80211_vif *vif,
1640 - struct cfg80211_chan_def *chandef)
1642 - /* depend on vif->csa_active only */
1646 struct ieee80211_ops ath9k_ops = {
1648 .start = ath9k_start,
1649 @@ -2287,5 +2277,4 @@ struct ieee80211_ops ath9k_ops = {
1651 .sw_scan_start = ath9k_sw_scan_start,
1652 .sw_scan_complete = ath9k_sw_scan_complete,
1653 - .channel_switch_beacon = ath9k_channel_switch_beacon,
1655 --- a/drivers/net/wireless/ath/ath10k/mac.c
1656 +++ b/drivers/net/wireless/ath/ath10k/mac.c
1657 @@ -4142,14 +4142,6 @@ static int ath10k_set_bitrate_mask(struc
1658 fixed_nss, force_sgi);
1661 -static void ath10k_channel_switch_beacon(struct ieee80211_hw *hw,
1662 - struct ieee80211_vif *vif,
1663 - struct cfg80211_chan_def *chandef)
1665 - /* there's no need to do anything here. vif->csa_active is enough */
1669 static void ath10k_sta_rc_update(struct ieee80211_hw *hw,
1670 struct ieee80211_vif *vif,
1671 struct ieee80211_sta *sta,
1672 @@ -4256,7 +4248,6 @@ static const struct ieee80211_ops ath10k
1673 .restart_complete = ath10k_restart_complete,
1674 .get_survey = ath10k_get_survey,
1675 .set_bitrate_mask = ath10k_set_bitrate_mask,
1676 - .channel_switch_beacon = ath10k_channel_switch_beacon,
1677 .sta_rc_update = ath10k_sta_rc_update,
1678 .get_tsf = ath10k_get_tsf,
1680 --- a/net/mac80211/cfg.c
1681 +++ b/net/mac80211/cfg.c
1682 @@ -468,327 +468,6 @@ void sta_set_rate_info_rx(struct sta_inf
1683 rinfo->flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH;
1686 -static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
1688 - struct ieee80211_sub_if_data *sdata = sta->sdata;
1689 - struct ieee80211_local *local = sdata->local;
1690 - struct rate_control_ref *ref = local->rate_ctrl;
1691 - struct timespec uptime;
1696 - sinfo->generation = sdata->local->sta_generation;
1698 - sinfo->filled = STATION_INFO_INACTIVE_TIME |
1699 - STATION_INFO_RX_BYTES64 |
1700 - STATION_INFO_TX_BYTES64 |
1701 - STATION_INFO_RX_PACKETS |
1702 - STATION_INFO_TX_PACKETS |
1703 - STATION_INFO_TX_RETRIES |
1704 - STATION_INFO_TX_FAILED |
1705 - STATION_INFO_TX_BITRATE |
1706 - STATION_INFO_RX_BITRATE |
1707 - STATION_INFO_RX_DROP_MISC |
1708 - STATION_INFO_BSS_PARAM |
1709 - STATION_INFO_CONNECTED_TIME |
1710 - STATION_INFO_STA_FLAGS |
1711 - STATION_INFO_BEACON_LOSS_COUNT;
1713 - do_posix_clock_monotonic_gettime(&uptime);
1714 - sinfo->connected_time = uptime.tv_sec - sta->last_connected;
1716 - sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
1717 - sinfo->tx_bytes = 0;
1718 - for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1719 - sinfo->tx_bytes += sta->tx_bytes[ac];
1720 - packets += sta->tx_packets[ac];
1722 - sinfo->tx_packets = packets;
1723 - sinfo->rx_bytes = sta->rx_bytes;
1724 - sinfo->rx_packets = sta->rx_packets;
1725 - sinfo->tx_retries = sta->tx_retry_count;
1726 - sinfo->tx_failed = sta->tx_retry_failed;
1727 - sinfo->rx_dropped_misc = sta->rx_dropped;
1728 - sinfo->beacon_loss_count = sta->beacon_loss_count;
1730 - if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
1731 - (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
1732 - sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
1733 - if (!local->ops->get_rssi ||
1734 - drv_get_rssi(local, sdata, &sta->sta, &sinfo->signal))
1735 - sinfo->signal = (s8)sta->last_signal;
1736 - sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
1738 - if (sta->chains) {
1739 - sinfo->filled |= STATION_INFO_CHAIN_SIGNAL |
1740 - STATION_INFO_CHAIN_SIGNAL_AVG;
1742 - sinfo->chains = sta->chains;
1743 - for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
1744 - sinfo->chain_signal[i] = sta->chain_signal_last[i];
1745 - sinfo->chain_signal_avg[i] =
1746 - (s8) -ewma_read(&sta->chain_signal_avg[i]);
1750 - sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
1751 - sta_set_rate_info_rx(sta, &sinfo->rxrate);
1753 - if (ieee80211_vif_is_mesh(&sdata->vif)) {
1754 -#ifdef CPTCFG_MAC80211_MESH
1755 - sinfo->filled |= STATION_INFO_LLID |
1756 - STATION_INFO_PLID |
1757 - STATION_INFO_PLINK_STATE |
1758 - STATION_INFO_LOCAL_PM |
1759 - STATION_INFO_PEER_PM |
1760 - STATION_INFO_NONPEER_PM;
1762 - sinfo->llid = sta->llid;
1763 - sinfo->plid = sta->plid;
1764 - sinfo->plink_state = sta->plink_state;
1765 - if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
1766 - sinfo->filled |= STATION_INFO_T_OFFSET;
1767 - sinfo->t_offset = sta->t_offset;
1769 - sinfo->local_pm = sta->local_pm;
1770 - sinfo->peer_pm = sta->peer_pm;
1771 - sinfo->nonpeer_pm = sta->nonpeer_pm;
1775 - sinfo->bss_param.flags = 0;
1776 - if (sdata->vif.bss_conf.use_cts_prot)
1777 - sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
1778 - if (sdata->vif.bss_conf.use_short_preamble)
1779 - sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
1780 - if (sdata->vif.bss_conf.use_short_slot)
1781 - sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
1782 - sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
1783 - sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
1785 - sinfo->sta_flags.set = 0;
1786 - sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
1787 - BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
1788 - BIT(NL80211_STA_FLAG_WME) |
1789 - BIT(NL80211_STA_FLAG_MFP) |
1790 - BIT(NL80211_STA_FLAG_AUTHENTICATED) |
1791 - BIT(NL80211_STA_FLAG_ASSOCIATED) |
1792 - BIT(NL80211_STA_FLAG_TDLS_PEER);
1793 - if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
1794 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
1795 - if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
1796 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
1797 - if (test_sta_flag(sta, WLAN_STA_WME))
1798 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
1799 - if (test_sta_flag(sta, WLAN_STA_MFP))
1800 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
1801 - if (test_sta_flag(sta, WLAN_STA_AUTH))
1802 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
1803 - if (test_sta_flag(sta, WLAN_STA_ASSOC))
1804 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_ASSOCIATED);
1805 - if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
1806 - sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
1808 - /* check if the driver has a SW RC implementation */
1809 - if (ref && ref->ops->get_expected_throughput)
1810 - thr = ref->ops->get_expected_throughput(sta->rate_ctrl_priv);
1812 - thr = drv_get_expected_throughput(local, &sta->sta);
1815 - sinfo->filled |= STATION_INFO_EXPECTED_THROUGHPUT;
1816 - sinfo->expected_throughput = thr;
1820 -static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
1821 - "rx_packets", "rx_bytes", "wep_weak_iv_count",
1822 - "rx_duplicates", "rx_fragments", "rx_dropped",
1823 - "tx_packets", "tx_bytes", "tx_fragments",
1824 - "tx_filtered", "tx_retry_failed", "tx_retries",
1825 - "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
1826 - "channel", "noise", "ch_time", "ch_time_busy",
1827 - "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
1829 -#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
1831 -static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
1832 - struct net_device *dev,
1835 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1838 - if (sset == ETH_SS_STATS)
1839 - rv += STA_STATS_LEN;
1841 - rv += drv_get_et_sset_count(sdata, sset);
1844 - return -EOPNOTSUPP;
1848 -static void ieee80211_get_et_stats(struct wiphy *wiphy,
1849 - struct net_device *dev,
1850 - struct ethtool_stats *stats,
1853 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1854 - struct ieee80211_chanctx_conf *chanctx_conf;
1855 - struct ieee80211_channel *channel;
1856 - struct sta_info *sta;
1857 - struct ieee80211_local *local = sdata->local;
1858 - struct station_info sinfo;
1859 - struct survey_info survey;
1861 -#define STA_STATS_SURVEY_LEN 7
1863 - memset(data, 0, sizeof(u64) * STA_STATS_LEN);
1865 -#define ADD_STA_STATS(sta) \
1867 - data[i++] += sta->rx_packets; \
1868 - data[i++] += sta->rx_bytes; \
1869 - data[i++] += sta->wep_weak_iv_count; \
1870 - data[i++] += sta->num_duplicates; \
1871 - data[i++] += sta->rx_fragments; \
1872 - data[i++] += sta->rx_dropped; \
1874 - data[i++] += sinfo.tx_packets; \
1875 - data[i++] += sinfo.tx_bytes; \
1876 - data[i++] += sta->tx_fragments; \
1877 - data[i++] += sta->tx_filtered_count; \
1878 - data[i++] += sta->tx_retry_failed; \
1879 - data[i++] += sta->tx_retry_count; \
1880 - data[i++] += sta->beacon_loss_count; \
1883 - /* For Managed stations, find the single station based on BSSID
1884 - * and use that. For interface types, iterate through all available
1885 - * stations and add stats for any station that is assigned to this
1889 - mutex_lock(&local->sta_mtx);
1891 - if (sdata->vif.type == NL80211_IFTYPE_STATION) {
1892 - sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
1894 - if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
1898 - sta_set_sinfo(sta, &sinfo);
1901 - ADD_STA_STATS(sta);
1903 - data[i++] = sta->sta_state;
1906 - if (sinfo.filled & STATION_INFO_TX_BITRATE)
1907 - data[i] = 100000 *
1908 - cfg80211_calculate_bitrate(&sinfo.txrate);
1910 - if (sinfo.filled & STATION_INFO_RX_BITRATE)
1911 - data[i] = 100000 *
1912 - cfg80211_calculate_bitrate(&sinfo.rxrate);
1915 - if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
1916 - data[i] = (u8)sinfo.signal_avg;
1919 - list_for_each_entry(sta, &local->sta_list, list) {
1920 - /* Make sure this station belongs to the proper dev */
1921 - if (sta->sdata->dev != dev)
1925 - sta_set_sinfo(sta, &sinfo);
1927 - ADD_STA_STATS(sta);
1932 - i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
1933 - /* Get survey stats for current channel */
1934 - survey.filled = 0;
1937 - chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
1939 - channel = chanctx_conf->def.chan;
1942 - rcu_read_unlock();
1947 - survey.filled = 0;
1948 - if (drv_get_survey(local, q, &survey) != 0) {
1949 - survey.filled = 0;
1953 - } while (channel != survey.channel);
1956 - if (survey.filled)
1957 - data[i++] = survey.channel->center_freq;
1960 - if (survey.filled & SURVEY_INFO_NOISE_DBM)
1961 - data[i++] = (u8)survey.noise;
1964 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
1965 - data[i++] = survey.channel_time;
1968 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
1969 - data[i++] = survey.channel_time_busy;
1972 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
1973 - data[i++] = survey.channel_time_ext_busy;
1976 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
1977 - data[i++] = survey.channel_time_rx;
1980 - if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
1981 - data[i++] = survey.channel_time_tx;
1985 - mutex_unlock(&local->sta_mtx);
1987 - if (WARN_ON(i != STA_STATS_LEN))
1990 - drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
1993 -static void ieee80211_get_et_strings(struct wiphy *wiphy,
1994 - struct net_device *dev,
1995 - u32 sset, u8 *data)
1997 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1998 - int sz_sta_stats = 0;
2000 - if (sset == ETH_SS_STATS) {
2001 - sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
2002 - memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
2004 - drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
2007 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
2008 int idx, u8 *mac, struct station_info *sinfo)
2010 @@ -875,7 +554,8 @@ static int ieee80211_set_monitor_channel
2013 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
2014 - const u8 *resp, size_t resp_len)
2015 + const u8 *resp, size_t resp_len,
2016 + const struct ieee80211_csa_settings *csa)
2018 struct probe_resp *new, *old;
2020 @@ -891,6 +571,11 @@ static int ieee80211_set_probe_resp(stru
2021 new->len = resp_len;
2022 memcpy(new->data, resp, resp_len);
2025 + memcpy(new->csa_counter_offsets, csa->counter_offsets_presp,
2026 + csa->n_counter_offsets_presp *
2027 + sizeof(new->csa_counter_offsets[0]));
2029 rcu_assign_pointer(sdata->u.ap.probe_resp, new);
2031 kfree_rcu(old, rcu_head);
2032 @@ -899,7 +584,8 @@ static int ieee80211_set_probe_resp(stru
2035 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
2036 - struct cfg80211_beacon_data *params)
2037 + struct cfg80211_beacon_data *params,
2038 + const struct ieee80211_csa_settings *csa)
2040 struct beacon_data *new, *old;
2041 int new_head_len, new_tail_len;
2042 @@ -943,6 +629,13 @@ static int ieee80211_assign_beacon(struc
2043 new->head_len = new_head_len;
2044 new->tail_len = new_tail_len;
2047 + new->csa_current_counter = csa->count;
2048 + memcpy(new->csa_counter_offsets, csa->counter_offsets_beacon,
2049 + csa->n_counter_offsets_beacon *
2050 + sizeof(new->csa_counter_offsets[0]));
2055 memcpy(new->head, params->head, new_head_len);
2056 @@ -957,7 +650,7 @@ static int ieee80211_assign_beacon(struc
2057 memcpy(new->tail, old->tail, new_tail_len);
2059 err = ieee80211_set_probe_resp(sdata, params->probe_resp,
2060 - params->probe_resp_len);
2061 + params->probe_resp_len, csa);
2065 @@ -1042,7 +735,7 @@ static int ieee80211_start_ap(struct wip
2066 sdata->vif.bss_conf.p2p_noa_attr.oppps_ctwindow |=
2067 IEEE80211_P2P_OPPPS_ENABLE_BIT;
2069 - err = ieee80211_assign_beacon(sdata, ¶ms->beacon);
2070 + err = ieee80211_assign_beacon(sdata, ¶ms->beacon, NULL);
2072 ieee80211_vif_release_channel(sdata);
2074 @@ -1090,7 +783,7 @@ static int ieee80211_change_beacon(struc
2078 - err = ieee80211_assign_beacon(sdata, params);
2079 + err = ieee80211_assign_beacon(sdata, params, NULL);
2082 ieee80211_bss_info_change_notify(sdata, err);
2083 @@ -3073,7 +2766,8 @@ static int ieee80211_set_after_csa_beaco
2085 switch (sdata->vif.type) {
2086 case NL80211_IFTYPE_AP:
2087 - err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
2088 + err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon,
2090 kfree(sdata->u.ap.next_beacon);
2091 sdata->u.ap.next_beacon = NULL;
2093 @@ -3176,6 +2870,7 @@ static int ieee80211_set_csa_beacon(stru
2094 struct cfg80211_csa_settings *params,
2097 + struct ieee80211_csa_settings csa = {};
2100 switch (sdata->vif.type) {
2101 @@ -3210,20 +2905,13 @@ static int ieee80211_set_csa_beacon(stru
2102 IEEE80211_MAX_CSA_COUNTERS_NUM))
2105 - /* make sure we don't have garbage in other counters */
2106 - memset(sdata->csa_counter_offset_beacon, 0,
2107 - sizeof(sdata->csa_counter_offset_beacon));
2108 - memset(sdata->csa_counter_offset_presp, 0,
2109 - sizeof(sdata->csa_counter_offset_presp));
2111 - memcpy(sdata->csa_counter_offset_beacon,
2112 - params->counter_offsets_beacon,
2113 - params->n_counter_offsets_beacon * sizeof(u16));
2114 - memcpy(sdata->csa_counter_offset_presp,
2115 - params->counter_offsets_presp,
2116 - params->n_counter_offsets_presp * sizeof(u16));
2117 + csa.counter_offsets_beacon = params->counter_offsets_beacon;
2118 + csa.counter_offsets_presp = params->counter_offsets_presp;
2119 + csa.n_counter_offsets_beacon = params->n_counter_offsets_beacon;
2120 + csa.n_counter_offsets_presp = params->n_counter_offsets_presp;
2121 + csa.count = params->count;
2123 - err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa);
2124 + err = ieee80211_assign_beacon(sdata, ¶ms->beacon_csa, &csa);
2126 kfree(sdata->u.ap.next_beacon);
2128 @@ -3367,7 +3055,6 @@ __ieee80211_channel_switch(struct wiphy
2129 sdata->csa_radar_required = params->radar_required;
2130 sdata->csa_chandef = params->chandef;
2131 sdata->csa_block_tx = params->block_tx;
2132 - sdata->csa_current_counter = params->count;
2133 sdata->vif.csa_active = true;
2135 if (sdata->csa_block_tx)
2136 @@ -3515,10 +3202,23 @@ static int ieee80211_mgmt_tx(struct wiph
2137 sdata->vif.type == NL80211_IFTYPE_ADHOC) &&
2138 params->n_csa_offsets) {
2140 - u8 c = sdata->csa_current_counter;
2141 + struct beacon_data *beacon = NULL;
2145 - for (i = 0; i < params->n_csa_offsets; i++)
2146 - data[params->csa_offsets[i]] = c;
2147 + if (sdata->vif.type == NL80211_IFTYPE_AP)
2148 + beacon = rcu_dereference(sdata->u.ap.beacon);
2149 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
2150 + beacon = rcu_dereference(sdata->u.ibss.presp);
2151 + else if (ieee80211_vif_is_mesh(&sdata->vif))
2152 + beacon = rcu_dereference(sdata->u.mesh.beacon);
2155 + for (i = 0; i < params->n_csa_offsets; i++)
2156 + data[params->csa_offsets[i]] =
2157 + beacon->csa_current_counter;
2159 + rcu_read_unlock();
2162 IEEE80211_SKB_CB(skb)->flags = flags;
2163 @@ -3598,21 +3298,6 @@ static int ieee80211_get_antenna(struct
2164 return drv_get_antenna(local, tx_ant, rx_ant);
2167 -static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2169 - struct ieee80211_local *local = wiphy_priv(wiphy);
2171 - return drv_set_ringparam(local, tx, rx);
2174 -static void ieee80211_get_ringparam(struct wiphy *wiphy,
2175 - u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2177 - struct ieee80211_local *local = wiphy_priv(wiphy);
2179 - drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2182 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
2183 struct net_device *dev,
2184 struct cfg80211_gtk_rekey_data *data)
2185 @@ -3844,8 +3529,6 @@ const struct cfg80211_ops mac80211_confi
2186 .mgmt_frame_register = ieee80211_mgmt_frame_register,
2187 .set_antenna = ieee80211_set_antenna,
2188 .get_antenna = ieee80211_get_antenna,
2189 - .set_ringparam = ieee80211_set_ringparam,
2190 - .get_ringparam = ieee80211_get_ringparam,
2191 .set_rekey_data = ieee80211_set_rekey_data,
2192 .tdls_oper = ieee80211_tdls_oper,
2193 .tdls_mgmt = ieee80211_tdls_mgmt,
2194 @@ -3854,9 +3537,6 @@ const struct cfg80211_ops mac80211_confi
2196 .set_wakeup = ieee80211_set_wakeup,
2198 - .get_et_sset_count = ieee80211_get_et_sset_count,
2199 - .get_et_stats = ieee80211_get_et_stats,
2200 - .get_et_strings = ieee80211_get_et_strings,
2201 .get_channel = ieee80211_cfg_get_channel,
2202 .start_radar_detection = ieee80211_start_radar_detection,
2203 .channel_switch = ieee80211_channel_switch,
2204 --- a/net/mac80211/debugfs_sta.c
2205 +++ b/net/mac80211/debugfs_sta.c
2206 @@ -587,7 +587,6 @@ void ieee80211_sta_debugfs_add(struct st
2207 DEBUGFS_ADD_COUNTER(tx_filtered, tx_filtered_count);
2208 DEBUGFS_ADD_COUNTER(tx_retry_failed, tx_retry_failed);
2209 DEBUGFS_ADD_COUNTER(tx_retry_count, tx_retry_count);
2210 - DEBUGFS_ADD_COUNTER(wep_weak_iv_count, wep_weak_iv_count);
2212 if (sizeof(sta->driver_buffered_tids) == sizeof(u32))
2213 debugfs_create_x32("driver_buffered_tids", 0400,
2214 --- a/net/mac80211/wep.c
2215 +++ b/net/mac80211/wep.c
2216 @@ -271,22 +271,6 @@ static int ieee80211_wep_decrypt(struct
2221 -static bool ieee80211_wep_is_weak_iv(struct sk_buff *skb,
2222 - struct ieee80211_key *key)
2224 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2225 - unsigned int hdrlen;
2229 - hdrlen = ieee80211_hdrlen(hdr->frame_control);
2230 - ivpos = skb->data + hdrlen;
2231 - iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
2233 - return ieee80211_wep_weak_iv(iv, key->conf.keylen);
2237 ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx)
2239 @@ -301,16 +285,12 @@ ieee80211_crypto_wep_decrypt(struct ieee
2240 if (!(status->flag & RX_FLAG_DECRYPTED)) {
2241 if (skb_linearize(rx->skb))
2242 return RX_DROP_UNUSABLE;
2243 - if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key))
2244 - rx->sta->wep_weak_iv_count++;
2245 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key))
2246 return RX_DROP_UNUSABLE;
2247 } else if (!(status->flag & RX_FLAG_IV_STRIPPED)) {
2248 if (!pskb_may_pull(rx->skb, ieee80211_hdrlen(fc) +
2249 IEEE80211_WEP_IV_LEN))
2250 return RX_DROP_UNUSABLE;
2251 - if (rx->sta && ieee80211_wep_is_weak_iv(rx->skb, rx->key))
2252 - rx->sta->wep_weak_iv_count++;
2253 ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key);
2255 if (pskb_trim(rx->skb, rx->skb->len - IEEE80211_WEP_ICV_LEN))
2256 --- a/include/net/cfg80211.h
2257 +++ b/include/net/cfg80211.h
2258 @@ -2278,16 +2278,6 @@ struct cfg80211_qos_map {
2260 * @set_noack_map: Set the NoAck Map for the TIDs.
2262 - * @get_et_sset_count: Ethtool API to get string-set count.
2263 - * See @ethtool_ops.get_sset_count
2265 - * @get_et_stats: Ethtool API to get a set of u64 stats.
2266 - * See @ethtool_ops.get_ethtool_stats
2268 - * @get_et_strings: Ethtool API to get a set of strings to describe stats
2269 - * and perhaps other supported types of ethtool data-sets.
2270 - * See @ethtool_ops.get_strings
2272 * @get_channel: Get the current operating channel for the virtual interface.
2273 * For monitor interfaces, it should return %NULL unless there's a single
2274 * current monitoring channel.
2275 @@ -2529,13 +2519,6 @@ struct cfg80211_ops {
2276 struct net_device *dev,
2279 - int (*get_et_sset_count)(struct wiphy *wiphy,
2280 - struct net_device *dev, int sset);
2281 - void (*get_et_stats)(struct wiphy *wiphy, struct net_device *dev,
2282 - struct ethtool_stats *stats, u64 *data);
2283 - void (*get_et_strings)(struct wiphy *wiphy, struct net_device *dev,
2284 - u32 sset, u8 *data);
2286 int (*get_channel)(struct wiphy *wiphy,
2287 struct wireless_dev *wdev,
2288 struct cfg80211_chan_def *chandef);
2289 @@ -4846,6 +4829,10 @@ void cfg80211_stop_iface(struct wiphy *w
2291 void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy);
2294 +/* ethtool helper */
2295 +void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
2297 /* Logging, debugging and troubleshooting/diagnostic helpers. */
2299 /* wiphy_printk helpers, similar to dev_printk */
2300 --- a/net/mac80211/Makefile
2301 +++ b/net/mac80211/Makefile
2302 @@ -17,6 +17,7 @@ mac80211-y := \
2310 --- a/net/mac80211/ieee80211_i.h
2311 +++ b/net/mac80211/ieee80211_i.h
2312 @@ -229,16 +229,29 @@ struct ieee80211_rx_data {
2316 +struct ieee80211_csa_settings {
2317 + const u16 *counter_offsets_beacon;
2318 + const u16 *counter_offsets_presp;
2320 + int n_counter_offsets_beacon;
2321 + int n_counter_offsets_presp;
2326 struct beacon_data {
2328 int head_len, tail_len;
2329 struct ieee80211_meshconf_ie *meshconf;
2330 + u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
2331 + u8 csa_current_counter;
2332 struct rcu_head rcu_head;
2336 struct rcu_head rcu_head;
2338 + u16 csa_counter_offsets[IEEE80211_MAX_CSA_COUNTERS_NUM];
2342 @@ -754,8 +767,6 @@ struct ieee80211_sub_if_data {
2343 struct mac80211_qos_map __rcu *qos_map;
2345 struct work_struct csa_finalize_work;
2346 - u16 csa_counter_offset_beacon[IEEE80211_MAX_CSA_COUNTERS_NUM];
2347 - u16 csa_counter_offset_presp[IEEE80211_MAX_CSA_COUNTERS_NUM];
2348 bool csa_radar_required;
2349 bool csa_block_tx; /* write-protected by sdata_lock and local->mtx */
2350 struct cfg80211_chan_def csa_chandef;
2351 @@ -767,7 +778,6 @@ struct ieee80211_sub_if_data {
2352 struct ieee80211_chanctx *reserved_chanctx;
2353 struct cfg80211_chan_def reserved_chandef;
2354 bool reserved_radar_required;
2355 - u8 csa_current_counter;
2357 /* used to reconfigure hardware SM PS */
2358 struct work_struct recalc_smps;
2359 @@ -1850,6 +1860,8 @@ int ieee80211_tdls_oper(struct wiphy *wi
2360 const u8 *peer, enum nl80211_tdls_operation oper);
2363 +extern const struct ethtool_ops ieee80211_ethtool_ops;
2365 #ifdef CPTCFG_MAC80211_NOINLINE
2366 #define debug_noinline noinline
2368 --- a/net/mac80211/iface.c
2369 +++ b/net/mac80211/iface.c
2370 @@ -399,6 +399,7 @@ int ieee80211_add_virtual_monitor(struct
2371 sdata->vif.type = NL80211_IFTYPE_MONITOR;
2372 snprintf(sdata->name, IFNAMSIZ, "%s-monitor",
2373 wiphy_name(local->hw.wiphy));
2374 + sdata->wdev.iftype = NL80211_IFTYPE_MONITOR;
2376 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
2378 @@ -1303,6 +1304,7 @@ static void ieee80211_setup_sdata(struct
2379 sdata->control_port_protocol = cpu_to_be16(ETH_P_PAE);
2380 sdata->control_port_no_encrypt = false;
2381 sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
2382 + sdata->vif.bss_conf.idle = true;
2384 sdata->noack_map = 0;
2386 @@ -1721,6 +1723,8 @@ int ieee80211_if_add(struct ieee80211_lo
2388 ndev->features |= local->hw.netdev_features;
2390 + netdev_set_default_ethtool_ops(ndev, &ieee80211_ethtool_ops);
2392 ret = register_netdevice(ndev);
2395 --- a/net/wireless/core.c
2396 +++ b/net/wireless/core.c
2399 #include "debugfs.h"
2400 #include "wext-compat.h"
2401 -#include "ethtool.h"
2402 #include "rdev-ops.h"
2404 /* name for sysfs, %d is appended */
2405 @@ -940,8 +939,6 @@ static int cfg80211_netdev_notifier_call
2406 /* allow mac80211 to determine the timeout */
2407 wdev->ps_timeout = -1;
2409 - netdev_set_default_ethtool_ops(dev, &cfg80211_ethtool_ops);
2411 if ((wdev->iftype == NL80211_IFTYPE_STATION ||
2412 wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
2413 wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
2414 --- a/net/wireless/ethtool.c
2415 +++ b/net/wireless/ethtool.c
2417 #include <linux/utsname.h>
2418 #include <net/cfg80211.h>
2420 -#include "ethtool.h"
2421 #include "rdev-ops.h"
2423 -static void cfg80211_get_drvinfo(struct net_device *dev,
2424 - struct ethtool_drvinfo *info)
2425 +void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2427 struct wireless_dev *wdev = dev->ieee80211_ptr;
2429 @@ -23,84 +21,4 @@ static void cfg80211_get_drvinfo(struct
2430 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
2431 sizeof(info->bus_info));
2434 -static int cfg80211_get_regs_len(struct net_device *dev)
2436 - /* For now, return 0... */
2440 -static void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
2443 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2445 - regs->version = wdev->wiphy->hw_version;
2449 -static void cfg80211_get_ringparam(struct net_device *dev,
2450 - struct ethtool_ringparam *rp)
2452 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2453 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2455 - memset(rp, 0, sizeof(*rp));
2457 - if (rdev->ops->get_ringparam)
2458 - rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending,
2459 - &rp->rx_pending, &rp->rx_max_pending);
2462 -static int cfg80211_set_ringparam(struct net_device *dev,
2463 - struct ethtool_ringparam *rp)
2465 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2466 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2468 - if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
2471 - if (rdev->ops->set_ringparam)
2472 - return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending);
2477 -static int cfg80211_get_sset_count(struct net_device *dev, int sset)
2479 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2480 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2481 - if (rdev->ops->get_et_sset_count)
2482 - return rdev_get_et_sset_count(rdev, dev, sset);
2483 - return -EOPNOTSUPP;
2486 -static void cfg80211_get_stats(struct net_device *dev,
2487 - struct ethtool_stats *stats, u64 *data)
2489 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2490 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2491 - if (rdev->ops->get_et_stats)
2492 - rdev_get_et_stats(rdev, dev, stats, data);
2495 -static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
2497 - struct wireless_dev *wdev = dev->ieee80211_ptr;
2498 - struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
2499 - if (rdev->ops->get_et_strings)
2500 - rdev_get_et_strings(rdev, dev, sset, data);
2503 -const struct ethtool_ops cfg80211_ethtool_ops = {
2504 - .get_drvinfo = cfg80211_get_drvinfo,
2505 - .get_regs_len = cfg80211_get_regs_len,
2506 - .get_regs = cfg80211_get_regs,
2507 - .get_link = ethtool_op_get_link,
2508 - .get_ringparam = cfg80211_get_ringparam,
2509 - .set_ringparam = cfg80211_set_ringparam,
2510 - .get_strings = cfg80211_get_strings,
2511 - .get_ethtool_stats = cfg80211_get_stats,
2512 - .get_sset_count = cfg80211_get_sset_count,
2514 +EXPORT_SYMBOL(cfg80211_get_drvinfo);
2515 --- a/net/wireless/ethtool.h
2518 -#ifndef __CFG80211_ETHTOOL__
2519 -#define __CFG80211_ETHTOOL__
2521 -extern const struct ethtool_ops cfg80211_ethtool_ops;
2523 -#endif /* __CFG80211_ETHTOOL__ */
2524 --- a/net/wireless/rdev-ops.h
2525 +++ b/net/wireless/rdev-ops.h
2526 @@ -714,25 +714,6 @@ static inline int rdev_get_antenna(struc
2530 -static inline int rdev_set_ringparam(struct cfg80211_registered_device *rdev,
2534 - trace_rdev_set_ringparam(&rdev->wiphy, tx, rx);
2535 - ret = rdev->ops->set_ringparam(&rdev->wiphy, tx, rx);
2536 - trace_rdev_return_int(&rdev->wiphy, ret);
2540 -static inline void rdev_get_ringparam(struct cfg80211_registered_device *rdev,
2541 - u32 *tx, u32 *tx_max, u32 *rx,
2544 - trace_rdev_get_ringparam(&rdev->wiphy);
2545 - rdev->ops->get_ringparam(&rdev->wiphy, tx, tx_max, rx, rx_max);
2546 - trace_rdev_return_void_tx_rx(&rdev->wiphy, *tx, *tx_max, *rx, *rx_max);
2550 rdev_sched_scan_start(struct cfg80211_registered_device *rdev,
2551 struct net_device *dev,
2552 @@ -816,35 +797,6 @@ static inline int rdev_set_noack_map(str
2556 -rdev_get_et_sset_count(struct cfg80211_registered_device *rdev,
2557 - struct net_device *dev, int sset)
2560 - trace_rdev_get_et_sset_count(&rdev->wiphy, dev, sset);
2561 - ret = rdev->ops->get_et_sset_count(&rdev->wiphy, dev, sset);
2562 - trace_rdev_return_int(&rdev->wiphy, ret);
2566 -static inline void rdev_get_et_stats(struct cfg80211_registered_device *rdev,
2567 - struct net_device *dev,
2568 - struct ethtool_stats *stats, u64 *data)
2570 - trace_rdev_get_et_stats(&rdev->wiphy, dev);
2571 - rdev->ops->get_et_stats(&rdev->wiphy, dev, stats, data);
2572 - trace_rdev_return_void(&rdev->wiphy);
2575 -static inline void rdev_get_et_strings(struct cfg80211_registered_device *rdev,
2576 - struct net_device *dev, u32 sset,
2579 - trace_rdev_get_et_strings(&rdev->wiphy, dev, sset);
2580 - rdev->ops->get_et_strings(&rdev->wiphy, dev, sset, data);
2581 - trace_rdev_return_void(&rdev->wiphy);
2585 rdev_get_channel(struct cfg80211_registered_device *rdev,
2586 struct wireless_dev *wdev,
2587 struct cfg80211_chan_def *chandef)
2588 --- a/net/wireless/trace.h
2589 +++ b/net/wireless/trace.h
2590 @@ -298,11 +298,6 @@ DEFINE_EVENT(wiphy_only_evt, rdev_return
2594 -DEFINE_EVENT(wiphy_only_evt, rdev_get_ringparam,
2595 - TP_PROTO(struct wiphy *wiphy),
2599 DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna,
2600 TP_PROTO(struct wiphy *wiphy),
2602 @@ -580,11 +575,6 @@ DEFINE_EVENT(wiphy_netdev_evt, rdev_stop
2603 TP_ARGS(wiphy, netdev)
2606 -DEFINE_EVENT(wiphy_netdev_evt, rdev_get_et_stats,
2607 - TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
2608 - TP_ARGS(wiphy, netdev)
2611 DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop,
2612 TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
2613 TP_ARGS(wiphy, netdev)
2614 @@ -1439,11 +1429,6 @@ DECLARE_EVENT_CLASS(tx_rx_evt,
2615 WIPHY_PR_ARG, __entry->tx, __entry->rx)
2618 -DEFINE_EVENT(tx_rx_evt, rdev_set_ringparam,
2619 - TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
2620 - TP_ARGS(wiphy, rx, tx)
2623 DEFINE_EVENT(tx_rx_evt, rdev_set_antenna,
2624 TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx),
2625 TP_ARGS(wiphy, rx, tx)
2626 @@ -1725,40 +1710,6 @@ TRACE_EVENT(rdev_set_noack_map,
2627 WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map)
2630 -TRACE_EVENT(rdev_get_et_sset_count,
2631 - TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int sset),
2632 - TP_ARGS(wiphy, netdev, sset),
2636 - __field(int, sset)
2641 - __entry->sset = sset;
2643 - TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %d",
2644 - WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset)
2647 -TRACE_EVENT(rdev_get_et_strings,
2648 - TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 sset),
2649 - TP_ARGS(wiphy, netdev, sset),
2653 - __field(u32, sset)
2658 - __entry->sset = sset;
2660 - TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", sset: %u",
2661 - WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset)
2664 DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel,
2665 TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev),
2666 TP_ARGS(wiphy, wdev)
2668 +++ b/net/mac80211/ethtool.c
2671 + * mac80211 ethtool hooks for cfg80211
2673 + * Copied from cfg.c - originally
2674 + * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
2675 + * Copyright 2014 Intel Corporation (Author: Johannes Berg)
2677 + * This file is GPLv2 as found in COPYING.
2679 +#include <linux/types.h>
2680 +#include <net/cfg80211.h>
2681 +#include "ieee80211_i.h"
2682 +#include "sta_info.h"
2683 +#include "driver-ops.h"
2685 +static int ieee80211_set_ringparam(struct net_device *dev,
2686 + struct ethtool_ringparam *rp)
2688 + struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
2690 + if (rp->rx_mini_pending != 0 || rp->rx_jumbo_pending != 0)
2693 + return drv_set_ringparam(local, rp->tx_pending, rp->rx_pending);
2696 +static void ieee80211_get_ringparam(struct net_device *dev,
2697 + struct ethtool_ringparam *rp)
2699 + struct ieee80211_local *local = wiphy_priv(dev->ieee80211_ptr->wiphy);
2701 + memset(rp, 0, sizeof(*rp));
2703 + drv_get_ringparam(local, &rp->tx_pending, &rp->tx_max_pending,
2704 + &rp->rx_pending, &rp->rx_max_pending);
2707 +static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
2708 + "rx_packets", "rx_bytes",
2709 + "rx_duplicates", "rx_fragments", "rx_dropped",
2710 + "tx_packets", "tx_bytes", "tx_fragments",
2711 + "tx_filtered", "tx_retry_failed", "tx_retries",
2712 + "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
2713 + "channel", "noise", "ch_time", "ch_time_busy",
2714 + "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
2716 +#define STA_STATS_LEN ARRAY_SIZE(ieee80211_gstrings_sta_stats)
2718 +static int ieee80211_get_sset_count(struct net_device *dev, int sset)
2720 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2723 + if (sset == ETH_SS_STATS)
2724 + rv += STA_STATS_LEN;
2726 + rv += drv_get_et_sset_count(sdata, sset);
2729 + return -EOPNOTSUPP;
2733 +static void ieee80211_get_stats(struct net_device *dev,
2734 + struct ethtool_stats *stats,
2737 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2738 + struct ieee80211_chanctx_conf *chanctx_conf;
2739 + struct ieee80211_channel *channel;
2740 + struct sta_info *sta;
2741 + struct ieee80211_local *local = sdata->local;
2742 + struct station_info sinfo;
2743 + struct survey_info survey;
2745 +#define STA_STATS_SURVEY_LEN 7
2747 + memset(data, 0, sizeof(u64) * STA_STATS_LEN);
2749 +#define ADD_STA_STATS(sta) \
2751 + data[i++] += sta->rx_packets; \
2752 + data[i++] += sta->rx_bytes; \
2753 + data[i++] += sta->num_duplicates; \
2754 + data[i++] += sta->rx_fragments; \
2755 + data[i++] += sta->rx_dropped; \
2757 + data[i++] += sinfo.tx_packets; \
2758 + data[i++] += sinfo.tx_bytes; \
2759 + data[i++] += sta->tx_fragments; \
2760 + data[i++] += sta->tx_filtered_count; \
2761 + data[i++] += sta->tx_retry_failed; \
2762 + data[i++] += sta->tx_retry_count; \
2763 + data[i++] += sta->beacon_loss_count; \
2766 + /* For Managed stations, find the single station based on BSSID
2767 + * and use that. For interface types, iterate through all available
2768 + * stations and add stats for any station that is assigned to this
2772 + mutex_lock(&local->sta_mtx);
2774 + if (sdata->vif.type == NL80211_IFTYPE_STATION) {
2775 + sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
2777 + if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
2781 + sta_set_sinfo(sta, &sinfo);
2784 + ADD_STA_STATS(sta);
2786 + data[i++] = sta->sta_state;
2789 + if (sinfo.filled & STATION_INFO_TX_BITRATE)
2790 + data[i] = 100000 *
2791 + cfg80211_calculate_bitrate(&sinfo.txrate);
2793 + if (sinfo.filled & STATION_INFO_RX_BITRATE)
2794 + data[i] = 100000 *
2795 + cfg80211_calculate_bitrate(&sinfo.rxrate);
2798 + if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
2799 + data[i] = (u8)sinfo.signal_avg;
2802 + list_for_each_entry(sta, &local->sta_list, list) {
2803 + /* Make sure this station belongs to the proper dev */
2804 + if (sta->sdata->dev != dev)
2808 + sta_set_sinfo(sta, &sinfo);
2810 + ADD_STA_STATS(sta);
2815 + i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
2816 + /* Get survey stats for current channel */
2817 + survey.filled = 0;
2820 + chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
2822 + channel = chanctx_conf->def.chan;
2825 + rcu_read_unlock();
2830 + survey.filled = 0;
2831 + if (drv_get_survey(local, q, &survey) != 0) {
2832 + survey.filled = 0;
2836 + } while (channel != survey.channel);
2839 + if (survey.filled)
2840 + data[i++] = survey.channel->center_freq;
2843 + if (survey.filled & SURVEY_INFO_NOISE_DBM)
2844 + data[i++] = (u8)survey.noise;
2847 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
2848 + data[i++] = survey.channel_time;
2851 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
2852 + data[i++] = survey.channel_time_busy;
2855 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
2856 + data[i++] = survey.channel_time_ext_busy;
2859 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
2860 + data[i++] = survey.channel_time_rx;
2863 + if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
2864 + data[i++] = survey.channel_time_tx;
2868 + mutex_unlock(&local->sta_mtx);
2870 + if (WARN_ON(i != STA_STATS_LEN))
2873 + drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
2876 +static void ieee80211_get_strings(struct net_device *dev, u32 sset, u8 *data)
2878 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2879 + int sz_sta_stats = 0;
2881 + if (sset == ETH_SS_STATS) {
2882 + sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
2883 + memcpy(data, ieee80211_gstrings_sta_stats, sz_sta_stats);
2885 + drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
2888 +static int ieee80211_get_regs_len(struct net_device *dev)
2893 +static void ieee80211_get_regs(struct net_device *dev,
2894 + struct ethtool_regs *regs,
2897 + struct wireless_dev *wdev = dev->ieee80211_ptr;
2899 + regs->version = wdev->wiphy->hw_version;
2903 +const struct ethtool_ops ieee80211_ethtool_ops = {
2904 + .get_drvinfo = cfg80211_get_drvinfo,
2905 + .get_regs_len = ieee80211_get_regs_len,
2906 + .get_regs = ieee80211_get_regs,
2907 + .get_link = ethtool_op_get_link,
2908 + .get_ringparam = ieee80211_get_ringparam,
2909 + .set_ringparam = ieee80211_set_ringparam,
2910 + .get_strings = ieee80211_get_strings,
2911 + .get_ethtool_stats = ieee80211_get_stats,
2912 + .get_sset_count = ieee80211_get_sset_count,
2914 --- a/net/mac80211/ibss.c
2915 +++ b/net/mac80211/ibss.c
2916 @@ -143,7 +143,7 @@ ieee80211_ibss_build_presp(struct ieee80
2917 *pos++ = csa_settings->block_tx ? 1 : 0;
2918 *pos++ = ieee80211_frequency_to_channel(
2919 csa_settings->chandef.chan->center_freq);
2920 - sdata->csa_counter_offset_beacon[0] = (pos - presp->head);
2921 + presp->csa_counter_offsets[0] = (pos - presp->head);
2922 *pos++ = csa_settings->count;
2925 @@ -1677,6 +1677,7 @@ int ieee80211_ibss_join(struct ieee80211
2926 sdata->u.ibss.control_port = params->control_port;
2927 sdata->u.ibss.userspace_handles_dfs = params->userspace_handles_dfs;
2928 sdata->u.ibss.basic_rates = params->basic_rates;
2929 + sdata->u.ibss.last_scan_completed = jiffies;
2931 /* fix basic_rates if channel does not support these rates */
2932 rate_flags = ieee80211_chandef_rate_flags(¶ms->chandef);
2933 --- a/net/mac80211/mesh.c
2934 +++ b/net/mac80211/mesh.c
2935 @@ -679,7 +679,7 @@ ieee80211_mesh_build_beacon(struct ieee8
2937 *pos++ = ieee80211_frequency_to_channel(
2938 csa->settings.chandef.chan->center_freq);
2939 - sdata->csa_counter_offset_beacon[0] = hdr_len + 6;
2940 + bcn->csa_counter_offsets[0] = hdr_len + 6;
2941 *pos++ = csa->settings.count;
2942 *pos++ = WLAN_EID_CHAN_SWITCH_PARAM;
2944 --- a/net/wireless/genregdb.awk
2945 +++ b/net/wireless/genregdb.awk
2946 @@ -65,17 +65,7 @@ function parse_reg_rule()
2949 if (units == "mW") {
2950 - if (power == 100) {
2952 - } else if (power == 200) {
2954 - } else if (power == 500) {
2956 - } else if (power == 1000) {
2959 - print "Unknown power value in database!"
2961 + power = 10 * log(power)/log(10)
2965 @@ -114,7 +104,7 @@ function parse_reg_rule()
2969 - printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
2970 + printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %.0f, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
2974 --- a/net/mac80211/debugfs_netdev.c
2975 +++ b/net/mac80211/debugfs_netdev.c
2976 @@ -34,8 +34,7 @@ static ssize_t ieee80211_if_read(
2977 ssize_t ret = -EINVAL;
2979 read_lock(&dev_base_lock);
2980 - if (sdata->dev->reg_state == NETREG_REGISTERED)
2981 - ret = (*format)(sdata, buf, sizeof(buf));
2982 + ret = (*format)(sdata, buf, sizeof(buf));
2983 read_unlock(&dev_base_lock);
2986 @@ -62,8 +61,7 @@ static ssize_t ieee80211_if_write(
2990 - if (sdata->dev->reg_state == NETREG_REGISTERED)
2991 - ret = (*write)(sdata, buf, count);
2992 + ret = (*write)(sdata, buf, count);
2996 --- a/drivers/net/wireless/b43/xmit.c
2997 +++ b/drivers/net/wireless/b43/xmit.c
2998 @@ -811,9 +811,13 @@ void b43_rx(struct b43_wldev *dev, struc
3001 status.band = IEEE80211_BAND_2GHZ;
3002 - /* chanid is the radio channel cookie value as used
3003 - * to tune the radio. */
3004 - status.freq = chanid + 2400;
3005 + /* Somewhere between 478.104 and 508.1084 firmware for G-PHY
3006 + * has been modified to be compatible with N-PHY and others.
3008 + if (dev->fw.rev >= 508)
3009 + status.freq = ieee80211_channel_to_frequency(chanid, status.band);
3011 + status.freq = chanid + 2400;
3014 case B43_PHYTYPE_LP:
3015 --- a/drivers/net/wireless/b43/main.c
3016 +++ b/drivers/net/wireless/b43/main.c
3017 @@ -5216,6 +5216,7 @@ static int b43_wireless_core_attach(stru
3018 /* We don't support 5 GHz on some PHYs yet */
3019 switch (dev->phy.type) {
3021 + case B43_PHYTYPE_G:
3023 case B43_PHYTYPE_LP:
3024 case B43_PHYTYPE_HT:
3025 --- a/net/wireless/reg.c
3026 +++ b/net/wireless/reg.c
3027 @@ -935,7 +935,7 @@ freq_reg_info_regd(struct wiphy *wiphy,
3028 if (!band_rule_found)
3029 band_rule_found = freq_in_rule_band(fr, center_freq);
3031 - bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(5));
3032 + bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20));
3034 if (band_rule_found && bw_fits)
3036 @@ -1019,10 +1019,10 @@ static void chan_reg_rule_print_dbg(cons
3040 -/* Find an ieee80211_reg_rule such that a 5MHz channel with frequency
3041 - * chan->center_freq fits there.
3042 - * If there is no such reg_rule, disable the channel, otherwise set the
3043 - * flags corresponding to the bandwidths allowed in the particular reg_rule
3045 + * Note that right now we assume the desired channel bandwidth
3046 + * is always 20 MHz for each individual channel (HT40 uses 20 MHz
3047 + * per channel, the primary and the extension channel).
3049 static void handle_channel(struct wiphy *wiphy,
3050 enum nl80211_reg_initiator initiator,
3051 @@ -1083,12 +1083,8 @@ static void handle_channel(struct wiphy
3052 if (reg_rule->flags & NL80211_RRF_AUTO_BW)
3053 max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
3055 - if (max_bandwidth_khz < MHZ_TO_KHZ(10))
3056 - bw_flags = IEEE80211_CHAN_NO_10MHZ;
3057 - if (max_bandwidth_khz < MHZ_TO_KHZ(20))
3058 - bw_flags |= IEEE80211_CHAN_NO_20MHZ;
3059 if (max_bandwidth_khz < MHZ_TO_KHZ(40))
3060 - bw_flags |= IEEE80211_CHAN_NO_HT40;
3061 + bw_flags = IEEE80211_CHAN_NO_HT40;
3062 if (max_bandwidth_khz < MHZ_TO_KHZ(80))
3063 bw_flags |= IEEE80211_CHAN_NO_80MHZ;
3064 if (max_bandwidth_khz < MHZ_TO_KHZ(160))
3065 @@ -1522,12 +1518,8 @@ static void handle_channel_custom(struct
3066 if (reg_rule->flags & NL80211_RRF_AUTO_BW)
3067 max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule);
3069 - if (max_bandwidth_khz < MHZ_TO_KHZ(10))
3070 - bw_flags = IEEE80211_CHAN_NO_10MHZ;
3071 - if (max_bandwidth_khz < MHZ_TO_KHZ(20))
3072 - bw_flags |= IEEE80211_CHAN_NO_20MHZ;
3073 if (max_bandwidth_khz < MHZ_TO_KHZ(40))
3074 - bw_flags |= IEEE80211_CHAN_NO_HT40;
3075 + bw_flags = IEEE80211_CHAN_NO_HT40;
3076 if (max_bandwidth_khz < MHZ_TO_KHZ(80))
3077 bw_flags |= IEEE80211_CHAN_NO_80MHZ;
3078 if (max_bandwidth_khz < MHZ_TO_KHZ(160))
3079 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
3080 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3081 @@ -185,7 +185,8 @@ struct ath_atx_ac {
3083 struct ath_frame_info {
3088 enum ath9k_key_type keytype;
3091 --- a/drivers/net/wireless/ath/ath9k/xmit.c
3092 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3093 @@ -147,15 +147,13 @@ static void ath_set_rates(struct ieee802
3094 static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
3095 struct sk_buff *skb)
3099 - q = skb_get_queue_mapping(skb);
3100 - if (txq == sc->tx.uapsdq)
3101 - txq = sc->tx.txq_map[q];
3102 + struct ath_frame_info *fi = get_frame_info(skb);
3105 - if (txq != sc->tx.txq_map[q])
3109 + txq = sc->tx.txq_map[q];
3110 if (WARN_ON(--txq->pending_frames < 0))
3111 txq->pending_frames = 0;
3113 @@ -887,6 +885,15 @@ ath_tx_get_tid_subframe(struct ath_softc
3115 tx_info = IEEE80211_SKB_CB(skb);
3116 tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT;
3119 + * No aggregation session is running, but there may be frames
3120 + * from a previous session or a failed attempt in the queue.
3121 + * Send them out as normal data frames
3124 + tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
3126 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) {
3127 bf->bf_state.bf_type = 0;
3129 @@ -1999,6 +2006,7 @@ static void setup_frame_info(struct ieee
3130 an = (struct ath_node *) sta->drv_priv;
3132 memset(fi, 0, sizeof(*fi));
3135 fi->keyix = hw_key->hw_key_idx;
3136 else if (an && ieee80211_is_data(hdr->frame_control) && an->ps_key > 0)
3137 @@ -2150,6 +2158,7 @@ int ath_tx_start(struct ieee80211_hw *hw
3138 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3139 struct ieee80211_sta *sta = txctl->sta;
3140 struct ieee80211_vif *vif = info->control.vif;
3141 + struct ath_frame_info *fi = get_frame_info(skb);
3142 struct ath_softc *sc = hw->priv;
3143 struct ath_txq *txq = txctl->txq;
3144 struct ath_atx_tid *tid = NULL;
3145 @@ -2170,11 +2179,13 @@ int ath_tx_start(struct ieee80211_hw *hw
3146 q = skb_get_queue_mapping(skb);
3148 ath_txq_lock(sc, txq);
3149 - if (txq == sc->tx.txq_map[q] &&
3150 - ++txq->pending_frames > sc->tx.txq_max_pending[q] &&
3152 - ieee80211_stop_queue(sc->hw, q);
3153 - txq->stopped = true;
3154 + if (txq == sc->tx.txq_map[q]) {
3156 + if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
3158 + ieee80211_stop_queue(sc->hw, q);
3159 + txq->stopped = true;
3163 if (txctl->an && ieee80211_is_data_present(hdr->frame_control))
3164 --- a/net/mac80211/chan.c
3165 +++ b/net/mac80211/chan.c
3166 @@ -521,6 +521,8 @@ static void ieee80211_recalc_chanctx_cha
3168 if (rcu_access_pointer(sdata->vif.chanctx_conf) != conf)
3170 + if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
3174 compat = &sdata->vif.bss_conf.chandef;
3175 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
3176 +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
3177 @@ -1004,9 +1004,11 @@ static bool ar5008_hw_ani_control_new(st
3178 case ATH9K_ANI_FIRSTEP_LEVEL:{
3182 + value = level * 2;
3183 REG_RMW_FIELD(ah, AR_PHY_FIND_SIG,
3184 AR_PHY_FIND_SIG_FIRSTEP, value);
3185 + REG_RMW_FIELD(ah, AR_PHY_FIND_SIG_LOW,
3186 + AR_PHY_FIND_SIG_FIRSTEP_LOW, value);
3188 if (level != aniState->firstepLevel) {
3189 ath_dbg(common, ANI,
3190 @@ -1040,9 +1042,8 @@ static bool ar5008_hw_ani_control_new(st
3191 REG_RMW_FIELD(ah, AR_PHY_TIMING5,
3192 AR_PHY_TIMING5_CYCPWR_THR1, value);
3194 - if (IS_CHAN_HT40(ah->curchan))
3195 - REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
3196 - AR_PHY_EXT_TIMING5_CYCPWR_THR1, value);
3197 + REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
3198 + AR_PHY_EXT_TIMING5_CYCPWR_THR1, value - 1);
3200 if (level != aniState->spurImmunityLevel) {
3201 ath_dbg(common, ANI,
3202 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3203 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
3204 @@ -517,6 +517,23 @@ static void ar9003_hw_spur_mitigate(stru
3205 ar9003_hw_spur_mitigate_ofdm(ah, chan);
3208 +static u32 ar9003_hw_compute_pll_control_soc(struct ath_hw *ah,
3209 + struct ath9k_channel *chan)
3213 + pll = SM(0x5, AR_RTC_9300_SOC_PLL_REFDIV);
3215 + if (chan && IS_CHAN_HALF_RATE(chan))
3216 + pll |= SM(0x1, AR_RTC_9300_SOC_PLL_CLKSEL);
3217 + else if (chan && IS_CHAN_QUARTER_RATE(chan))
3218 + pll |= SM(0x2, AR_RTC_9300_SOC_PLL_CLKSEL);
3220 + pll |= SM(0x2c, AR_RTC_9300_SOC_PLL_DIV_INT);
3225 static u32 ar9003_hw_compute_pll_control(struct ath_hw *ah,
3226 struct ath9k_channel *chan)
3228 @@ -1779,7 +1796,12 @@ void ar9003_hw_attach_phy_ops(struct ath
3230 priv_ops->rf_set_freq = ar9003_hw_set_channel;
3231 priv_ops->spur_mitigate_freq = ar9003_hw_spur_mitigate;
3232 - priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
3234 + if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah))
3235 + priv_ops->compute_pll_control = ar9003_hw_compute_pll_control_soc;
3237 + priv_ops->compute_pll_control = ar9003_hw_compute_pll_control;
3239 priv_ops->set_channel_regs = ar9003_hw_set_channel_regs;
3240 priv_ops->init_bb = ar9003_hw_init_bb;
3241 priv_ops->process_ini = ar9003_hw_process_ini;
3242 --- a/drivers/net/wireless/ath/ath9k/hw.c
3243 +++ b/drivers/net/wireless/ath/ath9k/hw.c
3244 @@ -702,6 +702,8 @@ static void ath9k_hw_init_pll(struct ath
3248 + pll = ath9k_hw_compute_pll_control(ah, chan);
3250 if (AR_SREV_9485(ah) || AR_SREV_9565(ah)) {
3251 /* program BB PLL ki and kd value, ki=0x4, kd=0x40 */
3252 REG_RMW_FIELD(ah, AR_CH0_BB_DPLL2,
3253 @@ -752,7 +754,8 @@ static void ath9k_hw_init_pll(struct ath
3254 REG_RMW_FIELD(ah, AR_CH0_DDR_DPLL3,
3255 AR_CH0_DPLL3_PHASE_SHIFT, 0x1);
3257 - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
3258 + REG_WRITE(ah, AR_RTC_PLL_CONTROL,
3259 + pll | AR_RTC_9300_PLL_BYPASS);
3262 /* program refdiv, nint, frac to RTC register */
3263 @@ -768,7 +771,8 @@ static void ath9k_hw_init_pll(struct ath
3264 } else if (AR_SREV_9340(ah) || AR_SREV_9550(ah) || AR_SREV_9531(ah)) {
3265 u32 regval, pll2_divint, pll2_divfrac, refdiv;
3267 - REG_WRITE(ah, AR_RTC_PLL_CONTROL, 0x1142c);
3268 + REG_WRITE(ah, AR_RTC_PLL_CONTROL,
3269 + pll | AR_RTC_9300_SOC_PLL_BYPASS);
3272 REG_SET_BIT(ah, AR_PHY_PLL_MODE, 0x1 << 16);
3273 @@ -840,7 +844,6 @@ static void ath9k_hw_init_pll(struct ath
3277 - pll = ath9k_hw_compute_pll_control(ah, chan);
3278 if (AR_SREV_9565(ah))
3280 REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll);
3281 --- a/drivers/net/wireless/ath/ath9k/reg.h
3282 +++ b/drivers/net/wireless/ath/ath9k/reg.h
3283 @@ -1236,12 +1236,23 @@ enum {
3284 #define AR_CH0_DPLL3_PHASE_SHIFT_S 23
3285 #define AR_PHY_CCA_NOM_VAL_2GHZ -118
3287 +#define AR_RTC_9300_SOC_PLL_DIV_INT 0x0000003f
3288 +#define AR_RTC_9300_SOC_PLL_DIV_INT_S 0
3289 +#define AR_RTC_9300_SOC_PLL_DIV_FRAC 0x000fffc0
3290 +#define AR_RTC_9300_SOC_PLL_DIV_FRAC_S 6
3291 +#define AR_RTC_9300_SOC_PLL_REFDIV 0x01f00000
3292 +#define AR_RTC_9300_SOC_PLL_REFDIV_S 20
3293 +#define AR_RTC_9300_SOC_PLL_CLKSEL 0x06000000
3294 +#define AR_RTC_9300_SOC_PLL_CLKSEL_S 25
3295 +#define AR_RTC_9300_SOC_PLL_BYPASS 0x08000000
3297 #define AR_RTC_9300_PLL_DIV 0x000003ff
3298 #define AR_RTC_9300_PLL_DIV_S 0
3299 #define AR_RTC_9300_PLL_REFDIV 0x00003C00
3300 #define AR_RTC_9300_PLL_REFDIV_S 10
3301 #define AR_RTC_9300_PLL_CLKSEL 0x0000C000
3302 #define AR_RTC_9300_PLL_CLKSEL_S 14
3303 +#define AR_RTC_9300_PLL_BYPASS 0x00010000
3305 #define AR_RTC_9160_PLL_DIV 0x000003ff
3306 #define AR_RTC_9160_PLL_DIV_S 0
3307 --- a/drivers/net/wireless/ath/ath9k/common.c
3308 +++ b/drivers/net/wireless/ath/ath9k/common.c
3309 @@ -368,11 +368,11 @@ void ath9k_cmn_update_txpow(struct ath_h
3311 struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
3313 - if (reg->power_limit != new_txpow) {
3314 + if (reg->power_limit != new_txpow)
3315 ath9k_hw_set_txpowerlimit(ah, new_txpow, false);
3316 - /* read back in case value is clamped */
3317 - *txpower = reg->max_power_level;
3320 + /* read back in case value is clamped */
3321 + *txpower = reg->max_power_level;
3323 EXPORT_SYMBOL(ath9k_cmn_update_txpow);