]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/net/wireless/intel/iwlwifi/mvm/utils.c
iwlwifi: mvm: apply RX diversity per PHY context
[mirror_ubuntu-jammy-kernel.git] / drivers / net / wireless / intel / iwlwifi / mvm / utils.c
index c566be99a4c74fd53f5f1b45b1557d7f74e89c2f..0e8ad798ab570afac7c162e0c1d0cc8edff6b6b5 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2020 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
  * Copyright (C) 2015-2017 Intel Deutschland GmbH
  */
@@ -621,7 +621,7 @@ void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
                         enum ieee80211_smps_mode smps_request)
 {
        struct iwl_mvm_vif *mvmvif;
-       enum ieee80211_smps_mode smps_mode;
+       enum ieee80211_smps_mode smps_mode = IEEE80211_SMPS_AUTOMATIC;
        int i;
 
        lockdep_assert_held(&mvm->mutex);
@@ -630,10 +630,8 @@ void iwl_mvm_update_smps(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
        if (num_of_ant(iwl_mvm_get_valid_rx_ant(mvm)) == 1)
                return;
 
-       if (vif->type == NL80211_IFTYPE_AP)
-               smps_mode = IEEE80211_SMPS_OFF;
-       else
-               smps_mode = IEEE80211_SMPS_AUTOMATIC;
+       if (vif->type != NL80211_IFTYPE_STATION)
+               return;
 
        mvmvif = iwl_mvm_vif_from_mac80211(vif);
        mvmvif->smps_requests[req_type] = smps_request;
@@ -683,23 +681,37 @@ void iwl_mvm_accu_radio_stats(struct iwl_mvm *mvm)
        mvm->accu_radio_stats.on_time_scan += mvm->radio_stats.on_time_scan;
 }
 
+struct iwl_mvm_diversity_iter_data {
+       struct iwl_mvm_phy_ctxt *ctxt;
+       bool result;
+};
+
 static void iwl_mvm_diversity_iter(void *_data, u8 *mac,
                                   struct ieee80211_vif *vif)
 {
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-       bool *result = _data;
+       struct iwl_mvm_diversity_iter_data *data = _data;
        int i;
 
+       if (mvmvif->phy_ctxt != data->ctxt)
+               return;
+
        for (i = 0; i < NUM_IWL_MVM_SMPS_REQ; i++) {
                if (mvmvif->smps_requests[i] == IEEE80211_SMPS_STATIC ||
-                   mvmvif->smps_requests[i] == IEEE80211_SMPS_DYNAMIC)
-                       *result = false;
+                   mvmvif->smps_requests[i] == IEEE80211_SMPS_DYNAMIC) {
+                       data->result = false;
+                       break;
+               }
        }
 }
 
-bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm)
+bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm,
+                                 struct iwl_mvm_phy_ctxt *ctxt)
 {
-       bool result = true;
+       struct iwl_mvm_diversity_iter_data data = {
+               .ctxt = ctxt,
+               .result = true,
+       };
 
        lockdep_assert_held(&mvm->mutex);
 
@@ -711,9 +723,9 @@ bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm)
 
        ieee80211_iterate_active_interfaces_atomic(
                        mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
-                       iwl_mvm_diversity_iter, &result);
+                       iwl_mvm_diversity_iter, &data);
 
-       return result;
+       return data.result;
 }
 
 void iwl_mvm_send_low_latency_cmd(struct iwl_mvm *mvm,
@@ -1398,7 +1410,8 @@ u32 iwl_mvm_get_systime(struct iwl_mvm *mvm)
        return iwl_read_prph(mvm->trans, reg_addr);
 }
 
-void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime)
+void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, int clock_type,
+                          u32 *gp2, u64 *boottime, ktime_t *realtime)
 {
        bool ps_disabled;
 
@@ -1412,7 +1425,11 @@ void iwl_mvm_get_sync_time(struct iwl_mvm *mvm, u32 *gp2, u64 *boottime)
        }
 
        *gp2 = iwl_mvm_get_systime(mvm);
-       *boottime = ktime_get_boottime_ns();
+
+       if (clock_type == CLOCK_BOOTTIME && boottime)
+               *boottime = ktime_get_boottime_ns();
+       else if (clock_type == CLOCK_REALTIME && realtime)
+               *realtime = ktime_get_real();
 
        if (!ps_disabled) {
                mvm->ps_disabled = ps_disabled;