blob: 6160525fc4115bb2d14223101322a5b104e5ea89 [file] [log] [blame]
From 29f282a0ca7e594da0b23db9429c0588408a708e 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 138/199] 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
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 c7ec01f2..40418f7e 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;
@@ -2732,6 +2732,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 48ff11d9..3a950a90 100644
--- a/mt7996/mcu.c
+++ b/mt7996/mcu.c
@@ -4397,7 +4397,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,
@@ -4408,6 +4408,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];
@@ -4448,8 +4450,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 cb35a927..259845a1 100644
--- a/mt7996/mt7996.h
+++ b/mt7996/mt7996.h
@@ -1054,7 +1054,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 0565ebc9..8b35d125 100644
--- a/mt7996/testmode.c
+++ b/mt7996/testmode.c
@@ -544,7 +544,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);
@@ -558,7 +558,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.18.0