developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 1 | From 1be3480176150329dd571219f69ccd8efa312daa 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: Wed, 5 Jul 2023 10:00:17 +0800 |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 4 | Subject: [PATCH 028/116] mtk: wifi: mt76: mt7996: support eagle ZWDFS on iFEM |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | Fix the case that control channel is not first chan during first |
| 7 | interface setup. |
| 8 | Refactor ifem adie logic (if/else to switch, use sku_type & fem_type) |
| 9 | |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 10 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 11 | --- |
| 12 | mt7996/main.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++--- |
| 13 | mt7996/mcu.c | 6 +++-- |
| 14 | mt7996/mt7996.h | 1 + |
| 15 | 3 files changed, 67 insertions(+), 5 deletions(-) |
| 16 | |
| 17 | diff --git a/mt7996/main.c b/mt7996/main.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 18 | index 46e3e5a..61396a8 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 19 | --- a/mt7996/main.c |
| 20 | +++ b/mt7996/main.c |
| 21 | @@ -1444,6 +1444,61 @@ mt7996_twt_teardown_request(struct ieee80211_hw *hw, |
| 22 | mutex_unlock(&dev->mt76.mutex); |
| 23 | } |
| 24 | |
| 25 | +static void |
| 26 | +mt7996_background_radar_handle_7975_ifem(struct ieee80211_hw *hw, |
| 27 | + struct cfg80211_chan_def *user_chandef, |
| 28 | + struct cfg80211_chan_def *fw_chandef) |
| 29 | +{ |
| 30 | + struct mt7996_dev *dev = mt7996_hw_dev(hw); |
| 31 | + struct cfg80211_chan_def *c = user_chandef; |
| 32 | + struct ieee80211_channel *first_chan; |
| 33 | + bool is_ifem_adie, expand = false; |
| 34 | + |
| 35 | + switch (mt76_chip(&dev->mt76)) { |
| 36 | + case 0x7990: |
| 37 | + is_ifem_adie = dev->fem_type == MT7996_FEM_INT && |
| 38 | + dev->chip_sku != MT7996_SKU_233; |
| 39 | + break; |
| 40 | + case 0x7992: |
| 41 | + is_ifem_adie = dev->chip_sku == MT7992_SKU_44 && |
| 42 | + dev->fem_type != MT7996_FEM_EXT; |
| 43 | + break; |
| 44 | + default: |
| 45 | + return; |
| 46 | + } |
| 47 | + |
| 48 | + if (!user_chandef || !is_ifem_adie) |
| 49 | + goto out; |
| 50 | + |
| 51 | + if (user_chandef->width == NL80211_CHAN_WIDTH_160) { |
| 52 | + first_chan = ieee80211_get_channel(hw->wiphy, user_chandef->center_freq1 - 70); |
| 53 | + if (dev->bg_nxt_freq) |
| 54 | + goto out; |
| 55 | + |
| 56 | + if (first_chan->flags & IEEE80211_CHAN_RADAR) |
| 57 | + dev->bg_nxt_freq = first_chan->center_freq; |
| 58 | + else |
| 59 | + c = fw_chandef; |
| 60 | + |
| 61 | + c->chan = ieee80211_get_channel(hw->wiphy, first_chan->center_freq + 80); |
| 62 | + } else { |
| 63 | + if (!dev->bg_nxt_freq) |
| 64 | + goto out; |
| 65 | + |
| 66 | + c->chan = ieee80211_get_channel(hw->wiphy, dev->bg_nxt_freq); |
| 67 | + dev->bg_nxt_freq = 0; |
| 68 | + expand = true; |
| 69 | + } |
| 70 | + c->width = NL80211_CHAN_WIDTH_80; |
| 71 | + c->center_freq1 = c->chan->center_freq + 30; |
| 72 | + |
| 73 | + if (c == user_chandef) |
| 74 | + cfg80211_background_radar_update_channel(hw->wiphy, c, expand); |
| 75 | + return; |
| 76 | +out: |
| 77 | + dev->bg_nxt_freq = 0; |
| 78 | +} |
| 79 | + |
| 80 | static int |
| 81 | mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 82 | struct cfg80211_chan_def *chandef) |
| 83 | @@ -1452,6 +1507,7 @@ mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 84 | struct mt7996_dev *dev = phy->dev; |
| 85 | int ret = -EINVAL; |
| 86 | bool running; |
| 87 | + struct cfg80211_chan_def ifem_chandef = {}; |
| 88 | |
| 89 | mutex_lock(&dev->mt76.mutex); |
| 90 | |
| 91 | @@ -1464,13 +1520,14 @@ mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 92 | goto out; |
| 93 | } |
| 94 | |
| 95 | + mt7996_background_radar_handle_7975_ifem(hw, chandef, &ifem_chandef); |
| 96 | + |
| 97 | /* rdd2 already configured on a radar channel */ |
| 98 | running = dev->rdd2_phy && |
| 99 | cfg80211_chandef_valid(&dev->rdd2_chandef) && |
| 100 | !!(dev->rdd2_chandef.chan->flags & IEEE80211_CHAN_RADAR); |
| 101 | |
| 102 | - if (!chandef || running || |
| 103 | - !(chandef->chan->flags & IEEE80211_CHAN_RADAR)) { |
| 104 | + if (!chandef || running) { |
| 105 | ret = mt7996_mcu_rdd_background_enable(phy, NULL); |
| 106 | if (ret) |
| 107 | goto out; |
| 108 | @@ -1479,7 +1536,9 @@ mt7996_set_radar_background(struct ieee80211_hw *hw, |
| 109 | goto update_phy; |
| 110 | } |
| 111 | |
| 112 | - ret = mt7996_mcu_rdd_background_enable(phy, chandef); |
| 113 | + ret = mt7996_mcu_rdd_background_enable(phy, |
| 114 | + ifem_chandef.chan ? |
| 115 | + &ifem_chandef : chandef); |
| 116 | if (ret) |
| 117 | goto out; |
| 118 | |
| 119 | diff --git a/mt7996/mcu.c b/mt7996/mcu.c |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 120 | index ffd3536..a3b66f1 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 121 | --- a/mt7996/mcu.c |
| 122 | +++ b/mt7996/mcu.c |
| 123 | @@ -372,12 +372,14 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb) |
| 124 | if (!mphy) |
| 125 | return; |
| 126 | |
| 127 | - if (r->band_idx == MT_RX_SEL2) |
| 128 | + if (r->band_idx == MT_RX_SEL2) { |
| 129 | + dev->bg_nxt_freq = 0; |
| 130 | cfg80211_background_radar_event(mphy->hw->wiphy, |
| 131 | &dev->rdd2_chandef, |
| 132 | GFP_ATOMIC); |
| 133 | - else |
| 134 | + } else { |
| 135 | ieee80211_radar_detected(mphy->hw); |
| 136 | + } |
| 137 | dev->hw_pattern++; |
| 138 | } |
| 139 | |
| 140 | diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 141 | index 7d6ec8b..fd93db2 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 142 | --- a/mt7996/mt7996.h |
| 143 | +++ b/mt7996/mt7996.h |
| 144 | @@ -399,6 +399,7 @@ struct mt7996_dev { |
| 145 | bool testmode_enable; |
| 146 | bool bin_file_mode; |
| 147 | u8 eeprom_mode; |
| 148 | + u32 bg_nxt_freq; |
| 149 | |
| 150 | bool ibf; |
| 151 | u8 fw_debug_wm; |
| 152 | -- |
developer | 9237f44 | 2024-06-14 17:13:04 +0800 | [diff] [blame] | 153 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 154 | |