]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/ath/ath10k/mac.c
ath10k: set CTS protection VDEV param only if VDEV is up
[karo-tx-linux.git] / drivers / net / wireless / ath / ath10k / mac.c
index aa545a1dbdc71931fdd588a05acd01fa8ee9d1d1..56f557e899121508d032a4b5bca0a172412f8615 100644 (file)
@@ -1227,6 +1227,36 @@ static int ath10k_monitor_recalc(struct ath10k *ar)
                return ath10k_monitor_stop(ar);
 }
 
+static bool ath10k_mac_can_set_cts_prot(struct ath10k_vif *arvif)
+{
+       struct ath10k *ar = arvif->ar;
+
+       lockdep_assert_held(&ar->conf_mutex);
+
+       if (!arvif->is_started) {
+               ath10k_dbg(ar, ATH10K_DBG_MAC, "defer cts setup, vdev is not ready yet\n");
+               return false;
+       }
+
+       return true;
+}
+
+static int ath10k_mac_set_cts_prot(struct ath10k_vif *arvif)
+{
+       struct ath10k *ar = arvif->ar;
+       u32 vdev_param;
+
+       lockdep_assert_held(&ar->conf_mutex);
+
+       vdev_param = ar->wmi.vdev_param->protection_mode;
+
+       ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d cts_protection %d\n",
+                  arvif->vdev_id, arvif->use_cts_prot);
+
+       return ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
+                                        arvif->use_cts_prot ? 1 : 0);
+}
+
 static int ath10k_recalc_rtscts_prot(struct ath10k_vif *arvif)
 {
        struct ath10k *ar = arvif->ar;
@@ -5328,20 +5358,18 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
 
        if (changed & BSS_CHANGED_ERP_CTS_PROT) {
                arvif->use_cts_prot = info->use_cts_prot;
-               ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d cts_prot %d\n",
-                          arvif->vdev_id, info->use_cts_prot);
 
                ret = ath10k_recalc_rtscts_prot(arvif);
                if (ret)
                        ath10k_warn(ar, "failed to recalculate rts/cts prot for vdev %d: %d\n",
                                    arvif->vdev_id, ret);
 
-               vdev_param = ar->wmi.vdev_param->protection_mode;
-               ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
-                                               info->use_cts_prot ? 1 : 0);
-               if (ret)
-                       ath10k_warn(ar, "failed to set protection mode %d on vdev %i: %d\n",
-                                   info->use_cts_prot, arvif->vdev_id, ret);
+               if (ath10k_mac_can_set_cts_prot(arvif)) {
+                       ret = ath10k_mac_set_cts_prot(arvif);
+                       if (ret)
+                               ath10k_warn(ar, "failed to set cts protection for vdev %d: %d\n",
+                                           arvif->vdev_id, ret);
+               }
        }
 
        if (changed & BSS_CHANGED_ERP_SLOT) {
@@ -7364,6 +7392,13 @@ ath10k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
                arvif->is_up = true;
        }
 
+       if (ath10k_mac_can_set_cts_prot(arvif)) {
+               ret = ath10k_mac_set_cts_prot(arvif);
+               if (ret)
+                       ath10k_warn(ar, "failed to set cts protection for vdev %d: %d\n",
+                                   arvif->vdev_id, ret);
+       }
+
        mutex_unlock(&ar->conf_mutex);
        return 0;