blob: fd1408de12330f2119037254217c98866e04354c [file] [log] [blame]
From 1dfd2813ec62c27890085927164b4613284c1f12 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/193] 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 bdb1fab..161b5cb 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;
@@ -2735,6 +2735,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 1f89c5f..29dc95b 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 21be14d..07c72d2 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 799e443..c68619c 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