Commit | Line | Data |
---|---|---|
8ca151b5 JB |
1 | /****************************************************************************** |
2 | * | |
3 | * This file is provided under a dual BSD/GPLv2 license. When using or | |
4 | * redistributing this file, you may do so under either license. | |
5 | * | |
6 | * GPL LICENSE SUMMARY | |
7 | * | |
51368bf7 | 8 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
8ca151b5 JB |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of version 2 of the GNU General Public License as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | |
22 | * USA | |
23 | * | |
24 | * The full GNU General Public License is included in this distribution | |
410dc5aa | 25 | * in the file called COPYING. |
8ca151b5 JB |
26 | * |
27 | * Contact Information: | |
28 | * Intel Linux Wireless <ilw@linux.intel.com> | |
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
30 | * | |
31 | * BSD LICENSE | |
32 | * | |
51368bf7 | 33 | * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. |
8ca151b5 JB |
34 | * All rights reserved. |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * | |
40 | * * Redistributions of source code must retain the above copyright | |
41 | * notice, this list of conditions and the following disclaimer. | |
42 | * * Redistributions in binary form must reproduce the above copyright | |
43 | * notice, this list of conditions and the following disclaimer in | |
44 | * the documentation and/or other materials provided with the | |
45 | * distribution. | |
46 | * * Neither the name Intel Corporation nor the names of its | |
47 | * contributors may be used to endorse or promote products derived | |
48 | * from this software without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
61 | * | |
62 | *****************************************************************************/ | |
63 | #include <linux/kernel.h> | |
64 | #include <linux/slab.h> | |
65 | #include <linux/skbuff.h> | |
66 | #include <linux/netdevice.h> | |
67 | #include <linux/etherdevice.h> | |
f0c2646a | 68 | #include <linux/ip.h> |
2ee8f021 | 69 | #include <linux/if_arp.h> |
8ca151b5 | 70 | #include <net/mac80211.h> |
f0c2646a | 71 | #include <net/tcp.h> |
8ca151b5 JB |
72 | |
73 | #include "iwl-op-mode.h" | |
74 | #include "iwl-io.h" | |
75 | #include "mvm.h" | |
76 | #include "sta.h" | |
77 | #include "time-event.h" | |
78 | #include "iwl-eeprom-parse.h" | |
79 | #include "fw-api-scan.h" | |
80 | #include "iwl-phy-db.h" | |
507cadf2 | 81 | #include "testmode.h" |
8ca151b5 JB |
82 | |
83 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { | |
84 | { | |
85 | .max = 1, | |
8eb38710 | 86 | .types = BIT(NL80211_IFTYPE_STATION), |
8ca151b5 | 87 | }, |
3c15a0fb JB |
88 | { |
89 | .max = 1, | |
8eb38710 IP |
90 | .types = BIT(NL80211_IFTYPE_AP) | |
91 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | |
3c15a0fb JB |
92 | BIT(NL80211_IFTYPE_P2P_GO), |
93 | }, | |
94 | { | |
95 | .max = 1, | |
96 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), | |
97 | }, | |
8ca151b5 JB |
98 | }; |
99 | ||
100 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { | |
101 | { | |
102 | .num_different_channels = 1, | |
103 | .max_interfaces = 3, | |
104 | .limits = iwl_mvm_limits, | |
105 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), | |
106 | }, | |
107 | }; | |
108 | ||
f0c2646a JB |
109 | #ifdef CONFIG_PM_SLEEP |
110 | static const struct nl80211_wowlan_tcp_data_token_feature | |
111 | iwl_mvm_wowlan_tcp_token_feature = { | |
112 | .min_len = 0, | |
113 | .max_len = 255, | |
114 | .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS, | |
115 | }; | |
116 | ||
117 | static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = { | |
118 | .tok = &iwl_mvm_wowlan_tcp_token_feature, | |
119 | .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN - | |
120 | sizeof(struct ethhdr) - | |
121 | sizeof(struct iphdr) - | |
122 | sizeof(struct tcphdr), | |
123 | .data_interval_max = 65535, /* __le16 in API */ | |
124 | .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN - | |
125 | sizeof(struct ethhdr) - | |
126 | sizeof(struct iphdr) - | |
127 | sizeof(struct tcphdr), | |
128 | .seq = true, | |
129 | }; | |
130 | #endif | |
131 | ||
77736923 | 132 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
2ee8f021 EP |
133 | /* |
134 | * Use the reserved field to indicate magic values. | |
135 | * these values will only be used internally by the driver, | |
136 | * and won't make it to the fw (reserved will be 0). | |
137 | * BC_FILTER_MAGIC_IP - configure the val of this attribute to | |
138 | * be the vif's ip address. in case there is not a single | |
139 | * ip address (0, or more than 1), this attribute will | |
140 | * be skipped. | |
141 | * BC_FILTER_MAGIC_MAC - set the val of this attribute to | |
142 | * the LSB bytes of the vif's mac address | |
143 | */ | |
144 | enum { | |
145 | BC_FILTER_MAGIC_NONE = 0, | |
146 | BC_FILTER_MAGIC_IP, | |
147 | BC_FILTER_MAGIC_MAC, | |
148 | }; | |
149 | ||
77736923 EP |
150 | static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters[] = { |
151 | { | |
152 | /* arp */ | |
153 | .discard = 0, | |
154 | .frame_type = BCAST_FILTER_FRAME_TYPE_ALL, | |
155 | .attrs = { | |
156 | { | |
157 | /* frame type - arp, hw type - ethernet */ | |
158 | .offset_type = | |
159 | BCAST_FILTER_OFFSET_PAYLOAD_START, | |
160 | .offset = sizeof(rfc1042_header), | |
161 | .val = cpu_to_be32(0x08060001), | |
162 | .mask = cpu_to_be32(0xffffffff), | |
163 | }, | |
2ee8f021 EP |
164 | { |
165 | /* arp dest ip */ | |
166 | .offset_type = | |
167 | BCAST_FILTER_OFFSET_PAYLOAD_START, | |
168 | .offset = sizeof(rfc1042_header) + 2 + | |
169 | sizeof(struct arphdr) + | |
170 | ETH_ALEN + sizeof(__be32) + | |
171 | ETH_ALEN, | |
172 | .mask = cpu_to_be32(0xffffffff), | |
173 | /* mark it as special field */ | |
174 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_IP), | |
175 | }, | |
176 | }, | |
177 | }, | |
178 | { | |
179 | /* dhcp offer bcast */ | |
180 | .discard = 0, | |
181 | .frame_type = BCAST_FILTER_FRAME_TYPE_IPV4, | |
182 | .attrs = { | |
183 | { | |
184 | /* udp dest port - 68 (bootp client)*/ | |
185 | .offset_type = BCAST_FILTER_OFFSET_IP_END, | |
186 | .offset = offsetof(struct udphdr, dest), | |
187 | .val = cpu_to_be32(0x00440000), | |
188 | .mask = cpu_to_be32(0xffff0000), | |
189 | }, | |
190 | { | |
191 | /* dhcp - lsb bytes of client hw address */ | |
192 | .offset_type = BCAST_FILTER_OFFSET_IP_END, | |
193 | .offset = 38, | |
194 | .mask = cpu_to_be32(0xffffffff), | |
195 | /* mark it as special field */ | |
196 | .reserved1 = cpu_to_le16(BC_FILTER_MAGIC_MAC), | |
197 | }, | |
77736923 EP |
198 | }, |
199 | }, | |
200 | /* last filter must be empty */ | |
201 | {}, | |
202 | }; | |
203 | #endif | |
204 | ||
7498cf4c EP |
205 | void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) |
206 | { | |
207 | if (!mvm->trans->cfg->d0i3) | |
208 | return; | |
209 | ||
210 | IWL_DEBUG_RPM(mvm, "Take mvm reference - type %d\n", ref_type); | |
211 | WARN_ON(test_and_set_bit(ref_type, mvm->ref_bitmap)); | |
212 | iwl_trans_ref(mvm->trans); | |
213 | } | |
214 | ||
215 | void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type) | |
216 | { | |
217 | if (!mvm->trans->cfg->d0i3) | |
218 | return; | |
219 | ||
220 | IWL_DEBUG_RPM(mvm, "Leave mvm reference - type %d\n", ref_type); | |
221 | WARN_ON(!test_and_clear_bit(ref_type, mvm->ref_bitmap)); | |
222 | iwl_trans_unref(mvm->trans); | |
223 | } | |
224 | ||
225 | static void | |
226 | iwl_mvm_unref_all_except(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref) | |
227 | { | |
228 | int i; | |
229 | ||
230 | if (!mvm->trans->cfg->d0i3) | |
231 | return; | |
232 | ||
233 | for_each_set_bit(i, mvm->ref_bitmap, IWL_MVM_REF_COUNT) { | |
234 | if (ref == i) | |
235 | continue; | |
236 | ||
237 | IWL_DEBUG_RPM(mvm, "Cleanup: remove mvm ref type %d\n", i); | |
238 | clear_bit(i, mvm->ref_bitmap); | |
239 | iwl_trans_unref(mvm->trans); | |
240 | } | |
241 | } | |
242 | ||
fe0f2de3 IP |
243 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
244 | { | |
245 | int i; | |
246 | ||
247 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); | |
248 | for (i = 0; i < NUM_PHY_CTX; i++) { | |
249 | mvm->phy_ctxts[i].id = i; | |
250 | mvm->phy_ctxts[i].ref = 0; | |
251 | } | |
252 | } | |
253 | ||
20f1a5de DS |
254 | static int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm) |
255 | { | |
256 | /* we create the 802.11 header and SSID element */ | |
257 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID) | |
258 | return mvm->fw->ucode_capa.max_probe_length - 24 - 2; | |
259 | return mvm->fw->ucode_capa.max_probe_length - 24 - 34; | |
260 | } | |
261 | ||
8ca151b5 JB |
262 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
263 | { | |
264 | struct ieee80211_hw *hw = mvm->hw; | |
831e85f3 | 265 | int num_mac, ret, i; |
8ca151b5 JB |
266 | |
267 | /* Tell mac80211 our characteristics */ | |
268 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | |
269 | IEEE80211_HW_SPECTRUM_MGMT | | |
270 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | | |
271 | IEEE80211_HW_QUEUE_CONTROL | | |
272 | IEEE80211_HW_WANT_MONITOR_VIF | | |
8ca151b5 JB |
273 | IEEE80211_HW_SUPPORTS_PS | |
274 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | | |
d2931bbd | 275 | IEEE80211_HW_AMPDU_AGGREGATION | |
d64048ed | 276 | IEEE80211_HW_TIMING_BEACON_ONLY | |
147fc9be EG |
277 | IEEE80211_HW_CONNECTION_MONITOR | |
278 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | |
e8e626ad | 279 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
8ca151b5 | 280 | |
19e737c9 | 281 | hw->queues = mvm->first_agg_queue; |
398e8c6c | 282 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
8ca151b5 JB |
283 | hw->rate_control_algorithm = "iwl-mvm-rs"; |
284 | ||
285 | /* | |
286 | * Enable 11w if advertised by firmware and software crypto | |
287 | * is not enabled (as the firmware will interpret some mgmt | |
288 | * packets, so enabling it with software crypto isn't safe) | |
289 | */ | |
290 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && | |
291 | !iwlwifi_mod_params.sw_crypto) | |
292 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; | |
293 | ||
e8e626ad AB |
294 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT) { |
295 | hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD; | |
296 | hw->uapsd_queues = IWL_UAPSD_AC_INFO; | |
297 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; | |
298 | } | |
299 | ||
8ca151b5 JB |
300 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
301 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); | |
fe0f2de3 | 302 | hw->chanctx_data_size = sizeof(u16); |
8ca151b5 JB |
303 | |
304 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | |
3c15a0fb JB |
305 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
306 | BIT(NL80211_IFTYPE_AP) | | |
307 | BIT(NL80211_IFTYPE_P2P_GO) | | |
308 | BIT(NL80211_IFTYPE_P2P_DEVICE); | |
8ca151b5 | 309 | |
5023d966 JB |
310 | /* IBSS has bugs in older versions */ |
311 | if (IWL_UCODE_API(mvm->fw->ucode_ver) >= 8) | |
312 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC); | |
313 | ||
a2f73b6c LR |
314 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
315 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | | |
316 | REGULATORY_DISABLE_BEACON_HINTS; | |
8ca151b5 | 317 | |
3e56eadf JB |
318 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD) |
319 | hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; | |
320 | ||
8ca151b5 JB |
321 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; |
322 | hw->wiphy->n_iface_combinations = | |
323 | ARRAY_SIZE(iwl_mvm_iface_combinations); | |
324 | ||
c451e6d4 | 325 | hw->wiphy->max_remain_on_channel_duration = 10000; |
8ca151b5 JB |
326 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
327 | ||
328 | /* Extract MAC address */ | |
329 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); | |
330 | hw->wiphy->addresses = mvm->addresses; | |
331 | hw->wiphy->n_addresses = 1; | |
831e85f3 IP |
332 | |
333 | /* Extract additional MAC addresses if available */ | |
334 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? | |
335 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; | |
336 | ||
337 | for (i = 1; i < num_mac; i++) { | |
338 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, | |
8ca151b5 | 339 | ETH_ALEN); |
831e85f3 | 340 | mvm->addresses[i].addr[5]++; |
8ca151b5 JB |
341 | hw->wiphy->n_addresses++; |
342 | } | |
343 | ||
fe0f2de3 IP |
344 | iwl_mvm_reset_phy_ctxts(mvm); |
345 | ||
20f1a5de DS |
346 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
347 | ||
8ca151b5 JB |
348 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
349 | ||
350 | if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels) | |
351 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | |
352 | &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; | |
353 | if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels) | |
354 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | |
355 | &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; | |
356 | ||
357 | hw->wiphy->hw_version = mvm->trans->hw_id; | |
358 | ||
ade50652 | 359 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
8ca151b5 JB |
360 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
361 | else | |
362 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | |
363 | ||
35a000b7 DS |
364 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SCHED_SCAN) { |
365 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; | |
366 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; | |
367 | hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; | |
368 | /* we create the 802.11 header and zero length SSID IE. */ | |
369 | hw->wiphy->max_sched_scan_ie_len = | |
370 | SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; | |
371 | } | |
372 | ||
8ca151b5 | 373 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
61f6325d HD |
374 | NL80211_FEATURE_P2P_GO_OPPPS | |
375 | NL80211_FEATURE_LOW_PRIORITY_SCAN; | |
8ca151b5 JB |
376 | |
377 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | |
378 | ||
e36e5433 | 379 | /* currently FW API supports only one optional cipher scheme */ |
9ddca860 | 380 | if (mvm->fw->cs[0].cipher) { |
e36e5433 | 381 | mvm->hw->n_cipher_schemes = 1; |
9ddca860 | 382 | mvm->hw->cipher_schemes = &mvm->fw->cs[0]; |
e36e5433 MS |
383 | } |
384 | ||
8ca151b5 JB |
385 | #ifdef CONFIG_PM_SLEEP |
386 | if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && | |
387 | mvm->trans->ops->d3_suspend && | |
388 | mvm->trans->ops->d3_resume && | |
389 | device_can_wakeup(mvm->trans->dev)) { | |
964dc9e2 JB |
390 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
391 | WIPHY_WOWLAN_DISCONNECT | | |
392 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | | |
393 | WIPHY_WOWLAN_RFKILL_RELEASE; | |
8ca151b5 | 394 | if (!iwlwifi_mod_params.sw_crypto) |
964dc9e2 JB |
395 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
396 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | | |
397 | WIPHY_WOWLAN_4WAY_HANDSHAKE; | |
398 | ||
399 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; | |
400 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; | |
401 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; | |
402 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; | |
403 | hw->wiphy->wowlan = &mvm->wowlan; | |
8ca151b5 JB |
404 | } |
405 | #endif | |
406 | ||
77736923 EP |
407 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
408 | /* assign default bcast filtering configuration */ | |
409 | mvm->bcast_filters = iwl_mvm_default_bcast_filters; | |
410 | #endif | |
411 | ||
8ca151b5 JB |
412 | ret = iwl_mvm_leds_init(mvm); |
413 | if (ret) | |
414 | return ret; | |
415 | ||
b7327d89 EG |
416 | ret = ieee80211_register_hw(mvm->hw); |
417 | if (ret) | |
418 | iwl_mvm_leds_exit(mvm); | |
419 | ||
420 | return ret; | |
8ca151b5 JB |
421 | } |
422 | ||
423 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, | |
424 | struct ieee80211_tx_control *control, | |
425 | struct sk_buff *skb) | |
426 | { | |
427 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
3e56eadf JB |
428 | struct ieee80211_sta *sta = control->sta; |
429 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | |
430 | struct ieee80211_hdr *hdr = (void *)skb->data; | |
8ca151b5 | 431 | |
9ee718aa EL |
432 | if (iwl_mvm_is_radio_killed(mvm)) { |
433 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); | |
8ca151b5 JB |
434 | goto drop; |
435 | } | |
436 | ||
398e8c6c | 437 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
8ca151b5 JB |
438 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) |
439 | goto drop; | |
440 | ||
3e56eadf JB |
441 | /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */ |
442 | if (unlikely(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER && | |
443 | ieee80211_is_mgmt(hdr->frame_control) && | |
444 | !ieee80211_is_deauth(hdr->frame_control) && | |
445 | !ieee80211_is_disassoc(hdr->frame_control) && | |
446 | !ieee80211_is_action(hdr->frame_control))) | |
447 | sta = NULL; | |
448 | ||
449 | if (sta) { | |
450 | if (iwl_mvm_tx_skb(mvm, skb, sta)) | |
8ca151b5 JB |
451 | goto drop; |
452 | return; | |
453 | } | |
454 | ||
455 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) | |
456 | goto drop; | |
457 | return; | |
458 | drop: | |
459 | ieee80211_free_txskb(hw, skb); | |
460 | } | |
461 | ||
462 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, | |
463 | struct ieee80211_vif *vif, | |
464 | enum ieee80211_ampdu_mlme_action action, | |
465 | struct ieee80211_sta *sta, u16 tid, | |
466 | u16 *ssn, u8 buf_size) | |
467 | { | |
468 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
469 | int ret; | |
470 | ||
471 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", | |
472 | sta->addr, tid, action); | |
473 | ||
474 | if (!(mvm->nvm_data->sku_cap_11n_enable)) | |
475 | return -EACCES; | |
476 | ||
477 | mutex_lock(&mvm->mutex); | |
478 | ||
479 | switch (action) { | |
480 | case IEEE80211_AMPDU_RX_START: | |
481 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) { | |
482 | ret = -EINVAL; | |
483 | break; | |
484 | } | |
485 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); | |
486 | break; | |
487 | case IEEE80211_AMPDU_RX_STOP: | |
488 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); | |
489 | break; | |
490 | case IEEE80211_AMPDU_TX_START: | |
5d158efa EG |
491 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) { |
492 | ret = -EINVAL; | |
493 | break; | |
494 | } | |
8ca151b5 JB |
495 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
496 | break; | |
497 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
e3d9e7ce EG |
498 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
499 | break; | |
8ca151b5 JB |
500 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
501 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | |
e3d9e7ce | 502 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
8ca151b5 JB |
503 | break; |
504 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
505 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); | |
506 | break; | |
507 | default: | |
508 | WARN_ON_ONCE(1); | |
509 | ret = -EINVAL; | |
510 | break; | |
511 | } | |
512 | mutex_unlock(&mvm->mutex); | |
513 | ||
514 | return ret; | |
515 | } | |
516 | ||
517 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, | |
518 | struct ieee80211_vif *vif) | |
519 | { | |
520 | struct iwl_mvm *mvm = data; | |
521 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
522 | ||
523 | mvmvif->uploaded = false; | |
524 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; | |
525 | ||
526 | /* does this make sense at all? */ | |
527 | mvmvif->color++; | |
528 | ||
529 | spin_lock_bh(&mvm->time_event_lock); | |
530 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); | |
531 | spin_unlock_bh(&mvm->time_event_lock); | |
532 | ||
fe0f2de3 | 533 | mvmvif->phy_ctxt = NULL; |
8ca151b5 JB |
534 | } |
535 | ||
536 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) | |
537 | { | |
538 | iwl_trans_stop_device(mvm->trans); | |
8ca151b5 JB |
539 | |
540 | mvm->scan_status = IWL_MVM_SCAN_NONE; | |
541 | ||
542 | /* just in case one was running */ | |
543 | ieee80211_remain_on_channel_expired(mvm->hw); | |
544 | ||
545 | ieee80211_iterate_active_interfaces_atomic( | |
546 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, | |
547 | iwl_mvm_cleanup_iterator, mvm); | |
548 | ||
fe0f2de3 | 549 | mvm->p2p_device_vif = NULL; |
37577fe2 | 550 | mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT; |
fe0f2de3 IP |
551 | |
552 | iwl_mvm_reset_phy_ctxts(mvm); | |
8ca151b5 JB |
553 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
554 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); | |
555 | ||
556 | ieee80211_wake_queues(mvm->hw); | |
557 | ||
7498cf4c EP |
558 | /* cleanup all stale references (scan, roc), but keep the |
559 | * ucode_down ref until reconfig is complete */ | |
560 | iwl_mvm_unref_all_except(mvm, IWL_MVM_REF_UCODE_DOWN); | |
561 | ||
8ca151b5 | 562 | mvm->vif_count = 0; |
113a0447 | 563 | mvm->rx_ba_sessions = 0; |
8ca151b5 JB |
564 | } |
565 | ||
566 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) | |
567 | { | |
568 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
569 | int ret; | |
570 | ||
571 | mutex_lock(&mvm->mutex); | |
572 | ||
573 | /* Clean up some internal and mac80211 state on restart */ | |
574 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | |
575 | iwl_mvm_restart_cleanup(mvm); | |
576 | ||
577 | ret = iwl_mvm_up(mvm); | |
578 | mutex_unlock(&mvm->mutex); | |
579 | ||
580 | return ret; | |
581 | } | |
582 | ||
583 | static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw) | |
584 | { | |
585 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
586 | int ret; | |
587 | ||
588 | mutex_lock(&mvm->mutex); | |
589 | ||
590 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
591 | ret = iwl_mvm_update_quotas(mvm, NULL); | |
592 | if (ret) | |
593 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", | |
594 | ret); | |
595 | ||
7498cf4c EP |
596 | /* allow transport/FW low power modes */ |
597 | iwl_mvm_unref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
598 | ||
8ca151b5 JB |
599 | mutex_unlock(&mvm->mutex); |
600 | } | |
601 | ||
602 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) | |
603 | { | |
604 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
605 | ||
37577fe2 | 606 | flush_work(&mvm->d0i3_exit_work); |
8ca151b5 JB |
607 | flush_work(&mvm->async_handlers_wk); |
608 | ||
609 | mutex_lock(&mvm->mutex); | |
7498cf4c EP |
610 | |
611 | /* disallow low power states when the FW is down */ | |
612 | iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); | |
613 | ||
8ca151b5 JB |
614 | /* async_handlers_wk is now blocked */ |
615 | ||
616 | /* | |
617 | * The work item could be running or queued if the | |
618 | * ROC time event stops just as we get here. | |
619 | */ | |
620 | cancel_work_sync(&mvm->roc_done_wk); | |
621 | ||
622 | iwl_trans_stop_device(mvm->trans); | |
8ca151b5 JB |
623 | |
624 | iwl_mvm_async_handlers_purge(mvm); | |
625 | /* async_handlers_list is empty and will stay empty: HW is stopped */ | |
626 | ||
627 | /* the fw is stopped, the aux sta is dead: clean up driver state */ | |
628 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); | |
629 | ||
630 | mutex_unlock(&mvm->mutex); | |
631 | ||
632 | /* | |
633 | * The worker might have been waiting for the mutex, let it run and | |
634 | * discover that its list is now empty. | |
635 | */ | |
636 | cancel_work_sync(&mvm->async_handlers_wk); | |
637 | } | |
638 | ||
8ca151b5 JB |
639 | static void iwl_mvm_power_update_iterator(void *data, u8 *mac, |
640 | struct ieee80211_vif *vif) | |
641 | { | |
642 | struct iwl_mvm *mvm = data; | |
643 | ||
644 | iwl_mvm_power_update_mode(mvm, vif); | |
645 | } | |
646 | ||
fe0f2de3 IP |
647 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
648 | { | |
649 | u16 i; | |
650 | ||
651 | lockdep_assert_held(&mvm->mutex); | |
652 | ||
653 | for (i = 0; i < NUM_PHY_CTX; i++) | |
654 | if (!mvm->phy_ctxts[i].ref) | |
655 | return &mvm->phy_ctxts[i]; | |
656 | ||
657 | IWL_ERR(mvm, "No available PHY context\n"); | |
658 | return NULL; | |
659 | } | |
660 | ||
ee9c6cb0 EG |
661 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
662 | s8 tx_power) | |
663 | { | |
664 | /* FW is in charge of regulatory enforcement */ | |
665 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { | |
666 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, | |
667 | .pwr_restriction = cpu_to_le16(tx_power), | |
668 | }; | |
669 | ||
670 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, | |
671 | sizeof(reduce_txpwr_cmd), | |
672 | &reduce_txpwr_cmd); | |
673 | } | |
674 | ||
8ca151b5 JB |
675 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
676 | struct ieee80211_vif *vif) | |
677 | { | |
678 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
679 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
680 | int ret; | |
681 | ||
682 | /* | |
683 | * Not much to do here. The stack will not allow interface | |
684 | * types or combinations that we didn't advertise, so we | |
685 | * don't really have to check the types. | |
686 | */ | |
687 | ||
688 | mutex_lock(&mvm->mutex); | |
689 | ||
e89044d7 | 690 | /* Allocate resources for the MAC context, and add it to the fw */ |
8ca151b5 JB |
691 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
692 | if (ret) | |
693 | goto out_unlock; | |
694 | ||
1c2abf72 | 695 | /* Counting number of interfaces is needed for legacy PM */ |
ea183d02 IP |
696 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
697 | mvm->vif_count++; | |
ea183d02 | 698 | |
8ca151b5 JB |
699 | /* |
700 | * The AP binding flow can be done only after the beacon | |
701 | * template is configured (which happens only in the mac80211 | |
702 | * start_ap() flow), and adding the broadcast station can happen | |
703 | * only after the binding. | |
704 | * In addition, since modifying the MAC before adding a bcast | |
705 | * station is not allowed by the FW, delay the adding of MAC context to | |
706 | * the point where we can also add the bcast station. | |
707 | * In short: there's not much we can do at this point, other than | |
708 | * allocating resources :) | |
709 | */ | |
5023d966 JB |
710 | if (vif->type == NL80211_IFTYPE_AP || |
711 | vif->type == NL80211_IFTYPE_ADHOC) { | |
8ca151b5 JB |
712 | u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif); |
713 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, | |
714 | qmask); | |
715 | if (ret) { | |
716 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); | |
717 | goto out_release; | |
718 | } | |
719 | ||
77740cb4 | 720 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
721 | goto out_unlock; |
722 | } | |
723 | ||
8ca151b5 JB |
724 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
725 | if (ret) | |
726 | goto out_release; | |
727 | ||
1c2abf72 | 728 | iwl_mvm_power_disable(mvm, vif); |
8ca151b5 | 729 | |
7df15b1e | 730 | /* beacon filtering */ |
3dd37d05 | 731 | ret = iwl_mvm_disable_beacon_filter(mvm, vif, CMD_SYNC); |
bd3351ba EP |
732 | if (ret) |
733 | goto out_remove_mac; | |
734 | ||
7df15b1e | 735 | if (!mvm->bf_allowed_vif && |
5dca7c24 HG |
736 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
737 | mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){ | |
7df15b1e | 738 | mvm->bf_allowed_vif = mvmvif; |
a20fd398 AO |
739 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
740 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; | |
7df15b1e HG |
741 | } |
742 | ||
8ca151b5 JB |
743 | /* |
744 | * P2P_DEVICE interface does not have a channel context assigned to it, | |
745 | * so a dedicated PHY context is allocated to it and the corresponding | |
746 | * MAC context is bound to it at this stage. | |
747 | */ | |
748 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
8ca151b5 | 749 | |
fe0f2de3 IP |
750 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
751 | if (!mvmvif->phy_ctxt) { | |
752 | ret = -ENOSPC; | |
bd3351ba | 753 | goto out_free_bf; |
fe0f2de3 | 754 | } |
8ca151b5 | 755 | |
53a9d61e | 756 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
757 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
758 | if (ret) | |
53a9d61e | 759 | goto out_unref_phy; |
8ca151b5 JB |
760 | |
761 | ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta); | |
762 | if (ret) | |
763 | goto out_unbind; | |
764 | ||
765 | /* Save a pointer to p2p device vif, so it can later be used to | |
766 | * update the p2p device MAC when a GO is started/stopped */ | |
767 | mvm->p2p_device_vif = vif; | |
768 | } | |
769 | ||
63494374 | 770 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
771 | goto out_unlock; |
772 | ||
773 | out_unbind: | |
774 | iwl_mvm_binding_remove_vif(mvm, vif); | |
53a9d61e | 775 | out_unref_phy: |
fe0f2de3 | 776 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
bd3351ba EP |
777 | out_free_bf: |
778 | if (mvm->bf_allowed_vif == mvmvif) { | |
779 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
780 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
781 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
bd3351ba | 782 | } |
8ca151b5 JB |
783 | out_remove_mac: |
784 | mvmvif->phy_ctxt = NULL; | |
785 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
786 | out_release: | |
5ee2b215 AB |
787 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
788 | mvm->vif_count--; | |
1c2abf72 AB |
789 | |
790 | /* TODO: remove this when legacy PM will be discarded */ | |
4bf881f5 AB |
791 | ieee80211_iterate_active_interfaces( |
792 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
793 | iwl_mvm_power_update_iterator, mvm); | |
1c2abf72 | 794 | |
8ca151b5 JB |
795 | iwl_mvm_mac_ctxt_release(mvm, vif); |
796 | out_unlock: | |
797 | mutex_unlock(&mvm->mutex); | |
798 | ||
799 | return ret; | |
800 | } | |
801 | ||
38a12b5b JB |
802 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
803 | struct ieee80211_vif *vif) | |
8ca151b5 | 804 | { |
8ca151b5 JB |
805 | u32 tfd_msk = 0, ac; |
806 | ||
807 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) | |
808 | if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) | |
809 | tfd_msk |= BIT(vif->hw_queue[ac]); | |
810 | ||
811 | if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE) | |
812 | tfd_msk |= BIT(vif->cab_queue); | |
813 | ||
814 | if (tfd_msk) { | |
815 | mutex_lock(&mvm->mutex); | |
816 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); | |
817 | mutex_unlock(&mvm->mutex); | |
818 | } | |
819 | ||
820 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
821 | /* | |
822 | * Flush the ROC worker which will flush the OFFCHANNEL queue. | |
823 | * We assume here that all the packets sent to the OFFCHANNEL | |
824 | * queue are sent in ROC session. | |
825 | */ | |
826 | flush_work(&mvm->roc_done_wk); | |
827 | } else { | |
828 | /* | |
829 | * By now, all the AC queues are empty. The AGG queues are | |
830 | * empty too. We already got all the Tx responses for all the | |
831 | * packets in the queues. The drain work can have been | |
0742a75a | 832 | * triggered. Flush it. |
8ca151b5 JB |
833 | */ |
834 | flush_work(&mvm->sta_drained_wk); | |
835 | } | |
38a12b5b JB |
836 | } |
837 | ||
838 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, | |
839 | struct ieee80211_vif *vif) | |
840 | { | |
841 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
842 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
843 | ||
844 | iwl_mvm_prepare_mac_removal(mvm, vif); | |
8ca151b5 JB |
845 | |
846 | mutex_lock(&mvm->mutex); | |
847 | ||
7df15b1e HG |
848 | if (mvm->bf_allowed_vif == mvmvif) { |
849 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
850 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
851 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
7df15b1e HG |
852 | } |
853 | ||
63494374 JB |
854 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
855 | ||
8ca151b5 JB |
856 | /* |
857 | * For AP/GO interface, the tear down of the resources allocated to the | |
38a12b5b | 858 | * interface is be handled as part of the stop_ap flow. |
8ca151b5 | 859 | */ |
5023d966 JB |
860 | if (vif->type == NL80211_IFTYPE_AP || |
861 | vif->type == NL80211_IFTYPE_ADHOC) { | |
507cadf2 DS |
862 | #ifdef CONFIG_NL80211_TESTMODE |
863 | if (vif == mvm->noa_vif) { | |
864 | mvm->noa_vif = NULL; | |
865 | mvm->noa_duration = 0; | |
866 | } | |
867 | #endif | |
8ca151b5 JB |
868 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); |
869 | goto out_release; | |
870 | } | |
871 | ||
872 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
873 | mvm->p2p_device_vif = NULL; | |
874 | iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta); | |
875 | iwl_mvm_binding_remove_vif(mvm, vif); | |
fe0f2de3 | 876 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
877 | mvmvif->phy_ctxt = NULL; |
878 | } | |
879 | ||
5ee2b215 | 880 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
8ca151b5 | 881 | mvm->vif_count--; |
1c2abf72 AB |
882 | |
883 | /* TODO: remove this when legacy PM will be discarded */ | |
884 | ieee80211_iterate_active_interfaces( | |
885 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
886 | iwl_mvm_power_update_iterator, mvm); | |
8ca151b5 JB |
887 | |
888 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
889 | ||
890 | out_release: | |
891 | iwl_mvm_mac_ctxt_release(mvm, vif); | |
892 | mutex_unlock(&mvm->mutex); | |
893 | } | |
894 | ||
895 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) | |
88f2fd73 | 896 | { |
8ca151b5 JB |
897 | return 0; |
898 | } | |
899 | ||
e59647ea EP |
900 | struct iwl_mvm_mc_iter_data { |
901 | struct iwl_mvm *mvm; | |
902 | int port_id; | |
903 | }; | |
904 | ||
905 | static void iwl_mvm_mc_iface_iterator(void *_data, u8 *mac, | |
906 | struct ieee80211_vif *vif) | |
907 | { | |
908 | struct iwl_mvm_mc_iter_data *data = _data; | |
909 | struct iwl_mvm *mvm = data->mvm; | |
910 | struct iwl_mcast_filter_cmd *cmd = mvm->mcast_filter_cmd; | |
911 | int ret, len; | |
912 | ||
913 | /* if we don't have free ports, mcast frames will be dropped */ | |
914 | if (WARN_ON_ONCE(data->port_id >= MAX_PORT_ID_NUM)) | |
915 | return; | |
916 | ||
917 | if (vif->type != NL80211_IFTYPE_STATION || | |
918 | !vif->bss_conf.assoc) | |
919 | return; | |
920 | ||
921 | cmd->port_id = data->port_id++; | |
922 | memcpy(cmd->bssid, vif->bss_conf.bssid, ETH_ALEN); | |
923 | len = roundup(sizeof(*cmd) + cmd->count * ETH_ALEN, 4); | |
924 | ||
925 | ret = iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC, len, cmd); | |
926 | if (ret) | |
927 | IWL_ERR(mvm, "mcast filter cmd error. ret=%d\n", ret); | |
928 | } | |
929 | ||
930 | static void iwl_mvm_recalc_multicast(struct iwl_mvm *mvm) | |
931 | { | |
932 | struct iwl_mvm_mc_iter_data iter_data = { | |
933 | .mvm = mvm, | |
88f2fd73 MG |
934 | }; |
935 | ||
e59647ea EP |
936 | lockdep_assert_held(&mvm->mutex); |
937 | ||
938 | if (WARN_ON_ONCE(!mvm->mcast_filter_cmd)) | |
939 | return; | |
940 | ||
941 | ieee80211_iterate_active_interfaces( | |
942 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
943 | iwl_mvm_mc_iface_iterator, &iter_data); | |
88f2fd73 MG |
944 | } |
945 | ||
e59647ea EP |
946 | static u64 iwl_mvm_prepare_multicast(struct ieee80211_hw *hw, |
947 | struct netdev_hw_addr_list *mc_list) | |
8ca151b5 | 948 | { |
e59647ea EP |
949 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
950 | struct iwl_mcast_filter_cmd *cmd; | |
951 | struct netdev_hw_addr *addr; | |
952 | int addr_count = netdev_hw_addr_list_count(mc_list); | |
953 | bool pass_all = false; | |
954 | int len; | |
955 | ||
956 | if (addr_count > MAX_MCAST_FILTERING_ADDRESSES) { | |
957 | pass_all = true; | |
958 | addr_count = 0; | |
959 | } | |
960 | ||
961 | len = roundup(sizeof(*cmd) + addr_count * ETH_ALEN, 4); | |
962 | cmd = kzalloc(len, GFP_ATOMIC); | |
963 | if (!cmd) | |
964 | return 0; | |
965 | ||
966 | if (pass_all) { | |
967 | cmd->pass_all = 1; | |
968 | return (u64)(unsigned long)cmd; | |
969 | } | |
970 | ||
971 | netdev_hw_addr_list_for_each(addr, mc_list) { | |
972 | IWL_DEBUG_MAC80211(mvm, "mcast addr (%d): %pM\n", | |
973 | cmd->count, addr->addr); | |
974 | memcpy(&cmd->addr_list[cmd->count * ETH_ALEN], | |
975 | addr->addr, ETH_ALEN); | |
976 | cmd->count++; | |
977 | } | |
978 | ||
979 | return (u64)(unsigned long)cmd; | |
8ca151b5 JB |
980 | } |
981 | ||
982 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, | |
983 | unsigned int changed_flags, | |
984 | unsigned int *total_flags, | |
985 | u64 multicast) | |
986 | { | |
e59647ea EP |
987 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); |
988 | struct iwl_mcast_filter_cmd *cmd = (void *)(unsigned long)multicast; | |
8ca151b5 | 989 | |
e59647ea | 990 | mutex_lock(&mvm->mutex); |
51b6b9e0 | 991 | |
e59647ea EP |
992 | /* replace previous configuration */ |
993 | kfree(mvm->mcast_filter_cmd); | |
994 | mvm->mcast_filter_cmd = cmd; | |
51b6b9e0 | 995 | |
e59647ea EP |
996 | if (!cmd) |
997 | goto out; | |
51b6b9e0 | 998 | |
e59647ea EP |
999 | iwl_mvm_recalc_multicast(mvm); |
1000 | out: | |
1001 | mutex_unlock(&mvm->mutex); | |
1002 | *total_flags = 0; | |
51b6b9e0 EG |
1003 | } |
1004 | ||
c87163b9 EP |
1005 | #ifdef CONFIG_IWLWIFI_BCAST_FILTERING |
1006 | struct iwl_bcast_iter_data { | |
1007 | struct iwl_mvm *mvm; | |
1008 | struct iwl_bcast_filter_cmd *cmd; | |
1009 | u8 current_filter; | |
1010 | }; | |
1011 | ||
1012 | static void | |
1013 | iwl_mvm_set_bcast_filter(struct ieee80211_vif *vif, | |
1014 | const struct iwl_fw_bcast_filter *in_filter, | |
1015 | struct iwl_fw_bcast_filter *out_filter) | |
1016 | { | |
1017 | struct iwl_fw_bcast_filter_attr *attr; | |
1018 | int i; | |
1019 | ||
1020 | memcpy(out_filter, in_filter, sizeof(*out_filter)); | |
1021 | ||
1022 | for (i = 0; i < ARRAY_SIZE(out_filter->attrs); i++) { | |
1023 | attr = &out_filter->attrs[i]; | |
1024 | ||
1025 | if (!attr->mask) | |
1026 | break; | |
1027 | ||
2ee8f021 EP |
1028 | switch (attr->reserved1) { |
1029 | case cpu_to_le16(BC_FILTER_MAGIC_IP): | |
1030 | if (vif->bss_conf.arp_addr_cnt != 1) { | |
1031 | attr->mask = 0; | |
1032 | continue; | |
1033 | } | |
1034 | ||
1035 | attr->val = vif->bss_conf.arp_addr_list[0]; | |
1036 | break; | |
1037 | case cpu_to_le16(BC_FILTER_MAGIC_MAC): | |
1038 | attr->val = *(__be32 *)&vif->addr[2]; | |
1039 | break; | |
1040 | default: | |
1041 | break; | |
1042 | } | |
1043 | attr->reserved1 = 0; | |
c87163b9 EP |
1044 | out_filter->num_attrs++; |
1045 | } | |
1046 | } | |
1047 | ||
1048 | static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac, | |
1049 | struct ieee80211_vif *vif) | |
1050 | { | |
1051 | struct iwl_bcast_iter_data *data = _data; | |
1052 | struct iwl_mvm *mvm = data->mvm; | |
1053 | struct iwl_bcast_filter_cmd *cmd = data->cmd; | |
1054 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1055 | struct iwl_fw_bcast_mac *bcast_mac; | |
1056 | int i; | |
1057 | ||
1058 | if (WARN_ON(mvmvif->id >= ARRAY_SIZE(cmd->macs))) | |
1059 | return; | |
1060 | ||
1061 | bcast_mac = &cmd->macs[mvmvif->id]; | |
1062 | ||
1063 | /* enable filtering only for associated stations */ | |
1064 | if (vif->type != NL80211_IFTYPE_STATION || !vif->bss_conf.assoc) | |
1065 | return; | |
1066 | ||
1067 | bcast_mac->default_discard = 1; | |
1068 | ||
1069 | /* copy all configured filters */ | |
1070 | for (i = 0; mvm->bcast_filters[i].attrs[0].mask; i++) { | |
1071 | /* | |
1072 | * Make sure we don't exceed our filters limit. | |
1073 | * if there is still a valid filter to be configured, | |
1074 | * be on the safe side and just allow bcast for this mac. | |
1075 | */ | |
1076 | if (WARN_ON_ONCE(data->current_filter >= | |
1077 | ARRAY_SIZE(cmd->filters))) { | |
1078 | bcast_mac->default_discard = 0; | |
1079 | bcast_mac->attached_filters = 0; | |
1080 | break; | |
1081 | } | |
1082 | ||
1083 | iwl_mvm_set_bcast_filter(vif, | |
1084 | &mvm->bcast_filters[i], | |
1085 | &cmd->filters[data->current_filter]); | |
1086 | ||
1087 | /* skip current filter if it contains no attributes */ | |
1088 | if (!cmd->filters[data->current_filter].num_attrs) | |
1089 | continue; | |
1090 | ||
1091 | /* attach the filter to current mac */ | |
1092 | bcast_mac->attached_filters |= | |
1093 | cpu_to_le16(BIT(data->current_filter)); | |
1094 | ||
1095 | data->current_filter++; | |
1096 | } | |
1097 | } | |
1098 | ||
de06a59e EP |
1099 | bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm *mvm, |
1100 | struct iwl_bcast_filter_cmd *cmd) | |
c87163b9 | 1101 | { |
c87163b9 EP |
1102 | struct iwl_bcast_iter_data iter_data = { |
1103 | .mvm = mvm, | |
de06a59e | 1104 | .cmd = cmd, |
c87163b9 EP |
1105 | }; |
1106 | ||
de06a59e EP |
1107 | memset(cmd, 0, sizeof(*cmd)); |
1108 | cmd->max_bcast_filters = ARRAY_SIZE(cmd->filters); | |
1109 | cmd->max_macs = ARRAY_SIZE(cmd->macs); | |
1110 | ||
1111 | #ifdef CONFIG_IWLWIFI_DEBUGFS | |
1112 | /* use debugfs filters/macs if override is configured */ | |
1113 | if (mvm->dbgfs_bcast_filtering.override) { | |
1114 | memcpy(cmd->filters, &mvm->dbgfs_bcast_filtering.cmd.filters, | |
1115 | sizeof(cmd->filters)); | |
1116 | memcpy(cmd->macs, &mvm->dbgfs_bcast_filtering.cmd.macs, | |
1117 | sizeof(cmd->macs)); | |
1118 | return true; | |
1119 | } | |
1120 | #endif | |
c87163b9 EP |
1121 | |
1122 | /* if no filters are configured, do nothing */ | |
1123 | if (!mvm->bcast_filters) | |
de06a59e | 1124 | return false; |
c87163b9 EP |
1125 | |
1126 | /* configure and attach these filters for each associated sta vif */ | |
1127 | ieee80211_iterate_active_interfaces( | |
1128 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
1129 | iwl_mvm_bcast_filter_iterator, &iter_data); | |
1130 | ||
de06a59e EP |
1131 | return true; |
1132 | } | |
1133 | static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, | |
1134 | struct ieee80211_vif *vif) | |
1135 | { | |
1136 | struct iwl_bcast_filter_cmd cmd; | |
1137 | ||
1138 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) | |
1139 | return 0; | |
1140 | ||
1141 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) | |
1142 | return 0; | |
1143 | ||
c87163b9 EP |
1144 | return iwl_mvm_send_cmd_pdu(mvm, BCAST_FILTER_CMD, CMD_SYNC, |
1145 | sizeof(cmd), &cmd); | |
1146 | } | |
1147 | #else | |
1148 | static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, | |
1149 | struct ieee80211_vif *vif) | |
1150 | { | |
1151 | return 0; | |
1152 | } | |
1153 | #endif | |
1154 | ||
8ca151b5 JB |
1155 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
1156 | struct ieee80211_vif *vif, | |
1157 | struct ieee80211_bss_conf *bss_conf, | |
1158 | u32 changes) | |
1159 | { | |
1160 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1161 | int ret; | |
1162 | ||
6e97b0d2 IP |
1163 | /* |
1164 | * Re-calculate the tsf id, as the master-slave relations depend on the | |
1165 | * beacon interval, which was not known when the station interface was | |
1166 | * added. | |
1167 | */ | |
1168 | if (changes & BSS_CHANGED_ASSOC && bss_conf->assoc) | |
1169 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); | |
1170 | ||
8ca151b5 JB |
1171 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); |
1172 | if (ret) | |
1173 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); | |
1174 | ||
1175 | if (changes & BSS_CHANGED_ASSOC) { | |
1176 | if (bss_conf->assoc) { | |
1177 | /* add quota for this interface */ | |
1178 | ret = iwl_mvm_update_quotas(mvm, vif); | |
1179 | if (ret) { | |
1180 | IWL_ERR(mvm, "failed to update quotas\n"); | |
1181 | return; | |
1182 | } | |
016d27e1 JB |
1183 | |
1184 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, | |
1185 | &mvm->status)) { | |
1186 | /* | |
1187 | * If we're restarting then the firmware will | |
1188 | * obviously have lost synchronisation with | |
1189 | * the AP. It will attempt to synchronise by | |
1190 | * itself, but we can make it more reliable by | |
1191 | * scheduling a session protection time event. | |
1192 | * | |
1193 | * The firmware needs to receive a beacon to | |
1194 | * catch up with synchronisation, use 110% of | |
1195 | * the beacon interval. | |
1196 | * | |
1197 | * Set a large maximum delay to allow for more | |
1198 | * than a single interface. | |
1199 | */ | |
1200 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; | |
1201 | iwl_mvm_protect_session(mvm, vif, dur, dur, | |
1202 | 5 * dur); | |
1203 | } | |
1f3b0ff8 LE |
1204 | |
1205 | iwl_mvm_sf_update(mvm, vif, false); | |
175a70b7 | 1206 | iwl_mvm_power_vif_assoc(mvm, vif); |
29a90a49 EP |
1207 | if (vif->p2p) |
1208 | iwl_mvm_ref(mvm, IWL_MVM_REF_P2P_CLIENT); | |
8ca151b5 | 1209 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
1f3b0ff8 LE |
1210 | /* |
1211 | * If update fails - SF might be running in associated | |
1212 | * mode while disassociated - which is forbidden. | |
1213 | */ | |
1214 | WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false), | |
1215 | "Failed to update SF upon disassociation\n"); | |
1216 | ||
8ca151b5 JB |
1217 | /* remove AP station now that the MAC is unassoc */ |
1218 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); | |
1219 | if (ret) | |
1220 | IWL_ERR(mvm, "failed to remove AP station\n"); | |
37577fe2 EP |
1221 | |
1222 | if (mvm->d0i3_ap_sta_id == mvmvif->ap_sta_id) | |
1223 | mvm->d0i3_ap_sta_id = IWL_MVM_STATION_COUNT; | |
8ca151b5 JB |
1224 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; |
1225 | /* remove quota for this interface */ | |
1226 | ret = iwl_mvm_update_quotas(mvm, NULL); | |
1227 | if (ret) | |
1228 | IWL_ERR(mvm, "failed to update quotas\n"); | |
29a90a49 EP |
1229 | |
1230 | if (vif->p2p) | |
1231 | iwl_mvm_unref(mvm, IWL_MVM_REF_P2P_CLIENT); | |
8ca151b5 | 1232 | } |
a20fd398 | 1233 | |
e59647ea | 1234 | iwl_mvm_recalc_multicast(mvm); |
c87163b9 | 1235 | iwl_mvm_configure_bcast_filter(mvm, vif); |
e59647ea | 1236 | |
a20fd398 AO |
1237 | /* reset rssi values */ |
1238 | mvmvif->bf_data.ave_beacon_signal = 0; | |
1239 | ||
e8e626ad AB |
1240 | if (!(mvm->fw->ucode_capa.flags & |
1241 | IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT)) { | |
e811ada7 AB |
1242 | /* Workaround for FW bug, otherwise FW disables device |
1243 | * power save upon disassociation | |
1244 | */ | |
1245 | ret = iwl_mvm_power_update_mode(mvm, vif); | |
1246 | if (ret) | |
1247 | IWL_ERR(mvm, "failed to update power mode\n"); | |
1248 | } | |
8e484f0b | 1249 | iwl_mvm_bt_coex_vif_change(mvm); |
f94045ed EG |
1250 | iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_TT, |
1251 | IEEE80211_SMPS_AUTOMATIC); | |
989c6505 | 1252 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
210a544e JB |
1253 | /* |
1254 | * We received a beacon _after_ association so | |
1255 | * remove the session protection. | |
1256 | */ | |
1257 | iwl_mvm_remove_time_event(mvm, mvmvif, | |
1258 | &mvmvif->time_event_data); | |
51498cf6 AB |
1259 | } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_P2P_PS | |
1260 | BSS_CHANGED_QOS)) { | |
4bf881f5 AB |
1261 | ret = iwl_mvm_power_update_mode(mvm, vif); |
1262 | if (ret) | |
1263 | IWL_ERR(mvm, "failed to update power mode\n"); | |
8ca151b5 | 1264 | } |
88f2fd73 MG |
1265 | if (changes & BSS_CHANGED_TXPOWER) { |
1266 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | |
1267 | bss_conf->txpower); | |
1268 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | |
1269 | } | |
a20fd398 AO |
1270 | |
1271 | if (changes & BSS_CHANGED_CQM) { | |
1272 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed"); | |
1273 | /* reset cqm events tracking */ | |
1274 | mvmvif->bf_data.last_cqm_event = 0; | |
3dd37d05 | 1275 | ret = iwl_mvm_update_beacon_filter(mvm, vif, false, CMD_SYNC); |
a20fd398 AO |
1276 | if (ret) |
1277 | IWL_ERR(mvm, "failed to update CQM thresholds\n"); | |
1278 | } | |
2ee8f021 EP |
1279 | |
1280 | if (changes & BSS_CHANGED_ARP_FILTER) { | |
1281 | IWL_DEBUG_MAC80211(mvm, "arp filter changed"); | |
1282 | iwl_mvm_configure_bcast_filter(mvm, vif); | |
1283 | } | |
8ca151b5 JB |
1284 | } |
1285 | ||
5023d966 JB |
1286 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
1287 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
1288 | { |
1289 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1290 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1291 | int ret; | |
1292 | ||
1293 | mutex_lock(&mvm->mutex); | |
1294 | ||
1295 | /* Send the beacon template */ | |
1296 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); | |
1297 | if (ret) | |
1298 | goto out_unlock; | |
1299 | ||
6e97b0d2 IP |
1300 | /* |
1301 | * Re-calculate the tsf id, as the master-slave relations depend on the | |
1302 | * beacon interval, which was not known when the AP interface was added. | |
1303 | */ | |
1304 | if (vif->type == NL80211_IFTYPE_AP) | |
1305 | iwl_mvm_mac_ctxt_recalc_tsf_id(mvm, vif); | |
1306 | ||
8ca151b5 JB |
1307 | /* Add the mac context */ |
1308 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); | |
1309 | if (ret) | |
1310 | goto out_unlock; | |
1311 | ||
1312 | /* Perform the binding */ | |
1313 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1314 | if (ret) | |
1315 | goto out_remove; | |
1316 | ||
5023d966 | 1317 | mvmvif->ap_ibss_active = true; |
8ca151b5 JB |
1318 | |
1319 | /* Send the bcast station. At this stage the TBTT and DTIM time events | |
1320 | * are added and applied to the scheduler */ | |
1321 | ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta); | |
1322 | if (ret) | |
1323 | goto out_unbind; | |
1324 | ||
5691e218 IP |
1325 | /* must be set before quota calculations */ |
1326 | mvmvif->ap_ibss_active = true; | |
1327 | ||
a11e144e IP |
1328 | /* power updated needs to be done before quotas */ |
1329 | mvm->bound_vif_cnt++; | |
1330 | iwl_mvm_power_update_binding(mvm, vif, true); | |
1331 | ||
8ca151b5 JB |
1332 | ret = iwl_mvm_update_quotas(mvm, vif); |
1333 | if (ret) | |
a11e144e | 1334 | goto out_quota_failed; |
8ca151b5 | 1335 | |
5023d966 | 1336 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 JB |
1337 | if (vif->p2p && mvm->p2p_device_vif) |
1338 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); | |
1339 | ||
29a90a49 EP |
1340 | iwl_mvm_ref(mvm, IWL_MVM_REF_AP_IBSS); |
1341 | ||
8e484f0b | 1342 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 1343 | |
8ca151b5 JB |
1344 | mutex_unlock(&mvm->mutex); |
1345 | return 0; | |
1346 | ||
a11e144e IP |
1347 | out_quota_failed: |
1348 | mvm->bound_vif_cnt--; | |
1349 | iwl_mvm_power_update_binding(mvm, vif, false); | |
5691e218 | 1350 | mvmvif->ap_ibss_active = false; |
8ca151b5 JB |
1351 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); |
1352 | out_unbind: | |
1353 | iwl_mvm_binding_remove_vif(mvm, vif); | |
1354 | out_remove: | |
1355 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
1356 | out_unlock: | |
1357 | mutex_unlock(&mvm->mutex); | |
1358 | return ret; | |
1359 | } | |
1360 | ||
5023d966 JB |
1361 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
1362 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
1363 | { |
1364 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1365 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1366 | ||
38a12b5b JB |
1367 | iwl_mvm_prepare_mac_removal(mvm, vif); |
1368 | ||
8ca151b5 JB |
1369 | mutex_lock(&mvm->mutex); |
1370 | ||
5023d966 | 1371 | mvmvif->ap_ibss_active = false; |
8ca151b5 | 1372 | |
8e484f0b | 1373 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 1374 | |
29a90a49 EP |
1375 | iwl_mvm_unref(mvm, IWL_MVM_REF_AP_IBSS); |
1376 | ||
5023d966 | 1377 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 JB |
1378 | if (vif->p2p && mvm->p2p_device_vif) |
1379 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); | |
1380 | ||
1381 | iwl_mvm_update_quotas(mvm, NULL); | |
1382 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); | |
1383 | iwl_mvm_binding_remove_vif(mvm, vif); | |
a11e144e IP |
1384 | |
1385 | mvm->bound_vif_cnt--; | |
1386 | iwl_mvm_power_update_binding(mvm, vif, false); | |
1387 | ||
8ca151b5 JB |
1388 | iwl_mvm_mac_ctxt_remove(mvm, vif); |
1389 | ||
1390 | mutex_unlock(&mvm->mutex); | |
1391 | } | |
1392 | ||
5023d966 JB |
1393 | static void |
1394 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, | |
1395 | struct ieee80211_vif *vif, | |
1396 | struct ieee80211_bss_conf *bss_conf, | |
1397 | u32 changes) | |
8ca151b5 | 1398 | { |
be2056fc | 1399 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8a5e3660 AA |
1400 | enum ieee80211_bss_change ht_change = BSS_CHANGED_ERP_CTS_PROT | |
1401 | BSS_CHANGED_HT | | |
1402 | BSS_CHANGED_BANDWIDTH; | |
1403 | int ret; | |
1404 | ||
be2056fc IP |
1405 | /* Changes will be applied when the AP/IBSS is started */ |
1406 | if (!mvmvif->ap_ibss_active) | |
1407 | return; | |
1408 | ||
8a5e3660 AA |
1409 | if (changes & ht_change) { |
1410 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); | |
1411 | if (ret) | |
1412 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); | |
1413 | } | |
1414 | ||
8ca151b5 JB |
1415 | /* Need to send a new beacon template to the FW */ |
1416 | if (changes & BSS_CHANGED_BEACON) { | |
1417 | if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) | |
1418 | IWL_WARN(mvm, "Failed updating beacon data\n"); | |
1419 | } | |
1420 | } | |
1421 | ||
1422 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, | |
1423 | struct ieee80211_vif *vif, | |
1424 | struct ieee80211_bss_conf *bss_conf, | |
1425 | u32 changes) | |
1426 | { | |
1427 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1428 | ||
1429 | mutex_lock(&mvm->mutex); | |
1430 | ||
1431 | switch (vif->type) { | |
1432 | case NL80211_IFTYPE_STATION: | |
1433 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); | |
1434 | break; | |
1435 | case NL80211_IFTYPE_AP: | |
5023d966 JB |
1436 | case NL80211_IFTYPE_ADHOC: |
1437 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); | |
8ca151b5 JB |
1438 | break; |
1439 | default: | |
1440 | /* shouldn't happen */ | |
1441 | WARN_ON_ONCE(1); | |
1442 | } | |
1443 | ||
1444 | mutex_unlock(&mvm->mutex); | |
1445 | } | |
1446 | ||
1447 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, | |
1448 | struct ieee80211_vif *vif, | |
1449 | struct cfg80211_scan_request *req) | |
1450 | { | |
1451 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
a6623e84 JB |
1452 | struct iwl_notification_wait wait_scan_done; |
1453 | static const u8 scan_done_notif[] = { SCAN_OFFLOAD_COMPLETE, }; | |
8ca151b5 JB |
1454 | int ret; |
1455 | ||
1456 | if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS) | |
1457 | return -EINVAL; | |
1458 | ||
1459 | mutex_lock(&mvm->mutex); | |
1460 | ||
a6623e84 JB |
1461 | switch (mvm->scan_status) { |
1462 | case IWL_MVM_SCAN_SCHED: | |
1463 | iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_done, | |
1464 | scan_done_notif, | |
1465 | ARRAY_SIZE(scan_done_notif), | |
1466 | NULL, NULL); | |
1467 | iwl_mvm_sched_scan_stop(mvm); | |
1468 | ret = iwl_wait_notification(&mvm->notif_wait, | |
1469 | &wait_scan_done, HZ); | |
1470 | if (ret) { | |
1471 | ret = -EBUSY; | |
1472 | goto out; | |
1473 | } | |
1474 | /* iwl_mvm_rx_scan_offload_complete_notif() will be called | |
1475 | * soon but will not reset the scan status as it won't be | |
1476 | * IWL_MVM_SCAN_SCHED any more since we queue the next scan | |
1477 | * immediately (below) | |
1478 | */ | |
1479 | break; | |
1480 | case IWL_MVM_SCAN_NONE: | |
1481 | break; | |
1482 | default: | |
8ca151b5 | 1483 | ret = -EBUSY; |
519e2026 AN |
1484 | goto out; |
1485 | } | |
8ca151b5 | 1486 | |
519e2026 AN |
1487 | iwl_mvm_ref(mvm, IWL_MVM_REF_SCAN); |
1488 | ||
1489 | ret = iwl_mvm_scan_request(mvm, vif, req); | |
1490 | if (ret) | |
1491 | iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN); | |
1492 | out: | |
8ca151b5 JB |
1493 | mutex_unlock(&mvm->mutex); |
1494 | ||
1495 | return ret; | |
1496 | } | |
1497 | ||
1498 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, | |
1499 | struct ieee80211_vif *vif) | |
1500 | { | |
1501 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1502 | ||
1503 | mutex_lock(&mvm->mutex); | |
1504 | ||
1505 | iwl_mvm_cancel_scan(mvm); | |
1506 | ||
1507 | mutex_unlock(&mvm->mutex); | |
1508 | } | |
1509 | ||
1510 | static void | |
1511 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, | |
3e56eadf | 1512 | struct ieee80211_sta *sta, u16 tids, |
8ca151b5 JB |
1513 | int num_frames, |
1514 | enum ieee80211_frame_release_type reason, | |
1515 | bool more_data) | |
1516 | { | |
1517 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
8ca151b5 | 1518 | |
3e56eadf | 1519 | /* Called when we need to transmit (a) frame(s) from mac80211 */ |
8ca151b5 | 1520 | |
3e56eadf JB |
1521 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, |
1522 | tids, more_data, false); | |
1523 | } | |
1524 | ||
1525 | static void | |
1526 | iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw, | |
1527 | struct ieee80211_sta *sta, u16 tids, | |
1528 | int num_frames, | |
1529 | enum ieee80211_frame_release_type reason, | |
1530 | bool more_data) | |
1531 | { | |
1532 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1533 | ||
1534 | /* Called when we need to transmit (a) frame(s) from agg queue */ | |
1535 | ||
1536 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames, | |
1537 | tids, more_data, true); | |
8ca151b5 JB |
1538 | } |
1539 | ||
1540 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, | |
1541 | struct ieee80211_vif *vif, | |
1542 | enum sta_notify_cmd cmd, | |
1543 | struct ieee80211_sta *sta) | |
1544 | { | |
1545 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
5b577a90 | 1546 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
3e56eadf | 1547 | int tid; |
8ca151b5 JB |
1548 | |
1549 | switch (cmd) { | |
1550 | case STA_NOTIFY_SLEEP: | |
e3d4bc8c | 1551 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
8ca151b5 | 1552 | ieee80211_sta_block_awake(hw, sta, true); |
3e56eadf JB |
1553 | spin_lock_bh(&mvmsta->lock); |
1554 | for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) { | |
1555 | struct iwl_mvm_tid_data *tid_data; | |
1556 | ||
1557 | tid_data = &mvmsta->tid_data[tid]; | |
1558 | if (tid_data->state != IWL_AGG_ON && | |
1559 | tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA) | |
1560 | continue; | |
1561 | if (iwl_mvm_tid_queued(tid_data) == 0) | |
1562 | continue; | |
1563 | ieee80211_sta_set_buffered(sta, tid, true); | |
1564 | } | |
1565 | spin_unlock_bh(&mvmsta->lock); | |
8ca151b5 JB |
1566 | /* |
1567 | * The fw updates the STA to be asleep. Tx packets on the Tx | |
1568 | * queues to this station will not be transmitted. The fw will | |
1569 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. | |
1570 | */ | |
1571 | break; | |
1572 | case STA_NOTIFY_AWAKE: | |
881acd89 | 1573 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
8ca151b5 | 1574 | break; |
9cc40712 | 1575 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
8ca151b5 JB |
1576 | break; |
1577 | default: | |
1578 | break; | |
1579 | } | |
1580 | } | |
1581 | ||
1ddbbb0c JB |
1582 | static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw, |
1583 | struct ieee80211_vif *vif, | |
1584 | struct ieee80211_sta *sta) | |
1585 | { | |
1586 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1587 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; | |
1588 | ||
1589 | /* | |
1590 | * This is called before mac80211 does RCU synchronisation, | |
1591 | * so here we already invalidate our internal RCU-protected | |
1592 | * station pointer. The rest of the code will thus no longer | |
1593 | * be able to find the station this way, and we don't rely | |
1594 | * on further RCU synchronisation after the sta_state() | |
1595 | * callback deleted the station. | |
1596 | */ | |
1597 | mutex_lock(&mvm->mutex); | |
1598 | if (sta == rcu_access_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id])) | |
1599 | rcu_assign_pointer(mvm->fw_id_to_mac_id[mvm_sta->sta_id], | |
1600 | ERR_PTR(-ENOENT)); | |
1601 | mutex_unlock(&mvm->mutex); | |
1602 | } | |
1603 | ||
8ca151b5 JB |
1604 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, |
1605 | struct ieee80211_vif *vif, | |
1606 | struct ieee80211_sta *sta, | |
1607 | enum ieee80211_sta_state old_state, | |
1608 | enum ieee80211_sta_state new_state) | |
1609 | { | |
1610 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1611 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1612 | int ret; | |
1613 | ||
1614 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", | |
1615 | sta->addr, old_state, new_state); | |
1616 | ||
1617 | /* this would be a mac80211 bug ... but don't crash */ | |
1618 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) | |
1619 | return -EINVAL; | |
1620 | ||
1621 | /* if a STA is being removed, reuse its ID */ | |
1622 | flush_work(&mvm->sta_drained_wk); | |
1623 | ||
1624 | mutex_lock(&mvm->mutex); | |
1625 | if (old_state == IEEE80211_STA_NOTEXIST && | |
1626 | new_state == IEEE80211_STA_NONE) { | |
48bc1307 JB |
1627 | /* |
1628 | * Firmware bug - it'll crash if the beacon interval is less | |
1629 | * than 16. We can't avoid connecting at all, so refuse the | |
1630 | * station state change, this will cause mac80211 to abandon | |
1631 | * attempts to connect to this AP, and eventually wpa_s will | |
1632 | * blacklist the AP... | |
1633 | */ | |
1634 | if (vif->type == NL80211_IFTYPE_STATION && | |
1635 | vif->bss_conf.beacon_int < 16) { | |
1636 | IWL_ERR(mvm, | |
1637 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", | |
1638 | sta->addr, vif->bss_conf.beacon_int); | |
1639 | ret = -EINVAL; | |
1640 | goto out_unlock; | |
1641 | } | |
8ca151b5 JB |
1642 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
1643 | } else if (old_state == IEEE80211_STA_NONE && | |
1644 | new_state == IEEE80211_STA_AUTH) { | |
1645 | ret = 0; | |
1646 | } else if (old_state == IEEE80211_STA_AUTH && | |
1647 | new_state == IEEE80211_STA_ASSOC) { | |
7a453973 JB |
1648 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
1649 | if (ret == 0) | |
1650 | iwl_mvm_rs_rate_init(mvm, sta, | |
b87c2179 ES |
1651 | mvmvif->phy_ctxt->channel->band, |
1652 | true); | |
8ca151b5 JB |
1653 | } else if (old_state == IEEE80211_STA_ASSOC && |
1654 | new_state == IEEE80211_STA_AUTHORIZED) { | |
7df15b1e | 1655 | /* enable beacon filtering */ |
3dd37d05 | 1656 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, CMD_SYNC)); |
8ca151b5 JB |
1657 | ret = 0; |
1658 | } else if (old_state == IEEE80211_STA_AUTHORIZED && | |
1659 | new_state == IEEE80211_STA_ASSOC) { | |
7df15b1e | 1660 | /* disable beacon filtering */ |
3dd37d05 | 1661 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif, CMD_SYNC)); |
8ca151b5 JB |
1662 | ret = 0; |
1663 | } else if (old_state == IEEE80211_STA_ASSOC && | |
1664 | new_state == IEEE80211_STA_AUTH) { | |
1665 | ret = 0; | |
1666 | } else if (old_state == IEEE80211_STA_AUTH && | |
1667 | new_state == IEEE80211_STA_NONE) { | |
1668 | ret = 0; | |
1669 | } else if (old_state == IEEE80211_STA_NONE && | |
1670 | new_state == IEEE80211_STA_NOTEXIST) { | |
1671 | ret = iwl_mvm_rm_sta(mvm, vif, sta); | |
1672 | } else { | |
1673 | ret = -EIO; | |
1674 | } | |
48bc1307 | 1675 | out_unlock: |
8ca151b5 JB |
1676 | mutex_unlock(&mvm->mutex); |
1677 | ||
1678 | return ret; | |
1679 | } | |
1680 | ||
1681 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | |
1682 | { | |
1683 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1684 | ||
1685 | mvm->rts_threshold = value; | |
1686 | ||
1687 | return 0; | |
1688 | } | |
1689 | ||
1f3b0ff8 LE |
1690 | static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, |
1691 | struct ieee80211_vif *vif, | |
1692 | struct ieee80211_sta *sta, u32 changed) | |
1693 | { | |
1694 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1695 | ||
1696 | if (vif->type == NL80211_IFTYPE_STATION && | |
1697 | changed & IEEE80211_RC_NSS_CHANGED) | |
1698 | iwl_mvm_sf_update(mvm, vif, false); | |
1699 | } | |
1700 | ||
8ca151b5 JB |
1701 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
1702 | struct ieee80211_vif *vif, u16 ac, | |
1703 | const struct ieee80211_tx_queue_params *params) | |
1704 | { | |
1705 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1706 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1707 | ||
1708 | mvmvif->queue_params[ac] = *params; | |
1709 | ||
1710 | /* | |
1711 | * No need to update right away, we'll get BSS_CHANGED_QOS | |
1712 | * The exception is P2P_DEVICE interface which needs immediate update. | |
1713 | */ | |
1714 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
1715 | int ret; | |
1716 | ||
1717 | mutex_lock(&mvm->mutex); | |
1718 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); | |
1719 | mutex_unlock(&mvm->mutex); | |
1720 | return ret; | |
1721 | } | |
1722 | return 0; | |
1723 | } | |
1724 | ||
1725 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, | |
1726 | struct ieee80211_vif *vif) | |
1727 | { | |
1728 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1729 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, | |
1730 | 200 + vif->bss_conf.beacon_int); | |
1731 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, | |
1732 | 100 + vif->bss_conf.beacon_int); | |
1733 | ||
1734 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) | |
1735 | return; | |
1736 | ||
1737 | mutex_lock(&mvm->mutex); | |
1738 | /* Try really hard to protect the session and hear a beacon */ | |
016d27e1 | 1739 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500); |
8ca151b5 JB |
1740 | mutex_unlock(&mvm->mutex); |
1741 | } | |
1742 | ||
35a000b7 DS |
1743 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
1744 | struct ieee80211_vif *vif, | |
1745 | struct cfg80211_sched_scan_request *req, | |
1746 | struct ieee80211_sched_scan_ies *ies) | |
1747 | { | |
1748 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1749 | int ret; | |
1750 | ||
1751 | mutex_lock(&mvm->mutex); | |
1752 | ||
1753 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { | |
1754 | IWL_DEBUG_SCAN(mvm, | |
1755 | "SCHED SCAN request during internal scan - abort\n"); | |
1756 | ret = -EBUSY; | |
1757 | goto out; | |
1758 | } | |
1759 | ||
1760 | mvm->scan_status = IWL_MVM_SCAN_SCHED; | |
1761 | ||
1762 | ret = iwl_mvm_config_sched_scan(mvm, vif, req, ies); | |
1763 | if (ret) | |
1764 | goto err; | |
1765 | ||
1766 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); | |
1767 | if (ret) | |
1768 | goto err; | |
1769 | ||
1770 | ret = iwl_mvm_sched_scan_start(mvm, req); | |
1771 | if (!ret) | |
1772 | goto out; | |
1773 | err: | |
1774 | mvm->scan_status = IWL_MVM_SCAN_NONE; | |
1775 | out: | |
1776 | mutex_unlock(&mvm->mutex); | |
1777 | return ret; | |
1778 | } | |
1779 | ||
1780 | static void iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, | |
1781 | struct ieee80211_vif *vif) | |
1782 | { | |
1783 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1784 | ||
1785 | mutex_lock(&mvm->mutex); | |
1786 | iwl_mvm_sched_scan_stop(mvm); | |
1787 | mutex_unlock(&mvm->mutex); | |
1788 | } | |
1789 | ||
8ca151b5 JB |
1790 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
1791 | enum set_key_cmd cmd, | |
1792 | struct ieee80211_vif *vif, | |
1793 | struct ieee80211_sta *sta, | |
1794 | struct ieee80211_key_conf *key) | |
1795 | { | |
1796 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1797 | int ret; | |
1798 | ||
1799 | if (iwlwifi_mod_params.sw_crypto) { | |
1800 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); | |
1801 | return -EOPNOTSUPP; | |
1802 | } | |
1803 | ||
1804 | switch (key->cipher) { | |
1805 | case WLAN_CIPHER_SUITE_TKIP: | |
1806 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | |
1807 | /* fall-through */ | |
1808 | case WLAN_CIPHER_SUITE_CCMP: | |
1809 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | |
1810 | break; | |
1811 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
1812 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); | |
1813 | break; | |
1814 | case WLAN_CIPHER_SUITE_WEP40: | |
1815 | case WLAN_CIPHER_SUITE_WEP104: | |
1816 | /* | |
1817 | * Support for TX only, at least for now, so accept | |
1818 | * the key and do nothing else. Then mac80211 will | |
1819 | * pass it for TX but we don't have to use it for RX. | |
1820 | */ | |
1821 | return 0; | |
1822 | default: | |
e36e5433 MS |
1823 | /* currently FW supports only one optional cipher scheme */ |
1824 | if (hw->n_cipher_schemes && | |
1825 | hw->cipher_schemes->cipher == key->cipher) | |
1826 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; | |
1827 | else | |
1828 | return -EOPNOTSUPP; | |
8ca151b5 JB |
1829 | } |
1830 | ||
1831 | mutex_lock(&mvm->mutex); | |
1832 | ||
1833 | switch (cmd) { | |
1834 | case SET_KEY: | |
5023d966 JB |
1835 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
1836 | vif->type == NL80211_IFTYPE_AP) && !sta) { | |
1837 | /* | |
1838 | * GTK on AP interface is a TX-only key, return 0; | |
1839 | * on IBSS they're per-station and because we're lazy | |
1840 | * we don't support them for RX, so do the same. | |
1841 | */ | |
6caffd4f JB |
1842 | ret = 0; |
1843 | key->hw_key_idx = STA_KEY_IDX_INVALID; | |
1844 | break; | |
1845 | } | |
1846 | ||
8ca151b5 JB |
1847 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
1848 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); | |
1849 | if (ret) { | |
1850 | IWL_WARN(mvm, "set key failed\n"); | |
1851 | /* | |
1852 | * can't add key for RX, but we don't need it | |
1853 | * in the device for TX so still return 0 | |
1854 | */ | |
6caffd4f | 1855 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
8ca151b5 JB |
1856 | ret = 0; |
1857 | } | |
1858 | ||
1859 | break; | |
1860 | case DISABLE_KEY: | |
6caffd4f JB |
1861 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
1862 | ret = 0; | |
1863 | break; | |
1864 | } | |
1865 | ||
8ca151b5 JB |
1866 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
1867 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); | |
1868 | break; | |
1869 | default: | |
1870 | ret = -EINVAL; | |
1871 | } | |
1872 | ||
1873 | mutex_unlock(&mvm->mutex); | |
1874 | return ret; | |
1875 | } | |
1876 | ||
1877 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, | |
1878 | struct ieee80211_vif *vif, | |
1879 | struct ieee80211_key_conf *keyconf, | |
1880 | struct ieee80211_sta *sta, | |
1881 | u32 iv32, u16 *phase1key) | |
1882 | { | |
1883 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1884 | ||
5023d966 JB |
1885 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
1886 | return; | |
1887 | ||
8ca151b5 JB |
1888 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
1889 | } | |
1890 | ||
1891 | ||
1892 | static int iwl_mvm_roc(struct ieee80211_hw *hw, | |
1893 | struct ieee80211_vif *vif, | |
1894 | struct ieee80211_channel *channel, | |
d339d5ca IP |
1895 | int duration, |
1896 | enum ieee80211_roc_type type) | |
8ca151b5 JB |
1897 | { |
1898 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 | 1899 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8ca151b5 | 1900 | struct cfg80211_chan_def chandef; |
31d385ae IP |
1901 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
1902 | int ret, i; | |
1903 | ||
1904 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, | |
1905 | duration, type); | |
8ca151b5 JB |
1906 | |
1907 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) { | |
1908 | IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type); | |
1909 | return -EINVAL; | |
1910 | } | |
1911 | ||
8ca151b5 JB |
1912 | mutex_lock(&mvm->mutex); |
1913 | ||
31d385ae IP |
1914 | for (i = 0; i < NUM_PHY_CTX; i++) { |
1915 | phy_ctxt = &mvm->phy_ctxts[i]; | |
1916 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) | |
1917 | continue; | |
1918 | ||
1919 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { | |
1920 | /* | |
1921 | * Unbind the P2P_DEVICE from the current PHY context, | |
1922 | * and if the PHY context is not used remove it. | |
1923 | */ | |
1924 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
1925 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
1926 | goto out_unlock; | |
1927 | ||
1928 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
1929 | ||
1930 | /* Bind the P2P_DEVICE to the current PHY Context */ | |
1931 | mvmvif->phy_ctxt = phy_ctxt; | |
1932 | ||
1933 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1934 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
1935 | goto out_unlock; | |
1936 | ||
1937 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
1938 | goto schedule_time_event; | |
1939 | } | |
1940 | } | |
1941 | ||
1942 | /* Need to update the PHY context only if the ROC channel changed */ | |
1943 | if (channel == mvmvif->phy_ctxt->channel) | |
1944 | goto schedule_time_event; | |
1945 | ||
8ca151b5 | 1946 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
8ca151b5 | 1947 | |
31d385ae IP |
1948 | /* |
1949 | * Change the PHY context configuration as it is currently referenced | |
1950 | * only by the P2P Device MAC | |
1951 | */ | |
1952 | if (mvmvif->phy_ctxt->ref == 1) { | |
1953 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, | |
1954 | &chandef, 1, 1); | |
1955 | if (ret) | |
1956 | goto out_unlock; | |
1957 | } else { | |
1958 | /* | |
1959 | * The PHY context is shared with other MACs. Need to remove the | |
1960 | * P2P Device from the binding, allocate an new PHY context and | |
1961 | * create a new binding | |
1962 | */ | |
1963 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); | |
1964 | if (!phy_ctxt) { | |
1965 | ret = -ENOSPC; | |
1966 | goto out_unlock; | |
1967 | } | |
1968 | ||
1969 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, | |
1970 | 1, 1); | |
1971 | if (ret) { | |
1972 | IWL_ERR(mvm, "Failed to change PHY context\n"); | |
1973 | goto out_unlock; | |
1974 | } | |
1975 | ||
1976 | /* Unbind the P2P_DEVICE from the current PHY context */ | |
1977 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
1978 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
1979 | goto out_unlock; | |
1980 | ||
1981 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
1982 | ||
1983 | /* Bind the P2P_DEVICE to the new allocated PHY context */ | |
1984 | mvmvif->phy_ctxt = phy_ctxt; | |
1985 | ||
1986 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1987 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
1988 | goto out_unlock; | |
1989 | ||
1990 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
1991 | } | |
1992 | ||
1993 | schedule_time_event: | |
8ca151b5 | 1994 | /* Schedule the time events */ |
e635c797 | 1995 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
8ca151b5 | 1996 | |
31d385ae | 1997 | out_unlock: |
8ca151b5 JB |
1998 | mutex_unlock(&mvm->mutex); |
1999 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
8ca151b5 JB |
2000 | return ret; |
2001 | } | |
2002 | ||
2003 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) | |
2004 | { | |
2005 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2006 | ||
2007 | IWL_DEBUG_MAC80211(mvm, "enter\n"); | |
2008 | ||
2009 | mutex_lock(&mvm->mutex); | |
2010 | iwl_mvm_stop_p2p_roc(mvm); | |
2011 | mutex_unlock(&mvm->mutex); | |
2012 | ||
2013 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
2014 | return 0; | |
2015 | } | |
2016 | ||
2017 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, | |
2018 | struct ieee80211_chanctx_conf *ctx) | |
2019 | { | |
2020 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
2021 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2022 | struct iwl_mvm_phy_ctxt *phy_ctxt; | |
8ca151b5 JB |
2023 | int ret; |
2024 | ||
53a9d61e | 2025 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
fe0f2de3 | 2026 | |
8ca151b5 | 2027 | mutex_lock(&mvm->mutex); |
fe0f2de3 IP |
2028 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
2029 | if (!phy_ctxt) { | |
2030 | ret = -ENOSPC; | |
2031 | goto out; | |
2032 | } | |
8ca151b5 | 2033 | |
dcbc3e1a | 2034 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
53a9d61e IP |
2035 | ctx->rx_chains_static, |
2036 | ctx->rx_chains_dynamic); | |
fe0f2de3 IP |
2037 | if (ret) { |
2038 | IWL_ERR(mvm, "Failed to add PHY context\n"); | |
2039 | goto out; | |
2040 | } | |
2041 | ||
53a9d61e | 2042 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
fe0f2de3 IP |
2043 | *phy_ctxt_id = phy_ctxt->id; |
2044 | out: | |
8ca151b5 JB |
2045 | mutex_unlock(&mvm->mutex); |
2046 | return ret; | |
2047 | } | |
2048 | ||
2049 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, | |
2050 | struct ieee80211_chanctx_conf *ctx) | |
2051 | { | |
2052 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
2053 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2054 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 JB |
2055 | |
2056 | mutex_lock(&mvm->mutex); | |
fe0f2de3 | 2057 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
8ca151b5 JB |
2058 | mutex_unlock(&mvm->mutex); |
2059 | } | |
2060 | ||
2061 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, | |
2062 | struct ieee80211_chanctx_conf *ctx, | |
2063 | u32 changed) | |
2064 | { | |
2065 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
2066 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2067 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 | 2068 | |
31d385ae IP |
2069 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
2070 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | | |
2071 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | | |
2dceedae AN |
2072 | IEEE80211_CHANCTX_CHANGE_RADAR | |
2073 | IEEE80211_CHANCTX_CHANGE_MIN_WIDTH)), | |
31d385ae IP |
2074 | "Cannot change PHY. Ref=%d, changed=0x%X\n", |
2075 | phy_ctxt->ref, changed)) | |
2076 | return; | |
2077 | ||
8ca151b5 | 2078 | mutex_lock(&mvm->mutex); |
dcbc3e1a | 2079 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->min_def, |
8ca151b5 JB |
2080 | ctx->rx_chains_static, |
2081 | ctx->rx_chains_dynamic); | |
8e484f0b | 2082 | iwl_mvm_bt_coex_vif_change(mvm); |
8ca151b5 JB |
2083 | mutex_unlock(&mvm->mutex); |
2084 | } | |
2085 | ||
2086 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, | |
2087 | struct ieee80211_vif *vif, | |
2088 | struct ieee80211_chanctx_conf *ctx) | |
2089 | { | |
2090 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
2091 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
2092 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 JB |
2093 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
2094 | int ret; | |
2095 | ||
2096 | mutex_lock(&mvm->mutex); | |
2097 | ||
fe0f2de3 | 2098 | mvmvif->phy_ctxt = phy_ctxt; |
8ca151b5 JB |
2099 | |
2100 | switch (vif->type) { | |
2101 | case NL80211_IFTYPE_AP: | |
5023d966 | 2102 | case NL80211_IFTYPE_ADHOC: |
8ca151b5 JB |
2103 | /* |
2104 | * The AP binding flow is handled as part of the start_ap flow | |
5023d966 | 2105 | * (in bss_info_changed), similarly for IBSS. |
8ca151b5 JB |
2106 | */ |
2107 | ret = 0; | |
2108 | goto out_unlock; | |
2109 | case NL80211_IFTYPE_STATION: | |
8ca151b5 JB |
2110 | case NL80211_IFTYPE_MONITOR: |
2111 | break; | |
2112 | default: | |
2113 | ret = -EINVAL; | |
2114 | goto out_unlock; | |
2115 | } | |
2116 | ||
2117 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
2118 | if (ret) | |
2119 | goto out_unlock; | |
2120 | ||
2121 | /* | |
92d85562 AB |
2122 | * Power state must be updated before quotas, |
2123 | * otherwise fw will complain. | |
2124 | */ | |
2125 | mvm->bound_vif_cnt++; | |
2126 | iwl_mvm_power_update_binding(mvm, vif, true); | |
2127 | ||
2128 | /* Setting the quota at this stage is only required for monitor | |
8ca151b5 JB |
2129 | * interfaces. For the other types, the bss_info changed flow |
2130 | * will handle quota settings. | |
2131 | */ | |
2132 | if (vif->type == NL80211_IFTYPE_MONITOR) { | |
1e1391ca | 2133 | mvmvif->monitor_active = true; |
8ca151b5 JB |
2134 | ret = iwl_mvm_update_quotas(mvm, vif); |
2135 | if (ret) | |
2136 | goto out_remove_binding; | |
2137 | } | |
2138 | ||
2139 | goto out_unlock; | |
2140 | ||
2141 | out_remove_binding: | |
2142 | iwl_mvm_binding_remove_vif(mvm, vif); | |
92d85562 AB |
2143 | mvm->bound_vif_cnt--; |
2144 | iwl_mvm_power_update_binding(mvm, vif, false); | |
8ca151b5 JB |
2145 | out_unlock: |
2146 | mutex_unlock(&mvm->mutex); | |
2147 | if (ret) | |
2148 | mvmvif->phy_ctxt = NULL; | |
2149 | return ret; | |
2150 | } | |
2151 | ||
2152 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, | |
2153 | struct ieee80211_vif *vif, | |
2154 | struct ieee80211_chanctx_conf *ctx) | |
2155 | { | |
2156 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2157 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
2158 | ||
2159 | mutex_lock(&mvm->mutex); | |
2160 | ||
2161 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); | |
2162 | ||
8ca151b5 | 2163 | switch (vif->type) { |
5023d966 JB |
2164 | case NL80211_IFTYPE_AP: |
2165 | case NL80211_IFTYPE_ADHOC: | |
2166 | goto out_unlock; | |
8ca151b5 | 2167 | case NL80211_IFTYPE_MONITOR: |
1e1391ca IP |
2168 | mvmvif->monitor_active = false; |
2169 | iwl_mvm_update_quotas(mvm, NULL); | |
8ca151b5 JB |
2170 | break; |
2171 | default: | |
2172 | break; | |
2173 | } | |
2174 | ||
1e1391ca | 2175 | iwl_mvm_binding_remove_vif(mvm, vif); |
1c2abf72 | 2176 | mvm->bound_vif_cnt--; |
92d85562 | 2177 | iwl_mvm_power_update_binding(mvm, vif, false); |
1c2abf72 | 2178 | |
a11e144e IP |
2179 | out_unlock: |
2180 | mvmvif->phy_ctxt = NULL; | |
8ca151b5 JB |
2181 | mutex_unlock(&mvm->mutex); |
2182 | } | |
2183 | ||
2184 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, | |
2185 | struct ieee80211_sta *sta, | |
2186 | bool set) | |
2187 | { | |
2188 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2189 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; | |
2190 | ||
2191 | if (!mvm_sta || !mvm_sta->vif) { | |
2192 | IWL_ERR(mvm, "Station is not associated to a vif\n"); | |
2193 | return -EINVAL; | |
2194 | } | |
2195 | ||
2196 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); | |
2197 | } | |
2198 | ||
507cadf2 DS |
2199 | #ifdef CONFIG_NL80211_TESTMODE |
2200 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { | |
2201 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, | |
2202 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, | |
f6c6ad42 | 2203 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
507cadf2 DS |
2204 | }; |
2205 | ||
2206 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, | |
2207 | struct ieee80211_vif *vif, | |
2208 | void *data, int len) | |
2209 | { | |
2210 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; | |
2211 | int err; | |
2212 | u32 noa_duration; | |
2213 | ||
2214 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy); | |
2215 | if (err) | |
2216 | return err; | |
2217 | ||
2218 | if (!tb[IWL_MVM_TM_ATTR_CMD]) | |
2219 | return -EINVAL; | |
2220 | ||
2221 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { | |
2222 | case IWL_MVM_TM_CMD_SET_NOA: | |
2223 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || | |
2224 | !vif->bss_conf.enable_beacon || | |
2225 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) | |
2226 | return -EINVAL; | |
2227 | ||
2228 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); | |
2229 | if (noa_duration >= vif->bss_conf.beacon_int) | |
2230 | return -EINVAL; | |
2231 | ||
2232 | mvm->noa_duration = noa_duration; | |
2233 | mvm->noa_vif = vif; | |
2234 | ||
2235 | return iwl_mvm_update_quotas(mvm, NULL); | |
f6c6ad42 JB |
2236 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
2237 | /* must be associated client vif - ignore authorized */ | |
2238 | if (!vif || vif->type != NL80211_IFTYPE_STATION || | |
2239 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || | |
2240 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) | |
2241 | return -EINVAL; | |
2242 | ||
2243 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) | |
3dd37d05 EP |
2244 | return iwl_mvm_enable_beacon_filter(mvm, vif, |
2245 | CMD_SYNC); | |
2246 | return iwl_mvm_disable_beacon_filter(mvm, vif, CMD_SYNC); | |
507cadf2 DS |
2247 | } |
2248 | ||
2249 | return -EOPNOTSUPP; | |
2250 | } | |
2251 | ||
2252 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, | |
2253 | struct ieee80211_vif *vif, | |
2254 | void *data, int len) | |
2255 | { | |
2256 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
2257 | int err; | |
2258 | ||
2259 | mutex_lock(&mvm->mutex); | |
2260 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); | |
2261 | mutex_unlock(&mvm->mutex); | |
2262 | ||
2263 | return err; | |
2264 | } | |
2265 | #endif | |
2266 | ||
8ca151b5 JB |
2267 | struct ieee80211_ops iwl_mvm_hw_ops = { |
2268 | .tx = iwl_mvm_mac_tx, | |
2269 | .ampdu_action = iwl_mvm_mac_ampdu_action, | |
2270 | .start = iwl_mvm_mac_start, | |
2271 | .restart_complete = iwl_mvm_mac_restart_complete, | |
2272 | .stop = iwl_mvm_mac_stop, | |
2273 | .add_interface = iwl_mvm_mac_add_interface, | |
2274 | .remove_interface = iwl_mvm_mac_remove_interface, | |
2275 | .config = iwl_mvm_mac_config, | |
e59647ea | 2276 | .prepare_multicast = iwl_mvm_prepare_multicast, |
8ca151b5 JB |
2277 | .configure_filter = iwl_mvm_configure_filter, |
2278 | .bss_info_changed = iwl_mvm_bss_info_changed, | |
2279 | .hw_scan = iwl_mvm_mac_hw_scan, | |
2280 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, | |
1ddbbb0c | 2281 | .sta_pre_rcu_remove = iwl_mvm_sta_pre_rcu_remove, |
8ca151b5 JB |
2282 | .sta_state = iwl_mvm_mac_sta_state, |
2283 | .sta_notify = iwl_mvm_mac_sta_notify, | |
2284 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, | |
3e56eadf | 2285 | .release_buffered_frames = iwl_mvm_mac_release_buffered_frames, |
8ca151b5 | 2286 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, |
1f3b0ff8 | 2287 | .sta_rc_update = iwl_mvm_sta_rc_update, |
8ca151b5 JB |
2288 | .conf_tx = iwl_mvm_mac_conf_tx, |
2289 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, | |
35a000b7 DS |
2290 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
2291 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, | |
8ca151b5 JB |
2292 | .set_key = iwl_mvm_mac_set_key, |
2293 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, | |
2294 | .remain_on_channel = iwl_mvm_roc, | |
2295 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, | |
8ca151b5 JB |
2296 | .add_chanctx = iwl_mvm_add_chanctx, |
2297 | .remove_chanctx = iwl_mvm_remove_chanctx, | |
2298 | .change_chanctx = iwl_mvm_change_chanctx, | |
2299 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, | |
2300 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, | |
2301 | ||
5023d966 JB |
2302 | .start_ap = iwl_mvm_start_ap_ibss, |
2303 | .stop_ap = iwl_mvm_stop_ap_ibss, | |
2304 | .join_ibss = iwl_mvm_start_ap_ibss, | |
2305 | .leave_ibss = iwl_mvm_stop_ap_ibss, | |
8ca151b5 JB |
2306 | |
2307 | .set_tim = iwl_mvm_set_tim, | |
2308 | ||
507cadf2 DS |
2309 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
2310 | ||
8ca151b5 JB |
2311 | #ifdef CONFIG_PM_SLEEP |
2312 | /* look at d3.c */ | |
2313 | .suspend = iwl_mvm_suspend, | |
2314 | .resume = iwl_mvm_resume, | |
2315 | .set_wakeup = iwl_mvm_set_wakeup, | |
2316 | .set_rekey_data = iwl_mvm_set_rekey_data, | |
2317 | #if IS_ENABLED(CONFIG_IPV6) | |
2318 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, | |
2319 | #endif | |
2320 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, | |
2321 | #endif | |
2322 | }; |