]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iwlwifi: copy iwl_he_capa for modifications
authorJohannes Berg <johannes.berg@intel.com>
Wed, 9 Dec 2020 21:16:15 +0000 (23:16 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Wed, 9 Dec 2020 22:11:20 +0000 (00:11 +0200)
This data is not necessarily the same across devices as we may
modify it due to the number of antennas and for overrides (though
in practice overrides are likely to be identical), so modifying
the global data is wrong.

Make a copy of it in the NVM data and modify it there instead.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201209231352.6b4ee30c59e4.I0c30ef78b3bf727fe80b16a19c7588016d6b04bf@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c

index 03a748cc98fa3a52a085196c22e98d9a804884af..3a4562b454109aea0a4061c07a6f245253dce76f 100644 (file)
@@ -99,6 +99,12 @@ struct iwl_nvm_data {
        bool lar_enabled;
        bool vht160_supported;
        struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
+
+       struct {
+               struct ieee80211_sband_iftype_data low[2];
+               struct ieee80211_sband_iftype_data high[2];
+       } iftd;
+
        struct ieee80211_channel channels[];
 };
 
index 6d19de3058d21b71d4849a408ecbe6ebd343e217..6f3aca19a25437dd527e436bdbf37bb2010c9521 100644 (file)
@@ -580,7 +580,7 @@ static void iwl_init_vht_hw_capab(struct iwl_trans *trans,
                cpu_to_le16(IEEE80211_VHT_EXT_NSS_BW_CAPABLE);
 }
 
-static struct ieee80211_sband_iftype_data iwl_he_capa[] = {
+static const struct ieee80211_sband_iftype_data iwl_he_capa[] = {
        {
                .types_mask = BIT(NL80211_IFTYPE_STATION),
                .he_cap = {
@@ -748,7 +748,30 @@ static void iwl_init_he_hw_capab(struct iwl_trans *trans,
                                 struct ieee80211_supported_band *sband,
                                 u8 tx_chains, u8 rx_chains)
 {
-       sband->iftype_data = iwl_he_capa;
+       struct ieee80211_sband_iftype_data *iftype_data;
+
+       /* should only initialize once */
+       if (WARN_ON(sband->iftype_data))
+               return;
+
+       BUILD_BUG_ON(sizeof(data->iftd.low) != sizeof(iwl_he_capa));
+       BUILD_BUG_ON(sizeof(data->iftd.high) != sizeof(iwl_he_capa));
+
+       switch (sband->band) {
+       case NL80211_BAND_2GHZ:
+               iftype_data = data->iftd.low;
+               break;
+       case NL80211_BAND_5GHZ:
+               iftype_data = data->iftd.high;
+               break;
+       default:
+               WARN_ON(1);
+               return;
+       }
+
+       memcpy(iftype_data, iwl_he_capa, sizeof(iwl_he_capa));
+
+       sband->iftype_data = iftype_data;
        sband->n_iftype_data = ARRAY_SIZE(iwl_he_capa);
 
        /* If not 2x2, we need to indicate 1x1 in the Midamble RX Max NSTS */
@@ -756,11 +779,11 @@ static void iwl_init_he_hw_capab(struct iwl_trans *trans,
                int i;
 
                for (i = 0; i < sband->n_iftype_data; i++) {
-                       iwl_he_capa[i].he_cap.he_cap_elem.phy_cap_info[1] &=
+                       iftype_data[i].he_cap.he_cap_elem.phy_cap_info[1] &=
                                ~IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS;
-                       iwl_he_capa[i].he_cap.he_cap_elem.phy_cap_info[2] &=
+                       iftype_data[i].he_cap.he_cap_elem.phy_cap_info[2] &=
                                ~IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS;
-                       iwl_he_capa[i].he_cap.he_cap_elem.phy_cap_info[7] &=
+                       iftype_data[i].he_cap.he_cap_elem.phy_cap_info[7] &=
                                ~IEEE80211_HE_PHY_CAP7_MAX_NC_MASK;
                }
        }