Commit 10f29031 authored by Ming Yen Hsieh's avatar Ming Yen Hsieh Committed by Felix Fietkau

wifi: mt76: mt7921: fix wrong 6Ghz power type

To avoid using incorrect 6g power settings after disconnection,
it should to update back to the default state when disconnected.

Fixes: 51ba0e3a ("wifi: mt76: mt7921: add 6GHz power type support for clc")
Signed-off-by: default avatarMing Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent d0a2bc5f
...@@ -683,17 +683,45 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw, ...@@ -683,17 +683,45 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
} }
static void static void
mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif) mt7921_calc_vif_num(void *priv, u8 *mac, struct ieee80211_vif *vif)
{
u32 *num = priv;
if (!priv)
return;
switch (vif->type) {
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_AP:
case NL80211_IFTYPE_P2P_GO:
*num += 1;
break;
default:
break;
}
}
static void
mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif, bool is_add)
{ {
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_phy *phy = mvif->phy; struct mt792x_phy *phy = mvif->phy;
struct mt792x_dev *dev = phy->dev; struct mt792x_dev *dev = phy->dev;
u32 valid_vif_num = 0;
ieee80211_iterate_active_interfaces(mt76_hw(dev),
IEEE80211_IFACE_ITER_RESUME_ALL,
mt7921_calc_vif_num, &valid_vif_num);
if (hweight64(dev->mt76.vif_mask) > 1) { if (valid_vif_num > 1) {
phy->power_type = MT_AP_DEFAULT; phy->power_type = MT_AP_DEFAULT;
goto out; goto out;
} }
if (!is_add)
vif->bss_conf.power_type = IEEE80211_REG_UNSET_AP;
switch (vif->bss_conf.power_type) { switch (vif->bss_conf.power_type) {
case IEEE80211_REG_SP_AP: case IEEE80211_REG_SP_AP:
phy->power_type = MT_AP_SP; phy->power_type = MT_AP_SP;
...@@ -705,6 +733,8 @@ mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif) ...@@ -705,6 +733,8 @@ mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif)
phy->power_type = MT_AP_LPI; phy->power_type = MT_AP_LPI;
break; break;
case IEEE80211_REG_UNSET_AP: case IEEE80211_REG_UNSET_AP:
phy->power_type = MT_AP_UNSET;
break;
default: default:
phy->power_type = MT_AP_DEFAULT; phy->power_type = MT_AP_DEFAULT;
break; break;
...@@ -749,7 +779,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -749,7 +779,7 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (ret) if (ret)
return ret; return ret;
mt7921_regd_set_6ghz_power_type(vif); mt7921_regd_set_6ghz_power_type(vif, true);
mt76_connac_power_save_sched(&dev->mphy, &dev->pm); mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
...@@ -811,6 +841,8 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, ...@@ -811,6 +841,8 @@ void mt7921_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
list_del_init(&msta->wcid.poll_list); list_del_init(&msta->wcid.poll_list);
spin_unlock_bh(&dev->mt76.sta_poll_lock); spin_unlock_bh(&dev->mt76.sta_poll_lock);
mt7921_regd_set_6ghz_power_type(vif, false);
mt76_connac_power_save_sched(&dev->mphy, &dev->pm); mt76_connac_power_save_sched(&dev->mphy, &dev->pm);
} }
EXPORT_SYMBOL_GPL(mt7921_mac_sta_remove); EXPORT_SYMBOL_GPL(mt7921_mac_sta_remove);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment