Lines Matching +full:assoc +full:- +full:select
1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
100 /* Operating Classes 131-135 */
241 #define ath12k_a_rates_size (ARRAY_SIZE(ath12k_legacy_rates) - 4)
270 return "11na-ht20"; in ath12k_mac_phymode_str()
272 return "11ng-ht20"; in ath12k_mac_phymode_str()
274 return "11na-ht40"; in ath12k_mac_phymode_str()
276 return "11ng-ht40"; in ath12k_mac_phymode_str()
278 return "11ac-vht20"; in ath12k_mac_phymode_str()
280 return "11ac-vht40"; in ath12k_mac_phymode_str()
282 return "11ac-vht80"; in ath12k_mac_phymode_str()
284 return "11ac-vht160"; in ath12k_mac_phymode_str()
286 return "11ac-vht80+80"; in ath12k_mac_phymode_str()
288 return "11ac-vht20-2g"; in ath12k_mac_phymode_str()
290 return "11ac-vht40-2g"; in ath12k_mac_phymode_str()
292 return "11ac-vht80-2g"; in ath12k_mac_phymode_str()
294 return "11ax-he20"; in ath12k_mac_phymode_str()
296 return "11ax-he40"; in ath12k_mac_phymode_str()
298 return "11ax-he80"; in ath12k_mac_phymode_str()
300 return "11ax-he80+80"; in ath12k_mac_phymode_str()
302 return "11ax-he160"; in ath12k_mac_phymode_str()
304 return "11ax-he20-2g"; in ath12k_mac_phymode_str()
306 return "11ax-he40-2g"; in ath12k_mac_phymode_str()
308 return "11ax-he80-2g"; in ath12k_mac_phymode_str()
310 return "11be-eht20"; in ath12k_mac_phymode_str()
312 return "11be-eht40"; in ath12k_mac_phymode_str()
314 return "11be-eht80"; in ath12k_mac_phymode_str()
316 return "11be-eht80+80"; in ath12k_mac_phymode_str()
318 return "11be-eht160"; in ath12k_mac_phymode_str()
320 return "11be-eht160+160"; in ath12k_mac_phymode_str()
322 return "11be-eht320"; in ath12k_mac_phymode_str()
324 return "11be-eht20-2g"; in ath12k_mac_phymode_str()
326 return "11be-eht40-2g"; in ath12k_mac_phymode_str()
405 return -EINVAL; in ath12k_mac_hw_ratecode_to_legacy_rate()
413 for (i = 0; i < sband->n_bitrates; i++) in ath12k_mac_bitrate_to_idx()
414 if (sband->bitrates[i].bitrate == bitrate) in ath12k_mac_bitrate_to_idx()
425 for (nss = IEEE80211_HT_MCS_MASK_LEN - 1; nss >= 0; nss--) in ath12k_mac_max_ht_nss()
437 for (nss = NL80211_VHT_NSS_MAX - 1; nss >= 0; nss--) in ath12k_mac_max_vht_nss()
446 /* From IEEE Std 802.11-2020 defined values for "Minimum MPDU Start Spacing": in ath12k_parse_mpdudensity()
485 conf = rcu_dereference(vif->bss_conf.chanctx_conf); in ath12k_mac_vif_chan()
488 return -ENOENT; in ath12k_mac_vif_chan()
491 *def = conf->def; in ath12k_mac_vif_chan()
516 for (i = 0; i < sband->n_bitrates; i++) { in ath12k_mac_hw_rate_to_idx()
517 rate = &sband->bitrates[i]; in ath12k_mac_hw_rate_to_idx()
519 if (ath12k_mac_bitrate_is_cck(rate->bitrate) != cck) in ath12k_mac_hw_rate_to_idx()
522 if (rate->hw_value == hw_rate) in ath12k_mac_hw_rate_to_idx()
524 else if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE && in ath12k_mac_hw_rate_to_idx()
525 rate->hw_value_short == hw_rate) in ath12k_mac_hw_rate_to_idx()
544 if (arvif->vdev_id == arvif_iter->vdev_id && in ath12k_get_arvif_iter()
545 arvif->ar == arvif_iter->ar) in ath12k_get_arvif_iter()
546 arvif_iter->arvif = arvif; in ath12k_get_arvif_iter()
563 ath12k_warn(ar->ab, "No VIF found for vdev %d\n", vdev_id); in ath12k_mac_get_arvif()
577 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_get_arvif_by_vdev_id()
578 pdev = rcu_dereference(ab->pdevs_active[i]); in ath12k_mac_get_arvif_by_vdev_id()
579 if (pdev && pdev->ar && in ath12k_mac_get_arvif_by_vdev_id()
580 (pdev->ar->allocated_vdev_map & (1LL << vdev_id))) { in ath12k_mac_get_arvif_by_vdev_id()
581 arvif = ath12k_mac_get_arvif(pdev->ar, vdev_id); in ath12k_mac_get_arvif_by_vdev_id()
595 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_get_ar_by_vdev_id()
596 pdev = rcu_dereference(ab->pdevs_active[i]); in ath12k_mac_get_ar_by_vdev_id()
597 if (pdev && pdev->ar) { in ath12k_mac_get_ar_by_vdev_id()
598 if (pdev->ar->allocated_vdev_map & (1LL << vdev_id)) in ath12k_mac_get_ar_by_vdev_id()
599 return pdev->ar; in ath12k_mac_get_ar_by_vdev_id()
611 if (ab->hw_params->single_pdev_only) { in ath12k_mac_get_ar_by_pdev_id()
612 pdev = rcu_dereference(ab->pdevs_active[0]); in ath12k_mac_get_ar_by_pdev_id()
613 return pdev ? pdev->ar : NULL; in ath12k_mac_get_ar_by_pdev_id()
616 if (WARN_ON(pdev_id > ab->num_radios)) in ath12k_mac_get_ar_by_pdev_id()
619 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_get_ar_by_pdev_id()
620 pdev = rcu_dereference(ab->pdevs_active[i]); in ath12k_mac_get_ar_by_pdev_id()
622 if (pdev && pdev->pdev_id == pdev_id) in ath12k_mac_get_ar_by_pdev_id()
623 return (pdev->ar ? pdev->ar : NULL); in ath12k_mac_get_ar_by_pdev_id()
632 struct ath12k_hw *ah = hw->priv; in ath12k_mac_get_ar_by_chan()
636 ar = ah->radio; in ath12k_mac_get_ar_by_chan()
638 if (ah->num_radio == 1) in ath12k_mac_get_ar_by_chan()
642 if (channel->center_freq >= ar->freq_low && in ath12k_mac_get_ar_by_chan()
643 channel->center_freq <= ar->freq_high) in ath12k_mac_get_ar_by_chan()
655 return ath12k_mac_get_ar_by_chan(hw, ctx->def.chan); in ath12k_get_ar_by_ctx()
667 if (ah->num_radio == 1) in ath12k_get_ar_by_vif()
668 return ah->radio; in ath12k_get_ar_by_vif()
670 if (arvif->is_created) in ath12k_get_ar_by_vif()
671 return arvif->ar; in ath12k_get_ar_by_vif()
680 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_get_vif_up()
681 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_mac_get_vif_up()
682 if (arvif->is_up) in ath12k_mac_get_vif_up()
710 struct ath12k *ar = arvif->ar; in ath12k_mac_get_target_pdev_id_from_vif()
711 struct ath12k_base *ab = ar->ab; in ath12k_mac_get_target_pdev_id_from_vif()
712 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_get_target_pdev_id_from_vif()
715 u8 pdev_id = ab->fw_pdev[0].pdev_id; in ath12k_mac_get_target_pdev_id_from_vif()
721 band = def.chan->band; in ath12k_mac_get_target_pdev_id_from_vif()
723 for (i = 0; i < ab->fw_pdev_count; i++) { in ath12k_mac_get_target_pdev_id_from_vif()
724 if (ath12k_mac_band_match(band, ab->fw_pdev[i].supported_bands)) in ath12k_mac_get_target_pdev_id_from_vif()
725 return ab->fw_pdev[i].pdev_id; in ath12k_mac_get_target_pdev_id_from_vif()
734 struct ath12k_base *ab = ar->ab; in ath12k_mac_get_target_pdev_id()
736 if (!ab->hw_params->single_pdev_only) in ath12k_mac_get_target_pdev_id()
737 return ar->pdev->pdev_id; in ath12k_mac_get_target_pdev_id()
746 return ar->ab->fw_pdev[0].pdev_id; in ath12k_mac_get_target_pdev_id()
754 struct ath12k_base *ab = ar->ab; in ath12k_pdev_caps_update()
756 ar->max_tx_power = ab->target_caps.hw_max_tx_power; in ath12k_pdev_caps_update()
758 /* FIXME: Set min_tx_power to ab->target_caps.hw_min_tx_power. in ath12k_pdev_caps_update()
760 * we can set ar->min_tx_power to 0 currently until in ath12k_pdev_caps_update()
763 ar->min_tx_power = 0; in ath12k_pdev_caps_update()
765 ar->txpower_limit_2g = ar->max_tx_power; in ath12k_pdev_caps_update()
766 ar->txpower_limit_5g = ar->max_tx_power; in ath12k_pdev_caps_update()
767 ar->txpower_scale = WMI_HOST_TP_SCALE_MAX; in ath12k_pdev_caps_update()
772 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_txpower_recalc()
774 int ret, txpower = -1; in ath12k_mac_txpower_recalc()
777 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_txpower_recalc()
779 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_mac_txpower_recalc()
780 if (arvif->txpower <= 0) in ath12k_mac_txpower_recalc()
783 if (txpower == -1) in ath12k_mac_txpower_recalc()
784 txpower = arvif->txpower; in ath12k_mac_txpower_recalc()
786 txpower = min(txpower, arvif->txpower); in ath12k_mac_txpower_recalc()
789 if (txpower == -1) in ath12k_mac_txpower_recalc()
793 txpower = min_t(u32, max_t(u32, ar->min_tx_power, txpower), in ath12k_mac_txpower_recalc()
794 ar->max_tx_power) * 2; in ath12k_mac_txpower_recalc()
796 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "txpower to set in hw %d\n", in ath12k_mac_txpower_recalc()
799 if ((pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) && in ath12k_mac_txpower_recalc()
800 ar->txpower_limit_2g != txpower) { in ath12k_mac_txpower_recalc()
803 txpower, ar->pdev->pdev_id); in ath12k_mac_txpower_recalc()
806 ar->txpower_limit_2g = txpower; in ath12k_mac_txpower_recalc()
809 if ((pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) && in ath12k_mac_txpower_recalc()
810 ar->txpower_limit_5g != txpower) { in ath12k_mac_txpower_recalc()
813 txpower, ar->pdev->pdev_id); in ath12k_mac_txpower_recalc()
816 ar->txpower_limit_5g = txpower; in ath12k_mac_txpower_recalc()
822 ath12k_warn(ar->ab, "failed to recalc txpower limit %d using pdev param %d: %d\n", in ath12k_mac_txpower_recalc()
829 struct ath12k *ar = arvif->ar; in ath12k_recalc_rtscts_prot()
833 lockdep_assert_held(&ar->conf_mutex); in ath12k_recalc_rtscts_prot()
843 if (arvif->num_legacy_stations > 0) in ath12k_recalc_rtscts_prot()
849 if (arvif->rtscts_prot_mode == rts_cts) in ath12k_recalc_rtscts_prot()
852 arvif->rtscts_prot_mode = rts_cts; in ath12k_recalc_rtscts_prot()
854 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d recalc rts/cts prot %d\n", in ath12k_recalc_rtscts_prot()
855 arvif->vdev_id, rts_cts); in ath12k_recalc_rtscts_prot()
857 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_recalc_rtscts_prot()
860 ath12k_warn(ar->ab, "failed to recalculate rts/cts prot for vdev %d: %d\n", in ath12k_recalc_rtscts_prot()
861 arvif->vdev_id, ret); in ath12k_recalc_rtscts_prot()
868 struct ath12k *ar = arvif->ar; in ath12k_mac_set_kickout()
874 ar->pdev->pdev_id); in ath12k_mac_set_kickout()
876 ath12k_warn(ar->ab, "failed to set kickout threshold on vdev %i: %d\n", in ath12k_mac_set_kickout()
877 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
882 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath12k_mac_set_kickout()
885 ath12k_warn(ar->ab, "failed to set keepalive minimum idle time on vdev %i: %d\n", in ath12k_mac_set_kickout()
886 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
891 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath12k_mac_set_kickout()
894 ath12k_warn(ar->ab, "failed to set keepalive maximum idle time on vdev %i: %d\n", in ath12k_mac_set_kickout()
895 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
900 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath12k_mac_set_kickout()
903 ath12k_warn(ar->ab, "failed to set keepalive maximum unresponsive time on vdev %i: %d\n", in ath12k_mac_set_kickout()
904 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
914 struct ath12k_base *ab = ar->ab; in ath12k_mac_peer_cleanup_all()
916 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_peer_cleanup_all()
918 spin_lock_bh(&ab->base_lock); in ath12k_mac_peer_cleanup_all()
919 list_for_each_entry_safe(peer, tmp, &ab->peers, list) { in ath12k_mac_peer_cleanup_all()
921 list_del(&peer->list); in ath12k_mac_peer_cleanup_all()
924 spin_unlock_bh(&ab->base_lock); in ath12k_mac_peer_cleanup_all()
926 ar->num_peers = 0; in ath12k_mac_peer_cleanup_all()
927 ar->num_stations = 0; in ath12k_mac_peer_cleanup_all()
932 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_setup_sync()
934 if (test_bit(ATH12K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) in ath12k_mac_vdev_setup_sync()
935 return -ESHUTDOWN; in ath12k_mac_vdev_setup_sync()
937 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "vdev setup timeout %d\n", in ath12k_mac_vdev_setup_sync()
940 if (!wait_for_completion_timeout(&ar->vdev_setup_done, in ath12k_mac_vdev_setup_sync()
942 return -ETIMEDOUT; in ath12k_mac_vdev_setup_sync()
944 return ar->last_wmi_vdev_start_status ? -EINVAL : 0; in ath12k_mac_vdev_setup_sync()
953 params.bssid = ar->mac_addr; in ath12k_monitor_vdev_up()
956 ath12k_warn(ar->ab, "failed to put up monitor vdev %i: %d\n", in ath12k_monitor_vdev_up()
961 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %i started\n", in ath12k_monitor_vdev_up()
974 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_start()
976 channel = chandef->chan; in ath12k_mac_monitor_vdev_start()
978 arg.freq = channel->center_freq; in ath12k_mac_monitor_vdev_start()
979 arg.band_center_freq1 = chandef->center_freq1; in ath12k_mac_monitor_vdev_start()
980 arg.band_center_freq2 = chandef->center_freq2; in ath12k_mac_monitor_vdev_start()
981 arg.mode = ath12k_phymodes[chandef->chan->band][chandef->width]; in ath12k_mac_monitor_vdev_start()
982 arg.chan_radar = !!(channel->flags & IEEE80211_CHAN_RADAR); in ath12k_mac_monitor_vdev_start()
985 arg.max_power = channel->max_power; in ath12k_mac_monitor_vdev_start()
986 arg.max_reg_power = channel->max_reg_power; in ath12k_mac_monitor_vdev_start()
987 arg.max_antenna_gain = channel->max_antenna_gain; in ath12k_mac_monitor_vdev_start()
989 arg.pref_tx_streams = ar->num_tx_chains; in ath12k_mac_monitor_vdev_start()
990 arg.pref_rx_streams = ar->num_rx_chains; in ath12k_mac_monitor_vdev_start()
993 arg.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR); in ath12k_mac_monitor_vdev_start()
995 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_monitor_vdev_start()
996 reinit_completion(&ar->vdev_delete_done); in ath12k_mac_monitor_vdev_start()
1000 ath12k_warn(ar->ab, "failed to request monitor vdev %i start: %d\n", in ath12k_mac_monitor_vdev_start()
1007 ath12k_warn(ar->ab, "failed to synchronize setup for monitor vdev %i start: %d\n", in ath12k_mac_monitor_vdev_start()
1013 params.bssid = ar->mac_addr; in ath12k_mac_monitor_vdev_start()
1016 ath12k_warn(ar->ab, "failed to put up monitor vdev %i: %d\n", in ath12k_mac_monitor_vdev_start()
1021 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %i started\n", in ath12k_mac_monitor_vdev_start()
1028 ath12k_warn(ar->ab, "failed to stop monitor vdev %i after start failure: %d\n", in ath12k_mac_monitor_vdev_start()
1037 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_stop()
1039 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_monitor_vdev_stop()
1041 ret = ath12k_wmi_vdev_stop(ar, ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_stop()
1043 ath12k_warn(ar->ab, "failed to request monitor vdev %i stop: %d\n", in ath12k_mac_monitor_vdev_stop()
1044 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_stop()
1048 ath12k_warn(ar->ab, "failed to synchronize monitor vdev %i stop: %d\n", in ath12k_mac_monitor_vdev_stop()
1049 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_stop()
1051 ret = ath12k_wmi_vdev_down(ar, ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_stop()
1053 ath12k_warn(ar->ab, "failed to put down monitor vdev %i: %d\n", in ath12k_mac_monitor_vdev_stop()
1054 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_stop()
1056 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %i stopped\n", in ath12k_mac_monitor_vdev_stop()
1057 ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_stop()
1063 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_monitor_vdev_create()
1069 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_create()
1071 if (ar->monitor_vdev_created) in ath12k_mac_monitor_vdev_create()
1074 if (ar->ab->free_vdev_map == 0) { in ath12k_mac_monitor_vdev_create()
1075 ath12k_warn(ar->ab, "failed to find free vdev id for monitor vdev\n"); in ath12k_mac_monitor_vdev_create()
1076 return -ENOMEM; in ath12k_mac_monitor_vdev_create()
1079 bit = __ffs64(ar->ab->free_vdev_map); in ath12k_mac_monitor_vdev_create()
1081 ar->monitor_vdev_id = bit; in ath12k_mac_monitor_vdev_create()
1083 arg.if_id = ar->monitor_vdev_id; in ath12k_mac_monitor_vdev_create()
1086 arg.pdev_id = pdev->pdev_id; in ath12k_mac_monitor_vdev_create()
1089 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_monitor_vdev_create()
1090 arg.chains[NL80211_BAND_2GHZ].tx = ar->num_tx_chains; in ath12k_mac_monitor_vdev_create()
1091 arg.chains[NL80211_BAND_2GHZ].rx = ar->num_rx_chains; in ath12k_mac_monitor_vdev_create()
1094 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath12k_mac_monitor_vdev_create()
1095 arg.chains[NL80211_BAND_5GHZ].tx = ar->num_tx_chains; in ath12k_mac_monitor_vdev_create()
1096 arg.chains[NL80211_BAND_5GHZ].rx = ar->num_rx_chains; in ath12k_mac_monitor_vdev_create()
1101 ath12k_warn(ar->ab, "failed to request monitor vdev %i creation: %d\n", in ath12k_mac_monitor_vdev_create()
1102 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_create()
1103 ar->monitor_vdev_id = -1; in ath12k_mac_monitor_vdev_create()
1107 nss = hweight32(ar->cfg_tx_chainmask) ? : 1; in ath12k_mac_monitor_vdev_create()
1108 ret = ath12k_wmi_vdev_set_param_cmd(ar, ar->monitor_vdev_id, in ath12k_mac_monitor_vdev_create()
1111 ath12k_warn(ar->ab, "failed to set vdev %d chainmask 0x%x, nss %d :%d\n", in ath12k_mac_monitor_vdev_create()
1112 ar->monitor_vdev_id, ar->cfg_tx_chainmask, nss, ret); in ath12k_mac_monitor_vdev_create()
1120 ar->allocated_vdev_map |= 1LL << ar->monitor_vdev_id; in ath12k_mac_monitor_vdev_create()
1121 ar->ab->free_vdev_map &= ~(1LL << ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_create()
1122 ar->num_created_vdevs++; in ath12k_mac_monitor_vdev_create()
1123 ar->monitor_vdev_created = true; in ath12k_mac_monitor_vdev_create()
1124 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %d created\n", in ath12k_mac_monitor_vdev_create()
1125 ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_create()
1135 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_delete()
1137 if (!ar->monitor_vdev_created) in ath12k_mac_monitor_vdev_delete()
1140 reinit_completion(&ar->vdev_delete_done); in ath12k_mac_monitor_vdev_delete()
1142 ret = ath12k_wmi_vdev_delete(ar, ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1144 ath12k_warn(ar->ab, "failed to request wmi monitor vdev %i removal: %d\n", in ath12k_mac_monitor_vdev_delete()
1145 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_delete()
1149 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, in ath12k_mac_monitor_vdev_delete()
1152 ath12k_warn(ar->ab, "Timeout in receiving vdev delete response\n"); in ath12k_mac_monitor_vdev_delete()
1154 ar->allocated_vdev_map &= ~(1LL << ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1155 ar->ab->free_vdev_map |= 1LL << (ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1156 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %d deleted\n", in ath12k_mac_monitor_vdev_delete()
1157 ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1158 ar->num_created_vdevs--; in ath12k_mac_monitor_vdev_delete()
1159 ar->monitor_vdev_id = -1; in ath12k_mac_monitor_vdev_delete()
1160 ar->monitor_vdev_created = false; in ath12k_mac_monitor_vdev_delete()
1173 *def = &conf->def; in ath12k_mac_get_any_chandef_iter()
1181 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_start()
1183 if (ar->monitor_started) in ath12k_mac_monitor_start()
1192 ret = ath12k_mac_monitor_vdev_start(ar, ar->monitor_vdev_id, chandef); in ath12k_mac_monitor_start()
1194 ath12k_warn(ar->ab, "failed to start monitor vdev: %d\n", ret); in ath12k_mac_monitor_start()
1199 ar->monitor_started = true; in ath12k_mac_monitor_start()
1200 ar->num_started_vdevs++; in ath12k_mac_monitor_start()
1202 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor started ret %d\n", ret); in ath12k_mac_monitor_start()
1211 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_stop()
1213 if (!ar->monitor_started) in ath12k_mac_monitor_stop()
1218 ath12k_warn(ar->ab, "failed to stop monitor vdev: %d\n", ret); in ath12k_mac_monitor_stop()
1222 ar->monitor_started = false; in ath12k_mac_monitor_stop()
1223 ar->num_started_vdevs--; in ath12k_mac_monitor_stop()
1225 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor stopped ret %d\n", ret); in ath12k_mac_monitor_stop()
1231 struct ath12k *ar = arvif->ar; in ath12k_mac_vdev_stop()
1234 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_stop()
1236 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_vdev_stop()
1238 ret = ath12k_wmi_vdev_stop(ar, arvif->vdev_id); in ath12k_mac_vdev_stop()
1240 ath12k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n", in ath12k_mac_vdev_stop()
1241 arvif->vdev_id, ret); in ath12k_mac_vdev_stop()
1247 ath12k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n", in ath12k_mac_vdev_stop()
1248 arvif->vdev_id, ret); in ath12k_mac_vdev_stop()
1252 WARN_ON(ar->num_started_vdevs == 0); in ath12k_mac_vdev_stop()
1254 ar->num_started_vdevs--; in ath12k_mac_vdev_stop()
1255 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "vdev %pM stopped, vdev_id %d\n", in ath12k_mac_vdev_stop()
1256 arvif->vif->addr, arvif->vdev_id); in ath12k_mac_vdev_stop()
1258 if (test_bit(ATH12K_CAC_RUNNING, &ar->dev_flags)) { in ath12k_mac_vdev_stop()
1259 clear_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_vdev_stop()
1260 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "CAC Stopped for vdev %d\n", in ath12k_mac_vdev_stop()
1261 arvif->vdev_id); in ath12k_mac_vdev_stop()
1272 struct ieee80211_conf *conf = &hw->conf; in ath12k_mac_config()
1275 mutex_lock(&ar->conf_mutex); in ath12k_mac_config()
1278 ar->monitor_conf_enabled = conf->flags & IEEE80211_CONF_MONITOR; in ath12k_mac_config()
1279 if (ar->monitor_conf_enabled) { in ath12k_mac_config()
1280 if (ar->monitor_vdev_created) in ath12k_mac_config()
1289 if (!ar->monitor_vdev_created) in ath12k_mac_config()
1299 mutex_unlock(&ar->conf_mutex); in ath12k_mac_config()
1304 mutex_unlock(&ar->conf_mutex); in ath12k_mac_config()
1318 ath12k_warn(ar->ab, "failed to update config pdev idx %d: %d\n", in ath12k_mac_op_config()
1319 ar->pdev_idx, ret); in ath12k_mac_op_config()
1327 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_bcn_p2p_ie()
1332 mgmt = (void *)bcn->data; in ath12k_mac_setup_bcn_p2p_ie()
1334 mgmt->u.beacon.variable, in ath12k_mac_setup_bcn_p2p_ie()
1335 bcn->len - (mgmt->u.beacon.variable - in ath12k_mac_setup_bcn_p2p_ie()
1336 bcn->data)); in ath12k_mac_setup_bcn_p2p_ie()
1338 ath12k_warn(ar->ab, "no P2P ie found in beacon\n"); in ath12k_mac_setup_bcn_p2p_ie()
1339 return -ENOENT; in ath12k_mac_setup_bcn_p2p_ie()
1342 ret = ath12k_wmi_p2p_go_bcn_ie(ar, arvif->vdev_id, p2p_ie); in ath12k_mac_setup_bcn_p2p_ie()
1344 ath12k_warn(ar->ab, "failed to submit P2P GO bcn ie for vdev %i: %d\n", in ath12k_mac_setup_bcn_p2p_ie()
1345 arvif->vdev_id, ret); in ath12k_mac_setup_bcn_p2p_ie()
1359 if (WARN_ON(skb->len < ie_offset)) in ath12k_mac_remove_vendor_ie()
1360 return -EINVAL; in ath12k_mac_remove_vendor_ie()
1363 skb->data + ie_offset, in ath12k_mac_remove_vendor_ie()
1364 skb->len - ie_offset); in ath12k_mac_remove_vendor_ie()
1366 return -ENOENT; in ath12k_mac_remove_vendor_ie()
1369 end = skb->data + skb->len; in ath12k_mac_remove_vendor_ie()
1373 return -EINVAL; in ath12k_mac_remove_vendor_ie()
1375 memmove(ie, next, end - next); in ath12k_mac_remove_vendor_ie()
1376 skb_trim(skb, skb->len - len); in ath12k_mac_remove_vendor_ie()
1384 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)bcn->data; in ath12k_mac_set_arvif_ies()
1390 start = bcn->data + ieee80211_get_hdrlen_from_skb(bcn) + sizeof(mgmt->u.beacon); in ath12k_mac_set_arvif_ies()
1392 rem_len = tail - start; in ath12k_mac_set_arvif_ies()
1394 arvif->rsnie_present = false; in ath12k_mac_set_arvif_ies()
1395 arvif->wpaie_present = false; in ath12k_mac_set_arvif_ies()
1398 arvif->rsnie_present = true; in ath12k_mac_set_arvif_ies()
1401 arvif->wpaie_present = true; in ath12k_mac_set_arvif_ies()
1421 if (elem->datalen < 12 || elem->data[0] < 1) in ath12k_mac_set_arvif_ies()
1424 for_each_element(nontx, elem->data + 1, elem->datalen - 1) { in ath12k_mac_set_arvif_ies()
1425 start = nontx->data; in ath12k_mac_set_arvif_ies()
1427 if (nontx->id != 0 || nontx->datalen < 4) in ath12k_mac_set_arvif_ies()
1430 if (nontx->data[0] != WLAN_EID_NON_TX_BSSID_CAP || in ath12k_mac_set_arvif_ies()
1431 nontx->data[1] != 2) { in ath12k_mac_set_arvif_ies()
1435 if (nontx->data[4] != WLAN_EID_SSID) in ath12k_mac_set_arvif_ies()
1439 start, nontx->datalen); in ath12k_mac_set_arvif_ies()
1440 if (!index || index->datalen < 1 || index->data[0] == 0) in ath12k_mac_set_arvif_ies()
1443 if (index->data[0] == bssid_index) { in ath12k_mac_set_arvif_ies()
1446 nontx->data, in ath12k_mac_set_arvif_ies()
1447 nontx->datalen)) { in ath12k_mac_set_arvif_ies()
1448 arvif->rsnie_present = true; in ath12k_mac_set_arvif_ies()
1450 } else if (!arvif->rsnie_present) { in ath12k_mac_set_arvif_ies()
1455 nontx->data, in ath12k_mac_set_arvif_ies()
1456 nontx->datalen); in ath12k_mac_set_arvif_ies()
1457 if (!nie || nie->datalen < 2) in ath12k_mac_set_arvif_ies()
1458 return; /* Invalid non-inheritance element */ in ath12k_mac_set_arvif_ies()
1460 for (i = 1; i < nie->datalen - 1; i++) { in ath12k_mac_set_arvif_ies()
1461 if (nie->data[i] == WLAN_EID_RSN) { in ath12k_mac_set_arvif_ies()
1462 arvif->rsnie_present = false; in ath12k_mac_set_arvif_ies()
1475 struct ieee80211_bss_conf *bss_conf = &arvif->vif->bss_conf; in ath12k_mac_setup_bcn_tmpl_ema()
1483 tx_arvif = ath12k_vif_to_arvif(arvif->vif->mbssid_tx_vif); in ath12k_mac_setup_bcn_tmpl_ema()
1484 beacons = ieee80211_beacon_get_template_ema_list(ath12k_ar_to_hw(tx_arvif->ar), in ath12k_mac_setup_bcn_tmpl_ema()
1485 tx_arvif->vif, 0); in ath12k_mac_setup_bcn_tmpl_ema()
1486 if (!beacons || !beacons->cnt) { in ath12k_mac_setup_bcn_tmpl_ema()
1487 ath12k_warn(arvif->ar->ab, in ath12k_mac_setup_bcn_tmpl_ema()
1489 return -EPERM; in ath12k_mac_setup_bcn_tmpl_ema()
1493 ath12k_mac_set_arvif_ies(arvif, beacons->bcn[0].skb, 0, NULL); in ath12k_mac_setup_bcn_tmpl_ema()
1495 for (i = 0; i < beacons->cnt; i++) { in ath12k_mac_setup_bcn_tmpl_ema()
1497 ath12k_mac_set_arvif_ies(arvif, beacons->bcn[i].skb, in ath12k_mac_setup_bcn_tmpl_ema()
1498 bss_conf->bssid_index, in ath12k_mac_setup_bcn_tmpl_ema()
1501 ema_args.bcn_cnt = beacons->cnt; in ath12k_mac_setup_bcn_tmpl_ema()
1503 ret = ath12k_wmi_bcn_tmpl(tx_arvif->ar, tx_arvif->vdev_id, in ath12k_mac_setup_bcn_tmpl_ema()
1504 &beacons->bcn[i].offs, in ath12k_mac_setup_bcn_tmpl_ema()
1505 beacons->bcn[i].skb, &ema_args); in ath12k_mac_setup_bcn_tmpl_ema()
1507 ath12k_warn(tx_arvif->ar->ab, in ath12k_mac_setup_bcn_tmpl_ema()
1515 ath12k_warn(arvif->ar->ab, in ath12k_mac_setup_bcn_tmpl_ema()
1517 bss_conf->bssid_index); in ath12k_mac_setup_bcn_tmpl_ema()
1526 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_bcn_tmpl()
1527 struct ath12k_base *ab = ar->ab; in ath12k_mac_setup_bcn_tmpl()
1528 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_setup_bcn_tmpl()
1534 if (arvif->vdev_type != WMI_VDEV_TYPE_AP) in ath12k_mac_setup_bcn_tmpl()
1537 if (vif->mbssid_tx_vif) { in ath12k_mac_setup_bcn_tmpl()
1538 tx_arvif = ath12k_vif_to_arvif(vif->mbssid_tx_vif); in ath12k_mac_setup_bcn_tmpl()
1539 if (tx_arvif != arvif && arvif->is_up) in ath12k_mac_setup_bcn_tmpl()
1542 if (vif->bss_conf.ema_ap) in ath12k_mac_setup_bcn_tmpl()
1546 bcn = ieee80211_beacon_get_template(ath12k_ar_to_hw(tx_arvif->ar), tx_arvif->vif, in ath12k_mac_setup_bcn_tmpl()
1550 return -EPERM; in ath12k_mac_setup_bcn_tmpl()
1557 arvif->vif->bss_conf.bssid_index, in ath12k_mac_setup_bcn_tmpl()
1564 if (arvif->vif->type == NL80211_IFTYPE_AP && arvif->vif->p2p) { in ath12k_mac_setup_bcn_tmpl()
1587 ret = ath12k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn, NULL); in ath12k_mac_setup_bcn_tmpl()
1602 struct ath12k *ar = arvif->ar; in ath12k_control_beaconing()
1605 lockdep_assert_held(&arvif->ar->conf_mutex); in ath12k_control_beaconing()
1607 if (!info->enable_beacon) { in ath12k_control_beaconing()
1608 ret = ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_control_beaconing()
1610 ath12k_warn(ar->ab, "failed to down vdev_id %i: %d\n", in ath12k_control_beaconing()
1611 arvif->vdev_id, ret); in ath12k_control_beaconing()
1613 arvif->is_up = false; in ath12k_control_beaconing()
1620 ath12k_warn(ar->ab, "failed to update bcn tmpl during vdev up: %d\n", in ath12k_control_beaconing()
1625 arvif->aid = 0; in ath12k_control_beaconing()
1627 ether_addr_copy(arvif->bssid, info->bssid); in ath12k_control_beaconing()
1629 params.vdev_id = arvif->vdev_id; in ath12k_control_beaconing()
1630 params.aid = arvif->aid; in ath12k_control_beaconing()
1631 params.bssid = arvif->bssid; in ath12k_control_beaconing()
1632 if (arvif->vif->mbssid_tx_vif) { in ath12k_control_beaconing()
1633 params.tx_bssid = ath12k_vif_to_arvif(arvif->vif->mbssid_tx_vif)->bssid; in ath12k_control_beaconing()
1634 params.nontx_profile_idx = info->bssid_index; in ath12k_control_beaconing()
1635 params.nontx_profile_cnt = 1 << info->bssid_indicator; in ath12k_control_beaconing()
1637 ret = ath12k_wmi_vdev_up(arvif->ar, ¶ms); in ath12k_control_beaconing()
1639 ath12k_warn(ar->ab, "failed to bring up vdev %d: %i\n", in ath12k_control_beaconing()
1640 arvif->vdev_id, ret); in ath12k_control_beaconing()
1644 arvif->is_up = true; in ath12k_control_beaconing()
1646 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d up\n", arvif->vdev_id); in ath12k_control_beaconing()
1653 struct ieee80211_mgmt *mgmt = (void *)skb->data; in ath12k_mac_handle_beacon_iter()
1656 if (vif->type != NL80211_IFTYPE_STATION) in ath12k_mac_handle_beacon_iter()
1659 if (!ether_addr_equal(mgmt->bssid, vif->bss_conf.bssid)) in ath12k_mac_handle_beacon_iter()
1662 cancel_delayed_work(&arvif->connection_loss_work); in ath12k_mac_handle_beacon_iter()
1678 struct ath12k *ar = arvif->ar; in ath12k_mac_handle_beacon_miss_iter()
1681 if (arvif->vdev_id != *vdev_id) in ath12k_mac_handle_beacon_miss_iter()
1684 if (!arvif->is_up) in ath12k_mac_handle_beacon_miss_iter()
1694 ieee80211_queue_delayed_work(hw, &arvif->connection_loss_work, in ath12k_mac_handle_beacon_miss_iter()
1710 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_vif_sta_connection_loss_work()
1712 if (!arvif->is_up) in ath12k_mac_vif_sta_connection_loss_work()
1727 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_basic()
1729 if (vif->type == NL80211_IFTYPE_STATION) in ath12k_peer_assoc_h_basic()
1730 aid = vif->cfg.aid; in ath12k_peer_assoc_h_basic()
1732 aid = sta->aid; in ath12k_peer_assoc_h_basic()
1734 ether_addr_copy(arg->peer_mac, sta->addr); in ath12k_peer_assoc_h_basic()
1735 arg->vdev_id = arvif->vdev_id; in ath12k_peer_assoc_h_basic()
1736 arg->peer_associd = aid; in ath12k_peer_assoc_h_basic()
1737 arg->auth_flag = true; in ath12k_peer_assoc_h_basic()
1739 arg->peer_listen_intval = hw->conf.listen_interval; in ath12k_peer_assoc_h_basic()
1740 arg->peer_nss = 1; in ath12k_peer_assoc_h_basic()
1741 arg->peer_caps = vif->bss_conf.assoc_capability; in ath12k_peer_assoc_h_basic()
1749 struct ieee80211_bss_conf *info = &vif->bss_conf; in ath12k_peer_assoc_h_crypto()
1757 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_crypto()
1762 bss = cfg80211_get_bss(hw->wiphy, def.chan, info->bssid, NULL, 0, in ath12k_peer_assoc_h_crypto()
1765 if (arvif->rsnie_present || arvif->wpaie_present) { in ath12k_peer_assoc_h_crypto()
1766 arg->need_ptk_4_way = true; in ath12k_peer_assoc_h_crypto()
1767 if (arvif->wpaie_present) in ath12k_peer_assoc_h_crypto()
1768 arg->need_gtk_2_way = true; in ath12k_peer_assoc_h_crypto()
1775 ies = rcu_dereference(bss->ies); in ath12k_peer_assoc_h_crypto()
1779 ies->data, in ath12k_peer_assoc_h_crypto()
1780 ies->len); in ath12k_peer_assoc_h_crypto()
1782 cfg80211_put_bss(hw->wiphy, bss); in ath12k_peer_assoc_h_crypto()
1787 ath12k_dbg(ar->ab, ATH12K_DBG_WMI, in ath12k_peer_assoc_h_crypto()
1789 arg->need_ptk_4_way = true; in ath12k_peer_assoc_h_crypto()
1793 ath12k_dbg(ar->ab, ATH12K_DBG_WMI, in ath12k_peer_assoc_h_crypto()
1795 arg->need_gtk_2_way = true; in ath12k_peer_assoc_h_crypto()
1798 if (sta->mfp) { in ath12k_peer_assoc_h_crypto()
1800 arg->is_pmf_enabled = true; in ath12k_peer_assoc_h_crypto()
1803 /* TODO: safe_mode_enabled (bypass 4-way handshake) flag req? */ in ath12k_peer_assoc_h_crypto()
1812 struct wmi_rate_set_arg *rateset = &arg->peer_legacy_rates; in ath12k_peer_assoc_h_rates()
1822 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_rates()
1827 band = def.chan->band; in ath12k_peer_assoc_h_rates()
1828 sband = hw->wiphy->bands[band]; in ath12k_peer_assoc_h_rates()
1829 ratemask = sta->deflink.supp_rates[band]; in ath12k_peer_assoc_h_rates()
1830 ratemask &= arvif->bitrate_mask.control[band].legacy; in ath12k_peer_assoc_h_rates()
1831 rates = sband->bitrates; in ath12k_peer_assoc_h_rates()
1833 rateset->num_rates = 0; in ath12k_peer_assoc_h_rates()
1839 rate = ath12k_mac_bitrate_to_rate(rates->bitrate); in ath12k_peer_assoc_h_rates()
1840 rateset->rates[rateset->num_rates] = rate; in ath12k_peer_assoc_h_rates()
1841 rateset->num_rates++; in ath12k_peer_assoc_h_rates()
1874 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in ath12k_peer_assoc_h_ht()
1883 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_ht()
1888 if (!ht_cap->ht_supported) in ath12k_peer_assoc_h_ht()
1891 band = def.chan->band; in ath12k_peer_assoc_h_ht()
1892 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath12k_peer_assoc_h_ht()
1897 arg->ht_flag = true; in ath12k_peer_assoc_h_ht()
1899 arg->peer_max_mpdu = (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_ht()
1900 ht_cap->ampdu_factor)) - 1; in ath12k_peer_assoc_h_ht()
1902 arg->peer_mpdu_density = in ath12k_peer_assoc_h_ht()
1903 ath12k_parse_mpdudensity(ht_cap->ampdu_density); in ath12k_peer_assoc_h_ht()
1905 arg->peer_ht_caps = ht_cap->cap; in ath12k_peer_assoc_h_ht()
1906 arg->peer_rate_caps |= WMI_HOST_RC_HT_FLAG; in ath12k_peer_assoc_h_ht()
1908 if (ht_cap->cap & IEEE80211_HT_CAP_LDPC_CODING) in ath12k_peer_assoc_h_ht()
1909 arg->ldpc_flag = true; in ath12k_peer_assoc_h_ht()
1911 if (sta->deflink.bandwidth >= IEEE80211_STA_RX_BW_40) { in ath12k_peer_assoc_h_ht()
1912 arg->bw_40 = true; in ath12k_peer_assoc_h_ht()
1913 arg->peer_rate_caps |= WMI_HOST_RC_CW40_FLAG; in ath12k_peer_assoc_h_ht()
1916 if (arvif->bitrate_mask.control[band].gi != NL80211_TXRATE_FORCE_LGI) { in ath12k_peer_assoc_h_ht()
1917 if (ht_cap->cap & (IEEE80211_HT_CAP_SGI_20 | in ath12k_peer_assoc_h_ht()
1919 arg->peer_rate_caps |= WMI_HOST_RC_SGI_FLAG; in ath12k_peer_assoc_h_ht()
1922 if (ht_cap->cap & IEEE80211_HT_CAP_TX_STBC) { in ath12k_peer_assoc_h_ht()
1923 arg->peer_rate_caps |= WMI_HOST_RC_TX_STBC_FLAG; in ath12k_peer_assoc_h_ht()
1924 arg->stbc_flag = true; in ath12k_peer_assoc_h_ht()
1927 if (ht_cap->cap & IEEE80211_HT_CAP_RX_STBC) { in ath12k_peer_assoc_h_ht()
1928 stbc = ht_cap->cap & IEEE80211_HT_CAP_RX_STBC; in ath12k_peer_assoc_h_ht()
1931 arg->peer_rate_caps |= stbc; in ath12k_peer_assoc_h_ht()
1932 arg->stbc_flag = true; in ath12k_peer_assoc_h_ht()
1935 if (ht_cap->mcs.rx_mask[1] && ht_cap->mcs.rx_mask[2]) in ath12k_peer_assoc_h_ht()
1936 arg->peer_rate_caps |= WMI_HOST_RC_TS_FLAG; in ath12k_peer_assoc_h_ht()
1937 else if (ht_cap->mcs.rx_mask[1]) in ath12k_peer_assoc_h_ht()
1938 arg->peer_rate_caps |= WMI_HOST_RC_DS_FLAG; in ath12k_peer_assoc_h_ht()
1941 if ((ht_cap->mcs.rx_mask[i / 8] & BIT(i % 8)) && in ath12k_peer_assoc_h_ht()
1944 arg->peer_ht_rates.rates[n++] = i; in ath12k_peer_assoc_h_ht()
1947 /* This is a workaround for HT-enabled STAs which break the spec in ath12k_peer_assoc_h_ht()
1956 arg->peer_ht_rates.num_rates = 8; in ath12k_peer_assoc_h_ht()
1957 for (i = 0; i < arg->peer_ht_rates.num_rates; i++) in ath12k_peer_assoc_h_ht()
1958 arg->peer_ht_rates.rates[i] = i; in ath12k_peer_assoc_h_ht()
1960 arg->peer_ht_rates.num_rates = n; in ath12k_peer_assoc_h_ht()
1961 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath12k_peer_assoc_h_ht()
1964 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac ht peer %pM mcs cnt %d nss %d\n", in ath12k_peer_assoc_h_ht()
1965 arg->peer_mac, in ath12k_peer_assoc_h_ht()
1966 arg->peer_ht_rates.num_rates, in ath12k_peer_assoc_h_ht()
1967 arg->peer_nss); in ath12k_peer_assoc_h_ht()
1973 case IEEE80211_VHT_MCS_SUPPORT_0_7: return BIT(8) - 1; in ath12k_mac_get_max_vht_mcs_map()
1974 case IEEE80211_VHT_MCS_SUPPORT_0_8: return BIT(9) - 1; in ath12k_mac_get_max_vht_mcs_map()
1975 case IEEE80211_VHT_MCS_SUPPORT_0_9: return BIT(10) - 1; in ath12k_mac_get_max_vht_mcs_map()
1994 idx_limit = fls(mcs_map) - 1; in ath12k_peer_assoc_h_vht_limit()
1996 idx_limit = -1; in ath12k_peer_assoc_h_vht_limit()
2018 case -1: in ath12k_peer_assoc_h_vht_limit()
2035 const struct ieee80211_sta_vht_cap *vht_cap = &sta->deflink.vht_cap; in ath12k_peer_assoc_h_vht()
2048 if (!vht_cap->vht_supported) in ath12k_peer_assoc_h_vht()
2051 band = def.chan->band; in ath12k_peer_assoc_h_vht()
2052 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath12k_peer_assoc_h_vht()
2057 arg->vht_flag = true; in ath12k_peer_assoc_h_vht()
2060 arg->vht_capable = true; in ath12k_peer_assoc_h_vht()
2062 if (def.chan->band == NL80211_BAND_2GHZ) in ath12k_peer_assoc_h_vht()
2063 arg->vht_ng_flag = true; in ath12k_peer_assoc_h_vht()
2065 arg->peer_vht_caps = vht_cap->cap; in ath12k_peer_assoc_h_vht()
2067 ampdu_factor = (vht_cap->cap & in ath12k_peer_assoc_h_vht()
2071 /* Workaround: Some Netgear/Linksys 11ac APs set Rx A-MPDU factor to in ath12k_peer_assoc_h_vht()
2073 * arg->peer_max_mpdu at this point contains HT max_mpdu so keep in ath12k_peer_assoc_h_vht()
2076 arg->peer_max_mpdu = max(arg->peer_max_mpdu, in ath12k_peer_assoc_h_vht()
2078 ampdu_factor)) - 1); in ath12k_peer_assoc_h_vht()
2080 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_peer_assoc_h_vht()
2081 arg->bw_80 = true; in ath12k_peer_assoc_h_vht()
2083 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in ath12k_peer_assoc_h_vht()
2084 arg->bw_160 = true; in ath12k_peer_assoc_h_vht()
2090 vht_mcs = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map) >> in ath12k_peer_assoc_h_vht()
2097 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath12k_peer_assoc_h_vht()
2098 arg->rx_max_rate = __le16_to_cpu(vht_cap->vht_mcs.rx_highest); in ath12k_peer_assoc_h_vht()
2099 arg->rx_mcs_set = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); in ath12k_peer_assoc_h_vht()
2100 arg->tx_max_rate = __le16_to_cpu(vht_cap->vht_mcs.tx_highest); in ath12k_peer_assoc_h_vht()
2102 tx_mcs_map = __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); in ath12k_peer_assoc_h_vht()
2103 arg->tx_mcs_set = ath12k_peer_assoc_h_vht_limit(tx_mcs_map, vht_mcs_mask); in ath12k_peer_assoc_h_vht()
2109 arg->tx_mcs_set &= ~IEEE80211_VHT_MCS_SUPPORT_0_11_MASK; in ath12k_peer_assoc_h_vht()
2110 arg->tx_mcs_set |= IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11; in ath12k_peer_assoc_h_vht()
2112 if ((arg->tx_mcs_set & IEEE80211_VHT_MCS_NOT_SUPPORTED) == in ath12k_peer_assoc_h_vht()
2114 arg->peer_vht_caps &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; in ath12k_peer_assoc_h_vht()
2117 arg->tx_max_mcs_nss = 0xFF; in ath12k_peer_assoc_h_vht()
2119 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n", in ath12k_peer_assoc_h_vht()
2120 sta->addr, arg->peer_max_mpdu, arg->peer_flags); in ath12k_peer_assoc_h_vht()
2130 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath12k_peer_assoc_h_he()
2139 if (!he_cap->has_he) in ath12k_peer_assoc_h_he()
2142 arg->he_flag = true; in ath12k_peer_assoc_h_he()
2144 support_160 = !!(he_cap->he_cap_elem.phy_cap_info[0] & in ath12k_peer_assoc_h_he()
2147 /* Supported HE-MCS and NSS Set of peer he_cap is intersection with self he_cp */ in ath12k_peer_assoc_h_he()
2148 mcs_160_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160); in ath12k_peer_assoc_h_he()
2149 mcs_80_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80); in ath12k_peer_assoc_h_he()
2152 for (i = 7; i >= 0; i--) { in ath12k_peer_assoc_h_he()
2162 for (i = 7; i >= 0; i--) { in ath12k_peer_assoc_h_he()
2176 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath12k_peer_assoc_h_he()
2178 memcpy(&arg->peer_he_cap_macinfo, he_cap->he_cap_elem.mac_cap_info, in ath12k_peer_assoc_h_he()
2179 sizeof(he_cap->he_cap_elem.mac_cap_info)); in ath12k_peer_assoc_h_he()
2180 memcpy(&arg->peer_he_cap_phyinfo, he_cap->he_cap_elem.phy_cap_info, in ath12k_peer_assoc_h_he()
2181 sizeof(he_cap->he_cap_elem.phy_cap_info)); in ath12k_peer_assoc_h_he()
2182 arg->peer_he_ops = vif->bss_conf.he_oper.params; in ath12k_peer_assoc_h_he()
2185 arg->peer_he_ops &= 0xffffff; in ath12k_peer_assoc_h_he()
2188 * Exponent Extension in HE cap is zero, use the arg->peer_max_mpdu in ath12k_peer_assoc_h_he()
2192 * For non-zero value of Max AMPDU Exponent Extension in HE MAC caps, in ath12k_peer_assoc_h_he()
2193 * if a HE STA sends VHT cap and HE cap IE in assoc request then, use in ath12k_peer_assoc_h_he()
2195 * If a HE STA that does not send VHT cap, but HE and HT cap in assoc in ath12k_peer_assoc_h_he()
2199 ampdu_factor = u8_get_bits(he_cap->he_cap_elem.mac_cap_info[3], in ath12k_peer_assoc_h_he()
2203 if (sta->deflink.vht_cap.vht_supported) in ath12k_peer_assoc_h_he()
2204 arg->peer_max_mpdu = (1 << (IEEE80211_HE_VHT_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_he()
2205 ampdu_factor)) - 1; in ath12k_peer_assoc_h_he()
2206 else if (sta->deflink.ht_cap.ht_supported) in ath12k_peer_assoc_h_he()
2207 arg->peer_max_mpdu = (1 << (IEEE80211_HE_HT_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_he()
2208 ampdu_factor)) - 1; in ath12k_peer_assoc_h_he()
2211 if (he_cap->he_cap_elem.phy_cap_info[6] & in ath12k_peer_assoc_h_he()
2216 arg->peer_ppet.numss_m1 = he_cap->ppe_thres[0] & in ath12k_peer_assoc_h_he()
2218 arg->peer_ppet.ru_bit_mask = in ath12k_peer_assoc_h_he()
2219 (he_cap->ppe_thres[0] & in ath12k_peer_assoc_h_he()
2223 for (nss = 0; nss <= arg->peer_ppet.numss_m1; nss++) { in ath12k_peer_assoc_h_he()
2228 if ((arg->peer_ppet.ru_bit_mask & BIT(ru)) == 0) in ath12k_peer_assoc_h_he()
2232 val |= ((he_cap->ppe_thres[bit / 8] >> in ath12k_peer_assoc_h_he()
2236 arg->peer_ppet.ppet16_ppet8_ru3_ru0[nss] |= in ath12k_peer_assoc_h_he()
2242 if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_RES) in ath12k_peer_assoc_h_he()
2243 arg->twt_responder = true; in ath12k_peer_assoc_h_he()
2244 if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_REQ) in ath12k_peer_assoc_h_he()
2245 arg->twt_requester = true; in ath12k_peer_assoc_h_he()
2247 switch (sta->deflink.bandwidth) { in ath12k_peer_assoc_h_he()
2249 if (he_cap->he_cap_elem.phy_cap_info[0] & in ath12k_peer_assoc_h_he()
2251 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80p80); in ath12k_peer_assoc_h_he()
2252 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v; in ath12k_peer_assoc_h_he()
2254 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80p80); in ath12k_peer_assoc_h_he()
2255 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v; in ath12k_peer_assoc_h_he()
2257 arg->peer_he_mcs_count++; in ath12k_peer_assoc_h_he()
2259 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160); in ath12k_peer_assoc_h_he()
2260 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v; in ath12k_peer_assoc_h_he()
2262 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_160); in ath12k_peer_assoc_h_he()
2263 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v; in ath12k_peer_assoc_h_he()
2265 arg->peer_he_mcs_count++; in ath12k_peer_assoc_h_he()
2269 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80); in ath12k_peer_assoc_h_he()
2270 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v; in ath12k_peer_assoc_h_he()
2272 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80); in ath12k_peer_assoc_h_he()
2273 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v; in ath12k_peer_assoc_h_he()
2275 arg->peer_he_mcs_count++; in ath12k_peer_assoc_h_he()
2285 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath12k_peer_assoc_h_he_6ghz()
2293 band = def.chan->band; in ath12k_peer_assoc_h_he_6ghz()
2295 if (!arg->he_flag || band != NL80211_BAND_6GHZ || !sta->deflink.he_6ghz_capa.capa) in ath12k_peer_assoc_h_he_6ghz()
2298 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_he_6ghz()
2299 arg->bw_40 = true; in ath12k_peer_assoc_h_he_6ghz()
2301 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_peer_assoc_h_he_6ghz()
2302 arg->bw_80 = true; in ath12k_peer_assoc_h_he_6ghz()
2304 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in ath12k_peer_assoc_h_he_6ghz()
2305 arg->bw_160 = true; in ath12k_peer_assoc_h_he_6ghz()
2307 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) in ath12k_peer_assoc_h_he_6ghz()
2308 arg->bw_320 = true; in ath12k_peer_assoc_h_he_6ghz()
2310 arg->peer_he_caps_6ghz = le16_to_cpu(sta->deflink.he_6ghz_capa.capa); in ath12k_peer_assoc_h_he_6ghz()
2312 mpdu_density = u32_get_bits(arg->peer_he_caps_6ghz, in ath12k_peer_assoc_h_he_6ghz()
2314 arg->peer_mpdu_density = ath12k_parse_mpdudensity(mpdu_density); in ath12k_peer_assoc_h_he_6ghz()
2316 /* From IEEE Std 802.11ax-2021 - Section 10.12.2: An HE STA shall be capable of in ath12k_peer_assoc_h_he_6ghz()
2317 * receiving A-MPDU where the A-MPDU pre-EOF padding length is up to the value in ath12k_peer_assoc_h_he_6ghz()
2318 * indicated by the Maximum A-MPDU Length Exponent Extension field in the HE in ath12k_peer_assoc_h_he_6ghz()
2319 * Capabilities element and the Maximum A-MPDU Length Exponent field in HE 6 GHz in ath12k_peer_assoc_h_he_6ghz()
2322 * Here, we are extracting the Max A-MPDU Exponent Extension from HE caps and in ath12k_peer_assoc_h_he_6ghz()
2323 * factor is the Maximum A-MPDU Length Exponent from HE 6 GHZ Band capability. in ath12k_peer_assoc_h_he_6ghz()
2325 ampdu_factor = u8_get_bits(he_cap->he_cap_elem.mac_cap_info[3], in ath12k_peer_assoc_h_he_6ghz()
2327 u32_get_bits(arg->peer_he_caps_6ghz, in ath12k_peer_assoc_h_he_6ghz()
2330 arg->peer_max_mpdu = (1u << (IEEE80211_HE_6GHZ_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_he_6ghz()
2331 ampdu_factor)) - 1; in ath12k_peer_assoc_h_he_6ghz()
2338 if (ht_cap->ht_supported) in ath12k_get_smps_from_capa()
2339 *smps = u16_get_bits(ht_cap->cap, IEEE80211_HT_CAP_SM_PS); in ath12k_get_smps_from_capa()
2341 *smps = le16_get_bits(he_6ghz_capa->capa, in ath12k_get_smps_from_capa()
2345 return -EINVAL; in ath12k_get_smps_from_capa()
2353 const struct ieee80211_he_6ghz_capa *he_6ghz_capa = &sta->deflink.he_6ghz_capa; in ath12k_peer_assoc_h_smps()
2354 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in ath12k_peer_assoc_h_smps()
2357 if (!ht_cap->ht_supported && !he_6ghz_capa->capa) in ath12k_peer_assoc_h_smps()
2365 arg->static_mimops_flag = true; in ath12k_peer_assoc_h_smps()
2368 arg->dynamic_mimops_flag = true; in ath12k_peer_assoc_h_smps()
2371 arg->spatial_mux_flag = true; in ath12k_peer_assoc_h_smps()
2385 switch (arvif->vdev_type) { in ath12k_peer_assoc_h_qos()
2387 if (sta->wme) { in ath12k_peer_assoc_h_qos()
2389 arg->is_wme_set = true; in ath12k_peer_assoc_h_qos()
2390 arg->qos_flag = true; in ath12k_peer_assoc_h_qos()
2393 if (sta->wme && sta->uapsd_queues) { in ath12k_peer_assoc_h_qos()
2395 arg->is_wme_set = true; in ath12k_peer_assoc_h_qos()
2396 arg->apsd_flag = true; in ath12k_peer_assoc_h_qos()
2397 arg->peer_rate_caps |= WMI_HOST_RC_UAPSD_FLAG; in ath12k_peer_assoc_h_qos()
2401 if (sta->wme) { in ath12k_peer_assoc_h_qos()
2402 arg->is_wme_set = true; in ath12k_peer_assoc_h_qos()
2403 arg->qos_flag = true; in ath12k_peer_assoc_h_qos()
2410 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac peer %pM qos %d\n", in ath12k_peer_assoc_h_qos()
2411 sta->addr, arg->qos_flag); in ath12k_peer_assoc_h_qos()
2423 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_qos_ap()
2425 arg.vdev_id = arvif->vdev_id; in ath12k_peer_assoc_qos_ap()
2427 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac uapsd_queues 0x%x max_sp %d\n", in ath12k_peer_assoc_qos_ap()
2428 sta->uapsd_queues, sta->max_sp); in ath12k_peer_assoc_qos_ap()
2431 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) in ath12k_peer_assoc_qos_ap()
2434 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) in ath12k_peer_assoc_qos_ap()
2437 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) in ath12k_peer_assoc_qos_ap()
2440 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) in ath12k_peer_assoc_qos_ap()
2445 if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP) in ath12k_peer_assoc_qos_ap()
2446 max_sp = sta->max_sp; in ath12k_peer_assoc_qos_ap()
2450 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
2456 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
2463 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
2469 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
2476 ath12k_warn(ar->ab, "failed to set ap ps peer param %d for vdev %i: %d\n", in ath12k_peer_assoc_qos_ap()
2477 arg.param, arvif->vdev_id, ret); in ath12k_peer_assoc_qos_ap()
2483 return sta->deflink.supp_rates[NL80211_BAND_2GHZ] >> in ath12k_mac_sta_has_ofdm_only()
2490 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath12k_mac_get_phymode_vht()
2491 switch (sta->deflink.vht_cap.cap & in ath12k_mac_get_phymode_vht()
2503 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_mac_get_phymode_vht()
2506 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_mac_get_phymode_vht()
2509 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath12k_mac_get_phymode_vht()
2518 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath12k_mac_get_phymode_he()
2519 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_he()
2522 else if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_he()
2529 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_mac_get_phymode_he()
2532 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_mac_get_phymode_he()
2535 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath12k_mac_get_phymode_he()
2544 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) in ath12k_mac_get_phymode_eht()
2545 if (sta->deflink.eht_cap.eht_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_eht()
2549 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath12k_mac_get_phymode_eht()
2550 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_eht()
2554 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_eht()
2558 ath12k_warn(ar->ab, "invalid EHT PHY capability info for 160 Mhz: %d\n", in ath12k_mac_get_phymode_eht()
2559 sta->deflink.he_cap.he_cap_elem.phy_cap_info[0]); in ath12k_mac_get_phymode_eht()
2564 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_mac_get_phymode_eht()
2567 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_mac_get_phymode_eht()
2570 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath12k_mac_get_phymode_eht()
2591 band = def.chan->band; in ath12k_peer_assoc_h_phymode()
2592 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath12k_peer_assoc_h_phymode()
2593 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath12k_peer_assoc_h_phymode()
2597 if (sta->deflink.eht_cap.has_eht) { in ath12k_peer_assoc_h_phymode()
2598 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2602 } else if (sta->deflink.he_cap.has_he) { in ath12k_peer_assoc_h_phymode()
2603 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_peer_assoc_h_phymode()
2605 else if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2609 } else if (sta->deflink.vht_cap.vht_supported && in ath12k_peer_assoc_h_phymode()
2611 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2615 } else if (sta->deflink.ht_cap.ht_supported && in ath12k_peer_assoc_h_phymode()
2617 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2630 if (sta->deflink.eht_cap.has_eht) { in ath12k_peer_assoc_h_phymode()
2632 } else if (sta->deflink.he_cap.has_he) { in ath12k_peer_assoc_h_phymode()
2634 } else if (sta->deflink.vht_cap.vht_supported && in ath12k_peer_assoc_h_phymode()
2637 } else if (sta->deflink.ht_cap.ht_supported && in ath12k_peer_assoc_h_phymode()
2639 if (sta->deflink.bandwidth >= IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2651 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac peer %pM phymode %s\n", in ath12k_peer_assoc_h_phymode()
2652 sta->addr, ath12k_mac_phymode_str(phymode)); in ath12k_peer_assoc_h_phymode()
2654 arg->peer_phymode = phymode; in ath12k_peer_assoc_h_phymode()
2698 ppet->numss_m1 = u8_get_bits(ppe_thres[0], IEEE80211_EHT_PPE_THRES_NSS_MASK); in ath12k_mac_set_eht_ppe_threshold()
2699 ppet->ru_bit_mask = u16_get_bits(get_unaligned_le16(ppe_thres), in ath12k_mac_set_eht_ppe_threshold()
2702 for (nss = 0; nss <= ppet->numss_m1; nss++) { in ath12k_mac_set_eht_ppe_threshold()
2706 if ((ppet->ru_bit_mask & BIT(ru)) == 0) in ath12k_mac_set_eht_ppe_threshold()
2715 ppet->ppet16_ppet8_ru3_ru0[nss] |= in ath12k_mac_set_eht_ppe_threshold()
2726 const struct ieee80211_sta_eht_cap *eht_cap = &sta->deflink.eht_cap; in ath12k_peer_assoc_h_eht()
2727 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath12k_peer_assoc_h_eht()
2733 if (!sta->deflink.he_cap.has_he || !eht_cap->has_eht) in ath12k_peer_assoc_h_eht()
2736 arg->eht_flag = true; in ath12k_peer_assoc_h_eht()
2738 if ((eht_cap->eht_cap_elem.phy_cap_info[5] & in ath12k_peer_assoc_h_eht()
2740 eht_cap->eht_ppe_thres[0] != 0) in ath12k_peer_assoc_h_eht()
2741 ath12k_mac_set_eht_ppe_threshold(eht_cap->eht_ppe_thres, in ath12k_peer_assoc_h_eht()
2742 &arg->peer_eht_ppet); in ath12k_peer_assoc_h_eht()
2744 memcpy(arg->peer_eht_cap_mac, eht_cap->eht_cap_elem.mac_cap_info, in ath12k_peer_assoc_h_eht()
2745 sizeof(eht_cap->eht_cap_elem.mac_cap_info)); in ath12k_peer_assoc_h_eht()
2746 memcpy(arg->peer_eht_cap_phy, eht_cap->eht_cap_elem.phy_cap_info, in ath12k_peer_assoc_h_eht()
2747 sizeof(eht_cap->eht_cap_elem.phy_cap_info)); in ath12k_peer_assoc_h_eht()
2749 rx_mcs = arg->peer_eht_rx_mcs_set; in ath12k_peer_assoc_h_eht()
2750 tx_mcs = arg->peer_eht_tx_mcs_set; in ath12k_peer_assoc_h_eht()
2752 switch (sta->deflink.bandwidth) { in ath12k_peer_assoc_h_eht()
2754 bw = &eht_cap->eht_mcs_nss_supp.bw._320; in ath12k_peer_assoc_h_eht()
2755 ath12k_mac_set_eht_mcs(bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2756 bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2757 bw->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2758 bw->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2761 arg->peer_eht_mcs_count++; in ath12k_peer_assoc_h_eht()
2764 bw = &eht_cap->eht_mcs_nss_supp.bw._160; in ath12k_peer_assoc_h_eht()
2765 ath12k_mac_set_eht_mcs(bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2766 bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2767 bw->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2768 bw->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2771 arg->peer_eht_mcs_count++; in ath12k_peer_assoc_h_eht()
2774 if ((he_cap->he_cap_elem.phy_cap_info[0] & in ath12k_peer_assoc_h_eht()
2779 bw_20 = &eht_cap->eht_mcs_nss_supp.only_20mhz; in ath12k_peer_assoc_h_eht()
2781 ath12k_mac_set_eht_mcs(bw_20->rx_tx_mcs7_max_nss, in ath12k_peer_assoc_h_eht()
2782 bw_20->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2783 bw_20->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2784 bw_20->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2788 bw = &eht_cap->eht_mcs_nss_supp.bw._80; in ath12k_peer_assoc_h_eht()
2789 ath12k_mac_set_eht_mcs(bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2790 bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2791 bw->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2792 bw->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2797 arg->peer_eht_mcs_count++; in ath12k_peer_assoc_h_eht()
2801 arg->punct_bitmap = ~arvif->punct_bitmap; in ath12k_peer_assoc_h_eht()
2810 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_prepare()
2814 reinit_completion(&ar->peer_assoc_done); in ath12k_peer_assoc_prepare()
2816 arg->peer_new_assoc = !reassoc; in ath12k_peer_assoc_prepare()
2839 if (!ht_cap->ht_supported && !he_6ghz_capa) in ath12k_setup_peer_smps()
2846 return ath12k_wmi_set_peer_param(ar, addr, arvif->vdev_id, in ath12k_setup_peer_smps()
2855 struct ieee80211_vif *vif = arvif->vif; in ath12k_bss_assoc()
2863 lockdep_assert_held(&ar->conf_mutex); in ath12k_bss_assoc()
2865 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %i assoc bssid %pM aid %d\n", in ath12k_bss_assoc()
2866 arvif->vdev_id, arvif->bssid, arvif->aid); in ath12k_bss_assoc()
2870 ap_sta = ieee80211_find_sta(vif, bss_conf->bssid); in ath12k_bss_assoc()
2872 ath12k_warn(ar->ab, "failed to find station entry for bss %pM vdev %i\n", in ath12k_bss_assoc()
2873 bss_conf->bssid, arvif->vdev_id); in ath12k_bss_assoc()
2884 ath12k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n", in ath12k_bss_assoc()
2885 bss_conf->bssid, arvif->vdev_id, ret); in ath12k_bss_assoc()
2889 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath12k_bss_assoc()
2890 ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath12k_bss_assoc()
2891 bss_conf->bssid, arvif->vdev_id); in ath12k_bss_assoc()
2895 ret = ath12k_setup_peer_smps(ar, arvif, bss_conf->bssid, in ath12k_bss_assoc()
2896 &ap_sta->deflink.ht_cap, in ath12k_bss_assoc()
2897 &ap_sta->deflink.he_6ghz_capa); in ath12k_bss_assoc()
2899 ath12k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath12k_bss_assoc()
2900 arvif->vdev_id, ret); in ath12k_bss_assoc()
2904 WARN_ON(arvif->is_up); in ath12k_bss_assoc()
2906 arvif->aid = vif->cfg.aid; in ath12k_bss_assoc()
2907 ether_addr_copy(arvif->bssid, bss_conf->bssid); in ath12k_bss_assoc()
2909 params.vdev_id = arvif->vdev_id; in ath12k_bss_assoc()
2910 params.aid = arvif->aid; in ath12k_bss_assoc()
2911 params.bssid = arvif->bssid; in ath12k_bss_assoc()
2914 ath12k_warn(ar->ab, "failed to set vdev %d up: %d\n", in ath12k_bss_assoc()
2915 arvif->vdev_id, ret); in ath12k_bss_assoc()
2919 arvif->is_up = true; in ath12k_bss_assoc()
2920 arvif->rekey_data.enable_offload = false; in ath12k_bss_assoc()
2922 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_bss_assoc()
2924 arvif->vdev_id, bss_conf->bssid, vif->cfg.aid); in ath12k_bss_assoc()
2926 spin_lock_bh(&ar->ab->base_lock); in ath12k_bss_assoc()
2928 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, arvif->bssid); in ath12k_bss_assoc()
2929 if (peer && peer->is_authorized) in ath12k_bss_assoc()
2932 spin_unlock_bh(&ar->ab->base_lock); in ath12k_bss_assoc()
2936 ret = ath12k_wmi_set_peer_param(ar, arvif->bssid, in ath12k_bss_assoc()
2937 arvif->vdev_id, in ath12k_bss_assoc()
2941 ath12k_warn(ar->ab, "Unable to authorize BSS peer: %d\n", ret); in ath12k_bss_assoc()
2944 ret = ath12k_wmi_send_obss_spr_cmd(ar, arvif->vdev_id, in ath12k_bss_assoc()
2945 &bss_conf->he_obss_pd); in ath12k_bss_assoc()
2947 ath12k_warn(ar->ab, "failed to set vdev %i OBSS PD parameters: %d\n", in ath12k_bss_assoc()
2948 arvif->vdev_id, ret); in ath12k_bss_assoc()
2956 lockdep_assert_held(&ar->conf_mutex); in ath12k_bss_disassoc()
2958 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %i disassoc bssid %pM\n", in ath12k_bss_disassoc()
2959 arvif->vdev_id, arvif->bssid); in ath12k_bss_disassoc()
2961 ret = ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_bss_disassoc()
2963 ath12k_warn(ar->ab, "failed to down vdev %i: %d\n", in ath12k_bss_disassoc()
2964 arvif->vdev_id, ret); in ath12k_bss_disassoc()
2966 arvif->is_up = false; in ath12k_bss_disassoc()
2968 memset(&arvif->rekey_data, 0, sizeof(arvif->rekey_data)); in ath12k_bss_disassoc()
2970 cancel_delayed_work(&arvif->connection_loss_work); in ath12k_bss_disassoc()
2995 return -EINVAL; in ath12k_mac_get_rate_hw_value()
3011 lockdep_assert_held(&ar->conf_mutex); in ath12k_recalculate_mgmt_rate()
3013 sband = hw->wiphy->bands[def->chan->band]; in ath12k_recalculate_mgmt_rate()
3014 basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1; in ath12k_recalculate_mgmt_rate()
3015 bitrate = sband->bitrates[basic_rate_idx].bitrate; in ath12k_recalculate_mgmt_rate()
3019 ath12k_warn(ar->ab, "bitrate not supported %d\n", bitrate); in ath12k_recalculate_mgmt_rate()
3024 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath12k_recalculate_mgmt_rate()
3027 ath12k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret); in ath12k_recalculate_mgmt_rate()
3030 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath12k_recalculate_mgmt_rate()
3033 ath12k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret); in ath12k_recalculate_mgmt_rate()
3039 struct ath12k *ar = arvif->ar; in ath12k_mac_fils_discovery()
3046 if (info->fils_discovery.max_interval) { in ath12k_mac_fils_discovery()
3047 interval = info->fils_discovery.max_interval; in ath12k_mac_fils_discovery()
3049 tmpl = ieee80211_get_fils_discovery_tmpl(hw, arvif->vif); in ath12k_mac_fils_discovery()
3051 ret = ath12k_wmi_fils_discovery_tmpl(ar, arvif->vdev_id, in ath12k_mac_fils_discovery()
3053 } else if (info->unsol_bcast_probe_resp_interval) { in ath12k_mac_fils_discovery()
3055 interval = info->unsol_bcast_probe_resp_interval; in ath12k_mac_fils_discovery()
3058 arvif->vif); in ath12k_mac_fils_discovery()
3060 ret = ath12k_wmi_probe_resp_tmpl(ar, arvif->vdev_id, in ath12k_mac_fils_discovery()
3063 return ath12k_wmi_fils_discovery(ar, arvif->vdev_id, 0, false); in ath12k_mac_fils_discovery()
3067 ath12k_warn(ar->ab, in ath12k_mac_fils_discovery()
3069 arvif->vdev_id, (unsol_bcast_probe_resp_enabled ? in ath12k_mac_fils_discovery()
3072 return -EPERM; in ath12k_mac_fils_discovery()
3077 ret = ath12k_wmi_fils_discovery(ar, arvif->vdev_id, interval, in ath12k_mac_fils_discovery()
3085 struct ath12k *ar = arvif->ar; in ath12k_mac_vif_setup_ps()
3086 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_vif_setup_ps()
3087 struct ieee80211_conf *conf = &ath12k_ar_to_hw(ar)->conf; in ath12k_mac_vif_setup_ps()
3094 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vif_setup_ps()
3096 if (vif->type != NL80211_IFTYPE_STATION) in ath12k_mac_vif_setup_ps()
3099 enable_ps = arvif->ps; in ath12k_mac_vif_setup_ps()
3104 timeout = conf->dynamic_ps_timeout; in ath12k_mac_vif_setup_ps()
3107 timeout = ieee80211_tu_to_usec(vif->bss_conf.beacon_int) / 1000; in ath12k_mac_vif_setup_ps()
3110 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param, in ath12k_mac_vif_setup_ps()
3113 ath12k_warn(ar->ab, "failed to set inactivity time for vdev %d: %i\n", in ath12k_mac_vif_setup_ps()
3114 arvif->vdev_id, ret); in ath12k_mac_vif_setup_ps()
3121 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d psmode %s\n", in ath12k_mac_vif_setup_ps()
3122 arvif->vdev_id, psmode ? "enable" : "disable"); in ath12k_mac_vif_setup_ps()
3124 ret = ath12k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, psmode); in ath12k_mac_vif_setup_ps()
3126 ath12k_warn(ar->ab, "failed to set sta power save mode %d for vdev %d: %d\n", in ath12k_mac_vif_setup_ps()
3127 psmode, arvif->vdev_id, ret); in ath12k_mac_vif_setup_ps()
3135 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_bss_info_changed()
3136 struct ieee80211_vif_cfg *vif_cfg = &vif->cfg; in ath12k_mac_bss_info_changed()
3149 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_bss_info_changed()
3152 arvif->beacon_interval = info->beacon_int; in ath12k_mac_bss_info_changed()
3155 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3157 arvif->beacon_interval); in ath12k_mac_bss_info_changed()
3159 ath12k_warn(ar->ab, "Failed to set beacon interval for VDEV: %d\n", in ath12k_mac_bss_info_changed()
3160 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3162 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3164 arvif->beacon_interval, arvif->vdev_id); in ath12k_mac_bss_info_changed()
3171 param_value, ar->pdev->pdev_id); in ath12k_mac_bss_info_changed()
3173 ath12k_warn(ar->ab, "Failed to set beacon mode for VDEV: %d\n", in ath12k_mac_bss_info_changed()
3174 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3176 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3178 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3182 ath12k_warn(ar->ab, "failed to update bcn template: %d\n", in ath12k_mac_bss_info_changed()
3187 arvif->dtim_period = info->dtim_period; in ath12k_mac_bss_info_changed()
3190 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3192 arvif->dtim_period); in ath12k_mac_bss_info_changed()
3195 ath12k_warn(ar->ab, "Failed to set dtim period for VDEV %d: %i\n", in ath12k_mac_bss_info_changed()
3196 arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3198 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3200 arvif->dtim_period, arvif->vdev_id); in ath12k_mac_bss_info_changed()
3204 vif->type == NL80211_IFTYPE_AP) { in ath12k_mac_bss_info_changed()
3205 arvif->u.ap.ssid_len = vif->cfg.ssid_len; in ath12k_mac_bss_info_changed()
3206 if (vif->cfg.ssid_len) in ath12k_mac_bss_info_changed()
3207 memcpy(arvif->u.ap.ssid, vif->cfg.ssid, vif->cfg.ssid_len); in ath12k_mac_bss_info_changed()
3208 arvif->u.ap.hidden_ssid = info->hidden_ssid; in ath12k_mac_bss_info_changed()
3211 if (changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) in ath12k_mac_bss_info_changed()
3212 ether_addr_copy(arvif->bssid, info->bssid); in ath12k_mac_bss_info_changed()
3217 if (arvif->is_up && vif->bss_conf.he_support && in ath12k_mac_bss_info_changed()
3218 vif->bss_conf.he_oper.params) { in ath12k_mac_bss_info_changed()
3220 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3224 ath12k_warn(ar->ab, in ath12k_mac_bss_info_changed()
3226 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3229 param_value = vif->bss_conf.he_oper.params; in ath12k_mac_bss_info_changed()
3230 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3232 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3234 param_value, arvif->vdev_id); in ath12k_mac_bss_info_changed()
3237 ath12k_warn(ar->ab, "Failed to set he oper params %x for VDEV %d: %i\n", in ath12k_mac_bss_info_changed()
3238 param_value, arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3245 cts_prot = !!(info->use_cts_prot); in ath12k_mac_bss_info_changed()
3248 if (arvif->is_started) { in ath12k_mac_bss_info_changed()
3249 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3252 ath12k_warn(ar->ab, "Failed to set CTS prot for VDEV: %d\n", in ath12k_mac_bss_info_changed()
3253 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3255 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "Set CTS prot: %d for VDEV: %d\n", in ath12k_mac_bss_info_changed()
3256 cts_prot, arvif->vdev_id); in ath12k_mac_bss_info_changed()
3258 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "defer protection mode setup, vdev is not ready yet\n"); in ath12k_mac_bss_info_changed()
3265 if (info->use_short_slot) in ath12k_mac_bss_info_changed()
3272 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3275 ath12k_warn(ar->ab, "Failed to set erp slot for VDEV: %d\n", in ath12k_mac_bss_info_changed()
3276 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3278 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3280 slottime, arvif->vdev_id); in ath12k_mac_bss_info_changed()
3286 if (info->use_short_preamble) in ath12k_mac_bss_info_changed()
3292 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3295 ath12k_warn(ar->ab, "Failed to set preamble for VDEV: %d\n", in ath12k_mac_bss_info_changed()
3296 arvif->vdev_id); in ath12k_mac_bss_info_changed()
3298 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3300 preamble, arvif->vdev_id); in ath12k_mac_bss_info_changed()
3304 if (vif->cfg.assoc) in ath12k_mac_bss_info_changed()
3311 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev_id %i txpower %d\n", in ath12k_mac_bss_info_changed()
3312 arvif->vdev_id, info->txpower); in ath12k_mac_bss_info_changed()
3314 arvif->txpower = info->txpower; in ath12k_mac_bss_info_changed()
3319 !ath12k_mac_vif_chan(arvif->vif, &def)) { in ath12k_mac_bss_info_changed()
3320 band = def.chan->band; in ath12k_mac_bss_info_changed()
3321 mcast_rate = vif->bss_conf.mcast_rate[band]; in ath12k_mac_bss_info_changed()
3324 rateidx = mcast_rate - 1; in ath12k_mac_bss_info_changed()
3326 rateidx = ffs(vif->bss_conf.basic_rates) - 1; in ath12k_mac_bss_info_changed()
3328 if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) in ath12k_mac_bss_info_changed()
3341 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_bss_info_changed()
3343 arvif->vdev_id, rate); in ath12k_mac_bss_info_changed()
3346 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3349 ath12k_warn(ar->ab, in ath12k_mac_bss_info_changed()
3351 arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3354 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3357 ath12k_warn(ar->ab, in ath12k_mac_bss_info_changed()
3359 arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3363 !ath12k_mac_vif_chan(arvif->vif, &def)) in ath12k_mac_bss_info_changed()
3367 if (info->twt_requester || info->twt_responder) in ath12k_mac_bss_info_changed()
3368 ath12k_wmi_send_twt_enable_cmd(ar, ar->pdev->pdev_id); in ath12k_mac_bss_info_changed()
3370 ath12k_wmi_send_twt_disable_cmd(ar, ar->pdev->pdev_id); in ath12k_mac_bss_info_changed()
3374 ath12k_wmi_send_obss_spr_cmd(ar, arvif->vdev_id, in ath12k_mac_bss_info_changed()
3375 &info->he_obss_pd); in ath12k_mac_bss_info_changed()
3378 if (vif->type == NL80211_IFTYPE_AP) { in ath12k_mac_bss_info_changed()
3380 arvif->vdev_id, in ath12k_mac_bss_info_changed()
3381 info->he_bss_color.color, in ath12k_mac_bss_info_changed()
3383 info->he_bss_color.enabled); in ath12k_mac_bss_info_changed()
3385 ath12k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n", in ath12k_mac_bss_info_changed()
3386 arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3387 } else if (vif->type == NL80211_IFTYPE_STATION) { in ath12k_mac_bss_info_changed()
3389 arvif->vdev_id, in ath12k_mac_bss_info_changed()
3392 ath12k_warn(ar->ab, "failed to enable bss color change on vdev %i: %d\n", in ath12k_mac_bss_info_changed()
3393 arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3395 arvif->vdev_id, in ath12k_mac_bss_info_changed()
3400 ath12k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n", in ath12k_mac_bss_info_changed()
3401 arvif->vdev_id, ret); in ath12k_mac_bss_info_changed()
3408 ar->ab->hw_params->supports_sta_ps) { in ath12k_mac_bss_info_changed()
3409 arvif->ps = vif_cfg->ps; in ath12k_mac_bss_info_changed()
3416 if (!arvif->cache) in ath12k_arvif_get_cache()
3417 arvif->cache = kzalloc(sizeof(*arvif->cache), GFP_KERNEL); in ath12k_arvif_get_cache()
3419 return arvif->cache; in ath12k_arvif_get_cache()
3424 kfree(arvif->cache); in ath12k_arvif_put_cache()
3425 arvif->cache = NULL; in ath12k_arvif_put_cache()
3447 arvif->cache->bss_conf_changed |= changed; in ath12k_mac_op_bss_info_changed()
3451 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_bss_info_changed()
3455 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_bss_info_changed()
3463 struct ath12k_hw *ah = hw->priv; in ath12k_mac_select_scan_device()
3468 if (ah->num_radio == 1) in ath12k_mac_select_scan_device()
3469 return ah->radio; in ath12k_mac_select_scan_device()
3487 if (ar->mac.sbands[band].channels) in ath12k_mac_select_scan_device()
3498 lockdep_assert_held(&ar->data_lock); in __ath12k_mac_scan_finish()
3500 switch (ar->scan.state) { in __ath12k_mac_scan_finish()
3505 if (ar->scan.is_roc && ar->scan.roc_notify) in __ath12k_mac_scan_finish()
3509 if (!ar->scan.is_roc) { in __ath12k_mac_scan_finish()
3511 .aborted = ((ar->scan.state == in __ath12k_mac_scan_finish()
3513 (ar->scan.state == in __ath12k_mac_scan_finish()
3520 ar->scan.state = ATH12K_SCAN_IDLE; in __ath12k_mac_scan_finish()
3521 ar->scan_channel = NULL; in __ath12k_mac_scan_finish()
3522 ar->scan.roc_freq = 0; in __ath12k_mac_scan_finish()
3523 cancel_delayed_work(&ar->scan.timeout); in __ath12k_mac_scan_finish()
3524 complete(&ar->scan.completed); in __ath12k_mac_scan_finish()
3531 spin_lock_bh(&ar->data_lock); in ath12k_mac_scan_finish()
3533 spin_unlock_bh(&ar->data_lock); in ath12k_mac_scan_finish()
3544 lockdep_assert_held(&ar->conf_mutex); in ath12k_scan_stop()
3547 arg.pdev_id = ar->pdev->pdev_id; in ath12k_scan_stop()
3551 ath12k_warn(ar->ab, "failed to stop wmi scan: %d\n", ret); in ath12k_scan_stop()
3555 ret = wait_for_completion_timeout(&ar->scan.completed, 3 * HZ); in ath12k_scan_stop()
3557 ath12k_warn(ar->ab, in ath12k_scan_stop()
3559 ret = -ETIMEDOUT; in ath12k_scan_stop()
3572 spin_lock_bh(&ar->data_lock); in ath12k_scan_stop()
3573 if (ar->scan.state != ATH12K_SCAN_IDLE) in ath12k_scan_stop()
3575 spin_unlock_bh(&ar->data_lock); in ath12k_scan_stop()
3584 lockdep_assert_held(&ar->conf_mutex); in ath12k_scan_abort()
3586 spin_lock_bh(&ar->data_lock); in ath12k_scan_abort()
3588 switch (ar->scan.state) { in ath12k_scan_abort()
3596 ath12k_warn(ar->ab, "refusing scan abortion due to invalid scan state: %d\n", in ath12k_scan_abort()
3597 ar->scan.state); in ath12k_scan_abort()
3600 ar->scan.state = ATH12K_SCAN_ABORTING; in ath12k_scan_abort()
3601 spin_unlock_bh(&ar->data_lock); in ath12k_scan_abort()
3605 ath12k_warn(ar->ab, "failed to abort scan: %d\n", ret); in ath12k_scan_abort()
3607 spin_lock_bh(&ar->data_lock); in ath12k_scan_abort()
3611 spin_unlock_bh(&ar->data_lock); in ath12k_scan_abort()
3619 mutex_lock(&ar->conf_mutex); in ath12k_scan_timeout_work()
3621 mutex_unlock(&ar->conf_mutex); in ath12k_scan_timeout_work()
3629 lockdep_assert_held(&ar->conf_mutex); in ath12k_start_scan()
3635 ret = wait_for_completion_timeout(&ar->scan.started, 1 * HZ); in ath12k_start_scan()
3639 ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret); in ath12k_start_scan()
3641 return -ETIMEDOUT; in ath12k_start_scan()
3648 spin_lock_bh(&ar->data_lock); in ath12k_start_scan()
3649 if (ar->scan.state == ATH12K_SCAN_IDLE) { in ath12k_start_scan()
3650 spin_unlock_bh(&ar->data_lock); in ath12k_start_scan()
3651 return -EINVAL; in ath12k_start_scan()
3653 spin_unlock_bh(&ar->data_lock); in ath12k_start_scan()
3665 struct cfg80211_scan_request *req = &hw_req->req; in ath12k_mac_op_hw_scan()
3671 if (ah->num_radio == 1) { in ath12k_mac_op_hw_scan()
3672 WARN_ON(!arvif->is_created); in ath12k_mac_op_hw_scan()
3678 * requested in the hw_req, select the corresponding radio in ath12k_mac_op_hw_scan()
3680 ar = ath12k_mac_select_scan_device(hw, vif, hw_req->req.channels[0]->center_freq); in ath12k_mac_op_hw_scan()
3682 return -EINVAL; in ath12k_mac_op_hw_scan()
3690 * delete-create vdev's for the same ar, in case the request is in ath12k_mac_op_hw_scan()
3693 if (arvif->is_created) { in ath12k_mac_op_hw_scan()
3694 if (WARN_ON(!arvif->ar)) in ath12k_mac_op_hw_scan()
3695 return -EINVAL; in ath12k_mac_op_hw_scan()
3697 if (ar != arvif->ar && arvif->is_started) in ath12k_mac_op_hw_scan()
3698 return -EINVAL; in ath12k_mac_op_hw_scan()
3700 if (ar != arvif->ar) { in ath12k_mac_op_hw_scan()
3702 * would assign the arvif->ar to NULL after the call in ath12k_mac_op_hw_scan()
3704 prev_ar = arvif->ar; in ath12k_mac_op_hw_scan()
3705 mutex_lock(&prev_ar->conf_mutex); in ath12k_mac_op_hw_scan()
3707 mutex_unlock(&prev_ar->conf_mutex); in ath12k_mac_op_hw_scan()
3709 ath12k_warn(prev_ar->ab, in ath12k_mac_op_hw_scan()
3716 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
3718 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
3720 ath12k_warn(ar->ab, "unable to create scan vdev %d\n", ret); in ath12k_mac_op_hw_scan()
3721 return -EINVAL; in ath12k_mac_op_hw_scan()
3725 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
3727 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
3728 switch (ar->scan.state) { in ath12k_mac_op_hw_scan()
3730 reinit_completion(&ar->scan.started); in ath12k_mac_op_hw_scan()
3731 reinit_completion(&ar->scan.completed); in ath12k_mac_op_hw_scan()
3732 ar->scan.state = ATH12K_SCAN_STARTING; in ath12k_mac_op_hw_scan()
3733 ar->scan.is_roc = false; in ath12k_mac_op_hw_scan()
3734 ar->scan.vdev_id = arvif->vdev_id; in ath12k_mac_op_hw_scan()
3740 ret = -EBUSY; in ath12k_mac_op_hw_scan()
3743 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
3750 ret = -ENOMEM; in ath12k_mac_op_hw_scan()
3755 arg->vdev_id = arvif->vdev_id; in ath12k_mac_op_hw_scan()
3756 arg->scan_id = ATH12K_SCAN_ID; in ath12k_mac_op_hw_scan()
3758 if (req->ie_len) { in ath12k_mac_op_hw_scan()
3759 arg->extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL); in ath12k_mac_op_hw_scan()
3760 if (!arg->extraie.ptr) { in ath12k_mac_op_hw_scan()
3761 ret = -ENOMEM; in ath12k_mac_op_hw_scan()
3764 arg->extraie.len = req->ie_len; in ath12k_mac_op_hw_scan()
3767 if (req->n_ssids) { in ath12k_mac_op_hw_scan()
3768 arg->num_ssids = req->n_ssids; in ath12k_mac_op_hw_scan()
3769 for (i = 0; i < arg->num_ssids; i++) in ath12k_mac_op_hw_scan()
3770 arg->ssid[i] = req->ssids[i]; in ath12k_mac_op_hw_scan()
3772 arg->scan_f_passive = 1; in ath12k_mac_op_hw_scan()
3775 if (req->n_channels) { in ath12k_mac_op_hw_scan()
3776 arg->num_chan = req->n_channels; in ath12k_mac_op_hw_scan()
3777 arg->chan_list = kcalloc(arg->num_chan, sizeof(*arg->chan_list), in ath12k_mac_op_hw_scan()
3779 if (!arg->chan_list) { in ath12k_mac_op_hw_scan()
3780 ret = -ENOMEM; in ath12k_mac_op_hw_scan()
3784 for (i = 0; i < arg->num_chan; i++) in ath12k_mac_op_hw_scan()
3785 arg->chan_list[i] = req->channels[i]->center_freq; in ath12k_mac_op_hw_scan()
3790 ath12k_warn(ar->ab, "failed to start hw scan: %d\n", ret); in ath12k_mac_op_hw_scan()
3791 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
3792 ar->scan.state = ATH12K_SCAN_IDLE; in ath12k_mac_op_hw_scan()
3793 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
3797 ieee80211_queue_delayed_work(ath12k_ar_to_hw(ar), &ar->scan.timeout, in ath12k_mac_op_hw_scan()
3798 msecs_to_jiffies(arg->max_scan_time + in ath12k_mac_op_hw_scan()
3803 kfree(arg->chan_list); in ath12k_mac_op_hw_scan()
3804 kfree(arg->extraie.ptr); in ath12k_mac_op_hw_scan()
3808 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
3819 if (!arvif->is_created) in ath12k_mac_op_cancel_hw_scan()
3822 ar = arvif->ar; in ath12k_mac_op_cancel_hw_scan()
3824 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_cancel_hw_scan()
3826 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_cancel_hw_scan()
3828 cancel_delayed_work_sync(&ar->scan.timeout); in ath12k_mac_op_cancel_hw_scan()
3837 struct ath12k *ar = arvif->ar; in ath12k_install_key()
3839 .vdev_id = arvif->vdev_id, in ath12k_install_key()
3840 .key_idx = key->keyidx, in ath12k_install_key()
3841 .key_len = key->keylen, in ath12k_install_key()
3842 .key_data = key->key, in ath12k_install_key()
3847 lockdep_assert_held(&arvif->ar->conf_mutex); in ath12k_install_key()
3849 reinit_completion(&ar->install_key_done); in ath12k_install_key()
3851 if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) in ath12k_install_key()
3862 switch (key->cipher) { in ath12k_install_key()
3865 /* TODO: Re-check if flag is valid */ in ath12k_install_key()
3866 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT; in ath12k_install_key()
3881 ath12k_warn(ar->ab, "cipher %d is not supported\n", key->cipher); in ath12k_install_key()
3882 return -EOPNOTSUPP; in ath12k_install_key()
3885 if (test_bit(ATH12K_FLAG_RAW_MODE, &ar->ab->dev_flags)) in ath12k_install_key()
3886 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV | in ath12k_install_key()
3890 ret = ath12k_wmi_vdev_install_key(arvif->ar, &arg); in ath12k_install_key()
3895 if (!wait_for_completion_timeout(&ar->install_key_done, 1 * HZ)) in ath12k_install_key()
3896 return -ETIMEDOUT; in ath12k_install_key()
3898 if (ether_addr_equal(macaddr, arvif->vif->addr)) in ath12k_install_key()
3899 arvif->key_cipher = key->cipher; in ath12k_install_key()
3901 return ar->install_key_status ? -EINVAL : 0; in ath12k_install_key()
3907 struct ath12k *ar = arvif->ar; in ath12k_clear_peer_keys()
3908 struct ath12k_base *ab = ar->ab; in ath12k_clear_peer_keys()
3915 lockdep_assert_held(&ar->conf_mutex); in ath12k_clear_peer_keys()
3917 spin_lock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3918 peer = ath12k_peer_find(ab, arvif->vdev_id, addr); in ath12k_clear_peer_keys()
3919 spin_unlock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3922 return -ENOENT; in ath12k_clear_peer_keys()
3924 for (i = 0; i < ARRAY_SIZE(peer->keys); i++) { in ath12k_clear_peer_keys()
3925 if (!peer->keys[i]) in ath12k_clear_peer_keys()
3929 ret = ath12k_install_key(arvif, peer->keys[i], in ath12k_clear_peer_keys()
3938 spin_lock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3939 peer->keys[i] = NULL; in ath12k_clear_peer_keys()
3940 spin_unlock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3950 struct ath12k_base *ab = ar->ab; in ath12k_mac_set_key()
3958 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_set_key()
3960 if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags)) in ath12k_mac_set_key()
3964 peer_addr = sta->addr; in ath12k_mac_set_key()
3965 else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath12k_mac_set_key()
3966 peer_addr = vif->bss_conf.bssid; in ath12k_mac_set_key()
3968 peer_addr = vif->addr; in ath12k_mac_set_key()
3970 key->hw_key_idx = key->keyidx; in ath12k_mac_set_key()
3972 /* the peer should not disappear in mid-way (unless FW goes awry) since in ath12k_mac_set_key()
3975 spin_lock_bh(&ab->base_lock); in ath12k_mac_set_key()
3976 peer = ath12k_peer_find(ab, arvif->vdev_id, peer_addr); in ath12k_mac_set_key()
3977 spin_unlock_bh(&ab->base_lock); in ath12k_mac_set_key()
3981 ath12k_warn(ab, "cannot install key for non-existent peer %pM\n", in ath12k_mac_set_key()
3983 ret = -EOPNOTSUPP; in ath12k_mac_set_key()
3993 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in ath12k_mac_set_key()
4010 spin_lock_bh(&ab->base_lock); in ath12k_mac_set_key()
4011 peer = ath12k_peer_find(ab, arvif->vdev_id, peer_addr); in ath12k_mac_set_key()
4013 peer->keys[key->keyidx] = key; in ath12k_mac_set_key()
4014 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in ath12k_mac_set_key()
4015 peer->ucast_keyidx = key->keyidx; in ath12k_mac_set_key()
4016 peer->sec_type = ath12k_dp_tx_get_encrypt_type(key->cipher); in ath12k_mac_set_key()
4018 peer->mcast_keyidx = key->keyidx; in ath12k_mac_set_key()
4019 peer->sec_type_grp = ath12k_dp_tx_get_encrypt_type(key->cipher); in ath12k_mac_set_key()
4022 peer->keys[key->keyidx] = NULL; in ath12k_mac_set_key()
4023 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in ath12k_mac_set_key()
4024 peer->ucast_keyidx = 0; in ath12k_mac_set_key()
4026 peer->mcast_keyidx = 0; in ath12k_mac_set_key()
4034 switch (key->cipher) { in ath12k_mac_set_key()
4041 arsta->pn_type = HAL_PN_TYPE_WPA; in ath12k_mac_set_key()
4043 arsta->pn_type = HAL_PN_TYPE_NONE; in ath12k_mac_set_key()
4046 arsta->pn_type = HAL_PN_TYPE_NONE; in ath12k_mac_set_key()
4051 spin_unlock_bh(&ab->base_lock); in ath12k_mac_set_key()
4067 if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC || in ath12k_mac_op_set_key()
4068 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || in ath12k_mac_op_set_key()
4069 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 || in ath12k_mac_op_set_key()
4070 key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256) in ath12k_mac_op_set_key()
4073 if (key->keyidx > WMI_MAX_KEY_INDEX) in ath12k_mac_op_set_key()
4074 return -ENOSPC; in ath12k_mac_op_set_key()
4081 return -EINVAL; in ath12k_mac_op_set_key()
4086 return -ENOSPC; in ath12k_mac_op_set_key()
4087 cache->key_conf.cmd = cmd; in ath12k_mac_op_set_key()
4088 cache->key_conf.key = key; in ath12k_mac_op_set_key()
4089 cache->key_conf.changed = true; in ath12k_mac_op_set_key()
4093 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_key()
4095 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_key()
4107 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) in ath12k_mac_bitrate_mask_num_vht_rates()
4108 num_rates += hweight16(mask->control[band].vht_mcs[i]); in ath12k_mac_bitrate_mask_num_vht_rates()
4119 struct ath12k *ar = arvif->ar; in ath12k_mac_set_peer_vht_fixed_rate()
4124 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_set_peer_vht_fixed_rate()
4128 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) { in ath12k_mac_set_peer_vht_fixed_rate()
4129 if (hweight16(mask->control[band].vht_mcs[i]) == 1) { in ath12k_mac_set_peer_vht_fixed_rate()
4131 vht_rate = ffs(mask->control[band].vht_mcs[i]) - 1; in ath12k_mac_set_peer_vht_fixed_rate()
4136 ath12k_warn(ar->ab, "No single VHT Fixed rate found to set for %pM", in ath12k_mac_set_peer_vht_fixed_rate()
4137 sta->addr); in ath12k_mac_set_peer_vht_fixed_rate()
4138 return -EINVAL; in ath12k_mac_set_peer_vht_fixed_rate()
4141 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_set_peer_vht_fixed_rate()
4143 sta->addr); in ath12k_mac_set_peer_vht_fixed_rate()
4145 rate_code = ATH12K_HW_RATE_CODE(vht_rate, nss - 1, in ath12k_mac_set_peer_vht_fixed_rate()
4147 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_set_peer_vht_fixed_rate()
4148 arvif->vdev_id, in ath12k_mac_set_peer_vht_fixed_rate()
4152 ath12k_warn(ar->ab, in ath12k_mac_set_peer_vht_fixed_rate()
4154 sta->addr, rate_code, ret); in ath12k_mac_set_peer_vht_fixed_rate()
4172 lockdep_assert_held(&ar->conf_mutex); in ath12k_station_assoc()
4175 return -EPERM; in ath12k_station_assoc()
4177 band = def.chan->band; in ath12k_station_assoc()
4178 mask = &arvif->bitrate_mask; in ath12k_station_assoc()
4183 ath12k_warn(ar->ab, in ath12k_station_assoc()
4185 return -EINVAL; in ath12k_station_assoc()
4189 ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", in ath12k_station_assoc()
4190 sta->addr, arvif->vdev_id, ret); in ath12k_station_assoc()
4194 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath12k_station_assoc()
4195 ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath12k_station_assoc()
4196 sta->addr, arvif->vdev_id); in ath12k_station_assoc()
4197 return -ETIMEDOUT; in ath12k_station_assoc()
4207 if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) { in ath12k_station_assoc()
4214 /* Re-assoc is run only to update supported rates for given station. It in ath12k_station_assoc()
4220 ret = ath12k_setup_peer_smps(ar, arvif, sta->addr, in ath12k_station_assoc()
4221 &sta->deflink.ht_cap, in ath12k_station_assoc()
4222 &sta->deflink.he_6ghz_capa); in ath12k_station_assoc()
4224 ath12k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath12k_station_assoc()
4225 arvif->vdev_id, ret); in ath12k_station_assoc()
4229 if (!sta->wme) { in ath12k_station_assoc()
4230 arvif->num_legacy_stations++; in ath12k_station_assoc()
4236 if (sta->wme && sta->uapsd_queues) { in ath12k_station_assoc()
4239 ath12k_warn(ar->ab, "failed to set qos params for STA %pM for vdev %i: %d\n", in ath12k_station_assoc()
4240 sta->addr, arvif->vdev_id, ret); in ath12k_station_assoc()
4255 lockdep_assert_held(&ar->conf_mutex); in ath12k_station_disassoc()
4257 if (!sta->wme) { in ath12k_station_disassoc()
4258 arvif->num_legacy_stations--; in ath12k_station_disassoc()
4264 ret = ath12k_clear_peer_keys(arvif, sta->addr); in ath12k_station_disassoc()
4266 ath12k_warn(ar->ab, "failed to clear all peer keys for vdev %i: %d\n", in ath12k_station_disassoc()
4267 arvif->vdev_id, ret); in ath12k_station_disassoc()
4291 arvif = arsta->arvif; in ath12k_sta_rc_update_wk()
4292 ar = arvif->ar; in ath12k_sta_rc_update_wk()
4294 if (WARN_ON(ath12k_mac_vif_chan(arvif->vif, &def))) in ath12k_sta_rc_update_wk()
4297 band = def.chan->band; in ath12k_sta_rc_update_wk()
4298 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath12k_sta_rc_update_wk()
4299 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath12k_sta_rc_update_wk()
4301 spin_lock_bh(&ar->data_lock); in ath12k_sta_rc_update_wk()
4303 changed = arsta->changed; in ath12k_sta_rc_update_wk()
4304 arsta->changed = 0; in ath12k_sta_rc_update_wk()
4306 bw = arsta->bw; in ath12k_sta_rc_update_wk()
4307 bw_prev = arsta->bw_prev; in ath12k_sta_rc_update_wk()
4308 nss = arsta->nss; in ath12k_sta_rc_update_wk()
4309 smps = arsta->smps; in ath12k_sta_rc_update_wk()
4311 spin_unlock_bh(&ar->data_lock); in ath12k_sta_rc_update_wk()
4313 mutex_lock(&ar->conf_mutex); in ath12k_sta_rc_update_wk()
4320 ath12k_peer_assoc_h_phymode(ar, arvif->vif, sta, &peer_arg); in ath12k_sta_rc_update_wk()
4329 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac bandwidth upgrade for sta %pM new %d old %d\n", in ath12k_sta_rc_update_wk()
4330 sta->addr, bw, bw_prev); in ath12k_sta_rc_update_wk()
4331 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
4332 arvif->vdev_id, WMI_PEER_PHYMODE, in ath12k_sta_rc_update_wk()
4335 ath12k_warn(ar->ab, "failed to update STA %pM to peer phymode %d: %d\n", in ath12k_sta_rc_update_wk()
4336 sta->addr, peer_phymode, err); in ath12k_sta_rc_update_wk()
4339 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
4340 arvif->vdev_id, WMI_PEER_CHWIDTH, in ath12k_sta_rc_update_wk()
4343 ath12k_warn(ar->ab, "failed to update STA %pM to peer bandwidth %d: %d\n", in ath12k_sta_rc_update_wk()
4344 sta->addr, bw, err); in ath12k_sta_rc_update_wk()
4350 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac bandwidth downgrade for sta %pM new %d old %d\n", in ath12k_sta_rc_update_wk()
4351 sta->addr, bw, bw_prev); in ath12k_sta_rc_update_wk()
4352 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
4353 arvif->vdev_id, WMI_PEER_CHWIDTH, in ath12k_sta_rc_update_wk()
4356 ath12k_warn(ar->ab, "failed to update STA %pM peer to bandwidth %d: %d\n", in ath12k_sta_rc_update_wk()
4357 sta->addr, bw, err); in ath12k_sta_rc_update_wk()
4360 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
4361 arvif->vdev_id, WMI_PEER_PHYMODE, in ath12k_sta_rc_update_wk()
4364 ath12k_warn(ar->ab, "failed to update STA %pM to peer phymode %d: %d\n", in ath12k_sta_rc_update_wk()
4365 sta->addr, peer_phymode, err); in ath12k_sta_rc_update_wk()
4370 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac update sta %pM nss %d\n", in ath12k_sta_rc_update_wk()
4371 sta->addr, nss); in ath12k_sta_rc_update_wk()
4373 err = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath12k_sta_rc_update_wk()
4376 ath12k_warn(ar->ab, "failed to update STA %pM nss %d: %d\n", in ath12k_sta_rc_update_wk()
4377 sta->addr, nss, err); in ath12k_sta_rc_update_wk()
4381 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac update sta %pM smps %d\n", in ath12k_sta_rc_update_wk()
4382 sta->addr, smps); in ath12k_sta_rc_update_wk()
4384 err = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath12k_sta_rc_update_wk()
4387 ath12k_warn(ar->ab, "failed to update STA %pM smps %d: %d\n", in ath12k_sta_rc_update_wk()
4388 sta->addr, smps, err); in ath12k_sta_rc_update_wk()
4392 mask = &arvif->bitrate_mask; in ath12k_sta_rc_update_wk()
4400 * But, Single rate in VHT mask can be set as per-peer in ath12k_sta_rc_update_wk()
4403 * when per-peer Fixed rate is set. in ath12k_sta_rc_update_wk()
4407 if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) { in ath12k_sta_rc_update_wk()
4411 /* If the peer is non-VHT or no fixed VHT rate in ath12k_sta_rc_update_wk()
4415 ath12k_peer_assoc_prepare(ar, arvif->vif, sta, in ath12k_sta_rc_update_wk()
4420 ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", in ath12k_sta_rc_update_wk()
4421 sta->addr, arvif->vdev_id, err); in ath12k_sta_rc_update_wk()
4423 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) in ath12k_sta_rc_update_wk()
4424 ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath12k_sta_rc_update_wk()
4425 sta->addr, arvif->vdev_id); in ath12k_sta_rc_update_wk()
4429 mutex_unlock(&ar->conf_mutex); in ath12k_sta_rc_update_wk()
4435 struct ath12k *ar = arvif->ar; in ath12k_mac_inc_num_stations()
4437 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_inc_num_stations()
4439 if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls) in ath12k_mac_inc_num_stations()
4442 if (ar->num_stations >= ar->max_num_stations) in ath12k_mac_inc_num_stations()
4443 return -ENOBUFS; in ath12k_mac_inc_num_stations()
4445 ar->num_stations++; in ath12k_mac_inc_num_stations()
4453 struct ath12k *ar = arvif->ar; in ath12k_mac_dec_num_stations()
4455 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_dec_num_stations()
4457 if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls) in ath12k_mac_dec_num_stations()
4460 ar->num_stations--; in ath12k_mac_dec_num_stations()
4467 struct ath12k_base *ab = ar->ab; in ath12k_mac_station_add()
4473 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_station_add()
4478 ar->max_num_stations); in ath12k_mac_station_add()
4482 arsta->rx_stats = kzalloc(sizeof(*arsta->rx_stats), GFP_KERNEL); in ath12k_mac_station_add()
4483 if (!arsta->rx_stats) { in ath12k_mac_station_add()
4484 ret = -ENOMEM; in ath12k_mac_station_add()
4488 peer_param.vdev_id = arvif->vdev_id; in ath12k_mac_station_add()
4489 peer_param.peer_addr = sta->addr; in ath12k_mac_station_add()
4495 sta->addr, arvif->vdev_id); in ath12k_mac_station_add()
4500 sta->addr, arvif->vdev_id); in ath12k_mac_station_add()
4503 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_station_add()
4504 arvif->vdev_id, in ath12k_mac_station_add()
4508 sta->addr, ret); in ath12k_mac_station_add()
4513 ret = ath12k_dp_peer_setup(ar, arvif->vdev_id, sta->addr); in ath12k_mac_station_add()
4516 sta->addr, arvif->vdev_id, ret); in ath12k_mac_station_add()
4520 if (ab->hw_params->vdev_start_delay && in ath12k_mac_station_add()
4521 !arvif->is_started && in ath12k_mac_station_add()
4522 arvif->vdev_type != WMI_VDEV_TYPE_AP) { in ath12k_mac_station_add()
4533 ath12k_peer_delete(ar, arvif->vdev_id, sta->addr); in ath12k_mac_station_add()
4545 switch (sta->deflink.bandwidth) { in ath12k_mac_ieee80211_sta_bw_to_wmi()
4562 ath12k_warn(ar->ab, "Invalid bandwidth %d in rc update for %pM\n", in ath12k_mac_ieee80211_sta_bw_to_wmi()
4563 sta->deflink.bandwidth, sta->addr); in ath12k_mac_ieee80211_sta_bw_to_wmi()
4586 cancel_work_sync(&arsta->update_wk); in ath12k_mac_op_sta_state()
4591 return -EINVAL; in ath12k_mac_op_sta_state()
4594 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_sta_state()
4599 arsta->arvif = arvif; in ath12k_mac_op_sta_state()
4600 INIT_WORK(&arsta->update_wk, ath12k_sta_rc_update_wk); in ath12k_mac_op_sta_state()
4604 ath12k_warn(ar->ab, "Failed to add station: %pM for VDEV: %d\n", in ath12k_mac_op_sta_state()
4605 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
4608 if (arvif->vdev_type == WMI_VDEV_TYPE_STA) { in ath12k_mac_op_sta_state()
4612 ath12k_warn(ar->ab, "failed to stop vdev %i: %d\n", in ath12k_mac_op_sta_state()
4613 arvif->vdev_id, ret); in ath12k_mac_op_sta_state()
4615 ath12k_dp_peer_cleanup(ar, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
4617 ret = ath12k_peer_delete(ar, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
4619 ath12k_warn(ar->ab, "Failed to delete peer: %pM for VDEV: %d\n", in ath12k_mac_op_sta_state()
4620 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
4622 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "Removed peer: %pM for VDEV: %d\n", in ath12k_mac_op_sta_state()
4623 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
4626 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
4627 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
4628 if (peer && peer->sta == sta) { in ath12k_mac_op_sta_state()
4629 ath12k_warn(ar->ab, "Found peer entry %pM n vdev %i after it was supposedly removed\n", in ath12k_mac_op_sta_state()
4630 vif->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
4631 peer->sta = NULL; in ath12k_mac_op_sta_state()
4632 list_del(&peer->list); in ath12k_mac_op_sta_state()
4634 ar->num_peers--; in ath12k_mac_op_sta_state()
4636 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
4638 kfree(arsta->rx_stats); in ath12k_mac_op_sta_state()
4639 arsta->rx_stats = NULL; in ath12k_mac_op_sta_state()
4642 (vif->type == NL80211_IFTYPE_AP || in ath12k_mac_op_sta_state()
4643 vif->type == NL80211_IFTYPE_MESH_POINT || in ath12k_mac_op_sta_state()
4644 vif->type == NL80211_IFTYPE_ADHOC)) { in ath12k_mac_op_sta_state()
4647 ath12k_warn(ar->ab, "Failed to associate station: %pM\n", in ath12k_mac_op_sta_state()
4648 sta->addr); in ath12k_mac_op_sta_state()
4650 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_sta_state()
4652 arsta->bw = ath12k_mac_ieee80211_sta_bw_to_wmi(ar, sta); in ath12k_mac_op_sta_state()
4653 arsta->bw_prev = sta->deflink.bandwidth; in ath12k_mac_op_sta_state()
4655 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_sta_state()
4658 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
4660 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
4662 peer->is_authorized = true; in ath12k_mac_op_sta_state()
4664 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
4666 if (vif->type == NL80211_IFTYPE_STATION && arvif->is_up) { in ath12k_mac_op_sta_state()
4667 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_op_sta_state()
4668 arvif->vdev_id, in ath12k_mac_op_sta_state()
4672 ath12k_warn(ar->ab, "Unable to authorize peer %pM vdev %d: %d\n", in ath12k_mac_op_sta_state()
4673 sta->addr, arvif->vdev_id, ret); in ath12k_mac_op_sta_state()
4677 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
4679 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
4681 peer->is_authorized = false; in ath12k_mac_op_sta_state()
4683 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
4686 (vif->type == NL80211_IFTYPE_AP || in ath12k_mac_op_sta_state()
4687 vif->type == NL80211_IFTYPE_MESH_POINT || in ath12k_mac_op_sta_state()
4688 vif->type == NL80211_IFTYPE_ADHOC)) { in ath12k_mac_op_sta_state()
4691 ath12k_warn(ar->ab, "Failed to disassociate station: %pM\n", in ath12k_mac_op_sta_state()
4692 sta->addr); in ath12k_mac_op_sta_state()
4695 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_sta_state()
4710 if (sta->deflink.txpwr.type == NL80211_TX_POWER_AUTOMATIC) { in ath12k_mac_op_sta_set_txpwr()
4713 txpwr = sta->deflink.txpwr.power; in ath12k_mac_op_sta_set_txpwr()
4715 return -EINVAL; in ath12k_mac_op_sta_set_txpwr()
4719 return -EINVAL; in ath12k_mac_op_sta_set_txpwr()
4723 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_sta_set_txpwr()
4725 ret = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath12k_mac_op_sta_set_txpwr()
4728 ath12k_warn(ar->ab, "failed to set tx power for station ret: %d\n", in ath12k_mac_op_sta_set_txpwr()
4734 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_sta_set_txpwr()
4755 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_rc_update()
4757 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_rc_update()
4759 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_rc_update()
4760 ath12k_warn(ar->ab, "mac sta rc update failed to find peer %pM on vdev %i\n", in ath12k_mac_op_sta_rc_update()
4761 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_rc_update()
4765 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_rc_update()
4767 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_sta_rc_update()
4769 sta->addr, changed, sta->deflink.bandwidth, sta->deflink.rx_nss, in ath12k_mac_op_sta_rc_update()
4770 sta->deflink.smps_mode); in ath12k_mac_op_sta_rc_update()
4772 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_sta_rc_update()
4776 arsta->bw_prev = arsta->bw; in ath12k_mac_op_sta_rc_update()
4777 arsta->bw = bw; in ath12k_mac_op_sta_rc_update()
4781 arsta->nss = sta->deflink.rx_nss; in ath12k_mac_op_sta_rc_update()
4786 switch (sta->deflink.smps_mode) { in ath12k_mac_op_sta_rc_update()
4798 ath12k_warn(ar->ab, "Invalid smps %d in sta rc update for %pM\n", in ath12k_mac_op_sta_rc_update()
4799 sta->deflink.smps_mode, sta->addr); in ath12k_mac_op_sta_rc_update()
4804 arsta->smps = smps; in ath12k_mac_op_sta_rc_update()
4807 arsta->changed |= changed; in ath12k_mac_op_sta_rc_update()
4809 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_sta_rc_update()
4811 ieee80211_queue_work(hw, &arsta->update_wk); in ath12k_mac_op_sta_rc_update()
4817 struct ath12k *ar = arvif->ar; in ath12k_conf_tx_uapsd()
4821 if (arvif->vdev_type != WMI_VDEV_TYPE_STA) in ath12k_conf_tx_uapsd()
4844 arvif->u.sta.uapsd |= value; in ath12k_conf_tx_uapsd()
4846 arvif->u.sta.uapsd &= ~value; in ath12k_conf_tx_uapsd()
4848 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_conf_tx_uapsd()
4850 arvif->u.sta.uapsd); in ath12k_conf_tx_uapsd()
4852 ath12k_warn(ar->ab, "could not set uapsd params %d\n", ret); in ath12k_conf_tx_uapsd()
4856 if (arvif->u.sta.uapsd) in ath12k_conf_tx_uapsd()
4861 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_conf_tx_uapsd()
4865 ath12k_warn(ar->ab, "could not set rx wake param %d\n", ret); in ath12k_conf_tx_uapsd()
4876 struct ath12k *ar = arvif->ar; in ath12k_mac_conf_tx()
4877 struct ath12k_base *ab = ar->ab; in ath12k_mac_conf_tx()
4880 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_conf_tx()
4884 p = &arvif->wmm_params.ac_vo; in ath12k_mac_conf_tx()
4887 p = &arvif->wmm_params.ac_vi; in ath12k_mac_conf_tx()
4890 p = &arvif->wmm_params.ac_be; in ath12k_mac_conf_tx()
4893 p = &arvif->wmm_params.ac_bk; in ath12k_mac_conf_tx()
4898 ret = -EINVAL; in ath12k_mac_conf_tx()
4902 p->cwmin = params->cw_min; in ath12k_mac_conf_tx()
4903 p->cwmax = params->cw_max; in ath12k_mac_conf_tx()
4904 p->aifs = params->aifs; in ath12k_mac_conf_tx()
4905 p->txop = params->txop; in ath12k_mac_conf_tx()
4907 ret = ath12k_wmi_send_wmm_update_cmd(ar, arvif->vdev_id, in ath12k_mac_conf_tx()
4908 &arvif->wmm_params); in ath12k_mac_conf_tx()
4911 ar->pdev_idx, ret); in ath12k_mac_conf_tx()
4915 ret = ath12k_conf_tx_uapsd(arvif, ac, params->uapsd); in ath12k_mac_conf_tx()
4918 ar->pdev_idx, ret); in ath12k_mac_conf_tx()
4931 struct ath12k_vif_cache *cache = arvif->cache; in ath12k_mac_op_conf_tx()
4939 return -ENOSPC; in ath12k_mac_op_conf_tx()
4940 cache->tx_conf.changed = true; in ath12k_mac_op_conf_tx()
4941 cache->tx_conf.ac = ac; in ath12k_mac_op_conf_tx()
4942 cache->tx_conf.tx_queue_params = *params; in ath12k_mac_op_conf_tx()
4946 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_conf_tx()
4948 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_conf_tx()
4958 u32 ar_vht_cap = ar->pdev->cap.vht_cap; in ath12k_create_ht_cap()
5009 for (i = 0; i < ar->num_rx_chains; i++) { in ath12k_create_ht_cap()
5022 struct ath12k *ar = arvif->ar; in ath12k_mac_set_txbf_conf()
5025 u32 vht_cap = ar->pdev->cap.vht_cap; in ath12k_mac_set_txbf_conf()
5038 if (sound_dim > (ar->num_tx_chains - 1)) in ath12k_mac_set_txbf_conf()
5039 sound_dim = ar->num_tx_chains - 1; in ath12k_mac_set_txbf_conf()
5050 arvif->vdev_type == WMI_VDEV_TYPE_AP) in ath12k_mac_set_txbf_conf()
5058 arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath12k_mac_set_txbf_conf()
5062 return ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_txbf_conf()
5074 if (ar->num_tx_chains < 2) { in ath12k_set_vht_txbf_cap()
5096 if (sound_dim > (ar->num_tx_chains - 1)) in ath12k_set_vht_txbf_cap()
5097 sound_dim = ar->num_tx_chains - 1; in ath12k_set_vht_txbf_cap()
5117 vht_cap.cap = ar->pdev->cap.vht_cap; in ath12k_create_vht_cap()
5129 if (i < ar->num_tx_chains && rate_cap_tx_chainmask & BIT(i)) in ath12k_create_vht_cap()
5134 if (i < ar->num_rx_chains && rate_cap_rx_chainmask & BIT(i)) in ath12k_create_vht_cap()
5158 rate_cap_tx_chainmask = ar->cfg_tx_chainmask >> cap->tx_chain_mask_shift; in ath12k_mac_setup_ht_vht_cap()
5159 rate_cap_rx_chainmask = ar->cfg_rx_chainmask >> cap->rx_chain_mask_shift; in ath12k_mac_setup_ht_vht_cap()
5161 if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_setup_ht_vht_cap()
5162 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath12k_mac_setup_ht_vht_cap()
5163 ht_cap = cap->band[NL80211_BAND_2GHZ].ht_cap_info; in ath12k_mac_setup_ht_vht_cap()
5166 band->ht_cap = ath12k_create_ht_cap(ar, ht_cap, in ath12k_mac_setup_ht_vht_cap()
5170 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && in ath12k_mac_setup_ht_vht_cap()
5171 (ar->ab->hw_params->single_pdev_only || in ath12k_mac_setup_ht_vht_cap()
5172 !ar->supports_6ghz)) { in ath12k_mac_setup_ht_vht_cap()
5173 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath12k_mac_setup_ht_vht_cap()
5174 ht_cap = cap->band[NL80211_BAND_5GHZ].ht_cap_info; in ath12k_mac_setup_ht_vht_cap()
5177 band->ht_cap = ath12k_create_ht_cap(ar, ht_cap, in ath12k_mac_setup_ht_vht_cap()
5179 band->vht_cap = ath12k_create_vht_cap(ar, rate_cap_tx_chainmask, in ath12k_mac_setup_ht_vht_cap()
5199 he_ppet[0] = fw_ppet->numss_m1 & IEEE80211_PPE_THRES_NSS_MASK; in ath12k_gen_ppe_thresh()
5200 he_ppet[0] |= (fw_ppet->ru_bit_mask << in ath12k_gen_ppe_thresh()
5203 for (nss = 0; nss <= fw_ppet->numss_m1; nss++) { in ath12k_gen_ppe_thresh()
5208 if ((fw_ppet->ru_bit_mask & BIT(ru)) == 0) in ath12k_gen_ppe_thresh()
5210 val = (fw_ppet->ppet16_ppet8_ru3_ru0[nss] >> (ru * 6)) & in ath12k_gen_ppe_thresh()
5213 for (i = 5; i >= 0; i--) { in ath12k_gen_ppe_thresh()
5229 he_cap_elem->mac_cap_info[0] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5234 he_cap_elem->mac_cap_info[2] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5239 he_cap_elem->mac_cap_info[3] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5243 he_cap_elem->mac_cap_info[4] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5249 he_cap_elem->mac_cap_info[5] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5253 he_cap_elem->phy_cap_info[2] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5258 he_cap_elem->phy_cap_info[3] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5261 he_cap_elem->phy_cap_info[4] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5264 he_cap_elem->phy_cap_info[5] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5270 he_cap_elem->phy_cap_info[6] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5276 he_cap_elem->phy_cap_info[7] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5282 he_cap_elem->phy_cap_info[8] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5290 he_cap_elem->phy_cap_info[9] &= ~m; in ath12k_mac_filter_he_cap_mesh()
5298 bcap->he_6ghz_capa = IEEE80211_HT_MPDU_DENSITY_NONE; in ath12k_mac_setup_he_6ghz_cap()
5299 if (bcap->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS) in ath12k_mac_setup_he_6ghz_cap()
5300 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
5304 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
5307 val = u32_get_bits(pcap->vht_cap, in ath12k_mac_setup_he_6ghz_cap()
5309 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
5311 val = u32_get_bits(pcap->vht_cap, in ath12k_mac_setup_he_6ghz_cap()
5313 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
5315 if (pcap->vht_cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN) in ath12k_mac_setup_he_6ghz_cap()
5316 bcap->he_6ghz_capa |= IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS; in ath12k_mac_setup_he_6ghz_cap()
5317 if (pcap->vht_cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN) in ath12k_mac_setup_he_6ghz_cap()
5318 bcap->he_6ghz_capa |= IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS; in ath12k_mac_setup_he_6ghz_cap()
5320 return cpu_to_le16(bcap->he_6ghz_capa); in ath12k_mac_setup_he_6ghz_cap()
5327 struct ieee80211_he_cap_elem *he_cap_elem = &he_cap->he_cap_elem; in ath12k_mac_copy_he_cap()
5328 struct ieee80211_he_mcs_nss_supp *mcs_nss = &he_cap->he_mcs_nss_supp; in ath12k_mac_copy_he_cap()
5330 he_cap->has_he = true; in ath12k_mac_copy_he_cap()
5331 memcpy(he_cap_elem->mac_cap_info, band_cap->he_cap_info, in ath12k_mac_copy_he_cap()
5332 sizeof(he_cap_elem->mac_cap_info)); in ath12k_mac_copy_he_cap()
5333 memcpy(he_cap_elem->phy_cap_info, band_cap->he_cap_phy_info, in ath12k_mac_copy_he_cap()
5334 sizeof(he_cap_elem->phy_cap_info)); in ath12k_mac_copy_he_cap()
5336 he_cap_elem->mac_cap_info[1] &= in ath12k_mac_copy_he_cap()
5339 he_cap_elem->phy_cap_info[5] &= in ath12k_mac_copy_he_cap()
5341 he_cap_elem->phy_cap_info[5] &= in ath12k_mac_copy_he_cap()
5343 he_cap_elem->phy_cap_info[5] |= num_tx_chains - 1; in ath12k_mac_copy_he_cap()
5347 he_cap_elem->phy_cap_info[3] &= in ath12k_mac_copy_he_cap()
5349 he_cap_elem->phy_cap_info[9] |= in ath12k_mac_copy_he_cap()
5353 he_cap_elem->mac_cap_info[0] &= ~IEEE80211_HE_MAC_CAP0_TWT_RES; in ath12k_mac_copy_he_cap()
5354 he_cap_elem->mac_cap_info[0] |= IEEE80211_HE_MAC_CAP0_TWT_REQ; in ath12k_mac_copy_he_cap()
5355 he_cap_elem->phy_cap_info[9] |= in ath12k_mac_copy_he_cap()
5363 mcs_nss->rx_mcs_80 = cpu_to_le16(band_cap->he_mcs & 0xffff); in ath12k_mac_copy_he_cap()
5364 mcs_nss->tx_mcs_80 = cpu_to_le16(band_cap->he_mcs & 0xffff); in ath12k_mac_copy_he_cap()
5365 mcs_nss->rx_mcs_160 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
5366 mcs_nss->tx_mcs_160 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
5367 mcs_nss->rx_mcs_80p80 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
5368 mcs_nss->tx_mcs_80p80 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
5370 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres)); in ath12k_mac_copy_he_cap()
5371 if (he_cap_elem->phy_cap_info[6] & in ath12k_mac_copy_he_cap()
5373 ath12k_gen_ppe_thresh(&band_cap->he_ppet, he_cap->ppe_thres); in ath12k_mac_copy_he_cap()
5382 if ((he_cap->phy_cap_info[0] & in ath12k_mac_copy_eht_mcs_nss()
5387 memcpy(&mcs_nss->only_20mhz, &band_cap->eht_mcs_20_only, in ath12k_mac_copy_eht_mcs_nss()
5390 if (he_cap->phy_cap_info[0] & in ath12k_mac_copy_eht_mcs_nss()
5393 memcpy(&mcs_nss->bw._80, &band_cap->eht_mcs_80, in ath12k_mac_copy_eht_mcs_nss()
5396 if (he_cap->phy_cap_info[0] & in ath12k_mac_copy_eht_mcs_nss()
5398 memcpy(&mcs_nss->bw._160, &band_cap->eht_mcs_160, in ath12k_mac_copy_eht_mcs_nss()
5401 if (eht_cap->phy_cap_info[0] & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ) in ath12k_mac_copy_eht_mcs_nss()
5402 memcpy(&mcs_nss->bw._320, &band_cap->eht_mcs_320, in ath12k_mac_copy_eht_mcs_nss()
5412 u8p_replace_bits(&cap->eht_ppe_thres[0], fw_ppet->numss_m1, in ath12k_mac_copy_eht_ppe_thresh()
5415 u16p_replace_bits((u16 *)&cap->eht_ppe_thres[0], fw_ppet->ru_bit_mask, in ath12k_mac_copy_eht_ppe_thresh()
5418 for (nss = 0; nss <= fw_ppet->numss_m1; nss++) { in ath12k_mac_copy_eht_ppe_thresh()
5424 if ((fw_ppet->ru_bit_mask & BIT(ru)) == 0) in ath12k_mac_copy_eht_ppe_thresh()
5427 u32p_replace_bits(&val, fw_ppet->ppet16_ppet8_ru3_ru0[nss] >> in ath12k_mac_copy_eht_ppe_thresh()
5429 GENMASK(ppet_bit_len_per_ru - 1, 0)); in ath12k_mac_copy_eht_ppe_thresh()
5432 cap->eht_ppe_thres[bit / 8] |= in ath12k_mac_copy_eht_ppe_thresh()
5447 eht_cap_elem->mac_cap_info[0] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5450 eht_cap_elem->phy_cap_info[0] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5456 eht_cap_elem->phy_cap_info[3] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5462 eht_cap_elem->phy_cap_info[4] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5468 eht_cap_elem->phy_cap_info[5] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5471 eht_cap_elem->phy_cap_info[6] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5479 eht_cap_elem->phy_cap_info[7] &= ~m; in ath12k_mac_filter_eht_cap_mesh()
5488 struct ieee80211_eht_cap_elem_fixed *eht_cap_elem = &eht_cap->eht_cap_elem; in ath12k_mac_copy_eht_cap()
5492 if (!(test_bit(WMI_TLV_SERVICE_11BE, ar->ab->wmi_ab.svc_map))) in ath12k_mac_copy_eht_cap()
5495 eht_cap->has_eht = true; in ath12k_mac_copy_eht_cap()
5496 memcpy(eht_cap_elem->mac_cap_info, band_cap->eht_cap_mac_info, in ath12k_mac_copy_eht_cap()
5497 sizeof(eht_cap_elem->mac_cap_info)); in ath12k_mac_copy_eht_cap()
5498 memcpy(eht_cap_elem->phy_cap_info, band_cap->eht_cap_phy_info, in ath12k_mac_copy_eht_cap()
5499 sizeof(eht_cap_elem->phy_cap_info)); in ath12k_mac_copy_eht_cap()
5503 eht_cap_elem->phy_cap_info[0] &= in ath12k_mac_copy_eht_cap()
5505 eht_cap_elem->phy_cap_info[4] &= in ath12k_mac_copy_eht_cap()
5507 eht_cap_elem->phy_cap_info[5] &= in ath12k_mac_copy_eht_cap()
5511 eht_cap_elem->phy_cap_info[7] &= in ath12k_mac_copy_eht_cap()
5515 eht_cap_elem->phy_cap_info[7] &= in ath12k_mac_copy_eht_cap()
5527 ath12k_mac_copy_eht_mcs_nss(band_cap, &eht_cap->eht_mcs_nss_supp, in ath12k_mac_copy_eht_cap()
5530 if (eht_cap_elem->phy_cap_info[5] & in ath12k_mac_copy_eht_cap()
5532 ath12k_mac_copy_eht_ppe_thresh(&band_cap->eht_ppet, eht_cap); in ath12k_mac_copy_eht_cap()
5540 struct ath12k_band_cap *band_cap = &cap->band[band]; in ath12k_mac_copy_sband_iftype_data()
5558 ath12k_mac_copy_he_cap(band_cap, i, ar->num_tx_chains, he_cap); in ath12k_mac_copy_sband_iftype_data()
5563 ath12k_mac_copy_eht_cap(ar, band_cap, &he_cap->he_cap_elem, i, in ath12k_mac_copy_sband_iftype_data()
5578 if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_setup_sband_iftype_data()
5581 ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
5583 sband = &ar->mac.sbands[band]; in ath12k_mac_setup_sband_iftype_data()
5584 _ieee80211_set_sband_iftype_data(sband, ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
5588 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath12k_mac_setup_sband_iftype_data()
5591 ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
5593 sband = &ar->mac.sbands[band]; in ath12k_mac_setup_sband_iftype_data()
5594 _ieee80211_set_sband_iftype_data(sband, ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
5598 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && in ath12k_mac_setup_sband_iftype_data()
5599 ar->supports_6ghz) { in ath12k_mac_setup_sband_iftype_data()
5602 ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
5604 sband = &ar->mac.sbands[band]; in ath12k_mac_setup_sband_iftype_data()
5605 _ieee80211_set_sband_iftype_data(sband, ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
5615 lockdep_assert_held(&ar->conf_mutex); in __ath12k_set_antenna()
5618 return -EINVAL; in __ath12k_set_antenna()
5621 return -EINVAL; in __ath12k_set_antenna()
5627 tx_ant = min_t(u32, tx_ant, ar->pdev->cap.tx_chain_mask); in __ath12k_set_antenna()
5628 rx_ant = min_t(u32, rx_ant, ar->pdev->cap.rx_chain_mask); in __ath12k_set_antenna()
5630 ar->cfg_tx_chainmask = tx_ant; in __ath12k_set_antenna()
5631 ar->cfg_rx_chainmask = rx_ant; in __ath12k_set_antenna()
5633 if (ah->state != ATH12K_HW_STATE_ON && in __ath12k_set_antenna()
5634 ah->state != ATH12K_HW_STATE_RESTARTED) in __ath12k_set_antenna()
5638 tx_ant, ar->pdev->pdev_id); in __ath12k_set_antenna()
5640 ath12k_warn(ar->ab, "failed to set tx-chainmask: %d, req 0x%x\n", in __ath12k_set_antenna()
5645 ar->num_tx_chains = hweight32(tx_ant); in __ath12k_set_antenna()
5648 rx_ant, ar->pdev->pdev_id); in __ath12k_set_antenna()
5650 ath12k_warn(ar->ab, "failed to set rx-chainmask: %d, req 0x%x\n", in __ath12k_set_antenna()
5655 ar->num_rx_chains = hweight32(rx_ant); in __ath12k_set_antenna()
5658 ath12k_mac_setup_ht_vht_cap(ar, &ar->pdev->cap, NULL); in __ath12k_set_antenna()
5659 ath12k_mac_setup_sband_iftype_data(ar, &ar->pdev->cap); in __ath12k_set_antenna()
5670 num_mgmt = atomic_dec_if_positive(&ar->num_pending_mgmt_tx); in ath12k_mgmt_over_wmi_tx_drop()
5676 wake_up(&ar->txmgmt_empty_waitq); in ath12k_mgmt_over_wmi_tx_drop()
5684 struct ath12k_base *ab = ar->ab; in ath12k_mac_tx_mgmt_pending_free()
5686 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_tx_mgmt_pending_free()
5687 idr_remove(&ar->txmgmt_idr, buf_id); in ath12k_mac_tx_mgmt_pending_free()
5688 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_tx_mgmt_pending_free()
5689 dma_unmap_single(ab->dev, ATH12K_SKB_CB(msdu)->paddr, msdu->len, in ath12k_mac_tx_mgmt_pending_free()
5693 memset(&info->status, 0, sizeof(info->status)); in ath12k_mac_tx_mgmt_pending_free()
5705 struct ath12k *ar = skb_cb->ar; in ath12k_mac_vif_txmgmt_idr_remove()
5706 struct ath12k_base *ab = ar->ab; in ath12k_mac_vif_txmgmt_idr_remove()
5708 if (skb_cb->vif == vif) { in ath12k_mac_vif_txmgmt_idr_remove()
5709 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_vif_txmgmt_idr_remove()
5710 idr_remove(&ar->txmgmt_idr, buf_id); in ath12k_mac_vif_txmgmt_idr_remove()
5711 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_vif_txmgmt_idr_remove()
5712 dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, in ath12k_mac_vif_txmgmt_idr_remove()
5722 struct ath12k_base *ab = ar->ab; in ath12k_mac_mgmt_tx_wmi()
5723 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath12k_mac_mgmt_tx_wmi()
5729 ATH12K_SKB_CB(skb)->ar = ar; in ath12k_mac_mgmt_tx_wmi()
5730 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
5731 buf_id = idr_alloc(&ar->txmgmt_idr, skb, 0, in ath12k_mac_mgmt_tx_wmi()
5733 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
5735 return -ENOSPC; in ath12k_mac_mgmt_tx_wmi()
5738 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) { in ath12k_mac_mgmt_tx_wmi()
5739 if ((ieee80211_is_action(hdr->frame_control) || in ath12k_mac_mgmt_tx_wmi()
5740 ieee80211_is_deauth(hdr->frame_control) || in ath12k_mac_mgmt_tx_wmi()
5741 ieee80211_is_disassoc(hdr->frame_control)) && in ath12k_mac_mgmt_tx_wmi()
5742 ieee80211_has_protected(hdr->frame_control)) { in ath12k_mac_mgmt_tx_wmi()
5747 paddr = dma_map_single(ab->dev, skb->data, skb->len, DMA_TO_DEVICE); in ath12k_mac_mgmt_tx_wmi()
5748 if (dma_mapping_error(ab->dev, paddr)) { in ath12k_mac_mgmt_tx_wmi()
5750 ret = -EIO; in ath12k_mac_mgmt_tx_wmi()
5754 ATH12K_SKB_CB(skb)->paddr = paddr; in ath12k_mac_mgmt_tx_wmi()
5756 ret = ath12k_wmi_mgmt_send(ar, arvif->vdev_id, buf_id, skb); in ath12k_mac_mgmt_tx_wmi()
5758 ath12k_warn(ar->ab, "failed to send mgmt frame: %d\n", ret); in ath12k_mac_mgmt_tx_wmi()
5765 dma_unmap_single(ab->dev, ATH12K_SKB_CB(skb)->paddr, in ath12k_mac_mgmt_tx_wmi()
5766 skb->len, DMA_TO_DEVICE); in ath12k_mac_mgmt_tx_wmi()
5768 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
5769 idr_remove(&ar->txmgmt_idr, buf_id); in ath12k_mac_mgmt_tx_wmi()
5770 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
5779 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) in ath12k_mgmt_over_wmi_tx_purge()
5791 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) { in ath12k_mgmt_over_wmi_tx_work()
5793 if (!skb_cb->vif) { in ath12k_mgmt_over_wmi_tx_work()
5794 ath12k_warn(ar->ab, "no vif found for mgmt frame\n"); in ath12k_mgmt_over_wmi_tx_work()
5799 arvif = ath12k_vif_to_arvif(skb_cb->vif); in ath12k_mgmt_over_wmi_tx_work()
5801 if (ar->allocated_vdev_map & (1LL << arvif->vdev_id)) { in ath12k_mgmt_over_wmi_tx_work()
5804 ath12k_warn(ar->ab, "failed to tx mgmt frame, vdev_id %d :%d\n", in ath12k_mgmt_over_wmi_tx_work()
5805 arvif->vdev_id, ret); in ath12k_mgmt_over_wmi_tx_work()
5809 ath12k_warn(ar->ab, in ath12k_mgmt_over_wmi_tx_work()
5811 arvif->vdev_id, in ath12k_mgmt_over_wmi_tx_work()
5812 arvif->is_started); in ath12k_mgmt_over_wmi_tx_work()
5821 struct sk_buff_head *q = &ar->wmi_mgmt_tx_queue; in ath12k_mac_mgmt_tx()
5823 if (test_bit(ATH12K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) in ath12k_mac_mgmt_tx()
5824 return -ESHUTDOWN; in ath12k_mac_mgmt_tx()
5828 * other mgmt packets like auth and assoc to be sent on time in ath12k_mac_mgmt_tx()
5832 atomic_read(&ar->num_pending_mgmt_tx) > ATH12K_PRB_RSP_DROP_THRESHOLD) { in ath12k_mac_mgmt_tx()
5833 ath12k_warn(ar->ab, in ath12k_mac_mgmt_tx()
5835 return -ENOSPC; in ath12k_mac_mgmt_tx()
5839 ath12k_warn(ar->ab, "mgmt tx queue is full\n"); in ath12k_mac_mgmt_tx()
5840 return -ENOSPC; in ath12k_mac_mgmt_tx()
5844 atomic_inc(&ar->num_pending_mgmt_tx); in ath12k_mac_mgmt_tx()
5845 ieee80211_queue_work(ath12k_ar_to_hw(ar), &ar->wmi_mgmt_tx_work); in ath12k_mac_mgmt_tx()
5860 spin_lock_bh(&ar->data_lock); in ath12k_mac_add_p2p_noa_ie()
5862 if (arvif->u.ap.noa_data && in ath12k_mac_add_p2p_noa_ie()
5863 !pskb_expand_head(skb, 0, arvif->u.ap.noa_len, in ath12k_mac_add_p2p_noa_ie()
5865 skb_put_data(skb, arvif->u.ap.noa_data, in ath12k_mac_add_p2p_noa_ie()
5866 arvif->u.ap.noa_len); in ath12k_mac_add_p2p_noa_ie()
5868 spin_unlock_bh(&ar->data_lock); in ath12k_mac_add_p2p_noa_ie()
5877 struct ieee80211_vif *vif = info->control.vif; in ath12k_mac_op_tx()
5879 struct ath12k *ar = arvif->ar; in ath12k_mac_op_tx()
5880 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath12k_mac_op_tx()
5881 struct ieee80211_key_conf *key = info->control.hw_key; in ath12k_mac_op_tx()
5882 u32 info_flags = info->flags; in ath12k_mac_op_tx()
5887 skb_cb->vif = vif; in ath12k_mac_op_tx()
5890 skb_cb->cipher = key->cipher; in ath12k_mac_op_tx()
5891 skb_cb->flags |= ATH12K_SKB_CIPHER_SET; in ath12k_mac_op_tx()
5894 is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control); in ath12k_mac_op_tx()
5897 skb_cb->flags |= ATH12K_SKB_HW_80211_ENCAP; in ath12k_mac_op_tx()
5898 } else if (ieee80211_is_mgmt(hdr->frame_control)) { in ath12k_mac_op_tx()
5901 ath12k_warn(ar->ab, "failed to queue management frame %d\n", in ath12k_mac_op_tx()
5909 if (vif->type == NL80211_IFTYPE_AP && vif->p2p) in ath12k_mac_op_tx()
5914 ath12k_warn(ar->ab, "failed to transmit frame %d\n", ret); in ath12k_mac_op_tx()
5921 /* make sure rcu-protected mac80211 tx path itself is drained */ in ath12k_mac_drain_tx()
5924 cancel_work_sync(&ar->wmi_mgmt_tx_work); in ath12k_mac_drain_tx()
5930 return -EOPNOTSUPP; in ath12k_mac_config_mon_status_default()
5936 struct ath12k_hw *ah = ar->ah; in ath12k_mac_start()
5937 struct ath12k_base *ab = ar->ab; in ath12k_mac_start()
5938 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_start()
5941 lockdep_assert_held(&ah->hw_mutex); in ath12k_mac_start()
5943 mutex_lock(&ar->conf_mutex); in ath12k_mac_start()
5946 1, pdev->pdev_id); in ath12k_mac_start()
5954 pdev->pdev_id); in ath12k_mac_start()
5961 0, pdev->pdev_id); in ath12k_mac_start()
5968 ret = ath12k_wmi_send_dfs_phyerr_offload_enable_cmd(ar, pdev->pdev_id); in ath12k_mac_start()
5983 1, pdev->pdev_id); in ath12k_mac_start()
5990 __ath12k_set_antenna(ar, ar->cfg_tx_chainmask, ar->cfg_rx_chainmask); in ath12k_mac_start()
5996 ar->num_started_vdevs = 0; in ath12k_mac_start()
5997 ar->num_created_vdevs = 0; in ath12k_mac_start()
5998 ar->num_peers = 0; in ath12k_mac_start()
5999 ar->allocated_vdev_map = 0; in ath12k_mac_start()
6005 if (ret && (ret != -EOPNOTSUPP)) { in ath12k_mac_start()
6011 if (ret == -EOPNOTSUPP) in ath12k_mac_start()
6016 ath12k_wmi_pdev_lro_cfg(ar, ar->pdev->pdev_id); in ath12k_mac_start()
6019 if (ab->hw_params->idle_ps) { in ath12k_mac_start()
6021 1, pdev->pdev_id); in ath12k_mac_start()
6028 mutex_unlock(&ar->conf_mutex); in ath12k_mac_start()
6030 rcu_assign_pointer(ab->pdevs_active[ar->pdev_idx], in ath12k_mac_start()
6031 &ab->pdevs[ar->pdev_idx]); in ath12k_mac_start()
6035 mutex_unlock(&ar->conf_mutex); in ath12k_mac_start()
6057 guard(mutex)(&ah->hw_mutex); in ath12k_mac_op_start()
6059 switch (ah->state) { in ath12k_mac_op_start()
6061 ah->state = ATH12K_HW_STATE_ON; in ath12k_mac_op_start()
6064 ah->state = ATH12K_HW_STATE_RESTARTED; in ath12k_mac_op_start()
6069 ah->state = ATH12K_HW_STATE_OFF; in ath12k_mac_op_start()
6072 return -EINVAL; in ath12k_mac_op_start()
6078 ah->state = ATH12K_HW_STATE_OFF; in ath12k_mac_op_start()
6080 ath12k_err(ar->ab, "fail to start mac operations in pdev idx %d ret %d\n", in ath12k_mac_op_start()
6081 ar->pdev_idx, ret); in ath12k_mac_op_start()
6089 for (; i > 0; i--) { in ath12k_mac_op_start()
6090 ar = ath12k_ah_to_ar(ah, i - 1); in ath12k_mac_op_start()
6099 struct ath12k_base *ab = ar->ab; in ath12k_mac_rfkill_config()
6103 if (ab->hw_params->rfkill_pin == 0) in ath12k_mac_rfkill_config()
6104 return -EOPNOTSUPP; in ath12k_mac_rfkill_config()
6108 ab->hw_params->rfkill_pin, ab->hw_params->rfkill_cfg, in ath12k_mac_rfkill_config()
6109 ab->hw_params->rfkill_on_level); in ath12k_mac_rfkill_config()
6111 param = u32_encode_bits(ab->hw_params->rfkill_on_level, in ath12k_mac_rfkill_config()
6113 u32_encode_bits(ab->hw_params->rfkill_pin, in ath12k_mac_rfkill_config()
6115 u32_encode_bits(ab->hw_params->rfkill_cfg, in ath12k_mac_rfkill_config()
6119 param, ar->pdev->pdev_id); in ath12k_mac_rfkill_config()
6140 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac %d rfkill enable %d", in ath12k_mac_rfkill_enable_radio()
6141 ar->pdev_idx, param); in ath12k_mac_rfkill_enable_radio()
6144 param, ar->pdev->pdev_id); in ath12k_mac_rfkill_enable_radio()
6146 ath12k_warn(ar->ab, "failed to set rfkill enable param %d: %d\n", in ath12k_mac_rfkill_enable_radio()
6156 struct ath12k_hw *ah = ar->ah; in ath12k_mac_stop()
6160 lockdep_assert_held(&ah->hw_mutex); in ath12k_mac_stop()
6162 mutex_lock(&ar->conf_mutex); in ath12k_mac_stop()
6164 if (ret && (ret != -EOPNOTSUPP)) in ath12k_mac_stop()
6165 ath12k_err(ar->ab, "failed to clear rx_filter for monitor status ring: (%d)\n", in ath12k_mac_stop()
6168 clear_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_stop()
6169 mutex_unlock(&ar->conf_mutex); in ath12k_mac_stop()
6171 cancel_delayed_work_sync(&ar->scan.timeout); in ath12k_mac_stop()
6172 cancel_work_sync(&ar->regd_update_work); in ath12k_mac_stop()
6173 cancel_work_sync(&ar->ab->rfkill_work); in ath12k_mac_stop()
6175 spin_lock_bh(&ar->data_lock); in ath12k_mac_stop()
6176 list_for_each_entry_safe(ppdu_stats, tmp, &ar->ppdu_stats_info, list) { in ath12k_mac_stop()
6177 list_del(&ppdu_stats->list); in ath12k_mac_stop()
6180 spin_unlock_bh(&ar->data_lock); in ath12k_mac_stop()
6182 rcu_assign_pointer(ar->ab->pdevs_active[ar->pdev_idx], NULL); in ath12k_mac_stop()
6186 atomic_set(&ar->num_pending_mgmt_tx, 0); in ath12k_mac_stop()
6197 mutex_lock(&ah->hw_mutex); in ath12k_mac_op_stop()
6199 ah->state = ATH12K_HW_STATE_OFF; in ath12k_mac_op_stop()
6204 mutex_unlock(&ah->hw_mutex); in ath12k_mac_op_stop()
6210 struct ath12k_base *ab = arvif->ar->ab; in ath12k_mac_get_vdev_stats_id()
6214 if (ab->free_vdev_stats_id_map & (1LL << vdev_stats_id)) { in ath12k_mac_get_vdev_stats_id()
6221 ab->free_vdev_stats_id_map |= (1LL << vdev_stats_id); in ath12k_mac_get_vdev_stats_id()
6226 arvif->vdev_stats_id = vdev_stats_id; in ath12k_mac_get_vdev_stats_id()
6233 struct ieee80211_vif *tx_vif = arvif->vif->mbssid_tx_vif; in ath12k_mac_setup_vdev_params_mbssid()
6234 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_vdev_params_mbssid()
6242 if (arvif->vif->bss_conf.nontransmitted) { in ath12k_mac_setup_vdev_params_mbssid()
6243 if (ar->ah->hw->wiphy != ieee80211_vif_to_wdev(tx_vif)->wiphy) in ath12k_mac_setup_vdev_params_mbssid()
6244 return -EINVAL; in ath12k_mac_setup_vdev_params_mbssid()
6247 *tx_vdev_id = tx_arvif->vdev_id; in ath12k_mac_setup_vdev_params_mbssid()
6251 return -EINVAL; in ath12k_mac_setup_vdev_params_mbssid()
6254 if (arvif->vif->bss_conf.ema_ap) in ath12k_mac_setup_vdev_params_mbssid()
6263 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_vdev_create_arg()
6264 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_setup_vdev_create_arg()
6267 arg->if_id = arvif->vdev_id; in ath12k_mac_setup_vdev_create_arg()
6268 arg->type = arvif->vdev_type; in ath12k_mac_setup_vdev_create_arg()
6269 arg->subtype = arvif->vdev_subtype; in ath12k_mac_setup_vdev_create_arg()
6270 arg->pdev_id = pdev->pdev_id; in ath12k_mac_setup_vdev_create_arg()
6272 arg->mbssid_flags = WMI_VDEV_MBSSID_FLAGS_NON_MBSSID_AP; in ath12k_mac_setup_vdev_create_arg()
6273 arg->mbssid_tx_vdev_id = 0; in ath12k_mac_setup_vdev_create_arg()
6275 ar->ab->wmi_ab.svc_map)) { in ath12k_mac_setup_vdev_create_arg()
6277 &arg->mbssid_flags, in ath12k_mac_setup_vdev_create_arg()
6278 &arg->mbssid_tx_vdev_id); in ath12k_mac_setup_vdev_create_arg()
6283 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_setup_vdev_create_arg()
6284 arg->chains[NL80211_BAND_2GHZ].tx = ar->num_tx_chains; in ath12k_mac_setup_vdev_create_arg()
6285 arg->chains[NL80211_BAND_2GHZ].rx = ar->num_rx_chains; in ath12k_mac_setup_vdev_create_arg()
6287 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath12k_mac_setup_vdev_create_arg()
6288 arg->chains[NL80211_BAND_5GHZ].tx = ar->num_tx_chains; in ath12k_mac_setup_vdev_create_arg()
6289 arg->chains[NL80211_BAND_5GHZ].rx = ar->num_rx_chains; in ath12k_mac_setup_vdev_create_arg()
6291 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP && in ath12k_mac_setup_vdev_create_arg()
6292 ar->supports_6ghz) { in ath12k_mac_setup_vdev_create_arg()
6293 arg->chains[NL80211_BAND_6GHZ].tx = ar->num_tx_chains; in ath12k_mac_setup_vdev_create_arg()
6294 arg->chains[NL80211_BAND_6GHZ].rx = ar->num_rx_chains; in ath12k_mac_setup_vdev_create_arg()
6297 arg->if_stats_id = ath12k_mac_get_vdev_stats_id(arvif); in ath12k_mac_setup_vdev_create_arg()
6304 struct ath12k_pdev_cap *pdev_cap = &pdev->cap; in ath12k_mac_prepare_he_mode()
6309 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) in ath12k_mac_prepare_he_mode()
6310 cap_band = &pdev_cap->band[NL80211_BAND_2GHZ]; in ath12k_mac_prepare_he_mode()
6312 cap_band = &pdev_cap->band[NL80211_BAND_5GHZ]; in ath12k_mac_prepare_he_mode()
6314 hecap_phy_ptr = &cap_band->he_cap_phy_info[0]; in ath12k_mac_prepare_he_mode()
6339 struct ath12k_base *ab = ar->ab; in ath12k_set_he_mu_sounding_mode()
6343 param_value = ath12k_mac_prepare_he_mode(ar->pdev, arvif->vif->type); in ath12k_set_he_mu_sounding_mode()
6344 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_he_mu_sounding_mode()
6348 arvif->vdev_id, ret, param_value); in ath12k_set_he_mu_sounding_mode()
6356 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_he_mu_sounding_mode()
6360 arvif->vdev_id, ret); in ath12k_set_he_mu_sounding_mode()
6368 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_update_vif_offload()
6369 struct ath12k *ar = arvif->ar; in ath12k_mac_update_vif_offload()
6370 struct ath12k_base *ab = ar->ab; in ath12k_mac_update_vif_offload()
6375 if (vif->type != NL80211_IFTYPE_STATION && in ath12k_mac_update_vif_offload()
6376 vif->type != NL80211_IFTYPE_AP) in ath12k_mac_update_vif_offload()
6377 vif->offload_flags &= ~(IEEE80211_OFFLOAD_ENCAP_ENABLED | in ath12k_mac_update_vif_offload()
6380 if (vif->offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ath12k_mac_update_vif_offload()
6381 arvif->tx_encap_type = ATH12K_HW_TXRX_ETHERNET; in ath12k_mac_update_vif_offload()
6382 else if (test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) in ath12k_mac_update_vif_offload()
6383 arvif->tx_encap_type = ATH12K_HW_TXRX_RAW; in ath12k_mac_update_vif_offload()
6385 arvif->tx_encap_type = ATH12K_HW_TXRX_NATIVE_WIFI; in ath12k_mac_update_vif_offload()
6387 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_update_vif_offload()
6388 param_id, arvif->tx_encap_type); in ath12k_mac_update_vif_offload()
6391 arvif->vdev_id, ret); in ath12k_mac_update_vif_offload()
6392 vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; in ath12k_mac_update_vif_offload()
6396 if (vif->offload_flags & IEEE80211_OFFLOAD_DECAP_ENABLED) in ath12k_mac_update_vif_offload()
6398 else if (test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) in ath12k_mac_update_vif_offload()
6403 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_update_vif_offload()
6407 arvif->vdev_id, ret); in ath12k_mac_update_vif_offload()
6408 vif->offload_flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED; in ath12k_mac_update_vif_offload()
6422 struct ath12k_hw *ah = ar->ah; in ath12k_mac_vdev_create()
6423 struct ath12k_base *ab = ar->ab; in ath12k_mac_vdev_create()
6424 struct ieee80211_hw *hw = ah->hw; in ath12k_mac_vdev_create()
6433 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_create()
6435 arvif->ar = ar; in ath12k_mac_vdev_create()
6436 vdev_id = __ffs64(ab->free_vdev_map); in ath12k_mac_vdev_create()
6437 arvif->vdev_id = vdev_id; in ath12k_mac_vdev_create()
6438 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_NONE; in ath12k_mac_vdev_create()
6440 switch (vif->type) { in ath12k_mac_vdev_create()
6443 arvif->vdev_type = WMI_VDEV_TYPE_STA; in ath12k_mac_vdev_create()
6445 if (vif->p2p) in ath12k_mac_vdev_create()
6446 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_P2P_CLIENT; in ath12k_mac_vdev_create()
6450 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_MESH_11S; in ath12k_mac_vdev_create()
6453 arvif->vdev_type = WMI_VDEV_TYPE_AP; in ath12k_mac_vdev_create()
6455 if (vif->p2p) in ath12k_mac_vdev_create()
6456 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_P2P_GO; in ath12k_mac_vdev_create()
6460 arvif->vdev_type = WMI_VDEV_TYPE_MONITOR; in ath12k_mac_vdev_create()
6461 ar->monitor_vdev_id = vdev_id; in ath12k_mac_vdev_create()
6464 arvif->vdev_type = WMI_VDEV_TYPE_STA; in ath12k_mac_vdev_create()
6465 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_P2P_DEVICE; in ath12k_mac_vdev_create()
6472 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev create id %d type %d subtype %d map %llx\n", in ath12k_mac_vdev_create()
6473 arvif->vdev_id, arvif->vdev_type, arvif->vdev_subtype, in ath12k_mac_vdev_create()
6474 ab->free_vdev_map); in ath12k_mac_vdev_create()
6476 vif->cab_queue = arvif->vdev_id % (ATH12K_HW_MAX_QUEUES - 1); in ath12k_mac_vdev_create()
6477 for (i = 0; i < ARRAY_SIZE(vif->hw_queue); i++) in ath12k_mac_vdev_create()
6478 vif->hw_queue[i] = i % (ATH12K_HW_MAX_QUEUES - 1); in ath12k_mac_vdev_create()
6483 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6487 ret = ath12k_wmi_vdev_create(ar, vif->addr, &vdev_arg); in ath12k_mac_vdev_create()
6490 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6494 ar->num_created_vdevs++; in ath12k_mac_vdev_create()
6495 arvif->is_created = true; in ath12k_mac_vdev_create()
6497 vif->addr, arvif->vdev_id); in ath12k_mac_vdev_create()
6498 ar->allocated_vdev_map |= 1LL << arvif->vdev_id; in ath12k_mac_vdev_create()
6499 ab->free_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_vdev_create()
6501 spin_lock_bh(&ar->data_lock); in ath12k_mac_vdev_create()
6502 list_add(&arvif->list, &ar->arvifs); in ath12k_mac_vdev_create()
6503 spin_unlock_bh(&ar->data_lock); in ath12k_mac_vdev_create()
6507 nss = hweight32(ar->cfg_tx_chainmask) ? : 1; in ath12k_mac_vdev_create()
6508 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_vdev_create()
6512 arvif->vdev_id, ar->cfg_tx_chainmask, nss, ret); in ath12k_mac_vdev_create()
6516 switch (arvif->vdev_type) { in ath12k_mac_vdev_create()
6518 peer_param.vdev_id = arvif->vdev_id; in ath12k_mac_vdev_create()
6519 peer_param.peer_addr = vif->addr; in ath12k_mac_vdev_create()
6524 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6530 ath12k_warn(ar->ab, "failed to set vdev %i kickout parameters: %d\n", in ath12k_mac_vdev_create()
6531 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6538 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_mac_vdev_create()
6541 ath12k_warn(ar->ab, "failed to set vdev %d RX wake policy: %d\n", in ath12k_mac_vdev_create()
6542 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6548 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_mac_vdev_create()
6551 ath12k_warn(ar->ab, "failed to set vdev %d TX wake threshold: %d\n", in ath12k_mac_vdev_create()
6552 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6558 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_mac_vdev_create()
6561 ath12k_warn(ar->ab, "failed to set vdev %d pspoll count: %d\n", in ath12k_mac_vdev_create()
6562 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6566 ret = ath12k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, false); in ath12k_mac_vdev_create()
6568 ath12k_warn(ar->ab, "failed to disable vdev %d ps mode: %d\n", in ath12k_mac_vdev_create()
6569 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6577 arvif->txpower = vif->bss_conf.txpower; in ath12k_mac_vdev_create()
6583 param_value = hw->wiphy->rts_threshold; in ath12k_mac_vdev_create()
6584 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_vdev_create()
6587 ath12k_warn(ar->ab, "failed to set rts threshold for vdev %d: %d\n", in ath12k_mac_vdev_create()
6588 arvif->vdev_id, ret); in ath12k_mac_vdev_create()
6593 if (vif->type != NL80211_IFTYPE_MONITOR && ar->monitor_conf_enabled) in ath12k_mac_vdev_create()
6596 arvif->ar = ar; in ath12k_mac_vdev_create()
6600 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath12k_mac_vdev_create()
6601 reinit_completion(&ar->peer_delete_done); in ath12k_mac_vdev_create()
6603 ret = ath12k_wmi_send_peer_delete_cmd(ar, vif->addr, in ath12k_mac_vdev_create()
6604 arvif->vdev_id); in ath12k_mac_vdev_create()
6606 ath12k_warn(ar->ab, "failed to delete peer vdev_id %d addr %pM\n", in ath12k_mac_vdev_create()
6607 arvif->vdev_id, vif->addr); in ath12k_mac_vdev_create()
6611 ret = ath12k_wait_for_peer_delete_done(ar, arvif->vdev_id, in ath12k_mac_vdev_create()
6612 vif->addr); in ath12k_mac_vdev_create()
6616 ar->num_peers--; in ath12k_mac_vdev_create()
6620 ath12k_wmi_vdev_delete(ar, arvif->vdev_id); in ath12k_mac_vdev_create()
6621 ar->num_created_vdevs--; in ath12k_mac_vdev_create()
6622 arvif->is_created = false; in ath12k_mac_vdev_create()
6623 arvif->ar = NULL; in ath12k_mac_vdev_create()
6624 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_vdev_create()
6625 ab->free_vdev_map |= 1LL << arvif->vdev_id; in ath12k_mac_vdev_create()
6626 ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id); in ath12k_mac_vdev_create()
6627 spin_lock_bh(&ar->data_lock); in ath12k_mac_vdev_create()
6628 list_del(&arvif->list); in ath12k_mac_vdev_create()
6629 spin_unlock_bh(&ar->data_lock); in ath12k_mac_vdev_create()
6632 arvif->ar = NULL; in ath12k_mac_vdev_create()
6639 struct ath12k_vif_cache *cache = arvif->cache; in ath12k_mac_vif_cache_flush()
6640 struct ath12k_base *ab = ar->ab; in ath12k_mac_vif_cache_flush()
6644 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vif_cache_flush()
6649 if (cache->tx_conf.changed) { in ath12k_mac_vif_cache_flush()
6650 ret = ath12k_mac_conf_tx(arvif, 0, cache->tx_conf.ac, in ath12k_mac_vif_cache_flush()
6651 &cache->tx_conf.tx_queue_params); in ath12k_mac_vif_cache_flush()
6658 if (cache->bss_conf_changed) { in ath12k_mac_vif_cache_flush()
6659 ath12k_mac_bss_info_changed(ar, arvif, &vif->bss_conf, in ath12k_mac_vif_cache_flush()
6660 cache->bss_conf_changed); in ath12k_mac_vif_cache_flush()
6663 if (cache->key_conf.changed) { in ath12k_mac_vif_cache_flush()
6664 ret = ath12k_mac_set_key(ar, cache->key_conf.cmd, vif, NULL, in ath12k_mac_vif_cache_flush()
6665 cache->key_conf.key); in ath12k_mac_vif_cache_flush()
6668 arvif->vdev_id, ret); in ath12k_mac_vif_cache_flush()
6678 struct ath12k_hw *ah = hw->priv; in ath12k_mac_assign_vif_to_vdev()
6683 if (ah->num_radio == 1) in ath12k_mac_assign_vif_to_vdev()
6684 ar = ah->radio; in ath12k_mac_assign_vif_to_vdev()
6693 if (arvif->ar) { in ath12k_mac_assign_vif_to_vdev()
6695 if (WARN_ON(!arvif->is_created)) { in ath12k_mac_assign_vif_to_vdev()
6696 arvif->ar = NULL; in ath12k_mac_assign_vif_to_vdev()
6700 if (ah->num_radio == 1) in ath12k_mac_assign_vif_to_vdev()
6701 return arvif->ar; in ath12k_mac_assign_vif_to_vdev()
6707 if (ar != arvif->ar) { in ath12k_mac_assign_vif_to_vdev()
6708 if (WARN_ON(arvif->is_started)) in ath12k_mac_assign_vif_to_vdev()
6711 /* backup the previously used ar ptr since arvif->ar would in ath12k_mac_assign_vif_to_vdev()
6714 prev_ar = arvif->ar; in ath12k_mac_assign_vif_to_vdev()
6715 mutex_lock(&prev_ar->conf_mutex); in ath12k_mac_assign_vif_to_vdev()
6719 ath12k_warn(prev_ar->ab, "unable to delete vdev %d\n", in ath12k_mac_assign_vif_to_vdev()
6721 mutex_unlock(&prev_ar->conf_mutex); in ath12k_mac_assign_vif_to_vdev()
6725 ab = ar->ab; in ath12k_mac_assign_vif_to_vdev()
6727 mutex_lock(&ar->conf_mutex); in ath12k_mac_assign_vif_to_vdev()
6729 if (arvif->is_created) in ath12k_mac_assign_vif_to_vdev()
6732 if (vif->type == NL80211_IFTYPE_AP && in ath12k_mac_assign_vif_to_vdev()
6733 ar->num_peers > (ar->max_num_peers - 1)) { in ath12k_mac_assign_vif_to_vdev()
6738 if (ar->num_created_vdevs > (TARGET_NUM_VDEVS - 1)) { in ath12k_mac_assign_vif_to_vdev()
6746 ath12k_warn(ab, "failed to create vdev %pM ret %d", vif->addr, ret); in ath12k_mac_assign_vif_to_vdev()
6757 mutex_unlock(&ar->conf_mutex); in ath12k_mac_assign_vif_to_vdev()
6758 return arvif->ar; in ath12k_mac_assign_vif_to_vdev()
6769 arvif->vif = vif; in ath12k_mac_op_add_interface()
6771 INIT_LIST_HEAD(&arvif->list); in ath12k_mac_op_add_interface()
6772 INIT_DELAYED_WORK(&arvif->connection_loss_work, in ath12k_mac_op_add_interface()
6775 for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) { in ath12k_mac_op_add_interface()
6776 arvif->bitrate_mask.control[i].legacy = 0xffffffff; in ath12k_mac_op_add_interface()
6777 memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff, in ath12k_mac_op_add_interface()
6778 sizeof(arvif->bitrate_mask.control[i].ht_mcs)); in ath12k_mac_op_add_interface()
6779 memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff, in ath12k_mac_op_add_interface()
6780 sizeof(arvif->bitrate_mask.control[i].vht_mcs)); in ath12k_mac_op_add_interface()
6784 vif->cab_queue = ATH12K_HW_DEFAULT_QUEUE; in ath12k_mac_op_add_interface()
6785 for (i = 0; i < ARRAY_SIZE(vif->hw_queue); i++) in ath12k_mac_op_add_interface()
6786 vif->hw_queue[i] = ATH12K_HW_DEFAULT_QUEUE; in ath12k_mac_op_add_interface()
6788 vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD; in ath12k_mac_op_add_interface()
6790 /* For single radio wiphy(i.e ah->num_radio is 1), create the vdev in ath12k_mac_op_add_interface()
6807 spin_lock_bh(&dp->tx_desc_lock[i]); in ath12k_mac_vif_unref()
6809 list_for_each_entry(tx_desc_info, &dp->tx_desc_used_list[i], in ath12k_mac_vif_unref()
6811 skb = tx_desc_info->skb; in ath12k_mac_vif_unref()
6816 if (skb_cb->vif == vif) in ath12k_mac_vif_unref()
6817 skb_cb->vif = NULL; in ath12k_mac_vif_unref()
6820 spin_unlock_bh(&dp->tx_desc_lock[i]); in ath12k_mac_vif_unref()
6827 struct ath12k_base *ab = ar->ab; in ath12k_mac_vdev_delete()
6831 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_delete()
6832 reinit_completion(&ar->vdev_delete_done); in ath12k_mac_vdev_delete()
6834 ret = ath12k_wmi_vdev_delete(ar, arvif->vdev_id); in ath12k_mac_vdev_delete()
6837 arvif->vdev_id, ret); in ath12k_mac_vdev_delete()
6841 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, in ath12k_mac_vdev_delete()
6848 ab->free_vdev_map |= 1LL << arvif->vdev_id; in ath12k_mac_vdev_delete()
6849 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_vdev_delete()
6850 ar->num_created_vdevs--; in ath12k_mac_vdev_delete()
6852 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_vdev_delete()
6853 ar->monitor_vdev_id = -1; in ath12k_mac_vdev_delete()
6854 ar->monitor_vdev_created = false; in ath12k_mac_vdev_delete()
6855 } else if (ar->monitor_vdev_created && !ar->monitor_started) { in ath12k_mac_vdev_delete()
6860 vif->addr, arvif->vdev_id); in ath12k_mac_vdev_delete()
6863 spin_lock_bh(&ar->data_lock); in ath12k_mac_vdev_delete()
6864 list_del(&arvif->list); in ath12k_mac_vdev_delete()
6865 spin_unlock_bh(&ar->data_lock); in ath12k_mac_vdev_delete()
6867 ath12k_peer_cleanup(ar, arvif->vdev_id); in ath12k_mac_vdev_delete()
6870 idr_for_each(&ar->txmgmt_idr, in ath12k_mac_vdev_delete()
6873 ath12k_mac_vif_unref(&ab->dp, vif); in ath12k_mac_vdev_delete()
6874 ath12k_dp_tx_put_bank_profile(&ab->dp, arvif->bank_id); in ath12k_mac_vdev_delete()
6880 arvif->is_created = false; in ath12k_mac_vdev_delete()
6881 arvif->ar = NULL; in ath12k_mac_vdev_delete()
6894 if (!arvif->is_created) { in ath12k_mac_op_remove_interface()
6902 ar = arvif->ar; in ath12k_mac_op_remove_interface()
6903 ab = ar->ab; in ath12k_mac_op_remove_interface()
6905 cancel_delayed_work_sync(&arvif->connection_loss_work); in ath12k_mac_op_remove_interface()
6907 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_remove_interface()
6910 arvif->vdev_id); in ath12k_mac_op_remove_interface()
6912 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath12k_mac_op_remove_interface()
6913 ret = ath12k_peer_delete(ar, arvif->vdev_id, vif->addr); in ath12k_mac_op_remove_interface()
6915 ath12k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n", in ath12k_mac_op_remove_interface()
6916 arvif->vdev_id, ret); in ath12k_mac_op_remove_interface()
6921 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_remove_interface()
6940 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_configure_filter()
6942 ar->filter_flags = total_flags; in ath12k_mac_configure_filter()
6945 reset_flag = !(ar->filter_flags & FIF_BCN_PRBRESP_PROMISC); in ath12k_mac_configure_filter()
6949 ath12k_warn(ar->ab, in ath12k_mac_configure_filter()
6952 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_configure_filter()
6967 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_configure_filter()
6972 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_configure_filter()
6983 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_get_antenna()
6984 antennas_rx = max_t(u32, antennas_rx, ar->cfg_rx_chainmask); in ath12k_mac_op_get_antenna()
6985 antennas_tx = max_t(u32, antennas_tx, ar->cfg_tx_chainmask); in ath12k_mac_op_get_antenna()
6986 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_get_antenna()
7003 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_antenna()
7005 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_antenna()
7016 struct ath12k *ar = arvif->ar; in ath12k_mac_ampdu_action()
7017 int ret = -EINVAL; in ath12k_mac_ampdu_action()
7019 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_ampdu_action()
7021 switch (params->action) { in ath12k_mac_ampdu_action()
7033 /* Tx A-MPDU aggregation offloaded to hw/fw so deny mac80211 in ath12k_mac_ampdu_action()
7036 ret = -EOPNOTSUPP; in ath12k_mac_ampdu_action()
7050 int ret = -EINVAL; in ath12k_mac_op_ampdu_action()
7054 return -EINVAL; in ath12k_mac_op_ampdu_action()
7058 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_ampdu_action()
7060 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_ampdu_action()
7063 ath12k_warn(ar->ab, "pdev idx %d unable to perform ampdu action %d ret %d\n", in ath12k_mac_op_ampdu_action()
7064 ar->pdev_idx, params->action, ret); in ath12k_mac_op_ampdu_action()
7077 return -EINVAL; in ath12k_mac_op_add_chanctx()
7079 ab = ar->ab; in ath12k_mac_op_add_chanctx()
7083 ctx->def.chan->center_freq, ctx->def.width, ctx); in ath12k_mac_op_add_chanctx()
7085 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_add_chanctx()
7087 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_add_chanctx()
7091 ar->rx_channel = ctx->def.chan; in ath12k_mac_op_add_chanctx()
7092 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_add_chanctx()
7094 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_add_chanctx()
7109 ab = ar->ab; in ath12k_mac_op_remove_chanctx()
7113 ctx->def.chan->center_freq, ctx->def.width, ctx); in ath12k_mac_op_remove_chanctx()
7115 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_remove_chanctx()
7117 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_remove_chanctx()
7121 ar->rx_channel = NULL; in ath12k_mac_op_remove_chanctx()
7122 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_remove_chanctx()
7124 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_remove_chanctx()
7135 int n = ar->mac.sbands[band].n_iftype_data; in ath12k_mac_check_down_grade_phy_mode()
7142 data = ar->mac.iftype[band]; in ath12k_mac_check_down_grade_phy_mode()
7150 if (eht_cap && eht_cap->has_eht) in ath12k_mac_check_down_grade_phy_mode()
7182 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_check_down_grade_phy_mode()
7195 struct ath12k *ar = arvif->ar; in ath12k_mac_vdev_start_restart()
7196 struct ath12k_base *ab = ar->ab; in ath12k_mac_vdev_start_restart()
7198 const struct cfg80211_chan_def *chandef = &ctx->def; in ath12k_mac_vdev_start_restart()
7199 int he_support = arvif->vif->bss_conf.he_support; in ath12k_mac_vdev_start_restart()
7202 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_start_restart()
7204 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_vdev_start_restart()
7206 arg.vdev_id = arvif->vdev_id; in ath12k_mac_vdev_start_restart()
7207 arg.dtim_period = arvif->dtim_period; in ath12k_mac_vdev_start_restart()
7208 arg.bcn_intval = arvif->beacon_interval; in ath12k_mac_vdev_start_restart()
7209 arg.punct_bitmap = ~arvif->punct_bitmap; in ath12k_mac_vdev_start_restart()
7211 arg.freq = chandef->chan->center_freq; in ath12k_mac_vdev_start_restart()
7212 arg.band_center_freq1 = chandef->center_freq1; in ath12k_mac_vdev_start_restart()
7213 arg.band_center_freq2 = chandef->center_freq2; in ath12k_mac_vdev_start_restart()
7214 arg.mode = ath12k_phymodes[chandef->chan->band][chandef->width]; in ath12k_mac_vdev_start_restart()
7217 chandef->chan->band, in ath12k_mac_vdev_start_restart()
7218 arvif->vif->type); in ath12k_mac_vdev_start_restart()
7220 arg.max_power = chandef->chan->max_power * 2; in ath12k_mac_vdev_start_restart()
7221 arg.max_reg_power = chandef->chan->max_reg_power * 2; in ath12k_mac_vdev_start_restart()
7222 arg.max_antenna_gain = chandef->chan->max_antenna_gain * 2; in ath12k_mac_vdev_start_restart()
7224 arg.pref_tx_streams = ar->num_tx_chains; in ath12k_mac_vdev_start_restart()
7225 arg.pref_rx_streams = ar->num_rx_chains; in ath12k_mac_vdev_start_restart()
7230 ar->ab->wmi_ab.svc_map)) { in ath12k_mac_vdev_start_restart()
7238 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath12k_mac_vdev_start_restart()
7239 arg.ssid = arvif->u.ap.ssid; in ath12k_mac_vdev_start_restart()
7240 arg.ssid_len = arvif->u.ap.ssid_len; in ath12k_mac_vdev_start_restart()
7241 arg.hidden_ssid = arvif->u.ap.hidden_ssid; in ath12k_mac_vdev_start_restart()
7244 arg.chan_radar = !!(chandef->chan->flags & IEEE80211_CHAN_RADAR); in ath12k_mac_vdev_start_restart()
7246 arg.freq2_radar = ctx->radar_enabled; in ath12k_mac_vdev_start_restart()
7250 spin_lock_bh(&ab->base_lock); in ath12k_mac_vdev_start_restart()
7251 arg.regdomain = ar->ab->dfs_region; in ath12k_mac_vdev_start_restart()
7252 spin_unlock_bh(&ab->base_lock); in ath12k_mac_vdev_start_restart()
7258 ath12k_warn(ar->ab, "failed to set he mode vdev %i\n", in ath12k_mac_vdev_start_restart()
7265 arg.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR); in ath12k_mac_vdev_start_restart()
7274 ath12k_warn(ar->ab, "failed to %s WMI vdev %i\n", in ath12k_mac_vdev_start_restart()
7286 ar->num_started_vdevs++; in ath12k_mac_vdev_start_restart()
7288 arvif->vif->addr, arvif->vdev_id); in ath12k_mac_vdev_start_restart()
7297 if (arvif->vdev_type == WMI_VDEV_TYPE_AP && in ath12k_mac_vdev_start_restart()
7298 chandef->chan->dfs_cac_ms && in ath12k_mac_vdev_start_restart()
7299 chandef->chan->dfs_state == NL80211_DFS_USABLE) { in ath12k_mac_vdev_start_restart()
7300 set_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_vdev_start_restart()
7309 arvif->vdev_id, ret); in ath12k_mac_vdev_start_restart()
7341 if (arvif->ar != arg->ar) in ath12k_mac_change_chanctx_cnt_iter()
7344 if (rcu_access_pointer(vif->bss_conf.chanctx_conf) != arg->ctx) in ath12k_mac_change_chanctx_cnt_iter()
7347 arg->n_vifs++; in ath12k_mac_change_chanctx_cnt_iter()
7358 if (arvif->ar != arg->ar) in ath12k_mac_change_chanctx_fill_iter()
7361 ctx = rcu_access_pointer(vif->bss_conf.chanctx_conf); in ath12k_mac_change_chanctx_fill_iter()
7362 if (ctx != arg->ctx) in ath12k_mac_change_chanctx_fill_iter()
7365 if (WARN_ON(arg->next_vif == arg->n_vifs)) in ath12k_mac_change_chanctx_fill_iter()
7368 arg->vifs[arg->next_vif].vif = vif; in ath12k_mac_change_chanctx_fill_iter()
7369 arg->vifs[arg->next_vif].old_ctx = ctx; in ath12k_mac_change_chanctx_fill_iter()
7370 arg->vifs[arg->next_vif].new_ctx = ctx; in ath12k_mac_change_chanctx_fill_iter()
7371 arg->next_vif++; in ath12k_mac_change_chanctx_fill_iter()
7406 if (arvif->vdev_type != WMI_VDEV_TYPE_STA) in ath12k_mac_update_peer_puncturing_width()
7414 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_update_peer_puncturing_width()
7416 def.punctured, def.width, arvif->vdev_id); in ath12k_mac_update_peer_puncturing_width()
7418 ret = ath12k_wmi_set_peer_param(ar, arvif->bssid, in ath12k_mac_update_peer_puncturing_width()
7419 arvif->vdev_id, param_id, in ath12k_mac_update_peer_puncturing_width()
7431 struct ath12k_base *ab = ar->ab; in ath12k_mac_update_vif_chan()
7438 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_update_vif_chan()
7444 if (vif->type == NL80211_IFTYPE_MONITOR) in ath12k_mac_update_vif_chan()
7448 "mac chanctx switch vdev_id %i freq %u->%u width %d->%d\n", in ath12k_mac_update_vif_chan()
7449 arvif->vdev_id, in ath12k_mac_update_vif_chan()
7450 vifs[i].old_ctx->def.chan->center_freq, in ath12k_mac_update_vif_chan()
7451 vifs[i].new_ctx->def.chan->center_freq, in ath12k_mac_update_vif_chan()
7452 vifs[i].old_ctx->def.width, in ath12k_mac_update_vif_chan()
7453 vifs[i].new_ctx->def.width); in ath12k_mac_update_vif_chan()
7455 if (WARN_ON(!arvif->is_started)) in ath12k_mac_update_vif_chan()
7458 arvif->punct_bitmap = vifs[i].new_ctx->def.punctured; in ath12k_mac_update_vif_chan()
7461 * If vdev is down then it expect vdev_stop->vdev_start. in ath12k_mac_update_vif_chan()
7463 if (arvif->is_up) { in ath12k_mac_update_vif_chan()
7467 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
7474 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
7481 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
7491 params.vdev_id = arvif->vdev_id; in ath12k_mac_update_vif_chan()
7492 params.aid = arvif->aid; in ath12k_mac_update_vif_chan()
7493 params.bssid = arvif->bssid; in ath12k_mac_update_vif_chan()
7494 if (vif->mbssid_tx_vif) { in ath12k_mac_update_vif_chan()
7495 params.tx_bssid = ath12k_vif_to_arvif(vif->mbssid_tx_vif)->bssid; in ath12k_mac_update_vif_chan()
7496 params.nontx_profile_idx = vif->bss_conf.bssid_index; in ath12k_mac_update_vif_chan()
7497 params.nontx_profile_cnt = 1 << vif->bss_conf.bssid_indicator; in ath12k_mac_update_vif_chan()
7499 ret = ath12k_wmi_vdev_up(arvif->ar, ¶ms); in ath12k_mac_update_vif_chan()
7502 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
7506 ret = ath12k_mac_update_peer_puncturing_width(arvif->ar, arvif, in ath12k_mac_update_vif_chan()
7507 vifs[i].new_ctx->def); in ath12k_mac_update_vif_chan()
7509 ath12k_warn(ar->ab, in ath12k_mac_update_vif_chan()
7511 vifs[i].new_ctx->def.punctured, in ath12k_mac_update_vif_chan()
7512 vifs[i].new_ctx->def.width, ret); in ath12k_mac_update_vif_chan()
7518 if (!monitor_vif && ar->monitor_vdev_created) { in ath12k_mac_update_vif_chan()
7531 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_update_active_vif_chan()
7565 ab = ar->ab; in ath12k_mac_op_change_chanctx()
7567 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_change_chanctx()
7571 ctx->def.chan->center_freq, ctx->def.width, ctx, changed); in ath12k_mac_op_change_chanctx()
7587 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_change_chanctx()
7593 struct ath12k_base *ab = ar->ab; in ath12k_start_vdev_delay()
7594 struct ieee80211_vif *vif = arvif->vif; in ath12k_start_vdev_delay()
7597 if (WARN_ON(arvif->is_started)) in ath12k_start_vdev_delay()
7598 return -EBUSY; in ath12k_start_vdev_delay()
7600 ret = ath12k_mac_vdev_start(arvif, &arvif->chanctx); in ath12k_start_vdev_delay()
7603 arvif->vdev_id, vif->addr, in ath12k_start_vdev_delay()
7604 arvif->chanctx.def.chan->center_freq, ret); in ath12k_start_vdev_delay()
7608 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_start_vdev_delay()
7609 ret = ath12k_monitor_vdev_up(ar, arvif->vdev_id); in ath12k_start_vdev_delay()
7616 arvif->is_started = true; in ath12k_start_vdev_delay()
7639 return -EINVAL; in ath12k_mac_op_assign_vif_chanctx()
7642 ab = ar->ab; in ath12k_mac_op_assign_vif_chanctx()
7644 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_assign_vif_chanctx()
7648 ctx, arvif->vdev_id); in ath12k_mac_op_assign_vif_chanctx()
7650 arvif->punct_bitmap = ctx->def.punctured; in ath12k_mac_op_assign_vif_chanctx()
7653 if (ab->hw_params->vdev_start_delay && in ath12k_mac_op_assign_vif_chanctx()
7654 arvif->vdev_type != WMI_VDEV_TYPE_AP && in ath12k_mac_op_assign_vif_chanctx()
7655 arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath12k_mac_op_assign_vif_chanctx()
7656 !ath12k_peer_exist_by_vdev_id(ab, arvif->vdev_id)) { in ath12k_mac_op_assign_vif_chanctx()
7657 memcpy(&arvif->chanctx, ctx, sizeof(*ctx)); in ath12k_mac_op_assign_vif_chanctx()
7662 if (WARN_ON(arvif->is_started)) { in ath12k_mac_op_assign_vif_chanctx()
7663 ret = -EBUSY; in ath12k_mac_op_assign_vif_chanctx()
7667 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_op_assign_vif_chanctx()
7671 arvif->is_started = true; in ath12k_mac_op_assign_vif_chanctx()
7678 arvif->vdev_id, vif->addr, in ath12k_mac_op_assign_vif_chanctx()
7679 ctx->def.chan->center_freq, ret); in ath12k_mac_op_assign_vif_chanctx()
7683 if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && ar->monitor_vdev_created) in ath12k_mac_op_assign_vif_chanctx()
7686 arvif->is_started = true; in ath12k_mac_op_assign_vif_chanctx()
7691 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_assign_vif_chanctx()
7714 if (!arvif->is_created) in ath12k_mac_op_unassign_vif_chanctx()
7717 ar = arvif->ar; in ath12k_mac_op_unassign_vif_chanctx()
7718 ab = ar->ab; in ath12k_mac_op_unassign_vif_chanctx()
7720 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
7724 ctx, arvif->vdev_id); in ath12k_mac_op_unassign_vif_chanctx()
7726 WARN_ON(!arvif->is_started); in ath12k_mac_op_unassign_vif_chanctx()
7728 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_op_unassign_vif_chanctx()
7731 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
7735 arvif->is_started = false; in ath12k_mac_op_unassign_vif_chanctx()
7738 if (arvif->vdev_type != WMI_VDEV_TYPE_STA && in ath12k_mac_op_unassign_vif_chanctx()
7739 arvif->vdev_type != WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_op_unassign_vif_chanctx()
7744 arvif->vdev_id, ret); in ath12k_mac_op_unassign_vif_chanctx()
7746 arvif->is_started = false; in ath12k_mac_op_unassign_vif_chanctx()
7748 if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath12k_mac_op_unassign_vif_chanctx()
7749 ar->num_started_vdevs == 1 && ar->monitor_vdev_created) in ath12k_mac_op_unassign_vif_chanctx()
7752 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
7763 ar = ath12k_get_ar_by_ctx(hw, vifs->old_ctx); in ath12k_mac_op_switch_vif_chanctx()
7765 return -EINVAL; in ath12k_mac_op_switch_vif_chanctx()
7767 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_switch_vif_chanctx()
7770 if (ar != ath12k_get_ar_by_ctx(hw, vifs->new_ctx)) { in ath12k_mac_op_switch_vif_chanctx()
7771 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_switch_vif_chanctx()
7772 return -EINVAL; in ath12k_mac_op_switch_vif_chanctx()
7775 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_switch_vif_chanctx()
7780 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_switch_vif_chanctx()
7791 mutex_lock(&ar->conf_mutex); in ath12k_set_vdev_param_to_all_vifs()
7792 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_set_vdev_param_to_all_vifs()
7793 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "setting mac vdev %d param %d value %d\n", in ath12k_set_vdev_param_to_all_vifs()
7794 param, arvif->vdev_id, value); in ath12k_set_vdev_param_to_all_vifs()
7796 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_vdev_param_to_all_vifs()
7799 ath12k_warn(ar->ab, "failed to set param %d for vdev %d: %d\n", in ath12k_set_vdev_param_to_all_vifs()
7800 param, arvif->vdev_id, ret); in ath12k_set_vdev_param_to_all_vifs()
7804 mutex_unlock(&ar->conf_mutex); in ath12k_set_vdev_param_to_all_vifs()
7825 ath12k_warn(ar->ab, "failed to set RTS config for all vdevs of pdev %d", in ath12k_mac_op_set_rts_threshold()
7826 ar->pdev->pdev_id); in ath12k_mac_op_set_rts_threshold()
7846 return -EOPNOTSUPP; in ath12k_mac_op_set_frag_threshold()
7854 time_left = wait_event_timeout(ar->dp.tx_empty_waitq, in ath12k_mac_flush()
7855 (atomic_read(&ar->dp.num_tx_pending) == 0), in ath12k_mac_flush()
7858 ath12k_warn(ar->ab, in ath12k_mac_flush()
7860 atomic_read(&ar->dp.num_tx_pending)); in ath12k_mac_flush()
7861 ret = -ETIMEDOUT; in ath12k_mac_flush()
7864 time_left = wait_event_timeout(ar->txmgmt_empty_waitq, in ath12k_mac_flush()
7865 (atomic_read(&ar->num_pending_mgmt_tx) == 0), in ath12k_mac_flush()
7868 ath12k_warn(ar->ab, in ath12k_mac_flush()
7870 atomic_read(&ar->num_pending_mgmt_tx)); in ath12k_mac_flush()
7871 ret = -ETIMEDOUT; in ath12k_mac_flush()
7916 for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) in ath12k_mac_bitrate_mask_num_ht_rates()
7917 num_rates += hweight16(mask->control[band].ht_mcs[i]); in ath12k_mac_bitrate_mask_num_ht_rates()
7929 num_rates = hweight32(mask->control[band].legacy); in ath12k_mac_has_single_legacy_rate()
7946 struct ieee80211_supported_band *sband = &ar->mac.sbands[band]; in ath12k_mac_bitrate_mask_get_single_nss()
7947 u16 vht_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map); in ath12k_mac_bitrate_mask_get_single_nss()
7956 for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) { in ath12k_mac_bitrate_mask_get_single_nss()
7957 if (mask->control[band].ht_mcs[i] == 0) in ath12k_mac_bitrate_mask_get_single_nss()
7959 else if (mask->control[band].ht_mcs[i] == in ath12k_mac_bitrate_mask_get_single_nss()
7960 sband->ht_cap.mcs.rx_mask[i]) in ath12k_mac_bitrate_mask_get_single_nss()
7966 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) { in ath12k_mac_bitrate_mask_get_single_nss()
7967 if (mask->control[band].vht_mcs[i] == 0) in ath12k_mac_bitrate_mask_get_single_nss()
7969 else if (mask->control[band].vht_mcs[i] == in ath12k_mac_bitrate_mask_get_single_nss()
7982 if (BIT(fls(ht_nss_mask)) - 1 != ht_nss_mask) in ath12k_mac_bitrate_mask_get_single_nss()
8001 if (hweight32(mask->control[band].legacy) != 1) in ath12k_mac_get_single_legacy_rate()
8002 return -EINVAL; in ath12k_mac_get_single_legacy_rate()
8004 rate_idx = ffs(mask->control[band].legacy) - 1; in ath12k_mac_get_single_legacy_rate()
8026 struct ath12k *ar = arvif->ar; in ath12k_mac_set_fixed_rate_params()
8030 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_set_fixed_rate_params()
8032 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac set fixed rate params vdev %i rate 0x%02x nss %u sgi %u\n", in ath12k_mac_set_fixed_rate_params()
8033 arvif->vdev_id, rate, nss, sgi); in ath12k_mac_set_fixed_rate_params()
8036 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
8039 ath12k_warn(ar->ab, "failed to set fixed rate param 0x%02x: %d\n", in ath12k_mac_set_fixed_rate_params()
8045 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
8048 ath12k_warn(ar->ab, "failed to set nss param %d: %d\n", in ath12k_mac_set_fixed_rate_params()
8054 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
8057 ath12k_warn(ar->ab, "failed to set sgi param %d: %d\n", in ath12k_mac_set_fixed_rate_params()
8063 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
8066 ath12k_warn(ar->ab, "failed to set ldpc param %d: %d\n", in ath12k_mac_set_fixed_rate_params()
8083 vht_mcs = mask->control[band].vht_mcs[i]; in ath12k_mac_vht_mcs_range_present()
8087 case BIT(8) - 1: in ath12k_mac_vht_mcs_range_present()
8088 case BIT(9) - 1: in ath12k_mac_vht_mcs_range_present()
8089 case BIT(10) - 1: in ath12k_mac_vht_mcs_range_present()
8104 struct ath12k *ar = arvif->ar; in ath12k_mac_set_bitrate_mask_iter()
8106 if (arsta->arvif != arvif) in ath12k_mac_set_bitrate_mask_iter()
8109 spin_lock_bh(&ar->data_lock); in ath12k_mac_set_bitrate_mask_iter()
8110 arsta->changed |= IEEE80211_RC_SUPP_RATES_CHANGED; in ath12k_mac_set_bitrate_mask_iter()
8111 spin_unlock_bh(&ar->data_lock); in ath12k_mac_set_bitrate_mask_iter()
8113 ieee80211_queue_work(ath12k_ar_to_hw(ar), &arsta->update_wk); in ath12k_mac_set_bitrate_mask_iter()
8121 struct ath12k *ar = arvif->ar; in ath12k_mac_disable_peer_fixed_rate()
8124 if (arsta->arvif != arvif) in ath12k_mac_disable_peer_fixed_rate()
8127 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_disable_peer_fixed_rate()
8128 arvif->vdev_id, in ath12k_mac_disable_peer_fixed_rate()
8132 ath12k_warn(ar->ab, in ath12k_mac_disable_peer_fixed_rate()
8134 sta->addr, ret); in ath12k_mac_disable_peer_fixed_rate()
8144 struct ath12k *ar = arvif->ar; in ath12k_mac_op_set_bitrate_mask()
8157 return -EPERM; in ath12k_mac_op_set_bitrate_mask()
8159 band = def.chan->band; in ath12k_mac_op_set_bitrate_mask()
8160 ht_mcs_mask = mask->control[band].ht_mcs; in ath12k_mac_op_set_bitrate_mask()
8161 vht_mcs_mask = mask->control[band].vht_mcs; in ath12k_mac_op_set_bitrate_mask()
8162 ldpc = !!(ar->ht_cap_info & WMI_HT_CAP_LDPC); in ath12k_mac_op_set_bitrate_mask()
8164 sgi = mask->control[band].gi; in ath12k_mac_op_set_bitrate_mask()
8166 ret = -EINVAL; in ath12k_mac_op_set_bitrate_mask()
8182 ath12k_warn(ar->ab, "failed to get single legacy rate for vdev %i: %d\n", in ath12k_mac_op_set_bitrate_mask()
8183 arvif->vdev_id, ret); in ath12k_mac_op_set_bitrate_mask()
8195 nss = min_t(u32, ar->num_tx_chains, in ath12k_mac_op_set_bitrate_mask()
8202 * - Single VHT Rate : peer_assoc command accommodates only MCS in ath12k_mac_op_set_bitrate_mask()
8203 * range values i.e 0-7, 0-8, 0-9 for VHT. Though mac80211 in ath12k_mac_op_set_bitrate_mask()
8209 * If single VHT rate is passed along with HT rates, we select in ath12k_mac_op_set_bitrate_mask()
8211 * - Multiple VHT Rates : When Multiple VHT rates are given,this in ath12k_mac_op_set_bitrate_mask()
8212 * can be set using RATEMASK CMD which uses FW rate-ctl alg. in ath12k_mac_op_set_bitrate_mask()
8227 ath12k_warn(ar->ab, in ath12k_mac_op_set_bitrate_mask()
8229 ret = -EINVAL; in ath12k_mac_op_set_bitrate_mask()
8237 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
8239 arvif->bitrate_mask = *mask; in ath12k_mac_op_set_bitrate_mask()
8244 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
8247 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
8251 ath12k_warn(ar->ab, "failed to set fixed rate params on vdev %i: %d\n", in ath12k_mac_op_set_bitrate_mask()
8252 arvif->vdev_id, ret); in ath12k_mac_op_set_bitrate_mask()
8255 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
8274 guard(mutex)(&ah->hw_mutex); in ath12k_mac_op_reconfig_complete()
8276 if (ah->state != ATH12K_HW_STATE_RESTARTED) in ath12k_mac_op_reconfig_complete()
8279 ah->state = ATH12K_HW_STATE_ON; in ath12k_mac_op_reconfig_complete()
8283 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_reconfig_complete()
8285 ab = ar->ab; in ath12k_mac_op_reconfig_complete()
8287 ath12k_warn(ar->ab, "pdev %d successfully recovered\n", in ath12k_mac_op_reconfig_complete()
8288 ar->pdev->pdev_id); in ath12k_mac_op_reconfig_complete()
8290 if (ab->is_reset) { in ath12k_mac_op_reconfig_complete()
8291 recovery_count = atomic_inc_return(&ab->recovery_count); in ath12k_mac_op_reconfig_complete()
8299 if (recovery_count == ab->num_radios) { in ath12k_mac_op_reconfig_complete()
8300 atomic_dec(&ab->reset_count); in ath12k_mac_op_reconfig_complete()
8301 complete(&ab->reset_complete); in ath12k_mac_op_reconfig_complete()
8302 ab->is_reset = false; in ath12k_mac_op_reconfig_complete()
8303 atomic_set(&ab->fail_cont_count, 0); in ath12k_mac_op_reconfig_complete()
8308 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_mac_op_reconfig_complete()
8311 arvif->key_cipher, in ath12k_mac_op_reconfig_complete()
8312 arvif->is_up, in ath12k_mac_op_reconfig_complete()
8313 arvif->vdev_type); in ath12k_mac_op_reconfig_complete()
8320 if (arvif->is_up && in ath12k_mac_op_reconfig_complete()
8321 arvif->vdev_type == WMI_VDEV_TYPE_STA && in ath12k_mac_op_reconfig_complete()
8322 arvif->vdev_subtype == WMI_VDEV_SUBTYPE_NONE) { in ath12k_mac_op_reconfig_complete()
8323 ieee80211_hw_restart_disconnect(arvif->vif); in ath12k_mac_op_reconfig_complete()
8330 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_reconfig_complete()
8341 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_update_bss_chan_survey()
8343 if (!test_bit(WMI_TLV_SERVICE_BSS_CHANNEL_INFO_64, ar->ab->wmi_ab.svc_map) || in ath12k_mac_update_bss_chan_survey()
8344 ar->rx_channel != channel) in ath12k_mac_update_bss_chan_survey()
8347 if (ar->scan.state != ATH12K_SCAN_IDLE) { in ath12k_mac_update_bss_chan_survey()
8348 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_update_bss_chan_survey()
8353 reinit_completion(&ar->bss_survey_done); in ath12k_mac_update_bss_chan_survey()
8357 ath12k_warn(ar->ab, "failed to send pdev bss chan info request\n"); in ath12k_mac_update_bss_chan_survey()
8361 ret = wait_for_completion_timeout(&ar->bss_survey_done, 3 * HZ); in ath12k_mac_update_bss_chan_survey()
8363 ath12k_warn(ar->ab, "bss channel survey timed out\n"); in ath12k_mac_update_bss_chan_survey()
8374 return -ENOENT; in ath12k_mac_op_get_survey()
8376 sband = hw->wiphy->bands[NL80211_BAND_2GHZ]; in ath12k_mac_op_get_survey()
8377 if (sband && idx >= sband->n_channels) { in ath12k_mac_op_get_survey()
8378 idx -= sband->n_channels; in ath12k_mac_op_get_survey()
8383 sband = hw->wiphy->bands[NL80211_BAND_5GHZ]; in ath12k_mac_op_get_survey()
8384 if (sband && idx >= sband->n_channels) { in ath12k_mac_op_get_survey()
8385 idx -= sband->n_channels; in ath12k_mac_op_get_survey()
8390 sband = hw->wiphy->bands[NL80211_BAND_6GHZ]; in ath12k_mac_op_get_survey()
8392 if (!sband || idx >= sband->n_channels) in ath12k_mac_op_get_survey()
8393 return -ENOENT; in ath12k_mac_op_get_survey()
8395 ar = ath12k_mac_get_ar_by_chan(hw, &sband->channels[idx]); in ath12k_mac_op_get_survey()
8397 if (sband->channels[idx].flags & IEEE80211_CHAN_DISABLED) { in ath12k_mac_op_get_survey()
8401 return -ENOENT; in ath12k_mac_op_get_survey()
8404 ar_survey = &ar->survey[idx]; in ath12k_mac_op_get_survey()
8406 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_get_survey()
8408 ath12k_mac_update_bss_chan_survey(ar, &sband->channels[idx]); in ath12k_mac_op_get_survey()
8410 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_get_survey()
8412 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_get_survey()
8414 survey->channel = &sband->channels[idx]; in ath12k_mac_op_get_survey()
8416 if (ar->rx_channel == survey->channel) in ath12k_mac_op_get_survey()
8417 survey->filled |= SURVEY_INFO_IN_USE; in ath12k_mac_op_get_survey()
8419 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_get_survey()
8430 sinfo->rx_duration = arsta->rx_duration; in ath12k_mac_op_sta_statistics()
8431 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in ath12k_mac_op_sta_statistics()
8433 sinfo->tx_duration = arsta->tx_duration; in ath12k_mac_op_sta_statistics()
8434 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in ath12k_mac_op_sta_statistics()
8436 if (!arsta->txrate.legacy && !arsta->txrate.nss) in ath12k_mac_op_sta_statistics()
8439 if (arsta->txrate.legacy) { in ath12k_mac_op_sta_statistics()
8440 sinfo->txrate.legacy = arsta->txrate.legacy; in ath12k_mac_op_sta_statistics()
8442 sinfo->txrate.mcs = arsta->txrate.mcs; in ath12k_mac_op_sta_statistics()
8443 sinfo->txrate.nss = arsta->txrate.nss; in ath12k_mac_op_sta_statistics()
8444 sinfo->txrate.bw = arsta->txrate.bw; in ath12k_mac_op_sta_statistics()
8445 sinfo->txrate.he_gi = arsta->txrate.he_gi; in ath12k_mac_op_sta_statistics()
8446 sinfo->txrate.he_dcm = arsta->txrate.he_dcm; in ath12k_mac_op_sta_statistics()
8447 sinfo->txrate.he_ru_alloc = arsta->txrate.he_ru_alloc; in ath12k_mac_op_sta_statistics()
8449 sinfo->txrate.flags = arsta->txrate.flags; in ath12k_mac_op_sta_statistics()
8450 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in ath12k_mac_op_sta_statistics()
8453 sinfo->signal = arsta->rssi_comb + ATH12K_DEFAULT_NOISE_FLOOR; in ath12k_mac_op_sta_statistics()
8454 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in ath12k_mac_op_sta_statistics()
8465 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_cancel_remain_on_channel()
8467 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_cancel_remain_on_channel()
8468 ar->scan.roc_notify = false; in ath12k_mac_op_cancel_remain_on_channel()
8469 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_cancel_remain_on_channel()
8473 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_cancel_remain_on_channel()
8475 cancel_delayed_work_sync(&ar->scan.timeout); in ath12k_mac_op_cancel_remain_on_channel()
8494 if (ah->num_radio == 1) { in ath12k_mac_op_remain_on_channel()
8495 WARN_ON(!arvif->is_created); in ath12k_mac_op_remain_on_channel()
8500 ar = ath12k_mac_select_scan_device(hw, vif, chan->center_freq); in ath12k_mac_op_remain_on_channel()
8502 return -EINVAL; in ath12k_mac_op_remain_on_channel()
8510 * delete-create vdev's for the same ar, in case the request is in ath12k_mac_op_remain_on_channel()
8513 if (arvif->is_created) { in ath12k_mac_op_remain_on_channel()
8514 if (WARN_ON(!arvif->ar)) in ath12k_mac_op_remain_on_channel()
8515 return -EINVAL; in ath12k_mac_op_remain_on_channel()
8517 if (ar != arvif->ar && arvif->is_started) in ath12k_mac_op_remain_on_channel()
8518 return -EBUSY; in ath12k_mac_op_remain_on_channel()
8520 if (ar != arvif->ar) { in ath12k_mac_op_remain_on_channel()
8522 * would assign the arvif->ar to NULL after the call in ath12k_mac_op_remain_on_channel()
8524 prev_ar = arvif->ar; in ath12k_mac_op_remain_on_channel()
8525 mutex_lock(&prev_ar->conf_mutex); in ath12k_mac_op_remain_on_channel()
8527 mutex_unlock(&prev_ar->conf_mutex); in ath12k_mac_op_remain_on_channel()
8529 ath12k_warn(prev_ar->ab, in ath12k_mac_op_remain_on_channel()
8540 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_remain_on_channel()
8542 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_remain_on_channel()
8544 ath12k_warn(ar->ab, "unable to create scan vdev for roc: %d\n", in ath12k_mac_op_remain_on_channel()
8546 return -EINVAL; in ath12k_mac_op_remain_on_channel()
8551 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_remain_on_channel()
8552 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_remain_on_channel()
8554 switch (ar->scan.state) { in ath12k_mac_op_remain_on_channel()
8556 reinit_completion(&ar->scan.started); in ath12k_mac_op_remain_on_channel()
8557 reinit_completion(&ar->scan.completed); in ath12k_mac_op_remain_on_channel()
8558 reinit_completion(&ar->scan.on_channel); in ath12k_mac_op_remain_on_channel()
8559 ar->scan.state = ATH12K_SCAN_STARTING; in ath12k_mac_op_remain_on_channel()
8560 ar->scan.is_roc = true; in ath12k_mac_op_remain_on_channel()
8561 ar->scan.vdev_id = arvif->vdev_id; in ath12k_mac_op_remain_on_channel()
8562 ar->scan.roc_freq = chan->center_freq; in ath12k_mac_op_remain_on_channel()
8563 ar->scan.roc_notify = true; in ath12k_mac_op_remain_on_channel()
8569 ret = -EBUSY; in ath12k_mac_op_remain_on_channel()
8573 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_remain_on_channel()
8578 scan_time_msec = hw->wiphy->max_remain_on_channel_duration * 2; in ath12k_mac_op_remain_on_channel()
8586 ret = -ENOMEM; in ath12k_mac_op_remain_on_channel()
8590 arg.vdev_id = arvif->vdev_id; in ath12k_mac_op_remain_on_channel()
8592 arg.chan_list[0] = chan->center_freq; in ath12k_mac_op_remain_on_channel()
8601 ath12k_warn(ar->ab, "failed to start roc scan: %d\n", ret); in ath12k_mac_op_remain_on_channel()
8603 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_remain_on_channel()
8604 ar->scan.state = ATH12K_SCAN_IDLE; in ath12k_mac_op_remain_on_channel()
8605 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_remain_on_channel()
8609 ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ); in ath12k_mac_op_remain_on_channel()
8611 ath12k_warn(ar->ab, "failed to switch to channel for roc scan\n"); in ath12k_mac_op_remain_on_channel()
8614 ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret); in ath12k_mac_op_remain_on_channel()
8615 ret = -ETIMEDOUT; in ath12k_mac_op_remain_on_channel()
8619 ieee80211_queue_delayed_work(hw, &ar->scan.timeout, in ath12k_mac_op_remain_on_channel()
8627 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_remain_on_channel()
8637 struct ath12k_rekey_data *rekey_data = &arvif->rekey_data; in ath12k_mac_op_set_rekey_data()
8641 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac set rekey data vdev %d\n", in ath12k_mac_op_set_rekey_data()
8642 arvif->vdev_id); in ath12k_mac_op_set_rekey_data()
8644 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_rekey_data()
8646 memcpy(rekey_data->kck, data->kck, NL80211_KCK_LEN); in ath12k_mac_op_set_rekey_data()
8647 memcpy(rekey_data->kek, data->kek, NL80211_KEK_LEN); in ath12k_mac_op_set_rekey_data()
8649 /* The supplicant works on big-endian, the firmware expects it on in ath12k_mac_op_set_rekey_data()
8652 rekey_data->replay_ctr = get_unaligned_be64(data->replay_ctr); in ath12k_mac_op_set_rekey_data()
8654 arvif->rekey_data.enable_offload = true; in ath12k_mac_op_set_rekey_data()
8656 ath12k_dbg_dump(ar->ab, ATH12K_DBG_MAC, "kck", NULL, in ath12k_mac_op_set_rekey_data()
8657 rekey_data->kck, NL80211_KCK_LEN); in ath12k_mac_op_set_rekey_data()
8658 ath12k_dbg_dump(ar->ab, ATH12K_DBG_MAC, "kek", NULL, in ath12k_mac_op_set_rekey_data()
8659 rekey_data->kck, NL80211_KEK_LEN); in ath12k_mac_op_set_rekey_data()
8660 ath12k_dbg_dump(ar->ab, ATH12K_DBG_MAC, "replay ctr", NULL, in ath12k_mac_op_set_rekey_data()
8661 &rekey_data->replay_ctr, sizeof(rekey_data->replay_ctr)); in ath12k_mac_op_set_rekey_data()
8663 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_rekey_data()
8720 for (i = 0; i < band->n_channels; i++) { in ath12k_mac_update_ch_list()
8721 if (band->channels[i].center_freq < freq_low || in ath12k_mac_update_ch_list()
8722 band->channels[i].center_freq > freq_high) in ath12k_mac_update_ch_list()
8723 band->channels[i].flags |= IEEE80211_CHAN_DISABLED; in ath12k_mac_update_ch_list()
8726 ar->freq_low = freq_low; in ath12k_mac_update_ch_list()
8727 ar->freq_high = freq_high; in ath12k_mac_update_ch_list()
8732 struct ath12k_pdev *pdev = ar->pdev; in ath12k_get_phy_id()
8733 struct ath12k_pdev_cap *pdev_cap = &pdev->cap; in ath12k_get_phy_id()
8736 return pdev_cap->band[NL80211_BAND_2GHZ].phy_id; in ath12k_get_phy_id()
8739 return pdev_cap->band[NL80211_BAND_5GHZ].phy_id; in ath12k_get_phy_id()
8741 ath12k_warn(ar->ab, "unsupported phy cap:%d\n", band); in ath12k_get_phy_id()
8752 struct ath12k_hw *ah = ar->ah; in ath12k_mac_setup_channels_rates()
8761 reg_cap = &ar->ab->hal_reg_cap[ar->pdev_idx]; in ath12k_mac_setup_channels_rates()
8768 return -ENOMEM; in ath12k_mac_setup_channels_rates()
8770 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath12k_mac_setup_channels_rates()
8771 band->band = NL80211_BAND_2GHZ; in ath12k_mac_setup_channels_rates()
8772 band->n_channels = ARRAY_SIZE(ath12k_2ghz_channels); in ath12k_mac_setup_channels_rates()
8773 band->channels = channels; in ath12k_mac_setup_channels_rates()
8774 band->n_bitrates = ath12k_g_rates_size; in ath12k_mac_setup_channels_rates()
8775 band->bitrates = ath12k_g_rates; in ath12k_mac_setup_channels_rates()
8778 if (ar->ab->hw_params->single_pdev_only) { in ath12k_mac_setup_channels_rates()
8780 reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath12k_mac_setup_channels_rates()
8783 reg_cap->low_2ghz_chan, in ath12k_mac_setup_channels_rates()
8784 reg_cap->high_2ghz_chan); in ath12k_mac_setup_channels_rates()
8788 if (reg_cap->high_5ghz_chan >= ATH12K_MIN_6G_FREQ) { in ath12k_mac_setup_channels_rates()
8792 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath12k_mac_setup_channels_rates()
8793 return -ENOMEM; in ath12k_mac_setup_channels_rates()
8796 ar->supports_6ghz = true; in ath12k_mac_setup_channels_rates()
8797 band = &ar->mac.sbands[NL80211_BAND_6GHZ]; in ath12k_mac_setup_channels_rates()
8798 band->band = NL80211_BAND_6GHZ; in ath12k_mac_setup_channels_rates()
8799 band->n_channels = ARRAY_SIZE(ath12k_6ghz_channels); in ath12k_mac_setup_channels_rates()
8800 band->channels = channels; in ath12k_mac_setup_channels_rates()
8801 band->n_bitrates = ath12k_a_rates_size; in ath12k_mac_setup_channels_rates()
8802 band->bitrates = ath12k_a_rates; in ath12k_mac_setup_channels_rates()
8805 reg_cap->low_5ghz_chan, in ath12k_mac_setup_channels_rates()
8806 reg_cap->high_5ghz_chan); in ath12k_mac_setup_channels_rates()
8807 ah->use_6ghz_regd = true; in ath12k_mac_setup_channels_rates()
8810 if (reg_cap->low_5ghz_chan < ATH12K_MIN_6G_FREQ) { in ath12k_mac_setup_channels_rates()
8815 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath12k_mac_setup_channels_rates()
8816 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in ath12k_mac_setup_channels_rates()
8817 return -ENOMEM; in ath12k_mac_setup_channels_rates()
8820 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath12k_mac_setup_channels_rates()
8821 band->band = NL80211_BAND_5GHZ; in ath12k_mac_setup_channels_rates()
8822 band->n_channels = ARRAY_SIZE(ath12k_5ghz_channels); in ath12k_mac_setup_channels_rates()
8823 band->channels = channels; in ath12k_mac_setup_channels_rates()
8824 band->n_bitrates = ath12k_a_rates_size; in ath12k_mac_setup_channels_rates()
8825 band->bitrates = ath12k_a_rates; in ath12k_mac_setup_channels_rates()
8828 if (ar->ab->hw_params->single_pdev_only) { in ath12k_mac_setup_channels_rates()
8830 reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath12k_mac_setup_channels_rates()
8834 reg_cap->low_5ghz_chan, in ath12k_mac_setup_channels_rates()
8835 reg_cap->high_5ghz_chan); in ath12k_mac_setup_channels_rates()
8849 interface_modes &= ar->ab->hw_params->interface_modes; in ath12k_mac_get_ifmodes()
8864 interface_modes = ar->ab->hw_params->interface_modes; in ath12k_mac_is_iface_mode_enable()
8876 struct wiphy *wiphy = ah->hw->wiphy; in ath12k_mac_setup_iface_combinations()
8890 return -ENOMEM; in ath12k_mac_setup_iface_combinations()
8909 return -ENOMEM; in ath12k_mac_setup_iface_combinations()
8942 wiphy->iface_combinations = combinations; in ath12k_mac_setup_iface_combinations()
8943 wiphy->n_iface_combinations = 1; in ath12k_mac_setup_iface_combinations()
8991 idr_for_each(&ar->txmgmt_idr, ath12k_mac_tx_mgmt_pending_free, ar); in ath12k_mac_cleanup_unregister()
8992 idr_destroy(&ar->txmgmt_idr); in ath12k_mac_cleanup_unregister()
8994 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath12k_mac_cleanup_unregister()
8995 kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels); in ath12k_mac_cleanup_unregister()
8996 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in ath12k_mac_cleanup_unregister()
9001 struct ieee80211_hw *hw = ah->hw; in ath12k_mac_hw_unregister()
9002 struct wiphy *wiphy = hw->wiphy; in ath12k_mac_hw_unregister()
9007 cancel_work_sync(&ar->regd_update_work); in ath12k_mac_hw_unregister()
9016 kfree(wiphy->iface_combinations[0].limits); in ath12k_mac_hw_unregister()
9017 kfree(wiphy->iface_combinations); in ath12k_mac_hw_unregister()
9026 struct ath12k_pdev_cap *cap = &ar->pdev->cap; in ath12k_mac_setup_register()
9029 init_waitqueue_head(&ar->txmgmt_empty_waitq); in ath12k_mac_setup_register()
9030 idr_init(&ar->txmgmt_idr); in ath12k_mac_setup_register()
9031 spin_lock_init(&ar->txmgmt_idr_lock); in ath12k_mac_setup_register()
9036 cap->supported_bands, in ath12k_mac_setup_register()
9044 ar->max_num_stations = ath12k_core_get_max_station_per_radio(ar->ab); in ath12k_mac_setup_register()
9045 ar->max_num_peers = ath12k_core_get_max_peers_per_radio(ar->ab); in ath12k_mac_setup_register()
9052 struct ieee80211_hw *hw = ah->hw; in ath12k_mac_hw_register()
9053 struct wiphy *wiphy = hw->wiphy; in ath12k_mac_hw_register()
9055 struct ath12k_base *ab = ar->ab; in ath12k_mac_hw_register()
9075 wiphy->max_ap_assoc_sta = 0; in ath12k_mac_hw_register()
9080 pdev = ar->pdev; in ath12k_mac_hw_register()
9081 if (ar->ab->pdevs_macaddr_valid) { in ath12k_mac_hw_register()
9082 ether_addr_copy(ar->mac_addr, pdev->mac_addr); in ath12k_mac_hw_register()
9084 ether_addr_copy(ar->mac_addr, ar->ab->mac_addr); in ath12k_mac_hw_register()
9085 ar->mac_addr[4] += ar->pdev_idx; in ath12k_mac_hw_register()
9088 ret = ath12k_mac_setup_register(ar, &ht_cap_info, hw->wiphy->bands); in ath12k_mac_hw_register()
9093 wiphy->max_ap_assoc_sta += ar->max_num_stations; in ath12k_mac_hw_register()
9099 cap = &pdev->cap; in ath12k_mac_hw_register()
9101 antennas_rx = max_t(u32, antennas_rx, cap->rx_chain_mask); in ath12k_mac_hw_register()
9102 antennas_tx = max_t(u32, antennas_tx, cap->tx_chain_mask); in ath12k_mac_hw_register()
9104 if (ar->supports_6ghz) in ath12k_mac_hw_register()
9107 if (test_bit(ATH12K_FLAG_RAW_MODE, &ar->ab->dev_flags)) in ath12k_mac_hw_register()
9110 if (!ar->ab->hw_params->supports_monitor) in ath12k_mac_hw_register()
9114 mac_addr = ar->mac_addr; in ath12k_mac_hw_register()
9116 mac_addr = ab->mac_addr; in ath12k_mac_hw_register()
9121 wiphy->available_antennas_rx = antennas_rx; in ath12k_mac_hw_register()
9122 wiphy->available_antennas_tx = antennas_tx; in ath12k_mac_hw_register()
9125 SET_IEEE80211_DEV(hw, ab->dev); in ath12k_mac_hw_register()
9133 wiphy->interface_modes = ath12k_mac_get_ifmodes(ah); in ath12k_mac_hw_register()
9135 if (ah->num_radio == 1 && in ath12k_mac_hw_register()
9136 wiphy->bands[NL80211_BAND_2GHZ] && in ath12k_mac_hw_register()
9137 wiphy->bands[NL80211_BAND_5GHZ] && in ath12k_mac_hw_register()
9138 wiphy->bands[NL80211_BAND_6GHZ]) in ath12k_mac_hw_register()
9156 if ((ht_cap & WMI_HT_CAP_ENABLED) || ar->supports_6ghz) { in ath12k_mac_hw_register()
9164 wiphy->features |= NL80211_FEATURE_STATIC_SMPS; in ath12k_mac_hw_register()
9165 wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in ath12k_mac_hw_register()
9172 (ar->supports_6ghz && ab->hw_params->supports_dynamic_smps_6ghz)) in ath12k_mac_hw_register()
9173 wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS; in ath12k_mac_hw_register()
9175 wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID; in ath12k_mac_hw_register()
9176 wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN; in ath12k_mac_hw_register()
9178 hw->max_listen_interval = ATH12K_MAX_HW_LISTEN_INTERVAL; in ath12k_mac_hw_register()
9180 wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; in ath12k_mac_hw_register()
9181 wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; in ath12k_mac_hw_register()
9182 wiphy->max_remain_on_channel_duration = 5000; in ath12k_mac_hw_register()
9184 wiphy->flags |= WIPHY_FLAG_AP_UAPSD; in ath12k_mac_hw_register()
9185 wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | in ath12k_mac_hw_register()
9192 wiphy->flags |= WIPHY_FLAG_DISABLE_WEXT; in ath12k_mac_hw_register()
9194 hw->queues = ATH12K_HW_MAX_QUEUES; in ath12k_mac_hw_register()
9195 wiphy->tx_queue_len = ATH12K_QUEUE_LEN; in ath12k_mac_hw_register()
9196 hw->offchannel_tx_hw_queue = ATH12K_HW_MAX_QUEUES - 1; in ath12k_mac_hw_register()
9197 hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_EHT; in ath12k_mac_hw_register()
9199 hw->vif_data_size = sizeof(struct ath12k_vif); in ath12k_mac_hw_register()
9200 hw->sta_data_size = sizeof(struct ath12k_sta); in ath12k_mac_hw_register()
9201 hw->extra_tx_headroom = ab->hw_params->iova_mask; in ath12k_mac_hw_register()
9206 wiphy->cipher_suites = cipher_suites; in ath12k_mac_hw_register()
9207 wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); in ath12k_mac_hw_register()
9209 wiphy->iftype_ext_capab = ath12k_iftypes_ext_capa; in ath12k_mac_hw_register()
9210 wiphy->num_iftype_ext_capab = ARRAY_SIZE(ath12k_iftypes_ext_capa); in ath12k_mac_hw_register()
9212 wiphy->mbssid_max_interfaces = mbssid_max_interfaces; in ath12k_mac_hw_register()
9213 wiphy->ema_max_profile_periodicity = TARGET_EMA_MAX_PROFILE_PERIOD; in ath12k_mac_hw_register()
9227 hw->netdev_features = NETIF_F_HW_CSUM; in ath12k_mac_hw_register()
9232 if (test_bit(WMI_TLV_SERVICE_NLO, ar->wmi->wmi_ab->svc_map)) { in ath12k_mac_hw_register()
9233 wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS; in ath12k_mac_hw_register()
9234 wiphy->max_match_sets = WMI_PNO_MAX_SUPP_NETWORKS; in ath12k_mac_hw_register()
9235 wiphy->max_sched_scan_ie_len = WMI_PNO_MAX_IE_LENGTH; in ath12k_mac_hw_register()
9236 wiphy->max_sched_scan_plans = WMI_PNO_MAX_SCHED_SCAN_PLANS; in ath12k_mac_hw_register()
9237 wiphy->max_sched_scan_plan_interval = in ath12k_mac_hw_register()
9239 wiphy->max_sched_scan_plan_iterations = in ath12k_mac_hw_register()
9241 wiphy->features |= NL80211_FEATURE_ND_RANDOM_MAC_ADDR; in ath12k_mac_hw_register()
9246 ath12k_warn(ar->ab, "failed to init wow: %d\n", ret); in ath12k_mac_hw_register()
9262 wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR); in ath12k_mac_hw_register()
9268 ath12k_err(ar->ab, "ath12k regd update failed: %d\n", ret); in ath12k_mac_hw_register()
9284 kfree(wiphy->iface_combinations[0].limits); in ath12k_mac_hw_register()
9285 kfree(wiphy->iface_combinations); in ath12k_mac_hw_register()
9288 i = ah->num_radio; in ath12k_mac_hw_register()
9303 struct ath12k_base *ab = ar->ab; in ath12k_mac_setup()
9304 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_setup()
9305 u8 pdev_idx = ar->pdev_idx; in ath12k_mac_setup()
9307 ar->lmac_id = ath12k_hw_get_mac_from_pdev_id(ab->hw_params, pdev_idx); in ath12k_mac_setup()
9309 ar->wmi = &ab->wmi_ab.wmi[pdev_idx]; in ath12k_mac_setup()
9315 ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask; in ath12k_mac_setup()
9316 ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask; in ath12k_mac_setup()
9317 ar->num_tx_chains = hweight32(pdev->cap.tx_chain_mask); in ath12k_mac_setup()
9318 ar->num_rx_chains = hweight32(pdev->cap.rx_chain_mask); in ath12k_mac_setup()
9320 spin_lock_init(&ar->data_lock); in ath12k_mac_setup()
9321 INIT_LIST_HEAD(&ar->arvifs); in ath12k_mac_setup()
9322 INIT_LIST_HEAD(&ar->ppdu_stats_info); in ath12k_mac_setup()
9323 mutex_init(&ar->conf_mutex); in ath12k_mac_setup()
9324 init_completion(&ar->vdev_setup_done); in ath12k_mac_setup()
9325 init_completion(&ar->vdev_delete_done); in ath12k_mac_setup()
9326 init_completion(&ar->peer_assoc_done); in ath12k_mac_setup()
9327 init_completion(&ar->peer_delete_done); in ath12k_mac_setup()
9328 init_completion(&ar->install_key_done); in ath12k_mac_setup()
9329 init_completion(&ar->bss_survey_done); in ath12k_mac_setup()
9330 init_completion(&ar->scan.started); in ath12k_mac_setup()
9331 init_completion(&ar->scan.completed); in ath12k_mac_setup()
9332 init_completion(&ar->scan.on_channel); in ath12k_mac_setup()
9334 INIT_DELAYED_WORK(&ar->scan.timeout, ath12k_scan_timeout_work); in ath12k_mac_setup()
9335 INIT_WORK(&ar->regd_update_work, ath12k_regd_update_work); in ath12k_mac_setup()
9337 INIT_WORK(&ar->wmi_mgmt_tx_work, ath12k_mgmt_over_wmi_tx_work); in ath12k_mac_setup()
9338 skb_queue_head_init(&ar->wmi_mgmt_tx_queue); in ath12k_mac_setup()
9347 if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) in ath12k_mac_register()
9351 ab->cc_freq_hz = 320000; in ath12k_mac_register()
9352 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; in ath12k_mac_register()
9354 for (i = 0; i < ab->num_hw; i++) { in ath12k_mac_register()
9355 ah = ab->ah[i]; in ath12k_mac_register()
9365 for (i = i - 1; i >= 0; i--) { in ath12k_mac_register()
9366 ah = ab->ah[i]; in ath12k_mac_register()
9381 for (i = ab->num_hw - 1; i >= 0; i--) { in ath12k_mac_unregister()
9382 ah = ab->ah[i]; in ath12k_mac_unregister()
9392 ieee80211_free_hw(ah->hw); in ath12k_mac_hw_destroy()
9412 ah->hw = hw; in ath12k_mac_hw_allocate()
9413 ah->num_radio = num_pdev_map; in ath12k_mac_hw_allocate()
9415 mutex_init(&ah->hw_mutex); in ath12k_mac_hw_allocate()
9420 pdev = &ab->pdevs[pdev_idx]; in ath12k_mac_hw_allocate()
9423 ar->ah = ah; in ath12k_mac_hw_allocate()
9424 ar->ab = ab; in ath12k_mac_hw_allocate()
9425 ar->hw_link_id = pdev->hw_link_id; in ath12k_mac_hw_allocate()
9426 ar->pdev = pdev; in ath12k_mac_hw_allocate()
9427 ar->pdev_idx = pdev_idx; in ath12k_mac_hw_allocate()
9428 pdev->ar = ar; in ath12k_mac_hw_allocate()
9441 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_destroy()
9442 pdev = &ab->pdevs[i]; in ath12k_mac_destroy()
9443 if (!pdev->ar) in ath12k_mac_destroy()
9446 pdev->ar = NULL; in ath12k_mac_destroy()
9449 for (i = 0; i < ab->num_hw; i++) { in ath12k_mac_destroy()
9450 if (!ab->ah[i]) in ath12k_mac_destroy()
9453 ath12k_mac_hw_destroy(ab->ah[i]); in ath12k_mac_destroy()
9454 ab->ah[i] = NULL; in ath12k_mac_destroy()
9465 if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) in ath12k_mac_allocate()
9468 ab->num_hw = ab->num_radios; in ath12k_mac_allocate()
9471 for (i = 0; i < ab->num_hw; i++) { in ath12k_mac_allocate()
9481 ret = -ENOMEM; in ath12k_mac_allocate()
9485 ab->ah[i] = ah; in ath12k_mac_allocate()
9493 for (i = i - 1; i >= 0; i--) { in ath12k_mac_allocate()
9494 if (!ab->ah[i]) in ath12k_mac_allocate()
9497 ath12k_mac_hw_destroy(ab->ah[i]); in ath12k_mac_allocate()
9498 ab->ah[i] = NULL; in ath12k_mac_allocate()
9509 struct ath12k *ar = arvif->ar; in ath12k_mac_vif_set_keepalive()
9512 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vif_set_keepalive()
9514 if (arvif->vdev_type != WMI_VDEV_TYPE_STA) in ath12k_mac_vif_set_keepalive()
9517 if (!test_bit(WMI_TLV_SERVICE_STA_KEEP_ALIVE, ar->ab->wmi_ab.svc_map)) in ath12k_mac_vif_set_keepalive()
9520 arg.vdev_id = arvif->vdev_id; in ath12k_mac_vif_set_keepalive()
9527 ath12k_warn(ar->ab, "failed to set keepalive on vdev %i: %d\n", in ath12k_mac_vif_set_keepalive()
9528 arvif->vdev_id, ret); in ath12k_mac_vif_set_keepalive()