blob: a58349a5db19d5e5553abc4a1b9dc4debcb54987 [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From 70a14f12eef8b505890f654876a7f89432070bbf 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
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 099/223] 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
developerd0c89452024-10-11 16:53:27 +080030index a98fe4fb..a2b111c0 100644
developer66e89bc2024-04-23 14:50:01 +080031--- a/mac80211.c
32+++ b/mac80211.c
developerd0c89452024-10-11 16:53:27 +080033@@ -1801,7 +1801,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
developerd0c89452024-10-11 16:53:27 +080043index b65a6b0a..bc263bd4 100644
developer66e89bc2024-04-23 14:50:01 +080044--- a/mt76.h
45+++ b/mt76.h
developerd0c89452024-10-11 16:53:27 +080046@@ -862,6 +862,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
developerd0c89452024-10-11 16:53:27 +080055index fe5bfd72..e3f30b23 100644
developer66e89bc2024-04-23 14:50:01 +080056--- a/mt7996/main.c
57+++ b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080058@@ -2143,7 +2143,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;
developerd0c89452024-10-11 16:53:27 +080067@@ -2358,6 +2358,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) {
developerd0c89452024-10-11 16:53:27 +080075@@ -2385,8 +2386,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
developerd0c89452024-10-11 16:53:27 +080087@@ -2398,8 +2401,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 }
developerd0c89452024-10-11 16:53:27 +080099@@ -2497,6 +2502,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
developerd0c89452024-10-11 16:53:27 +0800108index 9359a251..d897098e 100644
developer66e89bc2024-04-23 14:50:01 +0800109--- a/mt7996/mcu.c
110+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800111@@ -362,10 +362,18 @@ int mt7996_mcu_wa_cmd(struct mt7996_dev *dev, int cmd, u32 a1, u32 a2, u32 a3)
developer66e89bc2024-04-23 14:50:01 +0800112 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
developerd0c89452024-10-11 16:53:27 +0800132@@ -480,7 +488,7 @@ mt7996_mcu_ie_countdown(struct mt7996_dev *dev, struct sk_buff *skb)
developer66e89bc2024-04-23 14:50:01 +0800133 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--
developerd0c89452024-10-11 16:53:27 +08001422.45.2
developer66e89bc2024-04-23 14:50:01 +0800143