mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled
[linux/fpc-iii.git] / drivers / net / wireless / iwlwifi / mvm / mac-ctxt.c
blob72c64152f48e678796b7397cd39960f106de7d67
1 /******************************************************************************
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.
6 * GPL LICENSE SUMMARY
8 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
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.
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.
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
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 * BSD LICENSE
33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
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.
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.
62 *****************************************************************************/
64 #include <linux/etherdevice.h>
65 #include <net/mac80211.h>
66 #include "iwl-io.h"
67 #include "iwl-prph.h"
68 #include "fw-api.h"
69 #include "mvm.h"
71 const u8 iwl_mvm_ac_to_tx_fifo[] = {
72 IWL_MVM_TX_FIFO_BK,
73 IWL_MVM_TX_FIFO_BE,
74 IWL_MVM_TX_FIFO_VI,
75 IWL_MVM_TX_FIFO_VO,
78 struct iwl_mvm_mac_iface_iterator_data {
79 struct iwl_mvm *mvm;
80 struct ieee80211_vif *vif;
81 unsigned long available_mac_ids[BITS_TO_LONGS(NUM_MAC_INDEX_DRIVER)];
82 unsigned long available_tsf_ids[BITS_TO_LONGS(NUM_TSF_IDS)];
83 unsigned long used_hw_queues[BITS_TO_LONGS(IWL_MVM_FIRST_AGG_QUEUE)];
84 enum iwl_tsf_id preferred_tsf;
85 bool found_vif;
88 static void iwl_mvm_mac_iface_iterator(void *_data, u8 *mac,
89 struct ieee80211_vif *vif)
91 struct iwl_mvm_mac_iface_iterator_data *data = _data;
92 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
93 u32 ac;
95 /* Iterator may already find the interface being added -- skip it */
96 if (vif == data->vif) {
97 data->found_vif = true;
98 return;
101 /* Mark the queues used by the vif */
102 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
103 if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
104 __set_bit(vif->hw_queue[ac], data->used_hw_queues);
106 if (vif->cab_queue != IEEE80211_INVAL_HW_QUEUE)
107 __set_bit(vif->cab_queue, data->used_hw_queues);
110 * Mark MAC IDs as used by clearing the available bit, and
111 * (below) mark TSFs as used if their existing use is not
112 * compatible with the new interface type.
113 * No locking or atomic bit operations are needed since the
114 * data is on the stack of the caller function.
116 __clear_bit(mvmvif->id, data->available_mac_ids);
119 * The TSF is a hardware/firmware resource, there are 4 and
120 * the driver should assign and free them as needed. However,
121 * there are cases where 2 MACs should share the same TSF ID
122 * for the purpose of clock sync, an optimization to avoid
123 * clock drift causing overlapping TBTTs/DTIMs for a GO and
124 * client in the system.
126 * The firmware will decide according to the MAC type which
127 * will be the master and slave. Clients that need to sync
128 * with a remote station will be the master, and an AP or GO
129 * will be the slave.
131 * Depending on the new interface type it can be slaved to
132 * or become the master of an existing interface.
134 switch (data->vif->type) {
135 case NL80211_IFTYPE_STATION:
137 * The new interface is client, so if the existing one
138 * we're iterating is an AP, the TSF should be used to
139 * avoid drift between the new client and existing AP,
140 * the existing AP will get drift updates from the new
141 * client context in this case
143 if (vif->type == NL80211_IFTYPE_AP) {
144 if (data->preferred_tsf == NUM_TSF_IDS &&
145 test_bit(mvmvif->tsf_id, data->available_tsf_ids))
146 data->preferred_tsf = mvmvif->tsf_id;
147 return;
149 break;
150 case NL80211_IFTYPE_AP:
152 * The new interface is AP/GO, so should get drift
153 * updates from an existing client or use the same
154 * TSF as an existing GO. There's no drift between
155 * TSFs internally but if they used different TSFs
156 * then a new client MAC could update one of them
157 * and cause drift that way.
159 if (vif->type == NL80211_IFTYPE_STATION ||
160 vif->type == NL80211_IFTYPE_AP) {
161 if (data->preferred_tsf == NUM_TSF_IDS &&
162 test_bit(mvmvif->tsf_id, data->available_tsf_ids))
163 data->preferred_tsf = mvmvif->tsf_id;
164 return;
166 break;
167 default:
169 * For all other interface types there's no need to
170 * take drift into account. Either they're exclusive
171 * like IBSS and monitor, or we don't care much about
172 * their TSF (like P2P Device), but we won't be able
173 * to share the TSF resource.
175 break;
179 * Unless we exited above, we can't share the TSF resource
180 * that the virtual interface we're iterating over is using
181 * with the new one, so clear the available bit and if this
182 * was the preferred one, reset that as well.
184 __clear_bit(mvmvif->tsf_id, data->available_tsf_ids);
186 if (data->preferred_tsf == mvmvif->tsf_id)
187 data->preferred_tsf = NUM_TSF_IDS;
191 * Get the mask of the queus used by the vif
193 u32 iwl_mvm_mac_get_queues_mask(struct iwl_mvm *mvm,
194 struct ieee80211_vif *vif)
196 u32 qmask = 0, ac;
198 if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
199 return BIT(IWL_MVM_OFFCHANNEL_QUEUE);
201 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
202 if (vif->hw_queue[ac] != IEEE80211_INVAL_HW_QUEUE)
203 qmask |= BIT(vif->hw_queue[ac]);
205 return qmask;
208 static int iwl_mvm_mac_ctxt_allocate_resources(struct iwl_mvm *mvm,
209 struct ieee80211_vif *vif)
211 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
212 struct iwl_mvm_mac_iface_iterator_data data = {
213 .mvm = mvm,
214 .vif = vif,
215 .available_mac_ids = { (1 << NUM_MAC_INDEX_DRIVER) - 1 },
216 .available_tsf_ids = { (1 << NUM_TSF_IDS) - 1 },
217 /* no preference yet */
218 .preferred_tsf = NUM_TSF_IDS,
219 .used_hw_queues = {
220 BIT(IWL_MVM_OFFCHANNEL_QUEUE) |
221 BIT(IWL_MVM_AUX_QUEUE) |
222 BIT(IWL_MVM_CMD_QUEUE)
224 .found_vif = false,
226 u32 ac;
227 int ret, i;
230 * Allocate a MAC ID and a TSF for this MAC, along with the queues
231 * and other resources.
235 * Before the iterator, we start with all MAC IDs and TSFs available.
237 * During iteration, all MAC IDs are cleared that are in use by other
238 * virtual interfaces, and all TSF IDs are cleared that can't be used
239 * by this new virtual interface because they're used by an interface
240 * that can't share it with the new one.
241 * At the same time, we check if there's a preferred TSF in the case
242 * that we should share it with another interface.
245 /* Currently, MAC ID 0 should be used only for the managed vif */
246 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
247 __clear_bit(0, data.available_mac_ids);
249 ieee80211_iterate_active_interfaces_atomic(
250 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
251 iwl_mvm_mac_iface_iterator, &data);
254 * In the case we're getting here during resume, it's similar to
255 * firmware restart, and with RESUME_ALL the iterator will find
256 * the vif being added already.
257 * We don't want to reassign any IDs in either case since doing
258 * so would probably assign different IDs (as interfaces aren't
259 * necessarily added in the same order), but the old IDs were
260 * preserved anyway, so skip ID assignment for both resume and
261 * recovery.
263 if (data.found_vif)
264 return 0;
266 /* Therefore, in recovery, we can't get here */
267 if (WARN_ON_ONCE(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)))
268 return -EBUSY;
270 mvmvif->id = find_first_bit(data.available_mac_ids,
271 NUM_MAC_INDEX_DRIVER);
272 if (mvmvif->id == NUM_MAC_INDEX_DRIVER) {
273 IWL_ERR(mvm, "Failed to init MAC context - no free ID!\n");
274 ret = -EIO;
275 goto exit_fail;
278 if (data.preferred_tsf != NUM_TSF_IDS)
279 mvmvif->tsf_id = data.preferred_tsf;
280 else
281 mvmvif->tsf_id = find_first_bit(data.available_tsf_ids,
282 NUM_TSF_IDS);
283 if (mvmvif->tsf_id == NUM_TSF_IDS) {
284 IWL_ERR(mvm, "Failed to init MAC context - no free TSF!\n");
285 ret = -EIO;
286 goto exit_fail;
289 mvmvif->color = 0;
291 INIT_LIST_HEAD(&mvmvif->time_event_data.list);
292 mvmvif->time_event_data.id = TE_MAX;
294 /* No need to allocate data queues to P2P Device MAC.*/
295 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
296 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
297 vif->hw_queue[ac] = IEEE80211_INVAL_HW_QUEUE;
299 return 0;
302 /* Find available queues, and allocate them to the ACs */
303 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
304 u8 queue = find_first_zero_bit(data.used_hw_queues,
305 IWL_MVM_FIRST_AGG_QUEUE);
307 if (queue >= IWL_MVM_FIRST_AGG_QUEUE) {
308 IWL_ERR(mvm, "Failed to allocate queue\n");
309 ret = -EIO;
310 goto exit_fail;
313 __set_bit(queue, data.used_hw_queues);
314 vif->hw_queue[ac] = queue;
317 /* Allocate the CAB queue for softAP and GO interfaces */
318 if (vif->type == NL80211_IFTYPE_AP) {
319 u8 queue = find_first_zero_bit(data.used_hw_queues,
320 IWL_MVM_FIRST_AGG_QUEUE);
322 if (queue >= IWL_MVM_FIRST_AGG_QUEUE) {
323 IWL_ERR(mvm, "Failed to allocate cab queue\n");
324 ret = -EIO;
325 goto exit_fail;
328 vif->cab_queue = queue;
329 } else {
330 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
333 mvmvif->bcast_sta.sta_id = IWL_MVM_STATION_COUNT;
334 mvmvif->ap_sta_id = IWL_MVM_STATION_COUNT;
336 for (i = 0; i < NUM_IWL_MVM_SMPS_REQ; i++)
337 mvmvif->smps_requests[i] = IEEE80211_SMPS_AUTOMATIC;
339 return 0;
341 exit_fail:
342 memset(mvmvif, 0, sizeof(struct iwl_mvm_vif));
343 memset(vif->hw_queue, IEEE80211_INVAL_HW_QUEUE, sizeof(vif->hw_queue));
344 vif->cab_queue = IEEE80211_INVAL_HW_QUEUE;
345 return ret;
348 int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
350 u32 ac;
351 int ret;
353 lockdep_assert_held(&mvm->mutex);
355 ret = iwl_mvm_mac_ctxt_allocate_resources(mvm, vif);
356 if (ret)
357 return ret;
359 switch (vif->type) {
360 case NL80211_IFTYPE_P2P_DEVICE:
361 iwl_trans_ac_txq_enable(mvm->trans, IWL_MVM_OFFCHANNEL_QUEUE,
362 IWL_MVM_TX_FIFO_VO);
363 break;
364 case NL80211_IFTYPE_AP:
365 iwl_trans_ac_txq_enable(mvm->trans, vif->cab_queue,
366 IWL_MVM_TX_FIFO_MCAST);
367 /* fall through */
368 default:
369 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
370 iwl_trans_ac_txq_enable(mvm->trans, vif->hw_queue[ac],
371 iwl_mvm_ac_to_tx_fifo[ac]);
372 break;
375 return 0;
378 void iwl_mvm_mac_ctxt_release(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
380 int ac;
382 lockdep_assert_held(&mvm->mutex);
384 switch (vif->type) {
385 case NL80211_IFTYPE_P2P_DEVICE:
386 iwl_trans_txq_disable(mvm->trans, IWL_MVM_OFFCHANNEL_QUEUE);
387 break;
388 case NL80211_IFTYPE_AP:
389 iwl_trans_txq_disable(mvm->trans, vif->cab_queue);
390 /* fall through */
391 default:
392 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
393 iwl_trans_txq_disable(mvm->trans, vif->hw_queue[ac]);
397 static void iwl_mvm_ack_rates(struct iwl_mvm *mvm,
398 struct ieee80211_vif *vif,
399 enum ieee80211_band band,
400 u8 *cck_rates, u8 *ofdm_rates)
402 struct ieee80211_supported_band *sband;
403 unsigned long basic = vif->bss_conf.basic_rates;
404 int lowest_present_ofdm = 100;
405 int lowest_present_cck = 100;
406 u8 cck = 0;
407 u8 ofdm = 0;
408 int i;
410 sband = mvm->hw->wiphy->bands[band];
412 for_each_set_bit(i, &basic, BITS_PER_LONG) {
413 int hw = sband->bitrates[i].hw_value;
414 if (hw >= IWL_FIRST_OFDM_RATE) {
415 ofdm |= BIT(hw - IWL_FIRST_OFDM_RATE);
416 if (lowest_present_ofdm > hw)
417 lowest_present_ofdm = hw;
418 } else {
419 BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
421 cck |= BIT(hw);
422 if (lowest_present_cck > hw)
423 lowest_present_cck = hw;
428 * Now we've got the basic rates as bitmaps in the ofdm and cck
429 * variables. This isn't sufficient though, as there might not
430 * be all the right rates in the bitmap. E.g. if the only basic
431 * rates are 5.5 Mbps and 11 Mbps, we still need to add 1 Mbps
432 * and 6 Mbps because the 802.11-2007 standard says in 9.6:
434 * [...] a STA responding to a received frame shall transmit
435 * its Control Response frame [...] at the highest rate in the
436 * BSSBasicRateSet parameter that is less than or equal to the
437 * rate of the immediately previous frame in the frame exchange
438 * sequence ([...]) and that is of the same modulation class
439 * ([...]) as the received frame. If no rate contained in the
440 * BSSBasicRateSet parameter meets these conditions, then the
441 * control frame sent in response to a received frame shall be
442 * transmitted at the highest mandatory rate of the PHY that is
443 * less than or equal to the rate of the received frame, and
444 * that is of the same modulation class as the received frame.
446 * As a consequence, we need to add all mandatory rates that are
447 * lower than all of the basic rates to these bitmaps.
450 if (IWL_RATE_24M_INDEX < lowest_present_ofdm)
451 ofdm |= IWL_RATE_BIT_MSK(24) >> IWL_FIRST_OFDM_RATE;
452 if (IWL_RATE_12M_INDEX < lowest_present_ofdm)
453 ofdm |= IWL_RATE_BIT_MSK(12) >> IWL_FIRST_OFDM_RATE;
454 /* 6M already there or needed so always add */
455 ofdm |= IWL_RATE_BIT_MSK(6) >> IWL_FIRST_OFDM_RATE;
458 * CCK is a bit more complex with DSSS vs. HR/DSSS vs. ERP.
459 * Note, however:
460 * - if no CCK rates are basic, it must be ERP since there must
461 * be some basic rates at all, so they're OFDM => ERP PHY
462 * (or we're in 5 GHz, and the cck bitmap will never be used)
463 * - if 11M is a basic rate, it must be ERP as well, so add 5.5M
464 * - if 5.5M is basic, 1M and 2M are mandatory
465 * - if 2M is basic, 1M is mandatory
466 * - if 1M is basic, that's the only valid ACK rate.
467 * As a consequence, it's not as complicated as it sounds, just add
468 * any lower rates to the ACK rate bitmap.
470 if (IWL_RATE_11M_INDEX < lowest_present_cck)
471 cck |= IWL_RATE_BIT_MSK(11) >> IWL_FIRST_CCK_RATE;
472 if (IWL_RATE_5M_INDEX < lowest_present_cck)
473 cck |= IWL_RATE_BIT_MSK(5) >> IWL_FIRST_CCK_RATE;
474 if (IWL_RATE_2M_INDEX < lowest_present_cck)
475 cck |= IWL_RATE_BIT_MSK(2) >> IWL_FIRST_CCK_RATE;
476 /* 1M already there or needed so always add */
477 cck |= IWL_RATE_BIT_MSK(1) >> IWL_FIRST_CCK_RATE;
479 *cck_rates = cck;
480 *ofdm_rates = ofdm;
483 static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
484 struct ieee80211_vif *vif,
485 struct iwl_mac_ctx_cmd *cmd,
486 u32 action)
488 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
489 struct ieee80211_chanctx_conf *chanctx;
490 u8 cck_ack_rates, ofdm_ack_rates;
491 int i;
493 cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
494 mvmvif->color));
495 cmd->action = cpu_to_le32(action);
497 switch (vif->type) {
498 case NL80211_IFTYPE_STATION:
499 if (vif->p2p)
500 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_P2P_STA);
501 else
502 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_BSS_STA);
503 break;
504 case NL80211_IFTYPE_AP:
505 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_GO);
506 break;
507 case NL80211_IFTYPE_MONITOR:
508 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_LISTENER);
509 break;
510 case NL80211_IFTYPE_P2P_DEVICE:
511 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_P2P_DEVICE);
512 break;
513 case NL80211_IFTYPE_ADHOC:
514 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_IBSS);
515 break;
516 default:
517 WARN_ON_ONCE(1);
520 cmd->tsf_id = cpu_to_le32(mvmvif->tsf_id);
522 memcpy(cmd->node_addr, vif->addr, ETH_ALEN);
523 if (vif->bss_conf.bssid)
524 memcpy(cmd->bssid_addr, vif->bss_conf.bssid, ETH_ALEN);
525 else
526 eth_broadcast_addr(cmd->bssid_addr);
528 rcu_read_lock();
529 chanctx = rcu_dereference(vif->chanctx_conf);
530 iwl_mvm_ack_rates(mvm, vif, chanctx ? chanctx->def.chan->band
531 : IEEE80211_BAND_2GHZ,
532 &cck_ack_rates, &ofdm_ack_rates);
533 rcu_read_unlock();
535 cmd->cck_rates = cpu_to_le32((u32)cck_ack_rates);
536 cmd->ofdm_rates = cpu_to_le32((u32)ofdm_ack_rates);
538 cmd->cck_short_preamble =
539 cpu_to_le32(vif->bss_conf.use_short_preamble ?
540 MAC_FLG_SHORT_PREAMBLE : 0);
541 cmd->short_slot =
542 cpu_to_le32(vif->bss_conf.use_short_slot ?
543 MAC_FLG_SHORT_SLOT : 0);
545 for (i = 0; i < AC_NUM; i++) {
546 cmd->ac[i].cw_min = cpu_to_le16(mvmvif->queue_params[i].cw_min);
547 cmd->ac[i].cw_max = cpu_to_le16(mvmvif->queue_params[i].cw_max);
548 cmd->ac[i].aifsn = mvmvif->queue_params[i].aifs;
549 cmd->ac[i].edca_txop =
550 cpu_to_le16(mvmvif->queue_params[i].txop * 32);
551 cmd->ac[i].fifos_mask = BIT(iwl_mvm_ac_to_tx_fifo[i]);
554 /* in AP mode, the MCAST FIFO takes the EDCA params from VO */
555 if (vif->type == NL80211_IFTYPE_AP)
556 cmd->ac[AC_VO].fifos_mask |= BIT(IWL_MVM_TX_FIFO_MCAST);
558 if (vif->bss_conf.qos)
559 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA);
561 /* Don't use cts to self as the fw doesn't support it currently. */
562 if (vif->bss_conf.use_cts_prot)
563 cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT);
566 * I think that we should enable these 2 flags regardless the HT PROT
567 * fields in the HT IE, but I am not sure. Someone knows whom to ask?...
569 if (vif->bss_conf.chandef.width != NL80211_CHAN_WIDTH_20_NOHT) {
570 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_TGN);
571 cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_HT_PROT |
572 MAC_PROT_FLG_FAT_PROT);
575 cmd->filter_flags = cpu_to_le32(MAC_FILTER_ACCEPT_GRP);
578 static int iwl_mvm_mac_ctxt_send_cmd(struct iwl_mvm *mvm,
579 struct iwl_mac_ctx_cmd *cmd)
581 int ret = iwl_mvm_send_cmd_pdu(mvm, MAC_CONTEXT_CMD, CMD_SYNC,
582 sizeof(*cmd), cmd);
583 if (ret)
584 IWL_ERR(mvm, "Failed to send MAC context (action:%d): %d\n",
585 le32_to_cpu(cmd->action), ret);
586 return ret;
590 * Fill the specific data for mac context of type station or p2p client
592 static void iwl_mvm_mac_ctxt_cmd_fill_sta(struct iwl_mvm *mvm,
593 struct ieee80211_vif *vif,
594 struct iwl_mac_data_sta *ctxt_sta,
595 bool force_assoc_off)
597 /* We need the dtim_period to set the MAC as associated */
598 if (vif->bss_conf.assoc && vif->bss_conf.dtim_period &&
599 !force_assoc_off) {
600 u32 dtim_offs;
603 * The DTIM count counts down, so when it is N that means N
604 * more beacon intervals happen until the DTIM TBTT. Therefore
605 * add this to the current time. If that ends up being in the
606 * future, the firmware will handle it.
608 * Also note that the system_timestamp (which we get here as
609 * "sync_device_ts") and TSF timestamp aren't at exactly the
610 * same offset in the frame -- the TSF is at the first symbol
611 * of the TSF, the system timestamp is at signal acquisition
612 * time. This means there's an offset between them of at most
613 * a few hundred microseconds (24 * 8 bits + PLCP time gives
614 * 384us in the longest case), this is currently not relevant
615 * as the firmware wakes up around 2ms before the TBTT.
617 dtim_offs = vif->bss_conf.sync_dtim_count *
618 vif->bss_conf.beacon_int;
619 /* convert TU to usecs */
620 dtim_offs *= 1024;
622 ctxt_sta->dtim_tsf =
623 cpu_to_le64(vif->bss_conf.sync_tsf + dtim_offs);
624 ctxt_sta->dtim_time =
625 cpu_to_le32(vif->bss_conf.sync_device_ts + dtim_offs);
627 IWL_DEBUG_INFO(mvm, "DTIM TBTT is 0x%llx/0x%x, offset %d\n",
628 le64_to_cpu(ctxt_sta->dtim_tsf),
629 le32_to_cpu(ctxt_sta->dtim_time),
630 dtim_offs);
632 ctxt_sta->is_assoc = cpu_to_le32(1);
633 } else {
634 ctxt_sta->is_assoc = cpu_to_le32(0);
637 ctxt_sta->bi = cpu_to_le32(vif->bss_conf.beacon_int);
638 ctxt_sta->bi_reciprocal =
639 cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int));
640 ctxt_sta->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
641 vif->bss_conf.dtim_period);
642 ctxt_sta->dtim_reciprocal =
643 cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int *
644 vif->bss_conf.dtim_period));
646 ctxt_sta->listen_interval = cpu_to_le32(mvm->hw->conf.listen_interval);
647 ctxt_sta->assoc_id = cpu_to_le32(vif->bss_conf.aid);
650 static int iwl_mvm_mac_ctxt_cmd_station(struct iwl_mvm *mvm,
651 struct ieee80211_vif *vif,
652 u32 action)
654 struct iwl_mac_ctx_cmd cmd = {};
656 WARN_ON(vif->type != NL80211_IFTYPE_STATION || vif->p2p);
658 /* Fill the common data for all mac context types */
659 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action);
661 /* Allow beacons to pass through as long as we are not associated,or we
662 * do not have dtim period information */
663 if (!vif->bss_conf.assoc || !vif->bss_conf.dtim_period)
664 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON);
665 else
666 cmd.filter_flags &= ~cpu_to_le32(MAC_FILTER_IN_BEACON);
668 /* Fill the data specific for station mode */
669 iwl_mvm_mac_ctxt_cmd_fill_sta(mvm, vif, &cmd.sta,
670 action == FW_CTXT_ACTION_ADD);
672 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
675 static int iwl_mvm_mac_ctxt_cmd_p2p_client(struct iwl_mvm *mvm,
676 struct ieee80211_vif *vif,
677 u32 action)
679 struct iwl_mac_ctx_cmd cmd = {};
680 struct ieee80211_p2p_noa_attr *noa = &vif->bss_conf.p2p_noa_attr;
682 WARN_ON(vif->type != NL80211_IFTYPE_STATION || !vif->p2p);
684 /* Fill the common data for all mac context types */
685 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action);
687 /* Fill the data specific for station mode */
688 iwl_mvm_mac_ctxt_cmd_fill_sta(mvm, vif, &cmd.p2p_sta.sta,
689 action == FW_CTXT_ACTION_ADD);
691 cmd.p2p_sta.ctwin = cpu_to_le32(noa->oppps_ctwindow &
692 IEEE80211_P2P_OPPPS_CTWINDOW_MASK);
694 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
697 static int iwl_mvm_mac_ctxt_cmd_listener(struct iwl_mvm *mvm,
698 struct ieee80211_vif *vif,
699 u32 action)
701 struct iwl_mac_ctx_cmd cmd = {};
703 WARN_ON(vif->type != NL80211_IFTYPE_MONITOR);
705 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action);
707 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROMISC |
708 MAC_FILTER_IN_CONTROL_AND_MGMT |
709 MAC_FILTER_IN_BEACON |
710 MAC_FILTER_IN_PROBE_REQUEST);
712 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
715 struct iwl_mvm_go_iterator_data {
716 bool go_active;
719 static void iwl_mvm_go_iterator(void *_data, u8 *mac, struct ieee80211_vif *vif)
721 struct iwl_mvm_go_iterator_data *data = _data;
722 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
724 if (vif->type == NL80211_IFTYPE_AP && vif->p2p && mvmvif->ap_active)
725 data->go_active = true;
728 static int iwl_mvm_mac_ctxt_cmd_p2p_device(struct iwl_mvm *mvm,
729 struct ieee80211_vif *vif,
730 u32 action)
732 struct iwl_mac_ctx_cmd cmd = {};
733 struct iwl_mvm_go_iterator_data data = {};
735 WARN_ON(vif->type != NL80211_IFTYPE_P2P_DEVICE);
737 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action);
739 cmd.protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT);
741 /* Override the filter flags to accept only probe requests */
742 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
745 * This flag should be set to true when the P2P Device is
746 * discoverable and there is at least another active P2P GO. Settings
747 * this flag will allow the P2P Device to be discoverable on other
748 * channels in addition to its listen channel.
749 * Note that this flag should not be set in other cases as it opens the
750 * Rx filters on all MAC and increases the number of interrupts.
752 ieee80211_iterate_active_interfaces_atomic(
753 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
754 iwl_mvm_go_iterator, &data);
756 cmd.p2p_dev.is_disc_extended = cpu_to_le32(data.go_active ? 1 : 0);
757 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
760 static void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
761 struct iwl_mac_beacon_cmd *beacon_cmd,
762 u8 *beacon, u32 frame_size)
764 u32 tim_idx;
765 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon;
767 /* The index is relative to frame start but we start looking at the
768 * variable-length part of the beacon. */
769 tim_idx = mgmt->u.beacon.variable - beacon;
771 /* Parse variable-length elements of beacon to find WLAN_EID_TIM */
772 while ((tim_idx < (frame_size - 2)) &&
773 (beacon[tim_idx] != WLAN_EID_TIM))
774 tim_idx += beacon[tim_idx+1] + 2;
776 /* If TIM field was found, set variables */
777 if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) {
778 beacon_cmd->tim_idx = cpu_to_le32(tim_idx);
779 beacon_cmd->tim_size = cpu_to_le32((u32)beacon[tim_idx+1]);
780 } else {
781 IWL_WARN(mvm, "Unable to find TIM Element in beacon\n");
785 static int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm *mvm,
786 struct ieee80211_vif *vif,
787 struct sk_buff *beacon)
789 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
790 struct iwl_host_cmd cmd = {
791 .id = BEACON_TEMPLATE_CMD,
792 .flags = CMD_ASYNC,
794 struct iwl_mac_beacon_cmd beacon_cmd = {};
795 struct ieee80211_tx_info *info;
796 u32 beacon_skb_len;
797 u32 rate;
799 if (WARN_ON(!beacon))
800 return -EINVAL;
802 beacon_skb_len = beacon->len;
804 /* TODO: for now the beacon template id is set to be the mac context id.
805 * Might be better to handle it as another resource ... */
806 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id);
808 /* Set up TX command fields */
809 beacon_cmd.tx.len = cpu_to_le16((u16)beacon_skb_len);
810 beacon_cmd.tx.sta_id = mvmvif->bcast_sta.sta_id;
811 beacon_cmd.tx.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
812 beacon_cmd.tx.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL |
813 TX_CMD_FLG_BT_DIS |
814 TX_CMD_FLG_TSF);
816 mvm->mgmt_last_antenna_idx =
817 iwl_mvm_next_antenna(mvm, iwl_fw_valid_tx_ant(mvm->fw),
818 mvm->mgmt_last_antenna_idx);
820 beacon_cmd.tx.rate_n_flags =
821 cpu_to_le32(BIT(mvm->mgmt_last_antenna_idx) <<
822 RATE_MCS_ANT_POS);
824 info = IEEE80211_SKB_CB(beacon);
826 if (info->band == IEEE80211_BAND_5GHZ || vif->p2p) {
827 rate = IWL_FIRST_OFDM_RATE;
828 } else {
829 rate = IWL_FIRST_CCK_RATE;
830 beacon_cmd.tx.rate_n_flags |= cpu_to_le32(RATE_MCS_CCK_MSK);
832 beacon_cmd.tx.rate_n_flags |=
833 cpu_to_le32(iwl_mvm_mac80211_idx_to_hwrate(rate));
835 /* Set up TX beacon command fields */
836 iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd,
837 beacon->data,
838 beacon_skb_len);
840 /* Submit command */
841 cmd.len[0] = sizeof(beacon_cmd);
842 cmd.data[0] = &beacon_cmd;
843 cmd.dataflags[0] = 0;
844 cmd.len[1] = beacon_skb_len;
845 cmd.data[1] = beacon->data;
846 cmd.dataflags[1] = IWL_HCMD_DFL_DUP;
848 return iwl_mvm_send_cmd(mvm, &cmd);
851 /* The beacon template for the AP/GO context has changed and needs update */
852 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
853 struct ieee80211_vif *vif)
855 struct sk_buff *beacon;
856 int ret;
858 WARN_ON(vif->type != NL80211_IFTYPE_AP);
860 beacon = ieee80211_beacon_get(mvm->hw, vif);
861 if (!beacon)
862 return -ENOMEM;
864 ret = iwl_mvm_mac_ctxt_send_beacon(mvm, vif, beacon);
865 dev_kfree_skb(beacon);
866 return ret;
869 struct iwl_mvm_mac_ap_iterator_data {
870 struct iwl_mvm *mvm;
871 struct ieee80211_vif *vif;
872 u32 beacon_device_ts;
873 u16 beacon_int;
876 /* Find the beacon_device_ts and beacon_int for a managed interface */
877 static void iwl_mvm_mac_ap_iterator(void *_data, u8 *mac,
878 struct ieee80211_vif *vif)
880 struct iwl_mvm_mac_ap_iterator_data *data = _data;
882 if (vif->type != NL80211_IFTYPE_STATION || !vif->bss_conf.assoc)
883 return;
885 /* Station client has higher priority over P2P client*/
886 if (vif->p2p && data->beacon_device_ts)
887 return;
889 data->beacon_device_ts = vif->bss_conf.sync_device_ts;
890 data->beacon_int = vif->bss_conf.beacon_int;
894 * Fill the specific data for mac context of type AP of P2P GO
896 static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm,
897 struct ieee80211_vif *vif,
898 struct iwl_mac_data_ap *ctxt_ap,
899 bool add)
901 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
902 struct iwl_mvm_mac_ap_iterator_data data = {
903 .mvm = mvm,
904 .vif = vif,
905 .beacon_device_ts = 0
908 ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int);
909 ctxt_ap->bi_reciprocal =
910 cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int));
911 ctxt_ap->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
912 vif->bss_conf.dtim_period);
913 ctxt_ap->dtim_reciprocal =
914 cpu_to_le32(iwl_mvm_reciprocal(vif->bss_conf.beacon_int *
915 vif->bss_conf.dtim_period));
917 ctxt_ap->mcast_qid = cpu_to_le32(vif->cab_queue);
920 * Only set the beacon time when the MAC is being added, when we
921 * just modify the MAC then we should keep the time -- the firmware
922 * can otherwise have a "jumping" TBTT.
924 if (add) {
926 * If there is a station/P2P client interface which is
927 * associated, set the AP's TBTT far enough from the station's
928 * TBTT. Otherwise, set it to the current system time
930 ieee80211_iterate_active_interfaces_atomic(
931 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
932 iwl_mvm_mac_ap_iterator, &data);
934 if (data.beacon_device_ts) {
935 u32 rand = (prandom_u32() % (80 - 20)) + 20;
936 mvmvif->ap_beacon_time = data.beacon_device_ts +
937 ieee80211_tu_to_usec(data.beacon_int * rand /
938 100);
939 } else {
940 mvmvif->ap_beacon_time =
941 iwl_read_prph(mvm->trans,
942 DEVICE_SYSTEM_TIME_REG);
946 ctxt_ap->beacon_time = cpu_to_le32(mvmvif->ap_beacon_time);
947 ctxt_ap->beacon_tsf = 0; /* unused */
949 /* TODO: Assume that the beacon id == mac context id */
950 ctxt_ap->beacon_template = cpu_to_le32(mvmvif->id);
953 static int iwl_mvm_mac_ctxt_cmd_ap(struct iwl_mvm *mvm,
954 struct ieee80211_vif *vif,
955 u32 action)
957 struct iwl_mac_ctx_cmd cmd = {};
959 WARN_ON(vif->type != NL80211_IFTYPE_AP || vif->p2p);
961 /* Fill the common data for all mac context types */
962 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action);
964 /* Also enable probe requests to pass */
965 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
967 /* Fill the data specific for ap mode */
968 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.ap,
969 action == FW_CTXT_ACTION_ADD);
971 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
974 static int iwl_mvm_mac_ctxt_cmd_go(struct iwl_mvm *mvm,
975 struct ieee80211_vif *vif,
976 u32 action)
978 struct iwl_mac_ctx_cmd cmd = {};
979 struct ieee80211_p2p_noa_attr *noa = &vif->bss_conf.p2p_noa_attr;
981 WARN_ON(vif->type != NL80211_IFTYPE_AP || !vif->p2p);
983 /* Fill the common data for all mac context types */
984 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action);
986 /* Fill the data specific for GO mode */
987 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.go.ap,
988 action == FW_CTXT_ACTION_ADD);
990 cmd.go.ctwin = cpu_to_le32(noa->oppps_ctwindow &
991 IEEE80211_P2P_OPPPS_CTWINDOW_MASK);
992 cmd.go.opp_ps_enabled =
993 cpu_to_le32(!!(noa->oppps_ctwindow &
994 IEEE80211_P2P_OPPPS_ENABLE_BIT));
996 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
999 static int iwl_mvm_mac_ctx_send(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1000 u32 action)
1002 switch (vif->type) {
1003 case NL80211_IFTYPE_STATION:
1004 if (!vif->p2p)
1005 return iwl_mvm_mac_ctxt_cmd_station(mvm, vif,
1006 action);
1007 else
1008 return iwl_mvm_mac_ctxt_cmd_p2p_client(mvm, vif,
1009 action);
1010 break;
1011 case NL80211_IFTYPE_AP:
1012 if (!vif->p2p)
1013 return iwl_mvm_mac_ctxt_cmd_ap(mvm, vif, action);
1014 else
1015 return iwl_mvm_mac_ctxt_cmd_go(mvm, vif, action);
1016 break;
1017 case NL80211_IFTYPE_MONITOR:
1018 return iwl_mvm_mac_ctxt_cmd_listener(mvm, vif, action);
1019 case NL80211_IFTYPE_P2P_DEVICE:
1020 return iwl_mvm_mac_ctxt_cmd_p2p_device(mvm, vif, action);
1021 default:
1022 break;
1025 return -EOPNOTSUPP;
1028 int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1030 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1031 int ret;
1033 if (WARN_ONCE(mvmvif->uploaded, "Adding active MAC %pM/%d\n",
1034 vif->addr, ieee80211_vif_type_p2p(vif)))
1035 return -EIO;
1037 ret = iwl_mvm_mac_ctx_send(mvm, vif, FW_CTXT_ACTION_ADD);
1038 if (ret)
1039 return ret;
1041 mvmvif->uploaded = true;
1042 return 0;
1045 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1047 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1049 if (WARN_ONCE(!mvmvif->uploaded, "Changing inactive MAC %pM/%d\n",
1050 vif->addr, ieee80211_vif_type_p2p(vif)))
1051 return -EIO;
1053 return iwl_mvm_mac_ctx_send(mvm, vif, FW_CTXT_ACTION_MODIFY);
1056 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1058 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1059 struct iwl_mac_ctx_cmd cmd;
1060 int ret;
1062 if (WARN_ONCE(!mvmvif->uploaded, "Removing inactive MAC %pM/%d\n",
1063 vif->addr, ieee80211_vif_type_p2p(vif)))
1064 return -EIO;
1066 memset(&cmd, 0, sizeof(cmd));
1068 cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
1069 mvmvif->color));
1070 cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
1072 ret = iwl_mvm_send_cmd_pdu(mvm, MAC_CONTEXT_CMD, CMD_SYNC,
1073 sizeof(cmd), &cmd);
1074 if (ret) {
1075 IWL_ERR(mvm, "Failed to remove MAC context: %d\n", ret);
1076 return ret;
1079 mvmvif->uploaded = false;
1080 return 0;
1083 int iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
1084 struct iwl_rx_cmd_buffer *rxb,
1085 struct iwl_device_cmd *cmd)
1087 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1088 struct iwl_beacon_notif *beacon = (void *)pkt->data;
1089 u16 status __maybe_unused =
1090 le16_to_cpu(beacon->beacon_notify_hdr.status.status);
1091 u32 rate __maybe_unused =
1092 le32_to_cpu(beacon->beacon_notify_hdr.initial_rate);
1094 IWL_DEBUG_RX(mvm, "beacon status %#x retries:%d tsf:0x%16llX rate:%d\n",
1095 status & TX_STATUS_MSK,
1096 beacon->beacon_notify_hdr.failure_frame,
1097 le64_to_cpu(beacon->tsf),
1098 rate);
1099 return 0;
1102 static void iwl_mvm_beacon_loss_iterator(void *_data, u8 *mac,
1103 struct ieee80211_vif *vif)
1105 struct iwl_missed_beacons_notif *missed_beacons = _data;
1106 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1108 if (mvmvif->id != (u16)le32_to_cpu(missed_beacons->mac_id))
1109 return;
1112 * TODO: the threshold should be adjusted based on latency conditions,
1113 * and/or in case of a CS flow on one of the other AP vifs.
1115 if (le32_to_cpu(missed_beacons->consec_missed_beacons_since_last_rx) >
1116 IWL_MVM_MISSED_BEACONS_THRESHOLD)
1117 ieee80211_beacon_loss(vif);
1120 int iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
1121 struct iwl_rx_cmd_buffer *rxb,
1122 struct iwl_device_cmd *cmd)
1124 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1125 struct iwl_missed_beacons_notif *mb = (void *)pkt->data;
1127 IWL_DEBUG_INFO(mvm,
1128 "missed bcn mac_id=%u, consecutive=%u (%u, %u, %u)\n",
1129 le32_to_cpu(mb->mac_id),
1130 le32_to_cpu(mb->consec_missed_beacons),
1131 le32_to_cpu(mb->consec_missed_beacons_since_last_rx),
1132 le32_to_cpu(mb->num_recvd_beacons),
1133 le32_to_cpu(mb->num_expected_beacons));
1135 ieee80211_iterate_active_interfaces_atomic(mvm->hw,
1136 IEEE80211_IFACE_ITER_NORMAL,
1137 iwl_mvm_beacon_loss_iterator,
1138 mb);
1139 return 0;