1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5 * Copyright (C) 2015-2017 Intel Deutschland GmbH
7 #include <linux/etherdevice.h>
8 #include <linux/crc32.h>
9 #include <net/mac80211.h>
14 #include "time-event.h"
16 const u8 iwl_mvm_ac_to_tx_fifo[] = {
23 const u8 iwl_mvm_ac_to_gen2_tx_fifo[] = {
24 IWL_GEN2_EDCA_TX_FIFO_VO,
25 IWL_GEN2_EDCA_TX_FIFO_VI,
26 IWL_GEN2_EDCA_TX_FIFO_BE,
27 IWL_GEN2_EDCA_TX_FIFO_BK,
28 IWL_GEN2_TRIG_TX_FIFO_VO,
29 IWL_GEN2_TRIG_TX_FIFO_VI,
30 IWL_GEN2_TRIG_TX_FIFO_BE,
31 IWL_GEN2_TRIG_TX_FIFO_BK,
34 struct iwl_mvm_mac_iface_iterator_data {
36 struct ieee80211_vif *vif;
37 unsigned long available_mac_ids[BITS_TO_LONGS(NUM_MAC_INDEX_DRIVER)];
38 unsigned long available_tsf_ids[BITS_TO_LONGS(NUM_TSF_IDS)];
39 enum iwl_tsf_id preferred_tsf;
43 static void iwl_mvm_mac_tsf_id_iter(void *_data, u8 *mac,
44 struct ieee80211_vif *vif)
46 struct iwl_mvm_mac_iface_iterator_data *data = _data;
47 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
50 /* Skip the interface for which we are trying to assign a tsf_id */
55 * The TSF is a hardware/firmware resource, there are 4 and
56 * the driver should assign and free them as needed. However,
57 * there are cases where 2 MACs should share the same TSF ID
58 * for the purpose of clock sync, an optimization to avoid
59 * clock drift causing overlapping TBTTs/DTIMs for a GO and
60 * client in the system.
62 * The firmware will decide according to the MAC type which
63 * will be the leader and follower. Clients that need to sync
64 * with a remote station will be the leader, and an AP or GO
65 * will be the follower.
67 * Depending on the new interface type it can be following
68 * or become the leader of an existing interface.
70 switch (data->vif->type) {
71 case NL80211_IFTYPE_STATION:
73 * The new interface is a client, so if the one we're iterating
74 * is an AP, and the beacon interval of the AP is a multiple or
75 * divisor of the beacon interval of the client, the same TSF
76 * should be used to avoid drift between the new client and
77 * existing AP. The existing AP will get drift updates from the
78 * new client context in this case.
80 if (vif->type != NL80211_IFTYPE_AP ||
81 data->preferred_tsf != NUM_TSF_IDS ||
82 !test_bit(mvmvif->tsf_id, data->available_tsf_ids))
85 min_bi = min(data->vif->bss_conf.beacon_int,
86 vif->bss_conf.beacon_int);
91 if ((data->vif->bss_conf.beacon_int -
92 vif->bss_conf.beacon_int) % min_bi == 0) {
93 data->preferred_tsf = mvmvif->tsf_id;
98 case NL80211_IFTYPE_AP:
100 * The new interface is AP/GO, so if its beacon interval is a
101 * multiple or a divisor of the beacon interval of an existing
102 * interface, it should get drift updates from an existing
103 * client or use the same TSF as an existing GO. There's no
104 * drift between TSFs internally but if they used different
105 * TSFs then a new client MAC could update one of them and
106 * cause drift that way.
108 if ((vif->type != NL80211_IFTYPE_AP &&
109 vif->type != NL80211_IFTYPE_STATION) ||
110 data->preferred_tsf != NUM_TSF_IDS ||
111 !test_bit(mvmvif->tsf_id, data->available_tsf_ids))
114 min_bi = min(data->vif->bss_conf.beacon_int,
115 vif->bss_conf.beacon_int);
120 if ((data->vif->bss_conf.beacon_int -
121 vif->bss_conf.beacon_int) % min_bi == 0) {
122 data->preferred_tsf = mvmvif->tsf_id;
128 * For all other interface types there's no need to
129 * take drift into account. Either they're exclusive
130 * like IBSS and monitor, or we don't care much about
131 * their TSF (like P2P Device), but we won't be able
132 * to share the TSF resource.
138 * Unless we exited above, we can't share the TSF resource
139 * that the virtual interface we're iterating over is using
140 * with the new one, so clear the available bit and if this
141 * was the preferred one, reset that as well.
143 __clear_bit(mvmvif->tsf_id, data->available_tsf_ids);
145 if (data->preferred_tsf == mvmvif->tsf_id)
146 data->preferred_tsf = NUM_TSF_IDS;
149 static void iwl_mvm_mac_iface_iterator(void *_data, u8 *mac,
150 struct ieee80211_vif *vif)
152 struct iwl_mvm_mac_iface_iterator_data *data = _data;
153 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
155 /* Iterator may already find the interface being added -- skip it */
156 if (vif == data->vif) {
157 data->found_vif = true;
161 /* Mark MAC IDs as used by clearing the available bit, and
162 * (below) mark TSFs as used if their existing use is not
163 * compatible with the new interface type.
164 * No locking or atomic bit operations are needed since the
165 * data is on the stack of the caller function.
167 __clear_bit(mvmvif->id, data->available_mac_ids);
169 /* find a suitable tsf_id */
170 iwl_mvm_mac_tsf_id_iter(_data, mac, vif);
173 void iwl_mvm_mac_ctxt_recalc_tsf_id(struct iwl_mvm *mvm,
174 struct ieee80211_vif *vif)
176 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
177 struct iwl_mvm_mac_iface_iterator_data data = {
180 .available_tsf_ids = { (1 << NUM_TSF_IDS) - 1 },
181 /* no preference yet */
182 .preferred_tsf = NUM_TSF_IDS,
185 ieee80211_iterate_active_interfaces_atomic(
186 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
187 iwl_mvm_mac_tsf_id_iter, &data);
189 if (data.preferred_tsf != NUM_TSF_IDS)
190 mvmvif->tsf_id = data.preferred_tsf;
191 else if (!test_bit(mvmvif->tsf_id, data.available_tsf_ids))
192 mvmvif->tsf_id = find_first_bit(data.available_tsf_ids,
196 int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
198 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
199 struct iwl_mvm_mac_iface_iterator_data data = {
202 .available_mac_ids = { (1 << NUM_MAC_INDEX_DRIVER) - 1 },
203 .available_tsf_ids = { (1 << NUM_TSF_IDS) - 1 },
204 /* no preference yet */
205 .preferred_tsf = NUM_TSF_IDS,
210 lockdep_assert_held(&mvm->mutex);
213 * Allocate a MAC ID and a TSF for this MAC, along with the queues
214 * and other resources.
218 * Before the iterator, we start with all MAC IDs and TSFs available.
220 * During iteration, all MAC IDs are cleared that are in use by other
221 * virtual interfaces, and all TSF IDs are cleared that can't be used
222 * by this new virtual interface because they're used by an interface
223 * that can't share it with the new one.
224 * At the same time, we check if there's a preferred TSF in the case
225 * that we should share it with another interface.
228 /* MAC ID 0 should be used only for the managed/IBSS vif with non-MLO
231 if (!mvm->mld_api_is_used) {
233 case NL80211_IFTYPE_ADHOC:
235 case NL80211_IFTYPE_STATION:
240 __clear_bit(0, data.available_mac_ids);
244 ieee80211_iterate_active_interfaces_atomic(
245 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
246 iwl_mvm_mac_iface_iterator, &data);
249 * In the case we're getting here during resume, it's similar to
250 * firmware restart, and with RESUME_ALL the iterator will find
251 * the vif being added already.
252 * We don't want to reassign any IDs in either case since doing
253 * so would probably assign different IDs (as interfaces aren't
254 * necessarily added in the same order), but the old IDs were
255 * preserved anyway, so skip ID assignment for both resume and
261 /* Therefore, in recovery, we can't get here */
262 if (WARN_ON_ONCE(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)))
265 mvmvif->id = find_first_bit(data.available_mac_ids,
266 NUM_MAC_INDEX_DRIVER);
267 if (mvmvif->id == NUM_MAC_INDEX_DRIVER) {
268 IWL_ERR(mvm, "Failed to init MAC context - no free ID!\n");
273 if (data.preferred_tsf != NUM_TSF_IDS)
274 mvmvif->tsf_id = data.preferred_tsf;
276 mvmvif->tsf_id = find_first_bit(data.available_tsf_ids,
278 if (mvmvif->tsf_id == NUM_TSF_IDS) {
279 IWL_ERR(mvm, "Failed to init MAC context - no free TSF!\n");
286 INIT_LIST_HEAD(&mvmvif->time_event_data.list);
287 mvmvif->time_event_data.id = TE_MAX;
289 /* No need to allocate data queues to P2P Device MAC and NAN.*/
290 if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
293 /* Allocate the CAB queue for softAP and GO interfaces */
294 if (vif->type == NL80211_IFTYPE_AP ||
295 vif->type == NL80211_IFTYPE_ADHOC) {
297 * For TVQM this will be overwritten later with the FW assigned
298 * queue value (when queue is enabled).
300 mvmvif->deflink.cab_queue = IWL_MVM_DQA_GCAST_QUEUE;
303 mvmvif->deflink.bcast_sta.sta_id = IWL_MVM_INVALID_STA;
304 mvmvif->deflink.mcast_sta.sta_id = IWL_MVM_INVALID_STA;
305 mvmvif->deflink.ap_sta_id = IWL_MVM_INVALID_STA;
307 for (i = 0; i < NUM_IWL_MVM_SMPS_REQ; i++)
308 mvmvif->deflink.smps_requests[i] = IEEE80211_SMPS_AUTOMATIC;
313 memset(mvmvif, 0, sizeof(struct iwl_mvm_vif));
317 static void iwl_mvm_ack_rates(struct iwl_mvm *mvm,
318 struct ieee80211_vif *vif,
319 enum nl80211_band band,
320 u8 *cck_rates, u8 *ofdm_rates)
322 struct ieee80211_supported_band *sband;
323 unsigned long basic = vif->bss_conf.basic_rates;
324 int lowest_present_ofdm = 100;
325 int lowest_present_cck = 100;
330 sband = mvm->hw->wiphy->bands[band];
332 for_each_set_bit(i, &basic, BITS_PER_LONG) {
333 int hw = sband->bitrates[i].hw_value;
334 if (hw >= IWL_FIRST_OFDM_RATE) {
335 ofdm |= BIT(hw - IWL_FIRST_OFDM_RATE);
336 if (lowest_present_ofdm > hw)
337 lowest_present_ofdm = hw;
339 BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
342 if (lowest_present_cck > hw)
343 lowest_present_cck = hw;
348 * Now we've got the basic rates as bitmaps in the ofdm and cck
349 * variables. This isn't sufficient though, as there might not
350 * be all the right rates in the bitmap. E.g. if the only basic
351 * rates are 5.5 Mbps and 11 Mbps, we still need to add 1 Mbps
352 * and 6 Mbps because the 802.11-2007 standard says in 9.6:
354 * [...] a STA responding to a received frame shall transmit
355 * its Control Response frame [...] at the highest rate in the
356 * BSSBasicRateSet parameter that is less than or equal to the
357 * rate of the immediately previous frame in the frame exchange
358 * sequence ([...]) and that is of the same modulation class
359 * ([...]) as the received frame. If no rate contained in the
360 * BSSBasicRateSet parameter meets these conditions, then the
361 * control frame sent in response to a received frame shall be
362 * transmitted at the highest mandatory rate of the PHY that is
363 * less than or equal to the rate of the received frame, and
364 * that is of the same modulation class as the received frame.
366 * As a consequence, we need to add all mandatory rates that are
367 * lower than all of the basic rates to these bitmaps.
370 if (IWL_RATE_24M_INDEX < lowest_present_ofdm)
371 ofdm |= IWL_RATE_BIT_MSK(24) >> IWL_FIRST_OFDM_RATE;
372 if (IWL_RATE_12M_INDEX < lowest_present_ofdm)
373 ofdm |= IWL_RATE_BIT_MSK(12) >> IWL_FIRST_OFDM_RATE;
374 /* 6M already there or needed so always add */
375 ofdm |= IWL_RATE_BIT_MSK(6) >> IWL_FIRST_OFDM_RATE;
378 * CCK is a bit more complex with DSSS vs. HR/DSSS vs. ERP.
380 * - if no CCK rates are basic, it must be ERP since there must
381 * be some basic rates at all, so they're OFDM => ERP PHY
382 * (or we're in 5 GHz, and the cck bitmap will never be used)
383 * - if 11M is a basic rate, it must be ERP as well, so add 5.5M
384 * - if 5.5M is basic, 1M and 2M are mandatory
385 * - if 2M is basic, 1M is mandatory
386 * - if 1M is basic, that's the only valid ACK rate.
387 * As a consequence, it's not as complicated as it sounds, just add
388 * any lower rates to the ACK rate bitmap.
390 if (IWL_RATE_11M_INDEX < lowest_present_cck)
391 cck |= IWL_RATE_BIT_MSK(11) >> IWL_FIRST_CCK_RATE;
392 if (IWL_RATE_5M_INDEX < lowest_present_cck)
393 cck |= IWL_RATE_BIT_MSK(5) >> IWL_FIRST_CCK_RATE;
394 if (IWL_RATE_2M_INDEX < lowest_present_cck)
395 cck |= IWL_RATE_BIT_MSK(2) >> IWL_FIRST_CCK_RATE;
396 /* 1M already there or needed so always add */
397 cck |= IWL_RATE_BIT_MSK(1) >> IWL_FIRST_CCK_RATE;
403 void iwl_mvm_set_fw_basic_rates(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
404 struct ieee80211_bss_conf *link_conf,
405 __le32 *cck_rates, __le32 *ofdm_rates)
407 struct ieee80211_chanctx_conf *chanctx;
408 u8 cck_ack_rates = 0, ofdm_ack_rates = 0;
411 chanctx = rcu_dereference(link_conf->chanctx_conf);
412 iwl_mvm_ack_rates(mvm, vif, chanctx ? chanctx->def.chan->band
414 &cck_ack_rates, &ofdm_ack_rates);
418 *cck_rates = cpu_to_le32((u32)cck_ack_rates);
419 *ofdm_rates = cpu_to_le32((u32)ofdm_ack_rates);
422 void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm,
423 struct ieee80211_vif *vif,
424 struct ieee80211_bss_conf *link_conf,
425 __le32 *protection_flags, u32 ht_flag,
428 /* for both sta and ap, ht_operation_mode hold the protection_mode */
429 u8 protection_mode = link_conf->ht_operation_mode &
430 IEEE80211_HT_OP_MODE_PROTECTION;
431 bool ht_enabled = !!(link_conf->ht_operation_mode &
432 IEEE80211_HT_OP_MODE_PROTECTION);
434 if (link_conf->use_cts_prot)
435 *protection_flags |= cpu_to_le32(tgg_flag);
437 IWL_DEBUG_RATE(mvm, "use_cts_prot %d, ht_operation_mode %d\n",
438 link_conf->use_cts_prot,
439 link_conf->ht_operation_mode);
444 IWL_DEBUG_RATE(mvm, "protection mode set to %d\n", protection_mode);
446 * See section 9.23.3.1 of IEEE 80211-2012.
447 * Nongreenfield HT STAs Present is not supported.
449 switch (protection_mode) {
450 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
452 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
453 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
454 *protection_flags |= cpu_to_le32(ht_flag);
456 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
457 /* Protect when channel wider than 20MHz */
458 if (link_conf->chandef.width > NL80211_CHAN_WIDTH_20)
459 *protection_flags |= cpu_to_le32(ht_flag);
462 IWL_ERR(mvm, "Illegal protection mode %d\n",
468 void iwl_mvm_set_fw_qos_params(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
469 struct ieee80211_bss_conf *link_conf,
470 struct iwl_ac_qos *ac, __le32 *qos_flags)
472 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
475 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
476 u8 txf = iwl_mvm_mac_ac_to_tx_fifo(mvm, i);
477 u8 ucode_ac = iwl_mvm_mac80211_ac_to_ucode_ac(i);
479 ac[ucode_ac].cw_min =
480 cpu_to_le16(mvmvif->deflink.queue_params[i].cw_min);
481 ac[ucode_ac].cw_max =
482 cpu_to_le16(mvmvif->deflink.queue_params[i].cw_max);
483 ac[ucode_ac].edca_txop =
484 cpu_to_le16(mvmvif->deflink.queue_params[i].txop * 32);
485 ac[ucode_ac].aifsn = mvmvif->deflink.queue_params[i].aifs;
486 ac[ucode_ac].fifos_mask = BIT(txf);
490 *qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA);
492 if (link_conf->chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
493 *qos_flags |= cpu_to_le32(MAC_QOS_FLG_TGN);
496 int iwl_mvm_get_mac_type(struct ieee80211_vif *vif)
498 u32 mac_type = FW_MAC_TYPE_BSS_STA;
501 case NL80211_IFTYPE_STATION:
503 mac_type = FW_MAC_TYPE_P2P_STA;
505 mac_type = FW_MAC_TYPE_BSS_STA;
507 case NL80211_IFTYPE_AP:
508 mac_type = FW_MAC_TYPE_GO;
510 case NL80211_IFTYPE_MONITOR:
511 mac_type = FW_MAC_TYPE_LISTENER;
513 case NL80211_IFTYPE_P2P_DEVICE:
514 mac_type = FW_MAC_TYPE_P2P_DEVICE;
516 case NL80211_IFTYPE_ADHOC:
517 mac_type = FW_MAC_TYPE_IBSS;
525 static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
526 struct ieee80211_vif *vif,
527 struct iwl_mac_ctx_cmd *cmd,
528 const u8 *bssid_override,
531 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
532 const u8 *bssid = bssid_override ?: vif->bss_conf.bssid;
535 cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
537 cmd->action = cpu_to_le32(action);
538 cmd->mac_type = cpu_to_le32(iwl_mvm_get_mac_type(vif));
540 cmd->tsf_id = cpu_to_le32(mvmvif->tsf_id);
542 memcpy(cmd->node_addr, vif->addr, ETH_ALEN);
545 memcpy(cmd->bssid_addr, bssid, ETH_ALEN);
547 eth_broadcast_addr(cmd->bssid_addr);
549 iwl_mvm_set_fw_basic_rates(mvm, vif, &vif->bss_conf, &cmd->cck_rates,
552 cmd->cck_short_preamble =
553 cpu_to_le32(vif->bss_conf.use_short_preamble ?
554 MAC_FLG_SHORT_PREAMBLE : 0);
556 cpu_to_le32(vif->bss_conf.use_short_slot ?
557 MAC_FLG_SHORT_SLOT : 0);
559 cmd->filter_flags = 0;
561 iwl_mvm_set_fw_qos_params(mvm, vif, &vif->bss_conf, &cmd->ac[0],
564 /* The fw does not distinguish between ht and fat */
565 ht_flag = MAC_PROT_FLG_HT_PROT | MAC_PROT_FLG_FAT_PROT;
566 iwl_mvm_set_fw_protection_flags(mvm, vif, &vif->bss_conf,
567 &cmd->protection_flags,
568 ht_flag, MAC_PROT_FLG_TGG_PROTECT);
571 static int iwl_mvm_mac_ctxt_send_cmd(struct iwl_mvm *mvm,
572 struct iwl_mac_ctx_cmd *cmd)
574 int ret = iwl_mvm_send_cmd_pdu(mvm, MAC_CONTEXT_CMD, 0,
577 IWL_ERR(mvm, "Failed to send MAC_CONTEXT_CMD (action:%d): %d\n",
578 le32_to_cpu(cmd->action), ret);
582 void iwl_mvm_set_fw_dtim_tbtt(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
583 struct ieee80211_bss_conf *link_conf,
584 __le64 *dtim_tsf, __le32 *dtim_time,
585 __le32 *assoc_beacon_arrive_time)
590 * The DTIM count counts down, so when it is N that means N
591 * more beacon intervals happen until the DTIM TBTT. Therefore
592 * add this to the current time. If that ends up being in the
593 * future, the firmware will handle it.
595 * Also note that the system_timestamp (which we get here as
596 * "sync_device_ts") and TSF timestamp aren't at exactly the
597 * same offset in the frame -- the TSF is at the first symbol
598 * of the TSF, the system timestamp is at signal acquisition
599 * time. This means there's an offset between them of at most
600 * a few hundred microseconds (24 * 8 bits + PLCP time gives
601 * 384us in the longest case), this is currently not relevant
602 * as the firmware wakes up around 2ms before the TBTT.
604 dtim_offs = link_conf->sync_dtim_count *
605 link_conf->beacon_int;
606 /* convert TU to usecs */
610 cpu_to_le64(link_conf->sync_tsf + dtim_offs);
612 cpu_to_le32(link_conf->sync_device_ts + dtim_offs);
613 *assoc_beacon_arrive_time =
614 cpu_to_le32(link_conf->sync_device_ts);
616 IWL_DEBUG_INFO(mvm, "DTIM TBTT is 0x%llx/0x%x, offset %d\n",
617 le64_to_cpu(*dtim_tsf),
618 le32_to_cpu(*dtim_time),
622 __le32 iwl_mvm_mac_ctxt_cmd_p2p_sta_get_oppps_ctwin(struct iwl_mvm *mvm,
623 struct ieee80211_vif *vif)
625 struct ieee80211_p2p_noa_attr *noa =
626 &vif->bss_conf.p2p_noa_attr;
628 return cpu_to_le32(noa->oppps_ctwindow &
629 IEEE80211_P2P_OPPPS_CTWINDOW_MASK);
632 u32 iwl_mvm_mac_ctxt_cmd_sta_get_twt_policy(struct iwl_mvm *mvm,
633 struct ieee80211_vif *vif)
637 if (vif->bss_conf.twt_requester && IWL_MVM_USE_TWT)
638 twt_policy |= TWT_SUPPORTED;
639 if (vif->bss_conf.twt_protected)
640 twt_policy |= PROTECTED_TWT_SUPPORTED;
641 if (vif->bss_conf.twt_broadcast)
642 twt_policy |= BROADCAST_TWT_SUPPORTED;
647 static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
648 struct ieee80211_vif *vif,
649 u32 action, bool force_assoc_off,
650 const u8 *bssid_override)
652 struct iwl_mac_ctx_cmd cmd = {};
653 struct iwl_mac_data_sta *ctxt_sta;
655 WARN_ON(vif->type != NL80211_IFTYPE_STATION);
657 /* Fill the common data for all mac context types */
658 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, bssid_override, action);
661 * We always want to hear MCAST frames, if we're not authorized yet,
664 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_ACCEPT_GRP);
668 iwl_mvm_mac_ctxt_cmd_p2p_sta_get_oppps_ctwin(mvm, vif);
670 ctxt_sta = &cmd.p2p_sta.sta;
675 /* We need the dtim_period to set the MAC as associated */
676 if (vif->cfg.assoc && vif->bss_conf.dtim_period &&
678 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
680 iwl_mvm_set_fw_dtim_tbtt(mvm, vif, &vif->bss_conf,
682 &ctxt_sta->dtim_time,
683 &ctxt_sta->assoc_beacon_arrive_time);
685 ctxt_sta->is_assoc = cpu_to_le32(1);
687 if (!mvmvif->authorized &&
688 fw_has_capa(&mvm->fw->ucode_capa,
689 IWL_UCODE_TLV_CAPA_COEX_HIGH_PRIO))
690 ctxt_sta->data_policy |=
691 cpu_to_le32(COEX_HIGH_PRIORITY_ENABLE);
693 ctxt_sta->is_assoc = cpu_to_le32(0);
695 /* Allow beacons to pass through as long as we are not
696 * associated, or we do not have dtim period information.
698 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON);
701 ctxt_sta->bi = cpu_to_le32(vif->bss_conf.beacon_int);
702 ctxt_sta->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
703 vif->bss_conf.dtim_period);
705 ctxt_sta->listen_interval = cpu_to_le32(mvm->hw->conf.listen_interval);
706 ctxt_sta->assoc_id = cpu_to_le32(vif->cfg.aid);
708 if (vif->probe_req_reg && vif->cfg.assoc && vif->p2p)
709 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
711 if (vif->bss_conf.he_support && !iwlwifi_mod_params.disable_11ax) {
712 cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_11AX);
713 ctxt_sta->data_policy |=
714 cpu_to_le32(iwl_mvm_mac_ctxt_cmd_sta_get_twt_policy(mvm, vif));
718 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
721 static int iwl_mvm_mac_ctxt_cmd_listener(struct iwl_mvm *mvm,
722 struct ieee80211_vif *vif,
725 struct iwl_mac_ctx_cmd cmd = {};
726 u32 tfd_queue_msk = 0;
729 WARN_ON(vif->type != NL80211_IFTYPE_MONITOR);
731 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
733 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROMISC |
734 MAC_FILTER_IN_CONTROL_AND_MGMT |
735 MAC_FILTER_IN_BEACON |
736 MAC_FILTER_IN_PROBE_REQUEST |
737 MAC_FILTER_IN_CRC32 |
738 MAC_FILTER_ACCEPT_GRP);
739 ieee80211_hw_set(mvm->hw, RX_INCLUDES_FCS);
742 * the queue mask is only relevant for old TX API, and
743 * mvm->snif_queue isn't set here (it's still set to
744 * IWL_MVM_INVALID_QUEUE so the BIT() of it is UB)
746 if (!iwl_mvm_has_new_tx_api(mvm))
747 tfd_queue_msk = BIT(mvm->snif_queue);
749 /* Allocate sniffer station */
750 ret = iwl_mvm_allocate_int_sta(mvm, &mvm->snif_sta, tfd_queue_msk,
751 vif->type, IWL_STA_GENERAL_PURPOSE);
755 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
758 static int iwl_mvm_mac_ctxt_cmd_ibss(struct iwl_mvm *mvm,
759 struct ieee80211_vif *vif,
762 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
763 struct iwl_mac_ctx_cmd cmd = {};
765 WARN_ON(vif->type != NL80211_IFTYPE_ADHOC);
767 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
769 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_BEACON |
770 MAC_FILTER_IN_PROBE_REQUEST |
771 MAC_FILTER_ACCEPT_GRP);
773 /* cmd.ibss.beacon_time/cmd.ibss.beacon_tsf are curently ignored */
774 cmd.ibss.bi = cpu_to_le32(vif->bss_conf.beacon_int);
776 /* TODO: Assumes that the beacon id == mac context id */
777 cmd.ibss.beacon_template = cpu_to_le32(mvmvif->id);
779 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
782 struct iwl_mvm_go_iterator_data {
786 static void iwl_mvm_go_iterator(void *_data, u8 *mac, struct ieee80211_vif *vif)
788 struct iwl_mvm_go_iterator_data *data = _data;
789 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
791 if (vif->type == NL80211_IFTYPE_AP && vif->p2p &&
792 mvmvif->ap_ibss_active)
793 data->go_active = true;
796 __le32 iwl_mac_ctxt_p2p_dev_has_extended_disc(struct iwl_mvm *mvm,
797 struct ieee80211_vif *vif)
799 struct iwl_mvm_go_iterator_data data = {};
802 * This flag should be set to true when the P2P Device is
803 * discoverable and there is at least another active P2P GO. Settings
804 * this flag will allow the P2P Device to be discoverable on other
805 * channels in addition to its listen channel.
806 * Note that this flag should not be set in other cases as it opens the
807 * Rx filters on all MAC and increases the number of interrupts.
809 ieee80211_iterate_active_interfaces_atomic(
810 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
811 iwl_mvm_go_iterator, &data);
813 return cpu_to_le32(data.go_active ? 1 : 0);
816 static int iwl_mvm_mac_ctxt_cmd_p2p_device(struct iwl_mvm *mvm,
817 struct ieee80211_vif *vif,
820 struct iwl_mac_ctx_cmd cmd = {};
822 WARN_ON(vif->type != NL80211_IFTYPE_P2P_DEVICE);
824 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
826 cmd.p2p_dev.is_disc_extended =
827 iwl_mac_ctxt_p2p_dev_has_extended_disc(mvm, vif);
829 /* Override the filter flags to accept only probe requests */
830 cmd.filter_flags = cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST);
832 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
835 void iwl_mvm_mac_ctxt_set_tim(struct iwl_mvm *mvm,
836 __le32 *tim_index, __le32 *tim_size,
837 u8 *beacon, u32 frame_size)
840 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon;
842 /* The index is relative to frame start but we start looking at the
843 * variable-length part of the beacon. */
844 tim_idx = mgmt->u.beacon.variable - beacon;
846 /* Parse variable-length elements of beacon to find WLAN_EID_TIM */
847 while ((tim_idx < (frame_size - 2)) &&
848 (beacon[tim_idx] != WLAN_EID_TIM))
849 tim_idx += beacon[tim_idx+1] + 2;
851 /* If TIM field was found, set variables */
852 if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) {
853 *tim_index = cpu_to_le32(tim_idx);
854 *tim_size = cpu_to_le32((u32)beacon[tim_idx + 1]);
856 IWL_WARN(mvm, "Unable to find TIM Element in beacon\n");
860 static u32 iwl_mvm_find_ie_offset(u8 *beacon, u8 eid, u32 frame_size)
862 struct ieee80211_mgmt *mgmt = (void *)beacon;
865 if (WARN_ON_ONCE(frame_size <= (mgmt->u.beacon.variable - beacon)))
868 frame_size -= mgmt->u.beacon.variable - beacon;
870 ie = cfg80211_find_ie(eid, mgmt->u.beacon.variable, frame_size);
877 u8 iwl_mvm_mac_ctxt_get_lowest_rate(struct iwl_mvm *mvm,
878 struct ieee80211_tx_info *info,
879 struct ieee80211_vif *vif)
881 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
882 struct ieee80211_supported_band *sband;
883 unsigned long basic = vif->bss_conf.basic_rates;
884 u16 lowest_cck = IWL_RATE_COUNT, lowest_ofdm = IWL_RATE_COUNT;
885 u32 link_id = u32_get_bits(info->control.flags,
886 IEEE80211_TX_CTRL_MLO_LINK);
887 u8 band = info->band;
891 if (link_id == IEEE80211_LINK_UNSPECIFIED && vif->valid_links) {
892 for (i = 0; i < ARRAY_SIZE(mvmvif->link); i++) {
893 if (!mvmvif->link[i])
895 /* shouldn't do this when >1 link is active */
896 WARN_ON_ONCE(link_id != IEEE80211_LINK_UNSPECIFIED);
901 if (link_id < IEEE80211_LINK_UNSPECIFIED) {
902 struct ieee80211_bss_conf *link_conf;
905 link_conf = rcu_dereference(vif->link_conf[link_id]);
907 basic = link_conf->basic_rates;
908 if (link_conf->chandef.chan)
909 band = link_conf->chandef.chan->band;
914 sband = mvm->hw->wiphy->bands[band];
915 for_each_set_bit(i, &basic, BITS_PER_LONG) {
916 u16 hw = sband->bitrates[i].hw_value;
918 if (hw >= IWL_FIRST_OFDM_RATE) {
919 if (lowest_ofdm > hw)
921 } else if (lowest_cck > hw) {
926 if (band == NL80211_BAND_2GHZ && !vif->p2p &&
927 vif->type != NL80211_IFTYPE_P2P_DEVICE &&
928 !(info->flags & IEEE80211_TX_CTL_NO_CCK_RATE)) {
929 if (lowest_cck != IWL_RATE_COUNT)
931 else if (lowest_ofdm != IWL_RATE_COUNT)
934 rate = IWL_RATE_1M_INDEX;
935 } else if (lowest_ofdm != IWL_RATE_COUNT) {
938 rate = IWL_RATE_6M_INDEX;
944 u16 iwl_mvm_mac_ctxt_get_beacon_flags(const struct iwl_fw *fw, u8 rate_idx)
946 u16 flags = iwl_mvm_mac80211_idx_to_hwrate(fw, rate_idx);
947 bool is_new_rate = iwl_fw_lookup_cmd_ver(fw, BEACON_TEMPLATE_CMD, 0) > 10;
949 if (rate_idx <= IWL_FIRST_CCK_RATE)
950 flags |= is_new_rate ? IWL_MAC_BEACON_CCK
951 : IWL_MAC_BEACON_CCK_V1;
956 u8 iwl_mvm_mac_ctxt_get_beacon_rate(struct iwl_mvm *mvm,
957 struct ieee80211_tx_info *info,
958 struct ieee80211_vif *vif)
960 struct ieee80211_supported_band *sband =
961 mvm->hw->wiphy->bands[info->band];
962 u32 legacy = vif->bss_conf.beacon_tx_rate.control[info->band].legacy;
964 /* if beacon rate was configured try using it */
965 if (hweight32(legacy) == 1) {
966 u32 rate = ffs(legacy) - 1;
968 return sband->bitrates[rate].hw_value;
971 return iwl_mvm_mac_ctxt_get_lowest_rate(mvm, info, vif);
974 static void iwl_mvm_mac_ctxt_set_tx(struct iwl_mvm *mvm,
975 struct ieee80211_vif *vif,
976 struct sk_buff *beacon,
977 struct iwl_tx_cmd *tx)
979 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
980 struct ieee80211_tx_info *info;
984 info = IEEE80211_SKB_CB(beacon);
986 /* Set up TX command fields */
987 tx->len = cpu_to_le16((u16)beacon->len);
988 tx->sta_id = mvmvif->deflink.bcast_sta.sta_id;
989 tx->life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
990 tx_flags = TX_CMD_FLG_SEQ_CTL | TX_CMD_FLG_TSF;
992 iwl_mvm_bt_coex_tx_prio(mvm, (void *)beacon->data, info, 0) <<
993 TX_CMD_FLG_BT_PRIO_POS;
994 tx->tx_flags = cpu_to_le32(tx_flags);
996 if (!fw_has_capa(&mvm->fw->ucode_capa,
997 IWL_UCODE_TLV_CAPA_BEACON_ANT_SELECTION))
998 iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
1001 cpu_to_le32(BIT(mvm->mgmt_last_antenna_idx) <<
1004 rate = iwl_mvm_mac_ctxt_get_beacon_rate(mvm, info, vif);
1007 cpu_to_le32(iwl_mvm_mac80211_idx_to_hwrate(mvm->fw, rate));
1008 if (rate == IWL_FIRST_CCK_RATE)
1009 tx->rate_n_flags |= cpu_to_le32(RATE_MCS_CCK_MSK_V1);
1013 int iwl_mvm_mac_ctxt_send_beacon_cmd(struct iwl_mvm *mvm,
1014 struct sk_buff *beacon,
1015 void *data, int len)
1017 struct iwl_host_cmd cmd = {
1018 .id = BEACON_TEMPLATE_CMD,
1024 cmd.dataflags[0] = 0;
1025 cmd.len[1] = beacon->len;
1026 cmd.data[1] = beacon->data;
1027 cmd.dataflags[1] = IWL_HCMD_DFL_DUP;
1029 return iwl_mvm_send_cmd(mvm, &cmd);
1032 static int iwl_mvm_mac_ctxt_send_beacon_v6(struct iwl_mvm *mvm,
1033 struct ieee80211_vif *vif,
1034 struct sk_buff *beacon)
1036 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1037 struct iwl_mac_beacon_cmd_v6 beacon_cmd = {};
1039 iwl_mvm_mac_ctxt_set_tx(mvm, vif, beacon, &beacon_cmd.tx);
1041 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id);
1043 if (vif->type == NL80211_IFTYPE_AP)
1044 iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd.tim_idx,
1045 &beacon_cmd.tim_size,
1046 beacon->data, beacon->len);
1048 return iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
1049 sizeof(beacon_cmd));
1052 static int iwl_mvm_mac_ctxt_send_beacon_v7(struct iwl_mvm *mvm,
1053 struct ieee80211_vif *vif,
1054 struct sk_buff *beacon)
1056 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1057 struct iwl_mac_beacon_cmd_v7 beacon_cmd = {};
1059 iwl_mvm_mac_ctxt_set_tx(mvm, vif, beacon, &beacon_cmd.tx);
1061 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id);
1063 if (vif->type == NL80211_IFTYPE_AP)
1064 iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd.tim_idx,
1065 &beacon_cmd.tim_size,
1066 beacon->data, beacon->len);
1068 beacon_cmd.csa_offset =
1069 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
1070 WLAN_EID_CHANNEL_SWITCH,
1072 beacon_cmd.ecsa_offset =
1073 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
1074 WLAN_EID_EXT_CHANSWITCH_ANN,
1077 return iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
1078 sizeof(beacon_cmd));
1081 static int iwl_mvm_mac_ctxt_send_beacon_v9(struct iwl_mvm *mvm,
1082 struct ieee80211_vif *vif,
1083 struct sk_buff *beacon,
1084 struct ieee80211_bss_conf *link_conf)
1086 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1087 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(beacon);
1088 struct iwl_mac_beacon_cmd beacon_cmd = {};
1089 u8 rate = iwl_mvm_mac_ctxt_get_beacon_rate(mvm, info, vif);
1091 struct ieee80211_chanctx_conf *ctx;
1093 flags = iwl_mvm_mac_ctxt_get_beacon_flags(mvm->fw, rate);
1095 /* Enable FILS on PSC channels only */
1097 ctx = rcu_dereference(link_conf->chanctx_conf);
1098 channel = ieee80211_frequency_to_channel(ctx->def.chan->center_freq);
1099 WARN_ON(channel == 0);
1100 if (cfg80211_channel_is_psc(ctx->def.chan) &&
1101 !IWL_MVM_DISABLE_AP_FILS) {
1102 flags |= iwl_fw_lookup_cmd_ver(mvm->fw, BEACON_TEMPLATE_CMD,
1104 IWL_MAC_BEACON_FILS :
1105 IWL_MAC_BEACON_FILS_V1;
1106 beacon_cmd.short_ssid =
1107 cpu_to_le32(~crc32_le(~0, vif->cfg.ssid,
1108 vif->cfg.ssid_len));
1112 beacon_cmd.flags = cpu_to_le16(flags);
1113 beacon_cmd.byte_cnt = cpu_to_le16((u16)beacon->len);
1115 if (WARN_ON(!mvmvif->link[link_conf->link_id]))
1118 if (iwl_fw_lookup_cmd_ver(mvm->fw, BEACON_TEMPLATE_CMD, 0) > 12)
1119 beacon_cmd.link_id =
1120 cpu_to_le32(mvmvif->link[link_conf->link_id]->fw_link_id);
1122 beacon_cmd.link_id = cpu_to_le32((u32)mvmvif->id);
1124 if (vif->type == NL80211_IFTYPE_AP)
1125 iwl_mvm_mac_ctxt_set_tim(mvm, &beacon_cmd.tim_idx,
1126 &beacon_cmd.tim_size,
1127 beacon->data, beacon->len);
1129 beacon_cmd.csa_offset =
1130 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
1131 WLAN_EID_CHANNEL_SWITCH,
1133 beacon_cmd.ecsa_offset =
1134 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data,
1135 WLAN_EID_EXT_CHANSWITCH_ANN,
1138 return iwl_mvm_mac_ctxt_send_beacon_cmd(mvm, beacon, &beacon_cmd,
1139 sizeof(beacon_cmd));
1142 static int iwl_mvm_mac_ctxt_send_beacon(struct iwl_mvm *mvm,
1143 struct ieee80211_vif *vif,
1144 struct sk_buff *beacon,
1145 struct ieee80211_bss_conf *link_conf)
1147 if (WARN_ON(!beacon))
1150 if (IWL_MVM_NON_TRANSMITTING_AP)
1153 if (!fw_has_capa(&mvm->fw->ucode_capa,
1154 IWL_UCODE_TLV_CAPA_CSA_AND_TBTT_OFFLOAD))
1155 return iwl_mvm_mac_ctxt_send_beacon_v6(mvm, vif, beacon);
1157 if (fw_has_api(&mvm->fw->ucode_capa,
1158 IWL_UCODE_TLV_API_NEW_BEACON_TEMPLATE))
1159 return iwl_mvm_mac_ctxt_send_beacon_v9(mvm, vif, beacon,
1162 return iwl_mvm_mac_ctxt_send_beacon_v7(mvm, vif, beacon);
1165 /* The beacon template for the AP/GO/IBSS has changed and needs update */
1166 int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
1167 struct ieee80211_vif *vif,
1168 struct ieee80211_bss_conf *link_conf)
1170 struct sk_buff *beacon;
1173 WARN_ON(vif->type != NL80211_IFTYPE_AP &&
1174 vif->type != NL80211_IFTYPE_ADHOC);
1176 beacon = ieee80211_beacon_get_template(mvm->hw, vif, NULL,
1177 link_conf->link_id);
1181 #ifdef CONFIG_IWLWIFI_DEBUGFS
1182 if (mvm->beacon_inject_active) {
1183 dev_kfree_skb(beacon);
1188 ret = iwl_mvm_mac_ctxt_send_beacon(mvm, vif, beacon, link_conf);
1189 dev_kfree_skb(beacon);
1193 struct iwl_mvm_mac_ap_iterator_data {
1194 struct iwl_mvm *mvm;
1195 struct ieee80211_vif *vif;
1196 u32 beacon_device_ts;
1200 /* Find the beacon_device_ts and beacon_int for a managed interface */
1201 static void iwl_mvm_mac_ap_iterator(void *_data, u8 *mac,
1202 struct ieee80211_vif *vif)
1204 struct iwl_mvm_mac_ap_iterator_data *data = _data;
1206 if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc)
1209 /* Station client has higher priority over P2P client*/
1210 if (vif->p2p && data->beacon_device_ts)
1213 data->beacon_device_ts = vif->bss_conf.sync_device_ts;
1214 data->beacon_int = vif->bss_conf.beacon_int;
1218 * Fill the filter flags for mac context of type AP or P2P GO.
1220 void iwl_mvm_mac_ctxt_cmd_ap_set_filter_flags(struct iwl_mvm *mvm,
1221 struct iwl_mvm_vif *mvmvif,
1222 __le32 *filter_flags,
1223 int accept_probe_req_flag,
1224 int accept_beacon_flag)
1227 * in AP mode, pass probe requests and beacons from other APs
1228 * (needed for ht protection); when there're no any associated
1229 * station don't ask FW to pass beacons to prevent unnecessary
1232 *filter_flags |= cpu_to_le32(accept_probe_req_flag);
1233 if (mvmvif->ap_assoc_sta_count || !mvm->drop_bcn_ap_mode) {
1234 *filter_flags |= cpu_to_le32(accept_beacon_flag);
1235 IWL_DEBUG_HC(mvm, "Asking FW to pass beacons\n");
1237 IWL_DEBUG_HC(mvm, "No need to receive beacons\n");
1242 * Fill the specific data for mac context of type AP of P2P GO
1244 static void iwl_mvm_mac_ctxt_cmd_fill_ap(struct iwl_mvm *mvm,
1245 struct ieee80211_vif *vif,
1246 struct iwl_mac_ctx_cmd *cmd,
1247 struct iwl_mac_data_ap *ctxt_ap,
1250 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1251 struct iwl_mvm_mac_ap_iterator_data data = {
1254 .beacon_device_ts = 0
1257 /* in AP mode, the MCAST FIFO takes the EDCA params from VO */
1258 cmd->ac[IWL_MVM_TX_FIFO_VO].fifos_mask |= BIT(IWL_MVM_TX_FIFO_MCAST);
1260 iwl_mvm_mac_ctxt_cmd_ap_set_filter_flags(mvm, mvmvif,
1262 MAC_FILTER_IN_PROBE_REQUEST,
1263 MAC_FILTER_IN_BEACON);
1265 ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int);
1266 ctxt_ap->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
1267 vif->bss_conf.dtim_period);
1269 if (!fw_has_api(&mvm->fw->ucode_capa,
1270 IWL_UCODE_TLV_API_STA_TYPE))
1271 ctxt_ap->mcast_qid = cpu_to_le32(mvmvif->deflink.cab_queue);
1274 * Only set the beacon time when the MAC is being added, when we
1275 * just modify the MAC then we should keep the time -- the firmware
1276 * can otherwise have a "jumping" TBTT.
1280 * If there is a station/P2P client interface which is
1281 * associated, set the AP's TBTT far enough from the station's
1282 * TBTT. Otherwise, set it to the current system time
1284 ieee80211_iterate_active_interfaces_atomic(
1285 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL,
1286 iwl_mvm_mac_ap_iterator, &data);
1288 if (data.beacon_device_ts) {
1289 u32 rand = get_random_u32_inclusive(36, 63);
1290 mvmvif->ap_beacon_time = data.beacon_device_ts +
1291 ieee80211_tu_to_usec(data.beacon_int * rand /
1294 mvmvif->ap_beacon_time = iwl_mvm_get_systime(mvm);
1298 ctxt_ap->beacon_time = cpu_to_le32(mvmvif->ap_beacon_time);
1299 ctxt_ap->beacon_tsf = 0; /* unused */
1301 /* TODO: Assume that the beacon id == mac context id */
1302 ctxt_ap->beacon_template = cpu_to_le32(mvmvif->id);
1305 static int iwl_mvm_mac_ctxt_cmd_ap(struct iwl_mvm *mvm,
1306 struct ieee80211_vif *vif,
1309 struct iwl_mac_ctx_cmd cmd = {};
1311 WARN_ON(vif->type != NL80211_IFTYPE_AP || vif->p2p);
1313 /* Fill the common data for all mac context types */
1314 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
1316 /* Fill the data specific for ap mode */
1317 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd, &cmd.ap,
1318 action == FW_CTXT_ACTION_ADD);
1320 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
1323 static int iwl_mvm_mac_ctxt_cmd_go(struct iwl_mvm *mvm,
1324 struct ieee80211_vif *vif,
1327 struct iwl_mac_ctx_cmd cmd = {};
1328 struct ieee80211_p2p_noa_attr *noa = &vif->bss_conf.p2p_noa_attr;
1330 WARN_ON(vif->type != NL80211_IFTYPE_AP || !vif->p2p);
1332 /* Fill the common data for all mac context types */
1333 iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, NULL, action);
1335 /* Fill the data specific for GO mode */
1336 iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd, &cmd.go.ap,
1337 action == FW_CTXT_ACTION_ADD);
1339 cmd.go.ctwin = cpu_to_le32(noa->oppps_ctwindow &
1340 IEEE80211_P2P_OPPPS_CTWINDOW_MASK);
1341 cmd.go.opp_ps_enabled =
1342 cpu_to_le32(!!(noa->oppps_ctwindow &
1343 IEEE80211_P2P_OPPPS_ENABLE_BIT));
1345 return iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
1348 static int iwl_mvm_mac_ctx_send(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1349 u32 action, bool force_assoc_off,
1350 const u8 *bssid_override)
1352 switch (vif->type) {
1353 case NL80211_IFTYPE_STATION:
1354 return iwl_mvm_mac_ctxt_cmd_sta(mvm, vif, action,
1357 case NL80211_IFTYPE_AP:
1359 return iwl_mvm_mac_ctxt_cmd_ap(mvm, vif, action);
1361 return iwl_mvm_mac_ctxt_cmd_go(mvm, vif, action);
1362 case NL80211_IFTYPE_MONITOR:
1363 return iwl_mvm_mac_ctxt_cmd_listener(mvm, vif, action);
1364 case NL80211_IFTYPE_P2P_DEVICE:
1365 return iwl_mvm_mac_ctxt_cmd_p2p_device(mvm, vif, action);
1366 case NL80211_IFTYPE_ADHOC:
1367 return iwl_mvm_mac_ctxt_cmd_ibss(mvm, vif, action);
1375 int iwl_mvm_mac_ctxt_add(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1377 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1380 if (WARN_ONCE(mvmvif->uploaded, "Adding active MAC %pM/%d\n",
1381 vif->addr, ieee80211_vif_type_p2p(vif)))
1384 ret = iwl_mvm_mac_ctx_send(mvm, vif, FW_CTXT_ACTION_ADD,
1389 /* will only do anything at resume from D3 time */
1390 iwl_mvm_set_last_nonqos_seq(mvm, vif);
1392 mvmvif->uploaded = true;
1396 int iwl_mvm_mac_ctxt_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1397 bool force_assoc_off, const u8 *bssid_override)
1399 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1401 if (WARN_ONCE(!mvmvif->uploaded, "Changing inactive MAC %pM/%d\n",
1402 vif->addr, ieee80211_vif_type_p2p(vif)))
1405 return iwl_mvm_mac_ctx_send(mvm, vif, FW_CTXT_ACTION_MODIFY,
1406 force_assoc_off, bssid_override);
1409 int iwl_mvm_mac_ctxt_remove(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
1411 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1412 struct iwl_mac_ctx_cmd cmd;
1415 if (WARN_ONCE(!mvmvif->uploaded, "Removing inactive MAC %pM/%d\n",
1416 vif->addr, ieee80211_vif_type_p2p(vif)))
1419 memset(&cmd, 0, sizeof(cmd));
1421 cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
1423 cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
1425 ret = iwl_mvm_mac_ctxt_send_cmd(mvm, &cmd);
1429 mvmvif->uploaded = false;
1431 if (vif->type == NL80211_IFTYPE_MONITOR) {
1432 __clear_bit(IEEE80211_HW_RX_INCLUDES_FCS, mvm->hw->flags);
1433 iwl_mvm_dealloc_snif_sta(mvm);
1439 static void iwl_mvm_csa_count_down(struct iwl_mvm *mvm,
1440 struct ieee80211_vif *csa_vif, u32 gp2,
1443 struct iwl_mvm_vif *mvmvif =
1444 iwl_mvm_vif_from_mac80211(csa_vif);
1446 /* Don't start to countdown from a failed beacon */
1447 if (!tx_success && !mvmvif->csa_countdown)
1450 mvmvif->csa_countdown = true;
1452 if (!ieee80211_beacon_cntdwn_is_complete(csa_vif)) {
1453 int c = ieee80211_beacon_update_cntdwn(csa_vif);
1455 iwl_mvm_mac_ctxt_beacon_changed(mvm, csa_vif,
1456 &csa_vif->bss_conf);
1458 !iwl_mvm_te_scheduled(&mvmvif->time_event_data) && gp2 &&
1460 u32 rel_time = (c + 1) *
1461 csa_vif->bss_conf.beacon_int -
1462 IWL_MVM_CHANNEL_SWITCH_TIME_GO;
1463 u32 apply_time = gp2 + rel_time * 1024;
1465 iwl_mvm_schedule_csa_period(mvm, csa_vif,
1466 IWL_MVM_CHANNEL_SWITCH_TIME_GO -
1467 IWL_MVM_CHANNEL_SWITCH_MARGIN,
1470 } else if (!iwl_mvm_te_scheduled(&mvmvif->time_event_data)) {
1471 /* we don't have CSA NoA scheduled yet, switch now */
1472 ieee80211_csa_finish(csa_vif);
1473 RCU_INIT_POINTER(mvm->csa_vif, NULL);
1477 void iwl_mvm_rx_beacon_notif(struct iwl_mvm *mvm,
1478 struct iwl_rx_cmd_buffer *rxb)
1480 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1481 unsigned int pkt_len = iwl_rx_packet_payload_len(pkt);
1482 struct iwl_extended_beacon_notif *beacon = (void *)pkt->data;
1483 struct iwl_extended_beacon_notif_v5 *beacon_v5 = (void *)pkt->data;
1484 struct ieee80211_vif *csa_vif;
1485 struct ieee80211_vif *tx_blocked_vif;
1486 struct agg_tx_status *agg_status;
1489 lockdep_assert_held(&mvm->mutex);
1491 mvm->ap_last_beacon_gp2 = le32_to_cpu(beacon->gp2);
1493 if (!iwl_mvm_is_short_beacon_notif_supported(mvm)) {
1494 struct iwl_mvm_tx_resp *beacon_notify_hdr =
1495 &beacon_v5->beacon_notify_hdr;
1497 if (unlikely(pkt_len < sizeof(*beacon_v5)))
1500 mvm->ibss_manager = beacon_v5->ibss_mgr_status != 0;
1501 agg_status = iwl_mvm_get_agg_status(mvm, beacon_notify_hdr);
1502 status = le16_to_cpu(agg_status->status) & TX_STATUS_MSK;
1504 "beacon status %#x retries:%d tsf:0x%016llX gp2:0x%X rate:%d\n",
1505 status, beacon_notify_hdr->failure_frame,
1506 le64_to_cpu(beacon->tsf),
1507 mvm->ap_last_beacon_gp2,
1508 le32_to_cpu(beacon_notify_hdr->initial_rate));
1510 if (unlikely(pkt_len < sizeof(*beacon)))
1513 mvm->ibss_manager = beacon->ibss_mgr_status != 0;
1514 status = le32_to_cpu(beacon->status) & TX_STATUS_MSK;
1516 "beacon status %#x tsf:0x%016llX gp2:0x%X\n",
1517 status, le64_to_cpu(beacon->tsf),
1518 mvm->ap_last_beacon_gp2);
1521 csa_vif = rcu_dereference_protected(mvm->csa_vif,
1522 lockdep_is_held(&mvm->mutex));
1523 if (unlikely(csa_vif && csa_vif->bss_conf.csa_active))
1524 iwl_mvm_csa_count_down(mvm, csa_vif, mvm->ap_last_beacon_gp2,
1525 (status == TX_STATUS_SUCCESS));
1527 tx_blocked_vif = rcu_dereference_protected(mvm->csa_tx_blocked_vif,
1528 lockdep_is_held(&mvm->mutex));
1529 if (unlikely(tx_blocked_vif)) {
1530 struct iwl_mvm_vif *mvmvif =
1531 iwl_mvm_vif_from_mac80211(tx_blocked_vif);
1534 * The channel switch is started and we have blocked the
1535 * stations. If this is the first beacon (the timeout wasn't
1536 * set), set the unblock timeout, otherwise countdown
1538 if (!mvm->csa_tx_block_bcn_timeout)
1539 mvm->csa_tx_block_bcn_timeout =
1540 IWL_MVM_CS_UNBLOCK_TX_TIMEOUT;
1542 mvm->csa_tx_block_bcn_timeout--;
1544 /* Check if the timeout is expired, and unblock tx */
1545 if (mvm->csa_tx_block_bcn_timeout == 0) {
1546 iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, false);
1547 RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL);
1552 void iwl_mvm_rx_missed_beacons_notif(struct iwl_mvm *mvm,
1553 struct iwl_rx_cmd_buffer *rxb)
1555 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1556 struct iwl_missed_beacons_notif *mb = (void *)pkt->data;
1557 struct iwl_fw_dbg_trigger_missed_bcon *bcon_trig;
1558 struct iwl_fw_dbg_trigger_tlv *trigger;
1559 u32 stop_trig_missed_bcon, stop_trig_missed_bcon_since_rx;
1560 u32 rx_missed_bcon, rx_missed_bcon_since_rx;
1561 struct ieee80211_vif *vif;
1562 /* Id can be mac/link id depending on the notification version */
1563 u32 id = le32_to_cpu(mb->link_id);
1564 union iwl_dbg_tlv_tp_data tp_data = { .fw_pkt = pkt };
1566 u8 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, LEGACY_GROUP,
1567 MISSED_BEACONS_NOTIFICATION,
1572 /* before version four the ID in the notification refers to mac ID */
1573 if (notif_ver < 4) {
1574 vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
1576 struct ieee80211_bss_conf *bss_conf =
1577 iwl_mvm_rcu_fw_link_id_to_link_conf(mvm, id, true);
1582 vif = bss_conf->vif;
1586 "missed bcn %s_id=%u, consecutive=%u (%u, %u, %u)\n",
1587 notif_ver < 4 ? "mac" : "link",
1589 le32_to_cpu(mb->consec_missed_beacons),
1590 le32_to_cpu(mb->consec_missed_beacons_since_last_rx),
1591 le32_to_cpu(mb->num_recvd_beacons),
1592 le32_to_cpu(mb->num_expected_beacons));
1597 mac_type = iwl_mvm_get_mac_type(vif);
1599 IWL_DEBUG_INFO(mvm, "missed beacon mac_type=%u,\n", mac_type);
1601 mvm->trans->dbg.dump_file_name_ext_valid = true;
1602 snprintf(mvm->trans->dbg.dump_file_name_ext, IWL_FW_INI_MAX_NAME,
1603 "MacId_%d_MacType_%d", id, mac_type);
1605 rx_missed_bcon = le32_to_cpu(mb->consec_missed_beacons);
1606 rx_missed_bcon_since_rx =
1607 le32_to_cpu(mb->consec_missed_beacons_since_last_rx);
1609 * TODO: the threshold should be adjusted based on latency conditions,
1610 * and/or in case of a CS flow on one of the other AP vifs.
1612 if (rx_missed_bcon > IWL_MVM_MISSED_BEACONS_THRESHOLD_LONG)
1613 iwl_mvm_connection_loss(mvm, vif, "missed beacons");
1614 else if (rx_missed_bcon_since_rx > IWL_MVM_MISSED_BEACONS_THRESHOLD)
1615 ieee80211_beacon_loss(vif);
1617 iwl_dbg_tlv_time_point(&mvm->fwrt,
1618 IWL_FW_INI_TIME_POINT_MISSED_BEACONS, &tp_data);
1620 trigger = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif),
1621 FW_DBG_TRIGGER_MISSED_BEACONS);
1625 bcon_trig = (void *)trigger->data;
1626 stop_trig_missed_bcon = le32_to_cpu(bcon_trig->stop_consec_missed_bcon);
1627 stop_trig_missed_bcon_since_rx =
1628 le32_to_cpu(bcon_trig->stop_consec_missed_bcon_since_rx);
1630 /* TODO: implement start trigger */
1632 if (rx_missed_bcon_since_rx >= stop_trig_missed_bcon_since_rx ||
1633 rx_missed_bcon >= stop_trig_missed_bcon)
1634 iwl_fw_dbg_collect_trig(&mvm->fwrt, trigger, NULL);
1640 void iwl_mvm_rx_stored_beacon_notif(struct iwl_mvm *mvm,
1641 struct iwl_rx_cmd_buffer *rxb)
1643 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1644 unsigned int pkt_len = iwl_rx_packet_payload_len(pkt);
1645 struct iwl_stored_beacon_notif_common *sb = (void *)pkt->data;
1646 struct ieee80211_rx_status rx_status;
1647 struct sk_buff *skb;
1649 u32 size = le32_to_cpu(sb->byte_count);
1650 int ver = iwl_fw_lookup_cmd_ver(mvm->fw,
1651 WIDE_ID(PROT_OFFLOAD_GROUP, STORED_BEACON_NTF),
1657 /* handle per-version differences */
1659 struct iwl_stored_beacon_notif_v2 *sb_v2 = (void *)pkt->data;
1661 if (pkt_len < struct_size(sb_v2, data, size))
1666 struct iwl_stored_beacon_notif_v3 *sb_v3 = (void *)pkt->data;
1668 if (pkt_len < struct_size(sb_v3, data, size))
1674 skb = alloc_skb(size, GFP_ATOMIC);
1676 IWL_ERR(mvm, "alloc_skb failed\n");
1680 /* update rx_status according to the notification's metadata */
1681 memset(&rx_status, 0, sizeof(rx_status));
1682 rx_status.mactime = le64_to_cpu(sb->tsf);
1683 /* TSF as indicated by the firmware is at INA time */
1684 rx_status.flag |= RX_FLAG_MACTIME_PLCP_START;
1685 rx_status.device_timestamp = le32_to_cpu(sb->system_time);
1687 (sb->band & cpu_to_le16(RX_RES_PHY_FLAGS_BAND_24)) ?
1688 NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
1690 ieee80211_channel_to_frequency(le16_to_cpu(sb->channel),
1694 skb_put_data(skb, data, size);
1695 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
1697 /* pass it as regular rx to mac80211 */
1698 ieee80211_rx_napi(mvm->hw, NULL, skb, NULL);
1701 void iwl_mvm_probe_resp_data_notif(struct iwl_mvm *mvm,
1702 struct iwl_rx_cmd_buffer *rxb)
1704 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1705 struct iwl_probe_resp_data_notif *notif = (void *)pkt->data;
1706 struct iwl_probe_resp_data *old_data, *new_data;
1707 u32 id = le32_to_cpu(notif->mac_id);
1708 struct ieee80211_vif *vif;
1709 struct iwl_mvm_vif *mvmvif;
1711 IWL_DEBUG_INFO(mvm, "Probe response data notif: noa %d, csa %d\n",
1712 notif->noa_active, notif->csa_counter);
1714 vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, false);
1718 mvmvif = iwl_mvm_vif_from_mac80211(vif);
1720 new_data = kzalloc(sizeof(*new_data), GFP_KERNEL);
1724 memcpy(&new_data->notif, notif, sizeof(new_data->notif));
1726 /* noa_attr contains 1 reserved byte, need to substruct it */
1727 new_data->noa_len = sizeof(struct ieee80211_vendor_ie) +
1728 sizeof(new_data->notif.noa_attr) - 1;
1731 * If it's a one time NoA, only one descriptor is needed,
1732 * adjust the length according to len_low.
1734 if (new_data->notif.noa_attr.len_low ==
1735 sizeof(struct ieee80211_p2p_noa_desc) + 2)
1736 new_data->noa_len -= sizeof(struct ieee80211_p2p_noa_desc);
1738 old_data = rcu_dereference_protected(mvmvif->deflink.probe_resp_data,
1739 lockdep_is_held(&mvmvif->mvm->mutex));
1740 rcu_assign_pointer(mvmvif->deflink.probe_resp_data, new_data);
1743 kfree_rcu(old_data, rcu_head);
1745 if (notif->csa_counter != IWL_PROBE_RESP_DATA_NO_CSA &&
1746 notif->csa_counter >= 1)
1747 ieee80211_beacon_set_cntdwn(vif, notif->csa_counter);
1750 void iwl_mvm_channel_switch_start_notif(struct iwl_mvm *mvm,
1751 struct iwl_rx_cmd_buffer *rxb)
1753 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1754 struct ieee80211_vif *csa_vif, *vif;
1755 struct iwl_mvm_vif *mvmvif, *csa_mvmvif;
1756 u32 id_n_color, csa_id;
1757 /* save mac_id or link_id to use later to cancel csa if needed */
1759 u8 notif_ver = iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
1760 CHANNEL_SWITCH_START_NOTIF, 0);
1764 if (notif_ver < 3) {
1765 struct iwl_channel_switch_start_notif_v1 *notif = (void *)pkt->data;
1768 id_n_color = le32_to_cpu(notif->id_and_color);
1769 mac_id = id_n_color & FW_CTXT_ID_MSK;
1771 vif = iwl_mvm_rcu_dereference_vif_id(mvm, mac_id, true);
1777 struct iwl_channel_switch_start_notif *notif = (void *)pkt->data;
1778 u32 link_id = le32_to_cpu(notif->link_id);
1779 struct ieee80211_bss_conf *bss_conf =
1780 iwl_mvm_rcu_fw_link_id_to_link_conf(mvm, link_id, true);
1786 vif = bss_conf->vif;
1789 mvmvif = iwl_mvm_vif_from_mac80211(vif);
1791 id_n_color = FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color);
1793 switch (vif->type) {
1794 case NL80211_IFTYPE_AP:
1795 csa_vif = rcu_dereference(mvm->csa_vif);
1796 if (WARN_ON(!csa_vif || !csa_vif->bss_conf.csa_active ||
1800 csa_mvmvif = iwl_mvm_vif_from_mac80211(csa_vif);
1801 csa_id = FW_CMD_ID_AND_COLOR(csa_mvmvif->id, csa_mvmvif->color);
1802 if (WARN(csa_id != id_n_color,
1803 "channel switch noa notification on unexpected vif (csa_vif=%d, notif=%d)",
1804 csa_id, id_n_color))
1807 IWL_DEBUG_INFO(mvm, "Channel Switch Started Notification\n");
1809 schedule_delayed_work(&mvm->cs_tx_unblock_dwork,
1810 msecs_to_jiffies(IWL_MVM_CS_UNBLOCK_TX_TIMEOUT *
1811 csa_vif->bss_conf.beacon_int));
1813 ieee80211_csa_finish(csa_vif);
1817 RCU_INIT_POINTER(mvm->csa_vif, NULL);
1819 case NL80211_IFTYPE_STATION:
1821 * if we don't know about an ongoing channel switch,
1822 * make sure FW cancels it
1824 if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP,
1825 CHANNEL_SWITCH_ERROR_NOTIF,
1826 0) && !vif->bss_conf.csa_active) {
1827 IWL_DEBUG_INFO(mvm, "Channel Switch was canceled\n");
1828 iwl_mvm_cancel_channel_switch(mvm, vif, id);
1832 iwl_mvm_csa_client_absent(mvm, vif);
1833 cancel_delayed_work(&mvmvif->csa_work);
1834 ieee80211_chswitch_done(vif, true);
1837 /* should never happen */
1845 void iwl_mvm_channel_switch_error_notif(struct iwl_mvm *mvm,
1846 struct iwl_rx_cmd_buffer *rxb)
1848 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1849 struct iwl_channel_switch_error_notif *notif = (void *)pkt->data;
1850 struct ieee80211_vif *vif;
1851 u32 id = le32_to_cpu(notif->link_id);
1852 u32 csa_err_mask = le32_to_cpu(notif->csa_err_mask);
1855 vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
1861 IWL_DEBUG_INFO(mvm, "FW reports CSA error: id=%u, csa_err_mask=%u\n",
1863 if (csa_err_mask & (CS_ERR_COUNT_ERROR |
1864 CS_ERR_LONG_DELAY_AFTER_CS |
1865 CS_ERR_TX_BLOCK_TIMER_EXPIRED))
1866 ieee80211_channel_switch_disconnect(vif, true);
1870 void iwl_mvm_rx_missed_vap_notif(struct iwl_mvm *mvm,
1871 struct iwl_rx_cmd_buffer *rxb)
1873 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1874 struct iwl_missed_vap_notif *mb = (void *)pkt->data;
1875 struct ieee80211_vif *vif;
1876 u32 id = le32_to_cpu(mb->mac_id);
1879 "missed_vap notify mac_id=%u, num_beacon_intervals_elapsed=%u, profile_periodicity=%u\n",
1880 le32_to_cpu(mb->mac_id),
1881 mb->num_beacon_intervals_elapsed,
1882 mb->profile_periodicity);
1886 vif = iwl_mvm_rcu_dereference_vif_id(mvm, id, true);
1888 iwl_mvm_connection_loss(mvm, vif, "missed vap beacon");