Lines Matching refs:ar
532 struct ath12k_vif *ath12k_mac_get_arvif(struct ath12k *ar, u32 vdev_id) in ath12k_mac_get_arvif() argument
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()
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()
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()
594 return pdev ? pdev->ar : NULL; in ath12k_mac_get_ar_by_pdev_id()
604 return (pdev->ar ? pdev->ar : NULL); in ath12k_mac_get_ar_by_pdev_id()
610 static void ath12k_pdev_caps_update(struct ath12k *ar) in ath12k_pdev_caps_update() argument
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()
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()
628 static int ath12k_mac_txpower_recalc(struct ath12k *ar) in ath12k_mac_txpower_recalc() argument
630 struct ath12k_pdev *pdev = ar->pdev; 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()
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()
658 ar->txpower_limit_2g != txpower) { in ath12k_mac_txpower_recalc()
660 ret = ath12k_wmi_pdev_set_param(ar, param, 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()
668 ar->txpower_limit_5g != txpower) { in ath12k_mac_txpower_recalc()
670 ret = ath12k_wmi_pdev_set_param(ar, param, 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() local
691 lockdep_assert_held(&ar->conf_mutex); 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()
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()
726 struct ath12k *ar = arvif->ar; in ath12k_mac_set_kickout() local
730 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_STA_KICKOUT_TH, 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()
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()
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()
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()
769 void ath12k_mac_peer_cleanup_all(struct ath12k *ar) in ath12k_mac_peer_cleanup_all() argument
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()
778 ath12k_dp_rx_peer_tid_cleanup(ar, peer); 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()
788 static int ath12k_mac_vdev_setup_sync(struct ath12k *ar) in ath12k_mac_vdev_setup_sync() argument
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()
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()
802 return ar->last_wmi_vdev_start_status ? -EINVAL : 0; in ath12k_mac_vdev_setup_sync()
805 static int ath12k_monitor_vdev_up(struct ath12k *ar, int vdev_id) in ath12k_monitor_vdev_up() argument
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()
821 static int ath12k_mac_monitor_vdev_start(struct ath12k *ar, int vdev_id, in ath12k_mac_monitor_vdev_start() argument
828 lockdep_assert_held(&ar->conf_mutex); 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()
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()
852 ret = ath12k_wmi_vdev_start(ar, &arg, false); 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()
859 ret = ath12k_mac_vdev_setup_sync(ar); 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()
878 ret = ath12k_wmi_vdev_stop(ar, vdev_id); 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()
885 static int ath12k_mac_monitor_vdev_stop(struct ath12k *ar) in ath12k_mac_monitor_vdev_stop() argument
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()
898 ret = ath12k_mac_vdev_setup_sync(ar); 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()
913 static int ath12k_mac_monitor_vdev_create(struct ath12k *ar) in ath12k_mac_monitor_vdev_create() argument
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()
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()
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()
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()
951 ret = ath12k_wmi_vdev_create(ar, tmp_addr, &arg); 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()
968 ret = ath12k_mac_txpower_recalc(ar); 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()
982 static int ath12k_mac_monitor_vdev_delete(struct ath12k *ar) in ath12k_mac_monitor_vdev_delete() argument
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()
1028 static int ath12k_mac_monitor_start(struct ath12k *ar) in ath12k_mac_monitor_start() argument
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()
1047 ath12k_mac_monitor_vdev_delete(ar); 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()
1053 ret = ath12k_dp_tx_htt_monitor_mode_ring_config(ar, false); 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()
1059 static int ath12k_mac_monitor_stop(struct ath12k *ar) in ath12k_mac_monitor_stop() argument
1063 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_monitor_stop()
1065 if (!ar->monitor_started) in ath12k_mac_monitor_stop()
1068 ret = ath12k_mac_monitor_vdev_stop(ar); 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()
1076 ret = ath12k_dp_tx_htt_monitor_mode_ring_config(ar, true); 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()
1083 struct ath12k *ar = hw->priv; in ath12k_mac_op_config() local
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()
1094 ret = ath12k_mac_monitor_vdev_create(ar); in ath12k_mac_op_config()
1097 ret = ath12k_mac_monitor_start(ar); in ath12k_mac_op_config()
1101 if (!ar->monitor_vdev_created) in ath12k_mac_op_config()
1103 ret = ath12k_mac_monitor_stop(ar); in ath12k_mac_op_config()
1106 ath12k_mac_monitor_vdev_delete(ar); in ath12k_mac_op_config()
1111 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_config()
1115 ath12k_mac_monitor_vdev_delete(ar); 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() local
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()
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() local
1169 lockdep_assert_held(&arvif->ar->conf_mutex); 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()
1184 ath12k_warn(ar->ab, "failed to update bcn tmpl during vdev up: %d\n", in ath12k_control_beaconing()
1193 ret = ath12k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid, in ath12k_control_beaconing()
1196 ath12k_warn(ar->ab, "failed to bring up vdev %d: %i\n", in ath12k_control_beaconing()
1203 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac vdev %d up\n", arvif->vdev_id); in ath12k_control_beaconing()
1206 static void ath12k_peer_assoc_h_basic(struct ath12k *ar, in ath12k_peer_assoc_h_basic() argument
1214 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_basic()
1226 arg->peer_listen_intval = ar->hw->conf.listen_interval; in ath12k_peer_assoc_h_basic()
1231 static void ath12k_peer_assoc_h_crypto(struct ath12k *ar, in ath12k_peer_assoc_h_crypto() argument
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()
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()
1279 ath12k_dbg(ar->ab, ATH12K_DBG_WMI, in ath12k_peer_assoc_h_crypto()
1292 static void ath12k_peer_assoc_h_rates(struct ath12k *ar, in ath12k_peer_assoc_h_rates() argument
1307 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_h_rates()
1313 sband = ar->hw->wiphy->bands[band]; in ath12k_peer_assoc_h_rates()
1354 static void ath12k_peer_assoc_h_ht(struct ath12k *ar, in ath12k_peer_assoc_h_ht() argument
1368 lockdep_assert_held(&ar->conf_mutex); 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()
1515 static void ath12k_peer_assoc_h_vht(struct ath12k *ar, in ath12k_peer_assoc_h_vht() argument
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()
1610 static void ath12k_peer_assoc_h_he(struct ath12k *ar, in ath12k_peer_assoc_h_he() argument
1791 static void ath12k_peer_assoc_h_qos(struct ath12k *ar, in ath12k_peer_assoc_h_qos() argument
1823 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac peer %pM qos %d\n", in ath12k_peer_assoc_h_qos()
1827 static int ath12k_peer_assoc_qos_ap(struct ath12k *ar, in ath12k_peer_assoc_qos_ap() argument
1836 lockdep_assert_held(&ar->conf_mutex); 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()
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()
1900 static enum wmi_phy_mode ath12k_mac_get_phymode_vht(struct ath12k *ar, in ath12k_mac_get_phymode_vht() argument
1928 static enum wmi_phy_mode ath12k_mac_get_phymode_he(struct ath12k *ar, in ath12k_mac_get_phymode_he() argument
1954 static enum wmi_phy_mode ath12k_mac_get_phymode_eht(struct ath12k *ar, in ath12k_mac_get_phymode_eht() argument
1971 ath12k_warn(ar->ab, "invalid EHT PHY capability info for 160 Mhz: %d\n", in ath12k_mac_get_phymode_eht()
1989 static void ath12k_peer_assoc_h_phymode(struct ath12k *ar, in ath12k_peer_assoc_h_phymode() argument
2044 phymode = ath12k_mac_get_phymode_eht(ar, sta); in ath12k_peer_assoc_h_phymode()
2046 phymode = ath12k_mac_get_phymode_he(ar, sta); in ath12k_peer_assoc_h_phymode()
2049 phymode = ath12k_mac_get_phymode_vht(ar, sta); 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()
2134 static void ath12k_peer_assoc_h_eht(struct ath12k *ar, in ath12k_peer_assoc_h_eht() argument
2217 static void ath12k_peer_assoc_prepare(struct ath12k *ar, in ath12k_peer_assoc_prepare() argument
2223 lockdep_assert_held(&ar->conf_mutex); in ath12k_peer_assoc_prepare()
2227 reinit_completion(&ar->peer_assoc_done); in ath12k_peer_assoc_prepare()
2230 ath12k_peer_assoc_h_basic(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2231 ath12k_peer_assoc_h_crypto(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2232 ath12k_peer_assoc_h_rates(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2233 ath12k_peer_assoc_h_ht(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2234 ath12k_peer_assoc_h_vht(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2235 ath12k_peer_assoc_h_he(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2236 ath12k_peer_assoc_h_eht(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2237 ath12k_peer_assoc_h_qos(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2238 ath12k_peer_assoc_h_phymode(ar, vif, sta, arg); in ath12k_peer_assoc_prepare()
2244 static int ath12k_setup_peer_smps(struct ath12k *ar, struct ath12k_vif *arvif, in ath12k_setup_peer_smps() argument
2259 return ath12k_wmi_set_peer_param(ar, addr, arvif->vdev_id, in ath12k_setup_peer_smps()
2268 struct ath12k *ar = hw->priv; in ath12k_bss_assoc() local
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()
2285 ath12k_warn(ar->ab, "failed to find station entry for bss %pM vdev %i\n", in ath12k_bss_assoc()
2291 ath12k_peer_assoc_prepare(ar, vif, ap_sta, &peer_arg, false); in ath12k_bss_assoc()
2295 ret = ath12k_wmi_send_peer_assoc_cmd(ar, &peer_arg); in ath12k_bss_assoc()
2297 ath12k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n", 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()
2308 ret = ath12k_setup_peer_smps(ar, arvif, bss_conf->bssid, in ath12k_bss_assoc()
2311 ath12k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", 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()
2330 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, 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()
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()
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()
2355 ath12k_warn(ar->ab, "failed to set vdev %i OBSS PD parameters: %d\n", in ath12k_bss_assoc()
2362 struct ath12k *ar = hw->priv; in ath12k_bss_disassoc() local
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()
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()
2406 static void ath12k_recalculate_mgmt_rate(struct ath12k *ar, in ath12k_recalculate_mgmt_rate() argument
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()
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() local
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()
2463 tmpl = ieee80211_get_unsol_bcast_probe_resp_tmpl(ar->hw, 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()
2483 ret = ath12k_wmi_fils_discovery(ar, arvif->vdev_id, interval, in ath12k_mac_fils_discovery()
2494 struct ath12k *ar = hw->priv; in ath12k_mac_op_bss_info_changed() local
2508 mutex_lock(&ar->conf_mutex); 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()
2518 ath12k_warn(ar->ab, "Failed to set beacon interval for VDEV: %d\n", in ath12k_mac_op_bss_info_changed()
2521 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, in ath12k_mac_op_bss_info_changed()
2529 ret = ath12k_wmi_pdev_set_param(ar, param_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()
2535 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, 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()
2549 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, 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()
2557 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, 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()
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()
2596 ath12k_warn(ar->ab, "Failed to set he oper params %x for VDEV %d: %i\n", 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()
2614 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "Set CTS prot: %d for VDEV: %d\n", 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()
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()
2637 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, 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()
2657 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, 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()
2674 ath12k_mac_txpower_recalc(ar); 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()
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()
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()
2723 ath12k_recalculate_mgmt_rate(ar, vif, &def); 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()
2738 ret = ath12k_wmi_obss_color_cfg_cmd(ar, 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()
2747 ret = ath12k_wmi_send_bss_color_change_enable_cmd(ar, 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()
2753 ret = ath12k_wmi_obss_color_cfg_cmd(ar, 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()
2771 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_bss_info_changed()
2774 void __ath12k_mac_scan_finish(struct ath12k *ar) in __ath12k_mac_scan_finish() argument
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()
2804 void ath12k_mac_scan_finish(struct ath12k *ar) in ath12k_mac_scan_finish() argument
2806 spin_lock_bh(&ar->data_lock); in ath12k_mac_scan_finish()
2807 __ath12k_mac_scan_finish(ar); in ath12k_mac_scan_finish()
2808 spin_unlock_bh(&ar->data_lock); in ath12k_mac_scan_finish()
2811 static int ath12k_scan_stop(struct ath12k *ar) in ath12k_scan_stop() argument
2819 lockdep_assert_held(&ar->conf_mutex); in ath12k_scan_stop()
2822 arg.pdev_id = ar->pdev->pdev_id; in ath12k_scan_stop()
2824 ret = ath12k_wmi_send_scan_stop_cmd(ar, &arg); 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()
2847 spin_lock_bh(&ar->data_lock); in ath12k_scan_stop()
2848 if (ar->scan.state != ATH12K_SCAN_IDLE) in ath12k_scan_stop()
2849 __ath12k_mac_scan_finish(ar); in ath12k_scan_stop()
2850 spin_unlock_bh(&ar->data_lock); in ath12k_scan_stop()
2855 static void ath12k_scan_abort(struct ath12k *ar) in ath12k_scan_abort() argument
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()
2878 ret = ath12k_scan_stop(ar); 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()
2891 struct ath12k *ar = container_of(work, struct ath12k, in ath12k_scan_timeout_work() local
2894 mutex_lock(&ar->conf_mutex); in ath12k_scan_timeout_work()
2895 ath12k_scan_abort(ar); in ath12k_scan_timeout_work()
2896 mutex_unlock(&ar->conf_mutex); in ath12k_scan_timeout_work()
2899 static int ath12k_start_scan(struct ath12k *ar, in ath12k_start_scan() argument
2904 lockdep_assert_held(&ar->conf_mutex); in ath12k_start_scan()
2906 ret = ath12k_wmi_send_scan_start_cmd(ar, arg); in ath12k_start_scan()
2910 ret = wait_for_completion_timeout(&ar->scan.started, 1 * HZ); in ath12k_start_scan()
2912 ret = ath12k_scan_stop(ar); in ath12k_start_scan()
2914 ath12k_warn(ar->ab, "failed to stop scan: %d\n", ret); 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()
2928 spin_unlock_bh(&ar->data_lock); in ath12k_start_scan()
2937 struct ath12k *ar = hw->priv; in ath12k_mac_op_hw_scan() local
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()
2962 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_hw_scan()
2967 ath12k_wmi_start_scan_init(ar, &arg); in ath12k_mac_op_hw_scan()
3002 ret = ath12k_start_scan(ar, &arg); 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()
3021 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_hw_scan()
3028 struct ath12k *ar = hw->priv; in ath12k_mac_op_cancel_hw_scan() local
3030 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_cancel_hw_scan()
3031 ath12k_scan_abort(ar); 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() local
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()
3087 ath12k_warn(ar->ab, "cipher %d is not supported\n", key->cipher); in ath12k_install_key()
3091 if (test_bit(ATH12K_FLAG_RAW_MODE, &ar->ab->dev_flags)) 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()
3107 return ar->install_key_status ? -EINVAL : 0; in ath12k_install_key()
3113 struct ath12k *ar = arvif->ar; in ath12k_clear_peer_keys() local
3114 struct ath12k_base *ab = ar->ab; in ath12k_clear_peer_keys()
3121 lockdep_assert_held(&ar->conf_mutex); in ath12k_clear_peer_keys()
3156 struct ath12k *ar = hw->priv; in ath12k_mac_op_set_key() local
3157 struct ath12k_base *ab = ar->ab; 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()
3178 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_key()
3271 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_key()
3276 ath12k_mac_bitrate_mask_num_vht_rates(struct ath12k *ar, in ath12k_mac_bitrate_mask_num_vht_rates() argument
3295 struct ath12k *ar = arvif->ar; in ath12k_mac_set_peer_vht_fixed_rate() local
3300 lockdep_assert_held(&ar->conf_mutex); 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()
3317 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, 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()
3328 ath12k_warn(ar->ab, in ath12k_mac_set_peer_vht_fixed_rate()
3335 static int ath12k_station_assoc(struct ath12k *ar, in ath12k_station_assoc() argument
3348 lockdep_assert_held(&ar->conf_mutex); in ath12k_station_assoc()
3356 ath12k_peer_assoc_prepare(ar, vif, sta, &peer_arg, reassoc); in ath12k_station_assoc()
3358 ret = ath12k_wmi_send_peer_assoc_cmd(ar, &peer_arg); 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()
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()
3371 num_vht_rates = ath12k_mac_bitrate_mask_num_vht_rates(ar, band, mask); in ath12k_station_assoc()
3391 ret = ath12k_setup_peer_smps(ar, arvif, sta->addr, in ath12k_station_assoc()
3394 ath12k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n", in ath12k_station_assoc()
3407 ret = ath12k_peer_assoc_qos_ap(ar, arvif, sta); 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()
3418 static int ath12k_station_disassoc(struct ath12k *ar, in ath12k_station_disassoc() argument
3425 lockdep_assert_held(&ar->conf_mutex); in ath12k_station_disassoc()
3436 ath12k_warn(ar->ab, "failed to clear all peer keys for vdev %i: %d\n", in ath12k_station_disassoc()
3445 struct ath12k *ar; in ath12k_sta_rc_update_wk() local
3462 ar = arvif->ar; in ath12k_sta_rc_update_wk()
3471 spin_lock_bh(&ar->data_lock); 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()
3501 err = ath12k_wmi_set_peer_param(ar, sta->addr, 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()
3509 err = ath12k_wmi_set_peer_param(ar, sta->addr, 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()
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()
3522 err = ath12k_wmi_set_peer_param(ar, sta->addr, 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()
3530 err = ath12k_wmi_set_peer_param(ar, sta->addr, 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()
3540 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac update sta %pM nss %d\n", 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()
3551 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "mac update sta %pM smps %d\n", 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()
3563 num_vht_rates = ath12k_mac_bitrate_mask_num_vht_rates(ar, band, in ath12k_sta_rc_update_wk()
3585 ath12k_peer_assoc_prepare(ar, arvif->vif, sta, in ath12k_sta_rc_update_wk()
3588 err = ath12k_wmi_send_peer_assoc_cmd(ar, &peer_arg); 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()
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()
3599 mutex_unlock(&ar->conf_mutex); in ath12k_sta_rc_update_wk()
3605 struct ath12k *ar = arvif->ar; in ath12k_mac_inc_num_stations() local
3607 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_inc_num_stations()
3612 if (ar->num_stations >= ar->max_num_stations) 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() local
3625 lockdep_assert_held(&ar->conf_mutex); in ath12k_mac_dec_num_stations()
3630 ar->num_stations--; in ath12k_mac_dec_num_stations()
3633 static int ath12k_mac_station_add(struct ath12k *ar, in ath12k_mac_station_add() argument
3637 struct ath12k_base *ab = ar->ab; 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()
3662 ret = ath12k_peer_create(ar, arvif, sta, &peer_param); in ath12k_mac_station_add()
3673 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_station_add()
3683 ret = ath12k_dp_peer_setup(ar, arvif->vdev_id, sta->addr); 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()
3710 static u32 ath12k_mac_ieee80211_sta_bw_to_wmi(struct ath12k *ar, in ath12k_mac_ieee80211_sta_bw_to_wmi() argument
3729 ath12k_warn(ar->ab, "Invalid bandwidth %d in rc update for %pM\n", in ath12k_mac_ieee80211_sta_bw_to_wmi()
3744 struct ath12k *ar = hw->priv; in ath12k_mac_op_sta_state() local
3755 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_sta_state()
3763 ret = ath12k_mac_station_add(ar, vif, sta); 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()
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()
3776 ath12k_dbg(ar->ab, ATH12K_DBG_MAC, "Removed peer: %pM for VDEV: %d\n", 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()
3783 ath12k_warn(ar->ab, "Found peer entry %pM n vdev %i after it was supposedly removed\n", 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()
3799 ret = ath12k_station_assoc(ar, vif, sta, false); in ath12k_mac_op_sta_state()
3801 ath12k_warn(ar->ab, "Failed to associate station: %pM\n", 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()
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()
3818 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3821 ret = ath12k_wmi_set_peer_param(ar, sta->addr, 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()
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()
3837 spin_unlock_bh(&ar->ab->base_lock); in ath12k_mac_op_sta_state()
3843 ret = ath12k_station_disassoc(ar, vif, sta); in ath12k_mac_op_sta_state()
3845 ath12k_warn(ar->ab, "Failed to disassociate station: %pM\n", in ath12k_mac_op_sta_state()
3849 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_sta_state()
3857 struct ath12k *ar = hw->priv; in ath12k_mac_op_sta_set_txpwr() local
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()
3893 struct ath12k *ar = hw->priv; in ath12k_mac_op_sta_rc_update() local
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()
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()
3916 spin_lock_bh(&ar->data_lock); in ath12k_mac_op_sta_rc_update()
3919 bw = ath12k_mac_ieee80211_sta_bw_to_wmi(ar, sta); 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()
3953 spin_unlock_bh(&ar->data_lock); in ath12k_mac_op_sta_rc_update()
3958 static int ath12k_conf_tx_uapsd(struct ath12k *ar, struct ieee80211_vif *vif, in ath12k_conf_tx_uapsd() argument
3992 ret = ath12k_wmi_set_sta_ps_param(ar, arvif->vdev_id, in ath12k_conf_tx_uapsd()
3996 ath12k_warn(ar->ab, "could not set uapsd params %d\n", ret); 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()
4020 struct ath12k *ar = hw->priv; in ath12k_mac_op_conf_tx() local
4025 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_conf_tx()
4052 ret = ath12k_wmi_send_wmm_update_cmd(ar, arvif->vdev_id, 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()
4070 ath12k_create_ht_cap(struct ath12k *ar, u32 ar_ht_cap, u32 rate_cap_rx_chainmask) in ath12k_create_ht_cap() argument
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() local
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()
4178 return ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_set_txbf_conf()
4182 static void ath12k_set_vht_txbf_cap(struct ath12k *ar, u32 *vht_cap) in ath12k_set_vht_txbf_cap() argument
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()
4225 ath12k_create_vht_cap(struct ath12k *ar, u32 rate_cap_tx_chainmask, in ath12k_create_vht_cap() argument
4233 vht_cap.cap = ar->pdev->cap.vht_cap; in ath12k_create_vht_cap()
4235 ath12k_set_vht_txbf_cap(ar, &vht_cap.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()
4265 static void ath12k_mac_setup_ht_vht_cap(struct ath12k *ar, in ath12k_mac_setup_ht_vht_cap() argument
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()
4278 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; 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()
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()
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()
4300 static int ath12k_check_chain_mask(struct ath12k *ar, u32 ant, bool is_tx_ant) in ath12k_check_chain_mask() argument
4601 static int ath12k_mac_copy_sband_iftype_data(struct ath12k *ar, in ath12k_mac_copy_sband_iftype_data() argument
4624 ath12k_mac_copy_he_cap(band_cap, i, ar->num_tx_chains, he_cap); in ath12k_mac_copy_sband_iftype_data()
4637 static void ath12k_mac_setup_sband_iftype_data(struct ath12k *ar, in ath12k_mac_setup_sband_iftype_data() argument
4646 count = ath12k_mac_copy_sband_iftype_data(ar, 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()
4656 count = ath12k_mac_copy_sband_iftype_data(ar, 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()
4665 ar->supports_6ghz) { in ath12k_mac_setup_sband_iftype_data()
4667 count = ath12k_mac_copy_sband_iftype_data(ar, cap, 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()
4676 static int __ath12k_set_antenna(struct ath12k *ar, u32 tx_ant, u32 rx_ant) in __ath12k_set_antenna() argument
4680 lockdep_assert_held(&ar->conf_mutex); in __ath12k_set_antenna()
4682 if (ath12k_check_chain_mask(ar, tx_ant, true)) in __ath12k_set_antenna()
4685 if (ath12k_check_chain_mask(ar, rx_ant, false)) 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()
4695 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_TX_CHAIN_MASK, 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()
4705 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_RX_CHAIN_MASK, 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()
4722 static void ath12k_mgmt_over_wmi_tx_drop(struct ath12k *ar, struct sk_buff *skb) in ath12k_mgmt_over_wmi_tx_drop() argument
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()
4741 struct ath12k *ar = ctx; in ath12k_mac_tx_mgmt_pending_free() local
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()
4753 ath12k_mgmt_over_wmi_tx_drop(ar, skb); in ath12k_mac_tx_mgmt_pending_free()
4763 struct ath12k *ar = skb_cb->ar; in ath12k_mac_vif_txmgmt_idr_remove() local
4764 struct ath12k_base *ab = ar->ab; 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()
4777 static int ath12k_mac_mgmt_tx_wmi(struct ath12k *ar, struct ath12k_vif *arvif, in ath12k_mac_mgmt_tx_wmi() argument
4780 struct ath12k_base *ab = ar->ab; 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()
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()
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()
4833 static void ath12k_mgmt_over_wmi_tx_purge(struct ath12k *ar) in ath12k_mgmt_over_wmi_tx_purge() argument
4837 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) in ath12k_mgmt_over_wmi_tx_purge()
4838 ath12k_mgmt_over_wmi_tx_drop(ar, skb); in ath12k_mgmt_over_wmi_tx_purge()
4843 struct ath12k *ar = container_of(work, struct ath12k, wmi_mgmt_tx_work); in ath12k_mgmt_over_wmi_tx_work() local
4849 while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) { 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()
4853 ath12k_mgmt_over_wmi_tx_drop(ar, skb); in ath12k_mgmt_over_wmi_tx_work()
4858 if (ar->allocated_vdev_map & (1LL << arvif->vdev_id) && in ath12k_mgmt_over_wmi_tx_work()
4860 ret = ath12k_mac_mgmt_tx_wmi(ar, arvif, skb); 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()
4864 ath12k_mgmt_over_wmi_tx_drop(ar, skb); in ath12k_mgmt_over_wmi_tx_work()
4867 ath12k_warn(ar->ab, in ath12k_mgmt_over_wmi_tx_work()
4871 ath12k_mgmt_over_wmi_tx_drop(ar, skb); in ath12k_mgmt_over_wmi_tx_work()
4876 static int ath12k_mac_mgmt_tx(struct ath12k *ar, struct sk_buff *skb, in ath12k_mac_mgmt_tx() argument
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()
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()
4897 ath12k_warn(ar->ab, "mgmt tx queue is full\n"); 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()
4913 struct ath12k *ar = hw->priv; in ath12k_mac_op_tx() local
4935 ret = ath12k_mac_mgmt_tx(ar, skb, is_prb_rsp); 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()
4944 ret = ath12k_dp_tx(ar, arvif, 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()
4951 void ath12k_mac_drain_tx(struct ath12k *ar) in ath12k_mac_drain_tx() argument
4956 cancel_work_sync(&ar->wmi_mgmt_tx_work); in ath12k_mac_drain_tx()
4957 ath12k_mgmt_over_wmi_tx_purge(ar); in ath12k_mac_drain_tx()
4960 static int ath12k_mac_config_mon_status_default(struct ath12k *ar, bool enable) in ath12k_mac_config_mon_status_default() argument
4990 struct ath12k *ar = hw->priv; in ath12k_mac_op_start() local
4991 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_start()
4992 struct ath12k_pdev *pdev = ar->pdev; in ath12k_mac_op_start()
4995 ath12k_mac_drain_tx(ar); 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()
5014 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_PMF_QOS, in ath12k_mac_op_start()
5018 ath12k_err(ar->ab, "failed to enable PMF QOS: (%d\n", ret); in ath12k_mac_op_start()
5022 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_DYNAMIC_BW, 1, in ath12k_mac_op_start()
5025 ath12k_err(ar->ab, "failed to enable dynamic bw: %d\n", ret); in ath12k_mac_op_start()
5029 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, in ath12k_mac_op_start()
5037 ret = ath12k_wmi_send_dfs_phyerr_offload_enable_cmd(ar, pdev->pdev_id); in ath12k_mac_op_start()
5044 ret = ath12k_dp_tx_htt_h2t_ppdu_stats_req(ar, in ath12k_mac_op_start()
5051 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_MESH_MCAST_ENABLE, 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()
5063 ath12k_reg_update_chan_list(ar); 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()
5073 ret = ath12k_mac_config_mon_status_default(ar, true); 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()
5089 ret = ath12k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_IDLE_PS_CONFIG, 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()
5113 struct ath12k *ar = hw->priv; in ath12k_mac_op_stop() local
5117 ath12k_mac_drain_tx(ar); in ath12k_mac_op_stop()
5119 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_stop()
5120 ret = ath12k_mac_config_mon_status_default(ar, false); 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()
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()
5172 struct ath12k *ar = arvif->ar; in ath12k_mac_setup_vdev_create_arg() local
5173 struct ath12k_pdev *pdev = ar->pdev; 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()
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()
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()
5231 static int ath12k_set_he_mu_sounding_mode(struct ath12k *ar, in ath12k_set_he_mu_sounding_mode() argument
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()
5252 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_set_he_mu_sounding_mode()
5265 struct ath12k *ar = hw->priv; in ath12k_mac_op_update_vif_offload() local
5266 struct ath12k_base *ab = ar->ab; 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()
5300 ret = ath12k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, in ath12k_mac_op_update_vif_offload()
5312 struct ath12k *ar = hw->priv; in ath12k_mac_op_add_interface() local
5313 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_add_interface()
5325 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_add_interface()
5328 ar->num_peers > (ar->max_num_peers - 1)) { in ath12k_mac_op_add_interface()
5334 if (ar->num_created_vdevs > (TARGET_NUM_VDEVS - 1)) { in ath12k_mac_op_add_interface()
5343 arvif->ar = ar; 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()
5395 ret = ath12k_wmi_vdev_create(ar, vif->addr, &vdev_arg); in ath12k_mac_op_add_interface()
5402 ar->num_created_vdevs++; in ath12k_mac_op_add_interface()
5405 ar->allocated_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()
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()
5428 ret = ath12k_peer_create(ar, arvif, NULL, &peer_param); 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()
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()
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()
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()
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()
5485 ret = ath12k_mac_txpower_recalc(ar); 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()
5498 ath12k_dp_vdev_tx_attach(ar, arvif); in ath12k_mac_op_add_interface()
5500 if (vif->type != NL80211_IFTYPE_MONITOR && ar->monitor_conf_enabled) in ath12k_mac_op_add_interface()
5501 ath12k_mac_monitor_vdev_create(ar); in ath12k_mac_op_add_interface()
5503 mutex_unlock(&ar->conf_mutex); 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()
5514 ath12k_warn(ar->ab, "failed to delete peer vdev_id %d addr %pM\n", in ath12k_mac_op_add_interface()
5519 ret = ath12k_wait_for_peer_delete_done(ar, arvif->vdev_id, 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()
5533 spin_lock_bh(&ar->data_lock); 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()
5571 struct ath12k *ar = hw->priv; in ath12k_mac_op_remove_interface() local
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()
5583 ret = ath12k_peer_delete(ar, arvif->vdev_id, vif->addr); 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()
5598 time_left = wait_for_completion_timeout(&ar->vdev_delete_done, 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()
5609 ret = ath12k_mac_monitor_vdev_delete(ar); in ath12k_mac_op_remove_interface()
5613 ar->allocated_vdev_map &= ~(1LL << arvif->vdev_id); in ath12k_mac_op_remove_interface()
5615 ar->num_created_vdevs--; in ath12k_mac_op_remove_interface()
5621 spin_lock_bh(&ar->data_lock); 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()
5634 ath12k_mac_txpower_recalc(ar); 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()
5657 struct ath12k *ar = hw->priv; in ath12k_mac_op_configure_filter() local
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()
5670 ret = ath12k_dp_tx_htt_monitor_mode_ring_config(ar, reset_flag); 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()
5689 struct ath12k *ar = hw->priv; in ath12k_mac_op_get_antenna() local
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()
5703 struct ath12k *ar = hw->priv; in ath12k_mac_op_set_antenna() local
5706 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_set_antenna()
5707 ret = __ath12k_set_antenna(ar, tx_ant, rx_ant); in ath12k_mac_op_set_antenna()
5708 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_antenna()
5717 struct ath12k *ar = hw->priv; in ath12k_mac_op_ampdu_action() local
5720 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_ampdu_action()
5724 ret = ath12k_dp_rx_ampdu_start(ar, params); in ath12k_mac_op_ampdu_action()
5727 ret = ath12k_dp_rx_ampdu_stop(ar, params); in ath12k_mac_op_ampdu_action()
5741 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_ampdu_action()
5749 struct ath12k *ar = hw->priv; in ath12k_mac_op_add_chanctx() local
5750 struct ath12k_base *ab = ar->ab; 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()
5773 struct ath12k *ar = hw->priv; in ath12k_mac_op_remove_chanctx() local
5774 struct ath12k_base *ab = ar->ab; 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() local
5798 struct ath12k_base *ab = ar->ab; 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()
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()
5836 arg.regdomain = ar->ab->dfs_region; in ath12k_mac_vdev_start_restart()
5841 ret = ath12k_set_he_mu_sounding_mode(ar, arvif); 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()
5857 ret = ath12k_wmi_vdev_start(ar, &arg, restart); in ath12k_mac_vdev_start_restart()
5859 ath12k_warn(ar->ab, "failed to %s WMI vdev %i\n", in ath12k_mac_vdev_start_restart()
5864 ret = ath12k_mac_vdev_setup_sync(ar); in ath12k_mac_vdev_start_restart()
5871 ar->num_started_vdevs++; in ath12k_mac_vdev_start_restart()
5885 set_bit(ATH12K_CAC_RUNNING, &ar->dev_flags); in ath12k_mac_vdev_start_restart()
5901 struct ath12k *ar = arvif->ar; in ath12k_mac_vdev_stop() local
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()
5915 ret = ath12k_mac_vdev_setup_sync(ar); in ath12k_mac_vdev_stop()
5917 ath12k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n", 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()
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()
5991 ath12k_mac_update_vif_chan(struct ath12k *ar, in ath12k_mac_update_vif_chan() argument
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()
6023 ret = ath12k_wmi_vdev_down(ar, arvif->vdev_id); 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()
6068 if (!monitor_vif && ar->monitor_vdev_created) { in ath12k_mac_update_vif_chan()
6069 if (!ath12k_mac_monitor_stop(ar)) in ath12k_mac_update_vif_chan()
6070 ath12k_mac_monitor_start(ar); in ath12k_mac_update_vif_chan()
6075 ath12k_mac_update_active_vif_chan(struct ath12k *ar, in ath12k_mac_update_active_vif_chan() argument
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()
6098 ath12k_mac_update_vif_chan(ar, arg.vifs, arg.n_vifs); in ath12k_mac_update_active_vif_chan()
6107 struct ath12k *ar = hw->priv; in ath12k_mac_op_change_chanctx() local
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()
6123 ath12k_mac_update_active_vif_chan(ar, ctx); in ath12k_mac_op_change_chanctx()
6128 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_change_chanctx()
6134 struct ath12k *ar = hw->priv; in ath12k_start_vdev_delay() local
6135 struct ath12k_base *ab = ar->ab; in ath12k_start_vdev_delay()
6151 ret = ath12k_monitor_vdev_up(ar, arvif->vdev_id); in ath12k_start_vdev_delay()
6170 struct ath12k *ar = hw->priv; in ath12k_mac_op_assign_vif_chanctx() local
6171 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_assign_vif_chanctx()
6176 mutex_lock(&ar->conf_mutex); in ath12k_mac_op_assign_vif_chanctx()
6204 param.peer_addr = ar->mac_addr; in ath12k_mac_op_assign_vif_chanctx()
6206 ret = ath12k_peer_create(ar, arvif, NULL, ¶m); in ath12k_mac_op_assign_vif_chanctx()
6215 ret = ath12k_mac_monitor_start(ar); 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()
6231 ath12k_mac_monitor_start(ar); in ath12k_mac_op_assign_vif_chanctx()
6238 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_assign_vif_chanctx()
6249 struct ath12k *ar = hw->priv; in ath12k_mac_op_unassign_vif_chanctx() local
6250 struct ath12k_base *ab = ar->ab; in ath12k_mac_op_unassign_vif_chanctx()
6254 mutex_lock(&ar->conf_mutex); 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()
6268 ret = ath12k_mac_monitor_stop(ar); in ath12k_mac_op_unassign_vif_chanctx()
6270 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
6286 ath12k_wmi_vdev_down(ar, arvif->vdev_id); in ath12k_mac_op_unassign_vif_chanctx()
6289 ar->num_started_vdevs == 1 && ar->monitor_vdev_created) in ath12k_mac_op_unassign_vif_chanctx()
6290 ath12k_mac_monitor_stop(ar); in ath12k_mac_op_unassign_vif_chanctx()
6292 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_unassign_vif_chanctx()
6301 struct ath12k *ar = hw->priv; in ath12k_mac_op_switch_vif_chanctx() local
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()
6308 ath12k_mac_update_vif_chan(ar, vifs, n_vifs); in ath12k_mac_op_switch_vif_chanctx()
6310 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_switch_vif_chanctx()
6316 ath12k_set_vdev_param_to_all_vifs(struct ath12k *ar, int param, u32 value) in ath12k_set_vdev_param_to_all_vifs() argument
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()
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()
6334 mutex_unlock(&ar->conf_mutex); in ath12k_set_vdev_param_to_all_vifs()
6343 struct ath12k *ar = hw->priv; in ath12k_mac_op_set_rts_threshold() local
6346 return ath12k_set_vdev_param_to_all_vifs(ar, param_id, value); in ath12k_mac_op_set_rts_threshold()
6367 struct ath12k *ar = hw->priv; in ath12k_mac_op_flush() local
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()
6388 ath12k_mac_bitrate_mask_num_ht_rates(struct ath12k *ar, in ath12k_mac_bitrate_mask_num_ht_rates() argument
6402 ath12k_mac_has_single_legacy_rate(struct ath12k *ar, in ath12k_mac_has_single_legacy_rate() argument
6410 if (ath12k_mac_bitrate_mask_num_ht_rates(ar, band, mask)) in ath12k_mac_has_single_legacy_rate()
6413 if (ath12k_mac_bitrate_mask_num_vht_rates(ar, band, mask)) in ath12k_mac_has_single_legacy_rate()
6420 ath12k_mac_bitrate_mask_get_single_nss(struct ath12k *ar, in ath12k_mac_bitrate_mask_get_single_nss() argument
6425 struct ieee80211_supported_band *sband = &ar->mac.sbands[band]; in ath12k_mac_bitrate_mask_get_single_nss()
6470 ath12k_mac_get_single_legacy_rate(struct ath12k *ar, in ath12k_mac_get_single_legacy_rate() argument
6505 struct ath12k *ar = arvif->ar; in ath12k_mac_set_fixed_rate_params() local
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()
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()
6554 ath12k_mac_vht_mcs_range_present(struct ath12k *ar, in ath12k_mac_vht_mcs_range_present() argument
6583 struct ath12k *ar = arvif->ar; in ath12k_mac_set_bitrate_mask_iter() local
6585 spin_lock_bh(&ar->data_lock); 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() local
6599 ret = ath12k_wmi_set_peer_param(ar, sta->addr, in ath12k_mac_disable_peer_fixed_rate()
6604 ath12k_warn(ar->ab, in ath12k_mac_disable_peer_fixed_rate()
6616 struct ath12k *ar = arvif->ar; in ath12k_mac_op_set_bitrate_mask() local
6634 ldpc = !!(ar->ht_cap_info & WMI_HT_CAP_LDPC); in ath12k_mac_op_set_bitrate_mask()
6648 if (ath12k_mac_has_single_legacy_rate(ar, band, mask)) { in ath12k_mac_op_set_bitrate_mask()
6649 ret = ath12k_mac_get_single_legacy_rate(ar, band, mask, &rate, 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()
6656 ieee80211_iterate_stations_atomic(ar->hw, in ath12k_mac_op_set_bitrate_mask()
6659 } else if (ath12k_mac_bitrate_mask_get_single_nss(ar, band, mask, in ath12k_mac_op_set_bitrate_mask()
6665 nss = min_t(u32, ar->num_tx_chains, in ath12k_mac_op_set_bitrate_mask()
6689 num_rates = ath12k_mac_bitrate_mask_num_vht_rates(ar, band, in ath12k_mac_op_set_bitrate_mask()
6692 if (!ath12k_mac_vht_mcs_range_present(ar, band, mask) && in ath12k_mac_op_set_bitrate_mask()
6697 ath12k_warn(ar->ab, 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()
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()
6724 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_set_bitrate_mask()
6733 struct ath12k *ar = hw->priv; in ath12k_mac_op_reconfig_complete() local
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()
6765 list_for_each_entry(arvif, &ar->arvifs, list) { in ath12k_mac_op_reconfig_complete()
6786 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_reconfig_complete()
6790 ath12k_mac_update_bss_chan_survey(struct ath12k *ar, in ath12k_mac_update_bss_chan_survey() argument
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()
6810 ret = ath12k_wmi_pdev_bss_chan_info_request(ar, type); 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()
6824 struct ath12k *ar = hw->priv; in ath12k_mac_op_get_survey() local
6832 ar_survey = &ar->survey[idx]; in ath12k_mac_op_get_survey()
6834 mutex_lock(&ar->conf_mutex); 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()
6858 if (ar->rx_channel == survey->channel) in ath12k_mac_op_get_survey()
6862 mutex_unlock(&ar->conf_mutex); in ath12k_mac_op_get_survey()
6936 static void ath12k_mac_update_ch_list(struct ath12k *ar, in ath12k_mac_update_ch_list() argument
6952 static u32 ath12k_get_phy_id(struct ath12k *ar, u32 band) in ath12k_get_phy_id() argument
6954 struct ath12k_pdev *pdev = ar->pdev; in ath12k_get_phy_id()
6963 ath12k_warn(ar->ab, "unsupported phy cap:%d\n", band); in ath12k_get_phy_id()
6968 static int ath12k_mac_setup_channels_rates(struct ath12k *ar, in ath12k_mac_setup_channels_rates() argument
6981 reg_cap = &ar->ab->hal_reg_cap[ar->pdev_idx]; in ath12k_mac_setup_channels_rates()
6990 band = &ar->mac.sbands[NL80211_BAND_2GHZ]; 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()
6999 phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_2G_CAP); in ath12k_mac_setup_channels_rates()
7000 reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath12k_mac_setup_channels_rates()
7002 ath12k_mac_update_ch_list(ar, band, in ath12k_mac_setup_channels_rates()
7012 kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels); 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()
7023 ar->hw->wiphy->bands[NL80211_BAND_6GHZ] = band; in ath12k_mac_setup_channels_rates()
7024 ath12k_mac_update_ch_list(ar, band, 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()
7039 band = &ar->mac.sbands[NL80211_BAND_5GHZ]; 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()
7048 phy_id = ath12k_get_phy_id(ar, WMI_HOST_WLAN_5G_CAP); in ath12k_mac_setup_channels_rates()
7049 reg_cap = &ar->ab->hal_reg_cap[phy_id]; in ath12k_mac_setup_channels_rates()
7052 ath12k_mac_update_ch_list(ar, band, in ath12k_mac_setup_channels_rates()
7061 static int ath12k_mac_setup_iface_combinations(struct ath12k *ar) in ath12k_mac_setup_iface_combinations() argument
7063 struct ath12k_base *ab = ar->ab; 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()
7157 static void __ath12k_mac_unregister(struct ath12k *ar) in __ath12k_mac_unregister() argument
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()
7178 struct ath12k *ar; in ath12k_mac_unregister() local
7184 ar = pdev->ar; in ath12k_mac_unregister()
7185 if (!ar) in ath12k_mac_unregister()
7188 __ath12k_mac_unregister(ar); in ath12k_mac_unregister()
7192 static int __ath12k_mac_register(struct ath12k *ar) in __ath12k_mac_register() argument
7194 struct ath12k_base *ab = ar->ab; in __ath12k_mac_register()
7195 struct ath12k_pdev_cap *cap = &ar->pdev->cap; in __ath12k_mac_register()
7210 ath12k_pdev_caps_update(ar); 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()
7216 ret = ath12k_mac_setup_channels_rates(ar, in __ath12k_mac_register()
7221 ath12k_mac_setup_ht_vht_cap(ar, cap, &ht_cap); in __ath12k_mac_register()
7222 ath12k_mac_setup_sband_iftype_data(ar, cap); in __ath12k_mac_register()
7224 ret = ath12k_mac_setup_iface_combinations(ar); 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()
7313 ath12k_reg_init(ar); 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()
7333 ar->hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR); in __ath12k_mac_register()
7336 ret = ath12k_regd_update(ar, true); 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()
7363 struct ath12k *ar; in ath12k_mac_register() local
7373 ar = pdev->ar; 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()
7381 ret = __ath12k_mac_register(ar); 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()
7399 ar = pdev->ar; in ath12k_mac_register()
7400 __ath12k_mac_unregister(ar); in ath12k_mac_register()
7409 struct ath12k *ar; in ath12k_mac_allocate() local
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()
7476 struct ath12k *ar; in ath12k_mac_destroy() local
7482 ar = pdev->ar; in ath12k_mac_destroy()
7483 if (!ar) in ath12k_mac_destroy()
7486 ieee80211_free_hw(ar->hw); in ath12k_mac_destroy()
7487 pdev->ar = NULL; in ath12k_mac_destroy()