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