mt7996_set_channel() programs the channel and the width of a chanctx, but not chandef->punctured, so the firmware does not know which subchannels of the channel are punctured. Send the bitmap of the chandef with the PP_EN_CTRL command on every channel set, in user mode with the firmware's own puncturing detection off. The firmware holds one bitmap per band, so stations and APs on the band use the same command. Do not wait for a response, like the MediaTek vendor driver, which sends this command with the same firmware. Skip 2.4 GHz, where an EHT channel is at most 40 MHz wide and cannot be punctured. Co-developed-by: Allen Ye Signed-off-by: Allen Ye Signed-off-by: Felix Fietkau --- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + .../net/wireless/mediatek/mt76/mt7996/main.c | 4 +++ .../net/wireless/mediatek/mt76/mt7996/mcu.c | 32 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7996/mcu.h | 4 +++ .../wireless/mediatek/mt76/mt7996/mt7996.h | 1 + 5 files changed, 42 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 88281733a3df..e9a7542c07dc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -1349,6 +1349,7 @@ enum { MCU_UNI_CMD_CHANNEL_SWITCH = 0x34, MCU_UNI_CMD_THERMAL = 0x35, MCU_UNI_CMD_VOW = 0x37, + MCU_UNI_CMD_PP = 0x38, MCU_UNI_CMD_FIXED_RATE_TABLE = 0x40, MCU_UNI_CMD_RSSI_MONITOR = 0x41, MCU_UNI_CMD_TESTMODE_CTRL = 0x46, diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c index e8faa826e037..3a3441951254 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c @@ -690,6 +690,10 @@ int mt7996_set_channel(struct mt76_phy *mphy) if (mphy->offchannel) mt7996_mac_update_beacons(phy); + ret = mt7996_mcu_set_punct(phy); + if (ret) + goto out; + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); if (ret) goto out; diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c index 7e72174bd6b1..f35250430383 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c @@ -4255,6 +4255,38 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) &req, sizeof(req), true); } +int mt7996_mcu_set_punct(struct mt7996_phy *phy) +{ + struct cfg80211_chan_def *chandef = &phy->mt76->chandef; + struct mt7996_dev *dev = phy->dev; + struct { + u8 __rsv[4]; + + __le16 tag; + __le16 len; + u8 mgmt_mode; + u8 band_idx; + u8 force_bitmap_ctrl; + u8 auto_mode; + __le16 bitmap; + u8 csa_enable; + u8 __rsv2; + } __packed req = { + .tag = cpu_to_le16(UNI_CMD_PP_EN_CTRL), + .len = cpu_to_le16(sizeof(req) - 4), + .mgmt_mode = 1, + .band_idx = phy->mt76->band_idx, + .force_bitmap_ctrl = 2, + .bitmap = cpu_to_le16(chandef->punctured), + }; + + if (chandef->chan->band == NL80211_BAND_2GHZ) + return 0; + + return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(PP), + &req, sizeof(req), false); +} + static int mt7996_mcu_get_cal_free_data(struct mt7996_dev *dev) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h index 6078f8811b1e..70ed57d9bf9a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h @@ -1033,6 +1033,10 @@ enum{ UNI_CMD_SR_SET_SIGA = 0xd0, }; +enum { + UNI_CMD_PP_EN_CTRL, +}; + enum { UNI_CMD_THERMAL_PROTECT_ENABLE = 0x6, UNI_CMD_THERMAL_PROTECT_DISABLE, diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h index d30b4d689bac..1f1dff9f6610 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h @@ -786,6 +786,7 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, struct mt7996_sta *msta, bool changed); int mt7996_set_channel(struct mt76_phy *mphy); int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag); +int mt7996_mcu_set_punct(struct mt7996_phy *phy); int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct ieee80211_vif *vif, struct ieee80211_bss_conf *link_conf); int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, -- 2.47.3