blob: 5fe37109d097b59022a200b9ad89425c3f23d817 [file] [log] [blame]
developeraace7f52022-06-24 13:40:42 +08001From 4c1658312392db894fd36bbdc98476d6e6b1e32f Mon Sep 17 00:00:00 2001
2From: Shayne Chen <shayne.chen@mediatek.com>
3Date: Wed, 22 Jun 2022 10:39:47 +0800
4Subject: [PATCH 1001/1008] mt76: mt7915: add mtk internal debug tools for mt76
developer3fa816c2022-04-19 10:21:20 +08005
6---
developer42b63282022-06-16 13:33:13 +08007 mt76_connac_mcu.h | 6 +
8 mt7915/Makefile | 2 +-
9 mt7915/debugfs.c | 73 +-
10 mt7915/mac.c | 14 +
developeraace7f52022-06-24 13:40:42 +080011 mt7915/main.c | 4 +
12 mt7915/mcu.c | 44 +
developer42b63282022-06-16 13:33:13 +080013 mt7915/mcu.h | 4 +
developeraace7f52022-06-24 13:40:42 +080014 mt7915/mt7915.h | 43 +
developer42b63282022-06-16 13:33:13 +080015 mt7915/mt7915_debug.h | 1350 +++++++++++++++++++
developeraace7f52022-06-24 13:40:42 +080016 mt7915/mtk_debugfs.c | 2923 +++++++++++++++++++++++++++++++++++++++++
developer42b63282022-06-16 13:33:13 +080017 mt7915/mtk_mcu.c | 51 +
18 tools/fwlog.c | 44 +-
developeraace7f52022-06-24 13:40:42 +080019 12 files changed, 4545 insertions(+), 13 deletions(-)
developer42b63282022-06-16 13:33:13 +080020 mode change 100644 => 100755 mt7915/mcu.c
21 create mode 100644 mt7915/mt7915_debug.h
22 create mode 100644 mt7915/mtk_debugfs.c
23 create mode 100644 mt7915/mtk_mcu.c
developer3fa816c2022-04-19 10:21:20 +080024
25diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h
developeraace7f52022-06-24 13:40:42 +080026index e94d670..333d3a0 100644
developer3fa816c2022-04-19 10:21:20 +080027--- a/mt76_connac_mcu.h
28+++ b/mt76_connac_mcu.h
developeraace7f52022-06-24 13:40:42 +080029@@ -1119,6 +1119,12 @@ enum {
developer3fa816c2022-04-19 10:21:20 +080030 MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58,
31 MCU_EXT_CMD_RXDCOC_CAL = 0x59,
32 MCU_EXT_CMD_GET_MIB_INFO = 0x5a,
33+#ifdef MTK_DEBUG
34+ MCU_EXT_CMD_RED_ENABLE = 0x68,
35+ MCU_EXT_CMD_RED_SHOW_STA = 0x69,
36+ MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A,
37+ MCU_EXT_CMD_RED_TX_RPT = 0x6B,
38+#endif
39 MCU_EXT_CMD_TXDPD_CAL = 0x60,
40 MCU_EXT_CMD_CAL_CACHE = 0x67,
41 MCU_EXT_CMD_SET_RADAR_TH = 0x7c,
42diff --git a/mt7915/Makefile b/mt7915/Makefile
developeraace7f52022-06-24 13:40:42 +080043index b794ceb..a3474e2 100644
developer3fa816c2022-04-19 10:21:20 +080044--- a/mt7915/Makefile
45+++ b/mt7915/Makefile
46@@ -3,7 +3,7 @@
47 obj-$(CONFIG_MT7915E) += mt7915e.o
48
49 mt7915e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \
50- debugfs.o mmio.o
51+ debugfs.o mmio.o mtk_debugfs.o mtk_mcu.o
52
53 mt7915e-$(CONFIG_NL80211_TESTMODE) += testmode.o
54 mt7915e-$(CONFIG_MT7986_WMAC) += soc.o
55\ No newline at end of file
56diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
developeraace7f52022-06-24 13:40:42 +080057index 9f21d97..0cfb606 100644
developer3fa816c2022-04-19 10:21:20 +080058--- a/mt7915/debugfs.c
59+++ b/mt7915/debugfs.c
60@@ -8,6 +8,9 @@
61 #include "mac.h"
62
63 #define FW_BIN_LOG_MAGIC 0x44e98caf
64+#ifdef MTK_DEBUG
65+#define FW_BIN_LOG_MAGIC_V2 0x44d9c99a
66+#endif
67
68 /** global debugfs **/
69
developerf32dabf2022-06-01 10:59:24 +080070@@ -448,6 +451,9 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
developer3fa816c2022-04-19 10:21:20 +080071 int ret;
72
developer42b63282022-06-16 13:33:13 +080073 dev->fw.debug_wm = val ? MCU_FW_LOG_TO_HOST : 0;
developer3fa816c2022-04-19 10:21:20 +080074+#ifdef MTK_DEBUG
developer42b63282022-06-16 13:33:13 +080075+ dev->fw.debug_wm = val;
developer3fa816c2022-04-19 10:21:20 +080076+#endif
77
developer42b63282022-06-16 13:33:13 +080078 if (dev->fw.debug_bin)
developer3fa816c2022-04-19 10:21:20 +080079 val = 16;
developerf32dabf2022-06-01 10:59:24 +080080@@ -472,6 +478,9 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
developer3fa816c2022-04-19 10:21:20 +080081 if (ret)
developer42b63282022-06-16 13:33:13 +080082 goto out;
developer3fa816c2022-04-19 10:21:20 +080083 }
84+#ifdef MTK_DEBUG
85+ mt7915_mcu_fw_dbg_ctrl(dev, 68, !!val);
86+#endif
87
88 /* WM CPU info record control */
89 mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0));
developerf32dabf2022-06-01 10:59:24 +080090@@ -479,6 +488,12 @@ mt7915_fw_debug_wm_set(void *data, u64 val)
developer3fa816c2022-04-19 10:21:20 +080091 mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5));
92 mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5));
93
94+#ifdef MTK_DEBUG
developer42b63282022-06-16 13:33:13 +080095+ if (dev->fw.debug_bin & BIT(3))
developer3fa816c2022-04-19 10:21:20 +080096+ /* use bit 7 to indicate v2 magic number */
developer42b63282022-06-16 13:33:13 +080097+ dev->fw.debug_wm |= BIT(7);
developer3fa816c2022-04-19 10:21:20 +080098+#endif
99+
developer42b63282022-06-16 13:33:13 +0800100 out:
101 if (ret)
102 dev->fw.debug_wm = 0;
103@@ -491,7 +506,11 @@ mt7915_fw_debug_wm_get(void *data, u64 *val)
developer3fa816c2022-04-19 10:21:20 +0800104 {
105 struct mt7915_dev *dev = data;
106
developer42b63282022-06-16 13:33:13 +0800107- *val = dev->fw.debug_wm;
developer3fa816c2022-04-19 10:21:20 +0800108+#ifdef MTK_DEBUG
developer42b63282022-06-16 13:33:13 +0800109+ *val = dev->fw.debug_wm & ~BIT(7);
developer3fa816c2022-04-19 10:21:20 +0800110+#else
developer42b63282022-06-16 13:33:13 +0800111+ val = dev->fw.debug_wm;
developer3fa816c2022-04-19 10:21:20 +0800112+#endif
113
114 return 0;
115 }
developer42b63282022-06-16 13:33:13 +0800116@@ -576,6 +595,17 @@ mt7915_fw_debug_bin_set(void *data, u64 val)
developer3fa816c2022-04-19 10:21:20 +0800117
118 relay_reset(dev->relay_fwlog);
119
120+#ifdef MTK_DEBUG
121+ dev->dbg.dump_mcu_pkt = val & BIT(4) ? true : false;
122+ dev->dbg.dump_txd = val & BIT(5) ? true : false;
123+ dev->dbg.dump_tx_pkt = val & BIT(6) ? true : false;
124+ dev->dbg.dump_rx_pkt = val & BIT(7) ? true : false;
125+ dev->dbg.dump_rx_raw = val & BIT(8) ? true : false;
126+ if (!(val & GENMASK(3, 0)))
127+ return 0;
128+#endif
129+
developer42b63282022-06-16 13:33:13 +0800130+
131 return mt7915_fw_debug_wm_set(dev, dev->fw.debug_wm);
developer3fa816c2022-04-19 10:21:20 +0800132 }
133
developer42b63282022-06-16 13:33:13 +0800134@@ -1038,6 +1068,11 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
developer3fa816c2022-04-19 10:21:20 +0800135 if (!ext_phy)
136 dev->debugfs_dir = dir;
137
138+#ifdef MTK_DEBUG
139+ debugfs_create_u16("wlan_idx", 0600, dir, &dev->wlan_idx);
140+ mt7915_mtk_init_debugfs(phy, dir);
141+#endif
142+
143 return 0;
144 }
145
developer42b63282022-06-16 13:33:13 +0800146@@ -1078,17 +1113,53 @@ void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int
developer3fa816c2022-04-19 10:21:20 +0800147 .msg_type = cpu_to_le16(PKT_TYPE_RX_FW_MONITOR),
148 };
149
150+#ifdef MTK_DEBUG
151+ struct {
152+ __le32 magic;
153+ u8 version;
154+ u8 _rsv;
155+ __le16 serial_id;
156+ __le32 timestamp;
157+ __le16 msg_type;
158+ __le16 len;
159+ } hdr2 = {
160+ .version = 0x1,
161+ .magic = cpu_to_le32(FW_BIN_LOG_MAGIC_V2),
162+ .msg_type = PKT_TYPE_RX_FW_MONITOR,
163+ };
164+#endif
165+
166 if (!dev->relay_fwlog)
167 return;
168
169+#ifdef MTK_DEBUG
170+ /* old magic num */
developer42b63282022-06-16 13:33:13 +0800171+ if (!(dev->fw.debug_wm & BIT(7))) {
developer3fa816c2022-04-19 10:21:20 +0800172+ hdr.timestamp = mt76_rr(dev, MT_LPON_FRCR(0));
173+ hdr.len = *(__le16 *)data;
174+ mt7915_debugfs_write_fwlog(dev, &hdr, sizeof(hdr), data, len);
175+ } else {
176+ hdr2.serial_id = dev->dbg.fwlog_seq++;
177+ hdr2.timestamp = mt76_rr(dev, MT_LPON_FRCR(0));
178+ hdr2.len = *(__le16 *)data;
179+ mt7915_debugfs_write_fwlog(dev, &hdr2, sizeof(hdr2), data, len);
180+ }
181+#else
182 hdr.timestamp = cpu_to_le32(mt76_rr(dev, MT_LPON_FRCR(0)));
183 hdr.len = *(__le16 *)data;
184 mt7915_debugfs_write_fwlog(dev, &hdr, sizeof(hdr), data, len);
185+#endif
186 }
187
188 bool mt7915_debugfs_rx_log(struct mt7915_dev *dev, const void *data, int len)
189 {
190+#ifdef MTK_DEBUG
191+ if (get_unaligned_le32(data) != FW_BIN_LOG_MAGIC &&
192+ get_unaligned_le32(data) != FW_BIN_LOG_MAGIC_V2 &&
193+ get_unaligned_le32(data) != PKT_BIN_DEBUG_MAGIC)
194+#else
195 if (get_unaligned_le32(data) != FW_BIN_LOG_MAGIC)
196+#endif
197 return false;
198
199 if (dev->relay_fwlog)
200diff --git a/mt7915/mac.c b/mt7915/mac.c
developeraace7f52022-06-24 13:40:42 +0800201index 6a4da8e..c332e0a 100644
developer3fa816c2022-04-19 10:21:20 +0800202--- a/mt7915/mac.c
203+++ b/mt7915/mac.c
developeraace7f52022-06-24 13:40:42 +0800204@@ -239,6 +239,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
developer3fa816c2022-04-19 10:21:20 +0800205 __le16 fc = 0;
206 int idx;
207
208+#ifdef MTK_DEBUG
209+ if (dev->dbg.dump_rx_raw)
210+ mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX_RAW, 0);
211+#endif
212 memset(status, 0, sizeof(*status));
213
214 if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->band_idx) {
developeraace7f52022-06-24 13:40:42 +0800215@@ -421,6 +425,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
developer3fa816c2022-04-19 10:21:20 +0800216 }
217
218 hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad;
219+#ifdef MTK_DEBUG
220+ if (dev->dbg.dump_rx_pkt)
221+ mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX, hdr_gap);
222+#endif
223 if (hdr_trans && ieee80211_has_morefrags(fc)) {
developeraace7f52022-06-24 13:40:42 +0800224 struct ieee80211_vif *vif;
225 int err;
226@@ -760,6 +768,12 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
developer3fa816c2022-04-19 10:21:20 +0800227 tx_info->buf[1].skip_unmap = true;
228 tx_info->nbuf = MT_CT_DMA_BUF_NUM;
229
230+#ifdef MTK_DEBUG
231+ if (dev->dbg.dump_txd)
232+ mt7915_packet_log_to_host(dev, txwi, MT_TXD_SIZE, PKT_BIN_DEBUG_TXD, 0);
233+ if (dev->dbg.dump_tx_pkt)
234+ mt7915_packet_log_to_host(dev, t->skb->data, t->skb->len, PKT_BIN_DEBUG_TX, 0);
235+#endif
236 return 0;
237 }
238
developeraace7f52022-06-24 13:40:42 +0800239diff --git a/mt7915/main.c b/mt7915/main.c
240index 3958799..929c726 100644
241--- a/mt7915/main.c
242+++ b/mt7915/main.c
243@@ -62,7 +62,11 @@ static int mt7915_start(struct ieee80211_hw *hw)
244 if (ret)
245 goto out;
246
247+#ifdef MTK_DEBUG
248+ ret = mt7915_mcu_set_sku_en(phy, !dev->dbg.sku_disable);
249+#else
250 ret = mt7915_mcu_set_sku_en(phy, true);
251+#endif
252 if (ret)
253 goto out;
254
developer3fa816c2022-04-19 10:21:20 +0800255diff --git a/mt7915/mcu.c b/mt7915/mcu.c
developer1eeb8e82022-05-03 14:10:10 +0800256old mode 100644
257new mode 100755
developeraace7f52022-06-24 13:40:42 +0800258index a726021..4ff13c7
developer3fa816c2022-04-19 10:21:20 +0800259--- a/mt7915/mcu.c
260+++ b/mt7915/mcu.c
developeraace7f52022-06-24 13:40:42 +0800261@@ -195,6 +195,11 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb,
262 else
263 qid = MT_MCUQ_WM;
developer3fa816c2022-04-19 10:21:20 +0800264
developer3fa816c2022-04-19 10:21:20 +0800265+#ifdef MTK_DEBUG
266+ if (dev->dbg.dump_mcu_pkt)
267+ mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_MCU, 0);
268+#endif
developeraace7f52022-06-24 13:40:42 +0800269+
270 return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0);
271 }
272
273@@ -3164,6 +3169,8 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
274 .sku_enable = enable,
275 };
developer3fa816c2022-04-19 10:21:20 +0800276
developeraace7f52022-06-24 13:40:42 +0800277+ pr_info("%s: enable = %d\n", __func__, enable);
278+
279 return mt76_mcu_send_msg(&dev->mt76,
280 MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
281 sizeof(req), true);
282@@ -3439,6 +3446,43 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
developer3fa816c2022-04-19 10:21:20 +0800283 &req, sizeof(req), true);
284 }
developer1eeb8e82022-05-03 14:10:10 +0800285
developer3fa816c2022-04-19 10:21:20 +0800286+#ifdef MTK_DEBUG
287+int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp)
288+{
289+ struct {
290+ __le32 args[3];
291+ } req = {
292+ .args = {
293+ cpu_to_le32(a1),
294+ cpu_to_le32(a2),
295+ cpu_to_le32(a3),
296+ },
297+ };
298+
299+ return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp);
300+}
301+
302+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled)
303+{
304+#define RED_DISABLE 0
305+#define RED_BY_HOST_ENABLE 1
306+#define RED_BY_WA_ENABLE 2
307+ int ret;
308+ u32 red_type = enabled > 0 ? RED_BY_WA_ENABLE : RED_DISABLE;
309+ __le32 req = cpu_to_le32(red_type);
310+
311+ ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(RED_ENABLE), &req,
312+ sizeof(req), false);
313+ if (ret < 0)
314+ return ret;
315+
316+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
317+ MCU_WA_PARAM_RED, enabled, 0, true);
318+
319+ return 0;
320+}
321+#endif
developer1eeb8e82022-05-03 14:10:10 +0800322+
323 int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set)
324 {
325 struct {
developer3fa816c2022-04-19 10:21:20 +0800326diff --git a/mt7915/mcu.h b/mt7915/mcu.h
developeraace7f52022-06-24 13:40:42 +0800327index b82f258..b2c51bf 100644
developer3fa816c2022-04-19 10:21:20 +0800328--- a/mt7915/mcu.h
329+++ b/mt7915/mcu.h
developeraace7f52022-06-24 13:40:42 +0800330@@ -259,6 +259,10 @@ enum {
developer3fa816c2022-04-19 10:21:20 +0800331 MCU_WA_PARAM_PDMA_RX = 0x04,
332 MCU_WA_PARAM_CPU_UTIL = 0x0b,
333 MCU_WA_PARAM_RED = 0x0e,
334+#ifdef MTK_DEBUG
335+ MCU_WA_PARAM_RED_SHOW_STA = 0xf,
336+ MCU_WA_PARAM_RED_TARGET_DELAY = 0x10,
337+#endif
338 };
339
340 enum mcu_mmps_mode {
341diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
developeraace7f52022-06-24 13:40:42 +0800342index b6a6aa7..594f2fb 100644
developer3fa816c2022-04-19 10:21:20 +0800343--- a/mt7915/mt7915.h
344+++ b/mt7915/mt7915.h
345@@ -9,6 +9,7 @@
346 #include "../mt76_connac.h"
347 #include "regs.h"
348
349+#define MTK_DEBUG 1
350 #define MT7915_MAX_INTERFACES 19
developer3fa816c2022-04-19 10:21:20 +0800351 #define MT7915_WTBL_SIZE 288
developeraace7f52022-06-24 13:40:42 +0800352 #define MT7916_WTBL_SIZE 544
353@@ -338,6 +339,29 @@ struct mt7915_dev {
developer3fa816c2022-04-19 10:21:20 +0800354 struct reset_control *rstc;
355 void __iomem *dcm;
356 void __iomem *sku;
357+
358+#ifdef MTK_DEBUG
359+ u16 wlan_idx;
360+ struct {
361+ u32 fixed_rate;
362+ u32 l1debugfs_reg;
363+ u32 l2debugfs_reg;
364+ u32 mac_reg;
365+ u32 fw_dbg_module;
366+ u8 fw_dbg_lv;
367+ u32 bcn_total_cnt[2];
368+ u16 fwlog_seq;
369+ bool dump_mcu_pkt;
370+ bool dump_txd;
371+ bool dump_tx_pkt;
372+ bool dump_rx_pkt;
373+ bool dump_rx_raw;
374+ u32 token_idx;
developeraace7f52022-06-24 13:40:42 +0800375+ u8 sku_disable;
376+ u8 muru_onoff;
developer3fa816c2022-04-19 10:21:20 +0800377+ } dbg;
378+ const struct mt7915_dbg_reg_desc *dbg_reg;
379+#endif
380 };
381
382 enum {
developeraace7f52022-06-24 13:40:42 +0800383@@ -592,4 +616,23 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
developer3fa816c2022-04-19 10:21:20 +0800384 struct ieee80211_sta *sta, struct dentry *dir);
385 #endif
386
387+#ifdef MTK_DEBUG
388+int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir);
389+int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp);
390+int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled);
391+void mt7915_dump_tmac_info(u8 *tmac_info);
392+int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level);
393+void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len);
394+
395+#define PKT_BIN_DEBUG_MAGIC 0xc8763123
396+enum {
397+ PKT_BIN_DEBUG_MCU,
398+ PKT_BIN_DEBUG_TXD,
399+ PKT_BIN_DEBUG_TX,
400+ PKT_BIN_DEBUG_RX,
401+ PKT_BIN_DEBUG_RX_RAW,
402+};
403+
404+#endif
405+
406 #endif
407diff --git a/mt7915/mt7915_debug.h b/mt7915/mt7915_debug.h
408new file mode 100644
developeraace7f52022-06-24 13:40:42 +0800409index 0000000..58ba2cd
developer3fa816c2022-04-19 10:21:20 +0800410--- /dev/null
411+++ b/mt7915/mt7915_debug.h
412@@ -0,0 +1,1350 @@
413+#ifndef __MT7915_DEBUG_H
414+#define __MT7915_DEBUG_H
415+
416+#ifdef MTK_DEBUG
417+
418+#define DBG_INVALID_BASE 0xffffffff
419+#define DBG_INVALID_OFFSET 0x0
420+
421+struct __dbg_map {
422+ u32 phys;
423+ u32 maps;
424+ u32 size;
425+};
426+
427+struct __dbg_reg {
428+ u32 base;
429+ u32 offs;
430+};
431+
432+struct __dbg_mask {
433+ u32 end;
434+ u32 start;
435+};
436+
437+enum dbg_base_rev {
438+ MT_DBG_WFDMA0_BASE,
439+ MT_DBG_WFDMA1_BASE,
440+ MT_DBG_WFDMA0_PCIE1_BASE,
441+ MT_DBG_WFDMA1_PCIE1_BASE,
442+ MT_DBG_WFDMA_EXT_CSR_BASE,
443+ MT_DBG_SWDEF_BASE,
444+ __MT_DBG_BASE_REV_MAX,
445+};
446+
447+enum dbg_reg_rev {
448+ DBG_INT_SOURCE_CSR,
449+ DBG_INT_MASK_CSR,
450+ DBG_INT1_SOURCE_CSR,
451+ DBG_INT1_MASK_CSR,
452+ DBG_TX_RING_BASE,
453+ DBG_RX_EVENT_RING_BASE,
454+ DBG_RX_STS_RING_BASE,
455+ DBG_RX_DATA_RING_BASE,
456+ DBG_DMA_ICSC_FR0,
457+ DBG_DMA_ICSC_FR1,
458+ DBG_TMAC_ICSCR0,
459+ DBG_RMAC_RXICSRPT,
460+ DBG_MIB_M0SDR0,
461+ DBG_MIB_M0SDR3,
462+ DBG_MIB_M0SDR4,
463+ DBG_MIB_M0SDR5,
464+ DBG_MIB_M0SDR7,
465+ DBG_MIB_M0SDR8,
466+ DBG_MIB_M0SDR9,
467+ DBG_MIB_M0SDR10,
468+ DBG_MIB_M0SDR11,
469+ DBG_MIB_M0SDR12,
470+ DBG_MIB_M0SDR14,
471+ DBG_MIB_M0SDR15,
472+ DBG_MIB_M0SDR16,
473+ DBG_MIB_M0SDR17,
474+ DBG_MIB_M0SDR18,
475+ DBG_MIB_M0SDR19,
476+ DBG_MIB_M0SDR20,
477+ DBG_MIB_M0SDR21,
478+ DBG_MIB_M0SDR22,
479+ DBG_MIB_M0SDR23,
480+ DBG_MIB_M0DR0,
481+ DBG_MIB_M0DR1,
482+ DBG_MIB_MUBF,
483+ DBG_MIB_M0DR6,
484+ DBG_MIB_M0DR7,
485+ DBG_MIB_M0DR8,
486+ DBG_MIB_M0DR9,
487+ DBG_MIB_M0DR10,
488+ DBG_MIB_M0DR11,
489+ DBG_MIB_M0DR12,
490+ DBG_WTBLON_WDUCR,
491+ DBG_UWTBL_WDUCR,
492+ DBG_PLE_DRR_TABLE_CTRL,
493+ DBG_PLE_DRR_TABLE_RDATA,
494+ DBG_PLE_PBUF_CTRL,
495+ DBG_PLE_QUEUE_EMPTY,
496+ DBG_PLE_FREEPG_CNT,
497+ DBG_PLE_FREEPG_HEAD_TAIL,
498+ DBG_PLE_PG_HIF_GROUP,
499+ DBG_PLE_HIF_PG_INFO,
500+ DBG_PLE_PG_HIF_TXCMD_GROUP,
501+ DBG_PLE_HIF_TXCMD_PG_INFO,
502+ DBG_PLE_PG_CPU_GROUP,
503+ DBG_PLE_CPU_PG_INFO,
504+ DBG_PLE_FL_QUE_CTRL,
505+ DBG_PLE_NATIVE_TXCMD_Q_EMPTY,
506+ DBG_PLE_TXCMD_Q_EMPTY,
507+ DBG_PLE_AC_QEMPTY,
508+ DBG_PLE_AC_OFFSET,
509+ DBG_PLE_STATION_PAUSE,
510+ DBG_PLE_DIS_STA_MAP,
511+ DBG_PSE_PBUF_CTRL,
512+ DBG_PSE_FREEPG_CNT,
513+ DBG_PSE_FREEPG_HEAD_TAIL,
514+ DBG_PSE_HIF0_PG_INFO,
515+ DBG_PSE_PG_HIF1_GROUP,
516+ DBG_PSE_HIF1_PG_INFO,
517+ DBG_PSE_PG_CPU_GROUP,
518+ DBG_PSE_CPU_PG_INFO,
519+ DBG_PSE_PG_PLE_GROUP,
520+ DBG_PSE_PLE_PG_INFO,
521+ DBG_PSE_PG_LMAC0_GROUP,
522+ DBG_PSE_LMAC0_PG_INFO,
523+ DBG_PSE_PG_LMAC1_GROUP,
524+ DBG_PSE_LMAC1_PG_INFO,
525+ DBG_PSE_PG_LMAC2_GROUP,
526+ DBG_PSE_LMAC2_PG_INFO,
527+ DBG_PSE_PG_LMAC3_GROUP,
528+ DBG_PSE_LMAC3_PG_INFO,
529+ DBG_PSE_PG_MDP_GROUP,
530+ DBG_PSE_MDP_PG_INFO,
531+ DBG_PSE_PG_PLE1_GROUP,
532+ DBG_PSE_PLE1_PG_INFO,
533+ DBG_AGG_AALCR0,
534+ DBG_AGG_AALCR1,
535+ DBG_AGG_AALCR2,
536+ DBG_AGG_AALCR3,
537+ DBG_AGG_AALCR4,
538+ DBG_AGG_B0BRR0,
539+ DBG_AGG_B1BRR0,
540+ DBG_AGG_B2BRR0,
541+ DBG_AGG_B3BRR0,
542+ DBG_AGG_AWSCR0,
543+ DBG_AGG_PCR0,
544+ DBG_AGG_TTCR0,
545+ DBG_MIB_M0ARNG0,
546+ DBG_MIB_M0DR2,
547+ DBG_MIB_M0DR13,
548+ __MT_DBG_REG_REV_MAX,
549+};
550+
551+enum dbg_mask_rev {
552+ DBG_MIB_M0SDR10_RX_MDRDY_COUNT,
553+ DBG_MIB_M0SDR14_AMPDU,
554+ DBG_MIB_M0SDR15_AMPDU_ACKED,
555+ DBG_MIB_RX_FCS_ERROR_COUNT,
556+ __MT_DBG_MASK_REV_MAX,
557+};
558+
559+enum dbg_bit_rev {
560+ __MT_DBG_BIT_REV_MAX,
561+};
562+
563+static const u32 mt7915_dbg_base[] = {
564+ [MT_DBG_WFDMA0_BASE] = 0xd4000,
565+ [MT_DBG_WFDMA1_BASE] = 0xd5000,
566+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0xd8000,
567+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0xd9000,
568+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0xd7000,
569+ [MT_DBG_SWDEF_BASE] = 0x41f200,
570+};
571+
572+static const u32 mt7916_dbg_base[] = {
573+ [MT_DBG_WFDMA0_BASE] = 0xd4000,
574+ [MT_DBG_WFDMA1_BASE] = 0xd5000,
575+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0xd8000,
576+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0xd9000,
577+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0xd7000,
578+ [MT_DBG_SWDEF_BASE] = 0x411400,
579+};
580+
581+static const u32 mt7986_dbg_base[] = {
582+ [MT_DBG_WFDMA0_BASE] = 0x24000,
583+ [MT_DBG_WFDMA1_BASE] = 0x25000,
584+ [MT_DBG_WFDMA0_PCIE1_BASE] = 0x28000,
585+ [MT_DBG_WFDMA1_PCIE1_BASE] = 0x29000,
586+ [MT_DBG_WFDMA_EXT_CSR_BASE] = 0x27000,
587+ [MT_DBG_SWDEF_BASE] = 0x411400,
588+};
589+
590+/* mt7915 regs with different base and offset */
591+static const struct __dbg_reg mt7915_dbg_reg[] = {
592+ [DBG_INT_SOURCE_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x10 },
593+ [DBG_INT_MASK_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x14 },
594+ [DBG_INT1_SOURCE_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x88 },
595+ [DBG_INT1_MASK_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x8c },
596+ [DBG_TX_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x400 },
597+ [DBG_RX_EVENT_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x500 },
598+ [DBG_RX_STS_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x510 },
599+ [DBG_RX_DATA_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x500 },
600+ [DBG_DMA_ICSC_FR0] = { DBG_INVALID_BASE, 0x0f0 },
601+ [DBG_DMA_ICSC_FR1] = { DBG_INVALID_BASE, 0x0f4 },
602+ [DBG_TMAC_ICSCR0] = { DBG_INVALID_BASE, 0x200 },
603+ [DBG_RMAC_RXICSRPT] = { DBG_INVALID_BASE, 0x618},
604+ [DBG_MIB_M0SDR0] = { DBG_INVALID_BASE, 0x010},
605+ [DBG_MIB_M0SDR3] = { DBG_INVALID_BASE, 0x014},
606+ [DBG_MIB_M0SDR4] = { DBG_INVALID_BASE, 0x018},
607+ [DBG_MIB_M0SDR5] = { DBG_INVALID_BASE, 0x01c},
608+ [DBG_MIB_M0SDR7] = { DBG_INVALID_BASE, 0x024},
609+ [DBG_MIB_M0SDR8] = { DBG_INVALID_BASE, 0x028},
610+ [DBG_MIB_M0SDR9] = { DBG_INVALID_BASE, 0x02C},
611+ [DBG_MIB_M0SDR10] = { DBG_INVALID_BASE, 0x030},
612+ [DBG_MIB_M0SDR11] = { DBG_INVALID_BASE, 0x034},
613+ [DBG_MIB_M0SDR12] = { DBG_INVALID_BASE, 0x038},
614+ [DBG_MIB_M0SDR14] = { DBG_INVALID_BASE, 0x040},
615+ [DBG_MIB_M0SDR15] = { DBG_INVALID_BASE, 0x044},
616+ [DBG_MIB_M0SDR16] = { DBG_INVALID_BASE, 0x048},
617+ [DBG_MIB_M0SDR17] = { DBG_INVALID_BASE, 0x04c},
618+ [DBG_MIB_M0SDR18] = { DBG_INVALID_BASE, 0x050},
619+ [DBG_MIB_M0SDR19] = { DBG_INVALID_BASE, 0x054},
620+ [DBG_MIB_M0SDR20] = { DBG_INVALID_BASE, 0x058},
621+ [DBG_MIB_M0SDR21] = { DBG_INVALID_BASE, 0x05c},
622+ [DBG_MIB_M0SDR22] = { DBG_INVALID_BASE, 0x060},
623+ [DBG_MIB_M0SDR23] = { DBG_INVALID_BASE, 0x064},
624+ [DBG_MIB_M0DR0] = { DBG_INVALID_BASE, 0x0a0},
625+ [DBG_MIB_M0DR1] = { DBG_INVALID_BASE, 0x0a4},
626+ [DBG_MIB_MUBF] = { DBG_INVALID_BASE, 0x090},
627+ [DBG_MIB_M0DR6] = { DBG_INVALID_BASE, 0x0b8},
628+ [DBG_MIB_M0DR7] = { DBG_INVALID_BASE, 0x0bc},
629+ [DBG_MIB_M0DR8] = { DBG_INVALID_BASE, 0x0c0},
630+ [DBG_MIB_M0DR9] = { DBG_INVALID_BASE, 0x0c4},
631+ [DBG_MIB_M0DR10] = { DBG_INVALID_BASE, 0x0c8},
632+ [DBG_MIB_M0DR11] = { DBG_INVALID_BASE, 0x0cc},
633+ [DBG_MIB_M0DR12] = { DBG_INVALID_BASE, 0x160},
634+ [DBG_WTBLON_WDUCR] = { DBG_INVALID_BASE, 0x0},
635+ [DBG_UWTBL_WDUCR] = { DBG_INVALID_BASE, 0x0},
636+ [DBG_PLE_DRR_TABLE_CTRL] = { DBG_INVALID_BASE, 0x388},
637+ [DBG_PLE_DRR_TABLE_RDATA] = { DBG_INVALID_BASE, 0x350},
638+ [DBG_PLE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x014},
639+ [DBG_PLE_QUEUE_EMPTY] = { DBG_INVALID_BASE, 0x0b0},
640+ [DBG_PLE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x100},
641+ [DBG_PLE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x104},
642+ [DBG_PLE_PG_HIF_GROUP] = { DBG_INVALID_BASE, 0x110},
643+ [DBG_PLE_HIF_PG_INFO] = { DBG_INVALID_BASE, 0x114},
644+ [DBG_PLE_PG_HIF_TXCMD_GROUP] = { DBG_INVALID_BASE, 0x120},
645+ [DBG_PLE_HIF_TXCMD_PG_INFO] = { DBG_INVALID_BASE, 0x124},
646+ [DBG_PLE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x150},
647+ [DBG_PLE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x154},
648+ [DBG_PLE_FL_QUE_CTRL] = { DBG_INVALID_BASE, 0x1b0},
649+ [DBG_PLE_NATIVE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x22c},
650+ [DBG_PLE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x230},
651+ [DBG_PLE_AC_QEMPTY] = { DBG_INVALID_BASE, 0x500},
652+ [DBG_PLE_AC_OFFSET] = { DBG_INVALID_BASE, 0x040},
653+ [DBG_PLE_STATION_PAUSE] = { DBG_INVALID_BASE, 0x400},
654+ [DBG_PLE_DIS_STA_MAP] = { DBG_INVALID_BASE, 0x440},
developerf32dabf2022-06-01 10:59:24 +0800655+ [DBG_PSE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x014},
developer3fa816c2022-04-19 10:21:20 +0800656+ [DBG_PSE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x100},
657+ [DBG_PSE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x104},
658+ [DBG_PSE_HIF0_PG_INFO] = { DBG_INVALID_BASE, 0x114},
659+ [DBG_PSE_PG_HIF1_GROUP] = { DBG_INVALID_BASE, 0x118},
660+ [DBG_PSE_HIF1_PG_INFO] = { DBG_INVALID_BASE, 0x11c},
661+ [DBG_PSE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x150},
662+ [DBG_PSE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x154},
663+ [DBG_PSE_PG_PLE_GROUP] = { DBG_INVALID_BASE, 0x160},
664+ [DBG_PSE_PLE_PG_INFO] = { DBG_INVALID_BASE, 0x164},
665+ [DBG_PSE_PG_LMAC0_GROUP] = { DBG_INVALID_BASE, 0x170},
666+ [DBG_PSE_LMAC0_PG_INFO] = { DBG_INVALID_BASE, 0x174},
667+ [DBG_PSE_PG_LMAC1_GROUP] = { DBG_INVALID_BASE, 0x178},
668+ [DBG_PSE_LMAC1_PG_INFO] = { DBG_INVALID_BASE, 0x17c},
669+ [DBG_PSE_PG_LMAC2_GROUP] = { DBG_INVALID_BASE, 0x180},
670+ [DBG_PSE_LMAC2_PG_INFO] = { DBG_INVALID_BASE, 0x184},
671+ [DBG_PSE_PG_LMAC3_GROUP] = { DBG_INVALID_BASE, 0x188},
672+ [DBG_PSE_LMAC3_PG_INFO] = { DBG_INVALID_BASE, 0x18c},
673+ [DBG_PSE_PG_MDP_GROUP] = { DBG_INVALID_BASE, 0x198},
674+ [DBG_PSE_MDP_PG_INFO] = { DBG_INVALID_BASE, 0x19c},
675+ [DBG_PSE_PG_PLE1_GROUP] = { DBG_INVALID_BASE, 0x168},
676+ [DBG_PSE_PLE1_PG_INFO] = { DBG_INVALID_BASE, 0x16c},
677+ [DBG_AGG_AALCR0] = { DBG_INVALID_BASE, 0x048},
678+ [DBG_AGG_AALCR1] = { DBG_INVALID_BASE, 0x04c},
679+ [DBG_AGG_AALCR2] = { DBG_INVALID_BASE, 0x050},
680+ [DBG_AGG_AALCR3] = { DBG_INVALID_BASE, 0x054},
681+ [DBG_AGG_AALCR4] = { DBG_INVALID_BASE, 0x058},
682+ [DBG_AGG_B0BRR0] = { DBG_INVALID_BASE, 0x100},
683+ [DBG_AGG_B1BRR0] = { DBG_INVALID_BASE, 0x104},
684+ [DBG_AGG_B2BRR0] = { DBG_INVALID_BASE, 0x108},
685+ [DBG_AGG_B3BRR0] = { DBG_INVALID_BASE, 0x10c},
686+ [DBG_AGG_AWSCR0] = { DBG_INVALID_BASE, 0x030},
687+ [DBG_AGG_PCR0] = { DBG_INVALID_BASE, 0x040},
688+ [DBG_AGG_TTCR0] = { DBG_INVALID_BASE, 0x04c},
689+ [DBG_MIB_M0ARNG0] = { DBG_INVALID_BASE, 0x4b8},
690+ [DBG_MIB_M0DR2] = { DBG_INVALID_BASE, 0x0a8},
691+ [DBG_MIB_M0DR13] = { DBG_INVALID_BASE, 0x164},
692+};
693+
694+/* mt7986/mt7916 regs with different base and offset */
695+static const struct __dbg_reg mt7916_dbg_reg[] = {
696+ [DBG_INT_SOURCE_CSR] = { MT_DBG_WFDMA0_BASE, 0x200 },
697+ [DBG_INT_MASK_CSR] = { MT_DBG_WFDMA0_BASE, 0x204 },
698+ [DBG_INT1_SOURCE_CSR] = { MT_DBG_WFDMA0_PCIE1_BASE, 0x200 },
699+ [DBG_INT1_MASK_CSR] = { MT_DBG_WFDMA0_PCIE1_BASE, 0x204 },
700+ [DBG_TX_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x400 },
701+ [DBG_RX_EVENT_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x500 },
702+ [DBG_RX_STS_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x520 },
703+ [DBG_RX_DATA_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x540 },
704+ [DBG_DMA_ICSC_FR0] = { DBG_INVALID_BASE, 0x05c },
705+ [DBG_DMA_ICSC_FR1] = { DBG_INVALID_BASE, 0x060 },
706+ [DBG_TMAC_ICSCR0] = { DBG_INVALID_BASE, 0x120 },
707+ [DBG_RMAC_RXICSRPT] = { DBG_INVALID_BASE, 0xd0 },
708+ [DBG_MIB_M0SDR0] = { DBG_INVALID_BASE, 0x7d8},
709+ [DBG_MIB_M0SDR3] = { DBG_INVALID_BASE, 0x698},
710+ [DBG_MIB_M0SDR4] = { DBG_INVALID_BASE, 0x788},
711+ [DBG_MIB_M0SDR5] = { DBG_INVALID_BASE, 0x780},
712+ [DBG_MIB_M0SDR7] = { DBG_INVALID_BASE, 0x5a8},
713+ [DBG_MIB_M0SDR8] = { DBG_INVALID_BASE, 0x78c},
714+ [DBG_MIB_M0SDR9] = { DBG_INVALID_BASE, 0x024},
715+ [DBG_MIB_M0SDR10] = { DBG_INVALID_BASE, 0x76c},
716+ [DBG_MIB_M0SDR11] = { DBG_INVALID_BASE, 0x790},
717+ [DBG_MIB_M0SDR12] = { DBG_INVALID_BASE, 0x558},
718+ [DBG_MIB_M0SDR14] = { DBG_INVALID_BASE, 0x564},
719+ [DBG_MIB_M0SDR15] = { DBG_INVALID_BASE, 0x564},
720+ [DBG_MIB_M0SDR16] = { DBG_INVALID_BASE, 0x7fc},
721+ [DBG_MIB_M0SDR17] = { DBG_INVALID_BASE, 0x800},
722+ [DBG_MIB_M0SDR18] = { DBG_INVALID_BASE, 0x030},
723+ [DBG_MIB_M0SDR19] = { DBG_INVALID_BASE, 0x5ac},
724+ [DBG_MIB_M0SDR20] = { DBG_INVALID_BASE, 0x5b0},
725+ [DBG_MIB_M0SDR21] = { DBG_INVALID_BASE, 0x5b4},
726+ [DBG_MIB_M0SDR22] = { DBG_INVALID_BASE, 0x770},
727+ [DBG_MIB_M0SDR23] = { DBG_INVALID_BASE, 0x774},
728+ [DBG_MIB_M0DR0] = { DBG_INVALID_BASE, 0x594},
729+ [DBG_MIB_M0DR1] = { DBG_INVALID_BASE, 0x598},
730+ [DBG_MIB_MUBF] = { DBG_INVALID_BASE, 0x7ac},
731+ [DBG_MIB_M0DR6] = { DBG_INVALID_BASE, 0x658},
732+ [DBG_MIB_M0DR7] = { DBG_INVALID_BASE, 0x65c},
733+ [DBG_MIB_M0DR8] = { DBG_INVALID_BASE, 0x56c},
734+ [DBG_MIB_M0DR9] = { DBG_INVALID_BASE, 0x570},
735+ [DBG_MIB_M0DR10] = { DBG_INVALID_BASE, 0x578},
736+ [DBG_MIB_M0DR11] = { DBG_INVALID_BASE, 0x574},
737+ [DBG_MIB_M0DR12] = { DBG_INVALID_BASE, 0x654},
738+ [DBG_WTBLON_WDUCR] = { DBG_INVALID_BASE, 0x200},
739+ [DBG_UWTBL_WDUCR] = { DBG_INVALID_BASE, 0x094},
740+ [DBG_PLE_DRR_TABLE_CTRL] = { DBG_INVALID_BASE, 0x490},
741+ [DBG_PLE_DRR_TABLE_RDATA] = { DBG_INVALID_BASE, 0x470},
742+ [DBG_PLE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x004},
743+ [DBG_PLE_QUEUE_EMPTY] = { DBG_INVALID_BASE, 0x360},
744+ [DBG_PLE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x380},
745+ [DBG_PLE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x384},
746+ [DBG_PLE_PG_HIF_GROUP] = { DBG_INVALID_BASE, 0x00c},
747+ [DBG_PLE_HIF_PG_INFO] = { DBG_INVALID_BASE, 0x388},
748+ [DBG_PLE_PG_HIF_TXCMD_GROUP] = { DBG_INVALID_BASE, 0x014},
749+ [DBG_PLE_HIF_TXCMD_PG_INFO] = { DBG_INVALID_BASE, 0x390},
750+ [DBG_PLE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x018},
751+ [DBG_PLE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x394},
752+ [DBG_PLE_FL_QUE_CTRL] = { DBG_INVALID_BASE, 0x3e0},
753+ [DBG_PLE_NATIVE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x370},
developerf32dabf2022-06-01 10:59:24 +0800754+ [DBG_PLE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x36c},
developer3fa816c2022-04-19 10:21:20 +0800755+ [DBG_PLE_AC_QEMPTY] = { DBG_INVALID_BASE, 0x600},
756+ [DBG_PLE_AC_OFFSET] = { DBG_INVALID_BASE, 0x080},
757+ [DBG_PLE_STATION_PAUSE] = { DBG_INVALID_BASE, 0x100},
758+ [DBG_PLE_DIS_STA_MAP] = { DBG_INVALID_BASE, 0x180},
759+ [DBG_PSE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x004},
760+ [DBG_PSE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x380},
761+ [DBG_PSE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x384},
762+ [DBG_PSE_HIF0_PG_INFO] = { DBG_INVALID_BASE, 0x150},
763+ [DBG_PSE_PG_HIF1_GROUP] = { DBG_INVALID_BASE, 0x154},
764+ [DBG_PSE_HIF1_PG_INFO] = { DBG_INVALID_BASE, 0x160},
765+ [DBG_PSE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x118},
766+ [DBG_PSE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x158},
767+ [DBG_PSE_PG_PLE_GROUP] = { DBG_INVALID_BASE, 0x11c},
768+ [DBG_PSE_PLE_PG_INFO] = { DBG_INVALID_BASE, 0x15c},
769+ [DBG_PSE_PG_LMAC0_GROUP] = { DBG_INVALID_BASE, 0x124},
770+ [DBG_PSE_LMAC0_PG_INFO] = { DBG_INVALID_BASE, 0x164},
771+ [DBG_PSE_PG_LMAC1_GROUP] = { DBG_INVALID_BASE, 0x128},
772+ [DBG_PSE_LMAC1_PG_INFO] = { DBG_INVALID_BASE, 0x168},
773+ [DBG_PSE_PG_LMAC2_GROUP] = { DBG_INVALID_BASE, 0x12c},
774+ [DBG_PSE_LMAC2_PG_INFO] = { DBG_INVALID_BASE, 0x16c},
775+ [DBG_PSE_PG_LMAC3_GROUP] = { DBG_INVALID_BASE, 0x130},
776+ [DBG_PSE_LMAC3_PG_INFO] = { DBG_INVALID_BASE, 0x17c},
777+ [DBG_PSE_PG_MDP_GROUP] = { DBG_INVALID_BASE, 0x134},
778+ [DBG_PSE_MDP_PG_INFO] = { DBG_INVALID_BASE, 0x174},
779+ [DBG_PSE_PG_PLE1_GROUP] = { DBG_INVALID_BASE, 0x120},
780+ [DBG_PSE_PLE1_PG_INFO] = { DBG_INVALID_BASE, 0x160},
781+ [DBG_AGG_AALCR0] = { DBG_INVALID_BASE, 0x028},
782+ [DBG_AGG_AALCR1] = { DBG_INVALID_BASE, 0x144},
783+ [DBG_AGG_AALCR2] = { DBG_INVALID_BASE, 0x14c},
784+ [DBG_AGG_AALCR3] = { DBG_INVALID_BASE, 0x154},
785+ [DBG_AGG_AALCR4] = { DBG_INVALID_BASE, 0x02c},
786+ [DBG_AGG_B0BRR0] = { DBG_INVALID_BASE, 0x08c},
787+ [DBG_AGG_B1BRR0] = { DBG_INVALID_BASE, 0x148},
788+ [DBG_AGG_B2BRR0] = { DBG_INVALID_BASE, 0x150},
789+ [DBG_AGG_B3BRR0] = { DBG_INVALID_BASE, 0x158},
790+ [DBG_AGG_AWSCR0] = { DBG_INVALID_BASE, 0x05c},
791+ [DBG_AGG_PCR0] = { DBG_INVALID_BASE, 0x06c},
792+ [DBG_AGG_TTCR0] = { DBG_INVALID_BASE, 0x07c},
793+ [DBG_MIB_M0ARNG0] = { DBG_INVALID_BASE, 0x0b0},
794+ [DBG_MIB_M0DR2] = { DBG_INVALID_BASE, 0x7dc},
795+ [DBG_MIB_M0DR13] = { DBG_INVALID_BASE, 0x7ec},
796+};
797+
798+static const struct __dbg_mask mt7915_dbg_mask[] = {
799+ [DBG_MIB_M0SDR10_RX_MDRDY_COUNT]= {25, 0},
800+ [DBG_MIB_M0SDR14_AMPDU] = {23, 0},
801+ [DBG_MIB_M0SDR15_AMPDU_ACKED] = {23, 0},
802+ [DBG_MIB_RX_FCS_ERROR_COUNT] = {15, 0},
803+};
804+
805+static const struct __dbg_mask mt7916_dbg_mask[] = {
806+ [DBG_MIB_M0SDR10_RX_MDRDY_COUNT]= {31, 0},
807+ [DBG_MIB_M0SDR14_AMPDU] = {31, 0},
808+ [DBG_MIB_M0SDR15_AMPDU_ACKED] = {31, 0},
809+ [DBG_MIB_RX_FCS_ERROR_COUNT] = {31, 16},
810+};
811+
812+/* used to differentiate between generations */
813+struct mt7915_dbg_reg_desc {
814+ const u32 id;
815+ const u32 *base_rev;
816+ const struct __dbg_reg *reg_rev;
817+ const struct __dbg_mask *mask_rev;
818+};
819+
820+static const struct mt7915_dbg_reg_desc dbg_reg_s[] = {
821+ { 0x7915,
822+ mt7915_dbg_base,
823+ mt7915_dbg_reg,
824+ mt7915_dbg_mask
825+ },
826+ { 0x7906,
827+ mt7916_dbg_base,
828+ mt7916_dbg_reg,
829+ mt7916_dbg_mask
830+ },
831+ { 0x7986,
832+ mt7986_dbg_base,
833+ mt7916_dbg_reg,
834+ mt7916_dbg_mask
835+ },
836+};
837+
838+struct bin_debug_hdr {
839+ __le32 magic_num;
840+ __le16 serial_id;
841+ __le16 msg_type;
842+ __le16 len;
843+ __le16 des_len; /* descriptor len for rxd */
844+} __packed;
845+
846+#define __DBG_REG_MAP(_dev, id, ofs) ((_dev)->dbg_reg->base_rev[(id)] + (ofs))
847+#define __DBG_REG_BASE(_dev, id) ((_dev)->dbg_reg->reg_rev[(id)].base)
848+#define __DBG_REG_OFFS(_dev, id) ((_dev)->dbg_reg->reg_rev[(id)].offs)
849+
850+#define __DBG_MASK(_dev, id) GENMASK((_dev)->dbg_reg->mask_rev[(id)].end, \
851+ (_dev)->dbg_reg->mask_rev[(id)].start)
852+#define __DBG_REG(_dev, id) __DBG_REG_MAP((_dev), __DBG_REG_BASE((_dev), (id)), \
853+ __DBG_REG_OFFS((_dev), (id)))
854+
855+#define __DBG_FIELD_GET(id, _reg) (((_reg) & __DBG_MASK(dev, (id))) >> \
856+ dev->dbg_reg->mask_rev[(id)].start)
857+#define __DBG_FIELD_PREP(id, _reg) (((_reg) << dev->dbg_reg->mask_rev[(id)].start) & \
858+ __DBG_MASK(dev, (id)))
859+
860+
861+#define MT_DBG_TX_RING_BASE __DBG_REG(dev, DBG_TX_RING_BASE)
862+#define MT_DBG_RX_EVENT_RING_BASE __DBG_REG(dev, DBG_RX_EVENT_RING_BASE)
863+#define MT_DBG_RX_STS_RING_BASE __DBG_REG(dev, DBG_RX_STS_RING_BASE)
864+#define MT_DBG_RX_DATA_RING_BASE __DBG_REG(dev, DBG_RX_DATA_RING_BASE)
865+
866+#define MT_DBG_TX_RING_CTRL(n) (MT_DBG_TX_RING_BASE + (0x10 * (n)))
867+#define MT_DBG_RX_DATA_RING_CTRL(n) (MT_DBG_RX_DATA_RING_BASE + (0x10 * (n)))
868+#define MT_DBG_RX_EVENT_RING_CTRL(n) (MT_DBG_RX_EVENT_RING_BASE + (0x10 * (n)))
869+
870+/* WFDMA COMMON */
871+#define MT_DBG_INT_SOURCE_CSR __DBG_REG(dev, DBG_INT_SOURCE_CSR)
872+#define MT_DBG_INT_MASK_CSR __DBG_REG(dev, DBG_INT_MASK_CSR)
873+#define MT_DBG_INT1_SOURCE_CSR __DBG_REG(dev, DBG_INT1_SOURCE_CSR)
874+#define MT_DBG_INT1_MASK_CSR __DBG_REG(dev, DBG_INT1_MASK_CSR)
875+
876+/* WFDMA0 */
877+#define MT_DBG_WFDMA0(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA0_BASE, (_ofs))
878+
879+#define MT_DBG_WFDMA0_INT_SOURCE_CSR MT_DBG_WFDMA0(0x200)
880+#define MT_DBG_WFDMA0_INT_MASK_CSR MT_DBG_WFDMA0(0x204)
881+
882+#define MT_DBG_WFDMA0_GLO_CFG MT_DBG_WFDMA0(0x208)
883+#define MT_DBG_WFDMA0_GLO_CFG_TX_DMA_EN BIT(0)
884+#define MT_DBG_WFDMA0_GLO_CFG_RX_DMA_EN BIT(2)
885+#define MT_DBG_WFDMA0_GLO_CFG_TX_BUSY_MASK BIT(1)
886+#define MT_DBG_WFDMA0_GLO_CFG_RX_BUSY_MASK BIT(3)
887+
888+
889+/* WFDMA1 */
890+#define MT_DBG_WFDMA1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA1_BASE, (_ofs))
891+#define MT_DBG_WFDMA1_INT_SOURCE_CSR MT_DBG_WFDMA1(0x200)
892+#define MT_DBG_WFDMA1_INT_MASK_CSR MT_DBG_WFDMA1(0x204)
893+
894+#define MT_DBG_WFDMA1_GLO_CFG MT_DBG_WFDMA1(0x208)
895+
896+#define MT_DBG_WFDMA1_GLO_CFG_TX_DMA_EN BIT(0)
897+#define MT_DBG_WFDMA1_GLO_CFG_RX_DMA_EN BIT(2)
898+#define MT_DBG_WFDMA1_GLO_CFG_TX_BUSY_MASK BIT(1)
899+#define MT_DBG_WFDMA1_GLO_CFG_RX_BUSY_MASK BIT(3)
900+
901+/* WFDMA0 PCIE1 */
902+#define MT_DBG_WFDMA0_PCIE1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA0_PCIE1_BASE, (_ofs))
903+
904+#define MT_DBG_WFDMA0_PCIE1_INT_SOURCE_CSR MT_DBG_WFDMA0_PCIE1(0x200)
905+#define MT_DBG_WFDMA0_PCIE1_INT_MASK_CSR MT_DBG_WFDMA0_PCIE1(0x204)
906+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG MT_DBG_WFDMA0_PCIE1(0x208)
907+#define MT_DBG_WFDMA0_PCIE1_RX1_CTRL0 MT_DBG_WFDMA1_PCIE1(0x510)
908+
909+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN BIT(0)
910+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK BIT(1)
911+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN BIT(2)
912+#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK BIT(3)
913+
914+/* WFDMA1 PCIE1 */
915+#define MT_DBG_WFDMA1_PCIE1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA1_PCIE1_BASE, (_ofs))
916+#define MT_DBG_WFDMA1_PCIE1_INT_SOURCE_CSR MT_DBG_WFDMA1_PCIE1(0x200)
917+#define MT_DBG_WFDMA1_PCIE1_INT_MASK_CSR MT_DBG_WFDMA1_PCIE1(0x204)
918+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG MT_DBG_WFDMA1_PCIE1(0x208)
919+#define MT_DBG_WFDMA1_PCIE1_TX19_CTRL0 MT_DBG_WFDMA1_PCIE1(0x330)
920+#define MT_DBG_WFDMA1_PCIE1_RX2_CTRL0 MT_DBG_WFDMA1_PCIE1(0x520)
921+
922+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_TX_DMA_EN BIT(0)
923+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_TX_BUSY_MASK BIT(1)
924+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_RX_DMA_EN BIT(2)
925+#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_RX_BUSY_MASK BIT(3)
926+
927+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_EN_MASK BIT(2)
928+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_EN_MASK BIT(0)
929+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_BUSY_MASK BIT(3)
930+#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_BUSY_MASK BIT(1)
931+
932+
933+/* WF DMA TOP: band 0(0x820E7000),band 1(0x820F7000) */
934+#define MT_DBG_WF_DMA_BASE(_band) ((_band) ? 0x820F7000 : 0x820E7000)
935+#define MT_DBG_WF_DMA(_band, ofs) (MT_WF_DMA_BASE(_band) + (ofs))
936+
937+#define MT_DBG_DMA_DCR0(_band) MT_DBG_WF_DMA((_band), 0x000)
938+#define MT_DBG_DMA_DCR0_MAX_RX_LEN GENMASK(15, 3)
939+#define MT_DBG_DMA_DCR0_RXD_G5_EN BIT(23)
940+
941+#define MT_DBG_DMA_ICSC_FR0(_band) MT_DBG_WF_DMA((_band), __DBG_REG_OFFS(dev, DBG_DMA_ICSC_FR0))
942+#define MT_DBG_DMA_ICSC_FR0_RXBF_EN BIT(25)
943+#define MT_DBG_DMA_ICSC_FR0_EN BIT(24)
944+#define MT_DBG_DMA_ICSC_FR0_TOUT_MASK GENMASK(23, 16)
945+#define MT_DBG_DMA_ICSC_FR0_PID_MASK GENMASK(9, 8)
946+#define MT_DBG_DMA_ICSC_FR0_QID_MASK GENMASK(6, 0)
947+
948+#define MT_DBG_DMA_ICSC_FR1(_band) MT_DBG_WF_DMA((_band), __DBG_REG_OFFS(dev, DBG_DMA_ICSC_FR1))
949+#define MT_DBG_DMA_ICSC_FR1_AGG_SIZE_MASK GENMASK(26, 16)
950+#define MT_DBG_DMA_ICSC_FR1_MAX_FRAME_SIZE_MASK GENMASK(10, 0)
951+
952+/* TMAC: band 0(0x820e4000), band 1(0x820f4000) */
953+#define MT_DBG_WF_TMAC_BASE(_band) ((_band) ? 0x820f4000 : 0x820e4000)
954+#define MT_DBG_WF_TMAC(_band, ofs) (MT_DBG_WF_TMAC_BASE(_band) + (ofs))
955+
956+#define MT_DBG_TMAC_ICSCR0(_band) MT_DBG_WF_TMAC((_band), __DBG_REG_OFFS(dev, DBG_TMAC_ICSCR0))
957+#define MT_DBG_TMAC_ICSCR0_ICSRPT_EN BIT(0)
958+
959+/* RMAC: band 0(0x820E5000), band 1(0x820f5000) */
960+#define MT_DBG_WF_RMAC_BASE(_band) ((_band) ? 0x820f5000 : 0x820E5000)
961+#define MT_DBG_WF_RMAC(_band, ofs) (MT_DBG_WF_RMAC_BASE(_band) + (ofs))
962+
963+#define MT_DBG_RMAC_RXICSRPT(_band) MT_DBG_WF_RMAC((_band), __DBG_REG_OFFS(dev, DBG_RMAC_RXICSRPT))
964+#define MT_DBG_RMAC_RXICSRPT_ICSRPT_EN BIT(0)
965+
966+/* MIB: band 0(0x820ed000), band 1(0x820fd000) */
967+#define MT_DBG_MIB_BASE(_band) ((_band) ? 0x820fd000 : 0x820ed000)
968+#define MT_DBG_MIB(_band, ofs) (MT_DBG_MIB_BASE(_band) + (ofs))
969+
970+
971+#define MT_DBG_MIB_M0SCR0(_band) MT_DBG_MIB((_band), 0x00)
972+#define MT_DBG_MIB_M0PBSCR(_band) MT_DBG_MIB((_band), 0x04)
973+
974+#define MT_DBG_MIB_M0SDR0(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR0))
975+#define MT_DBG_MIB_M0SDR3(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR3))
976+#define MT_DBG_MIB_RX_FCS_ERROR_COUNT_MASK __DBG_MASK(dev, DBG_MIB_RX_FCS_ERROR_COUNT)
977+#define MT_DBG_MIB_M0SDR4(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR4))
978+#define MT_DBG_MIB_M0SDR5(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR5))
979+#define MT_DBG_MIB_M0SDR6(_band) MT_DBG_MIB((_band), 0x20)
980+#define MT_DBG_MIB_M0SDR7(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR7))
981+#define MT_DBG_MIB_M0SDR8(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR8))
982+#define MT_DBG_MIB_M0SDR9(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR9))
983+#define MT_DBG_MIB_M0SDR10(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR10))
984+#define MT_DBG_MIB_M0SDR10_RX_MDRDY_COUNT_MASK __DBG_MASK(dev, DBG_MIB_M0SDR10_RX_MDRDY_COUNT)
985+#define MT_DBG_MIB_M0SDR11(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR11))
986+
987+#define MT_DBG_MIB_M0SDR12(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR12))
988+
989+#define MT_DBG_MIB_M0SDR14(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR14))
990+#define MT_DBG_MIB_M0SDR14_AMPDU_MASK __DBG_MASK(dev, DBG_MIB_M0SDR14_AMPDU)
991+#define MT_DBG_MIB_M0SDR15(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR15))
992+#define MT_DBG_MIB_M0SDR15_AMPDU_ACKED_MASK __DBG_MASK(dev, DBG_MIB_M0SDR15_AMPDU_ACKED)
993+#define MT_DBG_MIB_M0SDR16(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR16))
994+#define MT_DBG_MIB_M0SDR17(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR17))
995+#define MT_DBG_MIB_M0SDR18(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR18))
996+#define MT_DBG_MIB_M0SDR19(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR19))
997+#define MT_DBG_MIB_M0SDR20(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR20))
998+#define MT_DBG_MIB_M0SDR21(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR21))
999+#define MT_DBG_MIB_M0SDR22(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR22))
1000+#define MT_DBG_MIB_M0SDR23(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR23))
1001+#define MT_DBG_MIB_M0DR0(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR0))
1002+#define MT_DBG_MIB_M0DR1(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR1))
1003+
1004+#define MT_DBG_MIB_MUBF(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_MUBF))
1005+#define MT_DBG_MIB_M0DR6(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR6))
1006+#define MT_DBG_MIB_M0DR7(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR7))
1007+#define MT_DBG_MIB_M0DR8(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR8))
1008+#define MT_DBG_MIB_M0DR9(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR9))
1009+#define MT_DBG_MIB_M0DR10(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR10))
1010+#define MT_DBG_MIB_M0DR11(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR11))
1011+ #define MT_DBG_MIB_M0DR12(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR12))
1012+
1013+/* WTBLON TOP: 0x820D4000/pcie(0x34000) rbus(0x434000) */
1014+#define MT_DBG_WTBLON_TOP_BASE 0x820D4000
1015+#define MT_DBG_WTBLON_TOP(ofs) (MT_WTBLON_TOP_BASE + (ofs))
1016+#define MT_DBG_WTBLON_TOP_WDUCR MT_DBG_WTBLON_TOP(__DBG_REG_OFFS(dev, DBG_WTBLON_WDUCR))
1017+#define MT_DBG_WTBLON_TOP_WDUCR_GROUP GENMASK(2, 0)
1018+
1019+#define WF_WTBLON_TOP_B0BTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1000) // 5000
1020+#define WF_WTBLON_TOP_B0BTBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1010) // 5010
1021+#define WF_WTBLON_TOP_B0BRCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1020) // 5020
1022+#define WF_WTBLON_TOP_B0BRBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1030) // 5030
1023+#define WF_WTBLON_TOP_B0BTDCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1040) // 5040
1024+#define WF_WTBLON_TOP_B0BRDCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1050) // 5050
1025+#define WF_WTBLON_TOP_B0MBTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1100) // 5100
1026+#define WF_WTBLON_TOP_B0MBTBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1140) // 5140
1027+#define WF_WTBLON_TOP_B0MBRCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1180) // 5180
1028+#define WF_WTBLON_TOP_B0MBRBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x11C0) // 51C0
1029+
1030+#define WF_WTBLON_TOP_B1BTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1800) // 5800
1031+
1032+/* WTBLON TOP: 0x820C4000/pcie(0xa8000) rbus(0x4a8000) */
1033+#define MT_DBG_UWTBL_TOP_BASE 0x820C4000
1034+#define MT_DBG_UWTBL_TOP(ofs) (MT_DBG_UWTBL_TOP_BASE + (ofs))
1035+
1036+#define MT_DBG_UWTBL_TOP_WDUCR MT_DBG_WTBLON_TOP(__DBG_REG_OFFS(dev, DBG_UWTBL_WDUCR))
1037+
1038+#define MT_UWTBL_TOP_WDUCR_TARGET BIT(31)
1039+#define MT_UWTBL_TOP_WDUCR_GROUP GENMASK(3, 0)
1040+
1041+
1042+/* WTBL : 0x820D8000/pcie(0x38000) rbus(0x438000) */
1043+#define MT_DBG_WTBL_BASE 0x820D8000
1044+
1045+/* PLE related CRs. */
1046+#define MT_DBG_PLE_BASE 0x820C0000
1047+#define MT_DBG_PLE(ofs) (MT_DBG_PLE_BASE + (ofs))
1048+
1049+#define MT_DBG_PLE_DRR_TAB_CTRL MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_DRR_TABLE_CTRL))
1050+#define MT_DBG_PLE_DRR_TAB_RD_OFS __DBG_REG_OFFS(dev, DBG_PLE_DRR_TABLE_RDATA)
1051+
1052+#define MT_DBG_PLE_DRR_TABLE_RDATA0 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x0)
1053+#define MT_DBG_PLE_DRR_TABLE_RDATA1 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x4)
1054+#define MT_DBG_PLE_DRR_TABLE_RDATA2 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x8)
1055+#define MT_DBG_PLE_DRR_TABLE_RDATA3 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0xc)
1056+#define MT_DBG_PLE_DRR_TABLE_RDATA4 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x10)
1057+#define MT_DBG_PLE_DRR_TABLE_RDATA5 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x14)
1058+#define MT_DBG_PLE_DRR_TABLE_RDATA6 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x18)
1059+#define MT_DBG_PLE_DRR_TABLE_RDATA7 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS+ 0x1c)
1060+
1061+#define MT_DBG_PLE_PBUF_CTRL_ADDR MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PBUF_CTRL))
1062+#define MT_DBG_PLE_QUEUE_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_QUEUE_EMPTY))
1063+#define MT_DBG_PLE_FREEPG_CNT MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_FREEPG_CNT))
1064+#define MT_DBG_PLE_FREEPG_HEAD_TAIL MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_FREEPG_HEAD_TAIL))
1065+#define MT_DBG_PLE_PG_HIF_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_HIF_GROUP))
1066+#define MT_DBG_PLE_HIF_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_HIF_PG_INFO))
1067+#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_HIF_TXCMD_GROUP))
1068+#define MT_DBG_PLE_HIF_TXCMD_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_HIF_TXCMD_PG_INFO))
1069+#define MT_DBG_PLE_PG_CPU_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_CPU_GROUP))
1070+#define MT_DBG_PLE_CPU_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_CPU_PG_INFO))
1071+#define PLE_FL_QUE_CTRL_OFFSET __DBG_REG_OFFS(dev, DBG_PLE_FL_QUE_CTRL)
1072+#define MT_DBG_PLE_FL_QUE_CTRL0 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x0)
1073+#define MT_DBG_PLE_FL_QUE_CTRL1 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x4)
1074+#define MT_DBG_PLE_FL_QUE_CTRL2 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x8)
1075+#define MT_DBG_PLE_FL_QUE_CTRL3 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0xc)
1076+#define MT_DBG_PLE_NATIVE_TXCMD_Q_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_NATIVE_TXCMD_Q_EMPTY))
1077+#define MT_DBG_PLE_TXCMD_Q_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_TXCMD_Q_EMPTY))
1078+
1079+#define MT_DBG_PLE_PBUF_CTRL_PAGE_SIZE_MASK BIT(31)
1080+#define MT_DBG_PLE_PBUF_CTRL_OFFSET_MASK GENMASK(25, 17)
1081+#define MT_DBG_PLE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK GENMASK(11, 0)
1082+
1083+#define MT_DBG_PLE_FREEPG_CNT_FREEPG_CNT_MASK GENMASK(11, 0)
1084+#define MT_DBG_PLE_FREEPG_CNT_FFA_CNT_MASK GENMASK(27, 16)
1085+#define MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK GENMASK(27, 16)
1086+#define MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK GENMASK(11, 0)
1087+#define MT_DBG_PLE_PG_HIF_GROUP_HIF_MAX_QUOTA_MASK GENMASK(27, 16)
1088+#define MT_DBG_PLE_PG_HIF_GROUP_HIF_MIN_QUOTA_MASK GENMASK(11, 0)
1089+
1090+#define MT_DBG_PLE_HIF_PG_INFO_HIF_SRC_CNT_MASK GENMASK(27, 16)
1091+#define MT_DBG_PLE_HIF_PG_INFO_HIF_RSV_CNT_MASK GENMASK(11, 0)
1092+
1093+#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MAX_QUOTA_MASK GENMASK(27, 16)
1094+#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MIN_QUOTA_MASK GENMASK(11, 0)
1095+
1096+#define MT_DBG_PLE_HIF_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK GENMASK(27, 16)
1097+#define MT_DBG_PLE_HIF_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK GENMASK(11, 0)
1098+
1099+#define MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK GENMASK(27, 16)
1100+#define MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK GENMASK(11, 0)
1101+
1102+#define MT_DBG_PLE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK GENMASK(27, 16)
1103+#define MT_DBG_PLE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK GENMASK(11, 0)
1104+
1105+#define MT_DBG_PLE_CPU_PG_INFO_CPU_SRC_CNT_MASK GENMASK(27, 16)
1106+#define MT_DBG_PLE_CPU_PG_INFO_CPU_RSV_CNT_MASK GENMASK(11, 0)
1107+
1108+#define MT_DBG_PLE_Q_EMPTY_ALL_AC_EMPTY_MASK BIT(24)
1109+#define MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK BIT(31)
1110+#define MT_DBG_PLE_FL_QUE_CTRL0_Q_BUF_QID_MASK GENMASK(30, 24)
1111+
1112+#define MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT 24
1113+#define MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT 10
1114+
1115+#define MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK GENMASK(27, 16)
1116+#define MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK GENMASK(11, 0)
1117+#define MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK GENMASK(11, 0)
1118+
1119+#define MT_DBG_PLE_STATION_PAUSE(n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_STATION_PAUSE) + ((n) << 2))
1120+#define MT_DBG_PLE_DIS_STA_MAP(n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_DIS_STA_MAP) + ((n) << 2))
1121+#define MT_DBG_PLE_AC_QEMPTY(ac, n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_AC_QEMPTY) + \
1122+ __DBG_REG_OFFS(dev, DBG_PLE_AC_OFFSET) * (ac) + ((n) << 2))
1123+
1124+#define MT_DBG_PLE_AMSDU_PACK_MSDU_CNT(n) MT_DBG_PLE(0x10e0 + ((n) << 2))
1125+
1126+/* pseinfo related CRs. */
1127+#define MT_DBG_PSE_BASE 0x820C8000
1128+#define MT_DBG_PSE(ofs) (MT_DBG_PSE_BASE + (ofs))
1129+
developerf32dabf2022-06-01 10:59:24 +08001130+#define MT_DBG_PSE_PBUF_CTRL MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PBUF_CTRL))
1131+#define MT_DBG_PSE_QUEUE_EMPTY MT_DBG_PSE(0x0b0)
1132+#define MT_DBG_PSE_FREEPG_CNT MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_FREEPG_CNT))
1133+#define MT_DBG_PSE_FREEPG_HEAD_TAIL MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_FREEPG_HEAD_TAIL))
1134+#define MT_DBG_PSE_PG_HIF0_GROUP MT_DBG_PSE(0x110)
1135+#define MT_DBG_PSE_HIF0_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_HIF0_PG_INFO))
1136+#define MT_DBG_PSE_PG_HIF1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_HIF1_GROUP))
1137+#define MT_DBG_PSE_HIF1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_HIF1_PG_INFO))
1138+#define MT_DBG_PSE_PG_CPU_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_CPU_GROUP))
1139+#define MT_DBG_PSE_CPU_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_CPU_PG_INFO))
1140+#define MT_DBG_PSE_PG_LMAC0_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC0_GROUP))
1141+#define MT_DBG_PSE_LMAC0_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC0_PG_INFO))
1142+#define MT_DBG_PSE_PG_LMAC1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC1_GROUP))
1143+#define MT_DBG_PSE_LMAC1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC1_PG_INFO))
1144+#define MT_DBG_PSE_PG_LMAC2_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC2_GROUP))
1145+#define MT_DBG_PSE_LMAC2_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC2_PG_INFO))
1146+#define MT_DBG_PSE_PG_PLE_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_PLE_GROUP))
1147+#define MT_DBG_PSE_PLE_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PLE_PG_INFO))
1148+#define MT_DBG_PSE_PG_LMAC3_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC3_GROUP))
1149+#define MT_DBG_PSE_LMAC3_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC3_PG_INFO))
1150+#define MT_DBG_PSE_PG_MDP_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_MDP_GROUP))
1151+#define MT_DBG_PSE_MDP_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_MDP_PG_INFO))
1152+#define MT_DBG_PSE_PG_PLE1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_PLE1_GROUP))
1153+#define MT_DBG_PSE_PLE1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PLE1_PG_INFO))
developer3fa816c2022-04-19 10:21:20 +08001154+
1155+#define MT_DBG_PSE_PBUF_CTRL_PAGE_SIZE_CFG_MASK BIT(31)
1156+#define MT_DBG_PSE_PBUF_CTRL_PBUF_OFFSET_MASK GENMASK(25, 17)
1157+#define MT_DBG_PSE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK GENMASK(11, 0)
1158+#define MT_DBG_PSE_QUEUE_EMPTY_RLS_Q_EMTPY_MASK BIT(31)
1159+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_RXIOC_QUEUE_EMPTY_MASK BIT(23)
1160+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_TXIOC_QUEUE_EMPTY_MASK BIT(22)
1161+#define MT_DBG_PSE_QUEUE_EMPTY_SFD_PARK_QUEUE_EMPTY_MASK BIT(21)
1162+#define MT_DBG_PSE_QUEUE_EMPTY_SEC_RX_QUEUE_EMPTY_SHFT BIT(20)
1163+#define MT_DBG_PSE_QUEUE_EMPTY_SEC_TX_QUEUE_EMPTY_MASK BIT(19)
1164+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_RX_QUEUE_EMPTY_MASK BIT(18)
1165+#define MT_DBG_PSE_QUEUE_EMPTY_MDP_TX_QUEUE_EMPTY_MASK BIT(17)
1166+#define MT_DBG_PSE_QUEUE_EMPTY_LMAC_TX_QUEUE_EMPTY_MASK BIT(16)
1167+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_5_EMPTY_MASK BIT(13)
1168+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_4_EMPTY_MASK BIT(12)
1169+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_3_EMPTY_MASK BIT(11)
1170+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_2_EMPTY_MASK BIT(10)
1171+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_1_EMPTY_MASK BIT(9)
1172+#define MT_DBG_PSE_QUEUE_EMPTY_HIF_0_EMPTY_MASK BIT(8)
1173+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q3_EMPTY_MASK BIT(3)
1174+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q2_EMPTY_MASK BIT(2)
1175+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q1_EMPTY_MASK BIT(1)
1176+#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q0_EMPTY_MASK BIT(0)
1177+#define MT_DBG_PSE_FREEPG_CNT_FFA_CNT_MASK GENMASK(27, 16)
1178+#define MT_DBG_PSE_FREEPG_CNT_FREEPG_CNT_MASK GENMASK(11, 0)
1179+#define MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK GENMASK(27, 16)
1180+#define MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK GENMASK(11, 0)
1181+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK GENMASK(27, 16)
1182+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK GENMASK(11, 0)
1183+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK GENMASK(27, 16)
1184+#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK GENMASK(11, 0)
1185+#define MT_DBG_PSE_HIF0_PG_INFO_HIF0_SRC_CNT_MASK GENMASK(27, 16)
1186+#define MT_DBG_PSE_HIF0_PG_INFO_HIF0_RSV_CNT_MASK GENMASK(11, 0)
1187+#define MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MAX_QUOTA_MASK GENMASK(27, 16)
1188+#define MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MIN_QUOTA_MASK GENMASK(11, 0)
1189+#define MT_DBG_PSE_HIF1_PG_INFO_HIF1_SRC_CNT_MASK GENMASK(27, 16)
1190+#define MT_DBG_PSE_HIF1_PG_INFO_HIF1_RSV_CNT_MASK GENMASK(11, 0)
1191+#define MT_DBG_PSE_CPU_PG_INFO_CPU_SRC_CNT_MASK GENMASK(27, 16)
1192+#define MT_DBG_PSE_CPU_PG_INFO_CPU_RSV_CNT_MASK GENMASK(11, 0)
1193+#define MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK GENMASK(27, 16)
1194+#define MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK GENMASK(11, 0)
1195+#define MT_DBG_PSE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK GENMASK(27, 16)
1196+#define MT_DBG_PSE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK GENMASK(11, 0)
1197+#define MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK GENMASK(27, 16)
1198+#define MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK GENMASK(11, 0)
1199+#define MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MAX_QUOTA_MASK GENMASK(27, 16)
1200+#define MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MIN_QUOTA_MASK GENMASK(11, 0)
1201+#define MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_SRC_CNT_MASK GENMASK(27, 16)
1202+#define MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_RSV_CNT_MASK GENMASK(11, 0)
1203+#define MT_DBG_PSE_PG_LMAC1_GROUP_LMAC1_MAX_QUOTA_MASK GENMASK(27, 16)
1204+#define MT_DBG_TOP_PG_LMAC1_GROUP_LMAC1_MIN_QUOTA_MASK GENMASK(11, 0)
1205+#define MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_SRC_CNT_MASK GENMASK(27, 16)
1206+#define MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_RSV_CNT_MASK GENMASK(11, 0)
1207+#define MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MAX_QUOTA_MASK GENMASK(27, 16)
1208+#define MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MIN_QUOTA_MASK GENMASK(11, 0)
1209+#define MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_SRC_CNT_MASK GENMASK(27, 16)
1210+#define MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_RSV_CNT_MASK GENMASK(11, 0)
1211+#define MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK GENMASK(27, 16)
1212+#define MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK GENMASK(11, 0)
1213+#define MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_SRC_CNT_MASK GENMASK(27, 16)
1214+#define MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_RSV_CNT_MASK GENMASK(11, 0)
1215+#define MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK GENMASK(27, 16)
1216+#define MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK GENMASK(11, 0)
1217+#define MT_DBG_PSE_PG_MDP_GROUP_MDP_MAX_QUOTA_MASK GENMASK(27, 16)
1218+#define MT_DBG_PSE_PG_MDP_GROUP_MDP_MIN_QUOTA_MASK GENMASK(11, 0)
1219+#define MT_DBG_PSE_MDP_PG_INFO_MDP_SRC_CNT_MASK GENMASK(27, 16)
1220+#define MT_DBG_PSE_MDP_PG_INFO_MDP_RSV_CNT_MASK GENMASK(11, 0)
1221+
1222+#define MT_DBG_PSE_FL_QUE_CTRL_0_ADDR MT_DBG_PLE(0x1b0)
1223+#define MT_DBG_PSE_FL_QUE_CTRL_0_EXECUTE_MASK BIT(31)
1224+#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_QID_SHFT 24
1225+#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_PID_SHFT 10
1226+#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_WLANID_MASK GENMASK(9, 0)
1227+
1228+#define MT_DBG_PSE_FL_QUE_CTRL_2_ADDR MT_DBG_PLE(0x1b8)
1229+#define MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_TAIL_FID_MASK GENMASK(27, 16)
1230+#define MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_HEAD_FID_MASK GENMASK(11, 0)
1231+
1232+#define MT_DBG_PSE_FL_QUE_CTRL_3_ADDR MT_DBG_PLE(0x1bc)
1233+#define MT_DBG_PSE_FL_QUE_CTRL_3_QUEUE_PKT_NUM_MASK GENMASK(11, 0)
1234+
1235+
1236+/* AGG */
1237+#define MT_DBG_AGG_BASE(_band) ((_band) ? 0x820f2000 : 0x820e2000)
1238+#define MT_DBG_AGG(_band, ofs) (MT_DBG_AGG_BASE(_band) + (ofs))
1239+
1240+#define MT_DBG_AGG_AALCR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR0))
1241+#define MT_DBG_AGG_AALCR1(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR1))
1242+#define MT_DBG_AGG_AALCR2(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR2))
1243+#define MT_DBG_AGG_AALCR3(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR3))
1244+#define MT_DBG_AGG_AALCR4(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR4))
1245+#define MT_DBG_AGG_B0BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B0BRR0))
1246+#define MT_DBG_AGG_B1BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B1BRR0))
1247+#define MT_DBG_AGG_B2BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B2BRR0))
1248+#define MT_DBG_AGG_B3BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B3BRR0))
1249+#define MT_DBG_AGG_AWSCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AWSCR0) + ((n) << 2))
1250+#define MT_DBG_AGG_PCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_PCR0) + ((n) << 2))
1251+#define MT_DBG_AGG_TTCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_TTCR0) + ((n) << 2))
1252+#define MT_DBG_MIB_M0ARNG(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0ARNG0) + ((n) << 2))
1253+#define MT_DBG_MIB_M0DR2(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR2) + ((n) << 2))
1254+#define MT_DBG_MIB_M0DR13(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR13) + ((n) << 2))
1255+
1256+#define MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK GENMASK(31, 24)
1257+#define MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK GENMASK(23, 16)
1258+#define MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK GENMASK(15, 8)
1259+#define MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK GENMASK(7, 0)
1260+#define MT_DBG_AGG_AALCR4_ALTX0_AGG_LIMIT_MASK GENMASK(7, 0)
1261+
1262+#define MT_DBG_AGG_AWSCR0_WINSIZE3_MASK GENMASK(31, 24)
1263+#define MT_DBG_AGG_AWSCR0_WINSIZE2_MASK GENMASK(23, 16)
1264+#define MT_DBG_AGG_AWSCR0_WINSIZE1_MASK GENMASK(15, 8)
1265+#define MT_DBG_AGG_AWSCR0_WINSIZE0_MASK GENMASK(7, 0)
1266+
1267+#define MT_DBG_AGG_AWSCR1_WINSIZE7_MASK GENMASK(31, 24)
1268+#define MT_DBG_AGG_AWSCR1_WINSIZE6_MASK GENMASK(23, 16)
1269+#define MT_DBG_AGG_AWSCR1_WINSIZE5_MASK GENMASK(15, 8)
1270+#define MT_DBG_AGG_AWSCR1_WINSIZE4_MASK GENMASK(7, 0)
1271+
1272+#define MT_DBG_AGG_AWSCR2_WINSIZEB_MASK GENMASK(31, 24)
1273+#define MT_DBG_AGG_AWSCR2_WINSIZEA_MASK GENMASK(23, 16)
1274+#define MT_DBG_AGG_AWSCR2_WINSIZE9_MASK GENMASK(15, 8)
1275+#define MT_DBG_AGG_AWSCR2_WINSIZE8_MASK GENMASK(7, 0)
1276+
1277+#define MT_DBG_AGG_AWSCR3_WINSIZEE_MASK GENMASK(23, 16)
1278+#define MT_DBG_AGG_AWSCR3_WINSIZED_MASK GENMASK(15, 8)
1279+#define MT_DBG_AGG_AWSCR3_WINSIZEC_MASK GENMASK(7, 0)
1280+
1281+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL3_MASK GENMASK(31, 24)
1282+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL2_MASK GENMASK(23, 16)
1283+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL1_MASK GENMASK(15, 8)
1284+#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL0_MASK GENMASK(7, 0)
1285+
1286+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL7_MASK GENMASK(31, 24)
1287+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL6_MASK GENMASK(23, 16)
1288+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL5_MASK GENMASK(15, 8)
1289+#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL4_MASK GENMASK(7, 0)
1290+
1291+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL11_MASK GENMASK(31, 24)
1292+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL10_MASK GENMASK(23, 16)
1293+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL9_MASK GENMASK(15, 8)
1294+#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL8_MASK GENMASK(7, 0)
1295+
1296+#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL14_MASK GENMASK(23, 16)
1297+#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL13_MASK GENMASK(15, 8)
1298+#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL12_MASK GENMASK(7, 0)
1299+
1300+#define MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK GENMASK(31, 16)
1301+#define MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK GENMASK(15, 0)
1302+#define MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK GENMASK(31, 16)
1303+#define MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK GENMASK(15, 0)
1304+#define MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK GENMASK(31, 16)
1305+#define MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK GENMASK(15, 0)
1306+#define MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK GENMASK(31, 16)
1307+#define MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK GENMASK(15, 0)
1308+#define MT_DBG_MIB_M0DR13_TRX_AGG_RANGE9_CNT_MASK GENMASK(31, 16)
1309+#define MT_DBG_MIB_M0DR13_TRX_AGG_RANGE8_CNT_MASK GENMASK(15, 0)
1310+#define MT_DBG_MIB_M0DR14_TRX_AGG_RANGE11_CNT_MASK GENMASK(31, 16)
1311+#define MT_DBG_MIB_M0DR14_TRX_AGG_RANGE10_CNT_MASK GENMASK(15, 0)
1312+#define MT_DBG_MIB_M0DR15_TRX_AGG_RANGE13_CNT_MASK GENMASK(31, 16)
1313+#define MT_DBG_MIB_M0DR15_TRX_AGG_RANGE12_CNT_MASK GENMASK(15, 0)
1314+#define MT_DBG_MIB_M0DR16_TRX_AGG_RANGE15_CNT_MASK GENMASK(31, 16)
1315+#define MT_DBG_MIB_M0DR16_TRX_AGG_RANGE14_CNT_MASK GENMASK(15, 0)
1316+
1317+/* mt7915 host DMA*/
1318+#define MT_DBG_INT_DMA1_R0_DONE BIT(0)
1319+#define MT_DBG_INT_DMA1_R1_DONE BIT(1)
1320+#define MT_DBG_INT_DMA1_R2_DONE BIT(2)
1321+
1322+#define MT_DBG_INT_DMA1_T16_DONE BIT(26)
1323+#define MT_DBG_INT_DMA1_T17_DONE BIT(27)
1324+#define MT_DBG_INT_DMA1_T18_DONE BIT(30)
1325+#define MT_DBG_INT_DMA1_T19_DONE BIT(31)
1326+#define MT_DBG_INT_DMA1_T20_DONE BIT(15)
1327+
1328+#define MT_DBG_EXT_WRAP_INT_DMA0_R0_DONE BIT(16)
1329+#define MT_DBG_EXT_WRAP_INT_DMA0_R1_DONE BIT(17)
1330+
1331+/* mt7986 host DMA */
1332+#define MT_DBG_INT_DMA0_R0_DONE BIT(0)
1333+#define MT_DBG_INT_DMA0_R1_DONE BIT(1)
1334+#define MT_DBG_INT_DMA0_R2_DONE BIT(2)
1335+#define MT_DBG_INT_DMA0_R3_DONE BIT(3)
1336+#define MT_DBG_INT_DMA0_R4_DONE BIT(22)
1337+#define MT_DBG_INT_DMA0_R5_DONE BIT(23)
1338+
1339+#define MT_DBG_INT_DMA0_T16_DONE BIT(26)
1340+#define MT_DBG_INT_DMA0_T17_DONE BIT(27)
1341+#define MT_DBG_INT_DMA0_T18_DONE BIT(30)
1342+#define MT_DBG_INT_DMA0_T19_DONE BIT(31)
1343+#define MT_DBG_INT_DMA0_T20_DONE BIT(25)
1344+
1345+/* MCU DMA */
1346+#define WF_WFDMA_MCU_DMA0_BASE 0x54000000
1347+#define WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x200) // 0200
1348+#define WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0X204) // 0204
1349+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x208) // 0208
1350+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1351+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1352+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1353+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1354+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1355+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1356+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1357+#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1358+
1359+#define WF_WFDMA_MCU_DMA1_BASE 0x55000000
1360+#define WF_WFDMA_MCU_DMA1_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x200) // 0200
1361+#define WF_WFDMA_MCU_DMA1_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0X204) // 0204
1362+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x208) // 0208
1363+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1364+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1365+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1366+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1367+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1368+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1369+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1370+#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1371+#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x300) // 0300
1372+#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x310) // 0310
1373+#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x320) // 0320
1374+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x500) // 0500
1375+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x510) // 0510
1376+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x520) // 0520
1377+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x530) // 0530
1378+#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x540) // 0540
1379+
1380+#define WF_WFDMA_MCU_DMA1_PCIE1_BASE 0x59000000
1381+#define WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x200) // 0200
1382+#define WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0X204) // 0204
1383+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x208) // 0208
1384+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1385+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1386+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1387+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1388+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1389+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1390+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1391+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1392+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x320) // 0320
1393+#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x530) // 0530
1394+
1395+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x300) // 0300
1396+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x310) // 0310
1397+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x320) // 0320
1398+/* mt7986 add */
1399+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x330) // 0330
1400+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x340) // 0340
1401+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING5_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x350) // 0350
1402+#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING6_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x360) // 0360
1403+
1404+
1405+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x500) // 0500
1406+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x510) // 0510
1407+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x520) // 0520
1408+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x530) // 0530
1409+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x540) // 0540
1410+
1411+/* mt7986 add */
1412+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING5_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x550) // 0550
1413+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING6_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x560) // 0560
1414+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING7_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x570) // 0570
1415+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING8_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x580) // 0580
1416+#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING9_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x590) // 0590
1417+
1418+/* MEM DMA */
1419+#define WF_WFDMA_MEM_DMA_BASE 0x58000000
1420+#define WF_WFDMA_MEM_DMA_HOST_INT_STA_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x200) // 0200
1421+#define WF_WFDMA_MEM_DMA_HOST_INT_ENA_ADDR (WF_WFDMA_MEM_DMA_BASE + 0X204) // 0204
1422+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x208) // 0208
1423+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3]
1424+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3
1425+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2]
1426+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2
1427+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1]
1428+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1
1429+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0]
1430+#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0
1431+#define WF_WFDMA_MEM_DMA_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x300) // 0300
1432+#define WF_WFDMA_MEM_DMA_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x310) // 0310
1433+#define WF_WFDMA_MEM_DMA_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x500) // 0500
1434+#define WF_WFDMA_MEM_DMA_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x510) // 0510
1435+
1436+enum resource_attr {
1437+ HIF_TX_DATA,
1438+ HIF_TX_CMD,
1439+ HIF_TX_CMD_WM, /* direct path to WMCPU, only exist for WFDMA arch with 2 CPU */
1440+ HIF_TX_FWDL,
1441+ HIF_RX_DATA,
1442+ HIF_RX_EVENT,
1443+ RING_ATTR_NUM
1444+};
1445+
1446+struct hif_pci_tx_ring_desc {
1447+ u32 hw_int_mask;
1448+ u16 ring_size;
1449+ enum resource_attr ring_attr;
1450+ u8 band_idx;
1451+ char *const ring_info;
1452+};
1453+
1454+struct hif_pci_rx_ring_desc {
1455+ u32 hw_desc_base;
1456+ u32 hw_int_mask;
1457+ u16 ring_size;
1458+ enum resource_attr ring_attr;
1459+ u16 max_rx_process_cnt;
1460+ u16 max_sw_read_idx_inc;
1461+ char *const ring_info;
1462+};
1463+
1464+const struct hif_pci_tx_ring_desc mt7915_tx_ring_layout[] = {
1465+ {
1466+ .hw_int_mask = MT_DBG_INT_DMA1_T16_DONE,
1467+ .ring_size = 128,
1468+ .ring_attr = HIF_TX_FWDL,
1469+ .ring_info = "FWDL"
1470+ },
1471+ {
1472+ .hw_int_mask = MT_DBG_INT_DMA1_T17_DONE,
1473+ .ring_size = 256,
1474+ .ring_attr = HIF_TX_CMD_WM,
1475+ .ring_info = "cmd to WM"
1476+ },
1477+ {
1478+ .hw_int_mask = MT_DBG_INT_DMA1_T18_DONE,
1479+ .ring_size = 2048,
1480+ .ring_attr = HIF_TX_DATA,
1481+ .ring_info = "band0 TXD"
1482+ },
1483+ {
1484+ .hw_int_mask = MT_DBG_INT_DMA1_T19_DONE,
1485+ .ring_size = 2048,
1486+ .ring_attr = HIF_TX_DATA,
1487+ .ring_info = "band1 TXD"
1488+ },
1489+ {
1490+ .hw_int_mask = MT_DBG_INT_DMA1_T20_DONE,
1491+ .ring_size = 256,
1492+ .ring_attr = HIF_TX_CMD,
1493+ .ring_info = "cmd to WA"
1494+ }
1495+};
1496+
1497+const struct hif_pci_rx_ring_desc mt7915_rx_ring_layout[] = {
1498+ {
1499+ .hw_int_mask = MT_DBG_EXT_WRAP_INT_DMA0_R0_DONE,
1500+ .ring_size = 1536,
1501+ .ring_attr = HIF_RX_DATA,
1502+ .ring_info = "band0 RX data"
1503+ },
1504+ {
1505+ .hw_int_mask = MT_DBG_EXT_WRAP_INT_DMA0_R1_DONE,
1506+ .ring_size = 1536,
1507+ .ring_attr = HIF_RX_DATA,
1508+ .ring_info = "band1 RX data"
1509+ },
1510+ {
1511+ .hw_int_mask = MT_DBG_INT_DMA1_R0_DONE,
1512+ .ring_size = 512,
1513+ .ring_attr = HIF_RX_EVENT,
1514+ .ring_info = "event from WM"
1515+ },
1516+ {
1517+ .hw_int_mask = MT_DBG_INT_DMA1_R1_DONE,
1518+ .ring_size = 1024,
1519+ .ring_attr = HIF_RX_EVENT,
1520+ .ring_info = "event from WA band0"
1521+ },
1522+ {
1523+ .hw_int_mask = MT_DBG_INT_DMA1_R2_DONE,
1524+ .ring_size = 512,
1525+ .ring_attr = HIF_RX_EVENT,
1526+ .ring_info = "event from WA band1"
1527+ }
1528+};
1529+
1530+const struct hif_pci_tx_ring_desc mt7986_tx_ring_layout[] = {
1531+ {
1532+ .hw_int_mask = MT_DBG_INT_DMA0_T16_DONE,
1533+ .ring_size = 128,
1534+ .ring_attr = HIF_TX_FWDL,
1535+ .ring_info = "FWDL"
1536+ },
1537+ {
1538+ .hw_int_mask = MT_DBG_INT_DMA0_T17_DONE,
1539+ .ring_size = 256,
1540+ .ring_attr = HIF_TX_CMD_WM,
1541+ .ring_info = "cmd to WM"
1542+ },
1543+ {
1544+ .hw_int_mask = MT_DBG_INT_DMA0_T18_DONE,
1545+ .ring_size = 2048,
1546+ .ring_attr = HIF_TX_DATA,
1547+ .ring_info = "band0 TXD"
1548+ },
1549+ {
1550+ .hw_int_mask = MT_DBG_INT_DMA0_T19_DONE,
1551+ .ring_size = 2048,
1552+ .ring_attr = HIF_TX_DATA,
1553+ .ring_info = "band1 TXD"
1554+ },
1555+ {
1556+ .hw_int_mask = MT_DBG_INT_DMA0_T20_DONE,
1557+ .ring_size = 256,
1558+ .ring_attr = HIF_TX_CMD,
1559+ .ring_info = "cmd to WA"
1560+ }
1561+};
1562+
1563+const struct hif_pci_rx_ring_desc mt7986_rx_ring_layout[] = {
1564+ {
1565+ .hw_int_mask = MT_DBG_INT_DMA0_R4_DONE,
1566+ .ring_size = 1536,
1567+ .ring_attr = HIF_RX_DATA,
1568+ .ring_info = "band0 RX data"
1569+ },
1570+ {
1571+ .hw_int_mask = MT_DBG_INT_DMA0_R5_DONE,
1572+ .ring_size = 1536,
1573+ .ring_attr = HIF_RX_DATA,
1574+ .ring_info = "band1 RX data"
1575+ },
1576+ {
1577+ .hw_int_mask = MT_DBG_INT_DMA0_R0_DONE,
1578+ .ring_size = 512,
1579+ .ring_attr = HIF_RX_EVENT,
1580+ .ring_info = "event from WM"
1581+ },
1582+ {
1583+ .hw_int_mask = MT_DBG_INT_DMA0_R1_DONE,
1584+ .ring_size = 512,
1585+ .ring_attr = HIF_RX_EVENT,
1586+ .ring_info = "event from WA"
1587+ },
1588+ {
1589+ .hw_int_mask = MT_DBG_INT_DMA0_R2_DONE,
1590+ .ring_size = 1024,
1591+ .ring_attr = HIF_RX_EVENT,
1592+ .ring_info = "STS WA band0"
1593+ },
1594+ {
1595+ .hw_int_mask = MT_DBG_INT_DMA0_R3_DONE,
1596+ .ring_size = 512,
1597+ .ring_attr = HIF_RX_EVENT,
1598+ .ring_info = "STS WA band1"
1599+ },
1600+};
1601+
1602+/* mibinfo related CRs. */
1603+#define BN0_WF_MIB_TOP_BASE 0x820ed000
1604+#define BN1_WF_MIB_TOP_BASE 0x820fd000
1605+
1606+#define BN0_WF_MIB_TOP_BTOCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x400) // D400
1607+#define BN0_WF_MIB_TOP_BTBCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x428) // D428
1608+#define BN0_WF_MIB_TOP_BTDCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x4F0) // D4F0
1609+
1610+#define BN0_WF_MIB_TOP_BSDR0_ADDR (BN0_WF_MIB_TOP_BASE + 0x688) // D688
1611+#define BN0_WF_MIB_TOP_BSDR1_ADDR (BN0_WF_MIB_TOP_BASE + 0x690) // D690
1612+
1613+#define BN0_WF_MIB_TOP_BSDR2_ADDR (BN0_WF_MIB_TOP_BASE + 0x518) // D518
1614+#define BN0_WF_MIB_TOP_BSDR3_ADDR (BN0_WF_MIB_TOP_BASE + 0x520) // D520
1615+#define BN0_WF_MIB_TOP_BSDR4_ADDR (BN0_WF_MIB_TOP_BASE + 0x528) // D528
1616+#define BN0_WF_MIB_TOP_BSDR5_ADDR (BN0_WF_MIB_TOP_BASE + 0x530) // D530
1617+#define BN0_WF_MIB_TOP_BSDR6_ADDR (BN0_WF_MIB_TOP_BASE + 0x538) // D538
1618+
1619+#define BN0_WF_MIB_TOP_BROCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x5B8) // D5B8
1620+#define BN0_WF_MIB_TOP_BRBCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x5E0) // D5E0
1621+#define BN0_WF_MIB_TOP_BRDCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x630) // D630
1622+
1623+#define BN0_WF_MIB_TOP_M0SDR0_BEACONTXCOUNT_MASK 0x0000FFFF // BEACONTXCOUNT[15..0]
1624+
1625+#define BN0_WF_MIB_TOP_M0SDR4_RX_FIFO_FULL_COUNT_MASK 0x0000FFFF // RX_FIFO_FULL_COUNT[15..0]
1626+
1627+#define BN0_WF_MIB_TOP_M0SDR5_RX_MPDU_COUNT_MASK 0xFFFFFFFF // RX_MPDU_COUNT[31..0]
1628+
1629+#define BN0_WF_MIB_TOP_M0SDR6_CHANNEL_IDLE_COUNT_MASK 0x0000FFFF // CHANNEL_IDLE_COUNT[15..0]
1630+
1631+#define BN1_WF_MIB_TOP_BTOCR_ADDR (BN1_WF_MIB_TOP_BASE + 0x400) // D400
1632+
1633+#define BN0_WF_MIB_TOP_M0SDR7_VEC_MISS_COUNT_MASK 0x0000FFFF // VEC_MISS_COUNT[15..0]
1634+#define BN0_WF_MIB_TOP_M0SDR8_DELIMITER_FAIL_COUNT_MASK 0x0000FFFF // DELIMITER_FAIL_COUNT[15..0]
1635+#define BN0_WF_MIB_TOP_M0SDR9_CCA_NAV_TX_TIME_MASK 0x00FFFFFF // CCA_NAV_TX_TIME[23..0]
1636+
1637+#define BN0_WF_MIB_TOP_M0SDR11_RX_LEN_MISMATCH_MASK 0x0000FFFF // RX_LEN_MISMATCH[15..0]
1638+
1639+#define BN0_WF_MIB_TOP_M0SDR16_P_CCA_TIME_MASK 0x00FFFFFF // P_CCA_TIME[23..0]
1640+#define BN0_WF_MIB_TOP_M0SDR17_S_CCA_TIME_MASK 0x00FFFFFF // S_CCA_TIME[23..0]
1641+#define BN0_WF_MIB_TOP_M0SDR18_P_ED_TIME_MASK 0x00FFFFFF // P_ED_TIME[23..0]
1642+#define BN0_WF_MIB_TOP_M0SDR19_CCK_MDRDY_TIME_MASK 0x00FFFFFF // CCK_MDRDY_TIME[23..0]
1643+#define BN0_WF_MIB_TOP_M0SDR20_OFDM_LG_MIXED_VHT_MDRDY_TIME_MASK 0x00FFFFFF // OFDM_LG_MIXED_VHT_MDRDY_TIME[23..0]
1644+#define BN0_WF_MIB_TOP_M0SDR21_OFDM_GREEN_MDRDY_TIME_MASK 0x00FFFFFF // OFDM_GREEN_MDRDY_TIME[23..0]
1645+
1646+#define BN0_WF_MIB_TOP_M0SDR22_ADDR (BN0_WF_MIB_TOP_BASE + 0x60) // D060
1647+#define BN0_WF_MIB_TOP_M0SDR23_ADDR (BN0_WF_MIB_TOP_BASE + 0x64) // D064
1648+
1649+#define BN0_WF_MIB_TOP_M0SDR34_MUBF_TX_COUNT_MASK 0x0000FFFF // MUBF_TX_COUNT[15..0]
1650+
1651+#define BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_MASK 0xFFFF0000 // TX_40MHZ_CNT[31..16]
1652+#define BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_SHFT 16
1653+#define BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_MASK 0x0000FFFF // TX_20MHZ_CNT[15..0]
1654+#define BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_SHFT 0
1655+
1656+#define BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_MASK 0xFFFF0000 // TX_160MHZ_CNT[31..16]
1657+#define BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_SHFT 16
1658+#define BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_MASK 0x0000FFFF // TX_80MHZ_CNT[15..0]
1659+#define BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_SHFT 0
1660+
1661+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_MASK 0xFFFF0000 // TX_DDLMT_RNG2_CNT[31..16]
1662+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_SHFT 16
1663+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG1_CNT[15..0]
1664+#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_SHFT 0
1665+
1666+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_MASK 0xFFFF0000 // TX_DDLMT_RNG4_CNT[31..16]
1667+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_SHFT 16
1668+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG3_CNT[15..0]
1669+#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_SHFT 0
1670+
1671+#define BN0_WF_MIB_TOP_M0DR10_MU_FAIL_PPDU_CNT_MASK 0x0000FFFF // MU_FAIL_PPDU_CNT[15..0]
1672+
1673+#define BN0_WF_MIB_TOP_M0B0SDR0_ADDR (BN0_WF_MIB_TOP_BASE + 0x100) // D100
1674+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_MASK 0xFFFF0000 // RTSRETRYCOUNT[31..16]
1675+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_SHFT 16
1676+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_MASK 0x0000FFFF // RTSTXCOUNT[15..0]
1677+#define BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_SHFT 0
1678+#define BN0_WF_MIB_TOP_M0B0SDR1_ADDR (BN0_WF_MIB_TOP_BASE + 0x104) // D104
1679+#define BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_MASK 0xFFFF0000 // ACKFAILCOUNT[31..16]
1680+#define BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_SHFT 16
1681+#define BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_MASK 0x0000FFFF // BAMISSCOUNT[15..0]
1682+#define BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_SHFT 0
1683+#define BN0_WF_MIB_TOP_M0B0SDR2_ADDR (BN0_WF_MIB_TOP_BASE + 0x108) // D108
1684+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_MASK 0xFFFF0000 // FRAMERETRY2COUNT[31..16]
1685+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_SHFT 16
1686+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_MASK 0x0000FFFF // FRAMERETRYCOUNT[15..0]
1687+#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_SHFT 0
1688+#define BN0_WF_MIB_TOP_M0B0SDR3_ADDR (BN0_WF_MIB_TOP_BASE + 0x10C) // D10C
1689+#define BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_MASK 0x0000FFFF // FRAMERETRY3COUNT[15..0]
1690+#define BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_SHFT 0
1691+#define BN0_WF_MIB_TOP_M0DR12_TX_DDLMT_RNG0_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG0_CNT[15..0]
1692+
1693+
1694+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK 0xFFFF0000 // TX_OK_COUNT2np1[31..16]
1695+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT 16
1696+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK 0x0000FFFF // TX_OK_COUNT2n[15..0]
1697+#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT 0
1698+
1699+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_MASK 0xFFFF0000 // TX_DATA_COUNT2np1[31..16]
1700+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_SHFT 16
1701+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_MASK 0x0000FFFF // TX_DATA_COUNT2n[15..0]
1702+#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_SHFT 0
1703+
1704+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK 0xFFFF0000 // RX_OK_COUNT2np1[31..16]
1705+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT 16
1706+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK 0x0000FFFF // RX_OK_COUNT2n[15..0]
1707+#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT 0
1708+
1709+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_MASK 0xFFFF0000 // RX_DATA_COUNT2np1[31..16]
1710+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_SHFT 16
1711+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_MASK 0x0000FFFF // RX_DATA_COUNT2n[15..0]
1712+#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_SHFT 0
1713+
1714+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_MASK 0xFFFF0000 // RTSTXCOUNT2np1[31..16]
1715+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_SHFT 16
1716+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_MASK 0x0000FFFF // RTSTXCOUNT2n[15..0]
1717+#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_SHFT 0
1718+
1719+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_MASK 0xFFFF0000 // RTSRETRYCOUNT2np1[31..16]
1720+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_SHFT 16
1721+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_MASK 0x0000FFFF // RTSRETRYCOUNT2n[15..0]
1722+#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_SHFT 0
1723+
1724+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_MASK 0xFFFF0000 // BAMISSCOUNT2np1[31..16]
1725+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_SHFT 16
1726+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_MASK 0x0000FFFF // BAMISSCOUNT2n[15..0]
1727+#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_SHFT 0
1728+
1729+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_MASK 0xFFFF0000 // ACKFAILCOUNT2np1[31..16]
1730+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_SHFT 16
1731+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_MASK 0x0000FFFF // ACKFAILCOUNT2n[15..0]
1732+#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_SHFT 0
1733+
1734+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_MASK 0xFFFF0000 // FRAMERETRYCOUNT2np1[31..16]
1735+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_SHFT 16
1736+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_MASK 0x0000FFFF // FRAMERETRYCOUNT2n[15..0]
1737+#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_SHFT 0
1738+
1739+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_MASK 0xFFFF0000 // FRAMERETRY2COUNT2np1[31..16]
1740+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_SHFT 16
1741+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_MASK 0x0000FFFF // FRAMERETRY2COUNT2n[15..0]
1742+#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_SHFT 0
1743+
1744+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_MASK 0xFFFF0000 // FRAMERETRY3COUNT2np1[31..16]
1745+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_SHFT 16
1746+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_MASK 0x0000FFFF // FRAMERETRY3COUNT2n[15..0]
1747+#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_SHFT 0
1748+/* TXD */
1749+
1750+#define MT_TXD1_ETYP BIT(15)
1751+#define MT_TXD1_VLAN BIT(14)
1752+#define MT_TXD1_RMVL BIT(13)
1753+#define MT_TXD1_AMS BIT(13)
1754+#define MT_TXD1_EOSP BIT(12)
1755+#define MT_TXD1_MRD BIT(11)
1756+
1757+#define MT_TXD7_CTXD BIT(26)
1758+#define MT_TXD7_CTXD_CNT GENMASK(25, 23)
1759+#define MT_TXD7_TAT GENMASK(9, 0)
1760+
1761+#endif
1762+#endif
1763diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c
1764new file mode 100644
developeraace7f52022-06-24 13:40:42 +08001765index 0000000..f18c8b6
developer3fa816c2022-04-19 10:21:20 +08001766--- /dev/null
1767+++ b/mt7915/mtk_debugfs.c
developeraace7f52022-06-24 13:40:42 +08001768@@ -0,0 +1,2923 @@
developer3fa816c2022-04-19 10:21:20 +08001769+#include<linux/inet.h>
1770+#include "mt7915.h"
1771+#include "mt7915_debug.h"
1772+#include "mac.h"
1773+#include "mcu.h"
1774+
1775+#ifdef MTK_DEBUG
1776+#define LWTBL_IDX2BASE_ID GENMASK(14, 8)
1777+#define LWTBL_IDX2BASE_DW GENMASK(7, 2)
1778+#define LWTBL_IDX2BASE(_id, _dw) (MT_DBG_WTBL_BASE | \
1779+ FIELD_PREP(LWTBL_IDX2BASE_ID, _id) | \
1780+ FIELD_PREP(LWTBL_IDX2BASE_DW, _dw))
1781+
1782+#define UWTBL_IDX2BASE_ID GENMASK(12, 6)
1783+#define UWTBL_IDX2BASE_DW GENMASK(5, 2)
1784+#define UWTBL_IDX2BASE(_id, _dw) (MT_DBG_UWTBL_TOP_BASE | 0x2000 | \
1785+ FIELD_PREP(UWTBL_IDX2BASE_ID, _id) | \
1786+ FIELD_PREP(UWTBL_IDX2BASE_DW, _dw))
1787+
1788+#define KEYTBL_IDX2BASE_KEY GENMASK(12, 6)
1789+#define KEYTBL_IDX2BASE_DW GENMASK(5, 2)
1790+#define KEYTBL_IDX2BASE(_key, _dw) (MT_DBG_UWTBL_TOP_BASE | 0x2000 | \
1791+ FIELD_PREP(KEYTBL_IDX2BASE_KEY, _key) | \
1792+ FIELD_PREP(KEYTBL_IDX2BASE_DW, _dw))
1793+
1794+enum mt7915_wtbl_type {
1795+ WTBL_TYPE_LMAC, /* WTBL in LMAC */
1796+ WTBL_TYPE_UMAC, /* WTBL in UMAC */
1797+ WTBL_TYPE_KEY, /* Key Table */
1798+ MAX_NUM_WTBL_TYPE
1799+};
1800+
1801+static int mt7915_wtbl_read_raw(struct mt7915_dev *dev, u16 idx,
1802+ enum mt7915_wtbl_type type, u16 start_dw,
1803+ u16 len, void *buf)
1804+{
1805+ u32 *dest_cpy = (u32 *)buf;
1806+ u32 size_dw = len;
1807+ u32 src = 0;
1808+
1809+ if (!buf)
1810+ return 0xFF;
1811+
1812+ if (type == WTBL_TYPE_LMAC) {
1813+ mt76_wr(dev, MT_DBG_WTBLON_TOP_WDUCR,
1814+ FIELD_PREP(MT_DBG_WTBLON_TOP_WDUCR_GROUP, (idx >> 7)));
1815+ src = LWTBL_IDX2BASE(idx, start_dw);
1816+ } else if (type == WTBL_TYPE_UMAC) {
1817+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
1818+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
1819+ src = UWTBL_IDX2BASE(idx, start_dw);
1820+ } else if (type == WTBL_TYPE_KEY) {
1821+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
1822+ MT_UWTBL_TOP_WDUCR_TARGET |
1823+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
1824+ src = KEYTBL_IDX2BASE(idx, start_dw);
1825+ }
1826+
1827+ while (size_dw--) {
1828+ *dest_cpy++ = mt76_rr(dev, src);
1829+ src += 4;
1830+ };
1831+
1832+ return 0;
1833+}
1834+
1835+static int mt7915_wtbl_write_raw(struct mt7915_dev *dev, u16 idx,
1836+ enum mt7915_wtbl_type type, u16 start_dw,
1837+ u32 val)
1838+{
1839+ u32 addr = 0;
1840+
1841+ if (type == WTBL_TYPE_LMAC) {
1842+ mt76_wr(dev, MT_DBG_WTBLON_TOP_WDUCR,
1843+ FIELD_PREP(MT_WTBLON_TOP_WDUCR_GROUP, (idx >> 7)));
1844+ addr = LWTBL_IDX2BASE(idx, start_dw);
1845+ } else if (type == WTBL_TYPE_UMAC) {
1846+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
1847+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
1848+ addr = UWTBL_IDX2BASE(idx, start_dw);
1849+ } else if (type == WTBL_TYPE_KEY) {
1850+ mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR,
1851+ MT_UWTBL_TOP_WDUCR_TARGET |
1852+ FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7)));
1853+ addr = KEYTBL_IDX2BASE(idx, start_dw);
1854+ }
1855+
1856+ mt76_wr(dev, addr, val);
1857+
1858+ return 0;
1859+}
1860+
1861+void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len)
1862+{
1863+ struct bin_debug_hdr *hdr;
1864+ char *buf;
1865+
1866+ if (len > 1500 - sizeof(*hdr))
1867+ len = 1500 - sizeof(*hdr);
1868+
1869+ buf = kzalloc(sizeof(*hdr) + len, GFP_KERNEL);
1870+ if (!buf)
1871+ return;
1872+
1873+ hdr = (struct bin_debug_hdr *)buf;
1874+ hdr->magic_num = cpu_to_le32(PKT_BIN_DEBUG_MAGIC);
1875+ hdr->serial_id = cpu_to_le16(dev->dbg.fwlog_seq++);
1876+ hdr->msg_type = cpu_to_le16(type);
1877+ hdr->len = cpu_to_le16(len);
1878+ hdr->des_len = cpu_to_le16(des_len);
1879+
1880+ memcpy(buf + sizeof(*hdr), data, len);
1881+
1882+ mt7915_debugfs_rx_log(dev, buf, sizeof(*hdr) + len);
1883+}
1884+
1885+static int
1886+mt7915_fw_debug_module_set(void *data, u64 module)
1887+{
1888+ struct mt7915_dev *dev = data;
1889+
1890+ dev->dbg.fw_dbg_module = module;
1891+ return 0;
1892+}
1893+
1894+static int
1895+mt7915_fw_debug_module_get(void *data, u64 *module)
1896+{
1897+ struct mt7915_dev *dev = data;
1898+
1899+ *module = dev->dbg.fw_dbg_module;
1900+ return 0;
1901+}
1902+
1903+DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_module, mt7915_fw_debug_module_get,
1904+ mt7915_fw_debug_module_set, "%lld\n");
1905+
1906+static int
1907+mt7915_fw_debug_level_set(void *data, u64 level)
1908+{
1909+ struct mt7915_dev *dev = data;
1910+
1911+ dev->dbg.fw_dbg_lv = level;
1912+ mt7915_mcu_fw_dbg_ctrl(dev, dev->dbg.fw_dbg_module, dev->dbg.fw_dbg_lv);
1913+ return 0;
1914+}
1915+
1916+static int
1917+mt7915_fw_debug_level_get(void *data, u64 *level)
1918+{
1919+ struct mt7915_dev *dev = data;
1920+
1921+ *level = dev->dbg.fw_dbg_lv;
1922+ return 0;
1923+}
1924+
1925+DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_level, mt7915_fw_debug_level_get,
1926+ mt7915_fw_debug_level_set, "%lld\n");
1927+
1928+#define MAX_TX_MODE 12
1929+static char *HW_TX_MODE_STR[] = {"CCK", "OFDM", "HT-Mix", "HT-GF", "VHT",
1930+ "N/A", "N/A", "N/A", "HE_SU", "HE_EXT_SU",
1931+ "HE_TRIG", "HE_MU", "N/A"};
1932+static char *HW_TX_RATE_CCK_STR[] = {"1M", "2Mlong", "5.5Mlong", "11Mlong",
1933+ "N/A", "2Mshort", "5.5Mshort", "11Mshort",
1934+ "N/A"};
1935+static char *HW_TX_RATE_OFDM_STR[] = {"6M", "9M", "12M", "18M", "24M", "36M",
1936+ "48M", "54M", "N/A"};
1937+static char *fcap_str[] = {"20MHz", "20/40MHz", "20/40/80MHz",
1938+ "20/40/80/160/80+80MHz"};
1939+
1940+static char *hw_rate_ofdm_str(u16 ofdm_idx)
1941+{
1942+ switch (ofdm_idx) {
1943+ case 11: /* 6M */
1944+ return HW_TX_RATE_OFDM_STR[0];
1945+
1946+ case 15: /* 9M */
1947+ return HW_TX_RATE_OFDM_STR[1];
1948+
1949+ case 10: /* 12M */
1950+ return HW_TX_RATE_OFDM_STR[2];
1951+
1952+ case 14: /* 18M */
1953+ return HW_TX_RATE_OFDM_STR[3];
1954+
1955+ case 9: /* 24M */
1956+ return HW_TX_RATE_OFDM_STR[4];
1957+
1958+ case 13: /* 36M */
1959+ return HW_TX_RATE_OFDM_STR[5];
1960+
1961+ case 8: /* 48M */
1962+ return HW_TX_RATE_OFDM_STR[6];
1963+
1964+ case 12: /* 54M */
1965+ return HW_TX_RATE_OFDM_STR[7];
1966+
1967+ default:
1968+ return HW_TX_RATE_OFDM_STR[8];
1969+ }
1970+}
1971+
1972+static char *hw_rate_str(u8 mode, u16 rate_idx)
1973+{
1974+ if (mode == 0)
1975+ return rate_idx < 8 ? HW_TX_RATE_CCK_STR[rate_idx] : HW_TX_RATE_CCK_STR[8];
1976+ else if (mode == 1)
1977+ return hw_rate_ofdm_str(rate_idx);
1978+ else
1979+ return "MCS";
1980+}
1981+
1982+static void parse_rate(struct seq_file *s, u16 rate_idx, u16 txrate)
1983+{
1984+ u16 txmode, mcs, nss, stbc;
1985+
1986+ txmode = FIELD_GET(GENMASK(9, 6), txrate);
1987+ mcs = FIELD_GET(GENMASK(5, 0), txrate);
1988+ nss = FIELD_GET(GENMASK(12, 10), txrate);
1989+ stbc = FIELD_GET(BIT(13), txrate);
1990+
1991+ seq_printf(s, "\tRate%d(0x%x):TxMode=%d(%s), TxRate=%d(%s), Nsts=%d, STBC=%d\n",
1992+ rate_idx + 1, txrate,
1993+ txmode, (txmode < MAX_TX_MODE ? HW_TX_MODE_STR[txmode] : HW_TX_MODE_STR[MAX_TX_MODE]),
1994+ mcs, hw_rate_str(txmode, mcs), nss, stbc);
1995+}
1996+
1997+#define LWTBL_LEN_IN_DW 32
1998+#define UWTBL_LEN_IN_DW 8
1999+#define ONE_KEY_ENTRY_LEN_IN_DW 8
developerf32dabf2022-06-01 10:59:24 +08002000+static int mt7915_sta_info(struct seq_file *s, void *data)
2001+{
2002+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2003+ u8 lwtbl[LWTBL_LEN_IN_DW*4] = {0};
2004+ u16 i = 0;
2005+
2006+ for (i=0; i < mt7915_wtbl_size(dev); i++) {
2007+ mt7915_wtbl_read_raw(dev, i, WTBL_TYPE_LMAC, 0,
2008+ LWTBL_LEN_IN_DW, lwtbl);
2009+ if (lwtbl[4] || lwtbl[5] || lwtbl[6] || lwtbl[7] || lwtbl[0] || lwtbl[1])
2010+ seq_printf(s, "wcid:%d\tAddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
2011+ i, lwtbl[4], lwtbl[5], lwtbl[6], lwtbl[7], lwtbl[0], lwtbl[1]);
2012+ }
2013+
2014+ return 0;
2015+}
2016+
developer3fa816c2022-04-19 10:21:20 +08002017+static int mt7915_wtbl_read(struct seq_file *s, void *data)
2018+{
2019+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2020+ u8 lwtbl[LWTBL_LEN_IN_DW*4] = {0};
2021+ int x;
2022+ u32 *addr = 0;
2023+ u32 dw_value = 0;
2024+
2025+ mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_LMAC, 0,
2026+ LWTBL_LEN_IN_DW, lwtbl);
2027+ seq_printf(s, "Dump WTBL info of WLAN_IDX:%d\n", dev->wlan_idx);
2028+ seq_printf(s, "LMAC WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
2029+ MT_DBG_WTBLON_TOP_WDUCR,
2030+ mt76_rr(dev, MT_DBG_WTBLON_TOP_WDUCR),
2031+ LWTBL_IDX2BASE(dev->wlan_idx, 0));
2032+ for (x = 0; x < LWTBL_LEN_IN_DW; x++) {
2033+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2034+ x,
2035+ lwtbl[x * 4 + 3],
2036+ lwtbl[x * 4 + 2],
2037+ lwtbl[x * 4 + 1],
2038+ lwtbl[x * 4]);
2039+ }
2040+
2041+ seq_printf(s, "\n\tAddr: %02x:%02x:%02x:%02x:%02x:%02x(D0[B0~15], D1[B0~31])\n",
2042+ lwtbl[4], lwtbl[5], lwtbl[6], lwtbl[7], lwtbl[0], lwtbl[1]);
2043+
2044+ // DW0, DW1
2045+ seq_printf(s, "LWTBL DW 0/1\n\t");
2046+ addr = (u32 *)&(lwtbl[0]);
2047+ dw_value = *addr;
2048+ seq_printf(s, "MUAR_IDX:%lu/ ", FIELD_GET(GENMASK(21, 16), dw_value));
2049+ seq_printf(s, "RCA1:%ld/ ", FIELD_GET(BIT(22), dw_value));
2050+ seq_printf(s, "KID:%lu/ ", FIELD_GET(GENMASK(24, 23), dw_value));
2051+ seq_printf(s, "RCID:%ld/ ", FIELD_GET(BIT(25), dw_value));
2052+ seq_printf(s, "FROM_DS:%ld\n\t", FIELD_GET(BIT(26), dw_value));
2053+ seq_printf(s, "TO_DS:%ld/ ", FIELD_GET(BIT(27), dw_value));
2054+ seq_printf(s, "RV:%ld/ ", FIELD_GET(BIT(28), dw_value));
2055+ seq_printf(s, "RCA2:%ld/ ", FIELD_GET(BIT(29), dw_value));
2056+ seq_printf(s, "WPI_FLAG:%ld\n", FIELD_GET(BIT(30), dw_value));
2057+
2058+ // DW2
2059+ seq_printf(s, "LWTBL DW 2\n\t");
2060+ addr = (u32 *)&(lwtbl[2*4]);
2061+ dw_value = *addr;
2062+ seq_printf(s, "AID12:%lu/ ", FIELD_GET(GENMASK(11, 0), dw_value));
2063+ seq_printf(s, "SU:%ld/ ", FIELD_GET(BIT(12), dw_value));
2064+ seq_printf(s, "SPP_EN:%ld/ ", FIELD_GET(BIT(13), dw_value));
2065+ seq_printf(s, "WPI_EVEN:%ld\n\t",FIELD_GET(BIT(14), dw_value));
2066+ seq_printf(s, "CIPHER:%lu/ ", FIELD_GET(GENMASK(20, 16), dw_value));
2067+ seq_printf(s, "CIPHER_IGTK:%lu/ ",FIELD_GET(GENMASK(22, 21), dw_value));
2068+ seq_printf(s, "AAD_OM:%ld\n\t", FIELD_GET(BIT(15), dw_value));
2069+ seq_printf(s, "SW:%ld/ ", FIELD_GET(BIT(24), dw_value));
2070+ seq_printf(s, "UL:%ld/ ", FIELD_GET(BIT(25), dw_value));
2071+ seq_printf(s, "TX_POWER_SAVE:%ld\n\t", FIELD_GET(BIT(26), dw_value));
2072+ seq_printf(s, "QOS:%ld/ ", FIELD_GET(BIT(27), dw_value));
2073+ seq_printf(s, "HT:%ld/ ", FIELD_GET(BIT(28), dw_value));
2074+ seq_printf(s, "VHT:%ld/ ", FIELD_GET(BIT(29), dw_value));
2075+ seq_printf(s, "HE:%ld/ ", FIELD_GET(BIT(30), dw_value));
2076+ seq_printf(s, "MESH:%ld\n", FIELD_GET(BIT(31), dw_value));
2077+
2078+ // DW3
2079+ seq_printf(s, "LWTBL DW 3\n\t");
2080+ addr = (u32 *)&(lwtbl[3*4]);
2081+ dw_value = *addr;
2082+ seq_printf(s, "WMM_Q:%lu/ ", FIELD_GET(GENMASK(1, 0), dw_value));
2083+ seq_printf(s, "RXD_DUP_MODE:%lu\n\t", FIELD_GET(GENMASK(3, 2), dw_value));
2084+ seq_printf(s, "VLAN2ETH:%ld/ ", FIELD_GET(BIT(4), dw_value));
2085+ seq_printf(s, "BEAM_CHG:%ld/ ", FIELD_GET(BIT(5), dw_value));
2086+ seq_printf(s, "DIS_BA256:%ld\n\t", FIELD_GET(BIT(6), dw_value));
2087+ seq_printf(s, "PFMU_IDX:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2088+ seq_printf(s, "ULPF_IDX:%lu\n\t", FIELD_GET(GENMASK(23, 16), dw_value));
2089+ seq_printf(s, "RIBF:%ld/ ", FIELD_GET(BIT(24), dw_value));
2090+ seq_printf(s, "ULPF:%ld\n\t", FIELD_GET(BIT(25), dw_value));
2091+ seq_printf(s, "IGN_FBK:%ld/ ", FIELD_GET(BIT(26), dw_value));
2092+ seq_printf(s, "TBF:%ld/ ", FIELD_GET(BIT(29), dw_value));
2093+ seq_printf(s, "TBF_VHT:%ld/ ", FIELD_GET(BIT(30), dw_value));
2094+ seq_printf(s, "TBF_HE:%ld\n", FIELD_GET(BIT(31), dw_value));
2095+
2096+ // DW4
2097+ seq_printf(s, "LWTBL DW 4\n\t");
2098+ addr = (u32 *)&(lwtbl[4*4]);
2099+ dw_value = *addr;
2100+ seq_printf(s, "ANT_ID_STS0:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value));
2101+ seq_printf(s, "STS1:%lu/ ", FIELD_GET(GENMASK(5, 3), dw_value));
2102+ seq_printf(s, "STS2:%lu/ ", FIELD_GET(GENMASK(8, 6), dw_value));
2103+ seq_printf(s, "STS3:%lu\n\t", FIELD_GET(GENMASK(11, 9), dw_value));
2104+ seq_printf(s, "ANT_ID_STS4:%lu/ ", FIELD_GET(GENMASK(14, 12), dw_value));
2105+ seq_printf(s, "STS5:%lu/ ", FIELD_GET(GENMASK(17, 15), dw_value));
2106+ seq_printf(s, "STS6:%ld/ ", FIELD_GET(GENMASK(20, 18), dw_value));
2107+ seq_printf(s, "STS7:%lu\n\t", FIELD_GET(GENMASK(23, 21), dw_value));
2108+ seq_printf(s, "CASCAD:%ld/ ", FIELD_GET(BIT(24), dw_value));
2109+ seq_printf(s, "LDPC_HT:%ld/ ", FIELD_GET(BIT(25), dw_value));
2110+ seq_printf(s, "LDPC_VHT:%ld/ ", FIELD_GET(BIT(26), dw_value));
2111+ seq_printf(s, "LDPC_HE:%ld\n\t", FIELD_GET(BIT(27), dw_value));
2112+ seq_printf(s, "DIS_RHTR:%ld/ ", FIELD_GET(BIT(28), dw_value));
2113+ seq_printf(s, "ALL_ACK:%ld/ ", FIELD_GET(BIT(29), dw_value));
2114+ seq_printf(s, "DROP:%ld/ ", FIELD_GET(BIT(30), dw_value));
2115+ seq_printf(s, "ACK_EN:%ld\n", FIELD_GET(BIT(31), dw_value));
2116+
2117+ // DW5
2118+ seq_printf(s, "LWTBL DW 5\n\t");
2119+ addr = (u32 *)&(lwtbl[5*4]);
2120+ dw_value = *addr;
2121+ seq_printf(s, "AF:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value));
2122+ seq_printf(s, "AF_HE:%lu/ ", FIELD_GET(GENMASK(4, 3), dw_value));
2123+ seq_printf(s, "RTS:%ld/ ", FIELD_GET(BIT(5), dw_value));
2124+ seq_printf(s, "SMPS:%ld/ ", FIELD_GET(BIT(6), dw_value));
2125+ seq_printf(s, "DYN_BW:%ld\n\t", FIELD_GET(BIT(7), dw_value));
2126+ seq_printf(s, "MMSS:%lu/ ", FIELD_GET(GENMASK(10, 8), dw_value));
2127+ seq_printf(s, "USR:%ld/ ", FIELD_GET(BIT(11), dw_value));
2128+ seq_printf(s, "SR_RATE:%lu/ ", FIELD_GET(GENMASK(14, 12), dw_value));
2129+ seq_printf(s, "SR_ABORT:%ld\n\t", FIELD_GET(BIT(15), dw_value));
2130+ seq_printf(s, "TX_POWER_OFFSET:%lu/ ", FIELD_GET(GENMASK(21, 16), dw_value));
2131+ seq_printf(s, "WTBL_MPDU_SIZE:%lu\n\t", FIELD_GET(GENMASK(23, 22), dw_value));
2132+ seq_printf(s, "PE:%lu/ ", FIELD_GET(GENMASK(25, 24), dw_value));
2133+ seq_printf(s, "DOPPL:%ld/ ", FIELD_GET(BIT(26), dw_value));
2134+ seq_printf(s, "TXOP_PS_CAP:%ld/ ", FIELD_GET(BIT(27), dw_value));
2135+ seq_printf(s, "DONOT_UPDATE_I_PSM:%ld\n\t", FIELD_GET(BIT(28), dw_value));
2136+ seq_printf(s, "I_PSM:%ld/ ", FIELD_GET(BIT(29), dw_value));
2137+ seq_printf(s, "PSM:%ld/ ", FIELD_GET(BIT(30), dw_value));
2138+ seq_printf(s, "SKIP_TX:%ld\n", FIELD_GET(BIT(31), dw_value));
2139+
2140+ // DW6
2141+ seq_printf(s, "LWTBL DW 6\n\t");
2142+ seq_printf(s, "TID 0/1/2/3/4/5/6/7 BA_WIN_SIZE:");
2143+ addr = (u32 *)&(lwtbl[6*4]);
2144+ dw_value = *addr;
2145+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(3, 0), dw_value));
2146+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(7, 4), dw_value));
2147+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(11, 8), dw_value));
2148+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(15, 12), dw_value));
2149+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(19, 16), dw_value));
2150+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(23, 20), dw_value));
2151+ seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(27, 24), dw_value));
2152+ seq_printf(s, "%lu\n", FIELD_GET(GENMASK(31, 28), dw_value));
2153+
2154+ // DW7
2155+ seq_printf(s, "LWTBL DW 7\n\t");
2156+ addr = (u32 *)&(lwtbl[7*4]);
2157+ dw_value = *addr;
2158+ seq_printf(s, "CBRN:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value));
2159+ seq_printf(s, "DBNSS_EN:%ld/ ", FIELD_GET(BIT(3), dw_value));
2160+ seq_printf(s, "BAF_EN:%ld/ ", FIELD_GET(BIT(4), dw_value));
2161+ seq_printf(s, "RDGBA:%ld\n\t", FIELD_GET(BIT(5), dw_value));
2162+ seq_printf(s, "RDG:%ld/ ", FIELD_GET(BIT(6), dw_value));
2163+ seq_printf(s, "SPE_IDX:%lu/ ", FIELD_GET(GENMASK(11, 7), dw_value));
2164+ seq_printf(s, "G2:%ld/ ", FIELD_GET(BIT(12), dw_value));
2165+ seq_printf(s, "G4:%ld/ ", FIELD_GET(BIT(13), dw_value));
2166+ seq_printf(s, "G8:%ld/ ", FIELD_GET(BIT(14), dw_value));
2167+ seq_printf(s, "G16:%ld\n\t", FIELD_GET(BIT(15), dw_value));
2168+ seq_printf(s, "G2_LTF:%lu/ ", FIELD_GET(GENMASK(17, 16), dw_value));
2169+ seq_printf(s, "G4_LTF:%lu/ ", FIELD_GET(GENMASK(19, 18), dw_value));
2170+ seq_printf(s, "G8_LTF:%lu/ ", FIELD_GET(GENMASK(21, 20), dw_value));
2171+ seq_printf(s, "G16_LTF:%lu\n\t", FIELD_GET(GENMASK(23, 22), dw_value));
2172+ seq_printf(s, "G2_HE:%lu/ ", FIELD_GET(GENMASK(25, 24), dw_value));
2173+ seq_printf(s, "G4_HE:%lu/ ", FIELD_GET(GENMASK(27, 27), dw_value));
2174+ seq_printf(s, "G8_HE:%lu/ ", FIELD_GET(GENMASK(29, 28), dw_value));
2175+ seq_printf(s, "G16_HE:%lu\n", FIELD_GET(GENMASK(31, 30), dw_value));
2176+
2177+ // DW8
2178+ seq_printf(s, "LWTBL DW 8\n\t");
2179+ addr = (u32 *)&(lwtbl[8*4]);
2180+ dw_value = *addr;
2181+ seq_printf(s, "FAIL_CNT_AC0:%lu/ ", FIELD_GET(GENMASK(4, 0), dw_value));
2182+ seq_printf(s, "AC1:%lu/ ", FIELD_GET(GENMASK(9, 5), dw_value));
2183+ seq_printf(s, "AC2:%lu/ ", FIELD_GET(GENMASK(14, 10), dw_value));
2184+ seq_printf(s, "AC3:%lu\n\t", FIELD_GET(GENMASK(19, 15), dw_value));
2185+ seq_printf(s, "PARTIAL_AID:%lu/ ", FIELD_GET(GENMASK(28, 20), dw_value));
2186+ seq_printf(s, "CHK_PER:%lu\n", FIELD_GET(BIT(31), dw_value));
2187+
2188+ // DW9
2189+ seq_printf(s, "LWTBL DW 9\n\t");
2190+ addr = (u32 *)&(lwtbl[9*4]);
2191+ dw_value = *addr;
2192+ seq_printf(s, "RX_AVG_MPDU:%lu/ ", FIELD_GET(GENMASK(13, 0), dw_value));
2193+ seq_printf(s, "PRITX_SW_MODE:%ld/ ", FIELD_GET(BIT(16), dw_value));
2194+ seq_printf(s, "PRITX_PLR:%ld\n\t", FIELD_GET(BIT(17), dw_value));
2195+ seq_printf(s, "PRITX_DCM:%ld/ ", FIELD_GET(BIT(18), dw_value));
2196+ seq_printf(s, "PRITX_ER160:%ld/ ", FIELD_GET(BIT(19), dw_value));
2197+ seq_printf(s, "PRITX_ERSU:%lu\n\t", FIELD_GET(BIT(20), dw_value));
2198+ seq_printf(s, "MPDU_FAIL_CNT:%lu/ ", FIELD_GET(GENMASK(25, 23), dw_value));
2199+ seq_printf(s, "MPDU_OK_CNT:%lu/ ", FIELD_GET(GENMASK(28, 26), dw_value));
2200+ seq_printf(s, "RATE_IDX:%lu\n\t", FIELD_GET(GENMASK(31, 29), dw_value));
2201+ seq_printf(s, "FCAP:%s\n", fcap_str[FIELD_GET(GENMASK(22, 21), dw_value)]);
2202+
2203+ // DW10
2204+ seq_printf(s, "LWTBL DW 10\n");
2205+ addr = (u32 *)&(lwtbl[10*4]);
2206+ dw_value = *addr;
2207+ parse_rate(s, 0, FIELD_GET(GENMASK(13, 0), dw_value));
2208+ parse_rate(s, 1, FIELD_GET(GENMASK(29, 16), dw_value));
2209+ // DW11
2210+ seq_printf(s, "LWTBL DW 11\n");
2211+ addr = (u32 *)&(lwtbl[11*4]);
2212+ dw_value = *addr;
2213+ parse_rate(s, 2, FIELD_GET(GENMASK(13, 0), dw_value));
2214+ parse_rate(s, 3, FIELD_GET(GENMASK(29, 16), dw_value));
2215+ // DW12
2216+ seq_printf(s, "LWTBL DW 12\n");
2217+ addr = (u32 *)&(lwtbl[12*4]);
2218+ dw_value = *addr;
2219+ parse_rate(s, 4, FIELD_GET(GENMASK(13, 0), dw_value));
2220+ parse_rate(s, 5, FIELD_GET(GENMASK(29, 16), dw_value));
2221+ // DW13
2222+ seq_printf(s, "LWTBL DW 13\n");
2223+ addr = (u32 *)&(lwtbl[13*4]);
2224+ dw_value = *addr;
2225+ parse_rate(s, 6, FIELD_GET(GENMASK(13, 0), dw_value));
2226+ parse_rate(s, 7, FIELD_GET(GENMASK(29, 16), dw_value));
2227+
2228+ //DW28
2229+ seq_printf(s, "LWTBL DW 28\n\t");
2230+ addr = (u32 *)&(lwtbl[28*4]);
2231+ dw_value = *addr;
2232+ seq_printf(s, "OM_INFO:%lu/ ", FIELD_GET(GENMASK(11, 0), dw_value));
2233+ seq_printf(s, "OM_RXD_DUP_MODE:%u\n\t", !!(dw_value & BIT(12)) );
2234+
2235+ //DW29
2236+ seq_printf(s, "LWTBL DW 29\n");
2237+ addr = (u32 *)&(lwtbl[29*4]);
2238+ dw_value = *addr;
2239+ seq_printf(s, "USER_RSSI:%lu/ ", FIELD_GET(GENMASK(8, 0), dw_value));
2240+ seq_printf(s, "USER_SNR:%lu/ ", FIELD_GET(GENMASK(14, 9), dw_value));
2241+ seq_printf(s, "RAPID_REACTION_RATE:%lu/ ", FIELD_GET(GENMASK(26, 16), dw_value));
2242+ seq_printf(s, "HT_AMSDU(Read Only):%u/ ", !!(dw_value & BIT(30)) );
2243+ seq_printf(s, "AMSDU_CROSS_LG(Read Only):%u\n\t ", !!(dw_value & BIT(31)));
2244+
2245+ //DW30
2246+ seq_printf(s, "LWTBL DW 30\n\t");
2247+ addr = (u32 *)&(lwtbl[30*4]);
2248+ dw_value = *addr;
2249+ seq_printf(s, "RCPI 0:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2250+ seq_printf(s, "RCPI 1:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2251+ seq_printf(s, "RCPI 2:%lu/ ", FIELD_GET(GENMASK(23, 16), dw_value));
2252+ seq_printf(s, "RCPI 3:%lu\n\t", FIELD_GET(GENMASK(31, 24), dw_value));
2253+
2254+ //DW31
2255+ seq_printf(s, "LWTBL DW 31\n\t");
2256+ addr = (u32 *)&(lwtbl[31*4]);
2257+ dw_value = *addr;
2258+ seq_printf(s, "RCPI 4:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2259+ seq_printf(s, "RCPI 5:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2260+ seq_printf(s, "RCPI 6:%lu/ ", FIELD_GET(GENMASK(23, 16), dw_value));
2261+ seq_printf(s, "RCPI 7:%lu\n\t", FIELD_GET(GENMASK(31, 24), dw_value));
2262+
2263+ return 0;
2264+}
2265+
2266+static int mt7915_uwtbl_read(struct seq_file *s, void *data)
2267+{
2268+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2269+ u8 uwtbl[UWTBL_LEN_IN_DW * 4] = {0};
2270+ u8 keytbl[ONE_KEY_ENTRY_LEN_IN_DW*4] = {0};
2271+ int x;
2272+ u32 *addr = 0;
2273+ u32 dw_value = 0;
2274+ u32 amsdu_len = 0;
2275+ u32 u2SN = 0;
2276+ u16 keyloc0, keyloc1;
2277+
2278+ mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC, 0,
2279+ UWTBL_LEN_IN_DW, uwtbl);
2280+ seq_printf(s, "Dump WTBL info of WLAN_IDX:%d\n", dev->wlan_idx);
2281+ seq_printf(s, "UMAC WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
2282+ MT_DBG_WTBLON_TOP_WDUCR,
2283+ mt76_rr(dev, MT_DBG_WTBLON_TOP_WDUCR),
2284+ UWTBL_IDX2BASE(dev->wlan_idx, 0));
2285+ for (x = 0; x < UWTBL_LEN_IN_DW; x++) {
2286+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2287+ x,
2288+ uwtbl[x * 4 + 3],
2289+ uwtbl[x * 4 + 2],
2290+ uwtbl[x * 4 + 1],
2291+ uwtbl[x * 4]);
2292+ }
2293+
2294+ /* UMAC WTBL DW 0 */
2295+ seq_printf(s, "\nUWTBL PN\n\t");
2296+ addr = (u32 *)&(uwtbl[0]);
2297+ dw_value = *addr;
2298+ seq_printf(s, "PN0:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2299+ seq_printf(s, "PN1:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value));
2300+ seq_printf(s, "PN2:%lu\n\t", FIELD_GET(GENMASK(23, 16), dw_value));
2301+ seq_printf(s, "PN3:%lu/ ", FIELD_GET(GENMASK(31, 24), dw_value));
2302+
2303+ addr = (u32 *)&(uwtbl[1 * 4]);
2304+ dw_value = *addr;
2305+ seq_printf(s, "PN4:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value));
2306+ seq_printf(s, "PN5:%lu\n", FIELD_GET(GENMASK(15, 8), dw_value));
2307+
2308+ /* UMAC WTBL DW SN part */
2309+ seq_printf(s, "\nUWTBL SN\n");
2310+ addr = (u32 *)&(uwtbl[2 * 4]);
2311+ dw_value = *addr;
2312+ seq_printf(s, "TID0_AC0_SN:%lu\n", FIELD_GET(GENMASK(11, 0), dw_value));
2313+ seq_printf(s, "TID1_AC1_SN:%lu\n", FIELD_GET(GENMASK(23, 12), dw_value));
2314+
2315+ u2SN = FIELD_GET(GENMASK(31, 24), dw_value);
2316+ addr = (u32 *)&(uwtbl[3 * 4]);
2317+ dw_value = *addr;
2318+ u2SN |= FIELD_GET(GENMASK(3, 0), dw_value);
2319+ seq_printf(s, "TID2_AC2_SN:%u\n", u2SN);
2320+ seq_printf(s, "TID3_AC3_SN:%lu\n", FIELD_GET(GENMASK(15, 4), dw_value));
2321+ seq_printf(s, "TID4_SN:%lu\n", FIELD_GET(GENMASK(27, 16), dw_value));
2322+
2323+ u2SN = FIELD_GET(GENMASK(31, 28), dw_value);
2324+ addr = (u32 *)&(uwtbl[4 * 4]);
2325+ dw_value = *addr;
2326+ u2SN |= FIELD_GET(GENMASK(7, 0), dw_value);
2327+ seq_printf(s, "TID5_SN:%u\n", u2SN);
2328+ seq_printf(s, "TID6_SN:%lu\n", FIELD_GET(GENMASK(19, 8), dw_value));
2329+ seq_printf(s, "TID7_SN:%lu\n", FIELD_GET(GENMASK(31, 20), dw_value));
2330+
2331+ addr = (u32 *)&(uwtbl[1 * 4]);
2332+ dw_value = *addr;
2333+ seq_printf(s, "COM_SN:%lu\n", FIELD_GET(GENMASK(27, 16), dw_value));
2334+
2335+ /* UMAC WTBL DW 0 */
2336+ seq_printf(s, "\nUWTBL others\n");
2337+
2338+ addr = (u32 *)&(uwtbl[5 * 4]);
2339+ dw_value = *addr;
2340+ keyloc0 = FIELD_GET(GENMASK(10, 0), dw_value);
2341+ keyloc1 = FIELD_GET(GENMASK(26, 16), dw_value);
2342+ seq_printf(s, "\tKey Loc 1/2:%lu/%lu\n",
2343+ FIELD_GET(GENMASK(10, 0), dw_value),
2344+ FIELD_GET(GENMASK(26, 16), dw_value));
2345+ seq_printf(s, "\tUWTBL_QOS:%lu\n", FIELD_GET(BIT(27), dw_value));
2346+ seq_printf(s, "\tUWTBL_HT_VHT_HE:%lu\n", FIELD_GET(BIT(28), dw_value));
2347+
2348+ addr = (u32 *)&(uwtbl[6*4]);
2349+ dw_value = *addr;
2350+ seq_printf(s, "\tHW AMSDU Enable:%lu\n", FIELD_GET(BIT(9), dw_value));
2351+
2352+ amsdu_len = FIELD_GET(GENMASK(5, 0), dw_value);
2353+ if (amsdu_len == 0)
2354+ seq_printf(s, "\tHW AMSDU Len:invalid (WTBL value=0x%x)\n", amsdu_len);
2355+ else if (amsdu_len == 1)
2356+ seq_printf(s, "\tHW AMSDU Len:%d~%d (WTBL value=0x%x)\n",
2357+ 1,
2358+ 255,
2359+ amsdu_len);
2360+ else
2361+ seq_printf(s, "\tHW AMSDU Len:%d~%d (WTBL value=0x%x)\n",
2362+ 256 * (amsdu_len - 1),
2363+ 256 * (amsdu_len - 1) + 255,
2364+ amsdu_len
2365+ );
2366+ seq_printf(s, "\tHW AMSDU Num:%lu (WTBL value=0x%lx)\n",
2367+ FIELD_GET(GENMASK(8, 6), dw_value) + 1,
2368+ FIELD_GET(GENMASK(8, 6), dw_value));
2369+
2370+ /* Parse KEY link */
2371+ seq_printf(s, "\n\tkeyloc0:%d\n", keyloc0);
2372+ if(keyloc0 != GENMASK(10, 0)) {
2373+ mt7915_wtbl_read_raw(dev, keyloc0, WTBL_TYPE_KEY,
2374+ 0, ONE_KEY_ENTRY_LEN_IN_DW, keytbl);
2375+ seq_printf(s, "KEY WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
2376+ MT_DBG_WTBLON_TOP_WDUCR,
2377+ mt76_rr(dev, MT_DBG_WTBLON_TOP_WDUCR),
2378+ KEYTBL_IDX2BASE(keyloc0, 0));
2379+
2380+ for (x = 0; x < ONE_KEY_ENTRY_LEN_IN_DW; x++) {
2381+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2382+ x,
2383+ keytbl[x * 4 + 3],
2384+ keytbl[x * 4 + 2],
2385+ keytbl[x * 4 + 1],
2386+ keytbl[x * 4]);
2387+ }
2388+ }
2389+
2390+ seq_printf(s, "\n\tkeyloc1:%d\n", keyloc1);
2391+ if(keyloc1 != GENMASK(26, 16)) {
2392+ mt7915_wtbl_read_raw(dev, keyloc1, WTBL_TYPE_KEY,
2393+ 0, ONE_KEY_ENTRY_LEN_IN_DW, keytbl);
2394+ seq_printf(s, "KEY WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n",
2395+ MT_DBG_WTBLON_TOP_WDUCR,
2396+ mt76_rr(dev, MT_DBG_WTBLON_TOP_WDUCR),
2397+ KEYTBL_IDX2BASE(keyloc1, 0));
2398+
2399+ for (x = 0; x < ONE_KEY_ENTRY_LEN_IN_DW; x++) {
2400+ seq_printf(s, "DW%02d: %02x %02x %02x %02x\n",
2401+ x,
2402+ keytbl[x * 4 + 3],
2403+ keytbl[x * 4 + 2],
2404+ keytbl[x * 4 + 1],
2405+ keytbl[x * 4]);
2406+ }
2407+ }
2408+ return 0;
2409+}
2410+
2411+static void
2412+dump_dma_tx_ring_info(struct seq_file *s, struct mt7915_dev *dev, char *str, u32 ring_base)
2413+{
2414+ u32 base, cnt, cidx, didx, queue_cnt;
2415+
2416+ base= mt76_rr(dev, ring_base);
2417+ cnt = mt76_rr(dev, ring_base + 4);
2418+ cidx = mt76_rr(dev, ring_base + 8);
2419+ didx = mt76_rr(dev, ring_base + 12);
2420+ queue_cnt = (cidx >= didx) ? (cidx - didx) : (cidx - didx + cnt);
2421+
2422+ seq_printf(s, "%20s %10x %10x %10x %10x %10x\n", str, base, cnt, cidx, didx, queue_cnt);
2423+}
2424+
2425+static void
2426+dump_dma_rx_ring_info(struct seq_file *s, struct mt7915_dev *dev, char *str, u32 ring_base)
2427+{
2428+ u32 base, cnt, cidx, didx, queue_cnt;
2429+
2430+ base= mt76_rr(dev, ring_base);
2431+ cnt = mt76_rr(dev, ring_base + 4);
2432+ cidx = mt76_rr(dev, ring_base + 8);
2433+ didx = mt76_rr(dev, ring_base + 12);
2434+ queue_cnt = (didx > cidx) ? (didx - cidx - 1) : (didx - cidx + cnt - 1);
2435+
2436+ seq_printf(s, "%20s %10x %10x %10x %10x %10x\n", str, base, cnt, cidx, didx, queue_cnt);
2437+}
2438+
2439+static void
2440+mt7915_show_host_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2441+{
2442+ u32 sys_ctrl[10] = {};
2443+
2444+ /* HOST DMA */
2445+ sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT_SOURCE_CSR);
2446+ sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT_MASK_CSR);
2447+ sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_INT_SOURCE_CSR);
2448+ sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_INT_MASK_CSR);
2449+ sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA1_INT_SOURCE_CSR);
2450+ sys_ctrl[5] = mt76_rr(dev, MT_DBG_WFDMA1_INT_MASK_CSR);
2451+ sys_ctrl[6] = mt76_rr(dev, MT_DBG_WFDMA0_GLO_CFG);
2452+ sys_ctrl[7] = mt76_rr(dev, MT_DBG_WFDMA1_GLO_CFG);
2453+ seq_printf(s, "HOST_DMA Configuration\n");
2454+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2455+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2456+ seq_printf(s, "%10s %10x %10x\n",
2457+ "Merge", sys_ctrl[0], sys_ctrl[1]);
2458+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2459+ "DMA0", sys_ctrl[2], sys_ctrl[3], sys_ctrl[6],
2460+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_TX_DMA_EN, sys_ctrl[6]),
2461+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_RX_DMA_EN, sys_ctrl[6]),
2462+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_TX_BUSY_MASK, sys_ctrl[6]),
2463+ FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_RX_BUSY_MASK, sys_ctrl[6]));
2464+
2465+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2466+ "DMA1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[7],
2467+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_TX_DMA_EN, sys_ctrl[7]),
2468+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_RX_DMA_EN, sys_ctrl[7]),
2469+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[7]),
2470+ FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[7]));
2471+
2472+ sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT1_SOURCE_CSR);
2473+ sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT1_MASK_CSR);
2474+ sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_INT_SOURCE_CSR);
2475+ sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_INT_MASK_CSR);
2476+ sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_INT_SOURCE_CSR);
2477+ sys_ctrl[5] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_INT_MASK_CSR);
2478+ sys_ctrl[6] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_GLO_CFG);
2479+ sys_ctrl[7] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_GLO_CFG);
2480+ seq_printf(s, "%10s %10x %10x\n",
2481+ "MergeP1", sys_ctrl[0], sys_ctrl[1]);
2482+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2483+ "DMA0P1", sys_ctrl[2], sys_ctrl[3], sys_ctrl[6],
2484+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN, sys_ctrl[6]),
2485+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN, sys_ctrl[6]),
2486+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[6]),
2487+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[6]));
2488+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2489+ "DMA1P1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[7],
2490+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN, sys_ctrl[7]),
2491+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN, sys_ctrl[7]),
2492+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[7]),
2493+ FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[7]));
2494+
2495+ seq_printf(s, "HOST_DMA0 Ring Configuration\n");
2496+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2497+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2498+ dump_dma_rx_ring_info(s, dev, "R0:Data0(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(0));
2499+ dump_dma_rx_ring_info(s, dev, "R1:Data1(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(1));
2500+
2501+ seq_printf(s, "HOST_DMA0 PCIe 1 Ring Configuration\n");
2502+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2503+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2504+ dump_dma_rx_ring_info(s, dev, "R1:Data1(MAC2H)", MT_DBG_WFDMA0_PCIE1_RX1_CTRL0);
2505+
2506+ seq_printf(s, "HOST_DMA1 Ring Configuration\n");
2507+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2508+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2509+ dump_dma_tx_ring_info(s, dev, "T16:FWDL", MT_DBG_TX_RING_CTRL(0));
2510+ dump_dma_tx_ring_info(s, dev, "T17:Cmd(H2WM)", MT_DBG_TX_RING_CTRL(1));
2511+ dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_TX_RING_CTRL(2));
2512+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_TX_RING_CTRL(3));
2513+ dump_dma_tx_ring_info(s, dev, "T20:Cmd(H2WA)", MT_DBG_TX_RING_CTRL(4));
2514+ dump_dma_rx_ring_info(s, dev, "R0:Event(WM2H)", MT_DBG_RX_EVENT_RING_CTRL(0));
2515+ dump_dma_rx_ring_info(s, dev, "R1:Event0(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(1));
2516+ dump_dma_rx_ring_info(s, dev, "R2:Event1(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(2));
2517+
2518+ seq_printf(s, "HOST_DMA1 PCIe 1 Ring Configuration\n");
2519+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2520+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2521+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA1_PCIE1_TX19_CTRL0);
2522+ dump_dma_rx_ring_info(s, dev, "R2:Event1(WA2H)", MT_DBG_WFDMA1_PCIE1_RX2_CTRL0);
2523+}
2524+
2525+static void
2526+mt7915_show_mcu_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2527+{
2528+ u32 sys_ctrl[9] = {};
2529+
2530+ /* MCU DMA information */
2531+ sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR);
2532+ sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR);
2533+ sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR);
2534+
2535+ sys_ctrl[3] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_ADDR);
2536+ sys_ctrl[4] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_HOST_INT_STA_ADDR);
2537+ sys_ctrl[5] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_HOST_INT_ENA_ADDR);
2538+ sys_ctrl[6] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_ADDR);
2539+ sys_ctrl[7] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_STA_ADDR);
2540+ sys_ctrl[8] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_ENA_ADDR);
2541+
2542+ seq_printf(s, "MCU_DMA Configuration\n");
2543+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2544+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2545+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2546+ "DMA0", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0],
2547+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT,
2548+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT,
2549+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT,
2550+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT);
2551+
2552+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2553+ "DMA1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[3],
2554+ (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT,
2555+ (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT,
2556+ (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT,
2557+ (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT);
2558+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2559+ "DMA1P1", sys_ctrl[7], sys_ctrl[8], sys_ctrl[6],
2560+ (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT,
2561+ (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT,
2562+ (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT,
2563+ (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT);
2564+
2565+ seq_printf(s, "MCU_DMA0 Ring Configuration\n");
2566+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2567+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2568+ dump_dma_tx_ring_info(s, dev, "T0:TXD(WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR);
2569+ dump_dma_tx_ring_info(s, dev, "T1:TXCMD(WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR);
2570+ dump_dma_tx_ring_info(s, dev, "T2:TXD(WA2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR);
2571+ dump_dma_rx_ring_info(s, dev, "R0:Data(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR);
2572+ dump_dma_rx_ring_info(s, dev, "R1:TxDone(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR);
2573+ dump_dma_rx_ring_info(s, dev, "R2:SPL(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR);
2574+ dump_dma_rx_ring_info(s, dev, "R3:TxDone(MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR);
2575+ dump_dma_rx_ring_info(s, dev, "R4:TXS(MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR);
2576+
2577+ seq_printf(s, "MCU_DMA1 Ring Configuration\n");
2578+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2579+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2580+ dump_dma_tx_ring_info(s, dev, "T0:Event(WM2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING0_CTRL0_ADDR);
2581+ dump_dma_tx_ring_info(s, dev, "T1:Event0(WA2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING1_CTRL0_ADDR);
2582+ dump_dma_tx_ring_info(s, dev, "T2:Event1(WA2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING2_CTRL0_ADDR);
2583+ dump_dma_rx_ring_info(s, dev, "R0:FWDL", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING0_CTRL0_ADDR);
2584+ dump_dma_rx_ring_info(s, dev, "R1:Cmd(H2WM)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING1_CTRL0_ADDR);
2585+ dump_dma_rx_ring_info(s, dev, "R2:TXD0(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING2_CTRL0_ADDR);
2586+ dump_dma_rx_ring_info(s, dev, "R3:TXD1(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING3_CTRL0_ADDR);
2587+ dump_dma_rx_ring_info(s, dev, "R4:Cmd(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING4_CTRL0_ADDR);
2588+
2589+ seq_printf(s, "MCU_DMA1 PCIe 1 Ring Configuration\n");
2590+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2591+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2592+ dump_dma_tx_ring_info(s, dev, "T2:Event1(WA2H)", WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_TX_RING2_CTRL0_ADDR);
2593+ dump_dma_rx_ring_info(s, dev, "R3:TXD1(H2WA)", WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_RX_RING3_CTRL0_ADDR);
2594+}
2595+
2596+static void
2597+mt7986_show_host_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2598+{
2599+ u32 sys_ctrl[5] = {};
2600+
2601+ /* HOST DMA */
2602+ sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT_SOURCE_CSR);
2603+ sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT_MASK_CSR);
2604+ sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_INT_SOURCE_CSR);
2605+ sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_INT_MASK_CSR);
2606+ sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA0_GLO_CFG);
2607+
2608+ seq_printf(s, "HOST_DMA Configuration\n");
2609+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2610+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2611+ seq_printf(s, "%10s %10x %10x\n",
2612+ "Merge", sys_ctrl[0], sys_ctrl[1]);
2613+ seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n",
2614+ "DMA0", sys_ctrl[2], sys_ctrl[3], sys_ctrl[4],
2615+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_EN_MASK, sys_ctrl[4]),
2616+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_EN_MASK, sys_ctrl[4]),
2617+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_BUSY_MASK, sys_ctrl[4]),
2618+ FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_BUSY_MASK, sys_ctrl[4]));
2619+
2620+
2621+ seq_printf(s, "HOST_DMA0 Ring Configuration\n");
2622+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2623+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2624+ dump_dma_tx_ring_info(s, dev, "T16:FWDL", MT_DBG_TX_RING_CTRL(0));
2625+ dump_dma_tx_ring_info(s, dev, "T17:Cmd(H2WM)", MT_DBG_TX_RING_CTRL(1));
2626+ dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_TX_RING_CTRL(2));
2627+ dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_TX_RING_CTRL(3));
2628+ dump_dma_tx_ring_info(s, dev, "T20:Cmd(H2WA)", MT_DBG_TX_RING_CTRL(4));
2629+ dump_dma_rx_ring_info(s, dev, "R0:Event(WM2H)", MT_DBG_RX_DATA_RING_CTRL(0));
2630+ dump_dma_rx_ring_info(s, dev, "R1:Event(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(1));
2631+ dump_dma_rx_ring_info(s, dev, "R2:TxDone(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(2));
2632+ dump_dma_rx_ring_info(s, dev, "R3:TxDone1(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(3));
2633+ dump_dma_rx_ring_info(s, dev, "R4:Data0(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(0));
2634+ dump_dma_rx_ring_info(s, dev, "R5:Data1(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(1));
2635+}
2636+
2637+static void
2638+mt7986_show_mcu_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2639+{
2640+ u32 sys_ctrl[3] = {};
2641+
2642+ /* MCU DMA information */
2643+ sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR);
2644+ sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR);
2645+ sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR);
2646+
2647+ seq_printf(s, "MCU_DMA Configuration\n");
2648+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2649+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2650+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2651+ "DMA0", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0],
2652+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT,
2653+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT,
2654+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT,
2655+ (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT);
2656+
2657+ seq_printf(s, "MCU_DMA0 Ring Configuration\n");
2658+ seq_printf(s, "%22s %10s %10s %10s %10s %10s\n",
2659+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2660+ dump_dma_tx_ring_info(s, dev, "T0:Event (WM2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR);
2661+ dump_dma_tx_ring_info(s, dev, "T1:Event (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR);
2662+ dump_dma_tx_ring_info(s, dev, "T2:TxDone (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR);
2663+ dump_dma_tx_ring_info(s, dev, "T3:TxDone1 (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING3_CTRL0_ADDR);
2664+ dump_dma_tx_ring_info(s, dev, "T4:TXD (WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING4_CTRL0_ADDR);
2665+ dump_dma_tx_ring_info(s, dev, "T5:TXCMD (WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING5_CTRL0_ADDR);
2666+ dump_dma_tx_ring_info(s, dev, "T6:TXD (WA2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING6_CTRL0_ADDR);
2667+ dump_dma_rx_ring_info(s, dev, "R0:FWDL", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR);
2668+ dump_dma_rx_ring_info(s, dev, "R1:Cmd (H2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR);
2669+ dump_dma_rx_ring_info(s, dev, "R2:TXD (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR);
2670+ dump_dma_rx_ring_info(s, dev, "R3:TXD1 (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR);
2671+ dump_dma_rx_ring_info(s, dev, "R4:Cmd (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR);
2672+ dump_dma_rx_ring_info(s, dev, "R5:Data (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING5_CTRL0_ADDR);
2673+ dump_dma_rx_ring_info(s, dev, "R6:TxDone/STS (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING6_CTRL0_ADDR);
2674+ dump_dma_rx_ring_info(s, dev, "R7:RPT (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING7_CTRL0_ADDR);
2675+ dump_dma_rx_ring_info(s, dev, "R8:TxDone/STS (MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING8_CTRL0_ADDR);
2676+ dump_dma_rx_ring_info(s, dev, "R9:Data1 (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING9_CTRL0_ADDR);
2677+
2678+}
2679+
2680+static void
2681+mt7915_show_dma_info(struct seq_file *s, struct mt7915_dev *dev)
2682+{
2683+ u32 sys_ctrl[10] = {};
2684+
2685+ if(is_mt7915(&dev->mt76)) {
2686+ mt7915_show_host_dma_info(s, dev);
2687+ mt7915_show_mcu_dma_info(s, dev);
2688+ } else {
2689+ mt7986_show_host_dma_info(s, dev);
2690+ mt7986_show_mcu_dma_info(s, dev);
2691+ }
2692+
2693+ /* MEM DMA information */
2694+ sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_ADDR);
2695+ sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MEM_DMA_HOST_INT_STA_ADDR);
2696+ sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MEM_DMA_HOST_INT_ENA_ADDR);
2697+
2698+ seq_printf(s, "MEM_DMA Configuration\n");
2699+ seq_printf(s, "%10s %10s %10s %10s %10s %10s\n",
2700+ "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy");
2701+ seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n",
2702+ "MEM", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0],
2703+ (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_SHFT,
2704+ (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_SHFT,
2705+ (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT,
2706+ (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT);
2707+
2708+ seq_printf(s, "MEM_DMA Ring Configuration\n");
2709+ seq_printf(s, "%20s %10s %10s %10s %10s %10s\n",
2710+ "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt");
2711+ dump_dma_tx_ring_info(s, dev, "T0:CmdEvent(WM2WA)", WF_WFDMA_MEM_DMA_WPDMA_TX_RING0_CTRL0_ADDR);
2712+ dump_dma_tx_ring_info(s, dev, "T1:CmdEvent(WA2WM)", WF_WFDMA_MEM_DMA_WPDMA_TX_RING1_CTRL0_ADDR);
2713+ dump_dma_rx_ring_info(s, dev, "R0:CmdEvent(WM2WA)", WF_WFDMA_MEM_DMA_WPDMA_RX_RING0_CTRL0_ADDR);
2714+ dump_dma_rx_ring_info(s, dev, "R1:CmdEvent(WA2WM)", WF_WFDMA_MEM_DMA_WPDMA_RX_RING1_CTRL0_ADDR);
2715+}
2716+
2717+static int mt7915_trinfo_read(struct seq_file *s, void *data)
2718+{
2719+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2720+ const struct hif_pci_tx_ring_desc *tx_ring_layout;
2721+ const struct hif_pci_rx_ring_desc *rx_ring_layout;
2722+ u32 tx_ring_num, rx_ring_num;
2723+ u32 tbase[5], tcnt[5];
2724+ u32 tcidx[5], tdidx[5];
2725+ u32 rbase[6], rcnt[6];
2726+ u32 rcidx[6], rdidx[6];
2727+ int idx;
2728+
2729+ if(is_mt7915(&dev->mt76)) {
2730+ tx_ring_layout = &mt7915_tx_ring_layout[0];
2731+ rx_ring_layout = &mt7915_rx_ring_layout[0];
2732+ tx_ring_num = ARRAY_SIZE(mt7915_tx_ring_layout);
2733+ rx_ring_num = ARRAY_SIZE(mt7915_rx_ring_layout);
2734+ } else {
2735+ tx_ring_layout = &mt7986_tx_ring_layout[0];
2736+ rx_ring_layout = &mt7986_rx_ring_layout[0];
2737+ tx_ring_num = ARRAY_SIZE(mt7986_tx_ring_layout);
2738+ rx_ring_num = ARRAY_SIZE(mt7986_rx_ring_layout);
2739+ }
2740+
2741+ for (idx = 0; idx < tx_ring_num; idx++) {
2742+ tbase[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx));
2743+ tcnt[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x04);
2744+ tcidx[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x08);
2745+ tdidx[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x0c);
2746+ }
2747+
2748+ for (idx = 0; idx < rx_ring_num; idx++) {
2749+ if (idx < 2) {
2750+ rbase[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx));
2751+ rcnt[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x04);
2752+ rcidx[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x08);
2753+ rdidx[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x0c);
2754+ } else {
2755+ rbase[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2));
2756+ rcnt[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x04);
2757+ rcidx[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x08);
2758+ rdidx[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x0c);
2759+ }
2760+ }
2761+
2762+ seq_printf(s, "=================================================\n");
2763+ seq_printf(s, "TxRing Configuration\n");
2764+ seq_printf(s, "%4s %10s %8s %1s %6s %6s %6s %6s\n",
2765+ "Idx", "Attr", "Reg", "Base", "Cnt", "CIDX", "DIDX",
2766+ "QCnt");
2767+ for (idx = 0; idx < tx_ring_num; idx++) {
2768+ u32 queue_cnt;
2769+
2770+ queue_cnt = (tcidx[idx] >= tdidx[idx]) ?
2771+ (tcidx[idx] - tdidx[idx]) :
2772+ (tcidx[idx] - tdidx[idx] + tcnt[idx]);
2773+ seq_printf(s, "%4d %8s %8x %10x %6x %6x %6x %6x\n",
2774+ idx, tx_ring_layout[idx].ring_info,
2775+ MT_DBG_TX_RING_CTRL(idx), tbase[idx],
2776+ tcnt[idx], tcidx[idx], tdidx[idx], queue_cnt);
2777+ }
2778+
2779+ seq_printf(s, "RxRing Configuration\n");
2780+ seq_printf(s, "%4s %10s %8s %10s %6s %6s %6s %6s\n",
2781+ "Idx", "Attr", "Reg", "Base", "Cnt", "CIDX", "DIDX",
2782+ "QCnt");
2783+
2784+ for (idx = 0; idx < rx_ring_num; idx++) {
2785+ u32 queue_cnt;
2786+
2787+ queue_cnt = (rdidx[idx] > rcidx[idx]) ?
2788+ (rdidx[idx] - rcidx[idx] - 1) :
2789+ (rdidx[idx] - rcidx[idx] + rcnt[idx] - 1);
2790+ seq_printf(s, "%4d %8s %8x %10x %6x %6x %6x %6x\n",
2791+ idx, rx_ring_layout[idx].ring_info,
2792+ (idx < 2) ? MT_DBG_RX_DATA_RING_CTRL(idx): MT_DBG_RX_EVENT_RING_CTRL(idx - 2),
2793+ rbase[idx], rcnt[idx], rcidx[idx], rdidx[idx], queue_cnt);
2794+ }
2795+
2796+ mt7915_show_dma_info(s, dev);
2797+ return 0;
2798+}
2799+
2800+static int mt7915_drr_info(struct seq_file *s, void *data)
2801+{
2802+#define DL_AC_START 0x00
2803+#define DL_AC_END 0x0F
2804+#define UL_AC_START 0x10
2805+#define UL_AC_END 0x1F
2806+
2807+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
2808+ u32 drr_sta_status[16];
2809+ u32 drr_ctrl_def_val = 0x80220000, drr_ctrl_val = 0;
2810+ bool is_show = false;
2811+ int idx, sta_line = 0, sta_no = 0, max_sta_line = (mt7915_wtbl_size(dev) + 31) / 32;
2812+ seq_printf(s, "DRR Table STA Info:\n");
2813+
2814+ for (idx = DL_AC_START; idx <= DL_AC_END; idx++) {
2815+ is_show = true;
2816+ drr_ctrl_val = (drr_ctrl_def_val | idx);
2817+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
2818+ drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
2819+ drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
2820+ drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
2821+ drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
2822+ drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
2823+ drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
2824+ drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
2825+ drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
2826+
2827+ if (is_mt7915(&dev->mt76) && max_sta_line > 8) {
2828+ drr_ctrl_val = (drr_ctrl_def_val | idx | 1 << 10);
2829+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
2830+ drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
2831+ drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
2832+ drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
2833+ drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
2834+ drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
2835+ drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
2836+ drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
2837+ drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
2838+ }
2839+ if (!is_mt7915(&dev->mt76))
2840+ max_sta_line = 8;
2841+
2842+ for (sta_line = 0; sta_line < max_sta_line; sta_line++) {
2843+ if (drr_sta_status[sta_line] > 0) {
2844+ for (sta_no = 0; sta_no < 32; sta_no++) {
2845+ if (((drr_sta_status[sta_line] & (0x1 << sta_no)) >> sta_no)) {
2846+ if (is_show) {
2847+ seq_printf(s, "\n DL AC%02d Queue Non-Empty STA:\n", idx);
2848+ is_show = false;
2849+ }
2850+ seq_printf(s, "%d ", sta_no + (sta_line * 32));
2851+ }
2852+ }
2853+ }
2854+ }
2855+ }
2856+
2857+ for (idx = UL_AC_START; idx <= UL_AC_END; idx++) {
2858+ is_show = true;
2859+ drr_ctrl_val = (drr_ctrl_def_val | idx);
2860+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
2861+ drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
2862+ drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
2863+ drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
2864+ drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
2865+ drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
2866+ drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
2867+ drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
2868+ drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
2869+
2870+ if (is_mt7915(&dev->mt76) && max_sta_line > 8) {
2871+ drr_ctrl_val = (drr_ctrl_def_val | idx | 1 << 10);
2872+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
2873+ drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
2874+ drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
2875+ drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
2876+ drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
2877+ drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
2878+ drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
2879+ drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
2880+ drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
2881+ }
2882+
2883+ if (!is_mt7915(&dev->mt76))
2884+ max_sta_line = 8;
2885+
2886+ for (sta_line = 0; sta_line < max_sta_line; sta_line++) {
2887+ if (drr_sta_status[sta_line] > 0) {
2888+ for (sta_no = 0; sta_no < 32; sta_no++) {
2889+ if (((drr_sta_status[sta_line] & (0x1 << sta_no)) >> sta_no)) {
2890+ if (is_show) {
2891+ seq_printf(s, "\n UL AC%02d Queue Non-Empty STA:\n", idx);
2892+ is_show = false;
2893+ }
2894+ seq_printf(s, "%d ", sta_no + (sta_line * 32));
2895+ }
2896+ }
2897+ }
2898+ }
2899+ }
2900+
2901+ for (idx = DL_AC_START; idx <= DL_AC_END; idx++) {
2902+ drr_ctrl_def_val = 0x80420000;
2903+ drr_ctrl_val = (drr_ctrl_def_val | idx);
2904+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
2905+ drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
2906+ drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
2907+ drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
2908+ drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
2909+ drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
2910+ drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
2911+ drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
2912+ drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
2913+
2914+ if (is_mt7915(&dev->mt76) && max_sta_line > 8) {
2915+ drr_ctrl_val = (drr_ctrl_def_val | idx | 1<<10);
2916+ mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val);
2917+ drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0);
2918+ drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1);
2919+ drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2);
2920+ drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3);
2921+ drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4);
2922+ drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5);
2923+ drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6);
2924+ drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7);
2925+ }
2926+
2927+ seq_printf(s, "\nBSSGrp[%d]:\n", idx);
2928+ if (!is_mt7915(&dev->mt76))
2929+ max_sta_line = 8;
2930+
2931+ for (sta_line = 0; sta_line < max_sta_line; sta_line++) {
2932+ seq_printf(s, "0x%08x ", drr_sta_status[sta_line]);
2933+
2934+ if ((sta_line % 4) == 3)
2935+ seq_printf(s, "\n");
2936+ }
2937+ }
2938+
2939+ return 0;
2940+}
2941+
developerf32dabf2022-06-01 10:59:24 +08002942+#define CR_NUM_OF_AC 17
developer3fa816c2022-04-19 10:21:20 +08002943+
2944+typedef enum _ENUM_UMAC_PORT_T {
2945+ ENUM_UMAC_HIF_PORT_0 = 0,
2946+ ENUM_UMAC_CPU_PORT_1 = 1,
2947+ ENUM_UMAC_LMAC_PORT_2 = 2,
2948+ ENUM_PLE_CTRL_PSE_PORT_3 = 3,
2949+ ENUM_UMAC_PSE_PLE_PORT_TOTAL_NUM = 4
2950+} ENUM_UMAC_PORT_T, *P_ENUM_UMAC_PORT_T;
2951+
2952+/* N9 MCU QUEUE LIST */
2953+typedef enum _ENUM_UMAC_CPU_P_QUEUE_T {
2954+ ENUM_UMAC_CTX_Q_0 = 0,
2955+ ENUM_UMAC_CTX_Q_1 = 1,
2956+ ENUM_UMAC_CTX_Q_2 = 2,
2957+ ENUM_UMAC_CTX_Q_3 = 3,
2958+ ENUM_UMAC_CRX = 0,
2959+ ENUM_UMAC_CIF_QUEUE_TOTAL_NUM = 4
2960+} ENUM_UMAC_CPU_P_QUEUE_T, *P_ENUM_UMAC_CPU_P_QUEUE_T;
2961+
2962+/* LMAC PLE TX QUEUE LIST */
2963+typedef enum _ENUM_UMAC_LMAC_PLE_TX_P_QUEUE_T {
2964+ ENUM_UMAC_LMAC_PLE_TX_Q_00 = 0x00,
2965+ ENUM_UMAC_LMAC_PLE_TX_Q_01 = 0x01,
2966+ ENUM_UMAC_LMAC_PLE_TX_Q_02 = 0x02,
2967+ ENUM_UMAC_LMAC_PLE_TX_Q_03 = 0x03,
2968+
2969+ ENUM_UMAC_LMAC_PLE_TX_Q_10 = 0x04,
2970+ ENUM_UMAC_LMAC_PLE_TX_Q_11 = 0x05,
2971+ ENUM_UMAC_LMAC_PLE_TX_Q_12 = 0x06,
2972+ ENUM_UMAC_LMAC_PLE_TX_Q_13 = 0x07,
2973+
2974+ ENUM_UMAC_LMAC_PLE_TX_Q_20 = 0x08,
2975+ ENUM_UMAC_LMAC_PLE_TX_Q_21 = 0x09,
2976+ ENUM_UMAC_LMAC_PLE_TX_Q_22 = 0x0a,
2977+ ENUM_UMAC_LMAC_PLE_TX_Q_23 = 0x0b,
2978+
2979+ ENUM_UMAC_LMAC_PLE_TX_Q_30 = 0x0c,
2980+ ENUM_UMAC_LMAC_PLE_TX_Q_31 = 0x0d,
2981+ ENUM_UMAC_LMAC_PLE_TX_Q_32 = 0x0e,
2982+ ENUM_UMAC_LMAC_PLE_TX_Q_33 = 0x0f,
2983+
2984+ ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 = 0x10,
2985+ ENUM_UMAC_LMAC_PLE_TX_Q_BMC_0 = 0x11,
2986+ ENUM_UMAC_LMAC_PLE_TX_Q_BNC_0 = 0x12,
2987+ ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0 = 0x13,
2988+
2989+ ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 = 0x14,
2990+ ENUM_UMAC_LMAC_PLE_TX_Q_BMC_1 = 0x15,
2991+ ENUM_UMAC_LMAC_PLE_TX_Q_BNC_1 = 0x16,
2992+ ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1 = 0x17,
2993+ ENUM_UMAC_LMAC_PLE_TX_Q_NAF = 0x18,
2994+ ENUM_UMAC_LMAC_PLE_TX_Q_NBCN = 0x19,
2995+ ENUM_UMAC_LMAC_PLE_TX_Q_RELEASE = 0x1f, /* DE suggests not to use 0x1f, it's only for hw free queue */
2996+ ENUM_UMAC_LMAC_QUEUE_TOTAL_NUM = 24,
2997+
2998+} ENUM_UMAC_LMAC_TX_P_QUEUE_T, *P_ENUM_UMAC_LMAC_TX_P_QUEUE_T;
2999+
3000+typedef struct _EMPTY_QUEUE_INFO_T {
3001+ char *QueueName;
3002+ u32 Portid;
3003+ u32 Queueid;
3004+} EMPTY_QUEUE_INFO_T, *P_EMPTY_QUEUE_INFO_T;
3005+
3006+static EMPTY_QUEUE_INFO_T ple_queue_empty_info[] = {
3007+ {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0},
3008+ {"CPU Q1", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_1},
3009+ {"CPU Q2", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_2},
3010+ {"CPU Q3", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_3},
3011+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 4~7 not defined */
3012+ {"ALTX Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0}, /* Q16 */
3013+ {"BMC Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BMC_0},
3014+ {"BCN Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BNC_0},
3015+ {"PSMP Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0},
3016+ {"ALTX Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1},
3017+ {"BMC Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BMC_1},
3018+ {"BCN Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BNC_1},
3019+ {"PSMP Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1},
3020+ {"NAF Q", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_NAF},
3021+ {"NBCN Q", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_NBCN},
3022+ {NULL, 0, 0}, {NULL, 0, 0}, /* 18, 19 not defined */
3023+ {"FIXFID Q", ENUM_UMAC_LMAC_PORT_2, 0x1a},
3024+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0},
3025+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 21~29 not defined */
3026+ {"RLS Q", ENUM_PLE_CTRL_PSE_PORT_3, 0x7e},
3027+ {"RLS2 Q", ENUM_PLE_CTRL_PSE_PORT_3, 0x7f}
3028+};
3029+
3030+static EMPTY_QUEUE_INFO_T ple_txcmd_queue_empty_info[] = {
3031+ {"AC00Q", ENUM_UMAC_LMAC_PORT_2, 0x40},
3032+ {"AC01Q", ENUM_UMAC_LMAC_PORT_2, 0x41},
3033+ {"AC02Q", ENUM_UMAC_LMAC_PORT_2, 0x42},
3034+ {"AC03Q", ENUM_UMAC_LMAC_PORT_2, 0x43},
3035+ {"AC10Q", ENUM_UMAC_LMAC_PORT_2, 0x44},
3036+ {"AC11Q", ENUM_UMAC_LMAC_PORT_2, 0x45},
3037+ {"AC12Q", ENUM_UMAC_LMAC_PORT_2, 0x46},
3038+ {"AC13Q", ENUM_UMAC_LMAC_PORT_2, 0x47},
3039+ {"AC20Q", ENUM_UMAC_LMAC_PORT_2, 0x48},
3040+ {"AC21Q", ENUM_UMAC_LMAC_PORT_2, 0x49},
3041+ {"AC22Q", ENUM_UMAC_LMAC_PORT_2, 0x4a},
3042+ {"AC23Q", ENUM_UMAC_LMAC_PORT_2, 0x4b},
3043+ {"AC30Q", ENUM_UMAC_LMAC_PORT_2, 0x4c},
3044+ {"AC31Q", ENUM_UMAC_LMAC_PORT_2, 0x4d},
3045+ {"AC32Q", ENUM_UMAC_LMAC_PORT_2, 0x4e},
3046+ {"AC33Q", ENUM_UMAC_LMAC_PORT_2, 0x4f},
3047+ {"ALTX Q0", ENUM_UMAC_LMAC_PORT_2, 0x50},
3048+ {"TF Q0", ENUM_UMAC_LMAC_PORT_2, 0x51},
3049+ {"TWT TSF-TF Q0", ENUM_UMAC_LMAC_PORT_2, 0x52},
3050+ {"TWT DL Q0", ENUM_UMAC_LMAC_PORT_2, 0x53},
3051+ {"TWT UL Q0", ENUM_UMAC_LMAC_PORT_2, 0x54},
3052+ {"ALTX Q1", ENUM_UMAC_LMAC_PORT_2, 0x55},
3053+ {"TF Q1", ENUM_UMAC_LMAC_PORT_2, 0x56},
3054+ {"TWT TSF-TF Q1", ENUM_UMAC_LMAC_PORT_2, 0x57},
3055+ {"TWT DL Q1", ENUM_UMAC_LMAC_PORT_2, 0x58},
3056+ {"TWT UL Q1", ENUM_UMAC_LMAC_PORT_2, 0x59},
3057+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0},
3058+};
3059+
3060+
3061+
3062+static char* sta_ctrl_reg[] = {"ENABLE", "DISABLE", "PAUSE"};
3063+static u32 chip_show_sta_acq_info(struct seq_file *s, struct mt7915_dev *dev, u32 *ple_stat,
3064+ u32 *sta_pause, u32 *dis_sta_map,
3065+ u32 dumptxd)
3066+{
3067+ int i, j;
3068+ u32 total_nonempty_cnt = 0;
3069+ u32 ac_num = 9, all_ac_num;
3070+
3071+ /* TDO: ac_num = 16 for mt7986 */
developerf32dabf2022-06-01 10:59:24 +08003072+ if (!is_mt7915(&dev->mt76))
3073+ ac_num = 17;
developer3fa816c2022-04-19 10:21:20 +08003074+
3075+ all_ac_num = ac_num * 4;
3076+
3077+ for (j = 0; j < all_ac_num; j++) { /* show AC Q info */
3078+ for (i = 0; i < 32; i++) {
3079+ if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) {
developerf32dabf2022-06-01 10:59:24 +08003080+ u32 hfid, tfid, pktcnt, ac_n = j / ac_num, ctrl = 0;
developer3fa816c2022-04-19 10:21:20 +08003081+ u32 sta_num = i + (j % ac_num) * 32, fl_que_ctrl[3] = {0};
3082+ //struct wifi_dev *wdev = wdev_search_by_wcid(pAd, sta_num);
3083+ u32 wmmidx = 0;
3084+ struct mt7915_sta *msta;
3085+ struct mt76_wcid *wcid;
3086+ struct ieee80211_sta *sta = NULL;
3087+
3088+ wcid = rcu_dereference(dev->mt76.wcid[sta_num]);
3089+ sta = wcid_to_sta(wcid);
3090+ if (!sta) {
3091+ printk("ERROR!! no found STA wcid=%d\n", sta_num);
developerf32dabf2022-06-01 10:59:24 +08003092+ continue;
developer3fa816c2022-04-19 10:21:20 +08003093+ }
3094+ msta = container_of(wcid, struct mt7915_sta, wcid);
3095+ wmmidx = msta->vif->mt76.wmm_idx;
3096+
developerf32dabf2022-06-01 10:59:24 +08003097+ seq_printf(s, "\tSTA%d AC%d: ", sta_num, ac_n);
developer3fa816c2022-04-19 10:21:20 +08003098+
3099+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
3100+ fl_que_ctrl[0] |= (ENUM_UMAC_LMAC_PORT_2 << MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
developerf32dabf2022-06-01 10:59:24 +08003101+ fl_que_ctrl[0] |= (ac_n << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
developer3fa816c2022-04-19 10:21:20 +08003102+ fl_que_ctrl[0] |= sta_num;
3103+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
3104+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
3105+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
3106+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]);
3107+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]);
3108+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]);
3109+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x",
3110+ tfid, hfid, pktcnt);
3111+
3112+ if (((sta_pause[j % 6] & 0x1 << i) >> i) == 1)
3113+ ctrl = 2;
3114+
3115+ if (((dis_sta_map[j % 6] & 0x1 << i) >> i) == 1)
3116+ ctrl = 1;
3117+
3118+ seq_printf(s, " ctrl = %s", sta_ctrl_reg[ctrl]);
3119+ seq_printf(s, " (wmmidx=%d)\n", wmmidx);
3120+
3121+ total_nonempty_cnt++;
3122+
3123+ // TODO
3124+ //if (pktcnt > 0 && dumptxd > 0)
3125+ // ShowTXDInfo(pAd, hfid);
3126+ }
3127+ }
3128+ }
3129+
3130+ return total_nonempty_cnt;
3131+}
3132+
3133+static void chip_show_txcmdq_info(struct seq_file *s, struct mt7915_dev *dev, u32 ple_txcmd_stat)
3134+{
3135+ int i;
3136+
3137+ seq_printf(s, "Nonempty TXCMD Q info:\n");
developerf32dabf2022-06-01 10:59:24 +08003138+ for (i = 0; i < 32; i++) {
developer3fa816c2022-04-19 10:21:20 +08003139+ if (((ple_txcmd_stat & (0x1 << i)) >> i) == 0) {
3140+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
3141+
3142+ if (ple_txcmd_queue_empty_info[i].QueueName != NULL) {
3143+ seq_printf(s, "\t%s: ", ple_txcmd_queue_empty_info[i].QueueName);
3144+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
3145+ fl_que_ctrl[0] |= (ple_txcmd_queue_empty_info[i].Portid <<
3146+ MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
3147+ fl_que_ctrl[0] |= (ple_txcmd_queue_empty_info[i].Queueid <<
3148+ MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
3149+ } else
3150+ continue;
3151+
3152+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
3153+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
3154+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
3155+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]);
3156+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]);
3157+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]);
3158+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n",
3159+ tfid, hfid, pktcnt);
3160+ }
3161+ }
3162+}
3163+
3164+static void chip_get_ple_acq_stat(struct mt7915_dev *dev, u32 *ple_stat)
3165+{
3166+ int i;
3167+ int cr_num = 9, all_cr_num;
3168+ u32 ac , index;
3169+
3170+ /* TDO: cr_num = 16 for mt7986 */
developer3fa816c2022-04-19 10:21:20 +08003171+ if(!is_mt7915(&dev->mt76))
developerf32dabf2022-06-01 10:59:24 +08003172+ cr_num = 17;
3173+
developer3fa816c2022-04-19 10:21:20 +08003174+ all_cr_num = cr_num * 4;
3175+
3176+ ple_stat[0] = mt76_rr(dev, MT_DBG_PLE_QUEUE_EMPTY);
3177+
3178+ for(i = 0; i < all_cr_num; i++) {
3179+ ac = i / cr_num;
3180+ index = i % cr_num;
3181+ ple_stat[i + 1] =
3182+ mt76_rr(dev, MT_DBG_PLE_AC_QEMPTY(ac, index));
3183+
3184+ }
3185+}
3186+
3187+static void chip_get_dis_sta_map(struct mt7915_dev *dev, u32 *dis_sta_map)
3188+{
3189+ int i;
developerf32dabf2022-06-01 10:59:24 +08003190+ u32 ac_num = 9;
3191+
3192+ /* TDO: ac_num = 16 for mt7986 */
3193+ if (!is_mt7915(&dev->mt76))
3194+ ac_num = 17;
developer3fa816c2022-04-19 10:21:20 +08003195+
developerf32dabf2022-06-01 10:59:24 +08003196+ for(i = 0; i < ac_num; i++) {
developer3fa816c2022-04-19 10:21:20 +08003197+ dis_sta_map[i] = mt76_rr(dev, MT_DBG_PLE_DIS_STA_MAP(i));
3198+ }
3199+}
3200+
3201+static void chip_get_sta_pause(struct mt7915_dev *dev, u32 *sta_pause)
3202+{
3203+ int i;
developerf32dabf2022-06-01 10:59:24 +08003204+ u32 ac_num = 9;
developer3fa816c2022-04-19 10:21:20 +08003205+
developerf32dabf2022-06-01 10:59:24 +08003206+ /* TDO: ac_num = 16 for mt7986 */
3207+ if (!is_mt7915(&dev->mt76))
3208+ ac_num = 17;
3209+
3210+ for(i = 0; i < ac_num; i++) {
developer3fa816c2022-04-19 10:21:20 +08003211+ sta_pause[i] = mt76_rr(dev, MT_DBG_PLE_STATION_PAUSE(i));
3212+ }
3213+}
3214+
3215+static int mt7915_pleinfo_read(struct seq_file *s, void *data)
3216+{
3217+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3218+ u32 ple_buf_ctrl, pg_sz, pg_num;
developerf32dabf2022-06-01 10:59:24 +08003219+ u32 ple_stat[70] = {0}, pg_flow_ctrl[8] = {0};
developer3fa816c2022-04-19 10:21:20 +08003220+ u32 ple_native_txcmd_stat;
3221+ u32 ple_txcmd_stat;
3222+ u32 sta_pause[CR_NUM_OF_AC] = {0}, dis_sta_map[CR_NUM_OF_AC] = {0};
3223+ u32 fpg_cnt, ffa_cnt, fpg_head, fpg_tail, hif_max_q, hif_min_q;
3224+ u32 rpg_hif, upg_hif, cpu_max_q, cpu_min_q, rpg_cpu, upg_cpu;
3225+ int i, j;
3226+ u32 ac_num = 9, all_ac_num;
3227+
3228+ /* TDO: ac_num = 16 for mt7986 */
developerf32dabf2022-06-01 10:59:24 +08003229+ if (!is_mt7915(&dev->mt76))
3230+ ac_num = 17;
developer3fa816c2022-04-19 10:21:20 +08003231+
3232+ all_ac_num = ac_num * 4;
3233+
3234+ ple_buf_ctrl = mt76_rr(dev, MT_DBG_PLE_PBUF_CTRL_ADDR);
3235+ chip_get_ple_acq_stat(dev, ple_stat);
3236+ ple_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_TXCMD_Q_EMPTY);
3237+ ple_native_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_NATIVE_TXCMD_Q_EMPTY);
3238+ pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PLE_FREEPG_CNT);
3239+ pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FREEPG_HEAD_TAIL);
3240+ pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_GROUP);
3241+ pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PLE_HIF_PG_INFO);
3242+ pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PLE_PG_CPU_GROUP);
3243+ pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PLE_CPU_PG_INFO);
3244+ pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_TXCMD_GROUP);
3245+ pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PLE_HIF_TXCMD_PG_INFO);
3246+ chip_get_dis_sta_map(dev, dis_sta_map);
3247+ chip_get_sta_pause(dev, sta_pause);
3248+
3249+ seq_printf(s, "PLE Configuration Info:\n");
3250+ seq_printf(s, "\tPacket Buffer Control(0x%x): 0x%08x\n",
3251+ MT_DBG_PLE_PBUF_CTRL_ADDR, ple_buf_ctrl);
3252+
3253+ pg_sz = FIELD_GET(MT_DBG_PLE_PBUF_CTRL_PAGE_SIZE_MASK, ple_buf_ctrl);
3254+ seq_printf(s, "\t\tPage Size=%d(%d bytes per page)\n",
3255+ pg_sz, (pg_sz == 1 ? 128 : 64));
3256+ seq_printf(s, "\t\tPage Offset=%ld(in unit of 2KB)\n",
3257+ FIELD_GET(MT_DBG_PLE_PBUF_CTRL_OFFSET_MASK, ple_buf_ctrl));
3258+
3259+ pg_num = FIELD_GET(MT_DBG_PLE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK, ple_buf_ctrl);
3260+ seq_printf(s, "\t\tTotal Page=%d pages\n", pg_num);
3261+
3262+ /* Page Flow Control */
3263+ seq_printf(s, "PLE Page Flow Control:\n");
3264+ seq_printf(s, "\tFree page counter(0x%x): 0x%08x\n",
3265+ MT_DBG_PLE_FREEPG_CNT, pg_flow_ctrl[0]);
3266+ fpg_cnt = FIELD_GET(MT_DBG_PLE_FREEPG_CNT_FREEPG_CNT_MASK, pg_flow_ctrl[0]);
3267+
3268+ seq_printf(s, "\t\tThe toal page number of free=0x%03x\n", fpg_cnt);
3269+ ffa_cnt = FIELD_GET(MT_DBG_PLE_FREEPG_CNT_FFA_CNT_MASK, pg_flow_ctrl[0]);
3270+
3271+ seq_printf(s, "\t\tThe free page numbers of free for all=0x%03x\n", ffa_cnt);
3272+ seq_printf(s, "\tFree page head and tail(0x%x): 0x%08x\n",
3273+ MT_DBG_PLE_FREEPG_HEAD_TAIL, pg_flow_ctrl[1]);
3274+
3275+ fpg_head = FIELD_GET(MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK, pg_flow_ctrl[1]);
3276+ fpg_tail = FIELD_GET(MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK, pg_flow_ctrl[1]);
3277+ seq_printf(s, "\t\tThe tail/head page of free page list=0x%03x/0x%03x\n", fpg_tail, fpg_head);
3278+ seq_printf(s, "\tReserved page counter of HIF group(0x%x): 0x%08x\n",
3279+ MT_DBG_PLE_PG_HIF_GROUP, pg_flow_ctrl[2]);
3280+ seq_printf(s, "\tHIF group page status(0x%x): 0x%08x\n",
3281+ MT_DBG_PLE_HIF_PG_INFO, pg_flow_ctrl[3]);
3282+
3283+ hif_min_q = FIELD_GET(MT_DBG_PLE_PG_HIF_GROUP_HIF_MIN_QUOTA_MASK, pg_flow_ctrl[2]);
3284+ hif_max_q = FIELD_GET(MT_DBG_PLE_PG_HIF_GROUP_HIF_MAX_QUOTA_MASK, pg_flow_ctrl[2]);
3285+ seq_printf(s, "\t\tThe max/min quota pages of HIF group=0x%03x/0x%03x\n", hif_max_q, hif_min_q);
3286+
3287+ rpg_hif = FIELD_GET(MT_DBG_PLE_HIF_PG_INFO_HIF_RSV_CNT_MASK, pg_flow_ctrl[3]);
3288+ upg_hif = FIELD_GET(MT_DBG_PLE_HIF_PG_INFO_HIF_SRC_CNT_MASK, pg_flow_ctrl[3]);
3289+ seq_printf(s, "\t\tThe used/reserved pages of HIF group=0x%03x/0x%03x\n", upg_hif, rpg_hif);
3290+
3291+ seq_printf(s, "\tReserved page counter of HIF_TXCMD group(0x%x): 0x%08x\n",
3292+ MT_DBG_PLE_PG_HIF_TXCMD_GROUP, pg_flow_ctrl[6]);
3293+ seq_printf(s, "\tHIF_TXCMD group page status(0x%x): 0x%08x\n",
3294+ MT_DBG_PLE_HIF_TXCMD_PG_INFO, pg_flow_ctrl[7]);
3295+ cpu_min_q = FIELD_GET(MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MIN_QUOTA_MASK, pg_flow_ctrl[6]);
developerf32dabf2022-06-01 10:59:24 +08003296+ cpu_max_q = FIELD_GET(MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MAX_QUOTA_MASK, pg_flow_ctrl[6]);
developer3fa816c2022-04-19 10:21:20 +08003297+ seq_printf(s, "\t\tThe max/min quota pages of HIF_TXCMD group=0x%03x/0x%03x\n", cpu_max_q, cpu_min_q);
3298+
3299+ rpg_cpu = FIELD_GET(MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK, pg_flow_ctrl[7]);
3300+ upg_cpu = FIELD_GET(MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK, pg_flow_ctrl[7]);
3301+ seq_printf(s, "\t\tThe used/reserved pages of HIF_TXCMD group=0x%03x/0x%03x\n", upg_cpu, rpg_cpu);
3302+
developerf32dabf2022-06-01 10:59:24 +08003303+ seq_printf(s, "\tReserved page counter of CPU group(0x%x): 0x%08x\n",
3304+ MT_DBG_PLE_PG_CPU_GROUP, pg_flow_ctrl[4]);
3305+ seq_printf(s, "\tCPU group page status(0x%x): 0x%08x\n",
3306+ MT_DBG_PLE_CPU_PG_INFO, pg_flow_ctrl[5]);
developer3fa816c2022-04-19 10:21:20 +08003307+ cpu_min_q = FIELD_GET(MT_DBG_PLE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK, pg_flow_ctrl[4]);
3308+ cpu_max_q = FIELD_GET(MT_DBG_PLE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK, pg_flow_ctrl[4]);
3309+ seq_printf(s, "\t\tThe max/min quota pages of CPU group=0x%03x/0x%03x\n", cpu_max_q, cpu_min_q);
3310+
3311+ rpg_cpu = FIELD_GET(MT_DBG_PLE_CPU_PG_INFO_CPU_RSV_CNT_MASK, pg_flow_ctrl[5]);
3312+ upg_cpu = FIELD_GET(MT_DBG_PLE_CPU_PG_INFO_CPU_SRC_CNT_MASK, pg_flow_ctrl[5]);
3313+ seq_printf(s, "\t\tThe used/reserved pages of CPU group=0x%03x/0x%03x\n", upg_cpu, rpg_cpu);
3314+
3315+ if ((ple_stat[0] & MT_DBG_PLE_Q_EMPTY_ALL_AC_EMPTY_MASK) == 0) {
3316+ for (j = 0; j < all_ac_num; j++) {
3317+ if (j % ac_num == 0) {
3318+ seq_printf(s, "\n\tNonempty AC%d Q of STA#: ", j / ac_num);
3319+ }
3320+
developerf32dabf2022-06-01 10:59:24 +08003321+ for (i = 0; i < 32; i++) {
developer3fa816c2022-04-19 10:21:20 +08003322+ if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) {
3323+ seq_printf(s, "%d ", i + (j % ac_num) * 32);
3324+ }
3325+ }
3326+ }
3327+
3328+ seq_printf(s, "\n");
3329+ }
3330+
3331+ seq_printf(s, "non-native/native txcmd queue empty = %d/%d\n", ple_txcmd_stat, ple_native_txcmd_stat);
3332+
3333+ seq_printf(s, "Nonempty Q info:\n");
3334+
developerf32dabf2022-06-01 10:59:24 +08003335+ for (i = 0; i < 32; i++) {
developer3fa816c2022-04-19 10:21:20 +08003336+ if (((ple_stat[0] & (0x1 << i)) >> i) == 0) {
3337+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
3338+
3339+ if (ple_queue_empty_info[i].QueueName != NULL) {
3340+ seq_printf(s, "\t%s: ", ple_queue_empty_info[i].QueueName);
3341+ fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK;
3342+ fl_que_ctrl[0] |= (ple_queue_empty_info[i].Portid << MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT);
3343+ fl_que_ctrl[0] |= (ple_queue_empty_info[i].Queueid << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT);
3344+ } else
3345+ continue;
3346+
3347+ if (ple_queue_empty_info[i].Queueid >= ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 &&
3348+ ple_queue_empty_info[i].Queueid <= ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0)
3349+ /* band0 set TGID 0, bit31 = 0 */
3350+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x0);
3351+ else if (ple_queue_empty_info[i].Queueid >= ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 &&
3352+ ple_queue_empty_info[i].Queueid <= ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1)
3353+ /* band1 set TGID 1, bit31 = 1 */
3354+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x80000000);
3355+
3356+ mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]);
3357+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2);
3358+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3);
3359+ hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]);
3360+ tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]);
3361+ pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]);
3362+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n",
3363+ tfid, hfid, pktcnt);
3364+
3365+ /* TODO */
3366+ //if (pktcnt > 0 && dumptxd > 0)
3367+ // ShowTXDInfo(pAd, hfid);
3368+ }
3369+ }
3370+
3371+ chip_show_sta_acq_info(s, dev, ple_stat, sta_pause, dis_sta_map, 0/*dumptxd*/);
3372+ chip_show_txcmdq_info(s, dev, ple_native_txcmd_stat);
3373+
3374+ return 0;
3375+}
3376+
3377+typedef enum _ENUM_UMAC_PLE_CTRL_P3_QUEUE_T {
3378+ ENUM_UMAC_PLE_CTRL_P3_Q_0X1E = 0x1e,
3379+ ENUM_UMAC_PLE_CTRL_P3_Q_0X1F = 0x1f,
3380+ ENUM_UMAC_PLE_CTRL_P3_TOTAL_NUM = 2
3381+} ENUM_UMAC_PLE_CTRL_P3_QUEUE_T, *P_ENUM_UMAC_PLE_CTRL_P3_QUEUE_T;
3382+
3383+static EMPTY_QUEUE_INFO_T pse_queue_empty_info[] = {
3384+ {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0},
3385+ {"CPU Q1", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_1},
3386+ {"CPU Q2", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_2},
3387+ {"CPU Q3", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_3},
3388+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 4~7 not defined */
3389+ {"HIF Q0", ENUM_UMAC_HIF_PORT_0, 0}, /* Q8 */
3390+ {"HIF Q1", ENUM_UMAC_HIF_PORT_0, 1},
3391+ {"HIF Q2", ENUM_UMAC_HIF_PORT_0, 2},
3392+ {"HIF Q3", ENUM_UMAC_HIF_PORT_0, 3},
3393+ {"HIF Q4", ENUM_UMAC_HIF_PORT_0, 4},
3394+ {"HIF Q5", ENUM_UMAC_HIF_PORT_0, 5},
3395+ {NULL, 0, 0}, {NULL, 0, 0}, /* 14~15 not defined */
3396+ {"LMAC Q", ENUM_UMAC_LMAC_PORT_2, 0},
3397+ {"MDP TX Q", ENUM_UMAC_LMAC_PORT_2, 1},
3398+ {"MDP RX Q", ENUM_UMAC_LMAC_PORT_2, 2},
3399+ {"SEC TX Q", ENUM_UMAC_LMAC_PORT_2, 3},
3400+ {"SEC RX Q", ENUM_UMAC_LMAC_PORT_2, 4},
3401+ {"SFD_PARK Q", ENUM_UMAC_LMAC_PORT_2, 5},
3402+ {"MDP_TXIOC Q", ENUM_UMAC_LMAC_PORT_2, 6},
3403+ {"MDP_RXIOC Q", ENUM_UMAC_LMAC_PORT_2, 7},
3404+ {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 24~30 not defined */
3405+ {"RLS Q", ENUM_PLE_CTRL_PSE_PORT_3, ENUM_UMAC_PLE_CTRL_P3_Q_0X1F}
3406+};
3407+
3408+static int mt7915_pseinfo_read(struct seq_file *s, void *data)
3409+{
3410+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3411+ u32 pse_buf_ctrl, pg_sz, pg_num;
3412+ u32 pse_stat, pg_flow_ctrl[22] = {0};
3413+ u32 fpg_cnt, ffa_cnt, fpg_head, fpg_tail;
3414+ u32 max_q, min_q, rsv_pg, used_pg;
3415+ int i;
3416+
3417+ pse_buf_ctrl = mt76_rr(dev, MT_DBG_PSE_PBUF_CTRL);
3418+ pse_stat = mt76_rr(dev, MT_DBG_PSE_QUEUE_EMPTY);
3419+ pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PSE_FREEPG_CNT);
3420+ pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PSE_FREEPG_HEAD_TAIL);
3421+ pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PSE_PG_HIF0_GROUP);
3422+ pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PSE_HIF0_PG_INFO);
3423+ pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PSE_PG_HIF1_GROUP);
3424+ pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PSE_HIF1_PG_INFO);
3425+ pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PSE_PG_CPU_GROUP);
3426+ pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PSE_CPU_PG_INFO);
3427+ pg_flow_ctrl[8] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC0_GROUP);
3428+ pg_flow_ctrl[9] = mt76_rr(dev, MT_DBG_PSE_LMAC0_PG_INFO);
3429+ pg_flow_ctrl[10] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC1_GROUP);
3430+ pg_flow_ctrl[11] = mt76_rr(dev, MT_DBG_PSE_LMAC1_PG_INFO);
3431+ pg_flow_ctrl[12] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC2_GROUP);
3432+ pg_flow_ctrl[13] = mt76_rr(dev, MT_DBG_PSE_LMAC2_PG_INFO);
3433+ pg_flow_ctrl[14] = mt76_rr(dev, MT_DBG_PSE_PG_PLE_GROUP);
3434+ pg_flow_ctrl[15] = mt76_rr(dev, MT_DBG_PSE_PLE_PG_INFO);
3435+ pg_flow_ctrl[16] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC3_GROUP);
3436+ pg_flow_ctrl[17] = mt76_rr(dev, MT_DBG_PSE_LMAC3_PG_INFO);
3437+ pg_flow_ctrl[18] = mt76_rr(dev, MT_DBG_PSE_PG_MDP_GROUP);
3438+ pg_flow_ctrl[19] = mt76_rr(dev, MT_DBG_PSE_MDP_PG_INFO);
3439+ pg_flow_ctrl[20] = mt76_rr(dev, MT_DBG_PSE_PG_PLE1_GROUP);
3440+ pg_flow_ctrl[21] = mt76_rr(dev,MT_DBG_PSE_PLE1_PG_INFO);
3441+
3442+ /* Configuration Info */
3443+ seq_printf(s, "PSE Configuration Info:\n");
3444+ seq_printf(s, "\tPacket Buffer Control(0x82068014): 0x%08x\n", pse_buf_ctrl);
3445+ pg_sz = FIELD_GET(MT_DBG_PSE_PBUF_CTRL_PAGE_SIZE_CFG_MASK, pse_buf_ctrl);
3446+
3447+ seq_printf(s, "\t\tPage Size=%d(%d bytes per page)\n", pg_sz, (pg_sz == 1 ? 256 : 128));
3448+ seq_printf(s, "\t\tPage Offset=%ld(in unit of 64KB)\n",
3449+ FIELD_GET(MT_DBG_PSE_PBUF_CTRL_PBUF_OFFSET_MASK, pse_buf_ctrl));
3450+ pg_num = FIELD_GET(MT_DBG_PSE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK, pse_buf_ctrl);
3451+
3452+ seq_printf(s, "\t\tTotal page numbers=%d pages\n", pg_num);
3453+
3454+ /* Page Flow Control */
3455+ seq_printf(s, "PSE Page Flow Control:\n");
3456+ seq_printf(s, "\tFree page counter(0x82068100): 0x%08x\n", pg_flow_ctrl[0]);
3457+ fpg_cnt = FIELD_GET(MT_DBG_PSE_FREEPG_CNT_FREEPG_CNT_MASK, pg_flow_ctrl[0]);
3458+ seq_printf(s, "\t\tThe toal page number of free=0x%03x\n", fpg_cnt);
3459+
3460+ ffa_cnt = FIELD_GET(MT_DBG_PSE_FREEPG_CNT_FFA_CNT_MASK, pg_flow_ctrl[0]);
3461+ seq_printf(s, "\t\tThe free page numbers of free for all=0x%03x\n", ffa_cnt);
3462+
3463+ seq_printf(s, "\tFree page head and tail(0x82068104): 0x%08x\n", pg_flow_ctrl[1]);
3464+ fpg_head = FIELD_GET(MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK, pg_flow_ctrl[1]);
3465+
3466+ fpg_tail = FIELD_GET(MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK, pg_flow_ctrl[1]);
3467+ seq_printf(s, "\t\tThe tail/head page of free page list=0x%03x/0x%03x\n", fpg_tail, fpg_head);
3468+ seq_printf(s, "\tReserved page counter of HIF0 group(0x82068110): 0x%08x\n", pg_flow_ctrl[2]);
3469+ seq_printf(s, "\tHIF0 group page status(0x82068114): 0x%08x\n", pg_flow_ctrl[3]);
3470+ min_q = FIELD_GET(MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK, pg_flow_ctrl[2]);
3471+ max_q = FIELD_GET(MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK, pg_flow_ctrl[2]);
3472+ seq_printf(s, "\t\tThe max/min quota pages of HIF0 group=0x%03x/0x%03x\n", max_q, min_q);
3473+ rsv_pg = FIELD_GET(MT_DBG_PSE_HIF0_PG_INFO_HIF0_RSV_CNT_MASK, pg_flow_ctrl[3]);;
3474+ used_pg = FIELD_GET(MT_DBG_PSE_HIF0_PG_INFO_HIF0_SRC_CNT_MASK, pg_flow_ctrl[3]);
3475+ seq_printf(s, "\t\tThe used/reserved pages of HIF0 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3476+ seq_printf(s, "\tReserved page counter of HIF1 group(0x82068118): 0x%08x\n", pg_flow_ctrl[4]);
3477+ seq_printf(s, "\tHIF1 group page status(0x8206811c): 0x%08x\n", pg_flow_ctrl[5]);
3478+ min_q = FIELD_GET(MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MIN_QUOTA_MASK, pg_flow_ctrl[4]);
3479+ max_q = FIELD_GET(MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MAX_QUOTA_MASK, pg_flow_ctrl[4]);
3480+ seq_printf(s, "\t\tThe max/min quota pages of HIF1 group=0x%03x/0x%03x\n", max_q, min_q);
3481+ rsv_pg = FIELD_GET(MT_DBG_PSE_HIF1_PG_INFO_HIF1_RSV_CNT_MASK, pg_flow_ctrl[5]);
3482+ used_pg = FIELD_GET(MT_DBG_PSE_HIF1_PG_INFO_HIF1_SRC_CNT_MASK, pg_flow_ctrl[5]);
3483+
3484+ seq_printf(s, "\t\tThe used/reserved pages of HIF1 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3485+ seq_printf(s, "\tReserved page counter of CPU group(0x82068150): 0x%08x\n", pg_flow_ctrl[6]);
3486+ seq_printf(s, "\tCPU group page status(0x82068154): 0x%08x\n", pg_flow_ctrl[7]);
3487+ min_q = FIELD_GET(MT_DBG_PSE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK, pg_flow_ctrl[6]);
3488+ max_q = FIELD_GET(MT_DBG_PSE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK, pg_flow_ctrl[6]);
3489+ seq_printf(s, "\t\tThe max/min quota pages of CPU group=0x%03x/0x%03x\n", max_q, min_q);
3490+ rsv_pg = FIELD_GET(MT_DBG_PSE_CPU_PG_INFO_CPU_RSV_CNT_MASK, pg_flow_ctrl[7]);
3491+ used_pg = FIELD_GET(MT_DBG_PSE_CPU_PG_INFO_CPU_SRC_CNT_MASK, pg_flow_ctrl[7]);
3492+ seq_printf(s, "\t\tThe used/reserved pages of CPU group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3493+ seq_printf(s, "\tReserved page counter of LMAC0 group(0x82068170): 0x%08x\n", pg_flow_ctrl[8]);
3494+ seq_printf(s, "\tLMAC0 group page status(0x82068174): 0x%08x\n", pg_flow_ctrl[9]);
3495+ min_q = FIELD_GET(MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MIN_QUOTA_MASK, pg_flow_ctrl[8]);
3496+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MAX_QUOTA_MASK, pg_flow_ctrl[8]);
3497+ seq_printf(s, "\t\tThe max/min quota pages of LMAC0 group=0x%03x/0x%03x\n", max_q, min_q);
3498+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_RSV_CNT_MASK, pg_flow_ctrl[9]);
3499+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_SRC_CNT_MASK, pg_flow_ctrl[9]);
3500+ seq_printf(s, "\t\tThe used/reserved pages of LMAC0 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3501+ seq_printf(s, "\tReserved page counter of LMAC1 group(0x82068178): 0x%08x\n", pg_flow_ctrl[10]);
3502+ seq_printf(s, "\tLMAC1 group page status(0x8206817c): 0x%08x\n", pg_flow_ctrl[11]);
3503+ min_q = FIELD_GET(MT_DBG_TOP_PG_LMAC1_GROUP_LMAC1_MIN_QUOTA_MASK, pg_flow_ctrl[10]);
3504+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC1_GROUP_LMAC1_MAX_QUOTA_MASK, pg_flow_ctrl[10]);
3505+ seq_printf(s, "\t\tThe max/min quota pages of LMAC1 group=0x%03x/0x%03x\n", max_q, min_q);
3506+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_RSV_CNT_MASK, pg_flow_ctrl[11]);
3507+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_SRC_CNT_MASK, pg_flow_ctrl[11]);
3508+ seq_printf(s, "\t\tThe used/reserved pages of LMAC1 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3509+ seq_printf(s, "\tReserved page counter of LMAC2 group(0x82068180): 0x%08x\n", pg_flow_ctrl[11]);
3510+ seq_printf(s, "\tLMAC2 group page status(0x82068184): 0x%08x\n", pg_flow_ctrl[12]);
3511+ min_q = FIELD_GET(MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MIN_QUOTA_MASK, pg_flow_ctrl[12]);
3512+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MAX_QUOTA_MASK, pg_flow_ctrl[12]);
3513+ seq_printf(s, "\t\tThe max/min quota pages of LMAC2 group=0x%03x/0x%03x\n", max_q, min_q);
3514+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_RSV_CNT_MASK, pg_flow_ctrl[13]);
3515+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_SRC_CNT_MASK, pg_flow_ctrl[13]);
3516+ seq_printf(s, "\t\tThe used/reserved pages of LMAC2 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3517+
3518+ seq_printf(s, "\tReserved page counter of LMAC3 group(0x82068188): 0x%08x\n", pg_flow_ctrl[16]);
3519+ seq_printf(s, "\tLMAC3 group page status(0x8206818c): 0x%08x\n", pg_flow_ctrl[17]);
3520+ min_q = FIELD_GET(MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK, pg_flow_ctrl[16]);
3521+ max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK, pg_flow_ctrl[16]);
3522+ seq_printf(s, "\t\tThe max/min quota pages of LMAC3 group=0x%03x/0x%03x\n", max_q, min_q);
3523+ rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_RSV_CNT_MASK, pg_flow_ctrl[17]);
3524+ used_pg = FIELD_GET(MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_SRC_CNT_MASK, pg_flow_ctrl[17]);
3525+ seq_printf(s, "\t\tThe used/reserved pages of LMAC3 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3526+
3527+ seq_printf(s, "\tReserved page counter of PLE group(0x82068160): 0x%08x\n", pg_flow_ctrl[14]);
3528+ seq_printf(s, "\tPLE group page status(0x82068164): 0x%08x\n", pg_flow_ctrl[15]);
3529+ min_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK, pg_flow_ctrl[14]);
3530+ max_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK, pg_flow_ctrl[14]);
3531+ seq_printf(s, "\t\tThe max/min quota pages of PLE group=0x%03x/0x%03x\n", max_q, min_q);
3532+ rsv_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK, pg_flow_ctrl[15]);
3533+ used_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK, pg_flow_ctrl[15]);
3534+ seq_printf(s, "\t\tThe used/reserved pages of PLE group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3535+
3536+ seq_printf(s, "\tReserved page counter of PLE1 group(0x82068168): 0x%08x\n", pg_flow_ctrl[14]);
3537+ seq_printf(s, "\tPLE1 group page status(0x8206816c): 0x%08x\n", pg_flow_ctrl[15]);
3538+ min_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK, pg_flow_ctrl[20]);
3539+ max_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK, pg_flow_ctrl[20]);
3540+ seq_printf(s, "\t\tThe max/min quota pages of PLE1 group=0x%03x/0x%03x\n", max_q, min_q);
3541+ rsv_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK, pg_flow_ctrl[21]);
3542+ used_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK, pg_flow_ctrl[21]);
3543+ seq_printf(s, "\t\tThe used/reserved pages of PLE1 group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3544+
3545+ seq_printf(s, "\tReserved page counter of MDP group(0x82068198): 0x%08x\n", pg_flow_ctrl[18]);
3546+ seq_printf(s, "\tMDP group page status(0x8206819c): 0x%08x\n", pg_flow_ctrl[19]);
3547+ min_q = FIELD_GET(MT_DBG_PSE_PG_MDP_GROUP_MDP_MIN_QUOTA_MASK, pg_flow_ctrl[18]);
3548+ max_q = FIELD_GET(MT_DBG_PSE_PG_MDP_GROUP_MDP_MAX_QUOTA_MASK, pg_flow_ctrl[18]);
3549+ seq_printf(s, "\t\tThe max/min quota pages of MDP group=0x%03x/0x%03x\n", max_q, min_q);
3550+ rsv_pg = FIELD_GET(MT_DBG_PSE_MDP_PG_INFO_MDP_RSV_CNT_MASK, pg_flow_ctrl[19]);
3551+ used_pg = FIELD_GET(MT_DBG_PSE_MDP_PG_INFO_MDP_SRC_CNT_MASK, pg_flow_ctrl[19]);
3552+ seq_printf(s, "\t\tThe used/reserved pages of MDP group=0x%03x/0x%03x\n", used_pg, rsv_pg);
3553+
3554+ /* Queue Empty Status */
3555+ seq_printf(s, "PSE Queue Empty Status:\n");
3556+ seq_printf(s, "\tQUEUE_EMPTY(0x820680b0): 0x%08x\n", pse_stat);
3557+ seq_printf(s, "\t\tCPU Q0/1/2/3 empty=%ld/%ld/%ld/%ld\n",
3558+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q0_EMPTY_MASK, pse_stat),
3559+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q1_EMPTY_MASK, pse_stat),
3560+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q2_EMPTY_MASK, pse_stat),
3561+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q3_EMPTY_MASK, pse_stat));
3562+
3563+ seq_printf(s, "\t\tHIF Q0/1/2/3/4/5 empty=%ld/%ld/%ld/%ld/%ld/%ld\n",
3564+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_0_EMPTY_MASK, pse_stat),
3565+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_1_EMPTY_MASK, pse_stat),
3566+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_2_EMPTY_MASK, pse_stat),
3567+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_3_EMPTY_MASK, pse_stat),
3568+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_4_EMPTY_MASK, pse_stat),
3569+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_5_EMPTY_MASK, pse_stat));
3570+
3571+ seq_printf(s, "\t\tLMAC TX Q empty=%ld\n",
3572+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_LMAC_TX_QUEUE_EMPTY_MASK, pse_stat));
3573+ seq_printf(s, "\t\tMDP TX Q/RX Q empty=%ld/%ld\n",
3574+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_TX_QUEUE_EMPTY_MASK, pse_stat),
3575+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_RX_QUEUE_EMPTY_MASK, pse_stat));
3576+ seq_printf(s, "\t\tSEC TX Q/RX Q empty=%ld/%ld\n",
3577+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SEC_TX_QUEUE_EMPTY_MASK, pse_stat),
3578+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SEC_RX_QUEUE_EMPTY_SHFT, pse_stat));
3579+ seq_printf(s, "\t\tSFD PARK Q empty=%ld\n",
3580+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SFD_PARK_QUEUE_EMPTY_MASK, pse_stat));
3581+ seq_printf(s, "\t\tMDP TXIOC Q/RXIOC Q empty=%ld/%ld\n",
3582+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_TXIOC_QUEUE_EMPTY_MASK, pse_stat),
3583+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_RXIOC_QUEUE_EMPTY_MASK, pse_stat));
3584+ seq_printf(s, "\t\tRLS Q empty=%ld\n",
3585+ FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_RLS_Q_EMTPY_MASK, pse_stat));
3586+ seq_printf(s, "Nonempty Q info:\n");
3587+
3588+ for (i = 0; i < 31; i++) {
3589+ if (((pse_stat & (0x1 << i)) >> i) == 0) {
3590+ u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0};
3591+
3592+ if (pse_queue_empty_info[i].QueueName != NULL) {
3593+ seq_printf(s, "\t%s: ", pse_queue_empty_info[i].QueueName);
3594+ fl_que_ctrl[0] |= MT_DBG_PSE_FL_QUE_CTRL_0_EXECUTE_MASK;
3595+ fl_que_ctrl[0] |= (pse_queue_empty_info[i].Portid << MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_PID_SHFT);
3596+ fl_que_ctrl[0] |= (pse_queue_empty_info[i].Queueid << MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_QID_SHFT);
3597+ } else
3598+ continue;
3599+
3600+ fl_que_ctrl[0] |= (0x1 << 31);
3601+
3602+ mt76_wr(dev, MT_DBG_PSE_FL_QUE_CTRL_0_ADDR, fl_que_ctrl[0]);
3603+ fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PSE_FL_QUE_CTRL_2_ADDR);
3604+ fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PSE_FL_QUE_CTRL_3_ADDR);
3605+
3606+ hfid = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_HEAD_FID_MASK, fl_que_ctrl[1]);
3607+ tfid = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_TAIL_FID_MASK, fl_que_ctrl[1]);
3608+ pktcnt = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_3_QUEUE_PKT_NUM_MASK, fl_que_ctrl[2]);
3609+ seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n",
3610+ tfid, hfid, pktcnt);
3611+ }
3612+ }
3613+
3614+ return 0;
3615+}
3616+
3617+static int mt7915_mibinfo_read_per_band(struct seq_file *s, int band_idx)
3618+{
3619+#define BSS_NUM 4
3620+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3621+ u32 mac_val0, mac_val, mac_val1, idx, band_offset = 0;
3622+ u32 msdr6, msdr7, msdr8, msdr9, msdr10, msdr16, msdr17, msdr18, msdr19, msdr20, msdr21;
3623+ u32 mbxsdr[BSS_NUM][7];
3624+ u32 mbtcr[16], mbtbcr[16], mbrcr[16], mbrbcr[16];
3625+ u32 btcr[BSS_NUM], btbcr[BSS_NUM], brcr[BSS_NUM], brbcr[BSS_NUM], btdcr[BSS_NUM], brdcr[BSS_NUM];
3626+ u32 mu_cnt[5];
3627+ u32 ampdu_cnt[3];
3628+ unsigned long per;
3629+
3630+ seq_printf(s, "Band %d MIB Status\n", band_idx);
3631+ seq_printf(s, "===============================\n");
3632+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SCR0(band_idx));
3633+ seq_printf(s, "MIB Status Control=0x%x\n", mac_val);
3634+ if (is_mt7915(&dev->mt76)) {
3635+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0PBSCR(band_idx));
3636+ seq_printf(s, "MIB Per-BSS Status Control=0x%x\n", mac_val);
3637+ }
3638+
3639+ msdr6 = mt76_rr(dev, MT_DBG_MIB_M0SDR6(band_idx));
3640+ msdr7 = mt76_rr(dev, MT_DBG_MIB_M0SDR7(band_idx));
3641+ msdr8 = mt76_rr(dev, MT_DBG_MIB_M0SDR8(band_idx));
3642+ msdr9 = mt76_rr(dev, MT_DBG_MIB_M0SDR9(band_idx));
3643+ msdr10 = mt76_rr(dev, MT_DBG_MIB_M0SDR10(band_idx));
3644+ msdr16 = mt76_rr(dev, MT_DBG_MIB_M0SDR16(band_idx));
3645+ msdr17 = mt76_rr(dev, MT_DBG_MIB_M0SDR17(band_idx));
3646+ msdr18 = mt76_rr(dev, MT_DBG_MIB_M0SDR18(band_idx));
3647+ msdr19 = mt76_rr(dev, MT_DBG_MIB_M0SDR19(band_idx));
3648+ msdr20 = mt76_rr(dev, MT_DBG_MIB_M0SDR20(band_idx));
3649+ msdr21 = mt76_rr(dev, MT_DBG_MIB_M0SDR21(band_idx));
3650+ ampdu_cnt[0] = mt76_rr(dev, MT_DBG_MIB_M0SDR12(band_idx));
3651+ ampdu_cnt[1] = mt76_rr(dev, MT_DBG_MIB_M0SDR14(band_idx));
3652+ ampdu_cnt[2] = mt76_rr(dev, MT_DBG_MIB_M0SDR15(band_idx));
3653+ ampdu_cnt[1] &= MT_DBG_MIB_M0SDR14_AMPDU_MASK;
3654+ ampdu_cnt[2] &= MT_DBG_MIB_M0SDR15_AMPDU_ACKED_MASK;
3655+
3656+ seq_printf(s, "===Phy/Timing Related Counters===\n");
3657+ seq_printf(s, "\tChannelIdleCnt=0x%x\n", msdr6 & BN0_WF_MIB_TOP_M0SDR6_CHANNEL_IDLE_COUNT_MASK);
3658+ seq_printf(s, "\tCCA_NAV_Tx_Time=0x%x\n", msdr9 & BN0_WF_MIB_TOP_M0SDR9_CCA_NAV_TX_TIME_MASK);
3659+ seq_printf(s, "\tRx_MDRDY_CNT=0x%lx\n", msdr10 & MT_DBG_MIB_M0SDR10_RX_MDRDY_COUNT_MASK);
3660+ seq_printf(s, "\tCCK_MDRDY_TIME=0x%x, OFDM_MDRDY_TIME=0x%x, OFDM_GREEN_MDRDY_TIME=0x%x\n",
3661+ msdr19 & BN0_WF_MIB_TOP_M0SDR19_CCK_MDRDY_TIME_MASK,
3662+ msdr20 & BN0_WF_MIB_TOP_M0SDR20_OFDM_LG_MIXED_VHT_MDRDY_TIME_MASK,
3663+ msdr21 & BN0_WF_MIB_TOP_M0SDR21_OFDM_GREEN_MDRDY_TIME_MASK);
3664+ seq_printf(s, "\tPrim CCA Time=0x%x\n", msdr16 & BN0_WF_MIB_TOP_M0SDR16_P_CCA_TIME_MASK);
3665+ seq_printf(s, "\tSec CCA Time=0x%x\n", msdr17 & BN0_WF_MIB_TOP_M0SDR17_S_CCA_TIME_MASK);
3666+ seq_printf(s, "\tPrim ED Time=0x%x\n", msdr18 & BN0_WF_MIB_TOP_M0SDR18_P_ED_TIME_MASK);
3667+
3668+ seq_printf(s, "===Tx Related Counters(Generic)===\n");
3669+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR0(band_idx));
3670+ dev->dbg.bcn_total_cnt[band_idx] += (mac_val & BN0_WF_MIB_TOP_M0SDR0_BEACONTXCOUNT_MASK);
3671+ seq_printf(s, "\tBeaconTxCnt=0x%x\n",dev->dbg.bcn_total_cnt[band_idx]);
3672+ dev->dbg.bcn_total_cnt[band_idx] = 0;
3673+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR0(band_idx));
3674+ seq_printf(s, "\tTx 20MHz Cnt=0x%x\n", mac_val & BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_MASK);
3675+ seq_printf(s, "\tTx 40MHz Cnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_SHFT);
3676+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR1(band_idx));
3677+ seq_printf(s, "\tTx 80MHz Cnt=0x%x\n", mac_val & BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_MASK);
3678+ seq_printf(s, "\tTx 160MHz Cnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_SHFT);
3679+ seq_printf(s, "\tAMPDU Cnt=0x%x\n", ampdu_cnt[0]);
3680+ seq_printf(s, "\tAMPDU MPDU Cnt=0x%x\n", ampdu_cnt[1]);
3681+ seq_printf(s, "\tAMPDU MPDU Ack Cnt=0x%x\n", ampdu_cnt[2]);
3682+ per = (ampdu_cnt[2] == 0 ? 0 : 1000 * (ampdu_cnt[1] - ampdu_cnt[2]) / ampdu_cnt[1]);
3683+ seq_printf(s, "\tAMPDU MPDU PER=%ld.%1ld%%\n", per / 10, per % 10);
3684+
3685+ seq_printf(s, "===MU Related Counters===\n");
3686+ mu_cnt[0] = mt76_rr(dev, MT_DBG_MIB_MUBF(band_idx));
3687+ mu_cnt[1] = mt76_rr(dev, MT_DBG_MIB_M0DR8(band_idx));
3688+ mu_cnt[2] = mt76_rr(dev, MT_DBG_MIB_M0DR9(band_idx));
3689+ mu_cnt[3] = mt76_rr(dev, MT_DBG_MIB_M0DR10(band_idx));
3690+ mu_cnt[4] = mt76_rr(dev, MT_DBG_MIB_M0DR11(band_idx));
3691+ seq_printf(s, "\tMUBF_TX_COUNT=0x%x\n", mu_cnt[0] & BN0_WF_MIB_TOP_M0SDR34_MUBF_TX_COUNT_MASK);
3692+ seq_printf(s, "\tMU_TX_MPDU_COUNT(Ok+Fail)=0x%x\n", mu_cnt[1]);
3693+ seq_printf(s, "\tMU_TX_OK_MPDU_COUNT=0x%x\n", mu_cnt[2]);
3694+ seq_printf(s, "\tMU_TO_SU_PPDU_COUNT=0x%x\n", mu_cnt[3] & BN0_WF_MIB_TOP_M0DR10_MU_FAIL_PPDU_CNT_MASK);
3695+ seq_printf(s, "\tSU_TX_OK_MPDU_COUNT=0x%x\n", mu_cnt[4]);
3696+
3697+ seq_printf(s, "===Rx Related Counters(Generic)===\n");
3698+ seq_printf(s, "\tVector Mismacth Cnt=0x%x\n", msdr7 & BN0_WF_MIB_TOP_M0SDR7_VEC_MISS_COUNT_MASK);
3699+ seq_printf(s, "\tDelimiter Fail Cnt=0x%x\n", msdr8 & BN0_WF_MIB_TOP_M0SDR8_DELIMITER_FAIL_COUNT_MASK);
3700+
3701+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR3(band_idx));
3702+ seq_printf(s, "\tRxFCSErrCnt=0x%lx\n", __DBG_FIELD_GET(DBG_MIB_RX_FCS_ERROR_COUNT, mac_val));
3703+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR4(band_idx));
3704+ seq_printf(s, "\tRxFifoFullCnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR4_RX_FIFO_FULL_COUNT_MASK));
3705+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR11(band_idx));
3706+ seq_printf(s, "\tRxLenMismatch=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR11_RX_LEN_MISMATCH_MASK));
3707+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR5(band_idx));
3708+ seq_printf(s, "\tRxMPDUCnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR5_RX_MPDU_COUNT_MASK));
3709+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR22(band_idx));
3710+ seq_printf(s, "\tRx AMPDU Cnt=0x%x\n", mac_val);
3711+ /* TODO: shiang-MT7615, is MIB_M0SDR23 used for Rx total byte count for all or just AMPDU only??? */
3712+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR23(band_idx));
3713+ seq_printf(s, "\tRx Total ByteCnt=0x%x\n", mac_val);
3714+
3715+ if (is_mt7915(&dev->mt76)) {
3716+ band_offset = WF_WTBLON_TOP_B1BTCRn_ADDR - WF_WTBLON_TOP_B0BTCRn_ADDR;//check
3717+ seq_printf(s, "===Per-BSS Related Tx/Rx Counters===\n");
3718+ seq_printf(s, "BSS Idx TxCnt/DataCnt TxByteCnt RxCnt/DataCnt RxByteCnt\n");
3719+
3720+ for (idx = 0; idx < BSS_NUM; idx++) {
3721+ btcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTCRn_ADDR + band_offset + idx * 4);
3722+ btbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTBCRn_ADDR + band_offset + idx * 4);
3723+ brcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRCRn_ADDR + band_offset + idx * 4);
3724+ brbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRBCRn_ADDR + band_offset + idx * 4);
3725+ btdcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTDCRn_ADDR + band_offset + idx * 4);
3726+ brdcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRDCRn_ADDR + band_offset + idx * 4);
3727+ }
3728+
3729+ for (idx = 0; idx < BSS_NUM; idx++) {
3730+ seq_printf(s, "%d\t 0x%x/0x%x\t 0x%x \t 0x%x/0x%x \t 0x%x\n",
3731+ idx, btcr[idx], btdcr[idx], btbcr[idx],
3732+ brcr[idx], brdcr[idx], brbcr[idx]);
3733+ }
3734+
3735+ band_offset = (BN1_WF_MIB_TOP_BASE - BN0_WF_MIB_TOP_BASE) * band_idx;
3736+ seq_printf(s, "===Per-MBSS Related MIB Counters===\n");
3737+ seq_printf(s, "BSS Idx RTSTx/RetryCnt BAMissCnt AckFailCnt FrmRetry1/2/3Cnt\n");
3738+
3739+ for (idx = 0; idx < BSS_NUM; idx++) {
3740+ mbxsdr[idx][0] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR0_ADDR + band_offset + idx * 0x10);
3741+ mbxsdr[idx][1] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR1_ADDR + band_offset + idx * 0x10);
3742+ mbxsdr[idx][2] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR2_ADDR + band_offset + idx * 0x10);
3743+ mbxsdr[idx][3] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR3_ADDR + band_offset + idx * 0x10);
3744+ }
3745+
3746+ for (idx = 0; idx < BSS_NUM; idx++) {
3747+ seq_printf(s, "%d:\t0x%08x/0x%08x 0x%08x \t 0x%08x \t 0x%08x/0x%08x/0x%08x\n",
3748+ idx, (mbxsdr[idx][0] & BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_MASK),
3749+ (mbxsdr[idx][0] & BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_SHFT,
3750+ (mbxsdr[idx][1] & BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_MASK),
3751+ (mbxsdr[idx][1] & BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_SHFT,
3752+ (mbxsdr[idx][2] & BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_MASK),
3753+ (mbxsdr[idx][2] & BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_SHFT,
3754+ (mbxsdr[idx][3] & BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_MASK));
3755+ }
3756+
3757+ band_offset = WF_WTBLON_TOP_B1BTCRn_ADDR - WF_WTBLON_TOP_B0BTCRn_ADDR;
3758+ seq_printf(s, "===Per-MBSS Related Tx/Rx Counters===\n");
3759+ seq_printf(s, "MBSSIdx TxCnt TxByteCnt RxCnt RxByteCnt\n");
3760+
3761+ for (idx = 0; idx < 16; idx++) {
3762+ mbtcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBTCRn_ADDR + band_offset + idx * 4);
3763+ mbtbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBTBCRn_ADDR + band_offset + idx * 4);
3764+ mbrcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBRCRn_ADDR + band_offset + idx * 4);
3765+ mbrbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBRBCRn_ADDR + band_offset + idx * 4);
3766+ }
3767+
3768+ for (idx = 0; idx < 16; idx++) {
3769+ seq_printf(s, "%d\t 0x%08x\t 0x%08x \t 0x%08x \t 0x%08x\n",
3770+ idx, mbtcr[idx], mbtbcr[idx], mbrcr[idx], mbrbcr[idx]);
3771+ }
3772+ return 0;
3773+ } else {
3774+ u32 btocr[BSS_NUM], mbtocr[16],mbrocr[16], brocr[BSS_NUM];
3775+ u8 bss_nums = BSS_NUM;
3776+
3777+ band_offset = (BN1_WF_MIB_TOP_BTOCR_ADDR - BN0_WF_MIB_TOP_BTOCR_ADDR) * band_idx;
3778+ seq_printf(s, "===Per-BSS Related Tx/Rx Counters===\n");
3779+ seq_printf(s, "BSS Idx TxCnt/DataCnt TxByteCnt RxCnt/DataCnt RxByteCnt\n");
3780+
3781+ for (idx = 0; idx < BSS_NUM; idx++) {
3782+ btocr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTOCR_ADDR + band_offset + (idx >> 1) * 4));
3783+ btdcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTDCR_ADDR + band_offset + (idx >> 1) * 4));
3784+ btbcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTBCR_ADDR + band_offset + (idx * 4)));
3785+ brocr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BROCR_ADDR + band_offset + (idx >> 1) * 4));
3786+ brdcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BRDCR_ADDR + band_offset + (idx >> 1) * 4));
3787+ brbcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BRBCR_ADDR + band_offset + (idx * 4)));
3788+
3789+ if ((idx % 2) == 0) {
3790+ btocr[idx] = ((btocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT);
3791+ btdcr[idx] = ((btdcr[idx] & BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_SHFT);
3792+ brocr[idx] = ((brocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT);
3793+ brdcr[idx] = ((brdcr[idx] & BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_SHFT);
3794+ } else {
3795+ btocr[idx] = ((btocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT);
3796+ btdcr[idx] = ((btdcr[idx] & BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_SHFT);
3797+ brocr[idx] = ((brocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT);
3798+ brdcr[idx] = ((brdcr[idx] & BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_SHFT);
3799+ }
3800+ }
3801+
3802+ for (idx = 0; idx < BSS_NUM; idx++) {
3803+ seq_printf(s, "%d\t 0x%x/0x%x\t 0x%x \t 0x%x/0x%x \t 0x%x\n",
3804+ idx, btocr[idx], btdcr[idx], btbcr[idx], brocr[idx], brdcr[idx], brbcr[idx]);
3805+ }
3806+
3807+ band_offset = (BN1_WF_MIB_TOP_BASE - BN0_WF_MIB_TOP_BASE) * band_idx;
3808+ seq_printf(s, "===Per-MBSS Related MIB Counters===\n");
3809+ seq_printf(s, "BSS Idx RTSTx/RetryCnt BAMissCnt AckFailCnt FrmRetry1/2/3Cnt\n");
3810+
3811+ for (idx = 0; idx < BSS_NUM; idx++) {
3812+ mbxsdr[idx][0] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR0_ADDR + band_offset + ((idx >> 1) * 4));
3813+ mbxsdr[idx][1] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR1_ADDR + band_offset + ((idx >> 1) * 4));
3814+ mbxsdr[idx][2] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR2_ADDR + band_offset + ((idx >> 1) * 4));
3815+ mbxsdr[idx][3] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR3_ADDR + band_offset + ((idx >> 1) * 4));
3816+ mbxsdr[idx][4] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR4_ADDR + band_offset + ((idx >> 1) * 4));
3817+ mbxsdr[idx][5] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR5_ADDR + band_offset + ((idx >> 1) * 4));
3818+ mbxsdr[idx][6] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR6_ADDR + band_offset + ((idx >> 1) * 4));
3819+
3820+ if ((idx % 2) == 0) {
3821+ mbxsdr[idx][0] = ((mbxsdr[idx][0] & BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_SHFT);
3822+ mbxsdr[idx][1] = ((mbxsdr[idx][1] & BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_SHFT);
3823+ mbxsdr[idx][2] = ((mbxsdr[idx][2] & BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_SHFT);
3824+ mbxsdr[idx][3] = ((mbxsdr[idx][3] & BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_SHFT);
3825+ mbxsdr[idx][4] = ((mbxsdr[idx][4] & BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_SHFT);
3826+ mbxsdr[idx][5] = ((mbxsdr[idx][5] & BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_SHFT);
3827+ mbxsdr[idx][6] = ((mbxsdr[idx][6] & BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_SHFT);
3828+ } else {
3829+ mbxsdr[idx][0] = ((mbxsdr[idx][0] & BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_SHFT);
3830+ mbxsdr[idx][1] = ((mbxsdr[idx][1] & BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_SHFT);
3831+ mbxsdr[idx][2] = ((mbxsdr[idx][2] & BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_SHFT);
3832+ mbxsdr[idx][3] = ((mbxsdr[idx][3] & BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_SHFT);
3833+ mbxsdr[idx][4] = ((mbxsdr[idx][4] & BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_SHFT);
3834+ mbxsdr[idx][5] = ((mbxsdr[idx][5] & BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_SHFT);
3835+ mbxsdr[idx][6] = ((mbxsdr[idx][6] & BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_SHFT);
3836+ }
3837+ }
3838+
3839+ for (idx = 0; idx < BSS_NUM; idx++) {
3840+ seq_printf(s, "%d:\t0x%x/0x%x 0x%x \t 0x%x \t 0x%x/0x%x/0x%x\n",
3841+ idx,
3842+ mbxsdr[idx][0], mbxsdr[idx][1], mbxsdr[idx][2], mbxsdr[idx][3],
3843+ mbxsdr[idx][4], mbxsdr[idx][5], mbxsdr[idx][6]);
3844+ }
3845+
3846+ band_offset = (BN1_WF_MIB_TOP_BTOCR_ADDR - BN0_WF_MIB_TOP_BTOCR_ADDR) * band_idx;
3847+ seq_printf(s, "===Per-MBSS Related Tx/Rx Counters===\n");
3848+ seq_printf(s, "MBSSIdx TxCnt TxByteCnt RxCnt RxByteCnt\n");
3849+
3850+ for (idx = 0; idx < 16; idx++) {
3851+ mbtocr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BTOCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + ((idx >> 1) * 4)));
3852+ mbtbcr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BTBCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + (idx * 4)));
3853+ mbrocr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BROCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + ((idx >> 1) * 4)));
3854+ mbrbcr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BRBCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + (idx * 4)));
3855+
3856+ if ((idx % 2) == 0) {
3857+ mbtocr[idx] = ((mbtocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT);
3858+ mbrocr[idx] = ((mbrocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT);
3859+ } else {
3860+ mbtocr[idx] = ((mbtocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT);
3861+ mbrocr[idx] = ((mbrocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT);
3862+ }
3863+ }
3864+
3865+ for (idx = 0; idx < 16; idx++) {
3866+ seq_printf(s, "%d\t 0x%08x\t 0x%08x \t 0x%08x \t 0x%08x\n",
3867+ idx, mbtocr[idx], mbtbcr[idx], mbrocr[idx], mbrbcr[idx]);
3868+ }
3869+ }
3870+
3871+ seq_printf(s, "===Dummy delimiter insertion result===\n");
3872+ mac_val0 = mt76_rr(dev, MT_DBG_MIB_M0DR11(band_idx));
3873+ mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR6(band_idx));
3874+ mac_val1 = mt76_rr(dev, MT_DBG_MIB_M0DR7(band_idx));
3875+ seq_printf(s, "Range0 = %d\t Range1 = %d\t Range2 = %d\t Range3 = %d\t Range4 = %d\n",
3876+ (mac_val0 & BN0_WF_MIB_TOP_M0DR12_TX_DDLMT_RNG0_CNT_MASK),
3877+ (mac_val & BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_MASK),
3878+ (mac_val & BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_SHFT,
3879+ (mac_val1 & BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_MASK),
3880+ (mac_val1 & BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_SHFT);
3881+
3882+ return 0;
3883+}
3884+
3885+static int mt7915_mibinfo_band0(struct seq_file *s, void *data)
3886+{
3887+ mt7915_mibinfo_read_per_band(s, 0);
3888+ return 0;
3889+}
3890+
3891+static int mt7915_mibinfo_band1(struct seq_file *s, void *data)
3892+{
3893+ mt7915_mibinfo_read_per_band(s, 1);
3894+ return 0;
3895+}
3896+
3897+static int mt7915_token_read(struct seq_file *s, void *data)
3898+{
3899+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
3900+ int id, count = 0;
3901+ struct mt76_txwi_cache *txwi;
3902+
3903+ seq_printf(s, "Cut through token:\n");
3904+ spin_lock_bh(&dev->mt76.token_lock);
3905+ idr_for_each_entry(&dev->mt76.token, txwi, id) {
3906+ seq_printf(s, "%4d ", id);
3907+ count++;
3908+ if (count % 8 == 0)
3909+ seq_printf(s, "\n");
3910+ }
3911+ spin_unlock_bh(&dev->mt76.token_lock);
3912+ seq_printf(s, "\n");
3913+
3914+ return 0;
3915+}
3916+
3917+struct txd_l {
3918+ u32 txd_0;
3919+ u32 txd_1;
3920+ u32 txd_2;
3921+ u32 txd_3;
3922+ u32 txd_4;
3923+ u32 txd_5;
3924+ u32 txd_6;
3925+ u32 txd_7;
3926+} __packed;
3927+
3928+char *pkt_ft_str[] = {"cut_through", "store_forward", "cmd", "PDA_FW_Download"};
3929+char *hdr_fmt_str[] = {
3930+ "Non-80211-Frame",
3931+ "Command-Frame",
3932+ "Normal-80211-Frame",
3933+ "enhanced-80211-Frame",
3934+};
3935+/* TMAC_TXD_1.hdr_format */
3936+#define TMI_HDR_FT_NON_80211 0x0
3937+#define TMI_HDR_FT_CMD 0x1
3938+#define TMI_HDR_FT_NOR_80211 0x2
3939+#define TMI_HDR_FT_ENH_80211 0x3
3940+
3941+void mt7915_dump_tmac_info(u8 *tmac_info)
3942+{
3943+ struct txd_l *txd = (struct txd_l *)tmac_info;
3944+
3945+ printk("txd raw data: size=%d\n", MT_TXD_SIZE);
3946+ print_hex_dump(KERN_ERR , "", DUMP_PREFIX_OFFSET, 16, 1, tmac_info, MT_TXD_SIZE, false);
3947+
3948+ printk("TMAC_TXD Fields:\n");
3949+ printk("\tTMAC_TXD_0:\n");
3950+
3951+ /* DW0 */
3952+ /* TX Byte Count [15:0] */
3953+ printk("\t\tTxByteCnt = %ld\n", FIELD_GET(MT_TXD0_TX_BYTES, txd->txd_0));
3954+
3955+ /* PKT_FT: Packet Format [24:23] */
3956+ printk("\t\tpkt_ft = %ld(%s)\n",
3957+ FIELD_GET(MT_TXD0_PKT_FMT, txd->txd_0),
3958+ pkt_ft_str[FIELD_GET(MT_TXD0_PKT_FMT, txd->txd_0)]);
3959+
3960+ /* Q_IDX [31:25] */
3961+ printk("\t\tQueID =0x%lx\n", FIELD_GET(MT_TXD0_Q_IDX, txd->txd_0));
3962+
3963+ printk("\tTMAC_TXD_1:\n");
3964+
3965+ /* DW1 */
3966+ /* WLAN Indec [9:0] */
3967+ printk("\t\tWlan Index = %ld\n", FIELD_GET(MT_TXD1_WLAN_IDX, txd->txd_1));
3968+
3969+ /* VTA [10] */
3970+ printk("\t\tVTA = %d\n", ((txd->txd_1 & MT_TXD1_VTA) ? 1 : 0));
3971+
3972+ /* HF: Header Format [17:16] */
3973+ printk("\t\tHdrFmt = %ld(%s)\n",
3974+ FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1),
3975+ FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1) < 4 ?
3976+ hdr_fmt_str[FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1)] : "N/A");
3977+
3978+ switch (FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1)) {
3979+ case TMI_HDR_FT_NON_80211:
3980+ /* MRD [11], EOSP [12], RMVL [13], VLAN [14], ETYPE [15] */
3981+ printk("\t\t\tMRD = %d, EOSP = %d,\
3982+ RMVL = %d, VLAN = %d, ETYP = %d\n",
3983+ (txd->txd_1 & MT_TXD1_MRD) ? 1 : 0,
3984+ (txd->txd_1 & MT_TXD1_EOSP) ? 1 : 0,
3985+ (txd->txd_1 & MT_TXD1_RMVL) ? 1 : 0,
3986+ (txd->txd_1 & MT_TXD1_VLAN) ? 1 : 0,
3987+ (txd->txd_1 & MT_TXD1_ETYP) ? 1 : 0);
3988+ break;
3989+ case TMI_HDR_FT_NOR_80211:
3990+ /* HEADER_LENGTH [15:11] */
3991+ printk("\t\t\tHeader Len = %ld(WORD)\n", FIELD_GET(MT_TXD1_HDR_INFO, txd->txd_1));
3992+ break;
3993+
3994+ case TMI_HDR_FT_ENH_80211:
3995+ /* EOSP [12], AMS [13] */
3996+ printk("\t\t\tEOSP = %d, AMS = %d\n",
3997+ (txd->txd_1 & MT_TXD1_EOSP) ? 1 : 0,
3998+ (txd->txd_1 & MT_TXD1_AMS) ? 1 : 0);
3999+ break;
4000+ }
4001+
4002+ /* Header Padding [19:18] */
4003+ printk("\t\tHdrPad = %ld\n", FIELD_GET(MT_TXD1_HDR_PAD, txd->txd_1));
4004+
4005+ /* TID [22:20] */
4006+ printk("\t\tTID = %ld\n", FIELD_GET(MT_TXD1_TID, txd->txd_1));
4007+
4008+
4009+ /* UtxB/AMSDU_C/AMSDU [23] */
4010+ printk("\t\tamsdu = %d\n", ((txd->txd_1 & MT_TXD1_AMSDU) ? 1 : 0));
4011+
4012+ /* OM [29:24] */
4013+ printk("\t\town_mac = %ld\n", FIELD_GET(MT_TXD1_OWN_MAC, txd->txd_1));
4014+
4015+
4016+ /* TGID [30] */
4017+ printk("\t\tTGID = %d\n", ((txd->txd_1 & MT_TXD1_TGID) ? 1 : 0));
4018+
4019+
4020+ /* FT [31] */
4021+ printk("\t\tTxDFormatType = %d\n", (txd->txd_1 & MT_TXD1_LONG_FORMAT) ? 1 : 0);
4022+
4023+ printk("\tTMAC_TXD_2:\n");
4024+ /* DW2 */
4025+ /* Subtype [3:0] */
4026+ printk("\t\tsub_type = %ld\n", FIELD_GET(MT_TXD2_SUB_TYPE, txd->txd_2));
4027+
4028+ /* Type[5:4] */
4029+ printk("\t\tfrm_type = %ld\n", FIELD_GET(MT_TXD2_FRAME_TYPE, txd->txd_2));
4030+
4031+ /* NDP [6] */
4032+ printk("\t\tNDP = %d\n", ((txd->txd_2 & MT_TXD2_NDP) ? 1 : 0));
4033+
4034+ /* NDPA [7] */
4035+ printk("\t\tNDPA = %d\n", ((txd->txd_2 & MT_TXD2_NDPA) ? 1 : 0));
4036+
4037+ /* SD [8] */
4038+ printk("\t\tSounding = %d\n", ((txd->txd_2 & MT_TXD2_SOUNDING) ? 1 : 0));
4039+
4040+ /* RTS [9] */
4041+ printk("\t\tRTS = %d\n", ((txd->txd_2 & MT_TXD2_RTS) ? 1 : 0));
4042+
4043+ /* BM [10] */
4044+ printk("\t\tbc_mc_pkt = %d\n", ((txd->txd_2 & MT_TXD2_MULTICAST) ? 1 : 0));
4045+
4046+ /* B [11] */
4047+ printk("\t\tBIP = %d\n", ((txd->txd_2 & MT_TXD2_BIP) ? 1 : 0));
4048+
4049+ /* DU [12] */
4050+ printk("\t\tDuration = %d\n", ((txd->txd_2 & MT_TXD2_DURATION) ? 1 : 0));
4051+
4052+ /* HE [13] */
4053+ printk("\t\tHE(HTC Exist) = %d\n", ((txd->txd_2 & MT_TXD2_HTC_VLD) ? 1 : 0));
4054+
4055+ /* FRAG [15:14] */
4056+ printk("\t\tFRAG = %ld\n", FIELD_GET(MT_TXD2_FRAG, txd->txd_2));
4057+
4058+
4059+ /* Remaining Life Time [23:16]*/
4060+ printk("\t\tReamingLife/MaxTx time = %ld (unit: 64TU)\n",
4061+ FIELD_GET(MT_TXD2_MAX_TX_TIME, txd->txd_2));
4062+
4063+ /* Power Offset [29:24] */
4064+ printk("\t\tpwr_offset = %ld\n", FIELD_GET(MT_TXD2_POWER_OFFSET, txd->txd_2));
4065+
4066+ /* FRM [30] */
4067+ printk("\t\tfix rate mode = %d\n", (txd->txd_2 & MT_TXD2_FIXED_RATE) ? 1 : 0);
4068+
4069+ /* FR[31] */
4070+ printk("\t\tfix rate = %d\n", (txd->txd_2 & MT_TXD2_FIX_RATE) ? 1 : 0);
4071+
4072+
4073+ printk("\tTMAC_TXD_3:\n");
4074+
4075+ /* DW3 */
4076+ /* NA [0] */
4077+ printk("\t\tNoAck = %d\n", (txd->txd_3 & MT_TXD3_NO_ACK) ? 1 : 0);
4078+
4079+ /* PF [1] */
4080+ printk("\t\tPF = %d\n", (txd->txd_3 & MT_TXD3_PROTECT_FRAME) ? 1 : 0);
4081+
4082+ /* EMRD [2] */
4083+ printk("\t\tEMRD = %d\n", (txd->txd_3 & MT_TXD3_EMRD) ? 1 : 0);
4084+
4085+ /* EEOSP [3] */
4086+ printk("\t\tEEOSP = %d\n", (txd->txd_3 & MT_TXD3_EEOSP) ? 1 : 0);
4087+
4088+ /* DAS [4] */
4089+ printk("\t\tda_select = %d\n", (txd->txd_3 & MT_TXD3_DAS) ? 1 : 0);
4090+
4091+ /* TM [5] */
4092+ printk("\t\ttm = %d\n", (txd->txd_3 & MT_TXD3_TIMING_MEASURE) ? 1 : 0);
4093+
4094+ /* TX Count [10:6] */
4095+ printk("\t\ttx_cnt = %ld\n", FIELD_GET(MT_TXD3_TX_COUNT, txd->txd_3));
4096+
4097+ /* Remaining TX Count [15:11] */
4098+ printk("\t\tremain_tx_cnt = %ld\n", FIELD_GET(MT_TXD3_REM_TX_COUNT, txd->txd_3));
4099+
4100+ /* SN [27:16] */
4101+ printk("\t\tsn = %ld\n", FIELD_GET(MT_TXD3_SEQ, txd->txd_3));
4102+
4103+ /* BA_DIS [28] */
4104+ printk("\t\tba dis = %d\n", (txd->txd_3 & MT_TXD3_BA_DISABLE) ? 1 : 0);
4105+
4106+ /* Power Management [29] */
4107+ printk("\t\tpwr_mgmt = 0x%x\n", (txd->txd_3 & MT_TXD3_SW_POWER_MGMT) ? 1 : 0);
4108+
4109+ /* PN_VLD [30] */
4110+ printk("\t\tpn_vld = %d\n", (txd->txd_3 & MT_TXD3_PN_VALID) ? 1 : 0);
4111+
4112+ /* SN_VLD [31] */
4113+ printk("\t\tsn_vld = %d\n", (txd->txd_3 & MT_TXD3_SN_VALID) ? 1 : 0);
4114+
4115+
4116+ /* DW4 */
4117+ printk("\tTMAC_TXD_4:\n");
4118+
4119+ /* PN_LOW [31:0] */
4120+ printk("\t\tpn_low = 0x%lx\n", FIELD_GET(MT_TXD4_PN_LOW, txd->txd_4));
4121+
4122+
4123+ /* DW5 */
4124+ printk("\tTMAC_TXD_5:\n");
4125+
4126+ /* PID [7:0] */
4127+ printk("\t\tpid = %ld\n", FIELD_GET(MT_TXD5_PID, txd->txd_5));
4128+
4129+ /* TXSFM [8] */
4130+ printk("\t\ttx_status_fmt = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_FMT) ? 1 : 0);
4131+
4132+ /* TXS2M [9] */
4133+ printk("\t\ttx_status_2_mcu = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_MCU) ? 1 : 0);
4134+
4135+ /* TXS2H [10] */
4136+ printk("\t\ttx_status_2_host = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_HOST) ? 1 : 0);
4137+
4138+ /* ADD_BA [14] */
4139+ printk("\t\tADD_BA = %d\n", (txd->txd_5 & MT_TXD5_ADD_BA) ? 1 : 0);
4140+
4141+ /* MD [15] */
4142+ printk("\t\tMD = %d\n", (txd->txd_5 & MT_TXD5_MD) ? 1 : 0);
4143+
4144+ /* PN_HIGH [31:16] */
4145+ printk("\t\tpn_high = 0x%lx\n", FIELD_GET(MT_TXD5_PN_HIGH, txd->txd_5));
4146+
4147+ /* DW6 */
4148+ printk("\tTMAC_TXD_6:\n");
4149+
4150+ if (txd->txd_2 & MT_TXD2_FIX_RATE) {
4151+ /* Fixed BandWidth mode [2:0] */
4152+ printk("\t\tbw = %ld\n", FIELD_GET(MT_TXD6_BW, txd->txd_6));
4153+
4154+ /* DYN_BW [3] */
4155+ printk("\t\tdyn_bw = %d\n", (txd->txd_6 & MT_TXD6_DYN_BW) ? 1 : 0);
4156+
4157+ /* ANT_ID [7:4] */
4158+ printk("\t\tant_id = %ld\n", FIELD_GET(MT_TXD6_ANT_ID, txd->txd_6));
4159+
4160+ /* SPE_IDX_SEL [10] */
4161+ printk("\t\tspe_idx_sel = %d\n", (txd->txd_6 & MT_TXD6_SPE_ID_IDX) ? 1 : 0);
4162+
4163+ /* LDPC [11] */
4164+ printk("\t\tldpc = %d\n", (txd->txd_6 & MT_TXD6_LDPC) ? 1 : 0);
4165+
4166+ /* HELTF Type[13:12] */
4167+ printk("\t\tHELTF Type = %ld\n", FIELD_GET(MT_TXD6_HELTF, txd->txd_6));
4168+
4169+ /* GI Type [15:14] */
4170+ printk("\t\tGI = %ld\n", FIELD_GET(MT_TXD6_SGI, txd->txd_6));
4171+
4172+ /* Rate to be Fixed [29:16] */
4173+ printk("\t\ttx_rate = 0x%lx\n", FIELD_GET(MT_TXD6_TX_RATE, txd->txd_6));
4174+ }
4175+
4176+ /* TXEBF [30] */
4177+ printk("\t\ttxebf = %d\n", (txd->txd_6 & MT_TXD6_TX_EBF) ? 1 : 0);
4178+
4179+ /* TXIBF [31] */
4180+ printk("\t\ttxibf = %d\n", (txd->txd_6 & MT_TXD6_TX_IBF) ? 1 : 0);
4181+
4182+ /* DW7 */
4183+ printk("\tTMAC_TXD_7:\n");
4184+
4185+ if ((txd->txd_1 & MT_TXD1_VTA) == 0) {
4186+ /* SW Tx Time [9:0] */
4187+ printk("\t\tsw_tx_time = %ld\n", FIELD_GET(MT_TXD7_TX_TIME, txd->txd_7));
4188+ } else {
4189+ /* TXD Arrival Time [9:0] */
4190+ printk("\t\tat = %ld\n", FIELD_GET(MT_TXD7_TAT, txd->txd_7));
4191+ }
4192+
4193+ /* HW_AMSDU_CAP [10] */
4194+ printk("\t\thw amsdu cap = %d\n",(txd->txd_7 & MT_TXD7_HW_AMSDU) ? 1 : 0);
4195+
4196+ /* SPE_IDX [15:11] */
4197+ if (txd->txd_2 & MT_TXD2_FIX_RATE) {
4198+ printk("\t\tspe_idx = 0x%lx\n", FIELD_GET(MT_TXD7_SPE_IDX, txd->txd_7));
4199+ }
4200+
4201+ /* PSE_FID [27:16] */
4202+ printk("\t\tpse_fid = 0x%lx\n", FIELD_GET(MT_TXD7_PSE_FID, txd->txd_7));
4203+
4204+ /* Subtype [19:16] */
4205+ printk("\t\tpp_sub_type=%ld\n", FIELD_GET(MT_TXD7_SUB_TYPE, txd->txd_7));
4206+
4207+ /* Type [21:20] */
4208+ printk("\t\tpp_type=%ld\n", FIELD_GET(MT_TXD7_TYPE, txd->txd_7));
4209+
4210+ /* CTXD_CNT [25:23] */
4211+ printk("\t\tctxd cnt=0x%lx\n", FIELD_GET(MT_TXD7_CTXD_CNT, txd->txd_7));
4212+
4213+ /* CTXD [26] */
4214+ printk("\t\tctxd = %d\n", (txd->txd_7 & MT_TXD7_CTXD) ? 1 : 0);
4215+
4216+ /* I [28] */
4217+ printk("\t\ti = %d\n", (txd->txd_7 & MT_TXD7_IP_SUM) ? 1 : 0);
4218+
4219+ /* UT [29] */
4220+ printk("\t\tUT = %d\n", (txd->txd_7 & MT_TXD7_UDP_TCP_SUM) ? 1 : 0);
4221+
4222+ /* TXDLEN [31:30] */
4223+ printk("\t\t txd len= %ld\n", FIELD_GET(MT_TXD7_TXD_LEN, txd->txd_7));
4224+}
4225+
4226+
4227+static int mt7915_token_txd_read(struct seq_file *s, void *data)
4228+{
4229+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4230+ struct mt76_txwi_cache *t;
4231+ u8* txwi;
4232+
4233+ seq_printf(s, "\n");
4234+ spin_lock_bh(&dev->mt76.token_lock);
4235+
4236+ t = idr_find(&dev->mt76.token, dev->dbg.token_idx);
4237+
4238+ spin_unlock_bh(&dev->mt76.token_lock);
4239+ if (t != NULL) {
4240+ struct mt76_dev *mdev = &dev->mt76;
4241+ txwi = ((u8*)(t)) - (mdev->drv->txwi_size);
4242+ mt7915_dump_tmac_info((u8*) txwi);
4243+ seq_printf(s, "\n");
4244+ printk("[SKB]\n");
4245+ print_hex_dump(KERN_ERR , "", DUMP_PREFIX_OFFSET, 16, 1, (u8 *)t->skb->data, t->skb->len, false);
4246+ seq_printf(s, "\n");
4247+ }
4248+ return 0;
4249+}
4250+
4251+static int mt7915_amsduinfo_read(struct seq_file *s, void *data)
4252+{
4253+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4254+ u32 ple_stat[8] = {0}, total_amsdu = 0;
4255+ u8 i;
4256+
4257+ for (i = 0; i < 8; i++)
4258+ ple_stat[i] = mt76_rr(dev, MT_DBG_PLE_AMSDU_PACK_MSDU_CNT(i));
4259+
4260+ seq_printf(s, "TXD counter status of MSDU:\n");
4261+
4262+ for (i = 0; i < 8; i++)
4263+ total_amsdu += ple_stat[i];
4264+
4265+ for (i = 0; i < 8; i++) {
4266+ seq_printf(s, "AMSDU pack count of %d MSDU in TXD: 0x%x ", i + 1, ple_stat[i]);
4267+ if (total_amsdu != 0)
4268+ seq_printf(s, "(%d%%)\n", ple_stat[i] * 100 / total_amsdu);
4269+ else
4270+ seq_printf(s, "\n");
4271+ }
4272+
4273+ return 0;
4274+
4275+}
4276+
4277+static int mt7915_agginfo_read_per_band(struct seq_file *s, int band_idx)
4278+{
4279+ struct mt7915_dev *dev = dev_get_drvdata(s->private);
4280+ u32 value, idx, agg_rang_sel[15], ampdu_cnt[11], total_ampdu = 0;
4281+
4282+ seq_printf(s, "Band %d AGG Status\n", band_idx);
4283+ seq_printf(s, "===============================\n");
4284+ value = mt76_rr(dev, MT_DBG_AGG_AALCR0(band_idx));
4285+ seq_printf(s, "AC00 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4286+ seq_printf(s, "AC01 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4287+ seq_printf(s, "AC02 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4288+ seq_printf(s, "AC03 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4289+
4290+ value = mt76_rr(dev, MT_DBG_AGG_AALCR1(band_idx));
4291+ seq_printf(s, "AC10 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4292+ seq_printf(s, "AC11 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4293+ seq_printf(s, "AC12 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4294+ seq_printf(s, "AC13 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4295+
4296+ value = mt76_rr(dev, MT_DBG_AGG_AALCR2(band_idx));
4297+ seq_printf(s, "AC20 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4298+ seq_printf(s, "AC21 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4299+ seq_printf(s, "AC22 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4300+ seq_printf(s, "AC23 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4301+
4302+ value = mt76_rr(dev, MT_DBG_AGG_AALCR3(band_idx));
4303+ seq_printf(s, "AC30 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value));
4304+ seq_printf(s, "AC31 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value));
4305+ seq_printf(s, "AC32 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value));
4306+ seq_printf(s, "AC33 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value));
4307+
4308+ value = mt76_rr(dev, MT_DBG_AGG_AALCR4(band_idx));
4309+ seq_printf(s, "ALTX Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR4_ALTX0_AGG_LIMIT_MASK, value));
4310+
4311+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 0));
4312+ seq_printf(s, "Winsize0 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE0_MASK, value));
4313+ seq_printf(s, "Winsize1 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE1_MASK, value));
4314+ seq_printf(s, "Winsize2 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE2_MASK, value));
4315+ seq_printf(s, "Winsize3 limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE3_MASK, value));
4316+
4317+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 1));
4318+ seq_printf(s, "Winsize4 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE4_MASK, value));
4319+ seq_printf(s, "Winsize5 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE5_MASK, value));
4320+ seq_printf(s, "Winsize6 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE6_MASK, value));
4321+ seq_printf(s, "Winsize7 limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE7_MASK, value));
4322+
4323+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 2));
4324+ seq_printf(s, "Winsize8 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZE8_MASK, value));
4325+ seq_printf(s, "Winsize9 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZE9_MASK, value));
4326+ seq_printf(s, "WinsizeA limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZEA_MASK, value));
4327+ seq_printf(s, "WinsizeB limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZEB_MASK, value));
4328+
4329+
4330+ value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 3));
4331+ seq_printf(s, "WinsizeC limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZEC_MASK, value));
4332+ seq_printf(s, "WinsizeD limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZED_MASK, value));
4333+ seq_printf(s, "WinsizeE limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZEE_MASK, value));
4334+
4335+ seq_printf(s, "===AMPDU Related Counters===\n");
4336+
4337+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 0));
4338+ agg_rang_sel[0] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL0_MASK, value);
4339+ agg_rang_sel[1] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL1_MASK, value);
4340+ agg_rang_sel[2] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL2_MASK, value);
4341+ agg_rang_sel[3] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL3_MASK, value);
4342+
4343+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 1));
4344+ agg_rang_sel[4] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL4_MASK, value);
4345+ agg_rang_sel[5] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL5_MASK, value);
4346+ agg_rang_sel[6] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL6_MASK, value);
4347+ agg_rang_sel[7] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL7_MASK, value);
4348+
4349+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 2));
4350+ agg_rang_sel[8] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL8_MASK, value);
4351+ agg_rang_sel[9] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL9_MASK, value);
4352+ agg_rang_sel[10] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL10_MASK, value);
4353+ agg_rang_sel[11] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL11_MASK, value);
4354+
4355+ value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 3));
4356+ agg_rang_sel[12] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL12_MASK, value);
4357+ agg_rang_sel[13] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL13_MASK, value);
4358+ agg_rang_sel[14] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL14_MASK, value);
4359+
4360+ /* Need to add 1 after read from AGG_RANG_SEL CR */
4361+ for (idx = 0; idx < 15; idx++)
4362+ agg_rang_sel[idx]++;
4363+
4364+ ampdu_cnt[3] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 0));
4365+ ampdu_cnt[4] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 1));
4366+ ampdu_cnt[5] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 2));
4367+ ampdu_cnt[6] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 3));
4368+ ampdu_cnt[7] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 0));
4369+ ampdu_cnt[8] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 1));
4370+ ampdu_cnt[9] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 2));
4371+ ampdu_cnt[10] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 3));
4372+
4373+ seq_printf(s, "\tTx Agg Range: \t%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d\n",
4374+ agg_rang_sel[0],
4375+ agg_rang_sel[0] + 1, agg_rang_sel[1],
4376+ agg_rang_sel[1] + 1, agg_rang_sel[2],
4377+ agg_rang_sel[2] + 1, agg_rang_sel[3],
4378+ agg_rang_sel[3] + 1, agg_rang_sel[4],
4379+ agg_rang_sel[4] + 1, agg_rang_sel[5],
4380+ agg_rang_sel[5] + 1, agg_rang_sel[6],
4381+ agg_rang_sel[6] + 1, agg_rang_sel[7]);
4382+
4383+#define BIT_0_to_15_MASK 0x0000FFFF
4384+#define BIT_15_to_31_MASK 0xFFFF0000
4385+#define SHFIT_16_BIT 16
4386+
4387+ for (idx = 3; idx < 11; idx++)
4388+ total_ampdu = total_ampdu + (ampdu_cnt[idx] & BIT_0_to_15_MASK) + ((ampdu_cnt[idx] & BIT_15_to_31_MASK) >> SHFIT_16_BIT);
4389+
4390+ seq_printf(s, "\t\t\t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx\n",
4391+ (ampdu_cnt[3]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK,
4392+ FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[3]),
4393+ (ampdu_cnt[4]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK,
4394+ FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[4]),
4395+ (ampdu_cnt[5]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK,
4396+ FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[5]),
4397+ (ampdu_cnt[6]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK,
4398+ FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[6]));
4399+
4400+ if (total_ampdu != 0) {
4401+ seq_printf(s, "\t\t\t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%)\n",
4402+ ((ampdu_cnt[3]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK) * 100 / total_ampdu,
4403+ FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[3]) * 100 / total_ampdu,
4404+ ((ampdu_cnt[4]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK) * 100 / total_ampdu,
4405+ FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[4]) * 100 / total_ampdu,
4406+ ((ampdu_cnt[5]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK) * 100 / total_ampdu,
4407+ FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[5]) * 100 / total_ampdu,
4408+ ((ampdu_cnt[6]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK) * 100 / total_ampdu,
4409+ FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[6]) * 100 / total_ampdu);
4410+ }
4411+
4412+ seq_printf(s, "\t\t\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~256\n",
4413+ agg_rang_sel[7] + 1, agg_rang_sel[8],
4414+ agg_rang_sel[8] + 1, agg_rang_sel[9],
4415+ agg_rang_sel[9] + 1, agg_rang_sel[10],
4416+ agg_rang_sel[10] + 1, agg_rang_sel[11],
4417+ agg_rang_sel[11] + 1, agg_rang_sel[12],
4418+ agg_rang_sel[12] + 1, agg_rang_sel[13],
4419+ agg_rang_sel[13] + 1, agg_rang_sel[14],
4420+ agg_rang_sel[14] + 1);
4421+
4422+ seq_printf(s, "\t\t\t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx\n",
4423+ (ampdu_cnt[7]) & MT_DBG_MIB_M0DR13_TRX_AGG_RANGE8_CNT_MASK,
4424+ FIELD_GET(MT_DBG_MIB_M0DR13_TRX_AGG_RANGE9_CNT_MASK, ampdu_cnt[7]),
4425+ (ampdu_cnt[8]) & MT_DBG_MIB_M0DR14_TRX_AGG_RANGE10_CNT_MASK,
4426+ FIELD_GET(MT_DBG_MIB_M0DR14_TRX_AGG_RANGE11_CNT_MASK, ampdu_cnt[8]),
4427+ (ampdu_cnt[9]) & MT_DBG_MIB_M0DR15_TRX_AGG_RANGE12_CNT_MASK,
4428+ FIELD_GET(MT_DBG_MIB_M0DR15_TRX_AGG_RANGE13_CNT_MASK, ampdu_cnt[9]),
4429+ (ampdu_cnt[10]) & MT_DBG_MIB_M0DR16_TRX_AGG_RANGE14_CNT_MASK,
4430+ FIELD_GET(MT_DBG_MIB_M0DR16_TRX_AGG_RANGE15_CNT_MASK, ampdu_cnt[10]));
4431+
4432+ if (total_ampdu != 0) {
4433+ seq_printf(s, "\t\t\t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%)\n",
4434+ ((ampdu_cnt[7]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK) * 100 / total_ampdu,
4435+ FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[7]) * 100 / total_ampdu,
4436+ ((ampdu_cnt[8]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK) * 100 / total_ampdu,
4437+ FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[8]) * 100 / total_ampdu,
4438+ ((ampdu_cnt[9]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK) * 100 / total_ampdu,
4439+ FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[9]) * 100 / total_ampdu,
4440+ ((ampdu_cnt[10]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK) * 100 / total_ampdu,
4441+ FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[10]) * 100 / total_ampdu);
4442+ }
4443+
4444+ return 0;
4445+}
4446+
4447+static int mt7915_agginfo_read_band0(struct seq_file *s, void *data)
4448+{
4449+ mt7915_agginfo_read_per_band(s, 0);
4450+ return 0;
4451+}
4452+
4453+static int mt7915_agginfo_read_band1(struct seq_file *s, void *data)
4454+{
4455+ mt7915_agginfo_read_per_band(s, 1);
4456+ return 0;
4457+}
4458+
4459+/*usage: <en> <num> <len>
4460+ en: BIT(16) 0: sw amsdu 1: hw amsdu
4461+ num: GENMASK(15, 8) range 1-8
4462+ len: GENMASK(7, 0) unit: 256 bytes */
4463+static int mt7915_sta_tx_amsdu_set(void *data, u64 tx_amsdu)
4464+{
4465+/* UWTBL DW 6 */
4466+#define WTBL_AMSDU_LEN_MASK GENMASK(5, 0)
4467+#define WTBL_AMSDU_NUM_MASK GENMASK(8, 6)
4468+#define WTBL_AMSDU_EN_MASK BIT(9)
4469+#define UWTBL_HW_AMSDU_DW 6
4470+
4471+ struct mt7915_dev *dev = data;
4472+ u32 len = FIELD_GET(GENMASK(7, 0), tx_amsdu);
4473+ u32 num = FIELD_GET(GENMASK(15, 8), tx_amsdu);
4474+ u32 uwtbl;
4475+
4476+ mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC,
4477+ UWTBL_HW_AMSDU_DW, 1, &uwtbl);
4478+
4479+ if (len) {
4480+ uwtbl &= ~WTBL_AMSDU_LEN_MASK;
4481+ uwtbl |= FIELD_PREP(WTBL_AMSDU_LEN_MASK, len);
4482+ }
4483+
4484+ uwtbl &= ~WTBL_AMSDU_NUM_MASK;
4485+ uwtbl |= FIELD_PREP(WTBL_AMSDU_NUM_MASK, num);
4486+
4487+ if (tx_amsdu & BIT(16))
4488+ uwtbl |= WTBL_AMSDU_EN_MASK;
4489+
4490+ mt7915_wtbl_write_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC,
4491+ UWTBL_HW_AMSDU_DW, uwtbl);
4492+
4493+ return 0;
4494+}
4495+
4496+DEFINE_DEBUGFS_ATTRIBUTE(fops_tx_amsdu, NULL,
4497+ mt7915_sta_tx_amsdu_set, "%llx\n");
4498+
4499+static int mt7915_red_enable_set(void *data, u64 en)
4500+{
4501+ struct mt7915_dev *dev = data;
4502+
4503+ return mt7915_mcu_set_red(dev, en);
4504+}
4505+DEFINE_DEBUGFS_ATTRIBUTE(fops_red_en, NULL,
4506+ mt7915_red_enable_set, "%llx\n");
4507+
4508+static int mt7915_red_show_sta_set(void *data, u64 wlan_idx)
4509+{
4510+ struct mt7915_dev *dev = data;
4511+
4512+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
4513+ MCU_WA_PARAM_RED_SHOW_STA,
4514+ wlan_idx, 0, true);
4515+
4516+ return 0;
4517+}
4518+DEFINE_DEBUGFS_ATTRIBUTE(fops_red_show_sta, NULL,
4519+ mt7915_red_show_sta_set, "%llx\n");
4520+
4521+static int mt7915_red_target_dly_set(void *data, u64 delay)
4522+{
4523+ struct mt7915_dev *dev = data;
4524+
4525+ if (delay > 0 && delay <= 32767)
4526+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET),
4527+ MCU_WA_PARAM_RED_TARGET_DELAY,
4528+ delay, 0, true);
4529+
4530+ return 0;
4531+}
4532+DEFINE_DEBUGFS_ATTRIBUTE(fops_red_target_dly, NULL,
4533+ mt7915_red_target_dly_set, "%llx\n");
4534+
4535+static int
4536+mt7915_txpower_level_set(void *data, u64 val)
4537+{
4538+ struct mt7915_dev *dev = data;
4539+ struct mt7915_phy *ext_phy = mt7915_ext_phy(dev);
4540+ mt7915_mcu_set_txpower_level(&dev->phy, val);
4541+ if (ext_phy)
4542+ mt7915_mcu_set_txpower_level(ext_phy, val);
4543+
4544+ return 0;
4545+}
4546+
4547+DEFINE_DEBUGFS_ATTRIBUTE(fops_txpower_level, NULL,
4548+ mt7915_txpower_level_set, "%lld\n");
4549+
4550+/* usage: echo 0x[arg3][arg2][arg1] > fw_wa_set */
4551+static int
4552+mt7915_wa_set(void *data, u64 val)
4553+{
4554+ struct mt7915_dev *dev = data;
4555+ u32 arg1, arg2, arg3;
4556+
4557+ arg1 = FIELD_GET(GENMASK_ULL(7, 0), val);
4558+ arg2 = FIELD_GET(GENMASK_ULL(15, 8), val);
4559+ arg3 = FIELD_GET(GENMASK_ULL(23, 16), val);
4560+
4561+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), arg1, arg2, arg3, false);
4562+
4563+ return 0;
4564+}
4565+
4566+DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_set, NULL, mt7915_wa_set,
4567+ "0x%llx\n");
4568+/* usage: echo 0x[arg3][arg2][arg1] > fw_wa_query */
4569+static int
4570+mt7915_wa_query(void *data, u64 val)
4571+{
4572+ struct mt7915_dev *dev = data;
4573+ u32 arg1, arg2, arg3;
4574+
4575+ arg1 = FIELD_GET(GENMASK_ULL(7, 0), val);
4576+ arg2 = FIELD_GET(GENMASK_ULL(15, 8), val);
4577+ arg3 = FIELD_GET(GENMASK_ULL(23, 16), val);
4578+
4579+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(QUERY), arg1, arg2, arg3, false);
4580+
4581+ return 0;
4582+}
4583+
4584+DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_query, NULL, mt7915_wa_query,
4585+ "0x%llx\n");
4586+/* set wa debug level
4587+ usage:
4588+ echo 0x[arg] > fw_wa_debug
4589+ bit0 : DEBUG_WIFI_TX
4590+ bit1 : DEBUG_CMD_EVENT
4591+ bit2 : DEBUG_RED
4592+ bit3 : DEBUG_WARN
4593+ bit4 : DEBUG_WIFI_RX
4594+ bit5 : DEBUG_TIME_STAMP
4595+ bit6 : DEBUG_TX_FREE_DONE_EVENT
4596+ bit12 : DEBUG_WIFI_TXD */
4597+static int
4598+mt7915_wa_debug(void *data, u64 val)
4599+{
4600+ struct mt7915_dev *dev = data;
4601+ u32 arg;
4602+
4603+ arg = FIELD_GET(GENMASK_ULL(15, 0), val);
4604+
4605+ mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(DEBUG), arg, 0, 0, false);
4606+
4607+ return 0;
4608+}
4609+
4610+DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_debug, NULL, mt7915_wa_debug,
4611+ "0x%llx\n");
4612+
4613+int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir)
4614+{
4615+ struct mt7915_dev *dev = phy->dev;
4616+ u32 device_id = (dev->mt76.rev) >> 16;
4617+ int i = 0;
4618+
4619+ for (i = 0; i < ARRAY_SIZE(dbg_reg_s); i++) {
4620+ if (device_id == dbg_reg_s[i].id) {
4621+ dev->dbg_reg = &dbg_reg_s[i];
4622+ break;
4623+ }
4624+ }
4625+
4626+ mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0);
4627+
4628+ debugfs_create_file("fw_debug_module", 0600, dir, dev,
4629+ &fops_fw_debug_module);
4630+ debugfs_create_file("fw_debug_level", 0600, dir, dev,
4631+ &fops_fw_debug_level);
4632+
developerf32dabf2022-06-01 10:59:24 +08004633+ debugfs_create_devm_seqfile(dev->mt76.dev, "sta_info", dir,
4634+ mt7915_sta_info);
developer3fa816c2022-04-19 10:21:20 +08004635+ debugfs_create_devm_seqfile(dev->mt76.dev, "wtbl_info", dir,
4636+ mt7915_wtbl_read);
4637+ debugfs_create_devm_seqfile(dev->mt76.dev, "uwtbl_info", dir,
4638+ mt7915_uwtbl_read);
4639+
4640+ debugfs_create_devm_seqfile(dev->mt76.dev, "tr_info", dir,
4641+ mt7915_trinfo_read);
4642+
4643+ debugfs_create_devm_seqfile(dev->mt76.dev, "drr_info", dir,
4644+ mt7915_drr_info);
4645+
4646+ debugfs_create_devm_seqfile(dev->mt76.dev, "ple_info", dir,
4647+ mt7915_pleinfo_read);
4648+
4649+ debugfs_create_devm_seqfile(dev->mt76.dev, "pse_info", dir,
4650+ mt7915_pseinfo_read);
4651+
4652+ debugfs_create_devm_seqfile(dev->mt76.dev, "mib_info0", dir,
4653+ mt7915_mibinfo_band0);
4654+ debugfs_create_devm_seqfile(dev->mt76.dev, "mib_info1", dir,
4655+ mt7915_mibinfo_band1);
4656+
4657+ debugfs_create_u32("token_idx", 0600, dir, &dev->dbg.token_idx);
4658+ debugfs_create_devm_seqfile(dev->mt76.dev, "token", dir,
4659+ mt7915_token_read);
4660+ debugfs_create_devm_seqfile(dev->mt76.dev, "token_txd", dir,
4661+ mt7915_token_txd_read);
4662+
4663+ debugfs_create_devm_seqfile(dev->mt76.dev, "amsdu_info", dir,
4664+ mt7915_amsduinfo_read);
4665+
4666+ debugfs_create_devm_seqfile(dev->mt76.dev, "agg_info0", dir,
4667+ mt7915_agginfo_read_band0);
4668+ debugfs_create_devm_seqfile(dev->mt76.dev, "agg_info1", dir,
4669+ mt7915_agginfo_read_band1);
4670+
4671+ debugfs_create_file("tx_amsdu", 0600, dir, dev, &fops_tx_amsdu);
4672+
4673+ debugfs_create_file("fw_wa_query", 0600, dir, dev, &fops_wa_query);
4674+ debugfs_create_file("fw_wa_set", 0600, dir, dev, &fops_wa_set);
4675+ debugfs_create_file("fw_wa_debug", 0600, dir, dev, &fops_wa_debug);
4676+
4677+ debugfs_create_file("red_en", 0600, dir, dev,
4678+ &fops_red_en);
4679+ debugfs_create_file("red_show_sta", 0600, dir, dev,
4680+ &fops_red_show_sta);
4681+ debugfs_create_file("red_target_dly", 0600, dir, dev,
4682+ &fops_red_target_dly);
4683+
4684+ debugfs_create_file("txpower_level", 0400, dir, dev,
4685+ &fops_txpower_level);
4686+
developeraace7f52022-06-24 13:40:42 +08004687+ debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable);
4688+
developer3fa816c2022-04-19 10:21:20 +08004689+ return 0;
4690+}
4691+#endif
4692diff --git a/mt7915/mtk_mcu.c b/mt7915/mtk_mcu.c
4693new file mode 100644
developeraace7f52022-06-24 13:40:42 +08004694index 0000000..145fe78
developer3fa816c2022-04-19 10:21:20 +08004695--- /dev/null
4696+++ b/mt7915/mtk_mcu.c
4697@@ -0,0 +1,51 @@
4698+#include <linux/firmware.h>
4699+#include <linux/fs.h>
4700+#include<linux/inet.h>
4701+#include "mt7915.h"
4702+#include "mcu.h"
4703+#include "mac.h"
4704+
4705+int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level)
4706+{
4707+ struct mt7915_dev *dev = phy->dev;
4708+ struct mt7915_sku_val {
4709+ u8 format_id;
4710+ u8 val;
4711+ u8 band;
4712+ u8 _rsv;
4713+ } __packed req = {
4714+ .format_id = 1,
4715+ .band = phy->band_idx,
4716+ .val = !!drop_level,
4717+ };
4718+ int ret;
4719+
4720+ ret = mt76_mcu_send_msg(&dev->mt76,
4721+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
4722+ sizeof(req), true);
4723+ if (ret)
4724+ return ret;
4725+
4726+ req.format_id = 2;
4727+ if ((drop_level > 90 && drop_level < 100) || !drop_level)
4728+ req.val = 0;
4729+ else if (drop_level > 60 && drop_level <= 90)
4730+ /* reduce Pwr for 1 dB. */
4731+ req.val = 2;
4732+ else if (drop_level > 30 && drop_level <= 60)
4733+ /* reduce Pwr for 3 dB. */
4734+ req.val = 6;
4735+ else if (drop_level > 15 && drop_level <= 30)
4736+ /* reduce Pwr for 6 dB. */
4737+ req.val = 12;
4738+ else if (drop_level > 9 && drop_level <= 15)
4739+ /* reduce Pwr for 9 dB. */
4740+ req.val = 18;
4741+ else if (drop_level > 0 && drop_level <= 9)
4742+ /* reduce Pwr for 12 dB. */
4743+ req.val = 24;
4744+
4745+ return mt76_mcu_send_msg(&dev->mt76,
4746+ MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req,
4747+ sizeof(req), true);
4748+}
4749diff --git a/tools/fwlog.c b/tools/fwlog.c
developeraace7f52022-06-24 13:40:42 +08004750index e5d4a10..3d51d9e 100644
developer3fa816c2022-04-19 10:21:20 +08004751--- a/tools/fwlog.c
4752+++ b/tools/fwlog.c
4753@@ -26,7 +26,7 @@ static const char *debugfs_path(const char *phyname, const char *file)
4754 return path;
4755 }
4756
4757-static int mt76_set_fwlog_en(const char *phyname, bool en)
4758+static int mt76_set_fwlog_en(const char *phyname, bool en, char *val)
4759 {
4760 FILE *f = fopen(debugfs_path(phyname, "fw_debug_bin"), "w");
4761
4762@@ -35,7 +35,13 @@ static int mt76_set_fwlog_en(const char *phyname, bool en)
4763 return 1;
4764 }
4765
4766- fprintf(f, "7");
4767+ if (en && val)
4768+ fprintf(f, "%s", val);
4769+ else if (en)
4770+ fprintf(f, "7");
4771+ else
4772+ fprintf(f, "0");
4773+
4774 fclose(f);
4775
4776 return 0;
4777@@ -76,6 +82,7 @@ static void handle_signal(int sig)
4778
4779 int mt76_fwlog(const char *phyname, int argc, char **argv)
4780 {
4781+#define BUF_SIZE 1504
4782 struct sockaddr_in local = {
4783 .sin_family = AF_INET,
4784 .sin_addr.s_addr = INADDR_ANY,
developerf32dabf2022-06-01 10:59:24 +08004785@@ -84,9 +91,10 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
developer3fa816c2022-04-19 10:21:20 +08004786 .sin_family = AF_INET,
4787 .sin_port = htons(55688),
4788 };
4789- char buf[1504];
4790+ char *buf = calloc(BUF_SIZE, sizeof(char));
developerf32dabf2022-06-01 10:59:24 +08004791+ FILE *logfile = NULL;
developer3fa816c2022-04-19 10:21:20 +08004792 int ret = 0;
4793- int yes = 1;
4794+ /* int yes = 1; */
4795 int s, fd;
4796
4797 if (argc < 1) {
developerf32dabf2022-06-01 10:59:24 +08004798@@ -99,19 +107,28 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
4799 return 1;
4800 }
4801
4802+ if (argc == 3) {
4803+ fprintf(stdout, "start logging to file %s\n", argv[2]);
4804+ logfile = fopen(argv[2], "wb");
4805+ if (!logfile) {
4806+ perror("fopen");
4807+ return 1;
4808+ }
4809+ }
4810+
4811 s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
4812 if (s < 0) {
4813 perror("socket");
developer3fa816c2022-04-19 10:21:20 +08004814 return 1;
4815 }
4816
4817- setsockopt(s, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(yes));
4818+ /* setsockopt(s, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(yes)); */
4819 if (bind(s, (struct sockaddr *)&local, sizeof(local)) < 0) {
4820 perror("bind");
4821 return 1;
4822 }
4823
4824- if (mt76_set_fwlog_en(phyname, true))
4825+ if (mt76_set_fwlog_en(phyname, true, argv[1]))
4826 return 1;
4827
4828 fd = open(debugfs_path(phyname, "fwlog_data"), O_RDONLY);
developerf32dabf2022-06-01 10:59:24 +08004829@@ -145,8 +162,8 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
developer3fa816c2022-04-19 10:21:20 +08004830 if (!r)
4831 continue;
4832
4833- if (len > sizeof(buf)) {
4834- fprintf(stderr, "Length error: %d > %d\n", len, (int)sizeof(buf));
4835+ if (len > BUF_SIZE) {
4836+ fprintf(stderr, "Length error: %d > %d\n", len, BUF_SIZE);
4837 ret = 1;
4838 break;
4839 }
developerf32dabf2022-06-01 10:59:24 +08004840@@ -164,14 +181,19 @@ int mt76_fwlog(const char *phyname, int argc, char **argv)
4841 break;
4842 }
4843
4844- /* send buf */
4845- sendto(s, buf, len, 0, (struct sockaddr *)&remote, sizeof(remote));
4846+ if (logfile)
4847+ fwrite(buf, 1, len, logfile);
4848+ else
4849+ /* send buf */
4850+ sendto(s, buf, len, 0, (struct sockaddr *)&remote, sizeof(remote));
4851 }
4852
developer3fa816c2022-04-19 10:21:20 +08004853 close(fd);
4854
4855 out:
4856- mt76_set_fwlog_en(phyname, false);
4857+ mt76_set_fwlog_en(phyname, false, NULL);
4858+ free(buf);
developerf32dabf2022-06-01 10:59:24 +08004859+ fclose(logfile);
developer3fa816c2022-04-19 10:21:20 +08004860
4861 return ret;
4862 }
4863--
developer42b63282022-06-16 13:33:13 +080048642.18.0
developer3fa816c2022-04-19 10:21:20 +08004865