blob: f2976901b1d57a6d3fb41e47b85ac02ba8e91d33 [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
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
Emmanuel Grumbach410dc5a2013-02-18 09:22:28 +020025 * in the file called COPYING.
Johannes Berg8ca151b2013-01-24 14:25:36 +010026 *
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>
Johannes Bergf0c26462013-01-22 20:41:58 +010068#include <linux/ip.h>
Johannes Berg8ca151b2013-01-24 14:25:36 +010069#include <net/mac80211.h>
Johannes Bergf0c26462013-01-22 20:41:58 +010070#include <net/tcp.h>
Johannes Berg8ca151b2013-01-24 14:25:36 +010071
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"
80
81static const struct ieee80211_iface_limit iwl_mvm_limits[] = {
82 {
83 .max = 1,
84 .types = BIT(NL80211_IFTYPE_STATION) |
85 BIT(NL80211_IFTYPE_AP),
86 },
Johannes Berg8ca151b2013-01-24 14:25:36 +010087};
88
89static const struct ieee80211_iface_combination iwl_mvm_iface_combinations[] = {
90 {
91 .num_different_channels = 1,
92 .max_interfaces = 3,
93 .limits = iwl_mvm_limits,
94 .n_limits = ARRAY_SIZE(iwl_mvm_limits),
95 },
96};
97
Johannes Bergf0c26462013-01-22 20:41:58 +010098#ifdef CONFIG_PM_SLEEP
99static const struct nl80211_wowlan_tcp_data_token_feature
100iwl_mvm_wowlan_tcp_token_feature = {
101 .min_len = 0,
102 .max_len = 255,
103 .bufsize = IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS,
104};
105
106static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support = {
107 .tok = &iwl_mvm_wowlan_tcp_token_feature,
108 .data_payload_max = IWL_WOWLAN_TCP_MAX_PACKET_LEN -
109 sizeof(struct ethhdr) -
110 sizeof(struct iphdr) -
111 sizeof(struct tcphdr),
112 .data_interval_max = 65535, /* __le16 in API */
113 .wake_payload_max = IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN -
114 sizeof(struct ethhdr) -
115 sizeof(struct iphdr) -
116 sizeof(struct tcphdr),
117 .seq = true,
118};
119#endif
120
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200121static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm *mvm)
122{
123 int i;
124
125 memset(mvm->phy_ctxts, 0, sizeof(mvm->phy_ctxts));
126 for (i = 0; i < NUM_PHY_CTX; i++) {
127 mvm->phy_ctxts[i].id = i;
128 mvm->phy_ctxts[i].ref = 0;
129 }
130}
131
Johannes Berg8ca151b2013-01-24 14:25:36 +0100132int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
133{
134 struct ieee80211_hw *hw = mvm->hw;
Ilan Peer831e85f2013-02-07 17:09:09 +0200135 int num_mac, ret, i;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100136
137 /* Tell mac80211 our characteristics */
138 hw->flags = IEEE80211_HW_SIGNAL_DBM |
139 IEEE80211_HW_SPECTRUM_MGMT |
140 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
141 IEEE80211_HW_QUEUE_CONTROL |
142 IEEE80211_HW_WANT_MONITOR_VIF |
Johannes Berg8ca151b2013-01-24 14:25:36 +0100143 IEEE80211_HW_SUPPORTS_PS |
144 IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
Johannes Bergd2931bb2013-02-05 18:10:04 +0100145 IEEE80211_HW_AMPDU_AGGREGATION |
Hila Gonend64048e2013-03-13 18:00:03 +0200146 IEEE80211_HW_TIMING_BEACON_ONLY |
147 IEEE80211_HW_CONNECTION_MONITOR;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100148
Ilan Peer398e8c62013-03-13 15:20:35 +0200149 hw->queues = IWL_MVM_FIRST_AGG_QUEUE;
150 hw->offchannel_tx_hw_queue = IWL_MVM_OFFCHANNEL_QUEUE;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100151 hw->rate_control_algorithm = "iwl-mvm-rs";
152
153 /*
154 * Enable 11w if advertised by firmware and software crypto
155 * is not enabled (as the firmware will interpret some mgmt
156 * packets, so enabling it with software crypto isn't safe)
157 */
158 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_MFP &&
159 !iwlwifi_mod_params.sw_crypto)
160 hw->flags |= IEEE80211_HW_MFP_CAPABLE;
161
162 hw->sta_data_size = sizeof(struct iwl_mvm_sta);
163 hw->vif_data_size = sizeof(struct iwl_mvm_vif);
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200164 hw->chanctx_data_size = sizeof(u16);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100165
166 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Johannes Bergeebfc932013-05-23 22:17:50 +0200167 BIT(NL80211_IFTYPE_AP);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100168
169 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
170 WIPHY_FLAG_DISABLE_BEACON_HINTS |
171 WIPHY_FLAG_IBSS_RSN;
172
173 hw->wiphy->iface_combinations = iwl_mvm_iface_combinations;
174 hw->wiphy->n_iface_combinations =
175 ARRAY_SIZE(iwl_mvm_iface_combinations);
176
Ilan Peerc451e6d2013-02-20 08:41:54 +0200177 hw->wiphy->max_remain_on_channel_duration = 10000;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100178 hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;
179
180 /* Extract MAC address */
181 memcpy(mvm->addresses[0].addr, mvm->nvm_data->hw_addr, ETH_ALEN);
182 hw->wiphy->addresses = mvm->addresses;
183 hw->wiphy->n_addresses = 1;
Ilan Peer831e85f2013-02-07 17:09:09 +0200184
185 /* Extract additional MAC addresses if available */
186 num_mac = (mvm->nvm_data->n_hw_addrs > 1) ?
187 min(IWL_MVM_MAX_ADDRESSES, mvm->nvm_data->n_hw_addrs) : 1;
188
189 for (i = 1; i < num_mac; i++) {
190 memcpy(mvm->addresses[i].addr, mvm->addresses[i-1].addr,
Johannes Berg8ca151b2013-01-24 14:25:36 +0100191 ETH_ALEN);
Ilan Peer831e85f2013-02-07 17:09:09 +0200192 mvm->addresses[i].addr[5]++;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100193 hw->wiphy->n_addresses++;
194 }
195
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200196 iwl_mvm_reset_phy_ctxts(mvm);
197
Johannes Berg8ca151b2013-01-24 14:25:36 +0100198 /* we create the 802.11 header and a max-length SSID element */
199 hw->wiphy->max_scan_ie_len =
200 mvm->fw->ucode_capa.max_probe_length - 24 - 34;
201 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
202
203 if (mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels)
204 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
205 &mvm->nvm_data->bands[IEEE80211_BAND_2GHZ];
206 if (mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels)
207 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
208 &mvm->nvm_data->bands[IEEE80211_BAND_5GHZ];
209
210 hw->wiphy->hw_version = mvm->trans->hw_id;
211
Alexander Bondarade50652013-04-03 16:28:47 +0300212 if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100213 hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
214 else
215 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
216
217 hw->wiphy->features |= NL80211_FEATURE_P2P_GO_CTWIN |
218 NL80211_FEATURE_P2P_GO_OPPPS;
219
220 mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
221
222#ifdef CONFIG_PM_SLEEP
223 if (mvm->fw->img[IWL_UCODE_WOWLAN].sec[0].len &&
224 mvm->trans->ops->d3_suspend &&
225 mvm->trans->ops->d3_resume &&
226 device_can_wakeup(mvm->trans->dev)) {
227 hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT |
228 WIPHY_WOWLAN_DISCONNECT |
229 WIPHY_WOWLAN_EAP_IDENTITY_REQ |
230 WIPHY_WOWLAN_RFKILL_RELEASE;
231 if (!iwlwifi_mod_params.sw_crypto)
232 hw->wiphy->wowlan.flags |=
233 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY |
234 WIPHY_WOWLAN_GTK_REKEY_FAILURE |
235 WIPHY_WOWLAN_4WAY_HANDSHAKE;
236
237 hw->wiphy->wowlan.n_patterns = IWL_WOWLAN_MAX_PATTERNS;
238 hw->wiphy->wowlan.pattern_min_len = IWL_WOWLAN_MIN_PATTERN_LEN;
239 hw->wiphy->wowlan.pattern_max_len = IWL_WOWLAN_MAX_PATTERN_LEN;
Johannes Bergf0c26462013-01-22 20:41:58 +0100240 hw->wiphy->wowlan.tcp = &iwl_mvm_wowlan_tcp_support;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100241 }
242#endif
243
244 ret = iwl_mvm_leds_init(mvm);
245 if (ret)
246 return ret;
247
248 return ieee80211_register_hw(mvm->hw);
249}
250
251static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
252 struct ieee80211_tx_control *control,
253 struct sk_buff *skb)
254{
255 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
256
Eytan Lifshitz9ee718a2013-05-19 19:14:41 +0300257 if (iwl_mvm_is_radio_killed(mvm)) {
258 IWL_DEBUG_DROP(mvm, "Dropping - RF/CT KILL\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +0100259 goto drop;
260 }
261
Ilan Peer398e8c62013-03-13 15:20:35 +0200262 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
Johannes Berg8ca151b2013-01-24 14:25:36 +0100263 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status))
264 goto drop;
265
266 if (control->sta) {
267 if (iwl_mvm_tx_skb(mvm, skb, control->sta))
268 goto drop;
269 return;
270 }
271
272 if (iwl_mvm_tx_skb_non_sta(mvm, skb))
273 goto drop;
274 return;
275 drop:
276 ieee80211_free_txskb(hw, skb);
277}
278
279static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
280 struct ieee80211_vif *vif,
281 enum ieee80211_ampdu_mlme_action action,
282 struct ieee80211_sta *sta, u16 tid,
283 u16 *ssn, u8 buf_size)
284{
285 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
286 int ret;
287
288 IWL_DEBUG_HT(mvm, "A-MPDU action on addr %pM tid %d: action %d\n",
289 sta->addr, tid, action);
290
291 if (!(mvm->nvm_data->sku_cap_11n_enable))
292 return -EACCES;
293
294 mutex_lock(&mvm->mutex);
295
296 switch (action) {
297 case IEEE80211_AMPDU_RX_START:
298 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) {
299 ret = -EINVAL;
300 break;
301 }
302 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, *ssn, true);
303 break;
304 case IEEE80211_AMPDU_RX_STOP:
305 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false);
306 break;
307 case IEEE80211_AMPDU_TX_START:
Emmanuel Grumbach5d158ef2013-02-19 14:39:58 +0200308 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) {
309 ret = -EINVAL;
310 break;
311 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100312 ret = iwl_mvm_sta_tx_agg_start(mvm, vif, sta, tid, ssn);
313 break;
314 case IEEE80211_AMPDU_TX_STOP_CONT:
Emmanuel Grumbache3d9e7c2013-02-19 16:13:53 +0200315 ret = iwl_mvm_sta_tx_agg_stop(mvm, vif, sta, tid);
316 break;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100317 case IEEE80211_AMPDU_TX_STOP_FLUSH:
318 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
Emmanuel Grumbache3d9e7c2013-02-19 16:13:53 +0200319 ret = iwl_mvm_sta_tx_agg_flush(mvm, vif, sta, tid);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100320 break;
321 case IEEE80211_AMPDU_TX_OPERATIONAL:
322 ret = iwl_mvm_sta_tx_agg_oper(mvm, vif, sta, tid, buf_size);
323 break;
324 default:
325 WARN_ON_ONCE(1);
326 ret = -EINVAL;
327 break;
328 }
329 mutex_unlock(&mvm->mutex);
330
331 return ret;
332}
333
334static void iwl_mvm_cleanup_iterator(void *data, u8 *mac,
335 struct ieee80211_vif *vif)
336{
337 struct iwl_mvm *mvm = data;
338 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
339
340 mvmvif->uploaded = false;
341 mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
342
343 /* does this make sense at all? */
344 mvmvif->color++;
345
346 spin_lock_bh(&mvm->time_event_lock);
347 iwl_mvm_te_clear_data(mvm, &mvmvif->time_event_data);
348 spin_unlock_bh(&mvm->time_event_lock);
349
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200350 mvmvif->phy_ctxt = NULL;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100351}
352
353static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
354{
355 iwl_trans_stop_device(mvm->trans);
356 iwl_trans_stop_hw(mvm->trans, false);
357
358 mvm->scan_status = IWL_MVM_SCAN_NONE;
359
360 /* just in case one was running */
361 ieee80211_remain_on_channel_expired(mvm->hw);
362
363 ieee80211_iterate_active_interfaces_atomic(
364 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
365 iwl_mvm_cleanup_iterator, mvm);
366
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200367 mvm->p2p_device_vif = NULL;
368
369 iwl_mvm_reset_phy_ctxts(mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100370 memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
371 memset(mvm->sta_drained, 0, sizeof(mvm->sta_drained));
372
373 ieee80211_wake_queues(mvm->hw);
374
375 mvm->vif_count = 0;
376}
377
378static int iwl_mvm_mac_start(struct ieee80211_hw *hw)
379{
380 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
381 int ret;
382
383 mutex_lock(&mvm->mutex);
384
385 /* Clean up some internal and mac80211 state on restart */
386 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
387 iwl_mvm_restart_cleanup(mvm);
388
389 ret = iwl_mvm_up(mvm);
390 mutex_unlock(&mvm->mutex);
391
392 return ret;
393}
394
395static void iwl_mvm_mac_restart_complete(struct ieee80211_hw *hw)
396{
397 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
398 int ret;
399
400 mutex_lock(&mvm->mutex);
401
402 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
403 ret = iwl_mvm_update_quotas(mvm, NULL);
404 if (ret)
405 IWL_ERR(mvm, "Failed to update quotas after restart (%d)\n",
406 ret);
407
408 mutex_unlock(&mvm->mutex);
409}
410
411static void iwl_mvm_mac_stop(struct ieee80211_hw *hw)
412{
413 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
414
415 flush_work(&mvm->async_handlers_wk);
416
417 mutex_lock(&mvm->mutex);
418 /* async_handlers_wk is now blocked */
419
420 /*
421 * The work item could be running or queued if the
422 * ROC time event stops just as we get here.
423 */
424 cancel_work_sync(&mvm->roc_done_wk);
425
426 iwl_trans_stop_device(mvm->trans);
427 iwl_trans_stop_hw(mvm->trans, false);
428
429 iwl_mvm_async_handlers_purge(mvm);
430 /* async_handlers_list is empty and will stay empty: HW is stopped */
431
432 /* the fw is stopped, the aux sta is dead: clean up driver state */
433 iwl_mvm_dealloc_int_sta(mvm, &mvm->aux_sta);
434
435 mutex_unlock(&mvm->mutex);
436
437 /*
438 * The worker might have been waiting for the mutex, let it run and
439 * discover that its list is now empty.
440 */
441 cancel_work_sync(&mvm->async_handlers_wk);
442}
443
444static void iwl_mvm_pm_disable_iterator(void *data, u8 *mac,
445 struct ieee80211_vif *vif)
446{
447 struct iwl_mvm *mvm = data;
448 int ret;
449
450 ret = iwl_mvm_power_disable(mvm, vif);
451 if (ret)
452 IWL_ERR(mvm, "failed to disable power management\n");
453}
454
455static void iwl_mvm_power_update_iterator(void *data, u8 *mac,
456 struct ieee80211_vif *vif)
457{
458 struct iwl_mvm *mvm = data;
459
460 iwl_mvm_power_update_mode(mvm, vif);
461}
462
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200463static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
464{
465 u16 i;
466
467 lockdep_assert_held(&mvm->mutex);
468
469 for (i = 0; i < NUM_PHY_CTX; i++)
470 if (!mvm->phy_ctxts[i].ref)
471 return &mvm->phy_ctxts[i];
472
473 IWL_ERR(mvm, "No available PHY context\n");
474 return NULL;
475}
476
Johannes Berg8ca151b2013-01-24 14:25:36 +0100477static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
478 struct ieee80211_vif *vif)
479{
480 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
481 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
482 int ret;
483
484 /*
485 * Not much to do here. The stack will not allow interface
486 * types or combinations that we didn't advertise, so we
487 * don't really have to check the types.
488 */
489
490 mutex_lock(&mvm->mutex);
491
492 /* Allocate resources for the MAC context, and add it the the fw */
493 ret = iwl_mvm_mac_ctxt_init(mvm, vif);
494 if (ret)
495 goto out_unlock;
496
497 /*
498 * The AP binding flow can be done only after the beacon
499 * template is configured (which happens only in the mac80211
500 * start_ap() flow), and adding the broadcast station can happen
501 * only after the binding.
502 * In addition, since modifying the MAC before adding a bcast
503 * station is not allowed by the FW, delay the adding of MAC context to
504 * the point where we can also add the bcast station.
505 * In short: there's not much we can do at this point, other than
506 * allocating resources :)
507 */
508 if (vif->type == NL80211_IFTYPE_AP) {
509 u32 qmask = iwl_mvm_mac_get_queues_mask(mvm, vif);
510 ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->bcast_sta,
511 qmask);
512 if (ret) {
513 IWL_ERR(mvm, "Failed to allocate bcast sta\n");
514 goto out_release;
515 }
516
517 goto out_unlock;
518 }
519
520 /*
521 * TODO: remove this temporary code.
522 * Currently MVM FW supports power management only on single MAC.
Alexander Bondar5ee2b212013-03-05 10:16:40 +0200523 * If new interface added, disable PM on existing interface.
524 * P2P device is a special case, since it is handled by FW similary to
525 * scan. If P2P deviced is added, PM remains enabled on existing
526 * interface.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100527 * Note: the method below does not count the new interface being added
528 * at this moment.
529 */
Alexander Bondar5ee2b212013-03-05 10:16:40 +0200530 if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
531 mvm->vif_count++;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100532 if (mvm->vif_count > 1) {
533 IWL_DEBUG_MAC80211(mvm,
534 "Disable power on existing interfaces\n");
Emmanuel Grumbach5360cfb2013-02-11 15:56:01 +0200535 ieee80211_iterate_active_interfaces_atomic(
Johannes Berg8ca151b2013-01-24 14:25:36 +0100536 mvm->hw,
537 IEEE80211_IFACE_ITER_NORMAL,
538 iwl_mvm_pm_disable_iterator, mvm);
539 }
540
541 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
542 if (ret)
543 goto out_release;
544
545 /*
546 * Update power state on the new interface. Admittedly, based on
547 * mac80211 logics this power update will disable power management
548 */
549 iwl_mvm_power_update_mode(mvm, vif);
550
Hila Gonen7df15b12012-12-12 11:16:19 +0200551 /* beacon filtering */
552 if (!mvm->bf_allowed_vif &&
553 vif->type == NL80211_IFTYPE_STATION && !vif->p2p){
554 mvm->bf_allowed_vif = mvmvif;
555 vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER;
556 }
557
558 ret = iwl_mvm_disable_beacon_filter(mvm, vif);
559 if (ret)
560 goto out_release;
561
Johannes Berg8ca151b2013-01-24 14:25:36 +0100562 /*
563 * P2P_DEVICE interface does not have a channel context assigned to it,
564 * so a dedicated PHY context is allocated to it and the corresponding
565 * MAC context is bound to it at this stage.
566 */
567 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
Johannes Berg8ca151b2013-01-24 14:25:36 +0100568
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200569 mvmvif->phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
570 if (!mvmvif->phy_ctxt) {
571 ret = -ENOSPC;
572 goto out_remove_mac;
573 }
Johannes Berg8ca151b2013-01-24 14:25:36 +0100574
Ilan Peer53a9d612013-04-28 11:55:08 +0300575 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100576 ret = iwl_mvm_binding_add_vif(mvm, vif);
577 if (ret)
Ilan Peer53a9d612013-04-28 11:55:08 +0300578 goto out_unref_phy;
Johannes Berg8ca151b2013-01-24 14:25:36 +0100579
580 ret = iwl_mvm_add_bcast_sta(mvm, vif, &mvmvif->bcast_sta);
581 if (ret)
582 goto out_unbind;
583
584 /* Save a pointer to p2p device vif, so it can later be used to
585 * update the p2p device MAC when a GO is started/stopped */
586 mvm->p2p_device_vif = vif;
587 }
588
Johannes Berg63494372013-03-26 10:47:53 +0100589 iwl_mvm_vif_dbgfs_register(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100590 goto out_unlock;
591
592 out_unbind:
593 iwl_mvm_binding_remove_vif(mvm, vif);
Ilan Peer53a9d612013-04-28 11:55:08 +0300594 out_unref_phy:
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200595 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100596 out_remove_mac:
597 mvmvif->phy_ctxt = NULL;
598 iwl_mvm_mac_ctxt_remove(mvm, vif);
599 out_release:
Alexander Bondar5ee2b212013-03-05 10:16:40 +0200600 if (vif->type != NL80211_IFTYPE_P2P_DEVICE)
601 mvm->vif_count--;
Alexander Bondar4bf881f2013-05-29 10:19:50 +0300602 ieee80211_iterate_active_interfaces(
603 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
604 iwl_mvm_power_update_iterator, mvm);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100605 iwl_mvm_mac_ctxt_release(mvm, vif);
606 out_unlock:
607 mutex_unlock(&mvm->mutex);
608
609 return ret;
610}
611
Johannes Berg38a12b52013-02-22 14:07:56 +0100612static void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
613 struct ieee80211_vif *vif)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100614{
Johannes Berg8ca151b2013-01-24 14:25:36 +0100615 u32 tfd_msk = 0, ac;
616
617 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
618 if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
619 tfd_msk |= BIT(vif->hw_queue[ac]);
620
621 if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE)
622 tfd_msk |= BIT(vif->cab_queue);
623
624 if (tfd_msk) {
625 mutex_lock(&mvm->mutex);
626 iwl_mvm_flush_tx_path(mvm, tfd_msk, true);
627 mutex_unlock(&mvm->mutex);
628 }
629
630 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
631 /*
632 * Flush the ROC worker which will flush the OFFCHANNEL queue.
633 * We assume here that all the packets sent to the OFFCHANNEL
634 * queue are sent in ROC session.
635 */
636 flush_work(&mvm->roc_done_wk);
637 } else {
638 /*
639 * By now, all the AC queues are empty. The AGG queues are
640 * empty too. We already got all the Tx responses for all the
641 * packets in the queues. The drain work can have been
642 * triggered. Flush it. This work item takes the mutex, so kill
643 * it before we take it.
644 */
645 flush_work(&mvm->sta_drained_wk);
646 }
Johannes Berg38a12b52013-02-22 14:07:56 +0100647}
648
649static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
650 struct ieee80211_vif *vif)
651{
652 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
653 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
654
655 iwl_mvm_prepare_mac_removal(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100656
657 mutex_lock(&mvm->mutex);
658
Hila Gonen7df15b12012-12-12 11:16:19 +0200659 if (mvm->bf_allowed_vif == mvmvif) {
660 mvm->bf_allowed_vif = NULL;
661 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
662 }
663
Johannes Berg63494372013-03-26 10:47:53 +0100664 iwl_mvm_vif_dbgfs_clean(mvm, vif);
665
Johannes Berg8ca151b2013-01-24 14:25:36 +0100666 /*
667 * For AP/GO interface, the tear down of the resources allocated to the
Johannes Berg38a12b52013-02-22 14:07:56 +0100668 * interface is be handled as part of the stop_ap flow.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100669 */
670 if (vif->type == NL80211_IFTYPE_AP) {
671 iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta);
672 goto out_release;
673 }
674
675 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
676 mvm->p2p_device_vif = NULL;
677 iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
678 iwl_mvm_binding_remove_vif(mvm, vif);
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200679 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100680 mvmvif->phy_ctxt = NULL;
681 }
682
683 /*
684 * TODO: remove this temporary code.
685 * Currently MVM FW supports power management only on single MAC.
686 * Check if only one additional interface remains after removing
687 * current one. Update power mode on the remaining interface.
688 */
Alexander Bondar5ee2b212013-03-05 10:16:40 +0200689 if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100690 mvm->vif_count--;
691 IWL_DEBUG_MAC80211(mvm, "Currently %d interfaces active\n",
692 mvm->vif_count);
693 if (mvm->vif_count == 1) {
694 ieee80211_iterate_active_interfaces(
695 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
696 iwl_mvm_power_update_iterator, mvm);
697 }
698
699 iwl_mvm_mac_ctxt_remove(mvm, vif);
700
701out_release:
702 iwl_mvm_mac_ctxt_release(mvm, vif);
703 mutex_unlock(&mvm->mutex);
704}
705
706static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed)
707{
708 return 0;
709}
710
711static void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
712 unsigned int changed_flags,
713 unsigned int *total_flags,
714 u64 multicast)
715{
716 *total_flags = 0;
717}
718
Emmanuel Grumbach51b6b9e2013-05-02 15:01:24 +0300719static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm,
720 struct ieee80211_vif *vif)
721{
722 struct iwl_mcast_filter_cmd mcast_filter_cmd = {
723 .pass_all = 1,
724 };
725
726 memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN);
727
728 return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC,
729 sizeof(mcast_filter_cmd),
730 &mcast_filter_cmd);
731}
732
Johannes Berg8ca151b2013-01-24 14:25:36 +0100733static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
734 struct ieee80211_vif *vif,
735 struct ieee80211_bss_conf *bss_conf,
736 u32 changes)
737{
738 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
739 int ret;
740
741 ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
742 if (ret)
743 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
744
745 if (changes & BSS_CHANGED_ASSOC) {
746 if (bss_conf->assoc) {
747 /* add quota for this interface */
748 ret = iwl_mvm_update_quotas(mvm, vif);
749 if (ret) {
750 IWL_ERR(mvm, "failed to update quotas\n");
751 return;
752 }
Emmanuel Grumbach9166b1e2013-03-20 15:28:27 +0200753 iwl_mvm_bt_coex_vif_assoc(mvm, vif);
Emmanuel Grumbach51b6b9e2013-05-02 15:01:24 +0300754 iwl_mvm_configure_mcast_filter(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100755 } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
756 /* remove AP station now that the MAC is unassoc */
757 ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id);
758 if (ret)
759 IWL_ERR(mvm, "failed to remove AP station\n");
760 mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
761 /* remove quota for this interface */
762 ret = iwl_mvm_update_quotas(mvm, NULL);
763 if (ret)
764 IWL_ERR(mvm, "failed to update quotas\n");
765 }
Alexander Bondar5ec42ec2013-05-27 13:49:03 +0300766 ret = iwl_mvm_power_update_mode(mvm, vif);
767 if (ret)
768 IWL_ERR(mvm, "failed to update power mode\n");
Johannes Berg210a5442013-01-24 23:48:23 +0100769 } else if (changes & BSS_CHANGED_DTIM_PERIOD) {
770 /*
771 * We received a beacon _after_ association so
772 * remove the session protection.
773 */
774 iwl_mvm_remove_time_event(mvm, mvmvif,
775 &mvmvif->time_event_data);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100776 } else if (changes & BSS_CHANGED_PS) {
Alexander Bondar4bf881f2013-05-29 10:19:50 +0300777 ret = iwl_mvm_power_update_mode(mvm, vif);
778 if (ret)
779 IWL_ERR(mvm, "failed to update power mode\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +0100780 }
781}
782
783static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
784{
785 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
786 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
787 int ret;
788
789 mutex_lock(&mvm->mutex);
790
791 /* Send the beacon template */
792 ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif);
793 if (ret)
794 goto out_unlock;
795
796 /* Add the mac context */
797 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
798 if (ret)
799 goto out_unlock;
800
801 /* Perform the binding */
802 ret = iwl_mvm_binding_add_vif(mvm, vif);
803 if (ret)
804 goto out_remove;
805
806 mvmvif->ap_active = true;
807
808 /* Send the bcast station. At this stage the TBTT and DTIM time events
809 * are added and applied to the scheduler */
810 ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta);
811 if (ret)
812 goto out_unbind;
813
814 ret = iwl_mvm_update_quotas(mvm, vif);
815 if (ret)
816 goto out_rm_bcast;
817
818 /* Need to update the P2P Device MAC */
819 if (vif->p2p && mvm->p2p_device_vif)
820 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif);
821
822 mutex_unlock(&mvm->mutex);
823 return 0;
824
825out_rm_bcast:
826 iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
827out_unbind:
828 iwl_mvm_binding_remove_vif(mvm, vif);
829out_remove:
830 iwl_mvm_mac_ctxt_remove(mvm, vif);
831out_unlock:
832 mutex_unlock(&mvm->mutex);
833 return ret;
834}
835
836static void iwl_mvm_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
837{
838 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
839 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
840
Johannes Berg38a12b52013-02-22 14:07:56 +0100841 iwl_mvm_prepare_mac_removal(mvm, vif);
842
Johannes Berg8ca151b2013-01-24 14:25:36 +0100843 mutex_lock(&mvm->mutex);
844
845 mvmvif->ap_active = false;
846
847 /* Need to update the P2P Device MAC */
848 if (vif->p2p && mvm->p2p_device_vif)
849 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif);
850
851 iwl_mvm_update_quotas(mvm, NULL);
852 iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
853 iwl_mvm_binding_remove_vif(mvm, vif);
854 iwl_mvm_mac_ctxt_remove(mvm, vif);
855
856 mutex_unlock(&mvm->mutex);
857}
858
859static void iwl_mvm_bss_info_changed_ap(struct iwl_mvm *mvm,
860 struct ieee80211_vif *vif,
861 struct ieee80211_bss_conf *bss_conf,
862 u32 changes)
863{
864 /* Need to send a new beacon template to the FW */
865 if (changes & BSS_CHANGED_BEACON) {
866 if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif))
867 IWL_WARN(mvm, "Failed updating beacon data\n");
868 }
869}
870
871static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
872 struct ieee80211_vif *vif,
873 struct ieee80211_bss_conf *bss_conf,
874 u32 changes)
875{
876 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
877
878 mutex_lock(&mvm->mutex);
879
880 switch (vif->type) {
881 case NL80211_IFTYPE_STATION:
882 iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes);
883 break;
884 case NL80211_IFTYPE_AP:
885 iwl_mvm_bss_info_changed_ap(mvm, vif, bss_conf, changes);
886 break;
887 default:
888 /* shouldn't happen */
889 WARN_ON_ONCE(1);
890 }
891
892 mutex_unlock(&mvm->mutex);
893}
894
895static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
896 struct ieee80211_vif *vif,
897 struct cfg80211_scan_request *req)
898{
899 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
900 int ret;
901
902 if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS)
903 return -EINVAL;
904
905 mutex_lock(&mvm->mutex);
906
907 if (mvm->scan_status == IWL_MVM_SCAN_NONE)
908 ret = iwl_mvm_scan_request(mvm, vif, req);
909 else
910 ret = -EBUSY;
911
912 mutex_unlock(&mvm->mutex);
913
914 return ret;
915}
916
917static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
918 struct ieee80211_vif *vif)
919{
920 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
921
922 mutex_lock(&mvm->mutex);
923
924 iwl_mvm_cancel_scan(mvm);
925
926 mutex_unlock(&mvm->mutex);
927}
928
929static void
930iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
931 struct ieee80211_sta *sta, u16 tid,
932 int num_frames,
933 enum ieee80211_frame_release_type reason,
934 bool more_data)
935{
936 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100937
938 /* TODO: how do we tell the fw to send frames for a specific TID */
939
940 /*
941 * The fw will send EOSP notification when the last frame will be
942 * transmitted.
943 */
Johannes Berg9cc40712013-02-15 22:47:48 +0100944 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100945}
946
947static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw,
948 struct ieee80211_vif *vif,
949 enum sta_notify_cmd cmd,
950 struct ieee80211_sta *sta)
951{
952 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
953 struct iwl_mvm_sta *mvmsta = (void *)sta->drv_priv;
954
955 switch (cmd) {
956 case STA_NOTIFY_SLEEP:
Emmanuel Grumbache3d4bc82013-05-07 14:08:24 +0300957 if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100958 ieee80211_sta_block_awake(hw, sta, true);
959 /*
960 * The fw updates the STA to be asleep. Tx packets on the Tx
961 * queues to this station will not be transmitted. The fw will
962 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
963 */
964 break;
965 case STA_NOTIFY_AWAKE:
Emmanuel Grumbach881acd82013-03-19 16:16:00 +0200966 if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100967 break;
Johannes Berg9cc40712013-02-15 22:47:48 +0100968 iwl_mvm_sta_modify_ps_wake(mvm, sta);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100969 break;
970 default:
971 break;
972 }
973}
974
975static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
976 struct ieee80211_vif *vif,
977 struct ieee80211_sta *sta,
978 enum ieee80211_sta_state old_state,
979 enum ieee80211_sta_state new_state)
980{
981 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
982 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
983 int ret;
984
985 IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n",
986 sta->addr, old_state, new_state);
987
988 /* this would be a mac80211 bug ... but don't crash */
989 if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
990 return -EINVAL;
991
992 /* if a STA is being removed, reuse its ID */
993 flush_work(&mvm->sta_drained_wk);
994
995 mutex_lock(&mvm->mutex);
996 if (old_state == IEEE80211_STA_NOTEXIST &&
997 new_state == IEEE80211_STA_NONE) {
998 ret = iwl_mvm_add_sta(mvm, vif, sta);
999 } else if (old_state == IEEE80211_STA_NONE &&
1000 new_state == IEEE80211_STA_AUTH) {
1001 ret = 0;
1002 } else if (old_state == IEEE80211_STA_AUTH &&
1003 new_state == IEEE80211_STA_ASSOC) {
Johannes Berg7a453972013-02-12 13:10:44 +01001004 ret = iwl_mvm_update_sta(mvm, vif, sta);
1005 if (ret == 0)
1006 iwl_mvm_rs_rate_init(mvm, sta,
1007 mvmvif->phy_ctxt->channel->band);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001008 } else if (old_state == IEEE80211_STA_ASSOC &&
1009 new_state == IEEE80211_STA_AUTHORIZED) {
Hila Gonen7df15b12012-12-12 11:16:19 +02001010 /* enable beacon filtering */
1011 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif));
Johannes Berg8ca151b2013-01-24 14:25:36 +01001012 ret = 0;
1013 } else if (old_state == IEEE80211_STA_AUTHORIZED &&
1014 new_state == IEEE80211_STA_ASSOC) {
Hila Gonen7df15b12012-12-12 11:16:19 +02001015 /* disable beacon filtering */
1016 WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif));
Johannes Berg8ca151b2013-01-24 14:25:36 +01001017 ret = 0;
1018 } else if (old_state == IEEE80211_STA_ASSOC &&
1019 new_state == IEEE80211_STA_AUTH) {
1020 ret = 0;
1021 } else if (old_state == IEEE80211_STA_AUTH &&
1022 new_state == IEEE80211_STA_NONE) {
1023 ret = 0;
1024 } else if (old_state == IEEE80211_STA_NONE &&
1025 new_state == IEEE80211_STA_NOTEXIST) {
1026 ret = iwl_mvm_rm_sta(mvm, vif, sta);
1027 } else {
1028 ret = -EIO;
1029 }
1030 mutex_unlock(&mvm->mutex);
1031
1032 return ret;
1033}
1034
1035static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
1036{
1037 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1038
1039 mvm->rts_threshold = value;
1040
1041 return 0;
1042}
1043
1044static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw,
1045 struct ieee80211_vif *vif, u16 ac,
1046 const struct ieee80211_tx_queue_params *params)
1047{
1048 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1049 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1050
1051 mvmvif->queue_params[ac] = *params;
1052
1053 /*
1054 * No need to update right away, we'll get BSS_CHANGED_QOS
1055 * The exception is P2P_DEVICE interface which needs immediate update.
1056 */
1057 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1058 int ret;
1059
1060 mutex_lock(&mvm->mutex);
1061 ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
1062 mutex_unlock(&mvm->mutex);
1063 return ret;
1064 }
1065 return 0;
1066}
1067
1068static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
1069 struct ieee80211_vif *vif)
1070{
1071 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1072 u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS,
1073 200 + vif->bss_conf.beacon_int);
1074 u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS,
1075 100 + vif->bss_conf.beacon_int);
1076
1077 if (WARN_ON_ONCE(vif->bss_conf.assoc))
1078 return;
1079
1080 mutex_lock(&mvm->mutex);
1081 /* Try really hard to protect the session and hear a beacon */
1082 iwl_mvm_protect_session(mvm, vif, duration, min_duration);
1083 mutex_unlock(&mvm->mutex);
1084}
1085
1086static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
1087 enum set_key_cmd cmd,
1088 struct ieee80211_vif *vif,
1089 struct ieee80211_sta *sta,
1090 struct ieee80211_key_conf *key)
1091{
1092 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1093 int ret;
1094
1095 if (iwlwifi_mod_params.sw_crypto) {
1096 IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n");
1097 return -EOPNOTSUPP;
1098 }
1099
1100 switch (key->cipher) {
1101 case WLAN_CIPHER_SUITE_TKIP:
1102 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1103 /* fall-through */
1104 case WLAN_CIPHER_SUITE_CCMP:
1105 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1106 break;
1107 case WLAN_CIPHER_SUITE_AES_CMAC:
1108 WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE));
1109 break;
1110 case WLAN_CIPHER_SUITE_WEP40:
1111 case WLAN_CIPHER_SUITE_WEP104:
1112 /*
1113 * Support for TX only, at least for now, so accept
1114 * the key and do nothing else. Then mac80211 will
1115 * pass it for TX but we don't have to use it for RX.
1116 */
1117 return 0;
1118 default:
1119 return -EOPNOTSUPP;
1120 }
1121
1122 mutex_lock(&mvm->mutex);
1123
1124 switch (cmd) {
1125 case SET_KEY:
Johannes Berg6caffd42013-03-06 13:15:21 +01001126 if (vif->type == NL80211_IFTYPE_AP && !sta) {
1127 /* GTK on AP interface is a TX-only key, return 0 */
1128 ret = 0;
1129 key->hw_key_idx = STA_KEY_IDX_INVALID;
1130 break;
1131 }
1132
Johannes Berg8ca151b2013-01-24 14:25:36 +01001133 IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");
1134 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false);
1135 if (ret) {
1136 IWL_WARN(mvm, "set key failed\n");
1137 /*
1138 * can't add key for RX, but we don't need it
1139 * in the device for TX so still return 0
1140 */
Johannes Berg6caffd42013-03-06 13:15:21 +01001141 key->hw_key_idx = STA_KEY_IDX_INVALID;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001142 ret = 0;
1143 }
1144
1145 break;
1146 case DISABLE_KEY:
Johannes Berg6caffd42013-03-06 13:15:21 +01001147 if (key->hw_key_idx == STA_KEY_IDX_INVALID) {
1148 ret = 0;
1149 break;
1150 }
1151
Johannes Berg8ca151b2013-01-24 14:25:36 +01001152 IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n");
1153 ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key);
1154 break;
1155 default:
1156 ret = -EINVAL;
1157 }
1158
1159 mutex_unlock(&mvm->mutex);
1160 return ret;
1161}
1162
1163static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw,
1164 struct ieee80211_vif *vif,
1165 struct ieee80211_key_conf *keyconf,
1166 struct ieee80211_sta *sta,
1167 u32 iv32, u16 *phase1key)
1168{
1169 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1170
1171 iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key);
1172}
1173
1174
1175static int iwl_mvm_roc(struct ieee80211_hw *hw,
1176 struct ieee80211_vif *vif,
1177 struct ieee80211_channel *channel,
Ilan Peerd339d5c2013-02-12 09:34:13 +02001178 int duration,
1179 enum ieee80211_roc_type type)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001180{
1181 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001182 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001183 struct cfg80211_chan_def chandef;
Ilan Peer31d385a2013-04-02 10:25:46 +03001184 struct iwl_mvm_phy_ctxt *phy_ctxt;
1185 int ret, i;
1186
1187 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
1188 duration, type);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001189
1190 if (vif->type != NL80211_IFTYPE_P2P_DEVICE) {
1191 IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type);
1192 return -EINVAL;
1193 }
1194
Johannes Berg8ca151b2013-01-24 14:25:36 +01001195 mutex_lock(&mvm->mutex);
1196
Ilan Peer31d385a2013-04-02 10:25:46 +03001197 for (i = 0; i < NUM_PHY_CTX; i++) {
1198 phy_ctxt = &mvm->phy_ctxts[i];
1199 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt)
1200 continue;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001201
Ilan Peer31d385a2013-04-02 10:25:46 +03001202 if (phy_ctxt->ref && channel == phy_ctxt->channel) {
1203 /*
1204 * Unbind the P2P_DEVICE from the current PHY context,
1205 * and if the PHY context is not used remove it.
1206 */
1207 ret = iwl_mvm_binding_remove_vif(mvm, vif);
1208 if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
1209 goto out_unlock;
1210
1211 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1212
1213 /* Bind the P2P_DEVICE to the current PHY Context */
1214 mvmvif->phy_ctxt = phy_ctxt;
1215
1216 ret = iwl_mvm_binding_add_vif(mvm, vif);
1217 if (WARN(ret, "Failed binding P2P_DEVICE\n"))
1218 goto out_unlock;
1219
1220 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
1221 goto schedule_time_event;
1222 }
1223 }
1224
1225 /* Need to update the PHY context only if the ROC channel changed */
1226 if (channel == mvmvif->phy_ctxt->channel)
1227 goto schedule_time_event;
1228
1229 cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT);
1230
1231 /*
1232 * Change the PHY context configuration as it is currently referenced
1233 * only by the P2P Device MAC
1234 */
1235 if (mvmvif->phy_ctxt->ref == 1) {
1236 ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt,
1237 &chandef, 1, 1);
1238 if (ret)
1239 goto out_unlock;
1240 } else {
1241 /*
1242 * The PHY context is shared with other MACs. Need to remove the
1243 * P2P Device from the binding, allocate an new PHY context and
1244 * create a new binding
1245 */
1246 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
1247 if (!phy_ctxt) {
1248 ret = -ENOSPC;
1249 goto out_unlock;
1250 }
1251
1252 ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef,
1253 1, 1);
1254 if (ret) {
1255 IWL_ERR(mvm, "Failed to change PHY context\n");
1256 goto out_unlock;
1257 }
1258
1259 /* Unbind the P2P_DEVICE from the current PHY context */
1260 ret = iwl_mvm_binding_remove_vif(mvm, vif);
1261 if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
1262 goto out_unlock;
1263
1264 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1265
1266 /* Bind the P2P_DEVICE to the new allocated PHY context */
1267 mvmvif->phy_ctxt = phy_ctxt;
1268
1269 ret = iwl_mvm_binding_add_vif(mvm, vif);
1270 if (WARN(ret, "Failed binding P2P_DEVICE\n"))
1271 goto out_unlock;
1272
1273 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
1274 }
1275
1276schedule_time_event:
Johannes Berg8ca151b2013-01-24 14:25:36 +01001277 /* Schedule the time events */
Ilan Peere635c792013-02-13 11:05:18 +02001278 ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001279
Ilan Peer31d385a2013-04-02 10:25:46 +03001280out_unlock:
Johannes Berg8ca151b2013-01-24 14:25:36 +01001281 mutex_unlock(&mvm->mutex);
1282 IWL_DEBUG_MAC80211(mvm, "leave\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +01001283 return ret;
1284}
1285
1286static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw)
1287{
1288 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1289
1290 IWL_DEBUG_MAC80211(mvm, "enter\n");
1291
1292 mutex_lock(&mvm->mutex);
1293 iwl_mvm_stop_p2p_roc(mvm);
1294 mutex_unlock(&mvm->mutex);
1295
1296 IWL_DEBUG_MAC80211(mvm, "leave\n");
1297 return 0;
1298}
1299
1300static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw,
1301 struct ieee80211_chanctx_conf *ctx)
1302{
1303 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001304 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1305 struct iwl_mvm_phy_ctxt *phy_ctxt;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001306 int ret;
1307
Ilan Peer53a9d612013-04-28 11:55:08 +03001308 IWL_DEBUG_MAC80211(mvm, "Add channel context\n");
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001309
1310 mutex_lock(&mvm->mutex);
1311 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
1312 if (!phy_ctxt) {
1313 ret = -ENOSPC;
1314 goto out;
1315 }
1316
Ilan Peer53a9d612013-04-28 11:55:08 +03001317 ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def,
1318 ctx->rx_chains_static,
1319 ctx->rx_chains_dynamic);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001320 if (ret) {
1321 IWL_ERR(mvm, "Failed to add PHY context\n");
1322 goto out;
1323 }
1324
Ilan Peer53a9d612013-04-28 11:55:08 +03001325 iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001326 *phy_ctxt_id = phy_ctxt->id;
1327out:
Johannes Berg8ca151b2013-01-24 14:25:36 +01001328 mutex_unlock(&mvm->mutex);
1329 return ret;
1330}
1331
1332static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
1333 struct ieee80211_chanctx_conf *ctx)
1334{
1335 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001336 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1337 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
Johannes Berg8ca151b2013-01-24 14:25:36 +01001338
1339 mutex_lock(&mvm->mutex);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001340 iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001341 mutex_unlock(&mvm->mutex);
1342}
1343
1344static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
1345 struct ieee80211_chanctx_conf *ctx,
1346 u32 changed)
1347{
1348 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001349 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1350 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
Johannes Berg8ca151b2013-01-24 14:25:36 +01001351
Ilan Peer31d385a2013-04-02 10:25:46 +03001352 if (WARN_ONCE((phy_ctxt->ref > 1) &&
1353 (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH |
1354 IEEE80211_CHANCTX_CHANGE_RX_CHAINS |
1355 IEEE80211_CHANCTX_CHANGE_RADAR)),
1356 "Cannot change PHY. Ref=%d, changed=0x%X\n",
1357 phy_ctxt->ref, changed))
1358 return;
1359
Johannes Berg8ca151b2013-01-24 14:25:36 +01001360 mutex_lock(&mvm->mutex);
1361 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def,
1362 ctx->rx_chains_static,
1363 ctx->rx_chains_dynamic);
1364 mutex_unlock(&mvm->mutex);
1365}
1366
1367static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
1368 struct ieee80211_vif *vif,
1369 struct ieee80211_chanctx_conf *ctx)
1370{
1371 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001372 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1373 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
Johannes Berg8ca151b2013-01-24 14:25:36 +01001374 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1375 int ret;
1376
1377 mutex_lock(&mvm->mutex);
1378
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001379 mvmvif->phy_ctxt = phy_ctxt;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001380
1381 switch (vif->type) {
1382 case NL80211_IFTYPE_AP:
1383 /*
1384 * The AP binding flow is handled as part of the start_ap flow
1385 * (in bss_info_changed).
1386 */
1387 ret = 0;
1388 goto out_unlock;
1389 case NL80211_IFTYPE_STATION:
1390 case NL80211_IFTYPE_ADHOC:
1391 case NL80211_IFTYPE_MONITOR:
1392 break;
1393 default:
1394 ret = -EINVAL;
1395 goto out_unlock;
1396 }
1397
1398 ret = iwl_mvm_binding_add_vif(mvm, vif);
1399 if (ret)
1400 goto out_unlock;
1401
1402 /*
1403 * Setting the quota at this stage is only required for monitor
1404 * interfaces. For the other types, the bss_info changed flow
1405 * will handle quota settings.
1406 */
1407 if (vif->type == NL80211_IFTYPE_MONITOR) {
Ilan Peer1e1391c2013-03-13 14:52:04 +02001408 mvmvif->monitor_active = true;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001409 ret = iwl_mvm_update_quotas(mvm, vif);
1410 if (ret)
1411 goto out_remove_binding;
1412 }
1413
1414 goto out_unlock;
1415
1416 out_remove_binding:
1417 iwl_mvm_binding_remove_vif(mvm, vif);
1418 out_unlock:
1419 mutex_unlock(&mvm->mutex);
1420 if (ret)
1421 mvmvif->phy_ctxt = NULL;
1422 return ret;
1423}
1424
1425static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw,
1426 struct ieee80211_vif *vif,
1427 struct ieee80211_chanctx_conf *ctx)
1428{
1429 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1430 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1431
1432 mutex_lock(&mvm->mutex);
1433
1434 iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data);
1435
1436 if (vif->type == NL80211_IFTYPE_AP)
1437 goto out_unlock;
1438
Johannes Berg8ca151b2013-01-24 14:25:36 +01001439 switch (vif->type) {
1440 case NL80211_IFTYPE_MONITOR:
Ilan Peer1e1391c2013-03-13 14:52:04 +02001441 mvmvif->monitor_active = false;
1442 iwl_mvm_update_quotas(mvm, NULL);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001443 break;
1444 default:
1445 break;
1446 }
1447
Ilan Peer1e1391c2013-03-13 14:52:04 +02001448 iwl_mvm_binding_remove_vif(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001449out_unlock:
1450 mvmvif->phy_ctxt = NULL;
1451 mutex_unlock(&mvm->mutex);
1452}
1453
1454static int iwl_mvm_set_tim(struct ieee80211_hw *hw,
1455 struct ieee80211_sta *sta,
1456 bool set)
1457{
1458 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1459 struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv;
1460
1461 if (!mvm_sta || !mvm_sta->vif) {
1462 IWL_ERR(mvm, "Station is not associated to a vif\n");
1463 return -EINVAL;
1464 }
1465
1466 return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif);
1467}
1468
Emmanuel Grumbach2b76ef12013-01-24 10:35:13 +02001469static void iwl_mvm_mac_rssi_callback(struct ieee80211_hw *hw,
1470 struct ieee80211_vif *vif,
1471 enum ieee80211_rssi_event rssi_event)
1472{
1473 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1474
1475 iwl_mvm_bt_rssi_event(mvm, vif, rssi_event);
1476}
1477
Johannes Berg8ca151b2013-01-24 14:25:36 +01001478struct ieee80211_ops iwl_mvm_hw_ops = {
1479 .tx = iwl_mvm_mac_tx,
1480 .ampdu_action = iwl_mvm_mac_ampdu_action,
1481 .start = iwl_mvm_mac_start,
1482 .restart_complete = iwl_mvm_mac_restart_complete,
1483 .stop = iwl_mvm_mac_stop,
1484 .add_interface = iwl_mvm_mac_add_interface,
1485 .remove_interface = iwl_mvm_mac_remove_interface,
1486 .config = iwl_mvm_mac_config,
1487 .configure_filter = iwl_mvm_configure_filter,
1488 .bss_info_changed = iwl_mvm_bss_info_changed,
1489 .hw_scan = iwl_mvm_mac_hw_scan,
1490 .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
1491 .sta_state = iwl_mvm_mac_sta_state,
1492 .sta_notify = iwl_mvm_mac_sta_notify,
1493 .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames,
1494 .set_rts_threshold = iwl_mvm_mac_set_rts_threshold,
1495 .conf_tx = iwl_mvm_mac_conf_tx,
1496 .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx,
1497 .set_key = iwl_mvm_mac_set_key,
1498 .update_tkip_key = iwl_mvm_mac_update_tkip_key,
1499 .remain_on_channel = iwl_mvm_roc,
1500 .cancel_remain_on_channel = iwl_mvm_cancel_roc,
Emmanuel Grumbach2b76ef12013-01-24 10:35:13 +02001501 .rssi_callback = iwl_mvm_mac_rssi_callback,
Johannes Berg8ca151b2013-01-24 14:25:36 +01001502
1503 .add_chanctx = iwl_mvm_add_chanctx,
1504 .remove_chanctx = iwl_mvm_remove_chanctx,
1505 .change_chanctx = iwl_mvm_change_chanctx,
1506 .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx,
1507 .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx,
1508
1509 .start_ap = iwl_mvm_start_ap,
1510 .stop_ap = iwl_mvm_stop_ap,
1511
1512 .set_tim = iwl_mvm_set_tim,
1513
1514#ifdef CONFIG_PM_SLEEP
1515 /* look at d3.c */
1516 .suspend = iwl_mvm_suspend,
1517 .resume = iwl_mvm_resume,
1518 .set_wakeup = iwl_mvm_set_wakeup,
1519 .set_rekey_data = iwl_mvm_set_rekey_data,
1520#if IS_ENABLED(CONFIG_IPV6)
1521 .ipv6_addr_change = iwl_mvm_ipv6_addr_change,
1522#endif
1523 .set_default_unicast_key = iwl_mvm_set_default_unicast_key,
1524#endif
1525};