developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From 799a94c158a9c9df4586f8efec1cf586a7ad29d9 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 17 May 2024 14:49:50 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 126/223] mtk: mt76: mt7996: trigger channel calibration for |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | DFS link after sta is associated |
| 6 | |
| 7 | Trigger channel calibration (set channel with switch reason = NORMAL) |
| 8 | for DFS link after STA is associated. |
| 9 | Without this patch, 5G link might have high PER during T.P. test |
| 10 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 11 | Change-Id: I65ed79767049f4fdd31ac95a93496d1ccdc39699 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 12 | Signed-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 | |
| 20 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 21 | index 3f93eda0..f45f6c02 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 22 | --- 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 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 53 | @@ -2736,6 +2736,13 @@ mt7996_event_callback(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 54 | 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, |
| 67 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 68 | index d9d29c4e..a6f2c157 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 69 | --- a/mt7996/mcu.c |
| 70 | +++ b/mt7996/mcu.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 71 | @@ -4405,7 +4405,7 @@ int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 72 | 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, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 80 | @@ -4416,6 +4416,8 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 81 | 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]; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 89 | @@ -4456,8 +4458,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 90 | 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; |
| 99 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 100 | index 21be14d0..07c72d2b 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 101 | --- a/mt7996/mt7996.h |
| 102 | +++ b/mt7996/mt7996.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 103 | @@ -1058,7 +1058,7 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 104 | 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); |
| 112 | diff --git a/mt7996/testmode.c b/mt7996/testmode.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 113 | index 799e443c..c68619cb 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 114 | --- a/mt7996/testmode.c |
| 115 | +++ b/mt7996/testmode.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 116 | @@ -550,7 +550,7 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 117 | |
| 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); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 125 | @@ -564,7 +564,7 @@ out: |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 126 | 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 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 135 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 136 | |