developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 1 | From 33e8b84542a2d58af377c6e74eaeefbd7f29146c 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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3002/3007] 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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 11 | mt7915/main.c | 52 +++++++++++++++++++++++++++++++++++++++++++------ |
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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 16 | 8 files changed, 79 insertions(+), 9 deletions(-) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 17 | |
| 18 | diff --git a/mac80211.c b/mac80211.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 19 | index 4eaf317b..c477d625 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 20 | --- a/mac80211.c |
| 21 | +++ b/mac80211.c |
| 22 | @@ -1360,7 +1360,10 @@ void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif, |
| 23 | |
| 24 | mt76_packet_id_flush(dev, wcid); |
| 25 | |
| 26 | - mt76_wcid_mask_clear(dev->wcid_mask, idx); |
| 27 | + if (dev->drv->wed_wds_check(dev, sta)) |
| 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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 35 | index e997908a..ec9bd59d 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 36 | --- a/mt76.h |
| 37 | +++ b/mt76.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 38 | @@ -453,6 +453,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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 46 | @@ -826,6 +827,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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 55 | index 538ff5c3..cd9d846d 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 56 | --- a/mt7915/init.c |
| 57 | +++ b/mt7915/init.c |
| 58 | @@ -695,6 +695,15 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2) |
| 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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 75 | index 3a09f3f5..b1fb3ddf 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 76 | --- a/mt7915/main.c |
| 77 | +++ b/mt7915/main.c |
| 78 | @@ -658,6 +658,24 @@ mt7915_channel_switch_beacon(struct ieee80211_hw *hw, |
| 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 | { |
| 103 | @@ -670,8 +688,18 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif, |
| 104 | #endif |
| 105 | int ret, idx; |
| 106 | u32 addr; |
| 107 | + bool wed_wds = false; |
| 108 | |
| 109 | - idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA); |
| 110 | + if (mtk_wed_device_active(&mdev->mmio.wed) && is_mt7986(mdev)) |
| 111 | + wed_wds = !!test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags); |
| 112 | + |
| 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 | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 123 | @@ -1124,6 +1152,14 @@ 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); |
| 132 | + mt7915_sta_add(hw, vif, sta); |
| 133 | + } |
| 134 | + |
| 135 | mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta); |
| 136 | } |
| 137 | |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 138 | @@ -1463,12 +1499,16 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw, |
| 139 | path->dev = ctx->dev; |
| 140 | path->mtk_wdma.wdma_idx = wed->wdma_idx; |
| 141 | path->mtk_wdma.bss = mvif->mt76.idx; |
| 142 | - /* fw will find the wcid by dest addr */ |
| 143 | - if(is_mt7915(&dev->mt76)) |
| 144 | - path->mtk_wdma.wcid = 0xff; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 145 | - else |
| 146 | - path->mtk_wdma.wcid = 0x3ff; |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 147 | |
| 148 | + if (test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags)) { |
| 149 | + path->mtk_wdma.wcid = msta->wcid.idx; |
| 150 | + } else { |
| 151 | + /* fw will find the wcid by dest addr */ |
| 152 | + if(is_mt7915(&dev->mt76)) |
| 153 | + path->mtk_wdma.wcid = 0xff; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 154 | + else |
| 155 | + path->mtk_wdma.wcid = 0x3ff; |
| 156 | + } |
| 157 | path->mtk_wdma.queue = phy != &dev->phy; |
| 158 | |
| 159 | ctx->dev = NULL; |
| 160 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 161 | index f5caa326..21167f00 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 162 | --- a/mt7915/mcu.c |
| 163 | +++ b/mt7915/mcu.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 164 | @@ -2350,6 +2350,7 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 165 | int mt7915_run_firmware(struct mt7915_dev *dev) |
| 166 | { |
| 167 | int ret; |
| 168 | + struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
| 169 | |
| 170 | /* force firmware operation mode into normal state, |
| 171 | * which should be set before firmware download stage. |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 172 | @@ -2379,8 +2380,15 @@ int mt7915_run_firmware(struct mt7915_dev *dev) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 173 | if (ret) |
| 174 | return ret; |
| 175 | |
| 176 | - if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(&dev->mt76)) |
| 177 | - mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0); |
| 178 | + if (mtk_wed_device_active(wed)) { |
| 179 | + if (is_mt7915(&dev->mt76)) |
| 180 | + mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), |
| 181 | + 0, 0, 0); |
| 182 | + else |
| 183 | + mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 184 | + MCU_WA_PARAM_WED_VERSION, |
| 185 | + wed->rev_id, 0); |
| 186 | + } |
| 187 | |
| 188 | ret = mt7915_mcu_set_mwds(dev, 1); |
| 189 | if (ret) |
| 190 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 191 | index 9d0fac47..1f56db6b 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 192 | --- a/mt7915/mcu.h |
| 193 | +++ b/mt7915/mcu.h |
| 194 | @@ -268,6 +268,7 @@ enum { |
| 195 | MCU_WA_PARAM_RED_SHOW_STA = 0xf, |
| 196 | MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
| 197 | #endif |
| 198 | + MCU_WA_PARAM_WED_VERSION = 0x32, |
| 199 | }; |
| 200 | |
| 201 | enum mcu_mmps_mode { |
| 202 | diff --git a/mt7915/mmio.c b/mt7915/mmio.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 203 | index 11c90772..6df039a7 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 204 | --- a/mt7915/mmio.c |
| 205 | +++ b/mt7915/mmio.c |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 206 | @@ -736,6 +736,8 @@ mt7915_pci_wed_init(struct mt7915_dev *dev, struct device *pdev, int *irq) |
| 207 | /* disable dynamic tx token */ |
| 208 | wed->wlan.offload_enable = mt7915_wed_offload_enable; |
| 209 | wed->wlan.offload_disable = mt7915_wed_offload_disable; |
| 210 | + if (!is_mt7915(mdev)) |
| 211 | + wed->wlan.wcid_512 = true; |
| 212 | |
| 213 | if (mtk_wed_device_attach(wed) != 0) |
| 214 | return 0; |
| 215 | @@ -776,6 +778,7 @@ struct mt7915_dev *mt7915_mmio_probe(struct device *pdev, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 216 | .sta_add = mt7915_mac_sta_add, |
| 217 | .sta_remove = mt7915_mac_sta_remove, |
| 218 | .update_survey = mt7915_update_channel, |
| 219 | + .wed_wds_check = mt7915_wed_wds_check, |
| 220 | }; |
| 221 | struct mt7915_dev *dev; |
| 222 | struct mt76_dev *mdev; |
| 223 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 224 | index 1c78b882..486c203c 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 225 | --- a/mt7915/mt7915.h |
| 226 | +++ b/mt7915/mt7915.h |
| 227 | @@ -18,6 +18,9 @@ |
| 228 | #define MT7915_WTBL_STA (MT7915_WTBL_RESERVED - \ |
| 229 | MT7915_MAX_INTERFACES) |
| 230 | |
| 231 | +#define MT7915_WTBL_WDS_START 256 |
| 232 | +#define MT7915_WTBL_WDS_END 271 |
| 233 | + |
| 234 | #define MT7915_WATCHDOG_TIME (HZ / 10) |
| 235 | #define MT7915_RESET_TIMEOUT (30 * HZ) |
| 236 | |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 237 | @@ -697,6 +700,7 @@ void mt7915_tx_token_put(struct mt7915_dev *dev); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 238 | void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
| 239 | struct sk_buff *skb); |
| 240 | bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len); |
| 241 | +bool mt7915_wed_wds_check(struct mt76_dev *mdev, struct ieee80211_sta *sta); |
| 242 | void mt7915_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); |
| 243 | void mt7915_stats_work(struct work_struct *work); |
| 244 | int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force); |
| 245 | -- |
developer | 33907d4 | 2022-09-19 14:33:58 +0800 | [diff] [blame^] | 246 | 2.25.1 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 247 | |