wifi: iwlwifi: mvm: allow ADD_STA not to be advertised by the firwmare
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Tue, 13 Jun 2023 12:57:23 +0000 (15:57 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 14 Jun 2023 10:32:20 +0000 (12:32 +0200)
Newest firmware don't advertise the version of ADD_STA because it has
been replaced by another command. There are old firmware images
that also don't advertise it. Replace all the checks with a new
inline, and in that check for either MLD API or the ADD_STA
command version.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230613155501.4b9305510223.I7cc143d87186f8441e9b8435cc550b76734c7eef@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
drivers/net/wireless/intel/iwlwifi/mvm/scan.c
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c

index d1a559c4c6b963495449253fae6c58502d7ea41f..ed9370aac1b639c1f824423cec5229699f2b7970 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -1637,7 +1637,7 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
         * internal aux station for all aux activities that don't
         * requires a dedicated data queue.
         */
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) < 12) {
+       if (!iwl_mvm_has_new_station_api(mvm->fw)) {
                 /*
                  * In old version the aux station uses mac id like other
                  * station and not lmac id
@@ -1806,7 +1806,7 @@ int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
                RCU_INIT_POINTER(mvm->fw_id_to_link_sta[i], NULL);
        }
 
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) < 12) {
+       if (!iwl_mvm_has_new_station_api(mvm->fw)) {
                /*
                 * Add auxiliary station for scanning.
                 * Newer versions of this command implies that the fw uses
index 8267ff08e38d066c46e37108ee21f59e208c92f6..ee838dd60f4ede31707d4072db39ac403df974e3 100644 (file)
@@ -1243,7 +1243,7 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
 
        /* async_handlers_wk is now blocked */
 
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) < 12)
+       if (!iwl_mvm_has_new_station_api(mvm->fw))
                iwl_mvm_rm_aux_sta(mvm);
 
        iwl_mvm_stop_device(mvm);
@@ -4521,7 +4521,7 @@ static int iwl_mvm_add_aux_sta_for_hs20(struct iwl_mvm *mvm, u32 lmac_id)
                return -EINVAL;
        }
 
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12) {
+       if (iwl_mvm_has_new_station_api(mvm->fw)) {
                ret = iwl_mvm_add_aux_sta(mvm, lmac_id);
                WARN(ret, "Failed to allocate aux station");
        }
index 95efab52cdc26bd2b13b7d9ed7d50ab3f252126e..b452c35443d207c52b78329d254b8e067de31df8 100644 (file)
@@ -1433,6 +1433,12 @@ static inline bool iwl_mvm_has_mld_api(const struct iwl_fw *fw)
                           IWL_UCODE_TLV_CAPA_MLD_API_SUPPORT);
 }
 
+static inline bool iwl_mvm_has_new_station_api(const struct iwl_fw *fw)
+{
+       return iwl_mvm_has_mld_api(fw) ||
+              iwl_fw_lookup_cmd_ver(fw, ADD_STA, 0) >= 12;
+}
+
 static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm)
 {
        /* TODO - replace with TLV once defined */
index 175615755d9daafac5e8ce3865af4a8177756d0b..d7ac9ddbcfba53ecf03bdcf194e93f4c7fb4526f 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -647,7 +647,7 @@ static void iwl_mvm_scan_fill_tx_cmd(struct iwl_mvm *mvm,
                                                           NL80211_BAND_2GHZ,
                                                           no_cck);
 
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) < 12) {
+       if (!iwl_mvm_has_new_station_api(mvm->fw)) {
                tx_cmd[0].sta_id = mvm->aux_sta.sta_id;
                tx_cmd[1].sta_id = mvm->aux_sta.sta_id;
 
@@ -1084,7 +1084,7 @@ static void iwl_mvm_fill_scan_config_v1(struct iwl_mvm *mvm, void *config,
        memcpy(&cfg->mac_addr, &mvm->addresses[0].addr, ETH_ALEN);
 
        /* This function should not be called when using ADD_STA ver >=12 */
-       WARN_ON_ONCE(iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12);
+       WARN_ON_ONCE(iwl_mvm_has_new_station_api(mvm->fw));
 
        cfg->bcast_sta_id = mvm->aux_sta.sta_id;
        cfg->channel_flags = channel_flags;
@@ -1135,7 +1135,7 @@ static void iwl_mvm_fill_scan_config_v2(struct iwl_mvm *mvm, void *config,
        memcpy(&cfg->mac_addr, &mvm->addresses[0].addr, ETH_ALEN);
 
        /* This function should not be called when using ADD_STA ver >=12 */
-       WARN_ON_ONCE(iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12);
+       WARN_ON_ONCE(iwl_mvm_has_new_station_api(mvm->fw));
 
        cfg->bcast_sta_id = mvm->aux_sta.sta_id;
        cfg->channel_flags = channel_flags;
@@ -1250,7 +1250,7 @@ int iwl_mvm_config_scan(struct iwl_mvm *mvm)
 
        memset(&cfg, 0, sizeof(cfg));
 
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) < 12) {
+       if (!iwl_mvm_has_new_station_api(mvm->fw)) {
                cfg.bcast_sta_id = mvm->aux_sta.sta_id;
        } else if (iwl_fw_lookup_cmd_ver(mvm->fw, SCAN_CFG_CMD, 0) < 5) {
                /*
index 5e11b101d02e5358b601bc2d333ce528ed8ccc4b..ff1ce990a9d88673c41ba64451b0d26e09b9a661 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2015, 2018-2022 Intel Corporation
+ * Copyright (C) 2012-2015, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -1679,7 +1679,7 @@ static int iwl_mvm_add_int_sta_common(struct iwl_mvm *mvm,
        memset(&cmd, 0, sizeof(cmd));
        cmd.sta_id = sta->sta_id;
 
-       if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12 &&
+       if (iwl_mvm_has_new_station_api(mvm->fw) &&
            sta->type == IWL_STA_AUX_ACTIVITY)
                cmd.mac_id_n_color = cpu_to_le32(mac_id);
        else
index 6b7b6250f1bbdffd66681e28e5354fe884fc6eaf..5f0e7144a951ce9f1eaeb0e781acdfbe13ea01b3 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2017 Intel Deutschland GmbH
  */
@@ -103,7 +103,7 @@ void iwl_mvm_roc_done_wk(struct work_struct *wk)
                /* In newer version of this command an aux station is added only
                 * in cases of dedicated tx queue and need to be removed in end
                 * of use */
-               if (iwl_fw_lookup_cmd_ver(mvm->fw, ADD_STA, 0) >= 12)
+               if (iwl_mvm_has_new_station_api(mvm->fw))
                        iwl_mvm_rm_aux_sta(mvm);
        }