Lines Matching +full:sense +full:- +full:bitfield +full:- +full:width
1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
9 #include <linux/bitfield.h>
162 /* new addition in IEEE Std 802.11ax-2021 */
242 #define ath11k_a_rates_size (ARRAY_SIZE(ath11k_legacy_rates) - 4)
403 return -EINVAL; in ath11k_mac_hw_ratecode_to_legacy_rate()
424 for (i = 0; i < sband->n_bitrates; i++) in ath11k_mac_bitrate_to_idx()
425 if (sband->bitrates[i].bitrate == bitrate) in ath11k_mac_bitrate_to_idx()
436 for (nss = IEEE80211_HT_MCS_MASK_LEN - 1; nss >= 0; nss--) in ath11k_mac_max_ht_nss()
448 for (nss = NL80211_VHT_NSS_MAX - 1; nss >= 0; nss--) in ath11k_mac_max_vht_nss()
460 for (nss = NL80211_HE_NSS_MAX - 1; nss >= 0; nss--) in ath11k_mac_max_he_nss()
508 conf = rcu_dereference(vif->bss_conf.chanctx_conf); in ath11k_mac_vif_chan()
511 return -ENOENT; in ath11k_mac_vif_chan()
514 *def = conf->def; in ath11k_mac_vif_chan()
539 for (i = 0; i < sband->n_bitrates; i++) { in ath11k_mac_hw_rate_to_idx()
540 rate = &sband->bitrates[i]; in ath11k_mac_hw_rate_to_idx()
542 if (ath11k_mac_bitrate_is_cck(rate->bitrate) != cck) in ath11k_mac_hw_rate_to_idx()
545 if (rate->hw_value == hw_rate) in ath11k_mac_hw_rate_to_idx()
547 else if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE && in ath11k_mac_hw_rate_to_idx()
548 rate->hw_value_short == hw_rate) in ath11k_mac_hw_rate_to_idx()
565 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_get_arvif_iter()
567 if (arvif->vdev_id == arvif_iter->vdev_id) in ath11k_get_arvif_iter()
568 arvif_iter->arvif = arvif; in ath11k_get_arvif_iter()
580 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath11k_mac_get_arvif()
585 ath11k_warn(ar->ab, "No VIF found for vdev %d\n", vdev_id); in ath11k_mac_get_arvif()
599 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_get_arvif_by_vdev_id()
600 pdev = rcu_dereference(ab->pdevs_active[i]); in ath11k_mac_get_arvif_by_vdev_id()
601 if (pdev && pdev->ar && in ath11k_mac_get_arvif_by_vdev_id()
602 (pdev->ar->allocated_vdev_map & (1LL << vdev_id))) { in ath11k_mac_get_arvif_by_vdev_id()
603 arvif = ath11k_mac_get_arvif(pdev->ar, vdev_id); in ath11k_mac_get_arvif_by_vdev_id()
617 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_get_ar_by_vdev_id()
618 pdev = rcu_dereference(ab->pdevs_active[i]); in ath11k_mac_get_ar_by_vdev_id()
619 if (pdev && pdev->ar) { in ath11k_mac_get_ar_by_vdev_id()
620 if (pdev->ar->allocated_vdev_map & (1LL << vdev_id)) in ath11k_mac_get_ar_by_vdev_id()
621 return pdev->ar; in ath11k_mac_get_ar_by_vdev_id()
633 if (ab->hw_params.single_pdev_only) { in ath11k_mac_get_ar_by_pdev_id()
634 pdev = rcu_dereference(ab->pdevs_active[0]); in ath11k_mac_get_ar_by_pdev_id()
635 return pdev ? pdev->ar : NULL; in ath11k_mac_get_ar_by_pdev_id()
638 if (WARN_ON(pdev_id > ab->num_radios)) in ath11k_mac_get_ar_by_pdev_id()
641 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_get_ar_by_pdev_id()
642 pdev = rcu_dereference(ab->pdevs_active[i]); in ath11k_mac_get_ar_by_pdev_id()
644 if (pdev && pdev->pdev_id == pdev_id) in ath11k_mac_get_ar_by_pdev_id()
645 return (pdev->ar ? pdev->ar : NULL); in ath11k_mac_get_ar_by_pdev_id()
658 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_get_vif_up()
659 pdev = &ab->pdevs[i]; in ath11k_mac_get_vif_up()
660 ar = pdev->ar; in ath11k_mac_get_vif_up()
661 list_for_each_entry(arvif, &ar->arvifs, list) { in ath11k_mac_get_vif_up()
662 if (arvif->is_up) in ath11k_mac_get_vif_up()
679 struct ath11k *ar = arvif->ar; in ath11k_mac_get_target_pdev_id_from_vif()
680 struct ath11k_base *ab = ar->ab; in ath11k_mac_get_target_pdev_id_from_vif()
681 struct ieee80211_vif *vif = arvif->vif; in ath11k_mac_get_target_pdev_id_from_vif()
684 u8 pdev_id = ab->target_pdev_ids[0].pdev_id; in ath11k_mac_get_target_pdev_id_from_vif()
690 band = def.chan->band; in ath11k_mac_get_target_pdev_id_from_vif()
692 for (i = 0; i < ab->target_pdev_count; i++) { in ath11k_mac_get_target_pdev_id_from_vif()
693 if (ath11k_mac_band_match(band, ab->target_pdev_ids[i].supported_bands)) in ath11k_mac_get_target_pdev_id_from_vif()
694 return ab->target_pdev_ids[i].pdev_id; in ath11k_mac_get_target_pdev_id_from_vif()
704 arvif = ath11k_mac_get_vif_up(ar->ab); in ath11k_mac_get_target_pdev_id()
709 return ar->ab->target_pdev_ids[0].pdev_id; in ath11k_mac_get_target_pdev_id()
714 struct ath11k_base *ab = ar->ab; in ath11k_pdev_caps_update()
716 ar->max_tx_power = ab->target_caps.hw_max_tx_power; in ath11k_pdev_caps_update()
718 /* FIXME Set min_tx_power to ab->target_caps.hw_min_tx_power. in ath11k_pdev_caps_update()
720 * we can set ar->min_tx_power to 0 currently until in ath11k_pdev_caps_update()
723 ar->min_tx_power = 0; in ath11k_pdev_caps_update()
725 ar->txpower_limit_2g = ar->max_tx_power; in ath11k_pdev_caps_update()
726 ar->txpower_limit_5g = ar->max_tx_power; in ath11k_pdev_caps_update()
727 ar->txpower_scale = WMI_HOST_TP_SCALE_MAX; in ath11k_pdev_caps_update()
732 struct ath11k_pdev *pdev = ar->pdev; in ath11k_mac_txpower_recalc()
734 int ret, txpower = -1; in ath11k_mac_txpower_recalc()
737 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_txpower_recalc()
739 list_for_each_entry(arvif, &ar->arvifs, list) { in ath11k_mac_txpower_recalc()
740 if (arvif->txpower <= 0) in ath11k_mac_txpower_recalc()
743 if (txpower == -1) in ath11k_mac_txpower_recalc()
744 txpower = arvif->txpower; in ath11k_mac_txpower_recalc()
746 txpower = min(txpower, arvif->txpower); in ath11k_mac_txpower_recalc()
749 if (txpower == -1) in ath11k_mac_txpower_recalc()
753 txpower = min_t(u32, max_t(u32, ar->min_tx_power, txpower), in ath11k_mac_txpower_recalc()
754 ar->max_tx_power) * 2; in ath11k_mac_txpower_recalc()
756 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "txpower to set in hw %d\n", in ath11k_mac_txpower_recalc()
759 if ((pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) && in ath11k_mac_txpower_recalc()
760 ar->txpower_limit_2g != txpower) { in ath11k_mac_txpower_recalc()
763 txpower, ar->pdev->pdev_id); in ath11k_mac_txpower_recalc()
766 ar->txpower_limit_2g = txpower; in ath11k_mac_txpower_recalc()
769 if ((pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) && in ath11k_mac_txpower_recalc()
770 ar->txpower_limit_5g != txpower) { in ath11k_mac_txpower_recalc()
773 txpower, ar->pdev->pdev_id); in ath11k_mac_txpower_recalc()
776 ar->txpower_limit_5g = txpower; in ath11k_mac_txpower_recalc()
782 ath11k_warn(ar->ab, "failed to recalc txpower limit %d using pdev param %d: %d\n", in ath11k_mac_txpower_recalc()
789 struct ath11k *ar = arvif->ar; in ath11k_recalc_rtscts_prot()
793 lockdep_assert_held(&ar->conf_mutex); in ath11k_recalc_rtscts_prot()
803 if (arvif->num_legacy_stations > 0) in ath11k_recalc_rtscts_prot()
809 if (arvif->rtscts_prot_mode == rts_cts) in ath11k_recalc_rtscts_prot()
812 arvif->rtscts_prot_mode = rts_cts; in ath11k_recalc_rtscts_prot()
814 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev %d recalc rts/cts prot %d\n", in ath11k_recalc_rtscts_prot()
815 arvif->vdev_id, rts_cts); in ath11k_recalc_rtscts_prot()
817 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_recalc_rtscts_prot()
820 ath11k_warn(ar->ab, "failed to recalculate rts/cts prot for vdev %d: %d\n", in ath11k_recalc_rtscts_prot()
821 arvif->vdev_id, ret); in ath11k_recalc_rtscts_prot()
828 struct ath11k *ar = arvif->ar; in ath11k_mac_set_kickout()
834 ar->pdev->pdev_id); in ath11k_mac_set_kickout()
836 ath11k_warn(ar->ab, "failed to set kickout threshold on vdev %i: %d\n", in ath11k_mac_set_kickout()
837 arvif->vdev_id, ret); in ath11k_mac_set_kickout()
842 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath11k_mac_set_kickout()
845 ath11k_warn(ar->ab, "failed to set keepalive minimum idle time on vdev %i: %d\n", in ath11k_mac_set_kickout()
846 arvif->vdev_id, ret); in ath11k_mac_set_kickout()
851 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath11k_mac_set_kickout()
854 ath11k_warn(ar->ab, "failed to set keepalive maximum idle time on vdev %i: %d\n", in ath11k_mac_set_kickout()
855 arvif->vdev_id, ret); in ath11k_mac_set_kickout()
860 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath11k_mac_set_kickout()
863 ath11k_warn(ar->ab, "failed to set keepalive maximum unresponsive time on vdev %i: %d\n", in ath11k_mac_set_kickout()
864 arvif->vdev_id, ret); in ath11k_mac_set_kickout()
874 struct ath11k_base *ab = ar->ab; in ath11k_mac_peer_cleanup_all()
876 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_peer_cleanup_all()
878 mutex_lock(&ab->tbl_mtx_lock); in ath11k_mac_peer_cleanup_all()
879 spin_lock_bh(&ab->base_lock); in ath11k_mac_peer_cleanup_all()
880 list_for_each_entry_safe(peer, tmp, &ab->peers, list) { in ath11k_mac_peer_cleanup_all()
883 list_del(&peer->list); in ath11k_mac_peer_cleanup_all()
886 spin_unlock_bh(&ab->base_lock); in ath11k_mac_peer_cleanup_all()
887 mutex_unlock(&ab->tbl_mtx_lock); in ath11k_mac_peer_cleanup_all()
889 ar->num_peers = 0; in ath11k_mac_peer_cleanup_all()
890 ar->num_stations = 0; in ath11k_mac_peer_cleanup_all()
895 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_vdev_setup_sync()
897 if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) in ath11k_mac_vdev_setup_sync()
898 return -ESHUTDOWN; in ath11k_mac_vdev_setup_sync()
900 if (!wait_for_completion_timeout(&ar->vdev_setup_done, in ath11k_mac_vdev_setup_sync()
902 return -ETIMEDOUT; in ath11k_mac_vdev_setup_sync()
904 return ar->last_wmi_vdev_start_status ? -EINVAL : 0; in ath11k_mac_vdev_setup_sync()
914 *def = &conf->def; in ath11k_mac_get_any_chandef_iter()
924 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_monitor_vdev_start()
926 channel = chandef->chan; in ath11k_mac_monitor_vdev_start()
929 arg.channel.freq = channel->center_freq; in ath11k_mac_monitor_vdev_start()
930 arg.channel.band_center_freq1 = chandef->center_freq1; in ath11k_mac_monitor_vdev_start()
931 arg.channel.band_center_freq2 = chandef->center_freq2; in ath11k_mac_monitor_vdev_start()
933 arg.channel.mode = ath11k_phymodes[chandef->chan->band][chandef->width]; in ath11k_mac_monitor_vdev_start()
934 arg.channel.chan_radar = !!(channel->flags & IEEE80211_CHAN_RADAR); in ath11k_mac_monitor_vdev_start()
937 arg.channel.max_power = channel->max_power; in ath11k_mac_monitor_vdev_start()
938 arg.channel.max_reg_power = channel->max_reg_power; in ath11k_mac_monitor_vdev_start()
939 arg.channel.max_antenna_gain = channel->max_antenna_gain; in ath11k_mac_monitor_vdev_start()
941 arg.pref_tx_streams = ar->num_tx_chains; in ath11k_mac_monitor_vdev_start()
942 arg.pref_rx_streams = ar->num_rx_chains; in ath11k_mac_monitor_vdev_start()
944 arg.channel.passive = !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR); in ath11k_mac_monitor_vdev_start()
946 reinit_completion(&ar->vdev_setup_done); in ath11k_mac_monitor_vdev_start()
947 reinit_completion(&ar->vdev_delete_done); in ath11k_mac_monitor_vdev_start()
951 ath11k_warn(ar->ab, "failed to request monitor vdev %i start: %d\n", in ath11k_mac_monitor_vdev_start()
958 ath11k_warn(ar->ab, "failed to synchronize setup for monitor vdev %i start: %d\n", in ath11k_mac_monitor_vdev_start()
963 ret = ath11k_wmi_vdev_up(ar, vdev_id, 0, ar->mac_addr); in ath11k_mac_monitor_vdev_start()
965 ath11k_warn(ar->ab, "failed to put up monitor vdev %i: %d\n", in ath11k_mac_monitor_vdev_start()
970 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor vdev %i started\n", in ath11k_mac_monitor_vdev_start()
976 reinit_completion(&ar->vdev_setup_done); in ath11k_mac_monitor_vdev_start()
980 ath11k_warn(ar->ab, "failed to stop monitor vdev %i after start failure: %d\n", in ath11k_mac_monitor_vdev_start()
987 ath11k_warn(ar->ab, "failed to synchronize setup for vdev %i stop: %d\n", in ath11k_mac_monitor_vdev_start()
992 return -EIO; in ath11k_mac_monitor_vdev_start()
999 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_monitor_vdev_stop()
1001 reinit_completion(&ar->vdev_setup_done); in ath11k_mac_monitor_vdev_stop()
1003 ret = ath11k_wmi_vdev_stop(ar, ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_stop()
1005 ath11k_warn(ar->ab, "failed to request monitor vdev %i stop: %d\n", in ath11k_mac_monitor_vdev_stop()
1006 ar->monitor_vdev_id, ret); in ath11k_mac_monitor_vdev_stop()
1012 ath11k_warn(ar->ab, "failed to synchronize monitor vdev %i stop: %d\n", in ath11k_mac_monitor_vdev_stop()
1013 ar->monitor_vdev_id, ret); in ath11k_mac_monitor_vdev_stop()
1017 ret = ath11k_wmi_vdev_down(ar, ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_stop()
1019 ath11k_warn(ar->ab, "failed to put down monitor vdev %i: %d\n", in ath11k_mac_monitor_vdev_stop()
1020 ar->monitor_vdev_id, ret); in ath11k_mac_monitor_vdev_stop()
1024 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor vdev %i stopped\n", in ath11k_mac_monitor_vdev_stop()
1025 ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_stop()
1032 struct ath11k_pdev *pdev = ar->pdev; in ath11k_mac_monitor_vdev_create()
1038 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_monitor_vdev_create()
1040 if (test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) in ath11k_mac_monitor_vdev_create()
1043 if (ar->ab->free_vdev_map == 0) { in ath11k_mac_monitor_vdev_create()
1044 ath11k_warn(ar->ab, "failed to find free vdev id for monitor vdev\n"); in ath11k_mac_monitor_vdev_create()
1045 return -ENOMEM; in ath11k_mac_monitor_vdev_create()
1048 bit = __ffs64(ar->ab->free_vdev_map); in ath11k_mac_monitor_vdev_create()
1050 ar->monitor_vdev_id = bit; in ath11k_mac_monitor_vdev_create()
1052 param.if_id = ar->monitor_vdev_id; in ath11k_mac_monitor_vdev_create()
1055 param.pdev_id = pdev->pdev_id; in ath11k_mac_monitor_vdev_create()
1057 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath11k_mac_monitor_vdev_create()
1058 param.chains[NL80211_BAND_2GHZ].tx = ar->num_tx_chains; in ath11k_mac_monitor_vdev_create()
1059 param.chains[NL80211_BAND_2GHZ].rx = ar->num_rx_chains; in ath11k_mac_monitor_vdev_create()
1061 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath11k_mac_monitor_vdev_create()
1062 param.chains[NL80211_BAND_5GHZ].tx = ar->num_tx_chains; in ath11k_mac_monitor_vdev_create()
1063 param.chains[NL80211_BAND_5GHZ].rx = ar->num_rx_chains; in ath11k_mac_monitor_vdev_create()
1068 ath11k_warn(ar->ab, "failed to request monitor vdev %i creation: %d\n", in ath11k_mac_monitor_vdev_create()
1069 ar->monitor_vdev_id, ret); in ath11k_mac_monitor_vdev_create()
1070 ar->monitor_vdev_id = -1; in ath11k_mac_monitor_vdev_create()
1074 nss = get_num_chains(ar->cfg_tx_chainmask) ? : 1; in ath11k_mac_monitor_vdev_create()
1075 ret = ath11k_wmi_vdev_set_param_cmd(ar, ar->monitor_vdev_id, in ath11k_mac_monitor_vdev_create()
1078 ath11k_warn(ar->ab, "failed to set vdev %d chainmask 0x%x, nss %d :%d\n", in ath11k_mac_monitor_vdev_create()
1079 ar->monitor_vdev_id, ar->cfg_tx_chainmask, nss, ret); in ath11k_mac_monitor_vdev_create()
1085 ath11k_warn(ar->ab, "failed to recalc txpower for monitor vdev %d: %d\n", in ath11k_mac_monitor_vdev_create()
1086 ar->monitor_vdev_id, ret); in ath11k_mac_monitor_vdev_create()
1090 ar->allocated_vdev_map |= 1LL << ar->monitor_vdev_id; in ath11k_mac_monitor_vdev_create()
1091 ar->ab->free_vdev_map &= ~(1LL << ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_create()
1092 ar->num_created_vdevs++; in ath11k_mac_monitor_vdev_create()
1093 set_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags); in ath11k_mac_monitor_vdev_create()
1095 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor vdev %d created\n", in ath11k_mac_monitor_vdev_create()
1096 ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_create()
1101 ath11k_wmi_vdev_delete(ar, ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_create()
1102 ar->monitor_vdev_id = -1; in ath11k_mac_monitor_vdev_create()
1111 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_monitor_vdev_delete()
1113 if (!test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) in ath11k_mac_monitor_vdev_delete()
1116 reinit_completion(&ar->vdev_delete_done); in ath11k_mac_monitor_vdev_delete()
1118 ret = ath11k_wmi_vdev_delete(ar, ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_delete()
1120 ath11k_warn(ar->ab, "failed to request wmi monitor vdev %i removal: %d\n", in ath11k_mac_monitor_vdev_delete()
1121 ar->monitor_vdev_id, ret); in ath11k_mac_monitor_vdev_delete()
1125 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, in ath11k_mac_monitor_vdev_delete()
1128 ath11k_warn(ar->ab, "Timeout in receiving vdev delete response\n"); in ath11k_mac_monitor_vdev_delete()
1130 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor vdev %d deleted\n", in ath11k_mac_monitor_vdev_delete()
1131 ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_delete()
1133 ar->allocated_vdev_map &= ~(1LL << ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_delete()
1134 ar->ab->free_vdev_map |= 1LL << (ar->monitor_vdev_id); in ath11k_mac_monitor_vdev_delete()
1135 ar->num_created_vdevs--; in ath11k_mac_monitor_vdev_delete()
1136 ar->monitor_vdev_id = -1; in ath11k_mac_monitor_vdev_delete()
1137 clear_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags); in ath11k_mac_monitor_vdev_delete()
1148 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_monitor_start()
1150 if (test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags)) in ath11k_mac_monitor_start()
1153 ieee80211_iter_chan_contexts_atomic(ar->hw, in ath11k_mac_monitor_start()
1159 ret = ath11k_mac_monitor_vdev_start(ar, ar->monitor_vdev_id, chandef); in ath11k_mac_monitor_start()
1161 ath11k_warn(ar->ab, "failed to start monitor vdev: %d\n", ret); in ath11k_mac_monitor_start()
1166 set_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags); in ath11k_mac_monitor_start()
1168 ar->num_started_vdevs++; in ath11k_mac_monitor_start()
1171 ath11k_warn(ar->ab, "failed to configure htt monitor mode ring during start: %d", in ath11k_mac_monitor_start()
1176 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor started\n"); in ath11k_mac_monitor_start()
1185 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_monitor_stop()
1187 if (!test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags)) in ath11k_mac_monitor_stop()
1192 ath11k_warn(ar->ab, "failed to stop monitor vdev: %d\n", ret); in ath11k_mac_monitor_stop()
1196 clear_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags); in ath11k_mac_monitor_stop()
1197 ar->num_started_vdevs--; in ath11k_mac_monitor_stop()
1201 ath11k_warn(ar->ab, "failed to configure htt monitor mode ring during stop: %d", in ath11k_mac_monitor_stop()
1206 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac monitor stopped ret %d\n", ret); in ath11k_mac_monitor_stop()
1213 struct ath11k *ar = arvif->ar; in ath11k_mac_vif_setup_ps()
1214 struct ieee80211_vif *vif = arvif->vif; in ath11k_mac_vif_setup_ps()
1215 struct ieee80211_conf *conf = &ar->hw->conf; in ath11k_mac_vif_setup_ps()
1222 lockdep_assert_held(&arvif->ar->conf_mutex); in ath11k_mac_vif_setup_ps()
1224 if (arvif->vif->type != NL80211_IFTYPE_STATION) in ath11k_mac_vif_setup_ps()
1227 enable_ps = arvif->ps; in ath11k_mac_vif_setup_ps()
1229 if (!arvif->is_started) { in ath11k_mac_vif_setup_ps()
1232 * necessary if PS is disabled on a non-started vdev. Hence in ath11k_mac_vif_setup_ps()
1233 * force-enable PS for non-running vdevs. in ath11k_mac_vif_setup_ps()
1240 timeout = conf->dynamic_ps_timeout; in ath11k_mac_vif_setup_ps()
1243 timeout = ieee80211_tu_to_usec(vif->bss_conf.beacon_int) / 1000; in ath11k_mac_vif_setup_ps()
1246 ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id, param, in ath11k_mac_vif_setup_ps()
1249 ath11k_warn(ar->ab, "failed to set inactivity time for vdev %d: %i\n", in ath11k_mac_vif_setup_ps()
1250 arvif->vdev_id, ret); in ath11k_mac_vif_setup_ps()
1257 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev %d psmode %s\n", in ath11k_mac_vif_setup_ps()
1258 arvif->vdev_id, psmode ? "enable" : "disable"); in ath11k_mac_vif_setup_ps()
1260 ret = ath11k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, psmode); in ath11k_mac_vif_setup_ps()
1262 ath11k_warn(ar->ab, "failed to set sta power save mode %d for vdev %d: %d\n", in ath11k_mac_vif_setup_ps()
1263 psmode, arvif->vdev_id, ret); in ath11k_mac_vif_setup_ps()
1275 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_config_ps()
1277 list_for_each_entry(arvif, &ar->arvifs, list) { in ath11k_mac_config_ps()
1280 ath11k_warn(ar->ab, "failed to setup powersave: %d\n", ret); in ath11k_mac_config_ps()
1290 struct ath11k *ar = hw->priv; in ath11k_mac_op_config()
1291 struct ieee80211_conf *conf = &hw->conf; in ath11k_mac_op_config()
1294 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_config()
1297 if (conf->flags & IEEE80211_CONF_MONITOR) { in ath11k_mac_op_config()
1298 set_bit(ATH11K_FLAG_MONITOR_CONF_ENABLED, &ar->monitor_flags); in ath11k_mac_op_config()
1301 &ar->monitor_flags)) in ath11k_mac_op_config()
1306 ath11k_warn(ar->ab, "failed to create monitor vdev: %d", in ath11k_mac_op_config()
1313 ath11k_warn(ar->ab, "failed to start monitor: %d", in ath11k_mac_op_config()
1318 clear_bit(ATH11K_FLAG_MONITOR_CONF_ENABLED, &ar->monitor_flags); in ath11k_mac_op_config()
1321 &ar->monitor_flags)) in ath11k_mac_op_config()
1326 ath11k_warn(ar->ab, "failed to stop monitor: %d", in ath11k_mac_op_config()
1333 ath11k_warn(ar->ab, "failed to delete monitor vdev: %d", in ath11k_mac_op_config()
1341 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_config()
1346 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_config()
1352 struct ath11k *ar = arvif->ar; in ath11k_mac_setup_bcn_tmpl()
1353 struct ath11k_base *ab = ar->ab; in ath11k_mac_setup_bcn_tmpl()
1354 struct ieee80211_hw *hw = ar->hw; in ath11k_mac_setup_bcn_tmpl()
1355 struct ieee80211_vif *vif = arvif->vif; in ath11k_mac_setup_bcn_tmpl()
1362 if (arvif->vdev_type != WMI_VDEV_TYPE_AP) in ath11k_mac_setup_bcn_tmpl()
1368 return -EPERM; in ath11k_mac_setup_bcn_tmpl()
1371 ies = bcn->data + ieee80211_get_hdrlen_from_skb(bcn); in ath11k_mac_setup_bcn_tmpl()
1372 ies += sizeof(mgmt->u.beacon); in ath11k_mac_setup_bcn_tmpl()
1374 if (cfg80211_find_ie(WLAN_EID_RSN, ies, (skb_tail_pointer(bcn) - ies))) in ath11k_mac_setup_bcn_tmpl()
1375 arvif->rsnie_present = true; in ath11k_mac_setup_bcn_tmpl()
1377 arvif->rsnie_present = false; in ath11k_mac_setup_bcn_tmpl()
1381 ies, (skb_tail_pointer(bcn) - ies))) in ath11k_mac_setup_bcn_tmpl()
1382 arvif->wpaie_present = true; in ath11k_mac_setup_bcn_tmpl()
1384 arvif->wpaie_present = false; in ath11k_mac_setup_bcn_tmpl()
1386 ret = ath11k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn); in ath11k_mac_setup_bcn_tmpl()
1399 struct ieee80211_vif *vif = arvif->vif; in ath11k_mac_bcn_tx_event()
1401 if (!vif->bss_conf.color_change_active && !arvif->bcca_zero_sent) in ath11k_mac_bcn_tx_event()
1404 if (vif->bss_conf.color_change_active && in ath11k_mac_bcn_tx_event()
1406 arvif->bcca_zero_sent = true; in ath11k_mac_bcn_tx_event()
1411 arvif->bcca_zero_sent = false; in ath11k_mac_bcn_tx_event()
1413 if (vif->bss_conf.color_change_active) in ath11k_mac_bcn_tx_event()
1421 struct ath11k *ar = arvif->ar; in ath11k_control_beaconing()
1424 lockdep_assert_held(&arvif->ar->conf_mutex); in ath11k_control_beaconing()
1426 if (!info->enable_beacon) { in ath11k_control_beaconing()
1427 ret = ath11k_wmi_vdev_down(ar, arvif->vdev_id); in ath11k_control_beaconing()
1429 ath11k_warn(ar->ab, "failed to down vdev_id %i: %d\n", in ath11k_control_beaconing()
1430 arvif->vdev_id, ret); in ath11k_control_beaconing()
1432 arvif->is_up = false; in ath11k_control_beaconing()
1439 ath11k_warn(ar->ab, "failed to update bcn tmpl during vdev up: %d\n", in ath11k_control_beaconing()
1444 arvif->tx_seq_no = 0x1000; in ath11k_control_beaconing()
1446 arvif->aid = 0; in ath11k_control_beaconing()
1448 ether_addr_copy(arvif->bssid, info->bssid); in ath11k_control_beaconing()
1450 ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, in ath11k_control_beaconing()
1451 arvif->bssid); in ath11k_control_beaconing()
1453 ath11k_warn(ar->ab, "failed to bring up vdev %d: %i\n", in ath11k_control_beaconing()
1454 arvif->vdev_id, ret); in ath11k_control_beaconing()
1458 arvif->is_up = true; in ath11k_control_beaconing()
1460 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev %d up\n", arvif->vdev_id); in ath11k_control_beaconing()
1467 struct ieee80211_mgmt *mgmt = (void *)skb->data; in ath11k_mac_handle_beacon_iter()
1468 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_handle_beacon_iter()
1470 if (vif->type != NL80211_IFTYPE_STATION) in ath11k_mac_handle_beacon_iter()
1473 if (!ether_addr_equal(mgmt->bssid, vif->bss_conf.bssid)) in ath11k_mac_handle_beacon_iter()
1476 cancel_delayed_work(&arvif->connection_loss_work); in ath11k_mac_handle_beacon_iter()
1481 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath11k_mac_handle_beacon()
1491 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_handle_beacon_miss_iter()
1492 struct ath11k *ar = arvif->ar; in ath11k_mac_handle_beacon_miss_iter()
1493 struct ieee80211_hw *hw = ar->hw; in ath11k_mac_handle_beacon_miss_iter()
1495 if (arvif->vdev_id != *vdev_id) in ath11k_mac_handle_beacon_miss_iter()
1498 if (!arvif->is_up) in ath11k_mac_handle_beacon_miss_iter()
1505 * doesn't make sense to continue operation. Queue connection loss work in ath11k_mac_handle_beacon_miss_iter()
1508 ieee80211_queue_delayed_work(hw, &arvif->connection_loss_work, in ath11k_mac_handle_beacon_miss_iter()
1514 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath11k_mac_handle_beacon_miss()
1524 struct ieee80211_vif *vif = arvif->vif; in ath11k_mac_vif_sta_connection_loss_work()
1526 if (!arvif->is_up) in ath11k_mac_vif_sta_connection_loss_work()
1537 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_basic()
1540 lockdep_assert_held(&ar->conf_mutex); in ath11k_peer_assoc_h_basic()
1542 if (vif->type == NL80211_IFTYPE_STATION) in ath11k_peer_assoc_h_basic()
1543 aid = vif->cfg.aid; in ath11k_peer_assoc_h_basic()
1545 aid = sta->aid; in ath11k_peer_assoc_h_basic()
1547 ether_addr_copy(arg->peer_mac, sta->addr); in ath11k_peer_assoc_h_basic()
1548 arg->vdev_id = arvif->vdev_id; in ath11k_peer_assoc_h_basic()
1549 arg->peer_associd = aid; in ath11k_peer_assoc_h_basic()
1550 arg->auth_flag = true; in ath11k_peer_assoc_h_basic()
1552 arg->peer_listen_intval = ar->hw->conf.listen_interval; in ath11k_peer_assoc_h_basic()
1553 arg->peer_nss = 1; in ath11k_peer_assoc_h_basic()
1554 arg->peer_caps = vif->bss_conf.assoc_capability; in ath11k_peer_assoc_h_basic()
1562 struct ieee80211_bss_conf *info = &vif->bss_conf; in ath11k_peer_assoc_h_crypto()
1565 struct ath11k_vif *arvif = (struct ath11k_vif *)vif->drv_priv; in ath11k_peer_assoc_h_crypto()
1569 lockdep_assert_held(&ar->conf_mutex); in ath11k_peer_assoc_h_crypto()
1574 bss = cfg80211_get_bss(ar->hw->wiphy, def.chan, info->bssid, NULL, 0, in ath11k_peer_assoc_h_crypto()
1577 if (arvif->rsnie_present || arvif->wpaie_present) { in ath11k_peer_assoc_h_crypto()
1578 arg->need_ptk_4_way = true; in ath11k_peer_assoc_h_crypto()
1579 if (arvif->wpaie_present) in ath11k_peer_assoc_h_crypto()
1580 arg->need_gtk_2_way = true; in ath11k_peer_assoc_h_crypto()
1587 ies = rcu_dereference(bss->ies); in ath11k_peer_assoc_h_crypto()
1591 ies->data, in ath11k_peer_assoc_h_crypto()
1592 ies->len); in ath11k_peer_assoc_h_crypto()
1594 cfg80211_put_bss(ar->hw->wiphy, bss); in ath11k_peer_assoc_h_crypto()
1599 ath11k_dbg(ar->ab, ATH11K_DBG_WMI, in ath11k_peer_assoc_h_crypto()
1601 arg->need_ptk_4_way = true; in ath11k_peer_assoc_h_crypto()
1605 ath11k_dbg(ar->ab, ATH11K_DBG_WMI, in ath11k_peer_assoc_h_crypto()
1607 arg->need_gtk_2_way = true; in ath11k_peer_assoc_h_crypto()
1610 if (sta->mfp) { in ath11k_peer_assoc_h_crypto()
1612 arg->is_pmf_enabled = true; in ath11k_peer_assoc_h_crypto()
1615 /* TODO: safe_mode_enabled (bypass 4-way handshake) flag req? */ in ath11k_peer_assoc_h_crypto()
1623 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_rates()
1624 struct wmi_rate_set_arg *rateset = &arg->peer_legacy_rates; in ath11k_peer_assoc_h_rates()
1633 lockdep_assert_held(&ar->conf_mutex); in ath11k_peer_assoc_h_rates()
1638 band = def.chan->band; in ath11k_peer_assoc_h_rates()
1639 sband = ar->hw->wiphy->bands[band]; in ath11k_peer_assoc_h_rates()
1640 ratemask = sta->deflink.supp_rates[band]; in ath11k_peer_assoc_h_rates()
1641 ratemask &= arvif->bitrate_mask.control[band].legacy; in ath11k_peer_assoc_h_rates()
1642 rates = sband->bitrates; in ath11k_peer_assoc_h_rates()
1644 rateset->num_rates = 0; in ath11k_peer_assoc_h_rates()
1650 rate = ath11k_mac_bitrate_to_rate(rates->bitrate); in ath11k_peer_assoc_h_rates()
1651 rateset->rates[rateset->num_rates] = rate; in ath11k_peer_assoc_h_rates()
1652 rateset->num_rates++; in ath11k_peer_assoc_h_rates()
1685 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in ath11k_peer_assoc_h_ht()
1686 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_ht()
1694 lockdep_assert_held(&ar->conf_mutex); in ath11k_peer_assoc_h_ht()
1699 if (!ht_cap->ht_supported) in ath11k_peer_assoc_h_ht()
1702 band = def.chan->band; in ath11k_peer_assoc_h_ht()
1703 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath11k_peer_assoc_h_ht()
1708 arg->ht_flag = true; in ath11k_peer_assoc_h_ht()
1710 arg->peer_max_mpdu = (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + in ath11k_peer_assoc_h_ht()
1711 ht_cap->ampdu_factor)) - 1; in ath11k_peer_assoc_h_ht()
1713 arg->peer_mpdu_density = in ath11k_peer_assoc_h_ht()
1714 ath11k_parse_mpdudensity(ht_cap->ampdu_density); in ath11k_peer_assoc_h_ht()
1716 arg->peer_ht_caps = ht_cap->cap; in ath11k_peer_assoc_h_ht()
1717 arg->peer_rate_caps |= WMI_HOST_RC_HT_FLAG; in ath11k_peer_assoc_h_ht()
1719 if (ht_cap->cap & IEEE80211_HT_CAP_LDPC_CODING) in ath11k_peer_assoc_h_ht()
1720 arg->ldpc_flag = true; in ath11k_peer_assoc_h_ht()
1722 if (sta->deflink.bandwidth >= IEEE80211_STA_RX_BW_40) { in ath11k_peer_assoc_h_ht()
1723 arg->bw_40 = true; in ath11k_peer_assoc_h_ht()
1724 arg->peer_rate_caps |= WMI_HOST_RC_CW40_FLAG; in ath11k_peer_assoc_h_ht()
1731 if (arvif->bitrate_mask.control[band].gi == NL80211_TXRATE_DEFAULT_GI) in ath11k_peer_assoc_h_ht()
1732 arg->peer_ht_caps &= ~(IEEE80211_HT_CAP_SGI_20 | in ath11k_peer_assoc_h_ht()
1735 if (arvif->bitrate_mask.control[band].gi != NL80211_TXRATE_FORCE_LGI) { in ath11k_peer_assoc_h_ht()
1736 if (ht_cap->cap & (IEEE80211_HT_CAP_SGI_20 | in ath11k_peer_assoc_h_ht()
1738 arg->peer_rate_caps |= WMI_HOST_RC_SGI_FLAG; in ath11k_peer_assoc_h_ht()
1741 if (ht_cap->cap & IEEE80211_HT_CAP_TX_STBC) { in ath11k_peer_assoc_h_ht()
1742 arg->peer_rate_caps |= WMI_HOST_RC_TX_STBC_FLAG; in ath11k_peer_assoc_h_ht()
1743 arg->stbc_flag = true; in ath11k_peer_assoc_h_ht()
1746 if (ht_cap->cap & IEEE80211_HT_CAP_RX_STBC) { in ath11k_peer_assoc_h_ht()
1747 stbc = ht_cap->cap & IEEE80211_HT_CAP_RX_STBC; in ath11k_peer_assoc_h_ht()
1750 arg->peer_rate_caps |= stbc; in ath11k_peer_assoc_h_ht()
1751 arg->stbc_flag = true; in ath11k_peer_assoc_h_ht()
1754 if (ht_cap->mcs.rx_mask[1] && ht_cap->mcs.rx_mask[2]) in ath11k_peer_assoc_h_ht()
1755 arg->peer_rate_caps |= WMI_HOST_RC_TS_FLAG; in ath11k_peer_assoc_h_ht()
1756 else if (ht_cap->mcs.rx_mask[1]) in ath11k_peer_assoc_h_ht()
1757 arg->peer_rate_caps |= WMI_HOST_RC_DS_FLAG; in ath11k_peer_assoc_h_ht()
1760 if ((ht_cap->mcs.rx_mask[i / 8] & BIT(i % 8)) && in ath11k_peer_assoc_h_ht()
1763 arg->peer_ht_rates.rates[n++] = i; in ath11k_peer_assoc_h_ht()
1766 /* This is a workaround for HT-enabled STAs which break the spec in ath11k_peer_assoc_h_ht()
1775 arg->peer_ht_rates.num_rates = 8; in ath11k_peer_assoc_h_ht()
1776 for (i = 0; i < arg->peer_ht_rates.num_rates; i++) in ath11k_peer_assoc_h_ht()
1777 arg->peer_ht_rates.rates[i] = i; in ath11k_peer_assoc_h_ht()
1779 arg->peer_ht_rates.num_rates = n; in ath11k_peer_assoc_h_ht()
1780 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath11k_peer_assoc_h_ht()
1783 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac ht peer %pM mcs cnt %d nss %d\n", in ath11k_peer_assoc_h_ht()
1784 arg->peer_mac, in ath11k_peer_assoc_h_ht()
1785 arg->peer_ht_rates.num_rates, in ath11k_peer_assoc_h_ht()
1786 arg->peer_nss); in ath11k_peer_assoc_h_ht()
1792 case IEEE80211_VHT_MCS_SUPPORT_0_7: return BIT(8) - 1; in ath11k_mac_get_max_vht_mcs_map()
1793 case IEEE80211_VHT_MCS_SUPPORT_0_8: return BIT(9) - 1; in ath11k_mac_get_max_vht_mcs_map()
1794 case IEEE80211_VHT_MCS_SUPPORT_0_9: return BIT(10) - 1; in ath11k_mac_get_max_vht_mcs_map()
1813 idx_limit = fls(mcs_map) - 1; in ath11k_peer_assoc_h_vht_limit()
1815 idx_limit = -1; in ath11k_peer_assoc_h_vht_limit()
1837 case -1: in ath11k_peer_assoc_h_vht_limit()
1852 u8 nss_ratio_info = ar->pdev->cap.nss_ratio_info; in ath11k_get_nss_160mhz()
1860 ath11k_warn(ar->ab, "WMI_NSS_RATIO_3BY4_NSS not supported\n"); in ath11k_get_nss_160mhz()
1866 ath11k_warn(ar->ab, "WMI_NSS_RATIO_2_NSS not supported\n"); in ath11k_get_nss_160mhz()
1869 ath11k_warn(ar->ab, "invalid nss ratio received from firmware: %d\n", in ath11k_get_nss_160mhz()
1882 const struct ieee80211_sta_vht_cap *vht_cap = &sta->deflink.vht_cap; in ath11k_peer_assoc_h_vht()
1883 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_vht()
1896 if (!vht_cap->vht_supported) in ath11k_peer_assoc_h_vht()
1899 band = def.chan->band; in ath11k_peer_assoc_h_vht()
1900 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath11k_peer_assoc_h_vht()
1905 arg->vht_flag = true; in ath11k_peer_assoc_h_vht()
1908 arg->vht_capable = true; in ath11k_peer_assoc_h_vht()
1910 if (def.chan->band == NL80211_BAND_2GHZ) in ath11k_peer_assoc_h_vht()
1911 arg->vht_ng_flag = true; in ath11k_peer_assoc_h_vht()
1913 arg->peer_vht_caps = vht_cap->cap; in ath11k_peer_assoc_h_vht()
1915 ampdu_factor = (vht_cap->cap & in ath11k_peer_assoc_h_vht()
1919 /* Workaround: Some Netgear/Linksys 11ac APs set Rx A-MPDU factor to in ath11k_peer_assoc_h_vht()
1921 * arg->peer_max_mpdu at this point contains HT max_mpdu so keep in ath11k_peer_assoc_h_vht()
1924 arg->peer_max_mpdu = max(arg->peer_max_mpdu, in ath11k_peer_assoc_h_vht()
1926 ampdu_factor)) - 1); in ath11k_peer_assoc_h_vht()
1928 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath11k_peer_assoc_h_vht()
1929 arg->bw_80 = true; in ath11k_peer_assoc_h_vht()
1931 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in ath11k_peer_assoc_h_vht()
1932 arg->bw_160 = true; in ath11k_peer_assoc_h_vht()
1936 if (vht_nss > sta->deflink.rx_nss) { in ath11k_peer_assoc_h_vht()
1938 for (nss_idx = sta->deflink.rx_nss - 1; nss_idx >= 0; nss_idx--) { in ath11k_peer_assoc_h_vht()
1947 …ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac setting vht range mcs value to peer supported nss %d for p… in ath11k_peer_assoc_h_vht()
1948 sta->deflink.rx_nss, sta->addr); in ath11k_peer_assoc_h_vht()
1949 vht_mcs_mask[sta->deflink.rx_nss - 1] = vht_mcs_mask[vht_nss - 1]; in ath11k_peer_assoc_h_vht()
1956 vht_mcs = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map) >> in ath11k_peer_assoc_h_vht()
1963 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath11k_peer_assoc_h_vht()
1964 arg->rx_max_rate = __le16_to_cpu(vht_cap->vht_mcs.rx_highest); in ath11k_peer_assoc_h_vht()
1965 arg->rx_mcs_set = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); in ath11k_peer_assoc_h_vht()
1966 arg->tx_max_rate = __le16_to_cpu(vht_cap->vht_mcs.tx_highest); in ath11k_peer_assoc_h_vht()
1967 arg->tx_mcs_set = ath11k_peer_assoc_h_vht_limit( in ath11k_peer_assoc_h_vht()
1968 __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map), vht_mcs_mask); in ath11k_peer_assoc_h_vht()
1974 arg->tx_mcs_set &= ~IEEE80211_VHT_MCS_SUPPORT_0_11_MASK; in ath11k_peer_assoc_h_vht()
1975 arg->tx_mcs_set |= IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11; in ath11k_peer_assoc_h_vht()
1977 if ((arg->tx_mcs_set & IEEE80211_VHT_MCS_NOT_SUPPORTED) == in ath11k_peer_assoc_h_vht()
1979 arg->peer_vht_caps &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; in ath11k_peer_assoc_h_vht()
1982 arg->tx_max_mcs_nss = 0xFF; in ath11k_peer_assoc_h_vht()
1984 if (arg->peer_phymode == MODE_11AC_VHT160 || in ath11k_peer_assoc_h_vht()
1985 arg->peer_phymode == MODE_11AC_VHT80_80) { in ath11k_peer_assoc_h_vht()
1987 rx_nss = min(arg->peer_nss, tx_nss); in ath11k_peer_assoc_h_vht()
1988 arg->peer_bw_rxnss_override = ATH11K_BW_NSS_MAP_ENABLE; in ath11k_peer_assoc_h_vht()
1991 ath11k_warn(ar->ab, "invalid max_nss\n"); in ath11k_peer_assoc_h_vht()
1995 if (arg->peer_phymode == MODE_11AC_VHT160) in ath11k_peer_assoc_h_vht()
1996 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_160MHZ, rx_nss - 1); in ath11k_peer_assoc_h_vht()
1998 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_80_80MHZ, rx_nss - 1); in ath11k_peer_assoc_h_vht()
2000 arg->peer_bw_rxnss_override |= nss_160; in ath11k_peer_assoc_h_vht()
2003 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_peer_assoc_h_vht()
2005 sta->addr, arg->peer_max_mpdu, arg->peer_flags, in ath11k_peer_assoc_h_vht()
2006 arg->peer_bw_rxnss_override); in ath11k_peer_assoc_h_vht()
2012 case IEEE80211_HE_MCS_SUPPORT_0_7: return BIT(8) - 1; in ath11k_mac_get_max_he_mcs_map()
2013 case IEEE80211_HE_MCS_SUPPORT_0_9: return BIT(10) - 1; in ath11k_mac_get_max_he_mcs_map()
2014 case IEEE80211_HE_MCS_SUPPORT_0_11: return BIT(12) - 1; in ath11k_mac_get_max_he_mcs_map()
2032 idx_limit = fls(mcs_map) - 1; in ath11k_peer_assoc_h_he_limit()
2034 idx_limit = -1; in ath11k_peer_assoc_h_he_limit()
2051 case -1: in ath11k_peer_assoc_h_he_limit()
2080 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_he()
2082 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath11k_peer_assoc_h_he()
2097 if (!he_cap->has_he) in ath11k_peer_assoc_h_he()
2100 band = def.chan->band; in ath11k_peer_assoc_h_he()
2101 memcpy(he_mcs_mask, arvif->bitrate_mask.control[band].he_mcs, in ath11k_peer_assoc_h_he()
2107 arg->he_flag = true; in ath11k_peer_assoc_h_he()
2108 support_160 = !!(he_cap->he_cap_elem.phy_cap_info[0] & in ath11k_peer_assoc_h_he()
2111 /* Supported HE-MCS and NSS Set of peer he_cap is intersection with self he_cp */ in ath11k_peer_assoc_h_he()
2112 mcs_160_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160); in ath11k_peer_assoc_h_he()
2113 mcs_80_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80); in ath11k_peer_assoc_h_he()
2116 for (i = 7; i >= 0; i--) { in ath11k_peer_assoc_h_he()
2126 for (i = 7; i >= 0; i--) { in ath11k_peer_assoc_h_he()
2140 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath11k_peer_assoc_h_he()
2142 memcpy_and_pad(&arg->peer_he_cap_macinfo, in ath11k_peer_assoc_h_he()
2143 sizeof(arg->peer_he_cap_macinfo), in ath11k_peer_assoc_h_he()
2144 he_cap->he_cap_elem.mac_cap_info, in ath11k_peer_assoc_h_he()
2145 sizeof(he_cap->he_cap_elem.mac_cap_info), in ath11k_peer_assoc_h_he()
2147 memcpy_and_pad(&arg->peer_he_cap_phyinfo, in ath11k_peer_assoc_h_he()
2148 sizeof(arg->peer_he_cap_phyinfo), in ath11k_peer_assoc_h_he()
2149 he_cap->he_cap_elem.phy_cap_info, in ath11k_peer_assoc_h_he()
2150 sizeof(he_cap->he_cap_elem.phy_cap_info), in ath11k_peer_assoc_h_he()
2152 arg->peer_he_ops = vif->bss_conf.he_oper.params; in ath11k_peer_assoc_h_he()
2155 arg->peer_he_ops &= 0xffffff; in ath11k_peer_assoc_h_he()
2158 * in HE cap is zero, use the arg->peer_max_mpdu as calculated while parsing in ath11k_peer_assoc_h_he()
2161 * For non-zero value of Max AMPDU Extponent Extension in HE MAC caps, in ath11k_peer_assoc_h_he()
2168 ampdu_factor = u8_get_bits(he_cap->he_cap_elem.mac_cap_info[3], in ath11k_peer_assoc_h_he()
2172 if (sta->deflink.vht_cap.vht_supported) in ath11k_peer_assoc_h_he()
2173 arg->peer_max_mpdu = (1 << (IEEE80211_HE_VHT_MAX_AMPDU_FACTOR + in ath11k_peer_assoc_h_he()
2174 ampdu_factor)) - 1; in ath11k_peer_assoc_h_he()
2175 else if (sta->deflink.ht_cap.ht_supported) in ath11k_peer_assoc_h_he()
2176 arg->peer_max_mpdu = (1 << (IEEE80211_HE_HT_MAX_AMPDU_FACTOR + in ath11k_peer_assoc_h_he()
2177 ampdu_factor)) - 1; in ath11k_peer_assoc_h_he()
2180 if (he_cap->he_cap_elem.phy_cap_info[6] & in ath11k_peer_assoc_h_he()
2185 arg->peer_ppet.numss_m1 = he_cap->ppe_thres[0] & in ath11k_peer_assoc_h_he()
2187 arg->peer_ppet.ru_bit_mask = in ath11k_peer_assoc_h_he()
2188 (he_cap->ppe_thres[0] & in ath11k_peer_assoc_h_he()
2192 for (nss = 0; nss <= arg->peer_ppet.numss_m1; nss++) { in ath11k_peer_assoc_h_he()
2197 if ((arg->peer_ppet.ru_bit_mask & BIT(ru)) == 0) in ath11k_peer_assoc_h_he()
2201 val |= ((he_cap->ppe_thres[bit / 8] >> in ath11k_peer_assoc_h_he()
2205 arg->peer_ppet.ppet16_ppet8_ru3_ru0[nss] |= in ath11k_peer_assoc_h_he()
2211 if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_RES) in ath11k_peer_assoc_h_he()
2212 arg->twt_responder = true; in ath11k_peer_assoc_h_he()
2213 if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_REQ) in ath11k_peer_assoc_h_he()
2214 arg->twt_requester = true; in ath11k_peer_assoc_h_he()
2218 if (he_nss > sta->deflink.rx_nss) { in ath11k_peer_assoc_h_he()
2220 for (nss_idx = sta->deflink.rx_nss - 1; nss_idx >= 0; nss_idx--) { in ath11k_peer_assoc_h_he()
2229 …ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac setting he range mcs value to peer supported nss %d for pe… in ath11k_peer_assoc_h_he()
2230 sta->deflink.rx_nss, sta->addr); in ath11k_peer_assoc_h_he()
2231 he_mcs_mask[sta->deflink.rx_nss - 1] = he_mcs_mask[he_nss - 1]; in ath11k_peer_assoc_h_he()
2234 switch (sta->deflink.bandwidth) { in ath11k_peer_assoc_h_he()
2236 if (he_cap->he_cap_elem.phy_cap_info[0] & in ath11k_peer_assoc_h_he()
2238 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80p80); in ath11k_peer_assoc_h_he()
2240 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v; in ath11k_peer_assoc_h_he()
2242 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80p80); in ath11k_peer_assoc_h_he()
2243 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v; in ath11k_peer_assoc_h_he()
2245 arg->peer_he_mcs_count++; in ath11k_peer_assoc_h_he()
2248 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160); in ath11k_peer_assoc_h_he()
2249 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v; in ath11k_peer_assoc_h_he()
2251 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_160); in ath11k_peer_assoc_h_he()
2253 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v; in ath11k_peer_assoc_h_he()
2255 arg->peer_he_mcs_count++; in ath11k_peer_assoc_h_he()
2261 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80); in ath11k_peer_assoc_h_he()
2262 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v; in ath11k_peer_assoc_h_he()
2264 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80); in ath11k_peer_assoc_h_he()
2266 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v; in ath11k_peer_assoc_h_he()
2268 arg->peer_he_mcs_count++; in ath11k_peer_assoc_h_he()
2288 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath11k_peer_assoc_h_he()
2290 if (arg->peer_phymode == MODE_11AX_HE160 || in ath11k_peer_assoc_h_he()
2291 arg->peer_phymode == MODE_11AX_HE80_80) { in ath11k_peer_assoc_h_he()
2293 rx_nss = min(arg->peer_nss, tx_nss); in ath11k_peer_assoc_h_he()
2294 arg->peer_bw_rxnss_override = ATH11K_BW_NSS_MAP_ENABLE; in ath11k_peer_assoc_h_he()
2297 ath11k_warn(ar->ab, "invalid max_nss\n"); in ath11k_peer_assoc_h_he()
2301 if (arg->peer_phymode == MODE_11AX_HE160) in ath11k_peer_assoc_h_he()
2302 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_160MHZ, rx_nss - 1); in ath11k_peer_assoc_h_he()
2304 nss_160 = FIELD_PREP(ATH11K_PEER_RX_NSS_80_80MHZ, rx_nss - 1); in ath11k_peer_assoc_h_he()
2306 arg->peer_bw_rxnss_override |= nss_160; in ath11k_peer_assoc_h_he()
2309 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_peer_assoc_h_he()
2311 sta->addr, arg->peer_nss, in ath11k_peer_assoc_h_he()
2312 arg->peer_he_mcs_count, in ath11k_peer_assoc_h_he()
2313 arg->peer_bw_rxnss_override); in ath11k_peer_assoc_h_he()
2321 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath11k_peer_assoc_h_he_6ghz()
2329 band = def.chan->band; in ath11k_peer_assoc_h_he_6ghz()
2331 if (!arg->he_flag || band != NL80211_BAND_6GHZ || !sta->deflink.he_6ghz_capa.capa) in ath11k_peer_assoc_h_he_6ghz()
2334 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath11k_peer_assoc_h_he_6ghz()
2335 arg->bw_40 = true; in ath11k_peer_assoc_h_he_6ghz()
2337 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath11k_peer_assoc_h_he_6ghz()
2338 arg->bw_80 = true; in ath11k_peer_assoc_h_he_6ghz()
2340 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in ath11k_peer_assoc_h_he_6ghz()
2341 arg->bw_160 = true; in ath11k_peer_assoc_h_he_6ghz()
2343 arg->peer_he_caps_6ghz = le16_to_cpu(sta->deflink.he_6ghz_capa.capa); in ath11k_peer_assoc_h_he_6ghz()
2344 arg->peer_mpdu_density = in ath11k_peer_assoc_h_he_6ghz()
2346 arg->peer_he_caps_6ghz)); in ath11k_peer_assoc_h_he_6ghz()
2348 /* From IEEE Std 802.11ax-2021 - Section 10.12.2: An HE STA shall be capable of in ath11k_peer_assoc_h_he_6ghz()
2349 * receiving A-MPDU where the A-MPDU pre-EOF padding length is up to the value in ath11k_peer_assoc_h_he_6ghz()
2350 * indicated by the Maximum A-MPDU Length Exponent Extension field in the HE in ath11k_peer_assoc_h_he_6ghz()
2351 * Capabilities element and the Maximum A-MPDU Length Exponent field in HE 6 GHz in ath11k_peer_assoc_h_he_6ghz()
2354 * Here, we are extracting the Max A-MPDU Exponent Extension from HE caps and in ath11k_peer_assoc_h_he_6ghz()
2355 * factor is the Maximum A-MPDU Length Exponent from HE 6 GHZ Band capability. in ath11k_peer_assoc_h_he_6ghz()
2358 he_cap->he_cap_elem.mac_cap_info[3]) + in ath11k_peer_assoc_h_he_6ghz()
2360 arg->peer_he_caps_6ghz); in ath11k_peer_assoc_h_he_6ghz()
2362 arg->peer_max_mpdu = (1u << (IEEE80211_HE_6GHZ_MAX_AMPDU_FACTOR + in ath11k_peer_assoc_h_he_6ghz()
2363 ampdu_factor)) - 1; in ath11k_peer_assoc_h_he_6ghz()
2369 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in ath11k_peer_assoc_h_smps()
2372 if (!ht_cap->ht_supported && !sta->deflink.he_6ghz_capa.capa) in ath11k_peer_assoc_h_smps()
2375 if (ht_cap->ht_supported) { in ath11k_peer_assoc_h_smps()
2376 smps = ht_cap->cap & IEEE80211_HT_CAP_SM_PS; in ath11k_peer_assoc_h_smps()
2379 smps = le16_get_bits(sta->deflink.he_6ghz_capa.capa, in ath11k_peer_assoc_h_smps()
2385 arg->static_mimops_flag = true; in ath11k_peer_assoc_h_smps()
2388 arg->dynamic_mimops_flag = true; in ath11k_peer_assoc_h_smps()
2391 arg->spatial_mux_flag = true; in ath11k_peer_assoc_h_smps()
2403 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_qos()
2405 switch (arvif->vdev_type) { in ath11k_peer_assoc_h_qos()
2407 if (sta->wme) { in ath11k_peer_assoc_h_qos()
2409 arg->is_wme_set = true; in ath11k_peer_assoc_h_qos()
2410 arg->qos_flag = true; in ath11k_peer_assoc_h_qos()
2413 if (sta->wme && sta->uapsd_queues) { in ath11k_peer_assoc_h_qos()
2415 arg->is_wme_set = true; in ath11k_peer_assoc_h_qos()
2416 arg->apsd_flag = true; in ath11k_peer_assoc_h_qos()
2417 arg->peer_rate_caps |= WMI_HOST_RC_UAPSD_FLAG; in ath11k_peer_assoc_h_qos()
2421 if (sta->wme) { in ath11k_peer_assoc_h_qos()
2422 arg->is_wme_set = true; in ath11k_peer_assoc_h_qos()
2423 arg->qos_flag = true; in ath11k_peer_assoc_h_qos()
2430 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac peer %pM qos %d\n", in ath11k_peer_assoc_h_qos()
2431 sta->addr, arg->qos_flag); in ath11k_peer_assoc_h_qos()
2443 lockdep_assert_held(&ar->conf_mutex); in ath11k_peer_assoc_qos_ap()
2445 params.vdev_id = arvif->vdev_id; in ath11k_peer_assoc_qos_ap()
2447 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac uapsd_queues 0x%x max_sp %d\n", in ath11k_peer_assoc_qos_ap()
2448 sta->uapsd_queues, sta->max_sp); in ath11k_peer_assoc_qos_ap()
2451 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) in ath11k_peer_assoc_qos_ap()
2454 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) in ath11k_peer_assoc_qos_ap()
2457 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) in ath11k_peer_assoc_qos_ap()
2460 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) in ath11k_peer_assoc_qos_ap()
2465 if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP) in ath11k_peer_assoc_qos_ap()
2466 max_sp = sta->max_sp; in ath11k_peer_assoc_qos_ap()
2470 ret = ath11k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, ¶ms); in ath11k_peer_assoc_qos_ap()
2476 ret = ath11k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, ¶ms); in ath11k_peer_assoc_qos_ap()
2483 ret = ath11k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, ¶ms); in ath11k_peer_assoc_qos_ap()
2489 ret = ath11k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, ¶ms); in ath11k_peer_assoc_qos_ap()
2496 ath11k_warn(ar->ab, "failed to set ap ps peer param %d for vdev %i: %d\n", in ath11k_peer_assoc_qos_ap()
2497 params.param, arvif->vdev_id, ret); in ath11k_peer_assoc_qos_ap()
2503 return sta->deflink.supp_rates[NL80211_BAND_2GHZ] >> in ath11k_mac_sta_has_ofdm_only()
2510 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath11k_mac_get_phymode_vht()
2511 switch (sta->deflink.vht_cap.cap & in ath11k_mac_get_phymode_vht()
2523 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath11k_mac_get_phymode_vht()
2526 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath11k_mac_get_phymode_vht()
2529 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath11k_mac_get_phymode_vht()
2538 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath11k_mac_get_phymode_he()
2539 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath11k_mac_get_phymode_he()
2542 else if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath11k_mac_get_phymode_he()
2549 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath11k_mac_get_phymode_he()
2552 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath11k_mac_get_phymode_he()
2555 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath11k_mac_get_phymode_he()
2566 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_peer_assoc_h_phymode()
2577 band = def.chan->band; in ath11k_peer_assoc_h_phymode()
2578 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath11k_peer_assoc_h_phymode()
2579 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath11k_peer_assoc_h_phymode()
2580 he_mcs_mask = arvif->bitrate_mask.control[band].he_mcs; in ath11k_peer_assoc_h_phymode()
2584 if (sta->deflink.he_cap.has_he && in ath11k_peer_assoc_h_phymode()
2586 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath11k_peer_assoc_h_phymode()
2588 else if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath11k_peer_assoc_h_phymode()
2592 } else if (sta->deflink.vht_cap.vht_supported && in ath11k_peer_assoc_h_phymode()
2594 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath11k_peer_assoc_h_phymode()
2598 } else if (sta->deflink.ht_cap.ht_supported && in ath11k_peer_assoc_h_phymode()
2600 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath11k_peer_assoc_h_phymode()
2613 if (sta->deflink.he_cap.has_he && in ath11k_peer_assoc_h_phymode()
2616 } else if (sta->deflink.vht_cap.vht_supported && in ath11k_peer_assoc_h_phymode()
2619 } else if (sta->deflink.ht_cap.ht_supported && in ath11k_peer_assoc_h_phymode()
2621 if (sta->deflink.bandwidth >= IEEE80211_STA_RX_BW_40) in ath11k_peer_assoc_h_phymode()
2633 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac peer %pM phymode %s\n", in ath11k_peer_assoc_h_phymode()
2634 sta->addr, ath11k_wmi_phymode_str(phymode)); in ath11k_peer_assoc_h_phymode()
2636 arg->peer_phymode = phymode; in ath11k_peer_assoc_h_phymode()
2648 lockdep_assert_held(&ar->conf_mutex); in ath11k_peer_assoc_prepare()
2650 arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_peer_assoc_prepare()
2654 reinit_completion(&ar->peer_assoc_done); in ath11k_peer_assoc_prepare()
2656 arg->peer_new_assoc = !reassoc; in ath11k_peer_assoc_prepare()
2668 arsta->peer_nss = arg->peer_nss; in ath11k_peer_assoc_prepare()
2680 if (!ht_cap->ht_supported && !he_6ghz_capa) in ath11k_setup_peer_smps()
2683 if (ht_cap->ht_supported) { in ath11k_setup_peer_smps()
2684 smps = ht_cap->cap & IEEE80211_HT_CAP_SM_PS; in ath11k_setup_peer_smps()
2691 return -EINVAL; in ath11k_setup_peer_smps()
2693 return ath11k_wmi_set_peer_param(ar, addr, arvif->vdev_id, in ath11k_setup_peer_smps()
2702 struct ath11k *ar = hw->priv; in ath11k_bss_assoc()
2703 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_bss_assoc()
2710 lockdep_assert_held(&ar->conf_mutex); in ath11k_bss_assoc()
2712 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev %i assoc bssid %pM aid %d\n", in ath11k_bss_assoc()
2713 arvif->vdev_id, arvif->bssid, arvif->aid); in ath11k_bss_assoc()
2717 ap_sta = ieee80211_find_sta(vif, bss_conf->bssid); in ath11k_bss_assoc()
2719 ath11k_warn(ar->ab, "failed to find station entry for bss %pM vdev %i\n", in ath11k_bss_assoc()
2720 bss_conf->bssid, arvif->vdev_id); in ath11k_bss_assoc()
2732 ath11k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n", in ath11k_bss_assoc()
2733 bss_conf->bssid, arvif->vdev_id, ret); in ath11k_bss_assoc()
2737 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath11k_bss_assoc()
2738 ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath11k_bss_assoc()
2739 bss_conf->bssid, arvif->vdev_id); in ath11k_bss_assoc()
2743 ret = ath11k_setup_peer_smps(ar, arvif, bss_conf->bssid, in ath11k_bss_assoc()
2744 &ap_sta->deflink.ht_cap, in ath11k_bss_assoc()
2745 le16_to_cpu(ap_sta->deflink.he_6ghz_capa.capa)); in ath11k_bss_assoc()
2747 ath11k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath11k_bss_assoc()
2748 arvif->vdev_id, ret); in ath11k_bss_assoc()
2752 WARN_ON(arvif->is_up); in ath11k_bss_assoc()
2754 arvif->aid = vif->cfg.aid; in ath11k_bss_assoc()
2755 ether_addr_copy(arvif->bssid, bss_conf->bssid); in ath11k_bss_assoc()
2757 ret = ath11k_wmi_vdev_up(ar, arvif->vdev_id, arvif->aid, arvif->bssid); in ath11k_bss_assoc()
2759 ath11k_warn(ar->ab, "failed to set vdev %d up: %d\n", in ath11k_bss_assoc()
2760 arvif->vdev_id, ret); in ath11k_bss_assoc()
2764 arvif->is_up = true; in ath11k_bss_assoc()
2765 arvif->rekey_data.enable_offload = false; in ath11k_bss_assoc()
2767 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_bss_assoc()
2769 arvif->vdev_id, bss_conf->bssid, vif->cfg.aid); in ath11k_bss_assoc()
2771 spin_lock_bh(&ar->ab->base_lock); in ath11k_bss_assoc()
2773 peer = ath11k_peer_find(ar->ab, arvif->vdev_id, arvif->bssid); in ath11k_bss_assoc()
2774 if (peer && peer->is_authorized) in ath11k_bss_assoc()
2777 spin_unlock_bh(&ar->ab->base_lock); in ath11k_bss_assoc()
2780 ret = ath11k_wmi_set_peer_param(ar, arvif->bssid, in ath11k_bss_assoc()
2781 arvif->vdev_id, in ath11k_bss_assoc()
2785 ath11k_warn(ar->ab, "Unable to authorize BSS peer: %d\n", ret); in ath11k_bss_assoc()
2788 ret = ath11k_wmi_send_obss_spr_cmd(ar, arvif->vdev_id, in ath11k_bss_assoc()
2789 &bss_conf->he_obss_pd); in ath11k_bss_assoc()
2791 ath11k_warn(ar->ab, "failed to set vdev %i OBSS PD parameters: %d\n", in ath11k_bss_assoc()
2792 arvif->vdev_id, ret); in ath11k_bss_assoc()
2794 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_bss_assoc()
2798 ath11k_warn(ar->ab, "failed to set vdev %d dtim policy: %d\n", in ath11k_bss_assoc()
2799 arvif->vdev_id, ret); in ath11k_bss_assoc()
2801 ath11k_mac_11d_scan_stop_all(ar->ab); in ath11k_bss_assoc()
2807 struct ath11k *ar = hw->priv; in ath11k_bss_disassoc()
2808 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_bss_disassoc()
2811 lockdep_assert_held(&ar->conf_mutex); in ath11k_bss_disassoc()
2813 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev %i disassoc bssid %pM\n", in ath11k_bss_disassoc()
2814 arvif->vdev_id, arvif->bssid); in ath11k_bss_disassoc()
2816 ret = ath11k_wmi_vdev_down(ar, arvif->vdev_id); in ath11k_bss_disassoc()
2818 ath11k_warn(ar->ab, "failed to down vdev %i: %d\n", in ath11k_bss_disassoc()
2819 arvif->vdev_id, ret); in ath11k_bss_disassoc()
2821 arvif->is_up = false; in ath11k_bss_disassoc()
2823 memset(&arvif->rekey_data, 0, sizeof(arvif->rekey_data)); in ath11k_bss_disassoc()
2825 cancel_delayed_work_sync(&arvif->connection_loss_work); in ath11k_bss_disassoc()
2850 return -EINVAL; in ath11k_mac_get_rate_hw_value()
2857 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_recalculate_mgmt_rate()
2865 lockdep_assert_held(&ar->conf_mutex); in ath11k_recalculate_mgmt_rate()
2867 sband = ar->hw->wiphy->bands[def->chan->band]; in ath11k_recalculate_mgmt_rate()
2868 basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1; in ath11k_recalculate_mgmt_rate()
2869 bitrate = sband->bitrates[basic_rate_idx].bitrate; in ath11k_recalculate_mgmt_rate()
2873 ath11k_warn(ar->ab, "bitrate not supported %d\n", bitrate); in ath11k_recalculate_mgmt_rate()
2878 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath11k_recalculate_mgmt_rate()
2881 ath11k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret); in ath11k_recalculate_mgmt_rate()
2886 ar->hw_rate_code = hw_rate_code; in ath11k_recalculate_mgmt_rate()
2889 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath11k_recalculate_mgmt_rate()
2892 ath11k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret); in ath11k_recalculate_mgmt_rate()
2898 struct ath11k *ar = arvif->ar; in ath11k_mac_fils_discovery()
2904 if (info->fils_discovery.max_interval) { in ath11k_mac_fils_discovery()
2905 interval = info->fils_discovery.max_interval; in ath11k_mac_fils_discovery()
2907 tmpl = ieee80211_get_fils_discovery_tmpl(ar->hw, arvif->vif); in ath11k_mac_fils_discovery()
2909 ret = ath11k_wmi_fils_discovery_tmpl(ar, arvif->vdev_id, in ath11k_mac_fils_discovery()
2911 } else if (info->unsol_bcast_probe_resp_interval) { in ath11k_mac_fils_discovery()
2913 interval = info->unsol_bcast_probe_resp_interval; in ath11k_mac_fils_discovery()
2915 tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(ar->hw, in ath11k_mac_fils_discovery()
2916 arvif->vif); in ath11k_mac_fils_discovery()
2918 ret = ath11k_wmi_probe_resp_tmpl(ar, arvif->vdev_id, in ath11k_mac_fils_discovery()
2921 return ath11k_wmi_fils_discovery(ar, arvif->vdev_id, 0, false); in ath11k_mac_fils_discovery()
2925 ath11k_warn(ar->ab, in ath11k_mac_fils_discovery()
2927 arvif->vdev_id, (unsol_bcast_probe_resp_enabled ? in ath11k_mac_fils_discovery()
2930 return -EPERM; in ath11k_mac_fils_discovery()
2935 ret = ath11k_wmi_fils_discovery(ar, arvif->vdev_id, interval, in ath11k_mac_fils_discovery()
2948 pdev_id = ar->pdev->pdev_id; in ath11k_mac_config_obss_pd()
2950 /* Set and enable SRG/non-SRG OBSS PD Threshold */ in ath11k_mac_config_obss_pd()
2952 if (test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags)) { in ath11k_mac_config_obss_pd()
2955 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
2961 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_config_obss_pd()
2963 he_obss_pd->sr_ctrl, he_obss_pd->non_srg_max_offset, in ath11k_mac_config_obss_pd()
2964 he_obss_pd->max_offset); in ath11k_mac_config_obss_pd()
2968 if (he_obss_pd->sr_ctrl & in ath11k_mac_config_obss_pd()
2972 if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT) in ath11k_mac_config_obss_pd()
2974 he_obss_pd->non_srg_max_offset); in ath11k_mac_config_obss_pd()
2981 if (he_obss_pd->sr_ctrl & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) { in ath11k_mac_config_obss_pd()
2982 srg_th = ATH11K_OBSS_PD_MAX_THRESHOLD + he_obss_pd->max_offset; in ath11k_mac_config_obss_pd()
2987 ar->ab->wmi_ab.svc_map)) { in ath11k_mac_config_obss_pd()
2991 non_srg_th -= ATH11K_DEFAULT_NOISE_FLOOR; in ath11k_mac_config_obss_pd()
3000 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3011 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3019 param_val = !!(he_obss_pd->sr_ctrl & in ath11k_mac_config_obss_pd()
3023 ath11k_warn(ar->ab, "failed to set sr_prohibit for pdev: %u\n", in ath11k_mac_config_obss_pd()
3029 ar->ab->wmi_ab.svc_map)) in ath11k_mac_config_obss_pd()
3033 memcpy(bitmap, he_obss_pd->bss_color_bitmap, sizeof(bitmap)); in ath11k_mac_config_obss_pd()
3036 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3043 memcpy(bitmap, he_obss_pd->partial_bssid_bitmap, sizeof(bitmap)); in ath11k_mac_config_obss_pd()
3046 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3057 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3066 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3072 /* Enable all BSS Colors for non-SRG */ in ath11k_mac_config_obss_pd()
3075 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3081 /* Enable all partial BSSID mask for non-SRG */ in ath11k_mac_config_obss_pd()
3084 ath11k_warn(ar->ab, in ath11k_mac_config_obss_pd()
3098 struct ath11k *ar = hw->priv; in ath11k_mac_op_bss_info_changed()
3113 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_bss_info_changed()
3116 arvif->beacon_interval = info->beacon_int; in ath11k_mac_op_bss_info_changed()
3119 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3121 arvif->beacon_interval); in ath11k_mac_op_bss_info_changed()
3123 ath11k_warn(ar->ab, "Failed to set beacon interval for VDEV: %d\n", in ath11k_mac_op_bss_info_changed()
3124 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3126 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3128 arvif->beacon_interval, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3135 param_value, ar->pdev->pdev_id); in ath11k_mac_op_bss_info_changed()
3137 ath11k_warn(ar->ab, "Failed to set beacon mode for VDEV: %d\n", in ath11k_mac_op_bss_info_changed()
3138 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3140 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3142 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3144 if (!arvif->do_not_send_tmpl || !arvif->bcca_zero_sent) { in ath11k_mac_op_bss_info_changed()
3147 ath11k_warn(ar->ab, "failed to update bcn template: %d\n", in ath11k_mac_op_bss_info_changed()
3151 if (arvif->bcca_zero_sent) in ath11k_mac_op_bss_info_changed()
3152 arvif->do_not_send_tmpl = true; in ath11k_mac_op_bss_info_changed()
3154 arvif->do_not_send_tmpl = false; in ath11k_mac_op_bss_info_changed()
3156 if (vif->bss_conf.he_support) { in ath11k_mac_op_bss_info_changed()
3157 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3161 ath11k_warn(ar->ab, in ath11k_mac_op_bss_info_changed()
3163 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3165 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3167 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3172 arvif->dtim_period = info->dtim_period; in ath11k_mac_op_bss_info_changed()
3175 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3177 arvif->dtim_period); in ath11k_mac_op_bss_info_changed()
3180 ath11k_warn(ar->ab, "Failed to set dtim period for VDEV %d: %i\n", in ath11k_mac_op_bss_info_changed()
3181 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3183 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3185 arvif->dtim_period, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3189 vif->type == NL80211_IFTYPE_AP) { in ath11k_mac_op_bss_info_changed()
3190 arvif->u.ap.ssid_len = vif->cfg.ssid_len; in ath11k_mac_op_bss_info_changed()
3191 if (vif->cfg.ssid_len) in ath11k_mac_op_bss_info_changed()
3192 memcpy(arvif->u.ap.ssid, vif->cfg.ssid, in ath11k_mac_op_bss_info_changed()
3193 vif->cfg.ssid_len); in ath11k_mac_op_bss_info_changed()
3194 arvif->u.ap.hidden_ssid = info->hidden_ssid; in ath11k_mac_op_bss_info_changed()
3197 if (changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) in ath11k_mac_op_bss_info_changed()
3198 ether_addr_copy(arvif->bssid, info->bssid); in ath11k_mac_op_bss_info_changed()
3203 if (arvif->is_up && vif->bss_conf.he_support && in ath11k_mac_op_bss_info_changed()
3204 vif->bss_conf.he_oper.params) { in ath11k_mac_op_bss_info_changed()
3206 param_value = vif->bss_conf.he_oper.params; in ath11k_mac_op_bss_info_changed()
3207 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3209 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3211 param_value, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3214 ath11k_warn(ar->ab, "Failed to set he oper params %x for VDEV %d: %i\n", in ath11k_mac_op_bss_info_changed()
3215 param_value, arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3222 cts_prot = !!(info->use_cts_prot); in ath11k_mac_op_bss_info_changed()
3225 if (arvif->is_started) { in ath11k_mac_op_bss_info_changed()
3226 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3229 ath11k_warn(ar->ab, "Failed to set CTS prot for VDEV: %d\n", in ath11k_mac_op_bss_info_changed()
3230 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3232 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "Set CTS prot: %d for VDEV: %d\n", in ath11k_mac_op_bss_info_changed()
3233 cts_prot, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3235 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "defer protection mode setup, vdev is not ready yet\n"); in ath11k_mac_op_bss_info_changed()
3242 if (info->use_short_slot) in ath11k_mac_op_bss_info_changed()
3249 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3252 ath11k_warn(ar->ab, "Failed to set erp slot for VDEV: %d\n", in ath11k_mac_op_bss_info_changed()
3253 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3255 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3257 slottime, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3263 if (info->use_short_preamble) in ath11k_mac_op_bss_info_changed()
3269 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3272 ath11k_warn(ar->ab, "Failed to set preamble for VDEV: %d\n", in ath11k_mac_op_bss_info_changed()
3273 arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3275 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3277 preamble, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3281 if (vif->cfg.assoc) in ath11k_mac_op_bss_info_changed()
3288 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev_id %i txpower %d\n", in ath11k_mac_op_bss_info_changed()
3289 arvif->vdev_id, info->txpower); in ath11k_mac_op_bss_info_changed()
3291 arvif->txpower = info->txpower; in ath11k_mac_op_bss_info_changed()
3296 ar->ab->hw_params.supports_sta_ps) { in ath11k_mac_op_bss_info_changed()
3297 arvif->ps = vif->cfg.ps; in ath11k_mac_op_bss_info_changed()
3301 ath11k_warn(ar->ab, "failed to setup ps on vdev %i: %d\n", in ath11k_mac_op_bss_info_changed()
3302 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3306 !ath11k_mac_vif_chan(arvif->vif, &def)) { in ath11k_mac_op_bss_info_changed()
3307 band = def.chan->band; in ath11k_mac_op_bss_info_changed()
3308 mcast_rate = vif->bss_conf.mcast_rate[band]; in ath11k_mac_op_bss_info_changed()
3311 rateidx = mcast_rate - 1; in ath11k_mac_op_bss_info_changed()
3313 rateidx = ffs(vif->bss_conf.basic_rates) - 1; in ath11k_mac_op_bss_info_changed()
3315 if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) in ath11k_mac_op_bss_info_changed()
3328 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3330 arvif->vdev_id, rate); in ath11k_mac_op_bss_info_changed()
3333 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3336 ath11k_warn(ar->ab, in ath11k_mac_op_bss_info_changed()
3338 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3341 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3344 ath11k_warn(ar->ab, in ath11k_mac_op_bss_info_changed()
3346 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3350 !ath11k_mac_vif_chan(arvif->vif, &def)) in ath11k_mac_op_bss_info_changed()
3356 if (info->twt_requester || info->twt_responder) { in ath11k_mac_op_bss_info_changed()
3358 ath11k_wmi_send_twt_enable_cmd(ar, ar->pdev->pdev_id, in ath11k_mac_op_bss_info_changed()
3361 ath11k_wmi_send_twt_disable_cmd(ar, ar->pdev->pdev_id); in ath11k_mac_op_bss_info_changed()
3366 ath11k_mac_config_obss_pd(ar, &info->he_obss_pd); in ath11k_mac_op_bss_info_changed()
3369 if (vif->type == NL80211_IFTYPE_AP) { in ath11k_mac_op_bss_info_changed()
3371 ar, arvif->vdev_id, info->he_bss_color.color, in ath11k_mac_op_bss_info_changed()
3373 info->he_bss_color.enabled); in ath11k_mac_op_bss_info_changed()
3375 ath11k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n", in ath11k_mac_op_bss_info_changed()
3376 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3379 if (info->he_bss_color.enabled) in ath11k_mac_op_bss_info_changed()
3380 param_value = info->he_bss_color.color << in ath11k_mac_op_bss_info_changed()
3385 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3389 ath11k_warn(ar->ab, in ath11k_mac_op_bss_info_changed()
3391 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3393 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_bss_info_changed()
3395 param_value, arvif->vdev_id); in ath11k_mac_op_bss_info_changed()
3396 } else if (vif->type == NL80211_IFTYPE_STATION) { in ath11k_mac_op_bss_info_changed()
3398 arvif->vdev_id, in ath11k_mac_op_bss_info_changed()
3401 ath11k_warn(ar->ab, "failed to enable bss color change on vdev %i: %d\n", in ath11k_mac_op_bss_info_changed()
3402 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3404 ar, arvif->vdev_id, 0, in ath11k_mac_op_bss_info_changed()
3407 ath11k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n", in ath11k_mac_op_bss_info_changed()
3408 arvif->vdev_id, ret); in ath11k_mac_op_bss_info_changed()
3417 ipv4_cnt = min(vif->cfg.arp_addr_cnt, ATH11K_IPV4_MAX_COUNT); in ath11k_mac_op_bss_info_changed()
3418 memcpy(arvif->arp_ns_offload.ipv4_addr, in ath11k_mac_op_bss_info_changed()
3419 vif->cfg.arp_addr_list, in ath11k_mac_op_bss_info_changed()
3421 memcpy(arvif->arp_ns_offload.mac_addr, vif->addr, ETH_ALEN); in ath11k_mac_op_bss_info_changed()
3422 arvif->arp_ns_offload.ipv4_count = ipv4_cnt; in ath11k_mac_op_bss_info_changed()
3424 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac arp_addr_cnt %d vif->addr %pM, offload_addr %pI4\n", in ath11k_mac_op_bss_info_changed()
3425 vif->cfg.arp_addr_cnt, in ath11k_mac_op_bss_info_changed()
3426 vif->addr, arvif->arp_ns_offload.ipv4_addr); in ath11k_mac_op_bss_info_changed()
3429 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_bss_info_changed()
3434 lockdep_assert_held(&ar->data_lock); in __ath11k_mac_scan_finish()
3436 switch (ar->scan.state) { in __ath11k_mac_scan_finish()
3441 if (ar->scan.is_roc && ar->scan.roc_notify) in __ath11k_mac_scan_finish()
3442 ieee80211_remain_on_channel_expired(ar->hw); in __ath11k_mac_scan_finish()
3445 if (!ar->scan.is_roc) { in __ath11k_mac_scan_finish()
3447 .aborted = ((ar->scan.state == in __ath11k_mac_scan_finish()
3449 (ar->scan.state == in __ath11k_mac_scan_finish()
3453 ieee80211_scan_completed(ar->hw, &info); in __ath11k_mac_scan_finish()
3456 ar->scan.state = ATH11K_SCAN_IDLE; in __ath11k_mac_scan_finish()
3457 ar->scan_channel = NULL; in __ath11k_mac_scan_finish()
3458 ar->scan.roc_freq = 0; in __ath11k_mac_scan_finish()
3459 cancel_delayed_work(&ar->scan.timeout); in __ath11k_mac_scan_finish()
3460 complete_all(&ar->scan.completed); in __ath11k_mac_scan_finish()
3467 spin_lock_bh(&ar->data_lock); in ath11k_mac_scan_finish()
3469 spin_unlock_bh(&ar->data_lock); in ath11k_mac_scan_finish()
3480 lockdep_assert_held(&ar->conf_mutex); in ath11k_scan_stop()
3483 arg.pdev_id = ar->pdev->pdev_id; in ath11k_scan_stop()
3487 ath11k_warn(ar->ab, "failed to stop wmi scan: %d\n", ret); in ath11k_scan_stop()
3491 ret = wait_for_completion_timeout(&ar->scan.completed, 3 * HZ); in ath11k_scan_stop()
3493 ath11k_warn(ar->ab, in ath11k_scan_stop()
3495 ret = -ETIMEDOUT; in ath11k_scan_stop()
3508 spin_lock_bh(&ar->data_lock); in ath11k_scan_stop()
3509 if (ar->scan.state != ATH11K_SCAN_IDLE) in ath11k_scan_stop()
3511 spin_unlock_bh(&ar->data_lock); in ath11k_scan_stop()
3520 lockdep_assert_held(&ar->conf_mutex); in ath11k_scan_abort()
3522 spin_lock_bh(&ar->data_lock); in ath11k_scan_abort()
3524 switch (ar->scan.state) { in ath11k_scan_abort()
3532 ath11k_warn(ar->ab, "refusing scan abortion due to invalid scan state: %d\n", in ath11k_scan_abort()
3533 ar->scan.state); in ath11k_scan_abort()
3536 ar->scan.state = ATH11K_SCAN_ABORTING; in ath11k_scan_abort()
3537 spin_unlock_bh(&ar->data_lock); in ath11k_scan_abort()
3541 ath11k_warn(ar->ab, "failed to abort scan: %d\n", ret); in ath11k_scan_abort()
3543 spin_lock_bh(&ar->data_lock); in ath11k_scan_abort()
3547 spin_unlock_bh(&ar->data_lock); in ath11k_scan_abort()
3555 mutex_lock(&ar->conf_mutex); in ath11k_scan_timeout_work()
3557 mutex_unlock(&ar->conf_mutex); in ath11k_scan_timeout_work()
3566 lockdep_assert_held(&ar->conf_mutex); in ath11k_start_scan()
3575 if (test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ar->ab->wmi_ab.svc_map)) { in ath11k_start_scan()
3578 if (ar->supports_6ghz) in ath11k_start_scan()
3582 ret = wait_for_completion_timeout(&ar->scan.started, timeout); in ath11k_start_scan()
3586 ath11k_warn(ar->ab, "failed to stop scan: %d\n", ret); in ath11k_start_scan()
3588 return -ETIMEDOUT; in ath11k_start_scan()
3595 spin_lock_bh(&ar->data_lock); in ath11k_start_scan()
3596 if (ar->scan.state == ATH11K_SCAN_IDLE) { in ath11k_start_scan()
3597 spin_unlock_bh(&ar->data_lock); in ath11k_start_scan()
3598 return -EINVAL; in ath11k_start_scan()
3600 spin_unlock_bh(&ar->data_lock); in ath11k_start_scan()
3609 struct ath11k *ar = hw->priv; in ath11k_mac_op_hw_scan()
3611 struct cfg80211_scan_request *req = &hw_req->req; in ath11k_mac_op_hw_scan()
3616 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_hw_scan()
3618 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_hw_scan()
3619 switch (ar->scan.state) { in ath11k_mac_op_hw_scan()
3621 reinit_completion(&ar->scan.started); in ath11k_mac_op_hw_scan()
3622 reinit_completion(&ar->scan.completed); in ath11k_mac_op_hw_scan()
3623 ar->scan.state = ATH11K_SCAN_STARTING; in ath11k_mac_op_hw_scan()
3624 ar->scan.is_roc = false; in ath11k_mac_op_hw_scan()
3625 ar->scan.vdev_id = arvif->vdev_id; in ath11k_mac_op_hw_scan()
3631 ret = -EBUSY; in ath11k_mac_op_hw_scan()
3634 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_hw_scan()
3641 arg.vdev_id = arvif->vdev_id; in ath11k_mac_op_hw_scan()
3644 if (req->ie_len) { in ath11k_mac_op_hw_scan()
3645 arg.extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL); in ath11k_mac_op_hw_scan()
3647 ret = -ENOMEM; in ath11k_mac_op_hw_scan()
3650 arg.extraie.len = req->ie_len; in ath11k_mac_op_hw_scan()
3653 if (req->n_ssids) { in ath11k_mac_op_hw_scan()
3654 arg.num_ssids = req->n_ssids; in ath11k_mac_op_hw_scan()
3656 arg.ssid[i].length = req->ssids[i].ssid_len; in ath11k_mac_op_hw_scan()
3657 memcpy(&arg.ssid[i].ssid, req->ssids[i].ssid, in ath11k_mac_op_hw_scan()
3658 req->ssids[i].ssid_len); in ath11k_mac_op_hw_scan()
3664 if (req->n_channels) { in ath11k_mac_op_hw_scan()
3665 arg.num_chan = req->n_channels; in ath11k_mac_op_hw_scan()
3670 ret = -ENOMEM; in ath11k_mac_op_hw_scan()
3675 arg.chan_list[i] = req->channels[i]->center_freq; in ath11k_mac_op_hw_scan()
3678 if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { in ath11k_mac_op_hw_scan()
3680 ether_addr_copy(arg.mac_addr.addr, req->mac_addr); in ath11k_mac_op_hw_scan()
3681 ether_addr_copy(arg.mac_mask.addr, req->mac_addr_mask); in ath11k_mac_op_hw_scan()
3686 ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret); in ath11k_mac_op_hw_scan()
3687 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_hw_scan()
3688 ar->scan.state = ATH11K_SCAN_IDLE; in ath11k_mac_op_hw_scan()
3689 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_hw_scan()
3693 ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout, in ath11k_mac_op_hw_scan()
3700 if (req->ie_len) in ath11k_mac_op_hw_scan()
3703 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_hw_scan()
3705 if (ar->state_11d == ATH11K_11D_PREPARING) in ath11k_mac_op_hw_scan()
3706 ath11k_mac_11d_scan_start(ar, arvif->vdev_id); in ath11k_mac_op_hw_scan()
3714 struct ath11k *ar = hw->priv; in ath11k_mac_op_cancel_hw_scan()
3716 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_cancel_hw_scan()
3718 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_cancel_hw_scan()
3720 cancel_delayed_work_sync(&ar->scan.timeout); in ath11k_mac_op_cancel_hw_scan()
3729 struct ath11k *ar = arvif->ar; in ath11k_install_key()
3731 .vdev_id = arvif->vdev_id, in ath11k_install_key()
3732 .key_idx = key->keyidx, in ath11k_install_key()
3733 .key_len = key->keylen, in ath11k_install_key()
3734 .key_data = key->key, in ath11k_install_key()
3739 lockdep_assert_held(&arvif->ar->conf_mutex); in ath11k_install_key()
3741 reinit_completion(&ar->install_key_done); in ath11k_install_key()
3743 if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) in ath11k_install_key()
3752 switch (key->cipher) { in ath11k_install_key()
3755 /* TODO: Re-check if flag is valid */ in ath11k_install_key()
3756 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT; in ath11k_install_key()
3771 ath11k_warn(ar->ab, "cipher %d is not supported\n", key->cipher); in ath11k_install_key()
3772 return -EOPNOTSUPP; in ath11k_install_key()
3775 if (test_bit(ATH11K_FLAG_RAW_MODE, &ar->ab->dev_flags)) in ath11k_install_key()
3776 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV | in ath11k_install_key()
3780 ret = ath11k_wmi_vdev_install_key(arvif->ar, &arg); in ath11k_install_key()
3785 if (!wait_for_completion_timeout(&ar->install_key_done, 1 * HZ)) in ath11k_install_key()
3786 return -ETIMEDOUT; in ath11k_install_key()
3788 return ar->install_key_status ? -EINVAL : 0; in ath11k_install_key()
3794 struct ath11k *ar = arvif->ar; in ath11k_clear_peer_keys()
3795 struct ath11k_base *ab = ar->ab; in ath11k_clear_peer_keys()
3802 lockdep_assert_held(&ar->conf_mutex); in ath11k_clear_peer_keys()
3804 spin_lock_bh(&ab->base_lock); in ath11k_clear_peer_keys()
3805 peer = ath11k_peer_find(ab, arvif->vdev_id, addr); in ath11k_clear_peer_keys()
3806 spin_unlock_bh(&ab->base_lock); in ath11k_clear_peer_keys()
3809 return -ENOENT; in ath11k_clear_peer_keys()
3811 for (i = 0; i < ARRAY_SIZE(peer->keys); i++) { in ath11k_clear_peer_keys()
3812 if (!peer->keys[i]) in ath11k_clear_peer_keys()
3816 ret = ath11k_install_key(arvif, peer->keys[i], in ath11k_clear_peer_keys()
3825 spin_lock_bh(&ab->base_lock); in ath11k_clear_peer_keys()
3826 peer->keys[i] = NULL; in ath11k_clear_peer_keys()
3827 spin_unlock_bh(&ab->base_lock); in ath11k_clear_peer_keys()
3837 struct ath11k *ar = hw->priv; in ath11k_mac_op_set_key()
3838 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_set_key()
3847 if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC || in ath11k_mac_op_set_key()
3848 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || in ath11k_mac_op_set_key()
3849 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 || in ath11k_mac_op_set_key()
3850 key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256) in ath11k_mac_op_set_key()
3853 if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) in ath11k_mac_op_set_key()
3856 if (key->keyidx > WMI_MAX_KEY_INDEX) in ath11k_mac_op_set_key()
3857 return -ENOSPC; in ath11k_mac_op_set_key()
3859 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_key()
3862 peer_addr = sta->addr; in ath11k_mac_op_set_key()
3863 else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath11k_mac_op_set_key()
3864 peer_addr = vif->bss_conf.bssid; in ath11k_mac_op_set_key()
3866 peer_addr = vif->addr; in ath11k_mac_op_set_key()
3868 key->hw_key_idx = key->keyidx; in ath11k_mac_op_set_key()
3870 /* the peer should not disappear in mid-way (unless FW goes awry) since in ath11k_mac_op_set_key()
3873 spin_lock_bh(&ab->base_lock); in ath11k_mac_op_set_key()
3874 peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr); in ath11k_mac_op_set_key()
3881 spin_unlock_bh(&ab->base_lock); in ath11k_mac_op_set_key()
3885 ath11k_warn(ab, "cannot install key for non-existent peer %pM\n", in ath11k_mac_op_set_key()
3887 ret = -EOPNOTSUPP; in ath11k_mac_op_set_key()
3897 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in ath11k_mac_op_set_key()
3914 spin_lock_bh(&ab->base_lock); in ath11k_mac_op_set_key()
3915 peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr); in ath11k_mac_op_set_key()
3917 peer->keys[key->keyidx] = key; in ath11k_mac_op_set_key()
3918 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in ath11k_mac_op_set_key()
3919 peer->ucast_keyidx = key->keyidx; in ath11k_mac_op_set_key()
3920 peer->sec_type = ath11k_dp_tx_get_encrypt_type(key->cipher); in ath11k_mac_op_set_key()
3922 peer->mcast_keyidx = key->keyidx; in ath11k_mac_op_set_key()
3923 peer->sec_type_grp = ath11k_dp_tx_get_encrypt_type(key->cipher); in ath11k_mac_op_set_key()
3926 peer->keys[key->keyidx] = NULL; in ath11k_mac_op_set_key()
3927 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in ath11k_mac_op_set_key()
3928 peer->ucast_keyidx = 0; in ath11k_mac_op_set_key()
3930 peer->mcast_keyidx = 0; in ath11k_mac_op_set_key()
3936 arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_op_set_key()
3938 switch (key->cipher) { in ath11k_mac_op_set_key()
3945 arsta->pn_type = HAL_PN_TYPE_WPA; in ath11k_mac_op_set_key()
3947 arsta->pn_type = HAL_PN_TYPE_NONE; in ath11k_mac_op_set_key()
3950 arsta->pn_type = HAL_PN_TYPE_NONE; in ath11k_mac_op_set_key()
3955 spin_unlock_bh(&ab->base_lock); in ath11k_mac_op_set_key()
3958 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_key()
3970 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) in ath11k_mac_bitrate_mask_num_vht_rates()
3971 num_rates += hweight16(mask->control[band].vht_mcs[i]); in ath11k_mac_bitrate_mask_num_vht_rates()
3984 for (i = 0; i < ARRAY_SIZE(mask->control[band].he_mcs); i++) in ath11k_mac_bitrate_mask_num_he_rates()
3985 num_rates += hweight16(mask->control[band].he_mcs[i]); in ath11k_mac_bitrate_mask_num_he_rates()
3996 struct ath11k *ar = arvif->ar; in ath11k_mac_set_peer_vht_fixed_rate()
4001 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_set_peer_vht_fixed_rate()
4005 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) { in ath11k_mac_set_peer_vht_fixed_rate()
4006 if (hweight16(mask->control[band].vht_mcs[i]) == 1) { in ath11k_mac_set_peer_vht_fixed_rate()
4008 vht_rate = ffs(mask->control[band].vht_mcs[i]) - 1; in ath11k_mac_set_peer_vht_fixed_rate()
4013 ath11k_warn(ar->ab, "No single VHT Fixed rate found to set for %pM", in ath11k_mac_set_peer_vht_fixed_rate()
4014 sta->addr); in ath11k_mac_set_peer_vht_fixed_rate()
4015 return -EINVAL; in ath11k_mac_set_peer_vht_fixed_rate()
4019 if (nss > sta->deflink.rx_nss) in ath11k_mac_set_peer_vht_fixed_rate()
4020 return -EINVAL; in ath11k_mac_set_peer_vht_fixed_rate()
4022 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_set_peer_vht_fixed_rate()
4024 sta->addr); in ath11k_mac_set_peer_vht_fixed_rate()
4026 rate_code = ATH11K_HW_RATE_CODE(vht_rate, nss - 1, in ath11k_mac_set_peer_vht_fixed_rate()
4028 ret = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_mac_set_peer_vht_fixed_rate()
4029 arvif->vdev_id, in ath11k_mac_set_peer_vht_fixed_rate()
4033 ath11k_warn(ar->ab, in ath11k_mac_set_peer_vht_fixed_rate()
4035 sta->addr, rate_code, ret); in ath11k_mac_set_peer_vht_fixed_rate()
4046 struct ath11k *ar = arvif->ar; in ath11k_mac_set_peer_he_fixed_rate()
4051 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_set_peer_he_fixed_rate()
4055 for (i = 0; i < ARRAY_SIZE(mask->control[band].he_mcs); i++) { in ath11k_mac_set_peer_he_fixed_rate()
4056 if (hweight16(mask->control[band].he_mcs[i]) == 1) { in ath11k_mac_set_peer_he_fixed_rate()
4058 he_rate = ffs(mask->control[band].he_mcs[i]) - 1; in ath11k_mac_set_peer_he_fixed_rate()
4063 ath11k_warn(ar->ab, "No single he fixed rate found to set for %pM", in ath11k_mac_set_peer_he_fixed_rate()
4064 sta->addr); in ath11k_mac_set_peer_he_fixed_rate()
4065 return -EINVAL; in ath11k_mac_set_peer_he_fixed_rate()
4069 if (nss > sta->deflink.rx_nss) in ath11k_mac_set_peer_he_fixed_rate()
4070 return -EINVAL; in ath11k_mac_set_peer_he_fixed_rate()
4072 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_set_peer_he_fixed_rate()
4074 sta->addr); in ath11k_mac_set_peer_he_fixed_rate()
4076 rate_code = ATH11K_HW_RATE_CODE(he_rate, nss - 1, in ath11k_mac_set_peer_he_fixed_rate()
4079 ret = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_mac_set_peer_he_fixed_rate()
4080 arvif->vdev_id, in ath11k_mac_set_peer_he_fixed_rate()
4084 ath11k_warn(ar->ab, in ath11k_mac_set_peer_he_fixed_rate()
4086 sta->addr, rate_code, ret); in ath11k_mac_set_peer_he_fixed_rate()
4104 lockdep_assert_held(&ar->conf_mutex); in ath11k_station_assoc()
4107 return -EPERM; in ath11k_station_assoc()
4109 band = def.chan->band; in ath11k_station_assoc()
4110 mask = &arvif->bitrate_mask; in ath11k_station_assoc()
4117 ath11k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", in ath11k_station_assoc()
4118 sta->addr, arvif->vdev_id, ret); in ath11k_station_assoc()
4122 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath11k_station_assoc()
4123 ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath11k_station_assoc()
4124 sta->addr, arvif->vdev_id); in ath11k_station_assoc()
4125 return -ETIMEDOUT; in ath11k_station_assoc()
4136 if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) { in ath11k_station_assoc()
4141 } else if (sta->deflink.he_cap.has_he && num_he_rates == 1) { in ath11k_station_assoc()
4148 /* Re-assoc is run only to update supported rates for given station. It in ath11k_station_assoc()
4149 * doesn't make much sense to reconfigure the peer completely. in ath11k_station_assoc()
4154 ret = ath11k_setup_peer_smps(ar, arvif, sta->addr, in ath11k_station_assoc()
4155 &sta->deflink.ht_cap, in ath11k_station_assoc()
4156 le16_to_cpu(sta->deflink.he_6ghz_capa.capa)); in ath11k_station_assoc()
4158 ath11k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath11k_station_assoc()
4159 arvif->vdev_id, ret); in ath11k_station_assoc()
4163 if (!sta->wme) { in ath11k_station_assoc()
4164 arvif->num_legacy_stations++; in ath11k_station_assoc()
4170 if (sta->wme && sta->uapsd_queues) { in ath11k_station_assoc()
4173 ath11k_warn(ar->ab, "failed to set qos params for STA %pM for vdev %i: %d\n", in ath11k_station_assoc()
4174 sta->addr, arvif->vdev_id, ret); in ath11k_station_assoc()
4186 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_station_disassoc()
4189 lockdep_assert_held(&ar->conf_mutex); in ath11k_station_disassoc()
4191 if (!sta->wme) { in ath11k_station_disassoc()
4192 arvif->num_legacy_stations--; in ath11k_station_disassoc()
4198 ret = ath11k_clear_peer_keys(arvif, sta->addr); in ath11k_station_disassoc()
4200 ath11k_warn(ar->ab, "failed to clear all peer keys for vdev %i: %d\n", in ath11k_station_disassoc()
4201 arvif->vdev_id, ret); in ath11k_station_disassoc()
4225 arvif = arsta->arvif; in ath11k_sta_rc_update_wk()
4226 ar = arvif->ar; in ath11k_sta_rc_update_wk()
4228 if (WARN_ON(ath11k_mac_vif_chan(arvif->vif, &def))) in ath11k_sta_rc_update_wk()
4231 band = def.chan->band; in ath11k_sta_rc_update_wk()
4232 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath11k_sta_rc_update_wk()
4233 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath11k_sta_rc_update_wk()
4234 he_mcs_mask = arvif->bitrate_mask.control[band].he_mcs; in ath11k_sta_rc_update_wk()
4236 spin_lock_bh(&ar->data_lock); in ath11k_sta_rc_update_wk()
4238 changed = arsta->changed; in ath11k_sta_rc_update_wk()
4239 arsta->changed = 0; in ath11k_sta_rc_update_wk()
4241 bw = arsta->bw; in ath11k_sta_rc_update_wk()
4242 nss = arsta->nss; in ath11k_sta_rc_update_wk()
4243 smps = arsta->smps; in ath11k_sta_rc_update_wk()
4245 spin_unlock_bh(&ar->data_lock); in ath11k_sta_rc_update_wk()
4247 mutex_lock(&ar->conf_mutex); in ath11k_sta_rc_update_wk()
4259 ath11k_peer_assoc_prepare(ar, arvif->vif, sta, &peer_arg, true); in ath11k_sta_rc_update_wk()
4264 ath11k_warn(ar->ab, "failed to send peer assoc for STA %pM vdev %i: %d\n", in ath11k_sta_rc_update_wk()
4265 sta->addr, arvif->vdev_id, err); in ath11k_sta_rc_update_wk()
4266 } else if (wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath11k_sta_rc_update_wk()
4267 err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath11k_sta_rc_update_wk()
4270 ath11k_warn(ar->ab, "failed to update STA %pM peer bw %d: %d\n", in ath11k_sta_rc_update_wk()
4271 sta->addr, bw, err); in ath11k_sta_rc_update_wk()
4273 ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath11k_sta_rc_update_wk()
4274 sta->addr, arvif->vdev_id); in ath11k_sta_rc_update_wk()
4279 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac update sta %pM nss %d\n", in ath11k_sta_rc_update_wk()
4280 sta->addr, nss); in ath11k_sta_rc_update_wk()
4282 err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath11k_sta_rc_update_wk()
4285 ath11k_warn(ar->ab, "failed to update STA %pM nss %d: %d\n", in ath11k_sta_rc_update_wk()
4286 sta->addr, nss, err); in ath11k_sta_rc_update_wk()
4290 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac update sta %pM smps %d\n", in ath11k_sta_rc_update_wk()
4291 sta->addr, smps); in ath11k_sta_rc_update_wk()
4293 err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath11k_sta_rc_update_wk()
4296 ath11k_warn(ar->ab, "failed to update STA %pM smps %d: %d\n", in ath11k_sta_rc_update_wk()
4297 sta->addr, smps, err); in ath11k_sta_rc_update_wk()
4301 mask = &arvif->bitrate_mask; in ath11k_sta_rc_update_wk()
4311 * But, Single rate in VHT mask can be set as per-peer in ath11k_sta_rc_update_wk()
4314 * when per-peer Fixed rate is set. in ath11k_sta_rc_update_wk()
4318 if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) { in ath11k_sta_rc_update_wk()
4321 } else if (sta->deflink.he_cap.has_he && num_he_rates == 1) { in ath11k_sta_rc_update_wk()
4325 /* If the peer is non-VHT/HE or no fixed VHT/HE rate in ath11k_sta_rc_update_wk()
4331 err = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_sta_rc_update_wk()
4332 arvif->vdev_id, in ath11k_sta_rc_update_wk()
4336 ath11k_warn(ar->ab, in ath11k_sta_rc_update_wk()
4338 sta->addr, err); in ath11k_sta_rc_update_wk()
4340 ath11k_peer_assoc_prepare(ar, arvif->vif, sta, in ath11k_sta_rc_update_wk()
4346 ath11k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", in ath11k_sta_rc_update_wk()
4347 sta->addr, arvif->vdev_id, err); in ath11k_sta_rc_update_wk()
4349 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) in ath11k_sta_rc_update_wk()
4350 ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath11k_sta_rc_update_wk()
4351 sta->addr, arvif->vdev_id); in ath11k_sta_rc_update_wk()
4355 mutex_unlock(&ar->conf_mutex); in ath11k_sta_rc_update_wk()
4368 arvif = arsta->arvif; in ath11k_sta_set_4addr_wk()
4369 ar = arvif->ar; in ath11k_sta_set_4addr_wk()
4371 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_sta_set_4addr_wk()
4372 "setting USE_4ADDR for peer %pM\n", sta->addr); in ath11k_sta_set_4addr_wk()
4374 ret = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_sta_set_4addr_wk()
4375 arvif->vdev_id, in ath11k_sta_set_4addr_wk()
4379 ath11k_warn(ar->ab, "failed to set peer %pM 4addr capability: %d\n", in ath11k_sta_set_4addr_wk()
4380 sta->addr, ret); in ath11k_sta_set_4addr_wk()
4386 struct ath11k *ar = arvif->ar; in ath11k_mac_inc_num_stations()
4388 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_inc_num_stations()
4390 if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls) in ath11k_mac_inc_num_stations()
4393 if (ar->num_stations >= ar->max_num_stations) in ath11k_mac_inc_num_stations()
4394 return -ENOBUFS; in ath11k_mac_inc_num_stations()
4396 ar->num_stations++; in ath11k_mac_inc_num_stations()
4404 struct ath11k *ar = arvif->ar; in ath11k_mac_dec_num_stations()
4406 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_dec_num_stations()
4408 if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls) in ath11k_mac_dec_num_stations()
4411 ar->num_stations--; in ath11k_mac_dec_num_stations()
4418 struct ath11k_base *ab = ar->ab; in ath11k_mac_station_add()
4420 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_station_add()
4424 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_station_add()
4429 ar->max_num_stations); in ath11k_mac_station_add()
4433 arsta->rx_stats = kzalloc(sizeof(*arsta->rx_stats), GFP_KERNEL); in ath11k_mac_station_add()
4434 if (!arsta->rx_stats) { in ath11k_mac_station_add()
4435 ret = -ENOMEM; in ath11k_mac_station_add()
4439 peer_param.vdev_id = arvif->vdev_id; in ath11k_mac_station_add()
4440 peer_param.peer_addr = sta->addr; in ath11k_mac_station_add()
4446 sta->addr, arvif->vdev_id); in ath11k_mac_station_add()
4451 sta->addr, arvif->vdev_id); in ath11k_mac_station_add()
4454 arsta->tx_stats = kzalloc(sizeof(*arsta->tx_stats), GFP_KERNEL); in ath11k_mac_station_add()
4455 if (!arsta->tx_stats) { in ath11k_mac_station_add()
4456 ret = -ENOMEM; in ath11k_mac_station_add()
4463 "setting USE_4ADDR for mesh STA %pM\n", sta->addr); in ath11k_mac_station_add()
4464 ret = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_mac_station_add()
4465 arvif->vdev_id, in ath11k_mac_station_add()
4469 sta->addr, ret); in ath11k_mac_station_add()
4474 ret = ath11k_dp_peer_setup(ar, arvif->vdev_id, sta->addr); in ath11k_mac_station_add()
4477 sta->addr, arvif->vdev_id, ret); in ath11k_mac_station_add()
4481 if (ab->hw_params.vdev_start_delay && in ath11k_mac_station_add()
4482 !arvif->is_started && in ath11k_mac_station_add()
4483 arvif->vdev_type != WMI_VDEV_TYPE_AP) { in ath11k_mac_station_add()
4484 ret = ath11k_start_vdev_delay(ar->hw, vif); in ath11k_mac_station_add()
4491 ewma_avg_rssi_init(&arsta->avg_rssi); in ath11k_mac_station_add()
4495 kfree(arsta->tx_stats); in ath11k_mac_station_add()
4496 arsta->tx_stats = NULL; in ath11k_mac_station_add()
4498 ath11k_peer_delete(ar, arvif->vdev_id, sta->addr); in ath11k_mac_station_add()
4500 kfree(arsta->rx_stats); in ath11k_mac_station_add()
4501 arsta->rx_stats = NULL; in ath11k_mac_station_add()
4514 struct ath11k *ar = hw->priv; in ath11k_mac_op_sta_state()
4516 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_op_sta_state()
4523 cancel_work_sync(&arsta->update_wk); in ath11k_mac_op_sta_state()
4524 cancel_work_sync(&arsta->set_4addr_wk); in ath11k_mac_op_sta_state()
4527 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_sta_state()
4532 arsta->arvif = arvif; in ath11k_mac_op_sta_state()
4533 arsta->peer_ps_state = WMI_PEER_PS_STATE_DISABLED; in ath11k_mac_op_sta_state()
4534 INIT_WORK(&arsta->update_wk, ath11k_sta_rc_update_wk); in ath11k_mac_op_sta_state()
4535 INIT_WORK(&arsta->set_4addr_wk, ath11k_sta_set_4addr_wk); in ath11k_mac_op_sta_state()
4539 ath11k_warn(ar->ab, "Failed to add station: %pM for VDEV: %d\n", in ath11k_mac_op_sta_state()
4540 sta->addr, arvif->vdev_id); in ath11k_mac_op_sta_state()
4543 bool skip_peer_delete = ar->ab->hw_params.vdev_start_delay && in ath11k_mac_op_sta_state()
4544 vif->type == NL80211_IFTYPE_STATION; in ath11k_mac_op_sta_state()
4546 ath11k_dp_peer_cleanup(ar, arvif->vdev_id, sta->addr); in ath11k_mac_op_sta_state()
4549 ret = ath11k_peer_delete(ar, arvif->vdev_id, sta->addr); in ath11k_mac_op_sta_state()
4551 ath11k_warn(ar->ab, in ath11k_mac_op_sta_state()
4553 sta->addr, arvif->vdev_id); in ath11k_mac_op_sta_state()
4555 ath11k_dbg(ar->ab, in ath11k_mac_op_sta_state()
4558 sta->addr, arvif->vdev_id); in ath11k_mac_op_sta_state()
4562 mutex_lock(&ar->ab->tbl_mtx_lock); in ath11k_mac_op_sta_state()
4563 spin_lock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_state()
4564 peer = ath11k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath11k_mac_op_sta_state()
4566 peer->sta = NULL; in ath11k_mac_op_sta_state()
4567 } else if (peer && peer->sta == sta) { in ath11k_mac_op_sta_state()
4568 ath11k_warn(ar->ab, "Found peer entry %pM n vdev %i after it was supposedly removed\n", in ath11k_mac_op_sta_state()
4569 vif->addr, arvif->vdev_id); in ath11k_mac_op_sta_state()
4570 ath11k_peer_rhash_delete(ar->ab, peer); in ath11k_mac_op_sta_state()
4571 peer->sta = NULL; in ath11k_mac_op_sta_state()
4572 list_del(&peer->list); in ath11k_mac_op_sta_state()
4574 ar->num_peers--; in ath11k_mac_op_sta_state()
4576 spin_unlock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_state()
4577 mutex_unlock(&ar->ab->tbl_mtx_lock); in ath11k_mac_op_sta_state()
4579 kfree(arsta->tx_stats); in ath11k_mac_op_sta_state()
4580 arsta->tx_stats = NULL; in ath11k_mac_op_sta_state()
4582 kfree(arsta->rx_stats); in ath11k_mac_op_sta_state()
4583 arsta->rx_stats = NULL; in ath11k_mac_op_sta_state()
4586 (vif->type == NL80211_IFTYPE_AP || in ath11k_mac_op_sta_state()
4587 vif->type == NL80211_IFTYPE_MESH_POINT || in ath11k_mac_op_sta_state()
4588 vif->type == NL80211_IFTYPE_ADHOC)) { in ath11k_mac_op_sta_state()
4591 ath11k_warn(ar->ab, "Failed to associate station: %pM\n", in ath11k_mac_op_sta_state()
4592 sta->addr); in ath11k_mac_op_sta_state()
4595 spin_lock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_state()
4597 peer = ath11k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath11k_mac_op_sta_state()
4599 peer->is_authorized = true; in ath11k_mac_op_sta_state()
4601 spin_unlock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_state()
4603 if (vif->type == NL80211_IFTYPE_STATION && arvif->is_up) { in ath11k_mac_op_sta_state()
4604 ret = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_mac_op_sta_state()
4605 arvif->vdev_id, in ath11k_mac_op_sta_state()
4609 ath11k_warn(ar->ab, "Unable to authorize peer %pM vdev %d: %d\n", in ath11k_mac_op_sta_state()
4610 sta->addr, arvif->vdev_id, ret); in ath11k_mac_op_sta_state()
4614 spin_lock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_state()
4616 peer = ath11k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath11k_mac_op_sta_state()
4618 peer->is_authorized = false; in ath11k_mac_op_sta_state()
4620 spin_unlock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_state()
4623 (vif->type == NL80211_IFTYPE_AP || in ath11k_mac_op_sta_state()
4624 vif->type == NL80211_IFTYPE_MESH_POINT || in ath11k_mac_op_sta_state()
4625 vif->type == NL80211_IFTYPE_ADHOC)) { in ath11k_mac_op_sta_state()
4628 ath11k_warn(ar->ab, "Failed to disassociate station: %pM\n", in ath11k_mac_op_sta_state()
4629 sta->addr); in ath11k_mac_op_sta_state()
4632 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_sta_state()
4640 struct ath11k *ar = hw->priv; in ath11k_mac_op_sta_set_txpwr()
4641 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_sta_set_txpwr()
4645 if (sta->deflink.txpwr.type == NL80211_TX_POWER_AUTOMATIC) { in ath11k_mac_op_sta_set_txpwr()
4648 txpwr = sta->deflink.txpwr.power; in ath11k_mac_op_sta_set_txpwr()
4650 return -EINVAL; in ath11k_mac_op_sta_set_txpwr()
4654 return -EINVAL; in ath11k_mac_op_sta_set_txpwr()
4656 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_sta_set_txpwr()
4658 ret = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath11k_mac_op_sta_set_txpwr()
4661 ath11k_warn(ar->ab, "failed to set tx power for station ret: %d\n", in ath11k_mac_op_sta_set_txpwr()
4667 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_sta_set_txpwr()
4675 struct ath11k *ar = hw->priv; in ath11k_mac_op_sta_set_4addr()
4676 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_op_sta_set_4addr()
4678 if (enabled && !arsta->use_4addr_set) { in ath11k_mac_op_sta_set_4addr()
4679 ieee80211_queue_work(ar->hw, &arsta->set_4addr_wk); in ath11k_mac_op_sta_set_4addr()
4680 arsta->use_4addr_set = true; in ath11k_mac_op_sta_set_4addr()
4689 struct ath11k *ar = hw->priv; in ath11k_mac_op_sta_rc_update()
4690 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_op_sta_rc_update()
4691 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_sta_rc_update()
4695 spin_lock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_rc_update()
4697 peer = ath11k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath11k_mac_op_sta_rc_update()
4699 spin_unlock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_rc_update()
4700 ath11k_warn(ar->ab, "mac sta rc update failed to find peer %pM on vdev %i\n", in ath11k_mac_op_sta_rc_update()
4701 sta->addr, arvif->vdev_id); in ath11k_mac_op_sta_rc_update()
4705 spin_unlock_bh(&ar->ab->base_lock); in ath11k_mac_op_sta_rc_update()
4707 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_sta_rc_update()
4709 sta->addr, changed, sta->deflink.bandwidth, in ath11k_mac_op_sta_rc_update()
4710 sta->deflink.rx_nss, in ath11k_mac_op_sta_rc_update()
4711 sta->deflink.smps_mode); in ath11k_mac_op_sta_rc_update()
4713 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_sta_rc_update()
4718 switch (sta->deflink.bandwidth) { in ath11k_mac_op_sta_rc_update()
4732 ath11k_warn(ar->ab, "Invalid bandwidth %d in rc update for %pM\n", in ath11k_mac_op_sta_rc_update()
4733 sta->deflink.bandwidth, sta->addr); in ath11k_mac_op_sta_rc_update()
4738 arsta->bw = bw; in ath11k_mac_op_sta_rc_update()
4742 arsta->nss = sta->deflink.rx_nss; in ath11k_mac_op_sta_rc_update()
4747 switch (sta->deflink.smps_mode) { in ath11k_mac_op_sta_rc_update()
4759 ath11k_warn(ar->ab, "Invalid smps %d in sta rc update for %pM\n", in ath11k_mac_op_sta_rc_update()
4760 sta->deflink.smps_mode, sta->addr); in ath11k_mac_op_sta_rc_update()
4765 arsta->smps = smps; in ath11k_mac_op_sta_rc_update()
4768 arsta->changed |= changed; in ath11k_mac_op_sta_rc_update()
4770 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_sta_rc_update()
4772 ieee80211_queue_work(hw, &arsta->update_wk); in ath11k_mac_op_sta_rc_update()
4782 if (arvif->vdev_type != WMI_VDEV_TYPE_STA) in ath11k_conf_tx_uapsd()
4805 arvif->u.sta.uapsd |= value; in ath11k_conf_tx_uapsd()
4807 arvif->u.sta.uapsd &= ~value; in ath11k_conf_tx_uapsd()
4809 ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath11k_conf_tx_uapsd()
4811 arvif->u.sta.uapsd); in ath11k_conf_tx_uapsd()
4813 ath11k_warn(ar->ab, "could not set uapsd params %d\n", ret); in ath11k_conf_tx_uapsd()
4817 if (arvif->u.sta.uapsd) in ath11k_conf_tx_uapsd()
4822 ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath11k_conf_tx_uapsd()
4826 ath11k_warn(ar->ab, "could not set rx wake param %d\n", ret); in ath11k_conf_tx_uapsd()
4837 struct ath11k *ar = hw->priv; in ath11k_mac_op_conf_tx()
4838 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_conf_tx()
4842 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_conf_tx()
4846 p = &arvif->wmm_params.ac_vo; in ath11k_mac_op_conf_tx()
4849 p = &arvif->wmm_params.ac_vi; in ath11k_mac_op_conf_tx()
4852 p = &arvif->wmm_params.ac_be; in ath11k_mac_op_conf_tx()
4855 p = &arvif->wmm_params.ac_bk; in ath11k_mac_op_conf_tx()
4860 ret = -EINVAL; in ath11k_mac_op_conf_tx()
4864 p->cwmin = params->cw_min; in ath11k_mac_op_conf_tx()
4865 p->cwmax = params->cw_max; in ath11k_mac_op_conf_tx()
4866 p->aifs = params->aifs; in ath11k_mac_op_conf_tx()
4867 p->txop = params->txop; in ath11k_mac_op_conf_tx()
4869 ret = ath11k_wmi_send_wmm_update_cmd_tlv(ar, arvif->vdev_id, in ath11k_mac_op_conf_tx()
4870 &arvif->wmm_params); in ath11k_mac_op_conf_tx()
4872 ath11k_warn(ar->ab, "failed to set wmm params: %d\n", ret); in ath11k_mac_op_conf_tx()
4876 ret = ath11k_conf_tx_uapsd(ar, vif, ac, params->uapsd); in ath11k_mac_op_conf_tx()
4879 ath11k_warn(ar->ab, "failed to set sta uapsd: %d\n", ret); in ath11k_mac_op_conf_tx()
4882 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_conf_tx()
4891 u32 ar_vht_cap = ar->pdev->cap.vht_cap; in ath11k_create_ht_cap()
4942 for (i = 0; i < ar->num_rx_chains; i++) { in ath11k_create_ht_cap()
4955 struct ath11k *ar = arvif->ar; in ath11k_mac_set_txbf_conf()
4958 u32 vht_cap = ar->pdev->cap.vht_cap; in ath11k_mac_set_txbf_conf()
4964 if (nsts > (ar->num_rx_chains - 1)) in ath11k_mac_set_txbf_conf()
4965 nsts = ar->num_rx_chains - 1; in ath11k_mac_set_txbf_conf()
4973 if (sound_dim > (ar->num_tx_chains - 1)) in ath11k_mac_set_txbf_conf()
4974 sound_dim = ar->num_tx_chains - 1; in ath11k_mac_set_txbf_conf()
4985 arvif->vdev_type == WMI_VDEV_TYPE_AP) in ath11k_mac_set_txbf_conf()
4995 arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath11k_mac_set_txbf_conf()
4999 return ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_txbf_conf()
5011 if (ar->num_tx_chains < 2) { in ath11k_set_vht_txbf_cap()
5016 if (ar->num_rx_chains < 2) { in ath11k_set_vht_txbf_cap()
5039 if (sound_dim > (ar->num_tx_chains - 1)) in ath11k_set_vht_txbf_cap()
5040 sound_dim = ar->num_tx_chains - 1; in ath11k_set_vht_txbf_cap()
5049 if (nsts > (ar->num_rx_chains - 1)) in ath11k_set_vht_txbf_cap()
5050 nsts = ar->num_rx_chains - 1; in ath11k_set_vht_txbf_cap()
5067 vht_cap.cap = ar->pdev->cap.vht_cap; in ath11k_create_vht_cap()
5069 if (ar->pdev->cap.nss_ratio_enabled) in ath11k_create_vht_cap()
5078 if (i < ar->num_tx_chains && rate_cap_tx_chainmask & BIT(i)) in ath11k_create_vht_cap()
5083 if (i < ar->num_rx_chains && rate_cap_rx_chainmask & BIT(i)) in ath11k_create_vht_cap()
5107 rate_cap_tx_chainmask = ar->cfg_tx_chainmask >> cap->tx_chain_mask_shift; in ath11k_mac_setup_ht_vht_cap()
5108 rate_cap_rx_chainmask = ar->cfg_rx_chainmask >> cap->rx_chain_mask_shift; in ath11k_mac_setup_ht_vht_cap()
5110 if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath11k_mac_setup_ht_vht_cap()
5111 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath11k_mac_setup_ht_vht_cap()
5112 ht_cap = cap->band[NL80211_BAND_2GHZ].ht_cap_info; in ath11k_mac_setup_ht_vht_cap()
5115 band->ht_cap = ath11k_create_ht_cap(ar, ht_cap, in ath11k_mac_setup_ht_vht_cap()
5119 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && in ath11k_mac_setup_ht_vht_cap()
5120 (ar->ab->hw_params.single_pdev_only || in ath11k_mac_setup_ht_vht_cap()
5121 !ar->supports_6ghz)) { in ath11k_mac_setup_ht_vht_cap()
5122 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath11k_mac_setup_ht_vht_cap()
5123 ht_cap = cap->band[NL80211_BAND_5GHZ].ht_cap_info; in ath11k_mac_setup_ht_vht_cap()
5126 band->ht_cap = ath11k_create_ht_cap(ar, ht_cap, in ath11k_mac_setup_ht_vht_cap()
5128 band->vht_cap = ath11k_create_vht_cap(ar, rate_cap_tx_chainmask, in ath11k_mac_setup_ht_vht_cap()
5148 he_ppet[0] = fw_ppet->numss_m1 & IEEE80211_PPE_THRES_NSS_MASK; in ath11k_gen_ppe_thresh()
5149 he_ppet[0] |= (fw_ppet->ru_bit_mask << in ath11k_gen_ppe_thresh()
5152 for (nss = 0; nss <= fw_ppet->numss_m1; nss++) { in ath11k_gen_ppe_thresh()
5157 if ((fw_ppet->ru_bit_mask & BIT(ru)) == 0) in ath11k_gen_ppe_thresh()
5159 val = (fw_ppet->ppet16_ppet8_ru3_ru0[nss] >> (ru * 6)) & in ath11k_gen_ppe_thresh()
5162 for (i = 5; i >= 0; i--) { in ath11k_gen_ppe_thresh()
5178 he_cap_elem->mac_cap_info[0] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5183 he_cap_elem->mac_cap_info[2] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5188 he_cap_elem->mac_cap_info[3] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5192 he_cap_elem->mac_cap_info[4] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5198 he_cap_elem->mac_cap_info[5] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5202 he_cap_elem->phy_cap_info[2] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5207 he_cap_elem->phy_cap_info[3] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5210 he_cap_elem->phy_cap_info[4] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5213 he_cap_elem->phy_cap_info[5] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5219 he_cap_elem->phy_cap_info[6] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5225 he_cap_elem->phy_cap_info[7] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5231 he_cap_elem->phy_cap_info[8] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5239 he_cap_elem->phy_cap_info[9] &= ~m; in ath11k_mac_filter_he_cap_mesh()
5247 bcap->he_6ghz_capa = IEEE80211_HT_MPDU_DENSITY_NONE; in ath11k_mac_setup_he_6ghz_cap()
5248 if (bcap->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS) in ath11k_mac_setup_he_6ghz_cap()
5249 bcap->he_6ghz_capa |= in ath11k_mac_setup_he_6ghz_cap()
5253 bcap->he_6ghz_capa |= in ath11k_mac_setup_he_6ghz_cap()
5257 pcap->vht_cap); in ath11k_mac_setup_he_6ghz_cap()
5258 bcap->he_6ghz_capa |= in ath11k_mac_setup_he_6ghz_cap()
5260 val = FIELD_GET(IEEE80211_VHT_CAP_MAX_MPDU_MASK, pcap->vht_cap); in ath11k_mac_setup_he_6ghz_cap()
5261 bcap->he_6ghz_capa |= in ath11k_mac_setup_he_6ghz_cap()
5263 if (pcap->vht_cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN) in ath11k_mac_setup_he_6ghz_cap()
5264 bcap->he_6ghz_capa |= IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS; in ath11k_mac_setup_he_6ghz_cap()
5265 if (pcap->vht_cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN) in ath11k_mac_setup_he_6ghz_cap()
5266 bcap->he_6ghz_capa |= IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS; in ath11k_mac_setup_he_6ghz_cap()
5268 return cpu_to_le16(bcap->he_6ghz_capa); in ath11k_mac_setup_he_6ghz_cap()
5280 struct ath11k_band_cap *band_cap = &cap->band[band]; in ath11k_mac_copy_he_cap()
5282 &he_cap->he_cap_elem; in ath11k_mac_copy_he_cap()
5295 he_cap->has_he = true; in ath11k_mac_copy_he_cap()
5296 memcpy(he_cap_elem->mac_cap_info, band_cap->he_cap_info, in ath11k_mac_copy_he_cap()
5297 sizeof(he_cap_elem->mac_cap_info)); in ath11k_mac_copy_he_cap()
5298 memcpy(he_cap_elem->phy_cap_info, band_cap->he_cap_phy_info, in ath11k_mac_copy_he_cap()
5299 sizeof(he_cap_elem->phy_cap_info)); in ath11k_mac_copy_he_cap()
5301 he_cap_elem->mac_cap_info[1] &= in ath11k_mac_copy_he_cap()
5304 he_cap_elem->phy_cap_info[5] &= in ath11k_mac_copy_he_cap()
5306 he_cap_elem->phy_cap_info[5] |= ar->num_tx_chains - 1; in ath11k_mac_copy_he_cap()
5310 he_cap_elem->phy_cap_info[3] &= in ath11k_mac_copy_he_cap()
5312 he_cap_elem->phy_cap_info[9] |= in ath11k_mac_copy_he_cap()
5316 he_cap_elem->mac_cap_info[0] &= in ath11k_mac_copy_he_cap()
5318 he_cap_elem->mac_cap_info[0] |= in ath11k_mac_copy_he_cap()
5320 he_cap_elem->phy_cap_info[9] |= in ath11k_mac_copy_he_cap()
5328 he_cap->he_mcs_nss_supp.rx_mcs_80 = in ath11k_mac_copy_he_cap()
5329 cpu_to_le16(band_cap->he_mcs & 0xffff); in ath11k_mac_copy_he_cap()
5330 he_cap->he_mcs_nss_supp.tx_mcs_80 = in ath11k_mac_copy_he_cap()
5331 cpu_to_le16(band_cap->he_mcs & 0xffff); in ath11k_mac_copy_he_cap()
5332 he_cap->he_mcs_nss_supp.rx_mcs_160 = in ath11k_mac_copy_he_cap()
5333 cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath11k_mac_copy_he_cap()
5334 he_cap->he_mcs_nss_supp.tx_mcs_160 = in ath11k_mac_copy_he_cap()
5335 cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath11k_mac_copy_he_cap()
5336 he_cap->he_mcs_nss_supp.rx_mcs_80p80 = in ath11k_mac_copy_he_cap()
5337 cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath11k_mac_copy_he_cap()
5338 he_cap->he_mcs_nss_supp.tx_mcs_80p80 = in ath11k_mac_copy_he_cap()
5339 cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath11k_mac_copy_he_cap()
5341 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres)); in ath11k_mac_copy_he_cap()
5342 if (he_cap_elem->phy_cap_info[6] & in ath11k_mac_copy_he_cap()
5344 ath11k_gen_ppe_thresh(&band_cap->he_ppet, in ath11k_mac_copy_he_cap()
5345 he_cap->ppe_thres); in ath11k_mac_copy_he_cap()
5363 if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath11k_mac_setup_he_cap()
5365 ar->mac.iftype[NL80211_BAND_2GHZ], in ath11k_mac_setup_he_cap()
5367 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath11k_mac_setup_he_cap()
5368 band->iftype_data = ar->mac.iftype[NL80211_BAND_2GHZ]; in ath11k_mac_setup_he_cap()
5369 band->n_iftype_data = count; in ath11k_mac_setup_he_cap()
5372 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath11k_mac_setup_he_cap()
5374 ar->mac.iftype[NL80211_BAND_5GHZ], in ath11k_mac_setup_he_cap()
5376 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath11k_mac_setup_he_cap()
5377 band->iftype_data = ar->mac.iftype[NL80211_BAND_5GHZ]; in ath11k_mac_setup_he_cap()
5378 band->n_iftype_data = count; in ath11k_mac_setup_he_cap()
5381 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && in ath11k_mac_setup_he_cap()
5382 ar->supports_6ghz) { in ath11k_mac_setup_he_cap()
5384 ar->mac.iftype[NL80211_BAND_6GHZ], in ath11k_mac_setup_he_cap()
5386 band = &ar->mac.sbands[NL80211_BAND_6GHZ]; in ath11k_mac_setup_he_cap()
5387 band->iftype_data = ar->mac.iftype[NL80211_BAND_6GHZ]; in ath11k_mac_setup_he_cap()
5388 band->n_iftype_data = count; in ath11k_mac_setup_he_cap()
5396 lockdep_assert_held(&ar->conf_mutex); in __ath11k_set_antenna()
5399 return -EINVAL; in __ath11k_set_antenna()
5402 return -EINVAL; in __ath11k_set_antenna()
5404 ar->cfg_tx_chainmask = tx_ant; in __ath11k_set_antenna()
5405 ar->cfg_rx_chainmask = rx_ant; in __ath11k_set_antenna()
5407 if (ar->state != ATH11K_STATE_ON && in __ath11k_set_antenna()
5408 ar->state != ATH11K_STATE_RESTARTED) in __ath11k_set_antenna()
5412 tx_ant, ar->pdev->pdev_id); in __ath11k_set_antenna()
5414 ath11k_warn(ar->ab, "failed to set tx-chainmask: %d, req 0x%x\n", in __ath11k_set_antenna()
5419 ar->num_tx_chains = get_num_chains(tx_ant); in __ath11k_set_antenna()
5422 rx_ant, ar->pdev->pdev_id); in __ath11k_set_antenna()
5424 ath11k_warn(ar->ab, "failed to set rx-chainmask: %d, req 0x%x\n", in __ath11k_set_antenna()
5429 ar->num_rx_chains = get_num_chains(rx_ant); in __ath11k_set_antenna()
5432 ath11k_mac_setup_ht_vht_cap(ar, &ar->pdev->cap, NULL); in __ath11k_set_antenna()
5433 ath11k_mac_setup_he_cap(ar, &ar->pdev->cap); in __ath11k_set_antenna()
5442 ieee80211_free_txskb(ar->hw, skb); in ath11k_mgmt_over_wmi_tx_drop()
5444 num_mgmt = atomic_dec_if_positive(&ar->num_pending_mgmt_tx); in ath11k_mgmt_over_wmi_tx_drop()
5450 wake_up(&ar->txmgmt_empty_waitq); in ath11k_mgmt_over_wmi_tx_drop()
5458 spin_lock_bh(&ar->txmgmt_idr_lock); in ath11k_mac_tx_mgmt_free()
5459 msdu = idr_remove(&ar->txmgmt_idr, buf_id); in ath11k_mac_tx_mgmt_free()
5460 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath11k_mac_tx_mgmt_free()
5465 dma_unmap_single(ar->ab->dev, ATH11K_SKB_CB(msdu)->paddr, msdu->len, in ath11k_mac_tx_mgmt_free()
5469 memset(&info->status, 0, sizeof(info->status)); in ath11k_mac_tx_mgmt_free()
5487 struct ath11k *ar = skb_cb->ar; in ath11k_mac_vif_txmgmt_idr_remove()
5489 if (skb_cb->vif == vif) in ath11k_mac_vif_txmgmt_idr_remove()
5498 struct ath11k_base *ab = ar->ab; in ath11k_mac_mgmt_tx_wmi()
5499 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath11k_mac_mgmt_tx_wmi()
5505 ATH11K_SKB_CB(skb)->ar = ar; in ath11k_mac_mgmt_tx_wmi()
5507 spin_lock_bh(&ar->txmgmt_idr_lock); in ath11k_mac_mgmt_tx_wmi()
5508 buf_id = idr_alloc(&ar->txmgmt_idr, skb, 0, in ath11k_mac_mgmt_tx_wmi()
5510 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath11k_mac_mgmt_tx_wmi()
5512 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_mgmt_tx_wmi()
5516 return -ENOSPC; in ath11k_mac_mgmt_tx_wmi()
5519 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) { in ath11k_mac_mgmt_tx_wmi()
5520 if ((ieee80211_is_action(hdr->frame_control) || in ath11k_mac_mgmt_tx_wmi()
5521 ieee80211_is_deauth(hdr->frame_control) || in ath11k_mac_mgmt_tx_wmi()
5522 ieee80211_is_disassoc(hdr->frame_control)) && in ath11k_mac_mgmt_tx_wmi()
5523 ieee80211_has_protected(hdr->frame_control)) { in ath11k_mac_mgmt_tx_wmi()
5528 paddr = dma_map_single(ab->dev, skb->data, skb->len, DMA_TO_DEVICE); in ath11k_mac_mgmt_tx_wmi()
5529 if (dma_mapping_error(ab->dev, paddr)) { in ath11k_mac_mgmt_tx_wmi()
5531 ret = -EIO; in ath11k_mac_mgmt_tx_wmi()
5535 ATH11K_SKB_CB(skb)->paddr = paddr; in ath11k_mac_mgmt_tx_wmi()
5537 ret = ath11k_wmi_mgmt_send(ar, arvif->vdev_id, buf_id, skb); in ath11k_mac_mgmt_tx_wmi()
5539 ath11k_warn(ar->ab, "failed to send mgmt frame: %d\n", ret); in ath11k_mac_mgmt_tx_wmi()
5546 dma_unmap_single(ab->dev, ATH11K_SKB_CB(skb)->paddr, in ath11k_mac_mgmt_tx_wmi()
5547 skb->len, DMA_TO_DEVICE); in ath11k_mac_mgmt_tx_wmi()
5549 spin_lock_bh(&ar->txmgmt_idr_lock); in ath11k_mac_mgmt_tx_wmi()
5550 idr_remove(&ar->txmgmt_idr, buf_id); in ath11k_mac_mgmt_tx_wmi()
5551 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath11k_mac_mgmt_tx_wmi()
5560 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) in ath11k_mgmt_over_wmi_tx_purge()
5572 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) { in ath11k_mgmt_over_wmi_tx_work()
5574 if (!skb_cb->vif) { in ath11k_mgmt_over_wmi_tx_work()
5575 ath11k_warn(ar->ab, "no vif found for mgmt frame\n"); in ath11k_mgmt_over_wmi_tx_work()
5580 arvif = ath11k_vif_to_arvif(skb_cb->vif); in ath11k_mgmt_over_wmi_tx_work()
5581 mutex_lock(&ar->conf_mutex); in ath11k_mgmt_over_wmi_tx_work()
5582 if (ar->allocated_vdev_map & (1LL << arvif->vdev_id)) { in ath11k_mgmt_over_wmi_tx_work()
5585 ath11k_warn(ar->ab, "failed to tx mgmt frame, vdev_id %d :%d\n", in ath11k_mgmt_over_wmi_tx_work()
5586 arvif->vdev_id, ret); in ath11k_mgmt_over_wmi_tx_work()
5589 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mgmt_over_wmi_tx_work()
5591 arvif->vdev_id); in ath11k_mgmt_over_wmi_tx_work()
5594 ath11k_warn(ar->ab, in ath11k_mgmt_over_wmi_tx_work()
5596 arvif->vdev_id, in ath11k_mgmt_over_wmi_tx_work()
5597 arvif->is_started); in ath11k_mgmt_over_wmi_tx_work()
5600 mutex_unlock(&ar->conf_mutex); in ath11k_mgmt_over_wmi_tx_work()
5607 struct sk_buff_head *q = &ar->wmi_mgmt_tx_queue; in ath11k_mac_mgmt_tx()
5609 if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) in ath11k_mac_mgmt_tx()
5610 return -ESHUTDOWN; in ath11k_mac_mgmt_tx()
5618 atomic_read(&ar->num_pending_mgmt_tx) > ATH11K_PRB_RSP_DROP_THRESHOLD) { in ath11k_mac_mgmt_tx()
5619 ath11k_warn(ar->ab, in ath11k_mac_mgmt_tx()
5621 return -ENOSPC; in ath11k_mac_mgmt_tx()
5625 ath11k_warn(ar->ab, "mgmt tx queue is full\n"); in ath11k_mac_mgmt_tx()
5626 return -ENOSPC; in ath11k_mac_mgmt_tx()
5630 atomic_inc(&ar->num_pending_mgmt_tx); in ath11k_mac_mgmt_tx()
5631 queue_work(ar->ab->workqueue_aux, &ar->wmi_mgmt_tx_work); in ath11k_mac_mgmt_tx()
5641 struct ath11k *ar = hw->priv; in ath11k_mac_op_tx()
5643 struct ieee80211_vif *vif = info->control.vif; in ath11k_mac_op_tx()
5645 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath11k_mac_op_tx()
5646 struct ieee80211_key_conf *key = info->control.hw_key; in ath11k_mac_op_tx()
5648 u32 info_flags = info->flags; in ath11k_mac_op_tx()
5653 skb_cb->vif = vif; in ath11k_mac_op_tx()
5656 skb_cb->cipher = key->cipher; in ath11k_mac_op_tx()
5657 skb_cb->flags |= ATH11K_SKB_CIPHER_SET; in ath11k_mac_op_tx()
5661 skb_cb->flags |= ATH11K_SKB_HW_80211_ENCAP; in ath11k_mac_op_tx()
5662 } else if (ieee80211_is_mgmt(hdr->frame_control)) { in ath11k_mac_op_tx()
5663 is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control); in ath11k_mac_op_tx()
5666 ath11k_warn(ar->ab, "failed to queue management frame %d\n", in ath11k_mac_op_tx()
5668 ieee80211_free_txskb(ar->hw, skb); in ath11k_mac_op_tx()
5673 if (control->sta) in ath11k_mac_op_tx()
5674 arsta = (struct ath11k_sta *)control->sta->drv_priv; in ath11k_mac_op_tx()
5678 ath11k_warn(ar->ab, "failed to transmit frame %d\n", ret); in ath11k_mac_op_tx()
5679 ieee80211_free_txskb(ar->hw, skb); in ath11k_mac_op_tx()
5685 /* make sure rcu-protected mac80211 tx path itself is drained */ in ath11k_mac_drain_tx()
5688 cancel_work_sync(&ar->wmi_mgmt_tx_work); in ath11k_mac_drain_tx()
5695 struct ath11k_base *ab = ar->ab; in ath11k_mac_config_mon_status_default()
5705 for (i = 0; i < ab->hw_params.num_rxmda_per_pdev; i++) { in ath11k_mac_config_mon_status_default()
5706 ring_id = ar->dp.rx_mon_status_refill_ring[i].refill_buf_ring.ring_id; in ath11k_mac_config_mon_status_default()
5707 ret = ath11k_dp_tx_htt_rx_filter_setup(ar->ab, ring_id, in ath11k_mac_config_mon_status_default()
5708 ar->dp.mac_id + i, in ath11k_mac_config_mon_status_default()
5714 if (enable && !ar->ab->hw_params.rxdma1_enable) in ath11k_mac_config_mon_status_default()
5715 mod_timer(&ar->ab->mon_reap_timer, jiffies + in ath11k_mac_config_mon_status_default()
5725 if (!ab->is_reset) in ath11k_mac_wait_reconfigure()
5728 recovery_start_count = atomic_inc_return(&ab->recovery_start_count); in ath11k_mac_wait_reconfigure()
5731 if (recovery_start_count == ab->num_radios) { in ath11k_mac_wait_reconfigure()
5732 complete(&ab->recovery_start); in ath11k_mac_wait_reconfigure()
5738 wait_for_completion_timeout(&ab->reconfigure_complete, in ath11k_mac_wait_reconfigure()
5744 struct ath11k *ar = hw->priv; in ath11k_mac_op_start()
5745 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_start()
5746 struct ath11k_pdev *pdev = ar->pdev; in ath11k_mac_op_start()
5750 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_start()
5752 switch (ar->state) { in ath11k_mac_op_start()
5754 ar->state = ATH11K_STATE_ON; in ath11k_mac_op_start()
5757 ar->state = ATH11K_STATE_RESTARTED; in ath11k_mac_op_start()
5764 ret = -EINVAL; in ath11k_mac_op_start()
5769 1, pdev->pdev_id); in ath11k_mac_op_start()
5772 ath11k_err(ar->ab, "failed to enable PMF QOS: (%d\n", ret); in ath11k_mac_op_start()
5777 pdev->pdev_id); in ath11k_mac_op_start()
5779 ath11k_err(ar->ab, "failed to enable dynamic bw: %d\n", ret); in ath11k_mac_op_start()
5783 if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) { in ath11k_mac_op_start()
5784 ret = ath11k_wmi_scan_prob_req_oui(ar, ar->mac_addr); in ath11k_mac_op_start()
5792 0, pdev->pdev_id); in ath11k_mac_op_start()
5799 ret = ath11k_wmi_send_dfs_phyerr_offload_enable_cmd(ar, pdev->pdev_id); in ath11k_mac_op_start()
5814 1, pdev->pdev_id); in ath11k_mac_op_start()
5817 ath11k_err(ar->ab, "failed to enable MESH MCAST ENABLE: (%d\n", ret); in ath11k_mac_op_start()
5821 __ath11k_set_antenna(ar, ar->cfg_tx_chainmask, ar->cfg_rx_chainmask); in ath11k_mac_op_start()
5827 ar->num_started_vdevs = 0; in ath11k_mac_op_start()
5828 ar->num_created_vdevs = 0; in ath11k_mac_op_start()
5829 ar->num_peers = 0; in ath11k_mac_op_start()
5830 ar->allocated_vdev_map = 0; in ath11k_mac_op_start()
5843 ath11k_wmi_pdev_lro_cfg(ar, ar->pdev->pdev_id); in ath11k_mac_op_start()
5846 if (ab->hw_params.idle_ps) { in ath11k_mac_op_start()
5848 1, pdev->pdev_id); in ath11k_mac_op_start()
5855 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_start()
5857 rcu_assign_pointer(ab->pdevs_active[ar->pdev_idx], in ath11k_mac_op_start()
5858 &ab->pdevs[ar->pdev_idx]); in ath11k_mac_op_start()
5863 ar->state = ATH11K_STATE_OFF; in ath11k_mac_op_start()
5864 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_start()
5871 struct ath11k *ar = hw->priv; in ath11k_mac_op_stop()
5877 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_stop()
5880 ath11k_err(ar->ab, "failed to clear rx_filter for monitor status ring: (%d)\n", in ath11k_mac_op_stop()
5883 clear_bit(ATH11K_CAC_RUNNING, &ar->dev_flags); in ath11k_mac_op_stop()
5884 ar->state = ATH11K_STATE_OFF; in ath11k_mac_op_stop()
5885 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_stop()
5887 cancel_delayed_work_sync(&ar->scan.timeout); in ath11k_mac_op_stop()
5888 cancel_work_sync(&ar->regd_update_work); in ath11k_mac_op_stop()
5889 cancel_work_sync(&ar->ab->update_11d_work); in ath11k_mac_op_stop()
5891 if (ar->state_11d == ATH11K_11D_PREPARING) { in ath11k_mac_op_stop()
5892 ar->state_11d = ATH11K_11D_IDLE; in ath11k_mac_op_stop()
5893 complete(&ar->completed_11d_scan); in ath11k_mac_op_stop()
5896 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_stop()
5897 list_for_each_entry_safe(ppdu_stats, tmp, &ar->ppdu_stats_info, list) { in ath11k_mac_op_stop()
5898 list_del(&ppdu_stats->list); in ath11k_mac_op_stop()
5901 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_stop()
5903 rcu_assign_pointer(ar->ab->pdevs_active[ar->pdev_idx], NULL); in ath11k_mac_op_stop()
5907 atomic_set(&ar->num_pending_mgmt_tx, 0); in ath11k_mac_op_stop()
5914 struct ath11k *ar = arvif->ar; in ath11k_mac_setup_vdev_create_params()
5915 struct ath11k_pdev *pdev = ar->pdev; in ath11k_mac_setup_vdev_create_params()
5917 params->if_id = arvif->vdev_id; in ath11k_mac_setup_vdev_create_params()
5918 params->type = arvif->vdev_type; in ath11k_mac_setup_vdev_create_params()
5919 params->subtype = arvif->vdev_subtype; in ath11k_mac_setup_vdev_create_params()
5920 params->pdev_id = pdev->pdev_id; in ath11k_mac_setup_vdev_create_params()
5922 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath11k_mac_setup_vdev_create_params()
5923 params->chains[NL80211_BAND_2GHZ].tx = ar->num_tx_chains; in ath11k_mac_setup_vdev_create_params()
5924 params->chains[NL80211_BAND_2GHZ].rx = ar->num_rx_chains; in ath11k_mac_setup_vdev_create_params()
5926 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath11k_mac_setup_vdev_create_params()
5927 params->chains[NL80211_BAND_5GHZ].tx = ar->num_tx_chains; in ath11k_mac_setup_vdev_create_params()
5928 params->chains[NL80211_BAND_5GHZ].rx = ar->num_rx_chains; in ath11k_mac_setup_vdev_create_params()
5930 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP && in ath11k_mac_setup_vdev_create_params()
5931 ar->supports_6ghz) { in ath11k_mac_setup_vdev_create_params()
5932 params->chains[NL80211_BAND_6GHZ].tx = ar->num_tx_chains; in ath11k_mac_setup_vdev_create_params()
5933 params->chains[NL80211_BAND_6GHZ].rx = ar->num_rx_chains; in ath11k_mac_setup_vdev_create_params()
5940 struct ath11k_pdev_cap *pdev_cap = &pdev->cap; in ath11k_mac_prepare_he_mode()
5945 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) in ath11k_mac_prepare_he_mode()
5946 cap_band = &pdev_cap->band[NL80211_BAND_2GHZ]; in ath11k_mac_prepare_he_mode()
5948 cap_band = &pdev_cap->band[NL80211_BAND_5GHZ]; in ath11k_mac_prepare_he_mode()
5950 hecap_phy_ptr = &cap_band->he_cap_phy_info[0]; in ath11k_mac_prepare_he_mode()
5973 struct ath11k_base *ab = ar->ab; in ath11k_set_he_mu_sounding_mode()
5977 param_value = ath11k_mac_prepare_he_mode(ar->pdev, arvif->vif->type); in ath11k_set_he_mu_sounding_mode()
5978 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_set_he_mu_sounding_mode()
5982 arvif->vdev_id, ret, param_value); in ath11k_set_he_mu_sounding_mode()
5990 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_set_he_mu_sounding_mode()
5994 arvif->vdev_id, ret); in ath11k_set_he_mu_sounding_mode()
6003 struct ath11k *ar = hw->priv; in ath11k_mac_op_update_vif_offload()
6004 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_update_vif_offload()
6011 (vif->type != NL80211_IFTYPE_STATION && in ath11k_mac_op_update_vif_offload()
6012 vif->type != NL80211_IFTYPE_AP)) in ath11k_mac_op_update_vif_offload()
6013 vif->offload_flags &= ~(IEEE80211_OFFLOAD_ENCAP_ENABLED | in ath11k_mac_op_update_vif_offload()
6016 if (vif->offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ath11k_mac_op_update_vif_offload()
6018 else if (test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) in ath11k_mac_op_update_vif_offload()
6023 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_update_vif_offload()
6027 arvif->vdev_id, ret); in ath11k_mac_op_update_vif_offload()
6028 vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; in ath11k_mac_op_update_vif_offload()
6032 if (vif->offload_flags & IEEE80211_OFFLOAD_DECAP_ENABLED) in ath11k_mac_op_update_vif_offload()
6034 else if (test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) in ath11k_mac_op_update_vif_offload()
6039 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_update_vif_offload()
6043 arvif->vdev_id, ret); in ath11k_mac_op_update_vif_offload()
6044 vif->offload_flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED; in ath11k_mac_op_update_vif_offload()
6055 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_vif_ap_active_any()
6056 pdev = &ab->pdevs[i]; in ath11k_mac_vif_ap_active_any()
6057 ar = pdev->ar; in ath11k_mac_vif_ap_active_any()
6058 list_for_each_entry(arvif, &ar->arvifs, list) { in ath11k_mac_vif_ap_active_any()
6059 if (arvif->is_up && arvif->vdev_type == WMI_VDEV_TYPE_AP) in ath11k_mac_vif_ap_active_any()
6071 mutex_lock(&ar->ab->vdev_id_11d_lock); in ath11k_mac_11d_scan_start()
6073 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac vdev id for 11d scan %d\n", in ath11k_mac_11d_scan_start()
6074 ar->vdev_id_11d_scan); in ath11k_mac_11d_scan_start()
6076 if (ar->regdom_set_by_user) in ath11k_mac_11d_scan_start()
6079 if (ar->vdev_id_11d_scan != ATH11K_11D_INVALID_VDEV_ID) in ath11k_mac_11d_scan_start()
6082 if (!test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ar->ab->wmi_ab.svc_map)) in ath11k_mac_11d_scan_start()
6085 if (ath11k_mac_vif_ap_active_any(ar->ab)) in ath11k_mac_11d_scan_start()
6092 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac start 11d scan\n"); in ath11k_mac_11d_scan_start()
6096 ath11k_warn(ar->ab, "failed to start 11d scan vdev %d ret: %d\n", in ath11k_mac_11d_scan_start()
6099 ar->vdev_id_11d_scan = vdev_id; in ath11k_mac_11d_scan_start()
6100 if (ar->state_11d == ATH11K_11D_PREPARING) in ath11k_mac_11d_scan_start()
6101 ar->state_11d = ATH11K_11D_RUNNING; in ath11k_mac_11d_scan_start()
6105 if (ar->state_11d == ATH11K_11D_PREPARING) { in ath11k_mac_11d_scan_start()
6106 ar->state_11d = ATH11K_11D_IDLE; in ath11k_mac_11d_scan_start()
6107 complete(&ar->completed_11d_scan); in ath11k_mac_11d_scan_start()
6110 mutex_unlock(&ar->ab->vdev_id_11d_lock); in ath11k_mac_11d_scan_start()
6118 if (!test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ar->ab->wmi_ab.svc_map)) in ath11k_mac_11d_scan_stop()
6121 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac stop 11d scan\n"); in ath11k_mac_11d_scan_stop()
6123 mutex_lock(&ar->ab->vdev_id_11d_lock); in ath11k_mac_11d_scan_stop()
6125 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac stop 11d vdev id %d\n", in ath11k_mac_11d_scan_stop()
6126 ar->vdev_id_11d_scan); in ath11k_mac_11d_scan_stop()
6128 if (ar->state_11d == ATH11K_11D_PREPARING) { in ath11k_mac_11d_scan_stop()
6129 ar->state_11d = ATH11K_11D_IDLE; in ath11k_mac_11d_scan_stop()
6130 complete(&ar->completed_11d_scan); in ath11k_mac_11d_scan_stop()
6133 if (ar->vdev_id_11d_scan != ATH11K_11D_INVALID_VDEV_ID) { in ath11k_mac_11d_scan_stop()
6134 vdev_id = ar->vdev_id_11d_scan; in ath11k_mac_11d_scan_stop()
6138 ath11k_warn(ar->ab, in ath11k_mac_11d_scan_stop()
6142 ar->vdev_id_11d_scan = ATH11K_11D_INVALID_VDEV_ID; in ath11k_mac_11d_scan_stop()
6143 ar->state_11d = ATH11K_11D_IDLE; in ath11k_mac_11d_scan_stop()
6144 complete(&ar->completed_11d_scan); in ath11k_mac_11d_scan_stop()
6147 mutex_unlock(&ar->ab->vdev_id_11d_lock); in ath11k_mac_11d_scan_stop()
6158 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_11d_scan_stop_all()
6159 pdev = &ab->pdevs[i]; in ath11k_mac_11d_scan_stop_all()
6160 ar = pdev->ar; in ath11k_mac_11d_scan_stop_all()
6169 struct ath11k *ar = hw->priv; in ath11k_mac_op_add_interface()
6170 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_add_interface()
6180 vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD; in ath11k_mac_op_add_interface()
6182 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_add_interface()
6184 if (vif->type == NL80211_IFTYPE_AP && in ath11k_mac_op_add_interface()
6185 ar->num_peers > (ar->max_num_peers - 1)) { in ath11k_mac_op_add_interface()
6187 ret = -ENOBUFS; in ath11k_mac_op_add_interface()
6191 if (ar->num_created_vdevs > (TARGET_NUM_VDEVS(ab) - 1)) { in ath11k_mac_op_add_interface()
6193 ar->num_created_vdevs, TARGET_NUM_VDEVS(ab)); in ath11k_mac_op_add_interface()
6194 ret = -EBUSY; in ath11k_mac_op_add_interface()
6201 * These will be re-created later. in ath11k_mac_op_add_interface()
6207 arvif->ar = ar; in ath11k_mac_op_add_interface()
6208 arvif->vif = vif; in ath11k_mac_op_add_interface()
6210 INIT_LIST_HEAD(&arvif->list); in ath11k_mac_op_add_interface()
6211 INIT_DELAYED_WORK(&arvif->connection_loss_work, in ath11k_mac_op_add_interface()
6214 for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) { in ath11k_mac_op_add_interface()
6215 arvif->bitrate_mask.control[i].legacy = 0xffffffff; in ath11k_mac_op_add_interface()
6216 arvif->bitrate_mask.control[i].gi = NL80211_TXRATE_FORCE_SGI; in ath11k_mac_op_add_interface()
6217 memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff, in ath11k_mac_op_add_interface()
6218 sizeof(arvif->bitrate_mask.control[i].ht_mcs)); in ath11k_mac_op_add_interface()
6219 memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff, in ath11k_mac_op_add_interface()
6220 sizeof(arvif->bitrate_mask.control[i].vht_mcs)); in ath11k_mac_op_add_interface()
6221 memset(arvif->bitrate_mask.control[i].he_mcs, 0xff, in ath11k_mac_op_add_interface()
6222 sizeof(arvif->bitrate_mask.control[i].he_mcs)); in ath11k_mac_op_add_interface()
6225 bit = __ffs64(ab->free_vdev_map); in ath11k_mac_op_add_interface()
6227 arvif->vdev_id = bit; in ath11k_mac_op_add_interface()
6228 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_NONE; in ath11k_mac_op_add_interface()
6230 switch (vif->type) { in ath11k_mac_op_add_interface()
6233 arvif->vdev_type = WMI_VDEV_TYPE_STA; in ath11k_mac_op_add_interface()
6236 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_MESH_11S; in ath11k_mac_op_add_interface()
6239 arvif->vdev_type = WMI_VDEV_TYPE_AP; in ath11k_mac_op_add_interface()
6242 arvif->vdev_type = WMI_VDEV_TYPE_MONITOR; in ath11k_mac_op_add_interface()
6243 ar->monitor_vdev_id = bit; in ath11k_mac_op_add_interface()
6250 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac add interface id %d type %d subtype %d map %llx\n", in ath11k_mac_op_add_interface()
6251 arvif->vdev_id, arvif->vdev_type, arvif->vdev_subtype, in ath11k_mac_op_add_interface()
6252 ab->free_vdev_map); in ath11k_mac_op_add_interface()
6254 vif->cab_queue = arvif->vdev_id % (ATH11K_HW_MAX_QUEUES - 1); in ath11k_mac_op_add_interface()
6255 for (i = 0; i < ARRAY_SIZE(vif->hw_queue); i++) in ath11k_mac_op_add_interface()
6256 vif->hw_queue[i] = i % (ATH11K_HW_MAX_QUEUES - 1); in ath11k_mac_op_add_interface()
6260 ret = ath11k_wmi_vdev_create(ar, vif->addr, &vdev_param); in ath11k_mac_op_add_interface()
6263 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6267 ar->num_created_vdevs++; in ath11k_mac_op_add_interface()
6269 vif->addr, arvif->vdev_id); in ath11k_mac_op_add_interface()
6270 ar->allocated_vdev_map |= 1LL << arvif->vdev_id; in ath11k_mac_op_add_interface()
6271 ab->free_vdev_map &= ~(1LL << arvif->vdev_id); in ath11k_mac_op_add_interface()
6273 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_add_interface()
6274 list_add(&arvif->list, &ar->arvifs); in ath11k_mac_op_add_interface()
6275 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_add_interface()
6279 nss = get_num_chains(ar->cfg_tx_chainmask) ? : 1; in ath11k_mac_op_add_interface()
6280 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_add_interface()
6284 arvif->vdev_id, ar->cfg_tx_chainmask, nss, ret); in ath11k_mac_op_add_interface()
6288 switch (arvif->vdev_type) { in ath11k_mac_op_add_interface()
6290 peer_param.vdev_id = arvif->vdev_id; in ath11k_mac_op_add_interface()
6291 peer_param.peer_addr = vif->addr; in ath11k_mac_op_add_interface()
6296 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6302 ath11k_warn(ar->ab, "failed to set vdev %i kickout parameters: %d\n", in ath11k_mac_op_add_interface()
6303 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6307 ath11k_mac_11d_scan_stop_all(ar->ab); in ath11k_mac_op_add_interface()
6312 ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath11k_mac_op_add_interface()
6315 ath11k_warn(ar->ab, "failed to set vdev %d RX wake policy: %d\n", in ath11k_mac_op_add_interface()
6316 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6322 ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath11k_mac_op_add_interface()
6325 ath11k_warn(ar->ab, "failed to set vdev %d TX wake threshold: %d\n", in ath11k_mac_op_add_interface()
6326 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6332 ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath11k_mac_op_add_interface()
6335 ath11k_warn(ar->ab, "failed to set vdev %d pspoll count: %d\n", in ath11k_mac_op_add_interface()
6336 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6340 ret = ath11k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, in ath11k_mac_op_add_interface()
6343 ath11k_warn(ar->ab, "failed to disable vdev %d ps mode: %d\n", in ath11k_mac_op_add_interface()
6344 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6348 if (test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ab->wmi_ab.svc_map)) { in ath11k_mac_op_add_interface()
6349 reinit_completion(&ar->completed_11d_scan); in ath11k_mac_op_add_interface()
6350 ar->state_11d = ATH11K_11D_PREPARING; in ath11k_mac_op_add_interface()
6354 set_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags); in ath11k_mac_op_add_interface()
6360 arvif->txpower = vif->bss_conf.txpower; in ath11k_mac_op_add_interface()
6366 param_value = ar->hw->wiphy->rts_threshold; in ath11k_mac_op_add_interface()
6367 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_op_add_interface()
6370 ath11k_warn(ar->ab, "failed to set rts threshold for vdev %d: %d\n", in ath11k_mac_op_add_interface()
6371 arvif->vdev_id, ret); in ath11k_mac_op_add_interface()
6376 if (vif->type != NL80211_IFTYPE_MONITOR && in ath11k_mac_op_add_interface()
6377 test_bit(ATH11K_FLAG_MONITOR_CONF_ENABLED, &ar->monitor_flags)) { in ath11k_mac_op_add_interface()
6380 ath11k_warn(ar->ab, "failed to create monitor vdev during add interface: %d", in ath11k_mac_op_add_interface()
6388 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_add_interface()
6393 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath11k_mac_op_add_interface()
6394 fbret = ath11k_peer_delete(ar, arvif->vdev_id, vif->addr); in ath11k_mac_op_add_interface()
6396 ath11k_warn(ar->ab, "fallback fail to delete peer addr %pM vdev_id %d ret %d\n", in ath11k_mac_op_add_interface()
6397 vif->addr, arvif->vdev_id, fbret); in ath11k_mac_op_add_interface()
6403 ath11k_wmi_vdev_delete(ar, arvif->vdev_id); in ath11k_mac_op_add_interface()
6404 ar->num_created_vdevs--; in ath11k_mac_op_add_interface()
6405 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath11k_mac_op_add_interface()
6406 ab->free_vdev_map |= 1LL << arvif->vdev_id; in ath11k_mac_op_add_interface()
6407 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_add_interface()
6408 list_del(&arvif->list); in ath11k_mac_op_add_interface()
6409 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_add_interface()
6413 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_add_interface()
6423 if (skb_cb->vif == vif) in ath11k_mac_vif_unref()
6424 skb_cb->vif = NULL; in ath11k_mac_vif_unref()
6432 struct ath11k *ar = hw->priv; in ath11k_mac_op_remove_interface()
6434 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_remove_interface()
6439 cancel_delayed_work_sync(&arvif->connection_loss_work); in ath11k_mac_op_remove_interface()
6441 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_remove_interface()
6444 arvif->vdev_id); in ath11k_mac_op_remove_interface()
6446 if (arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath11k_mac_op_remove_interface()
6449 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath11k_mac_op_remove_interface()
6450 ret = ath11k_peer_delete(ar, arvif->vdev_id, vif->addr); in ath11k_mac_op_remove_interface()
6452 ath11k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n", in ath11k_mac_op_remove_interface()
6453 arvif->vdev_id, ret); in ath11k_mac_op_remove_interface()
6456 reinit_completion(&ar->vdev_delete_done); in ath11k_mac_op_remove_interface()
6458 ret = ath11k_wmi_vdev_delete(ar, arvif->vdev_id); in ath11k_mac_op_remove_interface()
6461 arvif->vdev_id, ret); in ath11k_mac_op_remove_interface()
6465 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, in ath11k_mac_op_remove_interface()
6472 ab->free_vdev_map |= 1LL << (arvif->vdev_id); in ath11k_mac_op_remove_interface()
6473 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath11k_mac_op_remove_interface()
6474 ar->num_created_vdevs--; in ath11k_mac_op_remove_interface()
6477 vif->addr, arvif->vdev_id); in ath11k_mac_op_remove_interface()
6479 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath11k_mac_op_remove_interface()
6480 clear_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags); in ath11k_mac_op_remove_interface()
6481 ar->monitor_vdev_id = -1; in ath11k_mac_op_remove_interface()
6482 } else if (test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags) && in ath11k_mac_op_remove_interface()
6483 !test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags)) { in ath11k_mac_op_remove_interface()
6487 ath11k_warn(ar->ab, "failed to delete vdev monitor during remove interface: %d", in ath11k_mac_op_remove_interface()
6492 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_remove_interface()
6493 list_del(&arvif->list); in ath11k_mac_op_remove_interface()
6494 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_remove_interface()
6496 ath11k_peer_cleanup(ar, arvif->vdev_id); in ath11k_mac_op_remove_interface()
6498 idr_for_each(&ar->txmgmt_idr, in ath11k_mac_op_remove_interface()
6501 for (i = 0; i < ab->hw_params.max_tx_ring; i++) { in ath11k_mac_op_remove_interface()
6502 spin_lock_bh(&ab->dp.tx_ring[i].tx_idr_lock); in ath11k_mac_op_remove_interface()
6503 idr_for_each(&ab->dp.tx_ring[i].txbuf_idr, in ath11k_mac_op_remove_interface()
6505 spin_unlock_bh(&ab->dp.tx_ring[i].tx_idr_lock); in ath11k_mac_op_remove_interface()
6515 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_remove_interface()
6533 struct ath11k *ar = hw->priv; in ath11k_mac_op_configure_filter()
6535 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_configure_filter()
6538 ar->filter_flags = *total_flags; in ath11k_mac_op_configure_filter()
6540 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_configure_filter()
6545 struct ath11k *ar = hw->priv; in ath11k_mac_op_get_antenna()
6547 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_get_antenna()
6549 *tx_ant = ar->cfg_tx_chainmask; in ath11k_mac_op_get_antenna()
6550 *rx_ant = ar->cfg_rx_chainmask; in ath11k_mac_op_get_antenna()
6552 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_get_antenna()
6559 struct ath11k *ar = hw->priv; in ath11k_mac_op_set_antenna()
6562 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_antenna()
6564 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_antenna()
6573 struct ath11k *ar = hw->priv; in ath11k_mac_op_ampdu_action()
6574 int ret = -EINVAL; in ath11k_mac_op_ampdu_action()
6576 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_ampdu_action()
6578 switch (params->action) { in ath11k_mac_op_ampdu_action()
6590 /* Tx A-MPDU aggregation offloaded to hw/fw so deny mac80211 in ath11k_mac_op_ampdu_action()
6593 ret = -EOPNOTSUPP; in ath11k_mac_op_ampdu_action()
6597 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_ampdu_action()
6605 struct ath11k *ar = hw->priv; in ath11k_mac_op_add_chanctx()
6606 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_add_chanctx()
6609 "mac chanctx add freq %u width %d ptr %pK\n", in ath11k_mac_op_add_chanctx()
6610 ctx->def.chan->center_freq, ctx->def.width, ctx); in ath11k_mac_op_add_chanctx()
6612 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_add_chanctx()
6614 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_add_chanctx()
6618 ar->rx_channel = ctx->def.chan; in ath11k_mac_op_add_chanctx()
6619 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_add_chanctx()
6621 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_add_chanctx()
6629 struct ath11k *ar = hw->priv; in ath11k_mac_op_remove_chanctx()
6630 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_remove_chanctx()
6633 "mac chanctx remove freq %u width %d ptr %pK\n", in ath11k_mac_op_remove_chanctx()
6634 ctx->def.chan->center_freq, ctx->def.width, ctx); in ath11k_mac_op_remove_chanctx()
6636 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_remove_chanctx()
6638 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_remove_chanctx()
6642 ar->rx_channel = NULL; in ath11k_mac_op_remove_chanctx()
6643 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_remove_chanctx()
6645 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_remove_chanctx()
6653 struct ath11k *ar = arvif->ar; in ath11k_mac_vdev_start_restart()
6654 struct ath11k_base *ab = ar->ab; in ath11k_mac_vdev_start_restart()
6656 const struct cfg80211_chan_def *chandef = &ctx->def; in ath11k_mac_vdev_start_restart()
6657 int he_support = arvif->vif->bss_conf.he_support; in ath11k_mac_vdev_start_restart()
6660 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_vdev_start_restart()
6662 reinit_completion(&ar->vdev_setup_done); in ath11k_mac_vdev_start_restart()
6664 arg.vdev_id = arvif->vdev_id; in ath11k_mac_vdev_start_restart()
6665 arg.dtim_period = arvif->dtim_period; in ath11k_mac_vdev_start_restart()
6666 arg.bcn_intval = arvif->beacon_interval; in ath11k_mac_vdev_start_restart()
6668 arg.channel.freq = chandef->chan->center_freq; in ath11k_mac_vdev_start_restart()
6669 arg.channel.band_center_freq1 = chandef->center_freq1; in ath11k_mac_vdev_start_restart()
6670 arg.channel.band_center_freq2 = chandef->center_freq2; in ath11k_mac_vdev_start_restart()
6672 ath11k_phymodes[chandef->chan->band][chandef->width]; in ath11k_mac_vdev_start_restart()
6675 arg.channel.max_power = chandef->chan->max_power; in ath11k_mac_vdev_start_restart()
6676 arg.channel.max_reg_power = chandef->chan->max_reg_power; in ath11k_mac_vdev_start_restart()
6677 arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain; in ath11k_mac_vdev_start_restart()
6679 arg.pref_tx_streams = ar->num_tx_chains; in ath11k_mac_vdev_start_restart()
6680 arg.pref_rx_streams = ar->num_rx_chains; in ath11k_mac_vdev_start_restart()
6682 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath11k_mac_vdev_start_restart()
6683 arg.ssid = arvif->u.ap.ssid; in ath11k_mac_vdev_start_restart()
6684 arg.ssid_len = arvif->u.ap.ssid_len; in ath11k_mac_vdev_start_restart()
6685 arg.hidden_ssid = arvif->u.ap.hidden_ssid; in ath11k_mac_vdev_start_restart()
6689 !!(chandef->chan->flags & IEEE80211_CHAN_RADAR); in ath11k_mac_vdev_start_restart()
6691 arg.channel.freq2_radar = ctx->radar_enabled; in ath11k_mac_vdev_start_restart()
6695 spin_lock_bh(&ab->base_lock); in ath11k_mac_vdev_start_restart()
6696 arg.regdomain = ar->ab->dfs_region; in ath11k_mac_vdev_start_restart()
6697 spin_unlock_bh(&ab->base_lock); in ath11k_mac_vdev_start_restart()
6702 ath11k_warn(ar->ab, "failed to set he mode vdev %i\n", in ath11k_mac_vdev_start_restart()
6709 arg.channel.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR); in ath11k_mac_vdev_start_restart()
6718 ath11k_warn(ar->ab, "failed to %s WMI vdev %i\n", in ath11k_mac_vdev_start_restart()
6731 ar->num_started_vdevs++; in ath11k_mac_vdev_start_restart()
6734 arvif->vif->addr, arvif->vdev_id); in ath11k_mac_vdev_start_restart()
6743 if (arvif->vdev_type == WMI_VDEV_TYPE_AP && in ath11k_mac_vdev_start_restart()
6744 chandef->chan->dfs_cac_ms && in ath11k_mac_vdev_start_restart()
6745 chandef->chan->dfs_state == NL80211_DFS_USABLE) { in ath11k_mac_vdev_start_restart()
6746 set_bit(ATH11K_CAC_RUNNING, &ar->dev_flags); in ath11k_mac_vdev_start_restart()
6755 arvif->vdev_id, ret); in ath11k_mac_vdev_start_restart()
6762 struct ath11k *ar = arvif->ar; in ath11k_mac_vdev_stop()
6765 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_vdev_stop()
6767 reinit_completion(&ar->vdev_setup_done); in ath11k_mac_vdev_stop()
6769 ret = ath11k_wmi_vdev_stop(ar, arvif->vdev_id); in ath11k_mac_vdev_stop()
6771 ath11k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n", in ath11k_mac_vdev_stop()
6772 arvif->vdev_id, ret); in ath11k_mac_vdev_stop()
6778 ath11k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n", in ath11k_mac_vdev_stop()
6779 arvif->vdev_id, ret); in ath11k_mac_vdev_stop()
6783 WARN_ON(ar->num_started_vdevs == 0); in ath11k_mac_vdev_stop()
6785 ar->num_started_vdevs--; in ath11k_mac_vdev_stop()
6786 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "vdev %pM stopped, vdev_id %d\n", in ath11k_mac_vdev_stop()
6787 arvif->vif->addr, arvif->vdev_id); in ath11k_mac_vdev_stop()
6789 if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) { in ath11k_mac_vdev_stop()
6790 clear_bit(ATH11K_CAC_RUNNING, &ar->dev_flags); in ath11k_mac_vdev_stop()
6791 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "CAC Stopped for vdev %d\n", in ath11k_mac_vdev_stop()
6792 arvif->vdev_id); in ath11k_mac_vdev_stop()
6825 if (rcu_access_pointer(vif->bss_conf.chanctx_conf) != arg->ctx) in ath11k_mac_change_chanctx_cnt_iter()
6828 arg->n_vifs++; in ath11k_mac_change_chanctx_cnt_iter()
6838 ctx = rcu_access_pointer(vif->bss_conf.chanctx_conf); in ath11k_mac_change_chanctx_fill_iter()
6839 if (ctx != arg->ctx) in ath11k_mac_change_chanctx_fill_iter()
6842 if (WARN_ON(arg->next_vif == arg->n_vifs)) in ath11k_mac_change_chanctx_fill_iter()
6845 arg->vifs[arg->next_vif].vif = vif; in ath11k_mac_change_chanctx_fill_iter()
6846 arg->vifs[arg->next_vif].old_ctx = ctx; in ath11k_mac_change_chanctx_fill_iter()
6847 arg->vifs[arg->next_vif].new_ctx = ctx; in ath11k_mac_change_chanctx_fill_iter()
6848 arg->next_vif++; in ath11k_mac_change_chanctx_fill_iter()
6856 struct ath11k_base *ab = ar->ab; in ath11k_mac_update_vif_chan()
6862 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_update_vif_chan()
6868 /* TODO: Update ar->rx_channel */ in ath11k_mac_update_vif_chan()
6871 arvif = (void *)vifs[i].vif->drv_priv; in ath11k_mac_update_vif_chan()
6873 if (WARN_ON(!arvif->is_started)) in ath11k_mac_update_vif_chan()
6877 * ieee80211_start_ap->ieee80211_vif_use_channel-> in ath11k_mac_update_vif_chan()
6881 * If vdev is down then it expect vdev_stop->vdev_start. in ath11k_mac_update_vif_chan()
6883 if (arvif->is_up) { in ath11k_mac_update_vif_chan()
6887 arvif->vdev_id, ret); in ath11k_mac_update_vif_chan()
6894 arvif->vdev_id, ret); in ath11k_mac_update_vif_chan()
6901 arvif->vdev_id, ret); in ath11k_mac_update_vif_chan()
6911 ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, in ath11k_mac_update_vif_chan()
6912 arvif->bssid); in ath11k_mac_update_vif_chan()
6915 arvif->vdev_id, ret); in ath11k_mac_update_vif_chan()
6922 test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) { in ath11k_mac_update_vif_chan()
6925 ath11k_warn(ar->ab, "failed to stop monitor during vif channel update: %d", in ath11k_mac_update_vif_chan()
6932 ath11k_warn(ar->ab, "failed to start monitor during vif channel update: %d", in ath11k_mac_update_vif_chan()
6945 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_update_active_vif_chan()
6947 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath11k_mac_update_active_vif_chan()
6958 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath11k_mac_update_active_vif_chan()
6972 struct ath11k *ar = hw->priv; in ath11k_mac_op_change_chanctx()
6973 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_change_chanctx()
6975 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_change_chanctx()
6978 "mac chanctx change freq %u width %d ptr %pK changed %x\n", in ath11k_mac_op_change_chanctx()
6979 ctx->def.chan->center_freq, ctx->def.width, ctx, changed); in ath11k_mac_op_change_chanctx()
6994 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_change_chanctx()
7000 struct ath11k *ar = hw->priv; in ath11k_start_vdev_delay()
7001 struct ath11k_base *ab = ar->ab; in ath11k_start_vdev_delay()
7002 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_start_vdev_delay()
7005 if (WARN_ON(arvif->is_started)) in ath11k_start_vdev_delay()
7006 return -EBUSY; in ath11k_start_vdev_delay()
7008 ret = ath11k_mac_vdev_start(arvif, &arvif->chanctx); in ath11k_start_vdev_delay()
7011 arvif->vdev_id, vif->addr, in ath11k_start_vdev_delay()
7012 arvif->chanctx.def.chan->center_freq, ret); in ath11k_start_vdev_delay()
7018 if (ar->hw_rate_code > 0) { in ath11k_start_vdev_delay()
7021 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath11k_start_vdev_delay()
7022 ar->hw_rate_code); in ath11k_start_vdev_delay()
7024 ath11k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret); in ath11k_start_vdev_delay()
7029 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath11k_start_vdev_delay()
7030 ret = ath11k_wmi_vdev_up(ar, arvif->vdev_id, 0, ar->mac_addr); in ath11k_start_vdev_delay()
7037 arvif->is_started = true; in ath11k_start_vdev_delay()
7049 struct ath11k *ar = hw->priv; in ath11k_mac_op_assign_vif_chanctx()
7050 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_assign_vif_chanctx()
7051 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_assign_vif_chanctx()
7055 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_assign_vif_chanctx()
7059 ctx, arvif->vdev_id); in ath11k_mac_op_assign_vif_chanctx()
7062 if (ab->hw_params.vdev_start_delay && in ath11k_mac_op_assign_vif_chanctx()
7063 arvif->vdev_type != WMI_VDEV_TYPE_AP && in ath11k_mac_op_assign_vif_chanctx()
7064 arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath11k_mac_op_assign_vif_chanctx()
7065 !ath11k_peer_find_by_vdev_id(ab, arvif->vdev_id)) { in ath11k_mac_op_assign_vif_chanctx()
7066 memcpy(&arvif->chanctx, ctx, sizeof(*ctx)); in ath11k_mac_op_assign_vif_chanctx()
7071 if (WARN_ON(arvif->is_started)) { in ath11k_mac_op_assign_vif_chanctx()
7072 ret = -EBUSY; in ath11k_mac_op_assign_vif_chanctx()
7076 if (ab->hw_params.vdev_start_delay && in ath11k_mac_op_assign_vif_chanctx()
7077 arvif->vdev_type != WMI_VDEV_TYPE_AP && in ath11k_mac_op_assign_vif_chanctx()
7078 arvif->vdev_type != WMI_VDEV_TYPE_MONITOR) { in ath11k_mac_op_assign_vif_chanctx()
7079 param.vdev_id = arvif->vdev_id; in ath11k_mac_op_assign_vif_chanctx()
7081 param.peer_addr = ar->mac_addr; in ath11k_mac_op_assign_vif_chanctx()
7091 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath11k_mac_op_assign_vif_chanctx()
7094 ath11k_warn(ar->ab, "failed to start monitor during vif channel context assignment: %d", in ath11k_mac_op_assign_vif_chanctx()
7099 arvif->is_started = true; in ath11k_mac_op_assign_vif_chanctx()
7106 arvif->vdev_id, vif->addr, in ath11k_mac_op_assign_vif_chanctx()
7107 ctx->def.chan->center_freq, ret); in ath11k_mac_op_assign_vif_chanctx()
7111 arvif->is_started = true; in ath11k_mac_op_assign_vif_chanctx()
7113 if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath11k_mac_op_assign_vif_chanctx()
7114 test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) { in ath11k_mac_op_assign_vif_chanctx()
7117 ath11k_warn(ar->ab, "failed to start monitor during vif channel context assignment: %d", in ath11k_mac_op_assign_vif_chanctx()
7128 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_assign_vif_chanctx()
7139 struct ath11k *ar = hw->priv; in ath11k_mac_op_unassign_vif_chanctx()
7140 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_unassign_vif_chanctx()
7141 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_unassign_vif_chanctx()
7145 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_unassign_vif_chanctx()
7149 ctx, arvif->vdev_id); in ath11k_mac_op_unassign_vif_chanctx()
7151 WARN_ON(!arvif->is_started); in ath11k_mac_op_unassign_vif_chanctx()
7153 if (ab->hw_params.vdev_start_delay && in ath11k_mac_op_unassign_vif_chanctx()
7154 arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath11k_mac_op_unassign_vif_chanctx()
7155 spin_lock_bh(&ab->base_lock); in ath11k_mac_op_unassign_vif_chanctx()
7156 peer = ath11k_peer_find_by_addr(ab, ar->mac_addr); in ath11k_mac_op_unassign_vif_chanctx()
7157 spin_unlock_bh(&ab->base_lock); in ath11k_mac_op_unassign_vif_chanctx()
7159 ath11k_peer_delete(ar, arvif->vdev_id, ar->mac_addr); in ath11k_mac_op_unassign_vif_chanctx()
7162 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath11k_mac_op_unassign_vif_chanctx()
7165 ath11k_warn(ar->ab, "failed to stop monitor during vif channel context unassignment: %d", in ath11k_mac_op_unassign_vif_chanctx()
7167 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_unassign_vif_chanctx()
7171 arvif->is_started = false; in ath11k_mac_op_unassign_vif_chanctx()
7172 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_unassign_vif_chanctx()
7179 arvif->vdev_id, ret); in ath11k_mac_op_unassign_vif_chanctx()
7181 arvif->is_started = false; in ath11k_mac_op_unassign_vif_chanctx()
7183 if (ab->hw_params.vdev_start_delay && in ath11k_mac_op_unassign_vif_chanctx()
7184 arvif->vdev_type == WMI_VDEV_TYPE_STA) { in ath11k_mac_op_unassign_vif_chanctx()
7185 ret = ath11k_peer_delete(ar, arvif->vdev_id, arvif->bssid); in ath11k_mac_op_unassign_vif_chanctx()
7187 ath11k_warn(ar->ab, in ath11k_mac_op_unassign_vif_chanctx()
7189 arvif->bssid, arvif->vdev_id, ret); in ath11k_mac_op_unassign_vif_chanctx()
7191 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_unassign_vif_chanctx()
7193 arvif->bssid, arvif->vdev_id); in ath11k_mac_op_unassign_vif_chanctx()
7196 if (ab->hw_params.vdev_start_delay && in ath11k_mac_op_unassign_vif_chanctx()
7197 arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) in ath11k_mac_op_unassign_vif_chanctx()
7198 ath11k_wmi_vdev_down(ar, arvif->vdev_id); in ath11k_mac_op_unassign_vif_chanctx()
7200 if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath11k_mac_op_unassign_vif_chanctx()
7201 ar->num_started_vdevs == 1 && in ath11k_mac_op_unassign_vif_chanctx()
7202 test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) { in ath11k_mac_op_unassign_vif_chanctx()
7206 ath11k_warn(ar->ab, "failed to stop monitor during vif channel context unassignment: %d", in ath11k_mac_op_unassign_vif_chanctx()
7210 if (arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath11k_mac_op_unassign_vif_chanctx()
7211 ath11k_mac_11d_scan_start(ar, arvif->vdev_id); in ath11k_mac_op_unassign_vif_chanctx()
7213 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_unassign_vif_chanctx()
7222 struct ath11k *ar = hw->priv; in ath11k_mac_op_switch_vif_chanctx()
7224 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_switch_vif_chanctx()
7226 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_switch_vif_chanctx()
7231 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_switch_vif_chanctx()
7242 mutex_lock(&ar->conf_mutex); in ath11k_set_vdev_param_to_all_vifs()
7243 list_for_each_entry(arvif, &ar->arvifs, list) { in ath11k_set_vdev_param_to_all_vifs()
7244 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "setting mac vdev %d param %d value %d\n", in ath11k_set_vdev_param_to_all_vifs()
7245 param, arvif->vdev_id, value); in ath11k_set_vdev_param_to_all_vifs()
7247 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_set_vdev_param_to_all_vifs()
7250 ath11k_warn(ar->ab, "failed to set param %d for vdev %d: %d\n", in ath11k_set_vdev_param_to_all_vifs()
7251 param, arvif->vdev_id, ret); in ath11k_set_vdev_param_to_all_vifs()
7255 mutex_unlock(&ar->conf_mutex); in ath11k_set_vdev_param_to_all_vifs()
7264 struct ath11k *ar = hw->priv; in ath11k_mac_op_set_rts_threshold()
7282 return -EOPNOTSUPP; in ath11k_mac_op_set_frag_threshold()
7290 time_left = wait_event_timeout(ar->dp.tx_empty_waitq, in ath11k_mac_flush_tx_complete()
7291 (atomic_read(&ar->dp.num_tx_pending) == 0), in ath11k_mac_flush_tx_complete()
7294 ath11k_warn(ar->ab, "failed to flush transmit queue, data pkts pending %d\n", in ath11k_mac_flush_tx_complete()
7295 atomic_read(&ar->dp.num_tx_pending)); in ath11k_mac_flush_tx_complete()
7296 ret = -ETIMEDOUT; in ath11k_mac_flush_tx_complete()
7299 time_left = wait_event_timeout(ar->txmgmt_empty_waitq, in ath11k_mac_flush_tx_complete()
7300 (atomic_read(&ar->num_pending_mgmt_tx) == 0), in ath11k_mac_flush_tx_complete()
7303 ath11k_warn(ar->ab, "failed to flush mgmt transmit queue, mgmt pkts pending %d\n", in ath11k_mac_flush_tx_complete()
7304 atomic_read(&ar->num_pending_mgmt_tx)); in ath11k_mac_flush_tx_complete()
7305 ret = -ETIMEDOUT; in ath11k_mac_flush_tx_complete()
7320 struct ath11k *ar = hw->priv; in ath11k_mac_op_flush()
7336 for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) in ath11k_mac_bitrate_mask_num_ht_rates()
7337 num_rates += hweight16(mask->control[band].ht_mcs[i]); in ath11k_mac_bitrate_mask_num_ht_rates()
7349 num_rates = hweight32(mask->control[band].legacy); in ath11k_mac_has_single_legacy_rate()
7366 if (he_cap->he_cap_elem.phy_cap_info[0] & in ath11k_mac_get_tx_mcs_map()
7368 return he_cap->he_mcs_nss_supp.tx_mcs_80p80; in ath11k_mac_get_tx_mcs_map()
7370 if (he_cap->he_cap_elem.phy_cap_info[0] & in ath11k_mac_get_tx_mcs_map()
7372 return he_cap->he_mcs_nss_supp.tx_mcs_160; in ath11k_mac_get_tx_mcs_map()
7374 return he_cap->he_mcs_nss_supp.tx_mcs_80; in ath11k_mac_get_tx_mcs_map()
7383 struct ieee80211_supported_band *sband = &ar->mac.sbands[band]; in ath11k_mac_bitrate_mask_get_single_nss()
7384 u16 vht_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map); in ath11k_mac_bitrate_mask_get_single_nss()
7395 for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) { in ath11k_mac_bitrate_mask_get_single_nss()
7396 if (mask->control[band].ht_mcs[i] == 0) in ath11k_mac_bitrate_mask_get_single_nss()
7398 else if (mask->control[band].ht_mcs[i] == in ath11k_mac_bitrate_mask_get_single_nss()
7399 sband->ht_cap.mcs.rx_mask[i]) in ath11k_mac_bitrate_mask_get_single_nss()
7405 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) { in ath11k_mac_bitrate_mask_get_single_nss()
7406 if (mask->control[band].vht_mcs[i] == 0) in ath11k_mac_bitrate_mask_get_single_nss()
7408 else if (mask->control[band].vht_mcs[i] == in ath11k_mac_bitrate_mask_get_single_nss()
7415 he_mcs_map = le16_to_cpu(ath11k_mac_get_tx_mcs_map(&sband->iftype_data->he_cap)); in ath11k_mac_bitrate_mask_get_single_nss()
7417 for (i = 0; i < ARRAY_SIZE(mask->control[band].he_mcs); i++) { in ath11k_mac_bitrate_mask_get_single_nss()
7418 if (mask->control[band].he_mcs[i] == 0) in ath11k_mac_bitrate_mask_get_single_nss()
7421 if (mask->control[band].he_mcs[i] == in ath11k_mac_bitrate_mask_get_single_nss()
7434 if (BIT(fls(ht_nss_mask)) - 1 != ht_nss_mask) in ath11k_mac_bitrate_mask_get_single_nss()
7453 if (hweight32(mask->control[band].legacy) != 1) in ath11k_mac_get_single_legacy_rate()
7454 return -EINVAL; in ath11k_mac_get_single_legacy_rate()
7456 rate_idx = ffs(mask->control[band].legacy) - 1; in ath11k_mac_get_single_legacy_rate()
7478 struct ath11k *ar = arvif->ar; in ath11k_mac_set_fixed_rate_gi_ltf()
7485 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_fixed_rate_gi_ltf()
7488 ath11k_warn(ar->ab, "failed to set he gi %d: %d\n", in ath11k_mac_set_fixed_rate_gi_ltf()
7496 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_fixed_rate_gi_ltf()
7499 ath11k_warn(ar->ab, "failed to set he ltf %d: %d\n", in ath11k_mac_set_fixed_rate_gi_ltf()
7510 struct ath11k *ar = arvif->ar; in ath11k_mac_set_auto_rate_gi_ltf()
7526 ath11k_warn(ar->ab, "invalid he gi: %d\n", he_gi); in ath11k_mac_set_auto_rate_gi_ltf()
7527 return -EINVAL; in ath11k_mac_set_auto_rate_gi_ltf()
7543 ath11k_warn(ar->ab, "invalid he ltf: %d\n", he_ltf); in ath11k_mac_set_auto_rate_gi_ltf()
7544 return -EINVAL; in ath11k_mac_set_auto_rate_gi_ltf()
7549 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_auto_rate_gi_ltf()
7553 ath11k_warn(ar->ab, in ath11k_mac_set_auto_rate_gi_ltf()
7566 struct ath11k *ar = arvif->ar; in ath11k_mac_set_rate_params()
7570 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_set_rate_params()
7572 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_set_rate_params()
7574 arvif->vdev_id, rate, nss, sgi, ldpc, he_gi, in ath11k_mac_set_rate_params()
7577 if (!arvif->vif->bss_conf.he_support) { in ath11k_mac_set_rate_params()
7579 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_rate_params()
7582 ath11k_warn(ar->ab, "failed to set fixed rate param 0x%02x: %d\n", in ath11k_mac_set_rate_params()
7589 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_rate_params()
7592 ath11k_warn(ar->ab, "failed to set nss param %d: %d\n", in ath11k_mac_set_rate_params()
7598 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_rate_params()
7601 ath11k_warn(ar->ab, "failed to set ldpc param %d: %d\n", in ath11k_mac_set_rate_params()
7606 if (arvif->vif->bss_conf.he_support) { in ath11k_mac_set_rate_params()
7611 ath11k_warn(ar->ab, "failed to set fixed rate gi ltf: %d\n", in ath11k_mac_set_rate_params()
7619 ath11k_warn(ar->ab, "failed to set auto rate gi ltf: %d\n", in ath11k_mac_set_rate_params()
7626 ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath11k_mac_set_rate_params()
7629 ath11k_warn(ar->ab, "failed to set sgi param %d: %d\n", in ath11k_mac_set_rate_params()
7647 vht_mcs = mask->control[band].vht_mcs[i]; in ath11k_mac_vht_mcs_range_present()
7651 case BIT(8) - 1: in ath11k_mac_vht_mcs_range_present()
7652 case BIT(9) - 1: in ath11k_mac_vht_mcs_range_present()
7653 case BIT(10) - 1: in ath11k_mac_vht_mcs_range_present()
7672 he_mcs = mask->control[band].he_mcs[i]; in ath11k_mac_he_mcs_range_present()
7676 case BIT(8) - 1: in ath11k_mac_he_mcs_range_present()
7677 case BIT(10) - 1: in ath11k_mac_he_mcs_range_present()
7678 case BIT(12) - 1: in ath11k_mac_he_mcs_range_present()
7692 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_set_bitrate_mask_iter()
7693 struct ath11k *ar = arvif->ar; in ath11k_mac_set_bitrate_mask_iter()
7695 spin_lock_bh(&ar->data_lock); in ath11k_mac_set_bitrate_mask_iter()
7696 arsta->changed |= IEEE80211_RC_SUPP_RATES_CHANGED; in ath11k_mac_set_bitrate_mask_iter()
7697 spin_unlock_bh(&ar->data_lock); in ath11k_mac_set_bitrate_mask_iter()
7699 ieee80211_queue_work(ar->hw, &arsta->update_wk); in ath11k_mac_set_bitrate_mask_iter()
7706 struct ath11k *ar = arvif->ar; in ath11k_mac_disable_peer_fixed_rate()
7709 ret = ath11k_wmi_set_peer_param(ar, sta->addr, in ath11k_mac_disable_peer_fixed_rate()
7710 arvif->vdev_id, in ath11k_mac_disable_peer_fixed_rate()
7714 ath11k_warn(ar->ab, in ath11k_mac_disable_peer_fixed_rate()
7716 sta->addr, ret); in ath11k_mac_disable_peer_fixed_rate()
7730 vht_mcs_mask = mask->control[band].vht_mcs; in ath11k_mac_validate_vht_he_fixed_rate_settings()
7731 he_mcs_mask = mask->control[band].he_mcs; in ath11k_mac_validate_vht_he_fixed_rate_settings()
7746 spin_lock_bh(&ar->ab->base_lock); in ath11k_mac_validate_vht_he_fixed_rate_settings()
7747 list_for_each_entry_safe(peer, tmp, &ar->ab->peers, list) { in ath11k_mac_validate_vht_he_fixed_rate_settings()
7748 if (peer->sta) { in ath11k_mac_validate_vht_he_fixed_rate_settings()
7749 deflink = &peer->sta->deflink; in ath11k_mac_validate_vht_he_fixed_rate_settings()
7751 if (vht_fixed_rate && (!deflink->vht_cap.vht_supported || in ath11k_mac_validate_vht_he_fixed_rate_settings()
7752 deflink->rx_nss < vht_nss)) { in ath11k_mac_validate_vht_he_fixed_rate_settings()
7757 if (he_fixed_rate && (!deflink->he_cap.has_he || in ath11k_mac_validate_vht_he_fixed_rate_settings()
7758 deflink->rx_nss < he_nss)) { in ath11k_mac_validate_vht_he_fixed_rate_settings()
7766 spin_unlock_bh(&ar->ab->base_lock); in ath11k_mac_validate_vht_he_fixed_rate_settings()
7776 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_set_bitrate_mask()
7779 struct ath11k *ar = arvif->ar; in ath11k_mac_op_set_bitrate_mask()
7796 return -EPERM; in ath11k_mac_op_set_bitrate_mask()
7798 band = def.chan->band; in ath11k_mac_op_set_bitrate_mask()
7799 cap = &ar->pdev->cap; in ath11k_mac_op_set_bitrate_mask()
7800 ht_mcs_mask = mask->control[band].ht_mcs; in ath11k_mac_op_set_bitrate_mask()
7801 vht_mcs_mask = mask->control[band].vht_mcs; in ath11k_mac_op_set_bitrate_mask()
7802 he_mcs_mask = mask->control[band].he_mcs; in ath11k_mac_op_set_bitrate_mask()
7803 ldpc = !!(cap->band[band].ht_cap_info & WMI_HT_CAP_TX_LDPC); in ath11k_mac_op_set_bitrate_mask()
7805 sgi = mask->control[band].gi; in ath11k_mac_op_set_bitrate_mask()
7807 return -EINVAL; in ath11k_mac_op_set_bitrate_mask()
7809 he_gi = mask->control[band].he_gi; in ath11k_mac_op_set_bitrate_mask()
7810 he_ltf = mask->control[band].he_ltf; in ath11k_mac_op_set_bitrate_mask()
7824 ath11k_warn(ar->ab, "failed to get single legacy rate for vdev %i: %d\n", in ath11k_mac_op_set_bitrate_mask()
7825 arvif->vdev_id, ret); in ath11k_mac_op_set_bitrate_mask()
7828 ieee80211_iterate_stations_atomic(ar->hw, in ath11k_mac_op_set_bitrate_mask()
7835 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_bitrate_mask()
7836 arvif->bitrate_mask = *mask; in ath11k_mac_op_set_bitrate_mask()
7837 ieee80211_iterate_stations_atomic(ar->hw, in ath11k_mac_op_set_bitrate_mask()
7840 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_bitrate_mask()
7845 ath11k_warn(ar->ab, in ath11k_mac_op_set_bitrate_mask()
7847 nss = min_t(u32, ar->num_tx_chains, in ath11k_mac_op_set_bitrate_mask()
7855 * - Single VHT Rate : peer_assoc command accommodates only MCS in ath11k_mac_op_set_bitrate_mask()
7856 * range values i.e 0-7, 0-8, 0-9 for VHT. Though mac80211 in ath11k_mac_op_set_bitrate_mask()
7864 * - Multiple VHT Rates : When Multiple VHT rates are given,this in ath11k_mac_op_set_bitrate_mask()
7865 * can be set using RATEMASK CMD which uses FW rate-ctl alg. in ath11k_mac_op_set_bitrate_mask()
7880 ath11k_warn(ar->ab, in ath11k_mac_op_set_bitrate_mask()
7883 return -EINVAL; in ath11k_mac_op_set_bitrate_mask()
7893 ath11k_warn(ar->ab, in ath11k_mac_op_set_bitrate_mask()
7895 return -EINVAL; in ath11k_mac_op_set_bitrate_mask()
7898 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_bitrate_mask()
7899 ieee80211_iterate_stations_atomic(ar->hw, in ath11k_mac_op_set_bitrate_mask()
7903 arvif->bitrate_mask = *mask; in ath11k_mac_op_set_bitrate_mask()
7904 ieee80211_iterate_stations_atomic(ar->hw, in ath11k_mac_op_set_bitrate_mask()
7908 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_bitrate_mask()
7911 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_bitrate_mask()
7916 ath11k_warn(ar->ab, "failed to set rate params on vdev %i: %d\n", in ath11k_mac_op_set_bitrate_mask()
7917 arvif->vdev_id, ret); in ath11k_mac_op_set_bitrate_mask()
7920 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_bitrate_mask()
7929 struct ath11k *ar = hw->priv; in ath11k_mac_op_reconfig_complete()
7930 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_reconfig_complete()
7936 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_reconfig_complete()
7938 if (ar->state == ATH11K_STATE_RESTARTED) { in ath11k_mac_op_reconfig_complete()
7939 ath11k_warn(ar->ab, "pdev %d successfully recovered\n", in ath11k_mac_op_reconfig_complete()
7940 ar->pdev->pdev_id); in ath11k_mac_op_reconfig_complete()
7941 ar->state = ATH11K_STATE_ON; in ath11k_mac_op_reconfig_complete()
7942 ieee80211_wake_queues(ar->hw); in ath11k_mac_op_reconfig_complete()
7944 if (ar->ab->hw_params.current_cc_support && in ath11k_mac_op_reconfig_complete()
7945 ar->alpha2[0] != 0 && ar->alpha2[1] != 0) { in ath11k_mac_op_reconfig_complete()
7948 memcpy(&set_current_param.alpha2, ar->alpha2, 2); in ath11k_mac_op_reconfig_complete()
7952 if (ab->is_reset) { in ath11k_mac_op_reconfig_complete()
7953 recovery_count = atomic_inc_return(&ab->recovery_count); in ath11k_mac_op_reconfig_complete()
7959 if (recovery_count == ab->num_radios) { in ath11k_mac_op_reconfig_complete()
7960 atomic_dec(&ab->reset_count); in ath11k_mac_op_reconfig_complete()
7961 complete(&ab->reset_complete); in ath11k_mac_op_reconfig_complete()
7962 ab->is_reset = false; in ath11k_mac_op_reconfig_complete()
7963 atomic_set(&ab->fail_cont_count, 0); in ath11k_mac_op_reconfig_complete()
7969 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_reconfig_complete()
7979 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_update_bss_chan_survey()
7981 if (!test_bit(WMI_TLV_SERVICE_BSS_CHANNEL_INFO_64, ar->ab->wmi_ab.svc_map) || in ath11k_mac_update_bss_chan_survey()
7982 ar->rx_channel != channel) in ath11k_mac_update_bss_chan_survey()
7985 if (ar->scan.state != ATH11K_SCAN_IDLE) { in ath11k_mac_update_bss_chan_survey()
7986 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_update_bss_chan_survey()
7991 reinit_completion(&ar->bss_survey_done); in ath11k_mac_update_bss_chan_survey()
7995 ath11k_warn(ar->ab, "failed to send pdev bss chan info request\n"); in ath11k_mac_update_bss_chan_survey()
7999 ret = wait_for_completion_timeout(&ar->bss_survey_done, 3 * HZ); in ath11k_mac_update_bss_chan_survey()
8001 ath11k_warn(ar->ab, "bss channel survey timed out\n"); in ath11k_mac_update_bss_chan_survey()
8007 struct ath11k *ar = hw->priv; in ath11k_mac_op_get_survey()
8013 return -ENOENT; in ath11k_mac_op_get_survey()
8015 ar_survey = &ar->survey[idx]; in ath11k_mac_op_get_survey()
8017 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_get_survey()
8019 sband = hw->wiphy->bands[NL80211_BAND_2GHZ]; in ath11k_mac_op_get_survey()
8020 if (sband && idx >= sband->n_channels) { in ath11k_mac_op_get_survey()
8021 idx -= sband->n_channels; in ath11k_mac_op_get_survey()
8026 sband = hw->wiphy->bands[NL80211_BAND_5GHZ]; in ath11k_mac_op_get_survey()
8027 if (sband && idx >= sband->n_channels) { in ath11k_mac_op_get_survey()
8028 idx -= sband->n_channels; in ath11k_mac_op_get_survey()
8033 sband = hw->wiphy->bands[NL80211_BAND_6GHZ]; in ath11k_mac_op_get_survey()
8034 if (!sband || idx >= sband->n_channels) { in ath11k_mac_op_get_survey()
8035 ret = -ENOENT; in ath11k_mac_op_get_survey()
8039 ath11k_mac_update_bss_chan_survey(ar, &sband->channels[idx]); in ath11k_mac_op_get_survey()
8041 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_get_survey()
8043 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_get_survey()
8045 survey->channel = &sband->channels[idx]; in ath11k_mac_op_get_survey()
8047 if (ar->rx_channel == survey->channel) in ath11k_mac_op_get_survey()
8048 survey->filled |= SURVEY_INFO_IN_USE; in ath11k_mac_op_get_survey()
8051 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_get_survey()
8060 struct ath11k *ar = arsta->arvif->ar; in ath11k_mac_put_chain_rssi()
8064 for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) { in ath11k_mac_put_chain_rssi()
8065 sinfo->chains &= ~BIT(i); in ath11k_mac_put_chain_rssi()
8066 rssi = arsta->chain_signal[i]; in ath11k_mac_put_chain_rssi()
8068 arsta->chain_signal[i] = ATH11K_INVALID_RSSI_FULL; in ath11k_mac_put_chain_rssi()
8070 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_put_chain_rssi()
8077 sinfo->chain_signal[i] = rssi; in ath11k_mac_put_chain_rssi()
8078 sinfo->chains |= BIT(i); in ath11k_mac_put_chain_rssi()
8079 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL); in ath11k_mac_put_chain_rssi()
8089 struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv; in ath11k_mac_op_sta_statistics()
8090 struct ath11k *ar = arsta->arvif->ar; in ath11k_mac_op_sta_statistics()
8093 ar->ab->wmi_ab.svc_map); in ath11k_mac_op_sta_statistics()
8095 sinfo->rx_duration = arsta->rx_duration; in ath11k_mac_op_sta_statistics()
8096 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in ath11k_mac_op_sta_statistics()
8098 sinfo->tx_duration = arsta->tx_duration; in ath11k_mac_op_sta_statistics()
8099 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in ath11k_mac_op_sta_statistics()
8101 if (arsta->txrate.legacy || arsta->txrate.nss) { in ath11k_mac_op_sta_statistics()
8102 if (arsta->txrate.legacy) { in ath11k_mac_op_sta_statistics()
8103 sinfo->txrate.legacy = arsta->txrate.legacy; in ath11k_mac_op_sta_statistics()
8105 sinfo->txrate.mcs = arsta->txrate.mcs; in ath11k_mac_op_sta_statistics()
8106 sinfo->txrate.nss = arsta->txrate.nss; in ath11k_mac_op_sta_statistics()
8107 sinfo->txrate.bw = arsta->txrate.bw; in ath11k_mac_op_sta_statistics()
8108 sinfo->txrate.he_gi = arsta->txrate.he_gi; in ath11k_mac_op_sta_statistics()
8109 sinfo->txrate.he_dcm = arsta->txrate.he_dcm; in ath11k_mac_op_sta_statistics()
8110 sinfo->txrate.he_ru_alloc = arsta->txrate.he_ru_alloc; in ath11k_mac_op_sta_statistics()
8112 sinfo->txrate.flags = arsta->txrate.flags; in ath11k_mac_op_sta_statistics()
8113 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in ath11k_mac_op_sta_statistics()
8118 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL)) && in ath11k_mac_op_sta_statistics()
8119 arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA && in ath11k_mac_op_sta_statistics()
8120 ar->ab->hw_params.supports_rssi_stats && in ath11k_mac_op_sta_statistics()
8121 !ath11k_debugfs_get_fw_stats(ar, ar->pdev->pdev_id, 0, in ath11k_mac_op_sta_statistics()
8126 signal = arsta->rssi_comb; in ath11k_mac_op_sta_statistics()
8128 arsta->arvif->vdev_type == WMI_VDEV_TYPE_STA && in ath11k_mac_op_sta_statistics()
8129 ar->ab->hw_params.supports_rssi_stats && in ath11k_mac_op_sta_statistics()
8130 !(ath11k_debugfs_get_fw_stats(ar, ar->pdev->pdev_id, 0, in ath11k_mac_op_sta_statistics()
8132 signal = arsta->rssi_beacon; in ath11k_mac_op_sta_statistics()
8134 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, in ath11k_mac_op_sta_statistics()
8136 db2dbm, arsta->rssi_comb, arsta->rssi_beacon); in ath11k_mac_op_sta_statistics()
8139 sinfo->signal = db2dbm ? signal : signal + ATH11K_DEFAULT_NOISE_FLOOR; in ath11k_mac_op_sta_statistics()
8140 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in ath11k_mac_op_sta_statistics()
8143 sinfo->signal_avg = ewma_avg_rssi_read(&arsta->avg_rssi) + in ath11k_mac_op_sta_statistics()
8145 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG); in ath11k_mac_op_sta_statistics()
8154 for (i = 0; i < offload->ipv6_count; i++) { in ath11k_generate_ns_mc_addr()
8155 offload->self_ipv6_addr[i][0] = 0xff; in ath11k_generate_ns_mc_addr()
8156 offload->self_ipv6_addr[i][1] = 0x02; in ath11k_generate_ns_mc_addr()
8157 offload->self_ipv6_addr[i][11] = 0x01; in ath11k_generate_ns_mc_addr()
8158 offload->self_ipv6_addr[i][12] = 0xff; in ath11k_generate_ns_mc_addr()
8159 offload->self_ipv6_addr[i][13] = in ath11k_generate_ns_mc_addr()
8160 offload->ipv6_addr[i][13]; in ath11k_generate_ns_mc_addr()
8161 offload->self_ipv6_addr[i][14] = in ath11k_generate_ns_mc_addr()
8162 offload->ipv6_addr[i][14]; in ath11k_generate_ns_mc_addr()
8163 offload->self_ipv6_addr[i][15] = in ath11k_generate_ns_mc_addr()
8164 offload->ipv6_addr[i][15]; in ath11k_generate_ns_mc_addr()
8165 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "NS solicited addr %pI6\n", in ath11k_generate_ns_mc_addr()
8166 offload->self_ipv6_addr[i]); in ath11k_generate_ns_mc_addr()
8174 struct ath11k *ar = hw->priv; in ath11k_mac_op_ipv6_changed()
8182 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac op ipv6 changed\n"); in ath11k_mac_op_ipv6_changed()
8184 offload = &arvif->arp_ns_offload; in ath11k_mac_op_ipv6_changed()
8187 read_lock_bh(&idev->lock); in ath11k_mac_op_ipv6_changed()
8189 memset(offload->ipv6_addr, 0, sizeof(offload->ipv6_addr)); in ath11k_mac_op_ipv6_changed()
8190 memset(offload->self_ipv6_addr, 0, sizeof(offload->self_ipv6_addr)); in ath11k_mac_op_ipv6_changed()
8191 memcpy(offload->mac_addr, vif->addr, ETH_ALEN); in ath11k_mac_op_ipv6_changed()
8194 list_for_each(p, &idev->addr_list) { in ath11k_mac_op_ipv6_changed()
8199 if (ifa6->flags & IFA_F_DADFAILED) in ath11k_mac_op_ipv6_changed()
8201 scope = ipv6_addr_src_scope(&ifa6->addr); in ath11k_mac_op_ipv6_changed()
8204 memcpy(offload->ipv6_addr[count], &ifa6->addr.s6_addr, in ath11k_mac_op_ipv6_changed()
8205 sizeof(ifa6->addr.s6_addr)); in ath11k_mac_op_ipv6_changed()
8206 offload->ipv6_type[count] = ATH11K_IPV6_UC_TYPE; in ath11k_mac_op_ipv6_changed()
8207 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac count %d ipv6 uc %pI6 scope %d\n", in ath11k_mac_op_ipv6_changed()
8208 count, offload->ipv6_addr[count], in ath11k_mac_op_ipv6_changed()
8212 ath11k_warn(ar->ab, "Unsupported ipv6 scope: %d\n", scope); in ath11k_mac_op_ipv6_changed()
8217 for (ifaca6 = idev->ac_list; ifaca6; ifaca6 = ifaca6->aca_next) { in ath11k_mac_op_ipv6_changed()
8221 scope = ipv6_addr_src_scope(&ifaca6->aca_addr); in ath11k_mac_op_ipv6_changed()
8224 memcpy(offload->ipv6_addr[count], &ifaca6->aca_addr, in ath11k_mac_op_ipv6_changed()
8225 sizeof(ifaca6->aca_addr)); in ath11k_mac_op_ipv6_changed()
8226 offload->ipv6_type[count] = ATH11K_IPV6_AC_TYPE; in ath11k_mac_op_ipv6_changed()
8227 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac count %d ipv6 ac %pI6 scope %d\n", in ath11k_mac_op_ipv6_changed()
8228 count, offload->ipv6_addr[count], in ath11k_mac_op_ipv6_changed()
8232 ath11k_warn(ar->ab, "Unsupported ipv scope: %d\n", scope); in ath11k_mac_op_ipv6_changed()
8237 offload->ipv6_count = count; in ath11k_mac_op_ipv6_changed()
8238 read_unlock_bh(&idev->lock); in ath11k_mac_op_ipv6_changed()
8249 struct ath11k *ar = hw->priv; in ath11k_mac_op_set_rekey_data()
8251 struct ath11k_rekey_data *rekey_data = &arvif->rekey_data; in ath11k_mac_op_set_rekey_data()
8253 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac set rekey data vdev %d\n", in ath11k_mac_op_set_rekey_data()
8254 arvif->vdev_id); in ath11k_mac_op_set_rekey_data()
8256 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_rekey_data()
8258 memcpy(rekey_data->kck, data->kck, NL80211_KCK_LEN); in ath11k_mac_op_set_rekey_data()
8259 memcpy(rekey_data->kek, data->kek, NL80211_KEK_LEN); in ath11k_mac_op_set_rekey_data()
8261 /* The supplicant works on big-endian, the firmware expects it on in ath11k_mac_op_set_rekey_data()
8264 rekey_data->replay_ctr = get_unaligned_be64(data->replay_ctr); in ath11k_mac_op_set_rekey_data()
8266 arvif->rekey_data.enable_offload = true; in ath11k_mac_op_set_rekey_data()
8268 ath11k_dbg_dump(ar->ab, ATH11K_DBG_MAC, "kck", NULL, in ath11k_mac_op_set_rekey_data()
8269 rekey_data->kck, NL80211_KCK_LEN); in ath11k_mac_op_set_rekey_data()
8270 ath11k_dbg_dump(ar->ab, ATH11K_DBG_MAC, "kek", NULL, in ath11k_mac_op_set_rekey_data()
8271 rekey_data->kck, NL80211_KEK_LEN); in ath11k_mac_op_set_rekey_data()
8272 ath11k_dbg_dump(ar->ab, ATH11K_DBG_MAC, "replay ctr", NULL, in ath11k_mac_op_set_rekey_data()
8273 &rekey_data->replay_ctr, sizeof(rekey_data->replay_ctr)); in ath11k_mac_op_set_rekey_data()
8275 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_rekey_data()
8281 struct ath11k *ar = hw->priv; in ath11k_mac_op_set_bios_sar_specs()
8287 if (!sar || sar->type != NL80211_SAR_TYPE_POWER || in ath11k_mac_op_set_bios_sar_specs()
8288 sar->num_sub_specs == 0) in ath11k_mac_op_set_bios_sar_specs()
8289 return -EINVAL; in ath11k_mac_op_set_bios_sar_specs()
8291 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_set_bios_sar_specs()
8293 if (!test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) || in ath11k_mac_op_set_bios_sar_specs()
8294 !ar->ab->hw_params.bios_sar_capa) { in ath11k_mac_op_set_bios_sar_specs()
8295 ret = -EOPNOTSUPP; in ath11k_mac_op_set_bios_sar_specs()
8301 ath11k_warn(ar->ab, "failed to set geo table: %d\n", ret); in ath11k_mac_op_set_bios_sar_specs()
8307 ret = -ENOMEM; in ath11k_mac_op_set_bios_sar_specs()
8311 sspec = sar->sub_specs; in ath11k_mac_op_set_bios_sar_specs()
8312 for (i = 0; i < sar->num_sub_specs; i++) { in ath11k_mac_op_set_bios_sar_specs()
8313 if (sspec->freq_range_index >= (BIOS_SAR_TABLE_LEN >> 1)) { in ath11k_mac_op_set_bios_sar_specs()
8314 ath11k_warn(ar->ab, "Ignore bad frequency index %u, max allowed %u\n", in ath11k_mac_op_set_bios_sar_specs()
8315 sspec->freq_range_index, BIOS_SAR_TABLE_LEN >> 1); in ath11k_mac_op_set_bios_sar_specs()
8320 sar_tbl[sspec->freq_range_index] = sspec->power; in ath11k_mac_op_set_bios_sar_specs()
8321 index = sspec->freq_range_index + (BIOS_SAR_TABLE_LEN >> 1); in ath11k_mac_op_set_bios_sar_specs()
8322 sar_tbl[index] = sspec->power; in ath11k_mac_op_set_bios_sar_specs()
8323 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "sar tbl[%d] = %d\n", in ath11k_mac_op_set_bios_sar_specs()
8324 sspec->freq_range_index, sar_tbl[sspec->freq_range_index]); in ath11k_mac_op_set_bios_sar_specs()
8330 ath11k_warn(ar->ab, "failed to set sar power: %d", ret); in ath11k_mac_op_set_bios_sar_specs()
8334 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_set_bios_sar_specs()
8342 struct ath11k *ar = hw->priv; in ath11k_mac_op_cancel_remain_on_channel()
8344 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_cancel_remain_on_channel()
8346 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_cancel_remain_on_channel()
8347 ar->scan.roc_notify = false; in ath11k_mac_op_cancel_remain_on_channel()
8348 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_cancel_remain_on_channel()
8352 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_cancel_remain_on_channel()
8354 cancel_delayed_work_sync(&ar->scan.timeout); in ath11k_mac_op_cancel_remain_on_channel()
8365 struct ath11k *ar = hw->priv; in ath11k_mac_op_remain_on_channel()
8366 struct ath11k_vif *arvif = (void *)vif->drv_priv; in ath11k_mac_op_remain_on_channel()
8371 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_remain_on_channel()
8373 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_remain_on_channel()
8374 switch (ar->scan.state) { in ath11k_mac_op_remain_on_channel()
8376 reinit_completion(&ar->scan.started); in ath11k_mac_op_remain_on_channel()
8377 reinit_completion(&ar->scan.completed); in ath11k_mac_op_remain_on_channel()
8378 reinit_completion(&ar->scan.on_channel); in ath11k_mac_op_remain_on_channel()
8379 ar->scan.state = ATH11K_SCAN_STARTING; in ath11k_mac_op_remain_on_channel()
8380 ar->scan.is_roc = true; in ath11k_mac_op_remain_on_channel()
8381 ar->scan.vdev_id = arvif->vdev_id; in ath11k_mac_op_remain_on_channel()
8382 ar->scan.roc_freq = chan->center_freq; in ath11k_mac_op_remain_on_channel()
8383 ar->scan.roc_notify = true; in ath11k_mac_op_remain_on_channel()
8389 ret = -EBUSY; in ath11k_mac_op_remain_on_channel()
8392 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_remain_on_channel()
8397 scan_time_msec = ar->hw->wiphy->max_remain_on_channel_duration * 2; in ath11k_mac_op_remain_on_channel()
8405 ret = -ENOMEM; in ath11k_mac_op_remain_on_channel()
8409 arg.vdev_id = arvif->vdev_id; in ath11k_mac_op_remain_on_channel()
8411 arg.chan_list[0] = chan->center_freq; in ath11k_mac_op_remain_on_channel()
8421 ath11k_warn(ar->ab, "failed to start roc scan: %d\n", ret); in ath11k_mac_op_remain_on_channel()
8423 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_remain_on_channel()
8424 ar->scan.state = ATH11K_SCAN_IDLE; in ath11k_mac_op_remain_on_channel()
8425 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_remain_on_channel()
8429 ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ); in ath11k_mac_op_remain_on_channel()
8431 ath11k_warn(ar->ab, "failed to switch to channel for roc scan\n"); in ath11k_mac_op_remain_on_channel()
8434 ath11k_warn(ar->ab, "failed to stop scan: %d\n", ret); in ath11k_mac_op_remain_on_channel()
8435 ret = -ETIMEDOUT; in ath11k_mac_op_remain_on_channel()
8439 ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout, in ath11k_mac_op_remain_on_channel()
8447 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_remain_on_channel()
8454 struct ath11k_base *ab = ar->ab; in ath11k_fw_stats_request()
8458 lockdep_assert_held(&ar->conf_mutex); in ath11k_fw_stats_request()
8460 spin_lock_bh(&ar->data_lock); in ath11k_fw_stats_request()
8461 ar->fw_stats_done = false; in ath11k_fw_stats_request()
8462 ath11k_fw_stats_pdevs_free(&ar->fw_stats.pdevs); in ath11k_fw_stats_request()
8463 spin_unlock_bh(&ar->data_lock); in ath11k_fw_stats_request()
8465 reinit_completion(&ar->fw_stats_complete); in ath11k_fw_stats_request()
8474 time_left = wait_for_completion_timeout(&ar->fw_stats_complete, in ath11k_fw_stats_request()
8478 return -ETIMEDOUT; in ath11k_fw_stats_request()
8487 struct ath11k *ar = hw->priv; in ath11k_mac_op_get_txpower()
8488 struct ath11k_base *ab = ar->ab; in ath11k_mac_op_get_txpower()
8499 mutex_lock(&ar->conf_mutex); in ath11k_mac_op_get_txpower()
8501 if (ar->state != ATH11K_STATE_ON) in ath11k_mac_op_get_txpower()
8504 req_param.pdev_id = ar->pdev->pdev_id; in ath11k_mac_op_get_txpower()
8513 spin_lock_bh(&ar->data_lock); in ath11k_mac_op_get_txpower()
8514 pdev = list_first_entry_or_null(&ar->fw_stats.pdevs, in ath11k_mac_op_get_txpower()
8517 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_get_txpower()
8522 *dbm = pdev->chan_tx_power / 2; in ath11k_mac_op_get_txpower()
8524 spin_unlock_bh(&ar->data_lock); in ath11k_mac_op_get_txpower()
8525 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_get_txpower()
8527 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "txpower from firmware %d, reported %d dBm\n", in ath11k_mac_op_get_txpower()
8528 pdev->chan_tx_power, *dbm); in ath11k_mac_op_get_txpower()
8532 mutex_unlock(&ar->conf_mutex); in ath11k_mac_op_get_txpower()
8533 /* We didn't get txpower from FW. Hence, relying on vif->bss_conf.txpower */ in ath11k_mac_op_get_txpower()
8534 *dbm = vif->bss_conf.txpower; in ath11k_mac_op_get_txpower()
8535 ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "txpower from firmware NaN, reported %d dBm\n", in ath11k_mac_op_get_txpower()
8606 for (i = 0; i < band->n_channels; i++) { in ath11k_mac_update_ch_list()
8607 if (band->channels[i].center_freq < freq_low || in ath11k_mac_update_ch_list()
8608 band->channels[i].center_freq > freq_high) in ath11k_mac_update_ch_list()
8609 band->channels[i].flags |= IEEE80211_CHAN_DISABLED; in ath11k_mac_update_ch_list()
8615 struct ath11k_pdev *pdev = ar->pdev; in ath11k_get_phy_id()
8616 struct ath11k_pdev_cap *pdev_cap = &pdev->cap; in ath11k_get_phy_id()
8619 return pdev_cap->band[NL80211_BAND_2GHZ].phy_id; in ath11k_get_phy_id()
8622 return pdev_cap->band[NL80211_BAND_5GHZ].phy_id; in ath11k_get_phy_id()
8624 ath11k_warn(ar->ab, "unsupported phy cap:%d\n", band); in ath11k_get_phy_id()
8642 reg_cap = &ar->ab->hal_reg_cap[ar->pdev_idx]; in ath11k_mac_setup_channels_rates()
8650 return -ENOMEM; in ath11k_mac_setup_channels_rates()
8652 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath11k_mac_setup_channels_rates()
8653 band->band = NL80211_BAND_2GHZ; in ath11k_mac_setup_channels_rates()
8654 band->n_channels = ARRAY_SIZE(ath11k_2ghz_channels); in ath11k_mac_setup_channels_rates()
8655 band->channels = channels; in ath11k_mac_setup_channels_rates()
8656 band->n_bitrates = ath11k_g_rates_size; in ath11k_mac_setup_channels_rates()
8657 band->bitrates = ath11k_g_rates; in ath11k_mac_setup_channels_rates()
8658 ar->hw->wiphy->bands[NL80211_BAND_2GHZ] = band; in ath11k_mac_setup_channels_rates()
8660 if (ar->ab->hw_params.single_pdev_only) { in ath11k_mac_setup_channels_rates()
8662 temp_reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath11k_mac_setup_channels_rates()
8665 temp_reg_cap->low_2ghz_chan, in ath11k_mac_setup_channels_rates()
8666 temp_reg_cap->high_2ghz_chan); in ath11k_mac_setup_channels_rates()
8670 if (reg_cap->high_5ghz_chan >= ATH11K_MAX_6G_FREQ) { in ath11k_mac_setup_channels_rates()
8674 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath11k_mac_setup_channels_rates()
8675 return -ENOMEM; in ath11k_mac_setup_channels_rates()
8678 ar->supports_6ghz = true; in ath11k_mac_setup_channels_rates()
8679 band = &ar->mac.sbands[NL80211_BAND_6GHZ]; in ath11k_mac_setup_channels_rates()
8680 band->band = NL80211_BAND_6GHZ; in ath11k_mac_setup_channels_rates()
8681 band->n_channels = ARRAY_SIZE(ath11k_6ghz_channels); in ath11k_mac_setup_channels_rates()
8682 band->channels = channels; in ath11k_mac_setup_channels_rates()
8683 band->n_bitrates = ath11k_a_rates_size; in ath11k_mac_setup_channels_rates()
8684 band->bitrates = ath11k_a_rates; in ath11k_mac_setup_channels_rates()
8685 ar->hw->wiphy->bands[NL80211_BAND_6GHZ] = band; in ath11k_mac_setup_channels_rates()
8687 if (ar->ab->hw_params.single_pdev_only) { in ath11k_mac_setup_channels_rates()
8689 temp_reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath11k_mac_setup_channels_rates()
8693 temp_reg_cap->low_5ghz_chan, in ath11k_mac_setup_channels_rates()
8694 temp_reg_cap->high_5ghz_chan); in ath11k_mac_setup_channels_rates()
8697 if (reg_cap->low_5ghz_chan < ATH11K_MIN_6G_FREQ) { in ath11k_mac_setup_channels_rates()
8702 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath11k_mac_setup_channels_rates()
8703 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in ath11k_mac_setup_channels_rates()
8704 return -ENOMEM; in ath11k_mac_setup_channels_rates()
8707 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath11k_mac_setup_channels_rates()
8708 band->band = NL80211_BAND_5GHZ; in ath11k_mac_setup_channels_rates()
8709 band->n_channels = ARRAY_SIZE(ath11k_5ghz_channels); in ath11k_mac_setup_channels_rates()
8710 band->channels = channels; in ath11k_mac_setup_channels_rates()
8711 band->n_bitrates = ath11k_a_rates_size; in ath11k_mac_setup_channels_rates()
8712 band->bitrates = ath11k_a_rates; in ath11k_mac_setup_channels_rates()
8713 ar->hw->wiphy->bands[NL80211_BAND_5GHZ] = band; in ath11k_mac_setup_channels_rates()
8715 if (ar->ab->hw_params.single_pdev_only) { in ath11k_mac_setup_channels_rates()
8717 temp_reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath11k_mac_setup_channels_rates()
8721 temp_reg_cap->low_5ghz_chan, in ath11k_mac_setup_channels_rates()
8722 temp_reg_cap->high_5ghz_chan); in ath11k_mac_setup_channels_rates()
8731 struct ath11k_base *ab = ar->ab; in ath11k_mac_setup_iface_combinations()
8738 return -ENOMEM; in ath11k_mac_setup_iface_combinations()
8745 return -ENOMEM; in ath11k_mac_setup_iface_combinations()
8755 ab->hw_params.interface_modes & BIT(NL80211_IFTYPE_MESH_POINT)) in ath11k_mac_setup_iface_combinations()
8771 ar->hw->wiphy->iface_combinations = combinations; in ath11k_mac_setup_iface_combinations()
8772 ar->hw->wiphy->n_iface_combinations = 1; in ath11k_mac_setup_iface_combinations()
8816 cancel_work_sync(&ar->regd_update_work); in __ath11k_mac_unregister()
8818 ieee80211_unregister_hw(ar->hw); in __ath11k_mac_unregister()
8820 idr_for_each(&ar->txmgmt_idr, ath11k_mac_tx_mgmt_pending_free, ar); in __ath11k_mac_unregister()
8821 idr_destroy(&ar->txmgmt_idr); in __ath11k_mac_unregister()
8823 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in __ath11k_mac_unregister()
8824 kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels); in __ath11k_mac_unregister()
8825 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in __ath11k_mac_unregister()
8827 kfree(ar->hw->wiphy->iface_combinations[0].limits); in __ath11k_mac_unregister()
8828 kfree(ar->hw->wiphy->iface_combinations); in __ath11k_mac_unregister()
8830 SET_IEEE80211_DEV(ar->hw, NULL); in __ath11k_mac_unregister()
8839 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_unregister()
8840 pdev = &ab->pdevs[i]; in ath11k_mac_unregister()
8841 ar = pdev->ar; in ath11k_mac_unregister()
8853 struct ath11k_base *ab = ar->ab; in __ath11k_mac_register()
8854 struct ath11k_pdev_cap *cap = &ar->pdev->cap; in __ath11k_mac_register()
8871 SET_IEEE80211_PERM_ADDR(ar->hw, ar->mac_addr); in __ath11k_mac_register()
8873 SET_IEEE80211_DEV(ar->hw, ab->dev); in __ath11k_mac_register()
8876 cap->supported_bands); in __ath11k_mac_register()
8885 ath11k_err(ar->ab, "failed to setup interface combinations: %d\n", ret); in __ath11k_mac_register()
8889 ar->hw->wiphy->available_antennas_rx = cap->rx_chain_mask; in __ath11k_mac_register()
8890 ar->hw->wiphy->available_antennas_tx = cap->tx_chain_mask; in __ath11k_mac_register()
8892 ar->hw->wiphy->interface_modes = ab->hw_params.interface_modes; in __ath11k_mac_register()
8894 if (ab->hw_params.single_pdev_only && ar->supports_6ghz) in __ath11k_mac_register()
8895 ieee80211_hw_set(ar->hw, SINGLE_SCAN_ON_ALL_BANDS); in __ath11k_mac_register()
8897 if (ab->hw_params.supports_multi_bssid) { in __ath11k_mac_register()
8898 ieee80211_hw_set(ar->hw, SUPPORTS_MULTI_BSSID); in __ath11k_mac_register()
8899 ieee80211_hw_set(ar->hw, SUPPORTS_ONLY_HE_MULTI_BSSID); in __ath11k_mac_register()
8902 ieee80211_hw_set(ar->hw, SIGNAL_DBM); in __ath11k_mac_register()
8903 ieee80211_hw_set(ar->hw, SUPPORTS_PS); in __ath11k_mac_register()
8904 ieee80211_hw_set(ar->hw, SUPPORTS_DYNAMIC_PS); in __ath11k_mac_register()
8905 ieee80211_hw_set(ar->hw, MFP_CAPABLE); in __ath11k_mac_register()
8906 ieee80211_hw_set(ar->hw, REPORTS_TX_ACK_STATUS); in __ath11k_mac_register()
8907 ieee80211_hw_set(ar->hw, HAS_RATE_CONTROL); in __ath11k_mac_register()
8908 ieee80211_hw_set(ar->hw, AP_LINK_PS); in __ath11k_mac_register()
8909 ieee80211_hw_set(ar->hw, SPECTRUM_MGMT); in __ath11k_mac_register()
8910 ieee80211_hw_set(ar->hw, CONNECTION_MONITOR); in __ath11k_mac_register()
8911 ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK); in __ath11k_mac_register()
8912 ieee80211_hw_set(ar->hw, WANT_MONITOR_VIF); in __ath11k_mac_register()
8913 ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA); in __ath11k_mac_register()
8914 ieee80211_hw_set(ar->hw, QUEUE_CONTROL); in __ath11k_mac_register()
8915 ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG); in __ath11k_mac_register()
8916 ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK); in __ath11k_mac_register()
8919 ieee80211_hw_set(ar->hw, SUPPORTS_TX_ENCAP_OFFLOAD); in __ath11k_mac_register()
8920 ieee80211_hw_set(ar->hw, SUPPORTS_RX_DECAP_OFFLOAD); in __ath11k_mac_register()
8923 if (cap->nss_ratio_enabled) in __ath11k_mac_register()
8924 ieee80211_hw_set(ar->hw, SUPPORTS_VHT_EXT_NSS_BW); in __ath11k_mac_register()
8926 if ((ht_cap & WMI_HT_CAP_ENABLED) || ar->supports_6ghz) { in __ath11k_mac_register()
8927 ieee80211_hw_set(ar->hw, AMPDU_AGGREGATION); in __ath11k_mac_register()
8928 ieee80211_hw_set(ar->hw, TX_AMPDU_SETUP_IN_HW); in __ath11k_mac_register()
8929 ieee80211_hw_set(ar->hw, SUPPORTS_REORDERING_BUFFER); in __ath11k_mac_register()
8930 ieee80211_hw_set(ar->hw, SUPPORTS_AMSDU_IN_AMPDU); in __ath11k_mac_register()
8931 ieee80211_hw_set(ar->hw, USES_RSS); in __ath11k_mac_register()
8934 ar->hw->wiphy->features |= NL80211_FEATURE_STATIC_SMPS; in __ath11k_mac_register()
8935 ar->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in __ath11k_mac_register()
8942 (ar->supports_6ghz && ab->hw_params.supports_dynamic_smps_6ghz)) in __ath11k_mac_register()
8943 ar->hw->wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS; in __ath11k_mac_register()
8945 ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID; in __ath11k_mac_register()
8946 ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN; in __ath11k_mac_register()
8948 ar->hw->max_listen_interval = ATH11K_MAX_HW_LISTEN_INTERVAL; in __ath11k_mac_register()
8950 ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; in __ath11k_mac_register()
8951 ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; in __ath11k_mac_register()
8952 ar->hw->wiphy->max_remain_on_channel_duration = 5000; in __ath11k_mac_register()
8954 ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; in __ath11k_mac_register()
8955 ar->hw->wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | in __ath11k_mac_register()
8958 ar->max_num_stations = TARGET_NUM_STATIONS(ab); in __ath11k_mac_register()
8959 ar->max_num_peers = TARGET_NUM_PEERS_PDEV(ab); in __ath11k_mac_register()
8961 ar->hw->wiphy->max_ap_assoc_sta = ar->max_num_stations; in __ath11k_mac_register()
8963 if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) { in __ath11k_mac_register()
8964 ar->hw->wiphy->features |= in __ath11k_mac_register()
8968 if (test_bit(WMI_TLV_SERVICE_NLO, ar->wmi->wmi_ab->svc_map)) { in __ath11k_mac_register()
8969 ar->hw->wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS; in __ath11k_mac_register()
8970 ar->hw->wiphy->max_match_sets = WMI_PNO_MAX_SUPP_NETWORKS; in __ath11k_mac_register()
8971 ar->hw->wiphy->max_sched_scan_ie_len = WMI_PNO_MAX_IE_LENGTH; in __ath11k_mac_register()
8972 ar->hw->wiphy->max_sched_scan_plans = WMI_PNO_MAX_SCHED_SCAN_PLANS; in __ath11k_mac_register()
8973 ar->hw->wiphy->max_sched_scan_plan_interval = in __ath11k_mac_register()
8975 ar->hw->wiphy->max_sched_scan_plan_iterations = in __ath11k_mac_register()
8977 ar->hw->wiphy->features |= NL80211_FEATURE_ND_RANDOM_MAC_ADDR; in __ath11k_mac_register()
8982 ath11k_warn(ar->ab, "failed to init wow: %d\n", ret); in __ath11k_mac_register()
8986 ar->hw->queues = ATH11K_HW_MAX_QUEUES; in __ath11k_mac_register()
8987 ar->hw->wiphy->tx_queue_len = ATH11K_QUEUE_LEN; in __ath11k_mac_register()
8988 ar->hw->offchannel_tx_hw_queue = ATH11K_HW_MAX_QUEUES - 1; in __ath11k_mac_register()
8989 ar->hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; in __ath11k_mac_register()
8991 ar->hw->vif_data_size = sizeof(struct ath11k_vif); in __ath11k_mac_register()
8992 ar->hw->sta_data_size = sizeof(struct ath11k_sta); in __ath11k_mac_register()
8994 wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in __ath11k_mac_register()
8995 wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR); in __ath11k_mac_register()
8997 ar->ab->wmi_ab.svc_map)) { in __ath11k_mac_register()
8998 wiphy_ext_feature_set(ar->hw->wiphy, in __ath11k_mac_register()
9000 ieee80211_hw_set(ar->hw, DETECTS_COLOR_COLLISION); in __ath11k_mac_register()
9003 ar->hw->wiphy->cipher_suites = cipher_suites; in __ath11k_mac_register()
9004 ar->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); in __ath11k_mac_register()
9006 ar->hw->wiphy->iftype_ext_capab = ath11k_iftypes_ext_capa; in __ath11k_mac_register()
9007 ar->hw->wiphy->num_iftype_ext_capab = in __ath11k_mac_register()
9010 if (ar->supports_6ghz) { in __ath11k_mac_register()
9011 wiphy_ext_feature_set(ar->hw->wiphy, in __ath11k_mac_register()
9013 wiphy_ext_feature_set(ar->hw->wiphy, in __ath11k_mac_register()
9019 if (!test_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags)) { in __ath11k_mac_register()
9020 ar->hw->netdev_features = NETIF_F_HW_CSUM; in __ath11k_mac_register()
9021 ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL); in __ath11k_mac_register()
9022 ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT); in __ath11k_mac_register()
9025 if (test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) && in __ath11k_mac_register()
9026 ab->hw_params.bios_sar_capa) in __ath11k_mac_register()
9027 ar->hw->wiphy->sar_capa = ab->hw_params.bios_sar_capa; in __ath11k_mac_register()
9029 ret = ieee80211_register_hw(ar->hw); in __ath11k_mac_register()
9031 ath11k_err(ar->ab, "ieee80211 registration failed: %d\n", ret); in __ath11k_mac_register()
9035 if (!ab->hw_params.supports_monitor) in __ath11k_mac_register()
9041 ar->hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR); in __ath11k_mac_register()
9046 ath11k_err(ar->ab, "ath11k regd update failed: %d\n", ret); in __ath11k_mac_register()
9050 if (ab->hw_params.current_cc_support && ab->new_alpha2[0]) { in __ath11k_mac_register()
9053 memcpy(&set_current_param.alpha2, ab->new_alpha2, 2); in __ath11k_mac_register()
9054 memcpy(&ar->alpha2, ab->new_alpha2, 2); in __ath11k_mac_register()
9057 ath11k_warn(ar->ab, in __ath11k_mac_register()
9063 ath11k_err(ar->ab, "debugfs registration failed: %d\n", ret); in __ath11k_mac_register()
9070 ieee80211_unregister_hw(ar->hw); in __ath11k_mac_register()
9073 kfree(ar->hw->wiphy->iface_combinations[0].limits); in __ath11k_mac_register()
9074 kfree(ar->hw->wiphy->iface_combinations); in __ath11k_mac_register()
9077 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in __ath11k_mac_register()
9078 kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels); in __ath11k_mac_register()
9079 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in __ath11k_mac_register()
9082 SET_IEEE80211_DEV(ar->hw, NULL); in __ath11k_mac_register()
9094 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) in ath11k_mac_register()
9098 ab->cc_freq_hz = IPQ8074_CC_FREQ_HERTZ; in ath11k_mac_register()
9099 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1; in ath11k_mac_register()
9105 device_get_mac_address(ab->dev, mac_addr); in ath11k_mac_register()
9107 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_register()
9108 pdev = &ab->pdevs[i]; in ath11k_mac_register()
9109 ar = pdev->ar; in ath11k_mac_register()
9110 if (ab->pdevs_macaddr_valid) { in ath11k_mac_register()
9111 ether_addr_copy(ar->mac_addr, pdev->mac_addr); in ath11k_mac_register()
9114 ether_addr_copy(ar->mac_addr, ab->mac_addr); in ath11k_mac_register()
9116 ether_addr_copy(ar->mac_addr, mac_addr); in ath11k_mac_register()
9117 ar->mac_addr[4] += i; in ath11k_mac_register()
9120 idr_init(&ar->txmgmt_idr); in ath11k_mac_register()
9121 spin_lock_init(&ar->txmgmt_idr_lock); in ath11k_mac_register()
9127 init_waitqueue_head(&ar->txmgmt_empty_waitq); in ath11k_mac_register()
9133 for (i = i - 1; i >= 0; i--) { in ath11k_mac_register()
9134 pdev = &ab->pdevs[i]; in ath11k_mac_register()
9135 ar = pdev->ar; in ath11k_mac_register()
9152 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) in ath11k_mac_allocate()
9155 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_allocate()
9156 pdev = &ab->pdevs[i]; in ath11k_mac_allocate()
9160 ret = -ENOMEM; in ath11k_mac_allocate()
9164 ar = hw->priv; in ath11k_mac_allocate()
9165 ar->hw = hw; in ath11k_mac_allocate()
9166 ar->ab = ab; in ath11k_mac_allocate()
9167 ar->pdev = pdev; in ath11k_mac_allocate()
9168 ar->pdev_idx = i; in ath11k_mac_allocate()
9169 ar->lmac_id = ath11k_hw_get_mac_from_pdev_id(&ab->hw_params, i); in ath11k_mac_allocate()
9171 ar->wmi = &ab->wmi_ab.wmi[i]; in ath11k_mac_allocate()
9177 ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask; in ath11k_mac_allocate()
9178 ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask; in ath11k_mac_allocate()
9179 ar->num_tx_chains = get_num_chains(pdev->cap.tx_chain_mask); in ath11k_mac_allocate()
9180 ar->num_rx_chains = get_num_chains(pdev->cap.rx_chain_mask); in ath11k_mac_allocate()
9182 pdev->ar = ar; in ath11k_mac_allocate()
9183 spin_lock_init(&ar->data_lock); in ath11k_mac_allocate()
9184 INIT_LIST_HEAD(&ar->arvifs); in ath11k_mac_allocate()
9185 INIT_LIST_HEAD(&ar->ppdu_stats_info); in ath11k_mac_allocate()
9186 mutex_init(&ar->conf_mutex); in ath11k_mac_allocate()
9187 init_completion(&ar->vdev_setup_done); in ath11k_mac_allocate()
9188 init_completion(&ar->vdev_delete_done); in ath11k_mac_allocate()
9189 init_completion(&ar->peer_assoc_done); in ath11k_mac_allocate()
9190 init_completion(&ar->peer_delete_done); in ath11k_mac_allocate()
9191 init_completion(&ar->install_key_done); in ath11k_mac_allocate()
9192 init_completion(&ar->bss_survey_done); in ath11k_mac_allocate()
9193 init_completion(&ar->scan.started); in ath11k_mac_allocate()
9194 init_completion(&ar->scan.completed); in ath11k_mac_allocate()
9195 init_completion(&ar->scan.on_channel); in ath11k_mac_allocate()
9196 init_completion(&ar->thermal.wmi_sync); in ath11k_mac_allocate()
9198 INIT_DELAYED_WORK(&ar->scan.timeout, ath11k_scan_timeout_work); in ath11k_mac_allocate()
9199 INIT_WORK(&ar->regd_update_work, ath11k_regd_update_work); in ath11k_mac_allocate()
9201 INIT_WORK(&ar->wmi_mgmt_tx_work, ath11k_mgmt_over_wmi_tx_work); in ath11k_mac_allocate()
9202 skb_queue_head_init(&ar->wmi_mgmt_tx_queue); in ath11k_mac_allocate()
9204 clear_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags); in ath11k_mac_allocate()
9206 ar->monitor_vdev_id = -1; in ath11k_mac_allocate()
9207 clear_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags); in ath11k_mac_allocate()
9208 ar->vdev_id_11d_scan = ATH11K_11D_INVALID_VDEV_ID; in ath11k_mac_allocate()
9209 init_completion(&ar->completed_11d_scan); in ath11k_mac_allocate()
9228 for (i = 0; i < ab->num_radios; i++) { in ath11k_mac_destroy()
9229 pdev = &ab->pdevs[i]; in ath11k_mac_destroy()
9230 ar = pdev->ar; in ath11k_mac_destroy()
9234 ieee80211_free_hw(ar->hw); in ath11k_mac_destroy()
9235 pdev->ar = NULL; in ath11k_mac_destroy()
9243 struct ath11k *ar = arvif->ar; in ath11k_mac_vif_set_keepalive()
9247 lockdep_assert_held(&ar->conf_mutex); in ath11k_mac_vif_set_keepalive()
9249 if (arvif->vdev_type != WMI_VDEV_TYPE_STA) in ath11k_mac_vif_set_keepalive()
9252 if (!test_bit(WMI_TLV_SERVICE_STA_KEEP_ALIVE, ar->ab->wmi_ab.svc_map)) in ath11k_mac_vif_set_keepalive()
9255 arg.vdev_id = arvif->vdev_id; in ath11k_mac_vif_set_keepalive()
9262 ath11k_warn(ar->ab, "failed to set keepalive on vdev %i: %d\n", in ath11k_mac_vif_set_keepalive()
9263 arvif->vdev_id, ret); in ath11k_mac_vif_set_keepalive()