Lines Matching +full:hw +full:- +full:channels

1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
13 #include "hw.h"
233 #define ath12k_a_rates_size (ARRAY_SIZE(ath12k_legacy_rates) - 4)
244 static int ath12k_start_vdev_delay(struct ieee80211_hw *hw,
259 return "11na-ht20"; in ath12k_mac_phymode_str()
261 return "11ng-ht20"; in ath12k_mac_phymode_str()
263 return "11na-ht40"; in ath12k_mac_phymode_str()
265 return "11ng-ht40"; in ath12k_mac_phymode_str()
267 return "11ac-vht20"; in ath12k_mac_phymode_str()
269 return "11ac-vht40"; in ath12k_mac_phymode_str()
271 return "11ac-vht80"; in ath12k_mac_phymode_str()
273 return "11ac-vht160"; in ath12k_mac_phymode_str()
275 return "11ac-vht80+80"; in ath12k_mac_phymode_str()
277 return "11ac-vht20-2g"; in ath12k_mac_phymode_str()
279 return "11ac-vht40-2g"; in ath12k_mac_phymode_str()
281 return "11ac-vht80-2g"; in ath12k_mac_phymode_str()
283 return "11ax-he20"; in ath12k_mac_phymode_str()
285 return "11ax-he40"; in ath12k_mac_phymode_str()
287 return "11ax-he80"; in ath12k_mac_phymode_str()
289 return "11ax-he80+80"; in ath12k_mac_phymode_str()
291 return "11ax-he160"; in ath12k_mac_phymode_str()
293 return "11ax-he20-2g"; in ath12k_mac_phymode_str()
295 return "11ax-he40-2g"; in ath12k_mac_phymode_str()
297 return "11ax-he80-2g"; in ath12k_mac_phymode_str()
299 return "11be-eht20"; in ath12k_mac_phymode_str()
301 return "11be-eht40"; in ath12k_mac_phymode_str()
303 return "11be-eht80"; in ath12k_mac_phymode_str()
305 return "11be-eht80+80"; in ath12k_mac_phymode_str()
307 return "11be-eht160"; in ath12k_mac_phymode_str()
309 return "11be-eht160+160"; in ath12k_mac_phymode_str()
311 return "11be-eht320"; in ath12k_mac_phymode_str()
313 return "11be-eht20-2g"; in ath12k_mac_phymode_str()
315 return "11be-eht40-2g"; in ath12k_mac_phymode_str()
389 return -EINVAL; in ath12k_mac_hw_ratecode_to_legacy_rate()
397 for (i = 0; i < sband->n_bitrates; i++) in ath12k_mac_bitrate_to_idx()
398 if (sband->bitrates[i].bitrate == bitrate) in ath12k_mac_bitrate_to_idx()
409 for (nss = IEEE80211_HT_MCS_MASK_LEN - 1; nss >= 0; nss--) in ath12k_mac_max_ht_nss()
421 for (nss = NL80211_VHT_NSS_MAX - 1; nss >= 0; nss--) in ath12k_mac_max_vht_nss()
430 /* From IEEE Std 802.11-2020 defined values for "Minimum MPDU Start Spacing": in ath12k_parse_mpdudensity()
469 conf = rcu_dereference(vif->bss_conf.chanctx_conf); in ath12k_mac_vif_chan()
472 return -ENOENT; in ath12k_mac_vif_chan()
475 *def = conf->def; in ath12k_mac_vif_chan()
500 for (i = 0; i < sband->n_bitrates; i++) { in ath12k_mac_hw_rate_to_idx()
501 rate = &sband->bitrates[i]; in ath12k_mac_hw_rate_to_idx()
503 if (ath12k_mac_bitrate_is_cck(rate->bitrate) != cck) in ath12k_mac_hw_rate_to_idx()
506 if (rate->hw_value == hw_rate) in ath12k_mac_hw_rate_to_idx()
508 else if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE && in ath12k_mac_hw_rate_to_idx()
509 rate->hw_value_short == hw_rate) in ath12k_mac_hw_rate_to_idx()
526 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_get_arvif_iter()
528 if (arvif->vdev_id == arvif_iter->vdev_id) in ath12k_get_arvif_iter()
529 arvif_iter->arvif = arvif; in ath12k_get_arvif_iter()
540 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath12k_mac_get_arvif()
545 ath12k_warn(ar->ab, "No VIF found for vdev %d\n", vdev_id); in ath12k_mac_get_arvif()
559 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_get_arvif_by_vdev_id()
560 pdev = rcu_dereference(ab->pdevs_active[i]); in ath12k_mac_get_arvif_by_vdev_id()
561 if (pdev && pdev->ar) { in ath12k_mac_get_arvif_by_vdev_id()
562 arvif = ath12k_mac_get_arvif(pdev->ar, vdev_id); in ath12k_mac_get_arvif_by_vdev_id()
576 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_get_ar_by_vdev_id()
577 pdev = rcu_dereference(ab->pdevs_active[i]); in ath12k_mac_get_ar_by_vdev_id()
578 if (pdev && pdev->ar) { in ath12k_mac_get_ar_by_vdev_id()
579 if (pdev->ar->allocated_vdev_map & (1LL << vdev_id)) in ath12k_mac_get_ar_by_vdev_id()
580 return pdev->ar; in ath12k_mac_get_ar_by_vdev_id()
592 if (ab->hw_params->single_pdev_only) { in ath12k_mac_get_ar_by_pdev_id()
593 pdev = rcu_dereference(ab->pdevs_active[0]); in ath12k_mac_get_ar_by_pdev_id()
594 return pdev ? pdev->ar : NULL; in ath12k_mac_get_ar_by_pdev_id()
597 if (WARN_ON(pdev_id > ab->num_radios)) in ath12k_mac_get_ar_by_pdev_id()
600 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_get_ar_by_pdev_id()
601 pdev = rcu_dereference(ab->pdevs_active[i]); in ath12k_mac_get_ar_by_pdev_id()
603 if (pdev && pdev->pdev_id == pdev_id) in ath12k_mac_get_ar_by_pdev_id()
604 return (pdev->ar ? pdev->ar : NULL); in ath12k_mac_get_ar_by_pdev_id()
612 struct ath12k_base *ab = ar->ab; in ath12k_pdev_caps_update()
614 ar->max_tx_power = ab->target_caps.hw_max_tx_power; in ath12k_pdev_caps_update()
616 /* FIXME: Set min_tx_power to ab->target_caps.hw_min_tx_power. in ath12k_pdev_caps_update()
618 * we can set ar->min_tx_power to 0 currently until in ath12k_pdev_caps_update()
621 ar->min_tx_power = 0; in ath12k_pdev_caps_update()
623 ar->txpower_limit_2g = ar->max_tx_power; in ath12k_pdev_caps_update()
624 ar->txpower_limit_5g = ar->max_tx_power; in ath12k_pdev_caps_update()
625 ar->txpower_scale = WMI_HOST_TP_SCALE_MAX; in ath12k_pdev_caps_update()
630 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_txpower_recalc()
632 int ret, txpower = -1; in ath12k_mac_txpower_recalc()
635 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_txpower_recalc()
637 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_mac_txpower_recalc()
638 if (arvif->txpower <= 0) in ath12k_mac_txpower_recalc()
641 if (txpower == -1) in ath12k_mac_txpower_recalc()
642 txpower = arvif->txpower; in ath12k_mac_txpower_recalc()
644 txpower = min(txpower, arvif->txpower); in ath12k_mac_txpower_recalc()
647 if (txpower == -1) in ath12k_mac_txpower_recalc()
651 txpower = min_t(u32, max_t(u32, ar->min_tx_power, txpower), in ath12k_mac_txpower_recalc()
652 ar->max_tx_power) * 2; in ath12k_mac_txpower_recalc()
654 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "txpower to set in hw %d\n", in ath12k_mac_txpower_recalc()
657 if ((pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) && in ath12k_mac_txpower_recalc()
658 ar->txpower_limit_2g != txpower) { in ath12k_mac_txpower_recalc()
661 txpower, ar->pdev->pdev_id); in ath12k_mac_txpower_recalc()
664 ar->txpower_limit_2g = txpower; in ath12k_mac_txpower_recalc()
667 if ((pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) && in ath12k_mac_txpower_recalc()
668 ar->txpower_limit_5g != txpower) { in ath12k_mac_txpower_recalc()
671 txpower, ar->pdev->pdev_id); in ath12k_mac_txpower_recalc()
674 ar->txpower_limit_5g = txpower; in ath12k_mac_txpower_recalc()
680 ath12k_warn(ar->ab, "failed to recalc txpower limit %d using pdev param %d: %d\n", in ath12k_mac_txpower_recalc()
687 struct ath12k *ar = arvif->ar; in ath12k_recalc_rtscts_prot()
691 lockdep_assert_held(&ar->conf_mutex); in ath12k_recalc_rtscts_prot()
701 if (arvif->num_legacy_stations > 0) in ath12k_recalc_rtscts_prot()
707 if (arvif->rtscts_prot_mode == rts_cts) in ath12k_recalc_rtscts_prot()
710 arvif->rtscts_prot_mode = rts_cts; in ath12k_recalc_rtscts_prot()
712 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d recalc rts/cts prot %d\n", in ath12k_recalc_rtscts_prot()
713 arvif->vdev_id, rts_cts); in ath12k_recalc_rtscts_prot()
715 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_recalc_rtscts_prot()
718 ath12k_warn(ar->ab, "failed to recalculate rts/cts prot for vdev %d: %d\n", in ath12k_recalc_rtscts_prot()
719 arvif->vdev_id, ret); in ath12k_recalc_rtscts_prot()
726 struct ath12k *ar = arvif->ar; in ath12k_mac_set_kickout()
732 ar->pdev->pdev_id); in ath12k_mac_set_kickout()
734 ath12k_warn(ar->ab, "failed to set kickout threshold on vdev %i: %d\n", in ath12k_mac_set_kickout()
735 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
740 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath12k_mac_set_kickout()
743 ath12k_warn(ar->ab, "failed to set keepalive minimum idle time on vdev %i: %d\n", in ath12k_mac_set_kickout()
744 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
749 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath12k_mac_set_kickout()
752 ath12k_warn(ar->ab, "failed to set keepalive maximum idle time on vdev %i: %d\n", in ath12k_mac_set_kickout()
753 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
758 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, in ath12k_mac_set_kickout()
761 ath12k_warn(ar->ab, "failed to set keepalive maximum unresponsive time on vdev %i: %d\n", in ath12k_mac_set_kickout()
762 arvif->vdev_id, ret); in ath12k_mac_set_kickout()
772 struct ath12k_base *ab = ar->ab; in ath12k_mac_peer_cleanup_all()
774 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_peer_cleanup_all()
776 spin_lock_bh(&ab->base_lock); in ath12k_mac_peer_cleanup_all()
777 list_for_each_entry_safe(peer, tmp, &ab->peers, list) { in ath12k_mac_peer_cleanup_all()
779 list_del(&peer->list); in ath12k_mac_peer_cleanup_all()
782 spin_unlock_bh(&ab->base_lock); in ath12k_mac_peer_cleanup_all()
784 ar->num_peers = 0; in ath12k_mac_peer_cleanup_all()
785 ar->num_stations = 0; in ath12k_mac_peer_cleanup_all()
790 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_setup_sync()
792 if (test_bit(ATH12K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) in ath12k_mac_vdev_setup_sync()
793 return -ESHUTDOWN; in ath12k_mac_vdev_setup_sync()
795 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "vdev setup timeout %d\n", in ath12k_mac_vdev_setup_sync()
798 if (!wait_for_completion_timeout(&ar->vdev_setup_done, in ath12k_mac_vdev_setup_sync()
800 return -ETIMEDOUT; in ath12k_mac_vdev_setup_sync()
802 return ar->last_wmi_vdev_start_status ? -EINVAL : 0; in ath12k_mac_vdev_setup_sync()
809 ret = ath12k_wmi_vdev_up(ar, vdev_id, 0, ar->mac_addr); in ath12k_monitor_vdev_up()
811 ath12k_warn(ar->ab, "failed to put up monitor vdev %i: %d\n", in ath12k_monitor_vdev_up()
816 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %i started\n", in ath12k_monitor_vdev_up()
828 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_start()
830 channel = chandef->chan; in ath12k_mac_monitor_vdev_start()
832 arg.freq = channel->center_freq; in ath12k_mac_monitor_vdev_start()
833 arg.band_center_freq1 = chandef->center_freq1; in ath12k_mac_monitor_vdev_start()
834 arg.band_center_freq2 = chandef->center_freq2; in ath12k_mac_monitor_vdev_start()
835 arg.mode = ath12k_phymodes[chandef->chan->band][chandef->width]; in ath12k_mac_monitor_vdev_start()
836 arg.chan_radar = !!(channel->flags & IEEE80211_CHAN_RADAR); in ath12k_mac_monitor_vdev_start()
839 arg.max_power = channel->max_power; in ath12k_mac_monitor_vdev_start()
840 arg.max_reg_power = channel->max_reg_power; in ath12k_mac_monitor_vdev_start()
841 arg.max_antenna_gain = channel->max_antenna_gain; in ath12k_mac_monitor_vdev_start()
843 arg.pref_tx_streams = ar->num_tx_chains; in ath12k_mac_monitor_vdev_start()
844 arg.pref_rx_streams = ar->num_rx_chains; in ath12k_mac_monitor_vdev_start()
847 arg.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR); in ath12k_mac_monitor_vdev_start()
849 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_monitor_vdev_start()
850 reinit_completion(&ar->vdev_delete_done); in ath12k_mac_monitor_vdev_start()
854 ath12k_warn(ar->ab, "failed to request monitor vdev %i start: %d\n", in ath12k_mac_monitor_vdev_start()
861 ath12k_warn(ar->ab, "failed to synchronize setup for monitor vdev %i start: %d\n", in ath12k_mac_monitor_vdev_start()
866 ret = ath12k_wmi_vdev_up(ar, vdev_id, 0, ar->mac_addr); in ath12k_mac_monitor_vdev_start()
868 ath12k_warn(ar->ab, "failed to put up monitor vdev %i: %d\n", in ath12k_mac_monitor_vdev_start()
873 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %i started\n", in ath12k_mac_monitor_vdev_start()
880 ath12k_warn(ar->ab, "failed to stop monitor vdev %i after start failure: %d\n", in ath12k_mac_monitor_vdev_start()
889 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_stop()
891 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_monitor_vdev_stop()
893 ret = ath12k_wmi_vdev_stop(ar, ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_stop()
895 ath12k_warn(ar->ab, "failed to request monitor vdev %i stop: %d\n", in ath12k_mac_monitor_vdev_stop()
896 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_stop()
900 ath12k_warn(ar->ab, "failed to synchronize monitor vdev %i stop: %d\n", in ath12k_mac_monitor_vdev_stop()
901 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_stop()
903 ret = ath12k_wmi_vdev_down(ar, ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_stop()
905 ath12k_warn(ar->ab, "failed to put down monitor vdev %i: %d\n", in ath12k_mac_monitor_vdev_stop()
906 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_stop()
908 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %i stopped\n", in ath12k_mac_monitor_vdev_stop()
909 ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_stop()
915 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_monitor_vdev_create()
921 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_create()
923 if (ar->monitor_vdev_created) in ath12k_mac_monitor_vdev_create()
926 if (ar->ab->free_vdev_map == 0) { in ath12k_mac_monitor_vdev_create()
927 ath12k_warn(ar->ab, "failed to find free vdev id for monitor vdev\n"); in ath12k_mac_monitor_vdev_create()
928 return -ENOMEM; in ath12k_mac_monitor_vdev_create()
931 bit = __ffs64(ar->ab->free_vdev_map); in ath12k_mac_monitor_vdev_create()
933 ar->monitor_vdev_id = bit; in ath12k_mac_monitor_vdev_create()
935 arg.if_id = ar->monitor_vdev_id; in ath12k_mac_monitor_vdev_create()
938 arg.pdev_id = pdev->pdev_id; in ath12k_mac_monitor_vdev_create()
941 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_monitor_vdev_create()
942 arg.chains[NL80211_BAND_2GHZ].tx = ar->num_tx_chains; in ath12k_mac_monitor_vdev_create()
943 arg.chains[NL80211_BAND_2GHZ].rx = ar->num_rx_chains; in ath12k_mac_monitor_vdev_create()
946 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath12k_mac_monitor_vdev_create()
947 arg.chains[NL80211_BAND_5GHZ].tx = ar->num_tx_chains; in ath12k_mac_monitor_vdev_create()
948 arg.chains[NL80211_BAND_5GHZ].rx = ar->num_rx_chains; in ath12k_mac_monitor_vdev_create()
953 ath12k_warn(ar->ab, "failed to request monitor vdev %i creation: %d\n", in ath12k_mac_monitor_vdev_create()
954 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_create()
955 ar->monitor_vdev_id = -1; in ath12k_mac_monitor_vdev_create()
959 nss = hweight32(ar->cfg_tx_chainmask) ? : 1; in ath12k_mac_monitor_vdev_create()
960 ret = ath12k_wmi_vdev_set_param_cmd(ar, ar->monitor_vdev_id, in ath12k_mac_monitor_vdev_create()
963 ath12k_warn(ar->ab, "failed to set vdev %d chainmask 0x%x, nss %d :%d\n", in ath12k_mac_monitor_vdev_create()
964 ar->monitor_vdev_id, ar->cfg_tx_chainmask, nss, ret); in ath12k_mac_monitor_vdev_create()
972 ar->allocated_vdev_map |= 1LL << ar->monitor_vdev_id; in ath12k_mac_monitor_vdev_create()
973 ar->ab->free_vdev_map &= ~(1LL << ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_create()
974 ar->num_created_vdevs++; in ath12k_mac_monitor_vdev_create()
975 ar->monitor_vdev_created = true; in ath12k_mac_monitor_vdev_create()
976 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %d created\n", in ath12k_mac_monitor_vdev_create()
977 ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_create()
987 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_vdev_delete()
989 if (!ar->monitor_vdev_created) in ath12k_mac_monitor_vdev_delete()
992 reinit_completion(&ar->vdev_delete_done); in ath12k_mac_monitor_vdev_delete()
994 ret = ath12k_wmi_vdev_delete(ar, ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
996 ath12k_warn(ar->ab, "failed to request wmi monitor vdev %i removal: %d\n", in ath12k_mac_monitor_vdev_delete()
997 ar->monitor_vdev_id, ret); in ath12k_mac_monitor_vdev_delete()
1001 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, in ath12k_mac_monitor_vdev_delete()
1004 ath12k_warn(ar->ab, "Timeout in receiving vdev delete response\n"); in ath12k_mac_monitor_vdev_delete()
1006 ar->allocated_vdev_map &= ~(1LL << ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1007 ar->ab->free_vdev_map |= 1LL << (ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1008 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor vdev %d deleted\n", in ath12k_mac_monitor_vdev_delete()
1009 ar->monitor_vdev_id); in ath12k_mac_monitor_vdev_delete()
1010 ar->num_created_vdevs--; in ath12k_mac_monitor_vdev_delete()
1011 ar->monitor_vdev_id = -1; in ath12k_mac_monitor_vdev_delete()
1012 ar->monitor_vdev_created = false; in ath12k_mac_monitor_vdev_delete()
1019 ath12k_mac_get_any_chandef_iter(struct ieee80211_hw *hw, in ath12k_mac_get_any_chandef_iter() argument
1025 *def = &conf->def; in ath12k_mac_get_any_chandef_iter()
1033 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_start()
1035 if (ar->monitor_started) in ath12k_mac_monitor_start()
1038 ieee80211_iter_chan_contexts_atomic(ar->hw, in ath12k_mac_monitor_start()
1044 ret = ath12k_mac_monitor_vdev_start(ar, ar->monitor_vdev_id, chandef); in ath12k_mac_monitor_start()
1046 ath12k_warn(ar->ab, "failed to start monitor vdev: %d\n", ret); in ath12k_mac_monitor_start()
1051 ar->monitor_started = true; in ath12k_mac_monitor_start()
1052 ar->num_started_vdevs++; in ath12k_mac_monitor_start()
1054 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor started ret %d\n", ret); in ath12k_mac_monitor_start()
1063 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_stop()
1065 if (!ar->monitor_started) in ath12k_mac_monitor_stop()
1070 ath12k_warn(ar->ab, "failed to stop monitor vdev: %d\n", ret); in ath12k_mac_monitor_stop()
1074 ar->monitor_started = false; in ath12k_mac_monitor_stop()
1075 ar->num_started_vdevs--; in ath12k_mac_monitor_stop()
1077 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac monitor stopped ret %d\n", ret); in ath12k_mac_monitor_stop()
1081 static int ath12k_mac_op_config(struct ieee80211_hw *hw, u32 changed) in ath12k_mac_op_config() argument
1083 struct ath12k *ar = hw->priv; in ath12k_mac_op_config()
1084 struct ieee80211_conf *conf = &hw->conf; in ath12k_mac_op_config()
1087 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_config()
1090 ar->monitor_conf_enabled = conf->flags & IEEE80211_CONF_MONITOR; in ath12k_mac_op_config()
1091 if (ar->monitor_conf_enabled) { in ath12k_mac_op_config()
1092 if (ar->monitor_vdev_created) in ath12k_mac_op_config()
1101 if (!ar->monitor_vdev_created) in ath12k_mac_op_config()
1111 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_config()
1116 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_config()
1122 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_bcn_tmpl()
1123 struct ath12k_base *ab = ar->ab; in ath12k_mac_setup_bcn_tmpl()
1124 struct ieee80211_hw *hw = ar->hw; in ath12k_mac_setup_bcn_tmpl() local
1125 struct ieee80211_vif *vif = arvif->vif; in ath12k_mac_setup_bcn_tmpl()
1132 if (arvif->vdev_type != WMI_VDEV_TYPE_AP) in ath12k_mac_setup_bcn_tmpl()
1135 bcn = ieee80211_beacon_get_template(hw, vif, &offs, 0); in ath12k_mac_setup_bcn_tmpl()
1138 return -EPERM; in ath12k_mac_setup_bcn_tmpl()
1141 ies = bcn->data + ieee80211_get_hdrlen_from_skb(bcn); in ath12k_mac_setup_bcn_tmpl()
1142 ies += sizeof(mgmt->u.beacon); in ath12k_mac_setup_bcn_tmpl()
1144 if (cfg80211_find_ie(WLAN_EID_RSN, ies, (skb_tail_pointer(bcn) - ies))) in ath12k_mac_setup_bcn_tmpl()
1145 arvif->rsnie_present = true; in ath12k_mac_setup_bcn_tmpl()
1149 ies, (skb_tail_pointer(bcn) - ies))) in ath12k_mac_setup_bcn_tmpl()
1150 arvif->wpaie_present = true; in ath12k_mac_setup_bcn_tmpl()
1152 ret = ath12k_wmi_bcn_tmpl(ar, arvif->vdev_id, &offs, bcn); in ath12k_mac_setup_bcn_tmpl()
1166 struct ath12k *ar = arvif->ar; in ath12k_control_beaconing()
1169 lockdep_assert_held(&arvif->ar->conf_mutex); in ath12k_control_beaconing()
1171 if (!info->enable_beacon) { in ath12k_control_beaconing()
1172 ret = ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_control_beaconing()
1174 ath12k_warn(ar->ab, "failed to down vdev_id %i: %d\n", in ath12k_control_beaconing()
1175 arvif->vdev_id, ret); in ath12k_control_beaconing()
1177 arvif->is_up = false; in ath12k_control_beaconing()
1184 ath12k_warn(ar->ab, "failed to update bcn tmpl during vdev up: %d\n", in ath12k_control_beaconing()
1189 arvif->aid = 0; in ath12k_control_beaconing()
1191 ether_addr_copy(arvif->bssid, info->bssid); in ath12k_control_beaconing()
1193 ret = ath12k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, in ath12k_control_beaconing()
1194 arvif->bssid); in ath12k_control_beaconing()
1196 ath12k_warn(ar->ab, "failed to bring up vdev %d: %i\n", in ath12k_control_beaconing()
1197 arvif->vdev_id, ret); in ath12k_control_beaconing()
1201 arvif->is_up = true; in ath12k_control_beaconing()
1203 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d up\n", arvif->vdev_id); in ath12k_control_beaconing()
1211 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_peer_assoc_h_basic()
1214 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_basic()
1216 if (vif->type == NL80211_IFTYPE_STATION) in ath12k_peer_assoc_h_basic()
1217 aid = vif->cfg.aid; in ath12k_peer_assoc_h_basic()
1219 aid = sta->aid; in ath12k_peer_assoc_h_basic()
1221 ether_addr_copy(arg->peer_mac, sta->addr); in ath12k_peer_assoc_h_basic()
1222 arg->vdev_id = arvif->vdev_id; in ath12k_peer_assoc_h_basic()
1223 arg->peer_associd = aid; in ath12k_peer_assoc_h_basic()
1224 arg->auth_flag = true; in ath12k_peer_assoc_h_basic()
1226 arg->peer_listen_intval = ar->hw->conf.listen_interval; in ath12k_peer_assoc_h_basic()
1227 arg->peer_nss = 1; in ath12k_peer_assoc_h_basic()
1228 arg->peer_caps = vif->bss_conf.assoc_capability; in ath12k_peer_assoc_h_basic()
1236 struct ieee80211_bss_conf *info = &vif->bss_conf; in ath12k_peer_assoc_h_crypto()
1239 struct ath12k_vif *arvif = (struct ath12k_vif *)vif->drv_priv; in ath12k_peer_assoc_h_crypto()
1243 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_crypto()
1248 bss = cfg80211_get_bss(ar->hw->wiphy, def.chan, info->bssid, NULL, 0, in ath12k_peer_assoc_h_crypto()
1251 if (arvif->rsnie_present || arvif->wpaie_present) { in ath12k_peer_assoc_h_crypto()
1252 arg->need_ptk_4_way = true; in ath12k_peer_assoc_h_crypto()
1253 if (arvif->wpaie_present) in ath12k_peer_assoc_h_crypto()
1254 arg->need_gtk_2_way = true; in ath12k_peer_assoc_h_crypto()
1261 ies = rcu_dereference(bss->ies); in ath12k_peer_assoc_h_crypto()
1265 ies->data, in ath12k_peer_assoc_h_crypto()
1266 ies->len); in ath12k_peer_assoc_h_crypto()
1268 cfg80211_put_bss(ar->hw->wiphy, bss); in ath12k_peer_assoc_h_crypto()
1273 ath12k_dbg(ar->ab, ATH12K_DBG_WMI, in ath12k_peer_assoc_h_crypto()
1275 arg->need_ptk_4_way = true; in ath12k_peer_assoc_h_crypto()
1279 ath12k_dbg(ar->ab, ATH12K_DBG_WMI, in ath12k_peer_assoc_h_crypto()
1281 arg->need_gtk_2_way = true; in ath12k_peer_assoc_h_crypto()
1284 if (sta->mfp) { in ath12k_peer_assoc_h_crypto()
1286 arg->is_pmf_enabled = true; in ath12k_peer_assoc_h_crypto()
1289 /* TODO: safe_mode_enabled (bypass 4-way handshake) flag req? */ in ath12k_peer_assoc_h_crypto()
1297 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_peer_assoc_h_rates()
1298 struct wmi_rate_set_arg *rateset = &arg->peer_legacy_rates; in ath12k_peer_assoc_h_rates()
1307 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_rates()
1312 band = def.chan->band; in ath12k_peer_assoc_h_rates()
1313 sband = ar->hw->wiphy->bands[band]; in ath12k_peer_assoc_h_rates()
1314 ratemask = sta->deflink.supp_rates[band]; in ath12k_peer_assoc_h_rates()
1315 ratemask &= arvif->bitrate_mask.control[band].legacy; in ath12k_peer_assoc_h_rates()
1316 rates = sband->bitrates; in ath12k_peer_assoc_h_rates()
1318 rateset->num_rates = 0; in ath12k_peer_assoc_h_rates()
1324 rate = ath12k_mac_bitrate_to_rate(rates->bitrate); in ath12k_peer_assoc_h_rates()
1325 rateset->rates[rateset->num_rates] = rate; in ath12k_peer_assoc_h_rates()
1326 rateset->num_rates++; in ath12k_peer_assoc_h_rates()
1359 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in ath12k_peer_assoc_h_ht()
1360 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_peer_assoc_h_ht()
1368 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_ht()
1373 if (!ht_cap->ht_supported) in ath12k_peer_assoc_h_ht()
1376 band = def.chan->band; in ath12k_peer_assoc_h_ht()
1377 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath12k_peer_assoc_h_ht()
1382 arg->ht_flag = true; in ath12k_peer_assoc_h_ht()
1384 arg->peer_max_mpdu = (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_ht()
1385 ht_cap->ampdu_factor)) - 1; in ath12k_peer_assoc_h_ht()
1387 arg->peer_mpdu_density = in ath12k_peer_assoc_h_ht()
1388 ath12k_parse_mpdudensity(ht_cap->ampdu_density); in ath12k_peer_assoc_h_ht()
1390 arg->peer_ht_caps = ht_cap->cap; in ath12k_peer_assoc_h_ht()
1391 arg->peer_rate_caps |= WMI_HOST_RC_HT_FLAG; in ath12k_peer_assoc_h_ht()
1393 if (ht_cap->cap & IEEE80211_HT_CAP_LDPC_CODING) in ath12k_peer_assoc_h_ht()
1394 arg->ldpc_flag = true; in ath12k_peer_assoc_h_ht()
1396 if (sta->deflink.bandwidth >= IEEE80211_STA_RX_BW_40) { in ath12k_peer_assoc_h_ht()
1397 arg->bw_40 = true; in ath12k_peer_assoc_h_ht()
1398 arg->peer_rate_caps |= WMI_HOST_RC_CW40_FLAG; in ath12k_peer_assoc_h_ht()
1401 if (arvif->bitrate_mask.control[band].gi != NL80211_TXRATE_FORCE_LGI) { in ath12k_peer_assoc_h_ht()
1402 if (ht_cap->cap & (IEEE80211_HT_CAP_SGI_20 | in ath12k_peer_assoc_h_ht()
1404 arg->peer_rate_caps |= WMI_HOST_RC_SGI_FLAG; in ath12k_peer_assoc_h_ht()
1407 if (ht_cap->cap & IEEE80211_HT_CAP_TX_STBC) { in ath12k_peer_assoc_h_ht()
1408 arg->peer_rate_caps |= WMI_HOST_RC_TX_STBC_FLAG; in ath12k_peer_assoc_h_ht()
1409 arg->stbc_flag = true; in ath12k_peer_assoc_h_ht()
1412 if (ht_cap->cap & IEEE80211_HT_CAP_RX_STBC) { in ath12k_peer_assoc_h_ht()
1413 stbc = ht_cap->cap & IEEE80211_HT_CAP_RX_STBC; in ath12k_peer_assoc_h_ht()
1416 arg->peer_rate_caps |= stbc; in ath12k_peer_assoc_h_ht()
1417 arg->stbc_flag = true; in ath12k_peer_assoc_h_ht()
1420 if (ht_cap->mcs.rx_mask[1] && ht_cap->mcs.rx_mask[2]) in ath12k_peer_assoc_h_ht()
1421 arg->peer_rate_caps |= WMI_HOST_RC_TS_FLAG; in ath12k_peer_assoc_h_ht()
1422 else if (ht_cap->mcs.rx_mask[1]) in ath12k_peer_assoc_h_ht()
1423 arg->peer_rate_caps |= WMI_HOST_RC_DS_FLAG; in ath12k_peer_assoc_h_ht()
1426 if ((ht_cap->mcs.rx_mask[i / 8] & BIT(i % 8)) && in ath12k_peer_assoc_h_ht()
1429 arg->peer_ht_rates.rates[n++] = i; in ath12k_peer_assoc_h_ht()
1432 /* This is a workaround for HT-enabled STAs which break the spec in ath12k_peer_assoc_h_ht()
1441 arg->peer_ht_rates.num_rates = 8; in ath12k_peer_assoc_h_ht()
1442 for (i = 0; i < arg->peer_ht_rates.num_rates; i++) in ath12k_peer_assoc_h_ht()
1443 arg->peer_ht_rates.rates[i] = i; in ath12k_peer_assoc_h_ht()
1445 arg->peer_ht_rates.num_rates = n; in ath12k_peer_assoc_h_ht()
1446 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath12k_peer_assoc_h_ht()
1449 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac ht peer %pM mcs cnt %d nss %d\n", in ath12k_peer_assoc_h_ht()
1450 arg->peer_mac, in ath12k_peer_assoc_h_ht()
1451 arg->peer_ht_rates.num_rates, in ath12k_peer_assoc_h_ht()
1452 arg->peer_nss); in ath12k_peer_assoc_h_ht()
1458 case IEEE80211_VHT_MCS_SUPPORT_0_7: return BIT(8) - 1; in ath12k_mac_get_max_vht_mcs_map()
1459 case IEEE80211_VHT_MCS_SUPPORT_0_8: return BIT(9) - 1; in ath12k_mac_get_max_vht_mcs_map()
1460 case IEEE80211_VHT_MCS_SUPPORT_0_9: return BIT(10) - 1; in ath12k_mac_get_max_vht_mcs_map()
1479 idx_limit = fls(mcs_map) - 1; in ath12k_peer_assoc_h_vht_limit()
1481 idx_limit = -1; in ath12k_peer_assoc_h_vht_limit()
1503 case -1: in ath12k_peer_assoc_h_vht_limit()
1520 const struct ieee80211_sta_vht_cap *vht_cap = &sta->deflink.vht_cap; in ath12k_peer_assoc_h_vht()
1521 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_peer_assoc_h_vht()
1533 if (!vht_cap->vht_supported) in ath12k_peer_assoc_h_vht()
1536 band = def.chan->band; in ath12k_peer_assoc_h_vht()
1537 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath12k_peer_assoc_h_vht()
1542 arg->vht_flag = true; in ath12k_peer_assoc_h_vht()
1545 arg->vht_capable = true; in ath12k_peer_assoc_h_vht()
1547 if (def.chan->band == NL80211_BAND_2GHZ) in ath12k_peer_assoc_h_vht()
1548 arg->vht_ng_flag = true; in ath12k_peer_assoc_h_vht()
1550 arg->peer_vht_caps = vht_cap->cap; in ath12k_peer_assoc_h_vht()
1552 ampdu_factor = (vht_cap->cap & in ath12k_peer_assoc_h_vht()
1556 /* Workaround: Some Netgear/Linksys 11ac APs set Rx A-MPDU factor to in ath12k_peer_assoc_h_vht()
1558 * arg->peer_max_mpdu at this point contains HT max_mpdu so keep in ath12k_peer_assoc_h_vht()
1561 arg->peer_max_mpdu = max(arg->peer_max_mpdu, in ath12k_peer_assoc_h_vht()
1563 ampdu_factor)) - 1); in ath12k_peer_assoc_h_vht()
1565 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_peer_assoc_h_vht()
1566 arg->bw_80 = true; in ath12k_peer_assoc_h_vht()
1568 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) in ath12k_peer_assoc_h_vht()
1569 arg->bw_160 = true; in ath12k_peer_assoc_h_vht()
1575 vht_mcs = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map) >> in ath12k_peer_assoc_h_vht()
1582 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath12k_peer_assoc_h_vht()
1583 arg->rx_max_rate = __le16_to_cpu(vht_cap->vht_mcs.rx_highest); in ath12k_peer_assoc_h_vht()
1584 arg->rx_mcs_set = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map); in ath12k_peer_assoc_h_vht()
1585 arg->tx_max_rate = __le16_to_cpu(vht_cap->vht_mcs.tx_highest); in ath12k_peer_assoc_h_vht()
1587 tx_mcs_map = __le16_to_cpu(vht_cap->vht_mcs.tx_mcs_map); in ath12k_peer_assoc_h_vht()
1588 arg->tx_mcs_set = ath12k_peer_assoc_h_vht_limit(tx_mcs_map, vht_mcs_mask); in ath12k_peer_assoc_h_vht()
1594 arg->tx_mcs_set &= ~IEEE80211_VHT_MCS_SUPPORT_0_11_MASK; in ath12k_peer_assoc_h_vht()
1595 arg->tx_mcs_set |= IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11; in ath12k_peer_assoc_h_vht()
1597 if ((arg->tx_mcs_set & IEEE80211_VHT_MCS_NOT_SUPPORTED) == in ath12k_peer_assoc_h_vht()
1599 arg->peer_vht_caps &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; in ath12k_peer_assoc_h_vht()
1602 arg->tx_max_mcs_nss = 0xFF; in ath12k_peer_assoc_h_vht()
1604 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vht peer %pM max_mpdu %d flags 0x%x\n", in ath12k_peer_assoc_h_vht()
1605 sta->addr, arg->peer_max_mpdu, arg->peer_flags); in ath12k_peer_assoc_h_vht()
1615 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath12k_peer_assoc_h_he()
1622 if (!he_cap->has_he) in ath12k_peer_assoc_h_he()
1625 arg->he_flag = true; in ath12k_peer_assoc_h_he()
1627 support_160 = !!(he_cap->he_cap_elem.phy_cap_info[0] & in ath12k_peer_assoc_h_he()
1630 /* Supported HE-MCS and NSS Set of peer he_cap is intersection with self he_cp */ in ath12k_peer_assoc_h_he()
1631 mcs_160_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160); in ath12k_peer_assoc_h_he()
1632 mcs_80_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80); in ath12k_peer_assoc_h_he()
1635 for (i = 7; i >= 0; i--) { in ath12k_peer_assoc_h_he()
1645 for (i = 7; i >= 0; i--) { in ath12k_peer_assoc_h_he()
1659 arg->peer_nss = min(sta->deflink.rx_nss, max_nss); in ath12k_peer_assoc_h_he()
1661 memcpy(&arg->peer_he_cap_macinfo, he_cap->he_cap_elem.mac_cap_info, in ath12k_peer_assoc_h_he()
1662 sizeof(he_cap->he_cap_elem.mac_cap_info)); in ath12k_peer_assoc_h_he()
1663 memcpy(&arg->peer_he_cap_phyinfo, he_cap->he_cap_elem.phy_cap_info, in ath12k_peer_assoc_h_he()
1664 sizeof(he_cap->he_cap_elem.phy_cap_info)); in ath12k_peer_assoc_h_he()
1665 arg->peer_he_ops = vif->bss_conf.he_oper.params; in ath12k_peer_assoc_h_he()
1668 arg->peer_he_ops &= 0xffffff; in ath12k_peer_assoc_h_he()
1671 * Exponent Extension in HE cap is zero, use the arg->peer_max_mpdu in ath12k_peer_assoc_h_he()
1675 * For non-zero value of Max AMPDU Exponent Extension in HE MAC caps, in ath12k_peer_assoc_h_he()
1682 ampdu_factor = (he_cap->he_cap_elem.mac_cap_info[3] & in ath12k_peer_assoc_h_he()
1687 if (sta->deflink.vht_cap.vht_supported) in ath12k_peer_assoc_h_he()
1688 arg->peer_max_mpdu = (1 << (IEEE80211_HE_VHT_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_he()
1689 ampdu_factor)) - 1; in ath12k_peer_assoc_h_he()
1690 else if (sta->deflink.ht_cap.ht_supported) in ath12k_peer_assoc_h_he()
1691 arg->peer_max_mpdu = (1 << (IEEE80211_HE_HT_MAX_AMPDU_FACTOR + in ath12k_peer_assoc_h_he()
1692 ampdu_factor)) - 1; in ath12k_peer_assoc_h_he()
1695 if (he_cap->he_cap_elem.phy_cap_info[6] & in ath12k_peer_assoc_h_he()
1700 arg->peer_ppet.numss_m1 = he_cap->ppe_thres[0] & in ath12k_peer_assoc_h_he()
1702 arg->peer_ppet.ru_bit_mask = in ath12k_peer_assoc_h_he()
1703 (he_cap->ppe_thres[0] & in ath12k_peer_assoc_h_he()
1707 for (nss = 0; nss <= arg->peer_ppet.numss_m1; nss++) { in ath12k_peer_assoc_h_he()
1712 if ((arg->peer_ppet.ru_bit_mask & BIT(ru)) == 0) in ath12k_peer_assoc_h_he()
1716 val |= ((he_cap->ppe_thres[bit / 8] >> in ath12k_peer_assoc_h_he()
1720 arg->peer_ppet.ppet16_ppet8_ru3_ru0[nss] |= in ath12k_peer_assoc_h_he()
1726 if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_RES) in ath12k_peer_assoc_h_he()
1727 arg->twt_responder = true; in ath12k_peer_assoc_h_he()
1728 if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_REQ) in ath12k_peer_assoc_h_he()
1729 arg->twt_requester = true; in ath12k_peer_assoc_h_he()
1731 switch (sta->deflink.bandwidth) { in ath12k_peer_assoc_h_he()
1733 if (he_cap->he_cap_elem.phy_cap_info[0] & in ath12k_peer_assoc_h_he()
1735 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80p80); in ath12k_peer_assoc_h_he()
1736 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v; in ath12k_peer_assoc_h_he()
1738 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80p80); in ath12k_peer_assoc_h_he()
1739 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v; in ath12k_peer_assoc_h_he()
1741 arg->peer_he_mcs_count++; in ath12k_peer_assoc_h_he()
1743 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160); in ath12k_peer_assoc_h_he()
1744 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v; in ath12k_peer_assoc_h_he()
1746 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_160); in ath12k_peer_assoc_h_he()
1747 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v; in ath12k_peer_assoc_h_he()
1749 arg->peer_he_mcs_count++; in ath12k_peer_assoc_h_he()
1753 v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80); in ath12k_peer_assoc_h_he()
1754 arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v; in ath12k_peer_assoc_h_he()
1756 v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80); in ath12k_peer_assoc_h_he()
1757 arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v; in ath12k_peer_assoc_h_he()
1759 arg->peer_he_mcs_count++; in ath12k_peer_assoc_h_he()
1767 const struct ieee80211_sta_ht_cap *ht_cap = &sta->deflink.ht_cap; in ath12k_peer_assoc_h_smps()
1770 if (!ht_cap->ht_supported) in ath12k_peer_assoc_h_smps()
1773 smps = ht_cap->cap & IEEE80211_HT_CAP_SM_PS; in ath12k_peer_assoc_h_smps()
1778 arg->static_mimops_flag = true; in ath12k_peer_assoc_h_smps()
1781 arg->dynamic_mimops_flag = true; in ath12k_peer_assoc_h_smps()
1784 arg->spatial_mux_flag = true; in ath12k_peer_assoc_h_smps()
1796 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_peer_assoc_h_qos()
1798 switch (arvif->vdev_type) { in ath12k_peer_assoc_h_qos()
1800 if (sta->wme) { in ath12k_peer_assoc_h_qos()
1802 arg->is_wme_set = true; in ath12k_peer_assoc_h_qos()
1803 arg->qos_flag = true; in ath12k_peer_assoc_h_qos()
1806 if (sta->wme && sta->uapsd_queues) { in ath12k_peer_assoc_h_qos()
1808 arg->is_wme_set = true; in ath12k_peer_assoc_h_qos()
1809 arg->apsd_flag = true; in ath12k_peer_assoc_h_qos()
1810 arg->peer_rate_caps |= WMI_HOST_RC_UAPSD_FLAG; in ath12k_peer_assoc_h_qos()
1814 if (sta->wme) { in ath12k_peer_assoc_h_qos()
1815 arg->is_wme_set = true; in ath12k_peer_assoc_h_qos()
1816 arg->qos_flag = true; in ath12k_peer_assoc_h_qos()
1823 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac peer %pM qos %d\n", in ath12k_peer_assoc_h_qos()
1824 sta->addr, arg->qos_flag); in ath12k_peer_assoc_h_qos()
1836 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_qos_ap()
1838 arg.vdev_id = arvif->vdev_id; in ath12k_peer_assoc_qos_ap()
1840 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac uapsd_queues 0x%x max_sp %d\n", in ath12k_peer_assoc_qos_ap()
1841 sta->uapsd_queues, sta->max_sp); in ath12k_peer_assoc_qos_ap()
1844 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VO) in ath12k_peer_assoc_qos_ap()
1847 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_VI) in ath12k_peer_assoc_qos_ap()
1850 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BK) in ath12k_peer_assoc_qos_ap()
1853 if (sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_BE) in ath12k_peer_assoc_qos_ap()
1858 if (sta->max_sp < MAX_WMI_AP_PS_PEER_PARAM_MAX_SP) in ath12k_peer_assoc_qos_ap()
1859 max_sp = sta->max_sp; in ath12k_peer_assoc_qos_ap()
1863 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
1869 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
1876 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
1882 ret = ath12k_wmi_send_set_ap_ps_param_cmd(ar, sta->addr, &arg); in ath12k_peer_assoc_qos_ap()
1889 ath12k_warn(ar->ab, "failed to set ap ps peer param %d for vdev %i: %d\n", in ath12k_peer_assoc_qos_ap()
1890 arg.param, arvif->vdev_id, ret); in ath12k_peer_assoc_qos_ap()
1896 return sta->deflink.supp_rates[NL80211_BAND_2GHZ] >> in ath12k_mac_sta_has_ofdm_only()
1903 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath12k_mac_get_phymode_vht()
1904 switch (sta->deflink.vht_cap.cap & in ath12k_mac_get_phymode_vht()
1916 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_mac_get_phymode_vht()
1919 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_mac_get_phymode_vht()
1922 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath12k_mac_get_phymode_vht()
1931 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath12k_mac_get_phymode_he()
1932 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_he()
1935 else if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_he()
1942 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_mac_get_phymode_he()
1945 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_mac_get_phymode_he()
1948 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath12k_mac_get_phymode_he()
1957 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_320) in ath12k_mac_get_phymode_eht()
1958 if (sta->deflink.eht_cap.eht_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_eht()
1962 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160) { in ath12k_mac_get_phymode_eht()
1963 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_eht()
1967 if (sta->deflink.he_cap.he_cap_elem.phy_cap_info[0] & in ath12k_mac_get_phymode_eht()
1971 ath12k_warn(ar->ab, "invalid EHT PHY capability info for 160 Mhz: %d\n", in ath12k_mac_get_phymode_eht()
1972 sta->deflink.he_cap.he_cap_elem.phy_cap_info[0]); in ath12k_mac_get_phymode_eht()
1977 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_mac_get_phymode_eht()
1980 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_mac_get_phymode_eht()
1983 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_20) in ath12k_mac_get_phymode_eht()
1994 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_peer_assoc_h_phymode()
2004 band = def.chan->band; in ath12k_peer_assoc_h_phymode()
2005 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath12k_peer_assoc_h_phymode()
2006 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath12k_peer_assoc_h_phymode()
2010 if (sta->deflink.eht_cap.has_eht) { in ath12k_peer_assoc_h_phymode()
2011 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2015 } else if (sta->deflink.he_cap.has_he) { in ath12k_peer_assoc_h_phymode()
2016 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80) in ath12k_peer_assoc_h_phymode()
2018 else if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2022 } else if (sta->deflink.vht_cap.vht_supported && in ath12k_peer_assoc_h_phymode()
2024 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2028 } else if (sta->deflink.ht_cap.ht_supported && in ath12k_peer_assoc_h_phymode()
2030 if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2043 if (sta->deflink.eht_cap.has_eht) { in ath12k_peer_assoc_h_phymode()
2045 } else if (sta->deflink.he_cap.has_he) { in ath12k_peer_assoc_h_phymode()
2047 } else if (sta->deflink.vht_cap.vht_supported && in ath12k_peer_assoc_h_phymode()
2050 } else if (sta->deflink.ht_cap.ht_supported && in ath12k_peer_assoc_h_phymode()
2052 if (sta->deflink.bandwidth >= IEEE80211_STA_RX_BW_40) in ath12k_peer_assoc_h_phymode()
2064 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac peer %pM phymode %s\n", in ath12k_peer_assoc_h_phymode()
2065 sta->addr, ath12k_mac_phymode_str(phymode)); in ath12k_peer_assoc_h_phymode()
2067 arg->peer_phymode = phymode; in ath12k_peer_assoc_h_phymode()
2111 ppet->numss_m1 = u8_get_bits(ppe_thres[0], IEEE80211_EHT_PPE_THRES_NSS_MASK); in ath12k_mac_set_eht_ppe_threshold()
2112 ppet->ru_bit_mask = u16_get_bits(get_unaligned_le16(ppe_thres), in ath12k_mac_set_eht_ppe_threshold()
2115 for (nss = 0; nss <= ppet->numss_m1; nss++) { in ath12k_mac_set_eht_ppe_threshold()
2119 if ((ppet->ru_bit_mask & BIT(ru)) == 0) in ath12k_mac_set_eht_ppe_threshold()
2128 ppet->ppet16_ppet8_ru3_ru0[nss] |= in ath12k_mac_set_eht_ppe_threshold()
2139 const struct ieee80211_sta_eht_cap *eht_cap = &sta->deflink.eht_cap; in ath12k_peer_assoc_h_eht()
2140 const struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; in ath12k_peer_assoc_h_eht()
2143 struct ath12k_vif *arvif = (struct ath12k_vif *)vif->drv_priv; in ath12k_peer_assoc_h_eht()
2146 if (!sta->deflink.he_cap.has_he || !eht_cap->has_eht) in ath12k_peer_assoc_h_eht()
2149 arg->eht_flag = true; in ath12k_peer_assoc_h_eht()
2151 if ((eht_cap->eht_cap_elem.phy_cap_info[5] & in ath12k_peer_assoc_h_eht()
2153 eht_cap->eht_ppe_thres[0] != 0) in ath12k_peer_assoc_h_eht()
2154 ath12k_mac_set_eht_ppe_threshold(eht_cap->eht_ppe_thres, in ath12k_peer_assoc_h_eht()
2155 &arg->peer_eht_ppet); in ath12k_peer_assoc_h_eht()
2157 memcpy(arg->peer_eht_cap_mac, eht_cap->eht_cap_elem.mac_cap_info, in ath12k_peer_assoc_h_eht()
2158 sizeof(eht_cap->eht_cap_elem.mac_cap_info)); in ath12k_peer_assoc_h_eht()
2159 memcpy(arg->peer_eht_cap_phy, eht_cap->eht_cap_elem.phy_cap_info, in ath12k_peer_assoc_h_eht()
2160 sizeof(eht_cap->eht_cap_elem.phy_cap_info)); in ath12k_peer_assoc_h_eht()
2162 rx_mcs = arg->peer_eht_rx_mcs_set; in ath12k_peer_assoc_h_eht()
2163 tx_mcs = arg->peer_eht_tx_mcs_set; in ath12k_peer_assoc_h_eht()
2165 switch (sta->deflink.bandwidth) { in ath12k_peer_assoc_h_eht()
2167 bw = &eht_cap->eht_mcs_nss_supp.bw._320; in ath12k_peer_assoc_h_eht()
2168 ath12k_mac_set_eht_mcs(bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2169 bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2170 bw->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2171 bw->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2174 arg->peer_eht_mcs_count++; in ath12k_peer_assoc_h_eht()
2177 bw = &eht_cap->eht_mcs_nss_supp.bw._160; in ath12k_peer_assoc_h_eht()
2178 ath12k_mac_set_eht_mcs(bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2179 bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2180 bw->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2181 bw->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2184 arg->peer_eht_mcs_count++; in ath12k_peer_assoc_h_eht()
2187 if ((he_cap->he_cap_elem.phy_cap_info[0] & in ath12k_peer_assoc_h_eht()
2192 bw_20 = &eht_cap->eht_mcs_nss_supp.only_20mhz; in ath12k_peer_assoc_h_eht()
2194 ath12k_mac_set_eht_mcs(bw_20->rx_tx_mcs7_max_nss, in ath12k_peer_assoc_h_eht()
2195 bw_20->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2196 bw_20->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2197 bw_20->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2201 bw = &eht_cap->eht_mcs_nss_supp.bw._80; in ath12k_peer_assoc_h_eht()
2202 ath12k_mac_set_eht_mcs(bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2203 bw->rx_tx_mcs9_max_nss, in ath12k_peer_assoc_h_eht()
2204 bw->rx_tx_mcs11_max_nss, in ath12k_peer_assoc_h_eht()
2205 bw->rx_tx_mcs13_max_nss, in ath12k_peer_assoc_h_eht()
2210 arg->peer_eht_mcs_count++; in ath12k_peer_assoc_h_eht()
2214 arg->punct_bitmap = ~arvif->punct_bitmap; in ath12k_peer_assoc_h_eht()
2223 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_prepare()
2227 reinit_completion(&ar->peer_assoc_done); in ath12k_peer_assoc_prepare()
2229 arg->peer_new_assoc = !reassoc; in ath12k_peer_assoc_prepare()
2250 if (!ht_cap->ht_supported) in ath12k_setup_peer_smps()
2253 smps = ht_cap->cap & IEEE80211_HT_CAP_SM_PS; in ath12k_setup_peer_smps()
2257 return -EINVAL; in ath12k_setup_peer_smps()
2259 return ath12k_wmi_set_peer_param(ar, addr, arvif->vdev_id, in ath12k_setup_peer_smps()
2264 static void ath12k_bss_assoc(struct ieee80211_hw *hw, in ath12k_bss_assoc() argument
2268 struct ath12k *ar = hw->priv; in ath12k_bss_assoc()
2269 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_bss_assoc()
2276 lockdep_assert_held(&ar->conf_mutex); in ath12k_bss_assoc()
2278 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %i assoc bssid %pM aid %d\n", in ath12k_bss_assoc()
2279 arvif->vdev_id, arvif->bssid, arvif->aid); in ath12k_bss_assoc()
2283 ap_sta = ieee80211_find_sta(vif, bss_conf->bssid); in ath12k_bss_assoc()
2285 ath12k_warn(ar->ab, "failed to find station entry for bss %pM vdev %i\n", in ath12k_bss_assoc()
2286 bss_conf->bssid, arvif->vdev_id); in ath12k_bss_assoc()
2297 ath12k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n", in ath12k_bss_assoc()
2298 bss_conf->bssid, arvif->vdev_id, ret); in ath12k_bss_assoc()
2302 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath12k_bss_assoc()
2303 ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath12k_bss_assoc()
2304 bss_conf->bssid, arvif->vdev_id); in ath12k_bss_assoc()
2308 ret = ath12k_setup_peer_smps(ar, arvif, bss_conf->bssid, in ath12k_bss_assoc()
2309 &ap_sta->deflink.ht_cap); in ath12k_bss_assoc()
2311 ath12k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath12k_bss_assoc()
2312 arvif->vdev_id, ret); in ath12k_bss_assoc()
2316 WARN_ON(arvif->is_up); in ath12k_bss_assoc()
2318 arvif->aid = vif->cfg.aid; in ath12k_bss_assoc()
2319 ether_addr_copy(arvif->bssid, bss_conf->bssid); in ath12k_bss_assoc()
2321 ret = ath12k_wmi_vdev_up(ar, arvif->vdev_id, arvif->aid, arvif->bssid); in ath12k_bss_assoc()
2323 ath12k_warn(ar->ab, "failed to set vdev %d up: %d\n", in ath12k_bss_assoc()
2324 arvif->vdev_id, ret); in ath12k_bss_assoc()
2328 arvif->is_up = true; in ath12k_bss_assoc()
2330 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_bss_assoc()
2332 arvif->vdev_id, bss_conf->bssid, vif->cfg.aid); in ath12k_bss_assoc()
2334 spin_lock_bh(&ar->ab->base_lock); in ath12k_bss_assoc()
2336 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, arvif->bssid); in ath12k_bss_assoc()
2337 if (peer && peer->is_authorized) in ath12k_bss_assoc()
2340 spin_unlock_bh(&ar->ab->base_lock); in ath12k_bss_assoc()
2344 ret = ath12k_wmi_set_peer_param(ar, arvif->bssid, in ath12k_bss_assoc()
2345 arvif->vdev_id, in ath12k_bss_assoc()
2349 ath12k_warn(ar->ab, "Unable to authorize BSS peer: %d\n", ret); in ath12k_bss_assoc()
2352 ret = ath12k_wmi_send_obss_spr_cmd(ar, arvif->vdev_id, in ath12k_bss_assoc()
2353 &bss_conf->he_obss_pd); in ath12k_bss_assoc()
2355 ath12k_warn(ar->ab, "failed to set vdev %i OBSS PD parameters: %d\n", in ath12k_bss_assoc()
2356 arvif->vdev_id, ret); in ath12k_bss_assoc()
2359 static void ath12k_bss_disassoc(struct ieee80211_hw *hw, in ath12k_bss_disassoc() argument
2362 struct ath12k *ar = hw->priv; in ath12k_bss_disassoc()
2363 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_bss_disassoc()
2366 lockdep_assert_held(&ar->conf_mutex); in ath12k_bss_disassoc()
2368 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %i disassoc bssid %pM\n", in ath12k_bss_disassoc()
2369 arvif->vdev_id, arvif->bssid); in ath12k_bss_disassoc()
2371 ret = ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_bss_disassoc()
2373 ath12k_warn(ar->ab, "failed to down vdev %i: %d\n", in ath12k_bss_disassoc()
2374 arvif->vdev_id, ret); in ath12k_bss_disassoc()
2376 arvif->is_up = false; in ath12k_bss_disassoc()
2403 return -EINVAL; in ath12k_mac_get_rate_hw_value()
2410 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_recalculate_mgmt_rate()
2418 lockdep_assert_held(&ar->conf_mutex); in ath12k_recalculate_mgmt_rate()
2420 sband = ar->hw->wiphy->bands[def->chan->band]; in ath12k_recalculate_mgmt_rate()
2421 basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1; in ath12k_recalculate_mgmt_rate()
2422 bitrate = sband->bitrates[basic_rate_idx].bitrate; in ath12k_recalculate_mgmt_rate()
2426 ath12k_warn(ar->ab, "bitrate not supported %d\n", bitrate); in ath12k_recalculate_mgmt_rate()
2431 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath12k_recalculate_mgmt_rate()
2434 ath12k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret); in ath12k_recalculate_mgmt_rate()
2437 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, in ath12k_recalculate_mgmt_rate()
2440 ath12k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret); in ath12k_recalculate_mgmt_rate()
2446 struct ath12k *ar = arvif->ar; in ath12k_mac_fils_discovery()
2452 if (info->fils_discovery.max_interval) { in ath12k_mac_fils_discovery()
2453 interval = info->fils_discovery.max_interval; in ath12k_mac_fils_discovery()
2455 tmpl = ieee80211_get_fils_discovery_tmpl(ar->hw, arvif->vif); in ath12k_mac_fils_discovery()
2457 ret = ath12k_wmi_fils_discovery_tmpl(ar, arvif->vdev_id, in ath12k_mac_fils_discovery()
2459 } else if (info->unsol_bcast_probe_resp_interval) { in ath12k_mac_fils_discovery()
2461 interval = info->unsol_bcast_probe_resp_interval; in ath12k_mac_fils_discovery()
2463 tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(ar->hw, in ath12k_mac_fils_discovery()
2464 arvif->vif); in ath12k_mac_fils_discovery()
2466 ret = ath12k_wmi_probe_resp_tmpl(ar, arvif->vdev_id, in ath12k_mac_fils_discovery()
2469 return ath12k_wmi_fils_discovery(ar, arvif->vdev_id, 0, false); in ath12k_mac_fils_discovery()
2473 ath12k_warn(ar->ab, in ath12k_mac_fils_discovery()
2475 arvif->vdev_id, (unsol_bcast_probe_resp_enabled ? in ath12k_mac_fils_discovery()
2478 return -EPERM; in ath12k_mac_fils_discovery()
2483 ret = ath12k_wmi_fils_discovery(ar, arvif->vdev_id, interval, in ath12k_mac_fils_discovery()
2489 static void ath12k_mac_op_bss_info_changed(struct ieee80211_hw *hw, in ath12k_mac_op_bss_info_changed() argument
2494 struct ath12k *ar = hw->priv; in ath12k_mac_op_bss_info_changed()
2508 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_bss_info_changed()
2511 arvif->beacon_interval = info->beacon_int; in ath12k_mac_op_bss_info_changed()
2514 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2516 arvif->beacon_interval); in ath12k_mac_op_bss_info_changed()
2518 ath12k_warn(ar->ab, "Failed to set beacon interval for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2519 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2521 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2523 arvif->beacon_interval, arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2530 param_value, ar->pdev->pdev_id); in ath12k_mac_op_bss_info_changed()
2532 ath12k_warn(ar->ab, "Failed to set beacon mode for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2533 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2535 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2537 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2541 ath12k_warn(ar->ab, "failed to update bcn template: %d\n", in ath12k_mac_op_bss_info_changed()
2546 arvif->dtim_period = info->dtim_period; in ath12k_mac_op_bss_info_changed()
2549 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2551 arvif->dtim_period); in ath12k_mac_op_bss_info_changed()
2554 ath12k_warn(ar->ab, "Failed to set dtim period for VDEV %d: %i\n", in ath12k_mac_op_bss_info_changed()
2555 arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2557 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2559 arvif->dtim_period, arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2563 vif->type == NL80211_IFTYPE_AP) { in ath12k_mac_op_bss_info_changed()
2564 arvif->u.ap.ssid_len = vif->cfg.ssid_len; in ath12k_mac_op_bss_info_changed()
2565 if (vif->cfg.ssid_len) in ath12k_mac_op_bss_info_changed()
2566 memcpy(arvif->u.ap.ssid, vif->cfg.ssid, vif->cfg.ssid_len); in ath12k_mac_op_bss_info_changed()
2567 arvif->u.ap.hidden_ssid = info->hidden_ssid; in ath12k_mac_op_bss_info_changed()
2570 if (changed & BSS_CHANGED_BSSID && !is_zero_ether_addr(info->bssid)) in ath12k_mac_op_bss_info_changed()
2571 ether_addr_copy(arvif->bssid, info->bssid); in ath12k_mac_op_bss_info_changed()
2576 if (arvif->is_up && vif->bss_conf.he_support && in ath12k_mac_op_bss_info_changed()
2577 vif->bss_conf.he_oper.params) { in ath12k_mac_op_bss_info_changed()
2579 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2583 ath12k_warn(ar->ab, in ath12k_mac_op_bss_info_changed()
2585 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2588 param_value = vif->bss_conf.he_oper.params; in ath12k_mac_op_bss_info_changed()
2589 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2591 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2593 param_value, arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2596 ath12k_warn(ar->ab, "Failed to set he oper params %x for VDEV %d: %i\n", in ath12k_mac_op_bss_info_changed()
2597 param_value, arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2604 cts_prot = !!(info->use_cts_prot); in ath12k_mac_op_bss_info_changed()
2607 if (arvif->is_started) { in ath12k_mac_op_bss_info_changed()
2608 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2611 ath12k_warn(ar->ab, "Failed to set CTS prot for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2612 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2614 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "Set CTS prot: %d for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2615 cts_prot, arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2617 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "defer protection mode setup, vdev is not ready yet\n"); in ath12k_mac_op_bss_info_changed()
2624 if (info->use_short_slot) in ath12k_mac_op_bss_info_changed()
2631 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2634 ath12k_warn(ar->ab, "Failed to set erp slot for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2635 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2637 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2639 slottime, arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2645 if (info->use_short_preamble) in ath12k_mac_op_bss_info_changed()
2651 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2654 ath12k_warn(ar->ab, "Failed to set preamble for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2655 arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2657 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2659 preamble, arvif->vdev_id); in ath12k_mac_op_bss_info_changed()
2663 if (vif->cfg.assoc) in ath12k_mac_op_bss_info_changed()
2664 ath12k_bss_assoc(hw, vif, info); in ath12k_mac_op_bss_info_changed()
2666 ath12k_bss_disassoc(hw, vif); in ath12k_mac_op_bss_info_changed()
2670 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev_id %i txpower %d\n", in ath12k_mac_op_bss_info_changed()
2671 arvif->vdev_id, info->txpower); in ath12k_mac_op_bss_info_changed()
2673 arvif->txpower = info->txpower; in ath12k_mac_op_bss_info_changed()
2678 !ath12k_mac_vif_chan(arvif->vif, &def)) { in ath12k_mac_op_bss_info_changed()
2679 band = def.chan->band; in ath12k_mac_op_bss_info_changed()
2680 mcast_rate = vif->bss_conf.mcast_rate[band]; in ath12k_mac_op_bss_info_changed()
2683 rateidx = mcast_rate - 1; in ath12k_mac_op_bss_info_changed()
2685 rateidx = ffs(vif->bss_conf.basic_rates) - 1; in ath12k_mac_op_bss_info_changed()
2687 if (ar->pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) in ath12k_mac_op_bss_info_changed()
2700 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2702 arvif->vdev_id, rate); in ath12k_mac_op_bss_info_changed()
2705 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2708 ath12k_warn(ar->ab, in ath12k_mac_op_bss_info_changed()
2710 arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2713 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2716 ath12k_warn(ar->ab, in ath12k_mac_op_bss_info_changed()
2718 arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2722 !ath12k_mac_vif_chan(arvif->vif, &def)) in ath12k_mac_op_bss_info_changed()
2726 if (info->twt_requester || info->twt_responder) in ath12k_mac_op_bss_info_changed()
2727 ath12k_wmi_send_twt_enable_cmd(ar, ar->pdev->pdev_id); in ath12k_mac_op_bss_info_changed()
2729 ath12k_wmi_send_twt_disable_cmd(ar, ar->pdev->pdev_id); in ath12k_mac_op_bss_info_changed()
2733 ath12k_wmi_send_obss_spr_cmd(ar, arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2734 &info->he_obss_pd); in ath12k_mac_op_bss_info_changed()
2737 if (vif->type == NL80211_IFTYPE_AP) { in ath12k_mac_op_bss_info_changed()
2739 arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2740 info->he_bss_color.color, in ath12k_mac_op_bss_info_changed()
2742 info->he_bss_color.enabled); in ath12k_mac_op_bss_info_changed()
2744 ath12k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n", in ath12k_mac_op_bss_info_changed()
2745 arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2746 } else if (vif->type == NL80211_IFTYPE_STATION) { in ath12k_mac_op_bss_info_changed()
2748 arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2751 ath12k_warn(ar->ab, "failed to enable bss color change on vdev %i: %d\n", in ath12k_mac_op_bss_info_changed()
2752 arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2754 arvif->vdev_id, in ath12k_mac_op_bss_info_changed()
2759 ath12k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n", in ath12k_mac_op_bss_info_changed()
2760 arvif->vdev_id, ret); in ath12k_mac_op_bss_info_changed()
2769 arvif->punct_bitmap = info->eht_puncturing; in ath12k_mac_op_bss_info_changed()
2771 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_bss_info_changed()
2776 lockdep_assert_held(&ar->data_lock); in __ath12k_mac_scan_finish()
2778 switch (ar->scan.state) { in __ath12k_mac_scan_finish()
2783 if (!ar->scan.is_roc) { in __ath12k_mac_scan_finish()
2785 .aborted = (ar->scan.state == in __ath12k_mac_scan_finish()
2789 ieee80211_scan_completed(ar->hw, &info); in __ath12k_mac_scan_finish()
2790 } else if (ar->scan.roc_notify) { in __ath12k_mac_scan_finish()
2791 ieee80211_remain_on_channel_expired(ar->hw); in __ath12k_mac_scan_finish()
2795 ar->scan.state = ATH12K_SCAN_IDLE; in __ath12k_mac_scan_finish()
2796 ar->scan_channel = NULL; in __ath12k_mac_scan_finish()
2797 ar->scan.roc_freq = 0; in __ath12k_mac_scan_finish()
2798 cancel_delayed_work(&ar->scan.timeout); in __ath12k_mac_scan_finish()
2799 complete(&ar->scan.completed); in __ath12k_mac_scan_finish()
2806 spin_lock_bh(&ar->data_lock); in ath12k_mac_scan_finish()
2808 spin_unlock_bh(&ar->data_lock); in ath12k_mac_scan_finish()
2819 lockdep_assert_held(&ar->conf_mutex); in ath12k_scan_stop()
2822 arg.pdev_id = ar->pdev->pdev_id; in ath12k_scan_stop()
2826 ath12k_warn(ar->ab, "failed to stop wmi scan: %d\n", ret); in ath12k_scan_stop()
2830 ret = wait_for_completion_timeout(&ar->scan.completed, 3 * HZ); in ath12k_scan_stop()
2832 ath12k_warn(ar->ab, in ath12k_scan_stop()
2834 ret = -ETIMEDOUT; in ath12k_scan_stop()
2847 spin_lock_bh(&ar->data_lock); in ath12k_scan_stop()
2848 if (ar->scan.state != ATH12K_SCAN_IDLE) in ath12k_scan_stop()
2850 spin_unlock_bh(&ar->data_lock); in ath12k_scan_stop()
2859 lockdep_assert_held(&ar->conf_mutex); in ath12k_scan_abort()
2861 spin_lock_bh(&ar->data_lock); in ath12k_scan_abort()
2863 switch (ar->scan.state) { in ath12k_scan_abort()
2871 ath12k_warn(ar->ab, "refusing scan abortion due to invalid scan state: %d\n", in ath12k_scan_abort()
2872 ar->scan.state); in ath12k_scan_abort()
2875 ar->scan.state = ATH12K_SCAN_ABORTING; in ath12k_scan_abort()
2876 spin_unlock_bh(&ar->data_lock); in ath12k_scan_abort()
2880 ath12k_warn(ar->ab, "failed to abort scan: %d\n", ret); in ath12k_scan_abort()
2882 spin_lock_bh(&ar->data_lock); in ath12k_scan_abort()
2886 spin_unlock_bh(&ar->data_lock); in ath12k_scan_abort()
2894 mutex_lock(&ar->conf_mutex); in ath12k_scan_timeout_work()
2896 mutex_unlock(&ar->conf_mutex); in ath12k_scan_timeout_work()
2904 lockdep_assert_held(&ar->conf_mutex); in ath12k_start_scan()
2910 ret = wait_for_completion_timeout(&ar->scan.started, 1 * HZ); in ath12k_start_scan()
2914 ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret); in ath12k_start_scan()
2916 return -ETIMEDOUT; in ath12k_start_scan()
2923 spin_lock_bh(&ar->data_lock); in ath12k_start_scan()
2924 if (ar->scan.state == ATH12K_SCAN_IDLE) { in ath12k_start_scan()
2925 spin_unlock_bh(&ar->data_lock); in ath12k_start_scan()
2926 return -EINVAL; in ath12k_start_scan()
2928 spin_unlock_bh(&ar->data_lock); in ath12k_start_scan()
2933 static int ath12k_mac_op_hw_scan(struct ieee80211_hw *hw, in ath12k_mac_op_hw_scan() argument
2937 struct ath12k *ar = hw->priv; in ath12k_mac_op_hw_scan()
2939 struct cfg80211_scan_request *req = &hw_req->req; in ath12k_mac_op_hw_scan()
2944 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
2946 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
2947 switch (ar->scan.state) { in ath12k_mac_op_hw_scan()
2949 reinit_completion(&ar->scan.started); in ath12k_mac_op_hw_scan()
2950 reinit_completion(&ar->scan.completed); in ath12k_mac_op_hw_scan()
2951 ar->scan.state = ATH12K_SCAN_STARTING; in ath12k_mac_op_hw_scan()
2952 ar->scan.is_roc = false; in ath12k_mac_op_hw_scan()
2953 ar->scan.vdev_id = arvif->vdev_id; in ath12k_mac_op_hw_scan()
2959 ret = -EBUSY; in ath12k_mac_op_hw_scan()
2962 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
2968 arg.vdev_id = arvif->vdev_id; in ath12k_mac_op_hw_scan()
2971 if (req->ie_len) { in ath12k_mac_op_hw_scan()
2972 arg.extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL); in ath12k_mac_op_hw_scan()
2974 ret = -ENOMEM; in ath12k_mac_op_hw_scan()
2977 arg.extraie.len = req->ie_len; in ath12k_mac_op_hw_scan()
2980 if (req->n_ssids) { in ath12k_mac_op_hw_scan()
2981 arg.num_ssids = req->n_ssids; in ath12k_mac_op_hw_scan()
2983 arg.ssid[i] = req->ssids[i]; in ath12k_mac_op_hw_scan()
2988 if (req->n_channels) { in ath12k_mac_op_hw_scan()
2989 arg.num_chan = req->n_channels; in ath12k_mac_op_hw_scan()
2994 ret = -ENOMEM; in ath12k_mac_op_hw_scan()
2999 arg.chan_list[i] = req->channels[i]->center_freq; in ath12k_mac_op_hw_scan()
3004 ath12k_warn(ar->ab, "failed to start hw scan: %d\n", ret); in ath12k_mac_op_hw_scan()
3005 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
3006 ar->scan.state = ATH12K_SCAN_IDLE; in ath12k_mac_op_hw_scan()
3007 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
3011 ieee80211_queue_delayed_work(ar->hw, &ar->scan.timeout, in ath12k_mac_op_hw_scan()
3018 if (req->ie_len) in ath12k_mac_op_hw_scan()
3021 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
3025 static void ath12k_mac_op_cancel_hw_scan(struct ieee80211_hw *hw, in ath12k_mac_op_cancel_hw_scan() argument
3028 struct ath12k *ar = hw->priv; in ath12k_mac_op_cancel_hw_scan()
3030 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_cancel_hw_scan()
3032 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_cancel_hw_scan()
3034 cancel_delayed_work_sync(&ar->scan.timeout); in ath12k_mac_op_cancel_hw_scan()
3043 struct ath12k *ar = arvif->ar; in ath12k_install_key()
3045 .vdev_id = arvif->vdev_id, in ath12k_install_key()
3046 .key_idx = key->keyidx, in ath12k_install_key()
3047 .key_len = key->keylen, in ath12k_install_key()
3048 .key_data = key->key, in ath12k_install_key()
3053 lockdep_assert_held(&arvif->ar->conf_mutex); in ath12k_install_key()
3055 reinit_completion(&ar->install_key_done); in ath12k_install_key()
3057 if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) in ath12k_install_key()
3068 switch (key->cipher) { in ath12k_install_key()
3071 /* TODO: Re-check if flag is valid */ in ath12k_install_key()
3072 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT; in ath12k_install_key()
3087 ath12k_warn(ar->ab, "cipher %d is not supported\n", key->cipher); in ath12k_install_key()
3088 return -EOPNOTSUPP; in ath12k_install_key()
3091 if (test_bit(ATH12K_FLAG_RAW_MODE, &ar->ab->dev_flags)) in ath12k_install_key()
3092 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV | in ath12k_install_key()
3096 ret = ath12k_wmi_vdev_install_key(arvif->ar, &arg); in ath12k_install_key()
3101 if (!wait_for_completion_timeout(&ar->install_key_done, 1 * HZ)) in ath12k_install_key()
3102 return -ETIMEDOUT; in ath12k_install_key()
3104 if (ether_addr_equal(macaddr, arvif->vif->addr)) in ath12k_install_key()
3105 arvif->key_cipher = key->cipher; in ath12k_install_key()
3107 return ar->install_key_status ? -EINVAL : 0; in ath12k_install_key()
3113 struct ath12k *ar = arvif->ar; in ath12k_clear_peer_keys()
3114 struct ath12k_base *ab = ar->ab; in ath12k_clear_peer_keys()
3121 lockdep_assert_held(&ar->conf_mutex); in ath12k_clear_peer_keys()
3123 spin_lock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3124 peer = ath12k_peer_find(ab, arvif->vdev_id, addr); in ath12k_clear_peer_keys()
3125 spin_unlock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3128 return -ENOENT; in ath12k_clear_peer_keys()
3130 for (i = 0; i < ARRAY_SIZE(peer->keys); i++) { in ath12k_clear_peer_keys()
3131 if (!peer->keys[i]) in ath12k_clear_peer_keys()
3135 ret = ath12k_install_key(arvif, peer->keys[i], in ath12k_clear_peer_keys()
3144 spin_lock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3145 peer->keys[i] = NULL; in ath12k_clear_peer_keys()
3146 spin_unlock_bh(&ab->base_lock); in ath12k_clear_peer_keys()
3152 static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, in ath12k_mac_op_set_key() argument
3156 struct ath12k *ar = hw->priv; in ath12k_mac_op_set_key()
3157 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_set_key()
3166 if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC || in ath12k_mac_op_set_key()
3167 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || in ath12k_mac_op_set_key()
3168 key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256 || in ath12k_mac_op_set_key()
3169 key->cipher == WLAN_CIPHER_SUITE_BIP_CMAC_256) in ath12k_mac_op_set_key()
3172 if (test_bit(ATH12K_FLAG_HW_CRYPTO_DISABLED, &ar->ab->dev_flags)) in ath12k_mac_op_set_key()
3175 if (key->keyidx > WMI_MAX_KEY_INDEX) in ath12k_mac_op_set_key()
3176 return -ENOSPC; in ath12k_mac_op_set_key()
3178 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_key()
3181 peer_addr = sta->addr; in ath12k_mac_op_set_key()
3182 else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath12k_mac_op_set_key()
3183 peer_addr = vif->bss_conf.bssid; in ath12k_mac_op_set_key()
3185 peer_addr = vif->addr; in ath12k_mac_op_set_key()
3187 key->hw_key_idx = key->keyidx; in ath12k_mac_op_set_key()
3189 /* the peer should not disappear in mid-way (unless FW goes awry) since in ath12k_mac_op_set_key()
3192 spin_lock_bh(&ab->base_lock); in ath12k_mac_op_set_key()
3193 peer = ath12k_peer_find(ab, arvif->vdev_id, peer_addr); in ath12k_mac_op_set_key()
3194 spin_unlock_bh(&ab->base_lock); in ath12k_mac_op_set_key()
3198 ath12k_warn(ab, "cannot install key for non-existent peer %pM\n", in ath12k_mac_op_set_key()
3200 ret = -EOPNOTSUPP; in ath12k_mac_op_set_key()
3210 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in ath12k_mac_op_set_key()
3227 spin_lock_bh(&ab->base_lock); in ath12k_mac_op_set_key()
3228 peer = ath12k_peer_find(ab, arvif->vdev_id, peer_addr); in ath12k_mac_op_set_key()
3230 peer->keys[key->keyidx] = key; in ath12k_mac_op_set_key()
3231 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { in ath12k_mac_op_set_key()
3232 peer->ucast_keyidx = key->keyidx; in ath12k_mac_op_set_key()
3233 peer->sec_type = ath12k_dp_tx_get_encrypt_type(key->cipher); in ath12k_mac_op_set_key()
3235 peer->mcast_keyidx = key->keyidx; in ath12k_mac_op_set_key()
3236 peer->sec_type_grp = ath12k_dp_tx_get_encrypt_type(key->cipher); in ath12k_mac_op_set_key()
3239 peer->keys[key->keyidx] = NULL; in ath12k_mac_op_set_key()
3240 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) in ath12k_mac_op_set_key()
3241 peer->ucast_keyidx = 0; in ath12k_mac_op_set_key()
3243 peer->mcast_keyidx = 0; in ath12k_mac_op_set_key()
3249 arsta = (struct ath12k_sta *)sta->drv_priv; in ath12k_mac_op_set_key()
3251 switch (key->cipher) { in ath12k_mac_op_set_key()
3258 arsta->pn_type = HAL_PN_TYPE_WPA; in ath12k_mac_op_set_key()
3260 arsta->pn_type = HAL_PN_TYPE_NONE; in ath12k_mac_op_set_key()
3263 arsta->pn_type = HAL_PN_TYPE_NONE; in ath12k_mac_op_set_key()
3268 spin_unlock_bh(&ab->base_lock); in ath12k_mac_op_set_key()
3271 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_key()
3283 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) in ath12k_mac_bitrate_mask_num_vht_rates()
3284 num_rates += hweight16(mask->control[band].vht_mcs[i]); in ath12k_mac_bitrate_mask_num_vht_rates()
3295 struct ath12k *ar = arvif->ar; in ath12k_mac_set_peer_vht_fixed_rate()
3300 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_set_peer_vht_fixed_rate()
3304 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) { in ath12k_mac_set_peer_vht_fixed_rate()
3305 if (hweight16(mask->control[band].vht_mcs[i]) == 1) { in ath12k_mac_set_peer_vht_fixed_rate()
3307 vht_rate = ffs(mask->control[band].vht_mcs[i]) - 1; in ath12k_mac_set_peer_vht_fixed_rate()
3312 ath12k_warn(ar->ab, "No single VHT Fixed rate found to set for %pM", in ath12k_mac_set_peer_vht_fixed_rate()
3313 sta->addr); in ath12k_mac_set_peer_vht_fixed_rate()
3314 return -EINVAL; in ath12k_mac_set_peer_vht_fixed_rate()
3317 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_set_peer_vht_fixed_rate()
3319 sta->addr); in ath12k_mac_set_peer_vht_fixed_rate()
3321 rate_code = ATH12K_HW_RATE_CODE(vht_rate, nss - 1, in ath12k_mac_set_peer_vht_fixed_rate()
3323 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_set_peer_vht_fixed_rate()
3324 arvif->vdev_id, in ath12k_mac_set_peer_vht_fixed_rate()
3328 ath12k_warn(ar->ab, in ath12k_mac_set_peer_vht_fixed_rate()
3330 sta->addr, rate_code, ret); in ath12k_mac_set_peer_vht_fixed_rate()
3348 lockdep_assert_held(&ar->conf_mutex); in ath12k_station_assoc()
3351 return -EPERM; in ath12k_station_assoc()
3353 band = def.chan->band; in ath12k_station_assoc()
3354 mask = &arvif->bitrate_mask; in ath12k_station_assoc()
3360 ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", in ath12k_station_assoc()
3361 sta->addr, arvif->vdev_id, ret); in ath12k_station_assoc()
3365 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) { in ath12k_station_assoc()
3366 ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath12k_station_assoc()
3367 sta->addr, arvif->vdev_id); in ath12k_station_assoc()
3368 return -ETIMEDOUT; in ath12k_station_assoc()
3378 if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) { in ath12k_station_assoc()
3385 /* Re-assoc is run only to update supported rates for given station. It in ath12k_station_assoc()
3391 ret = ath12k_setup_peer_smps(ar, arvif, sta->addr, in ath12k_station_assoc()
3392 &sta->deflink.ht_cap); in ath12k_station_assoc()
3394 ath12k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath12k_station_assoc()
3395 arvif->vdev_id, ret); in ath12k_station_assoc()
3399 if (!sta->wme) { in ath12k_station_assoc()
3400 arvif->num_legacy_stations++; in ath12k_station_assoc()
3406 if (sta->wme && sta->uapsd_queues) { in ath12k_station_assoc()
3409 ath12k_warn(ar->ab, "failed to set qos params for STA %pM for vdev %i: %d\n", in ath12k_station_assoc()
3410 sta->addr, arvif->vdev_id, ret); in ath12k_station_assoc()
3422 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_station_disassoc()
3425 lockdep_assert_held(&ar->conf_mutex); in ath12k_station_disassoc()
3427 if (!sta->wme) { in ath12k_station_disassoc()
3428 arvif->num_legacy_stations--; in ath12k_station_disassoc()
3434 ret = ath12k_clear_peer_keys(arvif, sta->addr); in ath12k_station_disassoc()
3436 ath12k_warn(ar->ab, "failed to clear all peer keys for vdev %i: %d\n", in ath12k_station_disassoc()
3437 arvif->vdev_id, ret); in ath12k_station_disassoc()
3461 arvif = arsta->arvif; in ath12k_sta_rc_update_wk()
3462 ar = arvif->ar; in ath12k_sta_rc_update_wk()
3464 if (WARN_ON(ath12k_mac_vif_chan(arvif->vif, &def))) in ath12k_sta_rc_update_wk()
3467 band = def.chan->band; in ath12k_sta_rc_update_wk()
3468 ht_mcs_mask = arvif->bitrate_mask.control[band].ht_mcs; in ath12k_sta_rc_update_wk()
3469 vht_mcs_mask = arvif->bitrate_mask.control[band].vht_mcs; in ath12k_sta_rc_update_wk()
3471 spin_lock_bh(&ar->data_lock); in ath12k_sta_rc_update_wk()
3473 changed = arsta->changed; in ath12k_sta_rc_update_wk()
3474 arsta->changed = 0; in ath12k_sta_rc_update_wk()
3476 bw = arsta->bw; in ath12k_sta_rc_update_wk()
3477 bw_prev = arsta->bw_prev; in ath12k_sta_rc_update_wk()
3478 nss = arsta->nss; in ath12k_sta_rc_update_wk()
3479 smps = arsta->smps; in ath12k_sta_rc_update_wk()
3481 spin_unlock_bh(&ar->data_lock); in ath12k_sta_rc_update_wk()
3483 mutex_lock(&ar->conf_mutex); in ath12k_sta_rc_update_wk()
3490 ath12k_peer_assoc_h_phymode(ar, arvif->vif, sta, &peer_arg); in ath12k_sta_rc_update_wk()
3499 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac bandwidth upgrade for sta %pM new %d old %d\n", in ath12k_sta_rc_update_wk()
3500 sta->addr, bw, bw_prev); in ath12k_sta_rc_update_wk()
3501 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
3502 arvif->vdev_id, WMI_PEER_PHYMODE, in ath12k_sta_rc_update_wk()
3505 ath12k_warn(ar->ab, "failed to update STA %pM to peer phymode %d: %d\n", in ath12k_sta_rc_update_wk()
3506 sta->addr, peer_phymode, err); in ath12k_sta_rc_update_wk()
3509 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
3510 arvif->vdev_id, WMI_PEER_CHWIDTH, in ath12k_sta_rc_update_wk()
3513 ath12k_warn(ar->ab, "failed to update STA %pM to peer bandwidth %d: %d\n", in ath12k_sta_rc_update_wk()
3514 sta->addr, bw, err); in ath12k_sta_rc_update_wk()
3520 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac bandwidth downgrade for sta %pM new %d old %d\n", in ath12k_sta_rc_update_wk()
3521 sta->addr, bw, bw_prev); in ath12k_sta_rc_update_wk()
3522 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
3523 arvif->vdev_id, WMI_PEER_CHWIDTH, in ath12k_sta_rc_update_wk()
3526 ath12k_warn(ar->ab, "failed to update STA %pM peer to bandwidth %d: %d\n", in ath12k_sta_rc_update_wk()
3527 sta->addr, bw, err); in ath12k_sta_rc_update_wk()
3530 err = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_sta_rc_update_wk()
3531 arvif->vdev_id, WMI_PEER_PHYMODE, in ath12k_sta_rc_update_wk()
3534 ath12k_warn(ar->ab, "failed to update STA %pM to peer phymode %d: %d\n", in ath12k_sta_rc_update_wk()
3535 sta->addr, peer_phymode, err); in ath12k_sta_rc_update_wk()
3540 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac update sta %pM nss %d\n", in ath12k_sta_rc_update_wk()
3541 sta->addr, nss); in ath12k_sta_rc_update_wk()
3543 err = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath12k_sta_rc_update_wk()
3546 ath12k_warn(ar->ab, "failed to update STA %pM nss %d: %d\n", in ath12k_sta_rc_update_wk()
3547 sta->addr, nss, err); in ath12k_sta_rc_update_wk()
3551 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac update sta %pM smps %d\n", in ath12k_sta_rc_update_wk()
3552 sta->addr, smps); in ath12k_sta_rc_update_wk()
3554 err = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath12k_sta_rc_update_wk()
3557 ath12k_warn(ar->ab, "failed to update STA %pM smps %d: %d\n", in ath12k_sta_rc_update_wk()
3558 sta->addr, smps, err); in ath12k_sta_rc_update_wk()
3562 mask = &arvif->bitrate_mask; in ath12k_sta_rc_update_wk()
3570 * But, Single rate in VHT mask can be set as per-peer in ath12k_sta_rc_update_wk()
3573 * when per-peer Fixed rate is set. in ath12k_sta_rc_update_wk()
3577 if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) { in ath12k_sta_rc_update_wk()
3581 /* If the peer is non-VHT or no fixed VHT rate in ath12k_sta_rc_update_wk()
3585 ath12k_peer_assoc_prepare(ar, arvif->vif, sta, in ath12k_sta_rc_update_wk()
3590 ath12k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n", in ath12k_sta_rc_update_wk()
3591 sta->addr, arvif->vdev_id, err); in ath12k_sta_rc_update_wk()
3593 if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) in ath12k_sta_rc_update_wk()
3594 ath12k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n", in ath12k_sta_rc_update_wk()
3595 sta->addr, arvif->vdev_id); in ath12k_sta_rc_update_wk()
3599 mutex_unlock(&ar->conf_mutex); in ath12k_sta_rc_update_wk()
3605 struct ath12k *ar = arvif->ar; in ath12k_mac_inc_num_stations()
3607 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_inc_num_stations()
3609 if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls) in ath12k_mac_inc_num_stations()
3612 if (ar->num_stations >= ar->max_num_stations) in ath12k_mac_inc_num_stations()
3613 return -ENOBUFS; in ath12k_mac_inc_num_stations()
3615 ar->num_stations++; in ath12k_mac_inc_num_stations()
3623 struct ath12k *ar = arvif->ar; in ath12k_mac_dec_num_stations()
3625 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_dec_num_stations()
3627 if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls) in ath12k_mac_dec_num_stations()
3630 ar->num_stations--; in ath12k_mac_dec_num_stations()
3637 struct ath12k_base *ab = ar->ab; in ath12k_mac_station_add()
3639 struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv; in ath12k_mac_station_add()
3643 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_station_add()
3648 ar->max_num_stations); in ath12k_mac_station_add()
3652 arsta->rx_stats = kzalloc(sizeof(*arsta->rx_stats), GFP_KERNEL); in ath12k_mac_station_add()
3653 if (!arsta->rx_stats) { in ath12k_mac_station_add()
3654 ret = -ENOMEM; in ath12k_mac_station_add()
3658 peer_param.vdev_id = arvif->vdev_id; in ath12k_mac_station_add()
3659 peer_param.peer_addr = sta->addr; in ath12k_mac_station_add()
3665 sta->addr, arvif->vdev_id); in ath12k_mac_station_add()
3670 sta->addr, arvif->vdev_id); in ath12k_mac_station_add()
3673 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_station_add()
3674 arvif->vdev_id, in ath12k_mac_station_add()
3678 sta->addr, ret); in ath12k_mac_station_add()
3683 ret = ath12k_dp_peer_setup(ar, arvif->vdev_id, sta->addr); in ath12k_mac_station_add()
3686 sta->addr, arvif->vdev_id, ret); in ath12k_mac_station_add()
3690 if (ab->hw_params->vdev_start_delay && in ath12k_mac_station_add()
3691 !arvif->is_started && in ath12k_mac_station_add()
3692 arvif->vdev_type != WMI_VDEV_TYPE_AP) { in ath12k_mac_station_add()
3693 ret = ath12k_start_vdev_delay(ar->hw, vif); in ath12k_mac_station_add()
3703 ath12k_peer_delete(ar, arvif->vdev_id, sta->addr); in ath12k_mac_station_add()
3715 switch (sta->deflink.bandwidth) { in ath12k_mac_ieee80211_sta_bw_to_wmi()
3729 ath12k_warn(ar->ab, "Invalid bandwidth %d in rc update for %pM\n", in ath12k_mac_ieee80211_sta_bw_to_wmi()
3730 sta->deflink.bandwidth, sta->addr); in ath12k_mac_ieee80211_sta_bw_to_wmi()
3738 static int ath12k_mac_op_sta_state(struct ieee80211_hw *hw, in ath12k_mac_op_sta_state() argument
3744 struct ath12k *ar = hw->priv; in ath12k_mac_op_sta_state()
3746 struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv; in ath12k_mac_op_sta_state()
3753 cancel_work_sync(&arsta->update_wk); in ath12k_mac_op_sta_state()
3755 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_sta_state()
3760 arsta->arvif = arvif; in ath12k_mac_op_sta_state()
3761 INIT_WORK(&arsta->update_wk, ath12k_sta_rc_update_wk); in ath12k_mac_op_sta_state()
3765 ath12k_warn(ar->ab, "Failed to add station: %pM for VDEV: %d\n", in ath12k_mac_op_sta_state()
3766 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
3769 ath12k_dp_peer_cleanup(ar, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
3771 ret = ath12k_peer_delete(ar, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
3773 ath12k_warn(ar->ab, "Failed to delete peer: %pM for VDEV: %d\n", in ath12k_mac_op_sta_state()
3774 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
3776 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "Removed peer: %pM for VDEV: %d\n", in ath12k_mac_op_sta_state()
3777 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
3780 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3781 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
3782 if (peer && peer->sta == sta) { in ath12k_mac_op_sta_state()
3783 ath12k_warn(ar->ab, "Found peer entry %pM n vdev %i after it was supposedly removed\n", in ath12k_mac_op_sta_state()
3784 vif->addr, arvif->vdev_id); in ath12k_mac_op_sta_state()
3785 peer->sta = NULL; in ath12k_mac_op_sta_state()
3786 list_del(&peer->list); in ath12k_mac_op_sta_state()
3788 ar->num_peers--; in ath12k_mac_op_sta_state()
3790 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3792 kfree(arsta->rx_stats); in ath12k_mac_op_sta_state()
3793 arsta->rx_stats = NULL; in ath12k_mac_op_sta_state()
3796 (vif->type == NL80211_IFTYPE_AP || in ath12k_mac_op_sta_state()
3797 vif->type == NL80211_IFTYPE_MESH_POINT || in ath12k_mac_op_sta_state()
3798 vif->type == NL80211_IFTYPE_ADHOC)) { in ath12k_mac_op_sta_state()
3801 ath12k_warn(ar->ab, "Failed to associate station: %pM\n", in ath12k_mac_op_sta_state()
3802 sta->addr); in ath12k_mac_op_sta_state()
3804 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_sta_state()
3806 arsta->bw = ath12k_mac_ieee80211_sta_bw_to_wmi(ar, sta); in ath12k_mac_op_sta_state()
3807 arsta->bw_prev = sta->deflink.bandwidth; in ath12k_mac_op_sta_state()
3809 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_sta_state()
3812 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3814 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
3816 peer->is_authorized = true; in ath12k_mac_op_sta_state()
3818 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3820 if (vif->type == NL80211_IFTYPE_STATION && arvif->is_up) { in ath12k_mac_op_sta_state()
3821 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_op_sta_state()
3822 arvif->vdev_id, in ath12k_mac_op_sta_state()
3826 ath12k_warn(ar->ab, "Unable to authorize peer %pM vdev %d: %d\n", in ath12k_mac_op_sta_state()
3827 sta->addr, arvif->vdev_id, ret); in ath12k_mac_op_sta_state()
3831 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3833 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_state()
3835 peer->is_authorized = false; in ath12k_mac_op_sta_state()
3837 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3840 (vif->type == NL80211_IFTYPE_AP || in ath12k_mac_op_sta_state()
3841 vif->type == NL80211_IFTYPE_MESH_POINT || in ath12k_mac_op_sta_state()
3842 vif->type == NL80211_IFTYPE_ADHOC)) { in ath12k_mac_op_sta_state()
3845 ath12k_warn(ar->ab, "Failed to disassociate station: %pM\n", in ath12k_mac_op_sta_state()
3846 sta->addr); in ath12k_mac_op_sta_state()
3849 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_sta_state()
3853 static int ath12k_mac_op_sta_set_txpwr(struct ieee80211_hw *hw, in ath12k_mac_op_sta_set_txpwr() argument
3857 struct ath12k *ar = hw->priv; in ath12k_mac_op_sta_set_txpwr()
3858 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_mac_op_sta_set_txpwr()
3862 if (sta->deflink.txpwr.type == NL80211_TX_POWER_AUTOMATIC) { in ath12k_mac_op_sta_set_txpwr()
3865 txpwr = sta->deflink.txpwr.power; in ath12k_mac_op_sta_set_txpwr()
3867 return -EINVAL; in ath12k_mac_op_sta_set_txpwr()
3871 return -EINVAL; in ath12k_mac_op_sta_set_txpwr()
3873 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_sta_set_txpwr()
3875 ret = ath12k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id, in ath12k_mac_op_sta_set_txpwr()
3878 ath12k_warn(ar->ab, "failed to set tx power for station ret: %d\n", in ath12k_mac_op_sta_set_txpwr()
3884 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_sta_set_txpwr()
3888 static void ath12k_mac_op_sta_rc_update(struct ieee80211_hw *hw, in ath12k_mac_op_sta_rc_update() argument
3893 struct ath12k *ar = hw->priv; in ath12k_mac_op_sta_rc_update()
3894 struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv; in ath12k_mac_op_sta_rc_update()
3895 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_mac_op_sta_rc_update()
3899 spin_lock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_rc_update()
3901 peer = ath12k_peer_find(ar->ab, arvif->vdev_id, sta->addr); in ath12k_mac_op_sta_rc_update()
3903 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_rc_update()
3904 ath12k_warn(ar->ab, "mac sta rc update failed to find peer %pM on vdev %i\n", in ath12k_mac_op_sta_rc_update()
3905 sta->addr, arvif->vdev_id); in ath12k_mac_op_sta_rc_update()
3909 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_rc_update()
3911 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_sta_rc_update()
3913 sta->addr, changed, sta->deflink.bandwidth, sta->deflink.rx_nss, in ath12k_mac_op_sta_rc_update()
3914 sta->deflink.smps_mode); in ath12k_mac_op_sta_rc_update()
3916 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_sta_rc_update()
3920 arsta->bw_prev = arsta->bw; in ath12k_mac_op_sta_rc_update()
3921 arsta->bw = bw; in ath12k_mac_op_sta_rc_update()
3925 arsta->nss = sta->deflink.rx_nss; in ath12k_mac_op_sta_rc_update()
3930 switch (sta->deflink.smps_mode) { in ath12k_mac_op_sta_rc_update()
3942 ath12k_warn(ar->ab, "Invalid smps %d in sta rc update for %pM\n", in ath12k_mac_op_sta_rc_update()
3943 sta->deflink.smps_mode, sta->addr); in ath12k_mac_op_sta_rc_update()
3948 arsta->smps = smps; in ath12k_mac_op_sta_rc_update()
3951 arsta->changed |= changed; in ath12k_mac_op_sta_rc_update()
3953 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_sta_rc_update()
3955 ieee80211_queue_work(hw, &arsta->update_wk); in ath12k_mac_op_sta_rc_update()
3965 if (arvif->vdev_type != WMI_VDEV_TYPE_STA) in ath12k_conf_tx_uapsd()
3988 arvif->u.sta.uapsd |= value; in ath12k_conf_tx_uapsd()
3990 arvif->u.sta.uapsd &= ~value; in ath12k_conf_tx_uapsd()
3992 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_conf_tx_uapsd()
3994 arvif->u.sta.uapsd); in ath12k_conf_tx_uapsd()
3996 ath12k_warn(ar->ab, "could not set uapsd params %d\n", ret); in ath12k_conf_tx_uapsd()
4000 if (arvif->u.sta.uapsd) in ath12k_conf_tx_uapsd()
4005 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_conf_tx_uapsd()
4009 ath12k_warn(ar->ab, "could not set rx wake param %d\n", ret); in ath12k_conf_tx_uapsd()
4015 static int ath12k_mac_op_conf_tx(struct ieee80211_hw *hw, in ath12k_mac_op_conf_tx() argument
4020 struct ath12k *ar = hw->priv; in ath12k_mac_op_conf_tx()
4021 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_mac_op_conf_tx()
4025 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_conf_tx()
4029 p = &arvif->wmm_params.ac_vo; in ath12k_mac_op_conf_tx()
4032 p = &arvif->wmm_params.ac_vi; in ath12k_mac_op_conf_tx()
4035 p = &arvif->wmm_params.ac_be; in ath12k_mac_op_conf_tx()
4038 p = &arvif->wmm_params.ac_bk; in ath12k_mac_op_conf_tx()
4043 ret = -EINVAL; in ath12k_mac_op_conf_tx()
4047 p->cwmin = params->cw_min; in ath12k_mac_op_conf_tx()
4048 p->cwmax = params->cw_max; in ath12k_mac_op_conf_tx()
4049 p->aifs = params->aifs; in ath12k_mac_op_conf_tx()
4050 p->txop = params->txop; in ath12k_mac_op_conf_tx()
4052 ret = ath12k_wmi_send_wmm_update_cmd(ar, arvif->vdev_id, in ath12k_mac_op_conf_tx()
4053 &arvif->wmm_params); in ath12k_mac_op_conf_tx()
4055 ath12k_warn(ar->ab, "failed to set wmm params: %d\n", ret); in ath12k_mac_op_conf_tx()
4059 ret = ath12k_conf_tx_uapsd(ar, vif, ac, params->uapsd); in ath12k_mac_op_conf_tx()
4062 ath12k_warn(ar->ab, "failed to set sta uapsd: %d\n", ret); in ath12k_mac_op_conf_tx()
4065 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_conf_tx()
4074 u32 ar_vht_cap = ar->pdev->cap.vht_cap; in ath12k_create_ht_cap()
4125 for (i = 0; i < ar->num_rx_chains; i++) { in ath12k_create_ht_cap()
4138 struct ath12k *ar = arvif->ar; in ath12k_mac_set_txbf_conf()
4141 u32 vht_cap = ar->pdev->cap.vht_cap; in ath12k_mac_set_txbf_conf()
4154 if (sound_dim > (ar->num_tx_chains - 1)) in ath12k_mac_set_txbf_conf()
4155 sound_dim = ar->num_tx_chains - 1; in ath12k_mac_set_txbf_conf()
4166 arvif->vdev_type == WMI_VDEV_TYPE_AP) in ath12k_mac_set_txbf_conf()
4174 arvif->vdev_type == WMI_VDEV_TYPE_STA) in ath12k_mac_set_txbf_conf()
4178 return ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_txbf_conf()
4190 if (ar->num_tx_chains < 2) { in ath12k_set_vht_txbf_cap()
4212 if (sound_dim > (ar->num_tx_chains - 1)) in ath12k_set_vht_txbf_cap()
4213 sound_dim = ar->num_tx_chains - 1; in ath12k_set_vht_txbf_cap()
4233 vht_cap.cap = ar->pdev->cap.vht_cap; in ath12k_create_vht_cap()
4245 if (i < ar->num_tx_chains && rate_cap_tx_chainmask & BIT(i)) in ath12k_create_vht_cap()
4250 if (i < ar->num_rx_chains && rate_cap_rx_chainmask & BIT(i)) in ath12k_create_vht_cap()
4274 rate_cap_tx_chainmask = ar->cfg_tx_chainmask >> cap->tx_chain_mask_shift; in ath12k_mac_setup_ht_vht_cap()
4275 rate_cap_rx_chainmask = ar->cfg_rx_chainmask >> cap->rx_chain_mask_shift; in ath12k_mac_setup_ht_vht_cap()
4277 if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_setup_ht_vht_cap()
4278 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath12k_mac_setup_ht_vht_cap()
4279 ht_cap = cap->band[NL80211_BAND_2GHZ].ht_cap_info; in ath12k_mac_setup_ht_vht_cap()
4282 band->ht_cap = ath12k_create_ht_cap(ar, ht_cap, in ath12k_mac_setup_ht_vht_cap()
4286 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && in ath12k_mac_setup_ht_vht_cap()
4287 (ar->ab->hw_params->single_pdev_only || in ath12k_mac_setup_ht_vht_cap()
4288 !ar->supports_6ghz)) { in ath12k_mac_setup_ht_vht_cap()
4289 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath12k_mac_setup_ht_vht_cap()
4290 ht_cap = cap->band[NL80211_BAND_5GHZ].ht_cap_info; in ath12k_mac_setup_ht_vht_cap()
4293 band->ht_cap = ath12k_create_ht_cap(ar, ht_cap, in ath12k_mac_setup_ht_vht_cap()
4295 band->vht_cap = ath12k_create_vht_cap(ar, rate_cap_tx_chainmask, in ath12k_mac_setup_ht_vht_cap()
4315 he_ppet[0] = fw_ppet->numss_m1 & IEEE80211_PPE_THRES_NSS_MASK; in ath12k_gen_ppe_thresh()
4316 he_ppet[0] |= (fw_ppet->ru_bit_mask << in ath12k_gen_ppe_thresh()
4319 for (nss = 0; nss <= fw_ppet->numss_m1; nss++) { in ath12k_gen_ppe_thresh()
4324 if ((fw_ppet->ru_bit_mask & BIT(ru)) == 0) in ath12k_gen_ppe_thresh()
4326 val = (fw_ppet->ppet16_ppet8_ru3_ru0[nss] >> (ru * 6)) & in ath12k_gen_ppe_thresh()
4329 for (i = 5; i >= 0; i--) { in ath12k_gen_ppe_thresh()
4345 he_cap_elem->mac_cap_info[0] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4350 he_cap_elem->mac_cap_info[2] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4355 he_cap_elem->mac_cap_info[3] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4359 he_cap_elem->mac_cap_info[4] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4365 he_cap_elem->mac_cap_info[5] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4369 he_cap_elem->phy_cap_info[2] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4374 he_cap_elem->phy_cap_info[3] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4377 he_cap_elem->phy_cap_info[4] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4380 he_cap_elem->phy_cap_info[5] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4386 he_cap_elem->phy_cap_info[6] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4392 he_cap_elem->phy_cap_info[7] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4398 he_cap_elem->phy_cap_info[8] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4406 he_cap_elem->phy_cap_info[9] &= ~m; in ath12k_mac_filter_he_cap_mesh()
4414 bcap->he_6ghz_capa = IEEE80211_HT_MPDU_DENSITY_NONE; in ath12k_mac_setup_he_6ghz_cap()
4415 if (bcap->ht_cap_info & WMI_HT_CAP_DYNAMIC_SMPS) in ath12k_mac_setup_he_6ghz_cap()
4416 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
4420 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
4423 val = u32_get_bits(pcap->vht_cap, in ath12k_mac_setup_he_6ghz_cap()
4425 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
4427 val = u32_get_bits(pcap->vht_cap, in ath12k_mac_setup_he_6ghz_cap()
4429 bcap->he_6ghz_capa |= in ath12k_mac_setup_he_6ghz_cap()
4431 if (pcap->vht_cap & IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN) in ath12k_mac_setup_he_6ghz_cap()
4432 bcap->he_6ghz_capa |= IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS; in ath12k_mac_setup_he_6ghz_cap()
4433 if (pcap->vht_cap & IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN) in ath12k_mac_setup_he_6ghz_cap()
4434 bcap->he_6ghz_capa |= IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS; in ath12k_mac_setup_he_6ghz_cap()
4436 return cpu_to_le16(bcap->he_6ghz_capa); in ath12k_mac_setup_he_6ghz_cap()
4443 struct ieee80211_he_cap_elem *he_cap_elem = &he_cap->he_cap_elem; in ath12k_mac_copy_he_cap()
4444 struct ieee80211_he_mcs_nss_supp *mcs_nss = &he_cap->he_mcs_nss_supp; in ath12k_mac_copy_he_cap()
4446 he_cap->has_he = true; in ath12k_mac_copy_he_cap()
4447 memcpy(he_cap_elem->mac_cap_info, band_cap->he_cap_info, in ath12k_mac_copy_he_cap()
4448 sizeof(he_cap_elem->mac_cap_info)); in ath12k_mac_copy_he_cap()
4449 memcpy(he_cap_elem->phy_cap_info, band_cap->he_cap_phy_info, in ath12k_mac_copy_he_cap()
4450 sizeof(he_cap_elem->phy_cap_info)); in ath12k_mac_copy_he_cap()
4452 he_cap_elem->mac_cap_info[1] &= in ath12k_mac_copy_he_cap()
4455 he_cap_elem->phy_cap_info[5] &= in ath12k_mac_copy_he_cap()
4457 he_cap_elem->phy_cap_info[5] &= in ath12k_mac_copy_he_cap()
4459 he_cap_elem->phy_cap_info[5] |= num_tx_chains - 1; in ath12k_mac_copy_he_cap()
4463 he_cap_elem->phy_cap_info[3] &= in ath12k_mac_copy_he_cap()
4465 he_cap_elem->phy_cap_info[9] |= in ath12k_mac_copy_he_cap()
4469 he_cap_elem->mac_cap_info[0] &= ~IEEE80211_HE_MAC_CAP0_TWT_RES; in ath12k_mac_copy_he_cap()
4470 he_cap_elem->mac_cap_info[0] |= IEEE80211_HE_MAC_CAP0_TWT_REQ; in ath12k_mac_copy_he_cap()
4471 he_cap_elem->phy_cap_info[9] |= in ath12k_mac_copy_he_cap()
4479 mcs_nss->rx_mcs_80 = cpu_to_le16(band_cap->he_mcs & 0xffff); in ath12k_mac_copy_he_cap()
4480 mcs_nss->tx_mcs_80 = cpu_to_le16(band_cap->he_mcs & 0xffff); in ath12k_mac_copy_he_cap()
4481 mcs_nss->rx_mcs_160 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
4482 mcs_nss->tx_mcs_160 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
4483 mcs_nss->rx_mcs_80p80 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
4484 mcs_nss->tx_mcs_80p80 = cpu_to_le16((band_cap->he_mcs >> 16) & 0xffff); in ath12k_mac_copy_he_cap()
4486 memset(he_cap->ppe_thres, 0, sizeof(he_cap->ppe_thres)); in ath12k_mac_copy_he_cap()
4487 if (he_cap_elem->phy_cap_info[6] & in ath12k_mac_copy_he_cap()
4489 ath12k_gen_ppe_thresh(&band_cap->he_ppet, he_cap->ppe_thres); in ath12k_mac_copy_he_cap()
4498 if ((he_cap->phy_cap_info[0] & in ath12k_mac_copy_eht_mcs_nss()
4503 memcpy(&mcs_nss->only_20mhz, &band_cap->eht_mcs_20_only, in ath12k_mac_copy_eht_mcs_nss()
4506 if (he_cap->phy_cap_info[0] & in ath12k_mac_copy_eht_mcs_nss()
4509 memcpy(&mcs_nss->bw._80, &band_cap->eht_mcs_80, in ath12k_mac_copy_eht_mcs_nss()
4512 if (he_cap->phy_cap_info[0] & in ath12k_mac_copy_eht_mcs_nss()
4514 memcpy(&mcs_nss->bw._160, &band_cap->eht_mcs_160, in ath12k_mac_copy_eht_mcs_nss()
4517 if (eht_cap->phy_cap_info[0] & IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ) in ath12k_mac_copy_eht_mcs_nss()
4518 memcpy(&mcs_nss->bw._320, &band_cap->eht_mcs_320, in ath12k_mac_copy_eht_mcs_nss()
4528 u8p_replace_bits(&cap->eht_ppe_thres[0], fw_ppet->numss_m1, in ath12k_mac_copy_eht_ppe_thresh()
4531 u16p_replace_bits((u16 *)&cap->eht_ppe_thres[0], fw_ppet->ru_bit_mask, in ath12k_mac_copy_eht_ppe_thresh()
4534 for (nss = 0; nss <= fw_ppet->numss_m1; nss++) { in ath12k_mac_copy_eht_ppe_thresh()
4540 if ((fw_ppet->ru_bit_mask & BIT(ru)) == 0) in ath12k_mac_copy_eht_ppe_thresh()
4543 u32p_replace_bits(&val, fw_ppet->ppet16_ppet8_ru3_ru0[nss] >> in ath12k_mac_copy_eht_ppe_thresh()
4545 GENMASK(ppet_bit_len_per_ru - 1, 0)); in ath12k_mac_copy_eht_ppe_thresh()
4548 cap->eht_ppe_thres[bit / 8] |= in ath12k_mac_copy_eht_ppe_thresh()
4561 struct ieee80211_eht_cap_elem_fixed *eht_cap_elem = &eht_cap->eht_cap_elem; in ath12k_mac_copy_eht_cap()
4564 eht_cap->has_eht = true; in ath12k_mac_copy_eht_cap()
4565 memcpy(eht_cap_elem->mac_cap_info, band_cap->eht_cap_mac_info, in ath12k_mac_copy_eht_cap()
4566 sizeof(eht_cap_elem->mac_cap_info)); in ath12k_mac_copy_eht_cap()
4567 memcpy(eht_cap_elem->phy_cap_info, band_cap->eht_cap_phy_info, in ath12k_mac_copy_eht_cap()
4568 sizeof(eht_cap_elem->phy_cap_info)); in ath12k_mac_copy_eht_cap()
4572 eht_cap_elem->phy_cap_info[0] &= in ath12k_mac_copy_eht_cap()
4574 eht_cap_elem->phy_cap_info[4] &= in ath12k_mac_copy_eht_cap()
4576 eht_cap_elem->phy_cap_info[5] &= in ath12k_mac_copy_eht_cap()
4580 eht_cap_elem->phy_cap_info[7] &= in ath12k_mac_copy_eht_cap()
4584 eht_cap_elem->phy_cap_info[7] &= in ath12k_mac_copy_eht_cap()
4593 ath12k_mac_copy_eht_mcs_nss(band_cap, &eht_cap->eht_mcs_nss_supp, in ath12k_mac_copy_eht_cap()
4596 if (eht_cap_elem->phy_cap_info[5] & in ath12k_mac_copy_eht_cap()
4598 ath12k_mac_copy_eht_ppe_thresh(&band_cap->eht_ppet, eht_cap); in ath12k_mac_copy_eht_cap()
4606 struct ath12k_band_cap *band_cap = &cap->band[band]; in ath12k_mac_copy_sband_iftype_data()
4624 ath12k_mac_copy_he_cap(band_cap, i, ar->num_tx_chains, he_cap); in ath12k_mac_copy_sband_iftype_data()
4629 ath12k_mac_copy_eht_cap(band_cap, &he_cap->he_cap_elem, i, in ath12k_mac_copy_sband_iftype_data()
4644 if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_setup_sband_iftype_data()
4647 ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
4649 sband = &ar->mac.sbands[band]; in ath12k_mac_setup_sband_iftype_data()
4650 sband->iftype_data = ar->mac.iftype[band]; in ath12k_mac_setup_sband_iftype_data()
4651 sband->n_iftype_data = count; in ath12k_mac_setup_sband_iftype_data()
4654 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath12k_mac_setup_sband_iftype_data()
4657 ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
4659 sband = &ar->mac.sbands[band]; in ath12k_mac_setup_sband_iftype_data()
4660 sband->iftype_data = ar->mac.iftype[band]; in ath12k_mac_setup_sband_iftype_data()
4661 sband->n_iftype_data = count; in ath12k_mac_setup_sband_iftype_data()
4664 if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP && in ath12k_mac_setup_sband_iftype_data()
4665 ar->supports_6ghz) { in ath12k_mac_setup_sband_iftype_data()
4668 ar->mac.iftype[band], in ath12k_mac_setup_sband_iftype_data()
4670 sband = &ar->mac.sbands[band]; in ath12k_mac_setup_sband_iftype_data()
4671 sband->iftype_data = ar->mac.iftype[band]; in ath12k_mac_setup_sband_iftype_data()
4672 sband->n_iftype_data = count; in ath12k_mac_setup_sband_iftype_data()
4680 lockdep_assert_held(&ar->conf_mutex); in __ath12k_set_antenna()
4683 return -EINVAL; in __ath12k_set_antenna()
4686 return -EINVAL; in __ath12k_set_antenna()
4688 ar->cfg_tx_chainmask = tx_ant; in __ath12k_set_antenna()
4689 ar->cfg_rx_chainmask = rx_ant; in __ath12k_set_antenna()
4691 if (ar->state != ATH12K_STATE_ON && in __ath12k_set_antenna()
4692 ar->state != ATH12K_STATE_RESTARTED) in __ath12k_set_antenna()
4696 tx_ant, ar->pdev->pdev_id); in __ath12k_set_antenna()
4698 ath12k_warn(ar->ab, "failed to set tx-chainmask: %d, req 0x%x\n", in __ath12k_set_antenna()
4703 ar->num_tx_chains = hweight32(tx_ant); in __ath12k_set_antenna()
4706 rx_ant, ar->pdev->pdev_id); in __ath12k_set_antenna()
4708 ath12k_warn(ar->ab, "failed to set rx-chainmask: %d, req 0x%x\n", in __ath12k_set_antenna()
4713 ar->num_rx_chains = hweight32(rx_ant); in __ath12k_set_antenna()
4716 ath12k_mac_setup_ht_vht_cap(ar, &ar->pdev->cap, NULL); in __ath12k_set_antenna()
4717 ath12k_mac_setup_sband_iftype_data(ar, &ar->pdev->cap); in __ath12k_set_antenna()
4726 ieee80211_free_txskb(ar->hw, skb); in ath12k_mgmt_over_wmi_tx_drop()
4728 num_mgmt = atomic_dec_if_positive(&ar->num_pending_mgmt_tx); in ath12k_mgmt_over_wmi_tx_drop()
4734 wake_up(&ar->txmgmt_empty_waitq); in ath12k_mgmt_over_wmi_tx_drop()
4742 struct ath12k_base *ab = ar->ab; in ath12k_mac_tx_mgmt_pending_free()
4744 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_tx_mgmt_pending_free()
4745 idr_remove(&ar->txmgmt_idr, buf_id); in ath12k_mac_tx_mgmt_pending_free()
4746 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_tx_mgmt_pending_free()
4747 dma_unmap_single(ab->dev, ATH12K_SKB_CB(msdu)->paddr, msdu->len, in ath12k_mac_tx_mgmt_pending_free()
4751 memset(&info->status, 0, sizeof(info->status)); in ath12k_mac_tx_mgmt_pending_free()
4763 struct ath12k *ar = skb_cb->ar; in ath12k_mac_vif_txmgmt_idr_remove()
4764 struct ath12k_base *ab = ar->ab; in ath12k_mac_vif_txmgmt_idr_remove()
4766 if (skb_cb->vif == vif) { in ath12k_mac_vif_txmgmt_idr_remove()
4767 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_vif_txmgmt_idr_remove()
4768 idr_remove(&ar->txmgmt_idr, buf_id); in ath12k_mac_vif_txmgmt_idr_remove()
4769 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_vif_txmgmt_idr_remove()
4770 dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, in ath12k_mac_vif_txmgmt_idr_remove()
4780 struct ath12k_base *ab = ar->ab; in ath12k_mac_mgmt_tx_wmi()
4781 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath12k_mac_mgmt_tx_wmi()
4787 ATH12K_SKB_CB(skb)->ar = ar; in ath12k_mac_mgmt_tx_wmi()
4788 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
4789 buf_id = idr_alloc(&ar->txmgmt_idr, skb, 0, in ath12k_mac_mgmt_tx_wmi()
4791 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
4793 return -ENOSPC; in ath12k_mac_mgmt_tx_wmi()
4796 if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)) { in ath12k_mac_mgmt_tx_wmi()
4797 if ((ieee80211_is_action(hdr->frame_control) || in ath12k_mac_mgmt_tx_wmi()
4798 ieee80211_is_deauth(hdr->frame_control) || in ath12k_mac_mgmt_tx_wmi()
4799 ieee80211_is_disassoc(hdr->frame_control)) && in ath12k_mac_mgmt_tx_wmi()
4800 ieee80211_has_protected(hdr->frame_control)) { in ath12k_mac_mgmt_tx_wmi()
4805 paddr = dma_map_single(ab->dev, skb->data, skb->len, DMA_TO_DEVICE); in ath12k_mac_mgmt_tx_wmi()
4806 if (dma_mapping_error(ab->dev, paddr)) { in ath12k_mac_mgmt_tx_wmi()
4808 ret = -EIO; in ath12k_mac_mgmt_tx_wmi()
4812 ATH12K_SKB_CB(skb)->paddr = paddr; in ath12k_mac_mgmt_tx_wmi()
4814 ret = ath12k_wmi_mgmt_send(ar, arvif->vdev_id, buf_id, skb); in ath12k_mac_mgmt_tx_wmi()
4816 ath12k_warn(ar->ab, "failed to send mgmt frame: %d\n", ret); in ath12k_mac_mgmt_tx_wmi()
4823 dma_unmap_single(ab->dev, ATH12K_SKB_CB(skb)->paddr, in ath12k_mac_mgmt_tx_wmi()
4824 skb->len, DMA_TO_DEVICE); in ath12k_mac_mgmt_tx_wmi()
4826 spin_lock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
4827 idr_remove(&ar->txmgmt_idr, buf_id); in ath12k_mac_mgmt_tx_wmi()
4828 spin_unlock_bh(&ar->txmgmt_idr_lock); in ath12k_mac_mgmt_tx_wmi()
4837 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) in ath12k_mgmt_over_wmi_tx_purge()
4849 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) { in ath12k_mgmt_over_wmi_tx_work()
4851 if (!skb_cb->vif) { in ath12k_mgmt_over_wmi_tx_work()
4852 ath12k_warn(ar->ab, "no vif found for mgmt frame\n"); in ath12k_mgmt_over_wmi_tx_work()
4857 arvif = ath12k_vif_to_arvif(skb_cb->vif); in ath12k_mgmt_over_wmi_tx_work()
4858 if (ar->allocated_vdev_map & (1LL << arvif->vdev_id) && in ath12k_mgmt_over_wmi_tx_work()
4859 arvif->is_started) { in ath12k_mgmt_over_wmi_tx_work()
4862 ath12k_warn(ar->ab, "failed to tx mgmt frame, vdev_id %d :%d\n", in ath12k_mgmt_over_wmi_tx_work()
4863 arvif->vdev_id, ret); in ath12k_mgmt_over_wmi_tx_work()
4867 ath12k_warn(ar->ab, in ath12k_mgmt_over_wmi_tx_work()
4869 arvif->vdev_id, in ath12k_mgmt_over_wmi_tx_work()
4870 arvif->is_started); in ath12k_mgmt_over_wmi_tx_work()
4879 struct sk_buff_head *q = &ar->wmi_mgmt_tx_queue; in ath12k_mac_mgmt_tx()
4881 if (test_bit(ATH12K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) in ath12k_mac_mgmt_tx()
4882 return -ESHUTDOWN; in ath12k_mac_mgmt_tx()
4890 atomic_read(&ar->num_pending_mgmt_tx) > ATH12K_PRB_RSP_DROP_THRESHOLD) { in ath12k_mac_mgmt_tx()
4891 ath12k_warn(ar->ab, in ath12k_mac_mgmt_tx()
4893 return -ENOSPC; in ath12k_mac_mgmt_tx()
4897 ath12k_warn(ar->ab, "mgmt tx queue is full\n"); in ath12k_mac_mgmt_tx()
4898 return -ENOSPC; in ath12k_mac_mgmt_tx()
4902 atomic_inc(&ar->num_pending_mgmt_tx); in ath12k_mac_mgmt_tx()
4903 ieee80211_queue_work(ar->hw, &ar->wmi_mgmt_tx_work); in ath12k_mac_mgmt_tx()
4908 static void ath12k_mac_op_tx(struct ieee80211_hw *hw, in ath12k_mac_op_tx() argument
4913 struct ath12k *ar = hw->priv; in ath12k_mac_op_tx()
4915 struct ieee80211_vif *vif = info->control.vif; in ath12k_mac_op_tx()
4917 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; in ath12k_mac_op_tx()
4918 struct ieee80211_key_conf *key = info->control.hw_key; in ath12k_mac_op_tx()
4919 u32 info_flags = info->flags; in ath12k_mac_op_tx()
4924 skb_cb->vif = vif; in ath12k_mac_op_tx()
4927 skb_cb->cipher = key->cipher; in ath12k_mac_op_tx()
4928 skb_cb->flags |= ATH12K_SKB_CIPHER_SET; in ath12k_mac_op_tx()
4932 skb_cb->flags |= ATH12K_SKB_HW_80211_ENCAP; in ath12k_mac_op_tx()
4933 } else if (ieee80211_is_mgmt(hdr->frame_control)) { in ath12k_mac_op_tx()
4934 is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control); in ath12k_mac_op_tx()
4937 ath12k_warn(ar->ab, "failed to queue management frame %d\n", in ath12k_mac_op_tx()
4939 ieee80211_free_txskb(ar->hw, skb); in ath12k_mac_op_tx()
4946 ath12k_warn(ar->ab, "failed to transmit frame %d\n", ret); in ath12k_mac_op_tx()
4947 ieee80211_free_txskb(ar->hw, skb); in ath12k_mac_op_tx()
4953 /* make sure rcu-protected mac80211 tx path itself is drained */ in ath12k_mac_drain_tx()
4956 cancel_work_sync(&ar->wmi_mgmt_tx_work); in ath12k_mac_drain_tx()
4962 return -ENOTSUPP; in ath12k_mac_config_mon_status_default()
4970 if (!ab->is_reset) in ath12k_mac_wait_reconfigure()
4973 recovery_start_count = atomic_inc_return(&ab->recovery_start_count); in ath12k_mac_wait_reconfigure()
4977 if (recovery_start_count == ab->num_radios) { in ath12k_mac_wait_reconfigure()
4978 complete(&ab->recovery_start); in ath12k_mac_wait_reconfigure()
4984 wait_for_completion_timeout(&ab->reconfigure_complete, in ath12k_mac_wait_reconfigure()
4988 static int ath12k_mac_op_start(struct ieee80211_hw *hw) in ath12k_mac_op_start() argument
4990 struct ath12k *ar = hw->priv; in ath12k_mac_op_start()
4991 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_start()
4992 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_op_start()
4996 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_start()
4998 switch (ar->state) { in ath12k_mac_op_start()
5000 ar->state = ATH12K_STATE_ON; in ath12k_mac_op_start()
5003 ar->state = ATH12K_STATE_RESTARTED; in ath12k_mac_op_start()
5010 ret = -EINVAL; in ath12k_mac_op_start()
5015 1, pdev->pdev_id); in ath12k_mac_op_start()
5018 ath12k_err(ar->ab, "failed to enable PMF QOS: (%d\n", ret); in ath12k_mac_op_start()
5023 pdev->pdev_id); in ath12k_mac_op_start()
5025 ath12k_err(ar->ab, "failed to enable dynamic bw: %d\n", ret); in ath12k_mac_op_start()
5030 0, pdev->pdev_id); in ath12k_mac_op_start()
5037 ret = ath12k_wmi_send_dfs_phyerr_offload_enable_cmd(ar, pdev->pdev_id); in ath12k_mac_op_start()
5052 1, pdev->pdev_id); in ath12k_mac_op_start()
5055 ath12k_err(ar->ab, "failed to enable MESH MCAST ENABLE: (%d\n", ret); in ath12k_mac_op_start()
5059 __ath12k_set_antenna(ar, ar->cfg_tx_chainmask, ar->cfg_rx_chainmask); in ath12k_mac_op_start()
5065 ar->num_started_vdevs = 0; in ath12k_mac_op_start()
5066 ar->num_created_vdevs = 0; in ath12k_mac_op_start()
5067 ar->num_peers = 0; in ath12k_mac_op_start()
5068 ar->allocated_vdev_map = 0; in ath12k_mac_op_start()
5074 if (ret && (ret != -ENOTSUPP)) { in ath12k_mac_op_start()
5080 if (ret == -ENOTSUPP) in ath12k_mac_op_start()
5081 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_start()
5085 ath12k_wmi_pdev_lro_cfg(ar, ar->pdev->pdev_id); in ath12k_mac_op_start()
5088 if (ab->hw_params->idle_ps) { in ath12k_mac_op_start()
5090 1, pdev->pdev_id); in ath12k_mac_op_start()
5097 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_start()
5099 rcu_assign_pointer(ab->pdevs_active[ar->pdev_idx], in ath12k_mac_op_start()
5100 &ab->pdevs[ar->pdev_idx]); in ath12k_mac_op_start()
5105 ar->state = ATH12K_STATE_OFF; in ath12k_mac_op_start()
5106 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_start()
5111 static void ath12k_mac_op_stop(struct ieee80211_hw *hw) in ath12k_mac_op_stop() argument
5113 struct ath12k *ar = hw->priv; in ath12k_mac_op_stop()
5119 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_stop()
5121 if (ret && (ret != -ENOTSUPP)) in ath12k_mac_op_stop()
5122 ath12k_err(ar->ab, "failed to clear rx_filter for monitor status ring: (%d)\n", in ath12k_mac_op_stop()
5125 clear_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_op_stop()
5126 ar->state = ATH12K_STATE_OFF; in ath12k_mac_op_stop()
5127 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_stop()
5129 cancel_delayed_work_sync(&ar->scan.timeout); in ath12k_mac_op_stop()
5130 cancel_work_sync(&ar->regd_update_work); in ath12k_mac_op_stop()
5132 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_stop()
5133 list_for_each_entry_safe(ppdu_stats, tmp, &ar->ppdu_stats_info, list) { in ath12k_mac_op_stop()
5134 list_del(&ppdu_stats->list); in ath12k_mac_op_stop()
5137 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_stop()
5139 rcu_assign_pointer(ar->ab->pdevs_active[ar->pdev_idx], NULL); in ath12k_mac_op_stop()
5143 atomic_set(&ar->num_pending_mgmt_tx, 0); in ath12k_mac_op_stop()
5149 struct ath12k_base *ab = arvif->ar->ab; in ath12k_mac_get_vdev_stats_id()
5153 if (ab->free_vdev_stats_id_map & (1LL << vdev_stats_id)) { in ath12k_mac_get_vdev_stats_id()
5160 ab->free_vdev_stats_id_map |= (1LL << vdev_stats_id); in ath12k_mac_get_vdev_stats_id()
5165 arvif->vdev_stats_id = vdev_stats_id; in ath12k_mac_get_vdev_stats_id()
5172 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_vdev_create_arg()
5173 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_setup_vdev_create_arg()
5175 arg->if_id = arvif->vdev_id; in ath12k_mac_setup_vdev_create_arg()
5176 arg->type = arvif->vdev_type; in ath12k_mac_setup_vdev_create_arg()
5177 arg->subtype = arvif->vdev_subtype; in ath12k_mac_setup_vdev_create_arg()
5178 arg->pdev_id = pdev->pdev_id; in ath12k_mac_setup_vdev_create_arg()
5180 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) { in ath12k_mac_setup_vdev_create_arg()
5181 arg->chains[NL80211_BAND_2GHZ].tx = ar->num_tx_chains; in ath12k_mac_setup_vdev_create_arg()
5182 arg->chains[NL80211_BAND_2GHZ].rx = ar->num_rx_chains; in ath12k_mac_setup_vdev_create_arg()
5184 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP) { in ath12k_mac_setup_vdev_create_arg()
5185 arg->chains[NL80211_BAND_5GHZ].tx = ar->num_tx_chains; in ath12k_mac_setup_vdev_create_arg()
5186 arg->chains[NL80211_BAND_5GHZ].rx = ar->num_rx_chains; in ath12k_mac_setup_vdev_create_arg()
5188 if (pdev->cap.supported_bands & WMI_HOST_WLAN_5G_CAP && in ath12k_mac_setup_vdev_create_arg()
5189 ar->supports_6ghz) { in ath12k_mac_setup_vdev_create_arg()
5190 arg->chains[NL80211_BAND_6GHZ].tx = ar->num_tx_chains; in ath12k_mac_setup_vdev_create_arg()
5191 arg->chains[NL80211_BAND_6GHZ].rx = ar->num_rx_chains; in ath12k_mac_setup_vdev_create_arg()
5194 arg->if_stats_id = ath12k_mac_get_vdev_stats_id(arvif); in ath12k_mac_setup_vdev_create_arg()
5200 struct ath12k_pdev_cap *pdev_cap = &pdev->cap; in ath12k_mac_prepare_he_mode()
5205 if (pdev->cap.supported_bands & WMI_HOST_WLAN_2G_CAP) in ath12k_mac_prepare_he_mode()
5206 cap_band = &pdev_cap->band[NL80211_BAND_2GHZ]; in ath12k_mac_prepare_he_mode()
5208 cap_band = &pdev_cap->band[NL80211_BAND_5GHZ]; in ath12k_mac_prepare_he_mode()
5210 hecap_phy_ptr = &cap_band->he_cap_phy_info[0]; in ath12k_mac_prepare_he_mode()
5235 struct ath12k_base *ab = ar->ab; in ath12k_set_he_mu_sounding_mode()
5239 param_value = ath12k_mac_prepare_he_mode(ar->pdev, arvif->vif->type); in ath12k_set_he_mu_sounding_mode()
5240 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_he_mu_sounding_mode()
5244 arvif->vdev_id, ret, param_value); in ath12k_set_he_mu_sounding_mode()
5252 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_he_mu_sounding_mode()
5256 arvif->vdev_id, ret); in ath12k_set_he_mu_sounding_mode()
5262 static void ath12k_mac_op_update_vif_offload(struct ieee80211_hw *hw, in ath12k_mac_op_update_vif_offload() argument
5265 struct ath12k *ar = hw->priv; in ath12k_mac_op_update_vif_offload()
5266 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_update_vif_offload()
5272 if (vif->type != NL80211_IFTYPE_STATION && in ath12k_mac_op_update_vif_offload()
5273 vif->type != NL80211_IFTYPE_AP) in ath12k_mac_op_update_vif_offload()
5274 vif->offload_flags &= ~(IEEE80211_OFFLOAD_ENCAP_ENABLED | in ath12k_mac_op_update_vif_offload()
5277 if (vif->offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED) in ath12k_mac_op_update_vif_offload()
5278 arvif->tx_encap_type = ATH12K_HW_TXRX_ETHERNET; in ath12k_mac_op_update_vif_offload()
5279 else if (test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) in ath12k_mac_op_update_vif_offload()
5280 arvif->tx_encap_type = ATH12K_HW_TXRX_RAW; in ath12k_mac_op_update_vif_offload()
5282 arvif->tx_encap_type = ATH12K_HW_TXRX_NATIVE_WIFI; in ath12k_mac_op_update_vif_offload()
5284 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_update_vif_offload()
5285 param_id, arvif->tx_encap_type); in ath12k_mac_op_update_vif_offload()
5288 arvif->vdev_id, ret); in ath12k_mac_op_update_vif_offload()
5289 vif->offload_flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED; in ath12k_mac_op_update_vif_offload()
5293 if (vif->offload_flags & IEEE80211_OFFLOAD_DECAP_ENABLED) in ath12k_mac_op_update_vif_offload()
5295 else if (test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) in ath12k_mac_op_update_vif_offload()
5300 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_update_vif_offload()
5304 arvif->vdev_id, ret); in ath12k_mac_op_update_vif_offload()
5305 vif->offload_flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED; in ath12k_mac_op_update_vif_offload()
5309 static int ath12k_mac_op_add_interface(struct ieee80211_hw *hw, in ath12k_mac_op_add_interface() argument
5312 struct ath12k *ar = hw->priv; in ath12k_mac_op_add_interface()
5313 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_add_interface()
5323 vif->driver_flags |= IEEE80211_VIF_SUPPORTS_UAPSD; in ath12k_mac_op_add_interface()
5325 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_add_interface()
5327 if (vif->type == NL80211_IFTYPE_AP && in ath12k_mac_op_add_interface()
5328 ar->num_peers > (ar->max_num_peers - 1)) { in ath12k_mac_op_add_interface()
5330 ret = -ENOBUFS; in ath12k_mac_op_add_interface()
5334 if (ar->num_created_vdevs > (TARGET_NUM_VDEVS - 1)) { in ath12k_mac_op_add_interface()
5337 ret = -EBUSY; in ath12k_mac_op_add_interface()
5343 arvif->ar = ar; in ath12k_mac_op_add_interface()
5344 arvif->vif = vif; in ath12k_mac_op_add_interface()
5346 INIT_LIST_HEAD(&arvif->list); in ath12k_mac_op_add_interface()
5352 for (i = 0; i < ARRAY_SIZE(arvif->bitrate_mask.control); i++) { in ath12k_mac_op_add_interface()
5353 arvif->bitrate_mask.control[i].legacy = 0xffffffff; in ath12k_mac_op_add_interface()
5354 memset(arvif->bitrate_mask.control[i].ht_mcs, 0xff, in ath12k_mac_op_add_interface()
5355 sizeof(arvif->bitrate_mask.control[i].ht_mcs)); in ath12k_mac_op_add_interface()
5356 memset(arvif->bitrate_mask.control[i].vht_mcs, 0xff, in ath12k_mac_op_add_interface()
5357 sizeof(arvif->bitrate_mask.control[i].vht_mcs)); in ath12k_mac_op_add_interface()
5360 bit = __ffs64(ab->free_vdev_map); in ath12k_mac_op_add_interface()
5362 arvif->vdev_id = bit; in ath12k_mac_op_add_interface()
5363 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_NONE; in ath12k_mac_op_add_interface()
5365 switch (vif->type) { in ath12k_mac_op_add_interface()
5368 arvif->vdev_type = WMI_VDEV_TYPE_STA; in ath12k_mac_op_add_interface()
5371 arvif->vdev_subtype = WMI_VDEV_SUBTYPE_MESH_11S; in ath12k_mac_op_add_interface()
5374 arvif->vdev_type = WMI_VDEV_TYPE_AP; in ath12k_mac_op_add_interface()
5377 arvif->vdev_type = WMI_VDEV_TYPE_MONITOR; in ath12k_mac_op_add_interface()
5378 ar->monitor_vdev_id = bit; in ath12k_mac_op_add_interface()
5385 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac add interface id %d type %d subtype %d map %llx\n", in ath12k_mac_op_add_interface()
5386 arvif->vdev_id, arvif->vdev_type, arvif->vdev_subtype, in ath12k_mac_op_add_interface()
5387 ab->free_vdev_map); in ath12k_mac_op_add_interface()
5389 vif->cab_queue = arvif->vdev_id % (ATH12K_HW_MAX_QUEUES - 1); in ath12k_mac_op_add_interface()
5390 for (i = 0; i < ARRAY_SIZE(vif->hw_queue); i++) in ath12k_mac_op_add_interface()
5391 vif->hw_queue[i] = i % (ATH12K_HW_MAX_QUEUES - 1); in ath12k_mac_op_add_interface()
5395 ret = ath12k_wmi_vdev_create(ar, vif->addr, &vdev_arg); in ath12k_mac_op_add_interface()
5398 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5402 ar->num_created_vdevs++; in ath12k_mac_op_add_interface()
5404 vif->addr, arvif->vdev_id); in ath12k_mac_op_add_interface()
5405 ar->allocated_vdev_map |= 1LL << arvif->vdev_id; in ath12k_mac_op_add_interface()
5406 ab->free_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_op_add_interface()
5408 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_add_interface()
5409 list_add(&arvif->list, &ar->arvifs); in ath12k_mac_op_add_interface()
5410 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_add_interface()
5412 ath12k_mac_op_update_vif_offload(hw, vif); in ath12k_mac_op_add_interface()
5414 nss = hweight32(ar->cfg_tx_chainmask) ? : 1; in ath12k_mac_op_add_interface()
5415 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_add_interface()
5419 arvif->vdev_id, ar->cfg_tx_chainmask, nss, ret); in ath12k_mac_op_add_interface()
5423 switch (arvif->vdev_type) { in ath12k_mac_op_add_interface()
5425 peer_param.vdev_id = arvif->vdev_id; in ath12k_mac_op_add_interface()
5426 peer_param.peer_addr = vif->addr; in ath12k_mac_op_add_interface()
5431 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5437 ath12k_warn(ar->ab, "failed to set vdev %i kickout parameters: %d\n", in ath12k_mac_op_add_interface()
5438 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5445 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_mac_op_add_interface()
5448 ath12k_warn(ar->ab, "failed to set vdev %d RX wake policy: %d\n", in ath12k_mac_op_add_interface()
5449 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5455 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_mac_op_add_interface()
5458 ath12k_warn(ar->ab, "failed to set vdev %d TX wake threshold: %d\n", in ath12k_mac_op_add_interface()
5459 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5465 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_mac_op_add_interface()
5468 ath12k_warn(ar->ab, "failed to set vdev %d pspoll count: %d\n", in ath12k_mac_op_add_interface()
5469 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5473 ret = ath12k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, false); in ath12k_mac_op_add_interface()
5475 ath12k_warn(ar->ab, "failed to disable vdev %d ps mode: %d\n", in ath12k_mac_op_add_interface()
5476 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5484 arvif->txpower = vif->bss_conf.txpower; in ath12k_mac_op_add_interface()
5490 param_value = ar->hw->wiphy->rts_threshold; in ath12k_mac_op_add_interface()
5491 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_add_interface()
5494 ath12k_warn(ar->ab, "failed to set rts threshold for vdev %d: %d\n", in ath12k_mac_op_add_interface()
5495 arvif->vdev_id, ret); in ath12k_mac_op_add_interface()
5500 if (vif->type != NL80211_IFTYPE_MONITOR && ar->monitor_conf_enabled) in ath12k_mac_op_add_interface()
5503 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_add_interface()
5508 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath12k_mac_op_add_interface()
5509 reinit_completion(&ar->peer_delete_done); in ath12k_mac_op_add_interface()
5511 ret = ath12k_wmi_send_peer_delete_cmd(ar, vif->addr, in ath12k_mac_op_add_interface()
5512 arvif->vdev_id); in ath12k_mac_op_add_interface()
5514 ath12k_warn(ar->ab, "failed to delete peer vdev_id %d addr %pM\n", in ath12k_mac_op_add_interface()
5515 arvif->vdev_id, vif->addr); in ath12k_mac_op_add_interface()
5519 ret = ath12k_wait_for_peer_delete_done(ar, arvif->vdev_id, in ath12k_mac_op_add_interface()
5520 vif->addr); in ath12k_mac_op_add_interface()
5524 ar->num_peers--; in ath12k_mac_op_add_interface()
5528 ath12k_wmi_vdev_delete(ar, arvif->vdev_id); in ath12k_mac_op_add_interface()
5529 ar->num_created_vdevs--; in ath12k_mac_op_add_interface()
5530 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_op_add_interface()
5531 ab->free_vdev_map |= 1LL << arvif->vdev_id; in ath12k_mac_op_add_interface()
5532 ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id); in ath12k_mac_op_add_interface()
5533 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_add_interface()
5534 list_del(&arvif->list); in ath12k_mac_op_add_interface()
5535 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_add_interface()
5538 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_add_interface()
5551 spin_lock_bh(&dp->tx_desc_lock[i]); in ath12k_mac_vif_unref()
5553 list_for_each_entry(tx_desc_info, &dp->tx_desc_used_list[i], in ath12k_mac_vif_unref()
5555 skb = tx_desc_info->skb; in ath12k_mac_vif_unref()
5560 if (skb_cb->vif == vif) in ath12k_mac_vif_unref()
5561 skb_cb->vif = NULL; in ath12k_mac_vif_unref()
5564 spin_unlock_bh(&dp->tx_desc_lock[i]); in ath12k_mac_vif_unref()
5568 static void ath12k_mac_op_remove_interface(struct ieee80211_hw *hw, in ath12k_mac_op_remove_interface() argument
5571 struct ath12k *ar = hw->priv; in ath12k_mac_op_remove_interface()
5573 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_remove_interface()
5577 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_remove_interface()
5580 arvif->vdev_id); in ath12k_mac_op_remove_interface()
5582 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath12k_mac_op_remove_interface()
5583 ret = ath12k_peer_delete(ar, arvif->vdev_id, vif->addr); in ath12k_mac_op_remove_interface()
5585 ath12k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n", in ath12k_mac_op_remove_interface()
5586 arvif->vdev_id, ret); in ath12k_mac_op_remove_interface()
5589 reinit_completion(&ar->vdev_delete_done); in ath12k_mac_op_remove_interface()
5591 ret = ath12k_wmi_vdev_delete(ar, arvif->vdev_id); in ath12k_mac_op_remove_interface()
5594 arvif->vdev_id, ret); in ath12k_mac_op_remove_interface()
5598 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, in ath12k_mac_op_remove_interface()
5605 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_op_remove_interface()
5606 ar->monitor_vdev_id = -1; in ath12k_mac_op_remove_interface()
5607 ar->monitor_vdev_created = false; in ath12k_mac_op_remove_interface()
5608 } else if (ar->monitor_vdev_created && !ar->monitor_started) { in ath12k_mac_op_remove_interface()
5612 ab->free_vdev_map |= 1LL << (arvif->vdev_id); in ath12k_mac_op_remove_interface()
5613 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_op_remove_interface()
5614 ab->free_vdev_stats_id_map &= ~(1LL << arvif->vdev_stats_id); in ath12k_mac_op_remove_interface()
5615 ar->num_created_vdevs--; in ath12k_mac_op_remove_interface()
5618 vif->addr, arvif->vdev_id); in ath12k_mac_op_remove_interface()
5621 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_remove_interface()
5622 list_del(&arvif->list); in ath12k_mac_op_remove_interface()
5623 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_remove_interface()
5625 ath12k_peer_cleanup(ar, arvif->vdev_id); in ath12k_mac_op_remove_interface()
5627 idr_for_each(&ar->txmgmt_idr, in ath12k_mac_op_remove_interface()
5630 ath12k_mac_vif_unref(&ab->dp, vif); in ath12k_mac_op_remove_interface()
5631 ath12k_dp_tx_put_bank_profile(&ab->dp, arvif->bank_id); in ath12k_mac_op_remove_interface()
5635 clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); in ath12k_mac_op_remove_interface()
5639 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_remove_interface()
5652 static void ath12k_mac_op_configure_filter(struct ieee80211_hw *hw, in ath12k_mac_op_configure_filter() argument
5657 struct ath12k *ar = hw->priv; in ath12k_mac_op_configure_filter()
5661 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_configure_filter()
5665 ar->filter_flags = *total_flags; in ath12k_mac_op_configure_filter()
5668 reset_flag = !(ar->filter_flags & FIF_BCN_PRBRESP_PROMISC); in ath12k_mac_op_configure_filter()
5673 set_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); in ath12k_mac_op_configure_filter()
5675 clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); in ath12k_mac_op_configure_filter()
5677 ath12k_warn(ar->ab, in ath12k_mac_op_configure_filter()
5680 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_configure_filter()
5684 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_configure_filter()
5687 static int ath12k_mac_op_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant) in ath12k_mac_op_get_antenna() argument
5689 struct ath12k *ar = hw->priv; in ath12k_mac_op_get_antenna()
5691 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_get_antenna()
5693 *tx_ant = ar->cfg_tx_chainmask; in ath12k_mac_op_get_antenna()
5694 *rx_ant = ar->cfg_rx_chainmask; in ath12k_mac_op_get_antenna()
5696 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_get_antenna()
5701 static int ath12k_mac_op_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) in ath12k_mac_op_set_antenna() argument
5703 struct ath12k *ar = hw->priv; in ath12k_mac_op_set_antenna()
5706 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_antenna()
5708 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_antenna()
5713 static int ath12k_mac_op_ampdu_action(struct ieee80211_hw *hw, in ath12k_mac_op_ampdu_action() argument
5717 struct ath12k *ar = hw->priv; in ath12k_mac_op_ampdu_action()
5718 int ret = -EINVAL; in ath12k_mac_op_ampdu_action()
5720 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_ampdu_action()
5722 switch (params->action) { in ath12k_mac_op_ampdu_action()
5734 /* Tx A-MPDU aggregation offloaded to hw/fw so deny mac80211 in ath12k_mac_op_ampdu_action()
5737 ret = -EOPNOTSUPP; in ath12k_mac_op_ampdu_action()
5741 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_ampdu_action()
5746 static int ath12k_mac_op_add_chanctx(struct ieee80211_hw *hw, in ath12k_mac_op_add_chanctx() argument
5749 struct ath12k *ar = hw->priv; in ath12k_mac_op_add_chanctx()
5750 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_add_chanctx()
5754 ctx->def.chan->center_freq, ctx->def.width, ctx); in ath12k_mac_op_add_chanctx()
5756 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_add_chanctx()
5758 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_add_chanctx()
5762 ar->rx_channel = ctx->def.chan; in ath12k_mac_op_add_chanctx()
5763 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_add_chanctx()
5765 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_add_chanctx()
5770 static void ath12k_mac_op_remove_chanctx(struct ieee80211_hw *hw, in ath12k_mac_op_remove_chanctx() argument
5773 struct ath12k *ar = hw->priv; in ath12k_mac_op_remove_chanctx()
5774 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_remove_chanctx()
5778 ctx->def.chan->center_freq, ctx->def.width, ctx); in ath12k_mac_op_remove_chanctx()
5780 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_remove_chanctx()
5782 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_remove_chanctx()
5786 ar->rx_channel = NULL; in ath12k_mac_op_remove_chanctx()
5787 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_remove_chanctx()
5789 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_remove_chanctx()
5797 struct ath12k *ar = arvif->ar; in ath12k_mac_vdev_start_restart()
5798 struct ath12k_base *ab = ar->ab; in ath12k_mac_vdev_start_restart()
5800 int he_support = arvif->vif->bss_conf.he_support; in ath12k_mac_vdev_start_restart()
5803 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_start_restart()
5805 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_vdev_start_restart()
5807 arg.vdev_id = arvif->vdev_id; in ath12k_mac_vdev_start_restart()
5808 arg.dtim_period = arvif->dtim_period; in ath12k_mac_vdev_start_restart()
5809 arg.bcn_intval = arvif->beacon_interval; in ath12k_mac_vdev_start_restart()
5810 arg.punct_bitmap = ~arvif->punct_bitmap; in ath12k_mac_vdev_start_restart()
5812 arg.freq = chandef->chan->center_freq; in ath12k_mac_vdev_start_restart()
5813 arg.band_center_freq1 = chandef->center_freq1; in ath12k_mac_vdev_start_restart()
5814 arg.band_center_freq2 = chandef->center_freq2; in ath12k_mac_vdev_start_restart()
5815 arg.mode = ath12k_phymodes[chandef->chan->band][chandef->width]; in ath12k_mac_vdev_start_restart()
5818 arg.max_power = chandef->chan->max_power * 2; in ath12k_mac_vdev_start_restart()
5819 arg.max_reg_power = chandef->chan->max_reg_power * 2; in ath12k_mac_vdev_start_restart()
5820 arg.max_antenna_gain = chandef->chan->max_antenna_gain * 2; in ath12k_mac_vdev_start_restart()
5822 arg.pref_tx_streams = ar->num_tx_chains; in ath12k_mac_vdev_start_restart()
5823 arg.pref_rx_streams = ar->num_rx_chains; in ath12k_mac_vdev_start_restart()
5825 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) { in ath12k_mac_vdev_start_restart()
5826 arg.ssid = arvif->u.ap.ssid; in ath12k_mac_vdev_start_restart()
5827 arg.ssid_len = arvif->u.ap.ssid_len; in ath12k_mac_vdev_start_restart()
5828 arg.hidden_ssid = arvif->u.ap.hidden_ssid; in ath12k_mac_vdev_start_restart()
5831 arg.chan_radar = !!(chandef->chan->flags & IEEE80211_CHAN_RADAR); in ath12k_mac_vdev_start_restart()
5835 spin_lock_bh(&ab->base_lock); in ath12k_mac_vdev_start_restart()
5836 arg.regdomain = ar->ab->dfs_region; in ath12k_mac_vdev_start_restart()
5837 spin_unlock_bh(&ab->base_lock); in ath12k_mac_vdev_start_restart()
5843 ath12k_warn(ar->ab, "failed to set he mode vdev %i\n", in ath12k_mac_vdev_start_restart()
5850 arg.passive |= !!(chandef->chan->flags & IEEE80211_CHAN_NO_IR); in ath12k_mac_vdev_start_restart()
5859 ath12k_warn(ar->ab, "failed to %s WMI vdev %i\n", in ath12k_mac_vdev_start_restart()
5871 ar->num_started_vdevs++; in ath12k_mac_vdev_start_restart()
5873 arvif->vif->addr, arvif->vdev_id); in ath12k_mac_vdev_start_restart()
5876 * i.e dfs_cac_ms value which will be valid only for radar channels in ath12k_mac_vdev_start_restart()
5882 if (arvif->vdev_type == WMI_VDEV_TYPE_AP && in ath12k_mac_vdev_start_restart()
5883 chandef->chan->dfs_cac_ms && in ath12k_mac_vdev_start_restart()
5884 chandef->chan->dfs_state == NL80211_DFS_USABLE) { in ath12k_mac_vdev_start_restart()
5885 set_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_vdev_start_restart()
5894 arvif->vdev_id, ret); in ath12k_mac_vdev_start_restart()
5901 struct ath12k *ar = arvif->ar; in ath12k_mac_vdev_stop()
5904 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_vdev_stop()
5906 reinit_completion(&ar->vdev_setup_done); in ath12k_mac_vdev_stop()
5908 ret = ath12k_wmi_vdev_stop(ar, arvif->vdev_id); in ath12k_mac_vdev_stop()
5910 ath12k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n", in ath12k_mac_vdev_stop()
5911 arvif->vdev_id, ret); in ath12k_mac_vdev_stop()
5917 ath12k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n", in ath12k_mac_vdev_stop()
5918 arvif->vdev_id, ret); in ath12k_mac_vdev_stop()
5922 WARN_ON(ar->num_started_vdevs == 0); in ath12k_mac_vdev_stop()
5924 ar->num_started_vdevs--; in ath12k_mac_vdev_stop()
5925 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "vdev %pM stopped, vdev_id %d\n", in ath12k_mac_vdev_stop()
5926 arvif->vif->addr, arvif->vdev_id); in ath12k_mac_vdev_stop()
5928 if (test_bit(ATH12K_CAC_RUNNING, &ar->dev_flags)) { in ath12k_mac_vdev_stop()
5929 clear_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_vdev_stop()
5930 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "CAC Stopped for vdev %d\n", in ath12k_mac_vdev_stop()
5931 arvif->vdev_id); in ath12k_mac_vdev_stop()
5964 if (rcu_access_pointer(vif->bss_conf.chanctx_conf) != arg->ctx) in ath12k_mac_change_chanctx_cnt_iter()
5967 arg->n_vifs++; in ath12k_mac_change_chanctx_cnt_iter()
5977 ctx = rcu_access_pointer(vif->bss_conf.chanctx_conf); in ath12k_mac_change_chanctx_fill_iter()
5978 if (ctx != arg->ctx) in ath12k_mac_change_chanctx_fill_iter()
5981 if (WARN_ON(arg->next_vif == arg->n_vifs)) in ath12k_mac_change_chanctx_fill_iter()
5984 arg->vifs[arg->next_vif].vif = vif; in ath12k_mac_change_chanctx_fill_iter()
5985 arg->vifs[arg->next_vif].old_ctx = ctx; in ath12k_mac_change_chanctx_fill_iter()
5986 arg->vifs[arg->next_vif].new_ctx = ctx; in ath12k_mac_change_chanctx_fill_iter()
5987 arg->next_vif++; in ath12k_mac_change_chanctx_fill_iter()
5995 struct ath12k_base *ab = ar->ab; in ath12k_mac_update_vif_chan()
6001 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_update_vif_chan()
6004 arvif = (void *)vifs[i].vif->drv_priv; in ath12k_mac_update_vif_chan()
6006 if (vifs[i].vif->type == NL80211_IFTYPE_MONITOR) in ath12k_mac_update_vif_chan()
6010 "mac chanctx switch vdev_id %i freq %u->%u width %d->%d\n", in ath12k_mac_update_vif_chan()
6011 arvif->vdev_id, in ath12k_mac_update_vif_chan()
6012 vifs[i].old_ctx->def.chan->center_freq, in ath12k_mac_update_vif_chan()
6013 vifs[i].new_ctx->def.chan->center_freq, in ath12k_mac_update_vif_chan()
6014 vifs[i].old_ctx->def.width, in ath12k_mac_update_vif_chan()
6015 vifs[i].new_ctx->def.width); in ath12k_mac_update_vif_chan()
6017 if (WARN_ON(!arvif->is_started)) in ath12k_mac_update_vif_chan()
6020 if (WARN_ON(!arvif->is_up)) in ath12k_mac_update_vif_chan()
6023 ret = ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_mac_update_vif_chan()
6026 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
6035 /* TODO: Update ar->rx_channel */ in ath12k_mac_update_vif_chan()
6038 arvif = (void *)vifs[i].vif->drv_priv; in ath12k_mac_update_vif_chan()
6040 if (WARN_ON(!arvif->is_started)) in ath12k_mac_update_vif_chan()
6043 if (WARN_ON(!arvif->is_up)) in ath12k_mac_update_vif_chan()
6046 ret = ath12k_mac_vdev_restart(arvif, &vifs[i].new_ctx->def); in ath12k_mac_update_vif_chan()
6049 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
6058 ret = ath12k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, in ath12k_mac_update_vif_chan()
6059 arvif->bssid); in ath12k_mac_update_vif_chan()
6062 arvif->vdev_id, ret); in ath12k_mac_update_vif_chan()
6068 if (!monitor_vif && ar->monitor_vdev_created) { in ath12k_mac_update_vif_chan()
6080 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_update_active_vif_chan()
6082 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath12k_mac_update_active_vif_chan()
6093 ieee80211_iterate_active_interfaces_atomic(ar->hw, in ath12k_mac_update_active_vif_chan()
6103 static void ath12k_mac_op_change_chanctx(struct ieee80211_hw *hw, in ath12k_mac_op_change_chanctx() argument
6107 struct ath12k *ar = hw->priv; in ath12k_mac_op_change_chanctx()
6108 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_change_chanctx()
6110 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_change_chanctx()
6114 ctx->def.chan->center_freq, ctx->def.width, ctx, changed); in ath12k_mac_op_change_chanctx()
6128 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_change_chanctx()
6131 static int ath12k_start_vdev_delay(struct ieee80211_hw *hw, in ath12k_start_vdev_delay() argument
6134 struct ath12k *ar = hw->priv; in ath12k_start_vdev_delay()
6135 struct ath12k_base *ab = ar->ab; in ath12k_start_vdev_delay()
6136 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_start_vdev_delay()
6139 if (WARN_ON(arvif->is_started)) in ath12k_start_vdev_delay()
6140 return -EBUSY; in ath12k_start_vdev_delay()
6142 ret = ath12k_mac_vdev_start(arvif, &arvif->chanctx.def); in ath12k_start_vdev_delay()
6145 arvif->vdev_id, vif->addr, in ath12k_start_vdev_delay()
6146 arvif->chanctx.def.chan->center_freq, ret); in ath12k_start_vdev_delay()
6150 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_start_vdev_delay()
6151 ret = ath12k_monitor_vdev_up(ar, arvif->vdev_id); in ath12k_start_vdev_delay()
6158 arvif->is_started = true; in ath12k_start_vdev_delay()
6165 ath12k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw, in ath12k_mac_op_assign_vif_chanctx() argument
6170 struct ath12k *ar = hw->priv; in ath12k_mac_op_assign_vif_chanctx()
6171 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_assign_vif_chanctx()
6172 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_mac_op_assign_vif_chanctx()
6176 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_assign_vif_chanctx()
6180 ctx, arvif->vdev_id); in ath12k_mac_op_assign_vif_chanctx()
6182 arvif->punct_bitmap = link_conf->eht_puncturing; in ath12k_mac_op_assign_vif_chanctx()
6185 if (ab->hw_params->vdev_start_delay && in ath12k_mac_op_assign_vif_chanctx()
6186 arvif->vdev_type != WMI_VDEV_TYPE_AP && in ath12k_mac_op_assign_vif_chanctx()
6187 arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath12k_mac_op_assign_vif_chanctx()
6188 !ath12k_peer_exist_by_vdev_id(ab, arvif->vdev_id)) { in ath12k_mac_op_assign_vif_chanctx()
6189 memcpy(&arvif->chanctx, ctx, sizeof(*ctx)); in ath12k_mac_op_assign_vif_chanctx()
6194 if (WARN_ON(arvif->is_started)) { in ath12k_mac_op_assign_vif_chanctx()
6195 ret = -EBUSY; in ath12k_mac_op_assign_vif_chanctx()
6199 if (ab->hw_params->vdev_start_delay && in ath12k_mac_op_assign_vif_chanctx()
6200 (arvif->vdev_type == WMI_VDEV_TYPE_AP || in ath12k_mac_op_assign_vif_chanctx()
6201 arvif->vdev_type == WMI_VDEV_TYPE_MONITOR)) { in ath12k_mac_op_assign_vif_chanctx()
6202 param.vdev_id = arvif->vdev_id; in ath12k_mac_op_assign_vif_chanctx()
6204 param.peer_addr = ar->mac_addr; in ath12k_mac_op_assign_vif_chanctx()
6214 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_op_assign_vif_chanctx()
6218 arvif->is_started = true; in ath12k_mac_op_assign_vif_chanctx()
6222 ret = ath12k_mac_vdev_start(arvif, &ctx->def); in ath12k_mac_op_assign_vif_chanctx()
6225 arvif->vdev_id, vif->addr, in ath12k_mac_op_assign_vif_chanctx()
6226 ctx->def.chan->center_freq, ret); in ath12k_mac_op_assign_vif_chanctx()
6230 if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && ar->monitor_vdev_created) in ath12k_mac_op_assign_vif_chanctx()
6233 arvif->is_started = true; in ath12k_mac_op_assign_vif_chanctx()
6238 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_assign_vif_chanctx()
6244 ath12k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw, in ath12k_mac_op_unassign_vif_chanctx() argument
6249 struct ath12k *ar = hw->priv; in ath12k_mac_op_unassign_vif_chanctx()
6250 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_unassign_vif_chanctx()
6251 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_mac_op_unassign_vif_chanctx()
6254 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
6258 ctx, arvif->vdev_id); in ath12k_mac_op_unassign_vif_chanctx()
6260 WARN_ON(!arvif->is_started); in ath12k_mac_op_unassign_vif_chanctx()
6262 if (ab->hw_params->vdev_start_delay && in ath12k_mac_op_unassign_vif_chanctx()
6263 arvif->vdev_type == WMI_VDEV_TYPE_MONITOR && in ath12k_mac_op_unassign_vif_chanctx()
6264 ath12k_peer_find_by_addr(ab, ar->mac_addr)) in ath12k_mac_op_unassign_vif_chanctx()
6265 ath12k_peer_delete(ar, arvif->vdev_id, ar->mac_addr); in ath12k_mac_op_unassign_vif_chanctx()
6267 if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) { in ath12k_mac_op_unassign_vif_chanctx()
6270 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
6274 arvif->is_started = false; in ath12k_mac_op_unassign_vif_chanctx()
6280 arvif->vdev_id, ret); in ath12k_mac_op_unassign_vif_chanctx()
6282 arvif->is_started = false; in ath12k_mac_op_unassign_vif_chanctx()
6284 if (ab->hw_params->vdev_start_delay && in ath12k_mac_op_unassign_vif_chanctx()
6285 arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) in ath12k_mac_op_unassign_vif_chanctx()
6286 ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_mac_op_unassign_vif_chanctx()
6288 if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR && in ath12k_mac_op_unassign_vif_chanctx()
6289 ar->num_started_vdevs == 1 && ar->monitor_vdev_created) in ath12k_mac_op_unassign_vif_chanctx()
6292 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
6296 ath12k_mac_op_switch_vif_chanctx(struct ieee80211_hw *hw, in ath12k_mac_op_switch_vif_chanctx() argument
6301 struct ath12k *ar = hw->priv; in ath12k_mac_op_switch_vif_chanctx()
6303 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_switch_vif_chanctx()
6305 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_switch_vif_chanctx()
6310 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_switch_vif_chanctx()
6321 mutex_lock(&ar->conf_mutex); in ath12k_set_vdev_param_to_all_vifs()
6322 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_set_vdev_param_to_all_vifs()
6323 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "setting mac vdev %d param %d value %d\n", in ath12k_set_vdev_param_to_all_vifs()
6324 param, arvif->vdev_id, value); in ath12k_set_vdev_param_to_all_vifs()
6326 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_vdev_param_to_all_vifs()
6329 ath12k_warn(ar->ab, "failed to set param %d for vdev %d: %d\n", in ath12k_set_vdev_param_to_all_vifs()
6330 param, arvif->vdev_id, ret); in ath12k_set_vdev_param_to_all_vifs()
6334 mutex_unlock(&ar->conf_mutex); in ath12k_set_vdev_param_to_all_vifs()
6341 static int ath12k_mac_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) in ath12k_mac_op_set_rts_threshold() argument
6343 struct ath12k *ar = hw->priv; in ath12k_mac_op_set_rts_threshold()
6349 static int ath12k_mac_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value) in ath12k_mac_op_set_frag_threshold() argument
6361 return -EOPNOTSUPP; in ath12k_mac_op_set_frag_threshold()
6364 static void ath12k_mac_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, in ath12k_mac_op_flush() argument
6367 struct ath12k *ar = hw->priv; in ath12k_mac_op_flush()
6373 time_left = wait_event_timeout(ar->dp.tx_empty_waitq, in ath12k_mac_op_flush()
6374 (atomic_read(&ar->dp.num_tx_pending) == 0), in ath12k_mac_op_flush()
6377 ath12k_warn(ar->ab, "failed to flush transmit queue %ld\n", time_left); in ath12k_mac_op_flush()
6379 time_left = wait_event_timeout(ar->txmgmt_empty_waitq, in ath12k_mac_op_flush()
6380 (atomic_read(&ar->num_pending_mgmt_tx) == 0), in ath12k_mac_op_flush()
6383 ath12k_warn(ar->ab, "failed to flush mgmt transmit queue %ld\n", in ath12k_mac_op_flush()
6395 for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) in ath12k_mac_bitrate_mask_num_ht_rates()
6396 num_rates += hweight16(mask->control[band].ht_mcs[i]); in ath12k_mac_bitrate_mask_num_ht_rates()
6408 num_rates = hweight32(mask->control[band].legacy); in ath12k_mac_has_single_legacy_rate()
6425 struct ieee80211_supported_band *sband = &ar->mac.sbands[band]; in ath12k_mac_bitrate_mask_get_single_nss()
6426 u16 vht_mcs_map = le16_to_cpu(sband->vht_cap.vht_mcs.tx_mcs_map); in ath12k_mac_bitrate_mask_get_single_nss()
6435 for (i = 0; i < ARRAY_SIZE(mask->control[band].ht_mcs); i++) { in ath12k_mac_bitrate_mask_get_single_nss()
6436 if (mask->control[band].ht_mcs[i] == 0) in ath12k_mac_bitrate_mask_get_single_nss()
6438 else if (mask->control[band].ht_mcs[i] == in ath12k_mac_bitrate_mask_get_single_nss()
6439 sband->ht_cap.mcs.rx_mask[i]) in ath12k_mac_bitrate_mask_get_single_nss()
6445 for (i = 0; i < ARRAY_SIZE(mask->control[band].vht_mcs); i++) { in ath12k_mac_bitrate_mask_get_single_nss()
6446 if (mask->control[band].vht_mcs[i] == 0) in ath12k_mac_bitrate_mask_get_single_nss()
6448 else if (mask->control[band].vht_mcs[i] == in ath12k_mac_bitrate_mask_get_single_nss()
6461 if (BIT(fls(ht_nss_mask)) - 1 != ht_nss_mask) in ath12k_mac_bitrate_mask_get_single_nss()
6480 if (hweight32(mask->control[band].legacy) != 1) in ath12k_mac_get_single_legacy_rate()
6481 return -EINVAL; in ath12k_mac_get_single_legacy_rate()
6483 rate_idx = ffs(mask->control[band].legacy) - 1; in ath12k_mac_get_single_legacy_rate()
6505 struct ath12k *ar = arvif->ar; in ath12k_mac_set_fixed_rate_params()
6509 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_set_fixed_rate_params()
6511 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac set fixed rate params vdev %i rate 0x%02x nss %u sgi %u\n", in ath12k_mac_set_fixed_rate_params()
6512 arvif->vdev_id, rate, nss, sgi); in ath12k_mac_set_fixed_rate_params()
6515 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
6518 ath12k_warn(ar->ab, "failed to set fixed rate param 0x%02x: %d\n", in ath12k_mac_set_fixed_rate_params()
6524 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
6527 ath12k_warn(ar->ab, "failed to set nss param %d: %d\n", in ath12k_mac_set_fixed_rate_params()
6533 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
6536 ath12k_warn(ar->ab, "failed to set sgi param %d: %d\n", in ath12k_mac_set_fixed_rate_params()
6542 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_fixed_rate_params()
6545 ath12k_warn(ar->ab, "failed to set ldpc param %d: %d\n", in ath12k_mac_set_fixed_rate_params()
6562 vht_mcs = mask->control[band].vht_mcs[i]; in ath12k_mac_vht_mcs_range_present()
6566 case BIT(8) - 1: in ath12k_mac_vht_mcs_range_present()
6567 case BIT(9) - 1: in ath12k_mac_vht_mcs_range_present()
6568 case BIT(10) - 1: in ath12k_mac_vht_mcs_range_present()
6582 struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv; in ath12k_mac_set_bitrate_mask_iter()
6583 struct ath12k *ar = arvif->ar; in ath12k_mac_set_bitrate_mask_iter()
6585 spin_lock_bh(&ar->data_lock); in ath12k_mac_set_bitrate_mask_iter()
6586 arsta->changed |= IEEE80211_RC_SUPP_RATES_CHANGED; in ath12k_mac_set_bitrate_mask_iter()
6587 spin_unlock_bh(&ar->data_lock); in ath12k_mac_set_bitrate_mask_iter()
6589 ieee80211_queue_work(ar->hw, &arsta->update_wk); in ath12k_mac_set_bitrate_mask_iter()
6596 struct ath12k *ar = arvif->ar; in ath12k_mac_disable_peer_fixed_rate()
6599 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_disable_peer_fixed_rate()
6600 arvif->vdev_id, in ath12k_mac_disable_peer_fixed_rate()
6604 ath12k_warn(ar->ab, in ath12k_mac_disable_peer_fixed_rate()
6606 sta->addr, ret); in ath12k_mac_disable_peer_fixed_rate()
6610 ath12k_mac_op_set_bitrate_mask(struct ieee80211_hw *hw, in ath12k_mac_op_set_bitrate_mask() argument
6614 struct ath12k_vif *arvif = (void *)vif->drv_priv; in ath12k_mac_op_set_bitrate_mask()
6616 struct ath12k *ar = arvif->ar; in ath12k_mac_op_set_bitrate_mask()
6629 return -EPERM; in ath12k_mac_op_set_bitrate_mask()
6631 band = def.chan->band; in ath12k_mac_op_set_bitrate_mask()
6632 ht_mcs_mask = mask->control[band].ht_mcs; in ath12k_mac_op_set_bitrate_mask()
6633 vht_mcs_mask = mask->control[band].vht_mcs; in ath12k_mac_op_set_bitrate_mask()
6634 ldpc = !!(ar->ht_cap_info & WMI_HT_CAP_LDPC); in ath12k_mac_op_set_bitrate_mask()
6636 sgi = mask->control[band].gi; in ath12k_mac_op_set_bitrate_mask()
6638 return -EINVAL; in ath12k_mac_op_set_bitrate_mask()
6652 ath12k_warn(ar->ab, "failed to get single legacy rate for vdev %i: %d\n", in ath12k_mac_op_set_bitrate_mask()
6653 arvif->vdev_id, ret); in ath12k_mac_op_set_bitrate_mask()
6656 ieee80211_iterate_stations_atomic(ar->hw, in ath12k_mac_op_set_bitrate_mask()
6665 nss = min_t(u32, ar->num_tx_chains, in ath12k_mac_op_set_bitrate_mask()
6672 * - Single VHT Rate : peer_assoc command accommodates only MCS in ath12k_mac_op_set_bitrate_mask()
6673 * range values i.e 0-7, 0-8, 0-9 for VHT. Though mac80211 in ath12k_mac_op_set_bitrate_mask()
6681 * - Multiple VHT Rates : When Multiple VHT rates are given,this in ath12k_mac_op_set_bitrate_mask()
6682 * can be set using RATEMASK CMD which uses FW rate-ctl alg. in ath12k_mac_op_set_bitrate_mask()
6697 ath12k_warn(ar->ab, in ath12k_mac_op_set_bitrate_mask()
6699 return -EINVAL; in ath12k_mac_op_set_bitrate_mask()
6702 ieee80211_iterate_stations_atomic(ar->hw, in ath12k_mac_op_set_bitrate_mask()
6706 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
6708 arvif->bitrate_mask = *mask; in ath12k_mac_op_set_bitrate_mask()
6709 ieee80211_iterate_stations_atomic(ar->hw, in ath12k_mac_op_set_bitrate_mask()
6713 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
6716 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
6720 ath12k_warn(ar->ab, "failed to set fixed rate params on vdev %i: %d\n", in ath12k_mac_op_set_bitrate_mask()
6721 arvif->vdev_id, ret); in ath12k_mac_op_set_bitrate_mask()
6724 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
6730 ath12k_mac_op_reconfig_complete(struct ieee80211_hw *hw, in ath12k_mac_op_reconfig_complete() argument
6733 struct ath12k *ar = hw->priv; in ath12k_mac_op_reconfig_complete()
6734 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_reconfig_complete()
6741 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_reconfig_complete()
6743 if (ar->state == ATH12K_STATE_RESTARTED) { in ath12k_mac_op_reconfig_complete()
6744 ath12k_warn(ar->ab, "pdev %d successfully recovered\n", in ath12k_mac_op_reconfig_complete()
6745 ar->pdev->pdev_id); in ath12k_mac_op_reconfig_complete()
6746 ar->state = ATH12K_STATE_ON; in ath12k_mac_op_reconfig_complete()
6747 ieee80211_wake_queues(ar->hw); in ath12k_mac_op_reconfig_complete()
6749 if (ab->is_reset) { in ath12k_mac_op_reconfig_complete()
6750 recovery_count = atomic_inc_return(&ab->recovery_count); in ath12k_mac_op_reconfig_complete()
6756 if (recovery_count == ab->num_radios) { in ath12k_mac_op_reconfig_complete()
6757 atomic_dec(&ab->reset_count); in ath12k_mac_op_reconfig_complete()
6758 complete(&ab->reset_complete); in ath12k_mac_op_reconfig_complete()
6759 ab->is_reset = false; in ath12k_mac_op_reconfig_complete()
6760 atomic_set(&ab->fail_cont_count, 0); in ath12k_mac_op_reconfig_complete()
6765 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_mac_op_reconfig_complete()
6768 arvif->key_cipher, in ath12k_mac_op_reconfig_complete()
6769 arvif->is_up, in ath12k_mac_op_reconfig_complete()
6770 arvif->vdev_type); in ath12k_mac_op_reconfig_complete()
6774 * side, hence PN number mis-match will not happened. in ath12k_mac_op_reconfig_complete()
6776 if (arvif->is_up && in ath12k_mac_op_reconfig_complete()
6777 arvif->vdev_type == WMI_VDEV_TYPE_STA && in ath12k_mac_op_reconfig_complete()
6778 arvif->vdev_subtype == WMI_VDEV_SUBTYPE_NONE) { in ath12k_mac_op_reconfig_complete()
6779 ieee80211_hw_restart_disconnect(arvif->vif); in ath12k_mac_op_reconfig_complete()
6786 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_reconfig_complete()
6796 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_update_bss_chan_survey()
6798 if (!test_bit(WMI_TLV_SERVICE_BSS_CHANNEL_INFO_64, ar->ab->wmi_ab.svc_map) || in ath12k_mac_update_bss_chan_survey()
6799 ar->rx_channel != channel) in ath12k_mac_update_bss_chan_survey()
6802 if (ar->scan.state != ATH12K_SCAN_IDLE) { in ath12k_mac_update_bss_chan_survey()
6803 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_update_bss_chan_survey()
6808 reinit_completion(&ar->bss_survey_done); in ath12k_mac_update_bss_chan_survey()
6812 ath12k_warn(ar->ab, "failed to send pdev bss chan info request\n"); in ath12k_mac_update_bss_chan_survey()
6816 ret = wait_for_completion_timeout(&ar->bss_survey_done, 3 * HZ); in ath12k_mac_update_bss_chan_survey()
6818 ath12k_warn(ar->ab, "bss channel survey timed out\n"); in ath12k_mac_update_bss_chan_survey()
6821 static int ath12k_mac_op_get_survey(struct ieee80211_hw *hw, int idx, in ath12k_mac_op_get_survey() argument
6824 struct ath12k *ar = hw->priv; in ath12k_mac_op_get_survey()
6830 return -ENOENT; in ath12k_mac_op_get_survey()
6832 ar_survey = &ar->survey[idx]; in ath12k_mac_op_get_survey()
6834 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_get_survey()
6836 sband = hw->wiphy->bands[NL80211_BAND_2GHZ]; in ath12k_mac_op_get_survey()
6837 if (sband && idx >= sband->n_channels) { in ath12k_mac_op_get_survey()
6838 idx -= sband->n_channels; in ath12k_mac_op_get_survey()
6843 sband = hw->wiphy->bands[NL80211_BAND_5GHZ]; in ath12k_mac_op_get_survey()
6845 if (!sband || idx >= sband->n_channels) { in ath12k_mac_op_get_survey()
6846 ret = -ENOENT; in ath12k_mac_op_get_survey()
6850 ath12k_mac_update_bss_chan_survey(ar, &sband->channels[idx]); in ath12k_mac_op_get_survey()
6852 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_get_survey()
6854 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_get_survey()
6856 survey->channel = &sband->channels[idx]; in ath12k_mac_op_get_survey()
6858 if (ar->rx_channel == survey->channel) in ath12k_mac_op_get_survey()
6859 survey->filled |= SURVEY_INFO_IN_USE; in ath12k_mac_op_get_survey()
6862 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_get_survey()
6866 static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw, in ath12k_mac_op_sta_statistics() argument
6871 struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv; in ath12k_mac_op_sta_statistics()
6873 sinfo->rx_duration = arsta->rx_duration; in ath12k_mac_op_sta_statistics()
6874 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION); in ath12k_mac_op_sta_statistics()
6876 sinfo->tx_duration = arsta->tx_duration; in ath12k_mac_op_sta_statistics()
6877 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_DURATION); in ath12k_mac_op_sta_statistics()
6879 if (!arsta->txrate.legacy && !arsta->txrate.nss) in ath12k_mac_op_sta_statistics()
6882 if (arsta->txrate.legacy) { in ath12k_mac_op_sta_statistics()
6883 sinfo->txrate.legacy = arsta->txrate.legacy; in ath12k_mac_op_sta_statistics()
6885 sinfo->txrate.mcs = arsta->txrate.mcs; in ath12k_mac_op_sta_statistics()
6886 sinfo->txrate.nss = arsta->txrate.nss; in ath12k_mac_op_sta_statistics()
6887 sinfo->txrate.bw = arsta->txrate.bw; in ath12k_mac_op_sta_statistics()
6888 sinfo->txrate.he_gi = arsta->txrate.he_gi; in ath12k_mac_op_sta_statistics()
6889 sinfo->txrate.he_dcm = arsta->txrate.he_dcm; in ath12k_mac_op_sta_statistics()
6890 sinfo->txrate.he_ru_alloc = arsta->txrate.he_ru_alloc; in ath12k_mac_op_sta_statistics()
6892 sinfo->txrate.flags = arsta->txrate.flags; in ath12k_mac_op_sta_statistics()
6893 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); in ath12k_mac_op_sta_statistics()
6896 sinfo->signal = arsta->rssi_comb + ATH12K_DEFAULT_NOISE_FLOOR; in ath12k_mac_op_sta_statistics()
6897 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); in ath12k_mac_op_sta_statistics()
6945 for (i = 0; i < band->n_channels; i++) { in ath12k_mac_update_ch_list()
6946 if (band->channels[i].center_freq < freq_low || in ath12k_mac_update_ch_list()
6947 band->channels[i].center_freq > freq_high) in ath12k_mac_update_ch_list()
6948 band->channels[i].flags |= IEEE80211_CHAN_DISABLED; in ath12k_mac_update_ch_list()
6954 struct ath12k_pdev *pdev = ar->pdev; in ath12k_get_phy_id()
6955 struct ath12k_pdev_cap *pdev_cap = &pdev->cap; in ath12k_get_phy_id()
6958 return pdev_cap->band[NL80211_BAND_2GHZ].phy_id; in ath12k_get_phy_id()
6961 return pdev_cap->band[NL80211_BAND_5GHZ].phy_id; in ath12k_get_phy_id()
6963 ath12k_warn(ar->ab, "unsupported phy cap:%d\n", band); in ath12k_get_phy_id()
6973 void *channels; in ath12k_mac_setup_channels_rates() local
6981 reg_cap = &ar->ab->hal_reg_cap[ar->pdev_idx]; in ath12k_mac_setup_channels_rates()
6984 channels = kmemdup(ath12k_2ghz_channels, in ath12k_mac_setup_channels_rates()
6987 if (!channels) in ath12k_mac_setup_channels_rates()
6988 return -ENOMEM; in ath12k_mac_setup_channels_rates()
6990 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; in ath12k_mac_setup_channels_rates()
6991 band->band = NL80211_BAND_2GHZ; in ath12k_mac_setup_channels_rates()
6992 band->n_channels = ARRAY_SIZE(ath12k_2ghz_channels); in ath12k_mac_setup_channels_rates()
6993 band->channels = channels; in ath12k_mac_setup_channels_rates()
6994 band->n_bitrates = ath12k_g_rates_size; in ath12k_mac_setup_channels_rates()
6995 band->bitrates = ath12k_g_rates; in ath12k_mac_setup_channels_rates()
6996 ar->hw->wiphy->bands[NL80211_BAND_2GHZ] = band; in ath12k_mac_setup_channels_rates()
6998 if (ar->ab->hw_params->single_pdev_only) { in ath12k_mac_setup_channels_rates()
7000 reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath12k_mac_setup_channels_rates()
7003 reg_cap->low_2ghz_chan, in ath12k_mac_setup_channels_rates()
7004 reg_cap->high_2ghz_chan); in ath12k_mac_setup_channels_rates()
7008 if (reg_cap->high_5ghz_chan >= ATH12K_MAX_6G_FREQ) { in ath12k_mac_setup_channels_rates()
7009 channels = kmemdup(ath12k_6ghz_channels, in ath12k_mac_setup_channels_rates()
7011 if (!channels) { in ath12k_mac_setup_channels_rates()
7012 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath12k_mac_setup_channels_rates()
7013 return -ENOMEM; in ath12k_mac_setup_channels_rates()
7016 ar->supports_6ghz = true; in ath12k_mac_setup_channels_rates()
7017 band = &ar->mac.sbands[NL80211_BAND_6GHZ]; in ath12k_mac_setup_channels_rates()
7018 band->band = NL80211_BAND_6GHZ; in ath12k_mac_setup_channels_rates()
7019 band->n_channels = ARRAY_SIZE(ath12k_6ghz_channels); in ath12k_mac_setup_channels_rates()
7020 band->channels = channels; in ath12k_mac_setup_channels_rates()
7021 band->n_bitrates = ath12k_a_rates_size; in ath12k_mac_setup_channels_rates()
7022 band->bitrates = ath12k_a_rates; in ath12k_mac_setup_channels_rates()
7023 ar->hw->wiphy->bands[NL80211_BAND_6GHZ] = band; in ath12k_mac_setup_channels_rates()
7025 reg_cap->low_5ghz_chan, in ath12k_mac_setup_channels_rates()
7026 reg_cap->high_5ghz_chan); in ath12k_mac_setup_channels_rates()
7029 if (reg_cap->low_5ghz_chan < ATH12K_MIN_6G_FREQ) { in ath12k_mac_setup_channels_rates()
7030 channels = kmemdup(ath12k_5ghz_channels, in ath12k_mac_setup_channels_rates()
7033 if (!channels) { in ath12k_mac_setup_channels_rates()
7034 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in ath12k_mac_setup_channels_rates()
7035 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in ath12k_mac_setup_channels_rates()
7036 return -ENOMEM; in ath12k_mac_setup_channels_rates()
7039 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; in ath12k_mac_setup_channels_rates()
7040 band->band = NL80211_BAND_5GHZ; in ath12k_mac_setup_channels_rates()
7041 band->n_channels = ARRAY_SIZE(ath12k_5ghz_channels); in ath12k_mac_setup_channels_rates()
7042 band->channels = channels; in ath12k_mac_setup_channels_rates()
7043 band->n_bitrates = ath12k_a_rates_size; in ath12k_mac_setup_channels_rates()
7044 band->bitrates = ath12k_a_rates; in ath12k_mac_setup_channels_rates()
7045 ar->hw->wiphy->bands[NL80211_BAND_5GHZ] = band; in ath12k_mac_setup_channels_rates()
7047 if (ar->ab->hw_params->single_pdev_only) { in ath12k_mac_setup_channels_rates()
7049 reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath12k_mac_setup_channels_rates()
7053 reg_cap->low_5ghz_chan, in ath12k_mac_setup_channels_rates()
7054 reg_cap->high_5ghz_chan); in ath12k_mac_setup_channels_rates()
7063 struct ath12k_base *ab = ar->ab; in ath12k_mac_setup_iface_combinations()
7069 ap = ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_AP); in ath12k_mac_setup_iface_combinations()
7072 ab->hw_params->interface_modes & BIT(NL80211_IFTYPE_MESH_POINT); in ath12k_mac_setup_iface_combinations()
7076 return -ENOMEM; in ath12k_mac_setup_iface_combinations()
7089 return -ENOMEM; in ath12k_mac_setup_iface_combinations()
7114 ar->hw->wiphy->iface_combinations = combinations; in ath12k_mac_setup_iface_combinations()
7115 ar->hw->wiphy->n_iface_combinations = 1; in ath12k_mac_setup_iface_combinations()
7159 cancel_work_sync(&ar->regd_update_work); in __ath12k_mac_unregister()
7161 ieee80211_unregister_hw(ar->hw); in __ath12k_mac_unregister()
7163 idr_for_each(&ar->txmgmt_idr, ath12k_mac_tx_mgmt_pending_free, ar); in __ath12k_mac_unregister()
7164 idr_destroy(&ar->txmgmt_idr); in __ath12k_mac_unregister()
7166 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in __ath12k_mac_unregister()
7167 kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels); in __ath12k_mac_unregister()
7168 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in __ath12k_mac_unregister()
7170 kfree(ar->hw->wiphy->iface_combinations[0].limits); in __ath12k_mac_unregister()
7171 kfree(ar->hw->wiphy->iface_combinations); in __ath12k_mac_unregister()
7173 SET_IEEE80211_DEV(ar->hw, NULL); in __ath12k_mac_unregister()
7182 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_unregister()
7183 pdev = &ab->pdevs[i]; in ath12k_mac_unregister()
7184 ar = pdev->ar; in ath12k_mac_unregister()
7194 struct ath12k_base *ab = ar->ab; in __ath12k_mac_register()
7195 struct ath12k_pdev_cap *cap = &ar->pdev->cap; in __ath12k_mac_register()
7212 SET_IEEE80211_PERM_ADDR(ar->hw, ar->mac_addr); in __ath12k_mac_register()
7214 SET_IEEE80211_DEV(ar->hw, ab->dev); in __ath12k_mac_register()
7217 cap->supported_bands); in __ath12k_mac_register()
7226 ath12k_err(ar->ab, "failed to setup interface combinations: %d\n", ret); in __ath12k_mac_register()
7230 ar->hw->wiphy->available_antennas_rx = cap->rx_chain_mask; in __ath12k_mac_register()
7231 ar->hw->wiphy->available_antennas_tx = cap->tx_chain_mask; in __ath12k_mac_register()
7233 ar->hw->wiphy->interface_modes = ab->hw_params->interface_modes; in __ath12k_mac_register()
7235 ieee80211_hw_set(ar->hw, SIGNAL_DBM); in __ath12k_mac_register()
7236 ieee80211_hw_set(ar->hw, SUPPORTS_PS); in __ath12k_mac_register()
7237 ieee80211_hw_set(ar->hw, SUPPORTS_DYNAMIC_PS); in __ath12k_mac_register()
7238 ieee80211_hw_set(ar->hw, MFP_CAPABLE); in __ath12k_mac_register()
7239 ieee80211_hw_set(ar->hw, REPORTS_TX_ACK_STATUS); in __ath12k_mac_register()
7240 ieee80211_hw_set(ar->hw, HAS_RATE_CONTROL); in __ath12k_mac_register()
7241 ieee80211_hw_set(ar->hw, AP_LINK_PS); in __ath12k_mac_register()
7242 ieee80211_hw_set(ar->hw, SPECTRUM_MGMT); in __ath12k_mac_register()
7243 ieee80211_hw_set(ar->hw, CONNECTION_MONITOR); in __ath12k_mac_register()
7244 ieee80211_hw_set(ar->hw, SUPPORTS_PER_STA_GTK); in __ath12k_mac_register()
7245 ieee80211_hw_set(ar->hw, CHANCTX_STA_CSA); in __ath12k_mac_register()
7246 ieee80211_hw_set(ar->hw, QUEUE_CONTROL); in __ath12k_mac_register()
7247 ieee80211_hw_set(ar->hw, SUPPORTS_TX_FRAG); in __ath12k_mac_register()
7248 ieee80211_hw_set(ar->hw, REPORTS_LOW_ACK); in __ath12k_mac_register()
7251 ieee80211_hw_set(ar->hw, AMPDU_AGGREGATION); in __ath12k_mac_register()
7252 ieee80211_hw_set(ar->hw, TX_AMPDU_SETUP_IN_HW); in __ath12k_mac_register()
7253 ieee80211_hw_set(ar->hw, SUPPORTS_REORDERING_BUFFER); in __ath12k_mac_register()
7254 ieee80211_hw_set(ar->hw, SUPPORTS_AMSDU_IN_AMPDU); in __ath12k_mac_register()
7255 ieee80211_hw_set(ar->hw, USES_RSS); in __ath12k_mac_register()
7258 ar->hw->wiphy->features |= NL80211_FEATURE_STATIC_SMPS; in __ath12k_mac_register()
7259 ar->hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; in __ath12k_mac_register()
7266 ar->hw->wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS; in __ath12k_mac_register()
7268 ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID; in __ath12k_mac_register()
7269 ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN; in __ath12k_mac_register()
7271 ar->hw->max_listen_interval = ATH12K_MAX_HW_LISTEN_INTERVAL; in __ath12k_mac_register()
7273 ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; in __ath12k_mac_register()
7274 ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; in __ath12k_mac_register()
7275 ar->hw->wiphy->max_remain_on_channel_duration = 5000; in __ath12k_mac_register()
7277 ar->hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; in __ath12k_mac_register()
7278 ar->hw->wiphy->features |= NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE | in __ath12k_mac_register()
7281 ar->max_num_stations = TARGET_NUM_STATIONS; in __ath12k_mac_register()
7282 ar->max_num_peers = TARGET_NUM_PEERS_PDEV; in __ath12k_mac_register()
7284 ar->hw->wiphy->max_ap_assoc_sta = ar->max_num_stations; in __ath12k_mac_register()
7286 ar->hw->queues = ATH12K_HW_MAX_QUEUES; in __ath12k_mac_register()
7287 ar->hw->wiphy->tx_queue_len = ATH12K_QUEUE_LEN; in __ath12k_mac_register()
7288 ar->hw->offchannel_tx_hw_queue = ATH12K_HW_MAX_QUEUES - 1; in __ath12k_mac_register()
7289 ar->hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; in __ath12k_mac_register()
7291 ar->hw->vif_data_size = sizeof(struct ath12k_vif); in __ath12k_mac_register()
7292 ar->hw->sta_data_size = sizeof(struct ath12k_sta); in __ath12k_mac_register()
7294 wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST); in __ath12k_mac_register()
7295 wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_STA_TX_PWR); in __ath12k_mac_register()
7297 ar->hw->wiphy->cipher_suites = cipher_suites; in __ath12k_mac_register()
7298 ar->hw->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); in __ath12k_mac_register()
7300 ar->hw->wiphy->iftype_ext_capab = ath12k_iftypes_ext_capa; in __ath12k_mac_register()
7301 ar->hw->wiphy->num_iftype_ext_capab = in __ath12k_mac_register()
7304 if (ar->supports_6ghz) { in __ath12k_mac_register()
7305 wiphy_ext_feature_set(ar->hw->wiphy, in __ath12k_mac_register()
7307 wiphy_ext_feature_set(ar->hw->wiphy, in __ath12k_mac_register()
7311 wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_PUNCT); in __ath12k_mac_register()
7315 if (!test_bit(ATH12K_FLAG_RAW_MODE, &ab->dev_flags)) { in __ath12k_mac_register()
7316 ar->hw->netdev_features = NETIF_F_HW_CSUM; in __ath12k_mac_register()
7317 ieee80211_hw_set(ar->hw, SW_CRYPTO_CONTROL); in __ath12k_mac_register()
7318 ieee80211_hw_set(ar->hw, SUPPORT_FAST_XMIT); in __ath12k_mac_register()
7321 ret = ieee80211_register_hw(ar->hw); in __ath12k_mac_register()
7323 ath12k_err(ar->ab, "ieee80211 registration failed: %d\n", ret); in __ath12k_mac_register()
7327 if (!ab->hw_params->supports_monitor) in __ath12k_mac_register()
7333 ar->hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR); in __ath12k_mac_register()
7338 ath12k_err(ar->ab, "ath12k regd update failed: %d\n", ret); in __ath12k_mac_register()
7345 ieee80211_unregister_hw(ar->hw); in __ath12k_mac_register()
7348 kfree(ar->hw->wiphy->iface_combinations[0].limits); in __ath12k_mac_register()
7349 kfree(ar->hw->wiphy->iface_combinations); in __ath12k_mac_register()
7352 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); in __ath12k_mac_register()
7353 kfree(ar->mac.sbands[NL80211_BAND_5GHZ].channels); in __ath12k_mac_register()
7354 kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels); in __ath12k_mac_register()
7357 SET_IEEE80211_DEV(ar->hw, NULL); in __ath12k_mac_register()
7368 if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) in ath12k_mac_register()
7371 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_register()
7372 pdev = &ab->pdevs[i]; in ath12k_mac_register()
7373 ar = pdev->ar; in ath12k_mac_register()
7374 if (ab->pdevs_macaddr_valid) { in ath12k_mac_register()
7375 ether_addr_copy(ar->mac_addr, pdev->mac_addr); in ath12k_mac_register()
7377 ether_addr_copy(ar->mac_addr, ab->mac_addr); in ath12k_mac_register()
7378 ar->mac_addr[4] += i; in ath12k_mac_register()
7385 init_waitqueue_head(&ar->txmgmt_empty_waitq); in ath12k_mac_register()
7386 idr_init(&ar->txmgmt_idr); in ath12k_mac_register()
7387 spin_lock_init(&ar->txmgmt_idr_lock); in ath12k_mac_register()
7391 ab->cc_freq_hz = 320000; in ath12k_mac_register()
7392 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS)) - 1; in ath12k_mac_register()
7397 for (i = i - 1; i >= 0; i--) { in ath12k_mac_register()
7398 pdev = &ab->pdevs[i]; in ath12k_mac_register()
7399 ar = pdev->ar; in ath12k_mac_register()
7408 struct ieee80211_hw *hw; in ath12k_mac_allocate() local
7414 if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) in ath12k_mac_allocate()
7417 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_allocate()
7418 pdev = &ab->pdevs[i]; in ath12k_mac_allocate()
7419 hw = ieee80211_alloc_hw(sizeof(struct ath12k), &ath12k_ops); in ath12k_mac_allocate()
7420 if (!hw) { in ath12k_mac_allocate()
7421 ath12k_warn(ab, "failed to allocate mac80211 hw device\n"); in ath12k_mac_allocate()
7422 ret = -ENOMEM; in ath12k_mac_allocate()
7426 ar = hw->priv; in ath12k_mac_allocate()
7427 ar->hw = hw; in ath12k_mac_allocate()
7428 ar->ab = ab; in ath12k_mac_allocate()
7429 ar->pdev = pdev; in ath12k_mac_allocate()
7430 ar->pdev_idx = i; in ath12k_mac_allocate()
7431 ar->lmac_id = ath12k_hw_get_mac_from_pdev_id(ab->hw_params, i); in ath12k_mac_allocate()
7433 ar->wmi = &ab->wmi_ab.wmi[i]; in ath12k_mac_allocate()
7439 ar->cfg_tx_chainmask = pdev->cap.tx_chain_mask; in ath12k_mac_allocate()
7440 ar->cfg_rx_chainmask = pdev->cap.rx_chain_mask; in ath12k_mac_allocate()
7441 ar->num_tx_chains = hweight32(pdev->cap.tx_chain_mask); in ath12k_mac_allocate()
7442 ar->num_rx_chains = hweight32(pdev->cap.rx_chain_mask); in ath12k_mac_allocate()
7444 pdev->ar = ar; in ath12k_mac_allocate()
7445 spin_lock_init(&ar->data_lock); in ath12k_mac_allocate()
7446 INIT_LIST_HEAD(&ar->arvifs); in ath12k_mac_allocate()
7447 INIT_LIST_HEAD(&ar->ppdu_stats_info); in ath12k_mac_allocate()
7448 mutex_init(&ar->conf_mutex); in ath12k_mac_allocate()
7449 init_completion(&ar->vdev_setup_done); in ath12k_mac_allocate()
7450 init_completion(&ar->vdev_delete_done); in ath12k_mac_allocate()
7451 init_completion(&ar->peer_assoc_done); in ath12k_mac_allocate()
7452 init_completion(&ar->peer_delete_done); in ath12k_mac_allocate()
7453 init_completion(&ar->install_key_done); in ath12k_mac_allocate()
7454 init_completion(&ar->bss_survey_done); in ath12k_mac_allocate()
7455 init_completion(&ar->scan.started); in ath12k_mac_allocate()
7456 init_completion(&ar->scan.completed); in ath12k_mac_allocate()
7458 INIT_DELAYED_WORK(&ar->scan.timeout, ath12k_scan_timeout_work); in ath12k_mac_allocate()
7459 INIT_WORK(&ar->regd_update_work, ath12k_regd_update_work); in ath12k_mac_allocate()
7461 INIT_WORK(&ar->wmi_mgmt_tx_work, ath12k_mgmt_over_wmi_tx_work); in ath12k_mac_allocate()
7462 skb_queue_head_init(&ar->wmi_mgmt_tx_queue); in ath12k_mac_allocate()
7463 clear_bit(ATH12K_FLAG_MONITOR_ENABLED, &ar->monitor_flags); in ath12k_mac_allocate()
7480 for (i = 0; i < ab->num_radios; i++) { in ath12k_mac_destroy()
7481 pdev = &ab->pdevs[i]; in ath12k_mac_destroy()
7482 ar = pdev->ar; in ath12k_mac_destroy()
7486 ieee80211_free_hw(ar->hw); in ath12k_mac_destroy()
7487 pdev->ar = NULL; in ath12k_mac_destroy()