Lines Matching +full:rates +full:- +full:cck
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5 * Copyright (C) 2015-2017 Intel Deutschland GmbH
10 #include "iwl-io.h"
11 #include "iwl-prph.h"
12 #include "fw-api.h"
14 #include "time-event.h"
51 if (vif == data->vif) in iwl_mvm_mac_tsf_id_iter()
70 switch (data->vif->type) { in iwl_mvm_mac_tsf_id_iter()
80 if (vif->type != NL80211_IFTYPE_AP || in iwl_mvm_mac_tsf_id_iter()
81 data->preferred_tsf != NUM_TSF_IDS || in iwl_mvm_mac_tsf_id_iter()
82 !test_bit(mvmvif->tsf_id, data->available_tsf_ids)) in iwl_mvm_mac_tsf_id_iter()
85 min_bi = min(data->vif->bss_conf.beacon_int, in iwl_mvm_mac_tsf_id_iter()
86 vif->bss_conf.beacon_int); in iwl_mvm_mac_tsf_id_iter()
91 if ((data->vif->bss_conf.beacon_int - in iwl_mvm_mac_tsf_id_iter()
92 vif->bss_conf.beacon_int) % min_bi == 0) { in iwl_mvm_mac_tsf_id_iter()
93 data->preferred_tsf = mvmvif->tsf_id; in iwl_mvm_mac_tsf_id_iter()
108 if ((vif->type != NL80211_IFTYPE_AP && in iwl_mvm_mac_tsf_id_iter()
109 vif->type != NL80211_IFTYPE_STATION) || in iwl_mvm_mac_tsf_id_iter()
110 data->preferred_tsf != NUM_TSF_IDS || in iwl_mvm_mac_tsf_id_iter()
111 !test_bit(mvmvif->tsf_id, data->available_tsf_ids)) in iwl_mvm_mac_tsf_id_iter()
114 min_bi = min(data->vif->bss_conf.beacon_int, in iwl_mvm_mac_tsf_id_iter()
115 vif->bss_conf.beacon_int); in iwl_mvm_mac_tsf_id_iter()
120 if ((data->vif->bss_conf.beacon_int - in iwl_mvm_mac_tsf_id_iter()
121 vif->bss_conf.beacon_int) % min_bi == 0) { in iwl_mvm_mac_tsf_id_iter()
122 data->preferred_tsf = mvmvif->tsf_id; in iwl_mvm_mac_tsf_id_iter()
143 __clear_bit(mvmvif->tsf_id, data->available_tsf_ids); in iwl_mvm_mac_tsf_id_iter()
145 if (data->preferred_tsf == mvmvif->tsf_id) in iwl_mvm_mac_tsf_id_iter()
146 data->preferred_tsf = NUM_TSF_IDS; in iwl_mvm_mac_tsf_id_iter()
155 /* Iterator may already find the interface being added -- skip it */ in iwl_mvm_mac_iface_iterator()
156 if (vif == data->vif) { in iwl_mvm_mac_iface_iterator()
157 data->found_vif = true; in iwl_mvm_mac_iface_iterator()
167 __clear_bit(mvmvif->id, data->available_mac_ids); in iwl_mvm_mac_iface_iterator()
180 .available_tsf_ids = { (1 << NUM_TSF_IDS) - 1 }, in iwl_mvm_mac_ctxt_recalc_tsf_id()
186 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in iwl_mvm_mac_ctxt_recalc_tsf_id()
190 mvmvif->tsf_id = data.preferred_tsf; in iwl_mvm_mac_ctxt_recalc_tsf_id()
191 else if (!test_bit(mvmvif->tsf_id, data.available_tsf_ids)) in iwl_mvm_mac_ctxt_recalc_tsf_id()
192 mvmvif->tsf_id = find_first_bit(data.available_tsf_ids, in iwl_mvm_mac_ctxt_recalc_tsf_id()
202 .available_mac_ids = { (1 << NUM_MAC_INDEX_DRIVER) - 1 }, in iwl_mvm_mac_ctxt_init()
203 .available_tsf_ids = { (1 << NUM_TSF_IDS) - 1 }, in iwl_mvm_mac_ctxt_init()
210 lockdep_assert_held(&mvm->mutex); in iwl_mvm_mac_ctxt_init()
229 switch (vif->type) { in iwl_mvm_mac_ctxt_init()
233 if (!vif->p2p) in iwl_mvm_mac_ctxt_init()
241 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in iwl_mvm_mac_ctxt_init()
258 if (WARN_ON_ONCE(test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))) in iwl_mvm_mac_ctxt_init()
259 return -EBUSY; in iwl_mvm_mac_ctxt_init()
261 mvmvif->id = find_first_bit(data.available_mac_ids, in iwl_mvm_mac_ctxt_init()
263 if (mvmvif->id == NUM_MAC_INDEX_DRIVER) { in iwl_mvm_mac_ctxt_init()
264 IWL_ERR(mvm, "Failed to init MAC context - no free ID!\n"); in iwl_mvm_mac_ctxt_init()
265 ret = -EIO; in iwl_mvm_mac_ctxt_init()
270 mvmvif->tsf_id = data.preferred_tsf; in iwl_mvm_mac_ctxt_init()
272 mvmvif->tsf_id = find_first_bit(data.available_tsf_ids, in iwl_mvm_mac_ctxt_init()
274 if (mvmvif->tsf_id == NUM_TSF_IDS) { in iwl_mvm_mac_ctxt_init()
275 IWL_ERR(mvm, "Failed to init MAC context - no free TSF!\n"); in iwl_mvm_mac_ctxt_init()
276 ret = -EIO; in iwl_mvm_mac_ctxt_init()
280 mvmvif->color = 0; in iwl_mvm_mac_ctxt_init()
282 INIT_LIST_HEAD(&mvmvif->time_event_data.list); in iwl_mvm_mac_ctxt_init()
283 mvmvif->time_event_data.id = TE_MAX; in iwl_mvm_mac_ctxt_init()
286 if (vif->type == NL80211_IFTYPE_P2P_DEVICE) in iwl_mvm_mac_ctxt_init()
290 if (vif->type == NL80211_IFTYPE_AP || in iwl_mvm_mac_ctxt_init()
291 vif->type == NL80211_IFTYPE_ADHOC) { in iwl_mvm_mac_ctxt_init()
296 mvmvif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE; in iwl_mvm_mac_ctxt_init()
299 mvmvif->bcast_sta.sta_id = IWL_MVM_INVALID_STA; in iwl_mvm_mac_ctxt_init()
300 mvmvif->mcast_sta.sta_id = IWL_MVM_INVALID_STA; in iwl_mvm_mac_ctxt_init()
301 mvmvif->ap_sta_id = IWL_MVM_INVALID_STA; in iwl_mvm_mac_ctxt_init()
304 mvmvif->smps_requests[i] = IEEE80211_SMPS_AUTOMATIC; in iwl_mvm_mac_ctxt_init()
319 unsigned long basic = vif->bss_conf.basic_rates; in iwl_mvm_ack_rates()
322 u8 cck = 0; in iwl_mvm_ack_rates() local
326 sband = mvm->hw->wiphy->bands[band]; in iwl_mvm_ack_rates()
329 int hw = sband->bitrates[i].hw_value; in iwl_mvm_ack_rates()
331 ofdm |= BIT(hw - IWL_FIRST_OFDM_RATE); in iwl_mvm_ack_rates()
337 cck |= BIT(hw); in iwl_mvm_ack_rates()
344 * Now we've got the basic rates as bitmaps in the ofdm and cck in iwl_mvm_ack_rates()
346 * be all the right rates in the bitmap. E.g. if the only basic in iwl_mvm_ack_rates()
347 * rates are 5.5 Mbps and 11 Mbps, we still need to add 1 Mbps in iwl_mvm_ack_rates()
348 * and 6 Mbps because the 802.11-2007 standard says in 9.6: in iwl_mvm_ack_rates()
362 * As a consequence, we need to add all mandatory rates that are in iwl_mvm_ack_rates()
363 * lower than all of the basic rates to these bitmaps. in iwl_mvm_ack_rates()
374 * CCK is a bit more complex with DSSS vs. HR/DSSS vs. ERP. in iwl_mvm_ack_rates()
376 * - if no CCK rates are basic, it must be ERP since there must in iwl_mvm_ack_rates()
377 * be some basic rates at all, so they're OFDM => ERP PHY in iwl_mvm_ack_rates()
378 * (or we're in 5 GHz, and the cck bitmap will never be used) in iwl_mvm_ack_rates()
379 * - if 11M is a basic rate, it must be ERP as well, so add 5.5M in iwl_mvm_ack_rates()
380 * - if 5.5M is basic, 1M and 2M are mandatory in iwl_mvm_ack_rates()
381 * - if 2M is basic, 1M is mandatory in iwl_mvm_ack_rates()
382 * - if 1M is basic, that's the only valid ACK rate. in iwl_mvm_ack_rates()
384 * any lower rates to the ACK rate bitmap. in iwl_mvm_ack_rates()
387 cck |= IWL_RATE_BIT_MSK(11) >> IWL_FIRST_CCK_RATE; in iwl_mvm_ack_rates()
389 cck |= IWL_RATE_BIT_MSK(5) >> IWL_FIRST_CCK_RATE; in iwl_mvm_ack_rates()
391 cck |= IWL_RATE_BIT_MSK(2) >> IWL_FIRST_CCK_RATE; in iwl_mvm_ack_rates()
393 cck |= IWL_RATE_BIT_MSK(1) >> IWL_FIRST_CCK_RATE; in iwl_mvm_ack_rates()
395 *cck_rates = cck; in iwl_mvm_ack_rates()
404 u8 protection_mode = vif->bss_conf.ht_operation_mode & in iwl_mvm_mac_ctxt_set_ht_flags()
411 * See section 9.23.3.1 of IEEE 80211-2012. in iwl_mvm_mac_ctxt_set_ht_flags()
419 cmd->protection_flags |= cpu_to_le32(ht_flag); in iwl_mvm_mac_ctxt_set_ht_flags()
423 if (vif->bss_conf.chandef.width > NL80211_CHAN_WIDTH_20) in iwl_mvm_mac_ctxt_set_ht_flags()
424 cmd->protection_flags |= cpu_to_le32(ht_flag); in iwl_mvm_mac_ctxt_set_ht_flags()
441 bool ht_enabled = !!(vif->bss_conf.ht_operation_mode & in iwl_mvm_mac_ctxt_cmd_common()
444 const u8 *bssid = bssid_override ?: vif->bss_conf.bssid; in iwl_mvm_mac_ctxt_cmd_common()
447 cmd->id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_mac_ctxt_cmd_common()
448 mvmvif->color)); in iwl_mvm_mac_ctxt_cmd_common()
449 cmd->action = cpu_to_le32(action); in iwl_mvm_mac_ctxt_cmd_common()
451 switch (vif->type) { in iwl_mvm_mac_ctxt_cmd_common()
453 if (vif->p2p) in iwl_mvm_mac_ctxt_cmd_common()
454 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_P2P_STA); in iwl_mvm_mac_ctxt_cmd_common()
456 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_BSS_STA); in iwl_mvm_mac_ctxt_cmd_common()
459 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_GO); in iwl_mvm_mac_ctxt_cmd_common()
462 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_LISTENER); in iwl_mvm_mac_ctxt_cmd_common()
465 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_P2P_DEVICE); in iwl_mvm_mac_ctxt_cmd_common()
468 cmd->mac_type = cpu_to_le32(FW_MAC_TYPE_IBSS); in iwl_mvm_mac_ctxt_cmd_common()
474 cmd->tsf_id = cpu_to_le32(mvmvif->tsf_id); in iwl_mvm_mac_ctxt_cmd_common()
476 memcpy(cmd->node_addr, vif->addr, ETH_ALEN); in iwl_mvm_mac_ctxt_cmd_common()
479 memcpy(cmd->bssid_addr, bssid, ETH_ALEN); in iwl_mvm_mac_ctxt_cmd_common()
481 eth_broadcast_addr(cmd->bssid_addr); in iwl_mvm_mac_ctxt_cmd_common()
484 chanctx = rcu_dereference(vif->bss_conf.chanctx_conf); in iwl_mvm_mac_ctxt_cmd_common()
485 iwl_mvm_ack_rates(mvm, vif, chanctx ? chanctx->def.chan->band in iwl_mvm_mac_ctxt_cmd_common()
490 cmd->cck_rates = cpu_to_le32((u32)cck_ack_rates); in iwl_mvm_mac_ctxt_cmd_common()
491 cmd->ofdm_rates = cpu_to_le32((u32)ofdm_ack_rates); in iwl_mvm_mac_ctxt_cmd_common()
493 cmd->cck_short_preamble = in iwl_mvm_mac_ctxt_cmd_common()
494 cpu_to_le32(vif->bss_conf.use_short_preamble ? in iwl_mvm_mac_ctxt_cmd_common()
496 cmd->short_slot = in iwl_mvm_mac_ctxt_cmd_common()
497 cpu_to_le32(vif->bss_conf.use_short_slot ? in iwl_mvm_mac_ctxt_cmd_common()
500 cmd->filter_flags = 0; in iwl_mvm_mac_ctxt_cmd_common()
506 cmd->ac[ucode_ac].cw_min = in iwl_mvm_mac_ctxt_cmd_common()
507 cpu_to_le16(mvmvif->queue_params[i].cw_min); in iwl_mvm_mac_ctxt_cmd_common()
508 cmd->ac[ucode_ac].cw_max = in iwl_mvm_mac_ctxt_cmd_common()
509 cpu_to_le16(mvmvif->queue_params[i].cw_max); in iwl_mvm_mac_ctxt_cmd_common()
510 cmd->ac[ucode_ac].edca_txop = in iwl_mvm_mac_ctxt_cmd_common()
511 cpu_to_le16(mvmvif->queue_params[i].txop * 32); in iwl_mvm_mac_ctxt_cmd_common()
512 cmd->ac[ucode_ac].aifsn = mvmvif->queue_params[i].aifs; in iwl_mvm_mac_ctxt_cmd_common()
513 cmd->ac[ucode_ac].fifos_mask = BIT(txf); in iwl_mvm_mac_ctxt_cmd_common()
516 if (vif->bss_conf.qos) in iwl_mvm_mac_ctxt_cmd_common()
517 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA); in iwl_mvm_mac_ctxt_cmd_common()
519 if (vif->bss_conf.use_cts_prot) in iwl_mvm_mac_ctxt_cmd_common()
520 cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT); in iwl_mvm_mac_ctxt_cmd_common()
523 vif->bss_conf.use_cts_prot, in iwl_mvm_mac_ctxt_cmd_common()
524 vif->bss_conf.ht_operation_mode); in iwl_mvm_mac_ctxt_cmd_common()
525 if (vif->bss_conf.chandef.width != NL80211_CHAN_WIDTH_20_NOHT) in iwl_mvm_mac_ctxt_cmd_common()
526 cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_TGN); in iwl_mvm_mac_ctxt_cmd_common()
538 le32_to_cpu(cmd->action), ret); in iwl_mvm_mac_ctxt_send_cmd()
550 WARN_ON(vif->type != NL80211_IFTYPE_STATION); in iwl_mvm_mac_ctxt_cmd_sta()
561 if (vif->p2p) { in iwl_mvm_mac_ctxt_cmd_sta()
563 &vif->bss_conf.p2p_noa_attr; in iwl_mvm_mac_ctxt_cmd_sta()
565 cmd.p2p_sta.ctwin = cpu_to_le32(noa->oppps_ctwindow & in iwl_mvm_mac_ctxt_cmd_sta()
573 if (vif->cfg.assoc && vif->bss_conf.dtim_period && in iwl_mvm_mac_ctxt_cmd_sta()
586 * same offset in the frame -- the TSF is at the first symbol in iwl_mvm_mac_ctxt_cmd_sta()
593 dtim_offs = vif->bss_conf.sync_dtim_count * in iwl_mvm_mac_ctxt_cmd_sta()
594 vif->bss_conf.beacon_int; in iwl_mvm_mac_ctxt_cmd_sta()
598 ctxt_sta->dtim_tsf = in iwl_mvm_mac_ctxt_cmd_sta()
599 cpu_to_le64(vif->bss_conf.sync_tsf + dtim_offs); in iwl_mvm_mac_ctxt_cmd_sta()
600 ctxt_sta->dtim_time = in iwl_mvm_mac_ctxt_cmd_sta()
601 cpu_to_le32(vif->bss_conf.sync_device_ts + dtim_offs); in iwl_mvm_mac_ctxt_cmd_sta()
602 ctxt_sta->assoc_beacon_arrive_time = in iwl_mvm_mac_ctxt_cmd_sta()
603 cpu_to_le32(vif->bss_conf.sync_device_ts); in iwl_mvm_mac_ctxt_cmd_sta()
606 le64_to_cpu(ctxt_sta->dtim_tsf), in iwl_mvm_mac_ctxt_cmd_sta()
607 le32_to_cpu(ctxt_sta->dtim_time), in iwl_mvm_mac_ctxt_cmd_sta()
610 ctxt_sta->is_assoc = cpu_to_le32(1); in iwl_mvm_mac_ctxt_cmd_sta()
612 if (!mvmvif->authorized && in iwl_mvm_mac_ctxt_cmd_sta()
613 fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_mac_ctxt_cmd_sta()
615 ctxt_sta->data_policy |= in iwl_mvm_mac_ctxt_cmd_sta()
618 ctxt_sta->is_assoc = cpu_to_le32(0); in iwl_mvm_mac_ctxt_cmd_sta()
626 ctxt_sta->bi = cpu_to_le32(vif->bss_conf.beacon_int); in iwl_mvm_mac_ctxt_cmd_sta()
627 ctxt_sta->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int * in iwl_mvm_mac_ctxt_cmd_sta()
628 vif->bss_conf.dtim_period); in iwl_mvm_mac_ctxt_cmd_sta()
630 ctxt_sta->listen_interval = cpu_to_le32(mvm->hw->conf.listen_interval); in iwl_mvm_mac_ctxt_cmd_sta()
631 ctxt_sta->assoc_id = cpu_to_le32(vif->cfg.aid); in iwl_mvm_mac_ctxt_cmd_sta()
633 if (vif->probe_req_reg && vif->cfg.assoc && vif->p2p) in iwl_mvm_mac_ctxt_cmd_sta()
636 if (vif->bss_conf.he_support && !iwlwifi_mod_params.disable_11ax) { in iwl_mvm_mac_ctxt_cmd_sta()
638 if (vif->bss_conf.twt_requester && IWL_MVM_USE_TWT) in iwl_mvm_mac_ctxt_cmd_sta()
639 ctxt_sta->data_policy |= cpu_to_le32(TWT_SUPPORTED); in iwl_mvm_mac_ctxt_cmd_sta()
640 if (vif->bss_conf.twt_protected) in iwl_mvm_mac_ctxt_cmd_sta()
641 ctxt_sta->data_policy |= in iwl_mvm_mac_ctxt_cmd_sta()
643 if (vif->bss_conf.twt_broadcast) in iwl_mvm_mac_ctxt_cmd_sta()
644 ctxt_sta->data_policy |= in iwl_mvm_mac_ctxt_cmd_sta()
657 u32 tfd_queue_msk = BIT(mvm->snif_queue); in iwl_mvm_mac_ctxt_cmd_listener()
660 WARN_ON(vif->type != NL80211_IFTYPE_MONITOR); in iwl_mvm_mac_ctxt_cmd_listener()
670 ieee80211_hw_set(mvm->hw, RX_INCLUDES_FCS); in iwl_mvm_mac_ctxt_cmd_listener()
673 ret = iwl_mvm_allocate_int_sta(mvm, &mvm->snif_sta, tfd_queue_msk, in iwl_mvm_mac_ctxt_cmd_listener()
674 vif->type, IWL_STA_GENERAL_PURPOSE); in iwl_mvm_mac_ctxt_cmd_listener()
688 WARN_ON(vif->type != NL80211_IFTYPE_ADHOC); in iwl_mvm_mac_ctxt_cmd_ibss()
697 cmd.ibss.bi = cpu_to_le32(vif->bss_conf.beacon_int); in iwl_mvm_mac_ctxt_cmd_ibss()
700 cmd.ibss.beacon_template = cpu_to_le32(mvmvif->id); in iwl_mvm_mac_ctxt_cmd_ibss()
714 if (vif->type == NL80211_IFTYPE_AP && vif->p2p && in iwl_mvm_go_iterator()
715 mvmvif->ap_ibss_active) in iwl_mvm_go_iterator()
716 data->go_active = true; in iwl_mvm_go_iterator()
726 WARN_ON(vif->type != NL80211_IFTYPE_P2P_DEVICE); in iwl_mvm_mac_ctxt_cmd_p2p_device()
742 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in iwl_mvm_mac_ctxt_cmd_p2p_device()
757 * variable-length part of the beacon. */ in iwl_mvm_mac_ctxt_set_tim()
758 tim_idx = mgmt->u.beacon.variable - beacon; in iwl_mvm_mac_ctxt_set_tim()
760 /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ in iwl_mvm_mac_ctxt_set_tim()
761 while ((tim_idx < (frame_size - 2)) && in iwl_mvm_mac_ctxt_set_tim()
766 if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { in iwl_mvm_mac_ctxt_set_tim()
779 if (WARN_ON_ONCE(frame_size <= (mgmt->u.beacon.variable - beacon))) in iwl_mvm_find_ie_offset()
782 frame_size -= mgmt->u.beacon.variable - beacon; in iwl_mvm_find_ie_offset()
784 ie = cfg80211_find_ie(eid, mgmt->u.beacon.variable, frame_size); in iwl_mvm_find_ie_offset()
788 return ie - beacon; in iwl_mvm_find_ie_offset()
795 if (info->band == NL80211_BAND_2GHZ && !vif->p2p) in iwl_mvm_mac_ctxt_get_lowest_rate()
828 tx->len = cpu_to_le16((u16)beacon->len); in iwl_mvm_mac_ctxt_set_tx()
829 tx->sta_id = mvmvif->bcast_sta.sta_id; in iwl_mvm_mac_ctxt_set_tx()
830 tx->life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE); in iwl_mvm_mac_ctxt_set_tx()
833 iwl_mvm_bt_coex_tx_prio(mvm, (void *)beacon->data, info, 0) << in iwl_mvm_mac_ctxt_set_tx()
835 tx->tx_flags = cpu_to_le32(tx_flags); in iwl_mvm_mac_ctxt_set_tx()
837 if (!fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_mac_ctxt_set_tx()
839 iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx); in iwl_mvm_mac_ctxt_set_tx()
841 tx->rate_n_flags = in iwl_mvm_mac_ctxt_set_tx()
842 cpu_to_le32(BIT(mvm->mgmt_last_antenna_idx) << in iwl_mvm_mac_ctxt_set_tx()
847 tx->rate_n_flags |= in iwl_mvm_mac_ctxt_set_tx()
848 cpu_to_le32(iwl_mvm_mac80211_idx_to_hwrate(mvm->fw, rate)); in iwl_mvm_mac_ctxt_set_tx()
850 tx->rate_n_flags |= cpu_to_le32(RATE_MCS_CCK_MSK_V1); in iwl_mvm_mac_ctxt_set_tx()
866 cmd.len[1] = beacon->len; in iwl_mvm_mac_ctxt_send_beacon_cmd()
867 cmd.data[1] = beacon->data; in iwl_mvm_mac_ctxt_send_beacon_cmd()
882 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id); in iwl_mvm_mac_ctxt_send_beacon_v6()
884 if (vif->type == NL80211_IFTYPE_AP) in iwl_mvm_mac_ctxt_send_beacon_v6()
887 beacon->data, beacon->len); in iwl_mvm_mac_ctxt_send_beacon_v6()
902 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id); in iwl_mvm_mac_ctxt_send_beacon_v7()
904 if (vif->type == NL80211_IFTYPE_AP) in iwl_mvm_mac_ctxt_send_beacon_v7()
907 beacon->data, beacon->len); in iwl_mvm_mac_ctxt_send_beacon_v7()
910 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data, in iwl_mvm_mac_ctxt_send_beacon_v7()
912 beacon->len)); in iwl_mvm_mac_ctxt_send_beacon_v7()
914 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data, in iwl_mvm_mac_ctxt_send_beacon_v7()
916 beacon->len)); in iwl_mvm_mac_ctxt_send_beacon_v7()
933 flags = iwl_mvm_mac_ctxt_get_beacon_flags(mvm->fw, rate); in iwl_mvm_mac_ctxt_send_beacon_v9()
937 ctx = rcu_dereference(vif->bss_conf.chanctx_conf); in iwl_mvm_mac_ctxt_send_beacon_v9()
938 channel = ieee80211_frequency_to_channel(ctx->def.chan->center_freq); in iwl_mvm_mac_ctxt_send_beacon_v9()
940 if (cfg80211_channel_is_psc(ctx->def.chan) && in iwl_mvm_mac_ctxt_send_beacon_v9()
942 flags |= iwl_fw_lookup_cmd_ver(mvm->fw, BEACON_TEMPLATE_CMD, in iwl_mvm_mac_ctxt_send_beacon_v9()
947 cpu_to_le32(~crc32_le(~0, vif->cfg.ssid, in iwl_mvm_mac_ctxt_send_beacon_v9()
948 vif->cfg.ssid_len)); in iwl_mvm_mac_ctxt_send_beacon_v9()
953 beacon_cmd.byte_cnt = cpu_to_le16((u16)beacon->len); in iwl_mvm_mac_ctxt_send_beacon_v9()
954 beacon_cmd.template_id = cpu_to_le32((u32)mvmvif->id); in iwl_mvm_mac_ctxt_send_beacon_v9()
956 if (vif->type == NL80211_IFTYPE_AP) in iwl_mvm_mac_ctxt_send_beacon_v9()
959 beacon->data, beacon->len); in iwl_mvm_mac_ctxt_send_beacon_v9()
962 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data, in iwl_mvm_mac_ctxt_send_beacon_v9()
964 beacon->len)); in iwl_mvm_mac_ctxt_send_beacon_v9()
966 cpu_to_le32(iwl_mvm_find_ie_offset(beacon->data, in iwl_mvm_mac_ctxt_send_beacon_v9()
968 beacon->len)); in iwl_mvm_mac_ctxt_send_beacon_v9()
979 return -EINVAL; in iwl_mvm_mac_ctxt_send_beacon()
984 if (!fw_has_capa(&mvm->fw->ucode_capa, in iwl_mvm_mac_ctxt_send_beacon()
988 if (fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_mac_ctxt_send_beacon()
1002 WARN_ON(vif->type != NL80211_IFTYPE_AP && in iwl_mvm_mac_ctxt_beacon_changed()
1003 vif->type != NL80211_IFTYPE_ADHOC); in iwl_mvm_mac_ctxt_beacon_changed()
1005 beacon = ieee80211_beacon_get_template(mvm->hw, vif, NULL, 0); in iwl_mvm_mac_ctxt_beacon_changed()
1007 return -ENOMEM; in iwl_mvm_mac_ctxt_beacon_changed()
1010 if (mvm->beacon_inject_active) { in iwl_mvm_mac_ctxt_beacon_changed()
1012 return -EBUSY; in iwl_mvm_mac_ctxt_beacon_changed()
1034 if (vif->type != NL80211_IFTYPE_STATION || !vif->cfg.assoc) in iwl_mvm_mac_ap_iterator()
1038 if (vif->p2p && data->beacon_device_ts) in iwl_mvm_mac_ap_iterator()
1041 data->beacon_device_ts = vif->bss_conf.sync_device_ts; in iwl_mvm_mac_ap_iterator()
1042 data->beacon_int = vif->bss_conf.beacon_int; in iwl_mvm_mac_ap_iterator()
1062 cmd->ac[IWL_MVM_TX_FIFO_VO].fifos_mask |= BIT(IWL_MVM_TX_FIFO_MCAST); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1068 * wake-ups. in iwl_mvm_mac_ctxt_cmd_fill_ap()
1070 cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1071 if (mvmvif->ap_assoc_sta_count || !mvm->drop_bcn_ap_mode) { in iwl_mvm_mac_ctxt_cmd_fill_ap()
1072 cmd->filter_flags |= cpu_to_le32(MAC_FILTER_IN_BEACON); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1078 ctxt_ap->bi = cpu_to_le32(vif->bss_conf.beacon_int); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1079 ctxt_ap->dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int * in iwl_mvm_mac_ctxt_cmd_fill_ap()
1080 vif->bss_conf.dtim_period); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1082 if (!fw_has_api(&mvm->fw->ucode_capa, in iwl_mvm_mac_ctxt_cmd_fill_ap()
1084 ctxt_ap->mcast_qid = cpu_to_le32(mvmvif->cab_queue); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1088 * just modify the MAC then we should keep the time -- the firmware in iwl_mvm_mac_ctxt_cmd_fill_ap()
1098 mvm->hw, IEEE80211_IFACE_ITER_RESUME_ALL, in iwl_mvm_mac_ctxt_cmd_fill_ap()
1102 u32 rand = prandom_u32_max(64 - 36) + 36; in iwl_mvm_mac_ctxt_cmd_fill_ap()
1103 mvmvif->ap_beacon_time = data.beacon_device_ts + in iwl_mvm_mac_ctxt_cmd_fill_ap()
1107 mvmvif->ap_beacon_time = iwl_mvm_get_systime(mvm); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1111 ctxt_ap->beacon_time = cpu_to_le32(mvmvif->ap_beacon_time); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1112 ctxt_ap->beacon_tsf = 0; /* unused */ in iwl_mvm_mac_ctxt_cmd_fill_ap()
1115 ctxt_ap->beacon_template = cpu_to_le32(mvmvif->id); in iwl_mvm_mac_ctxt_cmd_fill_ap()
1124 WARN_ON(vif->type != NL80211_IFTYPE_AP || vif->p2p); in iwl_mvm_mac_ctxt_cmd_ap()
1141 struct ieee80211_p2p_noa_attr *noa = &vif->bss_conf.p2p_noa_attr; in iwl_mvm_mac_ctxt_cmd_go()
1143 WARN_ON(vif->type != NL80211_IFTYPE_AP || !vif->p2p); in iwl_mvm_mac_ctxt_cmd_go()
1152 cmd.go.ctwin = cpu_to_le32(noa->oppps_ctwindow & in iwl_mvm_mac_ctxt_cmd_go()
1155 cpu_to_le32(!!(noa->oppps_ctwindow & in iwl_mvm_mac_ctxt_cmd_go()
1165 switch (vif->type) { in iwl_mvm_mac_ctx_send()
1171 if (!vif->p2p) in iwl_mvm_mac_ctx_send()
1185 return -EOPNOTSUPP; in iwl_mvm_mac_ctx_send()
1193 if (WARN_ONCE(mvmvif->uploaded, "Adding active MAC %pM/%d\n", in iwl_mvm_mac_ctxt_add()
1194 vif->addr, ieee80211_vif_type_p2p(vif))) in iwl_mvm_mac_ctxt_add()
1195 return -EIO; in iwl_mvm_mac_ctxt_add()
1205 mvmvif->uploaded = true; in iwl_mvm_mac_ctxt_add()
1214 if (WARN_ONCE(!mvmvif->uploaded, "Changing inactive MAC %pM/%d\n", in iwl_mvm_mac_ctxt_changed()
1215 vif->addr, ieee80211_vif_type_p2p(vif))) in iwl_mvm_mac_ctxt_changed()
1216 return -EIO; in iwl_mvm_mac_ctxt_changed()
1228 if (WARN_ONCE(!mvmvif->uploaded, "Removing inactive MAC %pM/%d\n", in iwl_mvm_mac_ctxt_remove()
1229 vif->addr, ieee80211_vif_type_p2p(vif))) in iwl_mvm_mac_ctxt_remove()
1230 return -EIO; in iwl_mvm_mac_ctxt_remove()
1234 cmd.id_and_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, in iwl_mvm_mac_ctxt_remove()
1235 mvmvif->color)); in iwl_mvm_mac_ctxt_remove()
1245 mvmvif->uploaded = false; in iwl_mvm_mac_ctxt_remove()
1247 if (vif->type == NL80211_IFTYPE_MONITOR) { in iwl_mvm_mac_ctxt_remove()
1248 __clear_bit(IEEE80211_HW_RX_INCLUDES_FCS, mvm->hw->flags); in iwl_mvm_mac_ctxt_remove()
1263 if (!tx_success && !mvmvif->csa_countdown) in iwl_mvm_csa_count_down()
1266 mvmvif->csa_countdown = true; in iwl_mvm_csa_count_down()
1272 if (csa_vif->p2p && in iwl_mvm_csa_count_down()
1273 !iwl_mvm_te_scheduled(&mvmvif->time_event_data) && gp2 && in iwl_mvm_csa_count_down()
1276 csa_vif->bss_conf.beacon_int - in iwl_mvm_csa_count_down()
1281 IWL_MVM_CHANNEL_SWITCH_TIME_GO - in iwl_mvm_csa_count_down()
1285 } else if (!iwl_mvm_te_scheduled(&mvmvif->time_event_data)) { in iwl_mvm_csa_count_down()
1288 RCU_INIT_POINTER(mvm->csa_vif, NULL); in iwl_mvm_csa_count_down()
1297 struct iwl_extended_beacon_notif *beacon = (void *)pkt->data; in iwl_mvm_rx_beacon_notif()
1298 struct iwl_extended_beacon_notif_v5 *beacon_v5 = (void *)pkt->data; in iwl_mvm_rx_beacon_notif()
1304 lockdep_assert_held(&mvm->mutex); in iwl_mvm_rx_beacon_notif()
1306 mvm->ap_last_beacon_gp2 = le32_to_cpu(beacon->gp2); in iwl_mvm_rx_beacon_notif()
1310 &beacon_v5->beacon_notify_hdr; in iwl_mvm_rx_beacon_notif()
1315 mvm->ibss_manager = beacon_v5->ibss_mgr_status != 0; in iwl_mvm_rx_beacon_notif()
1317 status = le16_to_cpu(agg_status->status) & TX_STATUS_MSK; in iwl_mvm_rx_beacon_notif()
1320 status, beacon_notify_hdr->failure_frame, in iwl_mvm_rx_beacon_notif()
1321 le64_to_cpu(beacon->tsf), in iwl_mvm_rx_beacon_notif()
1322 mvm->ap_last_beacon_gp2, in iwl_mvm_rx_beacon_notif()
1323 le32_to_cpu(beacon_notify_hdr->initial_rate)); in iwl_mvm_rx_beacon_notif()
1328 mvm->ibss_manager = beacon->ibss_mgr_status != 0; in iwl_mvm_rx_beacon_notif()
1329 status = le32_to_cpu(beacon->status) & TX_STATUS_MSK; in iwl_mvm_rx_beacon_notif()
1332 status, le64_to_cpu(beacon->tsf), in iwl_mvm_rx_beacon_notif()
1333 mvm->ap_last_beacon_gp2); in iwl_mvm_rx_beacon_notif()
1336 csa_vif = rcu_dereference_protected(mvm->csa_vif, in iwl_mvm_rx_beacon_notif()
1337 lockdep_is_held(&mvm->mutex)); in iwl_mvm_rx_beacon_notif()
1338 if (unlikely(csa_vif && csa_vif->bss_conf.csa_active)) in iwl_mvm_rx_beacon_notif()
1339 iwl_mvm_csa_count_down(mvm, csa_vif, mvm->ap_last_beacon_gp2, in iwl_mvm_rx_beacon_notif()
1342 tx_blocked_vif = rcu_dereference_protected(mvm->csa_tx_blocked_vif, in iwl_mvm_rx_beacon_notif()
1343 lockdep_is_held(&mvm->mutex)); in iwl_mvm_rx_beacon_notif()
1353 if (!mvm->csa_tx_block_bcn_timeout) in iwl_mvm_rx_beacon_notif()
1354 mvm->csa_tx_block_bcn_timeout = in iwl_mvm_rx_beacon_notif()
1357 mvm->csa_tx_block_bcn_timeout--; in iwl_mvm_rx_beacon_notif()
1360 if (mvm->csa_tx_block_bcn_timeout == 0) { in iwl_mvm_rx_beacon_notif()
1362 RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); in iwl_mvm_rx_beacon_notif()
1371 struct iwl_missed_beacons_notif *mb = (void *)pkt->data; in iwl_mvm_rx_missed_beacons_notif()
1377 u32 id = le32_to_cpu(mb->mac_id); in iwl_mvm_rx_missed_beacons_notif()
1382 le32_to_cpu(mb->mac_id), in iwl_mvm_rx_missed_beacons_notif()
1383 le32_to_cpu(mb->consec_missed_beacons), in iwl_mvm_rx_missed_beacons_notif()
1384 le32_to_cpu(mb->consec_missed_beacons_since_last_rx), in iwl_mvm_rx_missed_beacons_notif()
1385 le32_to_cpu(mb->num_recvd_beacons), in iwl_mvm_rx_missed_beacons_notif()
1386 le32_to_cpu(mb->num_expected_beacons)); in iwl_mvm_rx_missed_beacons_notif()
1394 rx_missed_bcon = le32_to_cpu(mb->consec_missed_beacons); in iwl_mvm_rx_missed_beacons_notif()
1396 le32_to_cpu(mb->consec_missed_beacons_since_last_rx); in iwl_mvm_rx_missed_beacons_notif()
1406 iwl_dbg_tlv_time_point(&mvm->fwrt, in iwl_mvm_rx_missed_beacons_notif()
1409 trigger = iwl_fw_dbg_trigger_on(&mvm->fwrt, ieee80211_vif_to_wdev(vif), in iwl_mvm_rx_missed_beacons_notif()
1414 bcon_trig = (void *)trigger->data; in iwl_mvm_rx_missed_beacons_notif()
1415 stop_trig_missed_bcon = le32_to_cpu(bcon_trig->stop_consec_missed_bcon); in iwl_mvm_rx_missed_beacons_notif()
1417 le32_to_cpu(bcon_trig->stop_consec_missed_bcon_since_rx); in iwl_mvm_rx_missed_beacons_notif()
1423 iwl_fw_dbg_collect_trig(&mvm->fwrt, trigger, NULL); in iwl_mvm_rx_missed_beacons_notif()
1434 struct iwl_stored_beacon_notif_common *sb = (void *)pkt->data; in iwl_mvm_rx_stored_beacon_notif()
1438 u32 size = le32_to_cpu(sb->byte_count); in iwl_mvm_rx_stored_beacon_notif()
1439 int ver = iwl_fw_lookup_cmd_ver(mvm->fw, in iwl_mvm_rx_stored_beacon_notif()
1446 /* handle per-version differences */ in iwl_mvm_rx_stored_beacon_notif()
1448 struct iwl_stored_beacon_notif_v2 *sb_v2 = (void *)pkt->data; in iwl_mvm_rx_stored_beacon_notif()
1453 data = sb_v2->data; in iwl_mvm_rx_stored_beacon_notif()
1455 struct iwl_stored_beacon_notif_v3 *sb_v3 = (void *)pkt->data; in iwl_mvm_rx_stored_beacon_notif()
1460 data = sb_v3->data; in iwl_mvm_rx_stored_beacon_notif()
1471 rx_status.mactime = le64_to_cpu(sb->tsf); in iwl_mvm_rx_stored_beacon_notif()
1474 rx_status.device_timestamp = le32_to_cpu(sb->system_time); in iwl_mvm_rx_stored_beacon_notif()
1476 (sb->band & cpu_to_le16(RX_RES_PHY_FLAGS_BAND_24)) ? in iwl_mvm_rx_stored_beacon_notif()
1479 ieee80211_channel_to_frequency(le16_to_cpu(sb->channel), in iwl_mvm_rx_stored_beacon_notif()
1487 ieee80211_rx_napi(mvm->hw, NULL, skb, NULL); in iwl_mvm_rx_stored_beacon_notif()
1494 struct iwl_probe_resp_data_notif *notif = (void *)pkt->data; in iwl_mvm_probe_resp_data_notif()
1496 u32 id = le32_to_cpu(notif->mac_id); in iwl_mvm_probe_resp_data_notif()
1501 notif->noa_active, notif->csa_counter); in iwl_mvm_probe_resp_data_notif()
1513 memcpy(&new_data->notif, notif, sizeof(new_data->notif)); in iwl_mvm_probe_resp_data_notif()
1516 new_data->noa_len = sizeof(struct ieee80211_vendor_ie) + in iwl_mvm_probe_resp_data_notif()
1517 sizeof(new_data->notif.noa_attr) - 1; in iwl_mvm_probe_resp_data_notif()
1523 if (new_data->notif.noa_attr.len_low == in iwl_mvm_probe_resp_data_notif()
1525 new_data->noa_len -= sizeof(struct ieee80211_p2p_noa_desc); in iwl_mvm_probe_resp_data_notif()
1527 old_data = rcu_dereference_protected(mvmvif->probe_resp_data, in iwl_mvm_probe_resp_data_notif()
1528 lockdep_is_held(&mvmvif->mvm->mutex)); in iwl_mvm_probe_resp_data_notif()
1529 rcu_assign_pointer(mvmvif->probe_resp_data, new_data); in iwl_mvm_probe_resp_data_notif()
1534 if (notif->csa_counter != IWL_PROBE_RESP_DATA_NO_CSA && in iwl_mvm_probe_resp_data_notif()
1535 notif->csa_counter >= 1) in iwl_mvm_probe_resp_data_notif()
1536 ieee80211_beacon_set_cntdwn(vif, notif->csa_counter); in iwl_mvm_probe_resp_data_notif()
1543 struct iwl_channel_switch_start_notif *notif = (void *)pkt->data; in iwl_mvm_channel_switch_start_notif()
1548 id_n_color = le32_to_cpu(notif->id_and_color); in iwl_mvm_channel_switch_start_notif()
1555 vif = rcu_dereference(mvm->vif_id_to_mac[mac_id]); in iwl_mvm_channel_switch_start_notif()
1558 switch (vif->type) { in iwl_mvm_channel_switch_start_notif()
1560 csa_vif = rcu_dereference(mvm->csa_vif); in iwl_mvm_channel_switch_start_notif()
1561 if (WARN_ON(!csa_vif || !csa_vif->bss_conf.csa_active || in iwl_mvm_channel_switch_start_notif()
1565 csa_id = FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color); in iwl_mvm_channel_switch_start_notif()
1573 schedule_delayed_work(&mvm->cs_tx_unblock_dwork, in iwl_mvm_channel_switch_start_notif()
1575 csa_vif->bss_conf.beacon_int)); in iwl_mvm_channel_switch_start_notif()
1581 RCU_INIT_POINTER(mvm->csa_vif, NULL); in iwl_mvm_channel_switch_start_notif()
1588 if (iwl_fw_lookup_notif_ver(mvm->fw, MAC_CONF_GROUP, in iwl_mvm_channel_switch_start_notif()
1590 0) && !vif->bss_conf.csa_active) { in iwl_mvm_channel_switch_start_notif()
1597 cancel_delayed_work(&mvmvif->csa_work); in iwl_mvm_channel_switch_start_notif()
1613 struct iwl_channel_switch_error_notif *notif = (void *)pkt->data; in iwl_mvm_channel_switch_error_notif()
1615 u32 id = le32_to_cpu(notif->mac_id); in iwl_mvm_channel_switch_error_notif()
1616 u32 csa_err_mask = le32_to_cpu(notif->csa_err_mask); in iwl_mvm_channel_switch_error_notif()
1638 struct iwl_missed_vap_notif *mb = (void *)pkt->data; in iwl_mvm_rx_missed_vap_notif()
1640 u32 id = le32_to_cpu(mb->mac_id); in iwl_mvm_rx_missed_vap_notif()
1644 le32_to_cpu(mb->mac_id), in iwl_mvm_rx_missed_vap_notif()
1645 mb->num_beacon_intervals_elapsed, in iwl_mvm_rx_missed_vap_notif()
1646 mb->profile_periodicity); in iwl_mvm_rx_missed_vap_notif()