blob: c57d3c8d6dad4b9f117ed76aaf6ea3abd5af5d7a [file] [log] [blame]
developer9237f442024-06-14 17:13:04 +08001From 4969672ddd07d512af13af7622a8c941ddc21d53 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
developer9237f442024-06-14 17:13:04 +08004Subject: [PATCH 106/116] mtk: wifi: mt76: mt7996: support multi-link channel
developer66e89bc2024-04-23 14:50:01 +08005 switch
6
7mtk: wifi: mt76: mt7996: remove the limitation of radar detect width for mlo
8
9Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
10
11mtk: wifi: mt76: mt7996: start and finalize channel switch on link basis
12
13Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
14
15mtk: wifi: mt76: mt7996: fix DFS RDD init issue
16
171. Add radar enabled flag in mt76_phy since hw->conf.radar_enabled
18is only used for non-chanctx driver.
192. Add IEEE80211_CHANCTX_CHANGE_RADAR flag in change_chanctx for RDD
20DFS state update.
21
22Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
23
24mtk: wifi: mt76: mt7996: fix background radar using wrong phy for mld ap
25
26mt7996_hw_phy will be phy0 for 3 link mld ap
27
28Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
29---
30 mac80211.c | 2 +-
31 mt76.h | 1 +
32 mt7996/init.c | 2 --
33 mt7996/main.c | 12 +++++++++---
34 mt7996/mcu.c | 14 +++++++++++---
35 5 files changed, 22 insertions(+), 9 deletions(-)
36
37diff --git a/mac80211.c b/mac80211.c
developer9237f442024-06-14 17:13:04 +080038index 8b9f3fd..c2b82fb 100644
developer66e89bc2024-04-23 14:50:01 +080039--- a/mac80211.c
40+++ b/mac80211.c
developer9237f442024-06-14 17:13:04 +080041@@ -1798,7 +1798,7 @@ enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy)
developer66e89bc2024-04-23 14:50:01 +080042 test_bit(MT76_SCANNING, &phy->state))
43 return MT_DFS_STATE_DISABLED;
44
45- if (!hw->conf.radar_enabled) {
46+ if (!phy->radar_enabled) {
47 if ((hw->conf.flags & IEEE80211_CONF_MONITOR) &&
48 (phy->chandef.chan->flags & IEEE80211_CHAN_RADAR))
49 return MT_DFS_STATE_ACTIVE;
50diff --git a/mt76.h b/mt76.h
developer9237f442024-06-14 17:13:04 +080051index 0452e5d..d88d552 100644
developer66e89bc2024-04-23 14:50:01 +080052--- a/mt76.h
53+++ b/mt76.h
54@@ -849,6 +849,7 @@ struct mt76_phy {
55
56 struct mt76_channel_state *chan_state;
57 enum mt76_dfs_state dfs_state;
58+ bool radar_enabled;
59 ktime_t survey_time;
60
61 u32 aggr_stats[32];
62diff --git a/mt7996/init.c b/mt7996/init.c
developer9237f442024-06-14 17:13:04 +080063index f374119..0dee659 100644
developer66e89bc2024-04-23 14:50:01 +080064--- a/mt7996/init.c
65+++ b/mt7996/init.c
66@@ -36,13 +36,11 @@ static const struct ieee80211_iface_combination if_comb[] = {
67 .max_interfaces = MT7996_MAX_INTERFACES * 3,
68 .num_different_channels = 3,
69 .beacon_int_infra_match = true,
70- /*
71 .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
72 BIT(NL80211_CHAN_WIDTH_20) |
73 BIT(NL80211_CHAN_WIDTH_40) |
74 BIT(NL80211_CHAN_WIDTH_80) |
75 BIT(NL80211_CHAN_WIDTH_160),
76- */
77 }
78 };
79
80diff --git a/mt7996/main.c b/mt7996/main.c
developer9237f442024-06-14 17:13:04 +080081index 3e70d86..8e44da7 100644
developer66e89bc2024-04-23 14:50:01 +080082--- a/mt7996/main.c
83+++ b/mt7996/main.c
84@@ -2133,7 +2133,7 @@ static int
85 mt7996_set_radar_background(struct ieee80211_hw *hw,
86 struct cfg80211_chan_def *chandef)
87 {
88- struct mt7996_phy *phy = mt7996_hw_phy(hw);
89+ struct mt7996_phy *phy = mt7996_band_phy(hw, NL80211_BAND_5GHZ);
90 struct mt7996_dev *dev = phy->dev;
91 int ret = -EINVAL;
92 bool running;
93@@ -2332,6 +2332,7 @@ mt7996_add_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf)
94 }
95
96 phy->chanctx = ctx;
97+ phy->mt76->radar_enabled = conf->radar_enabled;
98 mutex_unlock(&phy->dev->mt76.mutex);
99
100 if (!mt76_testmode_enabled(phy->mt76) && !phy->mt76->test.bf_en) {
101@@ -2359,8 +2360,10 @@ mt7996_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co
102
103 mutex_lock(&phy->dev->mt76.mutex);
104 ctx->assigned = false;
105- if (ctx == phy->chanctx)
106+ if (ctx == phy->chanctx) {
107 phy->chanctx = NULL;
108+ phy->mt76->radar_enabled = false;
109+ }
110 mutex_unlock(&phy->dev->mt76.mutex);
111 }
112
113@@ -2372,8 +2375,10 @@ mt7996_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co
114 struct mt7996_phy *phy = ctx->phy;
115
116 wiphy_info(hw->wiphy, "%s: change %u, 0x%x\n", __func__, conf->def.chan->hw_value, changed);
117- if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH) {
118+ if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH ||
119+ changed & IEEE80211_CHANCTX_CHANGE_RADAR) {
120 ctx->chandef = conf->def;
121+ phy->mt76->radar_enabled = conf->radar_enabled;
122
123 mt7996_set_channel(phy, &ctx->chandef);
124 }
125@@ -2471,6 +2476,7 @@ mt7996_switch_vif_chanctx(struct ieee80211_hw *hw,
126 mutex_lock(&phy->dev->mt76.mutex);
127
128 phy->chanctx = new_ctx;
129+ phy->mt76->radar_enabled = vifs->new_ctx->radar_enabled;
130 new_ctx->assigned = true;
131 new_ctx->chandef = vifs->new_ctx->def;
132 new_ctx->phy = phy;
133diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developer9237f442024-06-14 17:13:04 +0800134index 1387a52..e18a553 100644
developer66e89bc2024-04-23 14:50:01 +0800135--- a/mt7996/mcu.c
136+++ b/mt7996/mcu.c
137@@ -357,10 +357,18 @@ int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
138 static void
139 mt7996_mcu_csa_finish(void *priv, u8 *mac, struct ieee80211_vif *vif)
140 {
141- if (!vif->bss_conf.csa_active || vif->type == NL80211_IFTYPE_STATION)
142+ struct mt76_phy *mphy = (struct mt76_phy *)priv;
143+ struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
144+ struct ieee80211_bss_conf *link_conf;
145+ int link_id, band_idx = mphy->band_idx;
146+
147+ link_id = mvif->band_to_link[band_idx];
148+ link_conf = rcu_dereference(vif->link_conf[link_id]);
149+
150+ if (!link_conf || !link_conf->csa_active || vif->type == NL80211_IFTYPE_STATION)
151 return;
152
153- ieee80211_csa_finish(vif, 0);
154+ ieee80211_csa_finish(vif, link_id);
155 }
156
157 static void
158@@ -475,7 +483,7 @@ mt7996_mcu_ie_countdown(struct mt7996_dev *dev, struct sk_buff *skb)
159 case UNI_EVENT_IE_COUNTDOWN_CSA:
160 ieee80211_iterate_active_interfaces_atomic(mphy->hw,
161 IEEE80211_IFACE_ITER_RESUME_ALL,
162- mt7996_mcu_csa_finish, mphy->hw);
163+ mt7996_mcu_csa_finish, mphy);
164 break;
165 case UNI_EVENT_IE_COUNTDOWN_BCC:
166 ieee80211_iterate_active_interfaces_atomic(mphy->hw,
167--
developer9237f442024-06-14 17:13:04 +08001682.18.0
developer66e89bc2024-04-23 14:50:01 +0800169