Skip to content

Commit d43ab29

Browse files
jmberg-intellucacoelho
authored andcommitted
iwlwifi: copy iwl_he_capa for modifications
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 <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Link: https://lore.kernel.org/r/iwlwifi.20201209231352.6b4ee30c59e4.I0c30ef78b3bf727fe80b16a19c7588016d6b04bf@changeid Signed-off-by: Luca Coelho <[email protected]>
1 parent 4adfaf9 commit d43ab29

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

drivers/net/wireless/intel/iwlwifi/iwl-eeprom-parse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ struct iwl_nvm_data {
9999
bool lar_enabled;
100100
bool vht160_supported;
101101
struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
102+
103+
struct {
104+
struct ieee80211_sband_iftype_data low[2];
105+
struct ieee80211_sband_iftype_data high[2];
106+
} iftd;
107+
102108
struct ieee80211_channel channels[];
103109
};
104110

drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ static void iwl_init_vht_hw_capab(struct iwl_trans *trans,
580580
cpu_to_le16(IEEE80211_VHT_EXT_NSS_BW_CAPABLE);
581581
}
582582

583-
static struct ieee80211_sband_iftype_data iwl_he_capa[] = {
583+
static const struct ieee80211_sband_iftype_data iwl_he_capa[] = {
584584
{
585585
.types_mask = BIT(NL80211_IFTYPE_STATION),
586586
.he_cap = {
@@ -748,19 +748,42 @@ static void iwl_init_he_hw_capab(struct iwl_trans *trans,
748748
struct ieee80211_supported_band *sband,
749749
u8 tx_chains, u8 rx_chains)
750750
{
751-
sband->iftype_data = iwl_he_capa;
751+
struct ieee80211_sband_iftype_data *iftype_data;
752+
753+
/* should only initialize once */
754+
if (WARN_ON(sband->iftype_data))
755+
return;
756+
757+
BUILD_BUG_ON(sizeof(data->iftd.low) != sizeof(iwl_he_capa));
758+
BUILD_BUG_ON(sizeof(data->iftd.high) != sizeof(iwl_he_capa));
759+
760+
switch (sband->band) {
761+
case NL80211_BAND_2GHZ:
762+
iftype_data = data->iftd.low;
763+
break;
764+
case NL80211_BAND_5GHZ:
765+
iftype_data = data->iftd.high;
766+
break;
767+
default:
768+
WARN_ON(1);
769+
return;
770+
}
771+
772+
memcpy(iftype_data, iwl_he_capa, sizeof(iwl_he_capa));
773+
774+
sband->iftype_data = iftype_data;
752775
sband->n_iftype_data = ARRAY_SIZE(iwl_he_capa);
753776

754777
/* If not 2x2, we need to indicate 1x1 in the Midamble RX Max NSTS */
755778
if ((tx_chains & rx_chains) != ANT_AB) {
756779
int i;
757780

758781
for (i = 0; i < sband->n_iftype_data; i++) {
759-
iwl_he_capa[i].he_cap.he_cap_elem.phy_cap_info[1] &=
782+
iftype_data[i].he_cap.he_cap_elem.phy_cap_info[1] &=
760783
~IEEE80211_HE_PHY_CAP1_MIDAMBLE_RX_TX_MAX_NSTS;
761-
iwl_he_capa[i].he_cap.he_cap_elem.phy_cap_info[2] &=
784+
iftype_data[i].he_cap.he_cap_elem.phy_cap_info[2] &=
762785
~IEEE80211_HE_PHY_CAP2_MIDAMBLE_RX_TX_MAX_NSTS;
763-
iwl_he_capa[i].he_cap.he_cap_elem.phy_cap_info[7] &=
786+
iftype_data[i].he_cap.he_cap_elem.phy_cap_info[7] &=
764787
~IEEE80211_HE_PHY_CAP7_MAX_NC_MASK;
765788
}
766789
}

0 commit comments

Comments
 (0)