wifi: mt76: mt7925: sync MT7927 BSS band assignment

MT7927 needs DBDC enabled and uses a fixed firmware band assignment for
2.4GHz and 5/6GHz BSS contexts.

Reprogram the STA dev context when the channel context is assigned so the
firmware sees the updated band_idx before the BSS is used. This avoids
stale band programming after band changes.

Co-developed-by: Javier Tia <floss@jetm.me>
Signed-off-by: Javier Tia <floss@jetm.me>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/20260425195011.790265-18-sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Sean Wang 2026-04-25 14:50:07 -05:00 committed by Felix Fietkau
parent 0683825c48
commit 05fd148853
5 changed files with 71 additions and 0 deletions

View File

@ -117,6 +117,15 @@ static int __mt7925_init_hardware(struct mt792x_dev *dev)
if (ret)
goto out;
if (is_mt7927(&dev->mt76)) {
ret = mt7925_mcu_set_dbdc(&dev->mphy, true);
if (ret) {
dev_warn(dev->mt76.dev,
"MT7927 DBDC enable failed: %d\n", ret);
ret = 0;
}
}
out:
return ret;
}

View File

@ -396,6 +396,18 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev,
mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ?
0 : mconf->mt76.idx;
mconf->mt76.band_idx = 0xff;
if (is_mt7927(&dev->mt76)) {
struct ieee80211_channel *chan;
if (link_conf->chanreq.oper.chan)
chan = link_conf->chanreq.oper.chan;
else
chan = mvif->phy->mt76->chandef.chan;
mconf->mt76.band_idx = mt7927_band_idx(chan->band);
}
mconf->mt76.wmm_idx = ieee80211_vif_is_mld(vif) ?
0 : mconf->mt76.idx % MT76_CONNAC_MAX_WMM_SETS;
mconf->mt76.link_idx = hweight16(mvif->valid_links);
@ -2244,6 +2256,29 @@ mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return err;
}
static int
mt7927_reconfig_band(struct mt792x_dev *dev, struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf,
struct mt792x_bss_conf *mconf,
u8 band_idx)
{
struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;
struct mt792x_link_sta *mlink = &mvif->sta.deflink;
int ret;
ret = mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf,
&mconf->mt76, &mlink->wcid,
false);
if (ret)
return ret;
mconf->mt76.band_idx = band_idx;
return mt76_connac_mcu_uni_add_dev(&dev->mphy, link_conf,
&mconf->mt76, &mlink->wcid,
true);
}
static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf,
@ -2254,6 +2289,7 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
struct mt792x_dev *dev = mt792x_hw_dev(hw);
struct ieee80211_bss_conf *pri_link_conf;
struct mt792x_bss_conf *mconf;
u8 band_idx;
mutex_lock(&dev->mt76.mutex);
@ -2267,6 +2303,12 @@ static int mt7925_assign_vif_chanctx(struct ieee80211_hw *hw,
NULL, true);
} else {
mconf = &mvif->bss_conf;
if (is_mt7927(&dev->mt76)) {
band_idx = mt7927_band_idx(ctx->def.chan->band);
mt7927_reconfig_band(dev, vif, link_conf, mconf, band_idx);
}
}
mconf->mt76.ctx = ctx;

View File

@ -2923,6 +2923,7 @@ int mt7925_mcu_set_dbdc(struct mt76_phy *phy, bool enable)
return err;
}
EXPORT_SYMBOL_GPL(mt7925_mcu_set_dbdc);
static void
mt7925_mcu_build_scan_ie_tlv(struct mt76_dev *mdev,

View File

@ -252,6 +252,18 @@ struct mt7925_txpwr {
s8 eht996x3_484[16][2];
};
static inline u8 mt7927_band_idx(enum nl80211_band band)
{
switch (band) {
case NL80211_BAND_2GHZ:
return 0;
case NL80211_BAND_5GHZ:
case NL80211_BAND_6GHZ:
default:
return 1;
}
}
extern const struct ieee80211_ops mt7925_ops;
int __mt7925_start(struct mt792x_phy *phy);

View File

@ -3,6 +3,7 @@
#include "mt7925.h"
#include "../dma.h"
#include "mcu.h"
#include "mac.h"
int mt7925e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
@ -144,6 +145,12 @@ int mt7925e_mac_reset(struct mt792x_dev *dev)
if (err)
goto out;
if (is_mt7927(&dev->mt76)) {
err = mt7925_mcu_set_dbdc(&dev->mphy, true);
if (err)
goto out;
}
err = __mt7925_start(&dev->phy);
out:
clear_bit(MT76_RESET, &dev->mphy.state);