[mt76-next,2/2] wifi: mt76: mt7921: use the BSS channel definition for ROC requests
Emery Hsin
emery.hsin at mediatek.com
Sun Nov 29 07:37:35 PST 2026
The ROC request always carried a 20 MHz bandwidth and a secondary channel
offset that was always 0. Use the chandef of the BSS channel context when
joining on the BSS channel, and a 20 MHz no-HT chandef otherwise, as
mt7925 does. Fill the bandwidth from the firmware channel width enum.
Signed-off-by: Emery Hsin <emery.hsin at mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 51 +++++++++++++++----
1 file changed, 42 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 77d3c07486cb..6171fa567d6b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -848,12 +848,29 @@ int mt7921_mcu_set_tx(struct mt792x_dev *dev, struct ieee80211_vif *vif)
&req_mu, sizeof(req_mu), false);
}
+static void
+mt7921_mcu_roc_chandef(struct mt792x_vif *vif, struct ieee80211_channel *chan,
+ enum mt7921_roc_req type, struct cfg80211_chan_def *chandef)
+{
+ struct mt76_vif_link *mlink = &vif->bss_conf.mt76;
+
+ if (type == MT7921_ROC_REQ_JOIN && mlink->ctx &&
+ mlink->ctx->def.chan == chan) {
+ *chandef = mlink->ctx->def;
+ return;
+ }
+
+ cfg80211_chandef_create(chandef, chan, NL80211_CHAN_NO_HT);
+}
+
int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
struct ieee80211_channel *chan, int duration,
enum mt7921_roc_req type, u8 token_id)
{
- int center_ch = ieee80211_frequency_to_channel(chan->center_freq);
struct mt792x_dev *dev = phy->dev;
+ struct cfg80211_chan_def chandef;
+ int center_ch, pri40_freq;
+ u8 bw;
struct {
struct {
u8 rsv[4];
@@ -886,18 +903,34 @@ int mt7921_mcu_set_roc(struct mt792x_phy *phy, struct mt792x_vif *vif,
.maxinterval = cpu_to_le32(duration),
.bss_idx = vif->bss_conf.mt76.idx,
.control_channel = chan->hw_value,
- .bw = CMD_CBW_20MHZ,
- .bw_from_ap = CMD_CBW_20MHZ,
- .center_chan = center_ch,
- .center_chan_from_ap = center_ch,
.dbdcband = 0xff, /* auto */
},
};
- if (chan->hw_value < center_ch)
- req.roc.sco = 1; /* SCA */
- else if (chan->hw_value > center_ch)
- req.roc.sco = 3; /* SCB */
+ mt7921_mcu_roc_chandef(vif, chan, type, &chandef);
+ center_ch = ieee80211_frequency_to_channel(chandef.center_freq1);
+ bw = mt792x_chandef_to_cw(&chandef);
+
+ req.roc.bw = bw;
+ req.roc.bw_from_ap = bw;
+ req.roc.center_chan = center_ch;
+ req.roc.center_chan_from_ap = center_ch;
+
+ if (chandef.center_freq2) {
+ u8 center_ch2 = ieee80211_frequency_to_channel(chandef.center_freq2);
+
+ req.roc.center_chan2 = center_ch2;
+ req.roc.center_chan2_from_ap = center_ch2;
+ }
+
+ if (nl80211_chan_width_to_mhz(chandef.width) >= 40) {
+ pri40_freq = cfg80211_chandef_primary(&chandef,
+ NL80211_CHAN_WIDTH_40, NULL);
+ if (pri40_freq > 0)
+ req.roc.sco = chan->center_freq < pri40_freq ?
+ IEEE80211_HT_PARAM_CHA_SEC_ABOVE :
+ IEEE80211_HT_PARAM_CHA_SEC_BELOW;
+ }
switch (chan->band) {
case NL80211_BAND_6GHZ:
--
2.45.2
More information about the linux-arm-kernel
mailing list