| From 799a94c158a9c9df4586f8efec1cf586a7ad29d9 Mon Sep 17 00:00:00 2001 |
| From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| Date: Fri, 17 May 2024 14:49:50 +0800 |
| Subject: [PATCH 126/223] mtk: mt76: mt7996: trigger channel calibration for |
| DFS link after sta is associated |
| |
| Trigger channel calibration (set channel with switch reason = NORMAL) |
| for DFS link after STA is associated. |
| Without this patch, 5G link might have high PER during T.P. test |
| |
| Change-Id: I65ed79767049f4fdd31ac95a93496d1ccdc39699 |
| Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| --- |
| mt7996/main.c | 15 +++++++++++---- |
| mt7996/mcu.c | 7 ++++--- |
| mt7996/mt7996.h | 2 +- |
| mt7996/testmode.c | 4 ++-- |
| 4 files changed, 18 insertions(+), 10 deletions(-) |
| |
| diff --git a/mt7996/main.c b/mt7996/main.c |
| index 3f93eda0..f45f6c02 100644 |
| --- a/mt7996/main.c |
| +++ b/mt7996/main.c |
| @@ -82,12 +82,12 @@ int mt7996_run(struct ieee80211_hw *hw) |
| if (ret) |
| goto out; |
| |
| - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH); |
| + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH, false); |
| if (ret) |
| goto out; |
| |
| /* set a parking channel */ |
| - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| if (ret) |
| goto out; |
| |
| @@ -554,11 +554,11 @@ static int __mt7996_set_channel(struct mt7996_phy *phy, |
| goto out; |
| } |
| |
| - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| if (ret) |
| goto out; |
| |
| - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH); |
| + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH, false); |
| if (ret) |
| goto out; |
| |
| @@ -2736,6 +2736,13 @@ mt7996_event_callback(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| next_time = min(next_time, |
| MT7996_MAX_BEACON_LOSS * |
| conf->beacon_int); |
| + |
| + /* trigger calibration for DFS link */ |
| + if (!cfg80211_reg_can_beacon(hw->wiphy, |
| + &mconf->chanctx->chandef, |
| + NL80211_IFTYPE_AP)) |
| + mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, |
| + true); |
| } |
| |
| ieee80211_queue_delayed_work(hw, &mvif->beacon_mon_work, |
| diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| index d9d29c4e..a6f2c157 100644 |
| --- a/mt7996/mcu.c |
| +++ b/mt7996/mcu.c |
| @@ -4405,7 +4405,7 @@ int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy, |
| 0, region); |
| } |
| |
| -int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| +int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta) |
| { |
| static const u8 ch_band[] = { |
| [NL80211_BAND_2GHZ] = 0, |
| @@ -4416,6 +4416,8 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| struct cfg80211_chan_def *chandef = &phy->mt76->chandef; |
| int freq1 = chandef->center_freq1; |
| u8 band_idx = phy->mt76->band_idx; |
| + enum nl80211_iftype iftype = sta ? NL80211_IFTYPE_STATION : |
| + NL80211_IFTYPE_AP; |
| struct { |
| /* fixed field */ |
| u8 __rsv[4]; |
| @@ -4456,8 +4458,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| phy->mt76->hw->conf.flags & IEEE80211_CONF_IDLE || |
| phy->scan_chan) |
| req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD; |
| - else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, |
| - NL80211_IFTYPE_AP)) |
| + else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, iftype)) |
| req.switch_reason = CH_SWITCH_DFS; |
| else |
| req.switch_reason = CH_SWITCH_NORMAL; |
| diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| index 21be14d0..07c72d2b 100644 |
| --- a/mt7996/mt7996.h |
| +++ b/mt7996/mt7996.h |
| @@ -1058,7 +1058,7 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
| int mt7996_mcu_add_mld_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| struct ieee80211_sta *sta, unsigned long add); |
| int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef); |
| -int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag); |
| +int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta); |
| int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf); |
| int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, |
| void *data, u16 version); |
| diff --git a/mt7996/testmode.c b/mt7996/testmode.c |
| index 799e443c..c68619cb 100644 |
| --- a/mt7996/testmode.c |
| +++ b/mt7996/testmode.c |
| @@ -550,7 +550,7 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req, |
| |
| /* set channel switch reason */ |
| mphy->hw->conf.flags |= IEEE80211_CONF_OFFCHANNEL; |
| - mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| + mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| |
| ret = mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TESTMODE_CTRL), req, |
| sizeof(*req), false); |
| @@ -564,7 +564,7 @@ out: |
| mphy->hw->conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; |
| memcpy(chandef, &chandef_backup, sizeof(struct cfg80211_chan_def)); |
| memcpy(chandef->chan, &chan_backup, sizeof(struct ieee80211_channel)); |
| - mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| + mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| |
| return ret; |
| } |
| -- |
| 2.45.2 |
| |