mt76: connac: fix GTK rekey offload failure on WPA mixed mode
Subsystems (2)
[email protected]
reviewerPATCH 1/2 mt76: connac: fix GTK rekey offload failure on WPA mixed mode
From: Leon Yen <[email protected]>
Update the proper firmware programming sequence to fix GTK rekey offload failure on WPA mixed mode.
In the mt76_connac_mcu_key_iter,gtk_tlv->proto should be only set up on pairwise key and gtk_tlk->group_cipher should be only set up on the group key.
Otherwise, those parameters required by firmware would be set incorrectly to cause GTK rekey offload failure on WPA mixed mode and then disconnection follows.
--- .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +9 -6
@@ -1957,19 +1957,22 @@ mt76_connac_mcu_key_iter(struct ieee80211_hw *hw, key->cipher != WLAN_CIPHER_SUITE_TKIP)return ; -if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) { - gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_1 ); +if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) cipher =BIT (3 ); - }else { - gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_2 ); +else cipher =BIT (4 ); - }/* we are assuming here to have a single pairwise key */ if (key->flags &IEEE80211_KEY_FLAG_PAIRWISE ) { +if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) + gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_1 ); +else + gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_2 ); + gtk_tlv->pairwise_cipher =cpu_to_le32 (cipher); - gtk_tlv->group_cipher =cpu_to_le32 (cipher); gtk_tlv->keyid = key->keyidx; + }else { + gtk_tlv->group_cipher =cpu_to_le32 (cipher); } }
Signature · 1 line
2.25.1
[email protected]
reviewerPATCH 2/2 mt76: connac: add support maximum regulatory Tx power
From: YN Chen <[email protected]>
Consider .max_reg_power in struct ieee80211_channel to limit the maximum power the wireless device allowed to transmit on the corresponding channel according to the regulatory domain.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +41 -2
@@ -1773,6 +1773,43 @@ static s8 mt76_connac_get_sar_power(struct mt76_phy *phy,return target_power; } +static s8 mt76_connac_get_ch_power (struct mt76_phy *phy, +struct ieee80211_channel *chan, +s8 target_power) +{ +struct mt76_dev *dev = phy->dev; +struct ieee80211_supported_band *sband; +int i; + +switch (chan->band) { +case NL80211_BAND_2GHZ : + sband = &phy->sband_2g.sband; +break ; +case NL80211_BAND_5GHZ : + sband = &phy->sband_5g.sband; +break ; +default : +return target_power; + } + +for (i =0 ; i < sband->n_channels; i++) { +struct ieee80211_channel *ch = &sband->channels[i]; + +if (ch->hw_value == chan->hw_value) { +if (!(ch->flags &IEEE80211_CHAN_DISABLED )) { +int power =2 * ch->max_reg_power; + +if (power >127 || power <-127 ) + power =127 ; + target_power =min_t (s8, power, target_power); + } +break ; + } + } + +return target_power; +} +static int mt76_connac_mcu_rate_txpower_band (struct mt76_phy *phy,enum nl80211_band band)
@@ -1840,10 +1877,12 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy, .hw_value = ch_list[idx], .band = band, }; -s8 sar_power; +s8 reg_power, sar_power; + reg_power =mt76_connac_get_ch_power (phy, &chan, + tx_power); sar_power =mt76_connac_get_sar_power (phy, &chan, - tx_power); + reg_power);mt76_get_rate_power_limits (phy, &chan, &limits, sar_power);
Signature · 1 line
2.25.1
Lorenzo Bianconi
maintainerRe: [PATCH 2/2] mt76: connac: add support maximum regulatory Tx power
Quoted 18 lines
From: YN Chen <[email protected]>
Consider .max_reg_power in struct
ieee80211_channelto limit the maximum power the wireless device allowed to transmit on the corresponding channel according to the regulatory domain.Co-developed-by Sean Wang <[email protected]>Signed-off-by Sean Wang <[email protected]>Signed-off-by YN Chen <[email protected]>--- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-)drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +0
-0
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c static s8 mt76_connac_get_sar_power(struct mt76_phy *phy, · line 1780
Quoted 8 lines
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +5
-0@@ -1773,6 +1773,43 @@ static s8 mt76_connac_get_sar_power(struct mt76_phy *phy,return target_power; } +static s8 mt76_connac_get_ch_power (struct mt76_phy *phy, +struct ieee80211_channel *chan, +s8 target_power) +{ +struct mt76_dev *dev = phy->dev;
is it used?
Quoted 13 lines
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +13
-0+struct ieee80211_supported_band *sband; +int i; + +switch (chan->band) { +case NL80211_BAND_2GHZ : + sband = &phy->sband_2g.sband; +break ; +case NL80211_BAND_5GHZ : + sband = &phy->sband_5g.sband; +break ; +default : +return target_power; + }
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c static s8 mt76_connac_get_sar_power(struct mt76_phy *phy, · line 1803
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +10
-0+ +for (i =0 ; i < sband->n_channels; i++) { +struct ieee80211_channel *ch = &sband->channels[i]; + +if (ch->hw_value == chan->hw_value) { +if (!(ch->flags &IEEE80211_CHAN_DISABLED )) { +int power =2 * ch->max_reg_power; + +if (power >127 || power <-127 ) + power =127 ;
please correct me if I am wrong, but I guess the limit for mt7663 should be 63, isn't it?
Regards,
Lorenzo
Quoted 30 lines
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +13
-2+ target_power =min_t (s8, power, target_power); + } +break ; + } + } + +return target_power; +} +static int mt76_connac_mcu_rate_txpower_band (struct mt76_phy *phy,enum nl80211_band band)@@ -1840,10 +1877,12 @@ mt76_connac_mcu_rate_txpower_band(struct mt76_phy *phy, .hw_value = ch_list[idx], .band = band, }; -s8 sar_power; +s8 reg_power, sar_power; + reg_power =mt76_connac_get_ch_power (phy, &chan, + tx_power); sar_power =mt76_connac_get_sar_power (phy, &chan, - tx_power); + reg_power);mt76_get_rate_power_limits (phy, &chan, &limits, sar_power);Signature · 1 line
2.25.1
Felix Fietkau
maintainerQuoted 35 lines · On 2021-07-28 00:59, [email protected] wrote:
From: Leon Yen <[email protected]>
Update the proper firmware programming sequence to fix GTK rekey offload failure on WPA mixed mode.
In the
mt76_connac_mcu_key_iter,gtk_tlv->protoshould be only set up on pairwise key andgtk_tlk->group_ciphershould be only set up on the group key.Otherwise, those parameters required by firmware would be set incorrectly to cause GTK rekey offload failure on WPA mixed mode and then disconnection follows.
Fixes b47e21e75c80 ("mt76: mt7615: add gtk rekey offload support")Co-developed-by Sean Wang <[email protected]>Signed-off-by Sean Wang <[email protected]>Signed-off-by Leon Yen <[email protected]>--- .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +1
-4@@ -1957,19 +1957,22 @@ mt76_connac_mcu_key_iter(struct ieee80211_hw *hw, key->cipher != WLAN_CIPHER_SUITE_TKIP)return ; -if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) { - gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_1 ); +if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) cipher =BIT (3 ); - }else { - gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_2 );
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c mt76_connac_mcu_key_iter(struct ieee80211_hw *hw, · line 1970
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +5
-1+else cipher =BIT (4 ); - }/* we are assuming here to have a single pairwise key */ if (key->flags &IEEE80211_KEY_FLAG_PAIRWISE ) { +if (key->cipher ==WLAN_CIPHER_SUITE_TKIP ) + gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_1 ); +else + gtk_tlv->proto =cpu_to_le32 (NL80211_WPA_VERSION_2 );
Why is gtk_tlv->proto set to WPA version values based on the cipher suite? That doesn't make much sense to me, since TKIP is supported by WPA2 as well. I will apply this patch anyway, since this check is there already, but this does look suspicious to me and should probably be revisited.
- Felix