developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 1 | From 2f1191e48c32e21c71c78f25961bc54baf579656 Mon Sep 17 00:00:00 2001 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 2 | From: Sujuan Chen <sujuan.chen@mediatek.com> |
| 3 | Date: Sat, 10 Sep 2022 17:09:21 +0800 |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3002/3011] mt76: mt7915: add-wed-tx-wds-support-on-mt7986 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com> |
| 7 | --- |
| 8 | mac80211.c | 5 ++++- |
| 9 | mt76.h | 2 ++ |
| 10 | mt7915/init.c | 9 +++++++++ |
developer | caeb1a0 | 2022-10-12 18:25:15 +0800 | [diff] [blame] | 11 | mt7915/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 12 | mt7915/mcu.c | 12 ++++++++++-- |
| 13 | mt7915/mcu.h | 1 + |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 14 | mt7915/mmio.c | 3 +++ |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 15 | mt7915/mt7915.h | 4 ++++ |
developer | caeb1a0 | 2022-10-12 18:25:15 +0800 | [diff] [blame] | 16 | 8 files changed, 76 insertions(+), 5 deletions(-) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 17 | |
| 18 | diff --git a/mac80211.c b/mac80211.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 19 | index b378231c..c84c9ef0 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 20 | --- a/mac80211.c |
| 21 | +++ b/mac80211.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 22 | @@ -1363,7 +1363,10 @@ void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 23 | |
| 24 | mt76_packet_id_flush(dev, wcid); |
| 25 | |
| 26 | - mt76_wcid_mask_clear(dev->wcid_mask, idx); |
developer | caeb1a0 | 2022-10-12 18:25:15 +0800 | [diff] [blame] | 27 | + if (dev->drv->wed_wds_check && dev->drv->wed_wds_check(dev, sta)) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 28 | + mt76_wcid_mask_clear(dev->wcid_wds_mask, idx); |
| 29 | + else |
| 30 | + mt76_wcid_mask_clear(dev->wcid_mask, idx); |
| 31 | mt76_wcid_mask_clear(dev->wcid_phy_mask, idx); |
| 32 | } |
| 33 | EXPORT_SYMBOL_GPL(__mt76_sta_remove); |
| 34 | diff --git a/mt76.h b/mt76.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 35 | index e29f490e..b86c8355 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 36 | --- a/mt76.h |
| 37 | +++ b/mt76.h |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 38 | @@ -454,6 +454,7 @@ struct mt76_driver_ops { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 39 | |
| 40 | void (*sta_remove)(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 41 | struct ieee80211_sta *sta); |
| 42 | + bool (*wed_wds_check)(struct mt76_dev *dev, struct ieee80211_sta *sta); |
| 43 | }; |
| 44 | |
| 45 | struct mt76_channel_state { |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 46 | @@ -825,6 +826,7 @@ struct mt76_dev { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 47 | spinlock_t status_lock; |
| 48 | |
| 49 | u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; |
| 50 | + u32 wcid_wds_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; |
| 51 | u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)]; |
| 52 | |
| 53 | u64 vif_mask; |
| 54 | diff --git a/mt7915/init.c b/mt7915/init.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 55 | index 69465dd0..039a5b01 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 56 | --- a/mt7915/init.c |
| 57 | +++ b/mt7915/init.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 58 | @@ -719,6 +719,15 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 59 | return ret; |
| 60 | } |
| 61 | |
| 62 | + /* wds workaround for mt7986 */ |
| 63 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7986(&dev->mt76)) { |
| 64 | + for(idx = MT7915_WTBL_WDS_START; idx < MT7915_WTBL_WDS_END; idx++) |
| 65 | + mt76_wcid_mask_set(dev->mt76.wcid_mask, idx); |
| 66 | + |
| 67 | + for (idx = 0; idx < DIV_ROUND_UP(MT7915_WTBL_STA, 32); idx++) |
| 68 | + dev->mt76.wcid_wds_mask[idx] = ~dev->mt76.wcid_mask[idx]; |
| 69 | + } |
| 70 | + |
| 71 | /* Beacon and mgmt frames should occupy wcid 0 */ |
| 72 | idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); |
| 73 | if (idx) |
| 74 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 75 | index f9b2c1ef..c0617860 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 76 | --- a/mt7915/main.c |
| 77 | +++ b/mt7915/main.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 78 | @@ -660,6 +660,24 @@ mt7915_channel_switch_beacon(struct ieee80211_hw *hw, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 79 | mutex_unlock(&dev->mt76.mutex); |
| 80 | } |
| 81 | |
| 82 | +bool |
| 83 | +mt7915_wed_wds_check(struct mt76_dev *mdev, struct ieee80211_sta *sta) |
| 84 | +{ |
| 85 | + struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; |
| 86 | + |
| 87 | + if (!mtk_wed_device_active(&mdev->mmio.wed)) |
| 88 | + return false; |
| 89 | + |
| 90 | + if(!is_mt7986(mdev)) |
| 91 | + return false; |
| 92 | + |
| 93 | + if((msta->wcid.idx < MT7915_WTBL_WDS_START || |
| 94 | + msta->wcid.idx > MT7915_WTBL_WDS_END)) |
| 95 | + return false; |
| 96 | + |
| 97 | + return true; |
| 98 | +} |
| 99 | + |
| 100 | int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 101 | struct ieee80211_sta *sta) |
| 102 | { |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 103 | @@ -672,8 +690,18 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 104 | #endif |
| 105 | int ret, idx; |
| 106 | u32 addr; |
| 107 | + bool wed_wds = false; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 108 | + |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 109 | + if (mtk_wed_device_active(&mdev->mmio.wed) && is_mt7986(mdev)) |
| 110 | + wed_wds = !!test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 111 | |
| 112 | - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 113 | + if (wed_wds) |
| 114 | + idx = mt76_wcid_alloc(mdev->wcid_wds_mask, MT7915_WTBL_STA); |
| 115 | + else { |
| 116 | + idx = mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA); |
| 117 | + if (idx < 0) |
| 118 | + idx = mt76_wcid_alloc(mdev->wcid_wds_mask, MT7915_WTBL_STA); |
| 119 | + } |
| 120 | if (idx < 0) |
| 121 | return -ENOSPC; |
| 122 | |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 123 | @@ -1135,6 +1163,15 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 124 | else |
| 125 | clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 126 | |
| 127 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed) && |
| 128 | + is_mt7986(&dev->mt76) && |
| 129 | + (msta->wcid.idx < MT7915_WTBL_WDS_START || |
| 130 | + msta->wcid.idx > MT7915_WTBL_WDS_END)) { |
| 131 | + mt7915_sta_remove(hw, vif, sta); |
developer | caeb1a0 | 2022-10-12 18:25:15 +0800 | [diff] [blame] | 132 | + mt76_sta_pre_rcu_remove(hw, vif, sta); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 133 | + mt7915_sta_add(hw, vif, sta); |
| 134 | + } |
| 135 | + |
| 136 | mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); |
| 137 | } |
| 138 | |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 139 | @@ -1473,7 +1510,11 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw, |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 140 | path->dev = ctx->dev; |
| 141 | path->mtk_wdma.wdma_idx = wed->wdma_idx; |
| 142 | path->mtk_wdma.bss = mvif->mt76.idx; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 143 | - path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff; |
| 144 | + |
| 145 | + if (test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags)) |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 146 | + path->mtk_wdma.wcid = msta->wcid.idx; |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 147 | + else |
| 148 | + path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 149 | path->mtk_wdma.queue = phy != &dev->phy; |
| 150 | |
| 151 | ctx->dev = NULL; |
| 152 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 153 | index fad35595..eb9343ca 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 154 | --- a/mt7915/mcu.c |
| 155 | +++ b/mt7915/mcu.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 156 | @@ -2279,6 +2279,7 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev) |
| 157 | int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 158 | { |
| 159 | int ret; |
| 160 | + struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| 161 | |
| 162 | /* force firmware operation mode into normal state, |
| 163 | * which should be set before firmware download stage. |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 164 | @@ -2308,8 +2309,15 @@ int mt7915_mcu_init_firmware(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 165 | if (ret) |
| 166 | return ret; |
| 167 | |
| 168 | - if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(&dev->mt76)) |
| 169 | - mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0); |
| 170 | + if (mtk_wed_device_active(wed)) { |
| 171 | + if (is_mt7915(&dev->mt76)) |
| 172 | + mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), |
| 173 | + 0, 0, 0); |
| 174 | + else |
| 175 | + mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 176 | + MCU_WA_PARAM_WED_VERSION, |
| 177 | + wed->rev_id, 0); |
| 178 | + } |
| 179 | |
| 180 | ret = mt7915_mcu_set_mwds(dev, 1); |
| 181 | if (ret) |
| 182 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 183 | index b2e4032f..42d5e39f 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 184 | --- a/mt7915/mcu.h |
| 185 | +++ b/mt7915/mcu.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 186 | @@ -270,6 +270,7 @@ enum { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 187 | MCU_WA_PARAM_RED_SHOW_STA = 0xf, |
| 188 | MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
| 189 | #endif |
| 190 | + MCU_WA_PARAM_WED_VERSION = 0x32, |
| 191 | }; |
| 192 | |
| 193 | enum mcu_mmps_mode { |
| 194 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 195 | index f76f8967..e45cd2d5 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 196 | --- a/mt7915/mmio.c |
| 197 | +++ b/mt7915/mmio.c |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 198 | @@ -646,6 +646,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 199 | wed->wlan.init_buf = mt7915_wed_init_buf; |
| 200 | wed->wlan.offload_enable = mt7915_mmio_wed_offload_enable; |
| 201 | wed->wlan.offload_disable = mt7915_mmio_wed_offload_disable; |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 202 | + if (!is_mt7915(mdev)) |
| 203 | + wed->wlan.wcid_512 = true; |
| 204 | |
developer | f131310 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 205 | if (mtk_wed_device_attach(wed)) |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame] | 206 | return 0; |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 207 | @@ -860,6 +862,7 @@ struct mt7915_dev *mt7915_mmio_probe(struct device *pdev, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 208 | .sta_add = mt7915_mac_sta_add, |
| 209 | .sta_remove = mt7915_mac_sta_remove, |
| 210 | .update_survey = mt7915_update_channel, |
| 211 | + .wed_wds_check = mt7915_wed_wds_check, |
| 212 | }; |
| 213 | struct mt7915_dev *dev; |
| 214 | struct mt76_dev *mdev; |
| 215 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 216 | index 527ec9ea..ba12a2d2 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 217 | --- a/mt7915/mt7915.h |
| 218 | +++ b/mt7915/mt7915.h |
| 219 | @@ -18,6 +18,9 @@ |
| 220 | #define MT7915_WTBL_STA (MT7915_WTBL_RESERVED - \ |
| 221 | MT7915_MAX_INTERFACES) |
| 222 | |
| 223 | +#define MT7915_WTBL_WDS_START 256 |
| 224 | +#define MT7915_WTBL_WDS_END 271 |
| 225 | + |
| 226 | #define MT7915_WATCHDOG_TIME (HZ / 10) |
| 227 | #define MT7915_RESET_TIMEOUT (30 * HZ) |
| 228 | |
developer | 2cbf2fb | 2022-11-16 12:20:48 +0800 | [diff] [blame^] | 229 | @@ -718,6 +721,7 @@ void mt7915_tx_token_put(struct mt7915_dev *dev); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 230 | void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 231 | struct sk_buff *skb); |
| 232 | bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len); |
| 233 | +bool mt7915_wed_wds_check(struct mt76_dev *mdev, struct ieee80211_sta *sta); |
| 234 | void mt7915_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); |
| 235 | void mt7915_stats_work(struct work_struct *work); |
| 236 | int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force); |
| 237 | -- |
developer | b81e95d | 2022-11-08 10:16:29 +0800 | [diff] [blame] | 238 | 2.18.0 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 239 | |