Skip to content

Commit

Permalink
wifi: mt76: mt7921: add 6GHz power type support for clc
Browse files Browse the repository at this point in the history
There are several power type should be supported in 6GHz band. mt7921
apply 6GHz power type from AP settings and clc will setup the
corresponding regulatory power.

Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
Ming Yen Hsieh authored and Felix Fietkau committed Sep 30, 2023
1 parent 7801da3 commit 51ba0e3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
34 changes: 34 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt7921/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,38 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw,
mt792x_mutex_release(dev);
}

static void
mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_phy *phy = mvif->phy;
struct mt792x_dev *dev = phy->dev;

if (hweight64(dev->mt76.vif_mask) > 1) {
phy->power_type = MT_AP_DEFAULT;
goto out;
}

switch (vif->bss_conf.power_type) {
case IEEE80211_REG_SP_AP:
phy->power_type = MT_AP_SP;
break;
case IEEE80211_REG_VLP_AP:
phy->power_type = MT_AP_VLP;
break;
case IEEE80211_REG_LPI_AP:
phy->power_type = MT_AP_LPI;
break;
case IEEE80211_REG_UNSET_AP:
default:
phy->power_type = MT_AP_DEFAULT;
break;
}

out:
mt7921_mcu_set_clc(dev, dev->mt76.alpha2, dev->country_ie_env);
}

int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
Expand Down Expand Up @@ -717,6 +749,8 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
if (ret)
return ret;

mt7921_regd_set_6ghz_power_type(vif);

mt76_connac_power_save_sched(&dev->mphy, &dev->pm);

return 0;
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,10 +1254,12 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
u8 pad1;
u8 alpha2[2];
u8 type[2];
u8 rsvd[64];
u8 env_6g;
u8 rsvd[63];
} __packed req = {
.idx = idx,
.env = env_cap,
.env_6g = dev->phy.power_type,
.acpi_conf = mt792x_acpi_get_flags(&dev->phy),
};
int ret, valid_cnt = 0;
Expand Down
9 changes: 9 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt792x.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ enum {
MT792x_CLC_MAX_NUM,
};

enum mt792x_reg_power_type {
MT_AP_UNSET = 0,
MT_AP_DEFAULT,
MT_AP_LPI,
MT_AP_SP,
MT_AP_VLP,
};

DECLARE_EWMA(avg_signal, 10, 8)

struct mt792x_sta {
Expand Down Expand Up @@ -117,6 +125,7 @@ struct mt792x_phy {
struct mt76_mib_stats mib;

u8 sta_work_count;
enum mt792x_reg_power_type power_type;

struct sk_buff_head scan_event_list;
struct delayed_work scan_work;
Expand Down

0 comments on commit 51ba0e3

Please sign in to comment.