]>
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 | * | |
8 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. | |
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 | * | |
33 | * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved. | |
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> |
8ca151b5 | 69 | #include <net/mac80211.h> |
f0c2646a | 70 | #include <net/tcp.h> |
8ca151b5 JB |
71 | |
72 | #include "iwl-op-mode.h" | |
73 | #include "iwl-io.h" | |
74 | #include "mvm.h" | |
75 | #include "sta.h" | |
76 | #include "time-event.h" | |
77 | #include "iwl-eeprom-parse.h" | |
78 | #include "fw-api-scan.h" | |
79 | #include "iwl-phy-db.h" | |
507cadf2 | 80 | #include "testmode.h" |
8ca151b5 JB |
81 | |
82 | static const struct ieee80211_iface_limit iwl_mvm_limits[] = { | |
83 | { | |
84 | .max = 1, | |
8eb38710 | 85 | .types = BIT(NL80211_IFTYPE_STATION), |
8ca151b5 | 86 | }, |
3c15a0fb JB |
87 | { |
88 | .max = 1, | |
8eb38710 IP |
89 | .types = BIT(NL80211_IFTYPE_AP) | |
90 | BIT(NL80211_IFTYPE_P2P_CLIENT) | | |
3c15a0fb JB |
91 | BIT(NL80211_IFTYPE_P2P_GO), |
92 | }, | |
93 | { | |
94 | .max = 1, | |
95 | .types = BIT(NL80211_IFTYPE_P2P_DEVICE), | |
96 | }, | |
8ca151b5 JB |
97 | }; |
98 | ||
99 | static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = { | |
100 | { | |
101 | .num_different_channels = 1, | |
102 | .max_interfaces = 3, | |
103 | .limits = iwl_mvm_limits, | |
104 | .n_limits = ARRAY_SIZE(iwl_mvm_limits), | |
105 | }, | |
106 | }; | |
107 | ||
f0c2646a JB |
108 | #ifdef CONFIG_PM_SLEEP |
109 | static const struct nl80211_wowlan_tcp_data_token_feature | |
110 | iwl_mvm_wowlan_tcp_token_feature = { | |
111 | .min_len = 0, | |
112 | .max_len = 255, | |
113 | .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS, | |
114 | }; | |
115 | ||
116 | static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = { | |
117 | .tok = &iwl_mvm_wowlan_tcp_token_feature, | |
118 | .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN - | |
119 | sizeof(struct ethhdr) - | |
120 | sizeof(struct iphdr) - | |
121 | sizeof(struct tcphdr), | |
122 | .data_interval_max = 65535, /* __le16 in API */ | |
123 | .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN - | |
124 | sizeof(struct ethhdr) - | |
125 | sizeof(struct iphdr) - | |
126 | sizeof(struct tcphdr), | |
127 | .seq = true, | |
128 | }; | |
129 | #endif | |
130 | ||
fe0f2de3 IP |
131 | static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm) |
132 | { | |
133 | int i; | |
134 | ||
135 | memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts)); | |
136 | for (i = 0; i < NUM_PHY_CTX; i++) { | |
137 | mvm->phy_ctxts[i].id = i; | |
138 | mvm->phy_ctxts[i].ref = 0; | |
139 | } | |
140 | } | |
141 | ||
20f1a5de DS |
142 | static int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm) |
143 | { | |
144 | /* we create the 802.11 header and SSID element */ | |
145 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID) | |
146 | return mvm->fw->ucode_capa.max_probe_length - 24 - 2; | |
147 | return mvm->fw->ucode_capa.max_probe_length - 24 - 34; | |
148 | } | |
149 | ||
8ca151b5 JB |
150 | int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm) |
151 | { | |
152 | struct ieee80211_hw *hw = mvm->hw; | |
831e85f3 | 153 | int num_mac, ret, i; |
8ca151b5 JB |
154 | |
155 | /* Tell mac80211 our characteristics */ | |
156 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | |
157 | IEEE80211_HW_SPECTRUM_MGMT | | |
158 | IEEE80211_HW_REPORTS_TX_ACK_STATUS | | |
159 | IEEE80211_HW_QUEUE_CONTROL | | |
160 | IEEE80211_HW_WANT_MONITOR_VIF | | |
8ca151b5 JB |
161 | IEEE80211_HW_SUPPORTS_PS | |
162 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS | | |
d2931bbd | 163 | IEEE80211_HW_AMPDU_AGGREGATION | |
d64048ed | 164 | IEEE80211_HW_TIMING_BEACON_ONLY | |
147fc9be EG |
165 | IEEE80211_HW_CONNECTION_MONITOR | |
166 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | | |
e8e626ad | 167 | IEEE80211_HW_SUPPORTS_STATIC_SMPS; |
8ca151b5 | 168 | |
19e737c9 | 169 | hw->queues = mvm->first_agg_queue; |
398e8c6c | 170 | hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE; |
8ca151b5 JB |
171 | hw->rate_control_algorithm = "iwl-mvm-rs"; |
172 | ||
173 | /* | |
174 | * Enable 11w if advertised by firmware and software crypto | |
175 | * is not enabled (as the firmware will interpret some mgmt | |
176 | * packets, so enabling it with software crypto isn't safe) | |
177 | */ | |
178 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP && | |
179 | !iwlwifi_mod_params.sw_crypto) | |
180 | hw->flags |= IEEE80211_HW_MFP_CAPABLE; | |
181 | ||
e8e626ad AB |
182 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT) { |
183 | hw->flags |= IEEE80211_HW_SUPPORTS_UAPSD; | |
184 | hw->uapsd_queues = IWL_UAPSD_AC_INFO; | |
185 | hw->uapsd_max_sp_len = IWL_UAPSD_MAX_SP; | |
186 | } | |
187 | ||
8ca151b5 JB |
188 | hw->sta_data_size = sizeof(struct iwl_mvm_sta); |
189 | hw->vif_data_size = sizeof(struct iwl_mvm_vif); | |
fe0f2de3 | 190 | hw->chanctx_data_size = sizeof(u16); |
8ca151b5 JB |
191 | |
192 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | |
3c15a0fb JB |
193 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
194 | BIT(NL80211_IFTYPE_AP) | | |
195 | BIT(NL80211_IFTYPE_P2P_GO) | | |
196 | BIT(NL80211_IFTYPE_P2P_DEVICE); | |
8ca151b5 | 197 | |
5023d966 JB |
198 | /* IBSS has bugs in older versions */ |
199 | if (IWL_UCODE_API(mvm->fw->ucode_ver) >= 8) | |
200 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC); | |
201 | ||
a2f73b6c LR |
202 | hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
203 | hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG | | |
204 | REGULATORY_DISABLE_BEACON_HINTS; | |
8ca151b5 JB |
205 | |
206 | hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; | |
207 | hw->wiphy->n_iface_combinations = | |
208 | ARRAY_SIZE(iwl_mvm_iface_combinations); | |
209 | ||
c451e6d4 | 210 | hw->wiphy->max_remain_on_channel_duration = 10000; |
8ca151b5 JB |
211 | hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; |
212 | ||
213 | /* Extract MAC address */ | |
214 | memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN); | |
215 | hw->wiphy->addresses = mvm->addresses; | |
216 | hw->wiphy->n_addresses = 1; | |
831e85f3 IP |
217 | |
218 | /* Extract additional MAC addresses if available */ | |
219 | num_mac = (mvm->nvm_data->n_hw_addrs > 1) ? | |
220 | min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1; | |
221 | ||
222 | for (i = 1; i < num_mac; i++) { | |
223 | memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr, | |
8ca151b5 | 224 | ETH_ALEN); |
831e85f3 | 225 | mvm->addresses[i].addr[5]++; |
8ca151b5 JB |
226 | hw->wiphy->n_addresses++; |
227 | } | |
228 | ||
fe0f2de3 IP |
229 | iwl_mvm_reset_phy_ctxts(mvm); |
230 | ||
20f1a5de DS |
231 | hw->wiphy->max_scan_ie_len = iwl_mvm_max_scan_ie_len(mvm); |
232 | ||
8ca151b5 JB |
233 | hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; |
234 | ||
235 | if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels) | |
236 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = | |
237 | &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ]; | |
238 | if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels) | |
239 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = | |
240 | &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ]; | |
241 | ||
242 | hw->wiphy->hw_version = mvm->trans->hw_id; | |
243 | ||
ade50652 | 244 | if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM) |
8ca151b5 JB |
245 | hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; |
246 | else | |
247 | hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; | |
248 | ||
35a000b7 DS |
249 | if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SCHED_SCAN) { |
250 | hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; | |
251 | hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; | |
252 | hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; | |
253 | /* we create the 802.11 header and zero length SSID IE. */ | |
254 | hw->wiphy->max_sched_scan_ie_len = | |
255 | SCAN_OFFLOAD_PROBE_REQ_SIZE - 24 - 2; | |
256 | } | |
257 | ||
8ca151b5 | 258 | hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN | |
61f6325d HD |
259 | NL80211_FEATURE_P2P_GO_OPPPS | |
260 | NL80211_FEATURE_LOW_PRIORITY_SCAN; | |
8ca151b5 JB |
261 | |
262 | mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | |
263 | ||
e36e5433 MS |
264 | /* currently FW API supports only one optional cipher scheme */ |
265 | if (mvm->fw->cs && mvm->fw->cs->cipher) { | |
266 | mvm->hw->n_cipher_schemes = 1; | |
267 | mvm->hw->cipher_schemes = mvm->fw->cs; | |
268 | } | |
269 | ||
8ca151b5 JB |
270 | #ifdef CONFIG_PM_SLEEP |
271 | if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len && | |
272 | mvm->trans->ops->d3_suspend && | |
273 | mvm->trans->ops->d3_resume && | |
274 | device_can_wakeup(mvm->trans->dev)) { | |
964dc9e2 JB |
275 | mvm->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | |
276 | WIPHY_WOWLAN_DISCONNECT | | |
277 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | | |
278 | WIPHY_WOWLAN_RFKILL_RELEASE; | |
8ca151b5 | 279 | if (!iwlwifi_mod_params.sw_crypto) |
964dc9e2 JB |
280 | mvm->wowlan.flags |= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
281 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | | |
282 | WIPHY_WOWLAN_4WAY_HANDSHAKE; | |
283 | ||
284 | mvm->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS; | |
285 | mvm->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN; | |
286 | mvm->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN; | |
287 | mvm->wowlan.tcp = &iwl_mvm_wowlan_tcp_support; | |
288 | hw->wiphy->wowlan = &mvm->wowlan; | |
8ca151b5 JB |
289 | } |
290 | #endif | |
291 | ||
292 | ret = iwl_mvm_leds_init(mvm); | |
293 | if (ret) | |
294 | return ret; | |
295 | ||
b7327d89 EG |
296 | ret = ieee80211_register_hw(mvm->hw); |
297 | if (ret) | |
298 | iwl_mvm_leds_exit(mvm); | |
299 | ||
300 | return ret; | |
8ca151b5 JB |
301 | } |
302 | ||
303 | static void iwl_mvm_mac_tx(struct ieee80211_hw *hw, | |
304 | struct ieee80211_tx_control *control, | |
305 | struct sk_buff *skb) | |
306 | { | |
307 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
308 | ||
9ee718aa EL |
309 | if (iwl_mvm_is_radio_killed(mvm)) { |
310 | IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n"); | |
8ca151b5 JB |
311 | goto drop; |
312 | } | |
313 | ||
398e8c6c | 314 | if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && |
8ca151b5 JB |
315 | !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) |
316 | goto drop; | |
317 | ||
318 | if (control->sta) { | |
319 | if (iwl_mvm_tx_skb(mvm, skb, control->sta)) | |
320 | goto drop; | |
321 | return; | |
322 | } | |
323 | ||
324 | if (iwl_mvm_tx_skb_non_sta(mvm, skb)) | |
325 | goto drop; | |
326 | return; | |
327 | drop: | |
328 | ieee80211_free_txskb(hw, skb); | |
329 | } | |
330 | ||
331 | static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, | |
332 | struct ieee80211_vif *vif, | |
333 | enum ieee80211_ampdu_mlme_action action, | |
334 | struct ieee80211_sta *sta, u16 tid, | |
335 | u16 *ssn, u8 buf_size) | |
336 | { | |
337 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
338 | int ret; | |
339 | ||
340 | IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n", | |
341 | sta->addr, tid, action); | |
342 | ||
343 | if (!(mvm->nvm_data->sku_cap_11n_enable)) | |
344 | return -EACCES; | |
345 | ||
346 | mutex_lock(&mvm->mutex); | |
347 | ||
348 | switch (action) { | |
349 | case IEEE80211_AMPDU_RX_START: | |
350 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) { | |
351 | ret = -EINVAL; | |
352 | break; | |
353 | } | |
354 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true); | |
355 | break; | |
356 | case IEEE80211_AMPDU_RX_STOP: | |
357 | ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); | |
358 | break; | |
359 | case IEEE80211_AMPDU_TX_START: | |
5d158efa EG |
360 | if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) { |
361 | ret = -EINVAL; | |
362 | break; | |
363 | } | |
8ca151b5 JB |
364 | ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn); |
365 | break; | |
366 | case IEEE80211_AMPDU_TX_STOP_CONT: | |
e3d9e7ce EG |
367 | ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid); |
368 | break; | |
8ca151b5 JB |
369 | case IEEE80211_AMPDU_TX_STOP_FLUSH: |
370 | case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: | |
e3d9e7ce | 371 | ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid); |
8ca151b5 JB |
372 | break; |
373 | case IEEE80211_AMPDU_TX_OPERATIONAL: | |
374 | ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size); | |
375 | break; | |
376 | default: | |
377 | WARN_ON_ONCE(1); | |
378 | ret = -EINVAL; | |
379 | break; | |
380 | } | |
381 | mutex_unlock(&mvm->mutex); | |
382 | ||
383 | return ret; | |
384 | } | |
385 | ||
386 | static void iwl_mvm_cleanup_iterator(void *data, u8 *mac, | |
387 | struct ieee80211_vif *vif) | |
388 | { | |
389 | struct iwl_mvm *mvm = data; | |
390 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
391 | ||
392 | mvmvif->uploaded = false; | |
393 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; | |
394 | ||
395 | /* does this make sense at all? */ | |
396 | mvmvif->color++; | |
397 | ||
398 | spin_lock_bh(&mvm->time_event_lock); | |
399 | iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data); | |
400 | spin_unlock_bh(&mvm->time_event_lock); | |
401 | ||
fe0f2de3 | 402 | mvmvif->phy_ctxt = NULL; |
8ca151b5 JB |
403 | } |
404 | ||
405 | static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm) | |
406 | { | |
407 | iwl_trans_stop_device(mvm->trans); | |
408 | iwl_trans_stop_hw(mvm->trans, false); | |
409 | ||
410 | mvm->scan_status = IWL_MVM_SCAN_NONE; | |
411 | ||
412 | /* just in case one was running */ | |
413 | ieee80211_remain_on_channel_expired(mvm->hw); | |
414 | ||
415 | ieee80211_iterate_active_interfaces_atomic( | |
416 | mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, | |
417 | iwl_mvm_cleanup_iterator, mvm); | |
418 | ||
fe0f2de3 IP |
419 | mvm->p2p_device_vif = NULL; |
420 | ||
421 | iwl_mvm_reset_phy_ctxts(mvm); | |
8ca151b5 JB |
422 | memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table)); |
423 | memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained)); | |
424 | ||
425 | ieee80211_wake_queues(mvm->hw); | |
426 | ||
427 | mvm->vif_count = 0; | |
113a0447 | 428 | mvm->rx_ba_sessions = 0; |
8ca151b5 JB |
429 | } |
430 | ||
431 | static int iwl_mvm_mac_start(struct ieee80211_hw *hw) | |
432 | { | |
433 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
434 | int ret; | |
435 | ||
436 | mutex_lock(&mvm->mutex); | |
437 | ||
438 | /* Clean up some internal and mac80211 state on restart */ | |
439 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) | |
440 | iwl_mvm_restart_cleanup(mvm); | |
441 | ||
442 | ret = iwl_mvm_up(mvm); | |
443 | mutex_unlock(&mvm->mutex); | |
444 | ||
445 | return ret; | |
446 | } | |
447 | ||
448 | static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw) | |
449 | { | |
450 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
451 | int ret; | |
452 | ||
453 | mutex_lock(&mvm->mutex); | |
454 | ||
455 | clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); | |
456 | ret = iwl_mvm_update_quotas(mvm, NULL); | |
457 | if (ret) | |
458 | IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n", | |
459 | ret); | |
460 | ||
461 | mutex_unlock(&mvm->mutex); | |
462 | } | |
463 | ||
464 | static void iwl_mvm_mac_stop(struct ieee80211_hw *hw) | |
465 | { | |
466 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
467 | ||
468 | flush_work(&mvm->async_handlers_wk); | |
469 | ||
470 | mutex_lock(&mvm->mutex); | |
471 | /* async_handlers_wk is now blocked */ | |
472 | ||
473 | /* | |
474 | * The work item could be running or queued if the | |
475 | * ROC time event stops just as we get here. | |
476 | */ | |
477 | cancel_work_sync(&mvm->roc_done_wk); | |
478 | ||
479 | iwl_trans_stop_device(mvm->trans); | |
480 | iwl_trans_stop_hw(mvm->trans, false); | |
481 | ||
482 | iwl_mvm_async_handlers_purge(mvm); | |
483 | /* async_handlers_list is empty and will stay empty: HW is stopped */ | |
484 | ||
485 | /* the fw is stopped, the aux sta is dead: clean up driver state */ | |
486 | iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta); | |
487 | ||
488 | mutex_unlock(&mvm->mutex); | |
489 | ||
490 | /* | |
491 | * The worker might have been waiting for the mutex, let it run and | |
492 | * discover that its list is now empty. | |
493 | */ | |
494 | cancel_work_sync(&mvm->async_handlers_wk); | |
495 | } | |
496 | ||
497 | static void iwl_mvm_pm_disable_iterator(void *data, u8 *mac, | |
498 | struct ieee80211_vif *vif) | |
499 | { | |
500 | struct iwl_mvm *mvm = data; | |
501 | int ret; | |
502 | ||
503 | ret = iwl_mvm_power_disable(mvm, vif); | |
504 | if (ret) | |
505 | IWL_ERR(mvm, "failed to disable power management\n"); | |
506 | } | |
507 | ||
508 | static void iwl_mvm_power_update_iterator(void *data, u8 *mac, | |
509 | struct ieee80211_vif *vif) | |
510 | { | |
511 | struct iwl_mvm *mvm = data; | |
512 | ||
513 | iwl_mvm_power_update_mode(mvm, vif); | |
514 | } | |
515 | ||
fe0f2de3 IP |
516 | static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm) |
517 | { | |
518 | u16 i; | |
519 | ||
520 | lockdep_assert_held(&mvm->mutex); | |
521 | ||
522 | for (i = 0; i < NUM_PHY_CTX; i++) | |
523 | if (!mvm->phy_ctxts[i].ref) | |
524 | return &mvm->phy_ctxts[i]; | |
525 | ||
526 | IWL_ERR(mvm, "No available PHY context\n"); | |
527 | return NULL; | |
528 | } | |
529 | ||
8ca151b5 JB |
530 | static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, |
531 | struct ieee80211_vif *vif) | |
532 | { | |
533 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
534 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
535 | int ret; | |
536 | ||
537 | /* | |
538 | * Not much to do here. The stack will not allow interface | |
539 | * types or combinations that we didn't advertise, so we | |
540 | * don't really have to check the types. | |
541 | */ | |
542 | ||
543 | mutex_lock(&mvm->mutex); | |
544 | ||
e89044d7 | 545 | /* Allocate resources for the MAC context, and add it to the fw */ |
8ca151b5 JB |
546 | ret = iwl_mvm_mac_ctxt_init(mvm, vif); |
547 | if (ret) | |
548 | goto out_unlock; | |
549 | ||
ea183d02 IP |
550 | /* |
551 | * TODO: remove this temporary code. | |
552 | * Currently MVM FW supports power management only on single MAC. | |
553 | * If new interface added, disable PM on existing interface. | |
554 | * P2P device is a special case, since it is handled by FW similary to | |
555 | * scan. If P2P deviced is added, PM remains enabled on existing | |
556 | * interface. | |
557 | * Note: the method below does not count the new interface being added | |
558 | * at this moment. | |
559 | */ | |
560 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) | |
561 | mvm->vif_count++; | |
562 | if (mvm->vif_count > 1) { | |
563 | IWL_DEBUG_MAC80211(mvm, | |
564 | "Disable power on existing interfaces\n"); | |
565 | ieee80211_iterate_active_interfaces_atomic( | |
566 | mvm->hw, | |
567 | IEEE80211_IFACE_ITER_NORMAL, | |
568 | iwl_mvm_pm_disable_iterator, mvm); | |
569 | } | |
570 | ||
8ca151b5 JB |
571 | /* |
572 | * The AP binding flow can be done only after the beacon | |
573 | * template is configured (which happens only in the mac80211 | |
574 | * start_ap() flow), and adding the broadcast station can happen | |
575 | * only after the binding. | |
576 | * In addition, since modifying the MAC before adding a bcast | |
577 | * station is not allowed by the FW, delay the adding of MAC context to | |
578 | * the point where we can also add the bcast station. | |
579 | * In short: there's not much we can do at this point, other than | |
580 | * allocating resources :) | |
581 | */ | |
5023d966 JB |
582 | if (vif->type == NL80211_IFTYPE_AP || |
583 | vif->type == NL80211_IFTYPE_ADHOC) { | |
8ca151b5 JB |
584 | u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif); |
585 | ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta, | |
586 | qmask); | |
587 | if (ret) { | |
588 | IWL_ERR(mvm, "Failed to allocate bcast sta\n"); | |
589 | goto out_release; | |
590 | } | |
591 | ||
77740cb4 | 592 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
593 | goto out_unlock; |
594 | } | |
595 | ||
8ca151b5 JB |
596 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); |
597 | if (ret) | |
598 | goto out_release; | |
599 | ||
600 | /* | |
601 | * Update power state on the new interface. Admittedly, based on | |
602 | * mac80211 logics this power update will disable power management | |
603 | */ | |
604 | iwl_mvm_power_update_mode(mvm, vif); | |
605 | ||
7df15b1e | 606 | /* beacon filtering */ |
bd3351ba EP |
607 | ret = iwl_mvm_disable_beacon_filter(mvm, vif); |
608 | if (ret) | |
609 | goto out_remove_mac; | |
610 | ||
7df15b1e | 611 | if (!mvm->bf_allowed_vif && |
5dca7c24 HG |
612 | vif->type == NL80211_IFTYPE_STATION && !vif->p2p && |
613 | mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BF_UPDATED){ | |
7df15b1e | 614 | mvm->bf_allowed_vif = mvmvif; |
a20fd398 AO |
615 | vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | |
616 | IEEE80211_VIF_SUPPORTS_CQM_RSSI; | |
7df15b1e HG |
617 | } |
618 | ||
8ca151b5 JB |
619 | /* |
620 | * P2P_DEVICE interface does not have a channel context assigned to it, | |
621 | * so a dedicated PHY context is allocated to it and the corresponding | |
622 | * MAC context is bound to it at this stage. | |
623 | */ | |
624 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
8ca151b5 | 625 | |
fe0f2de3 IP |
626 | mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
627 | if (!mvmvif->phy_ctxt) { | |
628 | ret = -ENOSPC; | |
bd3351ba | 629 | goto out_free_bf; |
fe0f2de3 | 630 | } |
8ca151b5 | 631 | |
53a9d61e | 632 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
633 | ret = iwl_mvm_binding_add_vif(mvm, vif); |
634 | if (ret) | |
53a9d61e | 635 | goto out_unref_phy; |
8ca151b5 JB |
636 | |
637 | ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta); | |
638 | if (ret) | |
639 | goto out_unbind; | |
640 | ||
641 | /* Save a pointer to p2p device vif, so it can later be used to | |
642 | * update the p2p device MAC when a GO is started/stopped */ | |
643 | mvm->p2p_device_vif = vif; | |
644 | } | |
645 | ||
63494374 | 646 | iwl_mvm_vif_dbgfs_register(mvm, vif); |
8ca151b5 JB |
647 | goto out_unlock; |
648 | ||
649 | out_unbind: | |
650 | iwl_mvm_binding_remove_vif(mvm, vif); | |
53a9d61e | 651 | out_unref_phy: |
fe0f2de3 | 652 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
bd3351ba EP |
653 | out_free_bf: |
654 | if (mvm->bf_allowed_vif == mvmvif) { | |
655 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
656 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
657 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
bd3351ba | 658 | } |
8ca151b5 JB |
659 | out_remove_mac: |
660 | mvmvif->phy_ctxt = NULL; | |
661 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
662 | out_release: | |
5ee2b215 AB |
663 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) |
664 | mvm->vif_count--; | |
4bf881f5 AB |
665 | ieee80211_iterate_active_interfaces( |
666 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
667 | iwl_mvm_power_update_iterator, mvm); | |
8ca151b5 JB |
668 | iwl_mvm_mac_ctxt_release(mvm, vif); |
669 | out_unlock: | |
670 | mutex_unlock(&mvm->mutex); | |
671 | ||
672 | return ret; | |
673 | } | |
674 | ||
38a12b5b JB |
675 | static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, |
676 | struct ieee80211_vif *vif) | |
8ca151b5 | 677 | { |
8ca151b5 JB |
678 | u32 tfd_msk = 0, ac; |
679 | ||
680 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) | |
681 | if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE) | |
682 | tfd_msk |= BIT(vif->hw_queue[ac]); | |
683 | ||
684 | if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE) | |
685 | tfd_msk |= BIT(vif->cab_queue); | |
686 | ||
687 | if (tfd_msk) { | |
688 | mutex_lock(&mvm->mutex); | |
689 | iwl_mvm_flush_tx_path(mvm, tfd_msk, true); | |
690 | mutex_unlock(&mvm->mutex); | |
691 | } | |
692 | ||
693 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
694 | /* | |
695 | * Flush the ROC worker which will flush the OFFCHANNEL queue. | |
696 | * We assume here that all the packets sent to the OFFCHANNEL | |
697 | * queue are sent in ROC session. | |
698 | */ | |
699 | flush_work(&mvm->roc_done_wk); | |
700 | } else { | |
701 | /* | |
702 | * By now, all the AC queues are empty. The AGG queues are | |
703 | * empty too. We already got all the Tx responses for all the | |
704 | * packets in the queues. The drain work can have been | |
0742a75a | 705 | * triggered. Flush it. |
8ca151b5 JB |
706 | */ |
707 | flush_work(&mvm->sta_drained_wk); | |
708 | } | |
38a12b5b JB |
709 | } |
710 | ||
711 | static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw, | |
712 | struct ieee80211_vif *vif) | |
713 | { | |
714 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
715 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
716 | ||
717 | iwl_mvm_prepare_mac_removal(mvm, vif); | |
8ca151b5 JB |
718 | |
719 | mutex_lock(&mvm->mutex); | |
720 | ||
7df15b1e HG |
721 | if (mvm->bf_allowed_vif == mvmvif) { |
722 | mvm->bf_allowed_vif = NULL; | |
a20fd398 AO |
723 | vif->driver_flags &= ~(IEEE80211_VIF_BEACON_FILTER | |
724 | IEEE80211_VIF_SUPPORTS_CQM_RSSI); | |
7df15b1e HG |
725 | } |
726 | ||
63494374 JB |
727 | iwl_mvm_vif_dbgfs_clean(mvm, vif); |
728 | ||
8ca151b5 JB |
729 | /* |
730 | * For AP/GO interface, the tear down of the resources allocated to the | |
38a12b5b | 731 | * interface is be handled as part of the stop_ap flow. |
8ca151b5 | 732 | */ |
5023d966 JB |
733 | if (vif->type == NL80211_IFTYPE_AP || |
734 | vif->type == NL80211_IFTYPE_ADHOC) { | |
507cadf2 DS |
735 | #ifdef CONFIG_NL80211_TESTMODE |
736 | if (vif == mvm->noa_vif) { | |
737 | mvm->noa_vif = NULL; | |
738 | mvm->noa_duration = 0; | |
739 | } | |
740 | #endif | |
8ca151b5 JB |
741 | iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta); |
742 | goto out_release; | |
743 | } | |
744 | ||
745 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
746 | mvm->p2p_device_vif = NULL; | |
747 | iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta); | |
748 | iwl_mvm_binding_remove_vif(mvm, vif); | |
fe0f2de3 | 749 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); |
8ca151b5 JB |
750 | mvmvif->phy_ctxt = NULL; |
751 | } | |
752 | ||
753 | /* | |
754 | * TODO: remove this temporary code. | |
755 | * Currently MVM FW supports power management only on single MAC. | |
756 | * Check if only one additional interface remains after removing | |
757 | * current one. Update power mode on the remaining interface. | |
758 | */ | |
5ee2b215 | 759 | if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE) |
8ca151b5 JB |
760 | mvm->vif_count--; |
761 | IWL_DEBUG_MAC80211(mvm, "Currently %d interfaces active\n", | |
762 | mvm->vif_count); | |
763 | if (mvm->vif_count == 1) { | |
764 | ieee80211_iterate_active_interfaces( | |
765 | mvm->hw, IEEE80211_IFACE_ITER_NORMAL, | |
766 | iwl_mvm_power_update_iterator, mvm); | |
767 | } | |
768 | ||
769 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
770 | ||
771 | out_release: | |
772 | iwl_mvm_mac_ctxt_release(mvm, vif); | |
773 | mutex_unlock(&mvm->mutex); | |
774 | } | |
775 | ||
88f2fd73 MG |
776 | static int iwl_mvm_set_tx_power(struct iwl_mvm *mvm, struct ieee80211_vif *vif, |
777 | s8 tx_power) | |
778 | { | |
779 | /* FW is in charge of regulatory enforcement */ | |
780 | struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd = { | |
781 | .mac_context_id = iwl_mvm_vif_from_mac80211(vif)->id, | |
782 | .pwr_restriction = cpu_to_le16(tx_power), | |
783 | }; | |
784 | ||
785 | return iwl_mvm_send_cmd_pdu(mvm, REDUCE_TX_POWER_CMD, CMD_SYNC, | |
786 | sizeof(reduce_txpwr_cmd), | |
787 | &reduce_txpwr_cmd); | |
788 | } | |
789 | ||
8ca151b5 JB |
790 | static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed) |
791 | { | |
792 | return 0; | |
793 | } | |
794 | ||
795 | static void iwl_mvm_configure_filter(struct ieee80211_hw *hw, | |
796 | unsigned int changed_flags, | |
797 | unsigned int *total_flags, | |
798 | u64 multicast) | |
799 | { | |
800 | *total_flags = 0; | |
801 | } | |
802 | ||
51b6b9e0 EG |
803 | static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm, |
804 | struct ieee80211_vif *vif) | |
805 | { | |
806 | struct iwl_mcast_filter_cmd mcast_filter_cmd = { | |
807 | .pass_all = 1, | |
808 | }; | |
809 | ||
810 | memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN); | |
811 | ||
812 | return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC, | |
813 | sizeof(mcast_filter_cmd), | |
814 | &mcast_filter_cmd); | |
815 | } | |
816 | ||
8ca151b5 JB |
817 | static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm, |
818 | struct ieee80211_vif *vif, | |
819 | struct ieee80211_bss_conf *bss_conf, | |
820 | u32 changes) | |
821 | { | |
822 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
823 | int ret; | |
824 | ||
825 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); | |
826 | if (ret) | |
827 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); | |
828 | ||
829 | if (changes & BSS_CHANGED_ASSOC) { | |
830 | if (bss_conf->assoc) { | |
831 | /* add quota for this interface */ | |
832 | ret = iwl_mvm_update_quotas(mvm, vif); | |
833 | if (ret) { | |
834 | IWL_ERR(mvm, "failed to update quotas\n"); | |
835 | return; | |
836 | } | |
51b6b9e0 | 837 | iwl_mvm_configure_mcast_filter(mvm, vif); |
016d27e1 JB |
838 | |
839 | if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, | |
840 | &mvm->status)) { | |
841 | /* | |
842 | * If we're restarting then the firmware will | |
843 | * obviously have lost synchronisation with | |
844 | * the AP. It will attempt to synchronise by | |
845 | * itself, but we can make it more reliable by | |
846 | * scheduling a session protection time event. | |
847 | * | |
848 | * The firmware needs to receive a beacon to | |
849 | * catch up with synchronisation, use 110% of | |
850 | * the beacon interval. | |
851 | * | |
852 | * Set a large maximum delay to allow for more | |
853 | * than a single interface. | |
854 | */ | |
855 | u32 dur = (11 * vif->bss_conf.beacon_int) / 10; | |
856 | iwl_mvm_protect_session(mvm, vif, dur, dur, | |
857 | 5 * dur); | |
858 | } | |
1f3b0ff8 LE |
859 | |
860 | iwl_mvm_sf_update(mvm, vif, false); | |
175a70b7 | 861 | iwl_mvm_power_vif_assoc(mvm, vif); |
8ca151b5 | 862 | } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) { |
1f3b0ff8 LE |
863 | /* |
864 | * If update fails - SF might be running in associated | |
865 | * mode while disassociated - which is forbidden. | |
866 | */ | |
867 | WARN_ONCE(iwl_mvm_sf_update(mvm, vif, false), | |
868 | "Failed to update SF upon disassociation\n"); | |
869 | ||
8ca151b5 JB |
870 | /* remove AP station now that the MAC is unassoc */ |
871 | ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id); | |
872 | if (ret) | |
873 | IWL_ERR(mvm, "failed to remove AP station\n"); | |
874 | mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT; | |
875 | /* remove quota for this interface */ | |
876 | ret = iwl_mvm_update_quotas(mvm, NULL); | |
877 | if (ret) | |
878 | IWL_ERR(mvm, "failed to update quotas\n"); | |
879 | } | |
a20fd398 AO |
880 | |
881 | /* reset rssi values */ | |
882 | mvmvif->bf_data.ave_beacon_signal = 0; | |
883 | ||
e8e626ad AB |
884 | if (!(mvm->fw->ucode_capa.flags & |
885 | IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT)) { | |
e811ada7 AB |
886 | /* Workaround for FW bug, otherwise FW disables device |
887 | * power save upon disassociation | |
888 | */ | |
889 | ret = iwl_mvm_power_update_mode(mvm, vif); | |
890 | if (ret) | |
891 | IWL_ERR(mvm, "failed to update power mode\n"); | |
892 | } | |
8e484f0b | 893 | iwl_mvm_bt_coex_vif_change(mvm); |
989c6505 | 894 | } else if (changes & BSS_CHANGED_BEACON_INFO) { |
210a544e JB |
895 | /* |
896 | * We received a beacon _after_ association so | |
897 | * remove the session protection. | |
898 | */ | |
899 | iwl_mvm_remove_time_event(mvm, mvmvif, | |
900 | &mvmvif->time_event_data); | |
e3c588ec | 901 | } else if (changes & (BSS_CHANGED_PS | BSS_CHANGED_QOS)) { |
4bf881f5 AB |
902 | ret = iwl_mvm_power_update_mode(mvm, vif); |
903 | if (ret) | |
904 | IWL_ERR(mvm, "failed to update power mode\n"); | |
8ca151b5 | 905 | } |
88f2fd73 MG |
906 | if (changes & BSS_CHANGED_TXPOWER) { |
907 | IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n", | |
908 | bss_conf->txpower); | |
909 | iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower); | |
910 | } | |
a20fd398 AO |
911 | |
912 | if (changes & BSS_CHANGED_CQM) { | |
913 | IWL_DEBUG_MAC80211(mvm, "cqm info_changed"); | |
914 | /* reset cqm events tracking */ | |
915 | mvmvif->bf_data.last_cqm_event = 0; | |
916 | ret = iwl_mvm_update_beacon_filter(mvm, vif); | |
917 | if (ret) | |
918 | IWL_ERR(mvm, "failed to update CQM thresholds\n"); | |
919 | } | |
8ca151b5 JB |
920 | } |
921 | ||
5023d966 JB |
922 | static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, |
923 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
924 | { |
925 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
926 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
927 | int ret; | |
928 | ||
929 | mutex_lock(&mvm->mutex); | |
930 | ||
931 | /* Send the beacon template */ | |
932 | ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif); | |
933 | if (ret) | |
934 | goto out_unlock; | |
935 | ||
936 | /* Add the mac context */ | |
937 | ret = iwl_mvm_mac_ctxt_add(mvm, vif); | |
938 | if (ret) | |
939 | goto out_unlock; | |
940 | ||
941 | /* Perform the binding */ | |
942 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
943 | if (ret) | |
944 | goto out_remove; | |
945 | ||
5023d966 | 946 | mvmvif->ap_ibss_active = true; |
8ca151b5 JB |
947 | |
948 | /* Send the bcast station. At this stage the TBTT and DTIM time events | |
949 | * are added and applied to the scheduler */ | |
950 | ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta); | |
951 | if (ret) | |
952 | goto out_unbind; | |
953 | ||
954 | ret = iwl_mvm_update_quotas(mvm, vif); | |
955 | if (ret) | |
956 | goto out_rm_bcast; | |
957 | ||
5023d966 | 958 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 JB |
959 | if (vif->p2p && mvm->p2p_device_vif) |
960 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); | |
961 | ||
8e484f0b | 962 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 963 | |
8ca151b5 JB |
964 | mutex_unlock(&mvm->mutex); |
965 | return 0; | |
966 | ||
967 | out_rm_bcast: | |
968 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); | |
969 | out_unbind: | |
970 | iwl_mvm_binding_remove_vif(mvm, vif); | |
971 | out_remove: | |
972 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
973 | out_unlock: | |
974 | mutex_unlock(&mvm->mutex); | |
975 | return ret; | |
976 | } | |
977 | ||
5023d966 JB |
978 | static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw *hw, |
979 | struct ieee80211_vif *vif) | |
8ca151b5 JB |
980 | { |
981 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
982 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
983 | ||
38a12b5b JB |
984 | iwl_mvm_prepare_mac_removal(mvm, vif); |
985 | ||
8ca151b5 JB |
986 | mutex_lock(&mvm->mutex); |
987 | ||
5023d966 | 988 | mvmvif->ap_ibss_active = false; |
8ca151b5 | 989 | |
8e484f0b | 990 | iwl_mvm_bt_coex_vif_change(mvm); |
dac94da8 | 991 | |
5023d966 | 992 | /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */ |
8ca151b5 JB |
993 | if (vif->p2p && mvm->p2p_device_vif) |
994 | iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif); | |
995 | ||
996 | iwl_mvm_update_quotas(mvm, NULL); | |
997 | iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta); | |
998 | iwl_mvm_binding_remove_vif(mvm, vif); | |
999 | iwl_mvm_mac_ctxt_remove(mvm, vif); | |
1000 | ||
1001 | mutex_unlock(&mvm->mutex); | |
1002 | } | |
1003 | ||
5023d966 JB |
1004 | static void |
1005 | iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm, | |
1006 | struct ieee80211_vif *vif, | |
1007 | struct ieee80211_bss_conf *bss_conf, | |
1008 | u32 changes) | |
8ca151b5 | 1009 | { |
8a5e3660 AA |
1010 | enum ieee80211_bss_change ht_change = BSS_CHANGED_ERP_CTS_PROT | |
1011 | BSS_CHANGED_HT | | |
1012 | BSS_CHANGED_BANDWIDTH; | |
1013 | int ret; | |
1014 | ||
1015 | if (changes & ht_change) { | |
1016 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); | |
1017 | if (ret) | |
1018 | IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr); | |
1019 | } | |
1020 | ||
8ca151b5 JB |
1021 | /* Need to send a new beacon template to the FW */ |
1022 | if (changes & BSS_CHANGED_BEACON) { | |
1023 | if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) | |
1024 | IWL_WARN(mvm, "Failed updating beacon data\n"); | |
1025 | } | |
1026 | } | |
1027 | ||
1028 | static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, | |
1029 | struct ieee80211_vif *vif, | |
1030 | struct ieee80211_bss_conf *bss_conf, | |
1031 | u32 changes) | |
1032 | { | |
1033 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1034 | ||
1035 | mutex_lock(&mvm->mutex); | |
1036 | ||
1037 | switch (vif->type) { | |
1038 | case NL80211_IFTYPE_STATION: | |
1039 | iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes); | |
1040 | break; | |
1041 | case NL80211_IFTYPE_AP: | |
5023d966 JB |
1042 | case NL80211_IFTYPE_ADHOC: |
1043 | iwl_mvm_bss_info_changed_ap_ibss(mvm, vif, bss_conf, changes); | |
8ca151b5 JB |
1044 | break; |
1045 | default: | |
1046 | /* shouldn't happen */ | |
1047 | WARN_ON_ONCE(1); | |
1048 | } | |
1049 | ||
1050 | mutex_unlock(&mvm->mutex); | |
1051 | } | |
1052 | ||
1053 | static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, | |
1054 | struct ieee80211_vif *vif, | |
1055 | struct cfg80211_scan_request *req) | |
1056 | { | |
1057 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1058 | int ret; | |
1059 | ||
1060 | if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS) | |
1061 | return -EINVAL; | |
1062 | ||
1063 | mutex_lock(&mvm->mutex); | |
1064 | ||
1065 | if (mvm->scan_status == IWL_MVM_SCAN_NONE) | |
1066 | ret = iwl_mvm_scan_request(mvm, vif, req); | |
1067 | else | |
1068 | ret = -EBUSY; | |
1069 | ||
1070 | mutex_unlock(&mvm->mutex); | |
1071 | ||
1072 | return ret; | |
1073 | } | |
1074 | ||
1075 | static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw, | |
1076 | struct ieee80211_vif *vif) | |
1077 | { | |
1078 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1079 | ||
1080 | mutex_lock(&mvm->mutex); | |
1081 | ||
1082 | iwl_mvm_cancel_scan(mvm); | |
1083 | ||
1084 | mutex_unlock(&mvm->mutex); | |
1085 | } | |
1086 | ||
1087 | static void | |
1088 | iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw, | |
1089 | struct ieee80211_sta *sta, u16 tid, | |
1090 | int num_frames, | |
1091 | enum ieee80211_frame_release_type reason, | |
1092 | bool more_data) | |
1093 | { | |
1094 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
8ca151b5 JB |
1095 | |
1096 | /* TODO: how do we tell the fw to send frames for a specific TID */ | |
1097 | ||
1098 | /* | |
1099 | * The fw will send EOSP notification when the last frame will be | |
1100 | * transmitted. | |
1101 | */ | |
9cc40712 | 1102 | iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames); |
8ca151b5 JB |
1103 | } |
1104 | ||
1105 | static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw, | |
1106 | struct ieee80211_vif *vif, | |
1107 | enum sta_notify_cmd cmd, | |
1108 | struct ieee80211_sta *sta) | |
1109 | { | |
1110 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
5b577a90 | 1111 | struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); |
8ca151b5 JB |
1112 | |
1113 | switch (cmd) { | |
1114 | case STA_NOTIFY_SLEEP: | |
e3d4bc8c | 1115 | if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0) |
8ca151b5 JB |
1116 | ieee80211_sta_block_awake(hw, sta, true); |
1117 | /* | |
1118 | * The fw updates the STA to be asleep. Tx packets on the Tx | |
1119 | * queues to this station will not be transmitted. The fw will | |
1120 | * send a Tx response with TX_STATUS_FAIL_DEST_PS. | |
1121 | */ | |
1122 | break; | |
1123 | case STA_NOTIFY_AWAKE: | |
881acd89 | 1124 | if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT)) |
8ca151b5 | 1125 | break; |
9cc40712 | 1126 | iwl_mvm_sta_modify_ps_wake(mvm, sta); |
8ca151b5 JB |
1127 | break; |
1128 | default: | |
1129 | break; | |
1130 | } | |
1131 | } | |
1132 | ||
1133 | static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, | |
1134 | struct ieee80211_vif *vif, | |
1135 | struct ieee80211_sta *sta, | |
1136 | enum ieee80211_sta_state old_state, | |
1137 | enum ieee80211_sta_state new_state) | |
1138 | { | |
1139 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1140 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1141 | int ret; | |
1142 | ||
1143 | IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n", | |
1144 | sta->addr, old_state, new_state); | |
1145 | ||
1146 | /* this would be a mac80211 bug ... but don't crash */ | |
1147 | if (WARN_ON_ONCE(!mvmvif->phy_ctxt)) | |
1148 | return -EINVAL; | |
1149 | ||
1150 | /* if a STA is being removed, reuse its ID */ | |
1151 | flush_work(&mvm->sta_drained_wk); | |
1152 | ||
1153 | mutex_lock(&mvm->mutex); | |
1154 | if (old_state == IEEE80211_STA_NOTEXIST && | |
1155 | new_state == IEEE80211_STA_NONE) { | |
48bc1307 JB |
1156 | /* |
1157 | * Firmware bug - it'll crash if the beacon interval is less | |
1158 | * than 16. We can't avoid connecting at all, so refuse the | |
1159 | * station state change, this will cause mac80211 to abandon | |
1160 | * attempts to connect to this AP, and eventually wpa_s will | |
1161 | * blacklist the AP... | |
1162 | */ | |
1163 | if (vif->type == NL80211_IFTYPE_STATION && | |
1164 | vif->bss_conf.beacon_int < 16) { | |
1165 | IWL_ERR(mvm, | |
1166 | "AP %pM beacon interval is %d, refusing due to firmware bug!\n", | |
1167 | sta->addr, vif->bss_conf.beacon_int); | |
1168 | ret = -EINVAL; | |
1169 | goto out_unlock; | |
1170 | } | |
8ca151b5 JB |
1171 | ret = iwl_mvm_add_sta(mvm, vif, sta); |
1172 | } else if (old_state == IEEE80211_STA_NONE && | |
1173 | new_state == IEEE80211_STA_AUTH) { | |
1174 | ret = 0; | |
1175 | } else if (old_state == IEEE80211_STA_AUTH && | |
1176 | new_state == IEEE80211_STA_ASSOC) { | |
7a453973 JB |
1177 | ret = iwl_mvm_update_sta(mvm, vif, sta); |
1178 | if (ret == 0) | |
1179 | iwl_mvm_rs_rate_init(mvm, sta, | |
b87c2179 ES |
1180 | mvmvif->phy_ctxt->channel->band, |
1181 | true); | |
8ca151b5 JB |
1182 | } else if (old_state == IEEE80211_STA_ASSOC && |
1183 | new_state == IEEE80211_STA_AUTHORIZED) { | |
7df15b1e HG |
1184 | /* enable beacon filtering */ |
1185 | WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif)); | |
8ca151b5 JB |
1186 | ret = 0; |
1187 | } else if (old_state == IEEE80211_STA_AUTHORIZED && | |
1188 | new_state == IEEE80211_STA_ASSOC) { | |
7df15b1e HG |
1189 | /* disable beacon filtering */ |
1190 | WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif)); | |
8ca151b5 JB |
1191 | ret = 0; |
1192 | } else if (old_state == IEEE80211_STA_ASSOC && | |
1193 | new_state == IEEE80211_STA_AUTH) { | |
1194 | ret = 0; | |
1195 | } else if (old_state == IEEE80211_STA_AUTH && | |
1196 | new_state == IEEE80211_STA_NONE) { | |
1197 | ret = 0; | |
1198 | } else if (old_state == IEEE80211_STA_NONE && | |
1199 | new_state == IEEE80211_STA_NOTEXIST) { | |
1200 | ret = iwl_mvm_rm_sta(mvm, vif, sta); | |
1201 | } else { | |
1202 | ret = -EIO; | |
1203 | } | |
48bc1307 | 1204 | out_unlock: |
8ca151b5 JB |
1205 | mutex_unlock(&mvm->mutex); |
1206 | ||
1207 | return ret; | |
1208 | } | |
1209 | ||
1210 | static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | |
1211 | { | |
1212 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1213 | ||
1214 | mvm->rts_threshold = value; | |
1215 | ||
1216 | return 0; | |
1217 | } | |
1218 | ||
1f3b0ff8 LE |
1219 | static void iwl_mvm_sta_rc_update(struct ieee80211_hw *hw, |
1220 | struct ieee80211_vif *vif, | |
1221 | struct ieee80211_sta *sta, u32 changed) | |
1222 | { | |
1223 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1224 | ||
1225 | if (vif->type == NL80211_IFTYPE_STATION && | |
1226 | changed & IEEE80211_RC_NSS_CHANGED) | |
1227 | iwl_mvm_sf_update(mvm, vif, false); | |
1228 | } | |
1229 | ||
8ca151b5 JB |
1230 | static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw, |
1231 | struct ieee80211_vif *vif, u16 ac, | |
1232 | const struct ieee80211_tx_queue_params *params) | |
1233 | { | |
1234 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1235 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1236 | ||
1237 | mvmvif->queue_params[ac] = *params; | |
1238 | ||
1239 | /* | |
1240 | * No need to update right away, we'll get BSS_CHANGED_QOS | |
1241 | * The exception is P2P_DEVICE interface which needs immediate update. | |
1242 | */ | |
1243 | if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { | |
1244 | int ret; | |
1245 | ||
1246 | mutex_lock(&mvm->mutex); | |
1247 | ret = iwl_mvm_mac_ctxt_changed(mvm, vif); | |
1248 | mutex_unlock(&mvm->mutex); | |
1249 | return ret; | |
1250 | } | |
1251 | return 0; | |
1252 | } | |
1253 | ||
1254 | static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw, | |
1255 | struct ieee80211_vif *vif) | |
1256 | { | |
1257 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1258 | u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS, | |
1259 | 200 + vif->bss_conf.beacon_int); | |
1260 | u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS, | |
1261 | 100 + vif->bss_conf.beacon_int); | |
1262 | ||
1263 | if (WARN_ON_ONCE(vif->bss_conf.assoc)) | |
1264 | return; | |
1265 | ||
1266 | mutex_lock(&mvm->mutex); | |
1267 | /* Try really hard to protect the session and hear a beacon */ | |
016d27e1 | 1268 | iwl_mvm_protect_session(mvm, vif, duration, min_duration, 500); |
8ca151b5 JB |
1269 | mutex_unlock(&mvm->mutex); |
1270 | } | |
1271 | ||
35a000b7 DS |
1272 | static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw *hw, |
1273 | struct ieee80211_vif *vif, | |
1274 | struct cfg80211_sched_scan_request *req, | |
1275 | struct ieee80211_sched_scan_ies *ies) | |
1276 | { | |
1277 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1278 | int ret; | |
1279 | ||
1280 | mutex_lock(&mvm->mutex); | |
1281 | ||
1282 | if (mvm->scan_status != IWL_MVM_SCAN_NONE) { | |
1283 | IWL_DEBUG_SCAN(mvm, | |
1284 | "SCHED SCAN request during internal scan - abort\n"); | |
1285 | ret = -EBUSY; | |
1286 | goto out; | |
1287 | } | |
1288 | ||
1289 | mvm->scan_status = IWL_MVM_SCAN_SCHED; | |
1290 | ||
1291 | ret = iwl_mvm_config_sched_scan(mvm, vif, req, ies); | |
1292 | if (ret) | |
1293 | goto err; | |
1294 | ||
1295 | ret = iwl_mvm_config_sched_scan_profiles(mvm, req); | |
1296 | if (ret) | |
1297 | goto err; | |
1298 | ||
1299 | ret = iwl_mvm_sched_scan_start(mvm, req); | |
1300 | if (!ret) | |
1301 | goto out; | |
1302 | err: | |
1303 | mvm->scan_status = IWL_MVM_SCAN_NONE; | |
1304 | out: | |
1305 | mutex_unlock(&mvm->mutex); | |
1306 | return ret; | |
1307 | } | |
1308 | ||
1309 | static void iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw *hw, | |
1310 | struct ieee80211_vif *vif) | |
1311 | { | |
1312 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1313 | ||
1314 | mutex_lock(&mvm->mutex); | |
1315 | iwl_mvm_sched_scan_stop(mvm); | |
1316 | mutex_unlock(&mvm->mutex); | |
1317 | } | |
1318 | ||
8ca151b5 JB |
1319 | static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw, |
1320 | enum set_key_cmd cmd, | |
1321 | struct ieee80211_vif *vif, | |
1322 | struct ieee80211_sta *sta, | |
1323 | struct ieee80211_key_conf *key) | |
1324 | { | |
1325 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1326 | int ret; | |
1327 | ||
1328 | if (iwlwifi_mod_params.sw_crypto) { | |
1329 | IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n"); | |
1330 | return -EOPNOTSUPP; | |
1331 | } | |
1332 | ||
1333 | switch (key->cipher) { | |
1334 | case WLAN_CIPHER_SUITE_TKIP: | |
1335 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; | |
1336 | /* fall-through */ | |
1337 | case WLAN_CIPHER_SUITE_CCMP: | |
1338 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | |
1339 | break; | |
1340 | case WLAN_CIPHER_SUITE_AES_CMAC: | |
1341 | WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE)); | |
1342 | break; | |
1343 | case WLAN_CIPHER_SUITE_WEP40: | |
1344 | case WLAN_CIPHER_SUITE_WEP104: | |
1345 | /* | |
1346 | * Support for TX only, at least for now, so accept | |
1347 | * the key and do nothing else. Then mac80211 will | |
1348 | * pass it for TX but we don't have to use it for RX. | |
1349 | */ | |
1350 | return 0; | |
1351 | default: | |
e36e5433 MS |
1352 | /* currently FW supports only one optional cipher scheme */ |
1353 | if (hw->n_cipher_schemes && | |
1354 | hw->cipher_schemes->cipher == key->cipher) | |
1355 | key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; | |
1356 | else | |
1357 | return -EOPNOTSUPP; | |
8ca151b5 JB |
1358 | } |
1359 | ||
1360 | mutex_lock(&mvm->mutex); | |
1361 | ||
1362 | switch (cmd) { | |
1363 | case SET_KEY: | |
5023d966 JB |
1364 | if ((vif->type == NL80211_IFTYPE_ADHOC || |
1365 | vif->type == NL80211_IFTYPE_AP) && !sta) { | |
1366 | /* | |
1367 | * GTK on AP interface is a TX-only key, return 0; | |
1368 | * on IBSS they're per-station and because we're lazy | |
1369 | * we don't support them for RX, so do the same. | |
1370 | */ | |
6caffd4f JB |
1371 | ret = 0; |
1372 | key->hw_key_idx = STA_KEY_IDX_INVALID; | |
1373 | break; | |
1374 | } | |
1375 | ||
8ca151b5 JB |
1376 | IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n"); |
1377 | ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false); | |
1378 | if (ret) { | |
1379 | IWL_WARN(mvm, "set key failed\n"); | |
1380 | /* | |
1381 | * can't add key for RX, but we don't need it | |
1382 | * in the device for TX so still return 0 | |
1383 | */ | |
6caffd4f | 1384 | key->hw_key_idx = STA_KEY_IDX_INVALID; |
8ca151b5 JB |
1385 | ret = 0; |
1386 | } | |
1387 | ||
1388 | break; | |
1389 | case DISABLE_KEY: | |
6caffd4f JB |
1390 | if (key->hw_key_idx == STA_KEY_IDX_INVALID) { |
1391 | ret = 0; | |
1392 | break; | |
1393 | } | |
1394 | ||
8ca151b5 JB |
1395 | IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n"); |
1396 | ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key); | |
1397 | break; | |
1398 | default: | |
1399 | ret = -EINVAL; | |
1400 | } | |
1401 | ||
1402 | mutex_unlock(&mvm->mutex); | |
1403 | return ret; | |
1404 | } | |
1405 | ||
1406 | static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw, | |
1407 | struct ieee80211_vif *vif, | |
1408 | struct ieee80211_key_conf *keyconf, | |
1409 | struct ieee80211_sta *sta, | |
1410 | u32 iv32, u16 *phase1key) | |
1411 | { | |
1412 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1413 | ||
5023d966 JB |
1414 | if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID) |
1415 | return; | |
1416 | ||
8ca151b5 JB |
1417 | iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key); |
1418 | } | |
1419 | ||
1420 | ||
1421 | static int iwl_mvm_roc(struct ieee80211_hw *hw, | |
1422 | struct ieee80211_vif *vif, | |
1423 | struct ieee80211_channel *channel, | |
d339d5ca IP |
1424 | int duration, |
1425 | enum ieee80211_roc_type type) | |
8ca151b5 JB |
1426 | { |
1427 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 | 1428 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
8ca151b5 | 1429 | struct cfg80211_chan_def chandef; |
31d385ae IP |
1430 | struct iwl_mvm_phy_ctxt *phy_ctxt; |
1431 | int ret, i; | |
1432 | ||
1433 | IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, | |
1434 | duration, type); | |
8ca151b5 JB |
1435 | |
1436 | if (vif->type != NL80211_IFTYPE_P2P_DEVICE) { | |
1437 | IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type); | |
1438 | return -EINVAL; | |
1439 | } | |
1440 | ||
8ca151b5 JB |
1441 | mutex_lock(&mvm->mutex); |
1442 | ||
31d385ae IP |
1443 | for (i = 0; i < NUM_PHY_CTX; i++) { |
1444 | phy_ctxt = &mvm->phy_ctxts[i]; | |
1445 | if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) | |
1446 | continue; | |
1447 | ||
1448 | if (phy_ctxt->ref && channel == phy_ctxt->channel) { | |
1449 | /* | |
1450 | * Unbind the P2P_DEVICE from the current PHY context, | |
1451 | * and if the PHY context is not used remove it. | |
1452 | */ | |
1453 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
1454 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
1455 | goto out_unlock; | |
1456 | ||
1457 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
1458 | ||
1459 | /* Bind the P2P_DEVICE to the current PHY Context */ | |
1460 | mvmvif->phy_ctxt = phy_ctxt; | |
1461 | ||
1462 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1463 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
1464 | goto out_unlock; | |
1465 | ||
1466 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
1467 | goto schedule_time_event; | |
1468 | } | |
1469 | } | |
1470 | ||
1471 | /* Need to update the PHY context only if the ROC channel changed */ | |
1472 | if (channel == mvmvif->phy_ctxt->channel) | |
1473 | goto schedule_time_event; | |
1474 | ||
8ca151b5 | 1475 | cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT); |
8ca151b5 | 1476 | |
31d385ae IP |
1477 | /* |
1478 | * Change the PHY context configuration as it is currently referenced | |
1479 | * only by the P2P Device MAC | |
1480 | */ | |
1481 | if (mvmvif->phy_ctxt->ref == 1) { | |
1482 | ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt, | |
1483 | &chandef, 1, 1); | |
1484 | if (ret) | |
1485 | goto out_unlock; | |
1486 | } else { | |
1487 | /* | |
1488 | * The PHY context is shared with other MACs. Need to remove the | |
1489 | * P2P Device from the binding, allocate an new PHY context and | |
1490 | * create a new binding | |
1491 | */ | |
1492 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); | |
1493 | if (!phy_ctxt) { | |
1494 | ret = -ENOSPC; | |
1495 | goto out_unlock; | |
1496 | } | |
1497 | ||
1498 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef, | |
1499 | 1, 1); | |
1500 | if (ret) { | |
1501 | IWL_ERR(mvm, "Failed to change PHY context\n"); | |
1502 | goto out_unlock; | |
1503 | } | |
1504 | ||
1505 | /* Unbind the P2P_DEVICE from the current PHY context */ | |
1506 | ret = iwl_mvm_binding_remove_vif(mvm, vif); | |
1507 | if (WARN(ret, "Failed unbinding P2P_DEVICE\n")) | |
1508 | goto out_unlock; | |
1509 | ||
1510 | iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt); | |
1511 | ||
1512 | /* Bind the P2P_DEVICE to the new allocated PHY context */ | |
1513 | mvmvif->phy_ctxt = phy_ctxt; | |
1514 | ||
1515 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1516 | if (WARN(ret, "Failed binding P2P_DEVICE\n")) | |
1517 | goto out_unlock; | |
1518 | ||
1519 | iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt); | |
1520 | } | |
1521 | ||
1522 | schedule_time_event: | |
8ca151b5 | 1523 | /* Schedule the time events */ |
e635c797 | 1524 | ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type); |
8ca151b5 | 1525 | |
31d385ae | 1526 | out_unlock: |
8ca151b5 JB |
1527 | mutex_unlock(&mvm->mutex); |
1528 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
8ca151b5 JB |
1529 | return ret; |
1530 | } | |
1531 | ||
1532 | static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw) | |
1533 | { | |
1534 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1535 | ||
1536 | IWL_DEBUG_MAC80211(mvm, "enter\n"); | |
1537 | ||
1538 | mutex_lock(&mvm->mutex); | |
1539 | iwl_mvm_stop_p2p_roc(mvm); | |
1540 | mutex_unlock(&mvm->mutex); | |
1541 | ||
1542 | IWL_DEBUG_MAC80211(mvm, "leave\n"); | |
1543 | return 0; | |
1544 | } | |
1545 | ||
1546 | static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw, | |
1547 | struct ieee80211_chanctx_conf *ctx) | |
1548 | { | |
1549 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
1550 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
1551 | struct iwl_mvm_phy_ctxt *phy_ctxt; | |
8ca151b5 JB |
1552 | int ret; |
1553 | ||
53a9d61e | 1554 | IWL_DEBUG_MAC80211(mvm, "Add channel context\n"); |
fe0f2de3 | 1555 | |
8ca151b5 | 1556 | mutex_lock(&mvm->mutex); |
fe0f2de3 IP |
1557 | phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm); |
1558 | if (!phy_ctxt) { | |
1559 | ret = -ENOSPC; | |
1560 | goto out; | |
1561 | } | |
8ca151b5 | 1562 | |
53a9d61e IP |
1563 | ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, |
1564 | ctx->rx_chains_static, | |
1565 | ctx->rx_chains_dynamic); | |
fe0f2de3 IP |
1566 | if (ret) { |
1567 | IWL_ERR(mvm, "Failed to add PHY context\n"); | |
1568 | goto out; | |
1569 | } | |
1570 | ||
53a9d61e | 1571 | iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt); |
fe0f2de3 IP |
1572 | *phy_ctxt_id = phy_ctxt->id; |
1573 | out: | |
8ca151b5 JB |
1574 | mutex_unlock(&mvm->mutex); |
1575 | return ret; | |
1576 | } | |
1577 | ||
1578 | static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw, | |
1579 | struct ieee80211_chanctx_conf *ctx) | |
1580 | { | |
1581 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
1582 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
1583 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 JB |
1584 | |
1585 | mutex_lock(&mvm->mutex); | |
fe0f2de3 | 1586 | iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt); |
8ca151b5 JB |
1587 | mutex_unlock(&mvm->mutex); |
1588 | } | |
1589 | ||
1590 | static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw, | |
1591 | struct ieee80211_chanctx_conf *ctx, | |
1592 | u32 changed) | |
1593 | { | |
1594 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
1595 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
1596 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 | 1597 | |
31d385ae IP |
1598 | if (WARN_ONCE((phy_ctxt->ref > 1) && |
1599 | (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH | | |
1600 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS | | |
1601 | IEEE80211_CHANCTX_CHANGE_RADAR)), | |
1602 | "Cannot change PHY. Ref=%d, changed=0x%X\n", | |
1603 | phy_ctxt->ref, changed)) | |
1604 | return; | |
1605 | ||
8ca151b5 JB |
1606 | mutex_lock(&mvm->mutex); |
1607 | iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def, | |
1608 | ctx->rx_chains_static, | |
1609 | ctx->rx_chains_dynamic); | |
8e484f0b | 1610 | iwl_mvm_bt_coex_vif_change(mvm); |
8ca151b5 JB |
1611 | mutex_unlock(&mvm->mutex); |
1612 | } | |
1613 | ||
1614 | static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw, | |
1615 | struct ieee80211_vif *vif, | |
1616 | struct ieee80211_chanctx_conf *ctx) | |
1617 | { | |
1618 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
fe0f2de3 IP |
1619 | u16 *phy_ctxt_id = (u16 *)ctx->drv_priv; |
1620 | struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id]; | |
8ca151b5 JB |
1621 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); |
1622 | int ret; | |
1623 | ||
1624 | mutex_lock(&mvm->mutex); | |
1625 | ||
fe0f2de3 | 1626 | mvmvif->phy_ctxt = phy_ctxt; |
8ca151b5 JB |
1627 | |
1628 | switch (vif->type) { | |
1629 | case NL80211_IFTYPE_AP: | |
5023d966 | 1630 | case NL80211_IFTYPE_ADHOC: |
8ca151b5 JB |
1631 | /* |
1632 | * The AP binding flow is handled as part of the start_ap flow | |
5023d966 | 1633 | * (in bss_info_changed), similarly for IBSS. |
8ca151b5 JB |
1634 | */ |
1635 | ret = 0; | |
1636 | goto out_unlock; | |
1637 | case NL80211_IFTYPE_STATION: | |
8ca151b5 JB |
1638 | case NL80211_IFTYPE_MONITOR: |
1639 | break; | |
1640 | default: | |
1641 | ret = -EINVAL; | |
1642 | goto out_unlock; | |
1643 | } | |
1644 | ||
1645 | ret = iwl_mvm_binding_add_vif(mvm, vif); | |
1646 | if (ret) | |
1647 | goto out_unlock; | |
1648 | ||
1649 | /* | |
1650 | * Setting the quota at this stage is only required for monitor | |
1651 | * interfaces. For the other types, the bss_info changed flow | |
1652 | * will handle quota settings. | |
1653 | */ | |
1654 | if (vif->type == NL80211_IFTYPE_MONITOR) { | |
1e1391ca | 1655 | mvmvif->monitor_active = true; |
8ca151b5 JB |
1656 | ret = iwl_mvm_update_quotas(mvm, vif); |
1657 | if (ret) | |
1658 | goto out_remove_binding; | |
1659 | } | |
1660 | ||
1661 | goto out_unlock; | |
1662 | ||
1663 | out_remove_binding: | |
1664 | iwl_mvm_binding_remove_vif(mvm, vif); | |
1665 | out_unlock: | |
1666 | mutex_unlock(&mvm->mutex); | |
1667 | if (ret) | |
1668 | mvmvif->phy_ctxt = NULL; | |
1669 | return ret; | |
1670 | } | |
1671 | ||
1672 | static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw, | |
1673 | struct ieee80211_vif *vif, | |
1674 | struct ieee80211_chanctx_conf *ctx) | |
1675 | { | |
1676 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1677 | struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); | |
1678 | ||
1679 | mutex_lock(&mvm->mutex); | |
1680 | ||
1681 | iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); | |
1682 | ||
8ca151b5 | 1683 | switch (vif->type) { |
5023d966 JB |
1684 | case NL80211_IFTYPE_AP: |
1685 | case NL80211_IFTYPE_ADHOC: | |
1686 | goto out_unlock; | |
8ca151b5 | 1687 | case NL80211_IFTYPE_MONITOR: |
1e1391ca IP |
1688 | mvmvif->monitor_active = false; |
1689 | iwl_mvm_update_quotas(mvm, NULL); | |
8ca151b5 JB |
1690 | break; |
1691 | default: | |
1692 | break; | |
1693 | } | |
1694 | ||
1e1391ca | 1695 | iwl_mvm_binding_remove_vif(mvm, vif); |
8ca151b5 JB |
1696 | out_unlock: |
1697 | mvmvif->phy_ctxt = NULL; | |
1698 | mutex_unlock(&mvm->mutex); | |
1699 | } | |
1700 | ||
1701 | static int iwl_mvm_set_tim(struct ieee80211_hw *hw, | |
1702 | struct ieee80211_sta *sta, | |
1703 | bool set) | |
1704 | { | |
1705 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1706 | struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv; | |
1707 | ||
1708 | if (!mvm_sta || !mvm_sta->vif) { | |
1709 | IWL_ERR(mvm, "Station is not associated to a vif\n"); | |
1710 | return -EINVAL; | |
1711 | } | |
1712 | ||
1713 | return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif); | |
1714 | } | |
1715 | ||
507cadf2 DS |
1716 | #ifdef CONFIG_NL80211_TESTMODE |
1717 | static const struct nla_policy iwl_mvm_tm_policy[IWL_MVM_TM_ATTR_MAX + 1] = { | |
1718 | [IWL_MVM_TM_ATTR_CMD] = { .type = NLA_U32 }, | |
1719 | [IWL_MVM_TM_ATTR_NOA_DURATION] = { .type = NLA_U32 }, | |
f6c6ad42 | 1720 | [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE] = { .type = NLA_U32 }, |
507cadf2 DS |
1721 | }; |
1722 | ||
1723 | static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm *mvm, | |
1724 | struct ieee80211_vif *vif, | |
1725 | void *data, int len) | |
1726 | { | |
1727 | struct nlattr *tb[IWL_MVM_TM_ATTR_MAX + 1]; | |
1728 | int err; | |
1729 | u32 noa_duration; | |
1730 | ||
1731 | err = nla_parse(tb, IWL_MVM_TM_ATTR_MAX, data, len, iwl_mvm_tm_policy); | |
1732 | if (err) | |
1733 | return err; | |
1734 | ||
1735 | if (!tb[IWL_MVM_TM_ATTR_CMD]) | |
1736 | return -EINVAL; | |
1737 | ||
1738 | switch (nla_get_u32(tb[IWL_MVM_TM_ATTR_CMD])) { | |
1739 | case IWL_MVM_TM_CMD_SET_NOA: | |
1740 | if (!vif || vif->type != NL80211_IFTYPE_AP || !vif->p2p || | |
1741 | !vif->bss_conf.enable_beacon || | |
1742 | !tb[IWL_MVM_TM_ATTR_NOA_DURATION]) | |
1743 | return -EINVAL; | |
1744 | ||
1745 | noa_duration = nla_get_u32(tb[IWL_MVM_TM_ATTR_NOA_DURATION]); | |
1746 | if (noa_duration >= vif->bss_conf.beacon_int) | |
1747 | return -EINVAL; | |
1748 | ||
1749 | mvm->noa_duration = noa_duration; | |
1750 | mvm->noa_vif = vif; | |
1751 | ||
1752 | return iwl_mvm_update_quotas(mvm, NULL); | |
f6c6ad42 JB |
1753 | case IWL_MVM_TM_CMD_SET_BEACON_FILTER: |
1754 | /* must be associated client vif - ignore authorized */ | |
1755 | if (!vif || vif->type != NL80211_IFTYPE_STATION || | |
1756 | !vif->bss_conf.assoc || !vif->bss_conf.dtim_period || | |
1757 | !tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE]) | |
1758 | return -EINVAL; | |
1759 | ||
1760 | if (nla_get_u32(tb[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE])) | |
1761 | return iwl_mvm_enable_beacon_filter(mvm, vif); | |
1762 | return iwl_mvm_disable_beacon_filter(mvm, vif); | |
507cadf2 DS |
1763 | } |
1764 | ||
1765 | return -EOPNOTSUPP; | |
1766 | } | |
1767 | ||
1768 | static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw *hw, | |
1769 | struct ieee80211_vif *vif, | |
1770 | void *data, int len) | |
1771 | { | |
1772 | struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); | |
1773 | int err; | |
1774 | ||
1775 | mutex_lock(&mvm->mutex); | |
1776 | err = __iwl_mvm_mac_testmode_cmd(mvm, vif, data, len); | |
1777 | mutex_unlock(&mvm->mutex); | |
1778 | ||
1779 | return err; | |
1780 | } | |
1781 | #endif | |
1782 | ||
8ca151b5 JB |
1783 | struct ieee80211_ops iwl_mvm_hw_ops = { |
1784 | .tx = iwl_mvm_mac_tx, | |
1785 | .ampdu_action = iwl_mvm_mac_ampdu_action, | |
1786 | .start = iwl_mvm_mac_start, | |
1787 | .restart_complete = iwl_mvm_mac_restart_complete, | |
1788 | .stop = iwl_mvm_mac_stop, | |
1789 | .add_interface = iwl_mvm_mac_add_interface, | |
1790 | .remove_interface = iwl_mvm_mac_remove_interface, | |
1791 | .config = iwl_mvm_mac_config, | |
1792 | .configure_filter = iwl_mvm_configure_filter, | |
1793 | .bss_info_changed = iwl_mvm_bss_info_changed, | |
1794 | .hw_scan = iwl_mvm_mac_hw_scan, | |
1795 | .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan, | |
1796 | .sta_state = iwl_mvm_mac_sta_state, | |
1797 | .sta_notify = iwl_mvm_mac_sta_notify, | |
1798 | .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames, | |
1799 | .set_rts_threshold = iwl_mvm_mac_set_rts_threshold, | |
1f3b0ff8 | 1800 | .sta_rc_update = iwl_mvm_sta_rc_update, |
8ca151b5 JB |
1801 | .conf_tx = iwl_mvm_mac_conf_tx, |
1802 | .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, | |
35a000b7 DS |
1803 | .sched_scan_start = iwl_mvm_mac_sched_scan_start, |
1804 | .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, | |
8ca151b5 JB |
1805 | .set_key = iwl_mvm_mac_set_key, |
1806 | .update_tkip_key = iwl_mvm_mac_update_tkip_key, | |
1807 | .remain_on_channel = iwl_mvm_roc, | |
1808 | .cancel_remain_on_channel = iwl_mvm_cancel_roc, | |
8ca151b5 JB |
1809 | .add_chanctx = iwl_mvm_add_chanctx, |
1810 | .remove_chanctx = iwl_mvm_remove_chanctx, | |
1811 | .change_chanctx = iwl_mvm_change_chanctx, | |
1812 | .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx, | |
1813 | .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx, | |
1814 | ||
5023d966 JB |
1815 | .start_ap = iwl_mvm_start_ap_ibss, |
1816 | .stop_ap = iwl_mvm_stop_ap_ibss, | |
1817 | .join_ibss = iwl_mvm_start_ap_ibss, | |
1818 | .leave_ibss = iwl_mvm_stop_ap_ibss, | |
8ca151b5 JB |
1819 | |
1820 | .set_tim = iwl_mvm_set_tim, | |
1821 | ||
507cadf2 DS |
1822 | CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) |
1823 | ||
8ca151b5 JB |
1824 | #ifdef CONFIG_PM_SLEEP |
1825 | /* look at d3.c */ | |
1826 | .suspend = iwl_mvm_suspend, | |
1827 | .resume = iwl_mvm_resume, | |
1828 | .set_wakeup = iwl_mvm_set_wakeup, | |
1829 | .set_rekey_data = iwl_mvm_set_rekey_data, | |
1830 | #if IS_ENABLED(CONFIG_IPV6) | |
1831 | .ipv6_addr_change = iwl_mvm_ipv6_addr_change, | |
1832 | #endif | |
1833 | .set_default_unicast_key = iwl_mvm_set_default_unicast_key, | |
1834 | #endif | |
1835 | }; |