blob: 3f696d99f3b4d04bf5b2f62daedde84b5ce3bad1 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 56f1336c11dd0627e8e79951c16713cc35463733 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
3Date: Fri, 19 Jan 2024 14:04:03 +0800
developer05f3b2b2024-08-19 19:17:34 +08004Subject: [PATCH 111/199] mtk: mt76: mt7996: support multi-link channel switch
developer66e89bc2024-04-23 14:50:01 +08005
6mtk: wifi: mt76: mt7996: remove the limitation of radar detect width for mlo
7
developer66e89bc2024-04-23 14:50:01 +08008mtk: wifi: mt76: mt7996: start and finalize channel switch on link basis
9
developer66e89bc2024-04-23 14:50:01 +080010mtk: wifi: mt76: mt7996: fix DFS RDD init issue
11
121. Add radar enabled flag in mt76_phy since hw->conf.radar_enabled
13is only used for non-chanctx driver.
142. Add IEEE80211_CHANCTX_CHANGE_RADAR flag in change_chanctx for RDD
15DFS state update.
16
developer66e89bc2024-04-23 14:50:01 +080017mtk: wifi: mt76: mt7996: fix background radar using wrong phy for mld ap
18
19mt7996_hw_phy will be phy0 for 3 link mld ap
20
21Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
22---
23 mac80211.c | 2 +-
24 mt76.h | 1 +
developer66e89bc2024-04-23 14:50:01 +080025 mt7996/main.c | 12 +++++++++---
26 mt7996/mcu.c | 14 +++++++++++---
developer05f3b2b2024-08-19 19:17:34 +080027 4 files changed, 22 insertions(+), 7 deletions(-)
developer66e89bc2024-04-23 14:50:01 +080028
29diff --git a/mac80211.c b/mac80211.c
developer05f3b2b2024-08-19 19:17:34 +080030index bc463437..5e4935f2 100644
developer66e89bc2024-04-23 14:50:01 +080031--- a/mac80211.c
32+++ b/mac80211.c
developer05f3b2b2024-08-19 19:17:34 +080033@@ -1787,7 +1787,7 @@ enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy)
developer66e89bc2024-04-23 14:50:01 +080034 test_bit(MT76_SCANNING, &phy->state))
35 return MT_DFS_STATE_DISABLED;
36
37- if (!hw->conf.radar_enabled) {
38+ if (!phy->radar_enabled) {
39 if ((hw->conf.flags & IEEE80211_CONF_MONITOR) &&
40 (phy->chandef.chan->flags & IEEE80211_CHAN_RADAR))
41 return MT_DFS_STATE_ACTIVE;
42diff --git a/mt76.h b/mt76.h
developer05f3b2b2024-08-19 19:17:34 +080043index b1f22e6a..c6dda4a8 100644
developer66e89bc2024-04-23 14:50:01 +080044--- a/mt76.h
45+++ b/mt76.h
developer05f3b2b2024-08-19 19:17:34 +080046@@ -847,6 +847,7 @@ struct mt76_phy {
developer66e89bc2024-04-23 14:50:01 +080047
48 struct mt76_channel_state *chan_state;
49 enum mt76_dfs_state dfs_state;
50+ bool radar_enabled;
51 ktime_t survey_time;
52
53 u32 aggr_stats[32];
developer66e89bc2024-04-23 14:50:01 +080054diff --git a/mt7996/main.c b/mt7996/main.c
developer05f3b2b2024-08-19 19:17:34 +080055index 17f4901f..7012aa96 100644
developer66e89bc2024-04-23 14:50:01 +080056--- a/mt7996/main.c
57+++ b/mt7996/main.c
developer05f3b2b2024-08-19 19:17:34 +080058@@ -2139,7 +2139,7 @@ static int
developer66e89bc2024-04-23 14:50:01 +080059 mt7996_set_radar_background(struct ieee80211_hw *hw,
60 struct cfg80211_chan_def *chandef)
61 {
62- struct mt7996_phy *phy = mt7996_hw_phy(hw);
63+ struct mt7996_phy *phy = mt7996_band_phy(hw, NL80211_BAND_5GHZ);
64 struct mt7996_dev *dev = phy->dev;
65 int ret = -EINVAL;
66 bool running;
developer05f3b2b2024-08-19 19:17:34 +080067@@ -2354,6 +2354,7 @@ mt7996_add_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf)
developer66e89bc2024-04-23 14:50:01 +080068 }
69
70 phy->chanctx = ctx;
71+ phy->mt76->radar_enabled = conf->radar_enabled;
72 mutex_unlock(&phy->dev->mt76.mutex);
73
74 if (!mt76_testmode_enabled(phy->mt76) && !phy->mt76->test.bf_en) {
developer05f3b2b2024-08-19 19:17:34 +080075@@ -2381,8 +2382,10 @@ mt7996_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co
developer66e89bc2024-04-23 14:50:01 +080076
77 mutex_lock(&phy->dev->mt76.mutex);
78 ctx->assigned = false;
79- if (ctx == phy->chanctx)
80+ if (ctx == phy->chanctx) {
81 phy->chanctx = NULL;
82+ phy->mt76->radar_enabled = false;
83+ }
84 mutex_unlock(&phy->dev->mt76.mutex);
85 }
86
developer05f3b2b2024-08-19 19:17:34 +080087@@ -2394,8 +2397,10 @@ mt7996_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co
developer66e89bc2024-04-23 14:50:01 +080088 struct mt7996_phy *phy = ctx->phy;
89
90 wiphy_info(hw->wiphy, "%s: change %u, 0x%x\n", __func__, conf->def.chan->hw_value, changed);
91- if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH) {
92+ if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH ||
93+ changed & IEEE80211_CHANCTX_CHANGE_RADAR) {
94 ctx->chandef = conf->def;
95+ phy->mt76->radar_enabled = conf->radar_enabled;
96
97 mt7996_set_channel(phy, &ctx->chandef);
98 }
developer05f3b2b2024-08-19 19:17:34 +080099@@ -2493,6 +2498,7 @@ mt7996_switch_vif_chanctx(struct ieee80211_hw *hw,
developer66e89bc2024-04-23 14:50:01 +0800100 mutex_lock(&phy->dev->mt76.mutex);
101
102 phy->chanctx = new_ctx;
103+ phy->mt76->radar_enabled = vifs->new_ctx->radar_enabled;
104 new_ctx->assigned = true;
105 new_ctx->chandef = vifs->new_ctx->def;
106 new_ctx->phy = phy;
107diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer05f3b2b2024-08-19 19:17:34 +0800108index 2884af9d..7b0d631e 100644
developer66e89bc2024-04-23 14:50:01 +0800109--- a/mt7996/mcu.c
110+++ b/mt7996/mcu.c
111@@ -357,10 +357,18 @@ int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
112 static void
113 mt7996_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
114 {
115- if (!vif->bss_conf.csa_active || vif->type == NL80211_IFTYPE_STATION)
116+ struct mt76_phy *mphy = (struct mt76_phy *)priv;
117+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
118+ struct ieee80211_bss_conf *link_conf;
119+ int link_id, band_idx = mphy->band_idx;
120+
121+ link_id = mvif->band_to_link[band_idx];
122+ link_conf = rcu_dereference(vif->link_conf[link_id]);
123+
124+ if (!link_conf || !link_conf->csa_active || vif->type == NL80211_IFTYPE_STATION)
125 return;
126
127- ieee80211_csa_finish(vif, 0);
128+ ieee80211_csa_finish(vif, link_id);
129 }
130
131 static void
132@@ -475,7 +483,7 @@ mt7996_mcu_ie_countdown(struct mt7996_dev *dev, struct sk_buff *skb)
133 case UNI_EVENT_IE_COUNTDOWN_CSA:
134 ieee80211_iterate_active_interfaces_atomic(mphy->hw,
135 IEEE80211_IFACE_ITER_RESUME_ALL,
136- mt7996_mcu_csa_finish, mphy->hw);
137+ mt7996_mcu_csa_finish, mphy);
138 break;
139 case UNI_EVENT_IE_COUNTDOWN_BCC:
140 ieee80211_iterate_active_interfaces_atomic(mphy->hw,
141--
developer9237f442024-06-14 17:13:04 +08001422.18.0
developer66e89bc2024-04-23 14:50:01 +0800143