developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From 29f282a0ca7e594da0b23db9429c0588408a708e Mon Sep 17 00:00:00 2001 |
| 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 17 May 2024 14:49:50 +0800 |
| 4 | Subject: [PATCH 138/199] mtk: mt76: mt7996: trigger channel calibration for |
| 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 | |
| 11 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 12 | --- |
| 13 | mt7996/main.c | 15 +++++++++++---- |
| 14 | mt7996/mcu.c | 7 ++++--- |
| 15 | mt7996/mt7996.h | 2 +- |
| 16 | mt7996/testmode.c | 4 ++-- |
| 17 | 4 files changed, 18 insertions(+), 10 deletions(-) |
| 18 | |
| 19 | diff --git a/mt7996/main.c b/mt7996/main.c |
| 20 | index c7ec01f2..40418f7e 100644 |
| 21 | --- a/mt7996/main.c |
| 22 | +++ b/mt7996/main.c |
| 23 | @@ -82,12 +82,12 @@ int mt7996_run(struct ieee80211_hw *hw) |
| 24 | if (ret) |
| 25 | goto out; |
| 26 | |
| 27 | - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH); |
| 28 | + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH, false); |
| 29 | if (ret) |
| 30 | goto out; |
| 31 | |
| 32 | /* set a parking channel */ |
| 33 | - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| 34 | + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| 35 | if (ret) |
| 36 | goto out; |
| 37 | |
| 38 | @@ -554,11 +554,11 @@ static int __mt7996_set_channel(struct mt7996_phy *phy, |
| 39 | goto out; |
| 40 | } |
| 41 | |
| 42 | - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| 43 | + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| 44 | if (ret) |
| 45 | goto out; |
| 46 | |
| 47 | - ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH); |
| 48 | + ret = mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_RX_PATH, false); |
| 49 | if (ret) |
| 50 | goto out; |
| 51 | |
| 52 | @@ -2732,6 +2732,13 @@ mt7996_event_callback(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 53 | next_time = min(next_time, |
| 54 | MT7996_MAX_BEACON_LOSS * |
| 55 | conf->beacon_int); |
| 56 | + |
| 57 | + /* trigger calibration for DFS link */ |
| 58 | + if (!cfg80211_reg_can_beacon(hw->wiphy, |
| 59 | + &mconf->chanctx->chandef, |
| 60 | + NL80211_IFTYPE_AP)) |
| 61 | + mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, |
| 62 | + true); |
| 63 | } |
| 64 | |
| 65 | ieee80211_queue_delayed_work(hw, &mvif->beacon_mon_work, |
| 66 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
| 67 | index 48ff11d9..3a950a90 100644 |
| 68 | --- a/mt7996/mcu.c |
| 69 | +++ b/mt7996/mcu.c |
| 70 | @@ -4397,7 +4397,7 @@ int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy, |
| 71 | 0, region); |
| 72 | } |
| 73 | |
| 74 | -int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| 75 | +int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta) |
| 76 | { |
| 77 | static const u8 ch_band[] = { |
| 78 | [NL80211_BAND_2GHZ] = 0, |
| 79 | @@ -4408,6 +4408,8 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| 80 | struct cfg80211_chan_def *chandef = &phy->mt76->chandef; |
| 81 | int freq1 = chandef->center_freq1; |
| 82 | u8 band_idx = phy->mt76->band_idx; |
| 83 | + enum nl80211_iftype iftype = sta ? NL80211_IFTYPE_STATION : |
| 84 | + NL80211_IFTYPE_AP; |
| 85 | struct { |
| 86 | /* fixed field */ |
| 87 | u8 __rsv[4]; |
| 88 | @@ -4448,8 +4450,7 @@ int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag) |
| 89 | phy->mt76->hw->conf.flags & IEEE80211_CONF_IDLE || |
| 90 | phy->scan_chan) |
| 91 | req.switch_reason = CH_SWITCH_SCAN_BYPASS_DPD; |
| 92 | - else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, |
| 93 | - NL80211_IFTYPE_AP)) |
| 94 | + else if (!cfg80211_reg_can_beacon(phy->mt76->hw->wiphy, chandef, iftype)) |
| 95 | req.switch_reason = CH_SWITCH_DFS; |
| 96 | else |
| 97 | req.switch_reason = CH_SWITCH_NORMAL; |
| 98 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
| 99 | index cb35a927..259845a1 100644 |
| 100 | --- a/mt7996/mt7996.h |
| 101 | +++ b/mt7996/mt7996.h |
| 102 | @@ -1054,7 +1054,7 @@ int mt7996_mcu_add_rate_ctrl(struct mt7996_dev *dev, |
| 103 | int mt7996_mcu_add_mld_sta(struct mt7996_dev *dev, struct ieee80211_vif *vif, |
| 104 | struct ieee80211_sta *sta, unsigned long add); |
| 105 | int mt7996_set_channel(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef); |
| 106 | -int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag); |
| 107 | +int mt7996_mcu_set_chan_info(struct mt7996_phy *phy, u16 tag, bool sta); |
| 108 | int mt7996_mcu_set_tx(struct mt7996_dev *dev, struct mt7996_bss_conf *mconf); |
| 109 | int mt7996_mcu_set_fixed_rate_ctrl(struct mt7996_dev *dev, |
| 110 | void *data, u16 version); |
| 111 | diff --git a/mt7996/testmode.c b/mt7996/testmode.c |
| 112 | index 0565ebc9..8b35d125 100644 |
| 113 | --- a/mt7996/testmode.c |
| 114 | +++ b/mt7996/testmode.c |
| 115 | @@ -544,7 +544,7 @@ mt7996_tm_dpd_prek_send_req(struct mt7996_phy *phy, struct mt7996_tm_req *req, |
| 116 | |
| 117 | /* set channel switch reason */ |
| 118 | mphy->hw->conf.flags |= IEEE80211_CONF_OFFCHANNEL; |
| 119 | - mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| 120 | + mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| 121 | |
| 122 | ret = mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(TESTMODE_CTRL), req, |
| 123 | sizeof(*req), false); |
| 124 | @@ -558,7 +558,7 @@ out: |
| 125 | mphy->hw->conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; |
| 126 | memcpy(chandef, &chandef_backup, sizeof(struct cfg80211_chan_def)); |
| 127 | memcpy(chandef->chan, &chan_backup, sizeof(struct ieee80211_channel)); |
| 128 | - mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH); |
| 129 | + mt7996_mcu_set_chan_info(phy, UNI_CHANNEL_SWITCH, false); |
| 130 | |
| 131 | return ret; |
| 132 | } |
| 133 | -- |
| 134 | 2.18.0 |
| 135 | |