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