blob: 8f6f8e08637bd795b6e30fe77b3bad086be8a73c [file] [log] [blame]
developer887da632022-10-28 09:35:38 +08001From 2e853a721466623df8fe208778afb48e7382b753 Mon Sep 17 00:00:00 2001
developere0cbe332022-09-10 17:36:02 +08002From: Sujuan Chen <sujuan.chen@mediatek.com>
3Date: Sat, 10 Sep 2022 17:09:21 +0800
developer887da632022-10-28 09:35:38 +08004Subject: [PATCH 3002/3010] mt76: mt7915: add-wed-tx-wds-support-on-mt7986
developere0cbe332022-09-10 17:36:02 +08005
6Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
developer887da632022-10-28 09:35:38 +08007Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
developere0cbe332022-09-10 17:36:02 +08008---
9 mac80211.c | 5 ++++-
10 mt76.h | 2 ++
11 mt7915/init.c | 9 +++++++++
developer515b0482022-10-11 14:09:57 +080012 mt7915/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
developere0cbe332022-09-10 17:36:02 +080013 mt7915/mcu.c | 12 ++++++++++--
14 mt7915/mcu.h | 1 +
developer203096a2022-09-13 21:07:19 +080015 mt7915/mmio.c | 3 +++
developere0cbe332022-09-10 17:36:02 +080016 mt7915/mt7915.h | 4 ++++
developer515b0482022-10-11 14:09:57 +080017 8 files changed, 76 insertions(+), 5 deletions(-)
developere0cbe332022-09-10 17:36:02 +080018
19diff --git a/mac80211.c b/mac80211.c
developer887da632022-10-28 09:35:38 +080020index b7c1b13..1e13b65 100644
developere0cbe332022-09-10 17:36:02 +080021--- a/mac80211.c
22+++ b/mac80211.c
developerc226de82022-10-03 12:24:57 +080023@@ -1364,7 +1364,10 @@ void __mt76_sta_remove(struct mt76_dev *dev, struct ieee80211_vif *vif,
developere0cbe332022-09-10 17:36:02 +080024
25 mt76_packet_id_flush(dev, wcid);
26
27- mt76_wcid_mask_clear(dev->wcid_mask, idx);
developerd31f89f2022-10-09 10:51:03 +080028+ if (dev->drv->wed_wds_check && dev->drv->wed_wds_check(dev, sta))
developere0cbe332022-09-10 17:36:02 +080029+ mt76_wcid_mask_clear(dev->wcid_wds_mask, idx);
30+ else
31+ mt76_wcid_mask_clear(dev->wcid_mask, idx);
32 mt76_wcid_mask_clear(dev->wcid_phy_mask, idx);
33 }
34 EXPORT_SYMBOL_GPL(__mt76_sta_remove);
35diff --git a/mt76.h b/mt76.h
developer887da632022-10-28 09:35:38 +080036index 93a81da..1888706 100644
developere0cbe332022-09-10 17:36:02 +080037--- a/mt76.h
38+++ b/mt76.h
developerc226de82022-10-03 12:24:57 +080039@@ -454,6 +454,7 @@ struct mt76_driver_ops {
developere0cbe332022-09-10 17:36:02 +080040
41 void (*sta_remove)(struct mt76_dev *dev, struct ieee80211_vif *vif,
42 struct ieee80211_sta *sta);
43+ bool (*wed_wds_check)(struct mt76_dev *dev, struct ieee80211_sta *sta);
44 };
45
46 struct mt76_channel_state {
developer887da632022-10-28 09:35:38 +080047@@ -822,6 +823,7 @@ struct mt76_dev {
developere0cbe332022-09-10 17:36:02 +080048 spinlock_t status_lock;
49
50 u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
51+ u32 wcid_wds_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
52 u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
53
54 u64 vif_mask;
55diff --git a/mt7915/init.c b/mt7915/init.c
developer887da632022-10-28 09:35:38 +080056index 6833bbf..8055c6e 100644
developere0cbe332022-09-10 17:36:02 +080057--- a/mt7915/init.c
58+++ b/mt7915/init.c
59@@ -695,6 +695,15 @@ mt7915_init_hardware(struct mt7915_dev *dev, struct mt7915_phy *phy2)
60 return ret;
61 }
62
63+ /* wds workaround for mt7986 */
64+ if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7986(&dev->mt76)) {
65+ for(idx = MT7915_WTBL_WDS_START; idx < MT7915_WTBL_WDS_END; idx++)
66+ mt76_wcid_mask_set(dev->mt76.wcid_mask, idx);
67+
68+ for (idx = 0; idx < DIV_ROUND_UP(MT7915_WTBL_STA, 32); idx++)
69+ dev->mt76.wcid_wds_mask[idx] = ~dev->mt76.wcid_mask[idx];
70+ }
71+
72 /* Beacon and mgmt frames should occupy wcid 0 */
73 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
74 if (idx)
75diff --git a/mt7915/main.c b/mt7915/main.c
developer887da632022-10-28 09:35:38 +080076index 4e91527..62b9658 100644
developere0cbe332022-09-10 17:36:02 +080077--- a/mt7915/main.c
78+++ b/mt7915/main.c
79@@ -658,6 +658,24 @@ mt7915_channel_switch_beacon(struct ieee80211_hw *hw,
80 mutex_unlock(&dev->mt76.mutex);
81 }
82
83+bool
84+mt7915_wed_wds_check(struct mt76_dev *mdev, struct ieee80211_sta *sta)
85+{
86+ struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
87+
88+ if (!mtk_wed_device_active(&mdev->mmio.wed))
89+ return false;
90+
91+ if(!is_mt7986(mdev))
92+ return false;
93+
94+ if((msta->wcid.idx < MT7915_WTBL_WDS_START ||
95+ msta->wcid.idx > MT7915_WTBL_WDS_END))
96+ return false;
97+
98+ return true;
99+}
100+
101 int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
102 struct ieee80211_sta *sta)
103 {
104@@ -670,8 +688,18 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
105 #endif
106 int ret, idx;
107 u32 addr;
108+ bool wed_wds = false;
developerc226de82022-10-03 12:24:57 +0800109+
developere0cbe332022-09-10 17:36:02 +0800110+ if (mtk_wed_device_active(&mdev->mmio.wed) && is_mt7986(mdev))
111+ wed_wds = !!test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
developerc226de82022-10-03 12:24:57 +0800112
113- idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7915_WTBL_STA);
developere0cbe332022-09-10 17:36:02 +0800114+ if (wed_wds)
115+ idx = mt76_wcid_alloc(mdev->wcid_wds_mask, MT7915_WTBL_STA);
116+ else {
117+ idx = mt76_wcid_alloc(mdev->wcid_mask, MT7915_WTBL_STA);
118+ if (idx < 0)
119+ idx = mt76_wcid_alloc(mdev->wcid_wds_mask, MT7915_WTBL_STA);
120+ }
121 if (idx < 0)
122 return -ENOSPC;
123
developer515b0482022-10-11 14:09:57 +0800124@@ -1125,6 +1153,15 @@ static void mt7915_sta_set_4addr(struct ieee80211_hw *hw,
developere0cbe332022-09-10 17:36:02 +0800125 else
126 clear_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags);
127
128+ if (mtk_wed_device_active(&dev->mt76.mmio.wed) &&
129+ is_mt7986(&dev->mt76) &&
130+ (msta->wcid.idx < MT7915_WTBL_WDS_START ||
131+ msta->wcid.idx > MT7915_WTBL_WDS_END)) {
132+ mt7915_sta_remove(hw, vif, sta);
developer515b0482022-10-11 14:09:57 +0800133+ mt76_sta_pre_rcu_remove(hw, vif, sta);
developere0cbe332022-09-10 17:36:02 +0800134+ mt7915_sta_add(hw, vif, sta);
135+ }
136+
137 mt76_connac_mcu_wtbl_update_hdr_trans(&dev->mt76, vif, sta);
138 }
139
developer515b0482022-10-11 14:09:57 +0800140@@ -1464,7 +1501,11 @@ mt7915_net_fill_forward_path(struct ieee80211_hw *hw,
developer203096a2022-09-13 21:07:19 +0800141 path->dev = ctx->dev;
142 path->mtk_wdma.wdma_idx = wed->wdma_idx;
143 path->mtk_wdma.bss = mvif->mt76.idx;
developerc226de82022-10-03 12:24:57 +0800144- path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff;
145+
146+ if (test_bit(MT_WCID_FLAG_4ADDR, &msta->wcid.flags))
developer203096a2022-09-13 21:07:19 +0800147+ path->mtk_wdma.wcid = msta->wcid.idx;
developerc226de82022-10-03 12:24:57 +0800148+ else
149+ path->mtk_wdma.wcid = is_mt7915(&dev->mt76) ? 0xff : 0x3ff;
developere0cbe332022-09-10 17:36:02 +0800150 path->mtk_wdma.queue = phy != &dev->phy;
151
152 ctx->dev = NULL;
153diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer887da632022-10-28 09:35:38 +0800154index d50482d..8f03a7d 100644
developere0cbe332022-09-10 17:36:02 +0800155--- a/mt7915/mcu.c
156+++ b/mt7915/mcu.c
developer20747c12022-09-16 14:09:40 +0800157@@ -2350,6 +2350,7 @@ mt7915_mcu_init_rx_airtime(struct mt7915_dev *dev)
developere0cbe332022-09-10 17:36:02 +0800158 int mt7915_run_firmware(struct mt7915_dev *dev)
159 {
160 int ret;
161+ struct mtk_wed_device *wed = &dev->mt76.mmio.wed;
162
163 /* force firmware operation mode into normal state,
164 * which should be set before firmware download stage.
developer20747c12022-09-16 14:09:40 +0800165@@ -2379,8 +2380,15 @@ int mt7915_run_firmware(struct mt7915_dev *dev)
developere0cbe332022-09-10 17:36:02 +0800166 if (ret)
167 return ret;
168
169- if (mtk_wed_device_active(&dev->mt76.mmio.wed) && is_mt7915(&dev->mt76))
170- mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY), 0, 0, 0);
171+ if (mtk_wed_device_active(wed)) {
172+ if (is_mt7915(&dev->mt76))
173+ mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(CAPABILITY),
174+ 0, 0, 0);
175+ else
176+ mt7915_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
177+ MCU_WA_PARAM_WED_VERSION,
178+ wed->rev_id, 0);
179+ }
180
181 ret = mt7915_mcu_set_mwds(dev, 1);
182 if (ret)
183diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developer887da632022-10-28 09:35:38 +0800184index 7738e96..cb95add 100644
developere0cbe332022-09-10 17:36:02 +0800185--- a/mt7915/mcu.h
186+++ b/mt7915/mcu.h
187@@ -268,6 +268,7 @@ enum {
188 MCU_WA_PARAM_RED_SHOW_STA = 0xf,
189 MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
190 #endif
191+ MCU_WA_PARAM_WED_VERSION = 0x32,
192 };
193
194 enum mcu_mmps_mode {
195diff --git a/mt7915/mmio.c b/mt7915/mmio.c
developer887da632022-10-28 09:35:38 +0800196index 5819281..84a47c9 100644
developere0cbe332022-09-10 17:36:02 +0800197--- a/mt7915/mmio.c
198+++ b/mt7915/mmio.c
developer515b0482022-10-11 14:09:57 +0800199@@ -596,6 +596,8 @@ int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr,
developerc226de82022-10-03 12:24:57 +0800200 wed->wlan.init_buf = mt7915_wed_init_buf;
201 wed->wlan.offload_enable = mt7915_mmio_wed_offload_enable;
202 wed->wlan.offload_disable = mt7915_mmio_wed_offload_disable;
developer203096a2022-09-13 21:07:19 +0800203+ if (!is_mt7915(mdev))
204+ wed->wlan.wcid_512 = true;
205
developerc226de82022-10-03 12:24:57 +0800206 if (mtk_wed_device_attach(wed))
developer203096a2022-09-13 21:07:19 +0800207 return 0;
developer515b0482022-10-11 14:09:57 +0800208@@ -810,6 +812,7 @@ struct mt7915_dev *mt7915_mmio_probe(struct device *pdev,
developere0cbe332022-09-10 17:36:02 +0800209 .sta_add = mt7915_mac_sta_add,
210 .sta_remove = mt7915_mac_sta_remove,
211 .update_survey = mt7915_update_channel,
212+ .wed_wds_check = mt7915_wed_wds_check,
213 };
214 struct mt7915_dev *dev;
215 struct mt76_dev *mdev;
216diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer887da632022-10-28 09:35:38 +0800217index c8e9c3b..a20d4b8 100644
developere0cbe332022-09-10 17:36:02 +0800218--- a/mt7915/mt7915.h
219+++ b/mt7915/mt7915.h
220@@ -18,6 +18,9 @@
221 #define MT7915_WTBL_STA (MT7915_WTBL_RESERVED - \
222 MT7915_MAX_INTERFACES)
223
224+#define MT7915_WTBL_WDS_START 256
225+#define MT7915_WTBL_WDS_END 271
226+
227 #define MT7915_WATCHDOG_TIME (HZ / 10)
228 #define MT7915_RESET_TIMEOUT (30 * HZ)
229
developer887da632022-10-28 09:35:38 +0800230@@ -697,6 +700,7 @@ void mt7915_tx_token_put(struct mt7915_dev *dev);
developere0cbe332022-09-10 17:36:02 +0800231 void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
232 struct sk_buff *skb);
233 bool mt7915_rx_check(struct mt76_dev *mdev, void *data, int len);
234+bool mt7915_wed_wds_check(struct mt76_dev *mdev, struct ieee80211_sta *sta);
235 void mt7915_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps);
236 void mt7915_stats_work(struct work_struct *work);
237 int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force);
238--
developer887da632022-10-28 09:35:38 +08002392.18.0
developere0cbe332022-09-10 17:36:02 +0800240