blob: 11e2f62cae60b1173c4a0e9843244ce5c5a6c1a1 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 799a94c158a9c9df4586f8efec1cf586a7ad29d9 Mon Sep 17 00:00:00 2001
developer05f3b2b2024-08-19 19:17:34 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 17 May 2024 14:49:50 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 126/223] mtk: mt76: mt7996: trigger channel calibration for
developer05f3b2b2024-08-19 19:17:34 +08005 DFS link after sta is associated
6
7Trigger channel calibration (set channel with switch reason = NORMAL)
8for DFS link after STA is associated.
9Without this patch, 5G link might have high PER during T.P. test
10
developerd0c89452024-10-11 16:53:27 +080011Change-Id: I65ed79767049f4fdd31ac95a93496d1ccdc39699
developer05f3b2b2024-08-19 19:17:34 +080012Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
13---
14 mt7996/main.c | 15 +++++++++++----
15 mt7996/mcu.c | 7 ++++---
16 mt7996/mt7996.h | 2 +-
17 mt7996/testmode.c | 4 ++--
18 4 files changed, 18 insertions(+), 10 deletions(-)
19
20diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080021index 3f93eda0..f45f6c02 100644
developer05f3b2b2024-08-19 19:17:34 +080022--- a/mt7996/main.c
23+++ b/mt7996/main.c
24@@ -82,12 +82,12 @@ int mt7996_run(struct ieee80211_hw *hw)
25 if (ret)
26 goto out;
27
28- ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH);
29+ ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH, false);
30 if (ret)
31 goto out;
32
33 /* set a parking channel */
34- ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
35+ ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false);
36 if (ret)
37 goto out;
38
39@@ -554,11 +554,11 @@ static int __mt7996_set_channel(struct mt7996_phy *phy,
40 goto out;
41 }
42
43- ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
44+ ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false);
45 if (ret)
46 goto out;
47
48- ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH);
49+ ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH, false);
50 if (ret)
51 goto out;
52
developerd0c89452024-10-11 16:53:27 +080053@@ -2736,6 +2736,13 @@ mt7996_event_callback(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer05f3b2b2024-08-19 19:17:34 +080054 next_time = min(next_time,
55 MT7996_MAX_BEACON_LOSS *
56 conf->beacon_int);
57+
58+ /* trigger calibration for DFS link */
59+ if (!cfg80211_reg_can_beacon(hw->wiphy,
60+ &mconf->chanctx->chandef,
61+ NL80211_IFTYPE_AP))
62+ mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH,
63+ true);
64 }
65
66 ieee80211_queue_delayed_work(hw, &mvif->beacon_mon_work,
67diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +080068index d9d29c4e..a6f2c157 100644
developer05f3b2b2024-08-19 19:17:34 +080069--- a/mt7996/mcu.c
70+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +080071@@ -4405,7 +4405,7 @@ int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy,
developer05f3b2b2024-08-19 19:17:34 +080072 0, region);
73 }
74
75-int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag)
76+int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta)
77 {
78 static const u8 ch_band[] = {
79 [NL80211_BAND_2GHZ] = 0,
developerd0c89452024-10-11 16:53:27 +080080@@ -4416,6 +4416,8 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag)
developer05f3b2b2024-08-19 19:17:34 +080081 struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
82 int freq1 = chandef->center_freq1;
83 u8 band_idx = phy->mt76->band_idx;
84+ enum nl80211_iftype iftype = sta ? NL80211_IFTYPE_STATION :
85+ NL80211_IFTYPE_AP;
86 struct {
87 /* fixed field */
88 u8 __rsv[4];
developerd0c89452024-10-11 16:53:27 +080089@@ -4456,8 +4458,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag)
developer05f3b2b2024-08-19 19:17:34 +080090 phy->mt76->hw->conf.flags & IEEE80211_CONF_IDLE ||
91 phy->scan_chan)
92 req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD;
93- else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef,
94- NL80211_IFTYPE_AP))
95+ else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, iftype))
96 req.switch_reason = CH_SWITCH_DFS;
97 else
98 req.switch_reason = CH_SWITCH_NORMAL;
99diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800100index 21be14d0..07c72d2b 100644
developer05f3b2b2024-08-19 19:17:34 +0800101--- a/mt7996/mt7996.h
102+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800103@@ -1058,7 +1058,7 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev,
developer05f3b2b2024-08-19 19:17:34 +0800104 int mt7996_mcu_add_mld_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif,
105 struct ieee80211_sta *sta, unsigned long add);
106 int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef);
107-int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag);
108+int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta);
109 int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf);
110 int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev,
111 void *data, u16 version);
112diff --git a/mt7996/testmode.c b/mt7996/testmode.c
developerd0c89452024-10-11 16:53:27 +0800113index 799e443c..c68619cb 100644
developer05f3b2b2024-08-19 19:17:34 +0800114--- a/mt7996/testmode.c
115+++ b/mt7996/testmode.c
developerd0c89452024-10-11 16:53:27 +0800116@@ -550,7 +550,7 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req,
developer05f3b2b2024-08-19 19:17:34 +0800117
118 /* set channel switch reason */
119 mphy->hw->conf.flags |= IEEE80211_CONF_OFFCHANNEL;
120- mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
121+ mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false);
122
123 ret = mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TESTMODE_CTRL), req,
124 sizeof(*req), false);
developerd0c89452024-10-11 16:53:27 +0800125@@ -564,7 +564,7 @@ out:
developer05f3b2b2024-08-19 19:17:34 +0800126 mphy->hw->conf.flags &= ~IEEE80211_CONF_OFFCHANNEL;
127 memcpy(chandef, &chandef_backup, sizeof(struct cfg80211_chan_def));
128 memcpy(chandef->chan, &chan_backup, sizeof(struct ieee80211_channel));
129- mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH);
130+ mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false);
131
132 return ret;
133 }
134--
developerd0c89452024-10-11 16:53:27 +08001352.45.2
developer05f3b2b2024-08-19 19:17:34 +0800136