developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 1 | From 56f1336c11dd0627e8e79951c16713cc35463733 Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 19 Jan 2024 14:04:03 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 4 | Subject: [PATCH 111/199] mtk: mt76: mt7996: support multi-link channel switch |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | mtk: wifi: mt76: mt7996: remove the limitation of radar detect width for mlo |
| 7 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 8 | mtk: wifi: mt76: mt7996: start and finalize channel switch on link basis |
| 9 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 10 | mtk: wifi: mt76: mt7996: fix DFS RDD init issue |
| 11 | |
| 12 | 1. Add radar enabled flag in mt76_phy since hw->conf.radar_enabled |
| 13 | is only used for non-chanctx driver. |
| 14 | 2. Add IEEE80211_CHANCTX_CHANGE_RADAR flag in change_chanctx for RDD |
| 15 | DFS state update. |
| 16 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 17 | mtk: wifi: mt76: mt7996: fix background radar using wrong phy for mld ap |
| 18 | |
| 19 | mt7996_hw_phy will be phy0 for 3 link mld ap |
| 20 | |
| 21 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 22 | --- |
| 23 | mac80211.c | 2 +- |
| 24 | mt76.h | 1 + |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 25 | mt7996/main.c | 12 +++++++++--- |
| 26 | mt7996/mcu.c | 14 +++++++++++--- |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 27 | 4 files changed, 22 insertions(+), 7 deletions(-) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 28 | |
| 29 | diff --git a/mac80211.c b/mac80211.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 30 | index bc463437..5e4935f2 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 31 | --- a/mac80211.c |
| 32 | +++ b/mac80211.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 33 | @@ -1787,7 +1787,7 @@ enum mt76_dfs_state mt76_phy_dfs_state(struct mt76_phy *phy) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 34 | 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; |
| 42 | diff --git a/mt76.h b/mt76.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 43 | index b1f22e6a..c6dda4a8 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 44 | --- a/mt76.h |
| 45 | +++ b/mt76.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 46 | @@ -847,6 +847,7 @@ struct mt76_phy { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 47 | |
| 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]; |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 54 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 55 | index 17f4901f..7012aa96 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 56 | --- a/mt7996/main.c |
| 57 | +++ b/mt7996/main.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 58 | @@ -2139,7 +2139,7 @@ static int |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 59 | 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; |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 67 | @@ -2354,6 +2354,7 @@ mt7996_add_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 68 | } |
| 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) { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 75 | @@ -2381,8 +2382,10 @@ mt7996_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 76 | |
| 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 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 87 | @@ -2394,8 +2397,10 @@ mt7996_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *co |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 88 | 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 | } |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 99 | @@ -2493,6 +2498,7 @@ mt7996_switch_vif_chanctx(struct ieee80211_hw *hw, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 100 | 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; |
| 107 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 108 | index 2884af9d..7b0d631e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 109 | --- 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 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 142 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 143 | |