blob: d9f759bd0a9acc8bcab9de6b5efdaa00d574c85a [file] [log] [blame]
developer1346ce52022-12-15 21:36:14 +08001From 829e658c7cfa9b9b0180495b8b791d11be7cc537 Mon Sep 17 00:00:00 2001
developerc978ea12022-11-09 15:58:31 +08002From: Lian Chen <lian.chen@mediatek.com>
3Date: Mon, 7 Nov 2022 14:47:44 +0800
developerafd75872022-12-14 21:15:46 +08004Subject: [PATCH 3010/3012] mt76: mt7915: wed: HW ATF support for mt7986
developerc978ea12022-11-09 15:58:31 +08005
6Signed-off-by: Lian Chen <lian.chen@mediatek.com>
7---
8 mt76_connac_mcu.h | 2 +
9 mt7915/debugfs.c | 405 +++++++++++++++++++++++++++++++++++++++++++
10 mt7915/init.c | 39 +++++
developer1346ce52022-12-15 21:36:14 +080011 mt7915/main.c | 15 ++
developerc978ea12022-11-09 15:58:31 +080012 mt7915/mcu.c | 165 ++++++++++++++++++
13 mt7915/mt7915.h | 68 ++++++++
14 mt7915/mtk_debugfs.c | 133 +++++++++++++-
developer1346ce52022-12-15 21:36:14 +080015 7 files changed, 826 insertions(+), 1 deletion(-)
developer356ecec2022-11-14 10:25:04 +080016 mode change 100644 => 100755 mt7915/init.c
developerc978ea12022-11-09 15:58:31 +080017
18diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developer1346ce52022-12-15 21:36:14 +080019index 98b0074..239643b 100644
developerc978ea12022-11-09 15:58:31 +080020--- a/mt76_connac_mcu.h
21+++ b/mt76_connac_mcu.h
developereb6a0182022-12-12 18:53:32 +080022@@ -1159,6 +1159,7 @@ enum {
developerc978ea12022-11-09 15:58:31 +080023 MCU_EXT_CMD_THERMAL_CTRL = 0x2c,
24 MCU_EXT_CMD_WTBL_UPDATE = 0x32,
25 MCU_EXT_CMD_SET_DRR_CTRL = 0x36,
26+ MCU_EXT_CMD_SET_FEATURE_CTRL = 0x38,
27 MCU_EXT_CMD_SET_RDD_CTRL = 0x3a,
28 MCU_EXT_CMD_ATE_CTRL = 0x3d,
29 MCU_EXT_CMD_PROTECT_CTRL = 0x3e,
developereb6a0182022-12-12 18:53:32 +080030@@ -1168,6 +1169,7 @@ enum {
developerc978ea12022-11-09 15:58:31 +080031 MCU_EXT_CMD_MUAR_UPDATE = 0x48,
32 MCU_EXT_CMD_BCN_OFFLOAD = 0x49,
33 MCU_EXT_CMD_RX_AIRTIME_CTRL = 0x4a,
34+ MCU_EXT_CMD_AT_PROC_MODULE = 0x4b,
35 MCU_EXT_CMD_SET_RX_PATH = 0x4e,
36 MCU_EXT_CMD_EFUSE_FREE_BLOCK = 0x4f,
37 MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58,
38diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
developer1346ce52022-12-15 21:36:14 +080039index 3ef2148..b178036 100644
developerc978ea12022-11-09 15:58:31 +080040--- a/mt7915/debugfs.c
41+++ b/mt7915/debugfs.c
42@@ -12,6 +12,10 @@
43 #define FW_BIN_LOG_MAGIC_V2 0x44d9c99a
44 #endif
45
46+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
47+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
48+
49+
50 /** global debugfs **/
51
52 struct hw_queue_map {
developer356ecec2022-11-14 10:25:04 +080053@@ -211,6 +215,406 @@ static const struct file_operations mt7915_sys_recovery_ops = {
developerc978ea12022-11-09 15:58:31 +080054 .llseek = default_llseek,
55 };
56
57+static ssize_t mt7915_vow_get(struct file *file, char __user *user_buf,
58+ size_t count, loff_t *ppos)
59+{
60+ char *buff;
61+ int desc = 0;
62+ ssize_t ret;
63+ static const size_t bufsz = 1000;
64+
65+ buff = kmalloc(bufsz, GFP_KERNEL);
66+ if (!buff)
67+ return -ENOMEM;
68+
69+ desc += scnprintf(buff + desc, bufsz - desc,
70+ "======== Control =============\n"
71+ "vow_atf_en=<0/1> 0:disable, 1:enable\n"
72+ "vow_watf_en=<0/1> 0:disable, 1:enable\n"
73+ "vow_watf_quantum=<level>-<quantum> unit 256us\n"
74+ "======== Station table =============\n"
75+ "vow_sta_dwrr_quantum_id=<wlanidx>-<WMM AC>-<Qid>\n"
76+ "vow_dwrr_max_wait_time=<time> 256us\n"
77+ "======== Debug =============\n"
78+ "vow_show_en=<0/1> 0:dieable, 1:enable\n"
79+ "vow_show_sta=<STA num>\n"
80+ "show_vow_info\n"
81+ "show_vow_sta_conf=<STA num> 0:all\n");
82+ ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
83+ kfree(buff);
84+ return ret;
85+}
86+
87+static int mt7915_set_vow_sta_dwrr_quantum_id(struct mt7915_dev *dev,
88+ u32 wcid_id,
89+ u32 ac, u32 val)
90+{
91+ struct mt7915_sta *msta;
92+ struct mt76_wcid *wcid;
93+ int ret;
94+
95+ wcid = rcu_dereference(dev->mt76.wcid[wcid_id]);
96+ if ((!wcid) || (!wcid->sta)) {
97+ dev_err(dev->mt76.dev, "%s: error station.\n", __func__);
98+ return 0;
99+ }
100+
101+ msta = container_of(wcid, struct mt7915_sta, wcid);
102+
103+ msta->vow_sta_cfg.dwrr_quantum[ac] = val;
104+
105+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, msta, VOW_DRR_STA_AC0_QUA_ID + ac);
106+ dev_info(dev->mt76.dev, "%s: set sta %d, ac %d, quantum id %u.\n",
107+ __func__, wcid_id, ac, val);
108+
109+ return ret;
110+}
111+
112+static int mt7915_set_vow_atf_en(struct mt7915_dev *dev, u32 val)
113+{
114+ int ret;
115+
116+ dev->vow_cfg.vow_atf_en = !!val;
117+ dev->vow_cfg.sta_max_wait_time = val ? 0x40 : 0x1;
118+ ret = mt7915_mcu_set_vow_feature_ctrl(dev);
119+ dev_info(dev->mt76.dev, "%s: set vow_atf_en %u.\n",
120+ __func__, val);
121+
122+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, NULL,
123+ VOW_DRR_AIRTIME_DEFICIT_BOUND);
124+ dev_info(dev->mt76.dev, "%s: set vow_dwrr_max_wait_time %u.\n",
125+ __func__, dev->vow_cfg.sta_max_wait_time);
126+
127+ return ret;
128+}
129+
130+static int mt7915_set_vow_dwrr_max_wait_time(struct mt7915_dev *dev,
131+ u32 val)
132+{
133+ int ret;
134+
135+ dev->vow_cfg.sta_max_wait_time = val;
136+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, NULL,
137+ VOW_DRR_AIRTIME_DEFICIT_BOUND);
138+ dev_info(dev->mt76.dev, "%s: set vow_dwrr_max_wait_time %u.\n",
139+ __func__, val);
140+
141+ return ret;
142+}
143+
144+static int mt7915_set_vow_watf_en(struct mt7915_dev *dev, u32 val)
145+{
146+ int ret;
147+
148+ dev->vow_cfg.vow_watf_en = !!val;
149+ ret = mt7915_mcu_set_vow_feature_ctrl(dev);
150+ dev_info(dev->mt76.dev, "%s: set vow_watf_en %u.\n", __func__, val);
151+
152+ return ret;
153+}
154+
155+static int mt7915_set_vow_watf_quantum(struct mt7915_dev *dev,
156+ u32 id, u32 val)
157+{
158+ int ret;
159+
160+ dev->vow_cfg.vow_sta_dwrr_quantum[id] = val;
161+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, NULL,
162+ VOW_DRR_AIRTIME_QUANTUM_L0 + id);
163+ dev_info(dev->mt76.dev, "%s: set quantum id %u, val %d.\n",
164+ __func__, id, val);
165+
166+ return ret;
167+}
168+
169+extern int mt7915_vow_pleinfo_read(struct mt7915_dev *dev);
170+static void mt7915_show_station_tx_airtime(struct work_struct *work){
171+ struct mt7915_dev *dev = container_of(work, struct mt7915_dev,
172+ vow_work.work);
173+ static u32 vow_last_tx_time[MT7916_WTBL_SIZE];
174+ struct ieee80211_sta *ieee80211_sta;
175+ struct mt7915_sta *msta;
176+ struct mt76_wcid *wcid;
177+ int idx = 0;
178+ int i = 0;
179+ u32 addr;
180+ int tx_airtime_sum = 0;
181+ int tx_add_airtime = 0;
182+
183+ if (!dev->vow_cfg.vow_show_en)
184+ return;
185+
186+ rcu_read_lock();
187+ for (idx = 1; (idx < dev->vow_cfg.vow_show_sta) &&
188+ (idx < MT7915_WTBL_STA); idx++) {
189+ if (idx >= ARRAY_SIZE(dev->mt76.wcid))
190+ return;
191+
192+ wcid = rcu_dereference(dev->mt76.wcid[idx]);
193+ if (!wcid || !wcid->sta)
194+ continue;
195+
196+ msta = container_of(wcid, struct mt7915_sta, wcid);
197+ addr = mt7915_mac_wtbl_lmac_addr(dev, idx, 20);
198+ tx_airtime_sum = 0;
199+
200+ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
201+ tx_airtime_sum += mt76_rr(dev, addr);
202+ addr += 8;
203+ }
204+ tx_add_airtime = tx_airtime_sum - vow_last_tx_time[idx];
205+ vow_last_tx_time[idx] = tx_airtime_sum;
206+
207+ ieee80211_sta = container_of((void *)msta, struct ieee80211_sta,
208+ drv_priv);
209+
210+ dev_info(dev->mt76.dev, "sta%u:" MACSTR " tx -> %u)\n",
211+ idx, MAC2STR(ieee80211_sta->addr), tx_add_airtime);
212+ }
213+ mt7915_vow_pleinfo_read(dev);
214+ ieee80211_queue_delayed_work(mt76_hw(dev), &dev->vow_work, 1 * HZ);
215+ rcu_read_unlock();
216+ return;
217+}
218+
219+
220+static int mt7915_set_vow_show_en(struct mt7915_dev *dev, u32 val)
221+{
222+ if (!!dev->vow_cfg.vow_show_en == !!val)
223+ return 0;
224+ dev->vow_cfg.vow_show_en = val;
225+ mt7915_mcu_set_vow_feature_ctrl(dev);
226+ if (dev->vow_cfg.vow_show_en) {
227+ INIT_DELAYED_WORK(&dev->vow_work, mt7915_show_station_tx_airtime);
228+ ieee80211_queue_delayed_work(mt76_hw(dev), &dev->vow_work, 1 * HZ);
229+ }
230+ else {
231+ cancel_delayed_work_sync(&dev->vow_work);
232+ }
233+ return 0;
234+}
235+
236+static int mt7915_set_vow_show_sta(struct mt7915_dev *dev, u32 val)
237+{
238+ dev->vow_cfg.vow_show_sta = val;
239+ dev_info(dev->mt76.dev, "%s: show station up to %d.\n",
240+ __func__, dev->vow_cfg.vow_show_sta);
241+ return 0;
242+}
243+static int mt7915_set_show_vow_info(struct mt7915_dev *dev)
244+{
245+ dev_info(dev->mt76.dev, "====== VOW Control Information ======\n");
246+ dev_info(dev->mt76.dev, "ATF Enbale: %d\n",
247+ dev->vow_cfg.vow_atf_en);
248+ dev_info(dev->mt76.dev, "WATF Enable: %d\n",
249+ dev->vow_cfg.vow_watf_en);
250+ dev_info(dev->mt76.dev, "refill_period: %d\n",
251+ dev->vow_cfg.refill_period);
252+ dev_info(dev->mt76.dev, "===== VOW Max Deficit Information =====\n");
253+ dev_info(dev->mt76.dev, "VOW Max Deficit(unit 256us): %d\n",
254+ dev->vow_cfg.sta_max_wait_time);
255+ dev_info(dev->mt76.dev, "===== VOW Quantum Information =====\n");
256+ dev_info(dev->mt76.dev, "Quantum ID 0 value(unit 256us): %d\n",
257+ dev->vow_cfg.vow_sta_dwrr_quantum[0]);
258+ dev_info(dev->mt76.dev, "Quantum ID 1 value(unit 256us): %d\n",
259+ dev->vow_cfg.vow_sta_dwrr_quantum[1]);
260+ dev_info(dev->mt76.dev, "Quantum ID 2 value(unit 256us): %d\n",
261+ dev->vow_cfg.vow_sta_dwrr_quantum[2]);
262+ dev_info(dev->mt76.dev, "Quantum ID 3 value(unit 256us): %d\n",
263+ dev->vow_cfg.vow_sta_dwrr_quantum[3]);
264+ return 0;
265+}
266+
267+static int mt7915_show_vow_sta_conf(struct mt7915_dev *dev, u32 val)
268+{
269+ struct ieee80211_sta *ieee80211_sta;
270+ struct mt7915_sta *msta;
271+ struct mt76_wcid *wcid;
272+ u32 i;
273+ u8 q;
274+
275+ if (val > 0 && val < MT7915_WTBL_STA) {
276+ wcid = rcu_dereference(dev->mt76.wcid[val]);
277+ if (!wcid || !wcid->sta)
278+ return 0;
279+ msta = container_of(wcid, struct mt7915_sta, wcid);
280+ ieee80211_sta = container_of((void *)msta, struct ieee80211_sta,
281+ drv_priv);
282+ dev_info(dev->mt76.dev, "%s: ****** sta%d: "MACSTR"******\n",
283+ __func__, val, MAC2STR(ieee80211_sta->addr));
284+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VO];
285+ dev_info(dev->mt76.dev, "Ac0 --> %uus(%u)\n",
286+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
287+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VI];
288+ dev_info(dev->mt76.dev, "Ac1 --> %uus(%u)\n",
289+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
290+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BE];
291+ dev_info(dev->mt76.dev, "Ac2 --> %uus(%u)\n",
292+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
293+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BK];
294+ dev_info(dev->mt76.dev, "Ac3 --> %uus(%u)\n",
295+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
296+ }
297+ else{
298+ for (i = 1; i < MT7915_WTBL_STA; i++) {
299+ wcid = rcu_dereference(dev->mt76.wcid[i]);
300+ if (!wcid || !wcid->sta)
301+ continue;
302+ msta = container_of(wcid, struct mt7915_sta, wcid);
303+ ieee80211_sta = container_of((void *)msta, struct ieee80211_sta,
304+ drv_priv);
305+ dev_info(dev->mt76.dev, "%s: ****** sta%d: "MACSTR"******\n",
306+ __func__, i, MAC2STR(ieee80211_sta->addr));
307+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VO];
308+ dev_info(dev->mt76.dev, "Ac0 --> %uus(%u)\n",
309+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
310+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VI];
311+ dev_info(dev->mt76.dev, "Ac1 --> %uus(%u)\n",
312+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
313+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BE];
314+ dev_info(dev->mt76.dev, "Ac2 --> %uus(%u)\n",
315+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
316+ q = msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BK];
317+ dev_info(dev->mt76.dev, "Ac3 --> %uus(%u)\n",
318+ (dev->vow_cfg.vow_sta_dwrr_quantum[q] << 8), q);
319+ }
320+ }
321+ return 0;
322+}
323+
324+static ssize_t
325+mt7915_vow_set(struct file *file, const char __user *user_buf,
326+ size_t count, loff_t *ppos)
327+{
328+ struct mt7915_phy *phy = file->private_data;
329+ struct mt7915_dev *dev = phy->dev;
330+ u32 rv, param1, param2, param3;
331+ char buf[128];
332+ int ret = 0;
333+
334+ if (count >= sizeof(buf))
335+ return -EINVAL;
336+
337+ if (copy_from_user(buf, user_buf, count))
338+ return -EFAULT;
339+
340+ if (count && buf[count - 1] == '\n')
341+ buf[count - 1] = '\0';
342+ else
343+ buf[count] = '\0';
344+
345+ if (!strncmp(buf, "vow_sta_dwrr_quantum_id",
346+ strlen("vow_sta_dwrr_quantum_id")))
347+ {
348+ rv = sscanf(buf, "vow_sta_dwrr_quantum_id=%d-%d-%d",
349+ &param1, &param2, &param3);
350+ if ((rv > 2) && (param2 < IEEE80211_NUM_ACS) &&
351+ (param3 < VOW_WATF_LEVEL_NUM)) {
352+ ret = mt7915_set_vow_sta_dwrr_quantum_id(dev, param1,
353+ param2, param3);
354+ }
355+ else {
356+ goto out;
357+ }
358+ }
359+ else if (!strncmp(buf, "vow_atf_en", strlen("vow_atf_en")))
360+ {
361+ rv = sscanf(buf, "vow_atf_en=%d", &param1);
362+ if (rv > 0) {
363+ ret = mt7915_set_vow_atf_en(dev, param1);
364+ }
365+ else {
366+ goto out;
367+ }
368+ }
369+ else if (!strncmp(buf, "vow_dwrr_max_wait_time",
370+ strlen("vow_dwrr_max_wait_time")))
371+ {
372+ rv = sscanf(buf, "vow_dwrr_max_wait_time=%d", &param1);
373+ if (rv > 0) {
374+ ret = mt7915_set_vow_dwrr_max_wait_time(dev, param1);
375+ }
376+ else {
377+ goto out;
378+ }
379+ }
380+ else if (!strncmp(buf, "vow_watf_en", strlen("vow_watf_en")))
381+ {
382+ rv = sscanf(buf, "vow_watf_en=%d", &param1);
383+ if (rv > 0) {
384+ ret = mt7915_set_vow_watf_en(dev, param1);
385+ }
386+ else {
387+ goto out;
388+ }
389+ }
390+ else if (!strncmp(buf, "vow_watf_quantum",
391+ strlen("vow_watf_quantum")))
392+ {
393+ rv = sscanf(buf, "vow_watf_quantum=%d-%d",
394+ &param1, &param2);
395+ if ((dev->vow_cfg.vow_watf_en) && (rv > 1) &&
396+ (param1 < VOW_WATF_LEVEL_NUM)) {
397+ ret = mt7915_set_vow_watf_quantum(dev, param1, param2);
398+ }
399+ else {
400+ goto out;
401+ }
402+ }
403+ else if (!strncmp(buf, "vow_show_en", strlen("vow_show_en")))
404+ {
405+ rv = sscanf(buf, "vow_show_en=%d", &param1);
406+ if (rv > 0) {
407+ ret = mt7915_set_vow_show_en(dev, param1);
408+ }
409+ else {
410+ goto out;
411+ }
412+ }
413+ else if (!strncmp(buf, "vow_show_sta", strlen("vow_show_sta")))
414+ {
415+ rv = sscanf(buf, "vow_show_sta=%d", &param1);
416+ if ((rv > 0)&& (param1 < MT7915_WTBL_STA)) {
417+ ret = mt7915_set_vow_show_sta(dev, param1);
418+ }
419+ else {
420+ goto out;
421+ }
422+ }
423+ else if (!strncmp(buf, "show_vow_info", strlen("show_vow_info")))
424+ {
425+ if (rv == 0) {
426+ ret = mt7915_set_show_vow_info(dev);
427+ }
428+ else {
429+ dev_err(dev->mt76.dev, "show_vow_info\n");
430+ goto out;
431+ }
432+ }
433+ else if (!strncmp(buf, "show_vow_sta_conf", strlen("show_vow_sta_conf")))
434+ {
435+ rv = sscanf(buf, "show_vow_sta_conf=%d", &param1);
436+ if ((rv > 0) && (param1 < MT7915_WTBL_STA)) {
437+ ret = mt7915_show_vow_sta_conf(dev, param1);
438+ }
439+ else {
440+ goto out;
441+ }
442+ }
443+
444+ if (ret)
445+ return ret;
446+out:
447+ return count;
448+}
449+
450+static const struct file_operations mt7915_vow_ops = {
451+ .write = mt7915_vow_set,
452+ .read = mt7915_vow_get,
453+ .open = simple_open,
454+ .llseek = default_llseek,
455+};
456+
457 static int
458 mt7915_radar_trigger(void *data, u64 val)
459 {
developerfe7be7f2022-12-13 21:40:24 +0800460@@ -1339,6 +1743,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
developerc978ea12022-11-09 15:58:31 +0800461 debugfs_create_devm_seqfile(dev->mt76.dev, "twt_stats", dir,
462 mt7915_twt_stats);
463 debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval);
464+ debugfs_create_file("vow", 0600, dir, phy, &mt7915_vow_ops);
465
developereb6a0182022-12-12 18:53:32 +0800466 if (!dev->dbdc_support || phy->mt76->band_idx) {
developerc978ea12022-11-09 15:58:31 +0800467 debugfs_create_u32("dfs_hw_pattern", 0400, dir,
468diff --git a/mt7915/init.c b/mt7915/init.c
developer356ecec2022-11-14 10:25:04 +0800469old mode 100644
470new mode 100755
developer1346ce52022-12-15 21:36:14 +0800471index e044f50..ef752e1
developerc978ea12022-11-09 15:58:31 +0800472--- a/mt7915/init.c
473+++ b/mt7915/init.c
developer9851a292022-12-15 17:33:43 +0800474@@ -563,10 +563,46 @@ mt7915_init_led_mux(struct mt7915_dev *dev)
developereb6a0182022-12-12 18:53:32 +0800475 }
developerc978ea12022-11-09 15:58:31 +0800476 }
477
478+void mt7915_vow_init(struct mt7915_dev *dev)
479+{
480+ struct mt7915_vow_cfg *vow_cfg = &dev->vow_cfg;
481+ bool ret;
482+ int i;
483+
484+ if (!(is_mt7915(&dev->mt76)))
485+ vow_cfg->vow_feature |= VOW_FEATURE_BWCG;
486+
487+ vow_cfg->vow_atf_en = 0x1;
488+ vow_cfg->sta_max_wait_time = 0x40;
489+ vow_cfg->refill_period = 0x5;
490+
491+ vow_cfg->vow_sta_dwrr_quantum[0] = 0x06;
492+ vow_cfg->vow_sta_dwrr_quantum[1] = 0x0c;
493+ vow_cfg->vow_sta_dwrr_quantum[2] = 0x10;
494+ vow_cfg->vow_sta_dwrr_quantum[3] = 0x14;
495+ vow_cfg->vow_sta_dwrr_quantum[4] = 0x18;
496+ vow_cfg->vow_sta_dwrr_quantum[5] = 0x1c;
497+ vow_cfg->vow_sta_dwrr_quantum[6] = 0x20;
498+ vow_cfg->vow_sta_dwrr_quantum[7] = 0x24;
499+
500+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, NULL,
501+ VOW_DRR_AIRTIME_DEFICIT_BOUND);
502+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, NULL,
503+ VOW_DRR_AIRTIME_QUANTUM_ALL);
504+
505+ for(i = 0; i < 4; i++)
506+ ret = mt7915_mcu_set_vow_drr_ctrl(dev, NULL,
507+ VOW_DRR_AIRTIME_QUANTUM_L0 + i);
508+
509+ ret = mt7915_mcu_set_vow_feature_ctrl(dev);
510+ return;
511+}
512+
513 void mt7915_mac_init(struct mt7915_dev *dev)
514 {
515 int i;
516 u32 rx_len = is_mt7915(&dev->mt76) ? 0x400 : 0x680;
517+ struct wiphy *wiphy = dev->phy.mt76->hw->wiphy;
518
519 /* config pse qid6 wfdma port selection */
520 if (!is_mt7915(&dev->mt76) && dev->hif2)
developer9851a292022-12-15 17:33:43 +0800521@@ -588,6 +624,9 @@ void mt7915_mac_init(struct mt7915_dev *dev)
developereb6a0182022-12-12 18:53:32 +0800522 mt7915_mac_init_band(dev, i);
523
524 mt7915_init_led_mux(dev);
developerc978ea12022-11-09 15:58:31 +0800525+
developereb6a0182022-12-12 18:53:32 +0800526+ if (mt7915_is_atf_default_on(wiphy, dev))
developerc978ea12022-11-09 15:58:31 +0800527+ mt7915_vow_init(dev);
528 }
529
530 int mt7915_txbf_init(struct mt7915_dev *dev)
531diff --git a/mt7915/main.c b/mt7915/main.c
developer1346ce52022-12-15 21:36:14 +0800532index 7dd3973..c87f04b 100644
developerc978ea12022-11-09 15:58:31 +0800533--- a/mt7915/main.c
534+++ b/mt7915/main.c
developer1346ce52022-12-15 21:36:14 +0800535@@ -209,6 +209,7 @@ int mt7915_init_vif(struct mt7915_phy *phy, struct ieee80211_vif *vif, bool bf_e
developerc978ea12022-11-09 15:58:31 +0800536 {
537 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
developer1346ce52022-12-15 21:36:14 +0800538 struct mt7915_dev *dev = phy->dev;
developerc978ea12022-11-09 15:58:31 +0800539+ struct wiphy *wiphy = dev->phy.mt76->hw->wiphy;
developerc978ea12022-11-09 15:58:31 +0800540 struct mt76_txq *mtxq;
541 bool ext_phy = phy != &dev->phy;
developer1346ce52022-12-15 21:36:14 +0800542 int idx, ret = 0;
543@@ -270,6 +271,9 @@ int mt7915_init_vif(struct mt7915_phy *phy, struct ieee80211_vif *vif, bool bf_e
developerc978ea12022-11-09 15:58:31 +0800544 mt7915_mcu_add_sta(dev, vif, NULL, true);
545 rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
546
developer1346ce52022-12-15 21:36:14 +0800547+ if (mt7915_is_atf_default_on(wiphy, dev))
developerc978ea12022-11-09 15:58:31 +0800548+ mt7915_mcu_set_vow_band(dev, mvif);
developerc978ea12022-11-09 15:58:31 +0800549+
developer1346ce52022-12-15 21:36:14 +0800550 return ret;
551 }
developerc978ea12022-11-09 15:58:31 +0800552
developer1346ce52022-12-15 21:36:14 +0800553@@ -691,6 +695,7 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developerc978ea12022-11-09 15:58:31 +0800554 struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
555 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
556 bool ext_phy = mvif->phy != &dev->phy;
557+ struct wiphy *wiphy = dev->phy.mt76->hw->wiphy;
558 #ifdef CONFIG_MTK_VENDOR
559 struct mt7915_phy *phy;
560 #endif
developer1346ce52022-12-15 21:36:14 +0800561@@ -742,6 +747,16 @@ int mt7915_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
developerc978ea12022-11-09 15:58:31 +0800562 mt7915_mcu_set_mimo(phy, 0);
563 }
564 #endif
developereb6a0182022-12-12 18:53:32 +0800565+ if (mt7915_is_atf_default_on(wiphy, dev)) {
developerc978ea12022-11-09 15:58:31 +0800566+ msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VO] = 2;
567+ msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VI] = 2;
568+ msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BE] = 1;
569+ msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BK] = 0;
570+ mt7915_mcu_set_vow_drr_ctrl(dev, msta, VOW_DRR_STA_BSS_GROUP);
571+ mt7915_mcu_set_vow_drr_ctrl(dev, msta, VOW_DRR_STA_PAUSE_SETTING);
572+ mt7915_mcu_set_vow_drr_ctrl(dev, msta, VOW_DRR_STA_ALL);
573+ }
574+
575 return 0;
576 }
577
578diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer1346ce52022-12-15 21:36:14 +0800579index 1164eff..aacc237 100644
developerc978ea12022-11-09 15:58:31 +0800580--- a/mt7915/mcu.c
581+++ b/mt7915/mcu.c
developer1346ce52022-12-15 21:36:14 +0800582@@ -3533,6 +3533,171 @@ int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band)
developerc978ea12022-11-09 15:58:31 +0800583 &req, sizeof(req), false);
584 }
585
586+int mt7915_mcu_set_vow_drr_ctrl(struct mt7915_dev *dev,
587+ struct mt7915_sta *msta,
588+ u32 subcmd)
589+{
590+ u32 setting = 0;
591+ u32 i;
592+
593+ struct {
594+ __le32 action;
595+ u8 wlan_idx_lo;
596+ u8 status;
597+ u8 wlan_idx_hi;
598+ u8 rsv0[5];
599+ union {
600+ __le32 com_value;
601+ struct {
602+ u8 air_time_quantum[VOW_MAX_STA_DWRR_NUM];
603+ }air_time_quantum_all;
604+ }air_time_ctrl;
605+ } __packed req = {
606+ .action = cpu_to_le32(subcmd),
607+ .wlan_idx_lo = msta ? to_wcid_lo(msta->wcid.idx) : to_wcid_lo(0x0),
608+ .wlan_idx_hi = msta ? to_wcid_hi(msta->wcid.idx) : to_wcid_hi(0x0),
609+ };
610+
611+ switch (subcmd) {
612+ case VOW_DRR_STA_ALL:{
613+ setting |= 0x00;
614+ setting |= msta->vif->mt76.idx;
615+ setting |= msta->vow_sta_cfg.ac_change_rule << 4;
616+ setting |= (msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VO] << 8);
617+ setting |= (msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VI] << 12);
618+ setting |= (msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BE] << 16);
619+ setting |= (msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BK] << 20);
620+ if (dev->vow_cfg.vow_feature & VOW_FEATURE_BWCG)
621+ setting |= ((UMAC_BWC_GROUP_MIN) << 24);
622+ req.air_time_ctrl.com_value = cpu_to_le32(setting);
623+ break;
624+ }
625+
626+ case VOW_DRR_STA_BSS_GROUP:
627+ req.air_time_ctrl.com_value = cpu_to_le32(0x0);
628+ break;
629+
630+ case VOW_DRR_STA_PAUSE_SETTING:
631+ req.air_time_ctrl.com_value = cpu_to_le32(msta->vow_sta_cfg.paused);
632+ break;
633+
634+ case VOW_DRR_STA_AC0_QUA_ID:
635+ req.air_time_ctrl.com_value =
636+ cpu_to_le32(msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VO]);
637+ break;
638+
639+ case VOW_DRR_STA_AC1_QUA_ID:
640+ req.air_time_ctrl.com_value =
641+ cpu_to_le32(msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_VI]);
642+ break;
643+
644+ case VOW_DRR_STA_AC2_QUA_ID:
645+ req.air_time_ctrl.com_value =
646+ cpu_to_le32(msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BE]);
647+ break;
648+
649+ case VOW_DRR_STA_AC3_QUA_ID:
650+ req.air_time_ctrl.com_value =
651+ cpu_to_le32(msta->vow_sta_cfg.dwrr_quantum[IEEE80211_AC_BK]);
652+ break;
653+
654+ case VOW_DRR_AIRTIME_DEFICIT_BOUND:
655+ req.air_time_ctrl.com_value =
656+ cpu_to_le32(dev->vow_cfg.sta_max_wait_time);
657+ break;
658+
659+ case VOW_DRR_AIRTIME_QUANTUM_L0:
660+ case VOW_DRR_AIRTIME_QUANTUM_L1:
661+ case VOW_DRR_AIRTIME_QUANTUM_L2:
662+ case VOW_DRR_AIRTIME_QUANTUM_L3:
663+ case VOW_DRR_AIRTIME_QUANTUM_L4:
664+ case VOW_DRR_AIRTIME_QUANTUM_L5:
665+ case VOW_DRR_AIRTIME_QUANTUM_L6:
666+ case VOW_DRR_AIRTIME_QUANTUM_L7:
667+ req.air_time_ctrl.com_value =
668+ cpu_to_le32(dev->vow_cfg.vow_sta_dwrr_quantum[subcmd -
669+ VOW_DRR_AIRTIME_QUANTUM_L0]);
670+ break;
671+
672+ case VOW_DRR_AIRTIME_QUANTUM_ALL: {
673+ for (i = 0; i < VOW_MAX_STA_DWRR_NUM; i++) {
674+ req.air_time_ctrl.air_time_quantum_all.air_time_quantum[i] =
675+ dev->vow_cfg.vow_sta_dwrr_quantum[i];
676+ }
677+ break;
678+ }
679+
680+ default:
681+ break;
682+ }
683+
684+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_DRR_CTRL),
685+ &req, sizeof(req), false);
686+}
687+
688+int mt7915_mcu_set_vow_feature_ctrl(struct mt7915_dev *dev)
689+{
690+ u16 value = 0;
691+ u32 sch_value = 0;
692+
693+ struct vow_feature_ctrl {
694+ __le16 bss_flag;
695+ __le16 vow_ctrl_flag;
696+ __le16 bss_value[9];
697+ __le16 vow_ctrl_val;
698+ __le16 time_token_value[2];
699+ __le16 length_token_value[2];
700+ __le32 tx_ctrl;
701+ __le32 sch_ctrl;
702+ } __packed req = {
703+ .bss_flag = cpu_to_le16(0xffff),
704+ .vow_ctrl_flag = cpu_to_le16(0xf231),
705+ .bss_value[0] = cpu_to_le16(0xffff),
706+ .bss_value[2] = cpu_to_le16(0xffff),
707+ .bss_value[8] = cpu_to_le16(0xffff),
708+ .time_token_value[0] = cpu_to_le16(0xffff),
709+ };
710+
711+ value |= dev->vow_cfg.refill_period;
712+ value |= 1 << 4;
713+ value |= 1 << 5;
714+ value |= dev->vow_cfg.vow_watf_en << 9;
715+ value |= 1 << 12;
716+ value |= dev->vow_cfg.vow_atf_en << 13;
717+ value |= 1 << 14;
718+ req.vow_ctrl_val = value;
719+ if (dev->vow_cfg.vow_atf_en)
720+ req.tx_ctrl = cpu_to_le32(0x6bf69e1f);
721+ sch_value |= 1 << 6;
722+ sch_value |= (((dev->vow_cfg.vow_show_en == 0) ? 0 :
723+ (dev->vow_cfg.vow_show_en - 1 )) << 4);
724+ req.sch_ctrl = sch_value;
725+
726+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(SET_FEATURE_CTRL),
727+ &req, sizeof(req), false);
728+}
729+
730+int mt7915_mcu_set_vow_band(struct mt7915_dev *dev, struct mt7915_vif *mvif)
731+{
732+ struct module_ctrl {
733+ __le16 action;
734+ __le16 sub_action;
735+ __le32 rsv1[5];
736+ u8 rsv2[72];
737+ u8 group_idx;
738+ u8 band_idx;
739+ u8 rsv3[2];
740+ } __packed req = {
741+ .action = cpu_to_le16(0x1),
742+ .sub_action = cpu_to_le16(0x4),
743+ .group_idx = mvif->mt76.band_idx * 4 + mvif->mt76.omac_idx % 4,
744+ .band_idx = mvif->mt76.band_idx,
745+ };
746+
747+ return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(AT_PROC_MODULE),
748+ &req, sizeof(req), false);
749+}
750+
751 int mt7915_mcu_set_txbf(struct mt7915_dev *dev, u8 action)
752 {
developer1346ce52022-12-15 21:36:14 +0800753 #define MT_BF_PROCESSING 4
developerc978ea12022-11-09 15:58:31 +0800754diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developer1346ce52022-12-15 21:36:14 +0800755index 3683ef0..b2bcf02 100644
developerc978ea12022-11-09 15:58:31 +0800756--- a/mt7915/mt7915.h
757+++ b/mt7915/mt7915.h
developer9851a292022-12-15 17:33:43 +0800758@@ -135,6 +135,58 @@ struct mt7915_twt_flow {
developer356ecec2022-11-14 10:25:04 +0800759
760 DECLARE_EWMA(avg_signal, 10, 8)
developerc978ea12022-11-09 15:58:31 +0800761
762+#define VOW_MAX_STA_DWRR_NUM 8
763+#define VOW_WATF_LEVEL_NUM 4
764+#define VOW_FEATURE_BWCG BIT(3)
765+#define UMAC_BWC_GROUP_MIN 40
766+
767+
768+enum ext_cmd_vow_drr_ctrl {
769+ /* Type 1 */
770+ VOW_DRR_STA_ALL = 0x00,
771+ VOW_DRR_STA_BSS_GROUP = 0x01,
772+ VOW_DRR_STA_AC0_QUA_ID = 0x03,
773+ VOW_DRR_STA_AC1_QUA_ID = 0x04,
774+ VOW_DRR_STA_AC2_QUA_ID = 0x05,
775+ VOW_DRR_STA_AC3_QUA_ID = 0x06,
776+
777+ /* Type 2 */
778+ VOW_DRR_AIRTIME_DEFICIT_BOUND = 0x10,
779+
780+ /* Type 3 */
781+ VOW_DRR_AIRTIME_QUANTUM_L0 = 0x20,
782+ VOW_DRR_AIRTIME_QUANTUM_L1 = 0x21,
783+ VOW_DRR_AIRTIME_QUANTUM_L2 = 0x22,
784+ VOW_DRR_AIRTIME_QUANTUM_L3 = 0x23,
785+ VOW_DRR_AIRTIME_QUANTUM_L4 = 0x24,
786+ VOW_DRR_AIRTIME_QUANTUM_L5 = 0x25,
787+ VOW_DRR_AIRTIME_QUANTUM_L6 = 0x26,
788+ VOW_DRR_AIRTIME_QUANTUM_L7 = 0x27,
789+ VOW_DRR_AIRTIME_QUANTUM_ALL = 0x28,
790+ VOW_DRR_STA_PAUSE_SETTING = 0x30,
791+};
792+
793+struct mt7915_vow_sta_cfg{
794+ u8 dwrr_quantum[IEEE80211_NUM_ACS];
795+ u8 ac_change_rule;
796+ bool paused;
797+};
798+
799+struct mt7915_vow_cfg{
800+ /*ATF setting */
801+ u32 vow_feature;
802+ bool vow_atf_en;
803+ u8 refill_period;
804+ u8 sta_max_wait_time;
805+ u8 vow_sta_dwrr_quantum[VOW_MAX_STA_DWRR_NUM];
806+ u8 vow_show_en;
807+ u32 vow_show_sta;
808+
809+ /*WATF setting */
810+ bool vow_watf_en;
811+};
812+
813+
814 struct mt7915_sta {
815 struct mt76_wcid wcid; /* must be first */
816
developer9851a292022-12-15 17:33:43 +0800817@@ -156,6 +208,7 @@ struct mt7915_sta {
developerc978ea12022-11-09 15:58:31 +0800818 u8 flowid_mask;
819 struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT];
820 } twt;
821+ struct mt7915_vow_sta_cfg vow_sta_cfg;
822 };
823
824 struct mt7915_vif_cap {
developer1346ce52022-12-15 21:36:14 +0800825@@ -469,6 +522,8 @@ struct mt7915_dev {
developerc978ea12022-11-09 15:58:31 +0800826 } dbg;
827 const struct mt7915_dbg_reg_desc *dbg_reg;
828 #endif
829+ struct delayed_work vow_work;
830+ struct mt7915_vow_cfg vow_cfg;
831 };
832
833 enum {
developer1346ce52022-12-15 21:36:14 +0800834@@ -501,6 +556,15 @@ enum mt7915_rdd_cmd {
developerc978ea12022-11-09 15:58:31 +0800835 RDD_IRQ_OFF,
836 };
837
838+static inline bool
developereb6a0182022-12-12 18:53:32 +0800839+mt7915_is_atf_default_on(struct wiphy *wiphy, struct mt7915_dev *dev)
developerc978ea12022-11-09 15:58:31 +0800840+{
841+ return ((!wiphy_ext_feature_isset(wiphy,
842+ NL80211_EXT_FEATURE_AIRTIME_FAIRNESS)) ||
843+ mtk_wed_device_active(&dev->mt76.mmio.wed));
844+}
845+
846+
847 static inline struct mt7915_phy *
848 mt7915_hw_phy(struct ieee80211_hw *hw)
849 {
developer9851a292022-12-15 17:33:43 +0800850@@ -629,6 +693,10 @@ int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
developerc978ea12022-11-09 15:58:31 +0800851 int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode,
852 u8 en);
853 int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band);
854+int mt7915_mcu_set_vow_drr_ctrl(struct mt7915_dev *dev, struct mt7915_sta *msta,
855+ u32 subcmd);
856+int mt7915_mcu_set_vow_feature_ctrl(struct mt7915_dev *dev);
857+int mt7915_mcu_set_vow_band(struct mt7915_dev *dev, struct mt7915_vif *mvif);
858 int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable);
859 int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy);
developerfe7be7f2022-12-13 21:40:24 +0800860 int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len,
developerc978ea12022-11-09 15:58:31 +0800861diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
developer1346ce52022-12-15 21:36:14 +0800862index 919cae4..c8df2d0 100644
developerc978ea12022-11-09 15:58:31 +0800863--- a/mt7915/mtk_debugfs.c
864+++ b/mt7915/mtk_debugfs.c
developer29647af2022-11-15 18:09:16 +0800865@@ -1301,7 +1301,6 @@ static EMPTY_QUEUE_INFO_T ple_txcmd_queue_empty_info[] = {
developerc978ea12022-11-09 15:58:31 +0800866 };
867
868
869-
870 static char* sta_ctrl_reg[] = {"ENABLE", "DISABLE", "PAUSE"};
871 static u32 chip_show_sta_acq_info(struct seq_file *s, struct mt7915_dev *dev, u32 *ple_stat,
872 u32 *sta_pause, u32 *dis_sta_map,
developer29647af2022-11-15 18:09:16 +0800873@@ -1455,6 +1454,138 @@ static void chip_get_sta_pause(struct mt7915_dev *dev, u32 *sta_pause)
developerc978ea12022-11-09 15:58:31 +0800874 }
875 }
876
877+u32 vow_chip_show_sta_acq_info(struct mt7915_dev *dev, u32 *ple_stat,
878+ u32 *sta_pause, u32 *dis_sta_map,
879+ u32 dumptxd)
880+{
881+ int i, j;
882+ u32 total_nonempty_cnt = 0;
883+ u32 ac_num = 9, all_ac_num;
884+ static char* sta_ctrl_reg[] = {"ENABLE", "DISABLE", "PAUSE"};
885+ if (!is_mt7915(&dev->mt76))
886+ ac_num = 17;
887+
888+ all_ac_num = ac_num * 4;
889+
890+ for (j = 0; j < all_ac_num; j++) { /* show AC Q info */
891+ for (i = 0; i < 32; i++) {
892+ if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) {
893+ u32 hfid, tfid, pktcnt, ac_n = j / ac_num, ctrl = 0;
894+ u32 sta_num = i + (j % ac_num) * 32, fl_que_ctrl[3] = {0};
895+ u32 wmmidx = 0;
896+ struct mt7915_sta *msta;
897+ struct mt76_wcid *wcid;
898+ struct ieee80211_sta *sta = NULL;
899+
900+ wcid = rcu_dereference(dev->mt76.wcid[sta_num]);
901+ sta = wcid_to_sta(wcid);
902+ if (!sta) {
903+ printk("ERROR!! no found STA wcid=%d\n", sta_num);
904+ continue;
905+ }
906+ msta = container_of(wcid, struct mt7915_sta, wcid);
907+ wmmidx = msta->vif->mt76.wmm_idx;
908+
909+ dev_info(dev->mt76.dev, "\tSTA%d AC%d: ", sta_num, ac_n);
910+
911+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
912+ fl_que_ctrl[0] |= (ENUM_UMAC_LMAC_PORT_2 <<
913+ MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
914+ fl_que_ctrl[0] |= (ac_n << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
915+ fl_que_ctrl[0] |= sta_num;
916+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
917+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
918+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
919+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK,
920+ fl_que_ctrl[1]);
921+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK,
922+ fl_que_ctrl[1]);
923+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK,
924+ fl_que_ctrl[2]);
925+ dev_info(dev->mt76.dev, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x",
926+ tfid, hfid, pktcnt);
927+
928+ if (((sta_pause[j % 6] & 0x1 << i) >> i) == 1)
929+ ctrl = 2;
930+
931+ if (((dis_sta_map[j % 6] & 0x1 << i) >> i) == 1)
932+ ctrl = 1;
933+
934+ dev_info(dev->mt76.dev, " ctrl = %s", sta_ctrl_reg[ctrl]);
935+ dev_info(dev->mt76.dev, " (wmmidx=%d)\n", wmmidx);
936+
937+ total_nonempty_cnt++;
938+ }
939+ }
940+ }
941+
942+ return total_nonempty_cnt;
943+}
944+
945+int mt7915_vow_pleinfo_read(struct mt7915_dev *dev)
946+{
947+ u32 ple_stat[70] = {0}, pg_flow_ctrl[8] = {0};
948+ u32 ple_txcmd_stat;
949+ u32 sta_pause[CR_NUM_OF_AC] = {0}, dis_sta_map[CR_NUM_OF_AC] = {0};
950+ int i;
951+
952+ chip_get_ple_acq_stat(dev, ple_stat);
953+ ple_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_TXCMD_Q_EMPTY);
954+ pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PLE_FREEPG_CNT);
955+ pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FREEPG_HEAD_TAIL);
956+ pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_GROUP);
957+ pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PLE_HIF_PG_INFO);
958+ pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PLE_PG_CPU_GROUP);
959+ pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PLE_CPU_PG_INFO);
960+ pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_TXCMD_GROUP);
961+ pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PLE_HIF_TXCMD_PG_INFO);
962+ chip_get_dis_sta_map(dev, dis_sta_map);
963+ chip_get_sta_pause(dev, sta_pause);
964+
965+ dev_info(dev->mt76.dev, "PLE Configuration Info:\n");
966+
967+ for (i = 0; i < 32; i++) {
968+ if (((ple_stat[0] & (0x1 << i)) >> i) == 0) {
969+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
970+
971+ if (ple_queue_empty_info[i].QueueName != NULL) {
972+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
973+ fl_que_ctrl[0] |= (ple_queue_empty_info[i].Portid <<
974+ MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
975+ fl_que_ctrl[0] |= (ple_queue_empty_info[i].Queueid <<
976+ MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
977+ } else
978+ continue;
979+
980+ if (ple_queue_empty_info[i].Queueid >=
981+ ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 &&
982+ ple_queue_empty_info[i].Queueid <=
983+ ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0)
984+ /* band0 set TGID 0, bit31 = 0 */
985+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x0);
986+ else if (ple_queue_empty_info[i].Queueid >=
987+ ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 &&
988+ ple_queue_empty_info[i].Queueid <=
989+ ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1)
990+ /* band1 set TGID 1, bit31 = 1 */
991+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x80000000);
992+
993+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
994+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
995+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
996+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK,
997+ fl_que_ctrl[1]);
998+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK,
999+ fl_que_ctrl[1]);
1000+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK,
1001+ fl_que_ctrl[2]);
1002+ }
1003+ }
1004+
1005+ vow_chip_show_sta_acq_info(dev, ple_stat, sta_pause, dis_sta_map, 0);
1006+
1007+ return 0;
1008+}
1009 static int mt7915_pleinfo_read(struct seq_file *s, void *data)
1010 {
1011 struct mt7915_dev *dev = dev_get_drvdata(s->private);
1012--
developer9851a292022-12-15 17:33:43 +080010132.18.0
developerc978ea12022-11-09 15:58:31 +08001014