blob: 3e626f4d66d5b6fee405d9f71fc159a9b9795b6c [file] [log] [blame]
developerd0c89452024-10-11 16:53:27 +08001From d55504a4ab7bd47bcc4c26859eda52302c4855a7 Mon Sep 17 00:00:00 2001
developer66e89bc2024-04-23 14:50:01 +08002From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Mon, 14 Aug 2023 13:36:58 +0800
developerd0c89452024-10-11 16:53:27 +08004Subject: [PATCH 037/223] mtk: mt76: mt7996: add cert patch
developer66e89bc2024-04-23 14:50:01 +08005
6This patch includes TGac and TGax
7
8Commit histroy:
9
10Add vendor cmd set ap wireless rts_sigta support
11
developer05f3b2b2024-08-19 19:17:34 +080012In Wi-Fi 7 UCC, there are a command without a specified interface,
13causing the AP to send trigger frames on only one link. When testing
14EMLSR+OFDMA test cases (EHT-4.45.1), this results in the AP sending
15trigger frames on only one link, leading to test failure.
16Therefore, the band_bitmap is corrected to ensure that trigger frames are sent on all links.
17
18The UCC command specifies an interface:
19ap_set_rfeature,NAME,Wi-Fi7APUT,Interface,5G,type,EHT,TriggerType,0,
20Trigger_Variant,HE,PPDUTxType,legacy
21
22The UCC command does not specify an interface:
23ap_set_rfeature,NAME,Wi-Fi7APUT,type,EHT,TriggerType,0,Trigger_Variant,
24EHT,PPDUTxType,legacy
25
26Logan set the band_bitmap to 7 in Wi-Fi 7 regardless of whether the UCC
27command specifies an interface.
28
developerd0c89452024-10-11 16:53:27 +080029Change-Id: I9c2a04efa733a6de5c37a21ea71d9715edc27ddb
developer66e89bc2024-04-23 14:50:01 +080030Signed-off-by: ye he <ye.he@mediatek.com>
developer05f3b2b2024-08-19 19:17:34 +080031Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
developer66e89bc2024-04-23 14:50:01 +080032---
33 mt7996/mac.c | 9 ++
34 mt7996/main.c | 31 ++++++-
35 mt7996/mcu.c | 40 +++++++++
36 mt7996/mcu.h | 6 ++
37 mt7996/mt7996.h | 13 +++
developer05f3b2b2024-08-19 19:17:34 +080038 mt7996/mtk_mcu.c | 206 ++++++++++++++++++++++++++++++++++++++++++
developer66e89bc2024-04-23 14:50:01 +080039 mt7996/mtk_mcu.h | 184 +++++++++++++++++++++++++++++++++++--
40 mt7996/vendor.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++-
41 mt7996/vendor.h | 67 ++++++++++++++
developer05f3b2b2024-08-19 19:17:34 +080042 9 files changed, 779 insertions(+), 7 deletions(-)
developer66e89bc2024-04-23 14:50:01 +080043
44diff --git a/mt7996/mac.c b/mt7996/mac.c
developerd0c89452024-10-11 16:53:27 +080045index 2ce9e839..484f91aa 100644
developer66e89bc2024-04-23 14:50:01 +080046--- a/mt7996/mac.c
47+++ b/mt7996/mac.c
48@@ -10,6 +10,7 @@
49 #include "../dma.h"
50 #include "mac.h"
51 #include "mcu.h"
52+#include "vendor.h"
53
54 #define to_rssi(field, rcpi) ((FIELD_GET(field, rcpi) - 220) / 2)
55
developerd0c89452024-10-11 16:53:27 +080056@@ -2296,6 +2297,14 @@ void mt7996_mac_update_stats(struct mt7996_phy *phy)
developer66e89bc2024-04-23 14:50:01 +080057 }
58 }
59
60+void mt7996_set_wireless_amsdu(struct ieee80211_hw *hw, u8 en)
61+{
62+ if (en)
63+ ieee80211_hw_set(hw, SUPPORTS_AMSDU_IN_AMPDU);
64+ else
65+ ieee80211_hw_clear(hw, SUPPORTS_AMSDU_IN_AMPDU);
66+}
67+
68 void mt7996_mac_sta_rc_work(struct work_struct *work)
69 {
70 struct mt7996_dev *dev = container_of(work, struct mt7996_dev, rc_work);
71diff --git a/mt7996/main.c b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080072index 6203e800..dc00cc2f 100644
developer66e89bc2024-04-23 14:50:01 +080073--- a/mt7996/main.c
74+++ b/mt7996/main.c
developerd0c89452024-10-11 16:53:27 +080075@@ -602,6 +602,7 @@ mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +080076 bool beacon, bool mcast)
77 {
78 struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
79+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
80 struct mt76_phy *mphy = hw->priv;
81 u16 rate;
82 u8 i, idx;
developerd0c89452024-10-11 16:53:27 +080083@@ -611,6 +612,9 @@ mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +080084 if (beacon) {
85 struct mt7996_phy *phy = mphy->priv;
86
87+ if (dev->cert_mode && phy->mt76->band_idx == MT_BAND2)
88+ rate = 0x0200;
89+
90 /* odd index for driver, even index for firmware */
91 idx = MT7996_BEACON_RATES_TBL + 2 * phy->mt76->band_idx;
92 if (phy->beacon_rate != rate)
developerd0c89452024-10-11 16:53:27 +080093@@ -738,6 +742,10 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +080094 u8 band_idx = mvif->phy->mt76->band_idx;
95 int ret, idx;
96
97+#ifdef CONFIG_MTK_VENDOR
98+ struct mt7996_phy *phy = &dev->phy;
99+#endif
100+
101 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
102 if (idx < 0)
103 return -ENOSPC;
developerd0c89452024-10-11 16:53:27 +0800104@@ -763,7 +771,28 @@ int mt7996_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developer66e89bc2024-04-23 14:50:01 +0800105 if (ret)
106 return ret;
107
108- return mt7996_mcu_add_rate_ctrl(dev, vif, sta, false);
109+ ret = mt7996_mcu_add_rate_ctrl(dev, vif, sta, false);
110+ if (ret)
111+ return ret;
112+
113+#ifdef CONFIG_MTK_VENDOR
114+ switch (band_idx) {
115+ case MT_BAND1:
116+ phy = mt7996_phy2(dev);
117+ break;
118+ case MT_BAND2:
119+ phy = mt7996_phy3(dev);
120+ break;
121+ case MT_BAND0:
122+ default:
123+ break;
124+ }
125+
126+ if (phy && phy->muru_onoff & MUMIMO_DL_CERT)
127+ mt7996_mcu_set_mimo(phy);
128+#endif
129+
130+ return 0;
131 }
132
133 void mt7996_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
134diff --git a/mt7996/mcu.c b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800135index baf71b0a..bfedfa3a 100644
developer66e89bc2024-04-23 14:50:01 +0800136--- a/mt7996/mcu.c
137+++ b/mt7996/mcu.c
developerd0c89452024-10-11 16:53:27 +0800138@@ -1362,6 +1362,10 @@ mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
developer66e89bc2024-04-23 14:50:01 +0800139 {
140 struct sta_rec_vht *vht;
141 struct tlv *tlv;
142+#ifdef CONFIG_MTK_VENDOR
143+ struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
144+ struct mt7996_phy *phy = (struct mt7996_phy *)msta->vif->phy;
145+#endif
146
147 /* For 6G band, this tlv is necessary to let hw work normally */
148 if (!sta->deflink.he_6ghz_capa.capa && !sta->deflink.vht_cap.vht_supported)
developerd0c89452024-10-11 16:53:27 +0800149@@ -1373,6 +1377,9 @@ mt7996_mcu_sta_vht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta)
developer66e89bc2024-04-23 14:50:01 +0800150 vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap);
151 vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map;
152 vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map;
153+#ifdef CONFIG_MTK_VENDOR
154+ vht->rts_bw_sig = phy->rts_bw_sig;
155+#endif
156 }
157
158 static void
developerd0c89452024-10-11 16:53:27 +0800159@@ -4476,6 +4483,27 @@ int mt7996_mcu_set_rts_thresh(struct mt7996_phy *phy, u32 val)
developer66e89bc2024-04-23 14:50:01 +0800160 &req, sizeof(req), true);
161 }
162
163+int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable)
164+{
165+ struct {
166+ u8 band_idx;
167+ u8 _rsv[3];
168+
169+ __le16 tag;
170+ __le16 len;
171+ bool enable;
172+ u8 _rsv2[3];
173+ } __packed req = {
174+ .band_idx = phy->mt76->band_idx,
175+ .tag = cpu_to_le16(option),
176+ .len = cpu_to_le16(sizeof(req) - 4),
177+ .enable = enable,
178+ };
179+
180+ return mt76_mcu_send_msg(&phy->dev->mt76, MCU_WM_UNI_CMD(BAND_CONFIG),
181+ &req, sizeof(req), true);
182+}
183+
184 int mt7996_mcu_set_radio_en(struct mt7996_phy *phy, bool enable)
185 {
186 struct {
developerd0c89452024-10-11 16:53:27 +0800187@@ -5043,6 +5071,18 @@ void mt7996_set_wireless_vif(void *data, u8 *mac, struct ieee80211_vif *vif)
developer66e89bc2024-04-23 14:50:01 +0800188 val = FIELD_GET(RATE_CFG_VAL, *((u32 *)data));
189
190 switch (mode) {
191+ case RATE_PARAM_FIXED_OFDMA:
192+ if (val == 3)
developer05f3b2b2024-08-19 19:17:34 +0800193+ phy->muru_onoff |= OFDMA_DL;
developer66e89bc2024-04-23 14:50:01 +0800194+ else
developer05f3b2b2024-08-19 19:17:34 +0800195+ phy->muru_onoff |= val;
developer66e89bc2024-04-23 14:50:01 +0800196+ break;
197+ case RATE_PARAM_FIXED_MIMO:
198+ if (val == 0)
developer05f3b2b2024-08-19 19:17:34 +0800199+ phy->muru_onoff |= MUMIMO_DL_CERT | MUMIMO_DL;
developer66e89bc2024-04-23 14:50:01 +0800200+ else
developer05f3b2b2024-08-19 19:17:34 +0800201+ phy->muru_onoff |= MUMIMO_UL;
developer66e89bc2024-04-23 14:50:01 +0800202+ break;
203 case RATE_PARAM_AUTO_MU:
204 if (val < 0 || val > 15) {
205 printk("Wrong value! The value is between 0-15.\n");
206diff --git a/mt7996/mcu.h b/mt7996/mcu.h
developer05f3b2b2024-08-19 19:17:34 +0800207index a98b174e..2546354e 100644
developer66e89bc2024-04-23 14:50:01 +0800208--- a/mt7996/mcu.h
209+++ b/mt7996/mcu.h
210@@ -755,6 +755,8 @@ enum {
211 RATE_PARAM_FIXED_GI = 11,
212 RATE_PARAM_AUTO = 20,
213 #ifdef CONFIG_MTK_VENDOR
214+ RATE_PARAM_FIXED_MIMO = 30,
215+ RATE_PARAM_FIXED_OFDMA = 31,
216 RATE_PARAM_AUTO_MU = 32,
217 #endif
218 };
219@@ -767,6 +769,7 @@ enum {
220 #define OFDMA_UL BIT(1)
221 #define MUMIMO_DL BIT(2)
222 #define MUMIMO_UL BIT(3)
223+#define MUMIMO_DL_CERT BIT(4)
224
225 enum {
226 BF_SOUNDING_ON = 1,
227@@ -853,11 +856,14 @@ enum {
228 UNI_BAND_CONFIG_EDCCA_ENABLE = 0x05,
229 UNI_BAND_CONFIG_EDCCA_THRESHOLD = 0x06,
230 UNI_BAND_CONFIG_RTS_THRESHOLD = 0x08,
231+ UNI_BAND_CONFIG_RTS_SIGTA_EN = 0x09,
232+ UNI_BAND_CONFIG_DIS_SECCH_CCA_DET = 0x0a,
233 };
234
235 enum {
236 UNI_WSYS_CONFIG_FW_LOG_CTRL,
237 UNI_WSYS_CONFIG_FW_DBG_CTRL,
238+ UNI_CMD_CERT_CFG = 6,
239 };
240
241 enum {
242diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800243index ed998c0e..a81e275d 100644
developer66e89bc2024-04-23 14:50:01 +0800244--- a/mt7996/mt7996.h
245+++ b/mt7996/mt7996.h
developerd0c89452024-10-11 16:53:27 +0800246@@ -363,6 +363,7 @@ struct mt7996_phy {
developer66e89bc2024-04-23 14:50:01 +0800247 } test;
248 #endif
249 #ifdef CONFIG_MTK_VENDOR
250+ u8 rts_bw_sig;
251 spinlock_t amnt_lock;
252 struct mt7996_air_monitor_ctrl amnt_ctrl;
253 #endif
developerd0c89452024-10-11 16:53:27 +0800254@@ -495,6 +496,9 @@ struct mt7996_dev {
developer66e89bc2024-04-23 14:50:01 +0800255 } dbg;
256 const struct mt7996_dbg_reg_desc *dbg_reg;
257 #endif
258+#ifdef CONFIG_MTK_VENDOR
259+ bool cert_mode;
260+#endif
261 };
262
263 enum {
developerd0c89452024-10-11 16:53:27 +0800264@@ -710,6 +714,7 @@ void mt7996_tm_rf_test_event(struct mt7996_dev *dev, struct sk_buff *skb);
developer66e89bc2024-04-23 14:50:01 +0800265 int mt7996_mcu_get_tx_power_info(struct mt7996_phy *phy, u8 category, void *event);
266 int mt7996_mcu_set_scs(struct mt7996_phy *phy, u8 enable);
267 void mt7996_mcu_scs_sta_poll(struct work_struct *work);
268+int mt7996_mcu_set_band_confg(struct mt7996_phy *phy, u16 option, bool enable);
269
270 static inline u8 mt7996_max_interface_num(struct mt7996_dev *dev)
271 {
developerd0c89452024-10-11 16:53:27 +0800272@@ -828,6 +833,10 @@ void mt7996_vendor_register(struct mt7996_phy *phy);
developer66e89bc2024-04-23 14:50:01 +0800273 void mt7996_vendor_amnt_fill_rx(struct mt7996_phy *phy, struct sk_buff *skb);
274 int mt7996_vendor_amnt_sta_remove(struct mt7996_phy *phy,
275 struct ieee80211_sta *sta);
276+void mt7996_set_wireless_amsdu(struct ieee80211_hw *hw, u8 en);
277+void mt7996_mcu_set_mimo(struct mt7996_phy *phy);
278+int mt7996_set_muru_cfg(struct mt7996_phy *phy, u8 action, u8 val);
279+int mt7996_mcu_set_muru_cfg(struct mt7996_phy *phy, void *data);
280 #endif
281
282 int mt7996_mcu_edcca_enable(struct mt7996_phy *phy, bool enable);
developerd0c89452024-10-11 16:53:27 +0800283@@ -855,6 +864,10 @@ int mt7996_mcu_set_txbf_snd_info(struct mt7996_phy *phy, void *para);
developer66e89bc2024-04-23 14:50:01 +0800284 int mt7996_mcu_set_muru_cmd(struct mt7996_dev *dev, u16 action, int val);
285 int mt7996_mcu_muru_set_prot_frame_thr(struct mt7996_dev *dev, u32 val);
286 int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val);
287+int mt7996_mcu_set_rfeature_trig_type(struct mt7996_phy *phy, u8 enable, u8 trig_type);
288+void mt7996_mcu_set_ppdu_tx_type(struct mt7996_phy *phy, u8 ppdu_type);
289+void mt7996_mcu_set_nusers_ofdma(struct mt7996_phy *phy, u8 type, u8 ofdma_user_cnt);
290+void mt7996_mcu_set_cert(struct mt7996_phy *phy, u8 type);
291 #endif
292
293 #ifdef CONFIG_NET_MEDIATEK_SOC_WED
294diff --git a/mt7996/mtk_mcu.c b/mt7996/mtk_mcu.c
developer05f3b2b2024-08-19 19:17:34 +0800295index 68650623..30da79f4 100644
developer66e89bc2024-04-23 14:50:01 +0800296--- a/mt7996/mtk_mcu.c
297+++ b/mt7996/mtk_mcu.c
developer05f3b2b2024-08-19 19:17:34 +0800298@@ -982,4 +982,210 @@ int mt7996_mcu_set_bypass_smthint(struct mt7996_phy *phy, u8 val)
developer66e89bc2024-04-23 14:50:01 +0800299 true);
300 }
301
302+int mt7996_mcu_set_bsrp_ctrl(struct mt7996_phy *phy, u16 interval,
303+ u16 ru_alloc, u32 trig_type, u8 trig_flow, u8 ext_cmd)
304+{
305+ struct mt7996_dev *dev = phy->dev;
306+ struct {
307+ u8 _rsv[4];
308+
309+ __le16 tag;
310+ __le16 len;
311+
312+ __le16 interval;
313+ __le16 ru_alloc;
314+ __le32 trigger_type;
315+ u8 trigger_flow;
316+ u8 ext_cmd_bsrp;
317+ u8 band_bitmap;
318+ u8 _rsv2;
319+ } __packed req = {
320+ .tag = cpu_to_le16(UNI_CMD_MURU_BSRP_CTRL),
321+ .len = cpu_to_le16(sizeof(req) - 4),
322+ .interval = cpu_to_le16(interval),
323+ .ru_alloc = cpu_to_le16(ru_alloc),
324+ .trigger_type = cpu_to_le32(trig_type),
325+ .trigger_flow = trig_flow,
326+ .ext_cmd_bsrp = ext_cmd,
developer05f3b2b2024-08-19 19:17:34 +0800327+ .band_bitmap = mt7996_band_valid(dev, MT_BAND2) ?
328+ GENMASK(2, 0) : GENMASK(1, 0),
developer66e89bc2024-04-23 14:50:01 +0800329+ };
330+
331+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &req,
332+ sizeof(req), false);
333+}
334+
335+int mt7996_mcu_set_rfeature_trig_type(struct mt7996_phy *phy, u8 enable, u8 trig_type)
336+{
337+ struct mt7996_dev *dev = phy->dev;
338+ int ret = 0;
339+ char buf[] = "01:00:00:1B";
340+
341+ if (enable) {
342+ ret = mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_TRIG_TYPE, trig_type);
343+ if (ret)
344+ return ret;
345+ }
346+
347+ switch (trig_type) {
348+ case CAPI_BASIC:
349+ return mt7996_mcu_set_bsrp_ctrl(phy, 5, 67, 0, 0, enable);
350+ case CAPI_BRP:
351+ return mt7996_mcu_set_txbf_snd_info(phy, buf);
352+ case CAPI_MU_BAR:
353+ return mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_MUDL_ACK_POLICY,
354+ MU_DL_ACK_POLICY_MU_BAR);
355+ case CAPI_BSRP:
356+ return mt7996_mcu_set_bsrp_ctrl(phy, 5, 67, 4, 0, enable);
357+ default:
358+ return 0;
359+ }
360+}
361+
362+int mt7996_mcu_set_muru_cfg(struct mt7996_phy *phy, void *data)
363+{
364+ struct mt7996_dev *dev = phy->dev;
365+ struct mt7996_muru *muru;
366+ struct {
367+ u8 _rsv[4];
368+
369+ __le16 tag;
370+ __le16 len;
371+
372+ u8 version;
373+ u8 revision;
374+ u8 _rsv2[2];
375+
376+ struct mt7996_muru muru;
377+ } __packed req = {
378+ .tag = cpu_to_le16(UNI_CMD_MURU_MUNUAL_CONFIG),
379+ .len = cpu_to_le16(sizeof(req) - 4),
380+ .version = UNI_CMD_MURU_VER_EHT,
381+ };
382+
383+ muru = (struct mt7996_muru *) data;
384+ memcpy(&req.muru, muru, sizeof(struct mt7996_muru));
385+
386+ return mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(MURU), &req,
387+ sizeof(req), false);
388+}
389+
390+int mt7996_set_muru_cfg(struct mt7996_phy *phy, u8 action, u8 val)
391+{
392+ struct mt7996_muru *muru;
393+ struct mt7996_muru_dl *dl;
394+ struct mt7996_muru_ul *ul;
395+ struct mt7996_muru_comm *comm;
396+ int ret = 0;
397+
398+ muru = kzalloc(sizeof(struct mt7996_muru), GFP_KERNEL);
399+ dl = &muru->dl;
400+ ul = &muru->ul;
401+ comm = &muru->comm;
402+
403+ switch (action) {
404+ case MU_CTRL_DL_USER_CNT:
405+ dl->user_num = val;
406+ comm->ppdu_format = MURU_PPDU_HE_MU;
407+ comm->sch_type = MURU_OFDMA_SCH_TYPE_DL;
408+ muru->cfg_comm = cpu_to_le32(MURU_COMM_SET);
409+ muru->cfg_dl = cpu_to_le32(MURU_FIXED_DL_TOTAL_USER_CNT);
410+ ret = mt7996_mcu_set_muru_cfg(phy, muru);
411+ break;
412+ case MU_CTRL_UL_USER_CNT:
413+ ul->user_num = val;
414+ comm->ppdu_format = MURU_PPDU_HE_TRIG;
415+ comm->sch_type = MURU_OFDMA_SCH_TYPE_UL;
416+ muru->cfg_comm = cpu_to_le32(MURU_COMM_SET);
417+ muru->cfg_ul = cpu_to_le32(MURU_FIXED_UL_TOTAL_USER_CNT);
418+ ret = mt7996_mcu_set_muru_cfg(phy, muru);
419+ break;
420+ default:
421+ break;
422+ }
423+
424+ kfree(muru);
425+ return ret;
426+}
427+
428+void mt7996_mcu_set_ppdu_tx_type(struct mt7996_phy *phy, u8 ppdu_type)
429+{
430+ struct mt7996_dev *dev = phy->dev;
431+ int enable_su;
432+
433+ switch (ppdu_type) {
434+ case CAPI_SU:
435+ enable_su = 1;
436+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SUTX_CTRL, enable_su);
437+ mt7996_set_muru_cfg(phy, MU_CTRL_DL_USER_CNT, 0);
438+ break;
439+ case CAPI_MU:
440+ enable_su = 0;
441+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SUTX_CTRL, enable_su);
442+ break;
443+ default:
444+ break;
445+ }
446+}
447+
448+void mt7996_mcu_set_nusers_ofdma(struct mt7996_phy *phy, u8 type, u8 user_cnt)
449+{
450+ struct mt7996_dev *dev = phy->dev;
451+ int enable_su = 0;
452+
453+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SUTX_CTRL, enable_su);
454+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_MUDL_ACK_POLICY, MU_DL_ACK_POLICY_SU_BAR);
455+ mt7996_mcu_muru_set_prot_frame_thr(dev, 9999);
456+
457+ mt7996_set_muru_cfg(phy, type, user_cnt);
458+}
459+
460+void mt7996_mcu_set_mimo(struct mt7996_phy *phy)
461+{
462+ struct mt7996_dev *dev = phy->dev;
463+ struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
464+ int disable_ra = 1;
465+ char buf[] = "2 134 0 1 0 1 2 2 2";
466+ int force_mu = 1;
467+
468+ switch (chandef->width) {
469+ case NL80211_CHAN_WIDTH_20_NOHT:
470+ case NL80211_CHAN_WIDTH_20:
471+ strscpy(buf, "2 122 0 1 0 1 2 2 2", sizeof(buf));
472+ break;
473+ case NL80211_CHAN_WIDTH_80:
474+ break;
475+ case NL80211_CHAN_WIDTH_160:
476+ strscpy(buf, "2 137 0 1 0 1 2 2 2", sizeof(buf));
477+ break;
478+ default:
479+ break;
480+ }
481+
482+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_MUDL_ACK_POLICY, MU_DL_ACK_POLICY_SU_BAR);
483+ mt7996_mcu_set_muru_fixed_rate_enable(dev, UNI_CMD_MURU_FIXED_RATE_CTRL, disable_ra);
484+ mt7996_mcu_set_muru_fixed_rate_parameter(dev, UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL, buf);
485+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_FORCE_MU, force_mu);
486+}
487+
488+void mt7996_mcu_set_cert(struct mt7996_phy *phy, u8 type)
489+{
490+ struct mt7996_dev *dev = phy->dev;
491+ struct {
492+ u8 _rsv[4];
493+
494+ __le16 tag;
495+ __le16 len;
496+ u8 action;
497+ u8 _rsv2[3];
498+ } __packed req = {
499+ .tag = cpu_to_le16(UNI_CMD_CERT_CFG),
500+ .len = cpu_to_le16(sizeof(req) - 4),
501+ .action = type, /* 1: CAPI Enable */
502+ };
503+
504+ mt76_mcu_send_msg(&dev->mt76, MCU_WM_UNI_CMD(WSYS_CONFIG), &req,
505+ sizeof(req), false);
506+}
507+
508 #endif
509diff --git a/mt7996/mtk_mcu.h b/mt7996/mtk_mcu.h
developer05f3b2b2024-08-19 19:17:34 +0800510index d9686ebb..7a4140b5 100644
developer66e89bc2024-04-23 14:50:01 +0800511--- a/mt7996/mtk_mcu.h
512+++ b/mt7996/mtk_mcu.h
513@@ -122,14 +122,15 @@ enum {
514 };
515
516 enum {
517+ UNI_CMD_MURU_BSRP_CTRL = 0x01,
518 UNI_CMD_MURU_SUTX_CTRL = 0x10,
519- UNI_CMD_MURU_FIXED_RATE_CTRL,
520- UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL,
521+ UNI_CMD_MURU_FIXED_RATE_CTRL = 0x11,
522+ UNI_CMD_MURU_FIXED_GROUP_RATE_CTRL = 0x12,
523 UNI_CMD_MURU_SET_FORCE_MU = 0x33,
524 UNI_CMD_MURU_MUNUAL_CONFIG = 0x64,
525- UNI_CMD_MURU_SET_MUDL_ACK_POLICY = 0xC9,
526- UNI_CMD_MURU_SET_TRIG_TYPE,
527- UNI_CMD_MURU_SET_20M_DYN_ALGO,
528+ UNI_CMD_MURU_SET_MUDL_ACK_POLICY = 0xC8,
529+ UNI_CMD_MURU_SET_TRIG_TYPE = 0xC9,
530+ UNI_CMD_MURU_SET_20M_DYN_ALGO = 0xCA,
531 UNI_CMD_MURU_PROT_FRAME_THR = 0xCC,
532 UNI_CMD_MURU_SET_CERT_MU_EDCA_OVERRIDE,
533 };
534@@ -533,6 +534,179 @@ struct mt7996_mcu_sr_hw_ind_event {
535 __le32 sr_ampdu_mpdu_cnt;
536 __le32 sr_ampdu_mpdu_acked_cnt;
537 };
538+
539+struct mt7996_muru_comm {
540+ u8 pda_pol;
541+ u8 band;
542+ u8 spe_idx;
543+ u8 proc_type;
544+
545+ __le16 mlo_ctrl;
546+ u8 sch_type;
547+ u8 ppdu_format;
548+ u8 ac;
549+ u8 _rsv[3];
550+};
551+
552+struct mt7996_muru_dl {
553+ u8 user_num;
554+ u8 tx_mode;
555+ u8 bw;
556+ u8 gi;
557+
558+ u8 ltf;
559+ u8 mcs;
560+ u8 dcm;
561+ u8 cmprs;
562+
563+ __le16 ru[16];
564+
565+ u8 c26[2];
566+ u8 ack_policy;
567+ u8 tx_power;
568+
569+ __le16 mu_ppdu_duration;
570+ u8 agc_disp_order;
571+ u8 _rsv1;
572+
573+ u8 agc_disp_pol;
574+ u8 agc_disp_ratio;
575+ __le16 agc_disp_linkMFG;
576+
577+ __le16 prmbl_punc_bmp;
578+ u8 _rsv2[2];
579+
580+ struct {
581+ __le16 wlan_idx;
582+ u8 ru_alloc_seg;
583+ u8 ru_idx;
584+ u8 ldpc;
585+ u8 nss;
586+ u8 mcs;
587+ u8 mu_group_idx;
588+ u8 vht_groud_id;
589+ u8 vht_up;
590+ u8 he_start_stream;
591+ u8 he_mu_spatial;
592+ __le16 tx_power_alpha;
593+ u8 ack_policy;
594+ u8 ru_allo_ps160;
595+ } usr[16];
596+};
597+
598+struct mt7996_muru_ul {
599+ u8 user_num;
600+ u8 tx_mode;
601+
602+ u8 ba_type;
603+ u8 _rsv;
604+
605+ u8 bw;
606+ u8 gi_ltf;
607+ __le16 ul_len;
608+
609+ __le16 trig_cnt;
610+ u8 pad;
611+ u8 trig_type;
612+
613+ __le16 trig_intv;
614+ u8 trig_ta[ETH_ALEN];
615+ __le16 ul_ru[16];
616+
617+ u8 c26[2];
618+ __le16 agc_disp_linkMFG;
619+
620+ u8 agc_disp_mu_len;
621+ u8 agc_disp_pol;
622+ u8 agc_disp_ratio;
623+ u8 agc_disp_pu_idx;
624+
625+ struct {
626+ __le16 wlan_idx;
627+ u8 ru_alloc_seg;
628+ u8 ru_idx;
629+ u8 ldpc;
630+ u8 nss;
631+ u8 mcs;
632+ u8 target_rssi;
633+ __le32 trig_pkt_size;
634+ u8 ru_allo_ps160;
635+ u8 _rsv2[3];
636+ } usr[16];
637+};
638+
639+struct mt7996_muru_dbg {
640+ /* HE TB RX Debug */
641+ __le32 rx_hetb_nonsf_en_bitmap;
642+ __le32 rx_hetb_cfg[2];
643+};
644+
645+struct mt7996_muru {
646+ __le32 cfg_comm;
647+ __le32 cfg_dl;
648+ __le32 cfg_ul;
649+ __le32 cfg_dbg;
650+
651+ struct mt7996_muru_comm comm;
652+ struct mt7996_muru_dl dl;
653+ struct mt7996_muru_ul ul;
654+ struct mt7996_muru_dbg dbg;
655+};
656+
657+
658+#define MURU_PPDU_HE_TRIG BIT(2)
659+#define MURU_PPDU_HE_MU BIT(3)
660+
661+#define MURU_OFDMA_SCH_TYPE_DL BIT(0)
662+#define MURU_OFDMA_SCH_TYPE_UL BIT(1)
663+
664+/* Common Config */
665+#define MURU_COMM_PPDU_FMT BIT(0)
666+#define MURU_COMM_SCH_TYPE BIT(1)
667+#define MURU_COMM_BAND BIT(2)
668+#define MURU_COMM_WMM BIT(3)
669+#define MURU_COMM_SPE_IDX BIT(4)
670+#define MURU_COMM_PROC_TYPE BIT(5)
671+#define MURU_COMM_SET (MURU_COMM_PPDU_FMT | MURU_COMM_SCH_TYPE)
672+#define MURU_COMM_SET_TM (MURU_COMM_PPDU_FMT | MURU_COMM_BAND | \
673+ MURU_COMM_WMM | MURU_COMM_SPE_IDX)
674+
675+/* DL Common config */
676+#define MURU_FIXED_DL_TOTAL_USER_CNT BIT(4)
677+
678+/* UL Common Config */
679+#define MURU_FIXED_UL_TOTAL_USER_CNT BIT(4)
680+
681+enum {
682+ CAPI_SU,
683+ CAPI_MU,
684+ CAPI_ER_SU,
685+ CAPI_TB,
686+ CAPI_LEGACY
687+};
688+
689+enum {
690+ CAPI_BASIC,
691+ CAPI_BRP,
692+ CAPI_MU_BAR,
693+ CAPI_MU_RTS,
694+ CAPI_BSRP,
695+ CAPI_GCR_MU_BAR,
696+ CAPI_BQRP,
697+ CAPI_NDP_FRP,
698+};
699+
700+enum {
701+ MU_DL_ACK_POLICY_MU_BAR = 3,
702+ MU_DL_ACK_POLICY_TF_FOR_ACK = 4,
703+ MU_DL_ACK_POLICY_SU_BAR = 5,
704+};
705+
706+enum muru_vendor_ctrl {
707+ MU_CTRL_UPDATE,
708+ MU_CTRL_DL_USER_CNT,
709+ MU_CTRL_UL_USER_CNT,
710+};
711 #endif
712
713 #endif
714diff --git a/mt7996/vendor.c b/mt7996/vendor.c
developer05f3b2b2024-08-19 19:17:34 +0800715index 0d6fa779..7ab64471 100644
developer66e89bc2024-04-23 14:50:01 +0800716--- a/mt7996/vendor.c
717+++ b/mt7996/vendor.c
718@@ -10,10 +10,31 @@
719 #include "vendor.h"
720 #include "mtk_mcu.h"
721
722+#ifdef CONFIG_MTK_VENDOR
723 static const struct nla_policy
724 mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL] = {
725 [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 },
726 [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 },
727+ [MTK_VENDOR_ATTR_MU_CTRL_STRUCT] = {.type = NLA_BINARY },
728+};
729+
730+static const struct nla_policy
731+wireless_ctrl_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL] = {
732+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU] = {.type = NLA_U8 },
733+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU] = {.type = NLA_U8 },
734+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT] = {.type = NLA_U8 },
735+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_RTS_SIGTA] = {.type = NLA_U8 },
736+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_MCS] = {.type = NLA_U8 },
737+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_OFDMA] = {.type = NLA_U8 },
738+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE] = {.type = NLA_U8 },
739+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA] = {.type = NLA_U8 },
740+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO] = {.type = NLA_U8 },
741+ [MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE] = {.type = NLA_U16 },
742+};
743+
744+static const struct nla_policy
745+wireless_dump_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP] = {
746+ [MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU] = { .type = NLA_U8 },
747 };
748
749 static const struct nla_policy
750@@ -76,6 +97,17 @@ pp_ctrl_policy[NUM_MTK_VENDOR_ATTRS_PP_CTRL] = {
751 [MTK_VENDOR_ATTR_PP_BAND_IDX] = { .type = NLA_U8 },
752 };
753
754+static const struct nla_policy
755+rfeature_ctrl_policy[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL] = {
756+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI] = {.type = NLA_U8 },
757+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_LTF] = { .type = NLA_U8 },
758+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG] = { .type = NLA_NESTED },
759+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_EN] = { .type = NLA_U8 },
760+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE] = { .type = NLA_U8 },
761+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY] = { .type = NLA_U8 },
762+ [MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TXBF] = { .type = NLA_U8 },
763+};
764+
765 struct mt7996_amnt_data {
766 u8 idx;
767 u8 addr[ETH_ALEN];
768@@ -90,6 +122,8 @@ static int mt7996_vendor_mu_ctrl(struct wiphy *wiphy,
769 {
770 struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
771 struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_MU_CTRL];
772+ struct mt7996_phy *phy = mt7996_hw_phy(hw);
773+ struct mt7996_muru *muru;
774 int err;
775 u8 val8;
776 u32 val32 = 0;
777@@ -105,9 +139,17 @@ static int mt7996_vendor_mu_ctrl(struct wiphy *wiphy,
778 FIELD_PREP(RATE_CFG_VAL, val8);
779 ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL,
780 mt7996_set_wireless_vif, &val32);
781+ } else if (tb[MTK_VENDOR_ATTR_MU_CTRL_STRUCT]) {
782+ muru = kzalloc(sizeof(struct mt7996_muru), GFP_KERNEL);
783+
784+ nla_memcpy(muru, tb[MTK_VENDOR_ATTR_MU_CTRL_STRUCT],
785+ sizeof(struct mt7996_muru));
786+
787+ err = mt7996_mcu_set_muru_cfg(phy, muru);
788+ kfree(muru);
789 }
790
791- return 0;
792+ return err;
793 }
794
795 static int
796@@ -130,6 +172,48 @@ mt7996_vendor_mu_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
797 return len;
798 }
799
800+void mt7996_set_wireless_rts_sigta(struct ieee80211_hw *hw, u8 value) {
801+ struct mt7996_phy *phy = mt7996_hw_phy(hw);
802+
803+ switch (value) {
804+ case BW_SIGNALING_STATIC:
805+ case BW_SIGNALING_DYNAMIC:
806+ mt7996_mcu_set_band_confg(phy, UNI_BAND_CONFIG_RTS_SIGTA_EN, true);
807+ mt7996_mcu_set_band_confg(phy, UNI_BAND_CONFIG_DIS_SECCH_CCA_DET, false);
808+ break;
809+ default:
810+ value = BW_SIGNALING_DISABLE;
811+ mt7996_mcu_set_band_confg(phy, UNI_BAND_CONFIG_RTS_SIGTA_EN, false);
812+ mt7996_mcu_set_band_confg(phy, UNI_BAND_CONFIG_DIS_SECCH_CCA_DET, true);
813+ break;
814+ }
815+
816+ phy->rts_bw_sig = value;
817+
818+ /* Set RTS Threshold to a lower Value */
819+ mt7996_mcu_set_rts_thresh(phy, 500);
820+}
821+
822+static int
823+mt7996_vendor_wireless_ctrl_dump(struct wiphy *wiphy, struct wireless_dev *wdev,
824+ struct sk_buff *skb, const void *data, int data_len,
825+ unsigned long *storage)
826+{
827+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
828+ int len = 0;
829+
830+ if (*storage == 1)
831+ return -ENOENT;
832+ *storage = 1;
833+
834+ if (nla_put_u8(skb, MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU,
835+ ieee80211_hw_check(hw, SUPPORTS_AMSDU_IN_AMPDU)))
836+ return -ENOMEM;
837+ len += 1;
838+
839+ return len;
840+ }
841+
842 void mt7996_vendor_amnt_fill_rx(struct mt7996_phy *phy, struct sk_buff *skb)
843 {
844 struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
845@@ -712,6 +796,126 @@ error:
846 return -EINVAL;
847 }
848
849+static int mt7996_vendor_rfeature_ctrl(struct wiphy *wiphy,
850+ struct wireless_dev *wdev,
851+ const void *data,
852+ int data_len)
853+{
854+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
855+ struct mt7996_phy *phy = mt7996_hw_phy(hw);
856+ struct mt7996_dev *dev = phy->dev;
857+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL];
858+ int err;
859+ u32 val;
860+
861+ err = nla_parse(tb, MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX, data, data_len,
862+ rfeature_ctrl_policy, NULL);
863+ if (err)
864+ return err;
865+
866+ val = CAPI_RFEATURE_CHANGED;
867+
868+ if (tb[MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG]) {
869+ u8 enable, trig_type;
870+ int rem;
871+ struct nlattr *cur;
872+
873+ nla_for_each_nested(cur, tb[MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG], rem) {
874+ switch (nla_type(cur)) {
875+ case MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_EN:
876+ enable = nla_get_u8(cur);
877+ break;
878+ case MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE:
879+ trig_type = nla_get_u8(cur);
880+ break;
881+ default:
882+ return -EINVAL;
883+ };
884+ }
885+
886+ err = mt7996_mcu_set_rfeature_trig_type(phy, enable, trig_type);
887+ if (err)
888+ return err;
889+ } else if (tb[MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY]) {
890+ u8 ack_policy;
891+
892+ ack_policy = nla_get_u8(tb[MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY]);
893+ switch (ack_policy) {
894+ case MU_DL_ACK_POLICY_TF_FOR_ACK:
895+ return mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_MUDL_ACK_POLICY,
896+ ack_policy);
897+ default:
898+ return 0;
899+ }
900+ }
901+
902+ return 0;
903+}
904+
905+static int mt7996_vendor_wireless_ctrl(struct wiphy *wiphy,
906+ struct wireless_dev *wdev,
907+ const void *data,
908+ int data_len)
909+{
910+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
911+ struct mt7996_phy *phy = mt7996_hw_phy(hw);
912+ struct mt7996_dev *dev = phy->dev;
913+ struct nlattr *tb[NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL];
914+ int err;
915+ u8 val8;
916+ u16 val16;
917+ u32 val32;
918+
919+ err = nla_parse(tb, MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX, data, data_len,
920+ wireless_ctrl_policy, NULL);
921+ if (err)
922+ return err;
923+
924+ val32 = CAPI_WIRELESS_CHANGED;
925+
926+ if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_OFDMA]) {
927+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_OFDMA]);
928+ val32 |= FIELD_PREP(RATE_CFG_MODE, RATE_PARAM_FIXED_OFDMA) |
929+ FIELD_PREP(RATE_CFG_VAL, val8);
930+ ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL,
931+ mt7996_set_wireless_vif, &val32);
932+ if (val8 == 3) /* DL20and80 */
933+ mt7996_mcu_set_muru_cmd(dev, UNI_CMD_MURU_SET_20M_DYN_ALGO, 1);
934+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE]) {
935+ val16 = nla_get_u16(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE]);
936+ hw->max_tx_aggregation_subframes = val16;
937+ hw->max_rx_aggregation_subframes = val16;
938+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE]) {
939+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE]);
940+ mt7996_mcu_set_ppdu_tx_type(phy, val8);
941+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA]) {
942+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA]);
943+ if (phy->muru_onoff & OFDMA_UL)
944+ mt7996_mcu_set_nusers_ofdma(phy, MU_CTRL_UL_USER_CNT, val8);
945+ else
946+ mt7996_mcu_set_nusers_ofdma(phy, MU_CTRL_DL_USER_CNT, val8);
947+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO]) {
948+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO]);
949+ val32 |= FIELD_PREP(RATE_CFG_MODE, RATE_PARAM_FIXED_MIMO) |
950+ FIELD_PREP(RATE_CFG_VAL, val8);
951+ ieee80211_iterate_active_interfaces_atomic(hw, IEEE80211_IFACE_ITER_RESUME_ALL,
952+ mt7996_set_wireless_vif, &val32);
953+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]) {
954+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT]);
955+ dev->cert_mode = val8;
956+ mt7996_mcu_set_cert(phy, val8);
957+ mt7996_mcu_set_bypass_smthint(phy, val8);
958+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU]) {
959+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU]);
960+ mt7996_set_wireless_amsdu(hw, val8);
961+ } else if (tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_RTS_SIGTA]) {
962+ val8 = nla_get_u8(tb[MTK_VENDOR_ATTR_WIRELESS_CTRL_RTS_SIGTA]);
963+ mt7996_set_wireless_rts_sigta(hw, val8);
964+ }
965+
966+ return 0;
967+}
968+
969 static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
970 {
971 .info = {
972@@ -725,6 +929,18 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
973 .policy = mu_ctrl_policy,
974 .maxattr = MTK_VENDOR_ATTR_MU_CTRL_MAX,
975 },
976+ {
977+ .info = {
978+ .vendor_id = MTK_NL80211_VENDOR_ID,
979+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL,
980+ },
981+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
982+ WIPHY_VENDOR_CMD_NEED_RUNNING,
983+ .doit = mt7996_vendor_wireless_ctrl,
984+ .dumpit = mt7996_vendor_wireless_ctrl_dump,
985+ .policy = wireless_ctrl_policy,
986+ .maxattr = MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX,
987+ },
988 {
989 .info = {
990 .vendor_id = MTK_NL80211_VENDOR_ID,
991@@ -794,6 +1010,17 @@ static const struct wiphy_vendor_command mt7996_vendor_commands[] = {
992 .policy = pp_ctrl_policy,
993 .maxattr = MTK_VENDOR_ATTR_PP_CTRL_MAX,
994 },
995+ {
996+ .info = {
997+ .vendor_id = MTK_NL80211_VENDOR_ID,
998+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL,
999+ },
1000+ .flags = WIPHY_VENDOR_CMD_NEED_NETDEV |
1001+ WIPHY_VENDOR_CMD_NEED_RUNNING,
1002+ .doit = mt7996_vendor_rfeature_ctrl,
1003+ .policy = rfeature_ctrl_policy,
1004+ .maxattr = MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX,
1005+ },
1006 };
1007
1008 void mt7996_vendor_register(struct mt7996_phy *phy)
1009@@ -803,3 +1030,4 @@ void mt7996_vendor_register(struct mt7996_phy *phy)
1010
1011 spin_lock_init(&phy->amnt_lock);
1012 }
1013+#endif
1014diff --git a/mt7996/vendor.h b/mt7996/vendor.h
developer05f3b2b2024-08-19 19:17:34 +08001015index 8aaa18ee..2ee1339a 100644
developer66e89bc2024-04-23 14:50:01 +08001016--- a/mt7996/vendor.h
1017+++ b/mt7996/vendor.h
1018@@ -3,8 +3,12 @@
1019
1020 #define MTK_NL80211_VENDOR_ID 0x0ce7
1021
1022+#ifdef CONFIG_MTK_VENDOR
1023+
1024 enum mtk_nl80211_vendor_subcmds {
1025 MTK_NL80211_VENDOR_SUBCMD_AMNT_CTRL = 0xae,
1026+ MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
1027+ MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
1028 MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5,
1029 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
1030 MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8,
1031@@ -61,6 +65,7 @@ enum mtk_vendor_attr_mu_ctrl {
1032
1033 MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
1034 MTK_VENDOR_ATTR_MU_CTRL_DUMP,
1035+ MTK_VENDOR_ATTR_MU_CTRL_STRUCT,
1036
1037 /* keep last */
1038 NUM_MTK_VENDOR_ATTRS_MU_CTRL,
1039@@ -68,6 +73,66 @@ enum mtk_vendor_attr_mu_ctrl {
1040 NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1
1041 };
1042
1043+enum mtk_capi_control_changed {
1044+ CAPI_RFEATURE_CHANGED = BIT(16),
1045+ CAPI_WIRELESS_CHANGED = BIT(17),
1046+};
1047+
1048+enum mtk_vendor_attr_rfeature_ctrl {
1049+ MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC,
1050+
1051+ MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_GI,
1052+ MTK_VENDOR_ATTR_RFEATURE_CTRL_HE_LTF,
1053+ MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_CFG,
1054+ MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE_EN,
1055+ MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TYPE,
1056+ MTK_VENDOR_ATTR_RFEATURE_CTRL_ACK_PLCY,
1057+ MTK_VENDOR_ATTR_RFEATURE_CTRL_TRIG_TXBF,
1058+
1059+ /* keep last */
1060+ NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL,
1061+ MTK_VENDOR_ATTR_RFEATURE_CTRL_MAX =
1062+ NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1
1063+};
1064+
1065+enum mtk_vendor_attr_wireless_ctrl {
1066+ MTK_VENDOR_ATTR_WIRELESS_CTRL_UNSPEC,
1067+
1068+ MTK_VENDOR_ATTR_WIRELESS_CTRL_FIXED_MCS,
1069+ MTK_VENDOR_ATTR_WIRELESS_CTRL_OFDMA,
1070+ MTK_VENDOR_ATTR_WIRELESS_CTRL_PPDU_TX_TYPE,
1071+ MTK_VENDOR_ATTR_WIRELESS_CTRL_NUSERS_OFDMA,
1072+ MTK_VENDOR_ATTR_WIRELESS_CTRL_BA_BUFFER_SIZE,
1073+ MTK_VENDOR_ATTR_WIRELESS_CTRL_MIMO,
1074+ MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU,
1075+ MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU,
1076+ MTK_VENDOR_ATTR_WIRELESS_CTRL_CERT = 9,
1077+ MTK_VENDOR_ATTR_WIRELESS_CTRL_RTS_SIGTA,
1078+ MTK_VENDOR_ATTR_WIRELESS_CTRL_MU_EDCA, /* reserve */
1079+
1080+ /* keep last */
1081+ NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL,
1082+ MTK_VENDOR_ATTR_WIRELESS_CTRL_MAX =
1083+ NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1
1084+};
1085+
1086+enum mtk_vendor_attr_wireless_dump {
1087+ MTK_VENDOR_ATTR_WIRELESS_DUMP_UNSPEC,
1088+
1089+ MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU,
1090+
1091+ /* keep last */
1092+ NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP,
1093+ MTK_VENDOR_ATTR_WIRELESS_DUMP_MAX =
1094+ NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP - 1
1095+};
1096+
1097+enum bw_sig {
1098+ BW_SIGNALING_DISABLE,
1099+ BW_SIGNALING_STATIC,
1100+ BW_SIGNALING_DYNAMIC
1101+};
1102+
1103 enum mtk_vendor_attr_mnt_ctrl {
1104 MTK_VENDOR_ATTR_AMNT_CTRL_UNSPEC,
1105
1106@@ -151,3 +216,5 @@ enum mtk_vendor_attr_pp_ctrl {
1107 };
1108
1109 #endif
1110+
1111+#endif
1112--
developerd0c89452024-10-11 16:53:27 +080011132.45.2
developer66e89bc2024-04-23 14:50:01 +08001114