blob: 795f65cf63328b91a4abf10b9e953b8bb70d3e72 [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
Emmanuel Grumbach0742a752013-06-10 14:10:33 +0300642 * triggered. Flush it.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100643 */
644 flush_work(&mvm->sta_drained_wk);
645 }
Johannes Berg38a12b52013-02-22 14:07:56 +0100646}
647
648static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
649 struct ieee80211_vif *vif)
650{
651 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
652 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
653
654 iwl_mvm_prepare_mac_removal(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100655
656 mutex_lock(&mvm->mutex);
657
Hila Gonen7df15b12012-12-12 11:16:19 +0200658 if (mvm->bf_allowed_vif == mvmvif) {
659 mvm->bf_allowed_vif = NULL;
660 vif->driver_flags &= ~IEEE80211_VIF_BEACON_FILTER;
661 }
662
Johannes Berg63494372013-03-26 10:47:53 +0100663 iwl_mvm_vif_dbgfs_clean(mvm, vif);
664
Johannes Berg8ca151b2013-01-24 14:25:36 +0100665 /*
666 * For AP/GO interface, the tear down of the resources allocated to the
Johannes Berg38a12b52013-02-22 14:07:56 +0100667 * interface is be handled as part of the stop_ap flow.
Johannes Berg8ca151b2013-01-24 14:25:36 +0100668 */
669 if (vif->type == NL80211_IFTYPE_AP) {
670 iwl_mvm_dealloc_int_sta(mvm, &mvmvif->bcast_sta);
671 goto out_release;
672 }
673
674 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
675 mvm->p2p_device_vif = NULL;
676 iwl_mvm_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
677 iwl_mvm_binding_remove_vif(mvm, vif);
Ilan Peerfe0f2de2013-03-21 10:23:52 +0200678 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100679 mvmvif->phy_ctxt = NULL;
680 }
681
682 /*
683 * TODO: remove this temporary code.
684 * Currently MVM FW supports power management only on single MAC.
685 * Check if only one additional interface remains after removing
686 * current one. Update power mode on the remaining interface.
687 */
Alexander Bondar5ee2b212013-03-05 10:16:40 +0200688 if (mvm->vif_count && vif->type != NL80211_IFTYPE_P2P_DEVICE)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100689 mvm->vif_count--;
690 IWL_DEBUG_MAC80211(mvm, "Currently %d interfaces active\n",
691 mvm->vif_count);
692 if (mvm->vif_count == 1) {
693 ieee80211_iterate_active_interfaces(
694 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
695 iwl_mvm_power_update_iterator, mvm);
696 }
697
698 iwl_mvm_mac_ctxt_remove(mvm, vif);
699
700out_release:
701 iwl_mvm_mac_ctxt_release(mvm, vif);
702 mutex_unlock(&mvm->mutex);
703}
704
705static int iwl_mvm_mac_config(struct ieee80211_hw *hw, u32 changed)
706{
707 return 0;
708}
709
710static void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
711 unsigned int changed_flags,
712 unsigned int *total_flags,
713 u64 multicast)
714{
715 *total_flags = 0;
716}
717
Emmanuel Grumbach51b6b9e2013-05-02 15:01:24 +0300718static int iwl_mvm_configure_mcast_filter(struct iwl_mvm *mvm,
719 struct ieee80211_vif *vif)
720{
721 struct iwl_mcast_filter_cmd mcast_filter_cmd = {
722 .pass_all = 1,
723 };
724
725 memcpy(mcast_filter_cmd.bssid, vif->bss_conf.bssid, ETH_ALEN);
726
727 return iwl_mvm_send_cmd_pdu(mvm, MCAST_FILTER_CMD, CMD_SYNC,
728 sizeof(mcast_filter_cmd),
729 &mcast_filter_cmd);
730}
731
Johannes Berg8ca151b2013-01-24 14:25:36 +0100732static void iwl_mvm_bss_info_changed_station(struct iwl_mvm *mvm,
733 struct ieee80211_vif *vif,
734 struct ieee80211_bss_conf *bss_conf,
735 u32 changes)
736{
737 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
738 int ret;
739
740 ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
741 if (ret)
742 IWL_ERR(mvm, "failed to update MAC %pM\n", vif->addr);
743
744 if (changes & BSS_CHANGED_ASSOC) {
745 if (bss_conf->assoc) {
746 /* add quota for this interface */
747 ret = iwl_mvm_update_quotas(mvm, vif);
748 if (ret) {
749 IWL_ERR(mvm, "failed to update quotas\n");
750 return;
751 }
Emmanuel Grumbach9166b1e2013-03-20 15:28:27 +0200752 iwl_mvm_bt_coex_vif_assoc(mvm, vif);
Emmanuel Grumbach51b6b9e2013-05-02 15:01:24 +0300753 iwl_mvm_configure_mcast_filter(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100754 } else if (mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
755 /* remove AP station now that the MAC is unassoc */
756 ret = iwl_mvm_rm_sta_id(mvm, vif, mvmvif->ap_sta_id);
757 if (ret)
758 IWL_ERR(mvm, "failed to remove AP station\n");
759 mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
760 /* remove quota for this interface */
761 ret = iwl_mvm_update_quotas(mvm, NULL);
762 if (ret)
763 IWL_ERR(mvm, "failed to update quotas\n");
764 }
Alexander Bondar5ec42ec2013-05-27 13:49:03 +0300765 ret = iwl_mvm_power_update_mode(mvm, vif);
766 if (ret)
767 IWL_ERR(mvm, "failed to update power mode\n");
Johannes Berg210a5442013-01-24 23:48:23 +0100768 } else if (changes & BSS_CHANGED_DTIM_PERIOD) {
769 /*
770 * We received a beacon _after_ association so
771 * remove the session protection.
772 */
773 iwl_mvm_remove_time_event(mvm, mvmvif,
774 &mvmvif->time_event_data);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100775 } else if (changes & BSS_CHANGED_PS) {
Alexander Bondar4bf881f2013-05-29 10:19:50 +0300776 ret = iwl_mvm_power_update_mode(mvm, vif);
777 if (ret)
778 IWL_ERR(mvm, "failed to update power mode\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +0100779 }
780}
781
782static int iwl_mvm_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
783{
784 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
785 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
786 int ret;
787
788 mutex_lock(&mvm->mutex);
789
790 /* Send the beacon template */
791 ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif);
792 if (ret)
793 goto out_unlock;
794
795 /* Add the mac context */
796 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
797 if (ret)
798 goto out_unlock;
799
800 /* Perform the binding */
801 ret = iwl_mvm_binding_add_vif(mvm, vif);
802 if (ret)
803 goto out_remove;
804
805 mvmvif->ap_active = true;
806
807 /* Send the bcast station. At this stage the TBTT and DTIM time events
808 * are added and applied to the scheduler */
809 ret = iwl_mvm_send_bcast_sta(mvm, vif, &mvmvif->bcast_sta);
810 if (ret)
811 goto out_unbind;
812
813 ret = iwl_mvm_update_quotas(mvm, vif);
814 if (ret)
815 goto out_rm_bcast;
816
817 /* Need to update the P2P Device MAC */
818 if (vif->p2p && mvm->p2p_device_vif)
819 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif);
820
821 mutex_unlock(&mvm->mutex);
822 return 0;
823
824out_rm_bcast:
825 iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
826out_unbind:
827 iwl_mvm_binding_remove_vif(mvm, vif);
828out_remove:
829 iwl_mvm_mac_ctxt_remove(mvm, vif);
830out_unlock:
831 mutex_unlock(&mvm->mutex);
832 return ret;
833}
834
835static void iwl_mvm_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
836{
837 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
838 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
839
Johannes Berg38a12b52013-02-22 14:07:56 +0100840 iwl_mvm_prepare_mac_removal(mvm, vif);
841
Johannes Berg8ca151b2013-01-24 14:25:36 +0100842 mutex_lock(&mvm->mutex);
843
844 mvmvif->ap_active = false;
845
846 /* Need to update the P2P Device MAC */
847 if (vif->p2p && mvm->p2p_device_vif)
848 iwl_mvm_mac_ctxt_changed(mvm, mvm->p2p_device_vif);
849
850 iwl_mvm_update_quotas(mvm, NULL);
851 iwl_mvm_send_rm_bcast_sta(mvm, &mvmvif->bcast_sta);
852 iwl_mvm_binding_remove_vif(mvm, vif);
853 iwl_mvm_mac_ctxt_remove(mvm, vif);
854
855 mutex_unlock(&mvm->mutex);
856}
857
858static void iwl_mvm_bss_info_changed_ap(struct iwl_mvm *mvm,
859 struct ieee80211_vif *vif,
860 struct ieee80211_bss_conf *bss_conf,
861 u32 changes)
862{
863 /* Need to send a new beacon template to the FW */
864 if (changes & BSS_CHANGED_BEACON) {
865 if (iwl_mvm_mac_ctxt_beacon_changed(mvm, vif))
866 IWL_WARN(mvm, "Failed updating beacon data\n");
867 }
868}
869
870static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
871 struct ieee80211_vif *vif,
872 struct ieee80211_bss_conf *bss_conf,
873 u32 changes)
874{
875 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
876
877 mutex_lock(&mvm->mutex);
878
879 switch (vif->type) {
880 case NL80211_IFTYPE_STATION:
881 iwl_mvm_bss_info_changed_station(mvm, vif, bss_conf, changes);
882 break;
883 case NL80211_IFTYPE_AP:
884 iwl_mvm_bss_info_changed_ap(mvm, vif, bss_conf, changes);
885 break;
886 default:
887 /* shouldn't happen */
888 WARN_ON_ONCE(1);
889 }
890
891 mutex_unlock(&mvm->mutex);
892}
893
894static int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw,
895 struct ieee80211_vif *vif,
896 struct cfg80211_scan_request *req)
897{
898 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
899 int ret;
900
901 if (req->n_channels == 0 || req->n_channels > MAX_NUM_SCAN_CHANNELS)
902 return -EINVAL;
903
904 mutex_lock(&mvm->mutex);
905
906 if (mvm->scan_status == IWL_MVM_SCAN_NONE)
907 ret = iwl_mvm_scan_request(mvm, vif, req);
908 else
909 ret = -EBUSY;
910
911 mutex_unlock(&mvm->mutex);
912
913 return ret;
914}
915
916static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
917 struct ieee80211_vif *vif)
918{
919 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
920
921 mutex_lock(&mvm->mutex);
922
923 iwl_mvm_cancel_scan(mvm);
924
925 mutex_unlock(&mvm->mutex);
926}
927
928static void
929iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
930 struct ieee80211_sta *sta, u16 tid,
931 int num_frames,
932 enum ieee80211_frame_release_type reason,
933 bool more_data)
934{
935 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100936
937 /* TODO: how do we tell the fw to send frames for a specific TID */
938
939 /*
940 * The fw will send EOSP notification when the last frame will be
941 * transmitted.
942 */
Johannes Berg9cc40712013-02-15 22:47:48 +0100943 iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100944}
945
946static void iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw,
947 struct ieee80211_vif *vif,
948 enum sta_notify_cmd cmd,
949 struct ieee80211_sta *sta)
950{
951 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
952 struct iwl_mvm_sta *mvmsta = (void *)sta->drv_priv;
953
954 switch (cmd) {
955 case STA_NOTIFY_SLEEP:
Emmanuel Grumbache3d4bc82013-05-07 14:08:24 +0300956 if (atomic_read(&mvm->pending_frames[mvmsta->sta_id]) > 0)
Johannes Berg8ca151b2013-01-24 14:25:36 +0100957 ieee80211_sta_block_awake(hw, sta, true);
958 /*
959 * The fw updates the STA to be asleep. Tx packets on the Tx
960 * queues to this station will not be transmitted. The fw will
961 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
962 */
963 break;
964 case STA_NOTIFY_AWAKE:
Emmanuel Grumbach881acd82013-03-19 16:16:00 +0200965 if (WARN_ON(mvmsta->sta_id == IWL_MVM_STATION_COUNT))
Johannes Berg8ca151b2013-01-24 14:25:36 +0100966 break;
Johannes Berg9cc40712013-02-15 22:47:48 +0100967 iwl_mvm_sta_modify_ps_wake(mvm, sta);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100968 break;
969 default:
970 break;
971 }
972}
973
974static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw,
975 struct ieee80211_vif *vif,
976 struct ieee80211_sta *sta,
977 enum ieee80211_sta_state old_state,
978 enum ieee80211_sta_state new_state)
979{
980 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
981 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
982 int ret;
983
984 IWL_DEBUG_MAC80211(mvm, "station %pM state change %d->%d\n",
985 sta->addr, old_state, new_state);
986
987 /* this would be a mac80211 bug ... but don't crash */
988 if (WARN_ON_ONCE(!mvmvif->phy_ctxt))
989 return -EINVAL;
990
991 /* if a STA is being removed, reuse its ID */
992 flush_work(&mvm->sta_drained_wk);
993
994 mutex_lock(&mvm->mutex);
995 if (old_state == IEEE80211_STA_NOTEXIST &&
996 new_state == IEEE80211_STA_NONE) {
997 ret = iwl_mvm_add_sta(mvm, vif, sta);
998 } else if (old_state == IEEE80211_STA_NONE &&
999 new_state == IEEE80211_STA_AUTH) {
1000 ret = 0;
1001 } else if (old_state == IEEE80211_STA_AUTH &&
1002 new_state == IEEE80211_STA_ASSOC) {
Johannes Berg7a453972013-02-12 13:10:44 +01001003 ret = iwl_mvm_update_sta(mvm, vif, sta);
1004 if (ret == 0)
1005 iwl_mvm_rs_rate_init(mvm, sta,
1006 mvmvif->phy_ctxt->channel->band);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001007 } else if (old_state == IEEE80211_STA_ASSOC &&
1008 new_state == IEEE80211_STA_AUTHORIZED) {
Hila Gonen7df15b12012-12-12 11:16:19 +02001009 /* enable beacon filtering */
1010 WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif));
Johannes Berg8ca151b2013-01-24 14:25:36 +01001011 ret = 0;
1012 } else if (old_state == IEEE80211_STA_AUTHORIZED &&
1013 new_state == IEEE80211_STA_ASSOC) {
Hila Gonen7df15b12012-12-12 11:16:19 +02001014 /* disable beacon filtering */
1015 WARN_ON(iwl_mvm_disable_beacon_filter(mvm, vif));
Johannes Berg8ca151b2013-01-24 14:25:36 +01001016 ret = 0;
1017 } else if (old_state == IEEE80211_STA_ASSOC &&
1018 new_state == IEEE80211_STA_AUTH) {
1019 ret = 0;
1020 } else if (old_state == IEEE80211_STA_AUTH &&
1021 new_state == IEEE80211_STA_NONE) {
1022 ret = 0;
1023 } else if (old_state == IEEE80211_STA_NONE &&
1024 new_state == IEEE80211_STA_NOTEXIST) {
1025 ret = iwl_mvm_rm_sta(mvm, vif, sta);
1026 } else {
1027 ret = -EIO;
1028 }
1029 mutex_unlock(&mvm->mutex);
1030
1031 return ret;
1032}
1033
1034static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
1035{
1036 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1037
1038 mvm->rts_threshold = value;
1039
1040 return 0;
1041}
1042
1043static int iwl_mvm_mac_conf_tx(struct ieee80211_hw *hw,
1044 struct ieee80211_vif *vif, u16 ac,
1045 const struct ieee80211_tx_queue_params *params)
1046{
1047 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1048 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1049
1050 mvmvif->queue_params[ac] = *params;
1051
1052 /*
1053 * No need to update right away, we'll get BSS_CHANGED_QOS
1054 * The exception is P2P_DEVICE interface which needs immediate update.
1055 */
1056 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1057 int ret;
1058
1059 mutex_lock(&mvm->mutex);
1060 ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
1061 mutex_unlock(&mvm->mutex);
1062 return ret;
1063 }
1064 return 0;
1065}
1066
1067static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw *hw,
1068 struct ieee80211_vif *vif)
1069{
1070 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1071 u32 duration = min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS,
1072 200 + vif->bss_conf.beacon_int);
1073 u32 min_duration = min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS,
1074 100 + vif->bss_conf.beacon_int);
1075
1076 if (WARN_ON_ONCE(vif->bss_conf.assoc))
1077 return;
1078
1079 mutex_lock(&mvm->mutex);
1080 /* Try really hard to protect the session and hear a beacon */
1081 iwl_mvm_protect_session(mvm, vif, duration, min_duration);
1082 mutex_unlock(&mvm->mutex);
1083}
1084
1085static int iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
1086 enum set_key_cmd cmd,
1087 struct ieee80211_vif *vif,
1088 struct ieee80211_sta *sta,
1089 struct ieee80211_key_conf *key)
1090{
1091 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1092 int ret;
1093
1094 if (iwlwifi_mod_params.sw_crypto) {
1095 IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n");
1096 return -EOPNOTSUPP;
1097 }
1098
1099 switch (key->cipher) {
1100 case WLAN_CIPHER_SUITE_TKIP:
1101 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
1102 /* fall-through */
1103 case WLAN_CIPHER_SUITE_CCMP:
1104 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
1105 break;
1106 case WLAN_CIPHER_SUITE_AES_CMAC:
1107 WARN_ON_ONCE(!(hw->flags & IEEE80211_HW_MFP_CAPABLE));
1108 break;
1109 case WLAN_CIPHER_SUITE_WEP40:
1110 case WLAN_CIPHER_SUITE_WEP104:
1111 /*
1112 * Support for TX only, at least for now, so accept
1113 * the key and do nothing else. Then mac80211 will
1114 * pass it for TX but we don't have to use it for RX.
1115 */
1116 return 0;
1117 default:
1118 return -EOPNOTSUPP;
1119 }
1120
1121 mutex_lock(&mvm->mutex);
1122
1123 switch (cmd) {
1124 case SET_KEY:
Johannes Berg6caffd42013-03-06 13:15:21 +01001125 if (vif->type == NL80211_IFTYPE_AP && !sta) {
1126 /* GTK on AP interface is a TX-only key, return 0 */
1127 ret = 0;
1128 key->hw_key_idx = STA_KEY_IDX_INVALID;
1129 break;
1130 }
1131
Johannes Berg8ca151b2013-01-24 14:25:36 +01001132 IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");
1133 ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, false);
1134 if (ret) {
1135 IWL_WARN(mvm, "set key failed\n");
1136 /*
1137 * can't add key for RX, but we don't need it
1138 * in the device for TX so still return 0
1139 */
Johannes Berg6caffd42013-03-06 13:15:21 +01001140 key->hw_key_idx = STA_KEY_IDX_INVALID;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001141 ret = 0;
1142 }
1143
1144 break;
1145 case DISABLE_KEY:
Johannes Berg6caffd42013-03-06 13:15:21 +01001146 if (key->hw_key_idx == STA_KEY_IDX_INVALID) {
1147 ret = 0;
1148 break;
1149 }
1150
Johannes Berg8ca151b2013-01-24 14:25:36 +01001151 IWL_DEBUG_MAC80211(mvm, "disable hwcrypto key\n");
1152 ret = iwl_mvm_remove_sta_key(mvm, vif, sta, key);
1153 break;
1154 default:
1155 ret = -EINVAL;
1156 }
1157
1158 mutex_unlock(&mvm->mutex);
1159 return ret;
1160}
1161
1162static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw *hw,
1163 struct ieee80211_vif *vif,
1164 struct ieee80211_key_conf *keyconf,
1165 struct ieee80211_sta *sta,
1166 u32 iv32, u16 *phase1key)
1167{
1168 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1169
1170 iwl_mvm_update_tkip_key(mvm, vif, keyconf, sta, iv32, phase1key);
1171}
1172
1173
1174static int iwl_mvm_roc(struct ieee80211_hw *hw,
1175 struct ieee80211_vif *vif,
1176 struct ieee80211_channel *channel,
Ilan Peerd339d5c2013-02-12 09:34:13 +02001177 int duration,
1178 enum ieee80211_roc_type type)
Johannes Berg8ca151b2013-01-24 14:25:36 +01001179{
1180 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001181 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001182 struct cfg80211_chan_def chandef;
Ilan Peer31d385a2013-04-02 10:25:46 +03001183 struct iwl_mvm_phy_ctxt *phy_ctxt;
1184 int ret, i;
1185
1186 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
1187 duration, type);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001188
1189 if (vif->type != NL80211_IFTYPE_P2P_DEVICE) {
1190 IWL_ERR(mvm, "vif isn't a P2P_DEVICE: %d\n", vif->type);
1191 return -EINVAL;
1192 }
1193
Johannes Berg8ca151b2013-01-24 14:25:36 +01001194 mutex_lock(&mvm->mutex);
1195
Ilan Peer31d385a2013-04-02 10:25:46 +03001196 for (i = 0; i < NUM_PHY_CTX; i++) {
1197 phy_ctxt = &mvm->phy_ctxts[i];
1198 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt)
1199 continue;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001200
Ilan Peer31d385a2013-04-02 10:25:46 +03001201 if (phy_ctxt->ref && channel == phy_ctxt->channel) {
1202 /*
1203 * Unbind the P2P_DEVICE from the current PHY context,
1204 * and if the PHY context is not used remove it.
1205 */
1206 ret = iwl_mvm_binding_remove_vif(mvm, vif);
1207 if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
1208 goto out_unlock;
1209
1210 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1211
1212 /* Bind the P2P_DEVICE to the current PHY Context */
1213 mvmvif->phy_ctxt = phy_ctxt;
1214
1215 ret = iwl_mvm_binding_add_vif(mvm, vif);
1216 if (WARN(ret, "Failed binding P2P_DEVICE\n"))
1217 goto out_unlock;
1218
1219 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
1220 goto schedule_time_event;
1221 }
1222 }
1223
1224 /* Need to update the PHY context only if the ROC channel changed */
1225 if (channel == mvmvif->phy_ctxt->channel)
1226 goto schedule_time_event;
1227
1228 cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT);
1229
1230 /*
1231 * Change the PHY context configuration as it is currently referenced
1232 * only by the P2P Device MAC
1233 */
1234 if (mvmvif->phy_ctxt->ref == 1) {
1235 ret = iwl_mvm_phy_ctxt_changed(mvm, mvmvif->phy_ctxt,
1236 &chandef, 1, 1);
1237 if (ret)
1238 goto out_unlock;
1239 } else {
1240 /*
1241 * The PHY context is shared with other MACs. Need to remove the
1242 * P2P Device from the binding, allocate an new PHY context and
1243 * create a new binding
1244 */
1245 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
1246 if (!phy_ctxt) {
1247 ret = -ENOSPC;
1248 goto out_unlock;
1249 }
1250
1251 ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef,
1252 1, 1);
1253 if (ret) {
1254 IWL_ERR(mvm, "Failed to change PHY context\n");
1255 goto out_unlock;
1256 }
1257
1258 /* Unbind the P2P_DEVICE from the current PHY context */
1259 ret = iwl_mvm_binding_remove_vif(mvm, vif);
1260 if (WARN(ret, "Failed unbinding P2P_DEVICE\n"))
1261 goto out_unlock;
1262
1263 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1264
1265 /* Bind the P2P_DEVICE to the new allocated PHY context */
1266 mvmvif->phy_ctxt = phy_ctxt;
1267
1268 ret = iwl_mvm_binding_add_vif(mvm, vif);
1269 if (WARN(ret, "Failed binding P2P_DEVICE\n"))
1270 goto out_unlock;
1271
1272 iwl_mvm_phy_ctxt_ref(mvm, mvmvif->phy_ctxt);
1273 }
1274
1275schedule_time_event:
Johannes Berg8ca151b2013-01-24 14:25:36 +01001276 /* Schedule the time events */
Ilan Peere635c792013-02-13 11:05:18 +02001277 ret = iwl_mvm_start_p2p_roc(mvm, vif, duration, type);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001278
Ilan Peer31d385a2013-04-02 10:25:46 +03001279out_unlock:
Johannes Berg8ca151b2013-01-24 14:25:36 +01001280 mutex_unlock(&mvm->mutex);
1281 IWL_DEBUG_MAC80211(mvm, "leave\n");
Johannes Berg8ca151b2013-01-24 14:25:36 +01001282 return ret;
1283}
1284
1285static int iwl_mvm_cancel_roc(struct ieee80211_hw *hw)
1286{
1287 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1288
1289 IWL_DEBUG_MAC80211(mvm, "enter\n");
1290
1291 mutex_lock(&mvm->mutex);
1292 iwl_mvm_stop_p2p_roc(mvm);
1293 mutex_unlock(&mvm->mutex);
1294
1295 IWL_DEBUG_MAC80211(mvm, "leave\n");
1296 return 0;
1297}
1298
1299static int iwl_mvm_add_chanctx(struct ieee80211_hw *hw,
1300 struct ieee80211_chanctx_conf *ctx)
1301{
1302 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001303 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1304 struct iwl_mvm_phy_ctxt *phy_ctxt;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001305 int ret;
1306
Ilan Peer53a9d612013-04-28 11:55:08 +03001307 IWL_DEBUG_MAC80211(mvm, "Add channel context\n");
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001308
1309 mutex_lock(&mvm->mutex);
1310 phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
1311 if (!phy_ctxt) {
1312 ret = -ENOSPC;
1313 goto out;
1314 }
1315
Ilan Peer53a9d612013-04-28 11:55:08 +03001316 ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def,
1317 ctx->rx_chains_static,
1318 ctx->rx_chains_dynamic);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001319 if (ret) {
1320 IWL_ERR(mvm, "Failed to add PHY context\n");
1321 goto out;
1322 }
1323
Ilan Peer53a9d612013-04-28 11:55:08 +03001324 iwl_mvm_phy_ctxt_ref(mvm, phy_ctxt);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001325 *phy_ctxt_id = phy_ctxt->id;
1326out:
Johannes Berg8ca151b2013-01-24 14:25:36 +01001327 mutex_unlock(&mvm->mutex);
1328 return ret;
1329}
1330
1331static void iwl_mvm_remove_chanctx(struct ieee80211_hw *hw,
1332 struct ieee80211_chanctx_conf *ctx)
1333{
1334 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001335 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1336 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
Johannes Berg8ca151b2013-01-24 14:25:36 +01001337
1338 mutex_lock(&mvm->mutex);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001339 iwl_mvm_phy_ctxt_unref(mvm, phy_ctxt);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001340 mutex_unlock(&mvm->mutex);
1341}
1342
1343static void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
1344 struct ieee80211_chanctx_conf *ctx,
1345 u32 changed)
1346{
1347 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001348 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1349 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
Johannes Berg8ca151b2013-01-24 14:25:36 +01001350
Ilan Peer31d385a2013-04-02 10:25:46 +03001351 if (WARN_ONCE((phy_ctxt->ref > 1) &&
1352 (changed & ~(IEEE80211_CHANCTX_CHANGE_WIDTH |
1353 IEEE80211_CHANCTX_CHANGE_RX_CHAINS |
1354 IEEE80211_CHANCTX_CHANGE_RADAR)),
1355 "Cannot change PHY. Ref=%d, changed=0x%X\n",
1356 phy_ctxt->ref, changed))
1357 return;
1358
Johannes Berg8ca151b2013-01-24 14:25:36 +01001359 mutex_lock(&mvm->mutex);
1360 iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &ctx->def,
1361 ctx->rx_chains_static,
1362 ctx->rx_chains_dynamic);
1363 mutex_unlock(&mvm->mutex);
1364}
1365
1366static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
1367 struct ieee80211_vif *vif,
1368 struct ieee80211_chanctx_conf *ctx)
1369{
1370 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001371 u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
1372 struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
Johannes Berg8ca151b2013-01-24 14:25:36 +01001373 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1374 int ret;
1375
1376 mutex_lock(&mvm->mutex);
1377
Ilan Peerfe0f2de2013-03-21 10:23:52 +02001378 mvmvif->phy_ctxt = phy_ctxt;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001379
1380 switch (vif->type) {
1381 case NL80211_IFTYPE_AP:
1382 /*
1383 * The AP binding flow is handled as part of the start_ap flow
1384 * (in bss_info_changed).
1385 */
1386 ret = 0;
1387 goto out_unlock;
1388 case NL80211_IFTYPE_STATION:
1389 case NL80211_IFTYPE_ADHOC:
1390 case NL80211_IFTYPE_MONITOR:
1391 break;
1392 default:
1393 ret = -EINVAL;
1394 goto out_unlock;
1395 }
1396
1397 ret = iwl_mvm_binding_add_vif(mvm, vif);
1398 if (ret)
1399 goto out_unlock;
1400
1401 /*
1402 * Setting the quota at this stage is only required for monitor
1403 * interfaces. For the other types, the bss_info changed flow
1404 * will handle quota settings.
1405 */
1406 if (vif->type == NL80211_IFTYPE_MONITOR) {
Ilan Peer1e1391c2013-03-13 14:52:04 +02001407 mvmvif->monitor_active = true;
Johannes Berg8ca151b2013-01-24 14:25:36 +01001408 ret = iwl_mvm_update_quotas(mvm, vif);
1409 if (ret)
1410 goto out_remove_binding;
1411 }
1412
1413 goto out_unlock;
1414
1415 out_remove_binding:
1416 iwl_mvm_binding_remove_vif(mvm, vif);
1417 out_unlock:
1418 mutex_unlock(&mvm->mutex);
1419 if (ret)
1420 mvmvif->phy_ctxt = NULL;
1421 return ret;
1422}
1423
1424static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw,
1425 struct ieee80211_vif *vif,
1426 struct ieee80211_chanctx_conf *ctx)
1427{
1428 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1429 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1430
1431 mutex_lock(&mvm->mutex);
1432
1433 iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data);
1434
1435 if (vif->type == NL80211_IFTYPE_AP)
1436 goto out_unlock;
1437
Johannes Berg8ca151b2013-01-24 14:25:36 +01001438 switch (vif->type) {
1439 case NL80211_IFTYPE_MONITOR:
Ilan Peer1e1391c2013-03-13 14:52:04 +02001440 mvmvif->monitor_active = false;
1441 iwl_mvm_update_quotas(mvm, NULL);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001442 break;
1443 default:
1444 break;
1445 }
1446
Ilan Peer1e1391c2013-03-13 14:52:04 +02001447 iwl_mvm_binding_remove_vif(mvm, vif);
Johannes Berg8ca151b2013-01-24 14:25:36 +01001448out_unlock:
1449 mvmvif->phy_ctxt = NULL;
1450 mutex_unlock(&mvm->mutex);
1451}
1452
1453static int iwl_mvm_set_tim(struct ieee80211_hw *hw,
1454 struct ieee80211_sta *sta,
1455 bool set)
1456{
1457 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1458 struct iwl_mvm_sta *mvm_sta = (void *)sta->drv_priv;
1459
1460 if (!mvm_sta || !mvm_sta->vif) {
1461 IWL_ERR(mvm, "Station is not associated to a vif\n");
1462 return -EINVAL;
1463 }
1464
1465 return iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm_sta->vif);
1466}
1467
Emmanuel Grumbach2b76ef12013-01-24 10:35:13 +02001468static void iwl_mvm_mac_rssi_callback(struct ieee80211_hw *hw,
1469 struct ieee80211_vif *vif,
1470 enum ieee80211_rssi_event rssi_event)
1471{
1472 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1473
1474 iwl_mvm_bt_rssi_event(mvm, vif, rssi_event);
1475}
1476
Johannes Berg8ca151b2013-01-24 14:25:36 +01001477struct ieee80211_ops iwl_mvm_hw_ops = {
1478 .tx = iwl_mvm_mac_tx,
1479 .ampdu_action = iwl_mvm_mac_ampdu_action,
1480 .start = iwl_mvm_mac_start,
1481 .restart_complete = iwl_mvm_mac_restart_complete,
1482 .stop = iwl_mvm_mac_stop,
1483 .add_interface = iwl_mvm_mac_add_interface,
1484 .remove_interface = iwl_mvm_mac_remove_interface,
1485 .config = iwl_mvm_mac_config,
1486 .configure_filter = iwl_mvm_configure_filter,
1487 .bss_info_changed = iwl_mvm_bss_info_changed,
1488 .hw_scan = iwl_mvm_mac_hw_scan,
1489 .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
1490 .sta_state = iwl_mvm_mac_sta_state,
1491 .sta_notify = iwl_mvm_mac_sta_notify,
1492 .allow_buffered_frames = iwl_mvm_mac_allow_buffered_frames,
1493 .set_rts_threshold = iwl_mvm_mac_set_rts_threshold,
1494 .conf_tx = iwl_mvm_mac_conf_tx,
1495 .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx,
1496 .set_key = iwl_mvm_mac_set_key,
1497 .update_tkip_key = iwl_mvm_mac_update_tkip_key,
1498 .remain_on_channel = iwl_mvm_roc,
1499 .cancel_remain_on_channel = iwl_mvm_cancel_roc,
Emmanuel Grumbach2b76ef12013-01-24 10:35:13 +02001500 .rssi_callback = iwl_mvm_mac_rssi_callback,
Johannes Berg8ca151b2013-01-24 14:25:36 +01001501
1502 .add_chanctx = iwl_mvm_add_chanctx,
1503 .remove_chanctx = iwl_mvm_remove_chanctx,
1504 .change_chanctx = iwl_mvm_change_chanctx,
1505 .assign_vif_chanctx = iwl_mvm_assign_vif_chanctx,
1506 .unassign_vif_chanctx = iwl_mvm_unassign_vif_chanctx,
1507
1508 .start_ap = iwl_mvm_start_ap,
1509 .stop_ap = iwl_mvm_stop_ap,
1510
1511 .set_tim = iwl_mvm_set_tim,
1512
1513#ifdef CONFIG_PM_SLEEP
1514 /* look at d3.c */
1515 .suspend = iwl_mvm_suspend,
1516 .resume = iwl_mvm_resume,
1517 .set_wakeup = iwl_mvm_set_wakeup,
1518 .set_rekey_data = iwl_mvm_set_rekey_data,
1519#if IS_ENABLED(CONFIG_IPV6)
1520 .ipv6_addr_change = iwl_mvm_ipv6_addr_change,
1521#endif
1522 .set_default_unicast_key = iwl_mvm_set_default_unicast_key,
1523#endif
1524};